menus.c 27.6 KB
Newer Older
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
1
2
/*
 *  Copyright (C) 2007 Savoir-Faire Linux inc.
Emmanuel Milou's avatar
Emmanuel Milou committed
3
 *  Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com>
4
 *  Author: Pierre-Luc Beaudoin <pierre-luc.beaudoin@savoirfairelinux.com>
5
 *
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
6
7
 *  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
8
 *  the Free Software Foundation; either version 3 of the License, or
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
9
 *  (at your option) any later version.
10
 *
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
11
12
13
14
 *  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.
15
 *
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
16
17
18
19
 *  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.
 */
20

Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
21
#include <menus.h>
22
#include <actions.h>
23
24
25
#include <calllist.h>
#include <calltree.h>
#include <config.h>
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
26
#include <configwindow.h>
27
28
#include <dbus.h>
#include <mainwindow.h>
areversat's avatar
areversat committed
29
#include <calltab.h>
30
#include <assistant.h>
31
#include <gtk/gtk.h>
32
#include <glib/gprintf.h>
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
33
34
#include <string.h> // for strlen

Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
35
36
GtkWidget * pickUpMenu;
GtkWidget * hangUpMenu;
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
37
GtkWidget * newCallMenu;
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
38
GtkWidget * holdMenu;
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
39
40
GtkWidget * copyMenu;
GtkWidget * pasteMenu;
41
GtkWidget * recordMenu;
42

Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
43
guint holdConnId;     //The hold_menu signal connection ID
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
44

45
46
GtkWidget * dialpadMenu;
GtkWidget * volumeMenu;
47
GtkWidget * searchbarMenu;
48
49


Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
50
void update_menus()
51
{
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
52
53
  //Block signals for holdMenu
  gtk_signal_handler_block(GTK_OBJECT(holdMenu), holdConnId);
54

Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
55
56
  gtk_widget_set_sensitive( GTK_WIDGET(pickUpMenu), FALSE);
  gtk_widget_set_sensitive( GTK_WIDGET(hangUpMenu), FALSE);
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
57
  gtk_widget_set_sensitive( GTK_WIDGET(newCallMenu),FALSE);
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
58
  gtk_widget_set_sensitive( GTK_WIDGET(holdMenu),   FALSE);
59
  gtk_widget_set_sensitive( GTK_WIDGET(recordMenu), FALSE);
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
60
  gtk_widget_set_sensitive( GTK_WIDGET(copyMenu),   FALSE);
61

62
  call_t * selectedCall = call_get_selected(active_calltree);
63
64
  if (selectedCall)
  {
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
65
    gtk_widget_set_sensitive( GTK_WIDGET(copyMenu),   TRUE);
66
    switch(selectedCall->state)
67
68
69
70
71
    {
      case CALL_STATE_INCOMING:
	gtk_widget_set_sensitive( GTK_WIDGET(pickUpMenu), TRUE);
	gtk_widget_set_sensitive( GTK_WIDGET(hangUpMenu), TRUE);
	break;
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
72
      case CALL_STATE_HOLD:
73
74
75
	gtk_widget_set_sensitive( GTK_WIDGET(hangUpMenu), TRUE);
	gtk_widget_set_sensitive( GTK_WIDGET(holdMenu),   TRUE);
	gtk_widget_set_sensitive( GTK_WIDGET(newCallMenu),TRUE);
Emmanuel Milou's avatar
Emmanuel Milou committed
76
        gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM ( holdMenu ), gtk_image_new_from_file( ICONS_DIR "/icon_unhold.svg"));
77
	break;
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
78
      case CALL_STATE_RINGING:
79
80
81
	gtk_widget_set_sensitive( GTK_WIDGET(pickUpMenu), TRUE);
	gtk_widget_set_sensitive( GTK_WIDGET(hangUpMenu), TRUE);
	break;
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
82
      case CALL_STATE_DIALING:
83
84
85
86
	gtk_widget_set_sensitive( GTK_WIDGET(pickUpMenu), TRUE);
	gtk_widget_set_sensitive( GTK_WIDGET(hangUpMenu), TRUE);
	gtk_widget_set_sensitive( GTK_WIDGET(newCallMenu),TRUE);
	break;
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
87
      case CALL_STATE_CURRENT:
88
      case CALL_STATE_RECORD:
89
90
91
	gtk_widget_set_sensitive( GTK_WIDGET(hangUpMenu), TRUE);
	gtk_widget_set_sensitive( GTK_WIDGET(holdMenu),   TRUE);
	gtk_widget_set_sensitive( GTK_WIDGET(newCallMenu),TRUE);
92
        gtk_widget_set_sensitive( GTK_WIDGET(recordMenu), TRUE);
Emmanuel Milou's avatar
Emmanuel Milou committed
93
        gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM ( holdMenu ), gtk_image_new_from_file( ICONS_DIR "/icon_hold.svg"));
94
	break;
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
95
96
      case CALL_STATE_BUSY:
      case CALL_STATE_FAILURE:
97
	gtk_widget_set_sensitive( GTK_WIDGET(hangUpMenu), TRUE);
98
	break;
99
100
101
102
      default:
	g_warning("Should not happen in update_menus()!");
	break;
    }
