Commit 3a02574f authored by Simon Morlat's avatar Simon Morlat
Browse files

multicall support in gtk interface

parent f2c5aab9
......@@ -221,6 +221,9 @@ static void call_accepted(SalOp *op){
}
linphone_call_set_state(call,LinphoneCallPaused,"Call paused");
}else{
if (lc->vtable.display_status){
lc->vtable.display_status(lc,_("Call answered - connected."));
}
linphone_call_set_state(call,LinphoneCallStreamsRunning,"Connected (streams running)");
}
linphone_connect_incoming (lc,call);
......
......@@ -229,17 +229,23 @@ static void linphone_call_set_terminated(LinphoneCall *call){
void linphone_call_set_state(LinphoneCall *call, LinphoneCallState cstate, const char *message){
LinphoneCore *lc=call->core;
bool_t finalize_call=FALSE;
if (call->state!=cstate){
if (cstate!=LinphoneCallRefered){
/*LinphoneCallRefered is rather an event, not a state.
Indeed it does not change the state of the call (still paused or running)*/
call->state=cstate;
}
if (cstate==LinphoneCallEnd || cstate==LinphoneCallError){
finalize_call=TRUE;
linphone_call_ref(call);
linphone_call_set_terminated (call);
}
if (lc->vtable.call_state_changed)
lc->vtable.call_state_changed(lc,call,cstate,message);
if (finalize_call)
linphone_call_unref(call);
}
if (call->state==LinphoneCallEnd || call->state==LinphoneCallError)
linphone_call_set_terminated (call);
}
static void linphone_call_destroy(LinphoneCall *obj)
......@@ -369,6 +375,14 @@ bool_t linphone_call_has_transfer_pending(const LinphoneCall *call){
return call->refer_pending;
}
/**
* Returns call's duration in seconds.
**/
int linphone_call_get_duration(const LinphoneCall *call){
if (call->media_start_time==0) return 0;
return time(NULL)-call->media_start_time;
}
/**
* @}
**/
......
......@@ -300,15 +300,10 @@ bool_t linphone_call_asked_to_autoanswer(LinphoneCall *call){
return FALSE;
}
int linphone_core_get_call_duration(LinphoneCall *call){
if (call==NULL) return 0;
if (call->media_start_time==0) return 0;
return time(NULL)-call->media_start_time;
}
int linphone_core_get_current_call_duration(const LinphoneCore *lc){
LinphoneCall *call=linphone_core_get_current_call((LinphoneCore *)lc);
return linphone_core_get_call_duration(call);
if (call) return linphone_call_get_duration(call);
return -1;
}
const LinphoneAddress *linphone_core_get_current_call_remote_address(struct _LinphoneCore *lc){
......
......@@ -174,6 +174,7 @@ void linphone_call_unref(LinphoneCall *call);
LinphoneCallLog *linphone_call_get_call_log(const LinphoneCall *call);
const char *linphone_call_get_refer_to(const LinphoneCall *call);
bool_t linphone_call_has_transfer_pending(const LinphoneCall *call);
int linphone_call_get_duration(const LinphoneCall *call);
void *linphone_call_get_user_pointer(LinphoneCall *call);
void linphone_call_set_user_pointer(LinphoneCall *call, void *user_pointer);
......
......@@ -2,7 +2,6 @@ UI_FILES= about.ui \
main.ui \
password.ui \
contact.ui \
incoming_call.ui \
parameters.ui \
sip_account.ui \
chatroom.ui \
......
......@@ -36,115 +36,155 @@ gboolean linphone_gtk_use_in_call_view(){
return val;
}
void linphone_gtk_show_in_call_view(void){
GtkWidget *main_window=linphone_gtk_get_main_window();
LinphoneCall *linphone_gtk_get_currently_displayed_call(){
LinphoneCore *lc=linphone_gtk_get_core();
GtkWidget *main_window=linphone_gtk_get_main_window ();
GtkNotebook *notebook=(GtkNotebook *)linphone_gtk_get_widget(main_window,"viewswitch");
GtkWidget *in_call_frame=linphone_gtk_get_widget(main_window,"in_call_frame");
gint idx;
/* Make the in call frame visible and arrange for the notebook to
show that page */
gtk_widget_show(in_call_frame);
idx = gtk_notebook_page_num(notebook, in_call_frame);
if (idx >= 0) {
gtk_notebook_set_current_page(notebook, idx);
const MSList *calls=linphone_core_get_calls(lc);
if (!linphone_gtk_use_in_call_view() || ms_list_size(calls)==1){
if (calls) return (LinphoneCall*)calls->data;
}else{
int idx=gtk_notebook_get_current_page (notebook);
GtkWidget *page=gtk_notebook_get_nth_page(notebook,idx);
if (page!=NULL){
LinphoneCall *call=(LinphoneCall*)g_object_get_data(G_OBJECT(page),"call");
return call;
}
}
return NULL;
}
void linphone_gtk_show_idle_view(void){
GtkWidget *main_window=linphone_gtk_get_main_window();
static GtkWidget *make_tab_header(int number){
GtkWidget *w=gtk_hbox_new (FALSE,0);
GtkWidget *i=create_pixmap ("status-green.png");
GtkWidget *l;
gchar *text=g_strdup_printf("Call %i",number);
l=gtk_label_new (text);
gtk_box_pack_start (GTK_BOX(w),i,FALSE,FALSE,0);
gtk_box_pack_end(GTK_BOX(w),l,TRUE,TRUE,0);
gtk_widget_show_all(w);
return w;
}
void linphone_gtk_create_in_call_view(LinphoneCall *call){
GtkWidget *call_view=linphone_gtk_create_widget("main","in_call_frame");
GtkWidget *main_window=linphone_gtk_get_main_window ();
GtkNotebook *notebook=(GtkNotebook *)linphone_gtk_get_widget(main_window,"viewswitch");
GtkWidget *idle_frame=linphone_gtk_get_widget(main_window,"idle_frame");
GtkWidget *in_call_frame=linphone_gtk_get_widget(main_window,"in_call_frame");
gint idx;
static int call_index=1;
int idx;
g_object_set_data(G_OBJECT(call_view),"call",call);
linphone_call_set_user_pointer (call,call_view);
linphone_call_ref(call);
gtk_notebook_append_page (notebook,call_view,make_tab_header(call_index));
gtk_widget_show(call_view);
idx = gtk_notebook_page_num(notebook, call_view);
gtk_notebook_set_current_page(notebook, idx);
call_index++;
}
/* Switch back to the idle frame page, maybe we should have
remembered where we were in gtk_show_in_call_view() to switch
back to that page of the notebook, but this should do in most
cases. */
gtk_widget_show(idle_frame); /* Make sure it is visible... */
idx = gtk_notebook_page_num(notebook, idle_frame);
if (idx >= 0) {
gtk_notebook_set_current_page(notebook, idx);
gtk_widget_hide(in_call_frame);
}
void linphone_gtk_remove_in_call_view(LinphoneCall *call){
GtkWidget *w=(GtkWidget*)linphone_call_get_user_pointer (call);
GtkWidget *main_window=linphone_gtk_get_main_window ();
GtkWidget *nb=linphone_gtk_get_widget(main_window,"viewswitch");
int idx;
g_return_if_fail(w!=NULL);
idx=gtk_notebook_page_num(GTK_NOTEBOOK(nb),w);
gtk_notebook_remove_page (GTK_NOTEBOOK(nb),idx);
gtk_widget_destroy(w);
linphone_call_set_user_pointer (call,NULL);
linphone_call_unref(call);
gtk_notebook_set_current_page(GTK_NOTEBOOK(nb), 0);
}
void display_peer_name_in_label(GtkWidget *label, const char *uri){
LinphoneAddress *from;
static void display_peer_name_in_label(GtkWidget *label, const LinphoneAddress *from){
const char *displayname=NULL;
char *id=NULL;
const char *id;
char *uri_label;
if (uri==NULL) {
ms_error("Strange: in call with nobody ?");
return;
}
from=linphone_address_new(uri);
if (from!=NULL){
displayname=linphone_address_get_display_name(from);
id=linphone_address_as_string_uri_only(from);
}else id=ms_strdup(uri);
displayname=linphone_address_get_display_name(from);
id=linphone_address_as_string_uri_only(from);
if (displayname!=NULL){
uri_label=g_markup_printf_escaped("<span size=\"large\">%s</span>\n<i>%s</i>",
displayname,id);
}else
uri_label=g_markup_printf_escaped("<span size=\"large\"><i>%s</i></span>\n",id);
gtk_label_set_markup(GTK_LABEL(label),uri_label);
ms_free(id);
g_free(uri_label);
if (from!=NULL) linphone_address_destroy(from);
}
void linphone_gtk_in_call_view_set_calling(const char *uri){
GtkWidget *main_window=linphone_gtk_get_main_window();
GtkWidget *status=linphone_gtk_get_widget(main_window,"in_call_status");
GtkWidget *callee=linphone_gtk_get_widget(main_window,"in_call_uri");
GtkWidget *duration=linphone_gtk_get_widget(main_window,"in_call_duration");
GtkWidget *animation=linphone_gtk_get_widget(main_window,"in_call_animation");
void linphone_gtk_in_call_view_set_calling(LinphoneCall *call){
GtkWidget *callview=(GtkWidget*)linphone_call_get_user_pointer(call);
GtkWidget *status=linphone_gtk_get_widget(callview,"in_call_status");
GtkWidget *callee=linphone_gtk_get_widget(callview,"in_call_uri");
GtkWidget *duration=linphone_gtk_get_widget(callview,"in_call_duration");
GtkWidget *animation=linphone_gtk_get_widget(callview,"in_call_animation");
GdkPixbufAnimation *pbuf=create_pixbuf_animation("calling_anim.gif");
gtk_label_set_markup(GTK_LABEL(status),_("<b>Calling...</b>"));
display_peer_name_in_label(callee,uri);
display_peer_name_in_label(callee,linphone_call_get_remote_address (call));
gtk_label_set_text(GTK_LABEL(duration),_("00::00::00"));
if (pbuf!=NULL){
gtk_image_set_from_animation(GTK_IMAGE(animation),pbuf);
g_object_unref(G_OBJECT(pbuf));
}else gtk_image_set_from_stock(GTK_IMAGE(animation),GTK_STOCK_INFO,GTK_ICON_SIZE_DIALOG);
}else gtk_image_set_from_stock(GTK_IMAGE(animation),GTK_STOCK_FIND,GTK_ICON_SIZE_DIALOG);
}
void linphone_gtk_in_call_view_set_in_call(){
LinphoneCore *lc=linphone_gtk_get_core();
GtkWidget *main_window=linphone_gtk_get_main_window();
GtkWidget *status=linphone_gtk_get_widget(main_window,"in_call_status");
GtkWidget *callee=linphone_gtk_get_widget(main_window,"in_call_uri");
GtkWidget *duration=linphone_gtk_get_widget(main_window,"in_call_duration");
GtkWidget *animation=linphone_gtk_get_widget(main_window,"in_call_animation");
void linphone_gtk_in_call_view_set_incoming(LinphoneCall *call){
GtkWidget *callview=(GtkWidget*)linphone_call_get_user_pointer(call);
GtkWidget *status=linphone_gtk_get_widget(callview,"in_call_status");
GtkWidget *callee=linphone_gtk_get_widget(callview,"in_call_uri");
GtkWidget *duration=linphone_gtk_get_widget(callview,"in_call_duration");
GtkWidget *animation=linphone_gtk_get_widget(callview,"in_call_animation");
GdkPixbufAnimation *pbuf=create_pixbuf_animation("calling_anim.gif");
gtk_label_set_markup(GTK_LABEL(status),_("<b>Incoming call</b>"));
gtk_widget_show_all(linphone_gtk_get_widget(callview,"answer_decline_panel"));
display_peer_name_in_label(callee,linphone_call_get_remote_address (call));
gtk_button_set_image(GTK_BUTTON(linphone_gtk_get_widget(callview,"accept_call")),
create_pixmap (linphone_gtk_get_ui_config("start_call_icon","startcall-green.png")));
gtk_button_set_image(GTK_BUTTON(linphone_gtk_get_widget(callview,"decline_call")),
create_pixmap (linphone_gtk_get_ui_config("stop_call_icon","stopcall-red.png")));
gtk_label_set_text(GTK_LABEL(duration),_("00::00::00"));
if (pbuf!=NULL){
gtk_image_set_from_animation(GTK_IMAGE(animation),pbuf);
g_object_unref(G_OBJECT(pbuf));
}else gtk_image_set_from_stock(GTK_IMAGE(animation),GTK_STOCK_EXECUTE,GTK_ICON_SIZE_DIALOG);
}
void linphone_gtk_in_call_view_set_in_call(LinphoneCall *call){
GtkWidget *callview=(GtkWidget*)linphone_call_get_user_pointer(call);
GtkWidget *status=linphone_gtk_get_widget(callview,"in_call_status");
GtkWidget *callee=linphone_gtk_get_widget(callview,"in_call_uri");
GtkWidget *duration=linphone_gtk_get_widget(callview,"in_call_duration");
GtkWidget *animation=linphone_gtk_get_widget(callview,"in_call_animation");
GdkPixbufAnimation *pbuf=create_pixbuf_animation("incall_anim.gif");
const LinphoneAddress *uri=linphone_core_get_current_call_remote_address(lc);
char *tmp=linphone_address_as_string(uri);
display_peer_name_in_label(callee,tmp);
ms_free(tmp);
GtkWidget *holdbutton;
display_peer_name_in_label(callee,linphone_call_get_remote_address (call));
gtk_widget_hide(linphone_gtk_get_widget(callview,"answer_decline_panel"));
gtk_label_set_markup(GTK_LABEL(status),_("<b>In call with</b>"));
gtk_label_set_text(GTK_LABEL(duration),_("00::00::00"));
if (pbuf!=NULL){
gtk_image_set_from_animation(GTK_IMAGE(animation),pbuf);
g_object_unref(G_OBJECT(pbuf));
}else gtk_image_set_from_stock(GTK_IMAGE(animation),GTK_STOCK_INFO,GTK_ICON_SIZE_DIALOG);
}else gtk_image_set_from_stock(GTK_IMAGE(animation),GTK_STOCK_EXECUTE,GTK_ICON_SIZE_DIALOG);
linphone_gtk_enable_mute_button(
GTK_TOGGLE_BUTTON(linphone_gtk_get_widget(main_window,"incall_mute")),TRUE);
linphone_gtk_enable_hold_button(
GTK_TOGGLE_BUTTON(linphone_gtk_get_widget(main_window,"hold_call")),TRUE);
GTK_TOGGLE_BUTTON(linphone_gtk_get_widget(callview,"incall_mute")),TRUE);
holdbutton=linphone_gtk_get_widget(callview,"hold_call");
linphone_gtk_enable_hold_button(GTK_TOGGLE_BUTTON(holdbutton),TRUE);
g_object_set_data(G_OBJECT(holdbutton),"call",call);
}
void linphone_gtk_in_call_view_update_duration(int duration){
GtkWidget *main_window=linphone_gtk_get_main_window();
GtkWidget *duration_label=linphone_gtk_get_widget(main_window,"in_call_duration");
void linphone_gtk_in_call_view_update_duration(LinphoneCall *call){
GtkWidget *callview=(GtkWidget*)linphone_call_get_user_pointer(call);
GtkWidget *duration_label=linphone_gtk_get_widget(callview,"in_call_duration");
int duration=linphone_call_get_duration(call);
char tmp[256]={0};
int seconds=duration%60;
int minutes=(duration/60)%60;
......@@ -153,15 +193,15 @@ void linphone_gtk_in_call_view_update_duration(int duration){
gtk_label_set_text(GTK_LABEL(duration_label),tmp);
}
static gboolean in_call_view_terminated(){
linphone_gtk_show_idle_view();
static gboolean in_call_view_terminated(LinphoneCall *call){
linphone_gtk_remove_in_call_view(call);
return FALSE;
}
void linphone_gtk_in_call_view_terminate(const char *error_msg){
GtkWidget *main_window=linphone_gtk_get_main_window();
GtkWidget *status=linphone_gtk_get_widget(main_window,"in_call_status");
GtkWidget *animation=linphone_gtk_get_widget(main_window,"in_call_animation");
void linphone_gtk_in_call_view_terminate(LinphoneCall *call, const char *error_msg){
GtkWidget *callview=(GtkWidget*)linphone_call_get_user_pointer(call);
GtkWidget *status=linphone_gtk_get_widget(callview,"in_call_status");
GtkWidget *animation=linphone_gtk_get_widget(callview,"in_call_animation");
GdkPixbuf *pbuf=create_pixbuf(linphone_gtk_get_ui_config("stop_call_icon","stopcall-red.png"));
if (error_msg==NULL)
......@@ -175,11 +215,12 @@ void linphone_gtk_in_call_view_terminate(const char *error_msg){
gtk_image_set_from_pixbuf(GTK_IMAGE(animation),pbuf);
g_object_unref(G_OBJECT(pbuf));
}
gtk_widget_hide(linphone_gtk_get_widget(callview,"answer_decline_panel"));
linphone_gtk_enable_mute_button(
GTK_TOGGLE_BUTTON(linphone_gtk_get_widget(main_window,"incall_mute")),FALSE);
GTK_TOGGLE_BUTTON(linphone_gtk_get_widget(callview,"incall_mute")),FALSE);
linphone_gtk_enable_hold_button(
GTK_TOGGLE_BUTTON(linphone_gtk_get_widget(main_window,"hold_call")),FALSE);
g_timeout_add_seconds(2,(GSourceFunc)in_call_view_terminated,NULL);
GTK_TOGGLE_BUTTON(linphone_gtk_get_widget(callview,"hold_call")),FALSE);
g_timeout_add_seconds(2,(GSourceFunc)in_call_view_terminated,call);
}
void linphone_gtk_draw_mute_button(GtkToggleButton *button, gboolean active){
......@@ -215,14 +256,14 @@ void linphone_gtk_enable_mute_button(GtkToggleButton *button, gboolean sensitive
void linphone_gtk_draw_hold_button(GtkToggleButton *button, gboolean active){
if (active){
GtkWidget *image=create_pixmap("hold_off.png");
gtk_button_set_label(GTK_BUTTON(button),_("HoldOff"));
gtk_button_set_label(GTK_BUTTON(button),_("Resume"));
if (image!=NULL) {
gtk_button_set_image(GTK_BUTTON(button),image);
gtk_widget_show(image);
}
}else{
GtkWidget *image=create_pixmap("hold_on.png");
gtk_button_set_label(GTK_BUTTON(button),_("HoldOn"));
gtk_button_set_label(GTK_BUTTON(button),_("Pause"));
if (image!=NULL) {
gtk_button_set_image(GTK_BUTTON(button),image);
gtk_widget_show(image);
......@@ -232,23 +273,14 @@ void linphone_gtk_draw_hold_button(GtkToggleButton *button, gboolean active){
void linphone_gtk_hold_toggled(GtkToggleButton *button){
gboolean active=gtk_toggle_button_get_active(button);
LinphoneCall *call=(LinphoneCall*)g_object_get_data(G_OBJECT(button),"call");
if(active)
{
LinphoneCall *call=linphone_core_get_current_call (linphone_gtk_get_core());
if (call==NULL) return;
linphone_core_pause_call(linphone_gtk_get_core(),call);
}
else
{
const MSList *calls=linphone_core_get_calls(linphone_gtk_get_core());
if (calls==NULL) return;
if (ms_list_size(calls)>1){
g_warning("Simultaneously calls not yet implemented in gtk ui.");
return;
}
/*we are supposed to have only one */
linphone_core_resume_call(linphone_gtk_get_core(),(LinphoneCall*)calls->data);
linphone_core_resume_call(linphone_gtk_get_core(),call);
}
linphone_gtk_draw_hold_button(button,active);
}
......
......@@ -48,6 +48,8 @@ GdkPixbuf *_gdk_pixbuf_new_from_memory_at_scale(const void *data, gint len, gint
GtkWidget *linphone_gtk_create_window(const char *window_name);
GtkWidget *linphone_gtk_get_widget(GtkWidget *window, const char *name);
GtkWidget *linphone_gtk_create_widget(const char *filename, const char *widget_name);
LinphoneCore *linphone_gtk_get_core(void);
GtkWidget *linphone_gtk_get_main_window();
void linphone_gtk_display_something(GtkMessageType type,const gchar *message);
......@@ -85,12 +87,13 @@ void linphone_gtk_show_directory_search(void);
/*functions controlling the different views*/
gboolean linphone_gtk_use_in_call_view();
void linphone_gtk_show_in_call_view(void);
void linphone_gtk_show_idle_view(void);
void linphone_gtk_in_call_view_set_calling(const char *uri);
void linphone_gtk_in_call_view_set_in_call(void);
void linphone_gtk_in_call_view_update_duration(int duration);
void linphone_gtk_in_call_view_terminate(const char *error_msg);
LinphoneCall *linphone_gtk_get_currently_displayed_call();
void linphone_gtk_create_in_call_view(LinphoneCall *call);
void linphone_gtk_in_call_view_set_calling(LinphoneCall *call);
void linphone_gtk_in_call_view_set_in_call(LinphoneCall *call);
void linphone_gtk_in_call_view_update_duration(LinphoneCall *call);
void linphone_gtk_in_call_view_terminate(LinphoneCall *call, const char *error_msg);
void linphone_gtk_in_call_view_set_incoming(LinphoneCall *call);
void linphone_gtk_enable_mute_button(GtkToggleButton *button, gboolean sensitive);
void linphone_gtk_enable_hold_button(GtkToggleButton *button, gboolean sensitive);
......
......@@ -213,14 +213,6 @@ static void linphone_gtk_log_file(OrtpLogLevel lev, const char *msg)
}
}
static gboolean delete_event_cb (GtkWidget *widget, GdkEvent *event, gpointer data)
{
gtk_widget_hide (widget);
return TRUE;
}
void linphone_gtk_log_hide(){
if (log_window)
gtk_widget_hide(log_window);
......@@ -234,7 +226,7 @@ void linphone_gtk_create_log_window(void){
gtk_text_buffer_create_tag(b,"orange","foreground","orange",NULL);
/*prevent the log window from being destroyed*/
g_signal_connect (G_OBJECT (log_window), "delete-event",
G_CALLBACK (delete_event_cb), NULL);
G_CALLBACK (gtk_widget_hide_on_delete), log_window);
}
......
......@@ -42,7 +42,6 @@ static LinphoneCore *the_core=NULL;
static GtkWidget *the_ui=NULL;
static void linphone_gtk_show(LinphoneCore *lc);
static void linphone_gtk_inv_recv(LinphoneCore *lc, LinphoneCall *call);
static void linphone_gtk_notify_recv(LinphoneCore *lc, LinphoneFriend * fid);
static void linphone_gtk_new_unknown_subscriber(LinphoneCore *lc, LinphoneFriend *lf, const char *url);
static void linphone_gtk_auth_info_requested(LinphoneCore *lc, const char *realm, const char *username);
......@@ -53,7 +52,7 @@ static void linphone_gtk_display_url(LinphoneCore *lc, const char *msg, const ch
static void linphone_gtk_call_log_updated(LinphoneCore *lc, LinphoneCallLog *cl);
static void linphone_gtk_refer_received(LinphoneCore *lc, const char *refer_to);
static void linphone_gtk_call_state_changed(LinphoneCore *lc, LinphoneCall *call, LinphoneCallState cs, const char *msg);
static gboolean linphone_gtk_auto_answer(GtkWidget *incall_window);
static gboolean linphone_gtk_auto_answer(LinphoneCall *call);
static gboolean verbose=0;
......@@ -107,7 +106,7 @@ static GOptionEntry linphone_options[]={
};
#define INSTALLED_XML_DIR PACKAGE_DATA_DIR "/linphone"
#define BUILD_TREE_XML_DIR "gtk-glade"
#define BUILD_TREE_XML_DIR "gtk"
#ifndef WIN32
#define CONFIG_FILE ".linphonerc"
......@@ -279,23 +278,31 @@ GtkWidget *linphone_gtk_get_widget(GtkWidget *window, const char *name){
#else
GtkWidget *linphone_gtk_create_window(const char *window_name){
GError* error = NULL;
GtkBuilder* builder = gtk_builder_new ();
char path[2048];
GtkWidget *w;
snprintf(path,sizeof(path),"%s/%s.ui",BUILD_TREE_XML_DIR,window_name);
static int get_ui_file(const char *name, char *path, int pathsize){
snprintf(path,pathsize,"%s/%s.ui",BUILD_TREE_XML_DIR,name);
if (access(path,F_OK)!=0){
snprintf(path,sizeof(path),"%s/%s.ui",INSTALLED_XML_DIR,window_name);
snprintf(path,pathsize,"%s/%s.ui",INSTALLED_XML_DIR,name);
if (access(path,F_OK)!=0){
g_error("Could not locate neither %s/%s.ui and %s/%s.ui .",BUILD_TREE_XML_DIR,window_name,
INSTALLED_XML_DIR,window_name);
return NULL;
g_error("Could not locate neither %s/%s.ui and %s/%s.ui .",BUILD_TREE_XML_DIR,name,
INSTALLED_XML_DIR,name);
return -1;
}
}
return 0;
}
GtkWidget *linphone_gtk_create_window(const char *window_name){
GError* error = NULL;
GtkBuilder* builder = gtk_builder_new ();
char path[512];
GtkWidget *w;
if (get_ui_file(window_name,path,sizeof(path))==-1) return NULL;
if (!gtk_builder_add_from_file (builder, path, &error)){
g_error("Couldn't load builder file: %s", error->message);
g_error_free (error);
return NULL;
}
w=GTK_WIDGET(gtk_builder_get_object (builder,window_name));
if (w==NULL){
......@@ -308,6 +315,33 @@ GtkWidget *linphone_gtk_create_window(const char *window_name){
return w;
}
GtkWidget *linphone_gtk_create_widget(const char *filename, const char *widget_name){
char path[2048];
GtkWidget *w;
GtkBuilder* builder = gtk_builder_new ();
GError *error=NULL;
gchar *object_ids[2];
object_ids[0]=g_strdup(widget_name);
object_ids[1]=NULL;
if (get_ui_file(filename,path,sizeof(path))==-1) return NULL;
if (!gtk_builder_add_objects_from_file(builder,path,object_ids,&error)){
g_error("Couldn't load %s from builder file %s: %s", widget_name,path,error->message);
g_error_free (error);
g_free(object_ids[0]);
return NULL;
}
g_free(object_ids[0]);
w=GTK_WIDGET(gtk_builder_get_object (builder,widget_name));
if (w==NULL){
g_error("Could not retrieve '%s' window from xml file",widget_name);
return NULL;
}
g_object_set_data(G_OBJECT(w),"builder",builder);
gtk_builder_connect_signals(builder,w);
return w;
}
GtkWidget *linphone_gtk_get_widget(GtkWidget *window, const char *name){
GtkBuilder *builder=(GtkBuilder*)g_object_get_data(G_OBJECT(window),"builder");
GObject *w;
......@@ -580,37 +614,74 @@ static void completion_add_text(GtkEntry *entry, const char *text){
save_uri_history();
}
void linphone_gtk_call_terminated(const char *error){
void linphone_gtk_call_terminated(LinphoneCall *call, const char *error){
GtkWidget *mw=linphone_gtk_get_main_window();
GtkWidget *icw;
gtk_widget_set_sensitive(linphone_gtk_get_widget(mw,"terminate_call"),FALSE);
gtk_widget_set_sensitive(linphone_gtk_get_widget(mw,"start_call"),TRUE);
linphone_gtk_enable_mute_button(GTK_TOGGLE_BUTTON(linphone_gtk_get_widget(mw,"main_mute")),FALSE);
if (linphone_gtk_use_in_call_view())
linphone_gtk_in_call_view_terminate(error);
if (linphone_gtk_use_in_call_view() && call)
linphone_gtk_in_call_view_terminate(call,error);
update_video_title();
icw=GTK_WIDGET(g_object_get_data(G_OBJECT(mw),"incoming_call"));
if (icw!=NULL){
g_object_set_data(G_OBJECT(mw),"incoming_call",NULL);
gtk_widget_destroy(icw);
}
}
static gboolean in_call_timer(){
if (linphone_core_in_call(linphone_gtk_get_core())){
linphone_gtk_in_call_view_update_duration(
linphone_core_get_current_call_duration(linphone_gtk_get_core()));
LinphoneCall *call=linphone_core_get_current_call(linphone_gtk_get_core());
if (call){
linphone_gtk_in_call_view_update_duration(call);
return TRUE;
}
return FALSE;
}
static void linphone_gtk_call_started(GtkWidget *mw){
gtk_widget_set_sensitive(linphone_gtk_get_widget(mw,"start_call"),FALSE);
gtk_widget_set_sensitive(linphone_gtk_get_widget(mw,"terminate_call"),TRUE);
static bool_t all_calls_paused(const MSList *calls){
for(;calls!=NULL;calls=calls->next){
LinphoneCall *call=(LinphoneCall*)calls->data;
if (linphone_call_get_state(call)!=LinphoneCallPaused)
return FALSE;
}
return TRUE;
}
static void linphone_gtk_update_call_buttons(LinphoneCall *call){
LinphoneCore *lc=linphone_gtk_get_core();
GtkWidget *mw=linphone_gtk_get_main_window();
const MSList *calls=linphone_core_get_calls(lc);
GtkWidget *button;
bool_t start_active=TRUE;
bool_t stop_active=FALSE;
bool_t add_call=FALSE;
if (calls==NULL){
start_active=TRUE;
stop_active=