Commit e7f22da8 authored by Pierre-Luc Beaudoin's avatar Pierre-Luc Beaudoin
Browse files

Popup menu!

parent 3944ac8b
......@@ -181,7 +181,7 @@ sflphone_hang_up()
dbus_hang_up (selectedCall);
break;
default:
g_warning("Should not happen!");
g_warning("Should not happen in sflphone_hang_up()!");
break;
}
}
......@@ -209,7 +209,7 @@ sflphone_pick_up()
dbus_transfert (selectedCall);
break;
default:
g_warning("Should not happen!");
g_warning("Should not happen in sflphone_pick_up()!");
break;
}
}
......@@ -227,7 +227,7 @@ sflphone_on_hold ()
dbus_hold (selectedCall);
break;
default:
g_warning("Should not happen!");
g_warning("Should not happen in sflphone_on_hold!");
break;
}
}
......@@ -245,7 +245,7 @@ sflphone_off_hold ()
dbus_unhold (selectedCall);
break;
default:
g_warning("Should not happen!");
g_warning("Should not happen in sflphone_off_hold ()!");
break;
}
}
......
......@@ -43,16 +43,24 @@ GtkWidget *accounts_list;
/**
* Show popup menu
*/
gboolean
static gboolean
popup_menu (GtkWidget *widget,
gpointer user_data)
{
g_print("POPIP");
show_popup_menu(widget, NULL);
return TRUE;
}
static gboolean
button_pressed(GtkWidget* widget, GdkEventButton *event, gpointer user_data)
{
if (event->button == 3 && event->type == GDK_BUTTON_PRESS)
{
show_popup_menu(widget, event);
return TRUE;
}
return FALSE;
}
/**
* Make a call
*/
......@@ -343,7 +351,6 @@ create_call_tree (){
G_TYPE_POINTER // Pointer to the Object
);
view = gtk_tree_view_new_with_model (GTK_TREE_MODEL(store));
gtk_tree_view_set_headers_visible (GTK_TREE_VIEW(view), FALSE);
g_signal_connect (G_OBJECT (view), "row-activated",
......@@ -354,6 +361,9 @@ create_call_tree (){
g_signal_connect (G_OBJECT (view), "popup-menu",
G_CALLBACK (popup_menu),
NULL);
g_signal_connect (G_OBJECT (view), "button-press-event",
G_CALLBACK (button_pressed),
NULL);
rend = gtk_cell_renderer_pixbuf_new();
col = gtk_tree_view_column_new_with_attributes ("Icon",
......@@ -385,7 +395,8 @@ create_call_tree (){
return ret;
}
void
void
update_call_tree_remove (call_t * c)
{
GtkTreeIter iter;
......@@ -416,7 +427,7 @@ update_call_tree_remove (call_t * c)
toolbar_update_buttons();
}
void
void
update_call_tree (call_t * c)
{
GdkPixbuf *pixbuf;
......@@ -508,7 +519,7 @@ update_call_tree (call_t * c)
}
void
void
update_call_tree_add (call_t * c)
{
GdkPixbuf *pixbuf;
......
......@@ -85,7 +85,7 @@ void update_menus()
gtk_widget_set_sensitive( GTK_WIDGET(hangUpMenu), TRUE);
break;
default:
g_warning("Should not happen!");
g_warning("Should not happen in update_menus()!");
break;
}
}
......@@ -97,7 +97,7 @@ void update_menus()
}
/* ----------------------------------------------------------------- */
void
static void
help_about ( void * foo)
{
gchar *authors[] = {
......@@ -155,38 +155,43 @@ create_help_menu()
return root_menu;
}
/* ----------------------------------------------------------------- */
void
static void
call_new_call ( void * foo)
{
sflphone_new_call();
}
void
static void
call_quit ( void * foo)
{
sflphone_quit();
}
void
static void
call_hold (void* foo)
{
if(gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(holdMenu)))
{
sflphone_on_hold();
}
else
call_t * selectedCall = call_get_selected();
if(selectedCall)
{
sflphone_off_hold();
if(selectedCall->state == CALL_STATE_HOLD)
{
sflphone_off_hold();
}
else
{
sflphone_on_hold();
}
}
}
void
static void
call_pick_up ( void * foo)
{
sflphone_pick_up();
}
void
static void
call_hang_up ( void * foo)
{
sflphone_hang_up();
......@@ -255,14 +260,14 @@ create_call_menu()
}
/* ----------------------------------------------------------------- */
void
static void
edit_preferences ( void * foo)
{
show_config_window();
}
// The menu Edit/Copy should copy the current selected call's number
void
static void
edit_copy ( void * foo)
{
GtkClipboard* clip = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD);
......@@ -294,7 +299,7 @@ edit_copy ( void * foo)
}
// The menu Edit/Paste should paste the clipboard into the current selected call
void
static void
edit_paste ( void * foo)
{
GtkClipboard* clip = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD);
......@@ -425,7 +430,7 @@ create_edit_menu()
return root_menu;
}
/* ----------------------------------------------------------------- */
void
static void
view_dial_pad (GtkCheckMenuItem *checkmenuitem,
void* foo)
{
......@@ -502,28 +507,115 @@ create_menus ( )
void
show_popup_menu (GtkWidget *my_widget, GdkEventButton *event)
{
g_print("Popup\n");
// TODO update the selection to make sure the call under the mouse is the call selected
gboolean pickup = FALSE, hangup = FALSE, hold = FALSE, copy = FALSE;
call_t * selectedCall = call_get_selected();
if (selectedCall)
{
copy = TRUE;
switch(selectedCall->state)
{
case CALL_STATE_INCOMING:
pickup = TRUE;
hangup = TRUE;
break;
case CALL_STATE_HOLD:
hangup = TRUE;
hold = TRUE;
break;
case CALL_STATE_RINGING:
hangup = TRUE;
break;
case CALL_STATE_DIALING:
pickup = TRUE;
hangup = TRUE;
break;
case CALL_STATE_CURRENT:
hangup = TRUE;
hold = TRUE;
break;
case CALL_STATE_BUSY:
case CALL_STATE_FAILURE:
hangup = TRUE;
break;
default:
g_warning("Should not happen in show_popup_menu!");
break;
}
}
GtkWidget *menu;
//GtkWidget *image;
int button, event_time;
GtkWidget * menu_items;
menu = gtk_menu_new ();
g_signal_connect (menu, "deactivate",
G_CALLBACK (gtk_widget_destroy), NULL);
//g_signal_connect (menu, "deactivate",
// G_CALLBACK (gtk_widget_destroy), NULL);
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_swapped (G_OBJECT (menu_items), "activate",
G_CALLBACK (edit_copy),
NULL);
gtk_widget_show (copyMenu);
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",
G_CALLBACK (edit_copy),
NULL);
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);
g_signal_connect_swapped (G_OBJECT (menu_items), "activate",
g_signal_connect (G_OBJECT (menu_items), "activate",
G_CALLBACK (edit_paste),
NULL);
gtk_widget_show (pasteMenu);
gtk_widget_show (menu_items);
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);
}
if(pickup)
{
menu_items = gtk_image_menu_item_new_with_mnemonic("_Pick up");
//image = gtk_image_new_from_file( ICONS_DIR "/accept.svg");
//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",
G_CALLBACK (call_pick_up),
NULL);
gtk_widget_show (menu_items);
}
if(hangup)
{
menu_items = gtk_image_menu_item_new_with_mnemonic("_Hang up");
//image = gtk_image_new_from_file( ICONS_DIR "/hang_up.svg");
//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",
G_CALLBACK (call_hang_up),
NULL);
gtk_widget_show (menu_items);
}
if(hold)
{
menu_items = gtk_check_menu_item_new_with_mnemonic ("On _Hold");
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items);
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu_items),
(selectedCall->state == CALL_STATE_HOLD ? TRUE : FALSE));
g_signal_connect(G_OBJECT (menu_items), "activate",
G_CALLBACK (call_hold),
NULL);
gtk_widget_show (menu_items);
}
if (event)
{
button = event->button;
......
Supports Markdown
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