]> git.0d.be Git - empathy.git/commitdiff
Move the “Unlink” button from the Edit dialogue to the linking dialogue
authorPhilip Withnall <philip.withnall@collabora.co.uk>
Wed, 1 Sep 2010 09:42:00 +0000 (10:42 +0100)
committerPhilip Withnall <philip.withnall@collabora.co.uk>
Mon, 6 Sep 2010 10:08:12 +0000 (11:08 +0100)
This is a more logical place for it, making unlinking more discoverable.
Helps: bgo#628376

libempathy-gtk/empathy-individual-edit-dialog.c
libempathy-gtk/empathy-linking-dialog.c

index 677a5340124c61c05bfb6d620ae6f13a05a4134e..3f5f35d452caf89ee0cf132d062efd59f0980b97 100644 (file)
@@ -30,7 +30,6 @@
 
 #include <telepathy-glib/util.h>
 #include <folks/folks.h>
-#include <folks/folks-telepathy.h>
 
 #include <libempathy/empathy-individual-manager.h>
 #include <libempathy/empathy-utils.h>
@@ -61,25 +60,11 @@ static void individual_edit_dialog_set_individual (
 G_DEFINE_TYPE (EmpathyIndividualEditDialog, empathy_individual_edit_dialog,
     GTK_TYPE_DIALOG);
 
-/* Fairly arbitrary response ID for the "Unlink" button */
-#define RESPONSE_UNLINK 5
-
 static void
 individual_dialogs_response_cb (GtkDialog *dialog,
     gint response,
     GList **dialogs)
 {
-  if (response == RESPONSE_UNLINK)
-    {
-      EmpathyIndividualEditDialogPriv *priv = GET_PRIV (dialog);
-      EmpathyIndividualManager *manager =
-          empathy_individual_manager_dup_singleton ();
-
-      empathy_individual_manager_unlink_individual (manager, priv->individual);
-
-      g_object_unref (manager);
-    }
-
   *dialogs = g_list_remove (*dialogs, dialog);
   gtk_widget_destroy (GTK_WIDGET (dialog));
 }
@@ -121,30 +106,6 @@ empathy_individual_edit_dialog_show (FolksIndividual *individual,
   gtk_widget_show (dialog);
 }
 
-static void
-set_unlink_button_sensitivity (EmpathyIndividualEditDialog *self)
-{
-  EmpathyIndividualEditDialogPriv *priv = GET_PRIV (self);
-  GList *personas, *l;
-  guint num_personas = 0;
-
-  /* Count how many Telepathy personas we have, to see whether we can
-   * unlink */
-  if (priv->individual != NULL)
-    {
-      personas = folks_individual_get_personas (priv->individual);
-      for (l = personas; l != NULL; l = l->next)
-        {
-          if (TPF_IS_PERSONA (l->data))
-            num_personas++;
-        }
-    }
-
-  /* Only make the "Unlink" button sensitive if we have enough personas */
-  gtk_dialog_set_response_sensitive (GTK_DIALOG (self), RESPONSE_UNLINK,
-      (num_personas > 1) ? TRUE : FALSE);
-}
-
 static void
 individual_removed_cb (FolksIndividual *individual,
     FolksIndividual *replacement_individual,
@@ -195,7 +156,6 @@ individual_edit_dialog_set_individual (
       /* Update the UI */
       empathy_individual_widget_set_individual (
           EMPATHY_INDIVIDUAL_WIDGET (priv->individual_widget), individual);
-      set_unlink_button_sensitivity (dialog);
     }
 }
 
@@ -275,7 +235,7 @@ static void
 empathy_individual_edit_dialog_init (
     EmpathyIndividualEditDialog *dialog)
 {
-  GtkWidget *button, *action_area;
+  GtkWidget *button;
   EmpathyIndividualEditDialogPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (
       dialog, EMPATHY_TYPE_INDIVIDUAL_EDIT_DIALOG,
       EmpathyIndividualEditDialogPriv);
@@ -297,17 +257,6 @@ empathy_individual_edit_dialog_init (
       GTK_DIALOG (dialog))), priv->individual_widget, TRUE, TRUE, 0);
   gtk_widget_show (priv->individual_widget);
 
