GtkComboBox

GtkComboBox — A widget used to choose from a list of items

Synopsis


#include <gtk/gtk.h>


            GtkComboBox;
GtkWidget*  gtk_combo_box_new               (void);
GtkWidget*  gtk_combo_box_new_with_model    (GtkTreeModel *model);
gint        gtk_combo_box_get_wrap_width    (GtkComboBox *combo_box);
void        gtk_combo_box_set_wrap_width    (GtkComboBox *combo_box,
                                             gint width);
gint        gtk_combo_box_get_row_span_column
                                            (GtkComboBox *combo_box);
void        gtk_combo_box_set_row_span_column
                                            (GtkComboBox *combo_box,
                                             gint row_span);
gint        gtk_combo_box_get_column_span_column
                                            (GtkComboBox *combo_box);
void        gtk_combo_box_set_column_span_column
                                            (GtkComboBox *combo_box,
                                             gint column_span);
gint        gtk_combo_box_get_active        (GtkComboBox *combo_box);
void        gtk_combo_box_set_active        (GtkComboBox *combo_box,
                                             gint index_);
gboolean    gtk_combo_box_get_active_iter   (GtkComboBox *combo_box,
                                             GtkTreeIter *iter);
void        gtk_combo_box_set_active_iter   (GtkComboBox *combo_box,
                                             GtkTreeIter *iter);
GtkTreeModel* gtk_combo_box_get_model       (GtkComboBox *combo_box);
void        gtk_combo_box_set_model         (GtkComboBox *combo_box,
                                             GtkTreeModel *model);
GtkWidget*  gtk_combo_box_new_text          (void);
void        gtk_combo_box_append_text       (GtkComboBox *combo_box,
                                             const gchar *text);
void        gtk_combo_box_insert_text       (GtkComboBox *combo_box,
                                             gint position,
                                             const gchar *text);
void        gtk_combo_box_prepend_text      (GtkComboBox *combo_box,
                                             const gchar *text);
void        gtk_combo_box_remove_text       (GtkComboBox *combo_box,
                                             gint position);
gchar*      gtk_combo_box_get_active_text   (GtkComboBox *combo_box);
void        gtk_combo_box_popup             (GtkComboBox *combo_box);
void        gtk_combo_box_popdown           (GtkComboBox *combo_box);
AtkObject*  gtk_combo_box_get_popup_accessible
                                            (GtkComboBox *combo_box);
GtkTreeViewRowSeparatorFunc gtk_combo_box_get_row_separator_func
                                            (GtkComboBox *combo_box);
void        gtk_combo_box_set_row_separator_func
                                            (GtkComboBox *combo_box,
                                             GtkTreeViewRowSeparatorFunc func,
                                             gpointer data,
                                             GtkDestroyNotify destroy);
void        gtk_combo_box_set_add_tearoffs  (GtkComboBox *combo_box,
                                             gboolean add_tearoffs);
gboolean    gtk_combo_box_get_add_tearoffs  (GtkComboBox *combo_box);
void        gtk_combo_box_set_focus_on_click
                                            (GtkComboBox *combo,
                                             gboolean focus_on_click);
gboolean    gtk_combo_box_get_focus_on_click
                                            (GtkComboBox *combo);


Object Hierarchy


  GObject
   +----GtkObject
         +----GtkWidget
               +----GtkContainer
                     +----GtkBin
                           +----GtkComboBox
                                 +----GtkComboBoxEntry

Implemented Interfaces

GtkComboBox implements AtkImplementorIface, GtkCellLayout and GtkCellEditable.

Properties


  "active"               gint                  : Read / Write
  "add-tearoffs"         gboolean              : Read / Write
  "column-span-column"   gint                  : Read / Write
  "focus-on-click"       gboolean              : Read / Write
  "has-frame"            gboolean              : Read / Write
  "model"                GtkTreeModel          : Read / Write
  "row-span-column"      gint                  : Read / Write
  "wrap-width"           gint                  : Read / Write

Style Properties


  "appears-as-list"      gboolean              : Read

Signal Prototypes


