Commit 2306ab5e authored by Simon Morlat's avatar Simon Morlat
Browse files

implement nice call logs interface

parent 8210107a
<?xml version="1.0"?>
<!--Generated with glade3 3.4.5 on Wed Jul 30 17:55:28 2008 -->
<interface>
<requires lib="gtk+" version="2.16"/>
<!-- interface-naming-policy toplevel-contextual -->
<object class="GtkListStore" id="call_logs_store">
<columns>
<!-- column-name icon -->
<column type="gchar"/>
<!-- column-name sipaddress -->
<column type="gchar"/>
</columns>
</object>
<object class="GtkDialog" id="call_logs">
<property name="width_request">500</property>
<property name="height_request">370</property>
<property name="border_width">5</property>
<property name="title" translatable="yes">Call history</property>
<property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property>
<property name="window_position">center-on-parent</property>
<property name="icon">linphone2.png</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
<property name="type_hint">dialog</property>
<property name="has_separator">False</property>
<child internal-child="vbox">
<object class="GtkVBox" id="dialog-vbox1">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="spacing">2</property>
<child>
<object class="GtkScrolledWindow" id="scrolledwindow1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">GTK_POLICY_NEVER</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="hscrollbar_policy">never</property>
<property name="vscrollbar_policy">automatic</property>
<child>
<object class="GtkTextView" id="logtextview">
<object class="GtkTreeView" id="logs_view">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">False</property>
<property name="wrap_mode">GTK_WRAP_WORD</property>
<property name="headers_visible">False</property>
<signal name="row_activated" handler="linphone_gtk_history_row_activated"/>
</object>
</child>
</object>
......@@ -36,32 +46,35 @@
<child internal-child="action_area">
<object class="GtkHButtonBox" id="dialog-action_area1">
<property name="visible">True</property>
<property name="layout_style">GTK_BUTTONBOX_END</property>
<property name="layout_style">end</property>
<child>
<placeholder/>
</child>
<child>
<object class="GtkButton" id="button1">
<object class="GtkButton" id="call_logs_close">
<property name="label">gtk-close</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="label" translatable="yes">gtk-close</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="pack_type">GTK_PACK_END</property>
<property name="pack_type">end</property>
<property name="position">0</property>
</packing>
</child>
</object>
</child>
<action-widgets>
<action-widget response="0">button1</action-widget>
<action-widget response="0">call_logs_close</action-widget>
</action-widgets>
</object>
</interface>
......@@ -21,27 +21,61 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
void linphone_gtk_call_log_update(GtkWidget *w){
GtkTextView *v=GTK_TEXT_VIEW(linphone_gtk_get_widget(w,"logtextview"));
GtkTextBuffer *b=gtk_text_view_get_buffer(v);
GtkTextIter iter,begin;
int off;
char *logmsg;
GtkTreeView *v=GTK_TREE_VIEW(linphone_gtk_get_widget(w,"logs_view"));
GtkListStore *store;
const MSList *logs;
store=(GtkListStore*)gtk_tree_view_get_model(v);
if (store==NULL){
store=gtk_list_store_new(3,G_TYPE_STRING,G_TYPE_STRING, G_TYPE_POINTER);
gtk_tree_view_set_model(v,GTK_TREE_MODEL(store));
}
gtk_list_store_clear (store);
for (logs=linphone_core_get_call_logs(linphone_gtk_get_core());logs!=NULL;logs=logs->next){
LinphoneCallLog *cl=(LinphoneCallLog*)logs->data;
logmsg=linphone_call_log_to_str(cl);
gtk_text_buffer_get_end_iter(b,&iter);
off=gtk_text_iter_get_offset(&iter);
gtk_text_buffer_insert(b,&iter,logmsg,-1);
gtk_text_buffer_get_end_iter(b,&iter);
gtk_text_buffer_insert(b,&iter,"\n",-1);
gtk_text_buffer_get_end_iter(b,&iter);
gtk_text_buffer_get_iter_at_offset(b,&begin,off);
gtk_text_buffer_apply_tag_by_name(b,cl->dir==LinphoneCallOutgoing ? "green" : "blue" ,&begin,&iter);
ms_free(logmsg);
GtkTreeIter iter;
LinphoneAddress *la=cl->dir==LinphoneCallIncoming ? cl->from : cl->to;
char *addr= linphone_address_as_string_uri_only (la);
const char *display;
gchar *logtxt;
display=linphone_address_get_display_name (la);
if (display==NULL){
display=linphone_address_get_username (la);
if (display==NULL)
display=linphone_address_get_domain (la);
}
logtxt=g_markup_printf_escaped("<big><b>%s</b></big>\t<small><i>%s</i></small>\n"
"%s\t%i minutes %i seconds",display, addr, cl->start_date,
cl->duration/60,cl->duration%60);
gtk_list_store_append (store,&iter);
gtk_list_store_set (store,&iter,
0, cl->dir==LinphoneCallOutgoing ? GTK_STOCK_GO_UP : GTK_STOCK_GO_DOWN,
1, logtxt,2,la,-1);
ms_free(addr);
g_free(logtxt);
}
}
void linphone_gtk_history_row_activated(GtkWidget *treeview){
GtkTreeSelection *sel;
sel=gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview));
if (sel!=NULL){
GtkTreeModel *model=NULL;
GtkTreeIter iter;
if (gtk_tree_selection_get_selected (sel,&model,&iter)){
gpointer pla;
LinphoneAddress *la;
char *tmp;
gtk_tree_model_get(model,&iter,2,&pla,-1);
la=(LinphoneAddress*)pla;
tmp=linphone_address_as_string (la);
gtk_entry_set_text(GTK_ENTRY(linphone_gtk_get_widget(linphone_gtk_get_main_window(),"uribar")),tmp);
ms_free(tmp);
}
}
gtk_text_buffer_get_end_iter(b,&iter);
gtk_text_view_scroll_to_iter(v,&iter,0,FALSE,0,0);
}
void linphone_gtk_call_log_response(GtkWidget *w){
......@@ -50,18 +84,28 @@ void linphone_gtk_call_log_response(GtkWidget *w){
gtk_widget_destroy(w);
}
static void fill_renderers(GtkTreeView *v){
GtkTreeViewColumn *c;
GtkCellRenderer *r=gtk_cell_renderer_pixbuf_new ();
g_object_set(r,"stock-size",GTK_ICON_SIZE_BUTTON,NULL);
c=gtk_tree_view_column_new_with_attributes("icon",r,"stock-id",0,NULL);
gtk_tree_view_append_column (v,c);
r=gtk_cell_renderer_text_new ();
c=gtk_tree_view_column_new_with_attributes("sipaddress",r,"markup",1,NULL);
gtk_tree_view_append_column (v,c);
}
GtkWidget * linphone_gtk_show_call_logs(void){
GtkWidget *mw=linphone_gtk_get_main_window();
GtkTextBuffer *b;
GtkWidget *w=(GtkWidget*)g_object_get_data(G_OBJECT(linphone_gtk_get_main_window()),"call_logs");
if (w==NULL){
w=linphone_gtk_create_window("call_logs");
fill_renderers(GTK_TREE_VIEW(linphone_gtk_get_widget(w,"logs_view")));
g_object_set_data(G_OBJECT(mw),"call_logs",w);
g_signal_connect(G_OBJECT(w),"response",(GCallback)linphone_gtk_call_log_response,NULL);
gtk_widget_show(w);
b=gtk_text_view_get_buffer(GTK_TEXT_VIEW(linphone_gtk_get_widget(w,"logtextview")));
gtk_text_buffer_create_tag(b,"blue","foreground","blue",NULL);
gtk_text_buffer_create_tag(b,"green","foreground","green",NULL);
linphone_gtk_call_log_update(w);
}else gtk_window_present(GTK_WINDOW(w));
return w;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment