]> git.0d.be Git - empathy.git/blobdiff - src/empathy-debug-window.c
Update Simplified Chinese help translation.
[empathy.git] / src / empathy-debug-window.c
index ea7dcb902e6927999c32f230370ba0195c92e79e..3874fe8d08e7133fd7d26f7624fb755698428a6b 100644 (file)
@@ -32,6 +32,7 @@
 
 #include <libempathy-gtk/empathy-account-chooser.h>
 #include <libempathy-gtk/empathy-geometry.h>
+#include <libempathy-gtk/empathy-ui-utils.h>
 
 #include <telepathy-glib/dbus.h>
 #include <telepathy-glib/interfaces.h>
@@ -745,9 +746,6 @@ debug_window_list_connection_names_cb (const gchar * const *names,
   g_object_unref (dbus);
 }
 
-#define CM_WELL_KNOWN_NAME_PREFIX \
-    "org.freedesktop.Telepathy.ConnectionManager."
-
 static void
 debug_window_name_owner_changed_cb (TpDBusDaemon *proxy,
     const gchar *arg0,
@@ -758,77 +756,79 @@ debug_window_name_owner_changed_cb (TpDBusDaemon *proxy,
 {
   EmpathyDebugWindow *self = EMPATHY_DEBUG_WINDOW (user_data);
   EmpathyDebugWindowPriv *priv = GET_PRIV (user_data);
+  ServiceType type;
+  const gchar *name;
 
-  /* Wow, I hate all of this code... */
-  if (!g_str_has_prefix (arg0, CM_WELL_KNOWN_NAME_PREFIX))
-    return;
+  if (g_str_has_prefix (arg0, TP_CM_BUS_NAME_BASE))
+    {
+      type = SERVICE_TYPE_CM;
+      name = arg0 + strlen (TP_CM_BUS_NAME_BASE);
+    }
+  else if (g_str_has_prefix (arg0, TP_CLIENT_BUS_NAME_BASE))
+    {
+      type = SERVICE_TYPE_CLIENT;
+      name = arg0 + strlen (TP_CLIENT_BUS_NAME_BASE);
+    }
+  else
+    {
+      return;
+    }
 
   if (EMP_STR_EMPTY (arg1) && !EMP_STR_EMPTY (arg2))
     {
-      /* A connection manager joined -- because it's guaranteed
-       * that the CM just joined (because o.fd.Tp.CM.foo
-       * just joined), we don't need to check whether the unique
-       * name is in the CM model. Hooray.
-       */
-      const gchar *name = arg0 + strlen (CM_WELL_KNOWN_NAME_PREFIX);
+      gchar *display_name;
 
+      if (type == SERVICE_TYPE_CM)
+        display_name = get_cm_display_name (self, name);
+      else
+        display_name = g_strdup (name);
+
+      /* A service joined */
       if (!g_hash_table_lookup (priv->cache, name))
         {
           GtkTreeIter iter;
-          char *str;
-
-          DEBUG ("Adding new CM '%s' at %s.", name, arg2);
 
-          str = get_cm_display_name (self, name);
+          DEBUG ("Adding new service '%s' at %s.", name, arg2);
 
           gtk_list_store_append (priv->service_store, &iter);
           gtk_list_store_set (priv->service_store, &iter,
-              COL_NAME, str,
+              COL_NAME, display_name,
               COL_UNIQUE_NAME, arg2,
               -1);
-
-          g_free (str);
         }
       else
         {
-          /* a CM with the same name is already in the hash table,
+          /* a service with the same name is already in the hash table,
            * update it and set it as re-enabled in the model.
            */
           GtkTreeIter *iter = NULL;
 
           if (debug_window_service_is_in_model (user_data, name, &iter, TRUE))
             {
-              char *str;
-
               DEBUG ("Refreshing CM '%s' at '%s'.", name, arg2);
 
-              str = get_cm_display_name (self, name);
-
               gtk_list_store_set (priv->service_store, iter,
-                  COL_NAME, str,
+                  COL_NAME, display_name,
                   COL_UNIQUE_NAME, arg2,
                   COL_GONE, FALSE,
                   -1);
               gtk_tree_iter_free (iter);
-              g_free (str);
 
               debug_window_service_chooser_changed_cb
                 (GTK_COMBO_BOX (priv->chooser), user_data);
             }
         }
+
+      g_free (display_name);
     }
   else if (!EMP_STR_EMPTY (arg1) && EMP_STR_EMPTY (arg2))
     {
-      /* A connection manager died -- because it's guaranteed
-       * that the CM itself just died (because o.fd.Tp.CM.foo
-       * just died), we don't need to check that it was already
-       * in the model.
-       */
+      /* A service died */
       GtkTreeIter *iter = NULL;
 
-      DEBUG ("Setting CM disabled from %s.", arg1);
+      DEBUG ("Setting service disabled from %s.", arg1);
 
-      /* set the CM as disabled in the model */
+      /* set the service as disabled in the model */
       if (debug_window_service_is_in_model (user_data, arg1, &iter, FALSE))
         {
           gtk_list_store_set (priv->service_store,
@@ -902,7 +902,7 @@ debug_window_fill_service_chooser (EmpathyDebugWindow *debug_window)
   /* add Mission Control */
   gtk_list_store_append (priv->service_store, &iter);
   gtk_list_store_set (priv->service_store, &iter,
-      COL_NAME, "misson-control",
+      COL_NAME, "mission-control",
       COL_UNIQUE_NAME, "org.freedesktop.Telepathy.MissionControl5",
       -1);
 
@@ -1027,7 +1027,7 @@ debug_window_show_menu (gpointer user_data)
   GtkWidget *menu, *item;
   GtkMenuShell *shell;
 
-  menu = gtk_menu_new ();
+  menu = empathy_context_menu_new (GTK_WIDGET (data->debug_window));
   shell = GTK_MENU_SHELL (menu);
 
   item = gtk_image_menu_item_new_from_stock (GTK_STOCK_COPY, NULL);
@@ -1040,8 +1040,6 @@ debug_window_show_menu (gpointer user_data)
 
   gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL,
      data->button, data->time);
-  g_object_ref_sink (menu);
-  g_object_unref (menu);
 
   g_slice_free (MenuPopupData, user_data);
 
@@ -1228,7 +1226,7 @@ debug_window_save_clicked_cb (GtkToolButton *tool_button,
       GTK_FILE_CHOOSER (file_chooser), TRUE);
 
   gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (file_chooser),
-      g_get_tmp_dir ());
+      g_get_home_dir ());
 
   name = get_active_service_name (debug_window);
 
@@ -1329,8 +1327,8 @@ debug_window_key_press_event_cb (GtkWidget *widget,
     GdkEventKey *event,
     gpointer user_data)
 {
-  if ((event->state & GDK_CONTROL_MASK && event->keyval == GDK_w)
-      || event->keyval == GDK_Escape)
+  if ((event->state & GDK_CONTROL_MASK && event->keyval == GDK_KEY_w)
+      || event->keyval == GDK_KEY_Escape)
     {
       gtk_widget_destroy (widget);
       return TRUE;
@@ -1409,12 +1407,14 @@ am_prepared_cb (GObject *am,
   gtk_toolbar_set_show_arrow (GTK_TOOLBAR (toolbar), TRUE);
   gtk_toolbar_set_icon_size (GTK_TOOLBAR (toolbar),
       GTK_ICON_SIZE_SMALL_TOOLBAR);
+  gtk_style_context_add_class (gtk_widget_get_style_context (toolbar),
+                              GTK_STYLE_CLASS_PRIMARY_TOOLBAR);
   gtk_widget_show (toolbar);
 
   gtk_box_pack_start (GTK_BOX (vbox), toolbar, FALSE, FALSE, 0);
 
   /* CM */
-  priv->chooser = gtk_combo_box_new_text ();
+  priv->chooser = gtk_combo_box_text_new ();
   priv->service_store = gtk_list_store_new (NUM_COLS, G_TYPE_STRING,
       G_TYPE_STRING, G_TYPE_BOOLEAN);
   gtk_combo_box_set_model (GTK_COMBO_BOX (priv->chooser),
@@ -1490,7 +1490,7 @@ am_prepared_cb (GObject *am,
   gtk_container_add (GTK_CONTAINER (priv->level_label), label);
   gtk_toolbar_insert (GTK_TOOLBAR (toolbar), priv->level_label, -1);
 
-  priv->level_filter = gtk_combo_box_new_text ();
+  priv->level_filter = gtk_combo_box_text_new ();
   gtk_widget_show (priv->level_filter);
 
   item = gtk_tool_item_new ();