"changed"   void        user_function      (GtkComboBox *combobox,
                                            gpointer user_data);

Description

Details

GtkComboBox

typedef struct _GtkComboBox GtkComboBox;


gtk_combo_box_new ()

GtkWidget*  gtk_combo_box_new               (void);

Creates a new empty GtkComboBox.

Returns : A new GtkComboBox.

Since 2.4


gtk_combo_box_new_with_model ()

GtkWidget*  gtk_combo_box_new_with_model    (GtkTreeModel *model);

Creates a new GtkComboBox with the model initialized to model.

model : A GtkTreeModel.
Returns : A new GtkComboBox.

Since 2.4


gtk_combo_box_get_wrap_width ()

gint        gtk_combo_box_get_wrap_width    (GtkComboBox *combo_box);

Returns the wrap width which is used to determine the number of columns for the popup menu. If the wrap width is larger than 1, the combo box is in table mode.

combo_box : A GtkComboBox.
Returns : the wrap width.

Since 2.6


gtk_combo_box_set_wrap_width ()

void        gtk_combo_box_set_wrap_width    (GtkComboBox *combo_box,
                                             gint width);

Sets the wrap width of combo_box to be width. The wrap width is basically the preferred number of columns when you want to the popup to be layed out in a table.

combo_box : A GtkComboBox.
width : Preferred number of columns.

Since 2.4


gtk_combo_box_get_row_span_column ()

gint        gtk_combo_box_get_row_span_column
                                            (GtkComboBox *combo_box);

Returns the column with row span information for combo_box.

combo_box : A GtkComboBox.
Returns : the row span column.

Since 2.6


gtk_combo_box_set_row_span_column ()

void        gtk_combo_box_set_row_span_column
                                            (GtkComboBox *combo_box,
                                             gint row_span);

Sets the column with row span information for combo_box to be row_span. The row span column contains integers which indicate how many rows an item should span.

combo_box : A GtkComboBox.
row_span : A column in the model passed during construction.

Since 2.4


gtk_combo_box_get_column_span_column ()

gint        gtk_combo_box_get_column_span_column
                                            (GtkComboBox *combo_box);

Returns the column with column span information for combo_box.

combo_box : A GtkComboBox.
Returns : the column span column.

Since 2.6


gtk_combo_box_set_column_span_column ()

void        gtk_combo_box_set_column_span_column
                                            (GtkComboBox *combo_box,
                                             gint column_span);

Sets the column with column span information for combo_box to be column_span. The column span column contains integers which indicate how many columns an item should span.

combo_box : A GtkComboBox.
column_span : A column in the model passed during construction.

Since 2.4


gtk_combo_box_get_active ()

gint        gtk_combo_box_get_active        (GtkComboBox *combo_box);

Returns the index of the currently active item, or -1 if there's no active item.

combo_box : A GtkComboBox.
Returns : An integer which is the index of the currently active item, or -1 if there's no active item.

Since 2.4


gtk_combo_box_set_active ()

void        gtk_combo_box_set_active        (GtkComboBox *combo_box,
                                             gint index_);

Sets the active item of combo_box to be the item at index.

combo_box : A GtkComboBox.
index_ : An index in the model passed during construction, or -1 to have no active item.

Since 2.4


gtk_combo_box_get_active_iter ()

gboolean    gtk_combo_box_get_active_iter   (GtkComboBox *combo_box,
                                             GtkTreeIter *iter);

Sets iter to point to the current active item, if it exists.

combo_box : A GtkComboBox
iter : The uninitialized GtkTreeIter.
Returns : TRUE, if iter was set

Since 2.4


gtk_combo_box_set_active_iter ()

void        gtk_combo_box_set_active_iter   (GtkComboBox *combo_box,
                                             GtkTreeIter *iter);

Sets the current active item to be the one referenced by iter. iter must correspond to a path of depth one.

combo_box : A GtkComboBox
iter : The GtkTreeIter.

Since 2.4


gtk_combo_box_get_model ()

GtkTreeModel* gtk_combo_box_get_model       (GtkComboBox *combo_box);