103
  }
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
104
105
106
  else
  {
    gtk_widget_set_sensitive( GTK_WIDGET(newCallMenu), TRUE);
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
107
  }
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
108
  gtk_signal_handler_unblock(holdMenu, holdConnId);
areversat's avatar
areversat committed
109

Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
110
}
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
111
/* ----------------------------------------------------------------- */
112
  static void
113
help_about ( void * foo UNUSED)
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
114
115
{
  gchar *authors[] = {
116
    "Yan Morin <yan.morin@savoirfairelinux.com>",
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
117
118
119
    "Jérôme Oufella <jerome.oufella@savoirfairelinux.com>",
    "Julien Plissonneau Duquene <julien.plissonneau.duquene@savoirfairelinux.com>",
    "Alexandre Bourget <alexandre.bourget@savoirfairelinux.com>",
120
    "Pierre-Luc Beaudoin <pierre-luc.beaudoin@savoirfairelinux.com>",
121
122
    "Emmanuel Milou <emmanuel.milou@savoirfairelinux.com>",
    "Yun Liu <yun.liu@savoirfairelinux.com>"
Emmanuel Milou's avatar
Emmanuel Milou committed
123
    "Jean-Philippe Barrette-LaPierre",
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
124
125
126
    "Laurielle Lea",
    NULL};
  gchar *artists[] = {
127
    "Pierre-Luc Beaudoin <pierre-luc.beaudoin@savoirfairelinux.com>",
Emmanuel Milou's avatar
Emmanuel Milou committed
128
    "Emmanuel Milou <emmanuel.milou@savoirfairelinux.com>",
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
129
    NULL};
130

Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
131
  gtk_show_about_dialog( GTK_WINDOW(get_main_window()),
Emmanuel Milou's avatar
Emmanuel Milou committed
132
133
134
      "artists", artists,
      "authors", authors,
      "comments", _("SFLphone is a VoIP client compatible with SIP and IAX2 protocols."),
135
      "copyright", "Copyright © 2004-2009 Savoir-faire Linux Inc.",
136
137
138
139
140
      "name", PACKAGE,
      "title", _("About SFLphone"),
      "version", VERSION,
      "website", "http://www.sflphone.org",
      NULL);
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
141
142
143
}


144
  GtkWidget *
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
145
146
147
148
149
create_help_menu()
{
  GtkWidget * menu;
  GtkWidget * root_menu;
  GtkWidget * menu_items;
150

Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
151
  menu      = gtk_menu_new ();
152

Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
153
154
155
  menu_items = gtk_image_menu_item_new_from_stock( GTK_STOCK_ABOUT, get_accel_group());
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items);
  g_signal_connect_swapped (G_OBJECT (menu_items), "activate",
156
      G_CALLBACK (help_about),
157
      NULL);
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
158
  gtk_widget_show (menu_items);
159

160
  root_menu = gtk_menu_item_new_with_mnemonic (_("_Help"));
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
161
162
163
164
165
  gtk_menu_item_set_submenu (GTK_MENU_ITEM (root_menu), menu);

  return root_menu;
}
/* ----------------------------------------------------------------- */
166
  static void
167
call_new_call ( void * foo UNUSED)
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
168
{
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
169
  sflphone_new_call();
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
170
171
}

172
  static void
173
call_quit ( void * foo UNUSED)
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
174
{
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
175
  sflphone_quit();
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
176
177
}

178
  static void
179
call_minimize ( void * foo UNUSED)
Emmanuel Milou's avatar
test    
Emmanuel Milou committed
180
{
181
#if GTK_CHECK_VERSION(2,10,0)
Emmanuel Milou's avatar
test    
Emmanuel Milou committed
182
  gtk_widget_hide(GTK_WIDGET( get_main_window() ));
183
  set_minimized( TRUE );
184
#endif
Emmanuel Milou's avatar
test    
Emmanuel Milou committed
185
186
}

