Commit 878fe8f4 authored by Emmanuel Milou's avatar Emmanuel Milou

Add a contextuel menu in the history

parent 9315ff4a
......@@ -116,6 +116,14 @@ call_list_clean_history( void )
call_list_reset( history );
}
void
call_list_remove_from_history( call_t* c )
{
call_list_remove( history, c->callID );
update_call_tree_remove( history, c );
g_print("Size of history = %i\n" , call_list_get_size( history ));
}
void
call_list_remove (calltab_t* tab, const gchar * callID)
{
......
......@@ -164,5 +164,15 @@ void call_select (calltab_t* tab, call_t * c );
* @return The number of the caller */
call_t * call_get_selected (calltab_t* tab);
/**
* Clean the history. Delete all calls
*/
void call_list_clean_history();
/**
* Remove one specified call from the history list
* @param c The call to remove
*/
void call_list_remove_from_history( call_t* c);
#endif
......@@ -40,6 +40,11 @@ GtkToolItem * mailboxButton;
guint transfertButtonConnId; //The button toggled signal connection ID
gboolean history_shown;
void
switch_tab()
{
(gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON(historyButton)))? gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(historyButton), FALSE):gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(historyButton), TRUE);
}
/**
* Show popup menu
......@@ -57,8 +62,16 @@ 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;
if( active_calltree == current_calls )
{
show_popup_menu(widget, event);
return TRUE;
}
else
{
show_popup_menu_history(widget, event);
return TRUE;
}
}
return FALSE;
}
......@@ -333,6 +346,9 @@ create_toolbar ()
ret = gtk_toolbar_new();
toolbar = ret;
gtk_toolbar_set_orientation(GTK_TOOLBAR(ret), GTK_ORIENTATION_HORIZONTAL);
gtk_toolbar_set_style(GTK_TOOLBAR(ret), GTK_TOOLBAR_ICONS);
image = gtk_image_new_from_file( ICONS_DIR "/call.svg");
callButton = gtk_tool_button_new (image, _("Place a call"));
#if GTK_CHECK_VERSION(2,12,0)
......@@ -341,8 +357,6 @@ create_toolbar ()
g_signal_connect (G_OBJECT (callButton), "clicked",
G_CALLBACK (call_button), NULL);
gtk_toolbar_insert(GTK_TOOLBAR(ret), GTK_TOOL_ITEM(callButton), -1);
gtk_toolbar_set_orientation(GTK_TOOLBAR(ret), GTK_ORIENTATION_HORIZONTAL);
gtk_toolbar_set_style(GTK_TOOLBAR(ret), GTK_TOOLBAR_ICONS);
image = gtk_image_new_from_file( ICONS_DIR "/accept.svg");
pickupButton = gtk_tool_button_new(image, _("Pick up"));
......@@ -696,7 +710,7 @@ update_call_tree_add (calltab_t* tab, call_t * c)
pixbuf = gdk_pixbuf_new_from_file(ICONS_DIR "/missed.svg", NULL);
break;
default:
g_warning("Should not happen!");
g_warning("History - Should not happen!");
}
date = timestamp_get_call_date();
......
......@@ -66,4 +66,6 @@ void update_call_tree_remove (calltab_t* ct, call_t * c);
*/
GtkWidget * create_toolbar();
void switch_tab( void );
#endif
......@@ -226,6 +226,34 @@ call_wizard ( void * foo)
#endif
}
static void
remove_from_history( void * foo )
{
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
call_back( void * foo )
{
call_t* c = call_get_selected( history );
if( c )
{
if(!c->to){
c->to = call_get_number(c);
c->from = g_strconcat("\"\" <", c->to, ">",NULL);
}
switch_tab();
printf("call : from : %s to %s\n", c->from, c->to);
call_list_add(current_calls, c);
update_call_tree_add(current_calls, c);
sflphone_place_call(c);
}
}
GtkWidget *
create_call_menu()
{
......@@ -646,7 +674,7 @@ show_popup_menu (GtkWidget *my_widget, GdkEventButton *event)
}
GtkWidget *menu;
//GtkWidget *image;
GtkWidget *image;
int button, event_time;
GtkWidget * menu_items;
......@@ -682,8 +710,8 @@ show_popup_menu (GtkWidget *my_widget, GdkEventButton *event)
{
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);
image = gtk_image_new_from_file( ICONS_DIR "/icon_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),
......@@ -694,8 +722,8 @@ show_popup_menu (GtkWidget *my_widget, GdkEventButton *event)
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);
image = gtk_image_new_from_file( ICONS_DIR "/icon_hangup.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),
......@@ -761,3 +789,65 @@ show_popup_menu (GtkWidget *my_widget, GdkEventButton *event)
button, event_time);
}
void
show_popup_menu_history(GtkWidget *my_widget, GdkEventButton *event)
{
gboolean pickup = FALSE;
gboolean remove = FALSE;
call_t * selectedCall = call_get_selected( history );
if (selectedCall)
{
remove = TRUE;
pickup = TRUE;
}
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);
if(pickup)
{
menu_items = gtk_image_menu_item_new_with_mnemonic(_("_Call back"));
image = gtk_image_new_from_file( ICONS_DIR "/icon_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_back), NULL);
gtk_widget_show (menu_items);
}
menu_items = gtk_separator_menu_item_new ();
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items);
gtk_widget_show (menu_items);
if(remove)
{
menu_items = gtk_image_menu_item_new_from_stock( GTK_STOCK_DELETE, get_accel_group());
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items);
g_signal_connect (G_OBJECT (menu_items), "activate", G_CALLBACK (remove_from_history), NULL);
gtk_widget_show (menu_items);
}
if (event)
{
button = event->button;
event_time = event->time;
}
else
{
button = 0;
event_time = gtk_get_current_event_time ();
}
gtk_menu_attach_to_widget (GTK_MENU (menu), my_widget, NULL);
gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL,
button, event_time);
}
......@@ -43,4 +43,10 @@ void update_menus();
*/
void show_popup_menu (GtkWidget *my_widget, GdkEventButton *event);
/**
* Create a menu on right-click for the history
* @param my_widget The widget you click on
* @param event The mouse event
*/
void show_popup_menu_history (GtkWidget *my_widget, GdkEventButton *event);
#endif
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