empathy r586 - in trunk: libempathy libempathy-gtk megaphone/src python/pyempathygtk
- From: xclaesse svn gnome org
- To: svn-commits-list gnome org
- Subject: empathy r586 - in trunk: libempathy libempathy-gtk megaphone/src python/pyempathygtk
- Date: Sun, 20 Jan 2008 21:42:02 +0000 (GMT)
Author: xclaesse
Date: Sun Jan 20 21:42:01 2008
New Revision: 586
URL: http://svn.gnome.org/viewvc/empathy?rev=586&view=rev
Log:
Add a property to have or not groups on EmpathyContactListStore
Modified:
trunk/libempathy-gtk/empathy-contact-list-store.c
trunk/libempathy-gtk/empathy-contact-list-store.h
trunk/libempathy-gtk/empathy-group-chat.c
trunk/libempathy-gtk/empathy-main-window.c
trunk/libempathy/empathy-contact-list.c
trunk/megaphone/src/megaphone-applet.c
trunk/python/pyempathygtk/pyempathygtk.defs
Modified: trunk/libempathy-gtk/empathy-contact-list-store.c
==============================================================================
--- trunk/libempathy-gtk/empathy-contact-list-store.c (original)
+++ trunk/libempathy-gtk/empathy-contact-list-store.c Sun Jan 20 21:42:01 2008
@@ -54,6 +54,7 @@
EmpathyContactList *list;
gboolean show_offline;
gboolean show_avatars;
+ gboolean show_groups;
gboolean is_compact;
gboolean show_active;
EmpathyContactListStoreSort sort_criterium;
@@ -155,14 +156,63 @@
enum {
PROP_0,
+ PROP_CONTACT_LIST,
PROP_SHOW_OFFLINE,
PROP_SHOW_AVATARS,
+ PROP_SHOW_GROUPS,
PROP_IS_COMPACT,
PROP_SORT_CRITERIUM
};
G_DEFINE_TYPE (EmpathyContactListStore, empathy_contact_list_store, GTK_TYPE_TREE_STORE);
+
+static gboolean
+contact_list_store_iface_setup (gpointer user_data)
+{
+ EmpathyContactListStore *store = user_data;
+ EmpathyContactListStorePriv *priv = GET_PRIV (store);
+ GList *contacts, *l;
+
+ /* Signal connection. */
+ g_signal_connect (priv->list,
+ "members-changed",
+ G_CALLBACK (contact_list_store_members_changed_cb),
+ store);
+ g_signal_connect (priv->list,
+ "groups-changed",
+ G_CALLBACK (contact_list_store_groups_changed_cb),
+ store);
+
+ /* Add contacts already created. */
+ contacts = empathy_contact_list_get_members (priv->list);
+ for (l = contacts; l; l = l->next) {
+ contact_list_store_members_changed_cb (priv->list, l->data,
+ NULL, 0, NULL,
+ TRUE,
+ store);
+
+ g_object_unref (l->data);
+ }
+ g_list_free (contacts);
+
+ return FALSE;
+}
+
+
+static void
+contact_list_store_set_contact_list (EmpathyContactListStore *store,
+ EmpathyContactList *list_iface)
+{
+ EmpathyContactListStorePriv *priv = GET_PRIV (store);
+
+ priv->list = g_object_ref (list_iface);
+
+ /* Let a chance to have all properties set before populating */
+ g_idle_add (contact_list_store_iface_setup,
+ store);
+}
+
static void
empathy_contact_list_store_class_init (EmpathyContactListStoreClass *klass)
{
@@ -173,6 +223,14 @@
object_class->set_property = contact_list_store_set_property;
g_object_class_install_property (object_class,
+ PROP_CONTACT_LIST,
+ g_param_spec_object ("contact-list",
+ "The contact list iface",
+ "The contact list iface",
+ EMPATHY_TYPE_CONTACT_LIST,
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_READWRITE));
+ g_object_class_install_property (object_class,
PROP_SHOW_OFFLINE,
g_param_spec_boolean ("show-offline",
"Show Offline",
@@ -188,6 +246,14 @@
"avatars for contacts",
TRUE,
G_PARAM_READWRITE));
+ g_object_class_install_property (object_class,
+ PROP_SHOW_GROUPS,
+ g_param_spec_boolean ("show-groups",
+ "Show Groups",
+ "Whether contact list should display "
+ "contact groups",
+ TRUE,
+ G_PARAM_READWRITE));
g_object_class_install_property (object_class,
PROP_IS_COMPACT,
g_param_spec_boolean ("is-compact",
@@ -216,9 +282,11 @@
priv = GET_PRIV (store);
priv->show_avatars = TRUE;
+ priv->show_groups = TRUE;
priv->inhibit_active = g_timeout_add_seconds (ACTIVE_USER_WAIT_TO_ENABLE_TIME,
(GSourceFunc) contact_list_store_inibit_active_cb,
store);
+ contact_list_store_setup (store);
}
static void
@@ -260,12 +328,18 @@
priv = GET_PRIV (object);
switch (param_id) {
+ case PROP_CONTACT_LIST:
+ g_value_set_object (value, priv->list);
+ break;
case PROP_SHOW_OFFLINE:
g_value_set_boolean (value, priv->show_offline);
break;
case PROP_SHOW_AVATARS:
g_value_set_boolean (value, priv->show_avatars);
break;
+ case PROP_SHOW_GROUPS:
+ g_value_set_boolean (value, priv->show_groups);
+ break;
case PROP_IS_COMPACT:
g_value_set_boolean (value, priv->is_compact);
break;
@@ -289,6 +363,10 @@
priv = GET_PRIV (object);
switch (param_id) {
+ case PROP_CONTACT_LIST:
+ contact_list_store_set_contact_list (EMPATHY_CONTACT_LIST_STORE (object),
+ g_value_get_object (value));
+ break;
case PROP_SHOW_OFFLINE:
empathy_contact_list_store_set_show_offline (EMPATHY_CONTACT_LIST_STORE (object),
g_value_get_boolean (value));
@@ -297,6 +375,10 @@
empathy_contact_list_store_set_show_avatars (EMPATHY_CONTACT_LIST_STORE (object),
g_value_get_boolean (value));
break;
+ case PROP_SHOW_GROUPS:
+ empathy_contact_list_store_set_show_groups (EMPATHY_CONTACT_LIST_STORE (object),
+ g_value_get_boolean (value));
+ break;
case PROP_IS_COMPACT:
empathy_contact_list_store_set_is_compact (EMPATHY_CONTACT_LIST_STORE (object),
g_value_get_boolean (value));
@@ -312,43 +394,15 @@
}
EmpathyContactListStore *
-empathy_contact_list_store_new (EmpathyContactList *list_iface)
+empathy_contact_list_store_new (EmpathyContactList *list_iface,
+ gboolean show_groups)
{
- EmpathyContactListStore *store;
- EmpathyContactListStorePriv *priv;
- GList *contacts, *l;
-
g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST (list_iface), NULL);
- store = g_object_new (EMPATHY_TYPE_CONTACT_LIST_STORE, NULL);
- priv = GET_PRIV (store);
-
- contact_list_store_setup (store);
- priv->list = g_object_ref (list_iface);
-
- /* Signal connection. */
- g_signal_connect (priv->list,
- "members-changed",
- G_CALLBACK (contact_list_store_members_changed_cb),
- store);
- g_signal_connect (priv->list,
- "groups-changed",
- G_CALLBACK (contact_list_store_groups_changed_cb),
- store);
-
- /* Add contacts already created. */
- contacts = empathy_contact_list_get_members (priv->list);
- for (l = contacts; l; l = l->next) {
- contact_list_store_members_changed_cb (priv->list, l->data,
- NULL, 0, NULL,
- TRUE,
- store);
-
- g_object_unref (l->data);
- }
- g_list_free (contacts);
-
- return store;
+ return g_object_new (EMPATHY_TYPE_CONTACT_LIST_STORE,
+ "contact-list", list_iface,
+ "show-groups", show_groups,
+ NULL);
}
EmpathyContactList *
@@ -403,6 +457,8 @@
/* Restore to original setting. */
priv->show_active = show_active;
+
+ g_object_notify (G_OBJECT (store), "show-offline");
}
gboolean
@@ -436,6 +492,54 @@
(GtkTreeModelForeachFunc)
contact_list_store_update_list_mode_foreach,
store);
+
+ g_object_notify (G_OBJECT (store), "show-avatars");
+}
+
+gboolean
+empathy_contact_list_store_get_show_groups (EmpathyContactListStore *store)
+{
+ EmpathyContactListStorePriv *priv;
+
+ g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST_STORE (store), TRUE);
+
+ priv = GET_PRIV (store);
+
+ return priv->show_groups;
+}
+
+void
+empathy_contact_list_store_set_show_groups (EmpathyContactListStore *store,
+ gboolean show_groups)
+{
+ EmpathyContactListStorePriv *priv;
+ GList *contacts, *l;
+
+ g_return_if_fail (EMPATHY_IS_CONTACT_LIST_STORE (store));
+
+ priv = GET_PRIV (store);
+
+ if (priv->show_groups == show_groups) {
+ return;
+ }
+
+ priv->show_groups = show_groups;
+
+ /* Remove all contacts and add them back, not optimized but that's the
+ * easy way :) */
+ gtk_tree_store_clear (GTK_TREE_STORE (store));
+ contacts = empathy_contact_list_get_members (priv->list);
+ for (l = contacts; l; l = l->next) {
+ contact_list_store_members_changed_cb (priv->list, l->data,
+ NULL, 0, NULL,
+ TRUE,
+ store);
+
+ g_object_unref (l->data);
+ }
+ g_list_free (contacts);
+
+ g_object_notify (G_OBJECT (store), "show-groups");
}
gboolean
@@ -469,6 +573,8 @@
(GtkTreeModelForeachFunc)
contact_list_store_update_list_mode_foreach,
store);
+
+ g_object_notify (G_OBJECT (store), "is-compact");
}
EmpathyContactListStoreSort
@@ -508,6 +614,8 @@
GTK_SORT_ASCENDING);
break;
}
+
+ g_object_notify (G_OBJECT (store), "sort-criterium");
}
gboolean
@@ -767,7 +875,7 @@
{
EmpathyContactListStorePriv *priv;
GtkTreeIter iter;
- GList *groups, *l;
+ GList *groups = NULL, *l;
priv = GET_PRIV (store);
@@ -775,7 +883,9 @@
return;
}
- groups = empathy_contact_list_get_groups (priv->list, contact);
+ if (priv->show_groups) {
+ groups = empathy_contact_list_get_groups (priv->list, contact);
+ }
/* If no groups just add it at the top level. */
if (!groups) {
Modified: trunk/libempathy-gtk/empathy-contact-list-store.h
==============================================================================
--- trunk/libempathy-gtk/empathy-contact-list-store.h (original)
+++ trunk/libempathy-gtk/empathy-contact-list-store.h Sun Jan 20 21:42:01 2008
@@ -73,7 +73,8 @@
};
GType empathy_contact_list_store_get_type (void) G_GNUC_CONST;
-EmpathyContactListStore * empathy_contact_list_store_new (EmpathyContactList *list_iface);
+EmpathyContactListStore * empathy_contact_list_store_new (EmpathyContactList *list_iface,
+ gboolean show_groups);
EmpathyContactList * empathy_contact_list_store_get_list_iface (EmpathyContactListStore *store);
gboolean empathy_contact_list_store_get_show_offline (EmpathyContactListStore *store);
void empathy_contact_list_store_set_show_offline (EmpathyContactListStore *store,
@@ -81,6 +82,9 @@
gboolean empathy_contact_list_store_get_show_avatars (EmpathyContactListStore *store);
void empathy_contact_list_store_set_show_avatars (EmpathyContactListStore *store,
gboolean show_avatars);
+gboolean empathy_contact_list_store_get_show_groups (EmpathyContactListStore *store);
+void empathy_contact_list_store_set_show_groups (EmpathyContactListStore *store,
+ gboolean show_groups);
gboolean empathy_contact_list_store_get_is_compact (EmpathyContactListStore *store);
void empathy_contact_list_store_set_is_compact (EmpathyContactListStore *store,
gboolean is_compact);
Modified: trunk/libempathy-gtk/empathy-group-chat.c
==============================================================================
--- trunk/libempathy-gtk/empathy-group-chat.c (original)
+++ trunk/libempathy-gtk/empathy-group-chat.c Sun Jan 20 21:42:01 2008
@@ -526,7 +526,7 @@
}
/* Create contact list */
- priv->store = empathy_contact_list_store_new (EMPATHY_CONTACT_LIST (priv->tp_chat));
+ priv->store = empathy_contact_list_store_new (EMPATHY_CONTACT_LIST (priv->tp_chat), TRUE);
priv->view = empathy_contact_list_view_new (priv->store,
EMPATHY_CONTACT_LIST_FEATURE_CONTACT_CHAT |
EMPATHY_CONTACT_LIST_FEATURE_CONTACT_CALL |
Modified: trunk/libempathy-gtk/empathy-main-window.c
==============================================================================
--- trunk/libempathy-gtk/empathy-main-window.c (original)
+++ trunk/libempathy-gtk/empathy-main-window.c Sun Jan 20 21:42:01 2008
@@ -284,7 +284,7 @@
empathy_status_presets_get_all ();
list_iface = EMPATHY_CONTACT_LIST (empathy_contact_manager_new ());
- window->list_store = empathy_contact_list_store_new (list_iface);
+ window->list_store = empathy_contact_list_store_new (list_iface, TRUE);
window->list_view = empathy_contact_list_view_new (window->list_store,
EMPATHY_CONTACT_LIST_FEATURE_ALL);
g_object_unref (list_iface);
Modified: trunk/libempathy/empathy-contact-list.c
==============================================================================
--- trunk/libempathy/empathy-contact-list.c (original)
+++ trunk/libempathy/empathy-contact-list.c Sun Jan 20 21:42:01 2008
@@ -41,6 +41,8 @@
type = g_type_register_static (G_TYPE_INTERFACE,
"EmpathyContactList",
&type_info, 0);
+
+ g_type_interface_add_prerequisite (type, G_TYPE_OBJECT);
}
return type;
Modified: trunk/megaphone/src/megaphone-applet.c
==============================================================================
--- trunk/megaphone/src/megaphone-applet.c (original)
+++ trunk/megaphone/src/megaphone-applet.c Sun Jan 20 21:42:01 2008
@@ -358,7 +358,7 @@
/* Show all contacts, even offline and sort alphabetically */
contact_manager = empathy_contact_manager_new ();
- contact_store = empathy_contact_list_store_new (EMPATHY_CONTACT_LIST (contact_manager));
+ contact_store = empathy_contact_list_store_new (EMPATHY_CONTACT_LIST (contact_manager), TRUE);
g_object_set (contact_store,
"is-compact", TRUE,
"show-avatars", TRUE,
Modified: trunk/python/pyempathygtk/pyempathygtk.defs
==============================================================================
--- trunk/python/pyempathygtk/pyempathygtk.defs (original)
+++ trunk/python/pyempathygtk/pyempathygtk.defs Sun Jan 20 21:42:01 2008
@@ -199,8 +199,10 @@
(c-name "EmpathyContactListFeatures")
(gtype-id "EMPATHY_TYPE_CONTACT_LIST_FEATURES")
(values
- '("groups-show" "EMPATHY_CONTACT_LIST_FEATURE_GROUPS_SHOW")
- '("groups-modify" "EMPATHY_CONTACT_LIST_FEATURE_GROUPS_MODIFY")
+ '("none" "EMPATHY_CONTACT_LIST_FEATURE_NONE")
+ '("groups-save" "EMPATHY_CONTACT_LIST_FEATURE_GROUPS_SAVE")
+ '("groups-rename" "EMPATHY_CONTACT_LIST_FEATURE_GROUPS_RENAME")
+ '("groups-remove" "EMPATHY_CONTACT_LIST_FEATURE_GROUPS_REMOVE")
'("contact-chat" "EMPATHY_CONTACT_LIST_FEATURE_CONTACT_CHAT")
'("contact-call" "EMPATHY_CONTACT_LIST_FEATURE_CONTACT_CALL")
'("contact-log" "EMPATHY_CONTACT_LIST_FEATURE_CONTACT_LOG")
@@ -209,6 +211,9 @@
'("contact-edit" "EMPATHY_CONTACT_LIST_FEATURE_CONTACT_EDIT")
'("contact-info" "EMPATHY_CONTACT_LIST_FEATURE_CONTACT_INFO")
'("contact-remove" "EMPATHY_CONTACT_LIST_FEATURE_CONTACT_REMOVE")
+ '("contact-drop" "EMPATHY_CONTACT_LIST_FEATURE_CONTACT_DROP")
+ '("contact-drag" "EMPATHY_CONTACT_LIST_FEATURE_CONTACT_DRAG")
+ '("all" "EMPATHY_CONTACT_LIST_FEATURE_ALL")
)
)
@@ -1047,6 +1052,9 @@
(of-object "EmpathyContactList")
(c-name "empathy_contact_list_store_new")
(return-type "EmpathyContactListStore*")
+ (parameters
+ '("gboolean" "show_groups")
+ )
)
(define-method get_list_iface
@@ -1085,6 +1093,21 @@
)
)
+(define-method get_show_groups
+ (of-object "EmpathyContactListStore")
+ (c-name "empathy_contact_list_store_get_show_groups")
+ (return-type "gboolean")
+)
+
+(define-method set_show_groups
+ (of-object "EmpathyContactListStore")
+ (c-name "empathy_contact_list_store_set_show_groups")
+ (return-type "none")
+ (parameters
+ '("gboolean" "show_groups")
+ )
+)
+
(define-method get_is_compact
(of-object "EmpathyContactListStore")
(c-name "empathy_contact_list_store_get_is_compact")
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]