Returns the GtkTreeModel which is acting as data source for combo_box.

combo_box : A GtkComboBox.
Returns : A GtkTreeModel which was passed during construction.

Since 2.4


gtk_combo_box_set_model ()

void        gtk_combo_box_set_model         (GtkComboBox *combo_box,
                                             GtkTreeModel *model);

Sets the model used by combo_box to be model. Will unset a previously set model (if applicable). If model is NULL, then it will unset the model.

Note that this function does not clear the cell renderers, you have to call gtk_combo_box_cell_layout_clear() yourself if you need to set up different cell renderers for the new model.

combo_box : A GtkComboBox.
model : A GtkTreeModel.

Since 2.4


gtk_combo_box_new_text ()

GtkWidget*  gtk_combo_box_new_text          (void);

Convenience function which constructs a new text combo box, which is a GtkComboBox just displaying strings. If you use this function to create a text combo box, you should only manipulate its data source with the following convenience functions: gtk_combo_box_append_text(), gtk_combo_box_insert_text(), gtk_combo_box_prepend_text() and gtk_combo_box_remove_text().

Returns : A new text combo box.

Since 2.4


gtk_combo_box_append_text ()

void        gtk_combo_box_append_text       (GtkComboBox *combo_box,
                                             const gchar *text);

Appends string to the list of strings stored in combo_box. Note that you can only use this function with combo boxes constructed with gtk_combo_box_new_text().

combo_box : A GtkComboBox constructed using gtk_combo_box_new_text().
text : A string.

Since 2.4


gtk_combo_box_insert_text ()

void        gtk_combo_box_insert_text       (GtkComboBox *combo_box,
                                             gint position,
                                             const gchar *text);

Inserts string at position in the list of strings stored in combo_box. Note that you can only use this function with combo boxes constructed with gtk_combo_box_new_text().

combo_box : A GtkComboBox constructed using gtk_combo_box_new_text().
position : An index to insert text.
text : A string.

Since 2.4


gtk_combo_box_prepend_text ()

void        gtk_combo_box_prepend_text      (GtkComboBox *combo_box,
                                             const gchar *text);

Prepends string to the list of strings stored in combo_box. Note that you can only use this function with combo boxes constructed with gtk_combo_box_new_text().

combo_box : A GtkComboBox constructed with gtk_combo_box_new_text().
text : A string.

Since 2.4


gtk_combo_box_remove_text ()

void        gtk_combo_box_remove_text       (GtkComboBox *combo_box,
                                             gint position);

Removes the string at position from combo_box. Note that you can only use this function with combo boxes constructed with gtk_combo_box_new_text().

combo_box : A GtkComboBox constructed with gtk_combo_box_new_text().
position : Index of the item to remove.

Since 2.4


gtk_combo_box_get_active_text ()

gchar*      gtk_combo_box_get_active_text   (GtkComboBox *combo_box);

Returns the currently active string in combo_box or NULL if none is selected. Note that you can only use this function with combo boxes constructed with gtk_combo_box_new_text().

combo_box : A GtkComboBox constructed with gtk_combo_box_new_text().
Returns : a newly allocated string containing the currently active text.

Since 2.6


gtk_combo_box_popup ()

void        gtk_combo_box_popup             (GtkComboBox *combo_box);

Pops up the menu or dropdown list of combo_box.

This function is mostly intended for use by accessibility technologies; applications should have little use for it.

combo_box : a GtkComboBox

Since 2.4


gtk_combo_box_popdown ()

void        gtk_combo_box_popdown           (GtkComboBox *combo_box);

Hides the menu or dropdown list of combo_box.

This function is mostly intended for use by accessibility technologies; applications should have little use for it.

combo_box : a GtkComboBox

Since 2.4


gtk_combo_box_get_popup_accessible ()

AtkObject*  gtk_combo_box_get_popup_accessible
                                            (GtkComboBox *combo_box);

Gets the accessible object corresponding to the combo box's popup.

This function is mostly intended for use by accessibility technologies; applications should have little use for it.

combo_box : a GtkComboBox
Returns : the accessible object corresponding to the combo box's popup.

