From 774058a6c2c6100c4ba885ae80396f9aa3946b13 Mon Sep 17 00:00:00 2001 From: Pierre Pronchery Date: Sat, 20 Aug 2011 15:20:25 +0000 Subject: [PATCH] Fixed suspending and resuming via plug-in messages --- src/phone.c | 4 ++-- src/plugins/systray.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/src/phone.c b/src/phone.c index 0eb91e5..99fda5c 100644 --- a/src/phone.c +++ b/src/phone.c @@ -3273,9 +3273,9 @@ static void _phone_message(Phone * phone, PhoneMessage message, ...) case PHONE_MESSAGE_POWER_MANAGEMENT: power = va_arg(ap, PhoneMessagePowerManagement); if(power == PHONE_MESSAGE_POWER_MANAGEMENT_RESUME) - event.type = PHONE_EVENT_TYPE_SUSPEND; - else if(power == PHONE_MESSAGE_POWER_MANAGEMENT_SUSPEND) event.type = PHONE_EVENT_TYPE_RESUME; + else if(power == PHONE_MESSAGE_POWER_MANAGEMENT_SUSPEND) + event.type = PHONE_EVENT_TYPE_SUSPEND; else break; phone_event(phone, &event); diff --git a/src/plugins/systray.c b/src/plugins/systray.c index ed4a8cc..1a60bfc 100644 --- a/src/plugins/systray.c +++ b/src/plugins/systray.c @@ -155,6 +155,8 @@ static void _popup_menu_on_show_dialer(gpointer data); static void _popup_menu_on_show_logs(gpointer data); static void _popup_menu_on_show_messages(gpointer data); static void _popup_menu_on_show_settings(gpointer data); +static void _popup_menu_on_resume(gpointer data); +static void _popup_menu_on_suspend(gpointer data); static void _systray_on_popup_menu(GtkStatusIcon * icon, guint button, guint time, gpointer data) @@ -164,6 +166,7 @@ static void _systray_on_popup_menu(GtkStatusIcon * icon, guint button, GtkWidget * menuitem; menu = gtk_menu_new(); + /* show windows */ menuitem = gtk_menu_item_new_with_mnemonic("Show _dialer"); g_signal_connect_swapped(menuitem, "activate", G_CALLBACK( _popup_menu_on_show_dialer), plugin); @@ -180,6 +183,17 @@ static void _systray_on_popup_menu(GtkStatusIcon * icon, guint button, g_signal_connect_swapped(menuitem, "activate", G_CALLBACK( _popup_menu_on_show_settings), plugin); gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); + /* suspend and resume */ + menuitem = gtk_separator_menu_item_new(); + gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); + menuitem = gtk_menu_item_new_with_mnemonic("_Resume telephony"); + g_signal_connect_swapped(menuitem, "activate", G_CALLBACK( + _popup_menu_on_resume), plugin); + gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); + menuitem = gtk_menu_item_new_with_mnemonic("S_uspend telephony"); + g_signal_connect_swapped(menuitem, "activate", G_CALLBACK( + _popup_menu_on_suspend), plugin); + gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); gtk_widget_show_all(menu); gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, button, time); } @@ -215,4 +229,22 @@ static void _popup_menu_on_show_settings(gpointer data) plugin->helper->message(plugin->helper->phone, PHONE_MESSAGE_SHOW, PHONE_MESSAGE_SHOW_SETTINGS); } + +static void _popup_menu_on_resume(gpointer data) +{ + PhonePlugin * plugin = data; + + plugin->helper->message(plugin->helper->phone, + PHONE_MESSAGE_POWER_MANAGEMENT, + PHONE_MESSAGE_POWER_MANAGEMENT_RESUME); +} + +static void _popup_menu_on_suspend(gpointer data) +{ + PhonePlugin * plugin = data; + + plugin->helper->message(plugin->helper->phone, + PHONE_MESSAGE_POWER_MANAGEMENT, + PHONE_MESSAGE_POWER_MANAGEMENT_SUSPEND); +} #endif