]> git.0d.be Git - empathy.git/blobdiff - src/empathy-roster-window.c
roster-view: inherit from GtkListBox
[empathy.git] / src / empathy-roster-window.c
index 93001d8d428b18d1137ee0382e89bbe9418e3aa0..b79c5f89c0a7b753dc6d7c57f628334bd8e20257 100644 (file)
@@ -26,6 +26,7 @@
 
 #include <sys/stat.h>
 #include <glib/gi18n.h>
+#include <tp-account-widgets/tpaw-builder.h>
 
 #include "empathy-about-dialog.h"
 #include "empathy-accounts-dialog.h"
@@ -329,6 +330,14 @@ roster_window_load_events_idle_cb (gpointer user_data)
   return FALSE;
 }
 
+static void
+hide_search_bar (EmpathyRosterWindow *roster_window)
+{
+  if (TPAW_IS_LIVE_SEARCH (roster_window->priv->search_bar) &&
+      gtk_widget_is_visible (roster_window->priv->search_bar))
+    gtk_widget_hide (roster_window->priv->search_bar);
+}
+
 static void
 individual_activated_cb (EmpathyRosterView *self,
     FolksIndividual *individual,
@@ -347,6 +356,9 @@ individual_activated_cb (EmpathyRosterView *self,
   empathy_chat_with_contact (contact, gtk_get_current_event_time ());
 
   g_object_unref (contact);
+
+  /* Hide the search-bar upon hitting "Enter" on an individual */
+  hide_search_bar (EMPATHY_ROSTER_WINDOW (user_data));
 }
 
 static void
@@ -356,6 +368,9 @@ event_activated_cb (EmpathyRosterView *self,
     gpointer user_data)
 {
   empathy_event_activate (event);
+
+  /* Hide the search-bar upon an event activation */
+  hide_search_bar (EMPATHY_ROSTER_WINDOW (user_data));
 }
 
 static void
@@ -729,7 +744,7 @@ roster_window_error_display (EmpathyRosterWindow *self,
        tp_account_get_detailed_error (account, NULL)))
     {
       roster_window_error_add_stock_button (GTK_INFO_BAR (info_bar),
-          GTK_STOCK_REFRESH, _("Update software..."),
+          GTK_STOCK_REFRESH, _("Update software"),
           ERROR_RESPONSE_RETRY);
     }
   else
@@ -1745,6 +1760,14 @@ account_disabled_cb (TpAccountManager *manager,
   set_notebook_page (self);
 }
 
+static void
+account_removed_cb (TpAccountManager *manager,
+    TpAccount *account,
+    EmpathyRosterWindow *self)
+{
+  set_notebook_page (self);
+}
+
 static void
 account_manager_prepared_cb (GObject *source_object,
     GAsyncResult *result,
@@ -1773,6 +1796,8 @@ account_manager_prepared_cb (GObject *source_object,
 
   g_signal_connect (manager, "account-validity-changed",
       G_CALLBACK (roster_window_account_validity_changed_cb), self);
+  tp_g_signal_connect_object (manager, "account-removed",
+      G_CALLBACK (account_removed_cb), self, 0);
   tp_g_signal_connect_object (manager, "account-disabled",
       G_CALLBACK (account_disabled_cb), self, 0);
   tp_g_signal_connect_object (manager, "account-enabled",
@@ -1937,8 +1962,18 @@ menu_deactivate_cb (GtkMenuShell *menushell,
   gtk_menu_detach (GTK_MENU (menushell));
 }
 
+static void
+menu_item_activated_cb (GtkMenuShell *menushell,
+    gpointer user_data)
+{
+    EmpathyRosterWindow *roster_window = EMPATHY_ROSTER_WINDOW (user_data);
+
+    hide_search_bar (roster_window);
+}
+
 static void
 popup_individual_menu_cb (EmpathyRosterView *view,
+    const gchar *active_group,
     FolksIndividual *individual,
     guint button,
     guint time,
@@ -1955,7 +1990,8 @@ popup_individual_menu_cb (EmpathyRosterView *view,
     EMPATHY_INDIVIDUAL_FEATURE_REMOVE |
     EMPATHY_INDIVIDUAL_FEATURE_FILE_TRANSFER;
 
-  menu = empathy_individual_menu_new (individual, features, NULL);
+  menu = empathy_individual_menu_new (individual, active_group,
+      features, NULL);
 
   /* menu is initially unowned but gtk_menu_attach_to_widget() takes its
    * floating ref. We can either wait for the view to release its ref
@@ -1965,6 +2001,8 @@ popup_individual_menu_cb (EmpathyRosterView *view,
    * during the whole lifetime of Empathy. */
   g_signal_connect (menu, "deactivate", G_CALLBACK (menu_deactivate_cb),
       NULL);
+  g_signal_connect (menu, "menu-item-activated",
+      G_CALLBACK (menu_item_activated_cb), user_data);
 
   gtk_menu_attach_to_widget (GTK_MENU (menu), GTK_WIDGET (view), NULL);
   gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, button, time);
@@ -2099,22 +2137,22 @@ view_drag_motion_cb (GtkWidget *widget,
     {
       /* Check if contact supports FT */
       FolksIndividual *individual;
-      GtkWidget *child;
+      GtkListBoxRow *row;
 
       individual = empathy_roster_view_get_individual_at_y (self->priv->view,
-          y, &child);
+          y, &row);
       if (individual == NULL)
         goto no_hl;
 
       if (!individual_supports_ft (individual))
         goto no_hl;
 
-      egg_list_box_drag_highlight_widget (EGG_LIST_BOX (widget), child);
+      gtk_list_box_drag_highlight_row (GTK_LIST_BOX (widget), row);
       return FALSE;
     }
 
 no_hl:
-  egg_list_box_drag_unhighlight_widget (EGG_LIST_BOX (widget));
+  gtk_list_box_drag_unhighlight_row (GTK_LIST_BOX (widget));
   return FALSE;
 }
 
@@ -2233,7 +2271,7 @@ empathy_roster_window_init (EmpathyRosterWindow *self)
 
   /* Set up interface */
   filename = empathy_file_lookup ("empathy-roster-window.ui", "src");
-  gui = empathy_builder_get_file (filename,
+  gui = tpaw_builder_get_file (filename,
       "main_vbox", &self->priv->main_vbox,
       "balance_vbox", &self->priv->balance_vbox,
       "errors_vbox", &self->priv->errors_vbox,
@@ -2278,7 +2316,7 @@ empathy_roster_window_init (EmpathyRosterWindow *self)
   roster_window_setup_actions (self);
 
   filename = empathy_file_lookup ("empathy-roster-window-menubar.ui", "src");
-  gui = empathy_builder_get_file (filename,
+  gui = tpaw_builder_get_file (filename,
       "appmenu", &self->priv->menumodel,
       "rooms", &self->priv->rooms_section,
       NULL);
@@ -2328,8 +2366,7 @@ empathy_roster_window_init (EmpathyRosterWindow *self)
 
   gtk_widget_show (GTK_WIDGET (self->priv->view));
 
-  egg_list_box_add_to_scrolled (EGG_LIST_BOX (self->priv->view),
-      GTK_SCROLLED_WINDOW (sw));
+  gtk_container_add (GTK_CONTAINER (sw), GTK_WIDGET (self->priv->view));
 
   g_signal_connect (self->priv->view, "individual-activated",
       G_CALLBACK (individual_activated_cb), self);
@@ -2359,10 +2396,10 @@ empathy_roster_window_init (EmpathyRosterWindow *self)
   gtk_widget_set_has_tooltip (GTK_WIDGET (self->priv->view), TRUE);
 
   /* Set up search bar */
-  self->priv->search_bar = empathy_live_search_new (
+  self->priv->search_bar = tpaw_live_search_new (
       GTK_WIDGET (self->priv->view));
   empathy_roster_view_set_live_search (self->priv->view,
-      EMPATHY_LIVE_SEARCH (self->priv->search_bar));
+      TPAW_LIVE_SEARCH (self->priv->search_bar));
   gtk_box_pack_start (GTK_BOX (search_vbox), self->priv->search_bar,
       FALSE, TRUE, 0);