]> git.0d.be Git - empathy.git/commitdiff
Only enable the 'Edit' menu option when the CAN_ALIAS or CAN_GROUP are set
authorDavyd Madeley <davyd@madeley.id.au>
Sun, 26 Apr 2009 02:33:32 +0000 (10:33 +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-menu.c

index d187b0d7368d316619c3778efbdf5d4dca9b6f9e..fc096b2889bf297b2f0e4c8ab689434d95aac157 100644 (file)
@@ -1508,7 +1508,6 @@ empathy_contact_list_view_get_contact_menu (EmpathyContactListView *view)
        }
        flags = empathy_contact_list_view_get_flags (view);
 
-       /* FIXME: how to get the contact list flags in empathy_contact_menu_new() */
        menu = empathy_contact_menu_new (contact, priv->contact_features);
 
        /* Remove contact */
index 2bad5c9fe4baaee812c5d0e73744defc68a54741..f6d1ca154a33abbe60bebd8b85a98919c7ee30ae 100644 (file)
@@ -31,6 +31,7 @@
 #include <libempathy/empathy-dispatcher.h>
 #include <libempathy/empathy-utils.h>
 #include <libempathy/empathy-chatroom-manager.h>
+#include <libempathy/empathy-contact-manager.h>
 
 #include "empathy-contact-menu.h"
 #include "empathy-images.h"
@@ -306,17 +307,36 @@ contact_edit_menu_item_activate_cb (EmpathyContact *contact)
 GtkWidget *
 empathy_contact_edit_menu_item_new (EmpathyContact *contact)
 {
+       EmpathyContactManager *manager;
        GtkWidget *item;
        GtkWidget *image;
+       gboolean enable = FALSE;
 
        g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
 
+       if (empathy_contact_manager_initialized ()) {
+               TpConnection *connection;
+               EmpathyContactListFlags flags;
+
+               manager = empathy_contact_manager_dup_singleton ();
+               connection = empathy_contact_get_connection (contact);
+               flags = empathy_contact_manager_get_flags_for_connection (
+                               manager, connection);
+
+               enable = (flags & EMPATHY_CONTACT_LIST_CAN_ALIAS ||
+                         flags & EMPATHY_CONTACT_LIST_CAN_GROUP);
+
+               g_object_unref (manager);
+       }
+
        item = gtk_image_menu_item_new_with_mnemonic (_("_Edit"));
        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);
 
+       gtk_widget_set_sensitive (item, enable);
+
        g_signal_connect_swapped (item, "activate",
                                  G_CALLBACK (contact_edit_menu_item_activate_cb),
                                  contact);