2 linphone, gtk-glade interface.
3 Copyright (C) 2008 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.
23 static void fill_renderers(GtkTreeView *v){
25 GtkCellRenderer *r=gtk_cell_renderer_pixbuf_new ();
27 c=gtk_tree_view_column_new_with_attributes("icon",r,"pixbuf",0,NULL);
28 gtk_tree_view_append_column (v,c);
30 r=gtk_cell_renderer_text_new ();
31 c=gtk_tree_view_column_new_with_attributes("sipaddress",r,"markup",1,NULL);
32 gtk_tree_view_append_column (v,c);
35 void linphone_gtk_call_log_update(GtkWidget *w){
36 GtkTreeView *v=GTK_TREE_VIEW(linphone_gtk_get_widget(w,"logs_view"));
40 store=(GtkListStore*)gtk_tree_view_get_model(v);
42 store=gtk_list_store_new(3,GDK_TYPE_PIXBUF,G_TYPE_STRING,G_TYPE_POINTER);
43 gtk_tree_view_set_model(v,GTK_TREE_MODEL(store));
44 g_object_unref(G_OBJECT(store));
45 fill_renderers(GTK_TREE_VIEW(linphone_gtk_get_widget(w,"logs_view")));
46 // gtk_button_set_image(GTK_BUTTON(linphone_gtk_get_widget(w,"call_back_button")),
47 // create_pixmap (linphone_gtk_get_ui_config("callback_button","status-green.png")));
49 gtk_list_store_clear (store);
51 for (logs=linphone_core_get_call_logs(linphone_gtk_get_core());logs!=NULL;logs=logs->next){
52 LinphoneCallLog *cl=(LinphoneCallLog*)logs->data;
54 LinphoneAddress *la=cl->dir==LinphoneCallIncoming ? cl->from : cl->to;
55 char *addr= linphone_address_as_string_uri_only (la);
57 gchar *logtxt, *minutes, *seconds;
59 const char *status=NULL;
60 gchar *start_date=NULL;
62 #if GLIB_CHECK_VERSION(2,26,0)
63 if (cl->start_date_time){
64 GDateTime *dt=g_date_time_new_from_unix_local(cl->start_date_time);
65 start_date=g_date_time_format(dt,"%c");
66 g_date_time_unref(dt);
70 display=linphone_address_get_display_name (la);
72 display=linphone_address_get_username (la);
74 display=linphone_address_get_domain (la);
77 snprintf(quality,sizeof(quality),"%.1f",cl->quality);
80 case LinphoneCallAborted:
83 case LinphoneCallMissed:
86 case LinphoneCallDeclined:
92 minutes=g_markup_printf_escaped(
93 ngettext("%i minute", "%i minutes", cl->duration/60),
95 seconds=g_markup_printf_escaped(
96 ngettext("%i second", "%i seconds", cl->duration%60),
98 if (status==NULL) logtxt=g_markup_printf_escaped(
99 _("<big><b>%s</b></big>\t<small><i>%s</i>\t"
100 "<i>Quality: %s</i></small>\n%s\t%s %s\t"),
101 display, addr, cl->quality!=-1 ? quality : _("n/a"),
102 start_date ? start_date : cl->start_date, minutes, seconds);
103 else logtxt=g_markup_printf_escaped(
104 _("<big><b>%s</b></big>\t<small><i>%s</i></small>\t"
107 start_date ? start_date : cl->start_date, status);
110 if (start_date) g_free(start_date);
111 gtk_list_store_append (store,&iter);
113 GdkPixbuf *incoming = create_pixbuf("call_status_incoming.png");
114 GdkPixbuf *outgoing = create_pixbuf("call_status_outgoing.png");
115 gtk_list_store_set (store,&iter,
116 0, cl->dir==LinphoneCallOutgoing ? outgoing : incoming,
124 static bool_t put_selection_to_uribar(GtkWidget *treeview){
125 GtkTreeSelection *sel;
127 sel=gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview));
129 GtkTreeModel *model=NULL;
131 if (gtk_tree_selection_get_selected (sel,&model,&iter)){
135 gtk_tree_model_get(model,&iter,2,&pla,-1);
136 la=(LinphoneAddress*)pla;
137 tmp=linphone_address_as_string (la);
138 gtk_entry_set_text(GTK_ENTRY(linphone_gtk_get_widget(linphone_gtk_get_main_window(),"uribar")),tmp);
146 void linphone_gtk_history_row_activated(GtkWidget *treeview){
147 if (put_selection_to_uribar(treeview)){
148 GtkWidget *mw=linphone_gtk_get_main_window();
149 linphone_gtk_start_call(linphone_gtk_get_widget(mw,"start_call"));
153 void linphone_gtk_history_row_selected(GtkWidget *treeview){
154 put_selection_to_uribar(treeview);
157 void linphone_gtk_clear_call_logs(GtkWidget *button){
158 linphone_core_clear_call_logs (linphone_gtk_get_core());
159 linphone_gtk_call_log_update(gtk_widget_get_toplevel(button));
162 void linphone_gtk_call_log_callback(GtkWidget *button){
163 GtkWidget *mw=linphone_gtk_get_main_window();
164 if (put_selection_to_uribar(linphone_gtk_get_widget(mw,"logs_view")))
165 linphone_gtk_start_call(linphone_gtk_get_widget(mw,"start_call"));
168 void linphone_gtk_call_log_response(GtkWidget *w, guint response_id){
169 GtkWidget *mw=linphone_gtk_get_main_window();
171 if (put_selection_to_uribar(linphone_gtk_get_widget(w,"logs_view")))
172 linphone_gtk_start_call(linphone_gtk_get_widget(mw,"start_call"));
173 }else if (response_id==2){
174 linphone_core_clear_call_logs (linphone_gtk_get_core());
175 linphone_gtk_call_log_update(w);
178 g_object_set_data(G_OBJECT(mw),"call_logs",NULL);
179 gtk_widget_destroy(w);
184 GtkWidget * linphone_gtk_show_call_logs(void){
185 GtkWidget *mw=linphone_gtk_get_main_window();
187 GtkWidget *w=(GtkWidget*)g_object_get_data(G_OBJECT(linphone_gtk_get_main_window()),"call_logs");
189 w=linphone_gtk_create_window("call_logs");
190 // gtk_button_set_image(GTK_BUTTON(linphone_gtk_get_widget(w,"call_back_button")),
191 // create_pixmap (linphone_gtk_get_ui_config("callback_button","status-green.png")));
192 g_object_set_data(G_OBJECT(mw),"call_logs",w);
193 g_signal_connect(G_OBJECT(w),"response",(GCallback)linphone_gtk_call_log_response,NULL);
195 linphone_gtk_call_log_update(w);
196 }else gtk_window_present(GTK_WINDOW(w));