aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilip Withnall <philip.withnall@collabora.co.uk>2010-08-06 00:28:16 +0800
committerPhilip Withnall <philip.withnall@collabora.co.uk>2010-08-12 00:34:55 +0800
commitdd8b8fb6b503194aecec14b4f5f9186c253a46c6 (patch)
treeca5c9318330aca8be009685301aa87ab82852d41
parent9d23b85fc16e7bc4b83af2850fdd2e96909b09d9 (diff)
downloadgsoc2013-empathy-dd8b8fb6b503194aecec14b4f5f9186c253a46c6.tar
gsoc2013-empathy-dd8b8fb6b503194aecec14b4f5f9186c253a46c6.tar.gz
gsoc2013-empathy-dd8b8fb6b503194aecec14b4f5f9186c253a46c6.tar.bz2
gsoc2013-empathy-dd8b8fb6b503194aecec14b4f5f9186c253a46c6.tar.lz
gsoc2013-empathy-dd8b8fb6b503194aecec14b4f5f9186c253a46c6.tar.xz
gsoc2013-empathy-dd8b8fb6b503194aecec14b4f5f9186c253a46c6.tar.zst
gsoc2013-empathy-dd8b8fb6b503194aecec14b4f5f9186c253a46c6.zip
Add EmpathyLinkingDialog
A dialogue which uses EmpathyIndividualLinker to allow linking of Individuals, accessible by a "Link" entry in the contacts' context menu.
-rw-r--r--libempathy-gtk/Makefile.am2
-rw-r--r--libempathy-gtk/empathy-individual-menu.c39
-rw-r--r--libempathy-gtk/empathy-individual-menu.h4
-rw-r--r--libempathy-gtk/empathy-linking-dialog.c175
-rw-r--r--libempathy-gtk/empathy-linking-dialog.h61
-rw-r--r--po/POTFILES.in1
6 files changed, 280 insertions, 2 deletions
diff --git a/libempathy-gtk/Makefile.am b/libempathy-gtk/Makefile.am
index c55f32ac6..fea658c0d 100644
--- a/libempathy-gtk/Makefile.am
+++ b/libempathy-gtk/Makefile.am
@@ -47,6 +47,7 @@ libempathy_gtk_handwritten_source = \
empathy-contact-list-store.c \
empathy-contact-list-view.c \
empathy-contact-menu.c \
+ empathy-linking-dialog.c \
empathy-live-search.c \
empathy-contact-selector.c \
empathy-contact-selector-dialog.c \
@@ -101,6 +102,7 @@ libempathy_gtk_headers = \
empathy-contact-list-store.h \
empathy-contact-list-view.h \
empathy-contact-menu.h \
+ empathy-linking-dialog.h \
empathy-live-search.h \
empathy-contact-selector.h \
empathy-contact-selector-dialog.h \
diff --git a/libempathy-gtk/empathy-individual-menu.c b/libempathy-gtk/empathy-individual-menu.c
index 092208b61..8f8c5e459 100644
--- a/libempathy-gtk/empathy-individual-menu.c
+++ b/libempathy-gtk/empathy-individual-menu.c
@@ -43,6 +43,7 @@
#include "empathy-individual-dialogs.h"
#include "empathy-ui-utils.h"
#include "empathy-share-my-desktop.h"
+#include "empathy-linking-dialog.h"
GtkWidget *
empathy_individual_menu_new (FolksIndividual *individual,
@@ -120,7 +121,8 @@ empathy_individual_menu_new (FolksIndividual *individual,
/* Separator */
if (features & (EMPATHY_INDIVIDUAL_FEATURE_EDIT |
EMPATHY_INDIVIDUAL_FEATURE_INFO |
- EMPATHY_INDIVIDUAL_FEATURE_FAVOURITE))
+ EMPATHY_INDIVIDUAL_FEATURE_FAVOURITE |
+ EMPATHY_INDIVIDUAL_FEATURE_LINK))
{
item = gtk_separator_menu_item_new ();
gtk_menu_shell_append (shell, item);
@@ -135,6 +137,14 @@ empathy_individual_menu_new (FolksIndividual *individual,
gtk_widget_show (item);
}
+ /* Link */
+ if (features & EMPATHY_INDIVIDUAL_FEATURE_LINK)
+ {
+ item = empathy_individual_link_menu_item_new (individual);
+ gtk_menu_shell_append (shell, item);
+ gtk_widget_show (item);
+ }
+
/* Info */
if (features & EMPATHY_INDIVIDUAL_FEATURE_INFO)
{
@@ -610,6 +620,33 @@ empathy_individual_edit_menu_item_new (FolksIndividual *individual)
return item;
}
+static void
+individual_link_menu_item_activate_cb (FolksIndividual *individual)
+{
+ empathy_linking_dialog_show (individual, NULL);
+}
+
+GtkWidget *
+empathy_individual_link_menu_item_new (FolksIndividual *individual)
+{
+ GtkWidget *item;
+ /*GtkWidget *image;*/
+
+ g_return_val_if_fail (FOLKS_IS_INDIVIDUAL (individual), NULL);
+
+ item = gtk_image_menu_item_new_with_mnemonic (
+ C_("Link individual (contextual menu)", "_Link"));
+ /* TODO */
+ /*image = gtk_image_new_from_icon_name (GTK_STOCK_EDIT, GTK_ICON_SIZE_MENU);
+ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
+ gtk_widget_show (image);*/
+
+ g_signal_connect_swapped (item, "activate",
+ G_CALLBACK (individual_link_menu_item_activate_cb), individual);
+
+ return item;
+}
+
typedef struct
{
FolksIndividual *individual;
diff --git a/libempathy-gtk/empathy-individual-menu.h b/libempathy-gtk/empathy-individual-menu.h
index 37b93ea4b..1c0d8318d 100644
--- a/libempathy-gtk/empathy-individual-menu.h
+++ b/libempathy-gtk/empathy-individual-menu.h
@@ -35,7 +35,8 @@ typedef enum {
EMPATHY_INDIVIDUAL_FEATURE_EDIT = 1 << 3,
EMPATHY_INDIVIDUAL_FEATURE_INFO = 1 << 4,
EMPATHY_INDIVIDUAL_FEATURE_FAVOURITE = 1 << 5,
- EMPATHY_INDIVIDUAL_FEATURE_ALL = (1 << 6) - 1,
+ EMPATHY_INDIVIDUAL_FEATURE_LINK = 1 << 6,
+ EMPATHY_INDIVIDUAL_FEATURE_ALL = (1 << 7) - 1,
} EmpathyIndividualFeatureFlags;
GtkWidget * empathy_individual_menu_new (FolksIndividual *individual,
@@ -49,6 +50,7 @@ GtkWidget * empathy_individual_video_call_menu_item_new (
GtkWidget * empathy_individual_log_menu_item_new (FolksIndividual *individual);
GtkWidget * empathy_individual_info_menu_item_new (FolksIndividual *individual);
GtkWidget * empathy_individual_edit_menu_item_new (FolksIndividual *individual);
+GtkWidget * empathy_individual_link_menu_item_new (FolksIndividual *individual);
GtkWidget * empathy_individual_invite_menu_item_new (
FolksIndividual *individual);
GtkWidget * empathy_individual_file_transfer_menu_item_new (
diff --git a/libempathy-gtk/empathy-linking-dialog.c b/libempathy-gtk/empathy-linking-dialog.c
new file mode 100644
index 000000000..52e0492c0
--- /dev/null
+++ b/libempathy-gtk/empathy-linking-dialog.c
@@ -0,0 +1,175 @@
+/*
+ * Copyright (C) 2010 Collabora Ltd.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Authors: Philip Withnall <philip.withnall@collabora.co.uk>
+ */
+
+#include <config.h>
+
+#include <string.h>
+#include <stdlib.h>
+
+#include <gtk/gtk.h>
+#include <glib/gi18n-lib.h>
+
+#include <libempathy/empathy-individual-manager.h>
+#include <libempathy/empathy-utils.h>
+
+#include "empathy-linking-dialog.h"
+#include "empathy-individual-linker.h"
+
+/**
+ * SECTION:empathy-individual-widget
+ * @title:EmpathyLinkingDialog
+ * @short_description: A dialog used to link individuals together
+ * @include: libempathy-empathy-linking-dialog.h
+ *
+ * #EmpathyLinkingDialog is a dialog which allows selection of individuals to
+ * link together, and preview of the newly linked individual. When submitted, it
+ * pushes the new links to backing storage.
+ */
+
+/**
+ * EmpathyLinkingDialog:
+ * @parent: parent object
+ *
+ * Widget which displays appropriate widgets with details about an individual,
+ * also allowing changing these details, if desired.
+ *
+ * Currently, it's just a thin wrapper around #EmpathyContactWidget, and
+ * displays the details of the first eligible persona found in the individual.
+ */
+
+static GtkWidget *linking_dialog = NULL;
+
+#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyLinkingDialog)
+
+typedef struct {
+ EmpathyIndividualLinker *linker; /* child widget */
+} EmpathyLinkingDialogPriv;
+
+G_DEFINE_TYPE (EmpathyLinkingDialog, empathy_linking_dialog,
+ GTK_TYPE_DIALOG);
+
+static void
+empathy_linking_dialog_class_init (EmpathyLinkingDialogClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ g_type_class_add_private (object_class, sizeof (EmpathyLinkingDialogPriv));
+}
+
+static void
+empathy_linking_dialog_init (EmpathyLinkingDialog *self)
+{
+ EmpathyLinkingDialogPriv *priv;
+ GtkDialog *dialog;
+ GtkWidget *button;
+ GtkBox *content_area;
+
+ priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
+ EMPATHY_TYPE_LINKING_DIALOG, EmpathyLinkingDialogPriv);
+ self->priv = priv;
+
+ dialog = GTK_DIALOG (self);
+
+ /* Set up dialog */
+ gtk_dialog_set_has_separator (dialog, FALSE);
+ gtk_window_set_resizable (GTK_WINDOW (self), TRUE);
+ gtk_window_set_title (GTK_WINDOW (self), _("Link Contacts"));
+ gtk_widget_set_size_request (GTK_WIDGET (self), 600, 500);
+
+ /* Cancel button */
+ button = gtk_button_new_with_label (GTK_STOCK_CANCEL);
+ gtk_button_set_use_stock (GTK_BUTTON (button), TRUE);
+ gtk_dialog_add_action_widget (dialog, button, GTK_RESPONSE_CANCEL);
+ gtk_widget_show (button);
+
+ /* Add button */
+ button = gtk_button_new_with_mnemonic (_("_Link"));
+ gtk_dialog_add_action_widget (dialog, button, GTK_RESPONSE_OK);
+ gtk_widget_show (button);
+
+ /* Linker widget */
+ priv->linker =
+ EMPATHY_INDIVIDUAL_LINKER (empathy_individual_linker_new (NULL));
+ gtk_container_set_border_width (GTK_CONTAINER (priv->linker), 8);
+ content_area = GTK_BOX (gtk_dialog_get_content_area (dialog));
+ gtk_box_pack_start (content_area, GTK_WIDGET (priv->linker), TRUE, TRUE, 0);
+ gtk_widget_show (GTK_WIDGET (priv->linker));
+}
+
+static void
+linking_response_cb (EmpathyLinkingDialog *self,
+ gint response,
+ gpointer user_data)
+{
+ EmpathyLinkingDialogPriv *priv = GET_PRIV (self);
+
+ if (response == GTK_RESPONSE_OK) {
+ EmpathyIndividualManager *manager;
+ GList *personas;
+
+ manager = empathy_individual_manager_dup_singleton ();
+
+ personas = empathy_individual_linker_get_linked_personas (priv->linker);
+ empathy_individual_manager_link_personas (manager, personas);
+
+ g_object_unref (manager);
+ }
+
+ linking_dialog = NULL;
+ gtk_widget_destroy (GTK_WIDGET (self));
+}
+
+/**
+ * empathy_linking_dialog_show:
+ * @individual: the #FolksIndividual to start linking against
+ * @parent: a parent window for the dialogue, or %NULL
+ *
+ * Create and show the linking dialogue, with @individual selected as the
+ * individual to link to. If the dialogue is already being shown, raise it and
+ * reset it so the start individual is @individual.
+ *
+ * Return value: the linking dialog
+ */
+GtkWidget *
+empathy_linking_dialog_show (FolksIndividual *individual,
+ GtkWindow *parent)
+{
+ EmpathyLinkingDialogPriv *priv;
+
+ /* Create the dialogue if it doesn't exist */
+ if (linking_dialog == NULL)
+ {
+ linking_dialog = GTK_WIDGET (g_object_new (EMPATHY_TYPE_LINKING_DIALOG,
+ NULL));
+
+ g_signal_connect (linking_dialog, "response",
+ (GCallback) linking_response_cb, NULL);
+ }
+
+ priv = GET_PRIV (linking_dialog);
+
+ if (parent != NULL)
+ gtk_window_set_transient_for (GTK_WINDOW (linking_dialog), parent);
+
+ empathy_individual_linker_set_start_individual (priv->linker, individual);
+
+ gtk_window_present (GTK_WINDOW (linking_dialog));
+
+ return linking_dialog;
+}
diff --git a/libempathy-gtk/empathy-linking-dialog.h b/libempathy-gtk/empathy-linking-dialog.h
new file mode 100644
index 000000000..912a3ce4d
--- /dev/null
+++ b/libempathy-gtk/empathy-linking-dialog.h
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2010 Collabora Ltd.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Authors: Philip Withnall <philip.withnall@collabora.co.uk>
+ */
+
+#ifndef __EMPATHY_LINKING_DIALOG_H__
+#define __EMPATHY_LINKING_DIALOG_H__
+
+#include <gtk/gtk.h>
+
+#include <folks/folks.h>
+
+G_BEGIN_DECLS
+
+#define EMPATHY_TYPE_LINKING_DIALOG (empathy_linking_dialog_get_type ())
+#define EMPATHY_LINKING_DIALOG(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), \
+ EMPATHY_TYPE_LINKING_DIALOG, EmpathyLinkingDialog))
+#define EMPATHY_LINKING_DIALOG_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), \
+ EMPATHY_TYPE_LINKING_DIALOG, EmpathyLinkingDialogClass))
+#define EMPATHY_IS_LINKING_DIALOG(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), \
+ EMPATHY_TYPE_LINKING_DIALOG))
+#define EMPATHY_IS_LINKING_DIALOG_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), \
+ EMPATHY_TYPE_LINKING_DIALOG))
+#define EMPATHY_LINKING_DIALOG_GET_CLASS(o) ( \
+ G_TYPE_INSTANCE_GET_CLASS ((o), EMPATHY_TYPE_LINKING_DIALOG, \
+ EmpathyLinkingDialogClass))
+
+typedef struct {
+ GtkDialog parent;
+
+ /*<private>*/
+ gpointer priv;
+} EmpathyLinkingDialog;
+
+typedef struct {
+ GtkDialogClass parent_class;
+} EmpathyLinkingDialogClass;
+
+GType empathy_linking_dialog_get_type (void) G_GNUC_CONST;
+
+GtkWidget * empathy_linking_dialog_show (FolksIndividual *individual,
+ GtkWindow *parent);
+
+G_END_DECLS
+
+#endif /* __EMPATHY_LINKING_DIALOG_H__ */
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 8e0448635..209c8e547 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -42,6 +42,7 @@ libempathy-gtk/empathy-individual-linker.c
libempathy-gtk/empathy-individual-menu.c
libempathy-gtk/empathy-individual-view.c
libempathy-gtk/empathy-irc-network-dialog.c
+libempathy-gtk/empathy-linking-dialog.c
libempathy-gtk/empathy-log-window.c
[type: gettext/glade]libempathy-gtk/empathy-log-window.ui
[type: gettext/glade]libempathy-gtk/empathy-contact-selector-dialog.ui