From 2bfcf29cb526992dd0ec69d36b299dd7ff93f0b5 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Mon, 19 Oct 2015 23:30:37 +0200 Subject: [PATCH] gtk friendlist: only make call and chat button visible when clicked. --- gtk/friendlist.c | 60 +++++++++++++++++++---- gtk/main.ui | 122 +++++++++++++++++++++++++++++++---------------- 2 files changed, 133 insertions(+), 49 deletions(-) diff --git a/gtk/friendlist.c b/gtk/friendlist.c index 0c1a32da9..812f1a15d 100644 --- a/gtk/friendlist.c +++ b/gtk/friendlist.c @@ -29,6 +29,8 @@ enum{ FRIEND_CHATROOM, FRIEND_SIP_ADDRESS, FRIEND_CHAT, + FRIEND_CALL_BUTTON, + FRIEND_CHAT_BUTTON_VISIBLE, FRIEND_LIST_NCOL }; @@ -181,29 +183,53 @@ static void linphone_gtk_call_selected(GtkTreeView *treeview){ } void linphone_gtk_friend_list_update_chat_picture(){ - GtkTreeIter iter; + GtkTreeIter iter, selected_iter; GtkWidget *w = linphone_gtk_get_main_window(); GtkWidget *friendlist=linphone_gtk_get_widget(w,"contact_list"); GtkTreeModel *model=gtk_tree_view_get_model(GTK_TREE_VIEW(friendlist)); + GtkTreeSelection *select=gtk_tree_view_get_selection(GTK_TREE_VIEW(friendlist)); LinphoneChatRoom *cr=NULL; bool_t is_composing; int nbmsg=0; + GtkTreePath *selected_path = NULL; + + if (gtk_tree_selection_get_selected(select, &model, &selected_iter)){ + selected_path = gtk_tree_model_get_path(model, &selected_iter); + } + if (gtk_tree_model_get_iter_first(model,&iter)) { do{ const char *icon_name = NULL; + bool_t is_visible = FALSE; gtk_tree_model_get (model, &iter,FRIEND_CHATROOM , &cr, -1); + nbmsg=linphone_chat_room_get_unread_messages_count(cr); is_composing=linphone_chat_room_is_remote_composing(cr); if(nbmsg != 0){ if (is_composing == TRUE) icon_name = "linphone-chat-new-message-and-writing"; else icon_name = "linphone-chat-new-message"; + is_visible = TRUE; } else { - if (is_composing == TRUE) icon_name = "linphone-chat-writing"; - else icon_name = "linphone-chat-nothing"; + if (is_composing == TRUE) { + icon_name = "linphone-chat-writing"; + is_visible = TRUE; + } + else { + icon_name = "linphone-chat-nothing"; + if (selected_path){ + GtkTreePath *path = gtk_tree_model_get_path(model, &iter); + if (gtk_tree_path_compare(path, selected_path) == 0){ + is_visible = TRUE; + } + gtk_tree_path_free(path); + } + } } - gtk_list_store_set(GTK_LIST_STORE(model),&iter,FRIEND_CHAT,icon_name,-1); + gtk_list_store_set(GTK_LIST_STORE(model),&iter,FRIEND_CHAT,icon_name, + FRIEND_CHAT_BUTTON_VISIBLE, is_visible, -1); }while(gtk_tree_model_iter_next(model,&iter)); } + if (selected_path) gtk_tree_path_free(selected_path); } static gboolean grab_focus(GtkWidget *w){ @@ -333,16 +359,34 @@ void linphone_gtk_chat_selected(GtkWidget *item){ } } -void linphone_gtk_contact_activated(GtkTreeView *treeview, + +void linphone_gtk_contact_activated(GtkTreeView *friendlist, GtkTreePath *path, GtkTreeViewColumn *column, - gpointer user_data) -{ - //linphone_gtk_call_selected(treeview); + gpointer user_data){ +} + +static void linphone_gtk_enable_buttons_for_selection(GtkTreeView *friendlist){ + GtkTreeSelection *select=gtk_tree_view_get_selection(GTK_TREE_VIEW(friendlist)); + GtkListStore * store=GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(friendlist))); + GtkTreeIter iter; + GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(friendlist)); + + if (gtk_tree_model_get_iter_first(model, &iter)){ + do{ + gtk_list_store_set(store, &iter, FRIEND_CALL_BUTTON, FALSE, -1); + }while (gtk_tree_model_iter_next(model, &iter)); + } + + if (gtk_tree_selection_get_selected (select, &model, &iter)){ + gtk_list_store_set(store, &iter, FRIEND_CALL_BUTTON, TRUE, -1); + } + linphone_gtk_friend_list_update_chat_picture(); } void linphone_gtk_contact_clicked(GtkTreeView *treeview){ linphone_gtk_set_selection_to_uri_bar(treeview); + linphone_gtk_enable_buttons_for_selection(treeview); if(GPOINTER_TO_INT(g_object_get_data(G_OBJECT(treeview),"numcol"))==1){ linphone_gtk_call_selected(treeview); } else { diff --git a/gtk/main.ui b/gtk/main.ui index 27d60138a..70a30b5ff 100644 --- a/gtk/main.ui +++ b/gtk/main.ui @@ -38,6 +38,10 @@ + + + + @@ -45,18 +49,24 @@ Toto toto@sip.linphone.org linphone-chat-nothing + False + False linphone-status-offline Toto2 toto2@sip.linphone.org linphone-chat-nothing + False + False linphone-status-offline Toto3 toto3@sip.linphone.org linphone-chat-nothing + False + False @@ -85,47 +95,6 @@ False gtk-info - - - - - - - - Default - - - - - True - False - 0.49000000953674316 - gtk-properties - - - True - False - Delete - gtk-remove - - - True - False - Delete - gtk-remove - - - True - False - 32 - linphone-start-call - - - True - False - 32 - linphone-start-chat - 640 480 @@ -146,6 +115,7 @@ True False + False _Options True @@ -158,6 +128,7 @@ gtk-preferences True False + False True True @@ -167,6 +138,7 @@ True False + False Set configuration URI True @@ -176,6 +148,7 @@ gtk-disconnect False + False True True @@ -191,6 +164,7 @@ True False + False Always start video True @@ -200,6 +174,7 @@ True False + False Enable self-view True True @@ -210,6 +185,7 @@ True False + False Show keypad True @@ -225,6 +201,7 @@ gtk-quit False + False True True @@ -238,6 +215,7 @@ True False + False _Help True @@ -249,6 +227,7 @@ gtk-about True False + False True True @@ -259,6 +238,7 @@ Show debug window True False + False info_image False @@ -269,6 +249,7 @@ _Homepage True False + False True home_image False @@ -279,6 +260,7 @@ Check _Updates False + False True execute_image False @@ -289,6 +271,7 @@ Account assistant False + False connect_image False @@ -299,6 +282,7 @@ Audio assistant True False + False properties_image False @@ -388,6 +372,7 @@ True True Initiate a new call + False add_call_image @@ -402,6 +387,7 @@ True True True + False start_call_image @@ -416,6 +402,7 @@ True True True + False start_chat_image @@ -512,6 +499,9 @@ linphone-start-call2 3 + + 6 + @@ -522,6 +512,7 @@ 3 + 7 5 @@ -547,6 +538,7 @@ True True immediate + False add_image1 1 @@ -562,6 +554,7 @@ True True True + False edit_image1 @@ -576,6 +569,7 @@ True True True + False remove_image1 @@ -674,6 +668,7 @@ True True True + False none @@ -740,6 +735,7 @@ Add contact True True + False @@ -773,6 +769,7 @@ True True True + False True @@ -894,6 +891,7 @@ True True True + False none @@ -930,6 +928,7 @@ True True True + False none @@ -971,4 +970,45 @@ + + + + + + + + Default + + + + + True + False + 0.49000000953674316 + gtk-properties + + + True + False + Delete + gtk-remove + + + True + False + Delete + gtk-remove + + + True + False + 32 + linphone-start-call + + + True + False + 32 + linphone-start-chat +