r17759 - gnucash/trunk/src/gnome - Commit r17686 "Bug 559783 - SQL-related menu entry only when

Phil Longstaff plongstaff at cvs.gnucash.org
Sun Dec 7 11:58:10 EST 2008


Author: plongstaff
Date: 2008-12-07 11:58:10 -0500 (Sun, 07 Dec 2008)
New Revision: 17759
Trac: http://svn.gnucash.org/trac/changeset/17759

Modified:
   gnucash/trunk/src/gnome/gnc-plugin-basic-commands.c
Log:
Commit r17686 "Bug 559783 - SQL-related menu entry only when 
--enable-dbi is given" introduced a Gtk critical warning because an 
action was removed from the compilation, but still referenced from the 
ui xml file.  This commit changes this so that the database connection 
action is still created, but the add_to_window() function is overriden 
to set that action insensitive if --enable-dbi is not given.


Modified: gnucash/trunk/src/gnome/gnc-plugin-basic-commands.c
===================================================================
--- gnucash/trunk/src/gnome/gnc-plugin-basic-commands.c	2008-12-07 13:35:12 UTC (rev 17758)
+++ gnucash/trunk/src/gnome/gnc-plugin-basic-commands.c	2008-12-07 16:58:10 UTC (rev 17759)
@@ -65,6 +65,8 @@
 static void gnc_plugin_basic_commands_init (GncPluginBasicCommands *plugin);
 static void gnc_plugin_basic_commands_finalize (GObject *object);
 
+static void gnc_plugin_basic_commands_add_to_window (GncPlugin *plugin, GncMainWindow *window, GQuark type);
+
 /* Command callbacks */
 static void gnc_main_window_cmd_file_new (GtkAction *action, GncMainWindowActionData *data);
 static void gnc_main_window_cmd_file_open (GtkAction *action, GncMainWindowActionData *data);
@@ -103,11 +105,9 @@
   { "FileOpenAction", GTK_STOCK_OPEN, N_("_Open..."), NULL,
     N_("Open an existing GnuCash file"),
     G_CALLBACK (gnc_main_window_cmd_file_open) },
-#ifdef HAVE_DBI_DBI_H
   { "FileDatabaseConnectionAction", NULL, N_("_Database Connection"), NULL,
     N_("Connect to a database"),
     G_CALLBACK (gnc_main_window_cmd_file_db_connection) },
-#endif
   { "FileSaveAction", GTK_STOCK_SAVE, N_("_Save"), "<control>s",
     N_("Save the current file"),
     G_CALLBACK (gnc_main_window_cmd_file_save) },
@@ -247,6 +247,29 @@
   return GNC_PLUGIN (plugin);
 }
 
+/** Initialize the basic commands menu for a window.  This function is
+ *  called as part of the initialization of a window, after all the
+ *  plugin menu items have been added to the menu structure.  Its job
+ *  is to correctly initialize the basic commands menu,  It does this by
+ *  hiding the Database Connection menu item if database support has not
+ *  been included in the build.
+ *
+ *  @param plugin A pointer to the gnc-plugin object responsible for
+ *  adding/removing the basic commands menu.
+ *
+ *  @param window A pointer the gnc-main-window that is being initialized.
+ *
+ *  @param type Unused
+ */
+static void
+gnc_plugin_basic_commands_add_to_window (GncPlugin *plugin,
+				       GncMainWindow *window,
+				       GQuark type)
+{
+#if !defined(HAVE_DBI_DBI_H)
+	gnc_main_window_all_action_set_sensitive("FileDatabaseConnectionAction", FALSE);
+#endif
+}
 
 /** Initialize the class for a new basic commands plugin.  This will
  *  set up any function pointers that override functions in the parent
@@ -268,6 +291,9 @@
   /* plugin info */
   plugin_class->plugin_name  = GNC_PLUGIN_BASIC_COMMANDS_NAME;
 
+  /* function overrides */
+  plugin_class->add_to_window = gnc_plugin_basic_commands_add_to_window;
+
   /* widget addition/removal */
   plugin_class->actions_name 	  = PLUGIN_ACTIONS_NAME;
   plugin_class->actions      	  = gnc_plugin_actions;



More information about the gnucash-changes mailing list