From cfaa76cf91c2037b0ffe49730417afe3132332cb Mon Sep 17 00:00:00 2001 From: Emilio Pozuelo Monfort Date: Wed, 27 Apr 2011 11:47:25 +0100 Subject: Fix buttons to work again with multiselection --- libempathy-gtk/empathy-log-window.c | 83 +++++++++++++++++++++---------------- 1 file changed, 48 insertions(+), 35 deletions(-) diff --git a/libempathy-gtk/empathy-log-window.c b/libempathy-gtk/empathy-log-window.c index ca36c83d4..1ed0b44c9 100644 --- a/libempathy-gtk/empathy-log-window.c +++ b/libempathy-gtk/empathy-log-window.c @@ -283,6 +283,8 @@ toolbutton_profile_clicked (GtkToolButton *toolbutton, GtkTreeSelection *selection; GtkTreeModel *model; GtkTreeIter iter; + GtkTreePath *path; + GList *paths; TpAccount *account; TplEntity *target; EmpathyContact *contact; @@ -293,26 +295,25 @@ toolbutton_profile_clicked (GtkToolButton *toolbutton, view = GTK_TREE_VIEW (log_window->treeview_who); selection = gtk_tree_view_get_selection (view); - if (gtk_tree_selection_get_selected (selection, &model, &iter)) - { - gtk_tree_model_get (model, &iter, - COL_WHO_ACCOUNT, &account, - COL_WHO_TARGET, &target, - COL_WHO_TYPE, &type, - -1); - } + paths = gtk_tree_selection_get_selected_rows (selection, &model); + g_return_if_fail (paths != NULL); - if (type == COL_TYPE_NORMAL) - { - contact = empathy_contact_from_tpl_contact (account, target); - empathy_contact_information_dialog_show (contact, - GTK_WINDOW (window->window)); - g_object_unref (contact); - } - else - { - g_warn_if_reached (); - } + 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, + COL_WHO_TYPE, &type, + -1); + + g_list_free_full (paths, (GDestroyNotify) gtk_tree_path_free); + + g_return_if_fail (type == COL_TYPE_NORMAL); + + contact = empathy_contact_from_tpl_contact (account, target); + empathy_contact_information_dialog_show (contact, + GTK_WINDOW (window->window)); + g_object_unref (contact); g_object_unref (account); g_object_unref (target); @@ -326,6 +327,8 @@ toolbutton_chat_clicked (GtkToolButton *toolbutton, GtkTreeSelection *selection; GtkTreeModel *model; GtkTreeIter iter; + GtkTreePath *path; + GList *paths; TpAccount *account; TplEntity *target; EmpathyContact *contact; @@ -336,14 +339,18 @@ toolbutton_chat_clicked (GtkToolButton *toolbutton, view = GTK_TREE_VIEW (log_window->treeview_who); selection = gtk_tree_view_get_selection (view); - if (gtk_tree_selection_get_selected (selection, &model, &iter)) - { - gtk_tree_model_get (model, &iter, - COL_WHO_ACCOUNT, &account, - COL_WHO_TARGET, &target, - COL_WHO_TYPE, &type, - -1); - } + 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, + COL_WHO_TYPE, &type, + -1); + + g_list_free_full (paths, (GDestroyNotify) gtk_tree_path_free); g_return_if_fail (type == COL_TYPE_NORMAL); @@ -364,6 +371,8 @@ toolbutton_av_clicked (GtkToolButton *toolbutton, GtkTreeSelection *selection; GtkTreeModel *model; GtkTreeIter iter; + GtkTreePath *path; + GList *paths; TpAccount *account; gchar *contact; gint type; @@ -374,14 +383,18 @@ toolbutton_av_clicked (GtkToolButton *toolbutton, view = GTK_TREE_VIEW (log_window->treeview_who); selection = gtk_tree_view_get_selection (view); - if (gtk_tree_selection_get_selected (selection, &model, &iter)) - { - gtk_tree_model_get (model, &iter, - COL_WHO_ACCOUNT, &account, - COL_WHO_NAME, &contact, - COL_WHO_TYPE, &type, - -1); - } + 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_NAME, &contact, + COL_WHO_TYPE, &type, + -1); + + g_list_free_full (paths, (GDestroyNotify) gtk_tree_path_free); g_return_if_fail (type == COL_TYPE_NORMAL); -- cgit v1.2.3