187
  static void
188
switch_account(  GtkWidget* item , gpointer data UNUSED)
189
190
191
{
  account_t* acc = g_object_get_data( G_OBJECT(item) , "account" );
  g_print("%s\n" , acc->accountID);
192
  account_list_set_current_id( acc->accountID );
193
194
}

195
  static void
196
call_hold  (void* foo UNUSED)
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
197
{
areversat's avatar
areversat committed
198
  call_t * selectedCall = call_get_selected(current_calls);
199

Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
200
  if(selectedCall)
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
201
  {
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
202
203
    if(selectedCall->state == CALL_STATE_HOLD)
    {
204
      gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM ( holdMenu ), gtk_image_new_from_file( ICONS_DIR "/icon_unhold.svg"));
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
205
206
207
208
      sflphone_off_hold();
    }
    else
    {
209
      gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM ( holdMenu ), gtk_image_new_from_file( ICONS_DIR "/icon_hold.svg"));
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
210
      sflphone_on_hold();
211
212
    }
  }
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
213
214
}

215
  static void
216
call_pick_up ( void * foo UNUSED)
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
217
218
219
220
{
  sflphone_pick_up();
}

221
  static void
222
call_hang_up ( void * foo UNUSED)
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
223
224
225
226
{
  sflphone_hang_up();
}

227
static void
228
229
230
231
232
call_record ( void * foo UNUSED)
{
  sflphone_rec_call();
}

233
  static void
234
call_wizard ( void * foo UNUSED)
235
{
236
#if GTK_CHECK_VERSION(2,10,0)
237
  build_wizard();
238
#endif
239
240
}

241
static void
242
remove_from_history( void * foo UNUSED)
243
244
245
246
247
248
249
250
251
{
  call_t* c = call_get_selected( history );
  if(c){
    g_print("Remove the call from the history\n");
    call_list_remove_from_history( c );
  }
}

static void
252
call_back( void * foo UNUSED)
253
{
Julien Bonjean's avatar
Julien Bonjean committed
254
  call_t* selectedCall = call_get_selected( active_calltree );
255
256
  call_t* newCall =  g_new0 (call_t, 1);
  if( selectedCall )
257
  {
258
259
260
261
    newCall->to = g_strdup(call_get_number(selectedCall));
    newCall->from = g_strconcat("\"\" <", call_get_number(selectedCall), ">",NULL);
    newCall->state = CALL_STATE_DIALING;
    newCall->callID = g_new0(gchar, 30);
262
    g_sprintf(newCall->callID, "%d", rand());
263
264
265
266
267
    newCall->_start = 0;
    newCall->_stop = 0;
    call_list_add(current_calls, newCall);
    update_call_tree_add(current_calls, newCall);
    sflphone_place_call(newCall);
268
269
    switch_tab(current_calls);
  }
270
}
271
272

  GtkWidget *
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
273
274
275
276
277
create_call_menu()
{
  GtkWidget * menu;
  GtkWidget * root_menu;
  GtkWidget * menu_items;
278
  GtkWidget * image;
279

Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
280
  menu      = gtk_menu_new ();
281

282
  image = gtk_image_new_from_file( ICONS_DIR "/icon_call.svg");
283
  newCallMenu = gtk_image_menu_item_new_with_mnemonic(_("_New call"));
284
  gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM ( newCallMenu ), image );
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
285
286
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), newCallMenu);
  g_signal_connect_swapped (G_OBJECT (newCallMenu), "activate",
287
      G_CALLBACK (call_new_call),
288
      NULL);
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
289
  gtk_widget_show (newCallMenu);
290

Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
291
292
  menu_items = gtk_separator_menu_item_new ();
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items);
293

294
  image = gtk_image_new_from_file( ICONS_DIR "/icon_accept.svg");
295
  pickUpMenu = gtk_image_menu_item_new_with_mnemonic(_("_Pick up"));
296
  gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM ( pickUpMenu ), image );
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
297
298
299
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), pickUpMenu);
  gtk_widget_set_sensitive( GTK_WIDGET(pickUpMenu), FALSE);
  g_signal_connect_swapped (G_OBJECT (pickUpMenu), "activate",
300
      G_CALLBACK (call_pick_up),
301
      NULL);
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
302
  gtk_widget_show (pickUpMenu);
303

304
  image = gtk_image_new_from_file( ICONS_DIR "/icon_hangup.svg");
305
  hangUpMenu = gtk_image_menu_item_new_with_mnemonic(_("_Hang up"));
306
  gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM ( hangUpMenu ), image );
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
307
308
309
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), hangUpMenu);
  gtk_widget_set_sensitive( GTK_WIDGET(hangUpMenu), FALSE);
  g_signal_connect_swapped (G_OBJECT (hangUpMenu), "activate",
310
      G_CALLBACK (call_hang_up),
311
      NULL);
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
312
  gtk_widget_show (hangUpMenu);
313

314
315
316
  image = gtk_image_new_from_file( ICONS_DIR "/icon_hold.svg");
  holdMenu = gtk_image_menu_item_new_with_mnemonic (_("On _Hold"));
  gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM ( holdMenu ), image );
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
317
318
319
320
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), holdMenu);
  gtk_widget_set_sensitive( GTK_WIDGET(holdMenu),   FALSE);
  //Here we connect only to activate
  //The toggled state is managed from update_menus()
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
321
  holdConnId = g_signal_connect(G_OBJECT (holdMenu), "activate",
322
      G_CALLBACK (call_hold),
323
      NULL);
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
324
  gtk_widget_show (menu_items);
325

326
327
328
329
330
331
  image = gtk_tool_button_new_from_stock (GTK_STOCK_MEDIA_RECORD);
  recordMenu = gtk_image_menu_item_new_with_mnemonic(_("_Record"));
  gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM ( recordMenu ), image );
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), recordMenu);
  gtk_widget_set_sensitive( GTK_WIDGET(recordMenu), FALSE);
  g_signal_connect_swapped (G_OBJECT (recordMenu), "activate",
332
      G_CALLBACK (call_record),
333
334
335
      NULL);
  gtk_widget_show (recordMenu);

Emmanuel Milou's avatar
test    
Emmanuel Milou committed
336
  // Separator
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
337
  menu_items = gtk_separator_menu_item_new ();
338
339
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items);

340
#if GTK_CHECK_VERSION(2,10,0)
341
342
343
344
345
346
  menu_items = gtk_image_menu_item_new_with_mnemonic(_("_Account Assistant"));
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items);
  g_signal_connect_swapped( G_OBJECT( menu_items ) , "activate" , G_CALLBACK( call_wizard  ) , NULL );
  gtk_widget_show (menu_items);
  // Separator
  menu_items = gtk_separator_menu_item_new ();
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
347
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items);
348
#endif
349

Emmanuel Milou's avatar
test    
Emmanuel Milou committed
350
351
352
353
  // Close menu to minimize the main window to the system tray
  menu_items = gtk_image_menu_item_new_from_stock( GTK_STOCK_CLOSE, get_accel_group());
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items);
  g_signal_connect_swapped (G_OBJECT (menu_items), "activate",
354
      G_CALLBACK (call_minimize),
355
      NULL);
Emmanuel Milou's avatar
test    
Emmanuel Milou committed
356
357
358
359
360
361
362
  gtk_widget_show (menu_items);

  // Separator
  menu_items = gtk_separator_menu_item_new ();
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items);

  // Quit Menu - quit SFLphone
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
363
364
365
  menu_items = gtk_image_menu_item_new_from_stock( GTK_STOCK_QUIT, get_accel_group());
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items);
  g_signal_connect_swapped (G_OBJECT (menu_items), "activate",
366
      G_CALLBACK (call_quit),
367
      NULL);
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
368
  gtk_widget_show (menu_items);
369
370


371
  root_menu = gtk_menu_item_new_with_mnemonic (_("_Call"));
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
372
373
374
375
376
  gtk_menu_item_set_submenu (GTK_MENU_ITEM (root_menu), menu);

  return root_menu;
}
/* ----------------------------------------------------------------- */
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
377

378
  static void
379
edit_preferences ( void * foo UNUSED)
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
380
381
382
383
{
  show_config_window();
}

384
  static void
385
edit_accounts ( void * foo UNUSED)
386
387
388
389
{
  show_accounts_window();
}

Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
390
// The menu Edit/Copy should copy the current selected call's number
391
  static void
392
edit_copy ( void * foo UNUSED)
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
393
394
{
  GtkClipboard* clip = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD);
areversat's avatar
areversat committed
395
  call_t * selectedCall = call_get_selected(current_calls);
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
396
  gchar * no = NULL;
