]> git.0d.be Git - empathy.git/blobdiff - src/empathy-roster-window.c
display all contacts in a flat list
[empathy.git] / src / empathy-roster-window.c
index 0c0d924383e36c74700ada63f1e6a34869022d2f..e874fb533b26e062273d068d7a07670927514b6f 100644 (file)
  *          Danielle Madeley <danielle.madeley@collabora.co.uk>
  */
 
-#include <config.h>
+#include "config.h"
+#include "empathy-roster-window.h"
 
 #include <sys/stat.h>
-#include <gtk/gtk.h>
-#include <gdk/gdkkeysyms.h>
 #include <glib/gi18n.h>
+#include <tp-account-widgets/tpaw-builder.h>
 
-#include <telepathy-glib/telepathy-glib.h>
-#include <folks/folks.h>
-
-#include <libempathy/empathy-contact.h>
-#include <libempathy/empathy-utils.h>
-#include <libempathy/empathy-request-util.h>
-#include <libempathy/empathy-chatroom-manager.h>
-#include <libempathy/empathy-chatroom.h>
-#include <libempathy/empathy-gsettings.h>
-#include <libempathy/empathy-individual-manager.h>
-#include <libempathy/empathy-gsettings.h>
-#include <libempathy/empathy-status-presets.h>
-#include <libempathy/empathy-presence-manager.h>
-
-#include <libempathy-gtk/empathy-live-search.h>
-#include <libempathy-gtk/empathy-contact-blocking-dialog.h>
-#include <libempathy-gtk/empathy-contact-search-dialog.h>
-#include <libempathy-gtk/empathy-geometry.h>
-#include <libempathy-gtk/empathy-gtk-enum-types.h>
-#include <libempathy-gtk/empathy-individual-dialogs.h>
-#include <libempathy-gtk/empathy-individual-store-manager.h>
-#include <libempathy-gtk/empathy-roster-model.h>
-#include <libempathy-gtk/empathy-roster-model-manager.h>
-#include <libempathy-gtk/empathy-roster-view.h>
-#include <libempathy-gtk/empathy-new-message-dialog.h>
-#include <libempathy-gtk/empathy-new-call-dialog.h>
-#include <libempathy-gtk/empathy-log-window.h>
-#include <libempathy-gtk/empathy-presence-chooser.h>
-#include <libempathy-gtk/empathy-sound-manager.h>
-#include <libempathy-gtk/empathy-ui-utils.h>
-
+#include "empathy-about-dialog.h"
 #include "empathy-accounts-dialog.h"
 #include "empathy-call-observer.h"
 #include "empathy-chat-manager.h"
-#include "empathy-roster-window.h"
-#include "empathy-preferences.h"
-#include "empathy-about-dialog.h"
-#include "empathy-debug-window.h"
-#include "empathy-new-chatroom-dialog.h"
+#include "empathy-chat-window.h"
+#include "empathy-chatroom-manager.h"
 #include "empathy-chatrooms-window.h"
+#include "empathy-client-factory.h"
+#include "empathy-contact-blocking-dialog.h"
+#include "empathy-contact-search-dialog.h"
 #include "empathy-event-manager.h"
 #include "empathy-ft-manager.h"
+#include "empathy-geometry.h"
+#include "empathy-gsettings.h"
+#include "empathy-gsettings.h"
+#include "empathy-gtk-enum-types.h"
+#include "empathy-individual-dialogs.h"
+#include "empathy-log-window.h"
+#include "empathy-new-call-dialog.h"
+#include "empathy-new-chatroom-dialog.h"
+#include "empathy-new-message-dialog.h"
+#include "empathy-preferences.h"
+#include "empathy-presence-chooser.h"
+#include "empathy-presence-manager.h"
+#include "empathy-request-util.h"
+#include "empathy-roster-model-manager.h"
+#include "empathy-roster-view.h"
+#include "empathy-status-presets.h"
+#include "empathy-theme-manager.h"
+#include "empathy-theme-manager.h"
+#include "empathy-ui-utils.h"
+#include "empathy-utils.h"
 
 #define DEBUG_FLAG EMPATHY_DEBUG_OTHER
