]> git.0d.be Git - empathy.git/commitdiff
Add a remove option to delete a contact group. Fixes bug #459520 (David Turner).
authorXavier Claessens <xclaesse@src.gnome.org>
Tue, 1 Jan 2008 22:10:22 +0000 (22:10 +0000)
committerXavier Claessens <xclaesse@src.gnome.org>
Tue, 1 Jan 2008 22:10:22 +0000 (22:10 +0000)
svn path=/trunk/; revision=528

libempathy-gtk/empathy-contact-list-view.c
libempathy/empathy-contact-list.c
libempathy/empathy-contact-list.h
libempathy/empathy-contact-manager.c
libempathy/empathy-tp-contact-list.c

index 498d887213f2c6cdbdee9bed77bb2d20e19e644c..6e5ab85366c3067c7ee594c1f0e0c6dd4c10cf67 100644 (file)
@@ -261,6 +261,7 @@ static const gchar *ui_info =
        "  </popup>"
        "  <popup name='Group'>"
        "    <menuitem action='Rename'/>"
+       "    <menuitem action='Remove'/>"
        "  </popup>"
        "</ui>";
 
@@ -1426,6 +1427,12 @@ contact_list_view_action_cb (GtkAction             *action,
        }
        else if (group && strcmp (name, "Rename") == 0) {
        }
+       else if (group && strcmp (name, "Remove") == 0) {
+               EmpathyContactList *list;
+
+               list = empathy_contact_list_store_get_list_iface (priv->store);
+               empathy_contact_list_remove_group (list, group);
+       }
 
        g_free (group);
        if (contact) {
index 5632652670a4fa4fbf9baa81d5f4717072fd514a..5164ccf1a5ad1b7adb890c60338982c91defa526 100644 (file)
@@ -203,3 +203,15 @@ empathy_contact_list_rename_group (EmpathyContactList *list,
        }
 }
 
+void
+empathy_contact_list_remove_group (EmpathyContactList *list,
+                                  const gchar *group)
+{
+       g_return_if_fail (EMPATHY_IS_CONTACT_LIST (list));
+       g_return_if_fail (group != NULL);
+
+       if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->remove_group) {
+               EMPATHY_CONTACT_LIST_GET_IFACE (list)->remove_group (list, group);
+       }
+}
+
index 96ab79e98896b5985fe32d91a1da9a004936713a..35575e1127b84eec2c8ab63205ff1c4a08ef2bc5 100644 (file)
@@ -61,6 +61,8 @@ struct _EmpathyContactListIface {
        void             (*rename_group)      (EmpathyContactList *list,
                                               const gchar        *old_group,
                                               const gchar        *new_group);
+       void             (*remove_group)      (EmpathyContactList *list,
+                                              const gchar        *group);
 };
 
 GType    empathy_contact_list_get_type          (void) G_GNUC_CONST;
@@ -84,6 +86,8 @@ void     empathy_contact_list_remove_from_group (EmpathyContactList *list,
 void     empathy_contact_list_rename_group      (EmpathyContactList *list,
                                                 const gchar        *old_group,
                                                 const gchar        *new_group);
+void    empathy_contact_list_remove_group      (EmpathyContactList *list,
+                                                const gchar        *group);
 
 G_END_DECLS
 
index 219cf888607209e8e82c6198109bfaf402c6d65d..d862750482a80714a21873d0de50049f0923fc81 100644 (file)
@@ -482,6 +482,27 @@ contact_manager_rename_group (EmpathyContactList *manager,
                              &data);
 }
 
+static void contact_manager_remove_group_foreach (McAccount    *account,
+                                                 EmpathyTpContactList *list,
+                                                 const gchar *group)
+{
+       empathy_contact_list_remove_group (EMPATHY_CONTACT_LIST (list),
+                                          group);
+}
+
+static void
+contact_manager_remove_group (EmpathyContactList *manager,
+                             const gchar *group)
+{
+       EmpathyContactManagerPriv *priv = GET_PRIV (manager);
+       
+       g_return_if_fail (EMPATHY_IS_CONTACT_MANAGER (manager));
+
+       g_hash_table_foreach (priv->lists,
+                             (GHFunc) contact_manager_remove_group_foreach,
+                             (gpointer) group);
+}
+
 static void
 contact_manager_iface_init (EmpathyContactListIface *iface)
 {
@@ -494,5 +515,6 @@ contact_manager_iface_init (EmpathyContactListIface *iface)
        iface->add_to_group      = contact_manager_add_to_group;
        iface->remove_from_group = contact_manager_remove_from_group;
        iface->rename_group      = contact_manager_rename_group;
+       iface->remove_group      = contact_manager_remove_group;
 }
 
index 8051501778d01f7169f224daf1c55e82267573ea..2f366ff103dee9fb4a159afeab0bcd596901b833 100644 (file)
@@ -980,6 +980,33 @@ tp_contact_list_rename_group (EmpathyContactList *list,
        g_list_free (members);
 }
 
+static void
+tp_contact_list_remove_group (EmpathyContactList *list,
+                             const gchar *group)
+{
+       EmpathyTpGroup *tp_group;
+       GList          *members;
+
+       g_return_if_fail (EMPATHY_IS_TP_CONTACT_LIST (list));
+
+       tp_group = tp_contact_list_find_group (EMPATHY_TP_CONTACT_LIST (list),
+                                              group);
+       
+       if (!tp_group) {
+               return;
+       }
+
+       empathy_debug (DEBUG_DOMAIN, "remove group %s", group);
+
+       /* Remove all members of the group */
+       members = empathy_tp_group_get_members (tp_group);
+       empathy_tp_group_remove_members (tp_group, members, "");
+       empathy_tp_group_close (tp_group);
+
+       g_list_foreach (members, (GFunc) g_object_unref, NULL);
+       g_list_free (members);
+}
+
 static void
 tp_contact_list_iface_init (EmpathyContactListIface *iface)
 {
@@ -992,5 +1019,6 @@ tp_contact_list_iface_init (EmpathyContactListIface *iface)
        iface->add_to_group      = tp_contact_list_add_to_group;
        iface->remove_from_group = tp_contact_list_remove_from_group;
        iface->rename_group      = tp_contact_list_rename_group;
+       iface->remove_group      = tp_contact_list_remove_group;
 }