From 20e75417bff42119088bc0e810c8993a016bfebc Mon Sep 17 00:00:00 2001 From: Alexandre Savard <alexandresavard@alexandresavard-desktop.(none)> Date: Thu, 11 Feb 2010 17:22:05 -0500 Subject: [PATCH] [#2558] Added hangup menu item in systray --- sflphone-client-gnome/src/statusicon.c | 39 +++++++++++++++++++++--- sflphone-client-gnome/src/statusicon.h | 13 ++++++++ sflphone-client-gnome/src/uimanager.c | 12 ++++++-- sflphone-common/src/dbus/callmanager.cpp | 3 +- 4 files changed, 58 insertions(+), 9 deletions(-) diff --git a/sflphone-client-gnome/src/statusicon.c b/sflphone-client-gnome/src/statusicon.c index 47e9d4a855..f017891e3e 100644 --- a/sflphone-client-gnome/src/statusicon.c +++ b/sflphone-client-gnome/src/statusicon.c @@ -25,11 +25,10 @@ #include <statusicon.h> #if GTK_CHECK_VERSION(2,10,0) -GtkStatusIcon* status; -GtkWidget * show_menu_item; +GtkStatusIcon *status; +GtkWidget *show_menu_item, *hangup_menu_item; gboolean __minimized = MINIMIZED; - void popup_main_window (void) { if (__POPUP_WINDOW) @@ -39,18 +38,39 @@ void popup_main_window (void) } } +void show_status_hangup_icon() { + + DEBUG("Show Hangup in Systray"); + gtk_widget_show(GTK_WIDGET(hangup_menu_item)); + +} + +void hide_status_hangup_icon() { + + DEBUG("Hide Hangup in Systray"); + gtk_widget_hide(GTK_WIDGET(hangup_menu_item)); +} + + void status_quit ( void * foo UNUSED) { sflphone_quit(); } +void +status_hangup () +{ + sflphone_hang_up(); +} + void status_icon_unminimize() { gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(show_menu_item), TRUE); } + gboolean main_widget_minimized() { return __minimized; @@ -90,6 +110,7 @@ GtkWidget* create_menu() { GtkWidget * menu; GtkWidget * menu_items; + GtkWidget * image; menu = gtk_menu_new (); @@ -99,10 +120,18 @@ GtkWidget* create_menu() g_signal_connect(G_OBJECT (show_menu_item), "toggled", G_CALLBACK (show_hide), NULL); - + + hangup_menu_item = 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(hangup_menu_item), image); + gtk_menu_shell_append(GTK_MENU_SHELL(menu), hangup_menu_item); + g_signal_connect(G_OBJECT (hangup_menu_item), "activate", + G_CALLBACK (status_hangup), + NULL); + 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_QUIT, get_accel_group()); g_signal_connect_swapped (G_OBJECT (menu_items), "activate", G_CALLBACK (status_quit), diff --git a/sflphone-client-gnome/src/statusicon.h b/sflphone-client-gnome/src/statusicon.h index 4a841c4ea0..f976c9ad17 100644 --- a/sflphone-client-gnome/src/statusicon.h +++ b/sflphone-client-gnome/src/statusicon.h @@ -45,6 +45,19 @@ void show_status_icon(); */ void status_icon_unminimize(); +/** + * Show hangup icon + */ +void show_status_hangup_icon(); + + +/** + * Show hangup icon + */ +void hide_status_hangup_icon(); + + + /** * Tells if the main window if minimized or not * @return gboolean TRUE if the main window is minimized diff --git a/sflphone-client-gnome/src/uimanager.c b/sflphone-client-gnome/src/uimanager.c index 1a4632c589..966b6311b4 100644 --- a/sflphone-client-gnome/src/uimanager.c +++ b/sflphone-client-gnome/src/uimanager.c @@ -27,6 +27,7 @@ #include <glib/gprintf.h> #include <libgnome/gnome-help.h> #include <uimanager.h> +#include <statusicon.h> static GtkWidget *toolbar; static GtkWidget *toolbarWindows; @@ -147,7 +148,9 @@ void update_actions() if (selectedCall) { - // DEBUG("------------------------- selected call ---------------------------\n"); + // update icon in systray + show_status_hangup_icon(); + gtk_action_set_sensitive (GTK_ACTION (copyAction), TRUE); switch(selectedCall->_state) @@ -225,7 +228,8 @@ void update_actions() } else if (selectedConf){ - // DEBUG("------------------------- selected conf ---------------------------\n"); + // update icon in systray + show_status_hangup_icon(); switch(selectedConf->_state) { @@ -265,6 +269,10 @@ void update_actions() } else { + + // update icon in systray + hide_status_hangup_icon(); + if( account_list_get_size() > 0 && current_account_has_mailbox ()) { gtk_toolbar_insert (GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (voicemailToolbar), -2); diff --git a/sflphone-common/src/dbus/callmanager.cpp b/sflphone-common/src/dbus/callmanager.cpp index 3468944497..1c30ef9755 100644 --- a/sflphone-common/src/dbus/callmanager.cpp +++ b/sflphone-common/src/dbus/callmanager.cpp @@ -40,8 +40,7 @@ void CallManager::placeCall (const std::string& accountID, const std::string& callID, const std::string& to) -{ - // Check if a destination number is available +{ // Check if a destination number is available if (to == "") _debug ("No number entered - Call stopped"); else Manager::instance().outgoingCall (accountID, callID, to); -- GitLab