calltree.c 14.1 KB
Newer Older
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
1
2
/*
 *  Copyright (C) 2007 Savoir-Faire Linux inc.
3
 *  Author: Pierre-Luc Beaudoin <pierre-luc@squidy.info>
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
 *                                                                              
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *                                                                                
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *                                                                              
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include <gtk/gtk.h>
21
#include <actions.h>
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
22
23
#include <calltree.h>
#include <calllist.h>
24
#include <dbus.h>
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
25
26

GtkListStore * store;
27
28
GtkWidget *view;

29
30
31
32
33
34
35
GtkWidget   * toolbar;
GtkToolItem * callButton;
GtkToolItem * pickupButton;
GtkToolItem * hangupButton;
GtkToolItem * holdButton;
GtkToolItem * transfertButton;
GtkToolItem * unholdButton;
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
36

37
/**
38
 * Make a call
39
40
 */
static void 
41
call_button( GtkWidget *widget, gpointer   data )
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
42
43
44
45
46
47
48
49
50
{
  sflphone_new_call();
}

/**
 * Pick up
 */
static void 
pick_up( GtkWidget *widget, gpointer   data )
51
{
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
52
  sflphone_pick_up();
53
54
55
}

/**
56
 * Hang up the line
57
58
 */
static void 
59
hang_up( GtkWidget *widget, gpointer   data )
60
{
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
61
  sflphone_hang_up();
62
63
64
}

/**
65
 * Hold the line
66
67
 */
static void 
68
hold( GtkWidget *widget, gpointer   data )
69
{
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
70
  sflphone_on_hold();
71
72
73
74
75
76
77
78
}

/**
 * Transfert the line
 */
static void 
transfert( GtkWidget *widget, gpointer   data )
{
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
79
  sflphone_set_transfert();
80
81
}

82
83
84
85
86
87
/**
 * Unhold call
 */
static void 
unhold( GtkWidget *widget, gpointer   data )
{
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
88
  sflphone_off_hold();
89
}
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
90

