empathy r2871 - trunk/libempathy-gtk
- From: xclaesse svn gnome org
- To: svn-commits-list gnome org
- Subject: empathy r2871 - trunk/libempathy-gtk
- Date: Thu, 16 Apr 2009 12:29:33 +0000 (UTC)
Author: xclaesse
Date: Thu Apr 16 12:29:33 2009
New Revision: 2871
URL: http://svn.gnome.org/viewvc/empathy?rev=2871&view=rev
Log:
Refactor the floating ref hack into a new function
From: Xavier Claessens <xclaesse gmail com>
Modified:
trunk/libempathy-gtk/empathy-account-widget-irc.c
trunk/libempathy-gtk/empathy-account-widget-sip.c
trunk/libempathy-gtk/empathy-account-widget.c
trunk/libempathy-gtk/empathy-contact-widget.c
trunk/libempathy-gtk/empathy-ui-utils.c
trunk/libempathy-gtk/empathy-ui-utils.h
Modified: trunk/libempathy-gtk/empathy-account-widget-irc.c
==============================================================================
--- trunk/libempathy-gtk/empathy-account-widget-irc.c (original)
+++ trunk/libempathy-gtk/empathy-account-widget-irc.c Thu Apr 16 12:29:33 2009
@@ -505,9 +505,5 @@
"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);
}
Modified: trunk/libempathy-gtk/empathy-account-widget-sip.c
==============================================================================
--- trunk/libempathy-gtk/empathy-account-widget-sip.c (original)
+++ trunk/libempathy-gtk/empathy-account-widget-sip.c Thu Apr 16 12:29:33 2009
@@ -115,9 +115,5 @@
"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);
}
Modified: trunk/libempathy-gtk/empathy-account-widget.c
==============================================================================
--- trunk/libempathy-gtk/empathy-account-widget.c (original)
+++ trunk/libempathy-gtk/empathy-account-widget.c Thu Apr 16 12:29:33 2009
@@ -481,11 +481,7 @@
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 @@
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 @@
"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 @@
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 @@
"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 @@
"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 @@
"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 @@
"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);
}
Modified: trunk/libempathy-gtk/empathy-contact-widget.c
==============================================================================
--- trunk/libempathy-gtk/empathy-contact-widget.c (original)
+++ trunk/libempathy-gtk/empathy-contact-widget.c Thu Apr 16 12:29:33 2009
@@ -209,11 +209,8 @@
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 *
Modified: trunk/libempathy-gtk/empathy-ui-utils.c
==============================================================================
--- trunk/libempathy-gtk/empathy-ui-utils.c (original)
+++ trunk/libempathy-gtk/empathy-ui-utils.c Thu Apr 16 12:29:33 2009
@@ -166,6 +166,23 @@
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)
{
Modified: trunk/libempathy-gtk/empathy-ui-utils.h
==============================================================================
--- trunk/libempathy-gtk/empathy-ui-utils.h (original)
+++ trunk/libempathy-gtk/empathy-ui-utils.h Thu Apr 16 12:29:33 2009
@@ -72,6 +72,8 @@
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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]