]> spindle.queued.net Git - midori/commitdiff
Create completion model in one place and thaw/ freeze only new model
authorChristian Dywan <christian@twotoasts.de>
Mon, 1 Jun 2009 06:11:50 +0000 (08:11 +0200)
committerChristian Dywan <christian@twotoasts.de>
Mon, 1 Jun 2009 06:11:50 +0000 (08:11 +0200)
midori/midori-locationaction.c

index d1a6ca2b5c4562fc86768bc7c510e7990430b577..3e3f1a4b9567fce5b037ac1e50b16891ff655a48 100644 (file)
@@ -323,6 +323,15 @@ midori_location_action_thaw (MidoriLocationAction* location_action)
     }
 }
 
+static GtkTreeModel*
+midori_location_action_create_model (void)
+{
+    GtkTreeModel* model = (GtkTreeModel*)gtk_list_store_new (N_COLS,
+        GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING,
+        G_TYPE_INT, G_TYPE_BOOLEAN);
+    return model;
+}
+
 static void
 midori_location_action_init (MidoriLocationAction* location_action)
 {
@@ -332,9 +341,7 @@ midori_location_action_init (MidoriLocationAction* location_action)
     location_action->secondary_icon = NULL;
     location_action->default_icon = NULL;
 
-    location_action->model = (GtkTreeModel*)gtk_list_store_new (N_COLS,
-        GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING,
-        G_TYPE_INT, G_TYPE_BOOLEAN);
+    location_action->model = midori_location_action_create_model ();
 
     location_action->filter_model = NULL;
     location_action->sort_model = NULL;
@@ -435,7 +442,6 @@ midori_location_action_set_property (GObject*      object,
         history = g_value_dup_object (value);
         katze_assign (location_action->history, g_object_ref (history));
         model = g_object_get_data (G_OBJECT (history), "midori-location-model");
-        midori_location_action_freeze (location_action);
         if (model != NULL)
         {
             katze_object_assign (location_action->model, g_object_ref (model));
@@ -443,17 +449,16 @@ midori_location_action_set_property (GObject*      object,
         else
         {
             g_object_unref (location_action->model);
-            location_action->model = (GtkTreeModel*)gtk_list_store_new (N_COLS,
-                GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING,
-                G_TYPE_INT, G_TYPE_BOOLEAN);
+            location_action->model = midori_location_action_create_model ();
+            midori_location_action_freeze (location_action);
             /* FIXME: MidoriBrowser is essentially making up for the lack
                       of synchronicity of newly added items. */
             midori_location_action_insert_history_item (location_action,
                 KATZE_ITEM (g_value_get_object (value)));
+            midori_location_action_thaw (location_action);
             g_object_set_data (G_OBJECT (history),
                 "midori-location-model", location_action->model);
         }
-        midori_location_action_thaw (location_action);
         break;
     }
     default: