Commit 323ce9f1 authored by Erwan Croze's avatar Erwan Croze 👋🏻
Browse files

Add shortcut for quickly accessing chatroom from the friendlist

parent 71cf2820
...@@ -19,6 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ...@@ -19,6 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "linphone.h" #include "linphone.h"
#include <bctoolbox/bc_vfs.h> #include <bctoolbox/bc_vfs.h>
#include <gdk/gdkkeysyms.h>
static GtkWidget *linphone_gtk_create_contact_menu(GtkWidget *contact_list); static GtkWidget *linphone_gtk_create_contact_menu(GtkWidget *contact_list);
...@@ -139,6 +140,35 @@ void linphone_gtk_remove_contact(GtkWidget *button){ ...@@ -139,6 +140,35 @@ void linphone_gtk_remove_contact(GtkWidget *button){
} }
} }
gboolean linphone_gtk_on_key_press(GtkWidget *widget, GdkEvent *event, gpointer user_data) {
if (event->type == GDK_KEY_PRESS && ((GdkEventKey*)event)->state & GDK_CONTROL_MASK
&& ((GdkEventKey*)event)->hardware_keycode >= 10 && ((GdkEventKey*)event)->hardware_keycode <= 19) {
GtkWidget *main_window = linphone_gtk_get_main_window();
GtkWidget *friendlist = linphone_gtk_get_widget(main_window,"contact_list");
GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(friendlist));
int key = ((GdkEventKey*)event)->hardware_keycode - 10;
GtkTreeIter iter;
if (gtk_tree_model_get_iter_first(model, &iter)) {
int index = 0;
LinphoneFriend *lf = NULL;
do{
if (index == key) {
const LinphoneAddress *uri;
gtk_tree_model_get (model, &iter,FRIEND_ID , &lf, -1);
uri = linphone_friend_get_address(lf);
linphone_gtk_friend_list_set_chat_conversation(uri);
return TRUE;
}
index++;
}while(gtk_tree_model_iter_next(model,&iter) && index <= 9);
}
}
return FALSE;
}
void linphone_gtk_delete_history(GtkWidget *button){ void linphone_gtk_delete_history(GtkWidget *button){
GtkWidget *w=linphone_gtk_get_main_window(); GtkWidget *w=linphone_gtk_get_main_window();
GtkTreeSelection *select; GtkTreeSelection *select;
......
...@@ -371,3 +371,5 @@ LINPHONE_PUBLIC void linphone_gtk_mark_chat_read(LinphoneChatRoom *cr); ...@@ -371,3 +371,5 @@ LINPHONE_PUBLIC void linphone_gtk_mark_chat_read(LinphoneChatRoom *cr);
#ifdef __APPLE__ #ifdef __APPLE__
LINPHONE_PUBLIC void linphone_gtk_update_badge_count(); LINPHONE_PUBLIC void linphone_gtk_update_badge_count();
#endif #endif
LINPHONE_PUBLIC gboolean linphone_gtk_on_key_press(GtkWidget *widget, GdkEvent *event, gpointer user_data);
\ No newline at end of file
...@@ -2263,6 +2263,7 @@ core_start: ...@@ -2263,6 +2263,7 @@ core_start:
the_ui=linphone_gtk_create_window("main", NULL); the_ui=linphone_gtk_create_window("main", NULL);
g_object_set_data(G_OBJECT(the_ui),"is_created",GINT_TO_POINTER(FALSE)); g_object_set_data(G_OBJECT(the_ui),"is_created",GINT_TO_POINTER(FALSE));
g_signal_connect(G_OBJECT (the_ui), "key_press_event", G_CALLBACK (linphone_gtk_on_key_press), NULL);
linphone_gtk_create_log_window(); linphone_gtk_create_log_window();
linphone_core_enable_logs_with_cb(linphone_gtk_log_handler); linphone_core_enable_logs_with_cb(linphone_gtk_log_handler);
......
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