Commit 6205ef49 authored by Pierre-Luc Beaudoin's avatar Pierre-Luc Beaudoin

New call option

parent 5b657998
......@@ -190,7 +190,7 @@ sflphone_on_hold ()
dbus_hold (selectedCall);
break;
default:
g_error("Should not happen!");
g_warning("Should not happen!");
break;
}
}
......@@ -208,7 +208,7 @@ sflphone_off_hold ()
dbus_unhold (selectedCall);
break;
default:
g_error("Should not happen!");
g_warning("Should not happen!");
break;
}
}
......@@ -322,22 +322,24 @@ void process_dialing(call_t * c, guint keyval, gchar * key)
}
void process_new_call(guint keyval, gchar * key){
if (keyval < 255 || (keyval >65453 && keyval < 65466))
{
/* Brackets mandatory because of local vars */
call_t * c = g_new0 (call_t, 1);
c->state = CALL_STATE_DIALING;
c->from = g_strconcat("\"\" <", key, ">", NULL);
c->callID = g_new0(gchar, 100);
g_sprintf(c->callID, "%d", rand());
c->to = g_strdup(key);
call_list_add(c);
screen_set_call(c);
update_call_tree_add(c);
}
call_t * sflphone_new_call()
{
call_t * c = g_new0 (call_t, 1);
c->state = CALL_STATE_DIALING;
c->from = g_strconcat("\"\" <>", NULL);
c->callID = g_new0(gchar, 30);
g_sprintf(c->callID, "%d", rand());
c->to = g_strdup("");
call_list_add(c);
screen_set_call(c);
update_call_tree_add(c);
update_menus();
return c;
}
void
......@@ -347,20 +349,18 @@ sflphone_keypad( guint keyval, gchar * key)
if(c)
{
switch(c->state) // Currently dialing => edit number
switch(c->state)
{
case CALL_STATE_DIALING:
case CALL_STATE_DIALING: // Currently dialing => edit number
process_dialing(c, keyval, key);
break;
case CALL_STATE_CURRENT:
case CALL_STATE_BUSY:
case CALL_STATE_FAILURE:
switch (keyval)
{
case 65307: /* ESCAPE */
dbus_hang_up(c);
break;
default:
default: // TODO should this be here?
dbus_play_dtmf(key);
if (keyval < 255 || (keyval >65453 && keyval < 65466))
{
......@@ -398,11 +398,13 @@ sflphone_keypad( guint keyval, gchar * key)
dbus_hang_up(c);
break;
default: // When a call is on hold, typing new numbers will create a new call
process_new_call(keyval, key);
process_dialing(sflphone_new_call(), keyval, key);
break;
}
break;
case CALL_STATE_RINGING:
case CALL_STATE_BUSY:
case CALL_STATE_FAILURE:
switch (keyval)
{
case 65307: /* ESCAPE */
......@@ -416,7 +418,18 @@ sflphone_keypad( guint keyval, gchar * key)
}
else
{ // Not in a call, not dialing, create a new call
process_new_call(keyval, key);
switch (keyval)
{
case 65293: /* ENTER */
case 65421: /* ENTER numpad */
case 65307: /* ESCAPE */
break;
default:
process_dialing(sflphone_new_call(), keyval, key);
break;
}
}
}
......
......@@ -49,6 +49,7 @@ void sflphone_hang_up ();
void sflphone_on_hold ();
void sflphone_off_hold ();
call_t * sflphone_new_call();
/**
......
......@@ -27,6 +27,7 @@ GtkListStore * store;
GtkWidget *view;
GtkWidget * callButton;
GtkWidget * pickupButton;
GtkWidget * hangupButton;
GtkWidget * holdButton;
GtkWidget * transfertButton;
......@@ -37,6 +38,15 @@ GtkWidget * unholdButton;
*/
static void
call_button( GtkWidget *widget, gpointer data )
{
sflphone_new_call();
}
/**
* Pick up
*/
static void
pick_up( GtkWidget *widget, gpointer data )
{
sflphone_pick_up();
}
......@@ -85,6 +95,7 @@ void
update_buttons ()
{
gtk_widget_set_sensitive( GTK_WIDGET(callButton), FALSE);
gtk_widget_set_sensitive( GTK_WIDGET(pickupButton), FALSE);
gtk_widget_set_sensitive( GTK_WIDGET(hangupButton), FALSE);
gtk_widget_set_sensitive( GTK_WIDGET(holdButton), FALSE);
gtk_widget_set_sensitive( GTK_WIDGET(transfertButton), FALSE);
......@@ -96,18 +107,19 @@ update_buttons ()
switch(selectedCall->state)
{
case CALL_STATE_INCOMING:
gtk_widget_set_sensitive( GTK_WIDGET(callButton), TRUE);
gtk_widget_set_sensitive( GTK_WIDGET(pickupButton), TRUE);
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);
gtk_widget_set_sensitive( GTK_WIDGET(callButton), TRUE);
break;
case CALL_STATE_RINGING:
gtk_widget_set_sensitive( GTK_WIDGET(hangupButton), TRUE);
break;
case CALL_STATE_DIALING:
gtk_widget_set_sensitive( GTK_WIDGET(callButton), TRUE);
gtk_widget_set_sensitive( GTK_WIDGET(pickupButton), TRUE);
gtk_widget_set_sensitive( GTK_WIDGET(hangupButton), TRUE);
break;
case CALL_STATE_CURRENT:
......@@ -115,6 +127,7 @@ update_buttons ()
gtk_widget_set_sensitive( GTK_WIDGET(hangupButton), TRUE);
gtk_widget_set_sensitive( GTK_WIDGET(holdButton), TRUE);
gtk_widget_set_sensitive( GTK_WIDGET(transfertButton), TRUE);
gtk_widget_set_sensitive( GTK_WIDGET(callButton), TRUE);
break;
case CALL_STATE_BUSY:
case CALL_STATE_FAILURE:
......@@ -125,6 +138,10 @@ update_buttons ()
break;
}
}
else
{
gtk_widget_set_sensitive( GTK_WIDGET(callButton), TRUE);
}
}
/* Call back when the user click on a call in the list */
static void
......@@ -232,7 +249,6 @@ create_call_tree (){
hbox = gtk_hbox_new (FALSE, 5);
callButton = gtk_button_new ();
gtk_widget_set_state( GTK_WIDGET(callButton), GTK_STATE_INSENSITIVE);
image = gtk_image_new_from_file( ICONS_DIR "/call.svg");
gtk_button_set_image(GTK_BUTTON(callButton), image);
//gtk_button_set_image_position( button, GTK_POS_TOP);
......@@ -240,6 +256,15 @@ create_call_tree (){
g_signal_connect (G_OBJECT (callButton), "clicked",
G_CALLBACK (call_button), NULL);
pickupButton = gtk_button_new ();
gtk_widget_set_state( GTK_WIDGET(pickupButton), GTK_STATE_INSENSITIVE);
image = gtk_image_new_from_file( ICONS_DIR "/accept.svg");
gtk_button_set_image(GTK_BUTTON(pickupButton), image);
//gtk_button_set_image_position( button, GTK_POS_TOP);
gtk_box_pack_start (GTK_BOX (hbox), pickupButton, FALSE /*expand*/, FALSE /*fill*/, 0 /*padding*/);
g_signal_connect (G_OBJECT (pickupButton), "clicked",
G_CALLBACK (pick_up), NULL);
hangupButton = gtk_button_new ();
gtk_widget_hide( hangupButton );
gtk_widget_set_state( GTK_WIDGET(hangupButton), GTK_STATE_INSENSITIVE);
......
......@@ -99,6 +99,7 @@ on_key_released (GtkWidget *widget,
event->keyval == 34 || // "
event->keyval == 65361 || // left arrow
event->keyval == 65363 || // right arrow
event->keyval >= 65470 || // F-keys
event->keyval == 32 // space
)
return FALSE;
......
......@@ -26,13 +26,20 @@
GtkWidget * pickUpMenu;
GtkWidget * hangUpMenu;
GtkWidget * newCallMenu;
GtkWidget * holdMenu;
guint holdConnId; //The hold_menu signal connection ID
void update_menus()
{
{
//Block signals for holdMenu
gtk_signal_handler_block(GTK_OBJECT(holdMenu), holdConnId);
gtk_widget_set_sensitive( GTK_WIDGET(pickUpMenu), FALSE);
gtk_widget_set_sensitive( GTK_WIDGET(hangUpMenu), FALSE);
gtk_widget_set_sensitive( GTK_WIDGET(newCallMenu),FALSE);
gtk_widget_set_sensitive( GTK_WIDGET(holdMenu), FALSE);
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(holdMenu), FALSE);
call_t * selectedCall = call_get_selected();
if (selectedCall)
......@@ -46,6 +53,8 @@ void update_menus()
case CALL_STATE_HOLD:
gtk_widget_set_sensitive( GTK_WIDGET(hangUpMenu), TRUE);
gtk_widget_set_sensitive( GTK_WIDGET(holdMenu), TRUE);
gtk_widget_set_sensitive( GTK_WIDGET(newCallMenu),TRUE);
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(holdMenu), TRUE);
break;
case CALL_STATE_RINGING:
gtk_widget_set_sensitive( GTK_WIDGET(pickUpMenu), TRUE);
......@@ -58,6 +67,7 @@ void update_menus()
case CALL_STATE_CURRENT:
gtk_widget_set_sensitive( GTK_WIDGET(hangUpMenu), TRUE);
gtk_widget_set_sensitive( GTK_WIDGET(holdMenu), TRUE);
gtk_widget_set_sensitive( GTK_WIDGET(newCallMenu),TRUE);
break;
case CALL_STATE_BUSY:
case CALL_STATE_FAILURE:
......@@ -67,7 +77,13 @@ void update_menus()
g_error("Should not happen!");
break;
}
}
else
{
gtk_widget_set_sensitive( GTK_WIDGET(newCallMenu), TRUE);
}
gtk_signal_handler_unblock(holdMenu, holdConnId);
}
/* ----------------------------------------------------------------- */
void
......@@ -122,7 +138,6 @@ create_help_menu()
NULL);
gtk_widget_show (menu_items);
root_menu = gtk_menu_item_new_with_mnemonic ("_Help");
gtk_menu_item_set_submenu (GTK_MENU_ITEM (root_menu), menu);
......@@ -130,15 +145,15 @@ create_help_menu()
}
/* ----------------------------------------------------------------- */
void
call_quit ( void * foo)
call_new_call ( void * foo)
{
sflphone_quit();
sflphone_new_call();
}
void
call_preferences ( void * foo)
call_quit ( void * foo)
{
show_config_window();
sflphone_quit();
}
void
......@@ -174,7 +189,17 @@ create_call_menu()
GtkWidget * menu_items;
menu = gtk_menu_new ();
newCallMenu = gtk_image_menu_item_new_with_mnemonic("_New call...");
gtk_menu_shell_append (GTK_MENU_SHELL (menu), newCallMenu);
g_signal_connect_swapped (G_OBJECT (newCallMenu), "activate",
G_CALLBACK (call_new_call),
NULL);
gtk_widget_show (newCallMenu);
menu_items = gtk_separator_menu_item_new ();
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items);
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);
......@@ -191,20 +216,16 @@ create_call_menu()
NULL);
gtk_widget_show (hangUpMenu);
menu_items = gtk_separator_menu_item_new ();
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items);
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",
holdConnId = 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);
......@@ -223,6 +244,48 @@ create_call_menu()
}
/* ----------------------------------------------------------------- */
void
edit_preferences ( void * foo)
{
show_config_window();
}
GtkWidget *
create_edit_menu()
{
GtkWidget * menu;
GtkWidget * root_menu;
GtkWidget * menu_items;
menu = gtk_menu_new ();
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);
gtk_widget_set_sensitive( GTK_WIDGET(menu_items), FALSE);
gtk_widget_show (menu_items);
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);
gtk_widget_set_sensitive( GTK_WIDGET(menu_items), FALSE);
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 (edit_preferences),
NULL);
gtk_widget_show (menu_items);
root_menu = gtk_menu_item_new_with_mnemonic ("_Edit");
gtk_menu_item_set_submenu (GTK_MENU_ITEM (root_menu), menu);
return root_menu;
}
/* ----------------------------------------------------------------- */
void
view_dial_pad (GtkCheckMenuItem *checkmenuitem,
void* foo)
......@@ -246,13 +309,19 @@ create_view_menu()
NULL);
gtk_widget_show (menu_items);
menu_items = gtk_separator_menu_item_new ();
menu_items = gtk_check_menu_item_new_with_mnemonic ("_Volume controls");
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items);
gtk_widget_set_sensitive( GTK_WIDGET(menu_items), FALSE);
g_signal_connect(G_OBJECT (menu_items), "toggled",
G_CALLBACK (view_dial_pad),
NULL);
gtk_widget_show (menu_items);
menu_items = gtk_image_menu_item_new_from_stock( GTK_STOCK_PREFERENCES, get_accel_group());
menu_items = gtk_check_menu_item_new_with_mnemonic ("_Toolbar");
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items);
g_signal_connect_swapped (G_OBJECT (menu_items), "activate",
G_CALLBACK (call_preferences),
gtk_widget_set_sensitive( GTK_WIDGET(menu_items), FALSE);
g_signal_connect(G_OBJECT (menu_items), "toggled",
G_CALLBACK (view_dial_pad),
NULL);
gtk_widget_show (menu_items);
......@@ -268,21 +337,21 @@ create_menus ( )
GtkWidget * menu_bar;
GtkWidget * root_menu;
menu_bar = gtk_menu_bar_new ();
root_menu = create_call_menu();
gtk_menu_shell_append (GTK_MENU_SHELL (menu_bar), root_menu);
root_menu = create_edit_menu();
gtk_menu_shell_append (GTK_MENU_SHELL (menu_bar), root_menu);
root_menu = create_view_menu();
gtk_menu_shell_append (GTK_MENU_SHELL (menu_bar), root_menu);
root_menu = create_help_menu();
gtk_menu_shell_append (GTK_MENU_SHELL (menu_bar), root_menu);
gtk_widget_show (menu_bar);
......
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