]> git.0d.be Git - empathy.git/blobdiff - libempathy-gtk/empathy-contact-menu.c
Merge remote-tracking branch 'jonny/ft'
[empathy.git] / libempathy-gtk / empathy-contact-menu.c
index 60e7052ea3711e7974ee177910c31afec838f94c..dd9ea5c1689212c124fca50f432a10fbda8aa9d1 100644 (file)
@@ -86,13 +86,6 @@ empathy_contact_menu_new (EmpathyContact             *contact,
                gtk_widget_show (item);
        }
 
-       /* Log */
-       if (features & EMPATHY_CONTACT_FEATURE_LOG) {
-               item = empathy_contact_log_menu_item_new (contact);
-               gtk_menu_shell_append (shell, item);
-               gtk_widget_show (item);
-       }
-
        /* Invite */
        item = empathy_contact_invite_menu_item_new (contact);
        gtk_menu_shell_append (shell, item);
@@ -114,8 +107,7 @@ empathy_contact_menu_new (EmpathyContact             *contact,
 
        /* Separator */
        if (features & (EMPATHY_CONTACT_FEATURE_EDIT |
-                       EMPATHY_CONTACT_FEATURE_INFO |
-                       EMPATHY_CONTACT_FEATURE_FAVOURITE)) {
+                       EMPATHY_CONTACT_FEATURE_INFO)) {
                item = gtk_separator_menu_item_new ();
                gtk_menu_shell_append (shell, item);
                gtk_widget_show (item);
@@ -128,16 +120,16 @@ empathy_contact_menu_new (EmpathyContact             *contact,
                gtk_widget_show (item);
        }
 
-       /* Info */
-       if (features & EMPATHY_CONTACT_FEATURE_INFO) {
-               item = empathy_contact_info_menu_item_new (contact);
+       /* Log */
+       if (features & EMPATHY_CONTACT_FEATURE_LOG) {
+               item = empathy_contact_log_menu_item_new (contact);
                gtk_menu_shell_append (shell, item);
                gtk_widget_show (item);
        }
 
-       /* Favorite checkbox */
-       if (features & EMPATHY_CONTACT_FEATURE_FAVOURITE) {
-               item = empathy_contact_favourite_menu_item_new (contact);
+       /* Info */
+       if (features & EMPATHY_CONTACT_FEATURE_INFO) {
+               item = empathy_contact_info_menu_item_new (contact);
                gtk_menu_shell_append (shell, item);
                gtk_widget_show (item);
        }
@@ -182,7 +174,6 @@ empathy_contact_add_menu_item_new (EmpathyContact *contact)
        TpConnection *connection;
        GList *l, *members;
        gboolean found = FALSE;
-       EmpathyContactListFlags flags;
 
        g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
 
@@ -193,12 +184,8 @@ empathy_contact_add_menu_item_new (EmpathyContact *contact)
        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_ADD)) {
+       if (!tp_connection_get_can_change_contact_list (connection))
                return NULL;
-       }
 
        members = empathy_contact_list_get_members (EMPATHY_CONTACT_LIST (manager));
        for (l = members; l; l = l->next) {
@@ -234,8 +221,8 @@ empathy_contact_block_menu_item_toggled (GtkCheckMenuItem *item,
                                         EmpathyContact   *contact)
 {
        static guint block_signal = 0;
-       EmpathyContactManager *manager;
        gboolean blocked, abusive;
+       TpContact *tp_contact;
 
        if (block_signal > 0)
                return;
@@ -260,10 +247,12 @@ empathy_contact_block_menu_item_toggled (GtkCheckMenuItem *item,
                        return;
        }
 
-       manager = empathy_contact_manager_dup_singleton ();
-       empathy_contact_list_set_blocked (EMPATHY_CONTACT_LIST (manager),
-                                         contact, blocked, abusive);
-       g_object_unref (manager);
+       tp_contact = empathy_contact_get_tp_contact (contact);
+
+       if (blocked)
+               tp_contact_block_async (tp_contact, abusive, NULL, NULL);
+       else
+               tp_contact_unblock_async (tp_contact, NULL, NULL);
 
        /* update the toggle with the blocked status */
        block_signal++;
@@ -275,34 +264,27 @@ static GtkWidget *
 empathy_contact_block_menu_item_new (EmpathyContact *contact)
 {
        GtkWidget *item;
-       EmpathyContactManager *manager;
        TpConnection *connection;
-       EmpathyContactListFlags flags;
-       gboolean blocked;
+       TpContact *tp_contact;
 
        g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
 
-       manager = empathy_contact_manager_dup_singleton ();
-
        if (!empathy_contact_manager_initialized ()) {
                return NULL;
        }
 
        connection = empathy_contact_get_connection (contact);
 
-       flags = empathy_contact_manager_get_flags_for_connection (manager,
-                       connection);
-
-       if (!(flags & EMPATHY_CONTACT_LIST_CAN_BLOCK)) {
+       if (!tp_proxy_has_interface_by_id (connection,
+               TP_IFACE_QUARK_CONNECTION_INTERFACE_CONTACT_BLOCKING))
                return NULL;
-       }
 
        item = gtk_check_menu_item_new_with_mnemonic (_("_Block Contact"));
-       blocked = empathy_contact_list_get_blocked (
-                       EMPATHY_CONTACT_LIST (manager),
-                       contact);
 
-       gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), blocked);
+       tp_contact = empathy_contact_get_tp_contact (contact);
+
+       gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item),
+                       tp_contact_is_blocked (tp_contact));
 
        g_signal_connect (item, "toggled",
                        G_CALLBACK (empathy_contact_block_menu_item_toggled),
@@ -497,46 +479,6 @@ empathy_contact_share_my_desktop_menu_item_new (EmpathyContact *contact)
        return item;
 }
 
-static void
-favourite_menu_item_toggled_cb (GtkCheckMenuItem *item,
-       EmpathyContact *contact)
-{
-       EmpathyContactManager *manager;
-       EmpathyContactList *list;
-
-       manager = empathy_contact_manager_dup_singleton ();
-       list = EMPATHY_CONTACT_LIST (manager);
-
-       if (gtk_check_menu_item_get_active (item)) {
-               empathy_contact_list_add_to_favourites (list, contact);
-       } else {
-               empathy_contact_list_remove_from_favourites (list, contact);
-       }
-
-       g_object_unref (manager);
-}
-
-GtkWidget *
-empathy_contact_favourite_menu_item_new (EmpathyContact *contact)
-{
-       GtkWidget *item;
-       EmpathyContactManager *manager;
-
-       item = gtk_check_menu_item_new_with_label (_("Favorite"));
-
-       manager = empathy_contact_manager_dup_singleton ();
-       gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item),
-               empathy_contact_list_is_favourite (EMPATHY_CONTACT_LIST (manager),
-                                                  contact));
-
-       g_signal_connect (item, "toggled",
-                         G_CALLBACK (favourite_menu_item_toggled_cb),
-                         contact);
-
-       g_object_unref (manager);
-       return item;
-}
-
 static void
 contact_info_menu_item_activate_cb (EmpathyContact *contact)
 {
@@ -573,7 +515,6 @@ 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;
@@ -582,17 +523,12 @@ empathy_contact_edit_menu_item_new (EmpathyContact *contact)
 
        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);
+               enable = (tp_connection_can_set_contact_alias (connection) ||
+                         tp_connection_get_group_storage (connection) !=
+                                        TP_CONTACT_METADATA_STORAGE_TYPE_NONE);
        }
 
        item = gtk_image_menu_item_new_with_mnemonic (