mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-20 04:28:10 +00:00
menu in call log view with call, chat and add contact
This commit is contained in:
parent
1782284ee3
commit
ccd8bbb69c
6 changed files with 225 additions and 67 deletions
|
|
@ -132,6 +132,13 @@ void linphone_friend_destroy(LinphoneFriend *lf);
|
|||
*/
|
||||
int linphone_friend_set_addr(LinphoneFriend *fr, const LinphoneAddress* address);
|
||||
|
||||
/**
|
||||
* set the display name for this friend
|
||||
* @param lf #LinphoneFriend object
|
||||
* @param name
|
||||
*/
|
||||
int linphone_friend_set_name(LinphoneFriend *lf, const char *name);
|
||||
|
||||
/**
|
||||
* get address of this friend
|
||||
* @param lf #LinphoneFriend object
|
||||
|
|
|
|||
|
|
@ -82,7 +82,9 @@
|
|||
<object class="GtkTreeView" id="logs_view">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
|
||||
<property name="headers_visible">False</property>
|
||||
<signal name="button-press-event" handler="linphone_gtk_call_log_button_pressed" swapped="no"/>
|
||||
<signal name="row-activated" handler="linphone_gtk_history_row_activated" swapped="no"/>
|
||||
</object>
|
||||
</child>
|
||||
|
|
|
|||
167
gtk/calllogs.c
167
gtk/calllogs.c
|
|
@ -47,6 +47,145 @@ void call_log_selection_changed(GtkTreeView *v){
|
|||
}
|
||||
}
|
||||
|
||||
void linphone_gtk_call_log_chat_selected(GtkWidget *w){
|
||||
GtkTreeSelection *select;
|
||||
GtkTreeIter iter;
|
||||
|
||||
select=gtk_tree_view_get_selection(GTK_TREE_VIEW(w));
|
||||
if (select!=NULL){
|
||||
GtkTreeModel *model=NULL;
|
||||
if (gtk_tree_selection_get_selected (select,&model,&iter)){
|
||||
gpointer pla;
|
||||
LinphoneAddress *la;
|
||||
gtk_tree_model_get(model,&iter,2,&pla,-1);
|
||||
la=(LinphoneAddress*)pla;
|
||||
if (la!=NULL){
|
||||
linphone_gtk_tree_view_set_chat_conversation(la);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void linphone_gtk_call_log_add_contact(GtkWidget *w){
|
||||
GtkTreeSelection *select;
|
||||
GtkTreeIter iter;
|
||||
|
||||
select=gtk_tree_view_get_selection(GTK_TREE_VIEW(w));
|
||||
if (select!=NULL){
|
||||
GtkTreeModel *model=NULL;
|
||||
if (gtk_tree_selection_get_selected (select,&model,&iter)){
|
||||
gpointer pla;
|
||||
LinphoneAddress *la;
|
||||
LinphoneFriend *lf;
|
||||
gtk_tree_model_get(model,&iter,2,&pla,-1);
|
||||
la=(LinphoneAddress*)pla;
|
||||
if (la!=NULL){
|
||||
char *uri=linphone_address_as_string(la);
|
||||
lf=linphone_friend_new_with_addr(uri);
|
||||
linphone_gtk_show_contact(lf);
|
||||
ms_free(uri);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static bool_t put_selection_to_uribar(GtkWidget *treeview){
|
||||
GtkTreeSelection *sel;
|
||||
|
||||
sel=gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview));
|
||||
if (sel!=NULL){
|
||||
GtkTreeModel *model=NULL;
|
||||
GtkTreeIter iter;
|
||||
if (gtk_tree_selection_get_selected (sel,&model,&iter)){
|
||||
gpointer pla;
|
||||
LinphoneAddress *la;
|
||||
char *tmp;
|
||||
gtk_tree_model_get(model,&iter,2,&pla,-1);
|
||||
la=(LinphoneAddress*)pla;
|
||||
tmp=linphone_address_as_string (la);
|
||||
gtk_entry_set_text(GTK_ENTRY(linphone_gtk_get_widget(linphone_gtk_get_main_window(),"uribar")),tmp);
|
||||
ms_free(tmp);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void linphone_gtk_call_selected(GtkTreeView *treeview){
|
||||
put_selection_to_uribar(GTK_WIDGET(treeview));
|
||||
linphone_gtk_start_call(linphone_gtk_get_widget(gtk_widget_get_toplevel(GTK_WIDGET(treeview)),
|
||||
"start_call"));
|
||||
}
|
||||
|
||||
static GtkWidget *linphone_gtk_create_call_log_menu(GtkWidget *call_log){
|
||||
GtkWidget *menu=gtk_menu_new();
|
||||
GtkWidget *menu_item;
|
||||
gchar *call_label=NULL;
|
||||
gchar *text_label=NULL;
|
||||
gchar *name=NULL;
|
||||
GtkWidget *image;
|
||||
GtkTreeSelection *select;
|
||||
GtkTreeIter iter;
|
||||
|
||||
select=gtk_tree_view_get_selection(GTK_TREE_VIEW(call_log));
|
||||
if (select!=NULL){
|
||||
GtkTreeModel *model=NULL;
|
||||
if (gtk_tree_selection_get_selected (select,&model,&iter)){
|
||||
gpointer pla;
|
||||
LinphoneAddress *la;
|
||||
gtk_tree_model_get(model,&iter,2,&pla,-1);
|
||||
la=(LinphoneAddress*)pla;
|
||||
name=linphone_address_as_string(la);
|
||||
call_label=g_strdup_printf(_("Call %s"),name);
|
||||
text_label=g_strdup_printf(_("Send text to %s"),name);
|
||||
g_free(name);
|
||||
}
|
||||
}
|
||||
if (call_label){
|
||||
menu_item=gtk_image_menu_item_new_with_label(call_label);
|
||||
image=gtk_image_new_from_stock(GTK_STOCK_NETWORK,GTK_ICON_SIZE_MENU);
|
||||
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menu_item),image);
|
||||
gtk_widget_show(image);
|
||||
gtk_widget_show(menu_item);
|
||||
gtk_menu_shell_append(GTK_MENU_SHELL(menu),menu_item);
|
||||
g_signal_connect_swapped(G_OBJECT(menu_item),"activate",(GCallback)linphone_gtk_call_selected,call_log);
|
||||
}
|
||||
if (text_label){
|
||||
menu_item=gtk_image_menu_item_new_with_label(text_label);
|
||||
image=gtk_image_new_from_stock(GTK_STOCK_NETWORK,GTK_ICON_SIZE_MENU);
|
||||
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menu_item),image);
|
||||
gtk_widget_show(image);
|
||||
gtk_widget_show(menu_item);
|
||||
gtk_menu_shell_append(GTK_MENU_SHELL(menu),menu_item);
|
||||
g_signal_connect_swapped(G_OBJECT(menu_item),"activate",(GCallback)linphone_gtk_call_log_chat_selected,call_log);
|
||||
}
|
||||
|
||||
menu_item=gtk_image_menu_item_new_from_stock(GTK_STOCK_ADD,NULL);
|
||||
gtk_widget_show(menu_item);
|
||||
gtk_menu_shell_append(GTK_MENU_SHELL(menu),menu_item);
|
||||
g_signal_connect_swapped(G_OBJECT(menu_item),"activate",(GCallback)linphone_gtk_call_log_add_contact,call_log);
|
||||
gtk_widget_show(menu);
|
||||
gtk_menu_attach_to_widget(GTK_MENU(menu),call_log, NULL);
|
||||
|
||||
if (call_label) g_free(call_label);
|
||||
if (text_label) g_free(text_label);
|
||||
return menu;
|
||||
}
|
||||
|
||||
gboolean linphone_gtk_call_log_popup_contact(GtkWidget *list, GdkEventButton *event){
|
||||
GtkWidget *m=linphone_gtk_create_call_log_menu(list);
|
||||
gtk_menu_popup (GTK_MENU (m), NULL, NULL, NULL, NULL,
|
||||
event ? event->button : 0, event ? event->time : gtk_get_current_event_time());
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean linphone_gtk_call_log_button_pressed(GtkWidget *widget, GdkEventButton *event){
|
||||
if (event->button == 3 && event->type == GDK_BUTTON_PRESS){
|
||||
return linphone_gtk_call_log_popup_contact(widget, event);
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void linphone_gtk_call_log_update(GtkWidget *w){
|
||||
GtkTreeView *v=GTK_TREE_VIEW(linphone_gtk_get_widget(w,"logs_view"));
|
||||
GtkTreeStore *store;
|
||||
|
|
@ -62,6 +201,7 @@ void linphone_gtk_call_log_update(GtkWidget *w){
|
|||
select=gtk_tree_view_get_selection(v);
|
||||
gtk_tree_selection_set_mode(select, GTK_SELECTION_SINGLE);
|
||||
g_signal_connect_swapped(G_OBJECT(select),"changed",(GCallback)call_log_selection_changed,v);
|
||||
g_signal_connect(G_OBJECT(v),"button-press-event",(GCallback)linphone_gtk_call_log_button_pressed,NULL);
|
||||
// gtk_button_set_image(GTK_BUTTON(linphone_gtk_get_widget(w,"call_back_button")),
|
||||
// create_pixmap (linphone_gtk_get_ui_config("callback_button","status-green.png")));
|
||||
}
|
||||
|
|
@ -149,28 +289,6 @@ void linphone_gtk_call_log_update(GtkWidget *w){
|
|||
|
||||
}
|
||||
|
||||
static bool_t put_selection_to_uribar(GtkWidget *treeview){
|
||||
GtkTreeSelection *sel;
|
||||
|
||||
sel=gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview));
|
||||
if (sel!=NULL){
|
||||
GtkTreeModel *model=NULL;
|
||||
GtkTreeIter iter;
|
||||
if (gtk_tree_selection_get_selected (sel,&model,&iter)){
|
||||
gpointer pla;
|
||||
LinphoneAddress *la;
|
||||
char *tmp;
|
||||
gtk_tree_model_get(model,&iter,2,&pla,-1);
|
||||
la=(LinphoneAddress*)pla;
|
||||
tmp=linphone_address_as_string (la);
|
||||
gtk_entry_set_text(GTK_ENTRY(linphone_gtk_get_widget(linphone_gtk_get_main_window(),"uribar")),tmp);
|
||||
ms_free(tmp);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void linphone_gtk_history_row_activated(GtkWidget *treeview){
|
||||
if (put_selection_to_uribar(treeview)){
|
||||
GtkWidget *mw=linphone_gtk_get_main_window();
|
||||
|
|
@ -207,8 +325,6 @@ void linphone_gtk_call_log_response(GtkWidget *w, guint response_id){
|
|||
gtk_widget_destroy(w);
|
||||
}
|
||||
|
||||
|
||||
|
||||
GtkWidget * linphone_gtk_show_call_logs(void){
|
||||
GtkWidget *mw=linphone_gtk_get_main_window();
|
||||
|
||||
|
|
@ -223,5 +339,4 @@ GtkWidget * linphone_gtk_show_call_logs(void){
|
|||
linphone_gtk_call_log_update(w);
|
||||
}else gtk_window_present(GTK_WINDOW(w));
|
||||
return w;
|
||||
}
|
||||
|
||||
}
|
||||
113
gtk/friendlist.c
113
gtk/friendlist.c
|
|
@ -195,38 +195,11 @@ void linphone_gtk_create_chat_picture(gboolean active){
|
|||
GtkTreeModel *model=gtk_tree_view_get_model(GTK_TREE_VIEW(friendlist));
|
||||
if (gtk_tree_model_get_iter_first(model,&iter)) {
|
||||
do{
|
||||
if(!active){
|
||||
//if(!active){
|
||||
gtk_list_store_set(GTK_LIST_STORE(model),&iter,FRIEND_CHAT,create_chat_picture(),-1);
|
||||
} else {
|
||||
gtk_list_store_set(GTK_LIST_STORE(model),&iter,FRIEND_CHAT,create_active_chat_picture(),-1);
|
||||
}
|
||||
}while(gtk_tree_model_iter_next(model,&iter));
|
||||
}
|
||||
}
|
||||
|
||||
void linphone_gtk_update_chat_picture(){
|
||||
GtkTreeIter iter;
|
||||
GtkListStore *store=NULL;
|
||||
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));
|
||||
GtkWidget *chat_view=(GtkWidget*)g_object_get_data(G_OBJECT(friendlist),"chatview");
|
||||
LinphoneFriend *lf=NULL;
|
||||
char *uri=(char *)g_object_get_data(G_OBJECT(friendlist),"from");
|
||||
store=GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(friendlist)));
|
||||
if (gtk_tree_model_get_iter_first(model,&iter)) {
|
||||
do{
|
||||
gtk_tree_model_get (model, &iter,FRIEND_ID , &lf, -1);
|
||||
if(chat_view!=NULL){
|
||||
if(uri !=NULL) {
|
||||
if(g_strcmp0(linphone_address_as_string(linphone_friend_get_address(lf)),
|
||||
uri)==0){
|
||||
gtk_list_store_set(store,&iter,FRIEND_CHAT,create_active_chat_picture(),-1);
|
||||
} else {
|
||||
gtk_list_store_set(store,&iter,FRIEND_CHAT,create_chat_picture(),-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
//} else {
|
||||
// gtk_list_store_set(GTK_LIST_STORE(model),&iter,FRIEND_CHAT,create_active_chat_picture(),-1);
|
||||
//}
|
||||
}while(gtk_tree_model_iter_next(model,&iter));
|
||||
}
|
||||
}
|
||||
|
|
@ -236,6 +209,66 @@ static gboolean grab_focus(GtkWidget *w){
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
void linphone_gtk_tree_view_set_chat_conversation(LinphoneAddress *la){
|
||||
GtkTreeIter iter;
|
||||
GtkListStore *store=NULL;
|
||||
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));
|
||||
GtkWidget *chat_view=(GtkWidget*)g_object_get_data(G_OBJECT(friendlist),"chatview");
|
||||
LinphoneFriend *lf=NULL;
|
||||
LinphoneChatRoom *cr=NULL;
|
||||
GtkNotebook *notebook=(GtkNotebook *)linphone_gtk_get_widget(w,"viewswitch");
|
||||
char *la_str=linphone_address_as_string(la);
|
||||
|
||||
lf=linphone_core_get_friend_by_address(linphone_gtk_get_core(),la_str);
|
||||
if(lf==NULL){
|
||||
cr=linphone_gtk_create_chatroom(la);
|
||||
g_object_set_data(G_OBJECT(friendlist),"from",la_str);
|
||||
if(chat_view==NULL){
|
||||
chat_view=linphone_gtk_init_chatroom(cr,la);
|
||||
g_object_set_data(G_OBJECT(friendlist),"chatview",(gpointer)chat_view);
|
||||
} else {
|
||||
linphone_gtk_load_chatroom(cr,la,chat_view);
|
||||
}
|
||||
gtk_notebook_set_current_page(notebook,gtk_notebook_page_num(notebook,chat_view));
|
||||
linphone_gtk_create_chat_picture(FALSE);
|
||||
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)));
|
||||
if (gtk_tree_model_get_iter_first(model,&iter)) {
|
||||
do{
|
||||
const LinphoneAddress *uri;
|
||||
char *lf_str;
|
||||
gtk_tree_model_get (model, &iter,FRIEND_ID , &lf, -1);
|
||||
uri=linphone_friend_get_address(lf);
|
||||
lf_str=linphone_address_as_string(uri);
|
||||
if( g_strcmp0(lf_str,la_str)==0){
|
||||
gtk_tree_model_get (model, &iter,FRIEND_CHATROOM , &cr, -1);
|
||||
if(cr==NULL){
|
||||
cr=linphone_gtk_create_chatroom(uri);
|
||||
gtk_list_store_set(store,&iter,FRIEND_CHATROOM,cr,-1);
|
||||
}
|
||||
g_object_set_data(G_OBJECT(friendlist),"from",linphone_address_as_string(uri));
|
||||
if(chat_view==NULL){
|
||||
chat_view=linphone_gtk_init_chatroom(cr,uri);
|
||||
g_object_set_data(G_OBJECT(friendlist),"chatview",(gpointer)chat_view);
|
||||
} else {
|
||||
linphone_gtk_load_chatroom(cr,uri,chat_view);
|
||||
}
|
||||
gtk_notebook_set_current_page(notebook,gtk_notebook_page_num(notebook,chat_view));
|
||||
linphone_gtk_create_chat_picture(FALSE);
|
||||
g_idle_add((GSourceFunc)grab_focus,linphone_gtk_get_widget(chat_view,"text_entry"));
|
||||
gtk_list_store_set(store,&iter,FRIEND_CHAT,create_active_chat_picture(),-1);
|
||||
gtk_list_store_set(store,&iter,FRIEND_NB_UNREAD_MSG,"",-1);
|
||||
break;
|
||||
}
|
||||
}while(gtk_tree_model_iter_next(model,&iter));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void linphone_gtk_chat_selected(GtkWidget *item){
|
||||
GtkWidget *w=gtk_widget_get_toplevel(item);
|
||||
GtkTreeSelection *select;
|
||||
|
|
@ -734,7 +767,6 @@ void linphone_gtk_show_friends(void){
|
|||
if(nbmsg != 0){
|
||||
sprintf(buf,"%i",nbmsg);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
gtk_list_store_set(store,&iter,FRIEND_CALL,create_call_picture(),-1);
|
||||
|
|
@ -743,7 +775,7 @@ void linphone_gtk_show_friends(void){
|
|||
escaped=g_markup_escape_text(uri,-1);
|
||||
gtk_list_store_set(store,&iter,FRIEND_SIP_ADDRESS,escaped,-1);
|
||||
g_free(escaped);
|
||||
linphone_gtk_update_chat_picture();
|
||||
//linphone_gtk_update_chat_picture();
|
||||
//bi=linphone_friend_get_info(lf);
|
||||
/*if (bi!=NULL && bi->image_data!=NULL){
|
||||
GdkPixbuf *pbuf=
|
||||
|
|
@ -787,6 +819,7 @@ void linphone_gtk_contact_cancel(GtkWidget *button){
|
|||
void linphone_gtk_contact_ok(GtkWidget *button){
|
||||
GtkWidget *w=gtk_widget_get_toplevel(button);
|
||||
LinphoneFriend *lf=(LinphoneFriend*)g_object_get_data(G_OBJECT(w),"friend_ref");
|
||||
LinphoneFriend *lf2;
|
||||
char *fixed_uri=NULL;
|
||||
gboolean show_presence=FALSE,allow_presence=FALSE;
|
||||
const gchar *name,*uri;
|
||||
|
|
@ -811,16 +844,20 @@ void linphone_gtk_contact_ok(GtkWidget *button){
|
|||
LinphoneAddress* friend_address = linphone_address_new(fixed_uri);
|
||||
linphone_address_set_display_name(friend_address,name);
|
||||
linphone_friend_set_addr(lf,friend_address);
|
||||
ms_free(fixed_uri);
|
||||
linphone_address_destroy(friend_address);
|
||||
|
||||
linphone_friend_send_subscribe(lf,show_presence);
|
||||
linphone_friend_set_inc_subscribe_policy(lf,allow_presence==TRUE ? LinphoneSPAccept : LinphoneSPDeny);
|
||||
if (linphone_friend_in_list(lf)) {
|
||||
linphone_friend_done(lf);
|
||||
}else{
|
||||
linphone_core_add_friend(linphone_gtk_get_core(),lf);
|
||||
} else {
|
||||
lf2=linphone_core_get_friend_by_address(linphone_gtk_get_core(),fixed_uri);
|
||||
if(lf2==NULL){
|
||||
linphone_friend_set_name(lf,name);
|
||||
linphone_core_add_friend(linphone_gtk_get_core(),lf);
|
||||
}
|
||||
}
|
||||
ms_free(fixed_uri);
|
||||
linphone_gtk_show_friends();
|
||||
gtk_widget_destroy(w);
|
||||
}
|
||||
|
|
@ -997,6 +1034,4 @@ gboolean linphone_gtk_contact_list_button_pressed(GtkWidget *widget, GdkEventBut
|
|||
void linphone_gtk_buddy_info_updated(LinphoneCore *lc, LinphoneFriend *lf){
|
||||
/*refresh the entire list*/
|
||||
linphone_gtk_show_friends();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -153,3 +153,4 @@ void linphone_gtk_unmonitor_usb(void);
|
|||
|
||||
gchar *linphone_gtk_get_record_path(const LinphoneAddress *address, gboolean is_conference);
|
||||
void linphone_gtk_friend_list_update_message(LinphoneChatMessage *msg);
|
||||
void linphone_gtk_tree_view_set_chat_conversation(LinphoneAddress *la);
|
||||
|
|
|
|||
|
|
@ -313,7 +313,6 @@
|
|||
<object class="GtkLabel" id="in_call_uri">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">label</property>
|
||||
<property name="justify">center</property>
|
||||
</object>
|
||||
<packing>
|
||||
|
|
@ -368,7 +367,6 @@
|
|||
<object class="GtkLabel" id="encryption_label">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">label</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue