[gnac/devel] Disabled trayicon's menu items while waiting for an exit confirmation



commit 0301820de11c0737e007117959de36e1c4077c2b
Author: Benoît Dupasquier <bdupasqu src gnome org>
Date:   Fri Jun 18 21:08:26 2010 +0100

    Disabled trayicon's menu items while waiting for an exit confirmation

 src/gnac-main.c |    9 +++++++++
 src/gnac-ui.c   |   13 +++++++++++++
 src/gnac-ui.h   |    3 +++
 3 files changed, 25 insertions(+), 0 deletions(-)
---
diff --git a/src/gnac-main.c b/src/gnac-main.c
index 61700bf..4b0902c 100644
--- a/src/gnac-main.c
+++ b/src/gnac-main.c
@@ -381,9 +381,15 @@ gnac_add_file(GFile *file)
 static gboolean
 gnac_confirm_exit(void)
 {
+  gboolean   has_trayicon;
   gint       response;
   GtkWidget *dialog;
 
+  has_trayicon = gnac_gconf_get_boolean(GNAC_GCONF_TRAY_ICON);
+
+  /* disable stop/resume and quit from trayicon's menu */
+  if (has_trayicon) gnac_ui_trayicon_menu_activate(FALSE);
+
   dialog = gtk_message_dialog_new(
       GTK_WINDOW(gnac_ui_get_widget("main_window")),
       GTK_DIALOG_MODAL,
@@ -399,6 +405,9 @@ gnac_confirm_exit(void)
 
   gtk_widget_destroy(dialog);
 
+  /* enable stop/resume and quit from trayicon's menu */
+  if (has_trayicon) gnac_ui_trayicon_menu_activate(TRUE);
+
   return (response == GTK_RESPONSE_YES);
 }
 
diff --git a/src/gnac-ui.c b/src/gnac-ui.c
index 1b2f0e3..5194ee2 100644
--- a/src/gnac-ui.c
+++ b/src/gnac-ui.c
@@ -1091,6 +1091,19 @@ gnac_ui_trayicon_tooltip_update(const gchar *tooltip)
 
 
 void
+gnac_ui_trayicon_menu_activate(gboolean activate)
+{
+  GtkAction *action;
+  action = gnac_ui_get_action("tray_pause_item");
+  gtk_action_set_sensitive(action, activate);
+  action = gnac_ui_get_action("tray_stop_item");
+  gtk_action_set_sensitive(action, activate);
+  action = gnac_ui_get_action("tray_quit_item");
+  gtk_action_set_sensitive(action, activate);
+}
+
+
+void
 gnac_ui_trayicon_menu_stop(gpointer data, 
                            gpointer user_data)
 {
diff --git a/src/gnac-ui.h b/src/gnac-ui.h
index ec320f7..2380300 100644
--- a/src/gnac-ui.h
+++ b/src/gnac-ui.h
@@ -149,6 +149,9 @@ void
 gnac_ui_trayicon_tooltip_update(const gchar *tooltip);
 
 void
+gnac_ui_trayicon_menu_activate(gboolean activate);
+
+void
 gnac_ui_trayicon_menu_stop(gpointer data, 
                            gpointer user_data);
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]