r21833 - gnucash/trunk/src/gnome - Fix Read-only Action Sensitivity

John Ralls jralls at code.gnucash.org
Mon Jan 9 18:10:30 EST 2012


Author: jralls
Date: 2012-01-09 18:10:29 -0500 (Mon, 09 Jan 2012)
New Revision: 21833
Trac: http://svn.gnucash.org/trac/changeset/21833

Modified:
   gnucash/trunk/src/gnome/gnc-plugin-basic-commands.c
Log:
Fix Read-only Action Sensitivity

So that FileSaveAction isn't made sensitive when the session isn't dirty.

Modified: gnucash/trunk/src/gnome/gnc-plugin-basic-commands.c
===================================================================
--- gnucash/trunk/src/gnome/gnc-plugin-basic-commands.c	2012-01-09 23:10:20 UTC (rev 21832)
+++ gnucash/trunk/src/gnome/gnc-plugin-basic-commands.c	2012-01-09 23:10:29 UTC (rev 21833)
@@ -219,9 +219,12 @@
     NULL,
 };
 
+/** These actions, plus FileSaveAction, are made not sensitive (i.e.,
+ * their toolbar and menu items are grayed out and do not send events
+ * when clicked) when the current book is "Read Only".
+ */
 static const gchar *readonly_inactive_actions[] =
 {
-    "FileSaveAction",
     "ToolsBookCloseAction",
     NULL
 };
@@ -315,9 +318,11 @@
 {
     GncMainWindow  *window;
     GtkActionGroup *action_group;
+    GtkAction *file_save_action;
 
     // We are readonly - so we have to switch particular actions to inactive.
     gboolean is_readwrite = !qof_book_is_readonly(gnc_get_current_book());
+    gboolean is_dirty = qof_book_session_not_saved (gnc_get_current_book ());
 
     // We continue only if the current page is a plugin page
     if (!plugin_page || !GNC_IS_PLUGIN_PAGE(plugin_page))
@@ -331,6 +336,10 @@
     /* Set the action's sensitivity */
     gnc_plugin_update_actions (action_group, readonly_inactive_actions,
                                "sensitive", is_readwrite);
+/* FileSaveAction needs to be set separately because it has *two* conditions */
+    file_save_action = gtk_action_group_get_action (action_group,
+						    "FileSaveAction");
+    gtk_action_set_sensitive (file_save_action, is_readwrite && is_dirty);
 }
 
 static void



More information about the gnucash-changes mailing list