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() ...@@ -181,7 +181,7 @@ sflphone_hang_up()
dbus_hang_up (selectedCall); dbus_hang_up (selectedCall);
break; break;
default: default:
g_warning("Should not happen!"); g_warning("Should not happen in sflphone_hang_up()!");
break; break;
} }
} }
...@@ -209,7 +209,7 @@ sflphone_pick_up() ...@@ -209,7 +209,7 @@ sflphone_pick_up()
dbus_transfert (selectedCall); dbus_transfert (selectedCall);
break; break;
default: default:
g_warning("Should not happen!"); g_warning("Should not happen in sflphone_pick_up()!");
break; break;
} }
} }
...@@ -227,7 +227,7 @@ sflphone_on_hold () ...@@ -227,7 +227,7 @@ sflphone_on_hold ()
dbus_hold (selectedCall); dbus_hold (selectedCall);
break; break;
default: default:
g_warning("Should not happen!"); g_warning("Should not happen in sflphone_on_hold!");
break; break;
} }
} }
...@@ -245,7 +245,7 @@ sflphone_off_hold () ...@@ -245,7 +245,7 @@ sflphone_off_hold ()
dbus_unhold (selectedCall); dbus_unhold (selectedCall);
break; break;
default: default:
g_warning("Should not happen!"); g_warning("Should not happen in sflphone_off_hold ()!");
break; break;
} }
} }
......
...@@ -43,16 +43,24 @@ GtkWidget *accounts_list; ...@@ -43,16 +43,24 @@ GtkWidget *accounts_list;
/** /**
* Show popup menu * Show popup menu
*/ */
gboolean static gboolean
popup_menu (GtkWidget *widget, popup_menu (GtkWidget *widget,
gpointer user_data) gpointer user_data)
{ {
g_print("POPIP");
show_popup_menu(widget, NULL); show_popup_menu(widget, NULL);
return TRUE; 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 * Make a call
*/ */
...@@ -343,7 +351,6 @@ create_call_tree (){ ...@@ -343,7 +351,6 @@ create_call_tree (){
G_TYPE_POINTER // Pointer to the Object G_TYPE_POINTER // Pointer to the Object
); );
view = gtk_tree_view_new_with_model (GTK_TREE_MODEL(store)); view = gtk_tree_view_new_with_model (GTK_TREE_MODEL(store));
gtk_tree_view_set_headers_visible (GTK_TREE_VIEW(view), FALSE); gtk_tree_view_set_headers_visible (GTK_TREE_VIEW(view), FALSE);
g_signal_connect (G_OBJECT (view), "row-activated", g_signal_connect (G_OBJECT (view), "row-activated",
...@@ -354,6 +361,9 @@ create_call_tree (){ ...@@ -354,6 +361,9 @@ create_call_tree (){
g_signal_connect (G_OBJECT (view), "popup-menu", g_signal_connect (G_OBJECT (view), "popup-menu",
G_CALLBACK (popup_menu), G_CALLBACK (popup_menu),
NULL); NULL);
g_signal_connect (G_OBJECT (view), "button-press-event",
G_CALLBACK (button_pressed),
NULL);
rend = gtk_cell_renderer_pixbuf_new(); rend = gtk_cell_renderer_pixbuf_new();
col = gtk_tree_view_column_new_with_attributes ("Icon", col = gtk_tree_view_column_new_with_attributes ("Icon",
...@@ -385,7 +395,8 @@ create_call_tree (){ ...@@ -385,7 +395,8 @@ create_call_tree (){
return ret; return ret;
} }
void
void
update_call_tree_remove (call_t * c) update_call_tree_remove (call_t * c)
{ {
GtkTreeIter iter; GtkTreeIter iter;
...@@ -416,7 +427,7 @@ update_call_tree_remove (call_t * c) ...@@ -416,7 +427,7 @@ update_call_tree_remove (call_t * c)
toolbar_update_buttons(); toolbar_update_buttons();
} }
void void
update_call_tree (call_t * c) update_call_tree (call_t * c)
{ {
GdkPixbuf *pixbuf; GdkPixbuf *pixbuf;
...@@ -508,7 +519,7 @@ update_call_tree (call_t * c) ...@@ -508,7 +519,7 @@ update_call_tree (call_t * c)
} }
void void
update_call_tree_add (call_t * c) update_call_tree_add (call_t * c)
{ {
GdkPixbuf *pixbuf; GdkPixbuf *pixbuf;
......
...@@ -85,7 +85,7 @@ void update_menus() ...@@ -85,7 +85,7 @@ void update_menus()
gtk_widget_set_sensitive( GTK_WIDGET(hangUpMenu), TRUE); gtk_widget_set_sensitive( GTK_WIDGET(hangUpMenu), TRUE);
break; break;
default: default:
g_warning("Should not happen!"); g_warning("Should not happen in update_menus()!");
break; break;
} }
} }
...@@ -97,7 +97,7 @@ void update_menus() ...@@ -97,7 +97,7 @@ void update_menus()
} }
/* ----------------------------------------------------------------- */ /* ----------------------------------------------------------------- */
void static void
help_about ( void * foo) help_about ( void * foo)
{ {
gchar *authors[] = { gchar *authors[] = {
...@@ -155,38 +155,43 @@ create_help_menu() ...@@ -155,38 +155,43 @@ create_help_menu()
return root_menu; return root_menu;
} }
/* ----------------------------------------------------------------- */ /* ----------------------------------------------------------------- */
void static void
call_new_call ( void * foo) call_new_call ( void * foo)
{ {
sflphone_new_call(); sflphone_new_call();
} }
void static void
call_quit ( void * foo) call_quit ( void * foo)
{ {
sflphone_quit(); sflphone_quit();
} }
void static void
call_hold (void* foo) call_hold (void* foo)
{ {
if(gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(holdMenu))) call_t * selectedCall = call_get_selected();
{
sflphone_on_hold(); if(selectedCall)
}
else
{ {
sflphone_off_hold(); if(selectedCall->state == CALL_STATE_HOLD)
{
sflphone_off_hold();
}
else
{
sflphone_on_hold();
}
} }
} }
void static void
call_pick_up ( void * foo) call_pick_up ( void * foo)
{ {
sflphone_pick_up(); sflphone_pick_up();
} }
void static void
call_hang_up ( void * foo) call_hang_up ( void * foo)
{ {
sflphone_hang_up(); sflphone_hang_up();
...@@ -255,14 +260,14 @@ create_call_menu() ...@@ -255,14 +260,14 @@ create_call_menu()
} }
/* ----------------------------------------------------------------- */ /* ----------------------------------------------------------------- */
void static void
edit_preferences ( void * foo) edit_preferences ( void * foo)
{ {
show_config_window(); show_config_window();
} }
// The menu Edit/Copy should copy the current selected call's number // The menu Edit/Copy should copy the current selected call's number
void static void
edit_copy ( void * foo) edit_copy ( void * foo)
{ {
GtkClipboard* clip = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD); GtkClipboard* clip = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD);
...@@ -294,7 +299,7 @@ edit_copy ( void * foo) ...@@ -294,7 +299,7 @@ edit_copy ( void * foo)
} }
// The menu Edit/Paste should paste the clipboard into the current selected call // The menu Edit/Paste should paste the clipboard into the current selected call
void static void
edit_paste ( void * foo) edit_paste ( void * foo)
{ {
GtkClipboard* clip = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD); GtkClipboard* clip = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD);
...@@ -425,7 +430,7 @@ create_edit_menu() ...@@ -425,7 +430,7 @@ create_edit_menu()
return root_menu; return root_menu;
} }
/* ----------------------------------------------------------------- */ /* ----------------------------------------------------------------- */
void static void
view_dial_pad (GtkCheckMenuItem *checkmenuitem, view_dial_pad (GtkCheckMenuItem *checkmenuitem,
void* foo) void* foo)
{ {
...@@ -502,28 +507,115 @@ create_menus ( ) ...@@ -502,28 +507,115 @@ create_menus ( )
void void
show_popup_menu (GtkWidget *my_widget, GdkEventButton *event) 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 *menu;
//GtkWidget *image;
int button, event_time; int button, event_time;
GtkWidget * menu_items; GtkWidget * menu_items;
menu = gtk_menu_new (); menu = gtk_menu_new ();
g_signal_connect (menu, "deactivate", //g_signal_connect (menu, "deactivate",
G_CALLBACK (gtk_widget_destroy), NULL); // G_CALLBACK (gtk_widget_destroy), NULL);
menu_items = gtk_image_menu_item_new_from_stock( GTK_STOCK_COPY, get_accel_group()); if(copy)
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items); {
g_signal_connect_swapped (G_OBJECT (menu_items), "activate", menu_items = gtk_image_menu_item_new_from_stock( GTK_STOCK_COPY, get_accel_group());
G_CALLBACK (edit_copy), gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items);
NULL); g_signal_connect (G_OBJECT (menu_items), "activate",
gtk_widget_show (copyMenu); 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()); 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_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), G_CALLBACK (edit_paste),
NULL); 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) if (event)
{ {
button = event->button; 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