]> git.0d.be Git - empathy.git/commitdiff
Allow to set custom function for getting groups of a contact. Make
authorXavier Claessens <xclaesse@gmail.com>
Sun, 20 May 2007 10:26:38 +0000 (10:26 +0000)
committerXavier Claessens <xclaesse@src.gnome.org>
Sun, 20 May 2007 10:26:38 +0000 (10:26 +0000)
2007-05-20  Xavier Claessens  <xclaesse@gmail.com>

* libempathy-gtk/gossip-contact-list-store.c: Allow to set custom
function for getting groups of a contact. Make possible to have groups
for presence or role/affiliation in chatroom for example.
* libempathy-gtk/gossip-contact-list-store.h: Allow to set custom
function to handle DnD of contact. Useful when a custom function is set
for groups.
* src/empathy-chat-main.c: Minor fix.
* TODO:
* po/POTFILES.in: Updated.

svn path=/trunk/; revision=76

ChangeLog
TODO
libempathy-gtk/gossip-contact-list-store.c
libempathy-gtk/gossip-contact-list-store.h
po/POTFILES.in
src/empathy-chat-main.c

index 88a07a0f6c556c74ace556b2b1c70dc6d302cb91..18aa6a5785babba107337a200748632646229b85 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2007-05-20  Xavier Claessens  <xclaesse@gmail.com>
+
+       * libempathy-gtk/gossip-contact-list-store.c: Allow to set custom 
+       function for getting groups of a contact. Make possible to have groups
+       for presence or role/affiliation in chatroom for example.
+       * libempathy-gtk/gossip-contact-list-store.h: Allow to set custom
+       function to handle DnD of contact. Useful when a custom function is set
+       for groups.
+       * src/empathy-chat-main.c: Minor fix.
+       * TODO:
+       * po/POTFILES.in: Updated.
+
 2007-05-19  Xavier Claessens  <xclaesse@gmail.com>
 
        * libempathy-gtk/Makefile.am:
 2007-05-19  Xavier Claessens  <xclaesse@gmail.com>
 
        * libempathy-gtk/Makefile.am:
diff --git a/TODO b/TODO
index 1b78f283dec37061625e3242473fe8b6d487f346..da967a33103247835cf7850ecce9d73d47b03269 100644 (file)
--- a/TODO
+++ b/TODO
@@ -8,6 +8,8 @@ Things you can do if you want to help:
  - Filter channels before dispatching them. For example we need a GtkStatusIcon that blink when an event arrives (text/voip/ft channel) and tells the MC to dispatch the channel only when the user clicked the icon. Like in gossip. For that we need a filter DBus API in MC, not yet written.
  - Make use of NetworkManager to set the presence
  - Remove Quit option everywhere, empathy is a session service and shouldn't be leaved.
  - Filter channels before dispatching them. For example we need a GtkStatusIcon that blink when an event arrives (text/voip/ft channel) and tells the MC to dispatch the channel only when the user clicked the icon. Like in gossip. For that we need a filter DBus API in MC, not yet written.
  - Make use of NetworkManager to set the presence
  - Remove Quit option everywhere, empathy is a session service and shouldn't be leaved.
+ - Add sound events
+ - Import loggin system from gossip
  - Testing and Bugfixing.
 
 SoC projects:
  - Testing and Bugfixing.
 
 SoC projects:
index 1536262bbaa54662733531d4cd2d323d702c379f..a2cbae57eb45791b9c5415d07c54a91f34b665e6 100644 (file)
@@ -57,6 +57,9 @@ struct _GossipContactListStorePriv {
        gboolean                    is_compact;
        gboolean                    show_active;
        GossipContactListStoreSort  sort_criterium;
        gboolean                    is_compact;
        gboolean                    show_active;
        GossipContactListStoreSort  sort_criterium;
+
+       GossipContactGroupsFunc     get_contact_groups;
+       gpointer                    get_contact_groups_data;
 };
 
 typedef struct {
 };
 
 typedef struct {
@@ -622,6 +625,69 @@ gossip_contact_list_store_search_equal_func (GtkTreeModel *model,
        return ret;
 }
 
        return ret;
 }
 
