]> sjero.net Git - linphone/blob - gtk/incall_view.c
Merge remote-tracking branch 'origin/master' into dev_videoios
[linphone] / gtk / incall_view.c
1 /*
2 linphone, gtk-glade interface.
3 Copyright (C) 2009  Simon MORLAT (simon.morlat@linphone.org)
4
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.
9
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.
14
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.
18 */
19 /*
20 *  C Implementation: incall_frame
21 *
22 * Description: 
23 *
24 *
25 * Author: Simon Morlat <simon.morlat@linphone.org>, (C) 2009
26 *
27 *
28 */
29
30 #include "linphone.h"
31
32
33 gboolean linphone_gtk_use_in_call_view(){
34         static int val=-1;
35         if (val==-1) val=linphone_gtk_get_ui_config_int("use_incall_view",1);
36         return val;
37 }
38
39 LinphoneCall *linphone_gtk_get_currently_displayed_call(){
40         LinphoneCore *lc=linphone_gtk_get_core();
41         GtkWidget *main_window=linphone_gtk_get_main_window ();
42         GtkNotebook *notebook=(GtkNotebook *)linphone_gtk_get_widget(main_window,"viewswitch");
43         const MSList *calls=linphone_core_get_calls(lc);
44         if (!linphone_gtk_use_in_call_view() || ms_list_size(calls)==1){
45                 if (calls) return (LinphoneCall*)calls->data;
46         }else{
47                 int idx=gtk_notebook_get_current_page (notebook);
48                 GtkWidget *page=gtk_notebook_get_nth_page(notebook,idx);
49                 if (page!=NULL){
50                         LinphoneCall *call=(LinphoneCall*)g_object_get_data(G_OBJECT(page),"call");
51                         return call;
52                 }
53         }
54         return NULL;
55 }
56
57 static GtkWidget *make_tab_header(int number){
58         GtkWidget *w=gtk_hbox_new (FALSE,0);
59         GtkWidget *i=create_pixmap ("status-green.png");
60         GtkWidget *l;
61         gchar *text=g_strdup_printf(_("Call #%i"),number);
62         l=gtk_label_new (text);
63         gtk_box_pack_start (GTK_BOX(w),i,FALSE,FALSE,0);
64         gtk_box_pack_end(GTK_BOX(w),l,TRUE,TRUE,0);
65         gtk_widget_show_all(w);
66         return w;
67 }
68
69 static void linphone_gtk_in_call_set_animation_image(GtkWidget *callview, const char *image_name, gboolean is_stock){
70         GtkWidget *container=linphone_gtk_get_widget(callview,"in_call_animation");
71         GList *elem=gtk_container_get_children(GTK_CONTAINER(container));
72         GtkWidget *image;
73         if (!is_stock)
74                 image=create_pixmap(image_name);
75         else
76                 image=gtk_image_new_from_stock(image_name,GTK_ICON_SIZE_DIALOG);
77         if (elem)
78                 gtk_widget_destroy((GtkWidget*)elem->data);
79         gtk_widget_show(image);
80         gtk_container_add(GTK_CONTAINER(container),image);
81         
82 }
83
84 static void linphone_gtk_in_call_set_animation_spinner(GtkWidget *callview){
85         GtkWidget *container=linphone_gtk_get_widget(callview,"in_call_animation");
86         GList *elem=gtk_container_get_children(GTK_CONTAINER(container));
87         GtkWidget *spinner=gtk_spinner_new();
88         if (elem)
89                 gtk_widget_destroy((GtkWidget*)elem->data);
90         gtk_widget_show(spinner);
91         gtk_container_add(GTK_CONTAINER(container),spinner);
92         gtk_spinner_start(GTK_SPINNER(spinner));
93 }
94
95
96 static void linphone_gtk_transfer_call(LinphoneCall *dest_call){
97         LinphoneCall *call=linphone_gtk_get_currently_displayed_call();
98         linphone_core_transfer_call_to_another (linphone_gtk_get_core(),call,dest_call);
99 }
100
101 static void transfer_button_clicked(GtkWidget *button, gpointer call_ref){
102         GtkWidget *menu_item;
103         GtkWidget *menu=gtk_menu_new();
104         LinphoneCall *call=(LinphoneCall*)call_ref;
105         LinphoneCore *lc=linphone_gtk_get_core();
106         const MSList *elem=linphone_core_get_calls(lc);
107         
108         for(;elem!=NULL;elem=elem->next){
109                 LinphoneCall *other_call=(LinphoneCall*)elem->data;
110                 GtkWidget *call_view=(GtkWidget*)linphone_call_get_user_pointer(other_call);
111                 if (other_call!=call){
112                         int call_index=GPOINTER_TO_INT(g_object_get_data(G_OBJECT(call_view),"call_index"));
113                         char *remote_uri=linphone_call_get_remote_address_as_string (other_call);
114                         char *text=g_strdup_printf(_("Transfer to call #%i with %s"),call_index,remote_uri);
115                         menu_item=gtk_image_menu_item_new_with_label(text);
116                         ms_free(remote_uri);
117                         g_free(text);
118                         gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menu_item),create_pixmap("status-green.png"));
119                         gtk_widget_show(menu_item);
120                         gtk_menu_shell_append(GTK_MENU_SHELL(menu),menu_item);
121                         g_signal_connect_swapped(G_OBJECT(menu_item),"activate",(GCallback)linphone_gtk_transfer_call,other_call);
122                 }
123         }
124         gtk_menu_popup(GTK_MENU(menu),NULL,NULL,NULL,NULL,0,
125                 gtk_get_current_event_time());
126         gtk_widget_show(menu);
127 }
128
129
130
131 void linphone_gtk_enable_transfer_button(LinphoneCore *lc, gboolean value){
132         const MSList *elem=linphone_core_get_calls(lc);
133         for(;elem!=NULL;elem=elem->next){
134                 LinphoneCall *call=(LinphoneCall*)elem->data;
135                 GtkWidget *call_view=(GtkWidget*)linphone_call_get_user_pointer(call);
136                 GtkWidget *box=linphone_gtk_get_widget (call_view,"mute_pause_buttons");
137                 GtkWidget *button=(GtkWidget*)g_object_get_data(G_OBJECT(box),"transfer");
138                 if (button && value==FALSE){
139                         gtk_widget_destroy(button);
140                         button=NULL;
141                 }else if (!button && value==TRUE){
142                         button=gtk_button_new_with_label (_("Transfer"));
143                         gtk_button_set_image(GTK_BUTTON(button),gtk_image_new_from_stock (GTK_STOCK_GO_FORWARD,GTK_ICON_SIZE_BUTTON));
144                         g_signal_connect(G_OBJECT(button),"clicked",(GCallback)transfer_button_clicked,call);
145                         gtk_widget_show_all(button);
146                         gtk_container_add(GTK_CONTAINER(box),button);
147                 }
148                 g_object_set_data(G_OBJECT(box),"transfer",button);
149         }
150 }
151
152 static void conference_button_clicked(GtkWidget *button, gpointer call_ref){
153
154 }
155
156 void linphone_gtk_enable_conference_button(LinphoneCore *lc, gboolean value){
157         const MSList *elem=linphone_core_get_calls(lc);
158         for(;elem!=NULL;elem=elem->next){
159                 LinphoneCall *call=(LinphoneCall*)elem->data;
160                 GtkWidget *call_view=(GtkWidget*)linphone_call_get_user_pointer(call);
161                 GtkWidget *box=linphone_gtk_get_widget (call_view,"mute_pause_buttons");
162                 GtkWidget *button=(GtkWidget*)g_object_get_data(G_OBJECT(box),"conference");
163                 if (button && value==FALSE){
164                         gtk_widget_destroy(button);
165                         button=NULL;
166                 }else if (!button && value==TRUE){
167                         button=gtk_button_new_with_label (_("Conference"));
168                         gtk_button_set_image(GTK_BUTTON(button),gtk_image_new_from_stock (GTK_STOCK_ADD,GTK_ICON_SIZE_BUTTON));
169                         g_signal_connect(G_OBJECT(button),"clicked",(GCallback)conference_button_clicked,call);
170                         gtk_widget_show_all(button);
171                         gtk_container_add(GTK_CONTAINER(box),button);
172                 }
173                 g_object_set_data(G_OBJECT(box),"conference",button);
174         }
175 }
176
177 void linphone_gtk_create_in_call_view(LinphoneCall *call){
178         GtkWidget *call_view=linphone_gtk_create_widget("main","in_call_frame");
179         GtkWidget *main_window=linphone_gtk_get_main_window ();
180         GtkNotebook *notebook=(GtkNotebook *)linphone_gtk_get_widget(main_window,"viewswitch");
181         static int call_index=1;
182         int idx;
183
184         if (ms_list_size(linphone_core_get_calls(linphone_gtk_get_core()))==1){
185                 /*this is the only call at this time */
186                 call_index=1;
187         }
188         g_object_set_data(G_OBJECT(call_view),"call",call);
189         g_object_set_data(G_OBJECT(call_view),"call_index",GINT_TO_POINTER(call_index));
190
191         linphone_call_set_user_pointer (call,call_view);
192         linphone_call_ref(call);
193         gtk_notebook_append_page (notebook,call_view,make_tab_header(call_index));
194         gtk_widget_show(call_view);
195         idx = gtk_notebook_page_num(notebook, call_view);
196         gtk_notebook_set_current_page(notebook, idx);
197         call_index++;
198         linphone_gtk_enable_hold_button (call,FALSE,TRUE);
199         linphone_gtk_enable_mute_button(
200                                         GTK_BUTTON(linphone_gtk_get_widget(call_view,"incall_mute")),FALSE);
201 }
202
203 void linphone_gtk_remove_in_call_view(LinphoneCall *call){
204         GtkWidget *w=(GtkWidget*)linphone_call_get_user_pointer (call);
205         GtkWidget *main_window=linphone_gtk_get_main_window ();
206         GtkWidget *nb=linphone_gtk_get_widget(main_window,"viewswitch");
207         int idx;
208         g_return_if_fail(w!=NULL);
209         idx=gtk_notebook_page_num(GTK_NOTEBOOK(nb),w);
210         gtk_notebook_remove_page (GTK_NOTEBOOK(nb),idx);
211         gtk_widget_destroy(w);
212         linphone_call_set_user_pointer (call,NULL);
213         linphone_call_unref(call);
214         gtk_notebook_set_current_page(GTK_NOTEBOOK(nb), 0);
215 }
216
217 static void display_peer_name_in_label(GtkWidget *label, const LinphoneAddress *from){
218         const char *displayname=NULL;
219         const char *id;
220         char *uri_label;
221         displayname=linphone_address_get_display_name(from);
222         id=linphone_address_as_string_uri_only(from);
223         
224         if (displayname!=NULL){
225                 uri_label=g_markup_printf_escaped("<span size=\"large\">%s</span>\n<i>%s</i>", 
226                         displayname,id);
227         }else
228                 uri_label=g_markup_printf_escaped("<span size=\"large\"><i>%s</i></span>\n",id);
229         gtk_label_set_markup(GTK_LABEL(label),uri_label);
230         g_free(uri_label);
231 }
232
233 void linphone_gtk_in_call_view_set_calling(LinphoneCall *call){
234         GtkWidget *callview=(GtkWidget*)linphone_call_get_user_pointer(call);
235         GtkWidget *status=linphone_gtk_get_widget(callview,"in_call_status");
236         GtkWidget *callee=linphone_gtk_get_widget(callview,"in_call_uri");
237         GtkWidget *duration=linphone_gtk_get_widget(callview,"in_call_duration");
238         
239         gtk_label_set_markup(GTK_LABEL(status),_("<b>Calling...</b>"));
240         display_peer_name_in_label(callee,linphone_call_get_remote_address (call));
241         
242         gtk_label_set_text(GTK_LABEL(duration),_("00::00::00"));
243         linphone_gtk_in_call_set_animation_spinner(callview);
244 }
245
246 void linphone_gtk_in_call_view_set_incoming(LinphoneCall *call){
247         GtkWidget *callview=(GtkWidget*)linphone_call_get_user_pointer(call);
248         GtkWidget *status=linphone_gtk_get_widget(callview,"in_call_status");
249         GtkWidget *callee=linphone_gtk_get_widget(callview,"in_call_uri");
250         GtkWidget *answer_button;
251         GtkWidget *image;
252
253         gtk_label_set_markup(GTK_LABEL(status),_("<b>Incoming call</b>"));
254         gtk_widget_show_all(linphone_gtk_get_widget(callview,"answer_decline_panel"));
255         gtk_widget_hide(linphone_gtk_get_widget(callview,"mute_pause_buttons"));
256         display_peer_name_in_label(callee,linphone_call_get_remote_address (call));
257
258         answer_button=linphone_gtk_get_widget(callview,"accept_call");
259         image=create_pixmap (linphone_gtk_get_ui_config("start_call_icon","startcall-green.png"));
260         gtk_button_set_label(GTK_BUTTON(answer_button),_("Answer"));
261         gtk_button_set_image(GTK_BUTTON(answer_button),image);
262         gtk_widget_show(image);
263         
264         image=create_pixmap (linphone_gtk_get_ui_config("stop_call_icon","stopcall-red.png"));
265         gtk_button_set_image(GTK_BUTTON(linphone_gtk_get_widget(callview,"decline_call")),image);
266         gtk_widget_show(image);
267         
268         linphone_gtk_in_call_set_animation_image(callview,GTK_STOCK_DIALOG_INFO,TRUE);
269 }
270
271 static void rating_to_color(float rating, GdkColor *color){
272         const char *colorname="grey";
273         if (rating>=4.0)
274                 colorname="green";
275         else if (rating>=3.0)
276                 colorname="white";
277         else if (rating>=2.0)
278                 colorname="yellow";
279         else if (rating>=1.0)
280                 colorname="orange";
281         else if (rating>=0)
282                 colorname="red";
283         if (!gdk_color_parse(colorname,color)){
284                 g_warning("Fail to parse color %s",colorname);
285         }
286 }
287
288 static const char *rating_to_text(float rating){
289         if (rating>=4.0)
290                 return _("good");
291         if (rating>=3.0)
292                 return _("average");
293         if (rating>=2.0)
294                 return _("poor");
295         if (rating>=1.0)
296                 return _("very poor");
297         if (rating>=0)
298                 return _("too bad");
299         return _("unavailable");
300 }
301
302 static gboolean linphone_gtk_in_call_view_refresh(LinphoneCall *call){
303         GtkWidget *callview=(GtkWidget*)linphone_call_get_user_pointer(call);
304         GtkWidget *qi=linphone_gtk_get_widget(callview,"quality_indicator");
305         float rating=linphone_call_get_current_quality(call);
306         GdkColor color;
307         gchar tmp[50];
308         linphone_gtk_in_call_view_update_duration(call);
309         if (rating>=0){
310                 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(qi),rating/5.0);
311                 snprintf(tmp,sizeof(tmp),"%.1f (%s)",rating,rating_to_text(rating));
312                 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(qi),tmp);
313         }else{
314                 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(qi),0);
315                 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(qi),_("unavailable"));
316         }
317         rating_to_color(rating,&color);
318         gtk_widget_modify_bg(qi,GTK_STATE_NORMAL,&color);
319         return TRUE;
320 }
321
322 typedef float (*get_volume_t)(void *data);
323
324 typedef struct _volume_ctx{
325         GtkWidget *widget;
326         get_volume_t get_volume;
327         void *data;
328         float last_value;
329 }volume_ctx_t;
330
331 #define UNSIGNIFICANT_VOLUME (-26)
332 #define SMOOTH 0.15
333
334 static gboolean update_audio_meter(volume_ctx_t *ctx){
335         float volume_db=ctx->get_volume(ctx->data);
336         float frac=(volume_db-UNSIGNIFICANT_VOLUME)/(float)(-UNSIGNIFICANT_VOLUME+3.0);
337         if (frac<0) frac=0;
338         if (frac>1.0) frac=1.0;
339         if (frac<ctx->last_value){
340                 frac=(frac*SMOOTH)+(ctx->last_value*(1-SMOOTH));
341         }
342         ctx->last_value=frac;
343         //g_message("volume_db=%f, frac=%f",volume_db,frac);
344         gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(ctx->widget),frac);
345         return TRUE;
346 }
347
348 static void on_audio_meter_destroy(guint task_id){
349         g_source_remove(task_id);
350 }
351
352 void linphone_gtk_init_audio_meter(GtkWidget *w, get_volume_t get_volume, void *data){
353         guint task_id=GPOINTER_TO_INT(g_object_get_data(G_OBJECT(w),"task_id"));
354         if (task_id==0){
355                 volume_ctx_t *ctx=g_new(volume_ctx_t,1);
356                 ctx->widget=w;
357                 ctx->get_volume=get_volume;
358                 ctx->data=data;
359                 ctx->last_value=0;
360                 g_object_set_data_full(G_OBJECT(w),"ctx",ctx,g_free);
361                 task_id=g_timeout_add(50,(GSourceFunc)update_audio_meter,ctx);
362                 g_object_set_data_full(G_OBJECT(w),"task_id",GINT_TO_POINTER(task_id),(GDestroyNotify)on_audio_meter_destroy);
363         }
364 }
365
366 void linphone_gtk_in_call_view_enable_audio_view(LinphoneCall *call){
367         GtkWidget *callview=(GtkWidget*)linphone_call_get_user_pointer(call);
368         GtkWidget *audio_view=linphone_gtk_get_widget(callview,"incall_audioview");
369         //GtkWidget *mic=linphone_gtk_get_widget(callview,"incall_mic_icon");
370         GtkWidget *spk=linphone_gtk_get_widget(callview,"incall_spk_icon");
371         GtkWidget *mic_level=linphone_gtk_get_widget(callview,"mic_audiolevel");
372         GtkWidget *spk_level=linphone_gtk_get_widget(callview,"spk_audiolevel");
373         GdkPixbuf *pbuf;
374         //gtk_image_set_from_pixbuf(GTK_IMAGE(mic),(pbuf=create_pixbuf("mic_active.png")));
375         //g_object_unref(pbuf);
376         gtk_image_set_from_pixbuf(GTK_IMAGE(spk),(pbuf=create_pixbuf("speaker.png")));
377         g_object_unref(pbuf);
378         linphone_gtk_init_audio_meter(mic_level,(get_volume_t)linphone_call_get_record_volume,call);
379         linphone_gtk_init_audio_meter(spk_level,(get_volume_t)linphone_call_get_play_volume,call);
380         gtk_widget_show_all(audio_view);
381 }
382
383 void linphone_gtk_in_call_view_set_in_call(LinphoneCall *call){
384         GtkWidget *callview=(GtkWidget*)linphone_call_get_user_pointer(call);
385         GtkWidget *status=linphone_gtk_get_widget(callview,"in_call_status");
386         GtkWidget *callee=linphone_gtk_get_widget(callview,"in_call_uri");
387         GtkWidget *duration=linphone_gtk_get_widget(callview,"in_call_duration");
388         guint taskid=GPOINTER_TO_INT(g_object_get_data(G_OBJECT(callview),"taskid"));
389         
390         display_peer_name_in_label(callee,linphone_call_get_remote_address (call));
391
392         gtk_widget_show(linphone_gtk_get_widget(callview,"mute_pause_buttons"));
393         gtk_widget_hide(linphone_gtk_get_widget(callview,"answer_decline_panel"));
394         gtk_label_set_markup(GTK_LABEL(status),_("<b>In call</b>"));
395
396         gtk_label_set_text(GTK_LABEL(duration),_("00::00::00"));
397         linphone_gtk_in_call_set_animation_image(callview,GTK_STOCK_MEDIA_PLAY,TRUE);
398         linphone_gtk_enable_mute_button(
399                                         GTK_BUTTON(linphone_gtk_get_widget(callview,"incall_mute")),TRUE);
400         if (taskid==0){
401                 taskid=g_timeout_add(250,(GSourceFunc)linphone_gtk_in_call_view_refresh,call);
402                 g_object_set_data(G_OBJECT(callview),"taskid",GINT_TO_POINTER(taskid));
403         }
404         linphone_gtk_in_call_view_enable_audio_view(call);
405 }
406
407 void linphone_gtk_in_call_view_set_paused(LinphoneCall *call){
408         GtkWidget *callview=(GtkWidget*)linphone_call_get_user_pointer(call);
409         GtkWidget *status=linphone_gtk_get_widget(callview,"in_call_status");
410         gtk_widget_hide(linphone_gtk_get_widget(callview,"answer_decline_panel"));
411         gtk_label_set_markup(GTK_LABEL(status),_("<b>Paused call</b>"));
412         linphone_gtk_in_call_set_animation_image(callview,GTK_STOCK_MEDIA_PAUSE,TRUE);
413 }
414
415 void linphone_gtk_in_call_view_update_duration(LinphoneCall *call){
416         GtkWidget *callview=(GtkWidget*)linphone_call_get_user_pointer(call);
417         GtkWidget *duration_label=linphone_gtk_get_widget(callview,"in_call_duration");
418         int duration=linphone_call_get_duration(call);
419         char tmp[256]={0};
420         int seconds=duration%60;
421         int minutes=(duration/60)%60;
422         int hours=duration/3600;
423         snprintf(tmp,sizeof(tmp)-1,_("%02i::%02i::%02i"),hours,minutes,seconds);
424         gtk_label_set_text(GTK_LABEL(duration_label),tmp);
425 }
426
427 static gboolean in_call_view_terminated(LinphoneCall *call){
428         linphone_gtk_remove_in_call_view(call);
429         return FALSE;
430 }
431
432 void linphone_gtk_in_call_view_terminate(LinphoneCall *call, const char *error_msg){
433         GtkWidget *callview=(GtkWidget*)linphone_call_get_user_pointer(call);
434         GtkWidget *status=linphone_gtk_get_widget(callview,"in_call_status");
435         guint taskid=GPOINTER_TO_INT(g_object_get_data(G_OBJECT(callview),"taskid"));
436
437         if (error_msg==NULL)
438                 gtk_label_set_markup(GTK_LABEL(status),_("<b>Call ended.</b>"));
439         else{
440                 char *msg=g_markup_printf_escaped("<span color=\"red\"><b>%s</b></span>",error_msg);
441                 gtk_label_set_markup(GTK_LABEL(status),msg);
442                 g_free(msg);
443         }
444         linphone_gtk_in_call_set_animation_image(callview,
445                    linphone_gtk_get_ui_config("stop_call_icon","stopcall-red.png"),FALSE);
446         
447         gtk_widget_hide(linphone_gtk_get_widget(callview,"answer_decline_panel"));
448         gtk_widget_hide(linphone_gtk_get_widget(callview,"incall_audioview"));
449         linphone_gtk_enable_mute_button(
450                 GTK_BUTTON(linphone_gtk_get_widget(callview,"incall_mute")),FALSE);
451         linphone_gtk_enable_hold_button(call,FALSE,TRUE);
452         if (taskid!=0) g_source_remove(taskid);
453         g_timeout_add_seconds(2,(GSourceFunc)in_call_view_terminated,call);
454 }
455
456 void linphone_gtk_draw_mute_button(GtkButton *button, gboolean active){
457         g_object_set_data(G_OBJECT(button),"active",GINT_TO_POINTER(active));
458         if (active){
459                 GtkWidget *image=create_pixmap("mic_muted.png");
460                 /*gtk_button_set_label(GTK_BUTTON(button),_("Unmute"));*/
461                 if (image!=NULL) {
462                         gtk_button_set_image(GTK_BUTTON(button),image);
463                         gtk_widget_show(image);
464                 }
465         }else{
466                 GtkWidget *image=create_pixmap("mic_active.png");
467                 /*gtk_button_set_label(GTK_BUTTON(button),_("Mute"));*/
468                 if (image!=NULL) {
469                         gtk_button_set_image(GTK_BUTTON(button),image);
470                         gtk_widget_show(image);
471                 }
472         }
473 }
474
475 void linphone_gtk_mute_clicked(GtkButton *button){
476         int active=GPOINTER_TO_INT(g_object_get_data(G_OBJECT(button),"active"));
477         linphone_core_mute_mic(linphone_gtk_get_core(),!active);
478         linphone_gtk_draw_mute_button(button,!active);
479 }
480
481 void linphone_gtk_enable_mute_button(GtkButton *button, gboolean sensitive)
482 {
483         /*gtk_widget_set_sensitive(GTK_WIDGET(button),sensitive);*/
484         gtk_widget_set_visible(GTK_WIDGET(button),sensitive);
485         linphone_gtk_draw_mute_button(button,FALSE);
486 }
487
488 void linphone_gtk_draw_hold_button(GtkButton *button, gboolean active){
489         g_object_set_data(G_OBJECT(button),"active",GINT_TO_POINTER(active));
490         if (active){
491                 GtkWidget *image=create_pixmap("hold_off.png");
492                 gtk_button_set_label(GTK_BUTTON(button),_("Resume"));
493                 if (image!=NULL) {
494                         gtk_button_set_image(GTK_BUTTON(button),image);
495                         gtk_widget_show(image);
496                 }
497         }else{
498                 GtkWidget *image=create_pixmap("hold_on.png");
499                 gtk_button_set_label(GTK_BUTTON(button),_("Pause"));
500                 if (image!=NULL) {
501                         gtk_button_set_image(GTK_BUTTON(button),image);
502                         gtk_widget_show(image);
503                 }
504         }
505 }
506
507 void linphone_gtk_hold_clicked(GtkButton *button){
508         int active=GPOINTER_TO_INT(g_object_get_data(G_OBJECT(button),"active"));
509         LinphoneCall *call=linphone_gtk_get_currently_displayed_call ();
510         if(!active)
511         {
512                 linphone_core_pause_call(linphone_gtk_get_core(),call);
513         }
514         else
515         {
516                 linphone_core_resume_call(linphone_gtk_get_core(),call);
517         }
518 }
519
520 void linphone_gtk_enable_hold_button(LinphoneCall *call, gboolean sensitive, gboolean holdon){
521         GtkWidget *callview=(GtkWidget*)linphone_call_get_user_pointer (call);
522         GtkWidget *button;
523         g_return_if_fail(callview!=NULL);
524         button=linphone_gtk_get_widget(callview,"hold_call");
525         gtk_widget_set_sensitive(GTK_WIDGET(button),sensitive);
526         gtk_widget_set_visible(GTK_WIDGET(button),sensitive);
527         linphone_gtk_draw_hold_button(GTK_BUTTON(button),!holdon);
528 }