Commit 789bc59f authored by François Grisez's avatar François Grisez

Rework friendlist in order to show buttons while hovering the friendlist

parent 36da7e74
......@@ -92,7 +92,6 @@ void linphone_gtk_quit_chatroom(LinphoneChatRoom *cr) {
g_return_if_fail(w!=NULL);
gtk_notebook_remove_page(GTK_NOTEBOOK(nb),gtk_notebook_page_num(GTK_NOTEBOOK(nb),w));
linphone_chat_room_mark_as_read(cr);
linphone_gtk_friend_list_update_chat_picture();
g_object_set_data(G_OBJECT(friendlist),"chatview",NULL);
from=g_object_get_data(G_OBJECT(w),"from_message");
if (from){
......@@ -291,7 +290,7 @@ void linphone_gtk_compose_text(void) {
if (cr) {
linphone_chat_room_compose(cr);
linphone_chat_room_mark_as_read(cr);
linphone_gtk_friend_list_update_chat_picture();
linphone_gtk_friend_list_update_button_display(GTK_TREE_VIEW(friendlist));
}
}
......@@ -389,6 +388,8 @@ static gboolean link_event_handler(GtkTextTag *tag, GObject *text_view,GdkEvent
GtkTextIter uri_end = *iter;
gchar *uri = NULL;
LinphoneChatRoom *chat_room = (LinphoneChatRoom *)g_object_get_data(G_OBJECT(chat_view), "cr");
GtkWidget *main_window = linphone_gtk_get_main_window();
GtkWidget *friendlist = linphone_gtk_get_widget(main_window, "contact_list");
gtk_text_iter_backward_to_tag_toggle(&uri_begin, tag);
gtk_text_iter_forward_to_tag_toggle(&uri_end, tag);
......@@ -403,7 +404,7 @@ static gboolean link_event_handler(GtkTextTag *tag, GObject *text_view,GdkEvent
g_free(uri);
linphone_chat_room_mark_as_read(chat_room);
linphone_gtk_friend_list_update_chat_picture();
linphone_gtk_friend_list_update_button_display(GTK_TREE_VIEW(friendlist));
return TRUE;
}
......@@ -645,5 +646,7 @@ void linphone_gtk_text_received ( LinphoneCore *lc, LinphoneChatRoom *room,
}
void linphone_gtk_is_composing_received(LinphoneCore *lc, LinphoneChatRoom *room) {
linphone_gtk_friend_list_update_chat_picture();
GtkWidget *main_window = linphone_gtk_get_main_window();
GtkWidget *friendlist = linphone_gtk_get_widget(main_window, "contact_list");
linphone_gtk_friend_list_update_button_display(GTK_TREE_VIEW(friendlist));
}
......@@ -29,7 +29,7 @@ enum{
FRIEND_CHATROOM,
FRIEND_SIP_ADDRESS,
FRIEND_CHAT,
FRIEND_CALL_BUTTON,
FRIEND_CALL_BUTTON_VISIBLE,
FRIEND_CHAT_BUTTON_VISIBLE,
FRIEND_LIST_NCOL
};
......@@ -182,16 +182,15 @@ static void linphone_gtk_call_selected(GtkTreeView *treeview){
"start_call"));
}
void linphone_gtk_friend_list_update_chat_picture(){
void linphone_gtk_friend_list_update_button_display(GtkTreeView *friendlist){
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));
GtkTreeModel *model=gtk_tree_view_get_model(friendlist);
GtkTreeSelection *select=gtk_tree_view_get_selection(friendlist);
LinphoneChatRoom *cr=NULL;
bool_t is_composing;
gboolean is_composing;
int nbmsg=0;
GtkTreePath *selected_path = NULL;
GtkTreePath *hovered_row = (GtkTreePath *)g_object_get_data(G_OBJECT(friendlist), "hovered_row");
if (gtk_tree_selection_get_selected(select, &model, &selected_iter)){
selected_path = gtk_tree_model_get_path(model, &selected_iter);
......@@ -200,33 +199,35 @@ void linphone_gtk_friend_list_update_chat_picture(){
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);
gboolean show_chat_button = FALSE;
gboolean show_call_button = FALSE;
GtkTreePath *path = gtk_tree_model_get_path(model, &iter);
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";
if (is_composing) icon_name = "linphone-chat-new-message-and-writing";
else icon_name = "linphone-chat-new-message";
is_visible = TRUE;
show_chat_button = TRUE;
} else {
if (is_composing == TRUE) {
if (is_composing) {
icon_name = "linphone-chat-writing";
is_visible = TRUE;
}
else {
show_chat_button = 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);
}
}
}
if ((selected_path && gtk_tree_path_compare(path, selected_path) == 0)
|| (hovered_row && gtk_tree_path_compare(path, hovered_row) == 0)){
show_chat_button = TRUE;
show_call_button = TRUE;
}
gtk_list_store_set(GTK_LIST_STORE(model),&iter,FRIEND_CHAT,icon_name,
FRIEND_CHAT_BUTTON_VISIBLE, is_visible, -1);
FRIEND_CHAT_BUTTON_VISIBLE, show_chat_button, -1);
gtk_list_store_set(GTK_LIST_STORE(model), &iter, FRIEND_CALL_BUTTON_VISIBLE, show_call_button, -1);
gtk_tree_path_free(path);
}while(gtk_tree_model_iter_next(model,&iter));
}
if (selected_path) gtk_tree_path_free(selected_path);
......@@ -271,7 +272,7 @@ void linphone_gtk_friend_list_set_chat_conversation(const LinphoneAddress *la){
linphone_gtk_load_chatroom(cr,la,chat_view);
}
gtk_notebook_set_current_page(notebook,gtk_notebook_page_num(notebook,chat_view));
linphone_gtk_friend_list_update_chat_picture();
linphone_gtk_friend_list_update_button_display(GTK_TREE_VIEW(chat_view));
g_idle_add((GSourceFunc)grab_focus,linphone_gtk_get_widget(chat_view,"text_entry"));
} else {
store=GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(friendlist)));
......@@ -294,7 +295,7 @@ void linphone_gtk_friend_list_set_chat_conversation(const LinphoneAddress *la){
linphone_gtk_load_chatroom(cr,uri,chat_view);
}
gtk_notebook_set_current_page(notebook,gtk_notebook_page_num(notebook,chat_view));
linphone_gtk_friend_list_update_chat_picture();
linphone_gtk_friend_list_update_button_display(GTK_TREE_VIEW(chat_view));
g_idle_add((GSourceFunc)grab_focus,linphone_gtk_get_widget(chat_view,"text_entry"));
break;
}
......@@ -344,7 +345,7 @@ void linphone_gtk_chat_selected(GtkWidget *item){
cr=linphone_gtk_create_chatroom(uri);
gtk_list_store_set(store,&iter,FRIEND_CHATROOM,cr,-1);
}
page=(GtkWidget*)g_object_get_data(G_OBJECT(friendlist),"chatview");
page=GTK_WIDGET(g_object_get_data(G_OBJECT(friendlist),"chatview"));
linphone_gtk_friend_list_set_active_address(uri);
if(page==NULL){
page=linphone_gtk_init_chatroom(cr,uri);
......@@ -354,39 +355,13 @@ void linphone_gtk_chat_selected(GtkWidget *item){
}
linphone_chat_room_mark_as_read(cr);
gtk_notebook_set_current_page(notebook,gtk_notebook_page_num(notebook,page));
linphone_gtk_friend_list_update_chat_picture();
g_idle_add((GSourceFunc)grab_focus,linphone_gtk_get_widget(page,"text_entry"));
}
}
void linphone_gtk_contact_activated(GtkTreeView *friendlist,
GtkTreePath *path,
GtkTreeViewColumn *column,
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);
linphone_gtk_friend_list_update_button_display(treeview);
if(GPOINTER_TO_INT(g_object_get_data(G_OBJECT(treeview),"numcol"))==1){
linphone_gtk_call_selected(treeview);
} else {
......@@ -1021,3 +996,29 @@ void linphone_gtk_buddy_info_updated(LinphoneCore *lc, LinphoneFriend *lf){
/*refresh the entire list*/
linphone_gtk_show_friends();
}
static void update_hovered_row_path(GtkTreeView *friendlist, int x_window, int y_window) {
int x_bin, y_bin;
GtkTreePath *path;
gtk_tree_view_convert_widget_to_bin_window_coords(friendlist, x_window, y_window, &x_bin, &y_bin);
gtk_tree_view_get_path_at_pos(friendlist, x_bin, y_bin, &path, NULL, NULL, NULL);
g_object_set_data_full(G_OBJECT(friendlist), "hovered_row", path, (GDestroyNotify)gtk_tree_path_free);
}
gboolean linphone_gtk_friend_list_enter_event_handler(GtkTreeView *friendlist, GdkEventCrossing *event) {
update_hovered_row_path(friendlist, event->x, event->y);
linphone_gtk_friend_list_update_button_display(friendlist);
return FALSE;
}
gboolean linphone_gtk_friend_list_leave_event_handler(GtkTreeView *friendlist, GdkEventCrossing *event) {
g_object_set_data(G_OBJECT(friendlist), "hovered_row", NULL);
linphone_gtk_friend_list_update_button_display(friendlist);
return FALSE;
}
gboolean linphone_gtk_friend_list_motion_event_handler(GtkTreeView *friendlist, GdkEventMotion *event) {
update_hovered_row_path(friendlist, event->x, event->y);
linphone_gtk_friend_list_update_button_display(friendlist);
return FALSE;
}
\ No newline at end of file
......@@ -154,12 +154,14 @@ LINPHONE_PUBLIC LinphoneChatRoom * linphone_gtk_create_chatroom(const LinphoneAd
LINPHONE_PUBLIC void linphone_gtk_text_received(LinphoneCore *lc, LinphoneChatRoom *room, LinphoneChatMessage *msg);
LINPHONE_PUBLIC void linphone_gtk_is_composing_received(LinphoneCore *lc, LinphoneChatRoom *room);
LINPHONE_PUBLIC void linphone_gtk_friend_list_update_chat_picture();
LINPHONE_PUBLIC void linphone_gtk_friend_list_update_button_display(GtkTreeView *friendlist);
LINPHONE_PUBLIC void linphone_gtk_friend_list_set_chat_conversation(const LinphoneAddress *la);
LINPHONE_PUBLIC gboolean linphone_gtk_friend_list_is_contact(const LinphoneAddress *addr);
LINPHONE_PUBLIC void linphone_gtk_friend_list_set_active_address(const LinphoneAddress *addr);
LINPHONE_PUBLIC const LinphoneAddress *linphone_gtk_friend_list_get_active_address(void);
// LINPHONE_PUBLIC void linphone_gtk_friend_list_on_presence_column_clicked(GtkTreeModel *model);
LINPHONE_PUBLIC gboolean linphone_gtk_friend_list_enter_event_handler(GtkTreeView *friendlist, GdkEventCrossing *event);
LINPHONE_PUBLIC gboolean linphone_gtk_friend_list_leave_event_handler(GtkTreeView *friendlist, GdkEventCrossing *event);
LINPHONE_PUBLIC gboolean linphone_gtk_friend_list_motion_event_handler(GtkTreeView *friendlist, GdkEventMotion *event);
LINPHONE_PUBLIC void linphone_gtk_friend_list_on_name_column_clicked(GtkTreeModel *model);
LINPHONE_PUBLIC void linphone_gtk_notebook_tab_select(GtkNotebook *notebook, GtkWidget *page, guint page_num, gpointer data);
LINPHONE_PUBLIC void linphone_gtk_show_friends(void);
......@@ -224,7 +226,6 @@ LINPHONE_PUBLIC void linphone_gtk_history_row_activated(GtkWidget *treeview);
LINPHONE_PUBLIC void linphone_gtk_history_row_selected(GtkWidget *treeview);
LINPHONE_PUBLIC void linphone_gtk_clear_call_logs(GtkWidget *button);
LINPHONE_PUBLIC void linphone_gtk_add_contact(void);
LINPHONE_PUBLIC void linphone_gtk_contact_activated(GtkTreeView *treeview, GtkTreePath *path, GtkTreeViewColumn *column, gpointer user_data);
LINPHONE_PUBLIC void linphone_gtk_contact_clicked(GtkTreeView *treeview);
LINPHONE_PUBLIC void linphone_gtk_add_button_clicked(void);
LINPHONE_PUBLIC void linphone_gtk_edit_button_clicked(GtkWidget *button);
......
......@@ -492,7 +492,9 @@
<property name="tooltip_column">4</property>
<signal name="button-press-event" handler="linphone_gtk_contact_list_button_pressed" swapped="no"/>
<signal name="cursor-changed" handler="linphone_gtk_contact_clicked" swapped="no"/>
<signal name="row-activated" handler="linphone_gtk_contact_activated" swapped="no"/>
<signal name="leave-notify-event" handler="linphone_gtk_friend_list_leave_event_handler" swapped="no"/>
<signal name="enter-notify-event" handler="linphone_gtk_friend_list_enter_event_handler" swapped="no"/>
<signal name="motion-notify-event" handler="linphone_gtk_friend_list_motion_event_handler" swapped="no"/>
<signal name="popup-menu" handler="linphone_gtk_popup_contact_menu" swapped="no"/>
<child>
<object class="GtkTreeViewColumn" id="presence_status_column">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment