diff options
author | Emilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk> | 2011-05-10 02:53:32 +0800 |
---|---|---|
committer | Emilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk> | 2011-05-10 22:51:52 +0800 |
commit | 36ee35009dc6a0e85be95ed9a1757c589582e4e8 (patch) | |
tree | a54a23a041e45783376210786169231e14bd157e /libempathy-gtk | |
parent | 3d7ac0c0d325997b277a8ce55df206fc28cd1d1c (diff) | |
download | gsoc2013-empathy-36ee35009dc6a0e85be95ed9a1757c589582e4e8.tar gsoc2013-empathy-36ee35009dc6a0e85be95ed9a1757c589582e4e8.tar.gz gsoc2013-empathy-36ee35009dc6a0e85be95ed9a1757c589582e4e8.tar.bz2 gsoc2013-empathy-36ee35009dc6a0e85be95ed9a1757c589582e4e8.tar.lz gsoc2013-empathy-36ee35009dc6a0e85be95ed9a1757c589582e4e8.tar.xz gsoc2013-empathy-36ee35009dc6a0e85be95ed9a1757c589582e4e8.tar.zst gsoc2013-empathy-36ee35009dc6a0e85be95ed9a1757c589582e4e8.zip |
LogWindow: better logic for the buttons sensitivity
Diffstat (limited to 'libempathy-gtk')
-rw-r--r-- | libempathy-gtk/empathy-log-window.c | 67 |
1 files changed, 55 insertions, 12 deletions
diff --git a/libempathy-gtk/empathy-log-window.c b/libempathy-gtk/empathy-log-window.c index e1c9856cb..648a6af6f 100644 --- a/libempathy-gtk/empathy-log-window.c +++ b/libempathy-gtk/empathy-log-window.c @@ -1499,9 +1499,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, @@ -1510,7 +1561,6 @@ log_window_who_changed_cb (GtkTreeSelection *selection, GtkTreeView *view; GtkTreeModel *model; GtkTreeIter iter; - gboolean someone = FALSE; DEBUG ("log_window_who_changed_cb"); @@ -1533,16 +1583,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); |