aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy-gtk
diff options
context:
space:
mode:
authorDavyd Madeley <davyd@madeley.id.au>2009-04-22 14:26:49 +0800
committerDavyd Madeley <davyd@madeley.id.au>2009-07-15 18:12:15 +0800
commit8b3f04ee2d55d07d298c0183c355e9e41e868c2a (patch)
treeab8a7c8ee26696dfc47cf2bf3895ff9711d10c1c /libempathy-gtk
parent5b001b1130224ac3400dc8f3432cedf43eaf5d0c (diff)
downloadgsoc2013-empathy-8b3f04ee2d55d07d298c0183c355e9e41e868c2a.tar
gsoc2013-empathy-8b3f04ee2d55d07d298c0183c355e9e41e868c2a.tar.gz
gsoc2013-empathy-8b3f04ee2d55d07d298c0183c355e9e41e868c2a.tar.bz2
gsoc2013-empathy-8b3f04ee2d55d07d298c0183c355e9e41e868c2a.tar.lz
gsoc2013-empathy-8b3f04ee2d55d07d298c0183c355e9e41e868c2a.tar.xz
gsoc2013-empathy-8b3f04ee2d55d07d298c0183c355e9e41e868c2a.tar.zst
gsoc2013-empathy-8b3f04ee2d55d07d298c0183c355e9e41e868c2a.zip
Look up flags to determine whether or not to display the 'Remove' item
Diffstat (limited to 'libempathy-gtk')
-rw-r--r--libempathy-gtk/empathy-contact-list-view.c54
-rw-r--r--libempathy-gtk/empathy-contact-list-view.h1
2 files changed, 40 insertions, 15 deletions
diff --git a/libempathy-gtk/empathy-contact-list-view.c b/libempathy-gtk/empathy-contact-list-view.c
index 9cebe1daa..fc096b288 100644
--- a/libempathy-gtk/empathy-contact-list-view.c
+++ b/libempathy-gtk/empathy-contact-list-view.c
@@ -1302,6 +1302,31 @@ empathy_contact_list_view_dup_selected (EmpathyContactListView *view)
return contact;
}
+EmpathyContactListFlags
+empathy_contact_list_view_get_flags (EmpathyContactListView *view)
+{
+ EmpathyContactListViewPriv *priv;
+ GtkTreeSelection *selection;
+ GtkTreeIter iter;
+ GtkTreeModel *model;
+ EmpathyContactListFlags flags;
+
+ g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST_VIEW (view), 0);
+
+ priv = GET_PRIV (view);
+
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (view));
+ if (!gtk_tree_selection_get_selected (selection, &model, &iter)) {
+ return 0;
+ }
+
+ gtk_tree_model_get (model, &iter,
+ EMPATHY_CONTACT_LIST_STORE_COL_FLAGS, &flags,
+ -1);
+
+ return flags;
+}
+
gchar *
empathy_contact_list_view_get_selected_group (EmpathyContactListView *view)
{
@@ -1473,6 +1498,7 @@ empathy_contact_list_view_get_contact_menu (EmpathyContactListView *view)
GtkWidget *menu;
GtkWidget *item;
GtkWidget *image;
+ EmpathyContactListFlags flags;
g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST_VIEW (view), NULL);
@@ -1480,25 +1506,23 @@ empathy_contact_list_view_get_contact_menu (EmpathyContactListView *view)
if (!contact) {
return NULL;
}
+ flags = empathy_contact_list_view_get_flags (view);
menu = empathy_contact_menu_new (contact, priv->contact_features);
- if (!(priv->list_features & EMPATHY_CONTACT_LIST_FEATURE_CONTACT_REMOVE)) {
- g_object_unref (contact);
- return menu;
- }
-
- if (menu) {
- /* Separator */
- item = gtk_separator_menu_item_new ();
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
- gtk_widget_show (item);
- } else {
- menu = gtk_menu_new ();
- }
-
/* Remove contact */
- if (priv->list_features & EMPATHY_CONTACT_LIST_FEATURE_CONTACT_REMOVE) {
+ if (priv->list_features & EMPATHY_CONTACT_LIST_FEATURE_CONTACT_REMOVE &&
+ flags & EMPATHY_CONTACT_LIST_CAN_REMOVE) {
+ /* create the menu if required, or just add a separator */
+ if (!menu) {
+ menu = gtk_menu_new ();
+ } else {
+ item = gtk_separator_menu_item_new ();
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+ gtk_widget_show (item);
+ }
+
+ /* Remove */
item = gtk_image_menu_item_new_with_mnemonic (_("_Remove"));
image = gtk_image_new_from_icon_name (GTK_STOCK_REMOVE,
GTK_ICON_SIZE_MENU);
diff --git a/libempathy-gtk/empathy-contact-list-view.h b/libempathy-gtk/empathy-contact-list-view.h
index e9c3457d8..6666cfbb7 100644
--- a/libempathy-gtk/empathy-contact-list-view.h
+++ b/libempathy-gtk/empathy-contact-list-view.h
@@ -71,6 +71,7 @@ EmpathyContactListView * empathy_contact_list_view_new (Empathy
EmpathyContactListFeatureFlags list_features,
EmpathyContactFeatureFlags contact_features);
EmpathyContact * empathy_contact_list_view_dup_selected (EmpathyContactListView *view);
+EmpathyContactListFlags empathy_contact_list_view_get_flags (EmpathyContactListView *view);
gchar * empathy_contact_list_view_get_selected_group (EmpathyContactListView *view);
GtkWidget * empathy_contact_list_view_get_contact_menu (EmpathyContactListView *view);
GtkWidget * empathy_contact_list_view_get_group_menu (EmpathyContactListView *view);