diff options
author | Philip Withnall <philip.withnall@collabora.co.uk> | 2010-09-01 17:42:00 +0800 |
---|---|---|
committer | Philip Withnall <philip.withnall@collabora.co.uk> | 2010-09-06 18:08:12 +0800 |
commit | d7c3afd92a4851669316aeb352235643002004e7 (patch) | |
tree | 1da6530f5b16cd072d167c06c11ab44c5ba40650 /libempathy-gtk/empathy-linking-dialog.c | |
parent | ee0ed7f28d8a567675d434e6d9b8d13789b72292 (diff) | |
download | gsoc2013-empathy-d7c3afd92a4851669316aeb352235643002004e7.tar gsoc2013-empathy-d7c3afd92a4851669316aeb352235643002004e7.tar.gz gsoc2013-empathy-d7c3afd92a4851669316aeb352235643002004e7.tar.bz2 gsoc2013-empathy-d7c3afd92a4851669316aeb352235643002004e7.tar.lz gsoc2013-empathy-d7c3afd92a4851669316aeb352235643002004e7.tar.xz gsoc2013-empathy-d7c3afd92a4851669316aeb352235643002004e7.tar.zst gsoc2013-empathy-d7c3afd92a4851669316aeb352235643002004e7.zip |
Move the “Unlink” button from the Edit dialogue to the linking dialogue
This is a more logical place for it, making unlinking more discoverable.
Helps: bgo#628376
Diffstat (limited to 'libempathy-gtk/empathy-linking-dialog.c')
-rw-r--r-- | libempathy-gtk/empathy-linking-dialog.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/libempathy-gtk/empathy-linking-dialog.c b/libempathy-gtk/empathy-linking-dialog.c index 4d80b659f..1ab58abb1 100644 --- a/libempathy-gtk/empathy-linking-dialog.c +++ b/libempathy-gtk/empathy-linking-dialog.c @@ -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); @@ -154,6 +166,19 @@ linking_response_cb (EmpathyLinkingDialog *self, 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); + } linking_dialog = NULL; gtk_widget_destroy (GTK_WIDGET (self)); @@ -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; |