]> git.0d.be Git - empathy.git/blobdiff - libempathy-gtk/empathy-account-widget-irc.c
Refactor the floating ref hack into a new function
[empathy.git] / libempathy-gtk / empathy-account-widget-irc.c
index 35fa7697f4668eeb3bb729d798aed37ebe56d09d..3af842415ec219a1e41b4298d86cb05f47408f0b 100644 (file)
 #include <string.h>
 #include <sys/stat.h>
 
-#include <glib/gi18n.h>
+#include <glib/gi18n-lib.h>
 #include <gtk/gtk.h>
-#include <glade/glade.h>
 
 #include <libmissioncontrol/mc-account.h>
 #include <libmissioncontrol/mc-protocol.h>
 
 #include <libempathy/empathy-utils.h>
-#include <libempathy/empathy-debug.h>
 #include <libempathy/empathy-irc-network-manager.h>
 
 #include "empathy-irc-network-dialog.h"
@@ -40,7 +38,8 @@
 #include "empathy-account-widget-irc.h"
 #include "empathy-ui-utils.h"
 
-#define DEBUG_DOMAIN "AccountWidgetIRC"
+#define DEBUG_FLAG EMPATHY_DEBUG_ACCOUNT | EMPATHY_DEBUG_IRC
+#include <libempathy/empathy-debug.h>
 
 #define IRC_NETWORKS_FILENAME "irc-networks.xml"
 
@@ -73,7 +72,7 @@ account_widget_irc_destroy_cb (GtkWidget *widget,
 static void
 unset_server_params (EmpathyAccountWidgetIrc *settings)
 {
-  empathy_debug (DEBUG_DOMAIN, "Unset server, port and use-ssl");
+  DEBUG ("Unset server, port and use-ssl");
   mc_account_unset_param (settings->account, "server");
   mc_account_unset_param (settings->account, "port");
   mc_account_unset_param (settings->account, "use-ssl");
@@ -101,7 +100,7 @@ update_server_params (EmpathyAccountWidgetIrc *settings)
   g_assert (network != NULL);
 
   g_object_get (network, "charset", &charset, NULL);
-  empathy_debug (DEBUG_DOMAIN, "Setting charset to %s", charset);
+  DEBUG ("Setting charset to %s", charset);
   mc_account_set_param_string (settings->account, "charset", charset);
   g_free (charset);
 
@@ -120,12 +119,11 @@ update_server_params (EmpathyAccountWidgetIrc *settings)
           "ssl", &ssl,
           NULL);
 
-      empathy_debug (DEBUG_DOMAIN, "Setting server to %s", address);
+      DEBUG ("Setting server to %s", address);
       mc_account_set_param_string (settings->account, "server", address);
-      empathy_debug (DEBUG_DOMAIN, "Setting port to %u", port);
+      DEBUG ("Setting port to %u", port);
       mc_account_set_param_int (settings->account, "port", port);
-      empathy_debug (DEBUG_DOMAIN, "Setting use-ssl to %s",
-          ssl ? "TRUE": "FALSE" );
+      DEBUG ("Setting use-ssl to %s", ssl ? "TRUE": "FALSE" );
       mc_account_set_param_boolean (settings->account, "use-ssl", ssl);
 
       g_free (address);
@@ -217,7 +215,7 @@ account_widget_irc_button_remove_clicked_cb (GtkWidget *button,
   g_assert (network != NULL);
 
   g_object_get (network, "name", &name, NULL);
-  empathy_debug (DEBUG_DOMAIN, "Remove network %s", name);
+  DEBUG ("Remove network %s", name);
 
   gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
   empathy_irc_network_manager_remove (settings->network_manager, network);
@@ -378,7 +376,7 @@ account_widget_irc_setup (EmpathyAccountWidgetIrc *settings)
           g_object_set (network, "charset", charset, NULL);
 
           g_object_get (network, "name", &name, NULL);
-          empathy_debug (DEBUG_DOMAIN, "Account use network %s", name);
+          DEBUG ("Account use network %s", name);
 
           g_free (name);
         }
@@ -388,7 +386,7 @@ account_widget_irc_setup (EmpathyAccountWidgetIrc *settings)
           EmpathyIrcServer *srv;
           GtkTreeIter iter;
 
-          empathy_debug (DEBUG_DOMAIN, "Create a network %s", server);
+          DEBUG ("Create a network %s", server);
           network = empathy_irc_network_new (server);
           srv = empathy_irc_server_new (server, port, ssl);
 
@@ -430,9 +428,10 @@ empathy_account_widget_irc_new (McAccount *account)
 {
   EmpathyAccountWidgetIrc *settings;
   gchar *dir, *user_file_with_path, *global_file_with_path;
-  GladeXML *glade;
+  GtkBuilder *gui;
   GtkListStore *store;
   GtkCellRenderer *renderer;
+  gchar *filename;
 
   settings = g_slice_new0 (EmpathyAccountWidgetIrc);
   settings->account = g_object_ref (account);
@@ -442,8 +441,8 @@ empathy_account_widget_irc_new (McAccount *account)
   user_file_with_path = g_build_filename (dir, IRC_NETWORKS_FILENAME, NULL);
   g_free (dir);
 
-  global_file_with_path = g_build_filename (UNINSTALLED_IRC_DIR,
-      IRC_NETWORKS_FILENAME, NULL);
+  global_file_with_path = g_build_filename (g_getenv ("EMPATHY_SRCDIR"),
+      "libempathy-gtk", IRC_NETWORKS_FILENAME, NULL);
   if (!g_file_test (global_file_with_path, G_FILE_TEST_EXISTS))
     {
       g_free (global_file_with_path);
@@ -458,15 +457,16 @@ empathy_account_widget_irc_new (McAccount *account)
   g_free (global_file_with_path);
   g_free (user_file_with_path);
 
-  glade = empathy_glade_get_file ("empathy-account-widget-irc.glade",
-      "vbox_irc_settings",
-      NULL,
+  filename = empathy_file_lookup ("empathy-account-widget-irc.ui",
+      "libempathy-gtk");
+  gui = empathy_builder_get_file (filename,
       "vbox_irc_settings", &settings->vbox_settings,
       "combobox_network", &settings->combobox_network,
       "button_network", &settings->button_network,
       "button_add_network", &settings->button_add_network,
       "button_remove", &settings->button_remove,
       NULL);
+  g_free (filename);
 
   /* Fill the networks combobox */
   store = gtk_list_store_new (2, G_TYPE_OBJECT, G_TYPE_STRING);
@@ -490,14 +490,14 @@ empathy_account_widget_irc_new (McAccount *account)
 
   account_widget_irc_setup (settings);
 
-  empathy_account_widget_handle_params (account, glade,
+  empathy_account_widget_handle_params (account, gui,
       "entry_nick", "account",
       "entry_fullname", "fullname",
       "entry_password", "password",
       "entry_quit_message", "quit-message",
       NULL);
 
-  empathy_glade_connect (glade, settings,
+  empathy_builder_connect (gui, settings,
       "vbox_irc_settings", "destroy", account_widget_irc_destroy_cb,
       "button_network", "clicked", account_widget_irc_button_edit_network_clicked_cb,
       "button_add_network", "clicked", account_widget_irc_button_add_network_clicked_cb,
@@ -505,7 +505,5 @@ empathy_account_widget_irc_new (McAccount *account)
       "combobox_network", "changed", account_widget_irc_combobox_network_changed_cb,
       NULL);
 
-  g_object_unref (glade);
-
-  return settings->vbox_settings;
+  return empathy_builder_unref_and_keep_widget (gui, settings->vbox_settings);
 }