static void update_inactive_actions(GncPluginPage *plugin_page) { GncMainWindow *window; GtkActionGroup *action_group; // We are readonly - so we have to switch particular actions to inactive. gboolean is_readwrite = !qof_book_is_readonly(gnc_get_current_book()); // We continue only if the current page is a plugin page if (!plugin_page || !GNC_IS_PLUGIN_PAGE(plugin_page)) return; // Check that this is a main window and not embedded sx if (!GNC_IS_MAIN_WINDOW(plugin_page->window)) return; window = GNC_MAIN_WINDOW(plugin_page->window); g_return_if_fail(GNC_IS_MAIN_WINDOW(window)); action_group = gnc_main_window_get_action_group(window, PLUGIN_ACTIONS_NAME); g_return_if_fail(GTK_IS_ACTION_GROUP(action_group)); /* Set the action's sensitivity */ gnc_plugin_update_actions (action_group, readonly_inactive_actions, "sensitive", is_readwrite); }
static void gnc_plugin_business_update_menus (GncPluginPage *plugin_page) { GncMainWindow *window; GtkActionGroup *action_group; gboolean is_txn_register, is_bus_txn = FALSE, is_bus_doc = FALSE; // We continue only if the current page is a plugin page if (!plugin_page || !GNC_IS_PLUGIN_PAGE(plugin_page)) return; // Check that this is a main window and not embedded sx if (!GNC_IS_MAIN_WINDOW(plugin_page->window)) return; is_txn_register = GNC_IS_PLUGIN_PAGE_REGISTER(plugin_page); window = GNC_MAIN_WINDOW(plugin_page->window); g_return_if_fail(GNC_IS_MAIN_WINDOW(window)); action_group = gnc_main_window_get_action_group(window, PLUGIN_ACTIONS_NAME); g_return_if_fail(GTK_IS_ACTION_GROUP(action_group)); if (is_txn_register) { Transaction *trans = gnc_plugin_page_register_get_current_txn (GNC_PLUGIN_PAGE_REGISTER(plugin_page)); if (xaccTransCountSplits(trans) > 0) is_bus_txn = (xaccTransGetFirstAPARAcctSplit(trans, TRUE) != NULL); is_bus_doc = (xaccTransGetTxnType (trans) == TXN_TYPE_INVOICE); } // Change visibility and also sensitivity according to whether we are in a txn register gnc_plugin_update_actions (action_group, register_txn_actions, "sensitive", is_txn_register && !is_bus_txn && !is_bus_doc); gnc_plugin_update_actions (action_group, register_txn_actions, "visible", is_txn_register && !is_bus_txn && !is_bus_doc); gnc_plugin_update_actions (action_group, register_bus_txn_actions, "sensitive", is_txn_register && is_bus_txn && !is_bus_doc); gnc_plugin_update_actions (action_group, register_bus_txn_actions, "visible", is_txn_register && is_bus_txn && !is_bus_doc); }
/** Create a new invoice page based on the information saved during a * previous instantiation of gnucash. * * @param window The window where this page should be installed. * * @param key_file A pointer to the GKeyFile data structure where the * page information should be read. * * @param group_name The group name to use when restoring data. */ static GncPluginPage * gnc_plugin_page_invoice_recreate_page (GtkWidget *window, GKeyFile *key_file, const gchar *group_name) { GncPluginPage *page; g_return_val_if_fail(GNC_IS_MAIN_WINDOW(window), NULL); g_return_val_if_fail(key_file, NULL); g_return_val_if_fail(group_name, NULL); ENTER("key_file %p, group_name %s", key_file, group_name); /* Create the new page. */ page = gnc_invoice_recreate_page(GNC_MAIN_WINDOW(window), key_file, group_name); LEAVE(" "); return page; }
/* Bind the visibility of the extra toolbar buttons to the * enable_toolbuttons preference. */ static void bind_toolbuttons_visibility (GncMainWindow *mainwindow) { GtkActionGroup *action_group; const char **iter; g_return_if_fail(mainwindow); g_return_if_fail(GNC_IS_MAIN_WINDOW(mainwindow)); /* Get the action group */ action_group = gnc_main_window_get_action_group(mainwindow, PLUGIN_ACTIONS_NAME); g_assert(action_group); for (iter = extra_toolbar_actions; *iter; ++iter) { /* Set the action's visibility */ GtkAction *action = gtk_action_group_get_action (action_group, *iter); gnc_prefs_bind (GNC_PREFS_GROUP_INVOICE, GNC_PREF_EXTRA_TOOLBUTTONS, G_OBJECT (action), "visible"); } }