397

Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
398
399
400
401
  if(selectedCall)
  {
    switch(selectedCall->state)
    {
402
      case CALL_STATE_TRANSFERT:
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
403
404
      case CALL_STATE_DIALING:
      case CALL_STATE_RINGING:
405
406
	no = selectedCall->to;
	break;
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
407
408
409
410
411
412
      case CALL_STATE_CURRENT:
      case CALL_STATE_HOLD:
      case CALL_STATE_BUSY:
      case CALL_STATE_FAILURE:
      case CALL_STATE_INCOMING:
      default:
413
414
	no = call_get_number(selectedCall);
	break;
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
415
    }
416

Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
417
418
    gtk_clipboard_set_text (clip, no, strlen(no) );
  }
419

Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
420
421
422
}

// The menu Edit/Paste should paste the clipboard into the current selected call
423
  static void
424
edit_paste ( void * foo UNUSED)
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
425
426
{
  GtkClipboard* clip = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD);
areversat's avatar
areversat committed
427
  call_t * selectedCall = call_get_selected(current_calls);
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
428
  gchar * no = gtk_clipboard_wait_for_text (clip);
429

Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
430
431
432
433
  if(no && selectedCall)
  {
    switch(selectedCall->state)
    {
434
      case CALL_STATE_TRANSFERT:
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
435
      case CALL_STATE_DIALING:
436
	// Add the text to the number
437
	{
438
439
440
441
442
443
444
445
446
447
	  gchar * before = selectedCall->to;
	  selectedCall->to = g_strconcat(selectedCall->to, no, NULL);
	  g_free(before);
	  g_print("TO: %s\n", selectedCall->to);

	  if(selectedCall->state == CALL_STATE_DIALING)
	  {
	    g_free(selectedCall->from);
	    selectedCall->from = g_strconcat("\"\" <", selectedCall->to, ">", NULL);
	  }
448
	  update_call_tree(current_calls, selectedCall);
449
450
	}
	break;
451
      case CALL_STATE_RINGING:
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
452
453
454
455
      case CALL_STATE_INCOMING:
      case CALL_STATE_BUSY:
      case CALL_STATE_FAILURE:
      case CALL_STATE_HOLD:
456
457
458
459
460
461
462
463
464
465
466
	{ // Create a new call to hold the new text
	  selectedCall = sflphone_new_call();

	  gchar * before = selectedCall->to;
	  selectedCall->to = g_strconcat(selectedCall->to, no, NULL);
	  g_free(before);
	  g_print("TO: %s\n", selectedCall->to);

	  g_free(selectedCall->from);
	  selectedCall->from = g_strconcat("\"\" <", selectedCall->to, ">", NULL);

467
	  update_call_tree(current_calls, selectedCall);
468
469
	}
	break;
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
470
471
      case CALL_STATE_CURRENT:
      default:
472
	{
Emmanuel Milou's avatar
Emmanuel Milou committed
473
	  unsigned int i;
474
475
476
477
478
479
480
481
482
483
484
	  for(i = 0; i < strlen(no); i++)
	  {
	    gchar * oneNo = g_strndup(&no[i], 1);
	    g_print("<%s>\n", oneNo);
	    dbus_play_dtmf(oneNo);

	    gchar * temp = g_strconcat(call_get_number(selectedCall), oneNo, NULL);
	    gchar * before = selectedCall->from;
	    selectedCall->from = g_strconcat("\"",call_get_name(selectedCall) ,"\" <", temp, ">", NULL);
	    g_free(before);
	    g_free(temp);
485
	    update_call_tree(current_calls, selectedCall);
486
487
488
489

	  }
	}
	break;
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
490
    }
491

Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
492
493
494
495
  }
  else // There is no current call, create one
  {
    selectedCall = sflphone_new_call();
496

Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
497
498
499
500
    gchar * before = selectedCall->to;
    selectedCall->to = g_strconcat(selectedCall->to, no, NULL);
    g_free(before);
    g_print("TO: %s\n", selectedCall->to);
501

Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
502
503
    g_free(selectedCall->from);
    selectedCall->from = g_strconcat("\"\" <", selectedCall->to, ">", NULL);
504
    update_call_tree(current_calls,selectedCall);
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
505
  }
506

507
508
509
}

  static void
510
clear_history (void)
511
{
512
  if( call_list_get_size( history ) != 0 ){
513
      call_list_clean_history();
514
    }
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
515
516
}

