[gtk+/gtk-2-24] Fix some issues with GtkComboBoxText
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/gtk-2-24] Fix some issues with GtkComboBoxText
- Date: Sat, 16 Oct 2010 12:04:54 +0000 (UTC)
commit d929bffd25768ef988d14a363e0a315c8caa7919
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Oct 16 08:03:58 2010 -0400
Fix some issues with GtkComboBoxText
gtk/gtkcombobox.c | 24 ++++++++++++++----------
gtk/gtkcomboboxtext.c | 8 ++++----
tests/testtreeview.c | 9 ++++-----
3 files changed, 22 insertions(+), 19 deletions(-)
---
diff --git a/gtk/gtkcombobox.c b/gtk/gtkcombobox.c
index 2e2ca7a..a0cc432 100644
--- a/gtk/gtkcombobox.c
+++ b/gtk/gtkcombobox.c
@@ -6190,13 +6190,16 @@ gtk_combo_box_get_has_entry (GtkComboBox *combo_box)
/**
* gtk_combo_box_set_entry_text_column:
- * @combo_box: A #GtkComboBox.
- * @text_column: A column in @model to get the strings from for the internal entry.
+ * @combo_box: A #GtkComboBox
+ * @text_column: A column in @model to get the strings from for
+ * the internal entry
*
* Sets the model column which @combo_box should use to get strings from
- * to be @text_column.
+ * to be @text_column. The column @text_column in the model of @combo_box
+ * must be of type %G_TYPE_STRING.
*
- * @combo_box must be created with GtkComboBox:has-entry as %TRUE.
+ * This is only relevant if @combo_box has been created with
+ * #GtkComboBox:has-entry as %TRUE.
*
* Since: 2.24
*/
@@ -6204,22 +6207,23 @@ void
gtk_combo_box_set_entry_text_column (GtkComboBox *combo_box,
gint text_column)
{
+ GtkComboBoxPrivate *priv = combo_box->priv;
GtkTreeModel *model;
g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
- g_return_if_fail (combo_box->priv->has_entry != FALSE);
model = gtk_combo_box_get_model (combo_box);
g_return_if_fail (text_column >= 0);
g_return_if_fail (model == NULL || text_column < gtk_tree_model_get_n_columns (model));
- combo_box->priv->text_column = text_column;
+ priv->text_column = text_column;
- gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo_box),
- combo_box->priv->text_renderer,
- "text", text_column,
- NULL);
+ if (priv->text_renderer)
+ gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo_box),
+ priv->text_renderer,
+ "text", text_column,
+ NULL);
}
/**
diff --git a/gtk/gtkcomboboxtext.c b/gtk/gtkcomboboxtext.c
index 914e6d3..e19da43 100644
--- a/gtk/gtkcomboboxtext.c
+++ b/gtk/gtkcomboboxtext.c
@@ -60,6 +60,8 @@ gtk_combo_box_text_init (GtkComboBoxText *combo_box)
gtk_combo_box_set_model (GTK_COMBO_BOX (combo_box), GTK_TREE_MODEL (store));
g_object_unref (store);
+ gtk_combo_box_set_entry_text_column (GTK_COMBO_BOX (combo_box), 0);
+
cell = gtk_cell_renderer_text_new ();
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo_box), cell, TRUE);
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo_box), cell,
@@ -97,10 +99,7 @@ gtk_combo_box_text_new (void)
GtkWidget *
gtk_combo_box_text_new_with_entry (void)
{
- return g_object_new (GTK_TYPE_COMBO_BOX_TEXT,
- "has-entry", TRUE,
- "entry-text-column", 0,
- NULL);
+ return g_object_new (GTK_TYPE_COMBO_BOX_TEXT, "has-entry", TRUE, NULL);
}
/**
@@ -127,6 +126,7 @@ gtk_combo_box_text_append_text (GtkComboBoxText *combo_box,
store = GTK_LIST_STORE (gtk_combo_box_get_model (GTK_COMBO_BOX (combo_box)));
g_return_if_fail (GTK_IS_LIST_STORE (store));
text_column = gtk_combo_box_get_entry_text_column (GTK_COMBO_BOX (combo_box));
+ g_return_if_fail (text_column == 0);
column_type = gtk_tree_model_get_column_type (GTK_TREE_MODEL (store), text_column);
g_return_if_fail (column_type == G_TYPE_STRING);
diff --git a/tests/testtreeview.c b/tests/testtreeview.c
index 6e72a1b..9d2c2d1 100644
--- a/tests/testtreeview.c
+++ b/tests/testtreeview.c
@@ -658,12 +658,12 @@ create_tree_model (void)
}
static void
-model_selected (GtkOptionMenu *om, gpointer data)
+model_selected (GtkComboBox *combo_box, gpointer data)
{
GtkTreeView *tree_view = GTK_TREE_VIEW (data);
gint hist;
- hist = gtk_option_menu_get_history (om);
+ hist = gtk_combo_box_get_active (combo_box);
if (models[hist] != gtk_tree_view_get_model (tree_view))
{
@@ -672,12 +672,12 @@ model_selected (GtkOptionMenu *om, gpointer data)
}
static void
-columns_selected (GtkOptionMenu *om, gpointer data)
+columns_selected (GtkComboBox *combo_box, gpointer data)
{
GtkTreeView *tree_view = GTK_TREE_VIEW (data);
gint hist;
- hist = gtk_option_menu_get_history (om);
+ hist = gtk_combo_box_get_active (combo_box);
if (hist != get_columns_type ())
{
@@ -705,7 +705,6 @@ main (int argc,
GtkWidget *tv;
GtkWidget *table;
GtkWidget *combo_box;
- GtkWidget *menu;
GtkTreeModel *model;
gint i;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]