Commit 5b657998 authored by Pierre-Luc Beaudoin's avatar Pierre-Luc Beaudoin

Better menus

parent bbb3ee4a
......@@ -22,6 +22,7 @@
#include <calltree.h>
#include <dbus.h>
#include <mainwindow.h>
#include <menus.h>
#include <screen.h>
#include <statusicon.h>
......@@ -57,6 +58,7 @@ sflphone_hold(call_t * c )
{
c->state = CALL_STATE_HOLD;
update_call_tree(c);
update_menus();
screen_clear();
}
......@@ -65,6 +67,7 @@ sflphone_ringing(call_t * c )
{
c->state = CALL_STATE_RINGING;
update_call_tree(c);
update_menus();
}
......@@ -125,18 +128,99 @@ sflphone_init()
}
void
sflphone_hang_up( call_t * c )
sflphone_hang_up()
{
call_list_remove(c->callID);
update_call_tree_remove(c);
screen_clear();
call_t * selectedCall = call_get_selected();
if(selectedCall)
{
switch(selectedCall->state)
{
case CALL_STATE_CURRENT:
case CALL_STATE_HOLD:
case CALL_STATE_DIALING:
case CALL_STATE_RINGING:
case CALL_STATE_BUSY:
case CALL_STATE_FAILURE:
dbus_hang_up (selectedCall);
break;
case CALL_STATE_INCOMING:
dbus_refuse (selectedCall);
break;
default:
g_warning("Should not happen!");
break;
}
}
}
void
sflphone_pick_up()
{
call_t * selectedCall = call_get_selected();
if(selectedCall)
{
switch(selectedCall->state)
{
case CALL_STATE_DIALING:
sflphone_place_call (selectedCall);
break;
case CALL_STATE_INCOMING:
dbus_accept (selectedCall);
break;
case CALL_STATE_HOLD:
dbus_unhold (selectedCall);
break;
default:
g_warning("Should not happen!");
break;
}
}
}
void
sflphone_on_hold ()
{
call_t * selectedCall = call_get_selected();
if(selectedCall)
{
switch(selectedCall->state)
{
case CALL_STATE_CURRENT:
dbus_hold (selectedCall);
break;
default:
g_error("Should not happen!");
break;
}
}
}
void
sflphone_off_hold ()
{
call_t * selectedCall = call_get_selected();
if(selectedCall)
{
switch(selectedCall->state)
{
case CALL_STATE_HOLD:
dbus_unhold (selectedCall);
break;
default:
g_error("Should not happen!");
break;
}
}
}
void
sflphone_fail( call_t * c )
{
c->state = CALL_STATE_FAILURE;
update_call_tree(c);
update_menus();
screen_set_call(c);
}
......@@ -145,6 +229,7 @@ sflphone_busy( call_t * c )
{
c->state = CALL_STATE_BUSY;
update_call_tree(c);
update_menus();
screen_set_call(c);
}
......@@ -153,6 +238,7 @@ sflphone_current( call_t * c )
{
c->state = CALL_STATE_CURRENT;
update_call_tree(c);
update_menus();
screen_set_call(c);
}
......@@ -161,6 +247,7 @@ sflphone_transfert( call_t * c, gchar * to )
{
screen_clear();
update_call_tree_remove(c);
update_menus();
}
void
......@@ -169,6 +256,7 @@ sflphone_incoming_call (call_t * c)
call_list_add ( c );
status_icon_unminimize();
update_call_tree_add(c);
update_menus();
}
void
......@@ -176,6 +264,7 @@ sflphone_hung_up (call_t * c )
{
call_list_remove(c->callID);
update_call_tree_remove(c);
update_menus();
screen_clear();
}
......
......@@ -43,9 +43,18 @@ gboolean sflphone_init ( ) ;
gboolean sflphone_quit ( ) ;
/**
* Hang up the call
* Hang up / refuse the current call
*/
void sflphone_hang_up ( call_t * c);
void sflphone_hang_up ();
void sflphone_on_hold ();
void sflphone_off_hold ();
/**
* Accept / dial the current call
*/
void sflphone_pick_up ();
/**
* Transfert the call
......@@ -53,7 +62,7 @@ void sflphone_hang_up ( call_t * c);
void sflphone_transfert ( call_t * c, gchar * to );
/**
* Put the call on hold
* Put the call on hold state
*/
void sflphone_hold ( call_t * c);
......@@ -71,7 +80,7 @@ void sflphone_fail( call_t * c );
void sflphone_current ( call_t * c);
/**
* The callee has hung up
* The callee has hung up
*/
void sflphone_hung_up( call_t * c);
......
......@@ -38,22 +38,7 @@ GtkWidget * unholdButton;
static void
call_button( GtkWidget *widget, gpointer data )
{
call_t * selectedCall = call_get_selected();
if(selectedCall)
{
switch(selectedCall->state)
{
case CALL_STATE_DIALING:
sflphone_place_call (selectedCall);
break;
case CALL_STATE_INCOMING:
dbus_accept (selectedCall);
break;
default:
g_error("Should not happen!");
break;
}
}
sflphone_pick_up();
}
/**
......@@ -62,25 +47,7 @@ call_button( GtkWidget *widget, gpointer data )
static void
hang_up( GtkWidget *widget, gpointer data )
{
call_t * selectedCall = call_get_selected();
if(selectedCall)
{
switch(selectedCall->state)
{
case CALL_STATE_CURRENT:
case CALL_STATE_HOLD:
case CALL_STATE_DIALING:
case CALL_STATE_RINGING:
dbus_hang_up (selectedCall);
break;
case CALL_STATE_INCOMING:
dbus_refuse (selectedCall);
break;
default:
g_error("Should not happen!");
break;
}
}
sflphone_hang_up();
}
/**
......@@ -89,19 +56,7 @@ hang_up( GtkWidget *widget, gpointer data )
static void
hold( GtkWidget *widget, gpointer data )
{
call_t * selectedCall = call_get_selected();
if(selectedCall)
{
switch(selectedCall->state)
{
case CALL_STATE_CURRENT:
dbus_hold (selectedCall);
break;
default:
g_error("Should not happen!");
break;
}
}
sflphone_on_hold();
}
/**
......@@ -123,20 +78,9 @@ transfert( GtkWidget *widget, gpointer data )
static void
unhold( GtkWidget *widget, gpointer data )
{
call_t * selectedCall = call_get_selected();
if(selectedCall)
{
switch(selectedCall->state)
{
case CALL_STATE_HOLD:
dbus_unhold (selectedCall);
break;
default:
g_error("Should not happen!");
break;
}
}
sflphone_off_hold();
}
void
update_buttons ()
{
......
......@@ -23,6 +23,52 @@
#include <actions.h>
#include <mainwindow.h>
#include <configwindow.h>
GtkWidget * pickUpMenu;
GtkWidget * hangUpMenu;
GtkWidget * holdMenu;
void update_menus()
{
gtk_widget_set_sensitive( GTK_WIDGET(pickUpMenu), FALSE);
gtk_widget_set_sensitive( GTK_WIDGET(hangUpMenu), FALSE);
gtk_widget_set_sensitive( GTK_WIDGET(holdMenu), FALSE);
call_t * selectedCall = call_get_selected();
if (selectedCall)
{
switch(selectedCall->state)
{
case CALL_STATE_INCOMING:
gtk_widget_set_sensitive( GTK_WIDGET(pickUpMenu), TRUE);
gtk_widget_set_sensitive( GTK_WIDGET(hangUpMenu), TRUE);
break;
case CALL_STATE_HOLD:
gtk_widget_set_sensitive( GTK_WIDGET(hangUpMenu), TRUE);
gtk_widget_set_sensitive( GTK_WIDGET(holdMenu), TRUE);
break;
case CALL_STATE_RINGING:
gtk_widget_set_sensitive( GTK_WIDGET(pickUpMenu), TRUE);
gtk_widget_set_sensitive( GTK_WIDGET(hangUpMenu), TRUE);
break;
case CALL_STATE_DIALING:
gtk_widget_set_sensitive( GTK_WIDGET(pickUpMenu), TRUE);
gtk_widget_set_sensitive( GTK_WIDGET(hangUpMenu), TRUE);
break;
case CALL_STATE_CURRENT:
gtk_widget_set_sensitive( GTK_WIDGET(hangUpMenu), TRUE);
gtk_widget_set_sensitive( GTK_WIDGET(holdMenu), TRUE);
break;
case CALL_STATE_BUSY:
case CALL_STATE_FAILURE:
gtk_widget_set_sensitive( GTK_WIDGET(hangUpMenu), TRUE);
break;
default:
g_error("Should not happen!");
break;
}
}
}
/* ----------------------------------------------------------------- */
void
help_about ( void * foo)
......@@ -95,6 +141,31 @@ call_preferences ( void * foo)
show_config_window();
}
void
call_hold (void* foo)
{
if(gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(holdMenu)))
{
sflphone_on_hold();
}
else
{
sflphone_off_hold();
}
}
void
call_pick_up ( void * foo)
{
sflphone_pick_up();
}
void
call_hang_up ( void * foo)
{
sflphone_hang_up();
}
GtkWidget *
create_call_menu()
{
......@@ -104,13 +175,36 @@ create_call_menu()
menu = gtk_menu_new ();
menu_items = gtk_image_menu_item_new_from_stock( GTK_STOCK_PREFERENCES, get_accel_group());
pickUpMenu = gtk_image_menu_item_new_with_mnemonic("_Pick up");
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",
G_CALLBACK (call_pick_up),
NULL);
gtk_widget_show (pickUpMenu);
hangUpMenu = gtk_image_menu_item_new_with_mnemonic("_Hang up");
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",
G_CALLBACK (call_hang_up),
NULL);
gtk_widget_show (hangUpMenu);
menu_items = gtk_separator_menu_item_new ();
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items);
g_signal_connect_swapped (G_OBJECT (menu_items), "activate",
G_CALLBACK (call_preferences),
holdMenu = gtk_check_menu_item_new_with_mnemonic ("On _Hold");
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()
g_signal_connect(G_OBJECT (holdMenu), "activate",
G_CALLBACK (call_hold),
NULL);
gtk_widget_show (menu_items);
menu_items = gtk_separator_menu_item_new ();
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items);
......@@ -128,45 +222,6 @@ create_call_menu()
return root_menu;
}
/* ----------------------------------------------------------------- */
void
debug_hang_up( void* foo)
{
call_t * c = (call_t*) call_list_get_by_state (CALL_STATE_CURRENT);
if(c)
{
sflphone_hang_up(c);
}
}
GtkWidget *
create_debug_menu()
{
GtkWidget * menu;
GtkWidget * root_menu;
GtkWidget * menu_items;
menu = gtk_menu_new ();
menu_items = gtk_menu_item_new_with_label ("Hang up current call");
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items);
g_signal_connect_swapped (G_OBJECT (menu_items), "activate",
G_CALLBACK (debug_hang_up),
NULL);
gtk_widget_show (menu_items);
/*menu_items = gtk_menu_item_new_with_label ("Transfert current call");
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items);
g_signal_connect_swapped (G_OBJECT (menu_items), "activate",
G_CALLBACK (debug_transfert),
NULL);
gtk_widget_show (menu_items);*/
root_menu = gtk_menu_item_new_with_mnemonic ("_Debug");
gtk_menu_item_set_submenu (GTK_MENU_ITEM (root_menu), menu);
return root_menu;
}
/* ----------------------------------------------------------------- */
void
view_dial_pad (GtkCheckMenuItem *checkmenuitem,
......@@ -191,6 +246,16 @@ create_view_menu()
NULL);
gtk_widget_show (menu_items);
menu_items = gtk_separator_menu_item_new ();
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items);
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",
G_CALLBACK (call_preferences),
NULL);
gtk_widget_show (menu_items);
root_menu = gtk_menu_item_new_with_mnemonic ("_View");
gtk_menu_item_set_submenu (GTK_MENU_ITEM (root_menu), menu);
......@@ -213,11 +278,6 @@ create_menus ( )
root_menu = create_view_menu();
gtk_menu_shell_append (GTK_MENU_SHELL (menu_bar), root_menu);
#ifdef DEBUG
root_menu = create_debug_menu();
gtk_menu_shell_append (GTK_MENU_SHELL (menu_bar), root_menu);
#endif
root_menu = create_help_menu();
gtk_menu_shell_append (GTK_MENU_SHELL (menu_bar), root_menu);
......
......@@ -25,5 +25,6 @@
* @brief The menus of the main window.
*/
GtkWidget * create_menus();
void update_menus();
#endif
......@@ -35,15 +35,13 @@ status_quit ( void * foo)
void
status_icon_unminimize()
{
gtk_widget_show(GTK_WIDGET(get_main_window()));
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(show_menu_item), FALSE);
minimized = FALSE;
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(show_menu_item), TRUE);
}
void
show_hide (GtkStatusIcon *status_icon, void * foo)
show_hide (GtkWidget *menu, void * foo)
{
if(minimized)
if(gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(show_menu_item)))
{
gtk_widget_show(GTK_WIDGET(get_main_window()));
}
......@@ -51,7 +49,14 @@ show_hide (GtkStatusIcon *status_icon, void * foo)
{
gtk_widget_hide(GTK_WIDGET(get_main_window()));
}
minimized = !minimized;
}
void
status_click (GtkStatusIcon *status_icon, void * foo)
{
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(show_menu_item),
!gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(show_menu_item)));
}
void menu (GtkStatusIcon *status_icon,
......@@ -97,7 +102,7 @@ show_status_icon()
{
status = gtk_status_icon_new_from_file(ICON_DIR "/sflphone.png");
g_signal_connect (G_OBJECT (status), "activate",
G_CALLBACK (show_hide),
G_CALLBACK (status_click),
NULL);
g_signal_connect (G_OBJECT (status), "popup-menu",
G_CALLBACK (menu),
......
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