]> git.0d.be Git - empathy.git/blobdiff - src/empathy.c
use a single window, with tabs
[empathy.git] / src / empathy.c
index d5149a3d2e2f954cda0a266e93707b5251fc6130..fa71d706640e778bc626cbbbbd7b2991778d7f0f 100644 (file)
@@ -24,6 +24,7 @@
 #include <glib/gstdio.h>
 #include <glib/gi18n.h>
 #include <libnotify/notify.h>
+#include <tp-account-widgets/tpaw-utils.h>
 
 #ifdef HAVE_LIBCHAMPLAIN
 #include <clutter-gtk/clutter-gtk.h>
@@ -31,6 +32,7 @@
 
 #include "empathy-accounts-common.h"
 #include "empathy-accounts-dialog.h"
+#include "empathy-bus-names.h"
 #include "empathy-chatroom-manager.h"
 #include "empathy-client-factory.h"
 #include "empathy-connection-aggregator.h"
@@ -49,8 +51,6 @@
 #define DEBUG_FLAG EMPATHY_DEBUG_OTHER
 #include "empathy-debug.h"
 
-#define EMPATHY_DBUS_NAME "org.gnome.Empathy"
-
 #define EMPATHY_TYPE_APP (empathy_app_get_type ())
 #define EMPATHY_APP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EMPATHY_TYPE_APP, EmpathyApp))
 #define EMPATHY_APP_CLASS(obj) (G_TYPE_CHECK_CLASS_CAST ((obj), EMPATHY_TYPE_APP, EmpathyAppClass))
@@ -317,6 +317,10 @@ empathy_app_activate (GApplication *app)
           "<Primary>h",
           "win." EMPATHY_PREFS_UI_SHOW_OFFLINE,
           NULL);
+      gtk_application_add_accelerator (GTK_APPLICATION (app),
+          "<Control>Page_Up", "win.tab_prev", NULL);
+      gtk_application_add_accelerator (GTK_APPLICATION (app),
+          "<Control>Page_Down", "win.tab_next", NULL);
 
       /* check if Shell is running */
       dbus = tp_dbus_daemon_dup (&error);
@@ -332,11 +336,18 @@ empathy_app_activate (GApplication *app)
     }
 
   if (self->show_preferences)
-    empathy_roster_window_show_preferences (
-        EMPATHY_ROSTER_WINDOW (self->window), self->preferences_tab);
+    {
+      empathy_roster_window_show_preferences (
+          EMPATHY_ROSTER_WINDOW (self->window),
+          tp_str_empty (self->preferences_tab) ? NULL : self->preferences_tab);
 
-  if (!self->start_hidden)
-    empathy_window_present (GTK_WINDOW (self->window));
+      self->show_preferences = FALSE;
+    }
+  else
+    {
+      if (!self->start_hidden)
+        tpaw_window_present (GTK_WINDOW (self->window));
+    }
 
   /* Display the accounts dialog if needed */
   tp_proxy_prepare_async (self->account_manager, NULL,
@@ -365,12 +376,26 @@ show_version_cb (const char *option_name,
     gpointer data,
     GError **error);
 
+static void
+open_preference_action_cb (GAction  *action,
+    GVariant *parameter,
+    gpointer  data)
+{
+  EmpathyApp *self = EMPATHY_APP (data);
+
+  self->show_preferences = TRUE;
+
+  g_free (self->preferences_tab);
+  self->preferences_tab = g_variant_dup_string (parameter, NULL);
+}
+
 static gboolean
 empathy_app_local_command_line (GApplication *app,
     gchar ***arguments,
     gint *exit_status)
 {
   EmpathyApp *self = (EmpathyApp *) app;
+  GSimpleAction *action;
   gint i;
   gchar **argv;
   gint argc = 0;
@@ -400,12 +425,17 @@ empathy_app_local_command_line (GApplication *app,
 
   if (!g_application_register (app, NULL, &error))
     {
-      g_warning("Impossible to register empathy: %s", error->message);
+      g_warning ("Impossible to register empathy: %s", error->message);
       g_clear_error (&error);
       *exit_status = EXIT_FAILURE;
       return retval;
     }
 
+  action = g_simple_action_new ("open-preferences", G_VARIANT_TYPE_STRING);
+  g_signal_connect (action, "activate", G_CALLBACK (open_preference_action_cb), app);
+  g_action_map_add_action (G_ACTION_MAP (app), G_ACTION (action));
+  g_object_unref (action);
+
   /* We create a group so that GOptionArgFuncs get the user data */
   group = g_option_group_new ("empathy", NULL, NULL, app, NULL);
   g_option_group_set_translation_domain (group, GETTEXT_PACKAGE);
@@ -440,6 +470,13 @@ empathy_app_local_command_line (GApplication *app,
       self->no_connect = no_connect;
       self->start_hidden = start_hidden;
 
+      if (self->show_preferences)
+        {
+          GVariant *parameter;
+          parameter = g_variant_new_string (self->preferences_tab ? self->preferences_tab : "");
+          g_action_group_activate_action (G_ACTION_GROUP (app), "open-preferences", parameter);
+        }
+
       g_application_activate (app);
     }
 
@@ -803,7 +840,7 @@ main (int argc, char *argv[])
   add_empathy_features ();
 
   app = g_object_new (EMPATHY_TYPE_APP,
-      "application-id", EMPATHY_DBUS_NAME,
+      "application-id", EMPATHY_CHAT_BUS_NAME,
       NULL);
 
   retval = g_application_run (G_APPLICATION (app), argc, argv);