2 linphone, gtk-glade interface.
3 Copyright (C) 2009 Simon MORLAT (simon.morlat@linphone.org)
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 * C Implementation: incall_frame
25 * Author: Simon Morlat <simon.morlat@linphone.org>, (C) 2009
33 gboolean linphone_gtk_use_in_call_view(){
35 if (val==-1) val=linphone_gtk_get_ui_config_int("use_incall_view",1);
39 void linphone_gtk_show_in_call_view(void){
40 GtkWidget *main_window=linphone_gtk_get_main_window();
41 GtkNotebook *notebook=(GtkNotebook *)linphone_gtk_get_widget(main_window,"viewswitch");
42 GtkWidget *in_call_frame=linphone_gtk_get_widget(main_window,"in_call_frame");
45 /* Make the in call frame visible and arrange for the notebook to
47 gtk_widget_show(in_call_frame);
48 idx = gtk_notebook_page_num(notebook, in_call_frame);
50 gtk_notebook_set_current_page(notebook, idx);
54 void linphone_gtk_show_idle_view(void){
55 GtkWidget *main_window=linphone_gtk_get_main_window();
56 GtkNotebook *notebook=(GtkNotebook *)linphone_gtk_get_widget(main_window,"viewswitch");
57 GtkWidget *idle_frame=linphone_gtk_get_widget(main_window,"idle_frame");
58 GtkWidget *in_call_frame=linphone_gtk_get_widget(main_window,"in_call_frame");
61 /* Switch back to the idle frame page, maybe we should have
62 remembered where we were in gtk_show_in_call_view() to switch
63 back to that page of the notebook, but this should do in most
65 gtk_widget_show(idle_frame); /* Make sure it is visible... */
66 idx = gtk_notebook_page_num(notebook, idle_frame);
68 gtk_notebook_set_current_page(notebook, idx);
69 gtk_widget_hide(in_call_frame);
73 void display_peer_name_in_label(GtkWidget *label, const char *uri){
74 LinphoneAddress *from;
75 const char *displayname=NULL;
80 ms_error("Strange: in call with nobody ?");
84 from=linphone_address_new(uri);
86 displayname=linphone_address_get_display_name(from);
87 id=linphone_address_as_string_uri_only(from);
88 }else id=ms_strdup(uri);
90 if (displayname!=NULL){
91 uri_label=g_markup_printf_escaped("<span size=\"large\">%s</span>\n<i>%s</i>",
94 uri_label=g_markup_printf_escaped("<span size=\"large\"><i>%s</i></span>\n",id);
95 gtk_label_set_markup(GTK_LABEL(label),uri_label);
98 if (from!=NULL) linphone_address_destroy(from);
101 void linphone_gtk_in_call_view_set_calling(const char *uri){
102 GtkWidget *main_window=linphone_gtk_get_main_window();
103 GtkWidget *status=linphone_gtk_get_widget(main_window,"in_call_status");
104 GtkWidget *callee=linphone_gtk_get_widget(main_window,"in_call_uri");
105 GtkWidget *duration=linphone_gtk_get_widget(main_window,"in_call_duration");
106 GtkWidget *animation=linphone_gtk_get_widget(main_window,"in_call_animation");
107 GdkPixbufAnimation *pbuf=create_pixbuf_animation("calling_anim.gif");
109 gtk_label_set_markup(GTK_LABEL(status),_("<b>Calling...</b>"));
110 display_peer_name_in_label(callee,uri);
112 gtk_label_set_text(GTK_LABEL(duration),_("00::00::00"));
114 gtk_image_set_from_animation(GTK_IMAGE(animation),pbuf);
115 g_object_unref(G_OBJECT(pbuf));
116 }else gtk_image_set_from_stock(GTK_IMAGE(animation),GTK_STOCK_INFO,GTK_ICON_SIZE_DIALOG);
119 void linphone_gtk_in_call_view_set_in_call(){
120 LinphoneCore *lc=linphone_gtk_get_core();
121 GtkWidget *main_window=linphone_gtk_get_main_window();
122 GtkWidget *status=linphone_gtk_get_widget(main_window,"in_call_status");
123 GtkWidget *callee=linphone_gtk_get_widget(main_window,"in_call_uri");
124 GtkWidget *duration=linphone_gtk_get_widget(main_window,"in_call_duration");
125 GtkWidget *animation=linphone_gtk_get_widget(main_window,"in_call_animation");
126 GdkPixbufAnimation *pbuf=create_pixbuf_animation("incall_anim.gif");
127 const LinphoneAddress *uri=linphone_core_get_current_call_remote_address(lc);
128 char *tmp=linphone_address_as_string(uri);
129 display_peer_name_in_label(callee,tmp);
132 gtk_label_set_markup(GTK_LABEL(status),_("<b>In call with</b>"));
134 gtk_label_set_text(GTK_LABEL(duration),_("00::00::00"));
136 gtk_image_set_from_animation(GTK_IMAGE(animation),pbuf);
137 g_object_unref(G_OBJECT(pbuf));
138 }else gtk_image_set_from_stock(GTK_IMAGE(animation),GTK_STOCK_INFO,GTK_ICON_SIZE_DIALOG);
139 linphone_gtk_enable_mute_button(
140 GTK_TOGGLE_BUTTON(linphone_gtk_get_widget(main_window,"incall_mute")),TRUE);
141 linphone_gtk_enable_hold_button(
142 GTK_TOGGLE_BUTTON(linphone_gtk_get_widget(main_window,"hold_call")),TRUE);
145 void linphone_gtk_in_call_view_update_duration(int duration){
146 GtkWidget *main_window=linphone_gtk_get_main_window();
147 GtkWidget *duration_label=linphone_gtk_get_widget(main_window,"in_call_duration");
149 int seconds=duration%60;
150 int minutes=(duration/60)%60;
151 int hours=duration/3600;
152 snprintf(tmp,sizeof(tmp)-1,_("%02i::%02i::%02i"),hours,minutes,seconds);
153 gtk_label_set_text(GTK_LABEL(duration_label),tmp);
156 static gboolean in_call_view_terminated(){
157 linphone_gtk_show_idle_view();
161 void linphone_gtk_in_call_view_terminate(const char *error_msg){
162 GtkWidget *main_window=linphone_gtk_get_main_window();
163 GtkWidget *status=linphone_gtk_get_widget(main_window,"in_call_status");
164 GtkWidget *animation=linphone_gtk_get_widget(main_window,"in_call_animation");
165 GdkPixbuf *pbuf=create_pixbuf(linphone_gtk_get_ui_config("stop_call_icon","stopcall-red.png"));
168 gtk_label_set_markup(GTK_LABEL(status),_("<b>Call ended.</b>"));
170 char *msg=g_markup_printf_escaped("<span color=\"red\"><b>%s</b></span>",error_msg);
171 gtk_label_set_markup(GTK_LABEL(status),msg);
175 gtk_image_set_from_pixbuf(GTK_IMAGE(animation),pbuf);
176 g_object_unref(G_OBJECT(pbuf));
178 linphone_gtk_enable_mute_button(
179 GTK_TOGGLE_BUTTON(linphone_gtk_get_widget(main_window,"incall_mute")),FALSE);
180 linphone_gtk_enable_hold_button(
181 GTK_TOGGLE_BUTTON(linphone_gtk_get_widget(main_window,"hold_call")),FALSE);
182 g_timeout_add_seconds(2,(GSourceFunc)in_call_view_terminated,NULL);
185 void linphone_gtk_draw_mute_button(GtkToggleButton *button, gboolean active){
187 GtkWidget *image=create_pixmap("mic_muted.png");
188 gtk_button_set_label(GTK_BUTTON(button),_("Unmute"));
190 gtk_button_set_image(GTK_BUTTON(button),image);
191 gtk_widget_show(image);
194 GtkWidget *image=create_pixmap("mic_active.png");
195 gtk_button_set_label(GTK_BUTTON(button),_("Mute"));
197 gtk_button_set_image(GTK_BUTTON(button),image);
198 gtk_widget_show(image);
203 void linphone_gtk_mute_toggled(GtkToggleButton *button){
204 gboolean active=gtk_toggle_button_get_active(button);
205 linphone_core_mute_mic(linphone_gtk_get_core(),active);
206 linphone_gtk_draw_mute_button(button,active);
209 void linphone_gtk_enable_mute_button(GtkToggleButton *button, gboolean sensitive)
211 gtk_widget_set_sensitive(GTK_WIDGET(button),sensitive);
212 linphone_gtk_draw_mute_button(button,FALSE);
215 void linphone_gtk_draw_hold_button(GtkToggleButton *button, gboolean active){
217 GtkWidget *image=create_pixmap("hold_off.png");
218 gtk_button_set_label(GTK_BUTTON(button),_("HoldOff"));
220 gtk_button_set_image(GTK_BUTTON(button),image);
221 gtk_widget_show(image);
224 GtkWidget *image=create_pixmap("hold_on.png");
225 gtk_button_set_label(GTK_BUTTON(button),_("HoldOn"));
227 gtk_button_set_image(GTK_BUTTON(button),image);
228 gtk_widget_show(image);
233 void linphone_gtk_hold_toggled(GtkToggleButton *button){
234 gboolean active=gtk_toggle_button_get_active(button);
238 LinphoneCall *call=linphone_core_get_current_call (linphone_gtk_get_core());
239 if (call==NULL) return;
240 linphone_core_pause_call(linphone_gtk_get_core(),call);
244 const MSList *calls=linphone_core_get_calls(linphone_gtk_get_core());
245 if (calls==NULL) return;
246 if (ms_list_size(calls)>1){
247 g_warning("Simultaneously calls not yet implemented in gtk ui.");
250 /*we are supposed to have only one */
251 linphone_core_resume_call(linphone_gtk_get_core(),(LinphoneCall*)calls->data);
253 linphone_gtk_draw_hold_button(button,active);
256 void linphone_gtk_enable_hold_button(GtkToggleButton *button, gboolean sensitive){
257 gtk_widget_set_sensitive(GTK_WIDGET(button),sensitive);
258 linphone_gtk_draw_hold_button(button,FALSE);