517
  GtkWidget *
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
518
519
520
create_edit_menu()
{
  GtkWidget * menu;
521
  GtkWidget * image;
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
522
523
  GtkWidget * root_menu;
  GtkWidget * menu_items;
524

Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
525
526
  menu      = gtk_menu_new ();

Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
527
528
529
  copyMenu = gtk_image_menu_item_new_from_stock( GTK_STOCK_COPY, get_accel_group());
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), copyMenu);
  g_signal_connect_swapped (G_OBJECT (copyMenu), "activate",
530
      G_CALLBACK (edit_copy),
531
      NULL);
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
532
  gtk_widget_show (copyMenu);
533

Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
534
535
536
  pasteMenu = gtk_image_menu_item_new_from_stock( GTK_STOCK_PASTE, get_accel_group());
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), pasteMenu);
  g_signal_connect_swapped (G_OBJECT (pasteMenu), "activate",
537
      G_CALLBACK (edit_paste),
538
      NULL);
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
539
  gtk_widget_show (pasteMenu);
540

Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
541
542
  menu_items = gtk_separator_menu_item_new ();
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items);
543

544
545
546
547
548
  menu_items = gtk_image_menu_item_new_with_mnemonic(_("_Clear history"));
  image = gtk_image_new_from_stock( GTK_STOCK_CLEAR , GTK_ICON_SIZE_MENU );
  gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM ( menu_items ), image );
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items);
  g_signal_connect_swapped (G_OBJECT (menu_items), "activate",
549
      G_CALLBACK (clear_history),
550
      NULL);
551
  gtk_widget_show (menu_items);
552
553
554
555

  menu_items = gtk_separator_menu_item_new ();
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items);

556
557
558
  menu_items = gtk_menu_item_new_with_mnemonic( _("_Accounts") );
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items);
  g_signal_connect_swapped (G_OBJECT (menu_items), "activate",
559
      G_CALLBACK (edit_accounts),
560
      NULL);
561
  gtk_widget_show (menu_items);
562

Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
563
564
565
  menu_items = gtk_image_menu_item_new_from_stock( GTK_STOCK_PREFERENCES, get_accel_group());
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items);
  g_signal_connect_swapped (G_OBJECT (menu_items), "activate",
566
      G_CALLBACK (edit_preferences),
567
      NULL);
568
  gtk_widget_show (menu_items);
569
570


571
  root_menu = gtk_menu_item_new_with_mnemonic (_("_Edit"));
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
572
573
574
575
576
  gtk_menu_item_set_submenu (GTK_MENU_ITEM (root_menu), menu);

  return root_menu;
}
/* ----------------------------------------------------------------- */
577
  static void
578
579
view_dialpad  (GtkImageMenuItem *imagemenuitem UNUSED,
    void* foo UNUSED)
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
580
{
581
582
583
584
585
  gboolean state;
  main_window_dialpad( &state );
  if( state )
    gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM ( dialpadMenu ),
				  gtk_image_new_from_file( ICONS_DIR "/icon_dialpad_off.svg"));
586
587
  else
    gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM ( dialpadMenu ),
588
589
				  gtk_image_new_from_file( ICONS_DIR "/icon_dialpad.svg"));
  dbus_set_dialpad( state );
590

591

Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
592
593
}

594
  static void
595
596
view_volume_controls  (GtkImageMenuItem *imagemenuitem UNUSED,
    void* foo UNUSED)
597
{
598
599
600
601
602
  gboolean state;
  main_window_volume_controls( &state );
  if( state )
    gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM ( volumeMenu ),
				  gtk_image_new_from_file( ICONS_DIR "/icon_volume_off.svg"));
603
604
  else
    gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM ( volumeMenu ),
605
606
				  gtk_image_new_from_file( ICONS_DIR "/icon_volume.svg"));
  dbus_set_volume_controls( state );
607
608
}

609
  static void
610
611
view_searchbar  (GtkImageMenuItem *imagemenuitem UNUSED,
    void* foo UNUSED)
612
613
614
615
616
617
{
  gboolean state;
  main_window_searchbar( &state );
  dbus_set_searchbar( state );
}

618
  GtkWidget *