+void
+gossip_contact_list_store_set_contact_groups_func (GossipContactListStore  *store,
+                                                  GossipContactGroupsFunc  func,
+                                                  gpointer                 user_data)
+{
+       GossipContactListStorePriv *priv;
+       GList                      *contacts, *l;
+
+       g_return_if_fail (GOSSIP_IS_CONTACT_LIST_STORE (store));
+
+       priv = GET_PRIV (store);
+
+       if (func) {
+               priv->get_contact_groups = func;
+               priv->get_contact_groups_data = user_data;
+       } else {
+               priv->get_contact_groups = NULL;
+               priv->get_contact_groups_data = NULL;
+       }
+
+       /* If we set a custom function to get contacts groups  we have to
+        * disconnect our default notify::groups signal and wait for the user
+        * to call himself gossip_contact_list_store_update_contact_groups ()
+        * when needed. If func is NULL we come back to default.
+        */
+       contacts = empathy_contact_list_get_contacts (priv->list);
+       for (l = contacts; l; l = l->next) {
+               GossipContact *contact;
+
+               contact = l->data;
+
+               if (func) {
+                       g_signal_handlers_disconnect_by_func (contact, 
+                                                             G_CALLBACK (contact_list_store_contact_groups_updated_cb),
+                                                             store);
+               } else {
+                       g_signal_connect (contact, "notify::groups",
+                                         G_CALLBACK (contact_list_store_contact_groups_updated_cb),
+                                         store);
+               }
+
+               gossip_contact_list_store_update_contact_groups (store, contact);
+
+               g_object_unref (contact);
+       }
+       g_list_free (contacts);
+}
+
+void
+gossip_contact_list_store_update_contact_groups (GossipContactListStore *store,
+                                                GossipContact          *contact)
+{
+       gossip_debug (DEBUG_DOMAIN, "Contact:'%s' updating groups",
+                     gossip_contact_get_name (contact));
+
+       /* We do this to make sure the groups are correct, if not, we
+        * would have to check the groups already set up for each
+        * contact and then see what has been updated.
+        */
+       contact_list_store_remove_contact (store, contact);
+       contact_list_store_add_contact (store, contact);
+}
+
 static void
 contact_list_store_setup (GossipContactListStore *store)
 {
 static void
 contact_list_store_setup (GossipContactListStore *store)
 {
@@ -668,9 +734,11 @@ contact_list_store_contact_added_cb (EmpathyContactList     *list_iface,
                      "Contact:'%s' added",
                      gossip_contact_get_name (contact));
 
                      "Contact:'%s' added",
                      gossip_contact_get_name (contact));
 
-       g_signal_connect (contact, "notify::groups",
-                         G_CALLBACK (contact_list_store_contact_groups_updated_cb),
-                         store);
+       if (!priv->get_contact_groups) {
+               g_signal_connect (contact, "notify::groups",
+                                 G_CALLBACK (contact_list_store_contact_groups_updated_cb),
+                                 store);
+       }
        g_signal_connect (contact, "notify::presence",
                          G_CALLBACK (contact_list_store_contact_updated_cb),
                          store);
        g_signal_connect (contact, "notify::presence",
                          G_CALLBACK (contact_list_store_contact_updated_cb),
                          store);
@@ -702,7 +770,13 @@ contact_list_store_add_contact (GossipContactListStore *store,
        }
 
        /* If no groups just add it at the top level. */
        }
 
        /* If no groups just add it at the top level. */