-#include <libempathy/empathy-debug.h>
+#include "empathy-debug.h"
 
 /* Flashing delay for icons (milliseconds). */
 #define FLASH_TIMEOUT 500
@@ -103,6 +93,8 @@ G_DEFINE_TYPE (EmpathyRosterWindow, empathy_roster_window, GTK_TYPE_APPLICATION_
 struct _EmpathyRosterWindowPriv {
   EmpathyRosterView *view;
   TpAccountManager *account_manager;
+  EmpathyChatManager *chat_manager;
+  EmpathyThemeManager *theme_manager;
   EmpathyChatroomManager *chatroom_manager;
   EmpathyEventManager *event_manager;
   EmpathySoundManager *sound_mgr;
@@ -125,8 +117,11 @@ struct _EmpathyRosterWindowPriv {
   GtkWidget *no_entry_label;
   GtkWidget *button_account_settings;
   GtkWidget *button_online;
+  GtkWidget *button_show_offline;
+  GtkWidget *button_add_contact;
   GtkWidget *spinner_loading;
   GtkWidget *tooltip_widget;
+  GtkWidget *chat_window;
 
   GMenu *menumodel;
   GMenu *rooms_section;
@@ -342,6 +337,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,
@@ -360,16 +363,21 @@ 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
 event_activated_cb (EmpathyRosterView *self,
     FolksIndividual *individual,
+    EmpathyEvent *event,
     gpointer user_data)
 {
-  EmpathyEvent *event = user_data;
-
   empathy_event_activate (event);
+
+  /* Hide the search-bar upon an event activation */
+  hide_search_bar (EMPATHY_ROSTER_WINDOW (user_data));
 }
 
 static void
@@ -394,14 +402,56 @@ button_online_clicked_cb (GtkButton *button,
   g_object_unref (mgr);
 }
 
+static void
+button_show_offline_clicked_cb (GtkButton *button,
+    EmpathyRosterWindow *self)
+{
+  g_settings_set_boolean (self->priv->gsettings_ui,
+      EMPATHY_PREFS_UI_SHOW_OFFLINE, TRUE);
+}
+
+static void
+button_add_contact_clicked_cb (GtkButton *button,
+    EmpathyRosterWindow *self)
+{
+  empathy_new_individual_dialog_show (GTK_WINDOW (self));
+}
+
 typedef enum
 {
   PAGE_MESSAGE_FLAG_NONE = 0,
   PAGE_MESSAGE_FLAG_ACCOUNTS = 1 << 0,
   PAGE_MESSAGE_FLAG_SPINNER = 1 << 2,
   PAGE_MESSAGE_FLAG_ONLINE = 1 << 3,
+  PAGE_MESSAGE_FLAG_SHOW_OFFLINE = 1 << 4,
+  PAGE_MESSAGE_FLAG_ADD_CONTACT = 1 << 5,
 } PageMessageFlags;
 
+static gboolean
+can_add_contact (EmpathyRosterWindow *self)
+{
+  GList *accounts, *l;
+  gboolean result = FALSE;
+
+  accounts = tp_account_manager_dup_valid_accounts (
+      self->priv->account_manager);
+  for (l = accounts; l != NULL && !result; l = g_list_next (l))
+    {
+      TpAccount *account = TP_ACCOUNT (l->data);
+      TpConnection *conn;
+
+      conn = tp_account_get_connection (account);
+      if (conn == NULL)
+        continue;
+
+      if (tp_connection_get_can_change_contact_list (conn))
+        result = TRUE;
+    }
+
+  g_list_free_full (accounts, g_object_unref);
+  return result;
+}
+
 static void
 display_page_message (EmpathyRosterWindow *self,
     const gchar *msg,
@@ -430,6 +480,14 @@ display_page_message (EmpathyRosterWindow *self,
       (flags & PAGE_MESSAGE_FLAG_SPINNER) != 0);
   gtk_widget_set_visible (self->priv->button_online,
       (flags & PAGE_MESSAGE_FLAG_ONLINE) != 0);
+  gtk_widget_set_visible (self->priv->button_show_offline,
+      (flags & PAGE_MESSAGE_FLAG_SHOW_OFFLINE) != 0);
+  gtk_widget_set_visible (self->priv->button_add_contact,
+      (flags & PAGE_MESSAGE_FLAG_ADD_CONTACT) != 0);
+
+  if ((flags & PAGE_MESSAGE_FLAG_ADD_CONTACT) != 0)
+    gtk_widget_set_sensitive (self->priv->button_add_contact,
+        can_add_contact (self));
 
   gtk_notebook_set_current_page (GTK_NOTEBOOK (self->priv->notebook),
       PAGE_MESSAGE);
@@ -439,7 +497,7 @@ static void
 display_page_no_account (EmpathyRosterWindow *self)
 {
   display_page_message (self,
-      _("You need to setup an account to see contacts here."),
+      _("You need to set up an account to see contacts here."),
       PAGE_MESSAGE_FLAG_ACCOUNTS);
 }
 
@@ -560,6 +618,7 @@ roster_window_error_create_info_bar (EmpathyRosterWindow *self,
   label = gtk_label_new (message_markup);
   gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
   gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
+  gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END);
   gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
   gtk_widget_show (label);
 
@@ -605,6 +664,54 @@ roster_window_error_add_stock_button (GtkInfoBar *info_bar,
   gtk_info_bar_add_action_widget (info_bar, button, response_id);
 }
 
+#ifdef HAVE_UOA
+static const gchar *
+uoa_account_display_string (TpAccount *account)
+{
+  const gchar *service;
+
+  service = tp_account_get_service (account);
+
+  /* Use well known service name, if available */
+  if (!tp_strdiff (service, "windows-live"))
+    return _("Windows Live");
+  else if (!tp_strdiff (service, "google-talk"))
+    return _("Google Talk");
+  else if (!tp_strdiff (service, "facebook"))
+    return _("Facebook");
+
+  return tp_account_get_display_name (account);
+}
+
+static void
+roster_window_uoa_auth_error (EmpathyRosterWindow *self,
+    TpAccount *account)
+{
+  GtkWidget *info_bar;
+  GtkWidget *image;
+  GtkWidget *button;
+  gchar *str;
+
+  /* translators: %s is an account name like 'Facebook' or 'Google Talk' */
+  str = g_strdup_printf (_("%s account requires authorisation"),
+      uoa_account_display_string (account));
+
+  info_bar = roster_window_error_create_info_bar (self, account,
+      GTK_MESSAGE_OTHER, str);
+  g_free (str);
+
+  image = gtk_image_new_from_icon_name ("credentials-preferences",
+      GTK_ICON_SIZE_BUTTON);
+  button = gtk_button_new ();
+  gtk_button_set_image (GTK_BUTTON (button), image);
+  gtk_widget_set_tooltip_text (button, _("Online Accounts"));
+  gtk_widget_show (button);
+
+  gtk_info_bar_add_action_widget (GTK_INFO_BAR (info_bar), button,
+      ERROR_RESPONSE_EDIT);
+}
+#endif
+
 static void
 roster_window_error_display (EmpathyRosterWindow *self,
     TpAccount *account)
@@ -620,6 +727,17 @@ roster_window_error_display (EmpathyRosterWindow *self,
   if (user_requested)
     return;
 
+#ifdef HAVE_UOA
+  if (!tp_strdiff (TP_ERROR_STR_AUTHENTICATION_FAILED,
+       tp_account_get_detailed_error (account, NULL)) &&
+      !tp_strdiff (tp_account_get_storage_provider (account),
+       EMPATHY_UOA_PROVIDER))
+    {
+      roster_window_uoa_auth_error (self, account);
+      return;
+    }
+#endif
+
   str = g_markup_printf_escaped ("<b>%s</b>\n%s",
       tp_account_get_display_name (account), error_message);
 
@@ -633,7 +751,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
@@ -657,6 +775,7 @@ roster_window_update_status (EmpathyRosterWindow *self)
 {
   gboolean connected, connecting;
   GList *l;
+  GAction *action;
 
   connected = empathy_account_manager_get_accounts_connected (&connecting);
 
@@ -675,6 +794,10 @@ roster_window_update_status (EmpathyRosterWindow *self)
   /* Update widgets sensibility */
   for (l = self->priv->actions_connected; l; l = l->next)
     g_simple_action_set_enabled (l->data, connected);
+
+  action = g_action_map_lookup_action (G_ACTION_MAP (self), "chat_add_contact");
+  if (!can_add_contact (self))
+    g_simple_action_set_enabled (G_SIMPLE_ACTION (action), FALSE);
 }
 
 static void
@@ -916,6 +1039,8 @@ empathy_roster_window_finalize (GObject *window)
 
   g_object_unref (self->priv->call_observer);
   g_object_unref (self->priv->event_manager);
+  g_object_unref (self->priv->chat_manager);
+  g_object_unref (self->priv->theme_manager);
   g_object_unref (self->priv->chatroom_manager);
 
   g_object_unref (self->priv->gsettings_ui);
@@ -932,13 +1057,17 @@ empathy_roster_window_finalize (GObject *window)
 static gboolean
 roster_window_key_press_event_cb  (GtkWidget *window,
     GdkEventKey *event,
-    gpointer user_data)
+    EmpathyRosterWindow *self)
 {
   if (event->keyval == GDK_KEY_T
       && event->state & GDK_SHIFT_MASK
       && event->state & GDK_CONTROL_MASK)
     empathy_chat_manager_call_undo_closed_chat ();
 
+  if (event->keyval == GDK_KEY_f
+      && event->state & GDK_CONTROL_MASK)
+    gtk_widget_show (self->priv->search_bar);
+
   return FALSE;
 }
 
@@ -1152,19 +1281,43 @@ roster_window_favorite_chatroom_join (EmpathyChatroom *chatroom)
 }
 
 static void
-roster_window_favorite_chatroom_menu_activate_cb (GAction *action,
+roster_window_join_chatroom_menu_activate_cb (GSimpleAction *action,
     GVariant *parameter,
-    EmpathyChatroom *chatroom)
+    gpointer user_data)
 {
+  EmpathyRosterWindow *self = user_data;
+  const gchar *room, *path;
+  EmpathyClientFactory *factory;
+  TpAccount *account;
+  GError *error = NULL;
+  EmpathyChatroom *chatroom;
+
+  g_variant_get (parameter, "(&s&s)", &room, &path);
+
+  factory = empathy_client_factory_dup ();
+
+  account = tp_simple_client_factory_ensure_account (
+      TP_SIMPLE_CLIENT_FACTORY (factory), path, NULL, &error);
+  if (account == NULL)
+    {
+      DEBUG ("Failed to get account '%s': %s", path, error->message);
+      g_error_free (error);
+      goto out;
+    }
+
+  chatroom = empathy_chatroom_manager_find (self->priv->chatroom_manager,
+      account, room);
+  if (chatroom == NULL)
+    {
+      DEBUG ("Failed to get chatroom '%s' on '%s'",
+          room, path);
+      goto out;
+    }
+
   roster_window_favorite_chatroom_join (chatroom);
-}
 
-static gchar *
-dup_join_action_name (EmpathyChatroom *chatroom,
-    gboolean prefix)
-{
-  return g_strconcat (prefix ? "win." : "", "join-",
-      empathy_chatroom_get_name (chatroom), NULL);
+out:
+  g_object_unref (factory);
 }
 
 static void
@@ -1172,35 +1325,26 @@ roster_window_favorite_chatroom_menu_add (EmpathyRosterWindow *self,
     EmpathyChatroom *chatroom)
 {
   GMenuItem *item;
-  const gchar *name, *account_name;
-  gchar *label, *action_name;
-  GAction *action;
+  const gchar *name, *account_name, *account_path;
+  TpAccount *account;
+  gchar *label;
+
+  account = empathy_chatroom_get_account (chatroom);
 
   name = empathy_chatroom_get_name (chatroom);
-  account_name = tp_account_get_display_name (
-      empathy_chatroom_get_account (chatroom));
+  account_name = tp_account_get_display_name (account);
+  account_path = tp_proxy_get_object_path (account);
 
   label = g_strdup_printf ("%s (%s)", name, account_name);
-  action_name = dup_join_action_name (chatroom, FALSE);
-
-  action = (GAction *) g_simple_action_new (action_name, NULL);
-  g_free (action_name);
-
-  g_signal_connect (action, "activate",
-      G_CALLBACK (roster_window_favorite_chatroom_menu_activate_cb),
-      chatroom);
-
-  g_action_map_add_action (G_ACTION_MAP (self), action);
-
-  action_name = dup_join_action_name (chatroom, TRUE);
 
-  item = g_menu_item_new (label, action_name);
+  item = g_menu_item_new (label, NULL);
+  g_menu_item_set_action_and_target (item, "win.join", "(ss)",
+      name, account_path);
   g_menu_item_set_attribute (item, "room-name", "s", name);
+  g_menu_item_set_attribute (item, "account-path", "s", account_path);
   g_menu_append_item (self->priv->rooms_section, item);
 
   g_free (label);
-  g_free (action_name);
-  g_object_unref (action);
 }
 
 static void
@@ -1218,26 +1362,46 @@ roster_window_favorite_chatroom_menu_removed_cb (
     EmpathyRosterWindow *self)
 {
   GList *chatrooms;
-  gchar *act;
-  gint i;
+  guint i, n;
+  TpAccount *account;
+  const gchar *account_path;
 
-  act = dup_join_action_name (chatroom, TRUE);
+  account = empathy_chatroom_get_account (chatroom);
+  account_path = tp_proxy_get_object_path (account);
 
-  g_action_map_remove_action (G_ACTION_MAP (self), act);
+  n = g_menu_model_get_n_items (G_MENU_MODEL (self->priv->rooms_section));
 
-  for (i = 0; i < g_menu_model_get_n_items (
-        G_MENU_MODEL (self->priv->rooms_section)); i++)
+  for (i = 0; i < n; i++)
     {
-      const gchar *name;
+      gchar *tmp;
+
+      if (!g_menu_model_get_item_attribute (
+            G_MENU_MODEL (self->priv->rooms_section), i,
+            "room-name", "s", &tmp))
+        continue;
+
+      if (tp_strdiff (tmp, empathy_chatroom_get_name (chatroom)))
+        {
+          g_free (tmp);
+          continue;
+        }
+
+      g_free (tmp);
+
+      if (!g_menu_model_get_item_attribute (
+            G_MENU_MODEL (self->priv->rooms_section), i,
+            "account-path", "s", &tmp))
+        continue;
 
-      if (g_menu_model_get_item_attribute (
-            G_MENU_MODEL (self->priv->rooms_section), i, "room-name",
-            "s", &name)
-          && !tp_strdiff (name, empathy_chatroom_get_name (chatroom)))
+      if (tp_strdiff (tmp, account_path))
         {
-          g_menu_remove (self->priv->rooms_section, i);
-          break;
+          g_free (tmp);
+          continue;
         }
+
+      g_menu_remove (self->priv->rooms_section, i);
+      g_free (tmp);
+      break;
     }
 
   chatrooms = empathy_chatroom_manager_get_chatrooms (
@@ -1384,6 +1548,25 @@ roster_window_help_contents_cb (GSimpleAction *action,
   empathy_url_show (GTK_WIDGET (self), "help:empathy");
 }
 
+static void
+next_tab_cb (GSimpleAction *action,
+    GVariant *parameter,
+    gpointer user_data)
+{
+  EmpathyRosterWindow *self = user_data;
+  empathy_chat_window_next_tab (EMPATHY_CHAT_WINDOW (self->priv->chat_window));
+}
+
+static void
+prev_tab_cb (GSimpleAction *action,
+    GVariant *parameter,
+    gpointer user_data)
+{
+  EmpathyRosterWindow *self = user_data;
+  empathy_chat_window_prev_tab (EMPATHY_CHAT_WINDOW (self->priv->chat_window));
+}
+
+
 static gboolean
 roster_window_throbber_button_press_event_cb (GtkWidget *throbber,
     GdkEventButton *event,
@@ -1567,8 +1750,13 @@ set_notebook_page (EmpathyRosterWindow *self)
         }
       else
         {
-          display_page_message (self, _("No online contacts"),
-              PAGE_MESSAGE_FLAG_NONE);
+          if (g_settings_get_boolean (self->priv->gsettings_ui,
+                EMPATHY_PREFS_UI_SHOW_OFFLINE))
+            display_page_message (self, _("You haven't added any contacts yet"),
+                PAGE_MESSAGE_FLAG_ADD_CONTACT);
+          else
+            display_page_message (self, _("No online contacts"),
+                PAGE_MESSAGE_FLAG_SHOW_OFFLINE);
         }
       goto out;
     }
@@ -1635,6 +1823,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,
@@ -1663,6 +1859,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",
@@ -1720,12 +1918,20 @@ static GActionEntry menubar_entries[] = {
 
   { "room_join_new", roster_window_room_join_new_cb, NULL, NULL, NULL },
   { "room_join_favorites", roster_window_room_join_favorites_cb, NULL, NULL, NULL },
+  { "join", roster_window_join_chatroom_menu_activate_cb, "(ss)", NULL, NULL },
   { "room_manage_favorites", roster_window_room_manage_favorites_cb, NULL, NULL, NULL },
 
   { "help_contents", roster_window_help_contents_cb, NULL, NULL, NULL },
   { "help_about", roster_window_help_about_cb, NULL, NULL, NULL },
 };
 
+static GActionEntry app_entries[] =
+{
+  { "tab_next", next_tab_cb, NULL, NULL, NULL },
+  { "tab_prev", prev_tab_cb, NULL, NULL, NULL }
+};
+
+
 static void
 empathy_roster_window_set_property (GObject *object,
     guint property_id,
@@ -1827,8 +2033,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,
@@ -1845,7 +2061,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
@@ -1855,6 +2072,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);
@@ -1989,22 +2208,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;
 }
 
@@ -2086,13 +2305,24 @@ roster_window_most_available_presence_changed_cb (TpAccountManager *manager,
   set_notebook_page (self);
 }
 
+static void
+show_offline_changed_cb (GSettings *settings,
+    const gchar *key,
+    EmpathyRosterWindow *self)
+{
+  set_notebook_page (self);
+}
+
 static void
 empathy_roster_window_init (EmpathyRosterWindow *self)
 {
   GtkBuilder *gui;
   GtkWidget *sw;
   gchar *filename;
-  GtkWidget *search_vbox;
+  GtkWidget *header_bar;
+  GtkWidget *new_conversation_button;
+  GtkWidget *image;
+  GtkWidget *chat_vbox;
   guint i;
   EmpathyRosterModel *model;
 
@@ -2115,27 +2345,43 @@ 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,
+      "chat_vbox", &chat_vbox,
       "balance_vbox", &self->priv->balance_vbox,
       "errors_vbox", &self->priv->errors_vbox,
       "auth_vbox", &self->priv->auth_vbox,
-      "search_vbox", &search_vbox,
       "presence_toolbar", &self->priv->presence_toolbar,
       "notebook", &self->priv->notebook,
       "no_entry_label", &self->priv->no_entry_label,
       "roster_scrolledwindow", &sw,
       "button_account_settings", &self->priv->button_account_settings,
       "button_online", &self->priv->button_online,
+      "button_show_offline", &self->priv->button_show_offline,
+      "button_add_contact", &self->priv->button_add_contact,
       "spinner_loading", &self->priv->spinner_loading,
       NULL);
   g_free (filename);
 
+  header_bar = gtk_header_bar_new ();
+  gtk_header_bar_set_title (GTK_HEADER_BAR(header_bar), _("Conversations"));
+  gtk_header_bar_set_show_close_button (GTK_HEADER_BAR(header_bar), TRUE);
+
+  image = gtk_image_new_from_icon_name ("list-add-symbolic", GTK_ICON_SIZE_BUTTON);
+  new_conversation_button = gtk_button_new ();
+  g_signal_connect (new_conversation_button, "clicked",
+      G_CALLBACK (roster_window_chat_new_message_cb), self);
+  gtk_button_set_image (GTK_BUTTON (new_conversation_button), image);
+  gtk_widget_set_tooltip_text (new_conversation_button, _("New Conversation"));
+  gtk_window_set_titlebar (GTK_WINDOW (self), header_bar);
+  gtk_container_add (GTK_CONTAINER (header_bar), new_conversation_button);
+  gtk_widget_show_all (header_bar);
+
   gtk_container_add (GTK_CONTAINER (self), self->priv->main_vbox);
   gtk_widget_show (self->priv->main_vbox);
 
   g_signal_connect (self, "key-press-event",
-      G_CALLBACK (roster_window_key_press_event_cb), NULL);
+      G_CALLBACK (roster_window_key_press_event_cb), self);
 
   g_object_unref (gui);
 
@@ -2152,13 +2398,17 @@ empathy_roster_window_init (EmpathyRosterWindow *self)
   self->priv->status_changed_handlers = g_hash_table_new_full (g_direct_hash,
       g_direct_equal, NULL, NULL);
 
+  /* set up accelerators */
+  g_action_map_add_action_entries (G_ACTION_MAP (self),
+      app_entries, G_N_ELEMENTS (app_entries), self);
+
   /* set up menus */
   g_action_map_add_action_entries (G_ACTION_MAP (self),
       menubar_entries, G_N_ELEMENTS (menubar_entries), 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);
@@ -2204,12 +2454,12 @@ empathy_roster_window_init (EmpathyRosterWindow *self)
   self->priv->view = EMPATHY_ROSTER_VIEW (
       empathy_roster_view_new (model));
 
+
   g_object_unref (model);
 
   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);
@@ -2239,12 +2489,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));
-  gtk_box_pack_start (GTK_BOX (search_vbox), self->priv->search_bar,
-      FALSE, TRUE, 0);
+      TPAW_LIVE_SEARCH (self->priv->search_bar));
 
   g_signal_connect_swapped (self, "map",
       G_CALLBACK (gtk_widget_grab_focus), self->priv->view);
