From aad7b3c8c9130194a160c1745f3ecefbc925a9ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Grisez?= Date: Thu, 22 Oct 2015 14:27:07 +0200 Subject: [PATCH] Automatically select a friend when right clicking in the friend list --- gtk/friendlist.c | 25 ++++++++++++++----------- gtk/linphone.h | 2 +- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/gtk/friendlist.c b/gtk/friendlist.c index 8b4a0dd3c..e4c6b5f88 100644 --- a/gtk/friendlist.c +++ b/gtk/friendlist.c @@ -911,32 +911,35 @@ static void select_row(GtkTreeView *treeview, GtkTreePath *path) { gtk_tree_selection_select_path(selection, path); } -gboolean linphone_gtk_contact_list_button_pressed(GtkWidget *widget, GdkEventButton *event){ +gboolean linphone_gtk_contact_list_button_pressed(GtkTreeView *friendlist, GdkEventButton *event){ /* Ignore double-clicks and triple-clicks */ - GtkTreeView *friendlist = GTK_TREE_VIEW(widget); gboolean ret = FALSE; + int x_bin, y_bin; + GtkTreePath *path; + GtkTreeViewColumn *column; + GtkTreeSelection *selection = gtk_tree_view_get_selection(friendlist); + + gtk_tree_view_convert_widget_to_bin_window_coords(friendlist, event->x, event->y, &x_bin, &y_bin); + gtk_tree_view_get_path_at_pos(friendlist, x_bin, y_bin, &path, &column, NULL, NULL); + if (event->button == 3 && event->type == GDK_BUTTON_PRESS) { - return linphone_gtk_popup_contact_menu(widget, event); + if(path) gtk_tree_selection_select_path(selection, path); + ret = linphone_gtk_popup_contact_menu(GTK_WIDGET(friendlist), event); } else if(event->button == 1 && event->type == GDK_BUTTON_PRESS){ - int x_bin, y_bin; - GtkTreePath *path; - GtkTreeViewColumn *column; - gtk_tree_view_convert_widget_to_bin_window_coords(friendlist, event->x, event->y, &x_bin, &y_bin); - gtk_tree_view_get_path_at_pos(friendlist, x_bin, y_bin, &path, &column, NULL, NULL); if(path && column) { int numcol = get_column_index(friendlist, column); if(numcol == 2) { select_row(friendlist, path); - linphone_gtk_call_selected(GTK_TREE_VIEW(widget)); + linphone_gtk_call_selected(friendlist); ret = TRUE; } else if(numcol == 3) { select_row(friendlist, path); - linphone_gtk_chat_selected(widget); + linphone_gtk_chat_selected(GTK_WIDGET(friendlist)); ret = TRUE; } } - if(path) gtk_tree_path_free(path); } + if(path) gtk_tree_path_free(path); return ret; } diff --git a/gtk/linphone.h b/gtk/linphone.h index 7f8c0cc27..c372a4314 100644 --- a/gtk/linphone.h +++ b/gtk/linphone.h @@ -234,7 +234,7 @@ LINPHONE_PUBLIC void linphone_gtk_remove_button_clicked(GtkWidget *button); LINPHONE_PUBLIC void linphone_gtk_my_presence_clicked(GtkWidget *button); LINPHONE_PUBLIC void linphone_gtk_directory_search_button_clicked(GtkWidget *button); LINPHONE_PUBLIC gboolean linphone_gtk_popup_contact_menu(GtkWidget *list, GdkEventButton *event); -gboolean linphone_gtk_contact_list_button_pressed(GtkWidget* firendlist, GdkEventButton* event); +LINPHONE_PUBLIC gboolean linphone_gtk_contact_list_button_pressed(GtkTreeView* firendlist, GdkEventButton* event); LINPHONE_PUBLIC void linphone_gtk_auth_token_verified_clicked(GtkButton *button); LINPHONE_PUBLIC void linphone_gtk_hold_clicked(GtkButton *button); LINPHONE_PUBLIC void linphone_gtk_record_call_toggled(GtkWidget *button);