619
620
621
622
create_view_menu()
{
  GtkWidget * menu;
  GtkWidget * root_menu;
623
  GtkWidget * image;
Emmanuel Milou's avatar
Emmanuel Milou committed
624

625
626
  menu      = gtk_menu_new ();

627
628
629
630
631
632
633
634
  if( SHOW_DIALPAD )
    image = gtk_image_new_from_file( ICONS_DIR "/icon_dialpad_off.svg");
  else
    image = gtk_image_new_from_file( ICONS_DIR "/icon_dialpad.svg");
  dialpadMenu = gtk_image_menu_item_new_with_mnemonic (_("_Dialpad"));
  gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM ( dialpadMenu ), image );
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), dialpadMenu);
  g_signal_connect(G_OBJECT ( dialpadMenu ), "activate",
635
      G_CALLBACK (view_dialpad),
636
      NULL);
637
  gtk_widget_show (dialpadMenu);
638

639
640
641
642
643
644
645
646
  if( SHOW_VOLUME )
    image = gtk_image_new_from_file( ICONS_DIR "/icon_volume.svg");
  else
    image = gtk_image_new_from_file( ICONS_DIR "/icon_volume.svg");
  volumeMenu = gtk_image_menu_item_new_with_mnemonic (_("_Volume controls"));
  gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM ( volumeMenu ), image );
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), volumeMenu);
  g_signal_connect(G_OBJECT (volumeMenu), "activate",
647
      G_CALLBACK (view_volume_controls),
648
      NULL);
649
  gtk_widget_show (volumeMenu);
Emmanuel Milou's avatar
Emmanuel Milou committed
650

651
652
653
654
655
  image = gtk_image_new_from_stock( GTK_STOCK_FIND , GTK_ICON_SIZE_MENU );
  searchbarMenu = gtk_image_menu_item_new_with_mnemonic (_("_Search history"));
  gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM ( searchbarMenu ), image );
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), searchbarMenu);
  g_signal_connect(G_OBJECT (searchbarMenu), "activate",
656
      G_CALLBACK (view_searchbar),
657
658
659
      NULL);
  gtk_widget_show (searchbarMenu);

660
  root_menu = gtk_menu_item_new_with_mnemonic (_("_View"));
661
662
663
664
665
  gtk_menu_item_set_submenu (GTK_MENU_ITEM (root_menu), menu);

  return root_menu;
}
/* ----------------------------------------------------------------- */
666
  GtkWidget *
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
667
668
669
670
671
672
673
create_menus ( )
{

  GtkWidget * menu_bar;
  GtkWidget * root_menu;

  menu_bar  = gtk_menu_bar_new ();
674

Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
675
676
  root_menu = create_call_menu();
  gtk_menu_shell_append (GTK_MENU_SHELL (menu_bar), root_menu);
677

Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
678
679
  root_menu = create_edit_menu();
  gtk_menu_shell_append (GTK_MENU_SHELL (menu_bar), root_menu);
680

681
682
  root_menu = create_view_menu();
  gtk_menu_shell_append (GTK_MENU_SHELL (menu_bar), root_menu);
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
683
684
685
686
687

  root_menu = create_help_menu();
  gtk_menu_shell_append (GTK_MENU_SHELL (menu_bar), root_menu);

  gtk_widget_show (menu_bar);
688
689


Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
690
691
692
  return menu_bar;
}

693
694
/* ----------------------------------------------------------------- */

695
  void
696
697
show_popup_menu (GtkWidget *my_widget, GdkEventButton *event)
{
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
698
  // TODO update the selection to make sure the call under the mouse is the call selected
699

700
  gboolean pickup = FALSE, hangup = FALSE, hold = FALSE, copy = FALSE, record = FALSE;
701
702
  gboolean accounts = FALSE;

703
  call_t * selectedCall = call_get_selected(current_calls);
704
705
  if (selectedCall)
  {
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
706
    copy = TRUE;
707
    switch(selectedCall->state)
708
709
710
711
712
    {
      case CALL_STATE_INCOMING:
	pickup = TRUE;
	hangup = TRUE;
	break;
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
713
      case CALL_STATE_HOLD:
714
715
716
	hangup = TRUE;
	hold   = TRUE;
	break;
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
717
      case CALL_STATE_RINGING:
718
719
	hangup = TRUE;
	break;
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
720
      case CALL_STATE_DIALING:
721
722
723
724
	pickup = TRUE;
	hangup = TRUE;
	accounts = TRUE;
	break;
725
      case CALL_STATE_RECORD:
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
726
      case CALL_STATE_CURRENT:
727
728
	hangup = TRUE;
	hold   = TRUE;
729
        record = TRUE;
730
	break;
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
731
732
      case CALL_STATE_BUSY:
      case CALL_STATE_FAILURE:
733
	hangup = TRUE;
734
	break;
735
736
737
738
      default:
	g_warning("Should not happen in show_popup_menu!");
	break;
    }
739
  }
740

741
  GtkWidget *menu;
742
  GtkWidget *image;
743
744
745
746
  int button, event_time;
  GtkWidget * menu_items;

  menu = gtk_menu_new ();
747
  //g_signal_connect (menu, "deactivate",
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
748
  //       G_CALLBACK (gtk_widget_destroy), NULL);
749

Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
750
751
752
753
754
  if(copy)
  {
    menu_items = gtk_image_menu_item_new_from_stock( GTK_STOCK_COPY, get_accel_group());
    gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items);
    g_signal_connect (G_OBJECT (menu_items), "activate",
755
	G_CALLBACK (edit_copy),
756
	NULL);
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
757
758
    gtk_widget_show (menu_items);
  }