@@ -2256,9 +2504,16 @@ empathy_roster_window_init (EmpathyRosterWindow *self)
   /* Set window size. */
   empathy_geometry_bind (GTK_WINDOW (self), GEOMETRY_NAME);
 
+  self->priv->chat_window = GTK_WIDGET (empathy_chat_window_new ());
+  gtk_widget_show (GTK_WIDGET (self->priv->chat_window) );
+  gtk_box_pack_start (GTK_BOX (chat_vbox), self->priv->chat_window, TRUE, TRUE, 0);
+
   /* Enable event handling */
   self->priv->call_observer = empathy_call_observer_dup_singleton ();
   self->priv->event_manager = empathy_event_manager_dup_singleton ();
+  self->priv->chat_manager = empathy_chat_manager_dup_singleton ();
+
+  self->priv->theme_manager = empathy_theme_manager_dup_singleton ();
 
   tp_g_signal_connect_object (self->priv->event_manager, "event-added",
       G_CALLBACK (roster_window_event_added_cb), self, 0);
@@ -2275,12 +2530,11 @@ empathy_roster_window_init (EmpathyRosterWindow *self)
       "most-available-presence-changed",
       G_CALLBACK (roster_window_most_available_presence_changed_cb), self);
 
-  g_settings_bind (self->priv->gsettings_ui, EMPATHY_PREFS_UI_SHOW_OFFLINE,
-      self->priv->view, "show-offline",
-      G_SETTINGS_BIND_GET);
-  g_settings_bind (self->priv->gsettings_ui, EMPATHY_PREFS_UI_SHOW_GROUPS,
-      self->priv->view, "show-groups",
-      G_SETTINGS_BIND_GET);
+  g_object_set (G_OBJECT (self->priv->view),
+                  "show-offline", TRUE,
+                  "show-groups", FALSE,
+                  NULL);
+
   g_settings_bind (self->priv->gsettings_ui, "show-balance-in-roster",
       self->priv->balance_vbox, "visible",
       G_SETTINGS_BIND_GET);
@@ -2289,6 +2543,10 @@ empathy_roster_window_init (EmpathyRosterWindow *self)
       G_CALLBACK (button_account_settings_clicked_cb), self);
   g_signal_connect (self->priv->button_online, "clicked",
       G_CALLBACK (button_online_clicked_cb), self);
+  g_signal_connect (self->priv->button_show_offline, "clicked",
+      G_CALLBACK (button_show_offline_clicked_cb), self);
+  g_signal_connect (self->priv->button_add_contact, "clicked",
+      G_CALLBACK (button_add_contact_clicked_cb), self);
 }
 
 GtkWidget *