diff options
author | Xavier Claessens <xclaesse@gmail.com> | 2009-04-16 20:29:33 +0800 |
---|---|---|
committer | Xavier Claessens <xclaesse@src.gnome.org> | 2009-04-16 20:29:33 +0800 |
commit | 293340151049a04517bb3741172a1f6750ddeabb (patch) | |
tree | 01d57d7d9d310f7254ef7166ef5311d74de64650 | |
parent | 5d0a01756d410f44588870dabbed42145f2b765e (diff) | |
download | gsoc2013-empathy-293340151049a04517bb3741172a1f6750ddeabb.tar gsoc2013-empathy-293340151049a04517bb3741172a1f6750ddeabb.tar.gz gsoc2013-empathy-293340151049a04517bb3741172a1f6750ddeabb.tar.bz2 gsoc2013-empathy-293340151049a04517bb3741172a1f6750ddeabb.tar.lz gsoc2013-empathy-293340151049a04517bb3741172a1f6750ddeabb.tar.xz gsoc2013-empathy-293340151049a04517bb3741172a1f6750ddeabb.tar.zst gsoc2013-empathy-293340151049a04517bb3741172a1f6750ddeabb.zip |
Refactor the floating ref hack into a new function
From: Xavier Claessens <xclaesse@gmail.com>
svn path=/trunk/; revision=2871
-rw-r--r-- | libempathy-gtk/empathy-account-widget-irc.c | 6 | ||||
-rw-r--r-- | libempathy-gtk/empathy-account-widget-sip.c | 6 | ||||
-rw-r--r-- | libempathy-gtk/empathy-account-widget.c | 48 | ||||
-rw-r--r-- | libempathy-gtk/empathy-contact-widget.c | 7 | ||||
-rw-r--r-- | libempathy-gtk/empathy-ui-utils.c | 17 | ||||
-rw-r--r-- | libempathy-gtk/empathy-ui-utils.h | 2 |
6 files changed, 31 insertions, 55 deletions
diff --git a/libempathy-gtk/empathy-account-widget-irc.c b/libempathy-gtk/empathy-account-widget-irc.c index 043f05dc8..3af842415 100644 --- a/libempathy-gtk/empathy-account-widget-irc.c +++ b/libempathy-gtk/empathy-account-widget-irc.c @@ -505,9 +505,5 @@ empathy_account_widget_irc_new (McAccount *account) "combobox_network", "changed", account_widget_irc_combobox_network_changed_cb, NULL); - g_object_ref (settings->vbox_settings); - g_object_force_floating (G_OBJECT (settings->vbox_settings)); - g_object_unref (gui); - - return settings->vbox_settings; + return empathy_builder_unref_and_keep_widget (gui, settings->vbox_settings); } diff --git a/libempathy-gtk/empathy-account-widget-sip.c b/libempathy-gtk/empathy-account-widget-sip.c index ffac231d6..2d4944779 100644 --- a/libempathy-gtk/empathy-account-widget-sip.c +++ b/libempathy-gtk/empathy-account-widget-sip.c @@ -115,9 +115,5 @@ empathy_account_widget_sip_new (McAccount *account) "checkbutton_discover-stun", "toggled", account_widget_sip_discover_stun_toggled_cb, NULL); - g_object_ref (settings->vbox_settings); - g_object_force_floating (G_OBJECT (settings->vbox_settings)); - g_object_unref (gui); - - return settings->vbox_settings; + return empathy_builder_unref_and_keep_widget (gui, settings->vbox_settings); } diff --git a/libempathy-gtk/empathy-account-widget.c b/libempathy-gtk/empathy-account-widget.c index e57fb2802..33cef69ae 100644 --- a/libempathy-gtk/empathy-account-widget.c +++ b/libempathy-gtk/empathy-account-widget.c @@ -481,11 +481,7 @@ empathy_account_widget_generic_new (McAccount *account) accounts_widget_generic_setup (account, table_common_settings, table_advanced_settings); - g_object_ref (widget); - g_object_force_floating (G_OBJECT (widget)); - g_object_unref (gui); - - return widget; + return empathy_builder_unref_and_keep_widget (gui, widget); } GtkWidget * @@ -513,11 +509,7 @@ empathy_account_widget_salut_new (McAccount *account) g_object_unref (gui); - g_object_ref (widget); - g_object_force_floating (G_OBJECT (widget)); - g_object_unref (gui); - - return widget; + return empathy_builder_unref_and_keep_widget (gui, widget); } GtkWidget * @@ -545,11 +537,7 @@ empathy_account_widget_msn_new (McAccount *account) "button_forget", "entry_password"); - g_object_ref (widget); - g_object_force_floating (G_OBJECT (widget)); - g_object_unref (gui); - - return widget; + return empathy_builder_unref_and_keep_widget (gui, widget); } GtkWidget * @@ -590,11 +578,7 @@ empathy_account_widget_jabber_new (McAccount *account) G_CALLBACK (account_widget_jabber_ssl_toggled_cb), spinbutton_port); - g_object_ref (widget); - g_object_force_floating (G_OBJECT (widget)); - g_object_unref (gui); - - return widget; + return empathy_builder_unref_and_keep_widget (gui, widget); } GtkWidget * @@ -625,11 +609,7 @@ empathy_account_widget_icq_new (McAccount *account) "button_forget", "entry_password"); - g_object_ref (widget); - g_object_force_floating (G_OBJECT (widget)); - g_object_unref (gui); - - return widget; + return empathy_builder_unref_and_keep_widget (gui, widget); } GtkWidget * @@ -659,11 +639,7 @@ empathy_account_widget_aim_new (McAccount *account) "button_forget", "entry_password"); - g_object_ref (widget); - g_object_force_floating (G_OBJECT (widget)); - g_object_unref (gui); - - return widget; + return empathy_builder_unref_and_keep_widget (gui, widget); } GtkWidget * @@ -695,11 +671,7 @@ empathy_account_widget_yahoo_new (McAccount *account) "button_forget", "entry_password"); - g_object_ref (widget); - g_object_force_floating (G_OBJECT (widget)); - g_object_unref (gui); - - return widget; + return empathy_builder_unref_and_keep_widget (gui, widget); } GtkWidget * @@ -727,10 +699,6 @@ empathy_account_widget_groupwise_new (McAccount *account) "button_forget", "entry_password"); - g_object_ref (widget); - g_object_force_floating (G_OBJECT (widget)); - g_object_unref (gui); - - return widget; + return empathy_builder_unref_and_keep_widget (gui, widget); } diff --git a/libempathy-gtk/empathy-contact-widget.c b/libempathy-gtk/empathy-contact-widget.c index 6d302171a..0b2fb82b8 100644 --- a/libempathy-gtk/empathy-contact-widget.c +++ b/libempathy-gtk/empathy-contact-widget.c @@ -209,11 +209,8 @@ empathy_contact_widget_new (EmpathyContact *contact, contact_widget_set_contact (information, contact); - g_object_ref (information->vbox_contact_widget); - g_object_force_floating (G_OBJECT (information->vbox_contact_widget)); - g_object_unref (gui); - - return information->vbox_contact_widget; + return empathy_builder_unref_and_keep_widget (gui, + information->vbox_contact_widget); } EmpathyContact * diff --git a/libempathy-gtk/empathy-ui-utils.c b/libempathy-gtk/empathy-ui-utils.c index a1f4a6bfc..aa3492899 100644 --- a/libempathy-gtk/empathy-ui-utils.c +++ b/libempathy-gtk/empathy-ui-utils.c @@ -166,6 +166,23 @@ empathy_builder_connect (GtkBuilder *gui, va_end (args); } +GtkWidget * +empathy_builder_unref_and_keep_widget (GtkBuilder *gui, + GtkWidget *widget) +{ + /* On construction gui sinks the initial reference to widget. When gui + * is finalized it will drop its ref to widget. We take our own ref to + * prevent widget being finalised. The widget is forced to have a + * floating reference, like when it was initially unowned so that it can + * be used like any other GtkWidget. */ + + g_object_ref (widget); + g_object_force_floating (G_OBJECT (widget)); + g_object_unref (gui); + + return widget; +} + const gchar * empathy_icon_name_from_account (McAccount *account) { diff --git a/libempathy-gtk/empathy-ui-utils.h b/libempathy-gtk/empathy-ui-utils.h index 3f9cbff25..8dcc4c037 100644 --- a/libempathy-gtk/empathy-ui-utils.h +++ b/libempathy-gtk/empathy-ui-utils.h @@ -72,6 +72,8 @@ void empathy_builder_connect (GtkBuilder *gui, gpointer user_data, gchar *first_object, ...); +GtkWidget *empathy_builder_unref_and_keep_widget (GtkBuilder *gui, + GtkWidget *root); /* Pixbufs */ const gchar * empathy_icon_name_from_account (McAccount *account); |