1Gtk2::ComboBox(3)     User Contributed Perl Documentation    Gtk2::ComboBox(3)
2
3
4

NAME

6       Gtk2::ComboBox - A widget used to choose from a list of items
7

SYNOPSIS

9         # the easy way:
10         $combobox = Gtk2::ComboBox->new_text;
11         foreach (@strings) {
12             $combobox->append_text ($_);
13         }
14         $combobox->prepend_text ($another_string);
15         $combobox->insert_text ($index, $yet_another_string);
16         $combobox->remove_text ($index);
17         $text = $combobox->get_active_text;
18
19
20         # the full-featured way.
21         # a combo box that shows stock ids and their images:
22         use constant ID_COLUMN => 0;
23         $model = Gtk2::ListStore->new ('Glib::String');
24         foreach (qw(gtk-ok gtk-cancel gtk-yes gtk-no gtk-save gtk-open)) {
25             $model->set ($model->append, ID_COLUMN, $_);
26         }
27         $combo_box = Gtk2::ComboBox->new ($model);
28         # to display anything, you must pack cell renderers into
29         # the combobox, which implements the Gtk2::CellLayout interface.
30         $renderer = Gtk2::CellRendererPixbuf->new;
31         $combo_box->pack_start ($renderer, FALSE);
32         $combo_box->add_attribute ($renderer, stock_id => ID_COLUMN);
33         $renderer = Gtk2::CellRendererText->new;
34         $combo_box->pack_start ($renderer, TRUE);
35         $combo_box->add_attribute ($renderer, text => ID_COLUMN);
36
37         # select by index
38         $combo_box->set_active ($index);
39         $active_index = $combo_box->get_active;
40
41         # or by iter
42         $combo_box->set_active_iter ($iter);
43         $active_iter = $combo_box->get_active_iter;
44

DESCRIPTION

46       Gtk2::ComboBox is a widget that allows the user to choose from a list
47       of valid choices.  The ComboBox displays the selected choice.  When
48       activated, the ComboBox displays a popup which allows the user to make
49       a new choice.
50
51       Unlike its predecessors Gtk2::Combo and Gtk2::OptionMenu, the
52       Gtk2::ComboBox uses the model-view pattern; the list of valid choices
53       is specified in the form of a tree model, and the display of the
54       choices can be adapted to the data in the model by using cell
55       renderers, as you would in a tree view.  This is possible since
56       ComboBox implements the Gtk2::CellLayout interface.  The tree model
57       holding the valid choices is not restricted to a flat list; it can be a
58       real tree, and the popup will reflect the tree structure.
59
60       In addition to the model-view API, ComboBox offers a simple API which
61       is suitable for text-only combo boxes, and hides the complexity of
62       managing the data in a model.  It consists of the methods "new_text",
63       "append_text", "insert_text", "prepend_text", "remove_text" and
64       "get_active_text".
65

HIERARCHY

67         Glib::Object
68         +----Glib::InitiallyUnowned
69              +----Gtk2::Object
70                   +----Gtk2::Widget
71                        +----Gtk2::Container
72                             +----Gtk2::Bin
73                                  +----Gtk2::ComboBox
74

INTERFACES

76         Glib::Object::_Unregistered::AtkImplementorIface
77         Gtk2::Buildable
78         Gtk2::CellLayout
79         Gtk2::CellEditable
80

METHODS

82   widget = Gtk2::ComboBox->new ($model=undef)
83           ·   $model (Gtk2::TreeModel)
84
85   widget = Gtk2::ComboBox->new_text
86   widget = Gtk2::ComboBox->new_with_model ($model=undef)
87           ·   $model (Gtk2::TreeModel)
88
89   integer = $combo_box->get_active
90   treeiter = $combo_box->get_active_iter
91   $combo_box->set_active_iter ($iter)
92           ·   $iter (Gtk2::TreeIter)
93
94   $combo_box->set_active ($index)
95           ·   $index (integer)
96
97   string = $combo_box->get_active_text
98           Since: gtk+ 2.6
99
100   boolean = $combo_box->get_add_tearoffs
101           Since: gtk+ 2.6
102
103   $combo_box->set_add_tearoffs ($add_tearoffs)
104           ·   $add_tearoffs (boolean)
105
106           Since: gtk+ 2.6
107
108   $combo_box->append_text ($text)
109           ·   $text (string)
110
111   integer = $combo_box->get_column_span_column
112           Since: gtk+ 2.6
113
114   $combo_box->set_column_span_column ($column_span)
115           ·   $column_span (integer)
116
117   boolean = $combo_box->get_focus_on_click
118           Since: gtk+ 2.6
119
120   $combo_box->set_focus_on_click ($focus_on_click)
121           ·   $focus_on_click (boolean)
122
123           Since: gtk+ 2.6
124
125   $combo_box->insert_text ($position, $text)
126           ·   $position (integer)
127
128           ·   $text (string)
129
130   treemodel = $combo_box->get_model
131   $combo_box->set_model ($model)
132           ·   $model (Gtk2::TreeModel)
133
134   $combo_box->popdown
135   $combo_box->popup
136   $combo_box->prepend_text ($text)
137           ·   $text (string)
138
139   $combo_box->remove_text ($position)
140           ·   $position (integer)
141
142   $combo_box->set_row_separator_func ($func, $data=undef)
143           ·   $func (scalar)
144
145           ·   $data (scalar)
146
147           Since: gtk+ 2.6
148
149   integer = $combo_box->get_row_span_column
150           Since: gtk+ 2.6
151
152   $combo_box->set_row_span_column ($row_span)
153           ·   $row_span (integer)
154
155   string = $combo_box->get_title
156           Since: gtk+ 2.10
157
158   $combo_box->set_title ($title)
159           ·   $title (string)
160
161           Since: gtk+ 2.10
162
163   integer = $combo_box->get_wrap_width
164           Since: gtk+ 2.6
165
166   $combo_box->set_wrap_width ($width)
167           ·   $width (integer)
168

