Preserve location entry model beyond widget lifetime

This commit is contained in:
Christian Dywan 2008-10-27 03:35:37 +01:00
parent 70516f1f5b
commit f5f1946c89

View file

@ -22,6 +22,8 @@ struct _MidoriLocationAction
gchar* uri; gchar* uri;
gdouble progress; gdouble progress;
GtkTreeModel* model;
}; };
struct _MidoriLocationActionClass struct _MidoriLocationActionClass
@ -199,6 +201,8 @@ midori_location_action_init (MidoriLocationAction* location_action)
{ {
location_action->uri = NULL; location_action->uri = NULL;
location_action->progress = 0.0; location_action->progress = 0.0;
location_action->model = NULL;
} }
static void static void
@ -208,6 +212,8 @@ midori_location_action_finalize (GObject* object)
g_free (location_action->uri); g_free (location_action->uri);
katze_object_assign (location_action->model, NULL);
G_OBJECT_CLASS (midori_location_action_parent_class)->finalize (object); G_OBJECT_CLASS (midori_location_action_parent_class)->finalize (object);
} }
@ -359,6 +365,7 @@ midori_location_action_connect_proxy (GtkAction* action,
{ {
GtkWidget* alignment; GtkWidget* alignment;
GtkWidget* entry; GtkWidget* entry;
MidoriLocationAction* location_action;
GTK_ACTION_CLASS (midori_location_action_parent_class)->connect_proxy ( GTK_ACTION_CLASS (midori_location_action_parent_class)->connect_proxy (
action, proxy); action, proxy);
@ -368,6 +375,14 @@ midori_location_action_connect_proxy (GtkAction* action,
alignment = gtk_bin_get_child (GTK_BIN (proxy)); alignment = gtk_bin_get_child (GTK_BIN (proxy));
entry = gtk_bin_get_child (GTK_BIN (alignment)); entry = gtk_bin_get_child (GTK_BIN (alignment));
location_action = MIDORI_LOCATION_ACTION (action);
if (location_action->model)
gtk_combo_box_set_model (GTK_COMBO_BOX (entry),
location_action->model);
else
location_action->model = g_object_ref (gtk_combo_box_get_model (
GTK_COMBO_BOX (entry)));
g_signal_connect (entry, "active-changed", g_signal_connect (entry, "active-changed",
G_CALLBACK (midori_location_action_active_changed_cb), action); G_CALLBACK (midori_location_action_active_changed_cb), action);
g_object_connect (gtk_bin_get_child (GTK_BIN (entry)), g_object_connect (gtk_bin_get_child (GTK_BIN (entry)),