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);
87 if (linphone_address_get_display_name(from))
88 displayname=linphone_address_get_display_name(from);
90 id=linphone_address_as_string_uri_only(from);
92 }else id=ms_strdup(uri);
94 if (displayname!=NULL)
95 uri_label=g_markup_printf_escaped("<span size=\"large\">%s</span>\n<i>%s</i>",
98 uri_label=g_markup_printf_escaped("<span size=\"large\"><i>%s</i></span>\n",id);
99 gtk_label_set_markup(GTK_LABEL(label),uri_label);
102 if (from!=NULL) linphone_address_destroy(from);
105 void linphone_gtk_in_call_view_set_calling(const char *uri){
106 GtkWidget *main_window=linphone_gtk_get_main_window();
107 GtkWidget *status=linphone_gtk_get_widget(main_window,"in_call_status");
108 GtkWidget *callee=linphone_gtk_get_widget(main_window,"in_call_uri");
109 GtkWidget *duration=linphone_gtk_get_widget(main_window,"in_call_duration");
110 GtkWidget *animation=linphone_gtk_get_widget(main_window,"in_call_animation");
111 GdkPixbufAnimation *pbuf=create_pixbuf_animation("calling_anim.gif");
113 gtk_label_set_markup(GTK_LABEL(status),_("<b>Calling...</b>"));
114 display_peer_name_in_label(callee,uri);
116 gtk_label_set_text(GTK_LABEL(duration),_("00::00::00"));
118 gtk_image_set_from_animation(GTK_IMAGE(animation),pbuf);
119 g_object_unref(G_OBJECT(pbuf));
120 }else gtk_image_set_from_stock(GTK_IMAGE(animation),GTK_STOCK_INFO,GTK_ICON_SIZE_DIALOG);
123 void linphone_gtk_in_call_view_set_in_call(){
124 LinphoneCore *lc=linphone_gtk_get_core();
125 GtkWidget *main_window=linphone_gtk_get_main_window();
126 GtkWidget *status=linphone_gtk_get_widget(main_window,"in_call_status");
127 GtkWidget *callee=linphone_gtk_get_widget(main_window,"in_call_uri");
128 GtkWidget *duration=linphone_gtk_get_widget(main_window,"in_call_duration");
129 GtkWidget *animation=linphone_gtk_get_widget(main_window,"in_call_animation");
130 GdkPixbufAnimation *pbuf=create_pixbuf_animation("incall_anim.gif");
131 const LinphoneAddress *uri=linphone_core_get_remote_uri(lc);
132 char *tmp=linphone_address_as_string(uri);
133 display_peer_name_in_label(callee,tmp);
136 gtk_label_set_markup(GTK_LABEL(status),_("<b>In call with</b>"));
138 gtk_label_set_text(GTK_LABEL(duration),_("00::00::00"));
140 gtk_image_set_from_animation(GTK_IMAGE(animation),pbuf);
141 g_object_unref(G_OBJECT(pbuf));
142 }else gtk_image_set_from_stock(GTK_IMAGE(animation),GTK_STOCK_INFO,GTK_ICON_SIZE_DIALOG);
143 linphone_gtk_enable_mute_button(
144 GTK_TOGGLE_BUTTON(linphone_gtk_get_widget(main_window,"incall_mute")),TRUE);
147 void linphone_gtk_in_call_view_update_duration(int duration){
148 GtkWidget *main_window=linphone_gtk_get_main_window();
149 GtkWidget *duration_label=linphone_gtk_get_widget(main_window,"in_call_duration");
151 int seconds=duration%60;
152 int minutes=(duration/60)%60;
153 int hours=duration/3600;
154 snprintf(tmp,sizeof(tmp)-1,_("%02i::%02i::%02i"),hours,minutes,seconds);
155 gtk_label_set_text(GTK_LABEL(duration_label),tmp);
158 static gboolean in_call_view_terminated(){
159 linphone_gtk_show_idle_view();
163 void linphone_gtk_in_call_view_terminate(const char *error_msg){
164 GtkWidget *main_window=linphone_gtk_get_main_window();
165 GtkWidget *status=linphone_gtk_get_widget(main_window,"in_call_status");
166 GtkWidget *animation=linphone_gtk_get_widget(main_window,"in_call_animation");
167 GdkPixbuf *pbuf=create_pixbuf(linphone_gtk_get_ui_config("stop_call_icon","red.png"));
170 gtk_label_set_markup(GTK_LABEL(status),_("<b>Call ended.</b>"));
172 char *msg=g_markup_printf_escaped("<span color=\"red\"><b>%s</b></span>",error_msg);
173 gtk_label_set_markup(GTK_LABEL(status),msg);
177 gtk_image_set_from_pixbuf(GTK_IMAGE(animation),pbuf);
178 g_object_unref(G_OBJECT(pbuf));
180 linphone_gtk_enable_mute_button(
181 GTK_TOGGLE_BUTTON(linphone_gtk_get_widget(main_window,"incall_mute")),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){
210 gtk_widget_set_sensitive(GTK_WIDGET(button),sensitive);
211 gtk_object_set(GTK_OBJECT(button),"gtk-button-images",TRUE,NULL);
212 linphone_gtk_draw_mute_button(button,FALSE);