759

760
761
  menu_items = gtk_image_menu_item_new_from_stock( GTK_STOCK_PASTE, get_accel_group());
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items);
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
762
  g_signal_connect (G_OBJECT (menu_items), "activate",
763
      G_CALLBACK (edit_paste),
764
      NULL);
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
765
  gtk_widget_show (menu_items);
766

Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
767
768
769
770
771
772
  if(pickup || hangup || hold)
  {
    menu_items = gtk_separator_menu_item_new ();
    gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items);
    gtk_widget_show (menu_items);
  }
773

Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
774
775
  if(pickup)
  {
776

777
    menu_items = gtk_image_menu_item_new_with_mnemonic(_("_Pick up"));
778
779
    image = gtk_image_new_from_file( ICONS_DIR "/icon_accept.svg");
    gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menu_items), image);
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
780
781
    gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items);
    g_signal_connect (G_OBJECT (menu_items), "activate",
782
	G_CALLBACK (call_pick_up),
783
	NULL);
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
784
785
    gtk_widget_show (menu_items);
  }
786

Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
787
788
  if(hangup)
  {
789
    menu_items = gtk_image_menu_item_new_with_mnemonic(_("_Hang up"));
790
791
    image = gtk_image_new_from_file( ICONS_DIR "/icon_hangup.svg");
    gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menu_items), image);
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
792
793
    gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items);
    g_signal_connect (G_OBJECT (menu_items), "activate",
794
	G_CALLBACK (call_hang_up),
795
	NULL);
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
796
797
    gtk_widget_show (menu_items);
  }
798

Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
799
800
  if(hold)
  {
801
    menu_items = gtk_check_menu_item_new_with_mnemonic (_("On _Hold"));
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
802
    gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items);
803
    gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu_items),
804
	(selectedCall->state == CALL_STATE_HOLD ? TRUE : FALSE));
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
805
    g_signal_connect(G_OBJECT (menu_items), "activate",
806
	G_CALLBACK (call_hold),
807
	NULL);
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
808
    gtk_widget_show (menu_items);
809
  }
810

811
812
813
814
815
816
817
   if(record)
  {
    menu_items = gtk_image_menu_item_new_with_mnemonic(_("_Record"));
    image = gtk_tool_button_new_from_stock (GTK_STOCK_MEDIA_RECORD);
    gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menu_items), image);
    gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items);
    g_signal_connect (G_OBJECT (menu_items), "activate",
818
	G_CALLBACK (call_record),
819
820
821
822
	NULL);
    gtk_widget_show (menu_items);
  }

823
824
825
826
827
828
  if(accounts)
  {
    menu_items = gtk_separator_menu_item_new ();
    gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items);
    gtk_widget_show (menu_items);

Emmanuel Milou's avatar
Emmanuel Milou committed
829
    unsigned int i;
830
831
832
833
    account_t* acc;
    gchar* alias;
    for( i = 0 ; i < account_list_get_size() ; i++ ){
      acc = account_list_get_nth(i);
834
      // Display only the registered accounts
835
836
837
838
839
      if( g_strcasecmp( account_state_name(acc -> state) , account_state_name(ACCOUNT_STATE_REGISTERED) ) == 0 ){
	alias = g_strconcat( g_hash_table_lookup(acc->properties , ACCOUNT_ALIAS) , " - ",g_hash_table_lookup(acc->properties , ACCOUNT_TYPE), NULL);
	menu_items = gtk_check_menu_item_new_with_mnemonic(alias);
	gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items);
	g_object_set_data( G_OBJECT( menu_items ) ,