PROPERTIES

170       'active' (integer : readable / writable / private)
171           The item which is currently active
172
173       'add-tearoffs' (boolean : readable / writable / private)
174           Whether dropdowns should have a tearoff menu item
175
176       'button-sensitivity' (Gtk2::SensitivityType : readable / writable /
177       private)
178           Whether the dropdown button is sensitive when the model is empty
179
180       'column-span-column' (integer : readable / writable / private)
181           TreeModel column containing the column span values
182
183       'focus-on-click' (boolean : readable / writable / private)
184           Whether the combo box grabs focus when it is clicked with the mouse
185
186       'has-frame' (boolean : readable / writable / private)
187           Whether the combo box draws a frame around the child
188
189       'model' (Gtk2::TreeModel : readable / writable / private)
190           The model for the combo box
191
192       'popup-shown' (boolean : readable / private)
193           Whether the combo's dropdown is shown
194
195       'row-span-column' (integer : readable / writable / private)
196           TreeModel column containing the row span values
197
198       'tearoff-title' (string : readable / writable / private)
199           A title that may be displayed by the window manager when the popup
200           is torn-off
201
202       'wrap-width' (integer : readable / writable / private)
203           Wrap width for laying out the items in a grid
204

SIGNALS

206       popup (Gtk2::ComboBox)
207       boolean = popdown (Gtk2::ComboBox)
208       changed (Gtk2::ComboBox)
209       move-active (Gtk2::ComboBox, Gtk2::ScrollType)
210

ENUMS AND FLAGS

212   enum Gtk2::ScrollType
213       ·   'none' / 'GTK_SCROLL_NONE'
214
215       ·   'jump' / 'GTK_SCROLL_JUMP'
216
217       ·   'step-backward' / 'GTK_SCROLL_STEP_BACKWARD'
218
219       ·   'step-forward' / 'GTK_SCROLL_STEP_FORWARD'
220
221       ·   'page-backward' / 'GTK_SCROLL_PAGE_BACKWARD'
222
223       ·   'page-forward' / 'GTK_SCROLL_PAGE_FORWARD'
224
225       ·   'step-up' / 'GTK_SCROLL_STEP_UP'
226
227       ·   'step-down' / 'GTK_SCROLL_STEP_DOWN'
228
229       ·   'page-up' / 'GTK_SCROLL_PAGE_UP'
230
231       ·   'page-down' / 'GTK_SCROLL_PAGE_DOWN'
232
233       ·   'step-left' / 'GTK_SCROLL_STEP_LEFT'
234
235       ·   'step-right' / 'GTK_SCROLL_STEP_RIGHT'
236
237       ·   'page-left' / 'GTK_SCROLL_PAGE_LEFT'
238
239       ·   'page-right' / 'GTK_SCROLL_PAGE_RIGHT'
240
241       ·   'start' / 'GTK_SCROLL_START'
242
243       ·   'end' / 'GTK_SCROLL_END'
244
245   enum Gtk2::SensitivityType
246       ·   'auto' / 'GTK_SENSITIVITY_AUTO'
247
248       ·   'on' / 'GTK_SENSITIVITY_ON'
249
250       ·   'off' / 'GTK_SENSITIVITY_OFF'
251

SEE ALSO

253       Gtk2, Glib::Object, Glib::InitiallyUnowned, Gtk2::Object, Gtk2::Widget,
254       Gtk2::Container, Gtk2::Bin
255
257       Copyright (C) 2003-2008 by the gtk2-perl team.
258
259       This software is licensed under the LGPL.  See Gtk2 for a full notice.
260
261
262
263perl v5.12.0                      2010-05-02                 Gtk2::ComboBox(3)
Impressum