-  /* Unlink button */
-  button = gtk_button_new_with_mnemonic (
-      C_("Unlink individual (button)", "_Unlink"));
-  gtk_dialog_add_action_widget (GTK_DIALOG (dialog), button, RESPONSE_UNLINK);
-
-  action_area = gtk_dialog_get_action_area (GTK_DIALOG (dialog));
-  gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (action_area), button,
-      TRUE);
-
-  gtk_widget_show (button);
-
   /* Close button */
   button = gtk_button_new_with_label (GTK_STOCK_CLOSE);
   gtk_button_set_use_stock (GTK_BUTTON (button), TRUE);
index 4d80b659f65c96e7535395ff113e256e99a7621f..1ab58abb1e10725e11ed2609d385d6c82b3c0334 100644 (file)
@@ -26,6 +26,9 @@
 #include <gtk/gtk.h>
 #include <glib/gi18n-lib.h>
 
+#include <folks/folks.h>
+#include <folks/folks-telepathy.h>
+
 #include <libempathy/empathy-individual-manager.h>
 #include <libempathy/empathy-utils.h>
 
@@ -56,6 +59,9 @@
 
 static GtkWidget *linking_dialog = NULL;
 
+/* Fairly arbitrary response ID for the "Unlink" button */
+#define RESPONSE_UNLINK 5
+
 #define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyLinkingDialog)
 
 typedef struct {
@@ -109,6 +115,12 @@ empathy_linking_dialog_init (EmpathyLinkingDialog *self)
   gtk_window_set_title (GTK_WINDOW (self), _("Link Contacts"));
   gtk_widget_set_size_request (GTK_WIDGET (self), 600, 500);
 
+  /* Unlink button */
+  button = gtk_button_new_with_mnemonic (
+      C_("Unlink individual (button)", "_Unlink"));
+  gtk_dialog_add_action_widget (dialog, button, RESPONSE_UNLINK);
+  gtk_widget_show (button);
+
   /* Cancel button */
   button = gtk_button_new_with_label (GTK_STOCK_CANCEL);
   gtk_button_set_use_stock (GTK_BUTTON (button), TRUE);
@@ -152,6 +164,19 @@ linking_response_cb (EmpathyLinkingDialog *self,
       personas = empathy_individual_linker_get_linked_personas (priv->linker);
       empathy_individual_manager_link_personas (manager, personas);
 
+      g_object_unref (manager);
+    }
+  else if (response == RESPONSE_UNLINK)
+    {
+      EmpathyIndividualManager *manager;
+      FolksIndividual *individual;
+
+      manager = empathy_individual_manager_dup_singleton ();
+      individual =
+          empathy_individual_linker_get_start_individual (priv->linker);
+
+      empathy_individual_manager_unlink_individual (manager, individual);
+
       g_object_unref (manager);
     }
 
@@ -175,6 +200,8 @@ empathy_linking_dialog_show (FolksIndividual *individual,
     GtkWindow *parent)
 {
   EmpathyLinkingDialogPriv *priv;
+  GList *personas, *l;
+  guint num_personas = 0;
 
   /* Create the dialogue if it doesn't exist */
   if (linking_dialog == NULL)
@@ -193,6 +220,19 @@ empathy_linking_dialog_show (FolksIndividual *individual,
 
   empathy_individual_linker_set_start_individual (priv->linker, individual);
 
+  /* Count how many Telepathy personas we have, to see whether we can
+   * unlink */
+  personas = folks_individual_get_personas (individual);
+  for (l = personas; l != NULL; l = l->next)
+    {
+      if (TPF_IS_PERSONA (l->data))
+        num_personas++;
+    }
+
+  /* Only make the "Unlink" button sensitive if we have enough personas */
+  gtk_dialog_set_response_sensitive (GTK_DIALOG (linking_dialog),
+      RESPONSE_UNLINK, (num_personas > 1) ? TRUE : FALSE);
+
   gtk_window_present (GTK_WINDOW (linking_dialog));
 
   return linking_dialog;