]> Pileus Git - ~andy/gtk/commitdiff
Allow out-of-order setting of model and active. Patch by Christian Dywan
authorMatthias Clasen <matthiasc@src.gnome.org>
Sat, 13 Dec 2008 08:11:54 +0000 (08:11 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Sat, 13 Dec 2008 08:11:54 +0000 (08:11 +0000)
        * gtk/gtkcombobox.c: Allow out-of-order setting of model and active.
        Patch by Christian Dywan

svn path=/trunk/; revision=21888

ChangeLog
gtk/gtkcombobox.c

index 23e9ab42e85898b89829f3277c75544c4590ca45..75b6f85b0365158ceed4df48f4289266125a2ad6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2008-12-13  Matthias Clasen  <mclasen@redhat.com>
+
+       Bug 555560 – gtk_combo_box_set_active fails with no model
+       
+       * gtk/gtkcombobox.c: Allow out-of-order setting of model and active.
+       Patch by Christian Dywan
+
 2008-12-13  Matthias Clasen  <mclasen@redhat.com>
 
        Bug 558306 – Cannot build gdk (gtk+ 2.14.4) on Solaris 8
index df6b60109423de4dff534bb73d9bcb5262b34888..dc3aae1aa78757f945415fca7f18430339446e90 100644 (file)
@@ -81,6 +81,7 @@ struct _GtkComboBoxPrivate
   gint wrap_width;
   GtkShadowType shadow_type;
 
+  gint active; /* Only temporary */
   GtkTreeRowReference *active_row;
 
   GtkWidget *tree_view;
@@ -928,6 +929,7 @@ gtk_combo_box_init (GtkComboBox *combo_box)
   priv->height = 0;
   priv->wrap_width = 0;
 
+  priv->active = -1;
   priv->active_row = NULL;
   priv->col_column = -1;
   priv->row_column = -1;
@@ -4839,6 +4841,13 @@ gtk_combo_box_set_active (GtkComboBox *combo_box,
   g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
   g_return_if_fail (index_ >= -1);
 
+  if (combo_box->priv->model == NULL)
+    {
+      /* Save index, in case the model is set after the index */
+      combo_box->priv->active = index_;
+      return;
+    }
+
   if (index_ != -1)
     path = gtk_tree_path_new_from_indices (index_, -1);
    
@@ -5034,6 +5043,13 @@ gtk_combo_box_set_model (GtkComboBox  *combo_box,
     gtk_cell_view_set_model (GTK_CELL_VIEW (combo_box->priv->cell_view),
                              combo_box->priv->model);
 
+  if (combo_box->priv->active != -1)
+    {
+      /* If an index was set in advance, apply it now */
+      gtk_combo_box_set_active (combo_box, combo_box->priv->active);
+      combo_box->priv->active = -1;
+    }
+
 out:
   gtk_combo_box_update_sensitivity (combo_box);