91
void 
92
toolbar_update_buttons ()
93
94
{
  gtk_widget_set_sensitive( GTK_WIDGET(callButton),       FALSE);
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
95
  gtk_widget_set_sensitive( GTK_WIDGET(pickupButton),     FALSE);
96
97
98
99
  gtk_widget_set_sensitive( GTK_WIDGET(hangupButton),     FALSE);
  gtk_widget_set_sensitive( GTK_WIDGET(holdButton),       FALSE);
  gtk_widget_set_sensitive( GTK_WIDGET(transfertButton),  FALSE);
  gtk_widget_set_sensitive( GTK_WIDGET(unholdButton),     FALSE);
100
101
102
103
104
  g_object_ref(holdButton);
  g_object_ref(unholdButton);
  gtk_container_remove(GTK_CONTAINER(toolbar), GTK_WIDGET(holdButton));
  gtk_container_remove(GTK_CONTAINER(toolbar), GTK_WIDGET(unholdButton));
  gtk_toolbar_insert(GTK_TOOLBAR(toolbar), holdButton, 3);
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
105
	
106
	call_t * selectedCall = call_get_selected();
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
107
	if (selectedCall)
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
108
	{
109
    switch(selectedCall->state) 
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
110
111
  	{
  	  case CALL_STATE_INCOMING:
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
112
        gtk_widget_set_sensitive( GTK_WIDGET(pickupButton),     TRUE);
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
113
114
115
116
117
        gtk_widget_set_sensitive( GTK_WIDGET(hangupButton),     TRUE);
        break;
      case CALL_STATE_HOLD:
    	  gtk_widget_set_sensitive( GTK_WIDGET(hangupButton),     TRUE);
        gtk_widget_set_sensitive( GTK_WIDGET(unholdButton),     TRUE);
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
118
        gtk_widget_set_sensitive( GTK_WIDGET(callButton),       TRUE);
119
120
121
        g_object_ref(holdButton);
        gtk_container_remove(GTK_CONTAINER(toolbar), GTK_WIDGET(holdButton));
        gtk_toolbar_insert(GTK_TOOLBAR(toolbar), unholdButton, 3);
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
122
123
124
125
126
        break;
      case CALL_STATE_RINGING:
    	  gtk_widget_set_sensitive( GTK_WIDGET(hangupButton),     TRUE);
        break;
      case CALL_STATE_DIALING:
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
127
        gtk_widget_set_sensitive( GTK_WIDGET(pickupButton),     TRUE);
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
128
        gtk_widget_set_sensitive( GTK_WIDGET(hangupButton),     TRUE);
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
129
        gtk_widget_set_sensitive( GTK_WIDGET(callButton),       TRUE);
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
130
131
132
133
134
        break;
      case CALL_STATE_CURRENT:
        gtk_widget_set_sensitive( GTK_WIDGET(hangupButton),     TRUE);
        gtk_widget_set_sensitive( GTK_WIDGET(holdButton),       TRUE);
        gtk_widget_set_sensitive( GTK_WIDGET(transfertButton),  TRUE);
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
135
        gtk_widget_set_sensitive( GTK_WIDGET(callButton),       TRUE);
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
136
137
138
139
140
141
        break;
      case CALL_STATE_BUSY:
      case CALL_STATE_FAILURE:
        gtk_widget_set_sensitive( GTK_WIDGET(hangupButton),     TRUE);
        break; 
  	  default:
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
142
  	    g_warning("Should not happen!");
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
143
144
145
  	    break;
  	}
  }
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
146
147
  else 
  {
148
149
150
151
152
153
154
155
    if( account_list_get_size() > 0 )
    {
      gtk_widget_set_sensitive( GTK_WIDGET(callButton), TRUE);
    }
    else
    {
      gtk_widget_set_sensitive( GTK_WIDGET(callButton), FALSE);
    }
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
156
  }
157
158
159
160
161
162
163
164
165
166
167
}
/* Call back when the user click on a call in the list */
static void 
selected(GtkTreeSelection *sel, GtkTreeModel *model) 
{
	GtkTreeIter  iter;
	GValue val;
	
	if (! gtk_tree_selection_get_selected (sel, &model, &iter))
		return;
  
168
	val.g_type = 0;
169
170
	gtk_tree_model_get_value (model, &iter, 2, &val);
	
171
	call_select((call_t*) g_value_get_pointer(&val));
172
  g_value_unset(&val);
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
173
  
174
  toolbar_update_buttons();
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
175
176
}

177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
/* A row is activated when it is double clicked */
void  row_activated(GtkTreeView       *tree_view,
                    GtkTreePath       *path,
                    GtkTreeViewColumn *column,
                    void * foo) 
{
  call_t * selectedCall = call_get_selected();
	if (selectedCall)
	{
    switch(selectedCall->state)  
  	{
  	  case CALL_STATE_INCOMING:
        dbus_accept(selectedCall);
        break;
      case CALL_STATE_HOLD:
        dbus_unhold(selectedCall);
        break;
      case CALL_STATE_RINGING:
      case CALL_STATE_CURRENT:
      case CALL_STATE_BUSY:
      case CALL_STATE_FAILURE:
        break;
      case CALL_STATE_DIALING:
        sflphone_place_call (selectedCall);
        break;
  	  default:
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
203
  	    g_warning("Should not happen!");
204
205
206
  	    break;
  	}
  }
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
}                  


GtkWidget * 
create_toolbar (){
  GtkWidget *ret;
  GtkWidget *image;

  ret = gtk_toolbar_new();
  
  toolbar = ret;

  image = gtk_image_new_from_file( ICONS_DIR "/call.svg");
  callButton = gtk_tool_button_new (image, "Place a Call");
  g_signal_connect (G_OBJECT (callButton), "clicked",
                    G_CALLBACK (call_button), NULL);
  gtk_toolbar_insert(GTK_TOOLBAR(ret), GTK_TOOL_ITEM(callButton), -1);  

  image = gtk_image_new_from_file( ICONS_DIR "/accept.svg");
  pickupButton = gtk_tool_button_new (image, "Pick Up");
  gtk_widget_set_state( GTK_WIDGET(pickupButton), GTK_STATE_INSENSITIVE);
  g_signal_connect (G_OBJECT (pickupButton), "clicked",
                    G_CALLBACK (pick_up), NULL);
  gtk_toolbar_insert(GTK_TOOLBAR(ret), GTK_TOOL_ITEM(pickupButton), -1);  

  image = gtk_image_new_from_file( ICONS_DIR "/hang_up.svg");
  hangupButton = gtk_tool_button_new (image, "Hang up");
  //gtk_widget_hide( hangupButton );
  gtk_widget_set_state( GTK_WIDGET(hangupButton), GTK_STATE_INSENSITIVE);
  g_signal_connect (G_OBJECT (hangupButton), "clicked",
                    G_CALLBACK (hang_up), NULL);
  gtk_toolbar_insert(GTK_TOOLBAR(ret), GTK_TOOL_ITEM(hangupButton), -1);  
                    
  image = gtk_image_new_from_file( ICONS_DIR "/unhold.svg");
  unholdButton = gtk_tool_button_new (image, "Off Hold");
  gtk_widget_set_state( GTK_WIDGET(unholdButton), GTK_STATE_INSENSITIVE);
  g_signal_connect (G_OBJECT (unholdButton), "clicked",
                    G_CALLBACK (unhold), NULL);
  gtk_widget_show_all(GTK_WIDGET(unholdButton));
         
  image = gtk_image_new_from_file( ICONS_DIR "/hold.svg");
  holdButton =  gtk_tool_button_new (image, "On Hold");
  gtk_widget_set_state( GTK_WIDGET(holdButton), GTK_STATE_INSENSITIVE);
  g_signal_connect (G_OBJECT (holdButton), "clicked",
                    G_CALLBACK (hold), NULL);
  gtk_toolbar_insert(GTK_TOOLBAR(ret), GTK_TOOL_ITEM(holdButton), -1);  
  
  image = gtk_image_new_from_file( ICONS_DIR "/transfert.svg");
  transfertButton = gtk_tool_button_new (image, "Transfert");
  gtk_widget_set_state( GTK_WIDGET(transfertButton), GTK_STATE_INSENSITIVE);
  g_signal_connect (G_OBJECT (transfertButton), "clicked",
                    G_CALLBACK (transfert), NULL);
  gtk_toolbar_insert(GTK_TOOLBAR(ret), GTK_TOOL_ITEM(transfertButton), -1);  
  

  return ret;

}  
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
265
266
267
268
269
270
271
272

GtkWidget * 
create_call_tree (){
  GtkWidget *ret;
	GtkWidget *sw;
	GtkCellRenderer *rend;
	GtkTreeViewColumn *col;
	GtkTreeSelection *sel;
273
	
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
274
275
276
277
	ret = gtk_vbox_new(FALSE, 10); 
	gtk_container_set_border_width (GTK_CONTAINER (ret), 0);

	sw = gtk_scrolled_window_new( NULL, NULL);
278
	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
279
280
281
282
283
284
285
286
287
288
	gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_IN);

	store = gtk_list_store_new (3, 
	  GDK_TYPE_PIXBUF,// Icon 
	  G_TYPE_STRING,  // Description
	  G_TYPE_POINTER  // Pointer to the Object
	  );


	view = gtk_tree_view_new_with_model (GTK_TREE_MODEL(store));
289
  gtk_tree_view_set_headers_visible (GTK_TREE_VIEW(view), FALSE);
290
291
292
  g_signal_connect (G_OBJECT (view), "row-activated",
			  G_CALLBACK (row_activated),
			  NULL);
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
	
  rend = gtk_cell_renderer_pixbuf_new();
  col = gtk_tree_view_column_new_with_attributes ("Icon",
							rend,
							"pixbuf", 0,
							NULL);
	gtk_tree_view_append_column (GTK_TREE_VIEW(view), col);

	rend = gtk_cell_renderer_text_new();
	col = gtk_tree_view_column_new_with_attributes ("Description",
							rend,
							"markup", 1,
							NULL);
	gtk_tree_view_append_column (GTK_TREE_VIEW(view), col);
	g_object_unref(G_OBJECT(store));
	gtk_container_add(GTK_CONTAINER(sw), view);

  sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (view));
  g_signal_connect (G_OBJECT (sel), "changed",
			  G_CALLBACK (selected),
			  store);
  
315
316
  gtk_box_pack_start(GTK_BOX(ret), sw, TRUE, TRUE, 0);
	
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
317
318
	gtk_widget_show(ret); 
	
319
320
	toolbar_update_buttons();
	
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
321
322
323
324
	return ret;
	
}
void 
325
update_call_tree_remove (call_t * c)
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
326
327
{
	GtkTreeIter iter;
328
329
	GValue val;
	call_t * iterCall;
330
 
331
332
333
334
335
336
	int nbChild = gtk_tree_model_iter_n_children(GTK_TREE_MODEL(store), NULL);
  int i;
	for( i = 0; i < nbChild; i++)
	{
	  if(gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(store), &iter, NULL, i))
	  {
337
	    val.g_type = 0;
338
339
340
341
342
343
344
345
346
347
348
    	gtk_tree_model_get_value (GTK_TREE_MODEL(store), &iter, 2, &val);
    	
    	iterCall = (call_t*) g_value_get_pointer(&val);
      g_value_unset(&val);
      
      if(iterCall == c)
      {
        gtk_list_store_remove(store, &iter);
      }
	  }
	}
349
	call_t * selectedCall = call_get_selected();
350
	if(selectedCall == c)
351
	  call_select(NULL);
352
	toolbar_update_buttons();
353
}
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
354

355
356
357
358
359
360
361
362
363
void 
update_call_tree (call_t * c)
{
  GdkPixbuf *pixbuf;
  GtkTreeIter iter;
	GValue val;
	call_t * iterCall;
	
	int nbChild = gtk_tree_model_iter_n_children(GTK_TREE_MODEL(store), NULL);
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
364
  int i;
365
	for( i = 0; i < nbChild; i++)
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
366
	{
367
368
	  if(gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(store), &iter, NULL, i))
	  {
369
	    val.g_type = 0;
370
371
372
373
374
375
    	gtk_tree_model_get_value (GTK_TREE_MODEL(store), &iter, 2, &val);
    	
    	iterCall = (call_t*) g_value_get_pointer(&val);
      g_value_unset(&val);
      
      if(iterCall == c)
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
376
      {
377
378
        // Existing call in the list
        gchar * markup;
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
379
380
381
382
383
384
385
386
387
388
389
        if(c->state == CALL_STATE_TRANSFERT)
        {
          markup = g_markup_printf_escaped("<b>%s</b>\n"
    						    "%s\n<i>Transfert to:</i> %s",  
    						    call_get_name(c), 
    						    call_get_number(c), 
    						    c->to);
        }
        else
        {
          markup = g_markup_printf_escaped("<b>%s</b>\n"
390
391
392
    						    "%s", 
    						    call_get_name(c), 
    						    call_get_number(c));
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
393
394
        }
        
395
    		    		
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
396
    		switch(c->state)
397
    		{
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
398
      		case CALL_STATE_HOLD:
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
399
      		  pixbuf = gdk_pixbuf_new_from_file(ICONS_DIR "/hold.svg", NULL);
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
400
401
      		  break;
      		case CALL_STATE_RINGING:
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
402
      		  pixbuf = gdk_pixbuf_new_from_file(ICONS_DIR "/ring.svg", NULL);
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
403
404
      		  break;
      		case CALL_STATE_CURRENT:
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
405
      		  pixbuf = gdk_pixbuf_new_from_file(ICONS_DIR "/current.svg", NULL);
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
406
407
      		  break;
      		case CALL_STATE_DIALING:
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
408
      		  pixbuf = gdk_pixbuf_new_from_file(ICONS_DIR "/dial.svg", NULL);
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
409
410
      		  break;
      		case CALL_STATE_FAILURE:
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
411
      		  pixbuf = gdk_pixbuf_new_from_file(ICONS_DIR "/fail.svg", NULL);
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
412
413
      		  break;
      		case CALL_STATE_BUSY:
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
414
      		  pixbuf = gdk_pixbuf_new_from_file(ICONS_DIR "/busy.svg", NULL);
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
415
      		  break;
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
416
417
418
      		case CALL_STATE_TRANSFERT:
      		  pixbuf = gdk_pixbuf_new_from_file(ICONS_DIR "/transfert.svg", NULL);
      		  break;
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
419
      		default:
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
420
      		  g_warning("Should not happen!");
421
    		}
422
423
    	  //Resize it
        if(pixbuf)
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
424
        {
425
426
427
428
          if(gdk_pixbuf_get_width(pixbuf) > 32 || gdk_pixbuf_get_height(pixbuf) > 32)
          {
            pixbuf =  gdk_pixbuf_scale_simple(pixbuf, 32, 32, GDK_INTERP_BILINEAR);
          }
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
429
        }
430
    		gtk_list_store_set(store, &iter,
431
432
433
    				  0, pixbuf, // Icon
  		        1, markup, // Description
  		        -1);
434
435
436
437
438
439
    				   
    		if (pixbuf != NULL)
    			g_object_unref(G_OBJECT(pixbuf));
        
      } 
    }
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
440
441
    
  } 
442
  toolbar_update_buttons();
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
443
	//return row_ref;
444
445
446
447
448
449
450
451

}

void 
update_call_tree_add (call_t * c)
{
  GdkPixbuf *pixbuf;
	GtkTreeIter iter;
452
	GtkTreeSelection* sel;
453
454
455

  // New call in the list
  gchar * markup;
456
  markup = g_markup_printf_escaped("<b>%s</b>\n"
457
458
459
  				    "%s", 
  				    call_get_name(c), 
  				    call_get_number(c));
460
  
461
462
  gtk_list_store_append (store, &iter);

Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
463
464
465
  switch(c->state)
	{
		case CALL_STATE_INCOMING:
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
466
		  pixbuf = gdk_pixbuf_new_from_file(ICONS_DIR "/ring.svg", NULL);
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
467
468
		  break;
		case CALL_STATE_DIALING:
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
469
		  pixbuf = gdk_pixbuf_new_from_file(ICONS_DIR "/dial.svg", NULL);
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
470
471
		  break;
		case CALL_STATE_RINGING:
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
472
		  pixbuf = gdk_pixbuf_new_from_file(ICONS_DIR "/ring.svg", NULL);
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
473
474
		  break;
		default:
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
475
		  g_warning("Should not happen!");
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
476
477
	}
	
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
  //Resize it
  if(pixbuf)
  {
    if(gdk_pixbuf_get_width(pixbuf) > 32 || gdk_pixbuf_get_height(pixbuf) > 32)
    {
      pixbuf =  gdk_pixbuf_scale_simple(pixbuf, 32, 32, GDK_INTERP_BILINEAR);
    }
  }
  gtk_list_store_set(store, &iter,
  		   0, pixbuf, // Icon
  		   1, markup, // Description
  		   2, c,      // Pointer
  		   -1);
  		   
  if (pixbuf != NULL)
  	g_object_unref(G_OBJECT(pixbuf));

  //g_free(markup);
496
497
  sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
  gtk_tree_selection_select_iter(GTK_TREE_SELECTION(sel), &iter);
498
  toolbar_update_buttons();
499
	//return row_ref;
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
500
}