aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorchantra <chantra@debuntu.org>2009-12-17 00:20:36 +0800
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2009-12-17 00:22:01 +0800
commitfbaeb693027d63d94488702635630644971dfc2f (patch)
tree9b58024f0089129e197824550b68ee1f30fbea05
parentd6152461b68592397130f5df2dd285b5651eb460 (diff)
downloadgsoc2013-empathy-fbaeb693027d63d94488702635630644971dfc2f.tar
gsoc2013-empathy-fbaeb693027d63d94488702635630644971dfc2f.tar.gz
gsoc2013-empathy-fbaeb693027d63d94488702635630644971dfc2f.tar.bz2
gsoc2013-empathy-fbaeb693027d63d94488702635630644971dfc2f.tar.lz
gsoc2013-empathy-fbaeb693027d63d94488702635630644971dfc2f.tar.xz
gsoc2013-empathy-fbaeb693027d63d94488702635630644971dfc2f.tar.zst
gsoc2013-empathy-fbaeb693027d63d94488702635630644971dfc2f.zip
contact_list: displays an icon showing the protocol by the contact (#603877)
-rw-r--r--data/empathy.schemas.in15
-rw-r--r--libempathy-gtk/empathy-conf.h1
-rw-r--r--libempathy-gtk/empathy-contact-list-store.c143
-rw-r--r--libempathy-gtk/empathy-contact-list-store.h8
-rw-r--r--libempathy-gtk/empathy-contact-list-view.c14
-rw-r--r--libempathy-gtk/empathy-contact-selector.c2
-rw-r--r--libempathy-gtk/empathy-ui-utils.c112
-rw-r--r--libempathy-gtk/empathy-ui-utils.h9
-rw-r--r--src/empathy-main-window.c63
-rw-r--r--src/empathy-main-window.ui7
10 files changed, 360 insertions, 14 deletions
diff --git a/data/empathy.schemas.in b/data/empathy.schemas.in
index faba263a5..11b5652af 100644
--- a/data/empathy.schemas.in
+++ b/data/empathy.schemas.in
@@ -47,6 +47,21 @@
</schema>
<schema>
+ <key>/schemas/apps/empathy/ui/show_protocols</key>
+ <applyto>/apps/empathy/ui/show_protocols</applyto>
+ <owner>empathy</owner>
+ <type>bool</type>
+ <default>true</default>
+ <locale name="C">
+ <short>Show protocols</short>
+ <long>
+ Whether or not to show protocols for contacts in the contact
+ list.
+ </long>
+ </locale>
+ </schema>
+
+ <schema>
<key>/schemas/apps/empathy/ui/compact_contact_list</key>
<applyto>/apps/empathy/ui/compact_contact_list</applyto>
<owner>empathy</owner>
diff --git a/libempathy-gtk/empathy-conf.h b/libempathy-gtk/empathy-conf.h
index 8d0066d90..551627364 100644
--- a/libempathy-gtk/empathy-conf.h
+++ b/libempathy-gtk/empathy-conf.h
@@ -73,6 +73,7 @@ struct _EmpathyConfClass {
#define EMPATHY_PREFS_UI_MAIN_WINDOW_HIDDEN EMPATHY_PREFS_PATH "/ui/main_window_hidden"
#define EMPATHY_PREFS_UI_AVATAR_DIRECTORY EMPATHY_PREFS_PATH "/ui/avatar_directory"
#define EMPATHY_PREFS_UI_SHOW_AVATARS EMPATHY_PREFS_PATH "/ui/show_avatars"
+#define EMPATHY_PREFS_UI_SHOW_PROTOCOLS EMPATHY_PREFS_PATH "/ui/show_protocols"
#define EMPATHY_PREFS_UI_COMPACT_CONTACT_LIST EMPATHY_PREFS_PATH "/ui/compact_contact_list"
#define EMPATHY_PREFS_UI_CHAT_WINDOW_PANED_POS EMPATHY_PREFS_PATH "/ui/chat_window_paned_pos"
#define EMPATHY_PREFS_CONTACTS_SHOW_OFFLINE EMPATHY_PREFS_PATH "/contacts/show_offline"
diff --git a/libempathy-gtk/empathy-contact-list-store.c b/libempathy-gtk/empathy-contact-list-store.c
index c516dbf7c..4660a0b14 100644
--- a/libempathy-gtk/empathy-contact-list-store.c
+++ b/libempathy-gtk/empathy-contact-list-store.c
@@ -60,11 +60,13 @@ typedef struct {
gboolean show_avatars;
gboolean show_groups;
gboolean is_compact;
+ gboolean show_protocols;
gboolean show_active;
EmpathyContactListStoreSort sort_criterium;
guint inhibit_active;
guint setup_idle_id;
gboolean dispose_has_run;
+ GHashTable *status_icons;
} EmpathyContactListStorePriv;
typedef struct {
@@ -165,6 +167,7 @@ enum {
PROP_CONTACT_LIST,
PROP_SHOW_OFFLINE,
PROP_SHOW_AVATARS,
+ PROP_SHOW_PROTOCOLS,
PROP_SHOW_GROUPS,
PROP_IS_COMPACT,
PROP_SORT_CRITERIUM
@@ -256,6 +259,14 @@ empathy_contact_list_store_class_init (EmpathyContactListStoreClass *klass)
TRUE,
G_PARAM_READWRITE));
g_object_class_install_property (object_class,
+ PROP_SHOW_PROTOCOLS,
+ g_param_spec_boolean ("show-protocols",
+ "Show Protocols",
+ "Whether contact list should display "
+ "protocols for contacts",
+ FALSE,
+ G_PARAM_READWRITE));
+ g_object_class_install_property (object_class,
PROP_SHOW_GROUPS,
g_param_spec_boolean ("show-groups",
"Show Groups",
@@ -292,9 +303,11 @@ empathy_contact_list_store_init (EmpathyContactListStore *store)
store->priv = priv;
priv->show_avatars = TRUE;
priv->show_groups = TRUE;
+ priv->show_protocols = FALSE;
priv->inhibit_active = g_timeout_add_seconds (ACTIVE_USER_WAIT_TO_ENABLE_TIME,
(GSourceFunc) contact_list_store_inibit_active_cb,
store);
+ priv->status_icons = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
contact_list_store_setup (store);
}
@@ -337,6 +350,7 @@ contact_list_store_dispose (GObject *object)
g_source_remove (priv->setup_idle_id);
}
+ g_hash_table_destroy (priv->status_icons);
G_OBJECT_CLASS (empathy_contact_list_store_parent_class)->dispose (object);
}
@@ -360,6 +374,9 @@ contact_list_store_get_property (GObject *object,
case PROP_SHOW_AVATARS:
g_value_set_boolean (value, priv->show_avatars);
break;
+ case PROP_SHOW_PROTOCOLS:
+ g_value_set_boolean (value, priv->show_protocols);
+ break;
case PROP_SHOW_GROUPS:
g_value_set_boolean (value, priv->show_groups);
break;
@@ -398,6 +415,10 @@ contact_list_store_set_property (GObject *object,
empathy_contact_list_store_set_show_avatars (EMPATHY_CONTACT_LIST_STORE (object),
g_value_get_boolean (value));
break;
+ case PROP_SHOW_PROTOCOLS:
+ empathy_contact_list_store_set_show_protocols (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));
@@ -517,6 +538,42 @@ empathy_contact_list_store_set_show_avatars (EmpathyContactListStore *store,
g_object_notify (G_OBJECT (store), "show-avatars");
}
+
+gboolean
+empathy_contact_list_store_get_show_protocols (EmpathyContactListStore *store)
+{
+ EmpathyContactListStorePriv *priv;
+
+ g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST_STORE (store), TRUE);
+
+ priv = GET_PRIV (store);
+
+ return priv->show_protocols;
+}
+
+void
+empathy_contact_list_store_set_show_protocols (EmpathyContactListStore *store,
+ gboolean show_protocols)
+{
+ EmpathyContactListStorePriv *priv;
+ GtkTreeModel *model;
+
+ g_return_if_fail (EMPATHY_IS_CONTACT_LIST_STORE (store));
+
+ priv = GET_PRIV (store);
+
+ priv->show_protocols = show_protocols;
+
+ model = GTK_TREE_MODEL (store);
+
+ gtk_tree_model_foreach (model,
+ (GtkTreeModelForeachFunc)
+ contact_list_store_update_list_mode_foreach,
+ store);
+
+ g_object_notify (G_OBJECT (store), "show-protocols");
+}
+
gboolean
empathy_contact_list_store_get_show_groups (EmpathyContactListStore *store)
{
@@ -753,7 +810,7 @@ contact_list_store_setup (EmpathyContactListStore *store)
{
EmpathyContactListStorePriv *priv;
GType types[] = {
- G_TYPE_STRING, /* Status icon-name */
+ GDK_TYPE_PIXBUF, /* Status pixbuf */
GDK_TYPE_PIXBUF, /* Avatar pixbuf */
G_TYPE_BOOLEAN, /* Avatar pixbuf visible */
G_TYPE_STRING, /* Name */
@@ -1055,7 +1112,9 @@ contact_list_store_contact_update (EmpathyContactListStore *store,
gboolean do_set_active = FALSE;
gboolean do_set_refresh = FALSE;
gboolean show_avatar = FALSE;
+ gboolean show_protocol = FALSE;
GdkPixbuf *pixbuf_avatar;
+ GdkPixbuf *pixbuf_status;
priv = GET_PRIV (store);
@@ -1148,10 +1207,14 @@ contact_list_store_contact_update (EmpathyContactListStore *store,
if (priv->show_avatars && !priv->is_compact) {
show_avatar = TRUE;
}
+ if (priv->show_protocols && !priv->is_compact) {
+ show_protocol = TRUE;
+ }
pixbuf_avatar = empathy_pixbuf_avatar_from_contact_scaled (contact, 32, 32);
+ pixbuf_status = contact_list_store_get_contact_status_icon (store, contact);
for (l = iters; l && set_model; l = l->next) {
gtk_tree_store_set (GTK_TREE_STORE (store), l->data,
- EMPATHY_CONTACT_LIST_STORE_COL_ICON_STATUS, empathy_icon_name_for_contact (contact),
+ EMPATHY_CONTACT_LIST_STORE_COL_ICON_STATUS, pixbuf_status,
EMPATHY_CONTACT_LIST_STORE_COL_PIXBUF_AVATAR, pixbuf_avatar,
EMPATHY_CONTACT_LIST_STORE_COL_PIXBUF_AVATAR_VISIBLE, show_avatar,
EMPATHY_CONTACT_LIST_STORE_COL_NAME, empathy_contact_get_name (contact),
@@ -1581,15 +1644,32 @@ contact_list_store_update_list_mode_foreach (GtkTreeModel *model,
EmpathyContactListStore *store)
{
EmpathyContactListStorePriv *priv;
- gboolean show_avatar = FALSE;
+ gboolean show_avatar = FALSE;
+ gboolean show_protocol = FALSE;
+ EmpathyContact *contact;
+ GdkPixbuf *pixbuf_status;
priv = GET_PRIV (store);
if (priv->show_avatars && !priv->is_compact) {
show_avatar = TRUE;
}
+ if (priv->show_protocols && !priv->is_compact) {
+ show_protocol = TRUE;
+ }
+
+ gtk_tree_model_get (model, iter,
+ EMPATHY_CONTACT_LIST_STORE_COL_CONTACT, &contact,
+ -1);
+
+ if (contact == NULL){
+ return FALSE;
+ }
+ /* get icon from hash_table */
+ pixbuf_status = contact_list_store_get_contact_status_icon (store, contact);
gtk_tree_store_set (GTK_TREE_STORE (store), iter,
+ EMPATHY_CONTACT_LIST_STORE_COL_ICON_STATUS, pixbuf_status,
EMPATHY_CONTACT_LIST_STORE_COL_PIXBUF_AVATAR_VISIBLE, show_avatar,
EMPATHY_CONTACT_LIST_STORE_COL_STATUS_VISIBLE, !priv->is_compact,
-1);
@@ -1597,3 +1677,60 @@ contact_list_store_update_list_mode_foreach (GtkTreeModel *model,
return FALSE;
}
+GdkPixbuf *
+contact_list_store_get_contact_status_icon (EmpathyContactListStore *store,
+ EmpathyContact *contact)
+{
+ GdkPixbuf *pixbuf_status = NULL;
+ const gchar *status_icon_name = NULL;
+
+ status_icon_name = empathy_icon_name_for_contact (contact);
+ pixbuf_status = contact_list_store_get_contact_status_icon_with_icon_name (
+ store,
+ contact,
+ status_icon_name);
+
+ return pixbuf_status;
+}
+
+GdkPixbuf *
+contact_list_store_get_contact_status_icon_with_icon_name (
+ EmpathyContactListStore *store,
+ EmpathyContact *contact,
+ const gchar *status_icon_name)
+{
+ GdkPixbuf *pixbuf_status = NULL;
+ EmpathyContactListStorePriv *priv;
+ const gchar *protocol_name = NULL;
+ gchar *icon_name = NULL;
+ gboolean show_protocol = FALSE;
+
+ priv = GET_PRIV (store);
+
+ if (priv->show_protocols && !priv->is_compact) {
+ show_protocol = TRUE;
+ }
+ if (show_protocol) {
+ protocol_name = empathy_protocol_name_for_contact (contact);
+ icon_name = g_strdup_printf ("%s-%s", status_icon_name, protocol_name);
+ } else {
+ icon_name = g_strdup_printf ("%s", status_icon_name);
+ }
+ pixbuf_status = g_hash_table_lookup (priv->status_icons, icon_name);
+ if (pixbuf_status == NULL) {
+ pixbuf_status = empathy_pixbuf_contact_status_icon_with_icon_name (contact,
+ status_icon_name,
+ show_protocol);
+ if (pixbuf_status != NULL) {
+ g_hash_table_insert (priv->status_icons,
+ g_strdup (icon_name),
+ pixbuf_status);
+ DEBUG( "Created status icon %s\n", icon_name);
+ }
+ } else {
+ DEBUG( "retrieved from cache status icon %s\n", icon_name);
+ }
+ g_free (icon_name);
+ return pixbuf_status;
+}
+
diff --git a/libempathy-gtk/empathy-contact-list-store.h b/libempathy-gtk/empathy-contact-list-store.h
index f97853991..c46e9e831 100644
--- a/libempathy-gtk/empathy-contact-list-store.h
+++ b/libempathy-gtk/empathy-contact-list-store.h
@@ -90,6 +90,9 @@ void empathy_contact_list_store_set_show_groups (Empathy
gboolean empathy_contact_list_store_get_is_compact (EmpathyContactListStore *store);
void empathy_contact_list_store_set_is_compact (EmpathyContactListStore *store,
gboolean is_compact);
+gboolean empathy_contact_list_store_get_show_protocols (EmpathyContactListStore *store);
+void empathy_contact_list_store_set_show_protocols (EmpathyContactListStore *store,
+ gboolean show_protocols);
EmpathyContactListStoreSort empathy_contact_list_store_get_sort_criterium (EmpathyContactListStore *store);
void empathy_contact_list_store_set_sort_criterium (EmpathyContactListStore *store,
EmpathyContactListStoreSort sort_criterium);
@@ -104,6 +107,11 @@ gboolean empathy_contact_list_store_search_equal_func (GtkTre
const gchar *key,
GtkTreeIter *iter,
gpointer search_data);
+GdkPixbuf * contact_list_store_get_contact_status_icon ( EmpathyContactListStore *store,
+ EmpathyContact *contact);
+GdkPixbuf * contact_list_store_get_contact_status_icon_with_icon_name (EmpathyContactListStore *store,
+ EmpathyContact *contact,
+ const gchar *status_icon_name);
G_END_DECLS
diff --git a/libempathy-gtk/empathy-contact-list-view.c b/libempathy-gtk/empathy-contact-list-view.c
index 6b25cc10f..e11a2e93f 100644
--- a/libempathy-gtk/empathy-contact-list-view.c
+++ b/libempathy-gtk/empathy-contact-list-view.c
@@ -842,22 +842,24 @@ contact_list_view_pixbuf_cell_data_func (GtkTreeViewColumn *tree_column,
GtkTreeIter *iter,
EmpathyContactListView *view)
{
- gchar *icon_name;
- gboolean is_group;
- gboolean is_active;
+ GdkPixbuf *pixbuf;
+ gboolean is_group;
+ gboolean is_active;
gtk_tree_model_get (model, iter,
EMPATHY_CONTACT_LIST_STORE_COL_IS_GROUP, &is_group,
EMPATHY_CONTACT_LIST_STORE_COL_IS_ACTIVE, &is_active,
- EMPATHY_CONTACT_LIST_STORE_COL_ICON_STATUS, &icon_name,
+ EMPATHY_CONTACT_LIST_STORE_COL_ICON_STATUS, &pixbuf,
-1);
g_object_set (cell,
"visible", !is_group,
- "icon-name", icon_name,
+ "pixbuf", pixbuf,
NULL);
- g_free (icon_name);
+ if (pixbuf != NULL) {
+ g_object_unref (pixbuf);
+ }
contact_list_view_cell_set_background (view, cell, is_group, is_active);
}
diff --git a/libempathy-gtk/empathy-contact-selector.c b/libempathy-gtk/empathy-contact-selector.c
index 8aa02fa6d..027ca41c2 100644
--- a/libempathy-gtk/empathy-contact-selector.c
+++ b/libempathy-gtk/empathy-contact-selector.c
@@ -211,7 +211,7 @@ contact_selector_constructor (GType type,
priv->store = empathy_contact_list_store_new (priv->contact_list);
g_object_set (priv->store, "is-compact", TRUE, "show-avatars", FALSE,
- "show-offline", FALSE, "show-groups", FALSE,
+ "show-offline", FALSE, "show-groups", FALSE, "show-protocols", FALSE,
"sort-criterium", EMPATHY_CONTACT_LIST_STORE_SORT_NAME, NULL);
g_signal_connect_swapped (priv->store, "row-changed",
diff --git a/libempathy-gtk/empathy-ui-utils.c b/libempathy-gtk/empathy-ui-utils.c
index 2d8f4091c..3fa39d53f 100644
--- a/libempathy-gtk/empathy-ui-utils.c
+++ b/libempathy-gtk/empathy-ui-utils.c
@@ -230,6 +230,21 @@ empathy_icon_name_for_contact (EmpathyContact *contact)
return empathy_icon_name_for_presence (presence);
}
+const gchar *
+empathy_protocol_name_for_contact (EmpathyContact *contact)
+{
+ TpAccount *account;
+
+ g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
+
+ account = empathy_contact_get_account (contact);
+ if (account == NULL) {
+ return NULL;
+ }
+
+ return tp_account_get_icon_name (account);
+}
+
GdkPixbuf *
empathy_pixbuf_from_data (gchar *data,
gsize data_size)
@@ -491,6 +506,103 @@ empathy_pixbuf_avatar_from_contact_scaled (EmpathyContact *contact,
}
GdkPixbuf *
+empathy_pixbuf_contact_status_icon (EmpathyContact *contact,
+ gboolean show_protocol)
+{
+ const gchar *icon_name;
+
+ g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
+
+ icon_name = empathy_icon_name_for_contact (contact);
+
+ if (icon_name == NULL) {
+ return NULL;
+ }
+ return empathy_pixbuf_contact_status_icon_with_icon_name (contact,
+ icon_name,
+ show_protocol);
+}
+
+GdkPixbuf *
+empathy_pixbuf_contact_status_icon_with_icon_name (EmpathyContact *contact,
+ const gchar *icon_name,
+ gboolean show_protocol)
+{
+ GdkPixbuf *pix_status;
+ GdkPixbuf *pix_protocol;
+ gchar *icon_filename;
+ gint height, width;
+ gint numerator, denominator;
+
+ g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
+
+ numerator = 3;
+ denominator = 4;
+
+ icon_filename = empathy_filename_from_icon_name (icon_name,
+ GTK_ICON_SIZE_MENU);
+ if (icon_filename == NULL) {
+ DEBUG ("icon name: %s could not be found\n", icon_name);
+ return NULL;
+ }
+
+ pix_status = gdk_pixbuf_new_from_file (icon_filename, NULL);
+
+ g_free (icon_filename);
+
+ if (pix_status == NULL) {
+ DEBUG ("Could not open icon %s\n", icon_filename);
+ return NULL;
+ }
+
+ if (!show_protocol)
+ return pix_status;
+
+ height = gdk_pixbuf_get_height (pix_status);
+ width = gdk_pixbuf_get_width (pix_status);
+
+ pix_protocol = empathy_pixbuf_protocol_from_contact_scaled (contact,
+ width * numerator / denominator,
+ height * numerator / denominator);
+
+ if (pix_protocol == NULL) {
+ return pix_status;
+ }
+ gdk_pixbuf_composite (pix_protocol, pix_status,
+ 0, height - height * numerator / denominator,
+ width * numerator / denominator, height * numerator / denominator,
+ 0, height - height * numerator / denominator,
+ 1, 1,
+ GDK_INTERP_BILINEAR, 255);
+
+ g_object_unref (pix_protocol);
+
+ return pix_status;
+}
+
+GdkPixbuf *
+empathy_pixbuf_protocol_from_contact_scaled (EmpathyContact *contact,
+ gint width,
+ gint height)
+{
+ TpAccount *account;
+ gchar *filename;
+ GdkPixbuf *pixbuf = NULL;
+
+ g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
+
+ account = empathy_contact_get_account (contact);
+ filename = empathy_filename_from_icon_name (tp_account_get_icon_name (account),
+ GTK_ICON_SIZE_MENU);
+ if (filename != NULL) {
+ pixbuf = gdk_pixbuf_new_from_file_at_size (filename, width, height, NULL);
+ g_free (filename);
+ }
+
+ return pixbuf;
+}
+
+GdkPixbuf *
empathy_pixbuf_scale_down_if_necessary (GdkPixbuf *pixbuf, gint max_size)
{
gint width, height;
diff --git a/libempathy-gtk/empathy-ui-utils.h b/libempathy-gtk/empathy-ui-utils.h
index 0eacd49b8..925ecc5cb 100644
--- a/libempathy-gtk/empathy-ui-utils.h
+++ b/libempathy-gtk/empathy-ui-utils.h
@@ -63,6 +63,7 @@ GtkWidget *empathy_builder_unref_and_keep_widget (GtkBuilder *gui,
/* Pixbufs */
const gchar * empathy_icon_name_for_presence (TpConnectionPresenceType presence);
const gchar * empathy_icon_name_for_contact (EmpathyContact *contact);
+const gchar * empathy_protocol_name_for_contact (EmpathyContact *contact);
GdkPixbuf * empathy_pixbuf_from_data (gchar *data,
gsize data_size);
GdkPixbuf * empathy_pixbuf_from_data_and_mime (gchar *data,
@@ -74,6 +75,14 @@ GdkPixbuf * empathy_pixbuf_from_avatar_scaled (EmpathyAvatar *avata
GdkPixbuf * empathy_pixbuf_avatar_from_contact_scaled (EmpathyContact *contact,
gint width,
gint height);
+GdkPixbuf * empathy_pixbuf_protocol_from_contact_scaled (EmpathyContact *contact,
+ gint width,
+ gint height);
+GdkPixbuf * empathy_pixbuf_contact_status_icon (EmpathyContact *contact,
+ gboolean show_protocol);
+GdkPixbuf * empathy_pixbuf_contact_status_icon_with_icon_name (EmpathyContact *contact,
+ const gchar *icon_name,
+ gboolean show_protocol);
GdkPixbuf * empathy_pixbuf_scale_down_if_necessary (GdkPixbuf *pixbuf,
gint max_size);
GdkPixbuf * empathy_pixbuf_from_icon_name (const gchar *icon_name,
diff --git a/src/empathy-main-window.c b/src/empathy-main-window.c
index 447e25b48..cbb6f10b0 100644
--- a/src/empathy-main-window.c
+++ b/src/empathy-main-window.c
@@ -94,6 +94,7 @@ typedef struct {
GtkWidget *presence_chooser;
GtkWidget *errors_vbox;
+ GtkToggleAction *show_protocols;
GtkRadioAction *sort_by_name;
GtkRadioAction *sort_by_status;
GtkRadioAction *normal_with_avatars;
@@ -131,8 +132,9 @@ main_window_flash_stop (EmpathyMainWindow *window)
}
typedef struct {
- EmpathyEvent *event;
- gboolean on;
+ EmpathyEvent *event;
+ gboolean on;
+ EmpathyMainWindow *window;
} FlashForeachData;
static gboolean
@@ -146,6 +148,7 @@ main_window_flash_foreach (GtkTreeModel *model,
const gchar *icon_name;
GtkTreePath *parent_path = NULL;
GtkTreeIter parent_iter;
+ GdkPixbuf *pixbuf = NULL;
/* To be used with gtk_tree_model_foreach, update the status icon
* of the contact to show the event icon (on=TRUE) or the presence
@@ -163,12 +166,17 @@ main_window_flash_foreach (GtkTreeModel *model,
if (data->on) {
icon_name = data->event->icon_name;
+ pixbuf = contact_list_store_get_contact_status_icon_with_icon_name (
+ data->window->list_store,
+ contact, icon_name);
} else {
- icon_name = empathy_icon_name_for_contact (contact);
+ pixbuf = contact_list_store_get_contact_status_icon (
+ data->window->list_store,
+ contact);
}
gtk_tree_store_set (GTK_TREE_STORE (model), iter,
- EMPATHY_CONTACT_LIST_STORE_COL_ICON_STATUS, icon_name,
+ EMPATHY_CONTACT_LIST_STORE_COL_ICON_STATUS, pixbuf,
-1);
/* To make sure the parent is shown correctly, we emit
@@ -203,6 +211,7 @@ main_window_flash_cb (EmpathyMainWindow *window)
events = empathy_event_manager_get_events (window->event_manager);
for (l = events; l; l = l->next) {
data.event = l->data;
+ data.window = window;
if (!data.event->contact || !data.event->must_ack) {
continue;
}
@@ -257,6 +266,7 @@ main_window_event_removed_cb (EmpathyEventManager *manager,
data.on = FALSE;
data.event = event;
+ data.window = window;
gtk_tree_model_foreach (GTK_TREE_MODEL (window->list_store),
main_window_flash_foreach,
&data);
@@ -747,6 +757,21 @@ main_window_view_sort_contacts_cb (GtkRadioAction *action,
empathy_contact_list_store_set_sort_criterium (window->list_store, value);
}
+static void
+main_window_view_show_protocols_cb (GtkToggleAction *action,
+ EmpathyMainWindow *window)
+{
+ gboolean value;
+
+ value = gtk_toggle_action_get_active (action);
+
+ empathy_conf_set_bool (empathy_conf_get (),
+ EMPATHY_PREFS_UI_SHOW_PROTOCOLS,
+ value == TRUE);
+ empathy_contact_list_store_set_show_protocols (window->list_store,
+ value == TRUE);
+}
+
/* Matches GtkRadioAction values set in empathy-main-window.ui */
#define CONTACT_LIST_NORMAL_SIZE_WITH_AVATARS 0
#define CONTACT_LIST_NORMAL_SIZE 1
@@ -772,8 +797,26 @@ main_window_view_contacts_list_size_cb (GtkRadioAction *action,
value == CONTACT_LIST_NORMAL_SIZE_WITH_AVATARS);
empathy_contact_list_store_set_is_compact (window->list_store,
value == CONTACT_LIST_COMPACT_SIZE);
+
+ gtk_action_set_sensitive (GTK_ACTION (window->show_protocols),
+ value != CONTACT_LIST_COMPACT_SIZE );
+}
+
+static void main_window_notify_show_protocols_cb (EmpathyConf *conf,
+ const gchar *key,
+ EmpathyMainWindow *window)
+{
+ gboolean show_protocols;
+
+ if (empathy_conf_get_bool (conf,
+ EMPATHY_PREFS_UI_SHOW_PROTOCOLS,
+ &show_protocols)) {
+ gtk_toggle_action_set_active (window->show_protocols,
+ show_protocols);
+ }
}
+
static void
main_window_notify_contact_list_size_cb (EmpathyConf *conf,
const gchar *key,
@@ -1193,6 +1236,7 @@ empathy_main_window_show (void)
"errors_vbox", &window->errors_vbox,
"ui_manager", &window->ui_manager,
"view_show_offline", &show_offline_widget,
+ "view_show_protocols", &window->show_protocols,
"view_sort_by_name", &window->sort_by_name,
"view_sort_by_status", &window->sort_by_status,
"view_normal_size_with_avatars", &window->normal_with_avatars,
@@ -1217,6 +1261,7 @@ empathy_main_window_show (void)
"chat_add_contact", "activate", main_window_chat_add_contact_cb,
"view_show_ft_manager", "activate", main_window_view_show_ft_manager,
"view_show_offline", "toggled", main_window_view_show_offline_cb,
+ "view_show_protocols", "toggled", main_window_view_show_protocols_cb,
"view_sort_by_name", "changed", main_window_view_sort_contacts_cb,
"view_normal_size_with_avatars", "changed", main_window_view_contacts_list_size_cb,
"view_show_map", "activate", main_window_view_show_map_cb,
@@ -1354,6 +1399,16 @@ empathy_main_window_show (void)
gtk_toggle_action_set_active (show_offline_widget, show_offline);
+ /* Show protocol ? */
+ empathy_conf_notify_add (conf,
+ EMPATHY_PREFS_UI_SHOW_PROTOCOLS,
+ (EmpathyConfNotifyFunc) main_window_notify_show_protocols_cb,
+ window);
+
+ main_window_notify_show_protocols_cb (conf,
+ EMPATHY_PREFS_UI_SHOW_PROTOCOLS,
+ window);
+
/* Sort by name / by status ? */
empathy_conf_notify_add (conf,
EMPATHY_PREFS_CONTACTS_SORT_CRITERIUM,
diff --git a/src/empathy-main-window.ui b/src/empathy-main-window.ui
index 26edc6bdf..b74f4acb9 100644
--- a/src/empathy-main-window.ui
+++ b/src/empathy-main-window.ui
@@ -48,6 +48,12 @@
<accelerator key="H" modifiers="GDK_CONTROL_MASK"/>
</child>
<child>
+ <object class="GtkToggleAction" id="view_show_protocols">
+ <property name="name">view_show_protocols</property>
+ <property name="label" translatable="yes">Show P_rotocols</property>
+ </object>
+ </child>
+ <child>
<object class="GtkAction" id="view_show_map">
<property name="name">view_show_map</property>
<property name="label" translatable="yes">Contacts on a _Map</property>
@@ -221,6 +227,7 @@
</menu>
<menu action="view">
<menuitem action="view_show_offline"/>
+ <menuitem action="view_show_protocols"/>
<separator/>
<menuitem action="view_sort_by_name"/>
<menuitem action="view_sort_by_status"/>