]> git.0d.be Git - empathy.git/commitdiff
Look up flags to determine whether or not to display the 'Remove' item
authorDavyd Madeley <davyd@madeley.id.au>
Wed, 22 Apr 2009 06:26:49 +0000 (14:26 +0800)
committerDavyd Madeley <davyd@madeley.id.au>
Wed, 15 Jul 2009 10:12:15 +0000 (11:12 +0100)
libempathy-gtk/empathy-contact-list-view.c
libempathy-gtk/empathy-contact-list-view.h

index 9cebe1daaadcc7f1d5c3e2a685166ab1636a549e..fc096b2889bf297b2f0e4c8ab689434d95aac157 100644 (file)
@@ -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);
index e9c3457d8d430719202f89bfec73197dc3862421..6666cfbb71af6077614de4e56bed47e751ee6b5d 100644 (file)
@@ -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);