Since 2.6


gtk_combo_box_get_row_separator_func ()

GtkTreeViewRowSeparatorFunc gtk_combo_box_get_row_separator_func
                                            (GtkComboBox *combo_box);

Returns the current row separator function.

combo_box : a GtkComboBox
Returns : the current row separator function.

Since 2.6


gtk_combo_box_set_row_separator_func ()

void        gtk_combo_box_set_row_separator_func
                                            (GtkComboBox *combo_box,
                                             GtkTreeViewRowSeparatorFunc func,
                                             gpointer data,
                                             GtkDestroyNotify destroy);

Sets the row separator function, which is used to determine whether a row should be drawn as a separator. If the row separator function is NULL, no separators are drawn. This is the default value.

combo_box : a GtkComboBox
func : a GtkTreeViewRowSeparatorFunc
data : user data to pass to func, or NULL
destroy : destroy notifier for data, or NULL

Since 2.6


gtk_combo_box_set_add_tearoffs ()

void        gtk_combo_box_set_add_tearoffs  (GtkComboBox *combo_box,
                                             gboolean add_tearoffs);

Sets whether the popup menu should have a tearoff menu item.

combo_box : a GtkComboBox
add_tearoffs : TRUE to add tearoff menu items

Since 2.6


gtk_combo_box_get_add_tearoffs ()

gboolean    gtk_combo_box_get_add_tearoffs  (GtkComboBox *combo_box);

Gets the current value of the :add-tearoffs property.

combo_box : a GtkComboBox
Returns : the current value of the :add-tearoffs property.

gtk_combo_box_set_focus_on_click ()

void        gtk_combo_box_set_focus_on_click
                                            (GtkComboBox *combo,
                                             gboolean focus_on_click);

Sets whether the combo box will grab focus when it is clicked with the mouse. Making mouse clicks not grab focus is useful in places like toolbars where you don't want the keyboard focus removed from the main area of the application.

combo : a GtkComboBox
focus_on_click : whether the combo box grabs focus when clicked with the mouse

Since 2.6


gtk_combo_box_get_focus_on_click ()

gboolean    gtk_combo_box_get_focus_on_click
                                            (GtkComboBox *combo);

Returns whether the combo box grabs focus when it is clicked with the mouse. See gtk_combo_box_set_focus_on_click().

combo : a GtkComboBox
Returns : TRUE if the combo box grabs focus when it is clicked with the mouse.

Since 2.6

Properties

The "active" property

  "active"               gint                  : Read / Write

The item which is currently active.

Allowed values: >= -1

Default value: -1


The "add-tearoffs" property

  "add-tearoffs"         gboolean              : Read / Write

The "add-tearoffs" property controls whether generated menus have tearoff menu items.

Note that this only affects menu style combo boxes.

Default value: FALSE

Since 2.6


The "column-span-column" property

  "column-span-column"   gint                  : Read / Write

TreeModel column containing the column span values.

Allowed values: >= -1

Default value: -1


The "focus-on-click" property

  "focus-on-click"       gboolean              : Read / Write

Whether the combo box grabs focus when it is clicked with the mouse.

Default value: TRUE


The "has-frame" property

  "has-frame"            gboolean              : Read / Write

The :has-frame property controls whether a frame is drawn around the entry.

Default value: TRUE

Since 2.6


The "model" property

  "model"                GtkTreeModel          : Read / Write

The model for the combo box.


The "row-span-column" property

  "row-span-column"      gint                  : Read / Write

TreeModel column containing the row span values.

Allowed values: >= -1

Default value: -1


The "wrap-width" property

  "wrap-width"           gint                  : Read / Write

Wrap width for layouting the items in a grid.

Allowed values: >= 0

Default value: 0

Style Properties

The "appears-as-list" style property

  "appears-as-list"      gboolean              : Read

Whether dropdowns should look like lists rather than menus.

Default value: FALSE

Signals

The "changed" signal

void        user_function                  (GtkComboBox *combobox,
                                            gpointer user_data);

combobox :the object which received the signal.
user_data :user data set when the signal handler was connected.