]> git.0d.be Git - empathy.git/blobdiff - libempathy-gtk/empathy-irc-network-chooser-dialog.c
debug-window: fix typo
[empathy.git] / libempathy-gtk / empathy-irc-network-chooser-dialog.c
index 755eb584e1701b8e84312985b34840207d00ea9c..00e9bf0eba36e16be58af257db9d0296975dd695 100644 (file)
 
 #include "config.h"
 
-#include <stdlib.h>
-#include <string.h>
-#include <sys/stat.h>
-
 #include <glib/gi18n-lib.h>
-#include <gtk/gtk.h>
 
 #include <libempathy/empathy-utils.h>
 #include <libempathy/empathy-irc-network-manager.h>
 
 #include "empathy-irc-network-dialog.h"
-#include "empathy-ui-utils.h"
 #include "empathy-live-search.h"
 
 #define DEBUG_FLAG EMPATHY_DEBUG_ACCOUNT | EMPATHY_DEBUG_IRC
@@ -303,7 +297,7 @@ display_irc_network_dialog (EmpathyIrcNetworkChooserDialog *self,
 {
   GtkWidget *dialog;
 
-  dialog = empathy_irc_network_dialog_show (network, NULL);
+  dialog = empathy_irc_network_dialog_show (network, GTK_WIDGET (self));
 
   g_signal_connect (dialog, "destroy",
       G_CALLBACK (irc_network_dialog_destroy_cb), self);
@@ -427,13 +421,7 @@ dialog_response_cb (GtkDialog *dialog,
     gint response,
     EmpathyIrcNetworkChooserDialog *self)
 {
-  if (response == GTK_RESPONSE_OK)
-    add_network (self);
-  else if (response == GTK_RESPONSE_APPLY)
-    edit_network (self);
-  else if (response == GTK_RESPONSE_REJECT)
-    remove_network (self);
-  else if (response == RESPONSE_RESET)
+  if (response == RESPONSE_RESET)
     reset_networks (self);
 }
 
@@ -505,13 +493,24 @@ search_text_notify_cb (EmpathyLiveSearch *search,
 }
 
 static void
-dialog_destroy_cb (GtkWidget *widget,
+add_clicked_cb (GtkToolButton *button,
     EmpathyIrcNetworkChooserDialog *self)
 {
-  EmpathyIrcNetworkChooserDialogPriv *priv = GET_PRIV (self);
+  add_network (self);
+}
+
+static void
+remove_clicked_cb (GtkToolButton *button,
+    EmpathyIrcNetworkChooserDialog *self)
+{
+  remove_network (self);
+}
 
-  g_signal_handler_disconnect (priv->search, priv->search_sig);
-  g_signal_handler_disconnect (priv->search, priv->activate_sig);
+static void
+edit_clicked_cb (GtkToolButton *button,
+    EmpathyIrcNetworkChooserDialog *self)
+{
+  edit_network (self);
 }
 
 static void
@@ -524,6 +523,9 @@ empathy_irc_network_chooser_dialog_constructed (GObject *object)
   GtkWidget *vbox;
   GtkTreeViewColumn *column;
   GtkWidget *scroll;
+  GtkWidget *toolbar;
+  GtkToolItem *item;
+  GtkStyleContext *context;
 
   g_assert (priv->settings != NULL);
 
@@ -560,6 +562,35 @@ empathy_irc_network_chooser_dialog_constructed (GObject *object)
   gtk_container_add (GTK_CONTAINER (scroll), priv->treeview);
   gtk_box_pack_start (GTK_BOX (vbox), scroll, TRUE, TRUE, 6);
 
+  /* Treeview toolbar */
+  toolbar = gtk_toolbar_new ();
+  gtk_toolbar_set_icon_size (GTK_TOOLBAR (toolbar), GTK_ICON_SIZE_MENU);
+  gtk_box_pack_start (GTK_BOX (vbox), toolbar, FALSE, TRUE, 0);
+
+  item = gtk_tool_button_new (NULL, "");
+  gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (item), "list-add-symbolic");
+  g_signal_connect (item, "clicked", G_CALLBACK (add_clicked_cb), self);
+  gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
+
+  item = gtk_tool_button_new (NULL, "");
+  gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (item),
+      "list-remove-symbolic");
+  g_signal_connect (item, "clicked", G_CALLBACK (remove_clicked_cb), self);
+  gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
+
+  item = gtk_tool_button_new (NULL, "");
+  gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (item),
+      "preferences-system-symbolic");
+  g_signal_connect (item, "clicked", G_CALLBACK (edit_clicked_cb), self);
+  gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
+
+  context = gtk_widget_get_style_context (scroll);
+  gtk_style_context_set_junction_sides (context, GTK_JUNCTION_BOTTOM);
+
+  context = gtk_widget_get_style_context (toolbar);
+  gtk_style_context_add_class (context, GTK_STYLE_CLASS_INLINE_TOOLBAR);
+  gtk_style_context_set_junction_sides (context, GTK_JUNCTION_TOP);
+
   /* Live search */
   priv->search = empathy_live_search_new (priv->treeview);
 
@@ -581,9 +612,6 @@ empathy_irc_network_chooser_dialog_constructed (GObject *object)
 
   /* Add buttons */
   gtk_dialog_add_buttons (dialog,
-      GTK_STOCK_ADD, GTK_RESPONSE_OK,
-      GTK_STOCK_EDIT, GTK_RESPONSE_APPLY,
-      GTK_STOCK_REMOVE, GTK_RESPONSE_REJECT,
       _("Reset _Networks List"), RESPONSE_RESET,
       NULL);
 
@@ -598,8 +626,6 @@ empathy_irc_network_chooser_dialog_constructed (GObject *object)
 
   g_signal_connect (self, "response",
       G_CALLBACK (dialog_response_cb), self);
-  g_signal_connect (self, "destroy",
-      G_CALLBACK (dialog_destroy_cb), self);
 
   /* Request a side ensuring to display at least some networks */
   gtk_widget_set_size_request (GTK_WIDGET (self), -1, 300);
@@ -613,6 +639,26 @@ empathy_irc_network_chooser_dialog_dispose (GObject *object)
   EmpathyIrcNetworkManager *self = (EmpathyIrcNetworkManager *) object;
   EmpathyIrcNetworkChooserDialogPriv *priv = GET_PRIV (self);
 
+  if (priv->search_sig != 0)
+    {
+      g_signal_handler_disconnect (priv->search, priv->search_sig);
+      priv->search_sig = 0;
+    }
+
+  if (priv->activate_sig != 0)
+    {
+      g_signal_handler_disconnect (priv->search, priv->activate_sig);
+      priv->activate_sig = 0;
+    }
+
+  if (priv->search != NULL)
+    {
+      empathy_live_search_set_hook_widget (EMPATHY_LIVE_SEARCH (priv->search),
+          NULL);
+
+      priv->search = NULL;
+    }
+
   tp_clear_object (&priv->settings);
   tp_clear_object (&priv->network);
   tp_clear_object (&priv->network_manager);