aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDanielle Madeley <danielle.madeley@collabora.co.uk>2011-02-09 10:05:20 +0800
committerDanielle Madeley <danielle.madeley@collabora.co.uk>2011-02-09 10:05:20 +0800
commit317493d0a14718d5f1df6fb8738743146b69388e (patch)
treeb13b3f78d89c03e5f6a7a324f1bd37e331cade01
parent61572ce5a33a31ec2d36ac676384a7a6d246d7b4 (diff)
downloadgsoc2013-empathy-317493d0a14718d5f1df6fb8738743146b69388e.tar
gsoc2013-empathy-317493d0a14718d5f1df6fb8738743146b69388e.tar.gz
gsoc2013-empathy-317493d0a14718d5f1df6fb8738743146b69388e.tar.bz2
gsoc2013-empathy-317493d0a14718d5f1df6fb8738743146b69388e.tar.lz
gsoc2013-empathy-317493d0a14718d5f1df6fb8738743146b69388e.tar.xz
gsoc2013-empathy-317493d0a14718d5f1df6fb8738743146b69388e.tar.zst
gsoc2013-empathy-317493d0a14718d5f1df6fb8738743146b69388e.zip
Add 'Block Contact' to empathy-contact-menu
-rw-r--r--libempathy-gtk/empathy-chat.c3
-rw-r--r--libempathy-gtk/empathy-contact-menu.c71
-rw-r--r--libempathy-gtk/empathy-contact-menu.h3
3 files changed, 75 insertions, 2 deletions
diff --git a/libempathy-gtk/empathy-chat.c b/libempathy-gtk/empathy-chat.c
index 550f2a709..f9c5e4272 100644
--- a/libempathy-gtk/empathy-chat.c
+++ b/libempathy-gtk/empathy-chat.c
@@ -3171,7 +3171,8 @@ empathy_chat_get_contact_menu (EmpathyChat *chat)
menu = empathy_contact_menu_new (priv->remote_contact,
EMPATHY_CONTACT_FEATURE_CALL |
EMPATHY_CONTACT_FEATURE_LOG |
- EMPATHY_CONTACT_FEATURE_INFO);
+ EMPATHY_CONTACT_FEATURE_INFO |
+ EMPATHY_CONTACT_FEATURE_BLOCK);
}
else if (priv->contact_list_view) {
EmpathyContactListView *view;
diff --git a/libempathy-gtk/empathy-contact-menu.c b/libempathy-gtk/empathy-contact-menu.c
index c7fd19b09..da5d61a8c 100644
--- a/libempathy-gtk/empathy-contact-menu.c
+++ b/libempathy-gtk/empathy-contact-menu.c
@@ -41,6 +41,8 @@
#include "empathy-ui-utils.h"
#include "empathy-share-my-desktop.h"
+static GtkWidget *empathy_contact_block_menu_item_new (EmpathyContact *);
+
GtkWidget *
empathy_contact_menu_new (EmpathyContact *contact,
EmpathyContactFeatureFlags features)
@@ -138,6 +140,19 @@ empathy_contact_menu_new (EmpathyContact *contact,
gtk_widget_show (item);
}
+ /* Separator & Block */
+ if (features & EMPATHY_CONTACT_FEATURE_BLOCK &&
+ (item = empathy_contact_block_menu_item_new (contact)) != NULL) {
+ GtkWidget *sep;
+
+ sep = gtk_separator_menu_item_new ();
+ gtk_menu_shell_append (shell, sep);
+ gtk_widget_show (sep);
+
+ gtk_menu_shell_append (shell, item);
+ gtk_widget_show (item);
+ }
+
return menu;
}
@@ -213,6 +228,62 @@ empathy_contact_add_menu_item_new (EmpathyContact *contact)
}
static void
+empathy_contact_block_menu_item_toggled (GtkCheckMenuItem *item,
+ EmpathyContact *contact)
+{
+ EmpathyContactManager *manager;
+ gboolean blocked;
+
+ manager = empathy_contact_manager_dup_singleton ();
+ blocked = gtk_check_menu_item_get_active (item);
+
+ empathy_contact_list_set_blocked (EMPATHY_CONTACT_LIST (manager),
+ contact, blocked);
+
+ g_object_unref (manager);
+}
+
+static GtkWidget *
+empathy_contact_block_menu_item_new (EmpathyContact *contact)
+{
+ GtkWidget *item;
+ EmpathyContactManager *manager;
+ TpConnection *connection;
+ EmpathyContactListFlags flags;
+ gboolean blocked;
+
+ g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
+
+ if (!empathy_contact_manager_initialized ()) {
+ return NULL;
+ }
+
+ manager = empathy_contact_manager_dup_singleton ();
+ connection = empathy_contact_get_connection (contact);
+
+ flags = empathy_contact_manager_get_flags_for_connection (manager,
+ connection);
+
+ if (!(flags & EMPATHY_CONTACT_LIST_CAN_BLOCK)) {
+ return NULL;
+ }
+
+ item = gtk_check_menu_item_new_with_mnemonic (_("_Block Contact"));
+ /* FIXME: this doesn't always get updated immediately */
+ blocked = empathy_contact_list_get_blocked (
+ EMPATHY_CONTACT_LIST (manager),
+ contact);
+
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), blocked);
+
+ g_signal_connect (item, "toggled",
+ G_CALLBACK (empathy_contact_block_menu_item_toggled),
+ contact);
+
+ return item;
+}
+
+static void
empathy_contact_chat_menu_item_activated (GtkMenuItem *item,
EmpathyContact *contact)
{
diff --git a/libempathy-gtk/empathy-contact-menu.h b/libempathy-gtk/empathy-contact-menu.h
index 4c6d62f9d..d7248da9e 100644
--- a/libempathy-gtk/empathy-contact-menu.h
+++ b/libempathy-gtk/empathy-contact-menu.h
@@ -36,7 +36,8 @@ typedef enum {
EMPATHY_CONTACT_FEATURE_EDIT = 1 << 3,
EMPATHY_CONTACT_FEATURE_INFO = 1 << 4,
EMPATHY_CONTACT_FEATURE_FAVOURITE = 1 << 5,
- EMPATHY_CONTACT_FEATURE_ALL = (1 << 6) - 1,
+ EMPATHY_CONTACT_FEATURE_BLOCK = 1 << 6,
+ EMPATHY_CONTACT_FEATURE_ALL = (1 << 7) - 1,
} EmpathyContactFeatureFlags;
GtkWidget * empathy_contact_menu_new (EmpathyContact *contact,