-       groups = gossip_contact_get_groups (contact);
+       if (priv->get_contact_groups) {
+               groups = priv->get_contact_groups (contact,
+                                                  priv->get_contact_groups_data);
+       } else {
+               groups = gossip_contact_get_groups (contact);
+       }
+
        if (!groups) {
                gtk_tree_store_append (GTK_TREE_STORE (store), &iter, NULL);
                gtk_tree_store_set (GTK_TREE_STORE (store), &iter,
        if (!groups) {
                gtk_tree_store_append (GTK_TREE_STORE (store), &iter, NULL);
                gtk_tree_store_set (GTK_TREE_STORE (store), &iter,
@@ -942,15 +1016,7 @@ contact_list_store_contact_groups_updated_cb (GossipContact          *contact,
                                              GParamSpec             *param,
                                              GossipContactListStore *store)
 {
                                              GParamSpec             *param,
                                              GossipContactListStore *store)
 {
-       gossip_debug (DEBUG_DOMAIN, "Contact:'%s' groups updated",
-                     gossip_contact_get_name (contact));
-
-       /* We do this to make sure the groups are correct, if not, we
-        * would have to check the groups already set up for each
-        * contact and then see what has been updated.
-        */
-       contact_list_store_remove_contact (store, contact);
-       contact_list_store_add_contact (store, contact);
+       gossip_contact_list_store_update_contact_groups (store, contact);
 }
 
 static void
 }
 
 static void
index 66d0b46ba70c2675861094ad281c68daf17cd29d..b2131bcab9d576b5240b02f1dab27cdebd9b53ed 100644 (file)
@@ -81,6 +81,8 @@ struct _GossipContactListStore {
 struct _GossipContactListStoreClass {
        GtkTreeStoreClass       parent_class;
 };
 struct _GossipContactListStoreClass {
        GtkTreeStoreClass       parent_class;
 };
+typedef GList *            (*GossipContactGroupsFunc)                   (GossipContact              *contact,
+                                                                        gpointer                    user_data);
 
 GType                      gossip_contact_list_store_get_type           (void) G_GNUC_CONST;
 GossipContactListStore *   gossip_contact_list_store_new                (EmpathyContactList         *list_iface);
 
 GType                      gossip_contact_list_store_get_type           (void) G_GNUC_CONST;
 GossipContactListStore *   gossip_contact_list_store_new                (EmpathyContactList         *list_iface);
@@ -108,6 +110,11 @@ gboolean                   gossip_contact_list_store_search_equal_func  (GtkTree
                                                                         const gchar                *key,
                                                                         GtkTreeIter                *iter,
                                                                         gpointer                    search_data);
                                                                         const gchar                *key,
                                                                         GtkTreeIter                *iter,
                                                                         gpointer                    search_data);
+void                       gossip_contact_list_store_set_contact_groups_func (GossipContactListStore*store,
+                                                                        GossipContactGroupsFunc     func,
+                                                                        gpointer                    user_data);
+void                       gossip_contact_list_store_update_contact_groups (GossipContactListStore  *store,
+                                                                        GossipContact              *contact);
 
 G_END_DECLS
 
 
 G_END_DECLS
 
index 5ca5eb807d15f05636a01a6c9e49ca4cb1cdd920..4d04ad5779942ce949fac8476ed07a8da133ae14 100644 (file)
@@ -20,7 +20,7 @@ libempathy-gtk/gossip-chat.c
 libempathy-gtk/gossip-chat.glade
 libempathy-gtk/gossip-chat-view.c
 libempathy-gtk/gossip-chat-window.c
 libempathy-gtk/gossip-chat.glade
 libempathy-gtk/gossip-chat-view.c
 libempathy-gtk/gossip-chat-window.c
-libempathy-gtk/gossip-contact-list.c
+libempathy-gtk/gossip-contact-list-view.c
 libempathy-gtk/gossip-preferences.c
 libempathy-gtk/gossip-preferences.glade
 libempathy-gtk/gossip-presence-chooser.c
 libempathy-gtk/gossip-preferences.c
 libempathy-gtk/gossip-preferences.glade
 libempathy-gtk/gossip-presence-chooser.c
index 287766594371284a360fb1d37bb203243ff0b6d7..339c4d0fa317409017b6a188e7bd2e56c5a51d02 100644 (file)
@@ -128,11 +128,8 @@ new_channel_cb (EmpathyChandler *chandler,
                        g_object_unref (tp_chat);
                }
                gossip_chat_present (chat);
                        g_object_unref (tp_chat);
                }
                gossip_chat_present (chat);
-
-               goto OUT;
        }
        }
-
-       if (tp_chan->handle_type == TP_HANDLE_TYPE_CONTACT) {
+       else if (tp_chan->handle_type == TP_HANDLE_TYPE_CONTACT) {
                EmpathyContactManager *manager;
                EmpathyTpContactList  *list;
                GossipContact         *contact;
                EmpathyContactManager *manager;
                EmpathyTpContactList  *list;
                GossipContact         *contact;
@@ -157,7 +154,7 @@ new_channel_cb (EmpathyChandler *chandler,
                g_object_unref (chat);
                g_object_unref (manager);
        }
                g_object_unref (chat);
                g_object_unref (manager);
        }
-       if (tp_chan->handle_type == TP_HANDLE_TYPE_ROOM) {
+       else if (tp_chan->handle_type == TP_HANDLE_TYPE_ROOM) {
 #if 0
                GossipGroupChat *chat;
 
 #if 0
                GossipGroupChat *chat;
 
@@ -176,7 +173,6 @@ new_channel_cb (EmpathyChandler *chandler,
 #endif
        }
 
 #endif
        }
 
-OUT:
        g_free (id);
        g_object_unref (account);
        g_object_unref (mc);
        g_free (id);
        g_object_unref (account);
        g_object_unref (mc);