aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy-gtk
diff options
context:
space:
mode:
authorEmilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk>2011-05-10 02:53:32 +0800
committerEmilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk>2011-06-09 19:34:57 +0800
commit0fbbd7093243ca64a98ca6b81b2cf9e3439c041a (patch)
treed4e96b61061b284326a28d2734bc3a2699ce3e7c /libempathy-gtk
parent577effbd7b0a97ce168105feb184ad5671db2bb6 (diff)
downloadgsoc2013-empathy-0fbbd7093243ca64a98ca6b81b2cf9e3439c041a.tar
gsoc2013-empathy-0fbbd7093243ca64a98ca6b81b2cf9e3439c041a.tar.gz
gsoc2013-empathy-0fbbd7093243ca64a98ca6b81b2cf9e3439c041a.tar.bz2
gsoc2013-empathy-0fbbd7093243ca64a98ca6b81b2cf9e3439c041a.tar.lz
gsoc2013-empathy-0fbbd7093243ca64a98ca6b81b2cf9e3439c041a.tar.xz
gsoc2013-empathy-0fbbd7093243ca64a98ca6b81b2cf9e3439c041a.tar.zst
gsoc2013-empathy-0fbbd7093243ca64a98ca6b81b2cf9e3439c041a.zip
LogWindow: better logic for the buttons sensitivity
Diffstat (limited to 'libempathy-gtk')
-rw-r--r--libempathy-gtk/empathy-log-window.c67
1 files changed, 55 insertions, 12 deletions
diff --git a/libempathy-gtk/empathy-log-window.c b/libempathy-gtk/empathy-log-window.c
index 84af51ce4..47cc365ef 100644
--- a/libempathy-gtk/empathy-log-window.c
+++ b/libempathy-gtk/empathy-log-window.c
@@ -1500,9 +1500,60 @@ log_window_search_entry_icon_pressed_cb (GtkEntry *entry,
"", -1);
}
-/*
- * Chats Code
- */
+static void
+log_window_update_buttons_sensitivity (EmpathyLogWindow *window,
+ GtkTreeModel *model,
+ GtkTreeSelection *selection)
+{
+ EmpathyContact *contact;
+ EmpathyCapabilities capabilities;
+ TpAccount *account;
+ TplEntity *target;
+ GtkTreeIter iter;
+ GList *paths;
+ GtkTreePath *path;
+ gboolean profile, chat, call, video;
+
+ profile = chat = call = video = FALSE;
+
+ if (!gtk_tree_model_get_iter_first (model, &iter))
+ goto out;
+
+ if (gtk_tree_selection_count_selected_rows (selection) != 1)
+ goto out;
+
+ if (gtk_tree_selection_iter_is_selected (selection, &iter))
+ goto out;
+
+ paths = gtk_tree_selection_get_selected_rows (selection, &model);
+ g_return_if_fail (paths != NULL);
+
+ path = paths->data;
+ gtk_tree_model_get_iter (model, &iter, path);
+ gtk_tree_model_get (model, &iter,
+ COL_WHO_ACCOUNT, &account,
+ COL_WHO_TARGET, &target,
+ -1);
+
+ g_list_free_full (paths, (GDestroyNotify) gtk_tree_path_free);
+
+ contact = empathy_contact_from_tpl_contact (account, target);
+
+ g_object_unref (account);
+ g_object_unref (target);
+
+ capabilities = empathy_contact_get_capabilities (contact);
+
+ profile = chat = TRUE;
+ call = capabilities & EMPATHY_CAPABILITIES_AUDIO;
+ video = capabilities & EMPATHY_CAPABILITIES_VIDEO;
+
+ out:
+ gtk_widget_set_sensitive (window->button_profile, profile);
+ gtk_widget_set_sensitive (window->button_chat, chat);
+ gtk_widget_set_sensitive (window->button_call, call);
+ gtk_widget_set_sensitive (window->button_video, video);
+}
static void
log_window_who_changed_cb (GtkTreeSelection *selection,
@@ -1511,7 +1562,6 @@ log_window_who_changed_cb (GtkTreeSelection *selection,
GtkTreeView *view;
GtkTreeModel *model;
GtkTreeIter iter;
- gboolean someone = FALSE;
DEBUG ("log_window_who_changed_cb");
@@ -1534,16 +1584,9 @@ log_window_who_changed_cb (GtkTreeSelection *selection,
log_window_who_changed_cb,
window);
}
- else if (gtk_tree_selection_count_selected_rows (selection) == 1)
- {
- someone = TRUE;
- }
}
- gtk_widget_set_sensitive (window->button_profile, someone);
- gtk_widget_set_sensitive (window->button_chat, someone);
- gtk_widget_set_sensitive (window->button_call, someone);
- gtk_widget_set_sensitive (window->button_video, someone);
+ log_window_update_buttons_sensitivity (window, model, selection);
/* The contact changed, so the dates need to be updated */
log_window_chats_get_messages (window, TRUE);