From cf7c654daa56a761efecc2226841f943fa060d12 Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Fri, 28 Oct 2022 16:03:38 +0100 Subject: [PATCH 01/77] Initial change to allow change of GtkAction to GAction --- gnucash/gnome-utils/gnc-plugin-page.c | 24 ++++++++++++++++++++++++ gnucash/gnome-utils/gnc-plugin-page.h | 5 +++-- gnucash/gnome-utils/gnc-plugin.c | 24 ++++++++++++++++++++++++ gnucash/gnome-utils/gnc-plugin.h | 23 ++++++++++++++++++++++- 4 files changed, 73 insertions(+), 3 deletions(-) diff --git a/gnucash/gnome-utils/gnc-plugin-page.c b/gnucash/gnome-utils/gnc-plugin-page.c index dec6e88f0c..1c7617cbf2 100644 --- a/gnucash/gnome-utils/gnc-plugin-page.c +++ b/gnucash/gnome-utils/gnc-plugin-page.c @@ -96,6 +96,9 @@ typedef struct _GncPluginPagePrivate guint merge_id; char *ui_description; + GtkBuilder *builder; //FIXMEb added + GSimpleActionGroup *simple_action_group; //FIXMEb added + GList *books; gboolean use_new_window; @@ -1113,7 +1116,16 @@ gnc_plugin_page_get_action_group(GncPluginPage *page) priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page); return priv->action_group; } +GSimpleActionGroup * +gnc_plugin_page_get_action_groupb (GncPluginPage *page) +{ + GncPluginPagePrivate *priv; + g_return_val_if_fail (GNC_IS_PLUGIN_PAGE(page), NULL); + + priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page); + return priv->simple_action_group; +} /* Create the GtkActionGroup object associated with this page. */ GtkActionGroup * @@ -1129,6 +1141,18 @@ gnc_plugin_page_create_action_group (GncPluginPage *page, const gchar *group_nam return group; } +GSimpleActionGroup * +gnc_plugin_page_create_action_groupb (GncPluginPage *page, const gchar *group_name) +{ + GncPluginPagePrivate *priv; + GSimpleActionGroup *group; + + priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page); + group = g_simple_action_group_new (); + priv->simple_action_group = group; + return group; +} + gboolean gnc_plugin_page_finish_pending (GncPluginPage *page) { diff --git a/gnucash/gnome-utils/gnc-plugin-page.h b/gnucash/gnome-utils/gnc-plugin-page.h index 9d0b7e560c..833f37947f 100644 --- a/gnucash/gnome-utils/gnc-plugin-page.h +++ b/gnucash/gnome-utils/gnc-plugin-page.h @@ -541,7 +541,7 @@ GtkUIManager *gnc_plugin_page_get_ui_merge (GncPluginPage *page); * @return A pointer to the GtkActionGroup object for this page. */ GtkActionGroup *gnc_plugin_page_get_action_group (GncPluginPage *page); - +GSimpleActionGroup *gnc_plugin_page_get_action_groupb (GncPluginPage *page); //FIXMEb added /** Create the GtkActionGroup object associated with this page. * @@ -557,7 +557,8 @@ GtkActionGroup *gnc_plugin_page_get_action_group (GncPluginPage *page); */ GtkActionGroup * gnc_plugin_page_create_action_group (GncPluginPage *page, const gchar *group_name); - +GSimpleActionGroup * gnc_plugin_page_create_action_groupb (GncPluginPage *page, + const gchar *group_name); //FIXMEb added /** Retrieve a GtkAction object associated with this page. * * @param page The page whose menu/toolbar action group should be diff --git a/gnucash/gnome-utils/gnc-plugin.c b/gnucash/gnome-utils/gnc-plugin.c index 73c487fbc0..a863f2534a 100644 --- a/gnucash/gnome-utils/gnc-plugin.c +++ b/gnucash/gnome-utils/gnc-plugin.c @@ -300,8 +300,32 @@ gnc_plugin_update_actions (GtkActionGroup *action_group, } } } +void +gnc_plugin_update_actionsb (GSimpleActionGroup *simple_action_group, + const gchar **action_names, + const gchar *property_name, + gboolean value) +{ + GAction *action; + gint i; + for (i = 0; action_names[i]; i++) + { + action = g_simple_action_group_lookup (simple_action_group, action_names[i]); + if (action) + { +//FIXMEb g_object_set (G_OBJECT(action), property_name, value, NULL); + } + else + { +//FIXMEb g_warning("No such action with name '%s' in action group %s (size %d)", +// action_names[i], gtk_action_group_get_name(simple_action_group), +// g_list_length(gtk_action_group_list_actions(simple_action_group))); + } + } +} + /** Load a new set of actions into an existing UI. * * See gnc-plugin.h for documentation on the function arguments. */ diff --git a/gnucash/gnome-utils/gnc-plugin.h b/gnucash/gnome-utils/gnc-plugin.h index 100afd6933..b38c4d920f 100644 --- a/gnucash/gnome-utils/gnc-plugin.h +++ b/gnucash/gnome-utils/gnc-plugin.h @@ -96,6 +96,15 @@ G_BEGIN_DECLS /* typedefs & structures */ +typedef struct +{ + const gchar *action_name; + const gchar *stock_id; + const gchar *label; + const gchar *accelerator; + const gchar *tooltip; +} GncDisplayItem; + /** The instance data structure for a menu-only plugin. */ typedef struct { @@ -119,6 +128,15 @@ typedef struct const gchar *actions_name; /** An array of actions that should automatically be added to * any GnuCash "main" content window that is opened. */ + GActionEntry *actionsb; //FIXMEb added + /** The number of actions in the actions array. */ + guint n_actionsb; //FIXMEb added + + /** An array of display items (menu / toolbar entries) */ + GncDisplayItem *display_items; //FIXMEb added + /** The number of display_items in the display item array. */ + guint n_display_items; //FIXMEb added + GtkActionEntry *actions; /** The number of actions in the actions array. */ guint n_actions; @@ -290,7 +308,10 @@ void gnc_plugin_update_actions (GtkActionGroup *action_group, const gchar **action_names, const gchar *property_name, gboolean value); - +void gnc_plugin_update_actionsb (GSimpleActionGroup *simple_action_group, + const gchar **action_names, + const gchar *property_name, + gboolean value); //FIXMEb added /** Load a new set of actions into an existing UI. The actions from * the provided group will be merged into the pre-existing ui, as From 0f70143c55ad56e16d4bea43a0af6727f0a147ec Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Sun, 30 Oct 2022 13:16:34 +0000 Subject: [PATCH 02/77] Initial change to plugin source files --- gnucash/gnome-utils/gnc-plugin-file-history.c | 52 +- gnucash/gnome/gnc-plugin-account-tree.c | 39 +- gnucash/gnome/gnc-plugin-basic-commands.c | 375 +++++++------ gnucash/gnome/gnc-plugin-budget.c | 126 +++-- gnucash/gnome/gnc-plugin-business.c | 507 ++++++++++-------- gnucash/gnome/gnc-plugin-register.c | 35 +- gnucash/gnome/gnc-plugin-report-system.c | 39 +- .../import-export/aqb/gnc-plugin-aqbanking.c | 177 +++--- .../bi-import/gnc-plugin-bi-import.c | 39 +- .../csv-exp/gnc-plugin-csv-export.c | 59 +- .../csv-imp/gnc-plugin-csv-import.c | 56 +- .../gnc-plugin-customer-import.c | 41 +- .../log-replay/gnc-plugin-log-replay.c | 35 +- gnucash/import-export/ofx/gnc-plugin-ofx.c | 35 +- .../qif-imp/gnc-plugin-qif-import.c | 34 +- .../gnc-module/example/gnc-plugin.example.c | 46 +- 16 files changed, 1002 insertions(+), 693 deletions(-) diff --git a/gnucash/gnome-utils/gnc-plugin-file-history.c b/gnucash/gnome-utils/gnc-plugin-file-history.c index 00664a16d7..160d0135e1 100644 --- a/gnucash/gnome-utils/gnc-plugin-file-history.c +++ b/gnucash/gnome-utils/gnc-plugin-file-history.c @@ -65,12 +65,12 @@ static void gnc_plugin_file_history_remove_from_window (GncPlugin *plugin, GncMa static QofLogModule log_module = GNC_MOD_GUI; /* Command callbacks */ -static void gnc_plugin_file_history_cmd_open_file (GtkAction *action, GncMainWindowActionData *data); +static void gnc_plugin_file_history_cmd_open_file (GSimpleAction *simple, GVariant *parameter, gpointer user_data); /** The label given to the main window for this plugin. */ #define PLUGIN_ACTIONS_NAME "gnc-plugin-file-history-actions" /** The name of the UI description file for this plugin. */ -#define PLUGIN_UI_FILENAME "gnc-plugin-file-history-ui.xml" +#define PLUGIN_UI_FILENAME "gnc-plugin-file-history.ui" #define GNOME1_HISTORY "History" #define GNOME1_MAXFILES "MaxFiles" @@ -80,21 +80,21 @@ static void gnc_plugin_file_history_cmd_open_file (GtkAction *action, GncMainWin * will be updated to reflect the users recent choices. This list is * limited to ten actions, although there may be a smaller limit set * by the user. The typical limit is four. */ -static GtkActionEntry gnc_plugin_actions [] = +static GActionEntry gnc_plugin_actions [] = { - { "RecentFile0Action", NULL, "", NULL, NULL, G_CALLBACK (gnc_plugin_file_history_cmd_open_file) }, - { "RecentFile1Action", NULL, "", NULL, NULL, G_CALLBACK (gnc_plugin_file_history_cmd_open_file) }, - { "RecentFile2Action", NULL, "", NULL, NULL, G_CALLBACK (gnc_plugin_file_history_cmd_open_file) }, - { "RecentFile3Action", NULL, "", NULL, NULL, G_CALLBACK (gnc_plugin_file_history_cmd_open_file) }, - { "RecentFile4Action", NULL, "", NULL, NULL, G_CALLBACK (gnc_plugin_file_history_cmd_open_file) }, - { "RecentFile5Action", NULL, "", NULL, NULL, G_CALLBACK (gnc_plugin_file_history_cmd_open_file) }, - { "RecentFile6Action", NULL, "", NULL, NULL, G_CALLBACK (gnc_plugin_file_history_cmd_open_file) }, - { "RecentFile7Action", NULL, "", NULL, NULL, G_CALLBACK (gnc_plugin_file_history_cmd_open_file) }, - { "RecentFile8Action", NULL, "", NULL, NULL, G_CALLBACK (gnc_plugin_file_history_cmd_open_file) }, - { "RecentFile9Action", NULL, "", NULL, NULL, G_CALLBACK (gnc_plugin_file_history_cmd_open_file) }, + { "RecentFile0Action", gnc_plugin_file_history_cmd_open_file, NULL, NULL, NULL }, + { "RecentFile1Action", gnc_plugin_file_history_cmd_open_file, NULL, NULL, NULL }, + { "RecentFile2Action", gnc_plugin_file_history_cmd_open_file, NULL, NULL, NULL }, + { "RecentFile3Action", gnc_plugin_file_history_cmd_open_file, NULL, NULL, NULL }, + { "RecentFile4Action", gnc_plugin_file_history_cmd_open_file, NULL, NULL, NULL }, + { "RecentFile5Action", gnc_plugin_file_history_cmd_open_file, NULL, NULL, NULL }, + { "RecentFile6Action", gnc_plugin_file_history_cmd_open_file, NULL, NULL, NULL }, + { "RecentFile7Action", gnc_plugin_file_history_cmd_open_file, NULL, NULL, NULL }, + { "RecentFile8Action", gnc_plugin_file_history_cmd_open_file, NULL, NULL, NULL }, + { "RecentFile9Action", gnc_plugin_file_history_cmd_open_file, NULL, NULL, NULL }, }; /** The number of actions provided by this plugin. */ -static guint gnc_plugin_n_actions = G_N_ELEMENTS (gnc_plugin_actions); +static guint gnc_plugin_n_actions = G_N_ELEMENTS(gnc_plugin_actions); /** The instance private data for a file history plugin. This data @@ -538,17 +538,16 @@ gnc_plugin_file_history_class_init (GncPluginFileHistoryClass *klass) object_class->finalize = gnc_plugin_file_history_finalize; /* plugin info */ - plugin_class->plugin_name = GNC_PLUGIN_FILE_HISTORY_NAME; + plugin_class->plugin_name = GNC_PLUGIN_FILE_HISTORY_NAME; /* function overrides */ plugin_class->add_to_window = gnc_plugin_file_history_add_to_window; - plugin_class->remove_from_window = - gnc_plugin_file_history_remove_from_window; + plugin_class->remove_from_window = gnc_plugin_file_history_remove_from_window; /* widget addition/removal */ plugin_class->actions_name = PLUGIN_ACTIONS_NAME; - plugin_class->actions = gnc_plugin_actions; - plugin_class->n_actions = gnc_plugin_n_actions; + plugin_class->actionsb = gnc_plugin_actions; + plugin_class->n_actionsb = gnc_plugin_n_actions; plugin_class->ui_filename = PLUGIN_UI_FILENAME; } @@ -633,8 +632,8 @@ gnc_plugin_file_history_add_to_window (GncPlugin *plugin, */ static void gnc_plugin_file_history_remove_from_window (GncPlugin *plugin, - GncMainWindow *window, - GQuark type) + GncMainWindow *window, + GQuark type) { gnc_prefs_remove_cb_by_func (GNC_PREFS_GROUP_HISTORY, NULL, gnc_plugin_history_list_changed, window); @@ -657,19 +656,22 @@ gnc_plugin_file_history_remove_from_window (GncPlugin *plugin, * function and we're about to close all the windows anyway. */ static void -gnc_plugin_file_history_cmd_open_file (GtkAction *action, - GncMainWindowActionData *data) +gnc_plugin_file_history_cmd_open_file (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) + { + GncMainWindowActionData *data = user_data; gchar *filename; - g_return_if_fail(GTK_IS_ACTION(action)); + g_return_if_fail(GTK_IS_ACTION(simple)); g_return_if_fail(data != NULL); /* DRH - Do we need to close all open windows but the first? * Which progress bar should we be using? One in a window, or * in a new "file loading" dialog??? */ - filename = g_object_get_data(G_OBJECT(action), FILENAME_STRING); + filename = g_object_get_data(G_OBJECT(simple), FILENAME_STRING); gnc_window_set_progressbar_window (GNC_WINDOW(data->window)); /* also opens new account page */ gnc_file_open_file (GTK_WINDOW (data->window), diff --git a/gnucash/gnome/gnc-plugin-account-tree.c b/gnucash/gnome/gnc-plugin-account-tree.c index 049f4e72e6..a13859ba2b 100644 --- a/gnucash/gnome/gnc-plugin-account-tree.c +++ b/gnucash/gnome/gnc-plugin-account-tree.c @@ -46,24 +46,29 @@ static void gnc_plugin_account_tree_init (GncPluginAccountTree *plugin); static void gnc_plugin_account_tree_finalize (GObject *object); /* Command callbacks */ -static void gnc_plugin_account_tree_cmd_new_account_tree (GtkAction *action, GncMainWindowActionData *data); +static void gnc_plugin_account_tree_cmd_new_account_tree (GSimpleAction *simple, GVariant *parameter, gpointer user_data); #define PLUGIN_ACTIONS_NAME "gnc-plugin-account-tree-actions" -#define PLUGIN_UI_FILENAME "gnc-plugin-account-tree-ui.xml" +#define PLUGIN_UI_FILENAME "gnc-plugin-account-tree.ui" /** An array of all of the actions provided by the account tree * plugin. */ -static GtkActionEntry gnc_plugin_actions [] = +static GActionEntry gnc_plugin_actions [] = { - { - "ViewAccountTreeAction", NULL, N_("New Accounts _Page"), NULL, - N_("Open a new Account Tree page"), - G_CALLBACK (gnc_plugin_account_tree_cmd_new_account_tree) - }, + { "ViewAccountTreeAction", gnc_plugin_account_tree_cmd_new_account_tree, NULL, NULL, NULL }, }; /** The number of actions provided by this plugin. */ -static guint gnc_plugin_n_actions = G_N_ELEMENTS (gnc_plugin_actions); +static guint gnc_plugin_n_actions = G_N_ELEMENTS(gnc_plugin_actions); +static GncDisplayItem gnc_plugin_display_items [] = + { + { + "ViewAccountTreeAction", NULL, N_("New Accounts _Page"), NULL, + N_("Open a new Account Tree page") + }, +}; +/** The number of display items provided by this plugin. */ +static guint gnc_plugin_n_display_items = G_N_ELEMENTS(gnc_plugin_display_items); /** The instance private data structure for an account tree plugin. */ typedef struct GncPluginAccountTreePrivate @@ -117,10 +122,12 @@ gnc_plugin_account_tree_class_init (GncPluginAccountTreeClass *klass) plugin_class->plugin_name = GNC_PLUGIN_ACCOUNT_TREE_NAME; /* widget addition/removal */ - plugin_class->actions_name = PLUGIN_ACTIONS_NAME; - plugin_class->actions = gnc_plugin_actions; - plugin_class->n_actions = gnc_plugin_n_actions; - plugin_class->ui_filename = PLUGIN_UI_FILENAME; + plugin_class->actions_name = PLUGIN_ACTIONS_NAME; + plugin_class->actionsb = gnc_plugin_actions; + plugin_class->n_actionsb = gnc_plugin_n_actions; + plugin_class->display_items = gnc_plugin_display_items; + plugin_class->n_display_items = gnc_plugin_n_display_items; + plugin_class->ui_filename = PLUGIN_UI_FILENAME; } @@ -156,9 +163,11 @@ gnc_plugin_account_tree_finalize (GObject *object) ************************************************************/ static void -gnc_plugin_account_tree_cmd_new_account_tree (GtkAction *action, - GncMainWindowActionData *data) +gnc_plugin_account_tree_cmd_new_account_tree (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *data = user_data; GncPluginPage *page; g_return_if_fail (data != NULL); diff --git a/gnucash/gnome/gnc-plugin-basic-commands.c b/gnucash/gnome/gnc-plugin-basic-commands.c index 4d6624ebb9..b2b8d7f7d6 100644 --- a/gnucash/gnome/gnc-plugin-basic-commands.c +++ b/gnucash/gnome/gnc-plugin-basic-commands.c @@ -71,80 +71,99 @@ static void gnc_plugin_basic_commands_add_to_window (GncPlugin *plugin, GncMainW static void gnc_plugin_basic_commands_main_window_page_changed(GncMainWindow *window, GncPluginPage *page, gpointer user_data); /* 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); -static void gnc_main_window_cmd_file_save (GtkAction *action, GncMainWindowActionData *data); -static void gnc_main_window_cmd_file_save_as (GtkAction *action, GncMainWindowActionData *data); -static void gnc_main_window_cmd_file_revert (GtkAction *action, GncMainWindowActionData *data); -static void gnc_main_window_cmd_file_export_accounts (GtkAction *action, GncMainWindowActionData *data); -static void gnc_main_window_cmd_edit_tax_options (GtkAction *action, GncMainWindowActionData *data); -static void gnc_main_window_cmd_actions_mortgage_loan (GtkAction *action, GncMainWindowActionData *data); -static void gnc_main_window_cmd_actions_scheduled_transaction_editor (GtkAction *action, GncMainWindowActionData *data); -static void gnc_main_window_cmd_actions_since_last_run (GtkAction *action, GncMainWindowActionData *data); +static void gnc_main_window_cmd_file_new (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_main_window_cmd_file_open (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_main_window_cmd_file_save (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_main_window_cmd_file_save_as (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_main_window_cmd_file_revert (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_main_window_cmd_file_export_accounts (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_main_window_cmd_edit_tax_options (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_main_window_cmd_actions_mortgage_loan (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_main_window_cmd_actions_scheduled_transaction_editor (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_main_window_cmd_actions_since_last_run (GSimpleAction *simple, GVariant *parameter, gpointer user_data); #if CLOSE_BOOKS_ACTUALLY_WORKS -static void gnc_main_window_cmd_actions_close_books (GtkAction *action, GncMainWindowActionData *data); +static void gnc_main_window_cmd_actions_close_books (GSimpleAction *simple, GVariant *parameter, gpointer user_data); #endif /* CLOSE_BOOKS_ACTUALLY_WORKS */ -static void gnc_main_window_cmd_tools_financial_calculator (GtkAction *action, GncMainWindowActionData *data); -static void gnc_main_window_cmd_tools_close_book (GtkAction *action, GncMainWindowActionData *data); -static void gnc_main_window_cmd_tools_find_transactions (GtkAction *action, GncMainWindowActionData *data); -static void gnc_main_window_cmd_tools_price_editor (GtkAction *action, GncMainWindowActionData *data); -static void gnc_main_window_cmd_tools_imap_editor (GtkAction *action, GncMainWindowActionData *data); -static void gnc_main_window_cmd_tools_trans_doclink (GtkAction *action, GncMainWindowActionData *data); -static void gnc_main_window_cmd_tools_commodity_editor (GtkAction *action, GncMainWindowActionData *data); -static void gnc_main_window_cmd_help_totd (GtkAction *action, GncMainWindowActionData *data); +static void gnc_main_window_cmd_tools_financial_calculator (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_main_window_cmd_tools_close_book (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_main_window_cmd_tools_find_transactions (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_main_window_cmd_tools_price_editor (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_main_window_cmd_tools_imap_editor (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_main_window_cmd_tools_trans_doclink (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_main_window_cmd_tools_commodity_editor (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_main_window_cmd_help_totd (GSimpleAction *simple, GVariant *parameter, gpointer user_data); #define PLUGIN_ACTIONS_NAME "gnc-plugin-basic-commands-actions" -#define PLUGIN_UI_FILENAME "gnc-plugin-basic-commands-ui.xml" +#define PLUGIN_UI_FILENAME "gnc-plugin-basic-commands.ui" /** An array of all of the actions provided by the basic commands * plugin. */ -static GtkActionEntry gnc_plugin_actions [] = +static GActionEntry gnc_plugin_actions [] = { + { "FileNewAction", gnc_main_window_cmd_file_new, NULL, NULL, NULL }, + { "FileOpenAction", gnc_main_window_cmd_file_open, NULL, NULL, NULL }, + { "FileSaveAction", gnc_main_window_cmd_file_save, NULL, NULL, NULL }, + { "FileSaveAsAction", gnc_main_window_cmd_file_save_as, NULL, NULL, NULL }, + { "FileRevertAction", gnc_main_window_cmd_file_revert, NULL, NULL, NULL }, + { "FileExportAccountsAction", gnc_main_window_cmd_file_export_accounts, NULL, NULL, NULL }, + { "EditFindTransactionsAction", gnc_main_window_cmd_tools_find_transactions, NULL, NULL, NULL }, + { "EditTaxOptionsAction", gnc_main_window_cmd_edit_tax_options, NULL, NULL, NULL }, + { "ActionsScheduledTransactionsAction", NULL, NULL, NULL, NULL }, + { "ActionsScheduledTransactionEditorAction", gnc_main_window_cmd_actions_scheduled_transaction_editor, NULL, NULL, NULL }, + { "ActionsSinceLastRunAction", gnc_main_window_cmd_actions_since_last_run, NULL, NULL, NULL }, + { "ActionsMortgageLoanAction", gnc_main_window_cmd_actions_mortgage_loan, NULL, NULL, NULL }, + { "ActionsBudgetAction", NULL, NULL, NULL, NULL }, +#ifdef CLOSE_BOOKS_ACTUALLY_WORKS + { "ActionsCloseBooksAction", gnc_main_window_cmd_actions_close_books, NULL, NULL, NULL }, +#endif // CLOSE_BOOKS_ACTUALLY_WORKS + { "ToolsPriceEditorAction", gnc_main_window_cmd_tools_price_editor, NULL, NULL, NULL }, + { "ToolsCommodityEditorAction", gnc_main_window_cmd_tools_commodity_editor, NULL, NULL, NULL }, + { "ToolsFinancialCalculatorAction", gnc_main_window_cmd_tools_financial_calculator, NULL, NULL, NULL }, + { "ToolsBookCloseAction", gnc_main_window_cmd_tools_close_book, NULL, NULL, NULL }, + { "ToolsImapEditorAction", gnc_main_window_cmd_tools_imap_editor, NULL, NULL, NULL }, + { "ToolsTransLinkedDocsAction", gnc_main_window_cmd_tools_trans_doclink, NULL, NULL, NULL }, + { "HelpTipsOfTheDayAction", gnc_main_window_cmd_help_totd, NULL, NULL, NULL }, +}; +/** The number of actions provided by this plugin. */ +static guint gnc_plugin_n_actions = G_N_ELEMENTS(gnc_plugin_actions); +static GncDisplayItem gnc_plugin_display_items [] = +{ /* File menu */ - { "FileNewAction", "document-new", N_("New _File"), "n", - N_("Create a new file"), - G_CALLBACK (gnc_main_window_cmd_file_new) + N_("Create a new file") }, { "FileOpenAction", "document-open", N_("_Open..."), "o", - N_("Open an existing GnuCash file"), - G_CALLBACK (gnc_main_window_cmd_file_open) + N_("Open an existing GnuCash file") }, { "FileSaveAction", "document-save", N_("_Save"), "s", - N_("Save the current file"), - G_CALLBACK (gnc_main_window_cmd_file_save) + N_("Save the current file") }, { "FileSaveAsAction", "document-save-as", N_("Save _As..."), "s", - N_("Save this file with a different name"), - G_CALLBACK (gnc_main_window_cmd_file_save_as) + N_("Save this file with a different name") }, { "FileRevertAction", "document-revert", N_("Re_vert"), NULL, - N_("Reload the current database, reverting all unsaved changes"), - G_CALLBACK (gnc_main_window_cmd_file_revert) + N_("Reload the current database, reverting all unsaved changes") }, { "FileExportAccountsAction", "go-next", N_("Export _Accounts"), NULL, - N_("Export the account hierarchy to a new GnuCash datafile"), - G_CALLBACK (gnc_main_window_cmd_file_export_accounts) + N_("Export the account hierarchy to a new GnuCash datafile") }, /* Edit menu */ - { "EditFindTransactionsAction", "edit-find", N_("_Find..."), "f", - N_("Find transactions with a search"), - G_CALLBACK (gnc_main_window_cmd_tools_find_transactions) + N_("Find transactions with a search") }, { "EditTaxOptionsAction", NULL, @@ -155,80 +174,65 @@ static GtkActionEntry gnc_plugin_actions [] = US: income tax and DE: VAT So adjust this string */ - N_("Setup relevant accounts for tax reports, e.g. US income tax"), - G_CALLBACK (gnc_main_window_cmd_edit_tax_options) + N_("Setup relevant accounts for tax reports, e.g. US income tax") }, /* Actions menu */ - - { "ActionsScheduledTransactionsAction", NULL, N_("_Scheduled Transactions"), NULL, NULL, NULL }, + { "ActionsScheduledTransactionsAction", NULL, N_("_Scheduled Transactions"), NULL, NULL }, { "ActionsScheduledTransactionEditorAction", NULL, N_("_Scheduled Transaction Editor"), NULL, - N_("The list of Scheduled Transactions"), - G_CALLBACK (gnc_main_window_cmd_actions_scheduled_transaction_editor) + N_("The list of Scheduled Transactions") }, { "ActionsSinceLastRunAction", NULL, N_("Since _Last Run..."), NULL, - N_("Create Scheduled Transactions since the last time run"), - G_CALLBACK (gnc_main_window_cmd_actions_since_last_run) + N_("Create Scheduled Transactions since the last time run") }, { "ActionsMortgageLoanAction", NULL, N_("_Mortgage & Loan Repayment..."), NULL, - N_("Setup scheduled transactions for repayment of a loan"), - G_CALLBACK (gnc_main_window_cmd_actions_mortgage_loan) + N_("Setup scheduled transactions for repayment of a loan") }, - { "ActionsBudgetAction", NULL, N_("B_udget"), NULL, NULL, NULL }, + { "ActionsBudgetAction", NULL, N_("B_udget"), NULL, NULL }, #ifdef CLOSE_BOOKS_ACTUALLY_WORKS { "ActionsCloseBooksAction", NULL, N_("Close _Books"), NULL, - N_("Archive old data using accounting periods"), - G_CALLBACK (gnc_main_window_cmd_actions_close_books) + N_("Archive old data using accounting periods") }, #endif // CLOSE_BOOKS_ACTUALLY_WORKS /* Tools menu */ { "ToolsPriceEditorAction", NULL, N_("_Price Database"), NULL, - N_("View and edit the prices for stocks and mutual funds"), - G_CALLBACK (gnc_main_window_cmd_tools_price_editor) + N_("View and edit the prices for stocks and mutual funds") }, { "ToolsCommodityEditorAction", NULL, N_("_Security Editor"), NULL, - N_("View and edit the commodities for stocks and mutual funds"), - G_CALLBACK (gnc_main_window_cmd_tools_commodity_editor) + N_("View and edit the commodities for stocks and mutual funds") }, { "ToolsFinancialCalculatorAction", NULL, N_("_Loan Repayment Calculator"), NULL, - N_("Use the loan/mortgage repayment calculator"), - G_CALLBACK (gnc_main_window_cmd_tools_financial_calculator) + N_("Use the loan/mortgage repayment calculator") }, { "ToolsBookCloseAction", NULL, N_("_Close Book"), NULL, - N_("Close the Book at the end of the Period"), - G_CALLBACK (gnc_main_window_cmd_tools_close_book) + N_("Close the Book at the end of the Period") }, { "ToolsImapEditorAction", NULL, N_("_Import Map Editor"), NULL, - N_("View and Delete Bayesian and non-Bayesian information"), - G_CALLBACK (gnc_main_window_cmd_tools_imap_editor) + N_("View and Delete Bayesian and non-Bayesian information") }, { "ToolsTransLinkedDocsAction", NULL, N_("_Transaction Linked Documents"), NULL, - N_("View all Transaction Linked Documents"), - G_CALLBACK (gnc_main_window_cmd_tools_trans_doclink) + N_("View all Transaction Linked Documents") }, /* Help menu */ - { "HelpTipsOfTheDayAction", NULL, N_("_Tips Of The Day"), NULL, - N_("View the Tips of the Day"), - G_CALLBACK (gnc_main_window_cmd_help_totd) + N_("View the Tips of the Day") }, }; -/** The number of actions provided by this plugin. */ -static guint gnc_plugin_n_actions = G_N_ELEMENTS (gnc_plugin_actions); - +/** The number of display items provided by this plugin. */ +static guint gnc_plugin_n_display_items = G_N_ELEMENTS(gnc_plugin_display_items); /** These are the "important" actions provided by the basic commands * plugin. Their labels will appear when the toolbar is set to @@ -278,7 +282,7 @@ typedef struct GncPluginBasicCommandsPrivate } GncPluginBasicCommandsPrivate; #define GNC_PLUGIN_BASIC_COMMANDS_GET_PRIVATE(o) \ - ((GncPluginBasicCommandsPrivate*)gnc_plugin_basic_commands_get_instance_private((GncPluginBasicCommands*)o)) + ((GncPluginBasicCommandsPrivate*)gnc_plugin_basic_commands_get_instance_private ((GncPluginBasicCommands*)o)) /** A pointer to the parent class of a plugin page. */ static GObjectClass *parent_class = NULL; @@ -314,8 +318,8 @@ gnc_plugin_basic_commands_new (void) */ static void gnc_plugin_basic_commands_add_to_window (GncPlugin *plugin, - GncMainWindow *window, - GQuark type) + GncMainWindow *window, + GQuark type) { GtkActionGroup *action_group = gnc_main_window_get_action_group(window, PLUGIN_ACTIONS_NAME); @@ -329,7 +333,7 @@ gnc_plugin_basic_commands_add_to_window (GncPlugin *plugin, /** Update the actions sensitivity */ -static void update_inactive_actions(GncPluginPage *plugin_page) +static void update_inactive_actions (GncPluginPage *plugin_page) { GncMainWindow *window; GtkActionGroup *action_group; @@ -355,15 +359,15 @@ static void update_inactive_actions(GncPluginPage *plugin_page) } static void -gnc_plugin_basic_commands_main_window_page_changed(GncMainWindow *window, - GncPluginPage *page, - gpointer user_data) +gnc_plugin_basic_commands_main_window_page_changed (GncMainWindow *window, + GncPluginPage *plugin_page, + gpointer user_data) { /* Make sure not to call this with a NULL GncPluginPage */ - if (page) + if (plugin_page) { // Update the action sensitivity due to read-only - update_inactive_actions(page); + update_inactive_actions (plugin_page); } } @@ -393,9 +397,11 @@ gnc_plugin_basic_commands_class_init (GncPluginBasicCommandsClass *klass) 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; - plugin_class->n_actions = gnc_plugin_n_actions; + plugin_class->actions_name = PLUGIN_ACTIONS_NAME; + plugin_class->actionsb = gnc_plugin_actions; + plugin_class->n_actionsb = gnc_plugin_n_actions; + plugin_class->display_items = gnc_plugin_display_items; + plugin_class->n_display_items = gnc_plugin_n_display_items; plugin_class->important_actions = gnc_plugin_important_actions; plugin_class->ui_filename = PLUGIN_UI_FILENAME; } @@ -423,9 +429,9 @@ gnc_plugin_basic_commands_init (GncPluginBasicCommands *plugin) static void gnc_plugin_basic_commands_finalize (GObject *object) { - g_return_if_fail (GNC_IS_PLUGIN_BASIC_COMMANDS (object)); + g_return_if_fail (GNC_IS_PLUGIN_BASIC_COMMANDS(object)); - G_OBJECT_CLASS (parent_class)->finalize (object); + G_OBJECT_CLASS(parent_class)->finalize (object); } /************************************************************ @@ -433,20 +439,28 @@ gnc_plugin_basic_commands_finalize (GObject *object) ************************************************************/ static void -gnc_main_window_cmd_file_new (GtkAction *action, GncMainWindowActionData *data) +gnc_main_window_cmd_file_new (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { - if (!gnc_main_window_all_finish_pending()) + GncMainWindowActionData *data = user_data; + + if (!gnc_main_window_all_finish_pending ()) return; - gnc_file_new (GTK_WINDOW (data->window)); + gnc_file_new (GTK_WINDOW(data->window)); } static void -gnc_main_window_cmd_file_open (GtkAction *action, GncMainWindowActionData *data) +gnc_main_window_cmd_file_open (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *data = user_data; + g_return_if_fail (data != NULL); - if (!gnc_main_window_all_finish_pending()) + if (!gnc_main_window_all_finish_pending ()) return; /* Reset the flag that indicates the conversion of the bayes KVP @@ -455,88 +469,114 @@ gnc_main_window_cmd_file_open (GtkAction *action, GncMainWindowActionData *data) gnc_window_set_progressbar_window (GNC_WINDOW(data->window)); #ifdef HAVE_DBI_DBI_H - gnc_ui_file_access_for_open (GTK_WINDOW (data->window)); + gnc_ui_file_access_for_open (GTK_WINDOW(data->window)); #else - gnc_file_open (GTK_WINDOW (data->window)); + gnc_file_open (GTK_WINDOW(data->window)); #endif gnc_window_set_progressbar_window (NULL); } static void -gnc_main_window_cmd_file_save (GtkAction *action, GncMainWindowActionData *data) +gnc_main_window_cmd_file_save (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *data = user_data; + g_return_if_fail (data != NULL); - if (!gnc_main_window_all_finish_pending()) + if (!gnc_main_window_all_finish_pending ()) return; gnc_window_set_progressbar_window (GNC_WINDOW(data->window)); - gnc_file_save (GTK_WINDOW (data->window)); + gnc_file_save (GTK_WINDOW(data->window)); gnc_window_set_progressbar_window (NULL); } static void -gnc_main_window_cmd_file_save_as (GtkAction *action, GncMainWindowActionData *data) +gnc_main_window_cmd_file_save_as (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *data = user_data; + g_return_if_fail (data != NULL); - if (!gnc_main_window_all_finish_pending()) + if (!gnc_main_window_all_finish_pending ()) return; gnc_window_set_progressbar_window (GNC_WINDOW(data->window)); #ifdef HAVE_DBI_DBI_H - gnc_ui_file_access_for_save_as (GTK_WINDOW (data->window)); + gnc_ui_file_access_for_save_as (GTK_WINDOW(data->window)); #else - gnc_file_save_as (GTK_WINDOW (data->window)); + gnc_file_save_as (GTK_WINDOW(data->window)); #endif gnc_window_set_progressbar_window (NULL); } static void -gnc_main_window_cmd_file_revert (GtkAction *action, GncMainWindowActionData *data) +gnc_main_window_cmd_file_revert (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *data = user_data; + g_return_if_fail (data != NULL); - if (!gnc_main_window_all_finish_pending()) + if (!gnc_main_window_all_finish_pending ()) return; gnc_window_set_progressbar_window (GNC_WINDOW(data->window)); - gnc_file_revert(GTK_WINDOW (data->window)); + gnc_file_revert (GTK_WINDOW(data->window)); gnc_window_set_progressbar_window (NULL); } static void -gnc_main_window_cmd_file_export_accounts (GtkAction *action, GncMainWindowActionData *data) +gnc_main_window_cmd_file_export_accounts (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *data = user_data; + g_return_if_fail (data != NULL); gnc_window_set_progressbar_window (GNC_WINDOW(data->window)); #ifdef HAVE_DBI_DBI_H - gnc_ui_file_access_for_export (GTK_WINDOW (data->window)); + gnc_ui_file_access_for_export (GTK_WINDOW(data->window)); #else - gnc_file_export (GTK_WINDOW (data->window)); + gnc_file_export (GTK_WINDOW(data->window)); #endif gnc_window_set_progressbar_window (NULL); } static void -gnc_main_window_cmd_edit_tax_options (GtkAction *action, GncMainWindowActionData *data) +gnc_main_window_cmd_edit_tax_options (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *data = user_data; + g_return_if_fail (data != NULL); - gnc_tax_info_dialog (GTK_WIDGET (data->window), NULL); + gnc_tax_info_dialog (GTK_WIDGET(data->window), NULL); } static void -gnc_main_window_cmd_actions_scheduled_transaction_editor (GtkAction *action, GncMainWindowActionData *data) +gnc_main_window_cmd_actions_scheduled_transaction_editor (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { - GncPluginPage *page = gnc_plugin_page_sx_list_new(); - gnc_main_window_open_page(NULL, page); + GncMainWindowActionData *data = user_data; + GncPluginPage *page = gnc_plugin_page_sx_list_new (); + gnc_main_window_open_page (NULL, page); } static void -gnc_main_window_cmd_actions_since_last_run (GtkAction *action, GncMainWindowActionData *data) +gnc_main_window_cmd_actions_since_last_run (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *data = user_data; GtkWindow *window; GncSxInstanceModel *sx_instances; GncSxSummary summary; @@ -546,9 +586,9 @@ gnc_main_window_cmd_actions_since_last_run (GtkAction *action, GncMainWindowActi g_return_if_fail (data != NULL); - window = GTK_WINDOW (data->window); + window = GTK_WINDOW(data->window); - if (qof_book_is_readonly(gnc_get_current_book())) + if (qof_book_is_readonly (gnc_get_current_book())) { /* Is the book read-only? Then don't change anything here. */ return; @@ -574,97 +614,122 @@ gnc_main_window_cmd_actions_since_last_run (GtkAction *action, GncMainWindowActi } else { - gnc_info_dialog(window, ngettext - /* Translators: %d is the number of transactions. This is a - ngettext(3) message. */ - ("There are no Scheduled Transactions to be entered at this time. " - "(%d transaction automatically created)", - "There are no Scheduled Transactions to be entered at this time. " - "(%d transactions automatically created)", - summary.num_auto_create_no_notify_instances), - summary.num_auto_create_no_notify_instances); + gnc_info_dialog (window, ngettext + /* Translators: %d is the number of transactions. This is a + ngettext(3) message. */ + ("There are no Scheduled Transactions to be entered at this time. " + "(%d transaction automatically created)", + "There are no Scheduled Transactions to be entered at this time. " + "(%d transactions automatically created)", + summary.num_auto_create_no_notify_instances), + summary.num_auto_create_no_notify_instances); } } - g_list_free(auto_created_txns); - g_object_unref(G_OBJECT(sx_instances)); + g_list_free (auto_created_txns); + g_object_unref (G_OBJECT(sx_instances)); } static void -gnc_main_window_cmd_actions_mortgage_loan (GtkAction *action, GncMainWindowActionData *data) +gnc_main_window_cmd_actions_mortgage_loan (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *data = user_data; gnc_ui_sx_loan_assistant_create (); } #ifdef CLOSE_BOOKS_ACTUALLY_WORKS static void -gnc_main_window_cmd_actions_close_books (GtkAction *action, GncMainWindowActionData *data) +gnc_main_window_cmd_actions_close_books (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { - gnc_acct_period_dialog(); + GncMainWindowActionData *data = user_data; + gnc_acct_period_dialog (); } #endif /* CLOSE_BOOKS_ACTUALLY_WORKS */ static void -gnc_main_window_cmd_tools_imap_editor (GtkAction *action, GncMainWindowActionData *data) -{ - gnc_set_busy_cursor(NULL, TRUE); - gnc_imap_dialog (GTK_WIDGET (data->window)); - gnc_unset_busy_cursor(NULL); -} - -static void -gnc_main_window_cmd_tools_trans_doclink (GtkAction *action, GncMainWindowActionData *data) +gnc_main_window_cmd_tools_imap_editor (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *data = user_data; gnc_set_busy_cursor (NULL, TRUE); - gnc_doclink_trans_dialog (GTK_WINDOW (data->window)); + gnc_imap_dialog (GTK_WIDGET(data->window)); gnc_unset_busy_cursor (NULL); } static void -gnc_main_window_cmd_tools_price_editor (GtkAction *action, GncMainWindowActionData *data) +gnc_main_window_cmd_tools_trans_doclink (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { - gnc_set_busy_cursor(NULL, TRUE); - gnc_prices_dialog (GTK_WIDGET (data->window)); - gnc_unset_busy_cursor(NULL); + GncMainWindowActionData *data = user_data; + gnc_set_busy_cursor (NULL, TRUE); + gnc_doclink_trans_dialog (GTK_WINDOW(data->window)); + gnc_unset_busy_cursor (NULL); } static void -gnc_main_window_cmd_tools_commodity_editor (GtkAction *action, GncMainWindowActionData *data) +gnc_main_window_cmd_tools_price_editor (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { - gnc_set_busy_cursor(NULL, TRUE); - gnc_commodities_dialog (GTK_WIDGET (data->window)); - gnc_unset_busy_cursor(NULL); + GncMainWindowActionData *data = user_data; + gnc_set_busy_cursor (NULL, TRUE); + gnc_prices_dialog (GTK_WIDGET(data->window)); + gnc_unset_busy_cursor (NULL); } static void -gnc_main_window_cmd_tools_financial_calculator (GtkAction *action, GncMainWindowActionData *data) +gnc_main_window_cmd_tools_commodity_editor (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { - gnc_ui_fincalc_dialog_create(GTK_WINDOW (data->window)); + GncMainWindowActionData *data = user_data; + gnc_set_busy_cursor (NULL, TRUE); + gnc_commodities_dialog (GTK_WIDGET(data->window)); + gnc_unset_busy_cursor (NULL); } static void -gnc_main_window_cmd_tools_close_book (GtkAction *action, GncMainWindowActionData *data) +gnc_main_window_cmd_tools_financial_calculator (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { - gnc_ui_close_book(gnc_get_current_book(), GTK_WINDOW (data->window)); + GncMainWindowActionData *data = user_data; + gnc_ui_fincalc_dialog_create (GTK_WINDOW(data->window)); } static void -gnc_main_window_cmd_tools_find_transactions (GtkAction *action, GncMainWindowActionData *data) +gnc_main_window_cmd_tools_close_book (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *data = user_data; + gnc_ui_close_book (gnc_get_current_book(), GTK_WINDOW(data->window)); +} + +static void +gnc_main_window_cmd_tools_find_transactions (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) +{ + GncMainWindowActionData *data = user_data; -#ifdef REGISTER2_ENABLED - /*################## Added for Reg2 #################*/ - gnc_ui_find_transactions_dialog_create2 (NULL); - /*################## Added for Reg2 #################*/ -#else gnc_ui_find_transactions_dialog_create (GTK_WINDOW(data->window), NULL); -#endif } static void -gnc_main_window_cmd_help_totd (GtkAction *action, GncMainWindowActionData *data) +gnc_main_window_cmd_help_totd (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *data = user_data; + g_return_if_fail (data != NULL); - gnc_totd_dialog(GTK_WINDOW(data->window), FALSE); + gnc_totd_dialog (GTK_WINDOW(data->window), FALSE); } /** @} */ diff --git a/gnucash/gnome/gnc-plugin-budget.c b/gnucash/gnome/gnc-plugin-budget.c index be38d71e84..b4b9158838 100644 --- a/gnucash/gnome/gnc-plugin-budget.c +++ b/gnucash/gnome/gnc-plugin-budget.c @@ -38,7 +38,7 @@ #include "gnc-component-manager.h" #define PLUGIN_ACTIONS_NAME "gnc-plugin-budget-actions" -#define PLUGIN_UI_FILENAME "gnc-plugin-budget-ui.xml" +#define PLUGIN_UI_FILENAME "gnc-plugin-budget.ui" static QofLogModule log_module = GNC_MOD_GUI; @@ -49,43 +49,44 @@ static void gnc_plugin_budget_add_to_window (GncPlugin *plugin, GncMainWindow *window, GQuark type); /* Command Callbacks */ -static void gnc_plugin_budget_cmd_new_budget (GtkAction *action, - GncMainWindowActionData *data); -static void gnc_plugin_budget_cmd_open_budget (GtkAction *action, - GncMainWindowActionData *data); -static void gnc_plugin_budget_cmd_copy_budget (GtkAction *action, - GncMainWindowActionData *data); -static void gnc_plugin_budget_cmd_delete_budget (GtkAction *action, - GncMainWindowActionData *data); +static void gnc_plugin_budget_cmd_new_budget (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_budget_cmd_open_budget (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_budget_cmd_copy_budget (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_budget_cmd_delete_budget (GSimpleAction *simple, GVariant *parameter, gpointer user_data); -static GtkActionEntry gnc_plugin_actions [] = +static GActionEntry gnc_plugin_actions [] = +{ + { "ActionsBudgetAction", NULL, NULL, NULL, NULL }, + { "NewBudgetAction", gnc_plugin_budget_cmd_new_budget, NULL, NULL, NULL }, + { "OpenBudgetAction", gnc_plugin_budget_cmd_open_budget, NULL, NULL, NULL }, + { "CopyBudgetAction", gnc_plugin_budget_cmd_copy_budget, NULL, NULL, NULL }, + { "DeleteBudgetAction", gnc_plugin_budget_cmd_delete_budget, NULL, NULL, NULL }, + +}; +/** The number of actions provided by this plugin. */ +static guint gnc_plugin_n_actions = G_N_ELEMENTS(gnc_plugin_actions); + +static GncDisplayItem gnc_plugin_display_items [] = { { "NewBudgetAction", NULL, N_("_New Budget"), NULL, - N_("Create a new Budget."), - G_CALLBACK(gnc_plugin_budget_cmd_new_budget) + N_("Create a new Budget.") }, - { "OpenBudgetAction", NULL, N_("_Open Budget"), NULL, - N_("Open an existing Budget in a new tab. If none exists a new budget will be created."), - G_CALLBACK(gnc_plugin_budget_cmd_open_budget) + N_("Open an existing Budget in a new tab. If none exists a new budget will be created.") }, - { "CopyBudgetAction", NULL, N_("_Copy Budget"), NULL, - N_("Copy an existing Budget."), - G_CALLBACK(gnc_plugin_budget_cmd_copy_budget) + N_("Copy an existing Budget.") }, { "DeleteBudgetAction", NULL, N_("_Delete Budget"), NULL, - N_("Delete an existing Budget."), - G_CALLBACK(gnc_plugin_budget_cmd_delete_budget) + N_("Delete an existing Budget.") }, - }; -static guint gnc_plugin_n_actions = G_N_ELEMENTS (gnc_plugin_actions); - +/** The number of display items provided by this plugin. */ +static guint gnc_plugin_n_display_items = G_N_ELEMENTS(gnc_plugin_display_items); static const gchar *plugin_writeable_actions[] = { @@ -106,7 +107,8 @@ typedef struct GncPluginBudgetPrivate static GObjectClass *parent_class = NULL; -GncPlugin * gnc_plugin_budget_new (void) +GncPlugin * +gnc_plugin_budget_new (void) { GncPluginBudget *plugin; ENTER(" "); @@ -120,23 +122,25 @@ GncPlugin * gnc_plugin_budget_new (void) return GNC_PLUGIN(plugin); } -static void page_changed (GncMainWindow *window, GncPluginPage *page, - gpointer user_data) +static void +page_changed (GncMainWindow *window, GncPluginPage *page, gpointer user_data) { GtkActionGroup *action_group = gnc_main_window_get_action_group (window, PLUGIN_ACTIONS_NAME); - +//FIXMEb if (qof_book_is_readonly (gnc_get_current_book())) gnc_plugin_update_actions (action_group, plugin_writeable_actions, "sensitive", FALSE); } -static void add_to_window (GncPlugin *plugin, GncMainWindow *mainwindow, GQuark type) +static void +add_to_window (GncPlugin *plugin, GncMainWindow *mainwindow, GQuark type) { g_signal_connect (mainwindow, "page_changed", G_CALLBACK (page_changed), plugin); } -static void remove_from_window (GncPlugin *plugin, GncMainWindow *window, GQuark type) +static void +remove_from_window (GncPlugin *plugin, GncMainWindow *window, GQuark type) { g_signal_handlers_disconnect_by_func (window, G_CALLBACK(page_changed), plugin); } @@ -153,12 +157,14 @@ gnc_plugin_budget_class_init (GncPluginBudgetClass *klass) parent_class = g_type_class_peek_parent (klass); object_class->finalize = gnc_plugin_budget_finalize; - plugin_class->plugin_name = GNC_PLUGIN_BUDGET_NAME; - plugin_class->actions_name = PLUGIN_ACTIONS_NAME; - plugin_class->actions = gnc_plugin_actions; - plugin_class->n_actions = gnc_plugin_n_actions; - plugin_class->ui_filename = PLUGIN_UI_FILENAME; - plugin_class->add_to_window = add_to_window; + plugin_class->plugin_name = GNC_PLUGIN_BUDGET_NAME; + plugin_class->actions_name = PLUGIN_ACTIONS_NAME; + plugin_class->actionsb = gnc_plugin_actions; + plugin_class->n_actionsb = gnc_plugin_n_actions; + plugin_class->display_items = gnc_plugin_display_items; + plugin_class->n_display_items = gnc_plugin_n_display_items; + plugin_class->ui_filename = PLUGIN_UI_FILENAME; + plugin_class->add_to_window = add_to_window; plugin_class->remove_from_window = remove_from_window; LEAVE (" "); @@ -186,15 +192,17 @@ gnc_plugin_budget_finalize (GObject *object) /* Make a new budget; put it in a page; open the page. */ static void -gnc_plugin_budget_cmd_new_budget (GtkAction *action, - GncMainWindowActionData *user_data) +gnc_plugin_budget_cmd_new_budget (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *data = user_data; GncBudget *budget; GncPluginPage *page; gchar *description, *date; QofBook *book = gnc_get_current_book(); - g_return_if_fail (user_data != NULL); + g_return_if_fail (data != NULL); if (!gnc_features_check_used (book, GNC_FEATURE_BUDGET_UNREVERSED)) { @@ -212,19 +220,22 @@ GnuCash 3.8 or later."); g_free (description); g_free (date); - gnc_main_window_open_page (user_data->window, page); + gnc_main_window_open_page (data->window, page); } /* If only one budget exists, open it; otherwise user selects one to open */ static void -gnc_plugin_budget_cmd_open_budget (GtkAction *action, - GncMainWindowActionData *user_data) +gnc_plugin_budget_cmd_open_budget (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *data = user_data; guint count; QofBook *book; GncBudget *bgt = NULL; QofCollection *col; - g_return_if_fail (user_data != NULL); + + g_return_if_fail (data != NULL); book = gnc_get_current_book (); col = qof_book_get_collection (book, GNC_ID_BUDGET); @@ -234,26 +245,29 @@ gnc_plugin_budget_cmd_open_budget (GtkAction *action, if (count == 1) bgt = gnc_budget_get_default (book); else - bgt = gnc_budget_gui_select_budget (GTK_WINDOW(user_data->window), book); + bgt = gnc_budget_gui_select_budget (GTK_WINDOW(data->window), book); if (bgt) - gnc_main_window_open_page (user_data->window, + gnc_main_window_open_page (data->window, gnc_plugin_page_budget_new (bgt)); } else /* if no budgets exist yet, just open a new budget */ - gnc_plugin_budget_cmd_new_budget (action, user_data); + gnc_plugin_budget_cmd_new_budget (simple, parameter, user_data); } /* If only one budget exists, create a copy of it; otherwise user selects one to copy */ static void -gnc_plugin_budget_cmd_copy_budget (GtkAction *action, - GncMainWindowActionData *user_data) +gnc_plugin_budget_cmd_copy_budget (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *data = user_data; guint count; QofBook *book; GncBudget *bgt = NULL; QofCollection *col; - g_return_if_fail (user_data != NULL); + + g_return_if_fail (data != NULL); book = gnc_get_current_book (); col = qof_book_get_collection (book, GNC_ID_BUDGET); @@ -263,7 +277,7 @@ gnc_plugin_budget_cmd_copy_budget (GtkAction *action, if (count == 1) bgt = gnc_budget_get_default(book); else - bgt = gnc_budget_gui_select_budget (GTK_WINDOW(user_data->window), book); + bgt = gnc_budget_gui_select_budget (GTK_WINDOW(data->window), book); if (bgt) { @@ -275,29 +289,31 @@ gnc_plugin_budget_cmd_copy_budget (GtkAction *action, gnc_budget_set_name (copy, name); g_free (name); - gnc_main_window_open_page (user_data->window, + gnc_main_window_open_page (data->window, gnc_plugin_page_budget_new (copy)); } } else /* if no budgets exist yet, just open a new budget */ - gnc_plugin_budget_cmd_new_budget (action, user_data); + gnc_plugin_budget_cmd_new_budget (simple, parameter, user_data); } /* user selects budget to delete */ static void -gnc_plugin_budget_cmd_delete_budget (GtkAction *action, - GncMainWindowActionData *user_data) +gnc_plugin_budget_cmd_delete_budget (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *data = user_data; GncBudget *bgt; QofBook *book; - g_return_if_fail (user_data != NULL); + g_return_if_fail (data != NULL); book = gnc_get_current_book (); if (qof_collection_count (qof_book_get_collection (book, GNC_ID_BUDGET)) == 0) return; - bgt = gnc_budget_gui_select_budget (GTK_WINDOW(user_data->window), book); + bgt = gnc_budget_gui_select_budget (GTK_WINDOW(data->window), book); if (!bgt) return; gnc_budget_gui_delete_budget (bgt); diff --git a/gnucash/gnome/gnc-plugin-business.c b/gnucash/gnome/gnc-plugin-business.c index 06d0ecf24c..6bf887be7c 100644 --- a/gnucash/gnome/gnc-plugin-business.c +++ b/gnucash/gnome/gnc-plugin-business.c @@ -63,80 +63,50 @@ static void gnc_plugin_business_class_init (GncPluginBusinessClass *klass); static void gnc_plugin_business_init (GncPluginBusiness *plugin); static void gnc_plugin_business_finalize (GObject *object); static void gnc_plugin_business_add_to_window (GncPlugin *plugin, - GncMainWindow *window, - GQuark type); + GncMainWindow *window, + GQuark type); /* Command callbacks */ -static void gnc_plugin_business_cmd_customer_page (GtkAction *action, - GncMainWindowActionData *data); -static void gnc_plugin_business_cmd_customer_new_customer (GtkAction *action, - GncMainWindowActionData *data); -static void gnc_plugin_business_cmd_customer_find_customer (GtkAction *action, - GncMainWindowActionData *data); -static void gnc_plugin_business_cmd_customer_new_invoice (GtkAction *action, - GncMainWindowActionData *data); -static void gnc_plugin_business_cmd_customer_find_invoice (GtkAction *action, - GncMainWindowActionData *data); -static void gnc_plugin_business_cmd_customer_new_job (GtkAction *action, - GncMainWindowActionData *data); -static void gnc_plugin_business_cmd_customer_find_job (GtkAction *action, - GncMainWindowActionData *data); -static void gnc_plugin_business_cmd_customer_process_payment (GtkAction *action, - GncMainWindowActionData *data); +static void gnc_plugin_business_cmd_customer_page (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_business_cmd_customer_new_customer (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_business_cmd_customer_find_customer (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_business_cmd_customer_new_invoice (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_business_cmd_customer_find_invoice (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_business_cmd_customer_new_job (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_business_cmd_customer_find_job (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_business_cmd_customer_process_payment (GSimpleAction *simple, GVariant *parameter, gpointer user_data); -static void gnc_plugin_business_cmd_vendor_page (GtkAction *action, - GncMainWindowActionData *data); -static void gnc_plugin_business_cmd_vendor_new_vendor (GtkAction *action, - GncMainWindowActionData *data); -static void gnc_plugin_business_cmd_vendor_find_vendor (GtkAction *action, - GncMainWindowActionData *data); -static void gnc_plugin_business_cmd_vendor_new_bill (GtkAction *action, - GncMainWindowActionData *data); -static void gnc_plugin_business_cmd_vendor_find_bill (GtkAction *action, - GncMainWindowActionData *data); -static void gnc_plugin_business_cmd_vendor_new_job (GtkAction *action, - GncMainWindowActionData *data); -static void gnc_plugin_business_cmd_vendor_find_job (GtkAction *action, - GncMainWindowActionData *data); -static void gnc_plugin_business_cmd_vendor_process_payment (GtkAction *action, - GncMainWindowActionData *data); +static void gnc_plugin_business_cmd_vendor_page (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_business_cmd_vendor_new_vendor (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_business_cmd_vendor_find_vendor (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_business_cmd_vendor_new_bill (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_business_cmd_vendor_find_bill (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_business_cmd_vendor_new_job (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_business_cmd_vendor_find_job (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_business_cmd_vendor_process_payment (GSimpleAction *simple, GVariant *parameter, gpointer user_data); -static void gnc_plugin_business_cmd_employee_page (GtkAction *action, - GncMainWindowActionData *data); -static void gnc_plugin_business_cmd_employee_new_employee (GtkAction *action, - GncMainWindowActionData *data); -static void gnc_plugin_business_cmd_employee_find_employee (GtkAction *action, - GncMainWindowActionData *data); -static void gnc_plugin_business_cmd_employee_new_expense_voucher (GtkAction *action, - GncMainWindowActionData *data); -static void gnc_plugin_business_cmd_employee_find_expense_voucher (GtkAction *action, - GncMainWindowActionData *data); -static void gnc_plugin_business_cmd_employee_process_payment (GtkAction *action, - GncMainWindowActionData *data); +static void gnc_plugin_business_cmd_employee_page (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_business_cmd_employee_new_employee (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_business_cmd_employee_find_employee (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_business_cmd_employee_new_expense_voucher (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_business_cmd_employee_find_expense_voucher (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_business_cmd_employee_process_payment (GSimpleAction *simple, GVariant *parameter, gpointer user_data); -static void gnc_plugin_business_cmd_doclink (GtkAction *action, - GncMainWindowActionData *data); -static void gnc_plugin_business_cmd_tax_tables (GtkAction *action, - GncMainWindowActionData *data); -static void gnc_plugin_business_cmd_billing_terms (GtkAction *action, - GncMainWindowActionData *data); -static void gnc_plugin_business_cmd_bills_due_reminder (GtkAction *action, - GncMainWindowActionData *data); -static void gnc_plugin_business_cmd_invoices_due_reminder (GtkAction *action, - GncMainWindowActionData *data); +static void gnc_plugin_business_cmd_doclink (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_business_cmd_tax_tables (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_business_cmd_billing_terms (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_business_cmd_bills_due_reminder (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_business_cmd_invoices_due_reminder (GSimpleAction *simple, GVariant *parameter, gpointer user_data); -static void gnc_plugin_business_cmd_test_search (GtkAction *action, - GncMainWindowActionData *data); +static void gnc_plugin_business_cmd_test_search (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_business_cmd_test_init_data (GSimpleAction *simple, GVariant *parameter, gpointer user_data); -static void gnc_plugin_business_cmd_test_init_data (GtkAction *action, - GncMainWindowActionData *data); +static void gnc_plugin_business_cmd_assign_payment (GSimpleAction *simple, GVariant *parameter, gpointer user_data); -static void gnc_plugin_business_cmd_assign_payment (GtkAction *action, - GncMainWindowActionData *data); -static void update_inactive_actions(GncPluginPage *page); +static void update_inactive_actions (GncPluginPage *page); #define PLUGIN_ACTIONS_NAME "gnc-plugin-business-actions" -#define PLUGIN_UI_FILENAME "gnc-plugin-business-ui.xml" +#define PLUGIN_UI_FILENAME "gnc-plugin-business.ui" #define GNC_PREF_EXTRA_TOOLBUTTONS "enable-toolbuttons" #define GNC_PREF_INV_PRINT_RPT "invoice-printreport" @@ -149,192 +119,207 @@ static void update_inactive_actions(GncPluginPage *page); */ static GncMainWindow *last_window = NULL; -static GtkActionEntry gnc_plugin_actions [] = +static GActionEntry gnc_plugin_actions [] = +{ + { "BusinessAction", NULL, NULL, NULL, NULL }, + { "CustomerMenuAction", NULL, NULL, NULL, NULL }, + { "CustomerOverviewPageAction", gnc_plugin_business_cmd_customer_page, NULL, NULL, NULL }, + { "CustomerNewCustomerOpenAction", gnc_plugin_business_cmd_customer_new_customer, NULL, NULL, NULL }, + { "CustomerFindCustomerOpenAction", gnc_plugin_business_cmd_customer_find_customer, NULL, NULL, NULL }, + { "CustomerNewInvoiceOpenAction", gnc_plugin_business_cmd_customer_new_invoice, NULL, NULL, NULL }, + { "CustomerFindInvoiceOpenAction", gnc_plugin_business_cmd_customer_find_invoice, NULL, NULL, NULL }, + { "CustomerNewJobOpenAction", gnc_plugin_business_cmd_customer_new_job, NULL, NULL, NULL }, + { "CustomerFindJobOpenAction", gnc_plugin_business_cmd_customer_find_job, NULL, NULL, NULL }, + { "CustomerProcessPaymentAction", gnc_plugin_business_cmd_customer_process_payment, NULL, NULL, NULL }, + + { "VendorMenuAction", NULL, NULL, NULL, NULL }, + { "VendorOverviewPageAction", gnc_plugin_business_cmd_vendor_page, NULL, NULL, NULL }, + { "VendorNewVendorOpenAction", gnc_plugin_business_cmd_vendor_new_vendor, NULL, NULL, NULL }, + { "VendorFindVendorOpenAction", gnc_plugin_business_cmd_vendor_find_vendor, NULL, NULL, NULL }, + { "VendorNewBillOpenAction", gnc_plugin_business_cmd_vendor_new_bill, NULL, NULL, NULL }, + { "VendorFindBillOpenAction", gnc_plugin_business_cmd_vendor_find_bill, NULL, NULL, NULL }, + { "VendorNewJobOpenAction", gnc_plugin_business_cmd_vendor_new_job, NULL, NULL, NULL }, + { "VendorFindJobOpenAction", gnc_plugin_business_cmd_vendor_find_job, NULL, NULL, NULL }, + { "VendorProcessPaymentAction", gnc_plugin_business_cmd_vendor_process_payment, NULL, NULL, NULL }, + + { "EmployeeMenuAction", NULL, NULL, NULL, NULL }, + { "EmployeeOverviewPageAction", gnc_plugin_business_cmd_employee_page, NULL, NULL, NULL }, + { "EmployeeNewEmployeeOpenAction", gnc_plugin_business_cmd_employee_new_employee, NULL, NULL, NULL }, + { "EmployeeFindEmployeeOpenAction", gnc_plugin_business_cmd_employee_find_employee, NULL, NULL, NULL }, + { "EmployeeNewExpenseVoucherOpenAction", gnc_plugin_business_cmd_employee_new_expense_voucher, NULL, NULL, NULL }, + { "EmployeeFindExpenseVoucherOpenAction", gnc_plugin_business_cmd_employee_find_expense_voucher, NULL, NULL, NULL }, + { "EmployeeProcessPaymentAction", gnc_plugin_business_cmd_employee_process_payment, NULL, NULL, NULL }, + + { "BusinessLinkedDocsAction", gnc_plugin_business_cmd_doclink, NULL, NULL, NULL }, + { "TaxTablesOpenAction", gnc_plugin_business_cmd_tax_tables, NULL, NULL, NULL }, + { "BillingTermsOpenAction", gnc_plugin_business_cmd_billing_terms, NULL, NULL, NULL }, + { "BillsDueReminderOpenAction", gnc_plugin_business_cmd_bills_due_reminder, NULL, NULL, NULL }, + { "InvoicesDueReminderOpenAction", gnc_plugin_business_cmd_invoices_due_reminder, NULL, NULL, NULL }, + + { "BusinessTestAction", NULL, NULL, NULL, NULL }, + { "BusinessTestSearchAction", gnc_plugin_business_cmd_test_search, NULL, NULL, NULL }, + { "BusinessTestInitDataAction", gnc_plugin_business_cmd_test_init_data, NULL, NULL, NULL }, + { "ToolbarNewInvoiceAction", gnc_plugin_business_cmd_customer_new_invoice, NULL, NULL, NULL }, + { "RegisterAssignPayment", gnc_plugin_business_cmd_assign_payment, NULL, NULL, NULL }, +//FIXMEb { "RegisterEditPayment", gnc_plugin_business_cmd_assign_payment, NULL, NULL, NULL }, +}; +/** The number of actions provided by this plugin. */ +static guint gnc_plugin_n_actions = G_N_ELEMENTS(gnc_plugin_actions); + +static GncDisplayItem gnc_plugin_display_items [] = { /* Toplevel */ - { "BusinessAction", NULL, N_("_Business"), NULL, NULL, NULL }, + { "BusinessAction", NULL, N_("_Business"), NULL, NULL }, /* Customer submenu */ - { "CustomerMenuAction", NULL, N_("_Customer"), NULL, NULL, NULL }, + { "CustomerMenuAction", NULL, N_("_Customer"), NULL, NULL }, { "CustomerOverviewPageAction", NULL, N_("Customers Overview"), NULL, - N_("Open a Customer overview page"), - G_CALLBACK (gnc_plugin_business_cmd_customer_page) + N_("Open a Customer overview page") }, { "CustomerNewCustomerOpenAction", NULL, N_("_New Customer..."), NULL, - N_("Open the New Customer dialog"), - G_CALLBACK (gnc_plugin_business_cmd_customer_new_customer) + N_("Open the New Customer dialog") }, { "CustomerFindCustomerOpenAction", NULL, N_("_Find Customer..."), NULL, - N_("Open the Find Customer dialog"), - G_CALLBACK (gnc_plugin_business_cmd_customer_find_customer) + N_("Open the Find Customer dialog") }, { "CustomerNewInvoiceOpenAction", NULL, N_("New _Invoice..."), NULL, - N_("Open the New Invoice dialog"), - G_CALLBACK (gnc_plugin_business_cmd_customer_new_invoice) + N_("Open the New Invoice dialog") }, { "CustomerFindInvoiceOpenAction", NULL, N_("Find In_voice..."), NULL, - N_("Open the Find Invoice dialog"), - G_CALLBACK (gnc_plugin_business_cmd_customer_find_invoice) + N_("Open the Find Invoice dialog") }, { "CustomerNewJobOpenAction", NULL, N_("New _Job..."), NULL, - N_("Open the New Job dialog"), - G_CALLBACK (gnc_plugin_business_cmd_customer_new_job) + N_("Open the New Job dialog") }, { "CustomerFindJobOpenAction", NULL, N_("Find Jo_b..."), NULL, - N_("Open the Find Job dialog"), - G_CALLBACK (gnc_plugin_business_cmd_customer_find_job) + N_("Open the Find Job dialog") }, { "CustomerProcessPaymentAction", NULL, N_("_Process Payment..."), NULL, - N_("Open the Process Payment dialog"), - G_CALLBACK (gnc_plugin_business_cmd_customer_process_payment) + N_("Open the Process Payment dialog") }, /* Vendor submenu */ { "VendorOverviewPageAction", NULL, N_("Vendors Overview"), NULL, - N_("Open a Vendor overview page"), - G_CALLBACK (gnc_plugin_business_cmd_vendor_page) + N_("Open a Vendor overview page") }, - { "VendorMenuAction", NULL, N_("_Vendor"), NULL, NULL, NULL }, + { "VendorMenuAction", NULL, N_("_Vendor"), NULL, NULL }, { "VendorNewVendorOpenAction", NULL, N_("_New Vendor..."), NULL, - N_("Open the New Vendor dialog"), - G_CALLBACK (gnc_plugin_business_cmd_vendor_new_vendor) + N_("Open the New Vendor dialog") }, { "VendorFindVendorOpenAction", NULL, N_("_Find Vendor..."), NULL, - N_("Open the Find Vendor dialog"), - G_CALLBACK (gnc_plugin_business_cmd_vendor_find_vendor) + N_("Open the Find Vendor dialog") }, { "VendorNewBillOpenAction", NULL, N_("New _Bill..."), NULL, - N_("Open the New Bill dialog"), - G_CALLBACK (gnc_plugin_business_cmd_vendor_new_bill) + N_("Open the New Bill dialog") }, { "VendorFindBillOpenAction", NULL, N_("Find Bi_ll..."), NULL, - N_("Open the Find Bill dialog"), - G_CALLBACK (gnc_plugin_business_cmd_vendor_find_bill) + N_("Open the Find Bill dialog") }, { "VendorNewJobOpenAction", NULL, N_("New _Job..."), NULL, - N_("Open the New Job dialog"), - G_CALLBACK (gnc_plugin_business_cmd_vendor_new_job) + N_("Open the New Job dialog") }, { "VendorFindJobOpenAction", NULL, N_("Find Jo_b..."), NULL, - N_("Open the Find Job dialog"), - G_CALLBACK (gnc_plugin_business_cmd_vendor_find_job) + N_("Open the Find Job dialog") }, { "VendorProcessPaymentAction", NULL, N_("_Process Payment..."), NULL, - N_("Open the Process Payment dialog"), - G_CALLBACK (gnc_plugin_business_cmd_vendor_process_payment) + N_("Open the Process Payment dialog") }, /* Employee submenu */ { "EmployeeOverviewPageAction", NULL, N_("Employees Overview"), NULL, - N_("Open a Employee overview page"), - G_CALLBACK (gnc_plugin_business_cmd_employee_page) + N_("Open a Employee overview page") }, - { "EmployeeMenuAction", NULL, N_("_Employee"), NULL, NULL, NULL }, + { "EmployeeMenuAction", NULL, N_("_Employee"), NULL, NULL }, { "EmployeeNewEmployeeOpenAction", NULL, N_("_New Employee..."), NULL, - N_("Open the New Employee dialog"), - G_CALLBACK (gnc_plugin_business_cmd_employee_new_employee) + N_("Open the New Employee dialog") }, { "EmployeeFindEmployeeOpenAction", NULL, N_("_Find Employee..."), NULL, - N_("Open the Find Employee dialog"), - G_CALLBACK (gnc_plugin_business_cmd_employee_find_employee) + N_("Open the Find Employee dialog") }, { "EmployeeNewExpenseVoucherOpenAction", NULL, N_("New _Expense Voucher..."), NULL, - N_("Open the New Expense Voucher dialog"), - G_CALLBACK (gnc_plugin_business_cmd_employee_new_expense_voucher) + N_("Open the New Expense Voucher dialog") }, { "EmployeeFindExpenseVoucherOpenAction", NULL, N_("Find Expense _Voucher..."), NULL, - N_("Open the Find Expense Voucher dialog"), - G_CALLBACK (gnc_plugin_business_cmd_employee_find_expense_voucher) + N_("Open the Find Expense Voucher dialog") }, { "EmployeeProcessPaymentAction", NULL, N_("_Process Payment..."), NULL, - N_("Open the Process Payment dialog"), - G_CALLBACK (gnc_plugin_business_cmd_employee_process_payment) + N_("Open the Process Payment dialog") }, /* Other menu items */ { "BusinessLinkedDocsAction", NULL, N_("Business Linked Documents"), NULL, - N_("View all Linked Business Documents"), - G_CALLBACK (gnc_plugin_business_cmd_doclink) + N_("View all Linked Business Documents") }, { "TaxTablesOpenAction", NULL, N_("Sales _Tax Table"), NULL, - N_("View and edit the list of Sales Tax Tables (GST/VAT)"), - G_CALLBACK (gnc_plugin_business_cmd_tax_tables) + N_("View and edit the list of Sales Tax Tables (GST/VAT)") }, { "BillingTermsOpenAction", NULL, N_("_Billing Terms Editor"), NULL, - N_("View and edit the list of Billing Terms"), - G_CALLBACK (gnc_plugin_business_cmd_billing_terms) + N_("View and edit the list of Billing Terms") }, { "BillsDueReminderOpenAction", NULL, N_("Bills _Due Reminder"), NULL, - N_("Open the Bills Due Reminder dialog"), - G_CALLBACK (gnc_plugin_business_cmd_bills_due_reminder) + N_("Open the Bills Due Reminder dialog") }, { "InvoicesDueReminderOpenAction", NULL, N_("Invoices _Due Reminder"), NULL, - N_("Open the Invoices Due Reminder dialog"), - G_CALLBACK (gnc_plugin_business_cmd_invoices_due_reminder) + N_("Open the Invoices Due Reminder dialog") }, - { "ExportMenuAction", NULL, N_("E_xport"), NULL, NULL, NULL }, + { "ExportMenuAction", NULL, N_("E_xport"), NULL, NULL }, /* Extensions Menu */ - { "BusinessTestAction", NULL, N_("_Business"), NULL, NULL, NULL }, + { "BusinessTestAction", NULL, N_("_Business"), NULL, NULL }, { "BusinessTestSearchAction", NULL, N_("Test Search Dialog"), NULL, - N_("Test Search Dialog"), - G_CALLBACK (gnc_plugin_business_cmd_test_search) + N_("Test Search Dialog") }, { "BusinessTestInitDataAction", NULL, N_("Initialize Test Data"), NULL, - N_("Initialize Test Data"), - G_CALLBACK (gnc_plugin_business_cmd_test_init_data) + N_("Initialize Test Data") }, /* Toolbar */ { "ToolbarNewInvoiceAction", GNC_ICON_INVOICE_NEW, N_("New _Invoice..."), NULL, - N_("Open the New Invoice dialog"), - G_CALLBACK (gnc_plugin_business_cmd_customer_new_invoice) + N_("Open the New Invoice dialog") }, /* Register popup menu */ { "RegisterAssignPayment", NULL, N_("Assign as payment..."), NULL, - N_("Assign the selected transaction as payment"), - G_CALLBACK (gnc_plugin_business_cmd_assign_payment) + N_("Assign the selected transaction as payment") }, { "RegisterEditPayment", NULL, N_("Edit payment..."), NULL, - N_("Edit the payment this transaction is a part of"), - G_CALLBACK (gnc_plugin_business_cmd_assign_payment) + N_("Edit the payment this transaction is a part of") }, }; -static guint gnc_plugin_n_actions = G_N_ELEMENTS (gnc_plugin_actions); - +/** The number of display items provided by this plugin. */ +static guint gnc_plugin_n_display_items = G_N_ELEMENTS(gnc_plugin_display_items); /************************************************************ * Plugin Function Implementation * @@ -387,10 +372,12 @@ gnc_plugin_business_class_init (GncPluginBusinessClass *klass) plugin_class->add_to_window = gnc_plugin_business_add_to_window; /* widget addition/removal */ - plugin_class->actions_name = PLUGIN_ACTIONS_NAME; - plugin_class->actions = gnc_plugin_actions; - plugin_class->n_actions = gnc_plugin_n_actions; - plugin_class->ui_filename = PLUGIN_UI_FILENAME; + plugin_class->actions_name = PLUGIN_ACTIONS_NAME; + plugin_class->actionsb = gnc_plugin_actions; + plugin_class->n_actionsb = gnc_plugin_n_actions; + plugin_class->display_items = gnc_plugin_display_items; + plugin_class->n_display_items = gnc_plugin_n_display_items; + plugin_class->ui_filename = PLUGIN_UI_FILENAME; } static void @@ -432,9 +419,11 @@ gnc_plugin_business_get_window() ************************************************************/ static void -gnc_plugin_business_cmd_customer_page (GtkAction *action, - GncMainWindowActionData *mw) +gnc_plugin_business_cmd_customer_page (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *mw = user_data; GncPluginPage *page; g_return_if_fail (mw != NULL); @@ -445,9 +434,12 @@ gnc_plugin_business_cmd_customer_page (GtkAction *action, } static void -gnc_plugin_business_cmd_customer_new_customer (GtkAction *action, - GncMainWindowActionData *mw) +gnc_plugin_business_cmd_customer_new_customer (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *mw = user_data; + g_return_if_fail (mw != NULL); g_return_if_fail (GNC_IS_PLUGIN_BUSINESS (mw->data)); @@ -455,9 +447,11 @@ gnc_plugin_business_cmd_customer_new_customer (GtkAction *action, } static void -gnc_plugin_business_cmd_customer_find_customer (GtkAction *action, - GncMainWindowActionData *mw) +gnc_plugin_business_cmd_customer_find_customer (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *mw = user_data; GncPluginBusiness *plugin; GncPluginBusinessPrivate *priv; GncCustomer*customer; @@ -472,9 +466,11 @@ gnc_plugin_business_cmd_customer_find_customer (GtkAction *action, } static void -gnc_plugin_business_cmd_customer_new_invoice (GtkAction *action, - GncMainWindowActionData *mw) +gnc_plugin_business_cmd_customer_new_invoice (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *mw = user_data; GncPluginBusiness *plugin; GncPluginBusinessPrivate *priv; @@ -488,9 +484,11 @@ gnc_plugin_business_cmd_customer_new_invoice (GtkAction *action, } static void -gnc_plugin_business_cmd_customer_find_invoice (GtkAction *action, - GncMainWindowActionData *mw) +gnc_plugin_business_cmd_customer_find_invoice (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *mw = user_data; GncPluginBusiness *plugin; GncPluginBusinessPrivate *priv; @@ -504,9 +502,11 @@ gnc_plugin_business_cmd_customer_find_invoice (GtkAction *action, } static void -gnc_plugin_business_cmd_customer_new_job (GtkAction *action, - GncMainWindowActionData *mw) +gnc_plugin_business_cmd_customer_new_job (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *mw = user_data; GncPluginBusiness *plugin; GncPluginBusinessPrivate *priv; @@ -519,9 +519,11 @@ gnc_plugin_business_cmd_customer_new_job (GtkAction *action, } static void -gnc_plugin_business_cmd_customer_find_job (GtkAction *action, - GncMainWindowActionData *mw) +gnc_plugin_business_cmd_customer_find_job (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *mw = user_data; GncPluginBusiness *plugin; GncPluginBusinessPrivate *priv; @@ -534,9 +536,11 @@ gnc_plugin_business_cmd_customer_find_job (GtkAction *action, } static void -gnc_plugin_business_cmd_customer_process_payment (GtkAction *action, - GncMainWindowActionData *mw) +gnc_plugin_business_cmd_customer_process_payment (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *mw = user_data; GncPluginBusiness *plugin; GncPluginBusinessPrivate *priv; @@ -549,9 +553,11 @@ gnc_plugin_business_cmd_customer_process_payment (GtkAction *action, } static void -gnc_plugin_business_cmd_vendor_page (GtkAction *action, - GncMainWindowActionData *mw) +gnc_plugin_business_cmd_vendor_page (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *mw = user_data; GncPluginPage *page; g_return_if_fail (mw != NULL); @@ -562,9 +568,11 @@ gnc_plugin_business_cmd_vendor_page (GtkAction *action, } static void -gnc_plugin_business_cmd_vendor_new_vendor (GtkAction *action, - GncMainWindowActionData *mw) +gnc_plugin_business_cmd_vendor_new_vendor (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *mw = user_data; g_return_if_fail (mw != NULL); g_return_if_fail (GNC_IS_PLUGIN_BUSINESS (mw->data)); @@ -572,9 +580,11 @@ gnc_plugin_business_cmd_vendor_new_vendor (GtkAction *action, } static void -gnc_plugin_business_cmd_vendor_find_vendor (GtkAction *action, - GncMainWindowActionData *mw) +gnc_plugin_business_cmd_vendor_find_vendor (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *mw = user_data; GncPluginBusiness *plugin; GncPluginBusinessPrivate *priv; GncVendor *vendor; @@ -589,9 +599,11 @@ gnc_plugin_business_cmd_vendor_find_vendor (GtkAction *action, } static void -gnc_plugin_business_cmd_vendor_new_bill (GtkAction *action, - GncMainWindowActionData *mw) +gnc_plugin_business_cmd_vendor_new_bill (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *mw = user_data; GncPluginBusiness *plugin; GncPluginBusinessPrivate *priv; @@ -605,9 +617,11 @@ gnc_plugin_business_cmd_vendor_new_bill (GtkAction *action, } static void -gnc_plugin_business_cmd_vendor_find_bill (GtkAction *action, - GncMainWindowActionData *mw) +gnc_plugin_business_cmd_vendor_find_bill (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *mw = user_data; GncPluginBusiness *plugin; GncPluginBusinessPrivate *priv; @@ -621,9 +635,11 @@ gnc_plugin_business_cmd_vendor_find_bill (GtkAction *action, } static void -gnc_plugin_business_cmd_vendor_new_job (GtkAction *action, - GncMainWindowActionData *mw) +gnc_plugin_business_cmd_vendor_new_job (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *mw = user_data; GncPluginBusiness *plugin; GncPluginBusinessPrivate *priv; @@ -636,9 +652,11 @@ gnc_plugin_business_cmd_vendor_new_job (GtkAction *action, } static void -gnc_plugin_business_cmd_vendor_find_job (GtkAction *action, - GncMainWindowActionData *mw) +gnc_plugin_business_cmd_vendor_find_job (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *mw = user_data; GncPluginBusiness *plugin; GncPluginBusinessPrivate *priv; @@ -651,9 +669,11 @@ gnc_plugin_business_cmd_vendor_find_job (GtkAction *action, } static void -gnc_plugin_business_cmd_vendor_process_payment (GtkAction *action, - GncMainWindowActionData *mw) +gnc_plugin_business_cmd_vendor_process_payment (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *mw = user_data; GncPluginBusiness *plugin; GncPluginBusinessPrivate *priv; @@ -666,9 +686,11 @@ gnc_plugin_business_cmd_vendor_process_payment (GtkAction *action, } static void -gnc_plugin_business_cmd_employee_page (GtkAction *action, - GncMainWindowActionData *mw) +gnc_plugin_business_cmd_employee_page (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *mw = user_data; GncPluginPage *page; g_return_if_fail (mw != NULL); @@ -679,9 +701,11 @@ gnc_plugin_business_cmd_employee_page (GtkAction *action, } static void -gnc_plugin_business_cmd_employee_new_employee (GtkAction *action, - GncMainWindowActionData *mw) +gnc_plugin_business_cmd_employee_new_employee (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *mw = user_data; g_return_if_fail (mw != NULL); g_return_if_fail (GNC_IS_PLUGIN_BUSINESS (mw->data)); @@ -689,9 +713,11 @@ gnc_plugin_business_cmd_employee_new_employee (GtkAction *action, } static void -gnc_plugin_business_cmd_employee_find_employee (GtkAction *action, - GncMainWindowActionData *mw) +gnc_plugin_business_cmd_employee_find_employee (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *mw = user_data; GncPluginBusiness *plugin; GncPluginBusinessPrivate *priv; GncEmployee *employee; @@ -706,9 +732,11 @@ gnc_plugin_business_cmd_employee_find_employee (GtkAction *action, } static void -gnc_plugin_business_cmd_employee_new_expense_voucher (GtkAction *action, - GncMainWindowActionData *mw) +gnc_plugin_business_cmd_employee_new_expense_voucher (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *mw = user_data; GncPluginBusiness *plugin; GncPluginBusinessPrivate *priv; @@ -722,9 +750,11 @@ gnc_plugin_business_cmd_employee_new_expense_voucher (GtkAction *action, } static void -gnc_plugin_business_cmd_employee_find_expense_voucher (GtkAction *action, - GncMainWindowActionData *mw) +gnc_plugin_business_cmd_employee_find_expense_voucher (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *mw = user_data; GncPluginBusiness *plugin; GncPluginBusinessPrivate *priv; @@ -738,9 +768,11 @@ gnc_plugin_business_cmd_employee_find_expense_voucher (GtkAction *action, } static void -gnc_plugin_business_cmd_employee_process_payment (GtkAction *action, - GncMainWindowActionData *mw) +gnc_plugin_business_cmd_employee_process_payment (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *mw = user_data; GncPluginBusiness *plugin; GncPluginBusinessPrivate *priv; @@ -753,9 +785,11 @@ gnc_plugin_business_cmd_employee_process_payment (GtkAction *action, } static void -gnc_plugin_business_cmd_doclink (GtkAction *action, - GncMainWindowActionData *mw) +gnc_plugin_business_cmd_doclink (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *mw = user_data; g_return_if_fail (mw != NULL); g_return_if_fail (GNC_IS_PLUGIN_BUSINESS (mw->data)); @@ -763,9 +797,11 @@ gnc_plugin_business_cmd_doclink (GtkAction *action, } static void -gnc_plugin_business_cmd_tax_tables (GtkAction *action, - GncMainWindowActionData *mw) +gnc_plugin_business_cmd_tax_tables (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *mw = user_data; g_return_if_fail (mw != NULL); g_return_if_fail (GNC_IS_PLUGIN_BUSINESS (mw->data)); @@ -773,9 +809,11 @@ gnc_plugin_business_cmd_tax_tables (GtkAction *action, } static void -gnc_plugin_business_cmd_billing_terms (GtkAction *action, - GncMainWindowActionData *mw) +gnc_plugin_business_cmd_billing_terms (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *mw = user_data; g_return_if_fail (mw != NULL); g_return_if_fail (GNC_IS_PLUGIN_BUSINESS (mw->data)); @@ -784,9 +822,11 @@ gnc_plugin_business_cmd_billing_terms (GtkAction *action, static void -gnc_plugin_business_cmd_bills_due_reminder (GtkAction *action, - GncMainWindowActionData *mw) +gnc_plugin_business_cmd_bills_due_reminder (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *mw = user_data; g_return_if_fail (mw != NULL); g_return_if_fail (GNC_IS_PLUGIN_BUSINESS (mw->data)); @@ -795,9 +835,11 @@ gnc_plugin_business_cmd_bills_due_reminder (GtkAction *action, static void -gnc_plugin_business_cmd_invoices_due_reminder (GtkAction *action, - GncMainWindowActionData *mw) +gnc_plugin_business_cmd_invoices_due_reminder (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *mw = user_data; g_return_if_fail (mw != NULL); g_return_if_fail (GNC_IS_PLUGIN_BUSINESS (mw->data)); @@ -805,15 +847,18 @@ gnc_plugin_business_cmd_invoices_due_reminder (GtkAction *action, } static void -gnc_plugin_business_cmd_test_search (GtkAction *action, - GncMainWindowActionData *data) +gnc_plugin_business_cmd_test_search (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *mw = user_data; gnc_search_dialog_test(); } -static void gnc_business_assign_payment (GtkWindow *parent, - Transaction *trans, - GncOwner *owner) +static void +gnc_business_assign_payment (GtkWindow *parent, + Transaction *trans, + GncOwner *owner) { g_return_if_fail(trans); @@ -825,9 +870,12 @@ static void gnc_business_assign_payment (GtkWindow *parent, gnc_ui_payment_new_with_txn(parent, owner, trans); } -static void gnc_plugin_business_cmd_assign_payment (GtkAction *action, - GncMainWindowActionData *mw) +static void +gnc_plugin_business_cmd_assign_payment (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *mw = user_data; GncPluginBusiness *plugin_business; GncPluginBusinessPrivate *plugin_business_priv; GncPluginPage *plugin_page; @@ -929,24 +977,28 @@ gnc_plugin_business_update_menus (GncPluginPage *plugin_page) } -static void gnc_plugin_business_main_window_page_changed(GncMainWindow *window, - GncPluginPage *page, - gpointer user_data) +static void +gnc_plugin_business_main_window_page_changed (GncMainWindow *window, + GncPluginPage *page, + gpointer user_data) { gnc_plugin_business_update_menus(page); update_inactive_actions(page); } -void gnc_plugin_business_split_reg_ui_update (GncPluginPage *plugin_page) +void +gnc_plugin_business_split_reg_ui_update (GncPluginPage *plugin_page) { gnc_plugin_business_main_window_page_changed(NULL, plugin_page, NULL); } static void -gnc_plugin_business_cmd_test_init_data (GtkAction *action, - GncMainWindowActionData *data) +gnc_plugin_business_cmd_test_init_data (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *mw = user_data; QofBook *book = gnc_get_current_book(); GncCustomer *customer = gncCustomerCreate(book); GncAddress *address = gncCustomerGetAddr(customer); @@ -1011,7 +1063,7 @@ gnc_plugin_business_cmd_test_init_data (GtkAction *action, gnc_account_append_child(root, tax_acct); // Launch the invoice editor - gnc_ui_invoice_edit (GTK_WINDOW (data->window), invoice); + gnc_ui_invoice_edit (GTK_WINDOW (mw->window), invoice); } /* This is the list of actions which are switched inactive in a read-only book. */ @@ -1035,7 +1087,8 @@ static const gchar* readonly_inactive_actions[] = NULL }; -static void update_inactive_actions(GncPluginPage *plugin_page) +static void +update_inactive_actions (GncPluginPage *plugin_page) { GncMainWindow *window; GtkActionGroup *action_group; @@ -1071,7 +1124,8 @@ static const char* extra_toolbar_actions[] = /* Bind the visibility of the extra toolbar buttons to the * enable_toolbuttons preference. */ -static void bind_toolbuttons_visibility (GncMainWindow *mainwindow) +static void +bind_toolbuttons_visibility (GncMainWindow *mainwindow) { GtkActionGroup *action_group; const char **iter; @@ -1080,16 +1134,15 @@ static void bind_toolbuttons_visibility (GncMainWindow *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); +//FIXMEb action_group = gnc_main_window_get_action_group (mainwindow, PLUGIN_ACTIONS_NAME); +// g_assert(action_group); - for (iter = extra_toolbar_actions; *iter; ++iter) - { +// 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"); - } +// 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"); +// } } /** @@ -1098,15 +1151,16 @@ static void bind_toolbuttons_visibility (GncMainWindow *mainwindow) * * Update the toolbar button visibility each time our plugin is added * to a new GncMainWindow. */ -static void gnc_plugin_business_add_to_window (GncPlugin *plugin, - GncMainWindow *mainwindow, - GQuark type) +static void +gnc_plugin_business_add_to_window (GncPlugin *plugin, + GncMainWindow *mainwindow, + GQuark type) { bind_toolbuttons_visibility (mainwindow); - g_signal_connect(mainwindow, "page_changed", - G_CALLBACK(gnc_plugin_business_main_window_page_changed), - plugin); + g_signal_connect (mainwindow, "page_changed", + G_CALLBACK(gnc_plugin_business_main_window_page_changed), + plugin); } static const char* invoice_printreport_values[] = @@ -1123,7 +1177,8 @@ static const char* invoice_printreport_values[] = NULL }; -const char *gnc_plugin_business_get_invoice_printreport(void) +const char * +gnc_plugin_business_get_invoice_printreport (void) { int value = gnc_prefs_get_int (GNC_PREFS_GROUP_INVOICE, GNC_PREF_INV_PRINT_RPT); if (value >= 0 && value < 4) diff --git a/gnucash/gnome/gnc-plugin-register.c b/gnucash/gnome/gnc-plugin-register.c index 4d6df65f0e..6cfdf995f9 100644 --- a/gnucash/gnome/gnc-plugin-register.c +++ b/gnucash/gnome/gnc-plugin-register.c @@ -42,20 +42,27 @@ static void gnc_plugin_register_add_to_window (GncPlugin *plugin, GncMainWindow static void gnc_plugin_register_remove_from_window (GncPlugin *plugin, GncMainWindow *window, GQuark type); /* Command callbacks */ -static void gnc_plugin_register_cmd_general_ledger (GtkAction *action, GncMainWindowActionData *data); +static void gnc_plugin_register_cmd_general_ledger (GSimpleAction *simple, GVariant *parameter, gpointer user_data); #define PLUGIN_ACTIONS_NAME "gnc-plugin-register-actions" -#define PLUGIN_UI_FILENAME "gnc-plugin-register-ui.xml" +#define PLUGIN_UI_FILENAME "gnc-plugin-register.ui" -static GtkActionEntry gnc_plugin_actions [] = +static GActionEntry gnc_plugin_actions [] = +{ + { "ToolsGeneralJournalAction", gnc_plugin_register_cmd_general_ledger, NULL, NULL, NULL }, +}; +/** The number of actions provided by this plugin. */ +static guint gnc_plugin_n_actions = G_N_ELEMENTS(gnc_plugin_actions); + +static GncDisplayItem gnc_plugin_display_items [] = { { "ToolsGeneralJournalAction", NULL, N_("_General Journal"), NULL, - N_("Open general journal window"), - G_CALLBACK (gnc_plugin_register_cmd_general_ledger) + N_("Open general journal window") }, }; -static guint gnc_plugin_n_actions = G_N_ELEMENTS (gnc_plugin_actions); +/** The number of display items provided by this plugin. */ +static guint gnc_plugin_n_display_items = G_N_ELEMENTS(gnc_plugin_display_items); typedef struct GncPluginRegisterPrivate { @@ -133,10 +140,12 @@ gnc_plugin_register_class_init (GncPluginRegisterClass *klass) gnc_plugin_register_remove_from_window; /* widget addition/removal */ - plugin_class->actions_name = PLUGIN_ACTIONS_NAME; - plugin_class->actions = gnc_plugin_actions; - plugin_class->n_actions = gnc_plugin_n_actions; - plugin_class->ui_filename = PLUGIN_UI_FILENAME; + plugin_class->actions_name = PLUGIN_ACTIONS_NAME; + plugin_class->actionsb = gnc_plugin_actions; + plugin_class->n_actionsb = gnc_plugin_n_actions; + plugin_class->display_items = gnc_plugin_display_items; + plugin_class->n_display_items = gnc_plugin_n_display_items; + plugin_class->ui_filename = PLUGIN_UI_FILENAME; } static void @@ -206,9 +215,11 @@ gnc_plugin_register_remove_from_window (GncPlugin *plugin, ************************************************************/ static void -gnc_plugin_register_cmd_general_ledger (GtkAction *action, - GncMainWindowActionData *data) +gnc_plugin_register_cmd_general_ledger (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *data = user_data; GncPluginPage *page; g_return_if_fail (data != NULL); diff --git a/gnucash/gnome/gnc-plugin-report-system.c b/gnucash/gnome/gnc-plugin-report-system.c index 621f001317..35de4b19f4 100644 --- a/gnucash/gnome/gnc-plugin-report-system.c +++ b/gnucash/gnome/gnc-plugin-report-system.c @@ -43,24 +43,29 @@ static void gnc_plugin_report_system_finalize (GObject *object); /* Command callbacks */ -static void gnc_plugin_report_system_cmd_edit_style_sheet (GtkAction *action, - GncMainWindowActionData *data); +static void gnc_plugin_report_system_cmd_edit_style_sheet (GSimpleAction *simple, GVariant *parameter, gpointer user_data); #define PLUGIN_ACTIONS_NAME "gnc-plugin-report-system-actions" -#define PLUGIN_UI_FILENAME "gnc-plugin-report-system-ui.xml" +#define PLUGIN_UI_FILENAME "gnc-plugin-report-system.ui" -static GtkActionEntry gnc_plugin_actions [] = +static GActionEntry gnc_plugin_actions [] = +{ + { "EditStyleSheetsAction", gnc_plugin_report_system_cmd_edit_style_sheet, NULL, NULL, NULL }, +}; +/** The number of actions provided by this plugin. */ +static guint gnc_plugin_n_actions = G_N_ELEMENTS (gnc_plugin_actions); + +static GncDisplayItem gnc_plugin_display_items [] = { /* Menu Items */ { "EditStyleSheetsAction", NULL, N_("St_yle Sheets"), NULL, - N_("Edit report style sheets"), - G_CALLBACK (gnc_plugin_report_system_cmd_edit_style_sheet) + N_("Edit report style sheets") }, }; -static guint gnc_plugin_n_actions = G_N_ELEMENTS (gnc_plugin_actions); - +/** The number of display items provided by this plugin. */ +static guint gnc_plugin_n_display_items = G_N_ELEMENTS (gnc_plugin_display_items); typedef struct GncPluginReportSystemPrivate { @@ -92,10 +97,12 @@ gnc_plugin_report_system_class_init (GncPluginReportSystemClass *klass) plugin_class->plugin_name = GNC_PLUGIN_REPORT_SYSTEM_NAME; /* widget addition/removal */ - plugin_class->actions_name = PLUGIN_ACTIONS_NAME; - plugin_class->actions = gnc_plugin_actions; - plugin_class->n_actions = gnc_plugin_n_actions; - plugin_class->ui_filename = PLUGIN_UI_FILENAME; + plugin_class->actions_name = PLUGIN_ACTIONS_NAME; + plugin_class->actionsb = gnc_plugin_actions; + plugin_class->n_actionsb = gnc_plugin_n_actions; + plugin_class->display_items = gnc_plugin_display_items; + plugin_class->n_display_items = gnc_plugin_n_display_items; + plugin_class->ui_filename = PLUGIN_UI_FILENAME; } static void @@ -116,10 +123,12 @@ gnc_plugin_report_system_finalize (GObject *object) ************************************************************/ static void -gnc_plugin_report_system_cmd_edit_style_sheet (GtkAction *action, - GncMainWindowActionData *data) +gnc_plugin_report_system_cmd_edit_style_sheet (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { - gnc_style_sheet_dialog_open(GTK_WINDOW (data->window)); + GncMainWindowActionData *data = user_data; + gnc_style_sheet_dialog_open (GTK_WINDOW(data->window)); } /************************************************************ diff --git a/gnucash/import-export/aqb/gnc-plugin-aqbanking.c b/gnucash/import-export/aqb/gnc-plugin-aqbanking.c index 1cbfc7ac00..b052cc95ff 100644 --- a/gnucash/import-export/aqb/gnc-plugin-aqbanking.c +++ b/gnucash/import-export/aqb/gnc-plugin-aqbanking.c @@ -67,65 +67,84 @@ static void gnc_plugin_ab_account_selected(GncPluginPage *plugin_page, Account * static Account *main_window_to_account(GncMainWindow *window); /* Command callbacks */ -static void gnc_plugin_ab_cmd_setup(GtkAction *action, GncMainWindowActionData *data); -static void gnc_plugin_ab_cmd_get_balance(GtkAction *action, GncMainWindowActionData *data); -static void gnc_plugin_ab_cmd_get_transactions(GtkAction *action, GncMainWindowActionData *data); -static void gnc_plugin_ab_cmd_issue_sepatransaction(GtkAction *action, GncMainWindowActionData *data); -static void gnc_plugin_ab_cmd_issue_sepainternaltransaction(GtkAction *action, GncMainWindowActionData *data); -static void gnc_plugin_ab_cmd_issue_inttransaction(GtkAction *action, GncMainWindowActionData *data); -static void gnc_plugin_ab_cmd_issue_sepa_direct_debit(GtkAction *action, GncMainWindowActionData *data); -static void gnc_plugin_ab_cmd_view_logwindow(GtkToggleAction *action, GncMainWindow *window); -static void gnc_plugin_ab_cmd_aqb_import(GtkAction *action, GncMainWindowActionData *data); +static void gnc_plugin_ab_cmd_setup (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_ab_cmd_get_balance (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_ab_cmd_get_transactions (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_ab_cmd_issue_sepatransaction (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_ab_cmd_issue_sepainternaltransaction (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_ab_cmd_issue_inttransaction (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_ab_cmd_issue_sepa_direct_debit (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_ab_cmd_view_logwindow (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_ab_cmd_aqb_import (GSimpleAction *simple, GVariant *parameter, gpointer user_data); #define PLUGIN_ACTIONS_NAME "gnc-plugin-aqbanking-actions" -#define PLUGIN_UI_FILENAME "gnc-plugin-aqbanking-ui.xml" +#define PLUGIN_UI_FILENAME "gnc-plugin-aqbanking.ui" #define MENU_TOGGLE_ACTION_AB_VIEW_LOGWINDOW "ABViewLogwindowAction" +static void +change_state_logwindow (GSimpleAction *simple, + GVariant *state, + gpointer user_data) +{ + g_simple_action_set_state (simple, state); +} -static GtkActionEntry gnc_plugin_actions [] = +static GActionEntry gnc_plugin_actions [] = +{ + { "OnlineActionsAction", NULL, NULL, NULL, NULL }, + { "ABSetupAction", gnc_plugin_ab_cmd_setup, NULL, NULL, NULL }, + { "ABGetBalanceAction", gnc_plugin_ab_cmd_get_balance, NULL, NULL, NULL }, + { "ABGetTransAction", gnc_plugin_ab_cmd_get_transactions, NULL, NULL, NULL }, + { "ABIssueSepaTransAction", gnc_plugin_ab_cmd_issue_sepatransaction, NULL, NULL, NULL }, + { "ABIssueSepaIntTransAction", gnc_plugin_ab_cmd_issue_sepainternaltransaction, NULL, NULL, NULL }, + { "ABIssueIntTransAction", gnc_plugin_ab_cmd_issue_inttransaction, NULL, NULL, NULL }, + { "ABIssueSepaDirectDebitAction", gnc_plugin_ab_cmd_issue_sepa_direct_debit, NULL, NULL, NULL }, + { "Mt940ImportAction", gnc_plugin_ab_cmd_mt940_import, NULL, NULL, NULL }, + { "Mt942ImportAction", gnc_plugin_ab_cmd_mt942_import, NULL, NULL, NULL }, + { "DtausImportAction", gnc_plugin_ab_cmd_dtaus_import, NULL, NULL, NULL }, + { "DtausImportSendAction", gnc_plugin_ab_cmd_dtaus_importsend, NULL, NULL, NULL }, + { MENU_TOGGLE_ACTION_AB_VIEW_LOGWINDOW, gnc_plugin_ab_cmd_view_logwindow, NULL, "TRUE", change_state_logwindow }, +}; +/** The number of actions provided by this plugin. */ +static guint gnc_plugin_n_actions = G_N_ELEMENTS(gnc_plugin_actions); + +static GncDisplayItem gnc_plugin_display_items [] = { /* Menus */ - { "OnlineActionsAction", NULL, N_("_Online Actions"), NULL, NULL, NULL }, + { "OnlineActionsAction", NULL, N_("_Online Actions"), NULL, NULL }, /* Menu Items */ { "ABSetupAction", NULL, N_("_Online Banking Setup..."), NULL, - N_("Initial setup of Online Banking access (HBCI, or OFX DirectConnect, using AqBanking)"), - G_CALLBACK(gnc_plugin_ab_cmd_setup) + N_("Initial setup of Online Banking access (HBCI, or OFX DirectConnect, using AqBanking)") }, { "ABGetBalanceAction", NULL, N_("Get _Balance"), NULL, - N_("Get the account balance online through Online Banking"), - G_CALLBACK(gnc_plugin_ab_cmd_get_balance) + N_("Get the account balance online through Online Banking") }, { "ABGetTransAction", NULL, N_("Get _Transactions..."), NULL, - N_("Get the transactions online through Online Banking"), - G_CALLBACK(gnc_plugin_ab_cmd_get_transactions) + N_("Get the transactions online through Online Banking") }, { "ABIssueSepaTransAction", NULL, - /* Translators: https://en.wikipedia.org/wiki/Single_Euro_Payments_Area */ - N_("Issue _SEPA Transaction..."), NULL, - N_("Issue a new international European (SEPA) transaction online through Online Banking"), - G_CALLBACK(gnc_plugin_ab_cmd_issue_sepatransaction) + /* Translators: https://en.wikipedia.org/wiki/Single_Euro_Payments_Area */ + N_("Issue _SEPA Transaction..."), NULL, + N_("Issue a new international European (SEPA) transaction online through Online Banking") }, { "ABIssueSepaIntTransAction", NULL, N_("Issue SEPA I_nternal Transaction..."), NULL, - N_("Issue a new internal European (SEPA) transaction online through Online Banking"), - G_CALLBACK(gnc_plugin_ab_cmd_issue_sepainternaltransaction) + N_("Issue a new internal European (SEPA) transaction online through Online Banking") }, { "ABIssueIntTransAction", NULL, N_("_Internal Transaction..."), NULL, - N_("Issue a new bank-internal transaction online through Online Banking"), - G_CALLBACK(gnc_plugin_ab_cmd_issue_inttransaction) + N_("Issue a new bank-internal transaction online through Online Banking") }, { "ABIssueSepaDirectDebitAction", NULL, N_("Issue SEPA Direct _Debit..."), NULL, - N_("Issue a new international European (SEPA) direct debit note online through Online Banking"), - G_CALLBACK(gnc_plugin_ab_cmd_issue_sepa_direct_debit) + N_("Issue a new international European (SEPA) direct debit note online through Online Banking") }, /* File -> Import menu item */ @@ -134,19 +153,14 @@ static GtkActionEntry gnc_plugin_actions [] = NULL, N_("Import into GnuCash any file format supported by AQBanking."), G_CALLBACK(gnc_plugin_ab_cmd_aqb_import) }, -}; -static guint gnc_plugin_n_actions = G_N_ELEMENTS(gnc_plugin_actions); - -static GtkToggleActionEntry gnc_plugin_toggle_actions [] = -{ { MENU_TOGGLE_ACTION_AB_VIEW_LOGWINDOW, NULL, N_("Show _log window"), NULL, - N_("Show the online banking log window."), - G_CALLBACK(gnc_plugin_ab_cmd_view_logwindow), TRUE + N_("Show the online banking log window.") }, }; -static guint gnc_plugin_n_toggle_actions = G_N_ELEMENTS(gnc_plugin_toggle_actions); +/** The number of display items provided by this plugin. */ +static guint gnc_plugin_n_display_items = G_N_ELEMENTS(gnc_plugin_display_items); static const gchar *need_account_actions[] = { @@ -200,10 +214,10 @@ gnc_plugin_aqbanking_class_init(GncPluginAqBankingClass *klass) /* widget addition/removal */ plugin_class->actions_name = PLUGIN_ACTIONS_NAME; - plugin_class->actions = gnc_plugin_actions; - plugin_class->n_actions = gnc_plugin_n_actions; - plugin_class->toggle_actions = gnc_plugin_toggle_actions; - plugin_class->n_toggle_actions = gnc_plugin_n_toggle_actions; + plugin_class->actionsb = gnc_plugin_actions; + plugin_class->n_actionsb = gnc_plugin_n_actions; + plugin_class->display_items = gnc_plugin_display_items; + plugin_class->n_display_items = gnc_plugin_n_display_items; plugin_class->ui_filename = PLUGIN_UI_FILENAME; plugin_class->add_to_window = gnc_plugin_aqbanking_add_to_window; plugin_class->remove_from_window = gnc_plugin_aqbanking_remove_from_window; @@ -464,20 +478,26 @@ gnc_plugin_aqbanking_set_logwindow_visible(gboolean logwindow_visible) ************************************************************/ static void -gnc_plugin_ab_cmd_setup(GtkAction *action, GncMainWindowActionData *data) +gnc_plugin_ab_cmd_setup (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { - ENTER("action %p, main window data %p", action, data); + GncMainWindowActionData *data = user_data; + ENTER("action %p, main window data %p", simple, data); gnc_main_window = data->window; gnc_ab_initial_assistant(); LEAVE(" "); } static void -gnc_plugin_ab_cmd_get_balance(GtkAction *action, GncMainWindowActionData *data) +gnc_plugin_ab_cmd_get_balance (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *data = user_data; Account *account; - ENTER("action %p, main window data %p", action, data); + ENTER("action %p, main window data %p", simple, data); account = main_window_to_account(data->window); if (account == NULL) { @@ -493,12 +513,14 @@ gnc_plugin_ab_cmd_get_balance(GtkAction *action, GncMainWindowActionData *data) } static void -gnc_plugin_ab_cmd_get_transactions(GtkAction *action, - GncMainWindowActionData *data) +gnc_plugin_ab_cmd_get_transactions (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *data = user_data; Account *account; - ENTER("action %p, main window data %p", action, data); + ENTER("action %p, main window data %p", simple, data); account = main_window_to_account(data->window); if (account == NULL) { @@ -514,12 +536,14 @@ gnc_plugin_ab_cmd_get_transactions(GtkAction *action, } static void -gnc_plugin_ab_cmd_issue_sepatransaction(GtkAction *action, - GncMainWindowActionData *data) +gnc_plugin_ab_cmd_issue_sepatransaction (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *data = user_data; Account *account; - ENTER("action %p, main window data %p", action, data); + ENTER("action %p, main window data %p", simple, data); account = main_window_to_account(data->window); if (account == NULL) { @@ -536,12 +560,14 @@ gnc_plugin_ab_cmd_issue_sepatransaction(GtkAction *action, #if (AQBANKING_VERSION_INT >= 60400) static void -gnc_plugin_ab_cmd_issue_sepainternaltransaction(GtkAction *action, - GncMainWindowActionData *data) +gnc_plugin_ab_cmd_issue_sepainternaltransaction (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *data = user_data; Account *account; - ENTER("action %p, main window data %p", action, data); + ENTER("action %p, main window data %p", simple, data); account = main_window_to_account(data->window); if (account == NULL) { @@ -557,23 +583,27 @@ gnc_plugin_ab_cmd_issue_sepainternaltransaction(GtkAction *action, } #else static void -gnc_plugin_ab_cmd_issue_sepainternaltransaction(GtkAction *action, - GncMainWindowActionData *data) +gnc_plugin_ab_cmd_issue_sepainternaltransaction (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *data = user_data; - ENTER("action %p, main window data %p", action, data); + ENTER("action %p, main window data %p", simple, data); PINFO("Sepa Internal Transfer not supported by your aqbanking version!"); LEAVE("Sepa Internal Transfer not supported!"); } #endif static void -gnc_plugin_ab_cmd_issue_inttransaction(GtkAction *action, - GncMainWindowActionData *data) +gnc_plugin_ab_cmd_issue_inttransaction (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *data = user_data; Account *account; - ENTER("action %p, main window data %p", action, data); + ENTER("action %p, main window data %p", simple, data); account = main_window_to_account(data->window); if (account == NULL) { @@ -590,12 +620,14 @@ gnc_plugin_ab_cmd_issue_inttransaction(GtkAction *action, } static void -gnc_plugin_ab_cmd_issue_sepa_direct_debit(GtkAction *action, - GncMainWindowActionData *data) +gnc_plugin_ab_cmd_issue_sepa_direct_debit (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *data = user_data; Account *account; - ENTER("action %p, main window data %p", action, data); + ENTER("action %p, main window data %p", simple, data); account = main_window_to_account(data->window); if (account == NULL) { @@ -611,29 +643,38 @@ gnc_plugin_ab_cmd_issue_sepa_direct_debit(GtkAction *action, } static void -gnc_plugin_ab_cmd_view_logwindow(GtkToggleAction *action, GncMainWindow *window) +gnc_plugin_ab_cmd_view_logwindow (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { - if (gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action))) + GncMainWindowActionData *data = user_data; + GVariant *state; + + state = g_action_get_state (G_ACTION(simple)); + + if (g_variant_get_boolean (state)) { if (!gnc_GWEN_Gui_show_dialog()) { /* Log window could not be made visible */ - gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), FALSE); + g_action_change_state (G_ACTION(simple), g_variant_new_boolean (FALSE)); } } else { gnc_GWEN_Gui_hide_dialog(); } + g_variant_unref (state); } static void -gnc_plugin_ab_cmd_aqb_import(GtkAction *action, - GncMainWindowActionData *data) +gnc_plugin_ab_cmd_aqb_import (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *data = user_data; gnc_main_window = data->window; gnc_file_aqbanking_import_dialog (GTK_WINDOW (gnc_main_window)); - } /************************************************************ diff --git a/gnucash/import-export/bi-import/gnc-plugin-bi-import.c b/gnucash/import-export/bi-import/gnc-plugin-bi-import.c index 38dcb4f2c5..aad0903f46 100644 --- a/gnucash/import-export/bi-import/gnc-plugin-bi-import.c +++ b/gnucash/import-export/bi-import/gnc-plugin-bi-import.c @@ -46,19 +46,28 @@ static void gnc_plugin_bi_import_init (GncPluginbi_import *plugin) static void gnc_plugin_bi_import_finalize (GObject *object); /* Command callbacks */ -static void gnc_plugin_bi_import_cmd_test (GtkAction *action, GncMainWindowActionData *data); +static void gnc_plugin_bi_import_cmd_test (GSimpleAction *simple, GVariant *parameter, gpointer user_data); #define PLUGIN_ACTIONS_NAME "gnc-plugin-bi-import-actions" -#define PLUGIN_UI_FILENAME "gnc-plugin-bi-import-ui.xml" +#define PLUGIN_UI_FILENAME "gnc-plugin-bi-import.ui" -static GtkActionEntry gnc_plugin_actions [] = +static GActionEntry gnc_plugin_actions [] = { - /* Menu Items */ - { "ImportMenuAction", NULL, N_("_Import"), NULL, NULL, NULL }, - { "bi_importAction", "go-previous", N_("Import Bills & _Invoices..."), NULL, N_("Import bills and invoices from a CSV text file"), G_CALLBACK(gnc_plugin_bi_import_cmd_test) }, + { "bi_importAction", gnc_plugin_bi_import_cmd_test, NULL, NULL, NULL }, }; +/** The number of actions provided by this plugin. */ static guint gnc_plugin_n_actions = G_N_ELEMENTS(gnc_plugin_actions); +static GncDisplayItem gnc_plugin_display_items [] = +{ + /* Menu Items */ + { "ImportMenuAction", NULL, N_("_Import"), NULL, NULL }, + { "bi_importAction", "go-previous", N_("Import Bills & _Invoices..."), + NULL, N_("Import bills and invoices from a CSV text file") + }, +}; +/** The number of display items provided by this plugin. */ +static guint gnc_plugin_n_display_items = G_N_ELEMENTS(gnc_plugin_display_items); /************************************************************ * Object Implementation * @@ -84,10 +93,12 @@ gnc_plugin_bi_import_class_init (GncPluginbi_importClass *klass) plugin_class->plugin_name = GNC_PLUGIN_BI_IMPORT_NAME; /* widget addition/removal */ - plugin_class->actions_name = PLUGIN_ACTIONS_NAME; - plugin_class->actions = gnc_plugin_actions; - plugin_class->n_actions = gnc_plugin_n_actions; - plugin_class->ui_filename = PLUGIN_UI_FILENAME; + plugin_class->actions_name = PLUGIN_ACTIONS_NAME; + plugin_class->actionsb = gnc_plugin_actions; + plugin_class->n_actionsb = gnc_plugin_n_actions; + plugin_class->display_items = gnc_plugin_display_items; + plugin_class->n_display_items = gnc_plugin_n_display_items; + plugin_class->ui_filename = PLUGIN_UI_FILENAME; } static void @@ -117,9 +128,13 @@ gnc_plugin_bi_import_create_plugin (void) ************************************************************/ static void -gnc_plugin_bi_import_cmd_test (GtkAction *action, GncMainWindowActionData *data) +gnc_plugin_bi_import_cmd_test (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { - ENTER ("action %p, main window data %p", action, data); + GncMainWindowActionData *data = user_data; + + ENTER ("action %p, main window data %p", simple, data); PINFO ("bi_import"); gnc_plugin_bi_import_showGUI(GTK_WINDOW(data->window)); diff --git a/gnucash/import-export/csv-exp/gnc-plugin-csv-export.c b/gnucash/import-export/csv-exp/gnc-plugin-csv-export.c index 8894a4cf22..3cc7ac56e7 100644 --- a/gnucash/import-export/csv-exp/gnc-plugin-csv-export.c +++ b/gnucash/import-export/csv-exp/gnc-plugin-csv-export.c @@ -38,33 +38,40 @@ static void gnc_plugin_csv_export_init (GncPluginCsvExport *plugin); static void gnc_plugin_csv_export_finalize (GObject *object); /* Command callbacks */ -static void gnc_plugin_csv_export_tree_cmd (GtkAction *action, GncMainWindowActionData *data); -static void gnc_plugin_csv_export_trans_cmd (GtkAction *action, GncMainWindowActionData *data); -static void gnc_plugin_csv_export_register_cmd (GtkAction *action, GncMainWindowActionData *data); +static void gnc_plugin_csv_export_tree_cmd (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_csv_export_trans_cmd (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_csv_export_register_cmd (GSimpleAction *simple, GVariant *parameter, gpointer user_data); #define PLUGIN_ACTIONS_NAME "gnc-plugin-csv-export-actions" -#define PLUGIN_UI_FILENAME "gnc-plugin-csv-export-ui.xml" +#define PLUGIN_UI_FILENAME "gnc-plugin-csv-export.ui" -static GtkActionEntry gnc_plugin_actions [] = +static GActionEntry gnc_plugin_actions [] = +{ + { "CsvExportTreeAction", gnc_plugin_csv_export_tree_cmd, NULL, NULL, NULL }, + { "CsvExportTransAction", gnc_plugin_csv_export_trans_cmd, NULL, NULL, NULL }, + { "CsvExportRegisterAction", gnc_plugin_csv_export_register_cmd, NULL, NULL, NULL }, +}; +/** The number of actions provided by this plugin. */ +static guint gnc_plugin_n_actions = G_N_ELEMENTS(gnc_plugin_actions); + +static GncDisplayItem gnc_plugin_display_items [] = { { "CsvExportTreeAction", "go-next", N_("Export Account T_ree to CSV..."), NULL, - N_("Export the Account Tree to a CSV file"), - G_CALLBACK (gnc_plugin_csv_export_tree_cmd) + N_("Export the Account Tree to a CSV file") }, { "CsvExportTransAction", "go-next", N_("Export _Transactions to CSV..."), NULL, - N_("Export the Transactions to a CSV file"), - G_CALLBACK (gnc_plugin_csv_export_trans_cmd) + N_("Export the Transactions to a CSV file") }, { "CsvExportRegisterAction", "go-next", N_("Export A_ctive Register to CSV...") - /* _A is already used by Export Accounts */, NULL, - N_("Export the Active Register to a CSV file"), - G_CALLBACK (gnc_plugin_csv_export_register_cmd) + /* _A is already used by Export Accounts */, NULL, + N_("Export the Active Register to a CSV file") }, }; -static guint gnc_plugin_n_actions = G_N_ELEMENTS (gnc_plugin_actions); +/** The number of display items provided by this plugin. */ +static guint gnc_plugin_n_display_items = G_N_ELEMENTS(gnc_plugin_display_items); typedef struct GncPluginCsvExportPrivate { @@ -98,10 +105,12 @@ gnc_plugin_csv_export_class_init (GncPluginCsvExportClass *klass) plugin_class->plugin_name = GNC_PLUGIN_CSV_EXPORT_NAME; /* widget addition/removal */ - plugin_class->actions_name = PLUGIN_ACTIONS_NAME; - plugin_class->actions = gnc_plugin_actions; - plugin_class->n_actions = gnc_plugin_n_actions; - plugin_class->ui_filename = PLUGIN_UI_FILENAME; + plugin_class->actions_name = PLUGIN_ACTIONS_NAME; + plugin_class->actionsb = gnc_plugin_actions; + plugin_class->n_actionsb = gnc_plugin_n_actions; + plugin_class->display_items = gnc_plugin_display_items; + plugin_class->n_display_items = gnc_plugin_n_display_items; + plugin_class->ui_filename = PLUGIN_UI_FILENAME; } static void @@ -125,23 +134,27 @@ gnc_plugin_csv_export_finalize (GObject *object) * Command Callbacks * ************************************************************/ static void -gnc_plugin_csv_export_tree_cmd (GtkAction *action, - GncMainWindowActionData *data) +gnc_plugin_csv_export_tree_cmd (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { gnc_file_csv_export(XML_EXPORT_TREE); } static void -gnc_plugin_csv_export_trans_cmd (GtkAction *action, - GncMainWindowActionData *data) +gnc_plugin_csv_export_trans_cmd (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { gnc_file_csv_export(XML_EXPORT_TRANS); } static void -gnc_plugin_csv_export_register_cmd (GtkAction *action, - GncMainWindowActionData *data) +gnc_plugin_csv_export_register_cmd (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *data = user_data; Query *query; Account *acc; diff --git a/gnucash/import-export/csv-imp/gnc-plugin-csv-import.c b/gnucash/import-export/csv-imp/gnc-plugin-csv-import.c index 11a031157b..d331a2e144 100644 --- a/gnucash/import-export/csv-imp/gnc-plugin-csv-import.c +++ b/gnucash/import-export/csv-imp/gnc-plugin-csv-import.c @@ -37,32 +37,39 @@ static void gnc_plugin_csv_import_init (GncPluginCsvImport *plugin); static void gnc_plugin_csv_import_finalize (GObject *object); /* Command callbacks */ -static void gnc_plugin_csv_import_tree_cmd (GtkAction *action, GncMainWindowActionData *data); -static void gnc_plugin_csv_import_trans_cmd (GtkAction *action, GncMainWindowActionData *data); -static void gnc_plugin_csv_import_price_cmd (GtkAction *action, GncMainWindowActionData *data); +static void gnc_plugin_csv_import_tree_cmd (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_csv_import_trans_cmd (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_csv_import_price_cmd (GSimpleAction *simple, GVariant *parameter, gpointer user_data); #define PLUGIN_ACTIONS_NAME "gnc-plugin-csv-import-actions" -#define PLUGIN_UI_FILENAME "gnc-plugin-csv-import-ui.xml" +#define PLUGIN_UI_FILENAME "gnc-plugin-csv-import.ui" -static GtkActionEntry gnc_plugin_actions [] = +static GActionEntry gnc_plugin_actions [] = +{ + { "CsvImportAccountAction", gnc_plugin_csv_import_tree_cmd, NULL, NULL, NULL }, + { "CsvImportTransAction", gnc_plugin_csv_import_trans_cmd, NULL, NULL, NULL }, + { "CsvImportPriceAction", gnc_plugin_csv_import_price_cmd, NULL, NULL, NULL }, +}; +/** The number of actions provided by this plugin. */ +static guint gnc_plugin_n_actions = G_N_ELEMENTS(gnc_plugin_actions); + +static GncDisplayItem gnc_plugin_display_items [] = { { "CsvImportAccountAction", "go-previous", N_("Import _Accounts from CSV..."), NULL, - N_("Import Accounts from a CSV file"), - G_CALLBACK (gnc_plugin_csv_import_tree_cmd) + N_("Import Accounts from a CSV file") }, { "CsvImportTransAction", "go-previous", N_("Import _Transactions from CSV..."), NULL, - N_("Import Transactions from a CSV file"), - G_CALLBACK (gnc_plugin_csv_import_trans_cmd) + N_("Import Transactions from a CSV file") }, { "CsvImportPriceAction", "go-previous", N_("Import _Prices from a CSV file..."), NULL, - N_("Import Prices from a CSV file"), - G_CALLBACK (gnc_plugin_csv_import_price_cmd) + N_("Import Prices from a CSV file") }, }; -static guint gnc_plugin_n_actions = G_N_ELEMENTS (gnc_plugin_actions); +/** The number of display items provided by this plugin. */ +static guint gnc_plugin_n_display_items = G_N_ELEMENTS(gnc_plugin_display_items); typedef struct GncPluginCsvImportPrivate { @@ -96,10 +103,12 @@ gnc_plugin_csv_import_class_init (GncPluginCsvImportClass *klass) plugin_class->plugin_name = GNC_PLUGIN_CSV_IMPORT_NAME; /* widget addition/removal */ - plugin_class->actions_name = PLUGIN_ACTIONS_NAME; - plugin_class->actions = gnc_plugin_actions; - plugin_class->n_actions = gnc_plugin_n_actions; - plugin_class->ui_filename = PLUGIN_UI_FILENAME; + plugin_class->actions_name = PLUGIN_ACTIONS_NAME; + plugin_class->actionsb = gnc_plugin_actions; + plugin_class->n_actionsb = gnc_plugin_n_actions; + plugin_class->display_items = gnc_plugin_display_items; + plugin_class->n_display_items = gnc_plugin_n_display_items; + plugin_class->ui_filename = PLUGIN_UI_FILENAME; } static void @@ -123,22 +132,25 @@ gnc_plugin_csv_import_finalize (GObject *object) * Command Callbacks * ************************************************************/ static void -gnc_plugin_csv_import_tree_cmd (GtkAction *action, - GncMainWindowActionData *data) +gnc_plugin_csv_import_tree_cmd (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { gnc_file_csv_account_import (); } static void -gnc_plugin_csv_import_trans_cmd (GtkAction *action, - GncMainWindowActionData *data) +gnc_plugin_csv_import_trans_cmd (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { gnc_file_csv_trans_import (); } static void -gnc_plugin_csv_import_price_cmd (GtkAction *action, - GncMainWindowActionData *data) +gnc_plugin_csv_import_price_cmd (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { gnc_file_csv_price_import (); } diff --git a/gnucash/import-export/customer-import/gnc-plugin-customer-import.c b/gnucash/import-export/customer-import/gnc-plugin-customer-import.c index 93449a00c5..660e063cf3 100644 --- a/gnucash/import-export/customer-import/gnc-plugin-customer-import.c +++ b/gnucash/import-export/customer-import/gnc-plugin-customer-import.c @@ -46,20 +46,29 @@ static void gnc_plugin_customer_import_init (GncPlugincustomer_imp static void gnc_plugin_customer_import_finalize (GObject *object); /* Command callbacks */ -static void gnc_plugin_customer_import_cmd_test (GtkAction *action, GncMainWindowActionData *data); +static void gnc_plugin_customer_import_cmd_test (GSimpleAction *simple, GVariant *parameter, gpointer user_data); #define PLUGIN_ACTIONS_NAME "gnc-plugin-customer-import-actions" -#define PLUGIN_UI_FILENAME "gnc-plugin-customer-import-ui.xml" +#define PLUGIN_UI_FILENAME "gnc-plugin-customer-import.ui" -static GtkActionEntry gnc_plugin_actions [] = +static GActionEntry gnc_plugin_actions [] = { - /* Menu Items */ - { "ImportMenuAction", NULL, N_("_Import"), NULL, NULL, NULL }, - /* Menu entry with label and tooltip */ - { "customer_importAction", "go-previous", N_("Import _Customers & Vendors..."), NULL, N_("Import Customers and Vendors from a CSV text file."), G_CALLBACK(gnc_plugin_customer_import_cmd_test) }, + { "customer_importAction", gnc_plugin_customer_import_cmd_test, NULL, NULL, NULL }, }; +/** The number of actions provided by this plugin. */ static guint gnc_plugin_n_actions = G_N_ELEMENTS(gnc_plugin_actions); +static GncDisplayItem gnc_plugin_display_items [] = +{ + /* Menu Items */ + { "ImportMenuAction", NULL, N_("_Import"), NULL, NULL }, + /* Menu entry with label and tooltip */ + { "customer_importAction", "go-previous", N_("Import _Customers & Vendors..."), + NULL, N_("Import Customers and Vendors from a CSV text file.") + }, +}; +/** The number of display items provided by this plugin. */ +static guint gnc_plugin_n_display_items = G_N_ELEMENTS(gnc_plugin_display_items); /************************************************************ * Object Implementation * @@ -85,10 +94,12 @@ gnc_plugin_customer_import_class_init (GncPlugincustomer_importClass *klass) plugin_class->plugin_name = GNC_PLUGIN_customer_import_NAME; /* widget addition/removal */ - plugin_class->actions_name = PLUGIN_ACTIONS_NAME; - plugin_class->actions = gnc_plugin_actions; - plugin_class->n_actions = gnc_plugin_n_actions; - plugin_class->ui_filename = PLUGIN_UI_FILENAME; + plugin_class->actions_name = PLUGIN_ACTIONS_NAME; + plugin_class->actionsb = gnc_plugin_actions; + plugin_class->n_actionsb = gnc_plugin_n_actions; + plugin_class->display_items = gnc_plugin_display_items; + plugin_class->n_display_items = gnc_plugin_n_display_items; + plugin_class->ui_filename = PLUGIN_UI_FILENAME; } static void @@ -118,9 +129,13 @@ gnc_plugin_customer_import_create_plugin (void) ************************************************************/ static void -gnc_plugin_customer_import_cmd_test (GtkAction *action, GncMainWindowActionData *data) +gnc_plugin_customer_import_cmd_test (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { - ENTER ("action %p, main window data %p", action, data); + GncMainWindowActionData *data = user_data; + + ENTER ("action %p, main window data %p", simple, data); PINFO ("customer_import"); gnc_plugin_customer_import_showGUI (GTK_WINDOW(data->window)); diff --git a/gnucash/import-export/log-replay/gnc-plugin-log-replay.c b/gnucash/import-export/log-replay/gnc-plugin-log-replay.c index 31f9809642..47ecfe5184 100644 --- a/gnucash/import-export/log-replay/gnc-plugin-log-replay.c +++ b/gnucash/import-export/log-replay/gnc-plugin-log-replay.c @@ -36,21 +36,28 @@ static void gnc_plugin_log_replay_init (GncPluginLogreplay *plugin); static void gnc_plugin_log_replay_finalize (GObject *object); /* Command callbacks */ -static void gnc_plugin_log_replay_cmd_new_log_replay (GtkAction *action, GncMainWindowActionData *data); +static void gnc_plugin_log_replay_cmd_new_log_replay (GSimpleAction *simple, GVariant *parameter, gpointer user_data); #define PLUGIN_ACTIONS_NAME "gnc-plugin-log-replay-actions" -#define PLUGIN_UI_FILENAME "gnc-plugin-log-replay-ui.xml" +#define PLUGIN_UI_FILENAME "gnc-plugin-log-replay.ui" -static GtkActionEntry gnc_plugin_actions [] = +static GActionEntry gnc_plugin_actions [] = +{ + { "LogReplayAction", gnc_plugin_log_replay_cmd_new_log_replay, NULL, NULL, NULL }, +}; +/** The number of actions provided by this plugin. */ +static guint gnc_plugin_n_actions = G_N_ELEMENTS(gnc_plugin_actions); + +static GncDisplayItem gnc_plugin_display_items [] = { { "LogReplayAction", "go-previous", N_("_Replay GnuCash .log file..."), NULL, - N_("Replay a GnuCash log file after a crash. This cannot be undone."), - G_CALLBACK (gnc_plugin_log_replay_cmd_new_log_replay) + N_("Replay a GnuCash log file after a crash. This cannot be undone.") }, }; -static guint gnc_plugin_n_actions = G_N_ELEMENTS (gnc_plugin_actions); +/** The number of display items provided by this plugin. */ +static guint gnc_plugin_n_display_items = G_N_ELEMENTS(gnc_plugin_display_items); typedef struct GncPluginLogreplayPrivate { @@ -84,10 +91,12 @@ gnc_plugin_log_replay_class_init (GncPluginLogreplayClass *klass) plugin_class->plugin_name = GNC_PLUGIN_LOG_REPLAY_NAME; /* widget addition/removal */ - plugin_class->actions_name = PLUGIN_ACTIONS_NAME; - plugin_class->actions = gnc_plugin_actions; - plugin_class->n_actions = gnc_plugin_n_actions; - plugin_class->ui_filename = PLUGIN_UI_FILENAME; + plugin_class->actions_name = PLUGIN_ACTIONS_NAME; + plugin_class->actionsb = gnc_plugin_actions; + plugin_class->n_actionsb = gnc_plugin_n_actions; + plugin_class->display_items = gnc_plugin_display_items; + plugin_class->n_display_items = gnc_plugin_n_display_items; + plugin_class->ui_filename = PLUGIN_UI_FILENAME; } static void @@ -112,9 +121,11 @@ gnc_plugin_log_replay_finalize (GObject *object) ************************************************************/ static void -gnc_plugin_log_replay_cmd_new_log_replay (GtkAction *action, - GncMainWindowActionData *data) +gnc_plugin_log_replay_cmd_new_log_replay (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *data = user_data; gnc_suspend_gui_refresh(); gnc_file_log_replay (GTK_WINDOW (data->window)); gnc_resume_gui_refresh(); diff --git a/gnucash/import-export/ofx/gnc-plugin-ofx.c b/gnucash/import-export/ofx/gnc-plugin-ofx.c index 94e7c3e4f4..a3707c2dd7 100644 --- a/gnucash/import-export/ofx/gnc-plugin-ofx.c +++ b/gnucash/import-export/ofx/gnc-plugin-ofx.c @@ -34,21 +34,28 @@ static void gnc_plugin_ofx_init (GncPluginOfx *plugin); static void gnc_plugin_ofx_finalize (GObject *object); /* Command callbacks */ -static void gnc_plugin_ofx_cmd_import (GtkAction *action, GncMainWindowActionData *data); +static void gnc_plugin_ofx_cmd_import (GSimpleAction *simple, GVariant *parameter, gpointer user_data); #define PLUGIN_ACTIONS_NAME "gnc-plugin-ofx-actions" -#define PLUGIN_UI_FILENAME "gnc-plugin-ofx-ui.xml" +#define PLUGIN_UI_FILENAME "gnc-plugin-ofx.ui" -static GtkActionEntry gnc_plugin_actions [] = +static GActionEntry gnc_plugin_actions [] = +{ + { "OfxImportAction", gnc_plugin_ofx_cmd_import, NULL, NULL, NULL }, +}; +/** The number of actions provided by this plugin. */ +static guint gnc_plugin_n_actions = G_N_ELEMENTS(gnc_plugin_actions); + +static GncDisplayItem gnc_plugin_display_items [] = { { "OfxImportAction", "go-previous", N_("Import _OFX/QFX..."), NULL, - N_("Process an OFX/QFX response file"), - G_CALLBACK (gnc_plugin_ofx_cmd_import) + N_("Process an OFX/QFX response file") }, }; -static guint gnc_plugin_n_actions = G_N_ELEMENTS (gnc_plugin_actions); +/** The number of display items provided by this plugin. */ +static guint gnc_plugin_n_display_items = G_N_ELEMENTS(gnc_plugin_display_items); typedef struct GncPluginOfxPrivate { @@ -82,10 +89,12 @@ gnc_plugin_ofx_class_init (GncPluginOfxClass *klass) plugin_class->plugin_name = GNC_PLUGIN_OFX_NAME; /* widget addition/removal */ - plugin_class->actions_name = PLUGIN_ACTIONS_NAME; - plugin_class->actions = gnc_plugin_actions; - plugin_class->n_actions = gnc_plugin_n_actions; - plugin_class->ui_filename = PLUGIN_UI_FILENAME; + plugin_class->actions_name = PLUGIN_ACTIONS_NAME; + plugin_class->actionsb = gnc_plugin_actions; + plugin_class->n_actionsb = gnc_plugin_n_actions; + plugin_class->display_items = gnc_plugin_display_items; + plugin_class->n_display_items = gnc_plugin_n_display_items; + plugin_class->ui_filename = PLUGIN_UI_FILENAME; } static void @@ -110,9 +119,11 @@ gnc_plugin_ofx_finalize (GObject *object) ************************************************************/ static void -gnc_plugin_ofx_cmd_import (GtkAction *action, - GncMainWindowActionData *data) +gnc_plugin_ofx_cmd_import (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *data = user_data; gnc_file_ofx_import (GTK_WINDOW (data->window)); } diff --git a/gnucash/import-export/qif-imp/gnc-plugin-qif-import.c b/gnucash/import-export/qif-imp/gnc-plugin-qif-import.c index 2aed0ae593..77dbfbb28b 100644 --- a/gnucash/import-export/qif-imp/gnc-plugin-qif-import.c +++ b/gnucash/import-export/qif-imp/gnc-plugin-qif-import.c @@ -37,20 +37,27 @@ static void gnc_plugin_qif_import_init (GncPluginQifImport *plugin); static void gnc_plugin_qif_import_finalize (GObject *object); /* Command callbacks */ -static void gnc_plugin_qif_import_cmd_new_qif_import (GtkAction *action, GncMainWindowActionData *data); +static void gnc_plugin_qif_import_cmd_new_qif_import (GSimpleAction *simple, GVariant *parameter, gpointer user_data); #define PLUGIN_ACTIONS_NAME "gnc-plugin-qif-import-actions" -#define PLUGIN_UI_FILENAME "gnc-plugin-qif-import-ui.xml" +#define PLUGIN_UI_FILENAME "gnc-plugin-qif-import.ui" -static GtkActionEntry gnc_plugin_actions [] = +static GActionEntry gnc_plugin_actions [] = +{ + { "QIFImportAction", gnc_plugin_qif_import_cmd_new_qif_import, NULL, NULL, NULL }, +}; +/** The number of actions provided by this plugin. */ +static guint gnc_plugin_n_actions = G_N_ELEMENTS(gnc_plugin_actions); + +static GncDisplayItem gnc_plugin_display_items [] = { { "QIFImportAction", "go-previous", N_("Import _QIF..."), NULL, - N_("Import a Quicken QIF file"), - G_CALLBACK (gnc_plugin_qif_import_cmd_new_qif_import) + N_("Import a Quicken QIF file") }, }; -static guint gnc_plugin_n_actions = G_N_ELEMENTS (gnc_plugin_actions); +/** The number of display items provided by this plugin. */ +static guint gnc_plugin_n_display_items = G_N_ELEMENTS(gnc_plugin_display_items); typedef struct GncPluginQifImportPrivate { @@ -84,10 +91,12 @@ gnc_plugin_qif_import_class_init (GncPluginQifImportClass *klass) plugin_class->plugin_name = GNC_PLUGIN_QIF_IMPORT_NAME; /* widget addition/removal */ - plugin_class->actions_name = PLUGIN_ACTIONS_NAME; - plugin_class->actions = gnc_plugin_actions; - plugin_class->n_actions = gnc_plugin_n_actions; - plugin_class->ui_filename = PLUGIN_UI_FILENAME; + plugin_class->actions_name = PLUGIN_ACTIONS_NAME; + plugin_class->actionsb = gnc_plugin_actions; + plugin_class->n_actionsb = gnc_plugin_n_actions; + plugin_class->display_items = gnc_plugin_display_items; + plugin_class->n_display_items = gnc_plugin_n_display_items; + plugin_class->ui_filename = PLUGIN_UI_FILENAME; } static void @@ -112,8 +121,9 @@ gnc_plugin_qif_import_finalize (GObject *object) ************************************************************/ static void -gnc_plugin_qif_import_cmd_new_qif_import (GtkAction *action, - GncMainWindowActionData *data) +gnc_plugin_qif_import_cmd_new_qif_import (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { gnc_file_qif_import(); } diff --git a/libgnucash/gnc-module/example/gnc-plugin.example.c b/libgnucash/gnc-module/example/gnc-plugin.example.c index 169e11596f..3be4ce1174 100644 --- a/libgnucash/gnc-module/example/gnc-plugin.example.c +++ b/libgnucash/gnc-module/example/gnc-plugin.example.c @@ -40,19 +40,28 @@ static void gnc_plugin_example_init (GncPluginexample *plugin); static void gnc_plugin_example_finalize (GObject *object); /* Command callbacks */ -static void gnc_plugin_example_cmd_test (GtkAction *action, GncMainWindowActionData *data); +static void gnc_plugin_example_cmd_test (GSimpleAction *simple, GVariant *parameter, gpointer user_data); ++{ #define PLUGIN_ACTIONS_NAME "gnc-plugin-example-actions" -#define PLUGIN_UI_FILENAME "gnc-plugin-example-ui.xml" +#define PLUGIN_UI_FILENAME "gnc-plugin-example.ui" -static GtkActionEntry gnc_plugin_actions [] = { - /* Menu Items */ - { "exampleAction", NULL, N_("example description..."), NULL, - N_("example tooltip"), - G_CALLBACK(gnc_plugin_example_cmd_test) }, +static GActionEntry gnc_plugin_actions [] = +{ + { "exampleAction", gnc_plugin_example_cmd_test, NULL, NULL, NULL }, }; +/** The number of actions provided by this plugin. */ static guint gnc_plugin_n_actions = G_N_ELEMENTS(gnc_plugin_actions); +static GncDisplayItem gnc_plugin_display_items [] = +{ + /* Menu Items */ + { "exampleAction", NULL, N_("example description..."), NULL, + N_("example tooltip") + }, +}; +/** The number of display items provided by this plugin. */ +static guint gnc_plugin_n_display_items = G_N_ELEMENTS(gnc_plugin_display_items); /************************************************************ * Object Implementation * @@ -69,7 +78,7 @@ gnc_plugin_example_new (void) static void gnc_plugin_example_class_init (GncPluginexampleClass *klass) { - GObjectClass *object_class = G_OBJECT_CLASS (klass); + GObjectClass *object_class = G_OBJECT_CLASS(klass); GncPluginClass *plugin_class = GNC_PLUGIN_CLASS(klass); object_class->finalize = gnc_plugin_example_finalize; @@ -78,10 +87,12 @@ gnc_plugin_example_class_init (GncPluginexampleClass *klass) plugin_class->plugin_name = GNC_PLUGIN_example_NAME; /* widget addition/removal */ - plugin_class->actions_name = PLUGIN_ACTIONS_NAME; - plugin_class->actions = gnc_plugin_actions; - plugin_class->n_actions = gnc_plugin_n_actions; - plugin_class->ui_filename = PLUGIN_UI_FILENAME; + plugin_class->actions_name = PLUGIN_ACTIONS_NAME; + plugin_class->actionsb = gnc_plugin_actions; + plugin_class->n_actionsb = gnc_plugin_n_actions; + plugin_class->display_items = gnc_plugin_display_items; + plugin_class->n_display_items = gnc_plugin_n_display_items; + plugin_class->ui_filename = PLUGIN_UI_FILENAME; } static void @@ -99,9 +110,12 @@ gnc_plugin_example_finalize (GObject *object) ************************************************************/ static void -gnc_plugin_example_cmd_test (GtkAction *action, GncMainWindowActionData *data) +gnc_plugin_example_cmd_test (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { - ENTER ("action %p, main window data %p", action, data); - PINFO ("example"); - LEAVE (" "); + GncMainWindowActionData *data = user_data; + ENTER("action %p, main window data %p", simple, data); + PINFO("example"); + LEAVE(" "); } From d067ec2cc94cb46f85bc7af4ff28b288a5396dca Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Fri, 28 Oct 2022 16:05:00 +0100 Subject: [PATCH 03/77] Initial change to plugin page source files --- gnucash/gnome/gnc-plugin-page-account-tree.c | 329 ++++--- gnucash/gnome/gnc-plugin-page-budget.c | 176 ++-- gnucash/gnome/gnc-plugin-page-invoice.c | 453 +++++---- gnucash/gnome/gnc-plugin-page-owner-tree.c | 260 ++--- gnucash/gnome/gnc-plugin-page-register.c | 979 ++++++++++--------- gnucash/gnome/gnc-plugin-page-report.cpp | 230 +++-- gnucash/gnome/gnc-plugin-page-sx-list.c | 127 ++- 7 files changed, 1397 insertions(+), 1157 deletions(-) diff --git a/gnucash/gnome/gnc-plugin-page-account-tree.c b/gnucash/gnome/gnc-plugin-page-account-tree.c index da3cc33649..46ce1695b7 100644 --- a/gnucash/gnome/gnc-plugin-page-account-tree.c +++ b/gnucash/gnome/gnc-plugin-page-account-tree.c @@ -150,30 +150,30 @@ void gppat_populate_trans_mas_list(GtkToggleButton *sa_mrb, GtkWidget *dialog); void gppat_set_insensitive_iff_rb_active(GtkWidget *widget, GtkToggleButton *b); /* Command callbacks */ -static void gnc_plugin_page_account_tree_cmd_new_account (GtkAction *action, GncPluginPageAccountTree *plugin_page); -static void gnc_plugin_page_account_tree_cmd_file_new_hierarchy (GtkAction *action, GncPluginPageAccountTree *plugin_page); -static void gnc_plugin_page_account_tree_cmd_open_account (GtkAction *action, GncPluginPageAccountTree *page); -static void gnc_plugin_page_account_tree_cmd_open_subaccounts (GtkAction *action, GncPluginPageAccountTree *page); -static void gnc_plugin_page_account_tree_cmd_edit_account (GtkAction *action, GncPluginPageAccountTree *page); -static void gnc_plugin_page_account_tree_cmd_find_account (GtkAction *action, GncPluginPageAccountTree *page); -static void gnc_plugin_page_account_tree_cmd_find_account_popup (GtkAction *action, GncPluginPageAccountTree *page); -static void gnc_plugin_page_account_tree_cmd_delete_account (GtkAction *action, GncPluginPageAccountTree *page); -static void gnc_plugin_page_account_tree_cmd_renumber_accounts (GtkAction *action, GncPluginPageAccountTree *page); -static void gnc_plugin_page_account_tree_cmd_view_filter_by (GtkAction *action, GncPluginPageAccountTree *plugin_page); -static void gnc_plugin_page_account_tree_cmd_reconcile (GtkAction *action, GncPluginPageAccountTree *page); -static void gnc_plugin_page_account_tree_cmd_refresh (GtkAction *action, GncPluginPageAccountTree *page); -static void gnc_plugin_page_account_tree_cmd_autoclear (GtkAction *action, GncPluginPageAccountTree *page); -static void gnc_plugin_page_account_tree_cmd_transfer (GtkAction *action, GncPluginPageAccountTree *page); -static void gnc_plugin_page_account_tree_cmd_stock_split (GtkAction *action, GncPluginPageAccountTree *page); -static void gnc_plugin_page_account_tree_cmd_edit_tax_options (GtkAction *action, GncPluginPageAccountTree *page); -static void gnc_plugin_page_account_tree_cmd_lots (GtkAction *action, GncPluginPageAccountTree *page); -static void gnc_plugin_page_account_tree_cmd_scrub (GtkAction *action, GncPluginPageAccountTree *page); -static void gnc_plugin_page_account_tree_cmd_scrub_sub (GtkAction *action, GncPluginPageAccountTree *page); -static void gnc_plugin_page_account_tree_cmd_scrub_all (GtkAction *action, GncPluginPageAccountTree *page); -static void gnc_plugin_page_account_tree_cmd_cascade_account_properties (GtkAction *action, GncPluginPageAccountTree *page); +static void gnc_plugin_page_account_tree_cmd_new_account (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_account_tree_cmd_file_new_hierarchy (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_account_tree_cmd_open_account (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_account_tree_cmd_open_subaccounts (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_account_tree_cmd_edit_account (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_account_tree_cmd_find_account (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_account_tree_cmd_find_account_popup (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_account_tree_cmd_delete_account (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_account_tree_cmd_renumber_accounts (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_account_tree_cmd_view_filter_by (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_account_tree_cmd_reconcile (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_account_tree_cmd_refresh (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_account_tree_cmd_autoclear (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_account_tree_cmd_transfer (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_account_tree_cmd_stock_split (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_account_tree_cmd_edit_tax_options (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_account_tree_cmd_lots (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_account_tree_cmd_scrub (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_account_tree_cmd_scrub_sub (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_account_tree_cmd_scrub_all (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_account_tree_cmd_cascade_account_properties (GSimpleAction *simple, GVariant *paramter, gpointer user_data); /* Account Deletion Actions. */ -static int confirm_delete_account (GtkAction *action, +static int confirm_delete_account (GSimpleAction *simple, GncPluginPageAccountTree *page, Account* ta, Account* sta, Account* saa, delete_helper_t delete_res); @@ -185,64 +185,76 @@ static void do_delete_account (Account* account, Account* saa, Account* sta, static guint plugin_page_signals[LAST_SIGNAL] = { 0 }; -static GtkActionEntry gnc_plugin_page_account_tree_actions [] = +static GActionEntry gnc_plugin_page_account_tree_actions [] = { - /* Toplevel */ - { "FakeToplevel", NULL, "", NULL, NULL, NULL }, + { "FileNewAccountAction", gnc_plugin_page_account_tree_cmd_new_account, NULL, NULL, NULL }, + { "FileAddAccountHierarchyAssistantAction", gnc_plugin_page_account_tree_cmd_file_new_hierarchy, NULL, NULL, NULL }, + { "FileOpenAccountAction", gnc_plugin_page_account_tree_cmd_open_account, NULL, NULL, NULL }, + { "FileOpenSubaccountsAction", gnc_plugin_page_account_tree_cmd_open_subaccounts, NULL, NULL, NULL }, + { "EditEditAccountAction", gnc_plugin_page_account_tree_cmd_edit_account, NULL, NULL, NULL }, + { "EditDeleteAccountAction", gnc_plugin_page_account_tree_cmd_delete_account, NULL, NULL, NULL }, + { "EditCascadeAccountAction", gnc_plugin_page_account_tree_cmd_cascade_account_properties, NULL, NULL, NULL }, + { "EditFindAccountAction", gnc_plugin_page_account_tree_cmd_find_account, NULL, NULL, NULL }, + { "EditFindAccountPopupAction", gnc_plugin_page_account_tree_cmd_find_account_popup, NULL, NULL, NULL }, + { "EditRenumberSubaccountsAction", gnc_plugin_page_account_tree_cmd_renumber_accounts, NULL, NULL, NULL }, + { "EditTaxOptionsAction", gnc_plugin_page_account_tree_cmd_edit_tax_options, NULL, NULL, NULL }, + { "ViewFilterByAction", gnc_plugin_page_account_tree_cmd_view_filter_by, NULL, NULL, NULL }, + { "ViewRefreshAction", gnc_plugin_page_account_tree_cmd_refresh, NULL, NULL, NULL }, + { "ActionsReconcileAction", gnc_plugin_page_account_tree_cmd_reconcile, NULL, NULL, NULL }, + { "ActionsAutoClearAction", gnc_plugin_page_account_tree_cmd_autoclear, NULL, NULL, NULL }, + { "ActionsTransferAction", gnc_plugin_page_account_tree_cmd_transfer, NULL, NULL, NULL }, + { "ActionsStockSplitAction", gnc_plugin_page_account_tree_cmd_stock_split, NULL, NULL, NULL }, + { "ActionsLotsAction", gnc_plugin_page_account_tree_cmd_lots, NULL, NULL, NULL }, + { "ScrubAction", gnc_plugin_page_account_tree_cmd_scrub, NULL, NULL, NULL }, + { "ScrubSubAction", gnc_plugin_page_account_tree_cmd_scrub_sub, NULL, NULL, NULL }, + { "ScrubAllAction", gnc_plugin_page_account_tree_cmd_scrub_all, NULL, NULL, NULL }, +}; +/** The number of actions provided by this plugin. */ +static guint gnc_plugin_page_account_tree_n_actions = G_N_ELEMENTS(gnc_plugin_page_account_tree_actions); +static GncDisplayItem gnc_plugin_page_account_tree_display_items [] = +{ /* File menu */ { "FileNewAccountAction", GNC_ICON_NEW_ACCOUNT, N_("New _Account..."), NULL, - N_("Create a new Account"), - G_CALLBACK (gnc_plugin_page_account_tree_cmd_new_account) + N_("Create a new Account") }, { "FileAddAccountHierarchyAssistantAction", GNC_ICON_NEW_ACCOUNT, N_("New Account _Hierarchy..."), NULL, - N_("Extend the current book by merging with new account type categories"), - G_CALLBACK (gnc_plugin_page_account_tree_cmd_file_new_hierarchy) + N_("Extend the current book by merging with new account type categories") }, { "FileOpenAccountAction", GNC_ICON_OPEN_ACCOUNT, N_("Open _Account"), NULL, - N_("Open the selected account"), - G_CALLBACK (gnc_plugin_page_account_tree_cmd_open_account) + N_("Open the selected account") }, - { "FileOpenSubaccountsAction", GNC_ICON_OPEN_ACCOUNT, N_("Open _SubAccounts"), NULL, - N_("Open the selected account and all its subaccounts"), - G_CALLBACK (gnc_plugin_page_account_tree_cmd_open_subaccounts) + N_("Open the selected account and all its subaccounts") }, - /* Edit menu */ { "EditEditAccountAction", GNC_ICON_EDIT_ACCOUNT, N_("Edit _Account"), "e", - N_("Edit the selected account"), - G_CALLBACK (gnc_plugin_page_account_tree_cmd_edit_account) + N_("Edit the selected account") }, { "EditDeleteAccountAction", GNC_ICON_DELETE_ACCOUNT, N_("_Delete Account..."), "Delete", - N_("Delete selected account"), - G_CALLBACK (gnc_plugin_page_account_tree_cmd_delete_account) + N_("Delete selected account") }, { "EditCascadeAccountAction", NULL, N_("_Cascade Account Properties..."), NULL, - N_("Cascade selected properties for account"), - G_CALLBACK (gnc_plugin_page_account_tree_cmd_cascade_account_properties) + N_("Cascade selected properties for account") }, { "EditFindAccountAction", "edit-find", N_("F_ind Account"), "i", - N_("Find an account"), - G_CALLBACK (gnc_plugin_page_account_tree_cmd_find_account) + N_("Find an account") }, { "EditFindAccountPopupAction", "edit-find", N_("F_ind Account"), "i", - N_("Find an account"), - G_CALLBACK (gnc_plugin_page_account_tree_cmd_find_account_popup) + N_("Find an account") }, { "EditRenumberSubaccountsAction", NULL, N_("_Renumber Subaccounts..."), NULL, - N_("Renumber the children of the selected account"), - G_CALLBACK (gnc_plugin_page_account_tree_cmd_renumber_accounts) + N_("Renumber the children of the selected account") }, { "EditTaxOptionsAction", NULL, @@ -253,68 +265,53 @@ static GtkActionEntry gnc_plugin_page_account_tree_actions [] = US: income tax and DE: VAT So adjust this string */ - N_("Setup relevant accounts for tax reports, e.g. US income tax"), - G_CALLBACK (gnc_plugin_page_account_tree_cmd_edit_tax_options) + N_("Setup relevant accounts for tax reports, e.g. US income tax") }, /* View menu */ { - "ViewFilterByAction", NULL, N_("_Filter By..."), NULL, NULL, - G_CALLBACK (gnc_plugin_page_account_tree_cmd_view_filter_by) + "ViewFilterByAction", NULL, N_("_Filter By..."), NULL, NULL }, { "ViewRefreshAction", "view-refresh", N_("_Refresh"), "r", - N_("Refresh this window"), - G_CALLBACK (gnc_plugin_page_account_tree_cmd_refresh) + N_("Refresh this window") }, - /* Actions menu */ { "ActionsReconcileAction", NULL, N_("_Reconcile..."), NULL, - N_("Reconcile the selected account"), - G_CALLBACK (gnc_plugin_page_account_tree_cmd_reconcile) + N_("Reconcile the selected account") }, { "ActionsAutoClearAction", NULL, N_("_Auto-clear..."), NULL, - N_("Automatically clear individual transactions, given a cleared amount"), - G_CALLBACK (gnc_plugin_page_account_tree_cmd_autoclear) + N_("Automatically clear individual transactions, given a cleared amount") }, { "ActionsTransferAction", NULL, N_("_Transfer..."), "t", - N_("Transfer funds from one account to another"), - G_CALLBACK (gnc_plugin_page_account_tree_cmd_transfer) + N_("Transfer funds from one account to another") }, { "ActionsStockSplitAction", NULL, N_("Stoc_k Split..."), NULL, - N_("Record a stock split or a stock merger"), - G_CALLBACK (gnc_plugin_page_account_tree_cmd_stock_split) + N_("Record a stock split or a stock merger") }, { "ActionsLotsAction", NULL, N_("View _Lots..."), NULL, - N_("Bring up the lot viewer/editor window"), - G_CALLBACK (gnc_plugin_page_account_tree_cmd_lots) + N_("Bring up the lot viewer/editor window") }, { "ScrubAction", NULL, N_("Check & Repair A_ccount"), NULL, - N_("Check for and repair unbalanced transactions and orphan splits " "in this account"), - G_CALLBACK (gnc_plugin_page_account_tree_cmd_scrub) + N_("Check for and repair unbalanced transactions and orphan splits " "in this account") }, { "ScrubSubAction", NULL, N_("Check & Repair Su_baccounts"), NULL, N_("Check for and repair unbalanced transactions and orphan splits " - "in this account and its subaccounts"), - G_CALLBACK (gnc_plugin_page_account_tree_cmd_scrub_sub) + "in this account and its subaccounts") }, { "ScrubAllAction", NULL, N_("Check & Repair A_ll"), NULL, - N_("Check for and repair unbalanced transactions and orphan splits " "in all accounts"), - G_CALLBACK (gnc_plugin_page_account_tree_cmd_scrub_all) + N_("Check for and repair unbalanced transactions and orphan splits " "in all accounts") }, - /* Extensions Menu */ - { "Register2TestAction", NULL, N_("_Register2"), NULL, NULL, NULL }, }; -/** The number of actions provided by this plugin. */ -static guint gnc_plugin_page_account_tree_n_actions = G_N_ELEMENTS (gnc_plugin_page_account_tree_actions); - +/** The number of display items provided by this plugin. */ +static guint gnc_plugin_page_account_tree_n_display_items = G_N_ELEMENTS(gnc_plugin_page_account_tree_display_items); /** Actions that require an account to be selected before they are * enabled, and the book is in read-write mode. */ @@ -366,10 +363,10 @@ static const gchar* readonly_inactive_actions[] = /** Short labels for use on the toolbar buttons. */ static action_toolbar_labels toolbar_labels[] = { - { "FileOpenAccountAction", N_("Open") }, - { "EditEditAccountAction", N_("Edit") }, - { "FileNewAccountAction", N_("New") }, - { "EditDeleteAccountAction", N_("Delete") }, + { "FileOpenAccountAction", N_("Open") }, + { "EditEditAccountAction", N_("Edit") }, + { "FileNewAccountAction", N_("New") }, + { "EditDeleteAccountAction", N_("Delete") }, { NULL, NULL }, }; @@ -468,7 +465,8 @@ gnc_plugin_page_account_tree_class_init (GncPluginPageAccountTreeClass *klass) static void gnc_plugin_page_account_tree_init (GncPluginPageAccountTree *plugin_page) { - GtkActionGroup *action_group; +// GtkActionGroup *action_group; + GSimpleActionGroup *simple_action_group; GncPluginPageAccountTreePrivate *priv; GncPluginPage *parent; const GList *page_list; @@ -481,7 +479,7 @@ gnc_plugin_page_account_tree_init (GncPluginPageAccountTree *plugin_page) g_object_set(G_OBJECT(plugin_page), "page-name", _("Accounts"), "page-uri", "default:", - "ui-description", "gnc-plugin-page-account-tree-ui.xml", + "ui-description", "gnc-plugin-page-account-tree.ui", NULL); g_signal_connect (G_OBJECT (plugin_page), "selected", G_CALLBACK (gnc_plugin_page_account_tree_selected), plugin_page); @@ -495,18 +493,16 @@ gnc_plugin_page_account_tree_init (GncPluginPageAccountTree *plugin_page) if (!page_list || plugin_page == page_list->data) { g_object_set_data(G_OBJECT(plugin_page), PLUGIN_PAGE_IMMUTABLE, - GINT_TO_POINTER(1)); + GINT_TO_POINTER(1)); } /* Create menu and toolbar information */ - action_group = - gnc_plugin_page_create_action_group(parent, - "GncPluginPageAccountTreeActions"); - gtk_action_group_add_actions(action_group, - gnc_plugin_page_account_tree_actions, - gnc_plugin_page_account_tree_n_actions, - plugin_page); - gnc_plugin_init_short_names (action_group, toolbar_labels); + simple_action_group = gnc_plugin_page_create_action_groupb (parent, "GncPluginPageAccountTreeActions"); + g_action_map_add_action_entries (G_ACTION_MAP(simple_action_group), + gnc_plugin_page_account_tree_actions, + gnc_plugin_page_account_tree_n_actions, + plugin_page); +//FIXMEb gnc_plugin_init_short_names (action_group, toolbar_labels); /* Visible types */ priv->fd.visible_types = -1; /* Start with all types */ @@ -516,7 +512,7 @@ gnc_plugin_page_account_tree_init (GncPluginPageAccountTree *plugin_page) priv->fd.filter_override = g_hash_table_new (g_direct_hash, g_direct_equal); LEAVE("page %p, priv %p, action group %p", - plugin_page, priv, action_group); + plugin_page, priv, simple_action_group); } static void @@ -934,8 +930,8 @@ gnc_plugin_page_account_tree_save_page (GncPluginPage *plugin_page, * @param group_name The group name to use when restoring data. */ static GncPluginPage * gnc_plugin_page_account_tree_recreate_page (GtkWidget *window, - GKeyFile *key_file, - const gchar *group_name) + GKeyFile *key_file, + const gchar *group_name) { GncPluginPageAccountTree *account_page; GncPluginPageAccountTreePrivate *priv; @@ -963,7 +959,9 @@ gnc_plugin_page_account_tree_recreate_page (GtkWidget *window, /* Callbacks */ static void -gnc_plugin_page_account_tree_summarybar_position_changed(gpointer prefs, gchar* pref, gpointer user_data) +gnc_plugin_page_account_tree_summarybar_position_changed (gpointer prefs, + gchar* pref, + gpointer user_data) { GncPluginPage *plugin_page; GncPluginPageAccountTree *page; @@ -993,8 +991,8 @@ gnc_plugin_page_account_tree_summarybar_position_changed(gpointer prefs, gchar* * registered in gnc-main-window.c. */ static gboolean gnc_plugin_page_account_tree_button_press_cb (GtkWidget *widget, - GdkEventButton *event, - GncPluginPage *page) + GdkEventButton *event, + GncPluginPage *page) { g_return_val_if_fail(GNC_IS_PLUGIN_PAGE(page), FALSE); @@ -1028,9 +1026,9 @@ gppat_open_account_common (GncPluginPageAccountTree *page, static void gnc_plugin_page_account_tree_double_click_cb (GtkTreeView *treeview, - GtkTreePath *path, - GtkTreeViewColumn *col, - GncPluginPageAccountTree *page) + GtkTreePath *path, + GtkTreeViewColumn *col, + GncPluginPageAccountTree *page) { GtkTreeModel *model; GtkTreeIter iter; @@ -1076,8 +1074,11 @@ gnc_plugin_page_account_tree_selection_changed_cb (GtkTreeSelection *selection, /* Command callbacks */ static void -gnc_plugin_page_account_tree_cmd_new_account (GtkAction *action, GncPluginPageAccountTree *page) +gnc_plugin_page_account_tree_cmd_new_account (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageAccountTree *page = user_data; Account *account = gnc_plugin_page_account_tree_get_current_account (page); GtkWindow *parent = GTK_WINDOW (gnc_plugin_page_get_window (GNC_PLUGIN_PAGE (page))); gnc_ui_new_account_window (parent, gnc_get_current_book(), @@ -1085,15 +1086,20 @@ gnc_plugin_page_account_tree_cmd_new_account (GtkAction *action, GncPluginPageAc } static void -gnc_plugin_page_account_tree_cmd_file_new_hierarchy (GtkAction *action, GncPluginPageAccountTree *page) +gnc_plugin_page_account_tree_cmd_file_new_hierarchy (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageAccountTree *page = user_data; gnc_ui_hierarchy_assistant(FALSE); } static void -gnc_plugin_page_account_tree_cmd_open_account (GtkAction *action, - GncPluginPageAccountTree *page) +gnc_plugin_page_account_tree_cmd_open_account (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageAccountTree *page = user_data; Account *account; g_return_if_fail (GNC_IS_PLUGIN_PAGE_ACCOUNT_TREE (page)); @@ -1102,9 +1108,11 @@ gnc_plugin_page_account_tree_cmd_open_account (GtkAction *action, } static void -gnc_plugin_page_account_tree_cmd_open_subaccounts (GtkAction *action, - GncPluginPageAccountTree *page) +gnc_plugin_page_account_tree_cmd_open_subaccounts (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageAccountTree *page = user_data; Account *account; g_return_if_fail (GNC_IS_PLUGIN_PAGE_ACCOUNT_TREE (page)); @@ -1113,11 +1121,14 @@ gnc_plugin_page_account_tree_cmd_open_subaccounts (GtkAction *action, } static void -gnc_plugin_page_account_tree_cmd_edit_account (GtkAction *action, GncPluginPageAccountTree *page) +gnc_plugin_page_account_tree_cmd_edit_account (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageAccountTree *page = user_data; Account *account; GtkWindow *parent = GTK_WINDOW (gnc_plugin_page_get_window (GNC_PLUGIN_PAGE (page))); - ENTER("action %p, page %p", action, page); + ENTER("action %p, page %p", simple, page); account = gnc_plugin_page_account_tree_get_current_account (page); g_return_if_fail (account != NULL); @@ -1127,11 +1138,14 @@ gnc_plugin_page_account_tree_cmd_edit_account (GtkAction *action, GncPluginPageA } static void -gnc_plugin_page_account_tree_cmd_find_account (GtkAction *action, GncPluginPageAccountTree *page) +gnc_plugin_page_account_tree_cmd_find_account (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageAccountTree *page = user_data; GtkWidget *window; - ENTER("action %p, page %p", action, page); + ENTER("action %p, page %p", simple, page); window = gnc_plugin_page_get_window(GNC_PLUGIN_PAGE(page)); @@ -1140,12 +1154,15 @@ gnc_plugin_page_account_tree_cmd_find_account (GtkAction *action, GncPluginPageA } static void -gnc_plugin_page_account_tree_cmd_find_account_popup (GtkAction *action, GncPluginPageAccountTree *page) +gnc_plugin_page_account_tree_cmd_find_account_popup (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageAccountTree *page = user_data; Account *account = NULL; GtkWidget *window; - ENTER("action %p, page %p", action, page); + ENTER("action %p, page %p", simple, page); account = gnc_plugin_page_account_tree_get_current_account (page); @@ -1156,12 +1173,15 @@ gnc_plugin_page_account_tree_cmd_find_account_popup (GtkAction *action, GncPlugi } static void -gnc_plugin_page_account_tree_cmd_cascade_account_properties (GtkAction *action, GncPluginPageAccountTree *page) +gnc_plugin_page_account_tree_cmd_cascade_account_properties (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageAccountTree *page = user_data; Account *account = NULL; GtkWidget *window; - ENTER("action %p, page %p", action, page); + ENTER("action %p, page %p", simple, page); account = gnc_plugin_page_account_tree_get_current_account (page); @@ -1507,8 +1527,11 @@ account_delete_dialog (Account *account, GtkWindow *parent, Adopters* adopt) } static void -gnc_plugin_page_account_tree_cmd_delete_account (GtkAction *action, GncPluginPageAccountTree *page) +gnc_plugin_page_account_tree_cmd_delete_account (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageAccountTree *page = user_data; Account *account = gnc_plugin_page_account_tree_get_current_account (page); gchar *acct_name; GtkWidget *window; @@ -1582,7 +1605,7 @@ gnc_plugin_page_account_tree_cmd_delete_account (GtkAction *action, GncPluginPag filter = g_object_get_data (G_OBJECT (dialog), DELETE_DIALOG_FILTER); gtk_widget_destroy(dialog); g_list_free(filter); - if (confirm_delete_account (action, page, adopt.trans.new_account, + if (confirm_delete_account (simple, page, adopt.trans.new_account, adopt.subtrans.new_account, adopt.subacct.new_account, adopt.delete_res) == GTK_RESPONSE_ACCEPT) @@ -1593,7 +1616,7 @@ gnc_plugin_page_account_tree_cmd_delete_account (GtkAction *action, GncPluginPag } static int -confirm_delete_account (GtkAction *action, GncPluginPageAccountTree *page, +confirm_delete_account (GSimpleAction *simple, GncPluginPageAccountTree *page, Account* ta, Account* sta, Account* saa, delete_helper_t delete_res) { @@ -1741,9 +1764,11 @@ void do_delete_account (Account* account, Account* saa, Account* sta, Account* t } static void -gnc_plugin_page_account_tree_cmd_renumber_accounts (GtkAction *action, - GncPluginPageAccountTree *page) +gnc_plugin_page_account_tree_cmd_renumber_accounts (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageAccountTree *page = user_data; Account *account; GtkWidget *window; @@ -1756,9 +1781,11 @@ gnc_plugin_page_account_tree_cmd_renumber_accounts (GtkAction *action, } static void -gnc_plugin_page_account_tree_cmd_refresh (GtkAction *action, - GncPluginPageAccountTree *page) +gnc_plugin_page_account_tree_cmd_refresh (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageAccountTree *page = user_data; GncPluginPageAccountTreePrivate *priv; g_return_if_fail(GNC_IS_PLUGIN_PAGE_ACCOUNT_TREE(page)); @@ -1772,13 +1799,15 @@ gnc_plugin_page_account_tree_cmd_refresh (GtkAction *action, /*********************/ static void -gnc_plugin_page_account_tree_cmd_view_filter_by (GtkAction *action, - GncPluginPageAccountTree *page) +gnc_plugin_page_account_tree_cmd_view_filter_by (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageAccountTree *page = user_data; GncPluginPageAccountTreePrivate *priv; g_return_if_fail(GNC_IS_PLUGIN_PAGE_ACCOUNT_TREE(page)); - ENTER("(action %p, page %p)", action, page); + ENTER("(action %p, page %p)", simple, page); priv = GNC_PLUGIN_PAGE_ACCOUNT_TREE_GET_PRIVATE(page); account_filter_dialog_create(&priv->fd, GNC_PLUGIN_PAGE(page)); @@ -1786,9 +1815,11 @@ gnc_plugin_page_account_tree_cmd_view_filter_by (GtkAction *action, } static void -gnc_plugin_page_account_tree_cmd_reconcile (GtkAction *action, - GncPluginPageAccountTree *page) +gnc_plugin_page_account_tree_cmd_reconcile (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageAccountTree *page = user_data; GtkWidget *window; Account *account; RecnWindow *recnData; @@ -1802,9 +1833,11 @@ gnc_plugin_page_account_tree_cmd_reconcile (GtkAction *action, } static void -gnc_plugin_page_account_tree_cmd_autoclear (GtkAction *action, - GncPluginPageAccountTree *page) +gnc_plugin_page_account_tree_cmd_autoclear (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageAccountTree *page = user_data; GtkWidget *window; Account *account; AutoClearWindow *autoClearData; @@ -1818,9 +1851,11 @@ gnc_plugin_page_account_tree_cmd_autoclear (GtkAction *action, } static void -gnc_plugin_page_account_tree_cmd_transfer (GtkAction *action, - GncPluginPageAccountTree *page) +gnc_plugin_page_account_tree_cmd_transfer (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageAccountTree *page = user_data; GtkWidget *window; Account *account; @@ -1830,9 +1865,11 @@ gnc_plugin_page_account_tree_cmd_transfer (GtkAction *action, } static void -gnc_plugin_page_account_tree_cmd_stock_split (GtkAction *action, - GncPluginPageAccountTree *page) +gnc_plugin_page_account_tree_cmd_stock_split (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageAccountTree *page = user_data; GtkWidget *window; Account *account; @@ -1842,9 +1879,11 @@ gnc_plugin_page_account_tree_cmd_stock_split (GtkAction *action, } static void -gnc_plugin_page_account_tree_cmd_edit_tax_options (GtkAction *action, - GncPluginPageAccountTree *page) +gnc_plugin_page_account_tree_cmd_edit_tax_options (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageAccountTree *page = user_data; GtkWidget *window; Account *account; @@ -1854,15 +1893,18 @@ gnc_plugin_page_account_tree_cmd_edit_tax_options (GtkAction *action, } static void -gnc_plugin_page_account_tree_cmd_lots (GtkAction *action, - GncPluginPageAccountTree *page) +gnc_plugin_page_account_tree_cmd_lots (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageAccountTree *page = user_data; Account *account = gnc_plugin_page_account_tree_get_current_account (page); GtkWidget *window = GNC_PLUGIN_PAGE (page)->window; gnc_lot_viewer_dialog (GTK_WINDOW(window), account); } -static gboolean scrub_kp_handler (GtkWidget *widget, GdkEventKey *event, gpointer data) +static gboolean +scrub_kp_handler (GtkWidget *widget, GdkEventKey *event, gpointer data) { if (event->length == 0) return FALSE; @@ -1885,8 +1927,11 @@ static gboolean scrub_kp_handler (GtkWidget *widget, GdkEventKey *event, gpointe } static void -gnc_plugin_page_account_tree_cmd_scrub (GtkAction *action, GncPluginPageAccountTree *page) +gnc_plugin_page_account_tree_cmd_scrub (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageAccountTree *page = user_data; Account *account = gnc_plugin_page_account_tree_get_current_account (page); GncWindow *window; gulong scrub_kp_handler_ID; @@ -1913,8 +1958,11 @@ gnc_plugin_page_account_tree_cmd_scrub (GtkAction *action, GncPluginPageAccountT } static void -gnc_plugin_page_account_tree_cmd_scrub_sub (GtkAction *action, GncPluginPageAccountTree *page) +gnc_plugin_page_account_tree_cmd_scrub_sub (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageAccountTree *page = user_data; Account *account = gnc_plugin_page_account_tree_get_current_account (page); GncWindow *window; gulong scrub_kp_handler_ID; @@ -1941,8 +1989,11 @@ gnc_plugin_page_account_tree_cmd_scrub_sub (GtkAction *action, GncPluginPageAcco } static void -gnc_plugin_page_account_tree_cmd_scrub_all (GtkAction *action, GncPluginPageAccountTree *page) +gnc_plugin_page_account_tree_cmd_scrub_all (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageAccountTree *page = user_data; Account *root = gnc_get_current_root_account (); GncWindow *window; gulong scrub_kp_handler_ID; diff --git a/gnucash/gnome/gnc-plugin-page-budget.c b/gnucash/gnome/gnc-plugin-page-budget.c index a2479635f9..dba4843d22 100644 --- a/gnucash/gnome/gnc-plugin-page-budget.c +++ b/gnucash/gnome/gnc-plugin-page-budget.c @@ -110,96 +110,88 @@ static void gppb_selection_changed_cb (GtkTreeSelection *selection, GncPluginPageBudget *page); #endif -static void gnc_plugin_page_budget_cmd_view_filter_by (GtkAction *action, - GncPluginPageBudget *page); +static void gnc_plugin_page_budget_cmd_view_filter_by (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_page_budget_cmd_open_account (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_page_budget_cmd_open_subaccounts (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_page_budget_cmd_delete_budget (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_page_budget_cmd_view_options (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_page_budget_cmd_estimate_budget (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_page_budget_cmd_allperiods_budget (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_page_budget_cmd_refresh (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_page_budget_cmd_budget_note (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_page_budget_cmd_budget_report (GSimpleAction *simple, GVariant *parameter, gpointer user_data); -/* Command Callbacks */ -static void gnc_plugin_page_budget_cmd_open_account (GtkAction *action, - GncPluginPageBudget *page); -static void gnc_plugin_page_budget_cmd_open_subaccounts (GtkAction *action, - GncPluginPageBudget *page); -static void gnc_plugin_page_budget_cmd_delete_budget (GtkAction *action, - GncPluginPageBudget *page); -static void gnc_plugin_page_budget_cmd_view_options (GtkAction *action, - GncPluginPageBudget *page); -static void gnc_plugin_page_budget_cmd_estimate_budget (GtkAction *action, - GncPluginPageBudget *page); -static void gnc_plugin_page_budget_cmd_allperiods_budget (GtkAction *action, - GncPluginPageBudget *page); -static void gnc_plugin_page_budget_cmd_refresh (GtkAction *action, - GncPluginPageBudget *page); -static void gnc_plugin_page_budget_cmd_budget_note (GtkAction *action, - GncPluginPageBudget *page); -static void gnc_plugin_page_budget_cmd_budget_report (GtkAction *action, - GncPluginPageBudget *page); static void allperiods_budget_helper (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data); -static GtkActionEntry gnc_plugin_page_budget_actions [] = +static GActionEntry gnc_plugin_page_budget_actions [] = { - /* Toplevel */ - { "FakeToplevel", "", NULL, NULL, NULL, NULL }, + { "FakeToplevel", NULL, NULL, NULL, NULL }, + { "OpenAccountAction", gnc_plugin_page_budget_cmd_open_account, NULL, NULL, NULL }, + { "OpenSubaccountsAction", gnc_plugin_page_budget_cmd_open_subaccounts, NULL, NULL, NULL }, + { "DeleteBudgetAction", gnc_plugin_page_budget_cmd_delete_budget, NULL, NULL, NULL }, + { "OptionsBudgetAction", gnc_plugin_page_budget_cmd_view_options, NULL, NULL, NULL }, + { "EstimateBudgetAction", gnc_plugin_page_budget_cmd_estimate_budget, NULL, NULL, NULL }, + { "AllPeriodsBudgetAction", gnc_plugin_page_budget_cmd_allperiods_budget, NULL, NULL, NULL }, + { "BudgetNoteAction", gnc_plugin_page_budget_cmd_budget_note, NULL, NULL, NULL }, + { "BudgetReportAction", gnc_plugin_page_budget_cmd_budget_report, NULL, NULL, NULL }, + { "ViewFilterByAction", gnc_plugin_page_budget_cmd_view_filter_by, NULL, NULL, NULL }, + { "ViewRefreshAction", gnc_plugin_page_budget_cmd_refresh, NULL, NULL, NULL }, +}; +static guint gnc_plugin_page_budget_n_actions = G_N_ELEMENTS(gnc_plugin_page_budget_actions); +static GncDisplayItem gnc_plugin_page_budget_display_items [] = +{ /* File menu */ { "OpenAccountAction", GNC_ICON_OPEN_ACCOUNT, N_("Open _Account"), NULL, - N_("Open the selected account."), - G_CALLBACK(gnc_plugin_page_budget_cmd_open_account) + N_("Open the selected account.") }, { "OpenSubaccountsAction", GNC_ICON_OPEN_ACCOUNT, N_("Open _Subaccounts"), NULL, - N_("Open the selected account and all its subaccounts."), - G_CALLBACK(gnc_plugin_page_budget_cmd_open_subaccounts) + N_("Open the selected account and all its subaccounts.") }, - /* Edit menu */ { "DeleteBudgetAction", GNC_ICON_DELETE_BUDGET, N_("_Delete Budget..."), - NULL, N_("Select this or another budget and delete it."), - G_CALLBACK(gnc_plugin_page_budget_cmd_delete_budget) + NULL, N_("Select this or another budget and delete it.") }, { "OptionsBudgetAction", "document-properties", N_("Budget _Options..."), - NULL, N_("Edit this budget's options."), - G_CALLBACK(gnc_plugin_page_budget_cmd_view_options) + NULL, N_("Edit this budget's options.") }, { "EstimateBudgetAction", "system-run", N_("Esti_mate Budget..."), NULL, - N_("Estimate a budget value for the selected accounts from past transactions."), - G_CALLBACK(gnc_plugin_page_budget_cmd_estimate_budget) + N_("Estimate a budget value for the selected accounts from past transactions.") }, { "AllPeriodsBudgetAction", "system-run", N_("_All Periods..."), NULL, - N_("Edit budget for all periods for the selected accounts."), - G_CALLBACK(gnc_plugin_page_budget_cmd_allperiods_budget) + N_("Edit budget for all periods for the selected accounts.") }, { "BudgetNoteAction", "text-x-generic", N_("Edit Note"), NULL, - N_("Edit note for the selected account and period."), - G_CALLBACK (gnc_plugin_page_budget_cmd_budget_note) + N_("Edit note for the selected account and period.") }, { "BudgetReportAction", "system-run", N_("Budget Report"), NULL, - N_("Run the budget report."), - G_CALLBACK (gnc_plugin_page_budget_cmd_budget_report) + N_("Run the budget report.") }, /* View menu */ { - "ViewFilterByAction", NULL, N_("_Filter By..."), NULL, NULL, - G_CALLBACK(gnc_plugin_page_budget_cmd_view_filter_by) + "ViewFilterByAction", NULL, N_("_Filter By..."), NULL, NULL }, { "ViewRefreshAction", "view-refresh", N_("_Refresh"), "r", - N_("Refresh this window."), - G_CALLBACK(gnc_plugin_page_budget_cmd_refresh) + N_("Refresh this window.") }, - }; +/** The number of display items provided by this plugin. */ +static guint gnc_plugin_page_budget_n_display_items = G_N_ELEMENTS(gnc_plugin_page_budget_display_items); static const gchar *writeable_actions[] = { @@ -212,9 +204,6 @@ static const gchar *writeable_actions[] = NULL }; -static guint gnc_plugin_page_budget_n_actions = - G_N_ELEMENTS(gnc_plugin_page_budget_actions); - #if 0 static const gchar *actions_requiring_account[] = { @@ -250,6 +239,8 @@ typedef struct GncPluginPageBudgetPrivate GtkActionGroup *action_group; guint merge_id; GtkUIManager *ui_merge; + GtkBuilder *builder; + GSimpleActionGroup *simple_action_group; GncBudgetView* budget_view; GtkTreeView *tree_view; @@ -348,7 +339,8 @@ gnc_plugin_page_budget_class_init (GncPluginPageBudgetClass *klass) static void gnc_plugin_page_budget_init (GncPluginPageBudget *plugin_page) { - GtkActionGroup *action_group; +// GtkActionGroup *action_group; + GSimpleActionGroup *simple_action_group; GncPluginPageBudgetPrivate *priv; GncPluginPage *parent; @@ -360,24 +352,22 @@ gnc_plugin_page_budget_init (GncPluginPageBudget *plugin_page) g_object_set (G_OBJECT(plugin_page), "page-name", _("Budget"), "page-uri", "default:", - "ui-description", "gnc-plugin-page-budget-ui.xml", + "ui-description", "gnc-plugin-page-budget.ui", NULL); /* change me when the system supports multiple books */ gnc_plugin_page_add_book (parent, gnc_get_current_book()); /* Create menu and toolbar information */ - action_group = - gnc_plugin_page_create_action_group (parent, - "GncPluginPageBudgetActions"); - gtk_action_group_add_actions (action_group, - gnc_plugin_page_budget_actions, - gnc_plugin_page_budget_n_actions, - plugin_page); - gnc_plugin_init_short_names (action_group, toolbar_labels); + simple_action_group = gnc_plugin_page_create_action_groupb (parent, "GncPluginPageBudgetActions"); + g_action_map_add_action_entries (G_ACTION_MAP(simple_action_group), + gnc_plugin_page_budget_actions, + gnc_plugin_page_budget_n_actions, + plugin_page); +//FIXMEb gnc_plugin_init_short_names (action_group, toolbar_labels); if (qof_book_is_readonly (gnc_get_current_book())) - gnc_plugin_update_actions (action_group, writeable_actions, + gnc_plugin_update_actionsb (simple_action_group, writeable_actions, "sensitive", FALSE); /* Visible types */ @@ -392,7 +382,7 @@ gnc_plugin_page_budget_init (GncPluginPageBudget *plugin_page) recurrenceSet (&priv->r, 1, PERIOD_MONTH, NULL, WEEKEND_ADJ_NONE); LEAVE("page %p, priv %p, action group %p", - plugin_page, priv, action_group); + plugin_page, priv, simple_action_group); } @@ -753,9 +743,11 @@ gppb_selection_changed_cb (GtkTreeSelection *selection, * Command callbacks * ********************/ static void -gnc_plugin_page_budget_cmd_open_account (GtkAction *action, - GncPluginPageBudget *page) +gnc_plugin_page_budget_cmd_open_account (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncPluginPageBudget *page = user_data; GncPluginPageBudgetPrivate *priv; GtkWidget *window; GncPluginPage *new_page; @@ -778,9 +770,11 @@ gnc_plugin_page_budget_cmd_open_account (GtkAction *action, static void -gnc_plugin_page_budget_cmd_open_subaccounts (GtkAction *action, - GncPluginPageBudget *page) +gnc_plugin_page_budget_cmd_open_subaccounts (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncPluginPageBudget *page = user_data; GncPluginPageBudgetPrivate *priv; GtkWidget *window; GncPluginPage *new_page; @@ -803,9 +797,11 @@ gnc_plugin_page_budget_cmd_open_subaccounts (GtkAction *action, static void -gnc_plugin_page_budget_cmd_delete_budget (GtkAction *action, - GncPluginPageBudget *page) +gnc_plugin_page_budget_cmd_delete_budget (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncPluginPageBudget *page = user_data; GncPluginPageBudgetPrivate *priv; GncBudget *budget; @@ -822,9 +818,11 @@ gnc_plugin_page_budget_cmd_delete_budget (GtkAction *action, /* Options Dialog */ /******************************/ static void -gnc_plugin_page_budget_cmd_view_options (GtkAction *action, - GncPluginPageBudget *page) +gnc_plugin_page_budget_cmd_view_options (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncPluginPageBudget *page = user_data; GncPluginPageBudgetPrivate *priv; GncRecurrence *gr; GtkBuilder *builder; @@ -1011,9 +1009,11 @@ estimate_budget_helper (GtkTreeModel *model, GtkTreePath *path, /* Estimate Dialog */ /*******************************/ static void -gnc_plugin_page_budget_cmd_estimate_budget (GtkAction *action, - GncPluginPageBudget *page) +gnc_plugin_page_budget_cmd_estimate_budget (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncPluginPageBudget *page = user_data; GncPluginPageBudgetPrivate *priv; GtkTreeSelection *sel; GtkWidget *dialog, *gde, *dtr, *hb, *avg; @@ -1140,9 +1140,11 @@ allperiods_budget_helper (GtkTreeModel *model, GtkTreePath *path, /* All Periods Value Dialog */ /*******************************/ static void -gnc_plugin_page_budget_cmd_allperiods_budget (GtkAction *action, - GncPluginPageBudget *page) +gnc_plugin_page_budget_cmd_allperiods_budget (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncPluginPageBudget *page = user_data; GncPluginPageBudgetPrivate *priv; GtkTreeSelection *sel; GtkWidget *dialog, *gde, *val, *dtr, *add, *mult; @@ -1224,9 +1226,11 @@ gnc_plugin_page_budget_cmd_allperiods_budget (GtkAction *action, } static void -gnc_plugin_page_budget_cmd_budget_note(GtkAction *action, - GncPluginPageBudget *page) +gnc_plugin_page_budget_cmd_budget_note (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncPluginPageBudget *page = user_data; GncPluginPageBudgetPrivate *priv; GtkTreeSelection *sel; GtkWidget *dialog, *note; @@ -1313,9 +1317,11 @@ equal_fn (gpointer find_data, gpointer elt_data) whereby report's report-type matches a budget report, and the report's budget option value matches the current budget. */ static void -gnc_plugin_page_budget_cmd_budget_report (GtkAction *action, - GncPluginPageBudget *page) +gnc_plugin_page_budget_cmd_budget_report (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncPluginPageBudget *page = user_data; GncPluginPageBudgetPrivate *priv; g_return_if_fail (GNC_IS_PLUGIN_PAGE_BUDGET (page)); @@ -1346,13 +1352,15 @@ gnc_plugin_page_budget_cmd_budget_report (GtkAction *action, } static void -gnc_plugin_page_budget_cmd_view_filter_by (GtkAction *action, - GncPluginPageBudget *page) +gnc_plugin_page_budget_cmd_view_filter_by (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncPluginPageBudget *page = user_data; GncPluginPageBudgetPrivate *priv; g_return_if_fail(GNC_IS_PLUGIN_PAGE_BUDGET(page)); - ENTER("(action %p, page %p)", action, page); + ENTER("(action %p, page %p)", simple, page); priv = GNC_PLUGIN_PAGE_BUDGET_GET_PRIVATE(page); account_filter_dialog_create (&priv->fd, GNC_PLUGIN_PAGE(page)); @@ -1361,13 +1369,15 @@ gnc_plugin_page_budget_cmd_view_filter_by (GtkAction *action, } static void -gnc_plugin_page_budget_cmd_refresh (GtkAction *action, - GncPluginPageBudget *page) +gnc_plugin_page_budget_cmd_refresh (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncPluginPageBudget *page = user_data; GncPluginPageBudgetPrivate *priv; g_return_if_fail (GNC_IS_PLUGIN_PAGE_BUDGET(page)); - ENTER("(action %p, page %p)", action, page); + ENTER("(action %p, page %p)", simple, page); priv = GNC_PLUGIN_PAGE_BUDGET_GET_PRIVATE(page); diff --git a/gnucash/gnome/gnc-plugin-page-invoice.c b/gnucash/gnome/gnc-plugin-page-invoice.c index 596b46900b..ce37164267 100644 --- a/gnucash/gnome/gnc-plugin-page-invoice.c +++ b/gnucash/gnome/gnc-plugin-page-invoice.c @@ -61,197 +61,190 @@ static void gnc_plugin_page_invoice_save_page (GncPluginPage *plugin_page, GKeyF static GncPluginPage *gnc_plugin_page_invoice_recreate_page (GtkWidget *window, GKeyFile *file, const gchar *group); static void gnc_plugin_page_invoice_window_changed (GncPluginPage *plugin_page, GtkWidget *window); -static void gnc_plugin_page_invoice_summarybar_position_changed(gpointer prefs, gchar* pref, gpointer user_data); +static void gnc_plugin_page_invoice_summarybar_position_changed (gpointer prefs, gchar* pref, gpointer user_data); /* Command callbacks */ -static void gnc_plugin_page_invoice_cmd_new_invoice (GtkAction *action, GncPluginPageInvoice *plugin_page); -static void gnc_plugin_page_invoice_cmd_new_account (GtkAction *action, GncPluginPageInvoice *plugin_page); -static void gnc_plugin_page_invoice_cmd_print (GtkAction *action, GncPluginPageInvoice *plugin_page); -static void gnc_plugin_page_invoice_cmd_cut (GtkAction *action, GncPluginPageInvoice *plugin_page); -static void gnc_plugin_page_invoice_cmd_copy (GtkAction *action, GncPluginPageInvoice *plugin_page); -static void gnc_plugin_page_invoice_cmd_paste (GtkAction *action, GncPluginPageInvoice *plugin_page); -static void gnc_plugin_page_invoice_cmd_edit (GtkAction *action, GncPluginPageInvoice *plugin_page); -static void gnc_plugin_page_invoice_cmd_duplicateInvoice (GtkAction *action, GncPluginPageInvoice *plugin_page); -static void gnc_plugin_page_invoice_cmd_post (GtkAction *action, GncPluginPageInvoice *plugin_page); -static void gnc_plugin_page_invoice_cmd_unpost (GtkAction *action, GncPluginPageInvoice *plugin_page); -static void gnc_plugin_page_invoice_cmd_refresh (GtkAction *action, GncPluginPageInvoice *plugin_page); +static void gnc_plugin_page_invoice_cmd_new_invoice (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_invoice_cmd_new_account (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_invoice_cmd_print (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_invoice_cmd_cut (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_invoice_cmd_copy (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_invoice_cmd_paste (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_invoice_cmd_edit (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_invoice_cmd_duplicateInvoice (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_invoice_cmd_post (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_invoice_cmd_unpost (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_invoice_cmd_refresh (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_invoice_cmd_sort_changed (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_page_invoice_cmd_enter (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_invoice_cmd_cancel (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_invoice_cmd_delete (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_invoice_cmd_blank (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_invoice_cmd_duplicateEntry (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_invoice_cmd_pay_invoice (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_invoice_cmd_save_layout (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_invoice_cmd_reset_layout (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_invoice_cmd_link (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_invoice_cmd_link_remove (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_invoice_cmd_link_open (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_invoice_cmd_company_report (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_invoice_cmd_entryUp (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_invoice_cmd_entryDown (GSimpleAction *simple, GVariant *paramter, gpointer user_data); -static void gnc_plugin_page_invoice_cmd_sort_changed (GtkAction *action, - GtkRadioAction *current, - GncPluginPageInvoice *plugin_page); - -static void gnc_plugin_page_invoice_cmd_enter (GtkAction *action, GncPluginPageInvoice *plugin_page); -static void gnc_plugin_page_invoice_cmd_cancel (GtkAction *action, GncPluginPageInvoice *plugin_page); -static void gnc_plugin_page_invoice_cmd_delete (GtkAction *action, GncPluginPageInvoice *plugin_page); -static void gnc_plugin_page_invoice_cmd_blank (GtkAction *action, GncPluginPageInvoice *plugin_page); -static void gnc_plugin_page_invoice_cmd_duplicateEntry (GtkAction *action, GncPluginPageInvoice *plugin_page); -static void gnc_plugin_page_invoice_cmd_pay_invoice (GtkAction *action, GncPluginPageInvoice *plugin_page); -static void gnc_plugin_page_invoice_cmd_save_layout (GtkAction *action, GncPluginPageInvoice *plugin_page); -static void gnc_plugin_page_invoice_cmd_reset_layout (GtkAction *action, GncPluginPageInvoice *plugin_page); -static void gnc_plugin_page_invoice_cmd_link (GtkAction *action, GncPluginPageInvoice *plugin_page); -static void gnc_plugin_page_invoice_cmd_link_remove (GtkAction *action, GncPluginPageInvoice *plugin_page); -static void gnc_plugin_page_invoice_cmd_link_open (GtkAction *action, GncPluginPageInvoice *plugin_page); -static void gnc_plugin_page_invoice_cmd_company_report (GtkAction *action, GncPluginPageInvoice *plugin_page); - -static void gnc_plugin_page_redraw_help_cb( GnucashRegister *gsr, GncPluginPageInvoice *invoice_page ); +static void gnc_plugin_page_redraw_help_cb (GnucashRegister *gsr, GncPluginPageInvoice *invoice_page); static void gnc_plugin_page_invoice_refresh_cb (GHashTable *changes, gpointer user_data); -static void gnc_plugin_page_invoice_cmd_entryUp (GtkAction *action, GncPluginPageInvoice *plugin_page); -static void gnc_plugin_page_invoice_cmd_entryDown (GtkAction *action, GncPluginPageInvoice *plugin_page); + +static void +change_radio_state (GSimpleAction *simple, + GVariant *state, + gpointer user_data) +{ + g_simple_action_set_state (simple, state); +} /************************************************************ * Actions * ************************************************************/ -static GtkActionEntry gnc_plugin_page_invoice_actions [] = +static GActionEntry gnc_plugin_page_invoice_actions [] = { - /* Toplevel */ - { "FakeToplevel", NULL, "", NULL, NULL, NULL }, - { "SortOrderAction", NULL, N_("Sort _Order"), NULL, NULL, NULL }, + { "SortOrderAction", NULL, NULL, NULL, NULL }, + { "FileNewAccountAction", gnc_plugin_page_invoice_cmd_new_account, NULL, NULL, NULL }, + { "FilePrintAction", gnc_plugin_page_invoice_cmd_print, NULL, NULL, NULL }, + { "EditCutAction", gnc_plugin_page_invoice_cmd_cut, NULL, NULL, NULL }, + { "EditCopyAction", gnc_plugin_page_invoice_cmd_copy, NULL, NULL, NULL }, + { "EditPasteAction", gnc_plugin_page_invoice_cmd_paste, NULL, NULL, NULL }, + { "EditEditInvoiceAction", gnc_plugin_page_invoice_cmd_edit, NULL, NULL, NULL }, + { "EditDuplicateInvoiceAction", gnc_plugin_page_invoice_cmd_duplicateInvoice, NULL, NULL, NULL }, + { "EditPostInvoiceAction", gnc_plugin_page_invoice_cmd_post, NULL, NULL, NULL }, + { "EditUnpostInvoiceAction", gnc_plugin_page_invoice_cmd_unpost, NULL, NULL, NULL }, + { "ViewRefreshAction", gnc_plugin_page_invoice_cmd_refresh, NULL, NULL, NULL }, + { "ViewSaveLayoutAction", gnc_plugin_page_invoice_cmd_save_layout, NULL, NULL, NULL }, + { "ViewResetLayoutAction", gnc_plugin_page_invoice_cmd_reset_layout, NULL, NULL, NULL }, + { "RecordEntryAction", gnc_plugin_page_invoice_cmd_enter, NULL, NULL, NULL }, + { "CancelEntryAction", gnc_plugin_page_invoice_cmd_cancel, NULL, NULL, NULL }, + { "DeleteEntryAction", gnc_plugin_page_invoice_cmd_delete, NULL, NULL, NULL }, + { "BlankEntryAction", gnc_plugin_page_invoice_cmd_blank, NULL, NULL, NULL }, + { "DuplicateEntryAction", gnc_plugin_page_invoice_cmd_duplicateEntry, NULL, NULL, NULL }, + { "EntryUpAction", gnc_plugin_page_invoice_cmd_entryUp, NULL, NULL, NULL }, + { "EntryDownAction", gnc_plugin_page_invoice_cmd_entryDown, NULL, NULL, NULL }, + { "BusinessNewInvoiceAction", gnc_plugin_page_invoice_cmd_new_invoice, NULL, NULL, NULL }, + { "BusinessLinkAction", gnc_plugin_page_invoice_cmd_link, NULL, NULL, NULL }, + { "BusinessLinkOpenAction", gnc_plugin_page_invoice_cmd_link_open, NULL, NULL, NULL }, + { "ToolsProcessPaymentAction", gnc_plugin_page_invoice_cmd_pay_invoice, NULL, NULL, NULL }, + { "ReportsCompanyReportAction", gnc_plugin_page_invoice_cmd_company_report, NULL, NULL, NULL }, + { "SortOrderRadio", gnc_plugin_page_invoice_cmd_sort_changed, "n", 0, change_radio_state }, +}; +static guint gnc_plugin_page_invoice_n_actions = G_N_ELEMENTS(gnc_plugin_page_invoice_actions); +static GncDisplayItem gnc_plugin_page_invoice_display_items [] = +{ + { "SortOrderAction", NULL, N_("Sort _Order"), NULL, NULL }, /* File menu */ { "FileNewAccountAction", GNC_ICON_NEW_ACCOUNT, N_("New _Account..."), NULL, - N_("Create a new account"), - G_CALLBACK (gnc_plugin_page_invoice_cmd_new_account) + N_("Create a new account") }, { - "FilePrintAction", "document-print", "_Print Invoice", "p", - "Make a printable invoice", - G_CALLBACK (gnc_plugin_page_invoice_cmd_print) + "FilePrintAction", "document-print", N_("_Print Invoice"), "p", + N_("Make a printable invoice") }, - /* Edit menu */ { "EditCutAction", "edit-cut", N_("_Cut"), "X", - NULL, - G_CALLBACK (gnc_plugin_page_invoice_cmd_cut) + NULL }, { "EditCopyAction", "edit-copy", N_("Copy"), "C", - NULL, - G_CALLBACK (gnc_plugin_page_invoice_cmd_copy) + NULL }, { "EditPasteAction", "edit-paste", N_("_Paste"), "V", - NULL, - G_CALLBACK (gnc_plugin_page_invoice_cmd_paste) + NULL }, { "EditEditInvoiceAction", GNC_ICON_INVOICE_EDIT, "_Edit Invoice", NULL, - "Edit this invoice", - G_CALLBACK (gnc_plugin_page_invoice_cmd_edit) + "Edit this invoice" }, { "EditDuplicateInvoiceAction", GNC_ICON_INVOICE_DUPLICATE, "_Duplicate Invoice", - NULL, "Create a new invoice as a duplicate of the current one", - G_CALLBACK (gnc_plugin_page_invoice_cmd_duplicateInvoice) + NULL, "Create a new invoice as a duplicate of the current one" }, { "EditPostInvoiceAction", GNC_ICON_INVOICE_POST, "_Post Invoice", NULL, - "Post this invoice to your Chart of Accounts", - G_CALLBACK (gnc_plugin_page_invoice_cmd_post) + "Post this invoice to your Chart of Accounts" }, { "EditUnpostInvoiceAction", GNC_ICON_INVOICE_UNPOST, "_Unpost Invoice", NULL, - "Unpost this invoice and make it editable", - G_CALLBACK (gnc_plugin_page_invoice_cmd_unpost) + "Unpost this invoice and make it editable" }, - /* View menu */ { "ViewRefreshAction", "view-refresh", N_("_Refresh"), "r", - N_("Refresh this window"), - G_CALLBACK (gnc_plugin_page_invoice_cmd_refresh) + N_("Refresh this window") }, { "ViewSaveLayoutAction", NULL, "_Use as Default Layout for Customer Documents", NULL, - "Use the current layout as default for all customer invoices and credit notes", - G_CALLBACK (gnc_plugin_page_invoice_cmd_save_layout) + "Use the current layout as default for all customer invoices and credit notes" }, { "ViewResetLayoutAction", NULL, "_Reset Default Layout for Customer Documents", NULL, - "Reset default layout for all customer invoices and credit notes back to built-in defaults and update the current page accordingly", - G_CALLBACK (gnc_plugin_page_invoice_cmd_reset_layout) + "Reset default layout for all customer invoices and credit notes back to built-in defaults and update the current page accordingly" }, - /* Actions menu */ { "RecordEntryAction", "list-add", N_("_Enter"), NULL, - N_("Record the current entry"), - G_CALLBACK (gnc_plugin_page_invoice_cmd_enter) + N_("Record the current entry") }, { "CancelEntryAction", "process-stop", N_("_Cancel"), NULL, - N_("Cancel the current entry"), - G_CALLBACK (gnc_plugin_page_invoice_cmd_cancel) + N_("Cancel the current entry") }, { "DeleteEntryAction", "edit-delete", N_("_Delete"), NULL, - N_("Delete the current entry"), - G_CALLBACK (gnc_plugin_page_invoice_cmd_delete) + N_("Delete the current entry") }, { "BlankEntryAction", "go-bottom", N_("_Blank"), NULL, - "Move to the blank entry at the bottom of the Invoice", - G_CALLBACK (gnc_plugin_page_invoice_cmd_blank) + "Move to the blank entry at the bottom of the Invoice" }, { "DuplicateEntryAction", "edit-copy", N_("Dup_licate Entry"), NULL, - N_("Make a copy of the current entry"), - G_CALLBACK (gnc_plugin_page_invoice_cmd_duplicateEntry) + N_("Make a copy of the current entry") }, { "EntryUpAction", "pan-up-symbolic", N_("Move Entry _Up"), NULL, - N_("Move the current entry one row upwards"), - G_CALLBACK (gnc_plugin_page_invoice_cmd_entryUp) + N_("Move the current entry one row upwards") }, { "EntryDownAction", "pan-down-symbolic", N_("Move Entry Do_wn"), NULL, - N_("Move the current entry one row downwards"), - G_CALLBACK (gnc_plugin_page_invoice_cmd_entryDown) + N_("Move the current entry one row downwards") }, - /* Business menu */ { "BusinessNewInvoiceAction", GNC_ICON_INVOICE_NEW, "New _Invoice", "", - "Create a new invoice for the same owner as the current one", - G_CALLBACK (gnc_plugin_page_invoice_cmd_new_invoice) + "Create a new invoice for the same owner as the current one" }, { "BusinessLinkAction", NULL, "_Manage Document Link...", NULL, - "Manage link of an external document to this item.", - G_CALLBACK (gnc_plugin_page_invoice_cmd_link) + "Manage link of an external document to this item." }, { "BusinessLinkOpenAction", NULL, "_Open Linked Document", NULL, - "Open the linked document", - G_CALLBACK (gnc_plugin_page_invoice_cmd_link_open) + "Open the linked document" }, { "ToolsProcessPaymentAction", GNC_ICON_INVOICE_PAY, "_Pay Invoice", NULL, - "Enter a payment for the owner of this invoice", - G_CALLBACK (gnc_plugin_page_invoice_cmd_pay_invoice) + "Enter a payment for the owner of this invoice" }, - /* Reports menu */ { "ReportsCompanyReportAction", NULL, N_("_Company Report"), NULL, - "Open a company report window for the owner of this invoice", - G_CALLBACK (gnc_plugin_page_invoice_cmd_company_report) + "Open a company report window for the owner of this invoice" }, }; -static guint gnc_plugin_page_invoice_n_actions = G_N_ELEMENTS (gnc_plugin_page_invoice_actions); - -static GtkRadioActionEntry radio_entries [] = -{ - { "SortStandardAction", NULL, N_("_Standard"), NULL, N_("Keep normal invoice order"), INVSORT_BY_STANDARD }, - { "SortDateAction", NULL, N_("_Date"), NULL, N_("Sort by date"), INVSORT_BY_DATE }, - { "SortDateEntryAction", NULL, N_("Date of _Entry"), NULL, N_("Sort by the date of entry"), INVSORT_BY_DATE_ENTERED }, - { "SortQuantityAction", NULL, N_("_Quantity"), NULL, N_("Sort by quantity"), INVSORT_BY_QTY }, - { "SortPriceAction", NULL, N_("_Price"), NULL, N_("Sort by price"), INVSORT_BY_PRICE }, - { "SortDescriptionAction", NULL, N_("Descri_ption"), NULL, N_("Sort by description"), INVSORT_BY_DESC }, -}; -static guint n_radio_entries = G_N_ELEMENTS (radio_entries); +/** The number of display items provided by this plugin. */ +static guint gnc_plugin_page_invoice_n_display_items = G_N_ELEMENTS(gnc_plugin_page_invoice_display_items); static const gchar *invoice_book_readwrite_actions[] = { @@ -560,7 +553,8 @@ static void gnc_plugin_page_invoice_init (GncPluginPageInvoice *plugin_page) { GncPluginPage *parent; - GtkActionGroup *action_group; +// GtkActionGroup *action_group; + GSimpleActionGroup *simple_action_group; gboolean use_new; /* Init parent declared variables */ @@ -569,26 +563,27 @@ gnc_plugin_page_invoice_init (GncPluginPageInvoice *plugin_page) g_object_set(G_OBJECT(plugin_page), "page-name", _("Invoice"), "page-uri", "default:", - "ui-description", "gnc-plugin-page-invoice-ui.xml", + "ui-description", "gnc-plugin-page-invoice.ui", "use-new-window", use_new, (char *)NULL); /* change me when the system supports multiple books */ - gnc_plugin_page_add_book(parent, gnc_get_current_book()); + gnc_plugin_page_add_book (parent, gnc_get_current_book()); /* Create menu and toolbar information */ - action_group = - gnc_plugin_page_create_action_group(parent, - "GncPluginPageInvoiceActions"); - gtk_action_group_add_actions (action_group, gnc_plugin_page_invoice_actions, - gnc_plugin_page_invoice_n_actions, plugin_page); - gtk_action_group_add_radio_actions (action_group, - radio_entries, n_radio_entries, - REG_STYLE_LEDGER, - G_CALLBACK(gnc_plugin_page_invoice_cmd_sort_changed), - plugin_page); + simple_action_group = gnc_plugin_page_create_action_groupb (parent,"GncPluginPageInvoiceActions"); + g_action_map_add_action_entries (G_ACTION_MAP(simple_action_group), + gnc_plugin_page_invoice_actions, + gnc_plugin_page_invoice_n_actions, + plugin_page); - gnc_plugin_init_short_names (action_group, toolbar_labels); +//FIXMEb gtk_action_group_add_radio_actions (action_group, +// radio_entries, n_radio_entries, +// REG_STYLE_LEDGER, +// G_CALLBACK(gnc_plugin_page_invoice_cmd_sort_changed), +// plugin_page); + +//FIXMEb gnc_plugin_init_short_names (action_group, toolbar_labels); } static void @@ -973,7 +968,9 @@ gnc_plugin_page_invoice_window_changed (GncPluginPage *plugin_page, static void -gnc_plugin_page_invoice_summarybar_position_changed(gpointer prefs, gchar *pref, gpointer user_data) +gnc_plugin_page_invoice_summarybar_position_changed (gpointer prefs, + gchar *pref, + gpointer user_data) { GncPluginPage *plugin_page; GncPluginPageInvoice *page; @@ -1000,15 +997,17 @@ gnc_plugin_page_invoice_summarybar_position_changed(gpointer prefs, gchar *pref, /************************************************************/ static void -gnc_plugin_page_invoice_cmd_new_invoice (GtkAction *action, - GncPluginPageInvoice *plugin_page) +gnc_plugin_page_invoice_cmd_new_invoice (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageInvoice *plugin_page = user_data; GncPluginPageInvoicePrivate *priv; GtkWindow *parent; g_return_if_fail(GNC_IS_PLUGIN_PAGE_INVOICE(plugin_page)); - ENTER("(action %p, plugin_page %p)", action, plugin_page); + ENTER("(action %p, plugin_page %p)", simple, plugin_page); priv = GNC_PLUGIN_PAGE_INVOICE_GET_PRIVATE(plugin_page); parent = GTK_WINDOW (gnc_plugin_page_get_window (GNC_PLUGIN_PAGE (plugin_page))); gnc_invoice_window_new_invoice_cb(parent, priv->iw); @@ -1016,27 +1015,31 @@ gnc_plugin_page_invoice_cmd_new_invoice (GtkAction *action, } static void -gnc_plugin_page_invoice_cmd_new_account (GtkAction *action, - GncPluginPageInvoice *plugin_page) +gnc_plugin_page_invoice_cmd_new_account (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageInvoice *plugin_page = user_data; GtkWindow *parent = NULL; g_return_if_fail(GNC_IS_PLUGIN_PAGE_INVOICE(plugin_page)); parent = GTK_WINDOW (gnc_plugin_page_get_window (GNC_PLUGIN_PAGE (plugin_page))); - ENTER("(action %p, plugin_page %p)", action, plugin_page); + ENTER("(action %p, plugin_page %p)", simple, plugin_page); gnc_ui_new_account_window (parent, gnc_get_current_book(), NULL); LEAVE(" "); } static void -gnc_plugin_page_invoice_cmd_print (GtkAction *action, - GncPluginPageInvoice *plugin_page) +gnc_plugin_page_invoice_cmd_print (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageInvoice *plugin_page = user_data; GncPluginPageInvoicePrivate *priv; GtkWindow *parent; g_return_if_fail(GNC_IS_PLUGIN_PAGE_INVOICE(plugin_page)); - ENTER("(action %p, plugin_page %p)", action, plugin_page); + ENTER("(action %p, plugin_page %p)", simple, plugin_page); priv = GNC_PLUGIN_PAGE_INVOICE_GET_PRIVATE(plugin_page); parent = GTK_WINDOW (gnc_plugin_page_get_window (GNC_PLUGIN_PAGE (plugin_page))); gnc_invoice_window_printCB (parent, priv->iw); @@ -1044,57 +1047,65 @@ gnc_plugin_page_invoice_cmd_print (GtkAction *action, } static void -gnc_plugin_page_invoice_cmd_cut (GtkAction *action, - GncPluginPageInvoice *plugin_page) +gnc_plugin_page_invoice_cmd_cut (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageInvoice *plugin_page = user_data; GncPluginPageInvoicePrivate *priv; g_return_if_fail(GNC_IS_PLUGIN_PAGE_INVOICE(plugin_page)); - ENTER("(action %p, plugin_page %p)", action, plugin_page); + ENTER("(action %p, plugin_page %p)", simple, plugin_page); priv = GNC_PLUGIN_PAGE_INVOICE_GET_PRIVATE(plugin_page); gnc_invoice_window_cut_cb(NULL, priv->iw); LEAVE(" "); } static void -gnc_plugin_page_invoice_cmd_copy (GtkAction *action, - GncPluginPageInvoice *plugin_page) +gnc_plugin_page_invoice_cmd_copy (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageInvoice *plugin_page = user_data; GncPluginPageInvoicePrivate *priv; g_return_if_fail(GNC_IS_PLUGIN_PAGE_INVOICE(plugin_page)); - ENTER("(action %p, plugin_page %p)", action, plugin_page); + ENTER("(action %p, plugin_page %p)", simple, plugin_page); priv = GNC_PLUGIN_PAGE_INVOICE_GET_PRIVATE(plugin_page); gnc_invoice_window_copy_cb(NULL, priv->iw); LEAVE(" "); } static void -gnc_plugin_page_invoice_cmd_paste (GtkAction *action, - GncPluginPageInvoice *plugin_page) +gnc_plugin_page_invoice_cmd_paste (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageInvoice *plugin_page = user_data; GncPluginPageInvoicePrivate *priv; g_return_if_fail(GNC_IS_PLUGIN_PAGE_INVOICE(plugin_page)); - ENTER("(action %p, plugin_page %p)", action, plugin_page); + ENTER("(action %p, plugin_page %p)", simple, plugin_page); priv = GNC_PLUGIN_PAGE_INVOICE_GET_PRIVATE(plugin_page); gnc_invoice_window_paste_cb(NULL, priv->iw); LEAVE(" "); } static void -gnc_plugin_page_invoice_cmd_edit (GtkAction *action, - GncPluginPageInvoice *plugin_page) +gnc_plugin_page_invoice_cmd_edit (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageInvoice *plugin_page = user_data; GncPluginPageInvoicePrivate *priv; GtkWindow *parent; g_return_if_fail(GNC_IS_PLUGIN_PAGE_INVOICE(plugin_page)); - ENTER("(action %p, plugin_page %p)", action, plugin_page); + ENTER("(action %p, plugin_page %p)", simple, plugin_page); priv = GNC_PLUGIN_PAGE_INVOICE_GET_PRIVATE(plugin_page); parent = GTK_WINDOW (gnc_plugin_page_get_window (GNC_PLUGIN_PAGE (plugin_page))); gnc_invoice_window_editCB (parent, priv->iw); @@ -1102,15 +1113,17 @@ gnc_plugin_page_invoice_cmd_edit (GtkAction *action, } static void -gnc_plugin_page_invoice_cmd_duplicateInvoice (GtkAction *action, - GncPluginPageInvoice *plugin_page) +gnc_plugin_page_invoice_cmd_duplicateInvoice (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageInvoice *plugin_page = user_data; GncPluginPageInvoicePrivate *priv; GtkWindow *parent; g_return_if_fail(GNC_IS_PLUGIN_PAGE_INVOICE(plugin_page)); - ENTER("(action %p, plugin_page %p)", action, plugin_page); + ENTER("(action %p, plugin_page %p)", simple, plugin_page); priv = GNC_PLUGIN_PAGE_INVOICE_GET_PRIVATE(plugin_page); parent = GTK_WINDOW (gnc_plugin_page_get_window (GNC_PLUGIN_PAGE (plugin_page))); gnc_invoice_window_duplicateInvoiceCB(parent, priv->iw); @@ -1118,66 +1131,68 @@ gnc_plugin_page_invoice_cmd_duplicateInvoice (GtkAction *action, } static void -gnc_plugin_page_invoice_cmd_post (GtkAction *action, - GncPluginPageInvoice *plugin_page) +gnc_plugin_page_invoice_cmd_post (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageInvoice *plugin_page = user_data; GncPluginPageInvoicePrivate *priv; g_return_if_fail(GNC_IS_PLUGIN_PAGE_INVOICE(plugin_page)); - ENTER("(action %p, plugin_page %p)", action, plugin_page); + ENTER("(action %p, plugin_page %p)", simple, plugin_page); priv = GNC_PLUGIN_PAGE_INVOICE_GET_PRIVATE(plugin_page); gnc_invoice_window_postCB(NULL, priv->iw); LEAVE(" "); } static void -gnc_plugin_page_invoice_cmd_unpost (GtkAction *action, - GncPluginPageInvoice *plugin_page) +gnc_plugin_page_invoice_cmd_unpost (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageInvoice *plugin_page = user_data; GncPluginPageInvoicePrivate *priv; g_return_if_fail(GNC_IS_PLUGIN_PAGE_INVOICE(plugin_page)); - ENTER("(action %p, plugin_page %p)", action, plugin_page); + ENTER("(action %p, plugin_page %p)", simple, plugin_page); priv = GNC_PLUGIN_PAGE_INVOICE_GET_PRIVATE(plugin_page); gnc_invoice_window_unpostCB(NULL, priv->iw); LEAVE(" "); } static void -gnc_plugin_page_invoice_cmd_sort_changed (GtkAction *action, - GtkRadioAction *current, - GncPluginPageInvoice *plugin_page) +gnc_plugin_page_invoice_cmd_sort_changed (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncPluginPageInvoice *plugin_page = user_data; GncPluginPageInvoicePrivate *priv; invoice_sort_type_t value; - ENTER("(action %p, radio action %p, plugin_page %p)", - action, current, plugin_page); - LEAVE("g_return testing..."); - - g_return_if_fail(GTK_IS_ACTION(action)); - g_return_if_fail(GTK_IS_RADIO_ACTION(current)); + g_return_if_fail(GTK_IS_ACTION(simple)); g_return_if_fail(GNC_IS_PLUGIN_PAGE_INVOICE(plugin_page)); - ENTER("...passed (action %p, radio action %p, plugin_page %p)", - action, current, plugin_page); + ENTER("action %p, plugin_page %p)", simple, plugin_page); + priv = GNC_PLUGIN_PAGE_INVOICE_GET_PRIVATE(plugin_page); - value = gtk_radio_action_get_current_value(current); - gnc_invoice_window_sort (priv->iw, value); +//FIXMEb value = gtk_radio_action_get_current_value(current); +// gnc_invoice_window_sort (priv->iw, value); LEAVE(" "); } static void -gnc_plugin_page_invoice_cmd_refresh (GtkAction *action, - GncPluginPageInvoice *plugin_page) +gnc_plugin_page_invoice_cmd_refresh (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageInvoice *plugin_page = user_data; GncPluginPageInvoicePrivate *priv; g_return_if_fail(GNC_IS_PLUGIN_PAGE_INVOICE(plugin_page)); - ENTER("(action %p, plugin_page %p)", action, plugin_page); + ENTER("(action %p, plugin_page %p)", simple, plugin_page); priv = GNC_PLUGIN_PAGE_INVOICE_GET_PRIVATE(plugin_page); gtk_widget_queue_draw (priv->widget); @@ -1185,111 +1200,127 @@ gnc_plugin_page_invoice_cmd_refresh (GtkAction *action, } static void -gnc_plugin_page_invoice_cmd_enter (GtkAction *action, - GncPluginPageInvoice *plugin_page) +gnc_plugin_page_invoice_cmd_enter (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageInvoice *plugin_page = user_data; GncPluginPageInvoicePrivate *priv; g_return_if_fail(GNC_IS_PLUGIN_PAGE_INVOICE(plugin_page)); - ENTER("(action %p, plugin_page %p)", action, plugin_page); + ENTER("(action %p, plugin_page %p)", simple, plugin_page); priv = GNC_PLUGIN_PAGE_INVOICE_GET_PRIVATE(plugin_page); gnc_invoice_window_recordCB(NULL, priv->iw); LEAVE(" "); } static void -gnc_plugin_page_invoice_cmd_cancel (GtkAction *action, - GncPluginPageInvoice *plugin_page) +gnc_plugin_page_invoice_cmd_cancel (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageInvoice *plugin_page = user_data; GncPluginPageInvoicePrivate *priv; g_return_if_fail(GNC_IS_PLUGIN_PAGE_INVOICE(plugin_page)); - ENTER("(action %p, plugin_page %p)", action, plugin_page); + ENTER("(action %p, plugin_page %p)", simple, plugin_page); priv = GNC_PLUGIN_PAGE_INVOICE_GET_PRIVATE(plugin_page); gnc_invoice_window_cancelCB(NULL, priv->iw); LEAVE(" "); } static void -gnc_plugin_page_invoice_cmd_delete (GtkAction *action, - GncPluginPageInvoice *plugin_page) +gnc_plugin_page_invoice_cmd_delete (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageInvoice *plugin_page = user_data; GncPluginPageInvoicePrivate *priv; g_return_if_fail(GNC_IS_PLUGIN_PAGE_INVOICE(plugin_page)); - ENTER("(action %p, plugin_page %p)", action, plugin_page); + ENTER("(action %p, plugin_page %p)", simple, plugin_page); priv = GNC_PLUGIN_PAGE_INVOICE_GET_PRIVATE(plugin_page); gnc_invoice_window_deleteCB(NULL, priv->iw); LEAVE(" "); } static void -gnc_plugin_page_invoice_cmd_blank (GtkAction *action, - GncPluginPageInvoice *plugin_page) +gnc_plugin_page_invoice_cmd_blank (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageInvoice *plugin_page = user_data; GncPluginPageInvoicePrivate *priv; g_return_if_fail(GNC_IS_PLUGIN_PAGE_INVOICE(plugin_page)); - ENTER("(action %p, plugin_page %p)", action, plugin_page); + ENTER("(action %p, plugin_page %p)", simple, plugin_page); priv = GNC_PLUGIN_PAGE_INVOICE_GET_PRIVATE(plugin_page); gnc_invoice_window_blankCB(NULL, priv->iw); LEAVE(" "); } static void -gnc_plugin_page_invoice_cmd_duplicateEntry (GtkAction *action, - GncPluginPageInvoice *plugin_page) +gnc_plugin_page_invoice_cmd_duplicateEntry (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageInvoice *plugin_page = user_data; GncPluginPageInvoicePrivate *priv; g_return_if_fail(GNC_IS_PLUGIN_PAGE_INVOICE(plugin_page)); - ENTER("(action %p, plugin_page %p)", action, plugin_page); + ENTER("(action %p, plugin_page %p)", simple, plugin_page); priv = GNC_PLUGIN_PAGE_INVOICE_GET_PRIVATE(plugin_page); gnc_invoice_window_duplicateCB(NULL, priv->iw); LEAVE(" "); } static void -gnc_plugin_page_invoice_cmd_entryUp (GtkAction *action, - GncPluginPageInvoice *plugin_page) +gnc_plugin_page_invoice_cmd_entryUp (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageInvoice *plugin_page = user_data; GncPluginPageInvoicePrivate *priv; g_return_if_fail(GNC_IS_PLUGIN_PAGE_INVOICE(plugin_page)); - ENTER("(action %p, plugin_page %p)", action, plugin_page); + ENTER("(action %p, plugin_page %p)", simple, plugin_page); priv = GNC_PLUGIN_PAGE_INVOICE_GET_PRIVATE(plugin_page); gnc_invoice_window_entryUpCB(NULL, priv->iw); LEAVE(" "); } static void -gnc_plugin_page_invoice_cmd_entryDown (GtkAction *action, - GncPluginPageInvoice *plugin_page) +gnc_plugin_page_invoice_cmd_entryDown (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageInvoice *plugin_page = user_data; GncPluginPageInvoicePrivate *priv; g_return_if_fail(GNC_IS_PLUGIN_PAGE_INVOICE(plugin_page)); - ENTER("(action %p, plugin_page %p)", action, plugin_page); + ENTER("(action %p, plugin_page %p)", simple, plugin_page); priv = GNC_PLUGIN_PAGE_INVOICE_GET_PRIVATE(plugin_page); gnc_invoice_window_entryDownCB(NULL, priv->iw); LEAVE(" "); } static void -gnc_plugin_page_invoice_cmd_pay_invoice (GtkAction *action, - GncPluginPageInvoice *plugin_page) +gnc_plugin_page_invoice_cmd_pay_invoice (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageInvoice *plugin_page = user_data; GncPluginPageInvoicePrivate *priv; GtkWindow *parent; g_return_if_fail(GNC_IS_PLUGIN_PAGE_INVOICE(plugin_page)); - ENTER("(action %p, plugin_page %p)", action, plugin_page); + ENTER("(action %p, plugin_page %p)", simple, plugin_page); priv = GNC_PLUGIN_PAGE_INVOICE_GET_PRIVATE(plugin_page); parent = GTK_WINDOW (gnc_plugin_page_get_window (GNC_PLUGIN_PAGE (plugin_page))); gnc_invoice_window_payment_cb (parent, priv->iw); @@ -1297,16 +1328,18 @@ gnc_plugin_page_invoice_cmd_pay_invoice (GtkAction *action, } static void -gnc_plugin_page_invoice_cmd_save_layout (GtkAction *action, - GncPluginPageInvoice *plugin_page) +gnc_plugin_page_invoice_cmd_save_layout (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageInvoice *plugin_page = user_data; GncPluginPageInvoicePrivate *priv; GtkWindow *parent; GtkAction *layout_action; g_return_if_fail (GNC_IS_PLUGIN_PAGE_INVOICE(plugin_page)); - ENTER("(action %p, plugin_page %p)", action, plugin_page); + ENTER("(action %p, plugin_page %p)", simple, plugin_page); priv = GNC_PLUGIN_PAGE_INVOICE_GET_PRIVATE(plugin_page); gnc_invoice_window_save_document_layout_to_user_state (priv->iw); @@ -1318,16 +1351,18 @@ gnc_plugin_page_invoice_cmd_save_layout (GtkAction *action, } static void -gnc_plugin_page_invoice_cmd_reset_layout (GtkAction *action, - GncPluginPageInvoice *plugin_page) +gnc_plugin_page_invoice_cmd_reset_layout (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageInvoice *plugin_page = user_data; GncPluginPageInvoicePrivate *priv; GtkWindow *parent; GtkAction *layout_action; g_return_if_fail (GNC_IS_PLUGIN_PAGE_INVOICE(plugin_page)); - ENTER("(action %p, plugin_page %p)", action, plugin_page); + ENTER("(action %p, plugin_page %p)", simple, plugin_page); priv = GNC_PLUGIN_PAGE_INVOICE_GET_PRIVATE(plugin_page); gnc_invoice_window_reset_document_layout_and_clear_user_state (priv->iw); @@ -1339,9 +1374,11 @@ gnc_plugin_page_invoice_cmd_reset_layout (GtkAction *action, } static void -gnc_plugin_page_invoice_cmd_link (GtkAction *action, - GncPluginPageInvoice *plugin_page) +gnc_plugin_page_invoice_cmd_link (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageInvoice *plugin_page = user_data; GncPluginPageInvoicePrivate *priv; GtkWindow *parent; GtkAction *uri_action; @@ -1351,7 +1388,7 @@ gnc_plugin_page_invoice_cmd_link (GtkAction *action, gboolean has_uri = FALSE; g_return_if_fail (GNC_IS_PLUGIN_PAGE_INVOICE(plugin_page)); - ENTER("(action %p, plugin_page %p)", action, plugin_page); + ENTER("(action %p, plugin_page %p)", simple, plugin_page); priv = GNC_PLUGIN_PAGE_INVOICE_GET_PRIVATE(plugin_page); parent = GTK_WINDOW(gnc_plugin_page_get_window (GNC_PLUGIN_PAGE(plugin_page))); @@ -1396,9 +1433,11 @@ gnc_plugin_page_invoice_cmd_link (GtkAction *action, } static void -gnc_plugin_page_invoice_cmd_link_remove (GtkAction *action, - GncPluginPageInvoice *plugin_page) +gnc_plugin_page_invoice_cmd_link_remove (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageInvoice *plugin_page = user_data; GncPluginPageInvoicePrivate *priv; GtkWindow *parent; GtkAction *uri_action; @@ -1406,7 +1445,7 @@ gnc_plugin_page_invoice_cmd_link_remove (GtkAction *action, GtkWidget *doclink_button; g_return_if_fail (GNC_IS_PLUGIN_PAGE_INVOICE(plugin_page)); - ENTER("(action %p, plugin_page %p)", action, plugin_page); + ENTER("(action %p, plugin_page %p)", simple, plugin_page); priv = GNC_PLUGIN_PAGE_INVOICE_GET_PRIVATE(plugin_page); parent = GTK_WINDOW(gnc_plugin_page_get_window (GNC_PLUGIN_PAGE(plugin_page))); @@ -1425,16 +1464,18 @@ gnc_plugin_page_invoice_cmd_link_remove (GtkAction *action, } static void -gnc_plugin_page_invoice_cmd_link_open (GtkAction *action, - GncPluginPageInvoice *plugin_page) +gnc_plugin_page_invoice_cmd_link_open (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageInvoice *plugin_page = user_data; GncPluginPageInvoicePrivate *priv; GtkWindow *parent; GncInvoice *invoice; const gchar *uri = NULL; g_return_if_fail(GNC_IS_PLUGIN_PAGE_INVOICE(plugin_page)); - ENTER("(action %p, plugin_page %p)", action, plugin_page); + ENTER("(action %p, plugin_page %p)", simple, plugin_page); priv = GNC_PLUGIN_PAGE_INVOICE_GET_PRIVATE(plugin_page); parent = GTK_WINDOW(gnc_plugin_page_get_window (GNC_PLUGIN_PAGE(plugin_page))); @@ -1448,15 +1489,17 @@ gnc_plugin_page_invoice_cmd_link_open (GtkAction *action, } static void -gnc_plugin_page_invoice_cmd_company_report (GtkAction *action, - GncPluginPageInvoice *plugin_page) +gnc_plugin_page_invoice_cmd_company_report (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageInvoice *plugin_page = user_data; GncPluginPageInvoicePrivate *priv; GtkWindow *parent; g_return_if_fail(GNC_IS_PLUGIN_PAGE_INVOICE(plugin_page)); - ENTER("(action %p, plugin_page %p)", action, plugin_page); + ENTER("(action %p, plugin_page %p)", simple, plugin_page); priv = GNC_PLUGIN_PAGE_INVOICE_GET_PRIVATE(plugin_page); parent = GTK_WINDOW (gnc_plugin_page_get_window (GNC_PLUGIN_PAGE (plugin_page))); gnc_invoice_window_report_owner_cb (parent, priv->iw); diff --git a/gnucash/gnome/gnc-plugin-page-owner-tree.c b/gnucash/gnome/gnc-plugin-page-owner-tree.c index 7fde41a602..84e0c08a0b 100644 --- a/gnucash/gnome/gnc-plugin-page-owner-tree.c +++ b/gnucash/gnome/gnc-plugin-page-owner-tree.c @@ -110,139 +110,144 @@ static GncPluginPage *gnc_plugin_page_owner_tree_recreate_page (GtkWidget *windo /* Callbacks */ static gboolean gnc_plugin_page_owner_tree_button_press_cb (GtkWidget *widget, - GdkEventButton *event, - GncPluginPage *page); -static void gnc_plugin_page_owner_tree_double_click_cb (GtkTreeView *treeview, - GtkTreePath *path, - GtkTreeViewColumn *col, - GncPluginPageOwnerTree *page); + GdkEventButton *event, + GncPluginPage *page); +static void gnc_plugin_page_owner_tree_double_click_cb (GtkTreeView *treeview, + GtkTreePath *path, + GtkTreeViewColumn *col, + GncPluginPageOwnerTree *page); static void gnc_plugin_page_owner_tree_selection_changed_cb (GtkTreeSelection *selection, - GncPluginPageOwnerTree *page); + GncPluginPageOwnerTree *page); /* Command callbacks */ -static void gnc_plugin_page_owner_tree_cmd_new_owner (GtkAction *action, GncPluginPageOwnerTree *page); -static void gnc_plugin_page_owner_tree_cmd_edit_owner (GtkAction *action, GncPluginPageOwnerTree *page); +static void gnc_plugin_page_owner_tree_cmd_new_owner (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_page_owner_tree_cmd_edit_owner (GSimpleAction *simple, GVariant *parameter, gpointer user_data); #if 0 /* Disabled due to crash */ -static void gnc_plugin_page_owner_tree_cmd_delete_owner (GtkAction *action, GncPluginPageOwnerTree *page); +static void gnc_plugin_page_owner_tree_cmd_delete_owner (GSimpleAction *simple, GVariant *parameter, gpointer user_data); #endif -static void gnc_plugin_page_owner_tree_cmd_view_filter_by (GtkAction *action, GncPluginPageOwnerTree *page); -static void gnc_plugin_page_owner_tree_cmd_refresh (GtkAction *action, GncPluginPageOwnerTree *page); -static void gnc_plugin_page_owner_tree_cmd_new_invoice (GtkAction *action, GncPluginPageOwnerTree *page); -static void gnc_plugin_page_owner_tree_cmd_owners_report (GtkAction *action, GncPluginPageOwnerTree *plugin_page); -static void gnc_plugin_page_owner_tree_cmd_owner_report (GtkAction *action, GncPluginPageOwnerTree *plugin_page); -static void gnc_plugin_page_owner_tree_cmd_process_payment (GtkAction *action, GncPluginPageOwnerTree *plugin_page); +static void gnc_plugin_page_owner_tree_cmd_view_filter_by (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_page_owner_tree_cmd_refresh (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_page_owner_tree_cmd_new_invoice (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_page_owner_tree_cmd_owners_report (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_page_owner_tree_cmd_owner_report (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_page_owner_tree_cmd_process_payment (GSimpleAction *simple, GVariant *parameter, gpointer user_data); static guint plugin_page_signals[LAST_SIGNAL] = { 0 }; -static GtkActionEntry gnc_plugin_page_owner_tree_actions [] = +static GActionEntry gnc_plugin_page_owner_tree_actions [] = { - /* Toplevel */ - { "FakeToplevel", NULL, "", NULL, NULL, NULL }, + { "OTEditVendorAction", gnc_plugin_page_owner_tree_cmd_edit_owner, NULL, NULL, NULL }, + { "OTEditCustomerAction", gnc_plugin_page_owner_tree_cmd_edit_owner, NULL, NULL, NULL }, + { "OTEditEmployeeAction", gnc_plugin_page_owner_tree_cmd_edit_owner, NULL, NULL, NULL }, + { "OTNewVendorAction", gnc_plugin_page_owner_tree_cmd_new_owner, NULL, NULL, NULL }, + { "OTNewCustomerAction", gnc_plugin_page_owner_tree_cmd_new_owner, NULL, NULL, NULL }, + { "OTNewEmployeeAction", gnc_plugin_page_owner_tree_cmd_new_owner, NULL, NULL, NULL }, +#if 0 /* Disabled due to crash */ + { "EditDeleteOwnerAction", gnc_plugin_page_owner_tree_cmd_delete_owner, NULL, NULL, NULL }, +#endif /* Disabled due to crash */ + + { "ViewFilterByAction", gnc_plugin_page_owner_tree_cmd_view_filter_by, NULL, NULL, NULL }, + { "ViewRefreshAction", gnc_plugin_page_owner_tree_cmd_refresh, NULL, NULL, NULL }, + { "OTNewBillAction", gnc_plugin_page_owner_tree_cmd_new_invoice, NULL, NULL, NULL }, + { "OTNewInvoiceAction", gnc_plugin_page_owner_tree_cmd_new_invoice, NULL, NULL, NULL }, + { "OTNewVoucherAction", gnc_plugin_page_owner_tree_cmd_new_invoice, NULL, NULL, NULL }, + { "OTVendorListingReportAction", gnc_plugin_page_owner_tree_cmd_owners_report, NULL, NULL, NULL }, + { "OTCustomerListingReportAction", gnc_plugin_page_owner_tree_cmd_owners_report, NULL, NULL, NULL }, + { "OTVendorReportAction", gnc_plugin_page_owner_tree_cmd_owner_report, NULL, NULL, NULL }, + { "OTCustomerReportAction", gnc_plugin_page_owner_tree_cmd_owner_report, NULL, NULL, NULL }, + { "OTEmployeeReportAction", gnc_plugin_page_owner_tree_cmd_owner_report, NULL, NULL, NULL }, + { "OTProcessPaymentAction", gnc_plugin_page_owner_tree_cmd_process_payment, NULL, NULL, NULL }, +}; +/** The number of actions provided by this plugin. */ +static guint gnc_plugin_page_owner_tree_n_actions = G_N_ELEMENTS(gnc_plugin_page_owner_tree_actions); + +static GncDisplayItem gnc_plugin_page_owner_tree_display_items [] = +{ /* Edit menu */ { "OTEditVendorAction", GNC_ICON_EDIT_ACCOUNT, N_("E_dit Vendor"), "e", - N_("Edit the selected vendor"), - G_CALLBACK (gnc_plugin_page_owner_tree_cmd_edit_owner) + N_("Edit the selected vendor") }, { "OTEditCustomerAction", GNC_ICON_EDIT_ACCOUNT, N_("E_dit Customer"), "e", - N_("Edit the selected customer"), - G_CALLBACK (gnc_plugin_page_owner_tree_cmd_edit_owner) + N_("Edit the selected customer") }, { "OTEditEmployeeAction", GNC_ICON_EDIT_ACCOUNT, N_("E_dit Employee"), "e", - N_("Edit the selected employee"), - G_CALLBACK (gnc_plugin_page_owner_tree_cmd_edit_owner) + N_("Edit the selected employee") }, { "OTNewVendorAction", GNC_ICON_NEW_ACCOUNT, N_("_New Vendor..."), NULL, - N_("Create a new vendor"), - G_CALLBACK (gnc_plugin_page_owner_tree_cmd_new_owner) + N_("Create a new vendor") }, { "OTNewCustomerAction", GNC_ICON_NEW_ACCOUNT, N_("_New Customer..."), NULL, - N_("Create a new customer"), - G_CALLBACK (gnc_plugin_page_owner_tree_cmd_new_owner) + N_("Create a new customer") }, { "OTNewEmployeeAction", GNC_ICON_NEW_ACCOUNT, N_("_New Employee..."), NULL, - N_("Create a new employee"), - G_CALLBACK (gnc_plugin_page_owner_tree_cmd_new_owner) + N_("Create a new employee") }, - #if 0 /* Disabled due to crash */ { "EditDeleteOwnerAction", GNC_ICON_DELETE_ACCOUNT, N_("_Delete Owner..."), "Delete", - N_("Delete selected owner"), - G_CALLBACK (gnc_plugin_page_owner_tree_cmd_delete_owner) + N_("Delete selected owner") }, #endif /* Disabled due to crash */ /* View menu */ { - "ViewFilterByAction", NULL, N_("_Filter By..."), NULL, NULL, - G_CALLBACK (gnc_plugin_page_owner_tree_cmd_view_filter_by) + "ViewFilterByAction", NULL, N_("_Filter By..."), NULL, NULL }, { "ViewRefreshAction", "view-refresh", N_("_Refresh"), "r", - N_("Refresh this window"), - G_CALLBACK (gnc_plugin_page_owner_tree_cmd_refresh) + N_("Refresh this window") }, /* Business menu */ { "OTNewBillAction", GNC_ICON_INVOICE_NEW, N_("New _Bill..."), NULL, - N_("Create a new bill"), - G_CALLBACK (gnc_plugin_page_owner_tree_cmd_new_invoice) + N_("Create a new bill") }, { "OTNewInvoiceAction", GNC_ICON_INVOICE_NEW, N_("New _Invoice..."), NULL, - N_("Create a new invoice"), - G_CALLBACK (gnc_plugin_page_owner_tree_cmd_new_invoice) + N_("Create a new invoice") }, { "OTNewVoucherAction", GNC_ICON_INVOICE_NEW, N_("New _Voucher..."), NULL, - N_("Create a new voucher"), - G_CALLBACK (gnc_plugin_page_owner_tree_cmd_new_invoice) + N_("Create a new voucher") }, { "OTVendorListingReportAction", "document-print-preview", N_("Vendor Listing"), NULL, - N_("Show vendor aging overview for all vendors"), - G_CALLBACK (gnc_plugin_page_owner_tree_cmd_owners_report) + N_("Show vendor aging overview for all vendors") }, { "OTCustomerListingReportAction", "document-print-preview", N_("Customer Listing"), NULL, - N_("Show customer aging overview for all customers"), - G_CALLBACK (gnc_plugin_page_owner_tree_cmd_owners_report) + N_("Show customer aging overview for all customers") }, { "OTVendorReportAction", NULL, N_("Vendor Report"), NULL, - N_("Show vendor report"), - G_CALLBACK (gnc_plugin_page_owner_tree_cmd_owner_report) + N_("Show vendor report") }, { "OTCustomerReportAction", NULL, N_("Customer Report"), NULL, - N_("Show customer report"), - G_CALLBACK (gnc_plugin_page_owner_tree_cmd_owner_report) + N_("Show customer report") }, { "OTEmployeeReportAction", NULL, N_("Employee Report"), NULL, - N_("Show employee report"), - G_CALLBACK (gnc_plugin_page_owner_tree_cmd_owner_report) + N_("Show employee report") }, { "OTProcessPaymentAction", GNC_ICON_INVOICE_PAY, - N_("Process Payment"), NULL, N_("Process Payment"), - G_CALLBACK (gnc_plugin_page_owner_tree_cmd_process_payment) + N_("Process Payment"), NULL, N_("Process Payment") }, -}; -/** The number of actions provided by this plugin. */ -static guint gnc_plugin_page_owner_tree_n_actions = G_N_ELEMENTS (gnc_plugin_page_owner_tree_actions); - + }; +/** The number of display items provided by this plugin. */ +static guint gnc_plugin_page_owner_tree_n_display_items = G_N_ELEMENTS(gnc_plugin_page_owner_tree_display_items); /** Actions that require an owner to be selected before they are * enabled. These ones are only sensitive in a read-write book. */ @@ -431,7 +436,8 @@ gnc_plugin_page_owner_tree_class_init (GncPluginPageOwnerTreeClass *klass) static void gnc_plugin_page_owner_tree_init (GncPluginPageOwnerTree *plugin_page) { - GtkActionGroup *action_group; +// GtkActionGroup *action_group; + GSimpleActionGroup *simple_action_group; GncPluginPageOwnerTreePrivate *priv; GncPluginPage *parent; @@ -443,7 +449,7 @@ gnc_plugin_page_owner_tree_init (GncPluginPageOwnerTree *plugin_page) g_object_set(G_OBJECT(plugin_page), "page-name", _("Owners"), "page-uri", "default:", - "ui-description", "gnc-plugin-page-owner-tree-ui.xml", + "ui-description", "gnc-plugin-page-owner-tree.ui", NULL); g_signal_connect (G_OBJECT (plugin_page), "selected", G_CALLBACK (gnc_plugin_page_owner_tree_selected), plugin_page); @@ -452,14 +458,12 @@ gnc_plugin_page_owner_tree_init (GncPluginPageOwnerTree *plugin_page) gnc_plugin_page_add_book(parent, gnc_get_current_book()); /* Create menu and toolbar information */ - action_group = - gnc_plugin_page_create_action_group(parent, - "GncPluginPageOwnerTreeActions"); - gtk_action_group_add_actions(action_group, - gnc_plugin_page_owner_tree_actions, - gnc_plugin_page_owner_tree_n_actions, - plugin_page); - gnc_plugin_init_short_names (action_group, toolbar_labels); + simple_action_group = gnc_plugin_page_create_action_groupb (parent, "GncPluginPageOwnerTreeActions"); + g_action_map_add_action_entries (G_ACTION_MAP(simple_action_group), + gnc_plugin_page_owner_tree_actions, + gnc_plugin_page_owner_tree_n_actions, + plugin_page); +//FIXMEb gnc_plugin_init_short_names (action_group, toolbar_labels); /* Init filter */ @@ -467,7 +471,7 @@ gnc_plugin_page_owner_tree_init (GncPluginPageOwnerTree *plugin_page) priv->fd.show_zero_total = TRUE; LEAVE("page %p, priv %p, action group %p", - plugin_page, priv, action_group); + plugin_page, priv, simple_action_group); } static void @@ -768,8 +772,8 @@ gnc_plugin_page_owner_tree_save_page (GncPluginPage *plugin_page, * @param group_name The group name to use when restoring data. */ static GncPluginPage * gnc_plugin_page_owner_tree_recreate_page (GtkWidget *window, - GKeyFile *key_file, - const gchar *group_name) + GKeyFile *key_file, + const gchar *group_name) { GncPluginPageOwnerTree *owner_page; GncPluginPageOwnerTreePrivate *priv; @@ -840,8 +844,8 @@ static void gnc_ui_owner_edit (GtkWindow *parent, GncOwner *owner) * registered in gnc-main-window.c. */ static gboolean gnc_plugin_page_owner_tree_button_press_cb (GtkWidget *widget, - GdkEventButton *event, - GncPluginPage *page) + GdkEventButton *event, + GncPluginPage *page) { g_return_val_if_fail(GNC_IS_PLUGIN_PAGE(page), FALSE); @@ -857,17 +861,17 @@ gnc_plugin_page_owner_tree_button_press_cb (GtkWidget *widget, } static void -gnc_plugin_page_owner_tree_double_click_cb (GtkTreeView *treeview, - GtkTreePath *path, - GtkTreeViewColumn *col, - GncPluginPageOwnerTree *page) +gnc_plugin_page_owner_tree_double_click_cb (GtkTreeView *treeview, + GtkTreePath *path, + GtkTreeViewColumn *col, + GncPluginPageOwnerTree *page) { - gnc_plugin_page_owner_tree_cmd_owner_report (NULL, page); + gnc_plugin_page_owner_tree_cmd_owner_report (NULL, NULL, (gpointer*)page); } static void gnc_plugin_page_owner_tree_selection_changed_cb (GtkTreeSelection *selection, - GncPluginPageOwnerTree *page) + GncPluginPageOwnerTree *page) { GtkActionGroup *action_group; GtkTreeView *view; @@ -1009,8 +1013,12 @@ static int build_owner_report (GncOwner *owner, Account *acc) /************************************************************/ static void -gnc_plugin_page_owner_tree_cmd_new_owner (GtkAction *action, GncPluginPageOwnerTree *page) +gnc_plugin_page_owner_tree_cmd_new_owner (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) + { + GncPluginPageOwnerTree *page = user_data; GncPluginPageOwnerTreePrivate *priv; GtkWindow *parent; @@ -1049,13 +1057,17 @@ gnc_plugin_page_owner_tree_cmd_new_owner (GtkAction *action, GncPluginPageOwnerT } static void -gnc_plugin_page_owner_tree_cmd_edit_owner (GtkAction *action, GncPluginPageOwnerTree *page) +gnc_plugin_page_owner_tree_cmd_edit_owner (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) + { + GncPluginPageOwnerTree *page = user_data; GtkWindow *parent; GncOwner *owner = gnc_plugin_page_owner_tree_get_current_owner (page); if (NULL == owner) return; - ENTER("action %p, page %p", action, page); + ENTER("action %p, page %p", simple, page); parent = GTK_WINDOW (gnc_plugin_page_get_window (GNC_PLUGIN_PAGE (page))); gnc_ui_owner_edit (parent, owner); @@ -1065,8 +1077,12 @@ gnc_plugin_page_owner_tree_cmd_edit_owner (GtkAction *action, GncPluginPageOwner #if 0 /* Disabled due to crash */ static void -gnc_plugin_page_owner_tree_cmd_delete_owner (GtkAction *action, GncPluginPageOwnerTree *page) +gnc_plugin_page_owner_tree_cmd_delete_owner (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) + { + GncPluginPageOwnerTree *page = user_data; GncOwner *owner = gnc_plugin_page_owner_tree_get_current_owner (page); gchar *owner_name; GtkWidget *window; @@ -1135,42 +1151,51 @@ gnc_plugin_page_owner_tree_cmd_delete_owner (GtkAction *action, GncPluginPageOwn /*********************/ static void -gnc_plugin_page_owner_tree_cmd_view_filter_by (GtkAction *action, - GncPluginPageOwnerTree *page) +gnc_plugin_page_owner_tree_cmd_view_filter_by (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) + { + GncPluginPageOwnerTree *plugin_page = user_data; GncPluginPageOwnerTreePrivate *priv; - g_return_if_fail(GNC_IS_PLUGIN_PAGE_OWNER_TREE(page)); - ENTER("(action %p, page %p)", action, page); + g_return_if_fail(GNC_IS_PLUGIN_PAGE_OWNER_TREE(plugin_page)); + ENTER("(action %p, page %p)", simple, plugin_page); - priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(page); - owner_filter_dialog_create(&priv->fd, GNC_PLUGIN_PAGE(page)); + priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(plugin_page); + owner_filter_dialog_create(&priv->fd, GNC_PLUGIN_PAGE(plugin_page)); LEAVE(" "); } static void -gnc_plugin_page_owner_tree_cmd_refresh (GtkAction *action, - GncPluginPageOwnerTree *page) +gnc_plugin_page_owner_tree_cmd_refresh (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) + { + GncPluginPageOwnerTree *plugin_page = user_data; GncPluginPageOwnerTreePrivate *priv; - g_return_if_fail(GNC_IS_PLUGIN_PAGE_OWNER_TREE(page)); + g_return_if_fail(GNC_IS_PLUGIN_PAGE_OWNER_TREE(plugin_page)); - priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(page); + priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(plugin_page); gtk_widget_queue_draw (priv->widget); } static void -gnc_plugin_page_owner_tree_cmd_new_invoice (GtkAction *action, - GncPluginPageOwnerTree *page) +gnc_plugin_page_owner_tree_cmd_new_invoice (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) + { + GncPluginPageOwnerTree *plugin_page = user_data; GncPluginPageOwnerTreePrivate *priv; GncOwner current_owner; GtkWindow *parent; - ENTER("action %p, page %p", action, page); + ENTER("action %p, plugin_page %p", simple, plugin_page); - priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(page); + priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(plugin_page); switch (priv->owner_type) { case GNC_OWNER_NONE : @@ -1180,30 +1205,30 @@ gnc_plugin_page_owner_tree_cmd_new_invoice (GtkAction *action, case GNC_OWNER_CUSTOMER : { gncOwnerInitCustomer(¤t_owner, - gncOwnerGetCustomer(gnc_plugin_page_owner_tree_get_current_owner (page)) ); + gncOwnerGetCustomer(gnc_plugin_page_owner_tree_get_current_owner (plugin_page))); break; } case GNC_OWNER_JOB : { gncOwnerInitJob(¤t_owner, - gncOwnerGetJob(gnc_plugin_page_owner_tree_get_current_owner (page)) ); + gncOwnerGetJob(gnc_plugin_page_owner_tree_get_current_owner (plugin_page))); break; } case GNC_OWNER_VENDOR : { gncOwnerInitVendor(¤t_owner, - gncOwnerGetVendor(gnc_plugin_page_owner_tree_get_current_owner (page)) ); + gncOwnerGetVendor(gnc_plugin_page_owner_tree_get_current_owner (plugin_page))); break; } case GNC_OWNER_EMPLOYEE : { gncOwnerInitEmployee(¤t_owner, - gncOwnerGetEmployee(gnc_plugin_page_owner_tree_get_current_owner (page)) ); + gncOwnerGetEmployee(gnc_plugin_page_owner_tree_get_current_owner (plugin_page))); break; } } - parent = GTK_WINDOW (gnc_plugin_page_get_window (GNC_PLUGIN_PAGE (page))); + parent = GTK_WINDOW (gnc_plugin_page_get_window (GNC_PLUGIN_PAGE(plugin_page))); if (gncOwnerGetType(¤t_owner) != GNC_OWNER_UNDEFINED) gnc_ui_invoice_new (parent, ¤t_owner, gnc_get_current_book ()); @@ -1211,13 +1236,16 @@ gnc_plugin_page_owner_tree_cmd_new_invoice (GtkAction *action, } static void -gnc_plugin_page_owner_tree_cmd_owners_report (GtkAction *action, - GncPluginPageOwnerTree *plugin_page) +gnc_plugin_page_owner_tree_cmd_owners_report (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) + { + GncPluginPageOwnerTree *plugin_page = user_data; GncPluginPageOwnerTreePrivate *priv; int id; - ENTER("(action %p, plugin_page %p)", action, plugin_page); + ENTER("(action %p, plugin_page %p)", simple, plugin_page); g_return_if_fail(GNC_IS_PLUGIN_PAGE_OWNER_TREE(plugin_page)); @@ -1234,13 +1262,16 @@ gnc_plugin_page_owner_tree_cmd_owners_report (GtkAction *action, } static void -gnc_plugin_page_owner_tree_cmd_owner_report (GtkAction *action, - GncPluginPageOwnerTree *plugin_page) +gnc_plugin_page_owner_tree_cmd_owner_report (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) + { + GncPluginPageOwnerTree *plugin_page = user_data; GncOwner *current_owner; int id; - ENTER("(action %p, plugin_page %p)", action, plugin_page); + ENTER("(action %p, plugin_page %p)", simple, plugin_page); g_return_if_fail(GNC_IS_PLUGIN_PAGE_OWNER_TREE(plugin_page)); @@ -1258,10 +1289,13 @@ gnc_plugin_page_owner_tree_cmd_owner_report (GtkAction *action, static void -gnc_plugin_page_owner_tree_cmd_process_payment (GtkAction *action, - GncPluginPageOwnerTree *plugin_page) +gnc_plugin_page_owner_tree_cmd_process_payment (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) + { - ENTER("(action %p, plugin_page %p)", action, plugin_page); + GncPluginPageOwnerTree *plugin_page = user_data; + ENTER("(action %p, plugin_page %p)", simple, plugin_page); g_return_if_fail(GNC_IS_PLUGIN_PAGE_OWNER_TREE(plugin_page)); diff --git a/gnucash/gnome/gnc-plugin-page-register.c b/gnucash/gnome/gnc-plugin-page-register.c index d03f7e949d..11efa31241 100644 --- a/gnucash/gnome/gnc-plugin-page-register.c +++ b/gnucash/gnome/gnc-plugin-page-register.c @@ -171,103 +171,59 @@ static gchar* gnc_plugin_page_register_filter_time2dmy (time64 raw_time); static gchar* gnc_plugin_page_register_get_filter (GncPluginPage* plugin_page); void gnc_plugin_page_register_set_filter (GncPluginPage* plugin_page, const gchar* filter); -static void gnc_plugin_page_register_set_filter_tooltip ( - GncPluginPageRegister* page); +static void gnc_plugin_page_register_set_filter_tooltip (GncPluginPageRegister* page); static void gnc_ppr_update_status_query (GncPluginPageRegister* page); static void gnc_ppr_update_date_query (GncPluginPageRegister* page); /* Command callbacks */ -static void gnc_plugin_page_register_cmd_print_check (GtkAction* action, - GncPluginPageRegister* plugin_page); -static void gnc_plugin_page_register_cmd_cut (GtkAction* action, - GncPluginPageRegister* plugin_page); -static void gnc_plugin_page_register_cmd_copy (GtkAction* action, - GncPluginPageRegister* plugin_page); -static void gnc_plugin_page_register_cmd_paste (GtkAction* action, - GncPluginPageRegister* plugin_page); -static void gnc_plugin_page_register_cmd_edit_account (GtkAction* action, - GncPluginPageRegister* plugin_page); -static void gnc_plugin_page_register_cmd_find_account (GtkAction* action, - GncPluginPageRegister* plugin_page); -static void gnc_plugin_page_register_cmd_find_transactions (GtkAction* action, - GncPluginPageRegister* plugin_page); -static void gnc_plugin_page_register_cmd_edit_tax_options (GtkAction* action, - GncPluginPageRegister* plugin_page); -static void gnc_plugin_page_register_cmd_cut_transaction (GtkAction* action, - GncPluginPageRegister* plugin_page); -static void gnc_plugin_page_register_cmd_copy_transaction (GtkAction* action, - GncPluginPageRegister* plugin_page); -static void gnc_plugin_page_register_cmd_paste_transaction (GtkAction* action, - GncPluginPageRegister* plugin_page); -static void gnc_plugin_page_register_cmd_void_transaction (GtkAction* action, - GncPluginPageRegister* plugin_page); -static void gnc_plugin_page_register_cmd_unvoid_transaction (GtkAction* action, - GncPluginPageRegister* plugin_page); -static void gnc_plugin_page_register_cmd_reverse_transaction ( - GtkAction* action, GncPluginPageRegister* plugin_page); -static void gnc_plugin_page_register_cmd_view_sort_by (GtkAction* action, - GncPluginPageRegister* plugin_page); -static void gnc_plugin_page_register_cmd_view_filter_by (GtkAction* action, - GncPluginPageRegister* plugin_page); -static void gnc_plugin_page_register_cmd_style_changed (GtkAction* action, - GtkRadioAction* current, GncPluginPageRegister* plugin_page); -static void gnc_plugin_page_register_cmd_style_double_line ( - GtkToggleAction* action, GncPluginPageRegister* plugin_page); +static void gnc_plugin_page_register_cmd_print_check (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_register_cmd_cut (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_register_cmd_copy (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_register_cmd_paste (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_register_cmd_edit_account (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_register_cmd_find_account (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_register_cmd_find_transactions (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_register_cmd_edit_tax_options (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_register_cmd_cut_transaction (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_register_cmd_copy_transaction (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_register_cmd_paste_transaction (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_register_cmd_void_transaction (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_register_cmd_unvoid_transaction (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_register_cmd_reverse_transaction (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_register_cmd_view_sort_by (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_register_cmd_view_filter_by (GSimpleAction *simple, GVariant *paramter, gpointer user_data); -static void gnc_plugin_page_register_cmd_reconcile (GtkAction* action, - GncPluginPageRegister* plugin_page); -static void gnc_plugin_page_register_cmd_stock_assistant (GtkAction* action, - GncPluginPageRegister* page); +static void gnc_plugin_page_register_cmd_style_changed (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_page_register_cmd_style_double_line (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_page_register_cmd_expand_transaction (GSimpleAction *simple, GVariant *parameter, gpointer user_data); + +static void gnc_plugin_page_register_cmd_reconcile (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_register_cmd_stock_assistant (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_register_cmd_autoclear (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_register_cmd_transfer (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_register_cmd_stock_split (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_register_cmd_lots (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_register_cmd_enter_transaction (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_register_cmd_cancel_transaction (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_register_cmd_delete_transaction (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_register_cmd_blank_transaction (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_register_cmd_goto_date (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_register_cmd_duplicate_transaction (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_register_cmd_reinitialize_transaction (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_register_cmd_exchange_rate (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_register_cmd_jump (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_register_cmd_reload (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_register_cmd_schedule (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_register_cmd_scrub_all (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_register_cmd_scrub_current (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_register_cmd_account_report (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_register_cmd_transaction_report (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_register_cmd_linked_transaction (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_register_cmd_linked_transaction_open (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_register_cmd_linked_transaction_remove (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_register_cmd_jump_linked_invoice (GSimpleAction *simple, GVariant *paramter, gpointer user_data); -static void gnc_plugin_page_register_cmd_autoclear (GtkAction* action, - GncPluginPageRegister* plugin_page); -static void gnc_plugin_page_register_cmd_transfer (GtkAction* action, - GncPluginPageRegister* plugin_page); -static void gnc_plugin_page_register_cmd_stock_split (GtkAction* action, - GncPluginPageRegister* plugin_page); -static void gnc_plugin_page_register_cmd_lots (GtkAction* action, - GncPluginPageRegister* plugin_page); -static void gnc_plugin_page_register_cmd_enter_transaction (GtkAction* action, - GncPluginPageRegister* plugin_page); -static void gnc_plugin_page_register_cmd_cancel_transaction (GtkAction* action, - GncPluginPageRegister* plugin_page); -static void gnc_plugin_page_register_cmd_delete_transaction (GtkAction* action, - GncPluginPageRegister* plugin_page); -static void gnc_plugin_page_register_cmd_blank_transaction (GtkAction* action, - GncPluginPageRegister* plugin_page); -static void gnc_plugin_page_register_cmd_goto_date (GtkAction* action, - GncPluginPageRegister* page); -static void gnc_plugin_page_register_cmd_duplicate_transaction ( - GtkAction* action, GncPluginPageRegister* plugin_page); -static void gnc_plugin_page_register_cmd_reinitialize_transaction ( - GtkAction* action, GncPluginPageRegister* plugin_page); -static void gnc_plugin_page_register_cmd_expand_transaction ( - GtkToggleAction* action, GncPluginPageRegister* plugin_page); -static void gnc_plugin_page_register_cmd_exchange_rate (GtkAction* action, - GncPluginPageRegister* plugin_page); -static void gnc_plugin_page_register_cmd_jump (GtkAction* action, - GncPluginPageRegister* plugin_page); -static void gnc_plugin_page_register_cmd_reload (GtkAction* action, - GncPluginPageRegister* plugin_page); -static void gnc_plugin_page_register_cmd_schedule (GtkAction* action, - GncPluginPageRegister* plugin_page); -static void gnc_plugin_page_register_cmd_scrub_all (GtkAction* action, - GncPluginPageRegister* plugin_page); -static void gnc_plugin_page_register_cmd_scrub_current (GtkAction* action, - GncPluginPageRegister* plugin_page); -static void gnc_plugin_page_register_cmd_account_report (GtkAction* action, - GncPluginPageRegister* plugin_page); -static void gnc_plugin_page_register_cmd_transaction_report (GtkAction* action, - GncPluginPageRegister* plugin_page); -static void gnc_plugin_page_register_cmd_linked_transaction (GtkAction *action, - GncPluginPageRegister *plugin_page); -static void gnc_plugin_page_register_cmd_linked_transaction_open (GtkAction *action, - GncPluginPageRegister *plugin_page); -static void gnc_plugin_page_register_cmd_linked_transaction_remove (GtkAction *action, - GncPluginPageRegister *plugin_page); -static void gnc_plugin_page_register_cmd_jump_linked_invoice (GtkAction* action, - GncPluginPageRegister* plugin_page); static void gnc_plugin_page_help_changed_cb (GNCSplitReg* gsr, GncPluginPageRegister* register_page); static void gnc_plugin_page_popup_menu_cb (GNCSplitReg* gsr, @@ -287,6 +243,22 @@ static void gnc_plugin_page_register_event_handler (QofInstance* entity, static GncInvoice* invoice_from_split (Split* split); static GList* invoices_from_transaction (Transaction* trans); +static void +change_toggle_state (GSimpleAction *simple, + GVariant *state, + gpointer user_data) +{ + g_simple_action_set_state (simple, state); +} + +static void +change_radio_state (GSimpleAction *simple, + GVariant *state, + gpointer user_data) +{ + g_simple_action_set_state (simple, state); +} + /************************************************************/ /* Actions */ /************************************************************/ @@ -326,46 +298,85 @@ static GList* invoices_from_transaction (Transaction* trans); #define DUPLICATE_SPLIT_TIP N_("Make a copy of the current split") #define DELETE_SPLIT_TIP N_("Delete the current split") -static GtkActionEntry gnc_plugin_page_register_actions [] = +static GActionEntry gnc_plugin_page_register_actions [] = +{ + { "FilePrintAction", gnc_plugin_page_register_cmd_print_check, NULL, NULL, NULL }, + { "EditCutAction", gnc_plugin_page_register_cmd_cut, NULL, NULL, NULL }, + { "EditCopyAction", gnc_plugin_page_register_cmd_copy, NULL, NULL, NULL }, + { "EditPasteAction", gnc_plugin_page_register_cmd_paste, NULL, NULL, NULL }, + { "EditEditAccountAction", gnc_plugin_page_register_cmd_edit_account, NULL, NULL, NULL }, + { "EditFindAccountAction", gnc_plugin_page_register_cmd_find_account, NULL, NULL, NULL }, + { "EditFindTransactionsAction", gnc_plugin_page_register_cmd_find_transactions, NULL, NULL, NULL }, + { "EditTaxOptionsAction", gnc_plugin_page_register_cmd_edit_tax_options, NULL, NULL, NULL }, + { "CutTransactionAction", gnc_plugin_page_register_cmd_cut_transaction, NULL, NULL, NULL }, + { "CopyTransactionAction", gnc_plugin_page_register_cmd_copy_transaction, NULL, NULL, NULL }, + { "PasteTransactionAction", gnc_plugin_page_register_cmd_paste_transaction, NULL, NULL, NULL }, + { "DuplicateTransactionAction", gnc_plugin_page_register_cmd_duplicate_transaction, NULL, NULL, NULL }, + { "DeleteTransactionAction", gnc_plugin_page_register_cmd_delete_transaction, NULL, NULL, NULL }, + { "RemoveTransactionSplitsAction", gnc_plugin_page_register_cmd_reinitialize_transaction, NULL, NULL, NULL }, + { "RecordTransactionAction", gnc_plugin_page_register_cmd_enter_transaction, NULL, NULL, NULL }, + { "CancelTransactionAction", gnc_plugin_page_register_cmd_cancel_transaction, NULL, NULL, NULL }, + { "VoidTransactionAction", gnc_plugin_page_register_cmd_void_transaction, NULL, NULL, NULL }, + { "UnvoidTransactionAction", gnc_plugin_page_register_cmd_unvoid_transaction, NULL, NULL, NULL }, + { "ReverseTransactionAction", gnc_plugin_page_register_cmd_reverse_transaction, NULL, NULL, NULL }, + { "LinkTransactionAction", gnc_plugin_page_register_cmd_linked_transaction, NULL, NULL, NULL }, + { "LinkedTransactionOpenAction", gnc_plugin_page_register_cmd_linked_transaction_open, NULL, NULL, NULL }, + { "JumpLinkedInvoiceAction", gnc_plugin_page_register_cmd_jump_linked_invoice, NULL, NULL, NULL }, + { "ViewSortByAction", gnc_plugin_page_register_cmd_view_sort_by, NULL, NULL, NULL }, + { "ViewFilterByAction", gnc_plugin_page_register_cmd_view_filter_by, NULL, NULL, NULL }, + { "ViewRefreshAction", gnc_plugin_page_register_cmd_reload, NULL, NULL, NULL }, + { "ActionsTransferAction", gnc_plugin_page_register_cmd_transfer, NULL, NULL, NULL }, + { "ActionsReconcileAction", gnc_plugin_page_register_cmd_reconcile, NULL, NULL, NULL }, + { "ActionsAutoClearAction", gnc_plugin_page_register_cmd_autoclear, NULL, NULL, NULL }, + { "ActionsStockAssistantAction", gnc_plugin_page_register_cmd_stock_assistant, NULL, NULL, NULL }, + { "ActionsStockSplitAction", gnc_plugin_page_register_cmd_stock_split, NULL, NULL, NULL }, + { "ActionsLotsAction", gnc_plugin_page_register_cmd_lots, NULL, NULL, NULL }, + { "BlankTransactionAction", gnc_plugin_page_register_cmd_blank_transaction, NULL, NULL, NULL }, + { "GotoDateAction", gnc_plugin_page_register_cmd_goto_date, NULL, NULL, NULL }, + { "EditExchangeRateAction", gnc_plugin_page_register_cmd_exchange_rate, NULL, NULL, NULL }, + { "JumpTransactionAction", gnc_plugin_page_register_cmd_jump, NULL, NULL, NULL }, + { "ScheduleTransactionAction", gnc_plugin_page_register_cmd_schedule, NULL, NULL, NULL }, + { "ScrubAllAction", gnc_plugin_page_register_cmd_scrub_all, NULL, NULL, NULL }, + { "ScrubCurrentAction", gnc_plugin_page_register_cmd_scrub_current, NULL, NULL, NULL }, + { "ReportsAccountReportAction", gnc_plugin_page_register_cmd_account_report, NULL, NULL, NULL }, + { "ReportsAcctTransReportAction", gnc_plugin_page_register_cmd_transaction_report, NULL, NULL, NULL }, + + { "ViewStyleDoubleLineAction", gnc_plugin_page_register_cmd_style_double_line, NULL, "FALSE", change_toggle_state }, + { "SplitTransactionAction", gnc_plugin_page_register_cmd_expand_transaction, NULL, "FALSE", change_toggle_state }, + { "ViewStyleRadioAction", gnc_plugin_page_register_cmd_style_changed, "n", 0, change_radio_state }, +}; +static guint gnc_plugin_page_register_n_actions = G_N_ELEMENTS(gnc_plugin_page_register_actions); + +static GncDisplayItem gnc_plugin_page_register_display_items [] = { /* File menu */ - { - "FilePrintAction", "document-print", N_ ("_Print Checks..."), "p", NULL, - G_CALLBACK (gnc_plugin_page_register_cmd_print_check) + "FilePrintAction", "document-print", N_ ("_Print Checks..."), "p", NULL }, - /* Edit menu */ - { "EditCutAction", "edit-cut", N_ ("Cu_t"), "X", - N_ ("Cut the current selection and copy it to clipboard"), - G_CALLBACK (gnc_plugin_page_register_cmd_cut) + N_ ("Cut the current selection and copy it to clipboard") }, { "EditCopyAction", "edit-copy", N_ ("_Copy"), "C", - N_ ("Copy the current selection to clipboard"), - G_CALLBACK (gnc_plugin_page_register_cmd_copy) + N_ ("Copy the current selection to clipboard") }, { "EditPasteAction", "edit-paste", N_ ("_Paste"), "V", - N_ ("Paste the clipboard content at the cursor position"), - G_CALLBACK (gnc_plugin_page_register_cmd_paste) + N_ ("Paste the clipboard content at the cursor position") }, { "EditEditAccountAction", GNC_ICON_EDIT_ACCOUNT, N_ ("Edit _Account"), "e", - N_ ("Edit the selected account"), - G_CALLBACK (gnc_plugin_page_register_cmd_edit_account) + N_ ("Edit the selected account") }, { "EditFindAccountAction", "edit-find", N_ ("F_ind Account"), "i", - N_ ("Find an account"), - G_CALLBACK (gnc_plugin_page_register_cmd_find_account) + N_ ("Find an account") }, { "EditFindTransactionsAction", "edit-find", N_ ("_Find..."), "f", - N_ ("Find transactions with a search"), - G_CALLBACK (gnc_plugin_page_register_cmd_find_transactions) + N_ ("Find transactions with a search") }, { "EditTaxOptionsAction", NULL, @@ -376,221 +387,141 @@ static GtkActionEntry gnc_plugin_page_register_actions [] = US: income tax and DE: VAT So adjust this string */ - N_("Setup relevant accounts for tax reports, e.g. US income tax"), - G_CALLBACK (gnc_plugin_page_register_cmd_edit_tax_options) + N_("Setup relevant accounts for tax reports, e.g. US income tax") }, - /* Transaction menu */ - { "CutTransactionAction", "edit-cut", CUT_TRANSACTION_LABEL, "", - CUT_TRANSACTION_TIP, - G_CALLBACK (gnc_plugin_page_register_cmd_cut_transaction) + CUT_TRANSACTION_TIP }, { "CopyTransactionAction", "edit-copy", COPY_TRANSACTION_LABEL, "", - COPY_TRANSACTION_TIP, - G_CALLBACK (gnc_plugin_page_register_cmd_copy_transaction) + COPY_TRANSACTION_TIP }, { "PasteTransactionAction", "edit-paste", PASTE_TRANSACTION_LABEL, "", - PASTE_TRANSACTION_TIP, - G_CALLBACK (gnc_plugin_page_register_cmd_paste_transaction) + PASTE_TRANSACTION_TIP }, { "DuplicateTransactionAction", "edit-copy", DUPLICATE_TRANSACTION_LABEL, "", - DUPLICATE_TRANSACTION_TIP, - G_CALLBACK (gnc_plugin_page_register_cmd_duplicate_transaction) + DUPLICATE_TRANSACTION_TIP }, { "DeleteTransactionAction", "edit-delete", DELETE_TRANSACTION_LABEL, NULL, - DELETE_TRANSACTION_TIP, - G_CALLBACK (gnc_plugin_page_register_cmd_delete_transaction) + DELETE_TRANSACTION_TIP }, { "RemoveTransactionSplitsAction", "edit-clear", N_ ("Remo_ve Other Splits"), NULL, - N_ ("Remove all splits in the current transaction"), - G_CALLBACK (gnc_plugin_page_register_cmd_reinitialize_transaction) + N_ ("Remove all splits in the current transaction") }, { "RecordTransactionAction", "list-add", N_ ("_Enter Transaction"), NULL, - N_ ("Record the current transaction"), - G_CALLBACK (gnc_plugin_page_register_cmd_enter_transaction) + N_ ("Record the current transaction") }, { "CancelTransactionAction", "process-stop", N_ ("Ca_ncel Transaction"), NULL, - N_ ("Cancel the current transaction"), - G_CALLBACK (gnc_plugin_page_register_cmd_cancel_transaction) + N_ ("Cancel the current transaction") }, { - "VoidTransactionAction", NULL, N_ ("_Void Transaction"), NULL, NULL, - G_CALLBACK (gnc_plugin_page_register_cmd_void_transaction) + "VoidTransactionAction", NULL, N_ ("_Void Transaction"), NULL, NULL }, { - "UnvoidTransactionAction", NULL, N_ ("_Unvoid Transaction"), NULL, NULL, - G_CALLBACK (gnc_plugin_page_register_cmd_unvoid_transaction) + "UnvoidTransactionAction", NULL, N_ ("_Unvoid Transaction"), NULL, NULL }, { - "ReverseTransactionAction", NULL, N_ ("Add _Reversing Transaction"), NULL, NULL, - G_CALLBACK (gnc_plugin_page_register_cmd_reverse_transaction) + "ReverseTransactionAction", NULL, N_ ("Add _Reversing Transaction"), NULL, NULL }, { "LinkTransactionAction", NULL, LINK_TRANSACTION_LABEL, NULL, - LINK_TRANSACTION_TIP, - G_CALLBACK (gnc_plugin_page_register_cmd_linked_transaction) + LINK_TRANSACTION_TIP }, { "LinkedTransactionOpenAction", NULL, LINK_TRANSACTION_OPEN_LABEL, NULL, - LINK_TRANSACTION_OPEN_TIP, - G_CALLBACK (gnc_plugin_page_register_cmd_linked_transaction_open) + LINK_TRANSACTION_OPEN_TIP }, { "JumpLinkedInvoiceAction", NULL, JUMP_LINKED_INVOICE_LABEL, NULL, - JUMP_LINKED_INVOICE_TIP, - G_CALLBACK (gnc_plugin_page_register_cmd_jump_linked_invoice) + JUMP_LINKED_INVOICE_TIP }, - /* View menu */ - { - "ViewSortByAction", NULL, N_ ("_Sort By..."), NULL, NULL, - G_CALLBACK (gnc_plugin_page_register_cmd_view_sort_by) + "ViewSortByAction", NULL, N_ ("_Sort By..."), NULL, NULL }, { - "ViewFilterByAction", NULL, N_ ("_Filter By..."), NULL, NULL, - G_CALLBACK (gnc_plugin_page_register_cmd_view_filter_by) + "ViewFilterByAction", NULL, N_ ("_Filter By..."), NULL, NULL }, { "ViewRefreshAction", "view-refresh", N_ ("_Refresh"), "r", - N_ ("Refresh this window"), - G_CALLBACK (gnc_plugin_page_register_cmd_reload) + N_ ("Refresh this window") }, - /* Actions menu */ - { "ActionsTransferAction", GNC_ICON_TRANSFER, N_ ("_Transfer..."), "t", - N_ ("Transfer funds from one account to another"), - G_CALLBACK (gnc_plugin_page_register_cmd_transfer) + N_ ("Transfer funds from one account to another") }, { "ActionsReconcileAction", "edit-select-all", N_ ("_Reconcile..."), NULL, - N_ ("Reconcile the selected account"), - G_CALLBACK (gnc_plugin_page_register_cmd_reconcile) + N_ ("Reconcile the selected account") }, { "ActionsAutoClearAction", "edit-select-all", N_ ("_Auto-clear..."), NULL, - N_ ("Automatically clear individual transactions, so as to reach a certain cleared amount"), - G_CALLBACK (gnc_plugin_page_register_cmd_autoclear) + N_ ("Automatically clear individual transactions, so as to reach a certain cleared amount") }, { "ActionsStockAssistantAction", "applications-utilities", - N_ ("Stock Ass_istant"), NULL, N_ ("Stock Assistant"), - G_CALLBACK (gnc_plugin_page_register_cmd_stock_assistant) + N_ ("Stock Ass_istant"), NULL, N_ ("Stock Assistant") }, { "ActionsStockSplitAction", NULL, N_ ("Stoc_k Split..."), NULL, - N_ ("Record a stock split or a stock merger"), - G_CALLBACK (gnc_plugin_page_register_cmd_stock_split) + N_ ("Record a stock split or a stock merger") }, { "ActionsLotsAction", NULL, N_ ("View _Lots..."), NULL, - N_ ("Bring up the lot viewer/editor window"), - G_CALLBACK (gnc_plugin_page_register_cmd_lots) + N_ ("Bring up the lot viewer/editor window") }, { "BlankTransactionAction", "go-bottom", N_ ("_Blank Transaction"), "Page_Down", - N_ ("Move to the blank transaction at the bottom of the register"), - G_CALLBACK (gnc_plugin_page_register_cmd_blank_transaction) + N_ ("Move to the blank transaction at the bottom of the register") }, { "GotoDateAction", "x-office-calendar", N_ ("_Go to Date"), "G", - N_ ("Move to the split at the specified date"), - G_CALLBACK (gnc_plugin_page_register_cmd_goto_date) + N_ ("Move to the split at the specified date") }, { "EditExchangeRateAction", NULL, N_ ("Edit E_xchange Rate"), NULL, - N_ ("Edit the exchange rate for the current transaction"), - G_CALLBACK (gnc_plugin_page_register_cmd_exchange_rate) + N_ ("Edit the exchange rate for the current transaction") }, { /* Translators: This is a menu item that will open a register tab for the account of the first other account in the current transaction's split list with focus on the current transaction's entry in that register. */ "JumpTransactionAction", GNC_ICON_JUMP_TO, N_ ("_Jump to the other account"), NULL, - N_ ("Open a new register tab for the other account with focus on this transaction."), - G_CALLBACK (gnc_plugin_page_register_cmd_jump) + N_ ("Open a new register tab for the other account with focus on this transaction.") }, { "ScheduleTransactionAction", GNC_ICON_SCHEDULE, N_ ("Sche_dule..."), NULL, - N_ ("Create a Scheduled Transaction with the current transaction as a template"), - G_CALLBACK (gnc_plugin_page_register_cmd_schedule) + N_ ("Create a Scheduled Transaction with the current transaction as a template") }, { "ScrubAllAction", NULL, /* Translators: The following 2 are Scrub actions in register view */ - N_ ("_All transactions"), NULL, NULL, - G_CALLBACK (gnc_plugin_page_register_cmd_scrub_all) + N_ ("_All transactions"), NULL, NULL }, { - "ScrubCurrentAction", NULL, N_ ("_This transaction"), NULL, NULL, - G_CALLBACK (gnc_plugin_page_register_cmd_scrub_current) + "ScrubCurrentAction", NULL, N_ ("_This transaction"), NULL, NULL }, - /* Reports menu */ - { "ReportsAccountReportAction", NULL, N_ ("Account Report"), NULL, - N_ ("Open a register report for this Account"), - G_CALLBACK (gnc_plugin_page_register_cmd_account_report) + N_ ("Open a register report for this Account") }, { "ReportsAcctTransReportAction", NULL, N_ ("Account Report - Single Transaction"), NULL, - N_ ("Open a register report for the selected Transaction"), - G_CALLBACK (gnc_plugin_page_register_cmd_transaction_report) + N_ ("Open a register report for the selected Transaction") }, }; - -static guint gnc_plugin_page_register_n_actions = G_N_ELEMENTS ( - gnc_plugin_page_register_actions); - -static GtkToggleActionEntry toggle_entries[] = -{ - { - "ViewStyleDoubleLineAction", NULL, N_ ("_Double Line"), NULL, - N_ ("Show a second line with \"Action\", \"Notes\", and \"Linked Document\" for each transaction."), - G_CALLBACK (gnc_plugin_page_register_cmd_style_double_line), FALSE - }, - - { - "SplitTransactionAction", GNC_ICON_SPLIT_TRANS, N_ ("S_plit Transaction"), NULL, - N_ ("Show all splits in the current transaction"), - G_CALLBACK (gnc_plugin_page_register_cmd_expand_transaction), FALSE - }, -}; - -static guint n_toggle_entries = G_N_ELEMENTS (toggle_entries); - -static GtkRadioActionEntry radio_entries_2 [] = -{ - /* Translators: This is a menu item in the View menu */ - { - "ViewStyleBasicAction", NULL, N_ ("_Basic Ledger"), NULL, - N_ ("Show transactions on one or two lines"), REG_STYLE_LEDGER - }, - /* Translators: This is a menu item in the View menu */ - { - "ViewStyleAutoSplitAction", NULL, N_ ("_Auto-Split Ledger"), NULL, - N_ ("Show transactions on one or two lines and expand the current transaction"), REG_STYLE_AUTO_LEDGER - }, - /* Translators: This is a menu item in the View menu */ - { - "ViewStyleJournalAction", NULL, N_ ("Transaction _Journal"), NULL, - N_ ("Show expanded transactions with all splits"), REG_STYLE_JOURNAL - } -}; - -static guint n_radio_entries_2 = G_N_ELEMENTS (radio_entries_2); +/** The number of display items provided by this plugin. */ +static guint gnc_plugin_page_register_n_display_items = G_N_ELEMENTS(gnc_plugin_page_register_display_items); /** These are the "important" actions provided by the register page. * Their labels will appear when the toolbar is set to "Icons and @@ -881,7 +812,8 @@ gnc_plugin_page_register_init (GncPluginPageRegister* plugin_page) { GncPluginPageRegisterPrivate* priv; GncPluginPage* parent; - GtkActionGroup* action_group; +// GtkActionGroup *action_group; + GSimpleActionGroup *simple_action_group; gboolean use_new; priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (plugin_page); @@ -893,27 +825,28 @@ gnc_plugin_page_register_init (GncPluginPageRegister* plugin_page) g_object_set (G_OBJECT (plugin_page), "page-name", _ ("General Journal"), "page-uri", "default:", - "ui-description", "gnc-plugin-page-register-ui.xml", + "ui-description", "gnc-plugin-page-register.ui", "use-new-window", use_new, NULL); /* Create menu and toolbar information */ - action_group = - gnc_plugin_page_create_action_group (parent, - "GncPluginPageRegisterActions"); - gtk_action_group_add_actions (action_group, gnc_plugin_page_register_actions, - gnc_plugin_page_register_n_actions, plugin_page); - gtk_action_group_add_toggle_actions (action_group, - toggle_entries, n_toggle_entries, - plugin_page); - gtk_action_group_add_radio_actions (action_group, - radio_entries_2, n_radio_entries_2, - REG_STYLE_LEDGER, - G_CALLBACK (gnc_plugin_page_register_cmd_style_changed), - plugin_page); + simple_action_group = gnc_plugin_page_create_action_groupb (parent, "GncPluginPageRegisterActions"); + g_action_map_add_action_entries (G_ACTION_MAP(simple_action_group), + gnc_plugin_page_register_actions, + gnc_plugin_page_register_n_actions, + plugin_page); - gnc_plugin_init_short_names (action_group, toolbar_labels); - gnc_plugin_set_important_actions (action_group, important_actions); +//FIXMEb gtk_action_group_add_toggle_actions (action_group, +// toggle_entries, n_toggle_entries, +// plugin_page); +//FIXMEb gtk_action_group_add_radio_actions (action_group, +// radio_entries_2, n_radio_entries_2, +// REG_STYLE_LEDGER, +// G_CALLBACK (gnc_plugin_page_register_cmd_style_changed), +// plugin_page); + +//FIXMEb gnc_plugin_init_short_names (action_group, toolbar_labels); +//FIXMEb gnc_plugin_set_important_actions (action_group, important_actions); priv->lines_default = DEFAULT_LINES_AMOUNT; priv->read_only = FALSE; @@ -1266,24 +1199,24 @@ gnc_plugin_page_register_ui_initial_state (GncPluginPageRegister* page) "sensitive", ledger_type == LD_SINGLE); reg = gnc_ledger_display_get_split_register (priv->ledger); - for (i = n_radio_entries_2 - 1; i > 0; i--) - { - DEBUG (" index %d: comparing %x to %x", i, radio_entries_2[i].value, - reg->style); - if (radio_entries_2[i].value == reg->style) - { - DEBUG ("match"); - break; - } - } +//FIXMEb for (i = n_radio_entries_2 - 1; i > 0; i--) +// { +// DEBUG (" index %d: comparing %x to %x", i, radio_entries_2[i].value, +// reg->style); +// if (radio_entries_2[i].value == reg->style) +// { +// DEBUG ("match"); +// break; +// } +// } /* Either a match was found, or fell out with i = 0 */ - action = gtk_action_group_get_action (action_group, radio_entries_2[i].name); - g_signal_handlers_block_by_func (action, - gnc_plugin_page_register_cmd_style_changed, page); - gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), TRUE); - g_signal_handlers_unblock_by_func (action, - gnc_plugin_page_register_cmd_style_changed, page); +// action = gtk_action_group_get_action (action_group, radio_entries_2[i].name); +// g_signal_handlers_block_by_func (action, +// gnc_plugin_page_register_cmd_style_changed, page); +// gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), TRUE); +// g_signal_handlers_unblock_by_func (action, +// gnc_plugin_page_register_cmd_style_changed, page); /* Set "double line" toggle button */ action = gtk_action_group_get_action (action_group, @@ -1793,16 +1726,16 @@ gnc_plugin_page_register_restore_edit_menu (GncPluginPage* page, if (i <= REG_STYLE_JOURNAL) { DEBUG ("Setting style: %d", i); - action = gnc_plugin_page_get_action (page, radio_entries_2[i].name); - gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), TRUE); +//FIXMEb action = gnc_plugin_page_get_action (page, radio_entries_2[i].name); +// gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), TRUE); } /* Update the double line action on this page */ use_double_line = g_key_file_get_boolean (key_file, group_name, KEY_DOUBLE_LINE, &error); DEBUG ("Setting double_line_mode: %d", use_double_line); - action = gnc_plugin_page_get_action (page, "ViewStyleDoubleLineAction"); - gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), use_double_line); +//FIXMEb action = gnc_plugin_page_get_action (page, "ViewStyleDoubleLineAction"); +// gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), use_double_line); LEAVE (" "); } @@ -2101,7 +2034,8 @@ gnc_plugin_page_register_get_tab_color (GncPluginPage* plugin_page) } static void -gnc_plugin_page_register_check_for_empty_group (GKeyFile *state_file, const gchar *state_section) +gnc_plugin_page_register_check_for_empty_group (GKeyFile *state_file, + const gchar *state_section) { gsize num_keys; gchar **keys = g_key_file_get_keys (state_file, state_section, &num_keys, NULL); @@ -2419,7 +2353,8 @@ gnc_plugin_page_register_get_long_name (GncPluginPage* plugin_page) static void gnc_plugin_page_register_summarybar_position_changed (gpointer prefs, - gchar* pref, gpointer user_data) + gchar* pref, + gpointer user_data) { GncPluginPage* plugin_page; GncPluginPageRegister* page; @@ -3631,9 +3566,11 @@ report_helper (GNCLedgerDisplay* ledger, Split* split, Query* query) /************************************************************/ static void -gnc_plugin_page_register_cmd_print_check (GtkAction* action, - GncPluginPageRegister* plugin_page) +gnc_plugin_page_register_cmd_print_check (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageRegister* page = user_data; GncPluginPageRegisterPrivate* priv; SplitRegister* reg; Split* split; @@ -3643,17 +3580,17 @@ gnc_plugin_page_register_cmd_print_check (GtkAction* action, Account* account; GtkWidget* window; - ENTER ("(action %p, plugin_page %p)", action, plugin_page); + ENTER ("(action %p, page %p)", simple, page); - g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page)); + g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); - priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (plugin_page); + priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page); reg = gnc_ledger_display_get_split_register (priv->ledger); ledger_type = gnc_ledger_display_type (priv->ledger); - window = gnc_plugin_page_get_window (GNC_PLUGIN_PAGE (plugin_page)); + window = gnc_plugin_page_get_window (GNC_PLUGIN_PAGE (page)); if (ledger_type == LD_SINGLE || ledger_type == LD_SUBACCOUNT) { - account = gnc_plugin_page_register_get_account (plugin_page); + account = gnc_plugin_page_register_get_account (page); split = gnc_split_register_get_current_split (reg); trans = xaccSplitGetParent (split); @@ -3740,14 +3677,16 @@ gnc_plugin_page_register_cmd_print_check (GtkAction* action, static void -gnc_plugin_page_register_cmd_cut (GtkAction* action, - GncPluginPageRegister* page) +gnc_plugin_page_register_cmd_cut (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageRegister* page = user_data; GncPluginPageRegisterPrivate* priv; g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); - ENTER ("(action %p, page %p)", action, page); + ENTER ("(action %p, page %p)", simple, page); priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page); gnucash_register_cut_clipboard (priv->gsr->reg); LEAVE (""); @@ -3755,14 +3694,16 @@ gnc_plugin_page_register_cmd_cut (GtkAction* action, static void -gnc_plugin_page_register_cmd_copy (GtkAction* action, - GncPluginPageRegister* page) +gnc_plugin_page_register_cmd_copy (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageRegister* page = user_data; GncPluginPageRegisterPrivate* priv; g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); - ENTER ("(action %p, page %p)", action, page); + ENTER ("(action %p, page %p)", simple, page); priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page); gnucash_register_copy_clipboard (priv->gsr->reg); LEAVE (""); @@ -3770,14 +3711,16 @@ gnc_plugin_page_register_cmd_copy (GtkAction* action, static void -gnc_plugin_page_register_cmd_paste (GtkAction* action, - GncPluginPageRegister* page) +gnc_plugin_page_register_cmd_paste (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageRegister* page = user_data; GncPluginPageRegisterPrivate* priv; g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); - ENTER ("(action %p, page %p)", action, page); + ENTER ("(action %p, page %p)", simple, page); priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page); gnucash_register_paste_clipboard (priv->gsr->reg); LEAVE (""); @@ -3785,15 +3728,16 @@ gnc_plugin_page_register_cmd_paste (GtkAction* action, static void -gnc_plugin_page_register_cmd_edit_account (GtkAction* action, - GncPluginPageRegister* page) +gnc_plugin_page_register_cmd_edit_account (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageRegister* page = user_data; Account* account; - GtkWindow* parent = GTK_WINDOW (gnc_plugin_page_get_window (GNC_PLUGIN_PAGE ( - page))); + GtkWindow* parent = GTK_WINDOW(gnc_plugin_page_get_window (GNC_PLUGIN_PAGE(page))); g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); - ENTER ("(action %p, page %p)", action, page); + ENTER ("(action %p, page %p)", simple, page); account = gnc_plugin_page_register_get_account (page); if (account) gnc_ui_edit_account_window (parent, account); @@ -3802,9 +3746,11 @@ gnc_plugin_page_register_cmd_edit_account (GtkAction* action, static void -gnc_plugin_page_register_cmd_find_account (GtkAction* action, - GncPluginPageRegister* page) +gnc_plugin_page_register_cmd_find_account (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageRegister* page = user_data; GtkWidget* window; g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); @@ -3815,15 +3761,17 @@ gnc_plugin_page_register_cmd_find_account (GtkAction* action, static void -gnc_plugin_page_register_cmd_find_transactions (GtkAction* action, - GncPluginPageRegister* page) +gnc_plugin_page_register_cmd_find_transactions (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageRegister* page = user_data; GncPluginPageRegisterPrivate* priv; GtkWindow* window; g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); - ENTER ("(action %p, page %p)", action, page); + ENTER ("(action %p, page %p)", simple, page); priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page); window = GTK_WINDOW (gnc_plugin_page_get_window (GNC_PLUGIN_PAGE (page))); gnc_ui_find_transactions_dialog_create (window, priv->ledger); @@ -3832,16 +3780,18 @@ gnc_plugin_page_register_cmd_find_transactions (GtkAction* action, static void -gnc_plugin_page_register_cmd_edit_tax_options (GtkAction* action, - GncPluginPageRegister* page) +gnc_plugin_page_register_cmd_edit_tax_options (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageRegister* page = user_data; GncPluginPageRegisterPrivate* priv; GtkWidget *window; Account* account; g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); - ENTER ("(action %p, page %p)", action, page); + ENTER ("(action %p, page %p)", simple, page); priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page); window = gnc_plugin_page_get_window (GNC_PLUGIN_PAGE (page)); account = gnc_plugin_page_register_get_account (page); @@ -3850,31 +3800,35 @@ gnc_plugin_page_register_cmd_edit_tax_options (GtkAction* action, } static void -gnc_plugin_page_register_cmd_cut_transaction (GtkAction* action, - GncPluginPageRegister* plugin_page) +gnc_plugin_page_register_cmd_cut_transaction (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageRegister* page = user_data; GncPluginPageRegisterPrivate* priv; - ENTER ("(action %p, plugin_page %p)", action, plugin_page); + ENTER ("(action %p, page %p)", simple, page); - g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page)); + g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); - priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (plugin_page); + priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page); gsr_default_cut_txn_handler (priv->gsr, NULL); LEAVE (" "); } static void -gnc_plugin_page_register_cmd_copy_transaction (GtkAction* action, - GncPluginPageRegister* page) +gnc_plugin_page_register_cmd_copy_transaction (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageRegister* page = user_data; GncPluginPageRegisterPrivate* priv; SplitRegister* reg; g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); - ENTER ("(action %p, page %p)", action, page); + ENTER ("(action %p, page %p)", simple, page); priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page); reg = gnc_ledger_display_get_split_register (priv->ledger); gnc_split_register_copy_current (reg); @@ -3883,15 +3837,17 @@ gnc_plugin_page_register_cmd_copy_transaction (GtkAction* action, static void -gnc_plugin_page_register_cmd_paste_transaction (GtkAction* action, - GncPluginPageRegister* page) +gnc_plugin_page_register_cmd_paste_transaction (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageRegister* page = user_data; GncPluginPageRegisterPrivate* priv; SplitRegister* reg; g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); - ENTER ("(action %p, page %p)", action, page); + ENTER ("(action %p, page %p)", simple, page); priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page); reg = gnc_ledger_display_get_split_register (priv->ledger); gnc_split_register_paste_current (reg); @@ -3900,9 +3856,11 @@ gnc_plugin_page_register_cmd_paste_transaction (GtkAction* action, static void -gnc_plugin_page_register_cmd_void_transaction (GtkAction* action, - GncPluginPageRegister* page) +gnc_plugin_page_register_cmd_void_transaction (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageRegister* page = user_data; GncPluginPageRegisterPrivate* priv; GtkWidget* dialog, *entry; SplitRegister* reg; @@ -3912,7 +3870,7 @@ gnc_plugin_page_register_cmd_void_transaction (GtkAction* action, gint result; GtkWindow* window; - ENTER ("(action %p, page %p)", action, page); + ENTER ("(action %p, page %p)", simple, page); g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); @@ -3967,14 +3925,16 @@ gnc_plugin_page_register_cmd_void_transaction (GtkAction* action, static void -gnc_plugin_page_register_cmd_unvoid_transaction (GtkAction* action, - GncPluginPageRegister* page) +gnc_plugin_page_register_cmd_unvoid_transaction (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageRegister* page = user_data; GncPluginPageRegisterPrivate* priv; SplitRegister* reg; Transaction* trans; - ENTER ("(action %p, page %p)", action, page); + ENTER ("(action %p, page %p)", simple, page); g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); @@ -3989,9 +3949,11 @@ gnc_plugin_page_register_cmd_unvoid_transaction (GtkAction* action, static void -gnc_plugin_page_register_cmd_reverse_transaction (GtkAction* action, - GncPluginPageRegister* page) +gnc_plugin_page_register_cmd_reverse_transaction (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageRegister* page = user_data; GncPluginPageRegisterPrivate* priv; SplitRegister* reg; GNCSplitReg* gsr; @@ -4001,7 +3963,7 @@ gnc_plugin_page_register_cmd_reverse_transaction (GtkAction* action, Account *account; Split *split; - ENTER ("(action %p, page %p)", action, page); + ENTER ("(action %p, page %p)", simple, page); g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); @@ -4064,8 +4026,7 @@ gnc_plugin_page_register_cmd_reverse_transaction (GtkAction* action, static gboolean gnc_plugin_page_register_show_fs_save (GncPluginPageRegister* page) { - GncPluginPageRegisterPrivate* priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE ( - page); + GncPluginPageRegisterPrivate* priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page); GNCLedgerDisplayType ledger_type = gnc_ledger_display_type (priv->ledger); SplitRegister* reg = gnc_ledger_display_get_split_register (priv->ledger); @@ -4090,9 +4051,11 @@ gnc_plugin_page_register_show_fs_save (GncPluginPageRegister* page) } static void -gnc_plugin_page_register_cmd_view_sort_by (GtkAction* action, - GncPluginPageRegister* page) +gnc_plugin_page_register_cmd_view_sort_by (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageRegister* page = user_data; GncPluginPageRegisterPrivate* priv; SplitRegister* reg; GtkWidget* dialog, *button; @@ -4102,7 +4065,7 @@ gnc_plugin_page_register_cmd_view_sort_by (GtkAction* action, gchar* title; g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); - ENTER ("(action %p, page %p)", action, page); + ENTER ("(action %p, page %p)", simple, page); priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page); if (priv->sd.dialog) @@ -4175,9 +4138,11 @@ gnc_plugin_page_register_cmd_view_sort_by (GtkAction* action, } static void -gnc_plugin_page_register_cmd_view_filter_by (GtkAction* action, - GncPluginPageRegister* page) +gnc_plugin_page_register_cmd_view_filter_by (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageRegister* page = user_data; GncPluginPageRegisterPrivate* priv; GtkWidget* dialog, *toggle, *button, *table, *hbox; time64 start_time, end_time, time_val; @@ -4188,7 +4153,7 @@ gnc_plugin_page_register_cmd_view_filter_by (GtkAction* action, int i; g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); - ENTER ("(action %p, page %p)", action, page); + ENTER ("(action %p, page %p)", simple, page); priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page); if (priv->fd.dialog) @@ -4365,17 +4330,19 @@ gnc_plugin_page_register_cmd_view_filter_by (GtkAction* action, } static void -gnc_plugin_page_register_cmd_reload (GtkAction* action, - GncPluginPageRegister* plugin_page) +gnc_plugin_page_register_cmd_reload (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageRegister* page = user_data; GncPluginPageRegisterPrivate* priv; SplitRegister* reg; - ENTER ("(action %p, page %p)", action, plugin_page); + ENTER ("(action %p, page %p)", simple, page); - g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page)); + g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); - priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (plugin_page); + priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page); reg = gnc_ledger_display_get_split_register (priv->ledger); /* Check for trans being edited */ @@ -4389,63 +4356,75 @@ gnc_plugin_page_register_cmd_reload (GtkAction* action, } static void -gnc_plugin_page_register_cmd_style_changed (GtkAction* action, - GtkRadioAction* current, - GncPluginPageRegister* plugin_page) +gnc_plugin_page_register_cmd_style_changed (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncPluginPageRegister* page = user_data; GncPluginPageRegisterPrivate* priv; SplitRegisterStyle value; + gint current; - ENTER ("(action %p, radio action %p, plugin_page %p)", - action, current, plugin_page); + ENTER ("(action %p, page %p)", simple, page); - g_return_if_fail (GTK_IS_ACTION (action)); - g_return_if_fail (GTK_IS_RADIO_ACTION (current)); - g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page)); + g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); - priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (plugin_page); - value = gtk_radio_action_get_current_value (current); - gnc_split_reg_change_style (priv->gsr, value, priv->enable_refresh); + priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page); - gnc_plugin_page_register_ui_update (NULL, plugin_page); + current = g_variant_get_int16 (parameter); + +//FIXMEb value = gtk_radio_action_get_current_value (current); +// gnc_split_reg_change_style (priv->gsr, value, priv->enable_refresh); + + gnc_plugin_page_register_ui_update (NULL, page); LEAVE (" "); } static void -gnc_plugin_page_register_cmd_style_double_line (GtkToggleAction* action, - GncPluginPageRegister* plugin_page) +gnc_plugin_page_register_cmd_style_double_line (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncPluginPageRegister* page = user_data; GncPluginPageRegisterPrivate* priv; SplitRegister* reg; gboolean use_double_line; + GVariant *state; - ENTER ("(action %p, plugin_page %p)", action, plugin_page); + ENTER ("(action %p, page %p)", simple, page); - g_return_if_fail (GTK_IS_ACTION (action)); - g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page)); + g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER(page)); - priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (plugin_page); + priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page); reg = gnc_ledger_display_get_split_register (priv->ledger); - use_double_line = gtk_toggle_action_get_active (action); + state = g_action_get_state (G_ACTION(simple)); + + use_double_line = g_variant_get_boolean (state); + + g_action_change_state (G_ACTION(simple), g_variant_new_boolean (!g_variant_get_boolean (state))); + if (use_double_line != reg->use_double_line) { gnc_split_register_config (reg, reg->type, reg->style, use_double_line); if (priv->enable_refresh) gnc_ledger_display_refresh (priv->ledger); } + g_variant_unref (state); LEAVE (" "); } static void -gnc_plugin_page_register_cmd_transfer (GtkAction* action, - GncPluginPageRegister* page) +gnc_plugin_page_register_cmd_transfer (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageRegister* page = user_data; Account* account; GncWindow* gnc_window; GtkWidget* window; - ENTER ("(action %p, plugin_page %p)", action, page); + ENTER ("(action %p, page %p)", simple, page); g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); @@ -4457,14 +4436,16 @@ gnc_plugin_page_register_cmd_transfer (GtkAction* action, } static void -gnc_plugin_page_register_cmd_reconcile (GtkAction* action, - GncPluginPageRegister* page) +gnc_plugin_page_register_cmd_reconcile (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageRegister* page = user_data; Account* account; GtkWindow* window; RecnWindow* recnData; - ENTER ("(action %p, plugin_page %p)", action, page); + ENTER ("(action %p, page %p)", simple, page); g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); @@ -4478,13 +4459,15 @@ gnc_plugin_page_register_cmd_reconcile (GtkAction* action, } static void -gnc_plugin_page_register_cmd_stock_assistant (GtkAction* action, - GncPluginPageRegister* page) +gnc_plugin_page_register_cmd_stock_assistant (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageRegister* page = user_data; Account *account; GtkWindow *window; - ENTER ("(action %p, plugin_page %p)", action, page); + ENTER ("(action %p, page %p)", simple, page); g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); window = gnc_window_get_gtk_window (GNC_WINDOW (GNC_PLUGIN_PAGE (page)->window)); @@ -4495,14 +4478,16 @@ gnc_plugin_page_register_cmd_stock_assistant (GtkAction* action, } static void -gnc_plugin_page_register_cmd_autoclear (GtkAction* action, - GncPluginPageRegister* page) +gnc_plugin_page_register_cmd_autoclear (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageRegister* page = user_data; Account* account; GtkWindow* window; AutoClearWindow* autoClearData; - ENTER ("(action %p, plugin_page %p)", action, page); + ENTER ("(action %p, page %p)", simple, page); g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); @@ -4516,13 +4501,15 @@ gnc_plugin_page_register_cmd_autoclear (GtkAction* action, } static void -gnc_plugin_page_register_cmd_stock_split (GtkAction* action, - GncPluginPageRegister* page) +gnc_plugin_page_register_cmd_stock_split (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageRegister* page = user_data; Account* account; GtkWindow* window; - ENTER ("(action %p, plugin_page %p)", action, page); + ENTER ("(action %p, page %p)", simple, page); g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); @@ -4533,13 +4520,15 @@ gnc_plugin_page_register_cmd_stock_split (GtkAction* action, } static void -gnc_plugin_page_register_cmd_lots (GtkAction* action, - GncPluginPageRegister* page) +gnc_plugin_page_register_cmd_lots (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageRegister* page = user_data; GtkWindow* window; Account* account; - ENTER ("(action %p, plugin_page %p)", action, page); + ENTER ("(action %p, page %p)", simple, page); g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); @@ -4551,96 +4540,108 @@ gnc_plugin_page_register_cmd_lots (GtkAction* action, } static void -gnc_plugin_page_register_cmd_enter_transaction (GtkAction* action, - GncPluginPageRegister* plugin_page) +gnc_plugin_page_register_cmd_enter_transaction (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageRegister* page = user_data; GncPluginPageRegisterPrivate* priv; - ENTER ("(action %p, plugin_page %p)", action, plugin_page); + ENTER ("(action %p, page %p)", simple, page); - g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page)); + g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); - priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (plugin_page); + priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page); gnc_split_reg_enter (priv->gsr, FALSE); LEAVE (" "); } static void -gnc_plugin_page_register_cmd_cancel_transaction (GtkAction* action, - GncPluginPageRegister* plugin_page) +gnc_plugin_page_register_cmd_cancel_transaction (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageRegister* page = user_data; GncPluginPageRegisterPrivate* priv; - ENTER ("(action %p, plugin_page %p)", action, plugin_page); + ENTER ("(action %p, page %p)", simple, page); - g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page)); + g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); - priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (plugin_page); + priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page); gnc_split_register_cancel_cursor_trans_changes (gnc_ledger_display_get_split_register (priv->ledger)); LEAVE (" "); } static void -gnc_plugin_page_register_cmd_delete_transaction (GtkAction* action, - GncPluginPageRegister* plugin_page) +gnc_plugin_page_register_cmd_delete_transaction (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageRegister* page = user_data; GncPluginPageRegisterPrivate* priv; - ENTER ("(action %p, plugin_page %p)", action, plugin_page); + ENTER ("(action %p, page %p)", simple, page); - g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page)); + g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); - priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (plugin_page); + priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page); gsr_default_delete_handler (priv->gsr, NULL); LEAVE (" "); } static void -gnc_plugin_page_register_cmd_linked_transaction (GtkAction *action, - GncPluginPageRegister* plugin_page) +gnc_plugin_page_register_cmd_linked_transaction (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageRegister* page = user_data; GncPluginPageRegisterPrivate* priv; - ENTER ("(action %p, plugin_page %p)", action, plugin_page); + ENTER ("(action %p, page %p)", simple, page); - g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page)); + g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); - priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (plugin_page); + priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page); gsr_default_doclink_handler (priv->gsr); - gnc_plugin_page_register_ui_update (NULL, plugin_page); + gnc_plugin_page_register_ui_update (NULL, page); LEAVE (" "); } static void -gnc_plugin_page_register_cmd_linked_transaction_open (GtkAction *action, - GncPluginPageRegister* plugin_page) +gnc_plugin_page_register_cmd_linked_transaction_open (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageRegister* page = user_data; GncPluginPageRegisterPrivate* priv; - ENTER ("(action %p, plugin_page %p)", action, plugin_page); + ENTER ("(action %p, page %p)", simple, page); - g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page)); + g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); - priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (plugin_page); + priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page); gsr_default_doclink_open_handler (priv->gsr); LEAVE (" "); } static void -gnc_plugin_page_register_cmd_linked_transaction_remove (GtkAction *action, - GncPluginPageRegister* plugin_page) +gnc_plugin_page_register_cmd_linked_transaction_remove (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageRegister* page = user_data; GncPluginPageRegisterPrivate* priv; - ENTER ("(action %p, plugin_page %p)", action, plugin_page); + ENTER ("(action %p, page %p)", simple, page); - g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page)); + g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); - priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (plugin_page); + priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page); gsr_default_doclink_remove_handler (priv->gsr); - gnc_plugin_page_register_ui_update (NULL, plugin_page); + gnc_plugin_page_register_ui_update (NULL, page); LEAVE (" "); } @@ -4683,23 +4684,25 @@ GList* invoices_from_transaction (Transaction* trans) } static void -gnc_plugin_page_register_cmd_jump_linked_invoice (GtkAction* action, - GncPluginPageRegister* plugin_page) +gnc_plugin_page_register_cmd_jump_linked_invoice (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageRegister* page = user_data; GncPluginPageRegisterPrivate* priv; SplitRegister* reg; GncInvoice* invoice; Transaction *txn; GtkWidget *window; - ENTER ("(action %p, plugin_page %p)", action, plugin_page); + ENTER ("(action %p, page %p)", simple, page); - g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page)); - priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (plugin_page); + g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); + priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page); reg = gnc_ledger_display_get_split_register (priv->gsr->ledger); txn = gnc_split_register_get_current_trans (reg); invoice = invoice_from_split (gnc_split_register_get_current_split (reg)); - window = GNC_PLUGIN_PAGE(plugin_page)->window; + window = GNC_PLUGIN_PAGE(page)->window; if (!invoice) { @@ -4754,17 +4757,19 @@ Please choose one:"), _("Select"), 0, details); } static void -gnc_plugin_page_register_cmd_blank_transaction (GtkAction* action, - GncPluginPageRegister* plugin_page) +gnc_plugin_page_register_cmd_blank_transaction (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageRegister* page = user_data; GncPluginPageRegisterPrivate* priv; SplitRegister* reg; - ENTER ("(action %p, plugin_page %p)", action, plugin_page); + ENTER ("(action %p, page %p)", simple, page); - g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page)); + g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); - priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (plugin_page); + priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page); reg = gnc_ledger_display_get_split_register (priv->ledger); if (gnc_split_register_save (reg, TRUE)) @@ -4775,15 +4780,17 @@ gnc_plugin_page_register_cmd_blank_transaction (GtkAction* action, } static void -gnc_plugin_page_register_cmd_goto_date (GtkAction* action, - GncPluginPageRegister* page) +gnc_plugin_page_register_cmd_goto_date (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageRegister* page = user_data; GNCSplitReg* gsr; Query* query; time64 date = gnc_time (NULL); GList *splits; - ENTER ("(action %p, plugin_page %p)", action, page); + ENTER ("(action %p, page %p)", simple, page); g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); if (!gnc_dup_time64_dialog (gnc_plugin_page_get_window (GNC_PLUGIN_PAGE (page)), @@ -4812,69 +4819,85 @@ gnc_plugin_page_register_cmd_goto_date (GtkAction* action, } static void -gnc_plugin_page_register_cmd_duplicate_transaction (GtkAction* action, - GncPluginPageRegister* plugin_page) +gnc_plugin_page_register_cmd_duplicate_transaction (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageRegister* page = user_data; GncPluginPageRegisterPrivate* priv; - ENTER ("(action %p, plugin_page %p)", action, plugin_page); + ENTER ("(action %p, page %p)", simple, page); - g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page)); + g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); - priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (plugin_page); + priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page); gnc_split_register_duplicate_current (gnc_ledger_display_get_split_register (priv->ledger)); LEAVE (" "); } static void -gnc_plugin_page_register_cmd_reinitialize_transaction (GtkAction* action, - GncPluginPageRegister* plugin_page) +gnc_plugin_page_register_cmd_reinitialize_transaction (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageRegister* page = user_data; GncPluginPageRegisterPrivate* priv; - ENTER ("(action %p, plugin_page %p)", action, plugin_page); + ENTER ("(action %p, page %p)", simple, page); - g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page)); + g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); - priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (plugin_page); + priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page); gsr_default_reinit_handler (priv->gsr, NULL); LEAVE (" "); } static void -gnc_plugin_page_register_cmd_expand_transaction (GtkToggleAction* action, - GncPluginPageRegister* plugin_page) +gnc_plugin_page_register_cmd_expand_transaction (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncPluginPageRegister* page = user_data; GncPluginPageRegisterPrivate* priv; SplitRegister* reg; gboolean expand; + GVariant *state; - ENTER ("(action %p, plugin_page %p)", action, plugin_page); + ENTER ("(action %p, page %p)", simple, page); - g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page)); + g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); - priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (plugin_page); + priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page); reg = gnc_ledger_display_get_split_register (priv->ledger); - expand = gtk_toggle_action_get_active (action); + + state = g_action_get_state (G_ACTION(simple)); + + g_action_change_state (G_ACTION(simple), g_variant_new_boolean (!g_variant_get_boolean (state))); + + expand = g_variant_get_boolean (state); + gnc_split_register_expand_current_trans (reg, expand); + g_variant_unref (state); LEAVE (" "); } /** Callback for "Edit Exchange Rate" menu item. */ static void -gnc_plugin_page_register_cmd_exchange_rate (GtkAction* action, - GncPluginPageRegister* plugin_page) +gnc_plugin_page_register_cmd_exchange_rate (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageRegister* page = user_data; GncPluginPageRegisterPrivate* priv; SplitRegister* reg; - ENTER ("(action %p, plugin_page %p)", action, plugin_page); + ENTER ("(action %p, page %p)", simple, page); - g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page)); + g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); - priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (plugin_page); + priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page); reg = gnc_ledger_display_get_split_register (priv->ledger); /* XXX Ignore the return value -- we don't care if this succeeds */ @@ -4883,9 +4906,11 @@ gnc_plugin_page_register_cmd_exchange_rate (GtkAction* action, } static void -gnc_plugin_page_register_cmd_jump (GtkAction* action, - GncPluginPageRegister* plugin_page) +gnc_plugin_page_register_cmd_jump (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageRegister* page = user_data; GncPluginPageRegisterPrivate* priv; GncPluginPage* new_page; GtkWidget* window; @@ -4895,12 +4920,12 @@ gnc_plugin_page_register_cmd_jump (GtkAction* action, Account* leader; Split* split; - ENTER ("(action %p, plugin_page %p)", action, plugin_page); + ENTER ("(action %p, page %p)", simple, page); - g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page)); + g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); - priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (plugin_page); - window = GNC_PLUGIN_PAGE (plugin_page)->window; + priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page); + window = GNC_PLUGIN_PAGE (page)->window; if (window == NULL) { LEAVE ("no window"); @@ -4965,19 +4990,21 @@ gnc_plugin_page_register_cmd_jump (GtkAction* action, } static void -gnc_plugin_page_register_cmd_schedule (GtkAction* action, - GncPluginPageRegister* plugin_page) +gnc_plugin_page_register_cmd_schedule (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageRegister* page = user_data; GncPluginPageRegisterPrivate* priv; GtkWindow* window; - ENTER ("(action %p, plugin_page %p)", action, plugin_page); + ENTER ("(action %p, page %p)", simple, page); - g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page)); + g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); window = GTK_WINDOW (gnc_plugin_page_get_window (GNC_PLUGIN_PAGE ( - plugin_page))); - priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (plugin_page); + page))); + priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page); gsr_default_schedule_handler (priv->gsr, window); LEAVE (" "); } @@ -5004,19 +5031,21 @@ static void scrub_split (Split *split) } static void -gnc_plugin_page_register_cmd_scrub_current (GtkAction* action, - GncPluginPageRegister* plugin_page) +gnc_plugin_page_register_cmd_scrub_current (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageRegister* page = user_data; GncPluginPageRegisterPrivate* priv; Query* query; Split* split; SplitRegister* reg; - g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page)); + g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); - ENTER ("(action %p, plugin_page %p)", action, plugin_page); + ENTER ("(action %p, page %p)", simple, page); - priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (plugin_page); + priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page); query = gnc_ledger_display_get_query (priv->ledger); if (query == NULL) { @@ -5056,9 +5085,11 @@ scrub_kp_handler (GtkWidget *widget, GdkEventKey *event, gpointer data) } static void -gnc_plugin_page_register_cmd_scrub_all (GtkAction* action, - GncPluginPageRegister* plugin_page) +gnc_plugin_page_register_cmd_scrub_all (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageRegister* page = user_data; GncPluginPageRegisterPrivate* priv; Query* query; GncWindow* window; @@ -5067,11 +5098,11 @@ gnc_plugin_page_register_cmd_scrub_all (GtkAction* action, gulong scrub_kp_handler_ID; const char* message = _ ("Checking splits in current register: %u of %u"); - g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page)); + g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); - ENTER ("(action %p, plugin_page %p)", action, plugin_page); + ENTER ("(action %p, page %p)", simple, page); - priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (plugin_page); + priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page); query = gnc_ledger_display_get_query (priv->ledger); if (!query) { @@ -5082,7 +5113,7 @@ gnc_plugin_page_register_cmd_scrub_all (GtkAction* action, gnc_suspend_gui_refresh(); is_scrubbing = TRUE; gnc_set_abort_scrub (FALSE); - window = GNC_WINDOW (GNC_PLUGIN_PAGE (plugin_page)->window); + window = GNC_WINDOW (GNC_PLUGIN_PAGE (page)->window); scrub_kp_handler_ID = g_signal_connect (G_OBJECT (window), "key-press-event", G_CALLBACK (scrub_kp_handler), NULL); gnc_window_set_progressbar_window (window); @@ -5122,19 +5153,21 @@ gnc_plugin_page_register_cmd_scrub_all (GtkAction* action, } static void -gnc_plugin_page_register_cmd_account_report (GtkAction* action, - GncPluginPageRegister* plugin_page) +gnc_plugin_page_register_cmd_account_report (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageRegister* page = user_data; GncPluginPageRegisterPrivate* priv; GncMainWindow* window; int id; - ENTER ("(action %p, plugin_page %p)", action, plugin_page); + ENTER ("(action %p, page %p)", simple, page); - g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page)); + g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); - window = GNC_MAIN_WINDOW (GNC_PLUGIN_PAGE (plugin_page)->window); - priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (plugin_page); + window = GNC_MAIN_WINDOW (GNC_PLUGIN_PAGE (page)->window); + priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page); id = report_helper (priv->ledger, NULL, NULL); if (id >= 0) gnc_main_window_open_report (id, window); @@ -5142,9 +5175,11 @@ gnc_plugin_page_register_cmd_account_report (GtkAction* action, } static void -gnc_plugin_page_register_cmd_transaction_report (GtkAction* action, - GncPluginPageRegister* plugin_page) +gnc_plugin_page_register_cmd_transaction_report (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncPluginPageRegister* page = user_data; GncPluginPageRegisterPrivate* priv; GncMainWindow* window; SplitRegister* reg; @@ -5153,11 +5188,11 @@ gnc_plugin_page_register_cmd_transaction_report (GtkAction* action, int id; - ENTER ("(action %p, plugin_page %p)", action, plugin_page); + ENTER ("(action %p, page %p)", simple, page); - g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page)); + g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); - priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (plugin_page); + priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page); reg = gnc_ledger_display_get_split_register (priv->ledger); split = gnc_split_register_get_current_split (reg); @@ -5171,7 +5206,7 @@ gnc_plugin_page_register_cmd_transaction_report (GtkAction* action, xaccQueryAddGUIDMatch (query, xaccSplitGetGUID (split), GNC_ID_SPLIT, QOF_QUERY_AND); - window = GNC_MAIN_WINDOW (GNC_PLUGIN_PAGE (plugin_page)->window); + window = GNC_MAIN_WINDOW (GNC_PLUGIN_PAGE (page)->window); id = report_helper (priv->ledger, split, query); if (id >= 0) gnc_main_window_open_report (id, window); @@ -5214,16 +5249,16 @@ gnc_plugin_page_register_get_gsr (GncPluginPage* plugin_page) static void gnc_plugin_page_help_changed_cb (GNCSplitReg* gsr, - GncPluginPageRegister* register_page) + GncPluginPageRegister* page) { GncPluginPageRegisterPrivate* priv; SplitRegister* reg; GncWindow* window; char* help; - g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (register_page)); + g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); - window = GNC_WINDOW (GNC_PLUGIN_PAGE (register_page)->window); + window = GNC_WINDOW (GNC_PLUGIN_PAGE (page)->window); if (!window) { // This routine can be called before the page is added to a @@ -5232,22 +5267,22 @@ gnc_plugin_page_help_changed_cb (GNCSplitReg* gsr, } /* Get the text from the ledger */ - priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (register_page); + priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page); reg = gnc_ledger_display_get_split_register (priv->ledger); help = gnc_table_get_help (reg->table); - gnc_window_set_status (window, GNC_PLUGIN_PAGE (register_page), help); + gnc_window_set_status (window, GNC_PLUGIN_PAGE (page), help); g_free (help); } static void gnc_plugin_page_popup_menu_cb (GNCSplitReg* gsr, - GncPluginPageRegister* register_page) + GncPluginPageRegister* page) { GncWindow* window; - g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (register_page)); + g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); - window = GNC_WINDOW (GNC_PLUGIN_PAGE (register_page)->window); + window = GNC_WINDOW (GNC_PLUGIN_PAGE (page)->window); if (!window) { // This routine can be called before the page is added to a @@ -5255,7 +5290,7 @@ gnc_plugin_page_popup_menu_cb (GNCSplitReg* gsr, return; } gnc_main_window_popup_menu_cb (GTK_WIDGET (window), - GNC_PLUGIN_PAGE (register_page)); + GNC_PLUGIN_PAGE (page)); } static void diff --git a/gnucash/gnome/gnc-plugin-page-report.cpp b/gnucash/gnome/gnc-plugin-page-report.cpp index 23c70a8e90..3b983476a0 100644 --- a/gnucash/gnome/gnc-plugin-page-report.cpp +++ b/gnucash/gnome/gnc-plugin-page-report.cpp @@ -126,7 +126,7 @@ typedef struct GncPluginPageReportPrivate SCM edited_reports; /* The page is in the process of reloading the html */ - gboolean reloading; + gboolean reloading; gboolean loaded; /// the gnc_html abstraction this PluginPage contains @@ -176,17 +176,17 @@ void gnc_plugin_page_report_remove_edited_report(GncPluginPageReportPrivate *pri void gnc_plugin_page_report_add_edited_report(GncPluginPageReportPrivate *priv, SCM report); void gnc_plugin_page_report_raise_editor(SCM report); -static void gnc_plugin_page_report_forw_cb(GtkAction *action, GncPluginPageReport *rep); -static void gnc_plugin_page_report_back_cb(GtkAction *action, GncPluginPageReport *rep); -static void gnc_plugin_page_report_reload_cb(GtkAction *action, GncPluginPageReport *rep); -static void gnc_plugin_page_report_stop_cb(GtkAction *action, GncPluginPageReport *rep); -static void gnc_plugin_page_report_save_cb(GtkAction *action, GncPluginPageReport *rep); -static void gnc_plugin_page_report_save_as_cb(GtkAction *action, GncPluginPageReport *rep); -static void gnc_plugin_page_report_export_cb(GtkAction *action, GncPluginPageReport *rep); -static void gnc_plugin_page_report_options_cb(GtkAction *action, GncPluginPageReport *rep); -static void gnc_plugin_page_report_print_cb(GtkAction *action, GncPluginPageReport *rep); -static void gnc_plugin_page_report_exportpdf_cb(GtkAction *action, GncPluginPageReport *rep); -static void gnc_plugin_page_report_copy_cb(GtkAction *action, GncPluginPageReport *rep); +static void gnc_plugin_page_report_forw_cb (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_page_report_back_cb (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_page_report_reload_cb (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_page_report_stop_cb (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_page_report_save_cb (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_page_report_save_as_cb (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_page_report_export_cb (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_page_report_options_cb (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_page_report_print_cb (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_page_report_exportpdf_cb (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_page_report_copy_cb (GSimpleAction *simple, GVariant *parameter, gpointer user_data); static void gnc_plugin_page_report_get_property( GObject *obj, @@ -734,7 +734,7 @@ gnc_plugin_page_report_option_change_cb(gpointer data) gnc_utf8_strip_invalid_and_controls(new_name); ENTER("Cleaned-up new report name: %s", new_name); main_window_update_page_name(GNC_PLUGIN_PAGE(report), new_name); - } + } g_free(new_name); /* it's probably already dirty, but make sure */ @@ -1127,7 +1127,7 @@ gnc_plugin_page_report_destroy(GncPluginPageReportPrivate * priv) /** Short labels for use on the toolbar buttons. */ static action_toolbar_labels toolbar_labels[] = { - { "FilePrintAction", N_("Print") }, + { "FilePrintAction", N_("Print") }, { "ReportExportAction", N_("Export") }, { "ReportOptionsAction", N_("Options") }, /* Translators: This string is meant to be a short alternative for "Save Report Configuration" @@ -1181,7 +1181,8 @@ static void gnc_plugin_page_report_constr_init(GncPluginPageReport *plugin_page, gint reportId) { GncPluginPageReportPrivate *priv; - GtkActionGroup *action_group; +// GtkActionGroup *action_group; + GSimpleActionGroup *simple_action_group; GncPluginPage *parent; gboolean use_new; gchar *name; @@ -1193,80 +1194,84 @@ gnc_plugin_page_report_constr_init(GncPluginPageReport *plugin_page, gint report _("Add the current report's configuration to the 'Reports->Saved Report Configurations' menu. " "The report configuration will be saved in the file %s."), saved_reports_path); - GtkActionEntry report_actions[] = + static GActionEntry report_actions[] = + { + { "FilePrintAction", gnc_plugin_page_report_print_cb, nullptr, nullptr, nullptr }, + { "FilePrintPDFAction", gnc_plugin_page_report_exportpdf_cb, nullptr, nullptr, nullptr }, + { "EditCopyAction", gnc_plugin_page_report_copy_cb, nullptr, nullptr, nullptr }, + { "ViewRefreshAction", gnc_plugin_page_report_reload_cb, nullptr, nullptr, nullptr }, + { "ReportSaveAction", gnc_plugin_page_report_save_cb, nullptr, nullptr, nullptr }, + { "ReportSaveAsAction", gnc_plugin_page_report_save_as_cb, nullptr, nullptr, nullptr }, + { "ReportExportAction", gnc_plugin_page_report_export_cb, nullptr, nullptr, nullptr }, + { "ReportOptionsAction", gnc_plugin_page_report_options_cb, nullptr, nullptr, nullptr }, + { "ReportBackAction", gnc_plugin_page_report_back_cb, nullptr, nullptr, nullptr }, + { "ReportForwAction", gnc_plugin_page_report_forw_cb, nullptr, nullptr, nullptr }, + { "ReportReloadAction", gnc_plugin_page_report_reload_cb, nullptr, nullptr, nullptr }, + { "ReportStopAction", gnc_plugin_page_report_stop_cb, nullptr, nullptr, nullptr }, + }; + guint num_report_actions = G_N_ELEMENTS( report_actions ); + + static GncDisplayItem report_display_items [] = { { "FilePrintAction", "document-print", N_("_Print Report..."), "p", - N_("Print the current report"), - G_CALLBACK(gnc_plugin_page_report_print_cb) + N_("Print the current report") }, { "FilePrintPDFAction", GNC_ICON_PDF_EXPORT, N_("Export as P_DF..."), nullptr, - N_("Export the current report as a PDF document"), - G_CALLBACK(gnc_plugin_page_report_exportpdf_cb) + N_("Export the current report as a PDF document") }, - { "EditCutAction", "edit-cut", N_("Cu_t"), "X", - N_("Cut the current selection and copy it to clipboard"), - nullptr + N_("Cut the current selection and copy it to clipboard") }, { "EditCopyAction", "edit-copy", N_("_Copy"), "C", - N_("Copy the current selection to clipboard"), - G_CALLBACK(gnc_plugin_page_report_copy_cb) + N_("Copy the current selection to clipboard") }, { "EditPasteAction", "edit-paste", N_("_Paste"), "V", - N_("Paste the clipboard content at the cursor position"), - nullptr + N_("Paste the clipboard content at the cursor position") }, { "ViewRefreshAction", "view-refresh", N_("_Refresh"), "r", - N_("Refresh this window"), - G_CALLBACK (gnc_plugin_page_report_reload_cb) + N_("Refresh this window") }, { "ReportSaveAction", "document-save", N_("Save _Report Configuration"), "s", - report_save_str, G_CALLBACK(gnc_plugin_page_report_save_cb) + report_save_str }, { "ReportSaveAsAction", "document-save-as", N_("Save Report Configuration As..."), "s", - report_saveas_str, G_CALLBACK(gnc_plugin_page_report_save_as_cb) + report_saveas_str }, { "ReportExportAction", "go-next", N_("Export _Report"), nullptr, - N_("Export HTML-formatted report to file"), - G_CALLBACK(gnc_plugin_page_report_export_cb) + N_("Export HTML-formatted report to file") }, { "ReportOptionsAction", "document-properties", N_("_Report Options"), nullptr, - N_("Edit report options"), - G_CALLBACK(gnc_plugin_page_report_options_cb) + N_("Edit report options") }, - { "ReportBackAction", "go-previous", N_("Back"), nullptr, - N_("Move back one step in the history"), - G_CALLBACK(gnc_plugin_page_report_back_cb) + N_("Move back one step in the history") }, { "ReportForwAction", "go-next", N_("Forward"), nullptr, - N_("Move forward one step in the history"), - G_CALLBACK(gnc_plugin_page_report_forw_cb) + N_("Move forward one step in the history") }, { "ReportReloadAction", "view-refresh", N_("Reload"), nullptr, - N_("Reload the current page"), - G_CALLBACK(gnc_plugin_page_report_reload_cb) + N_("Reload the current page") }, { "ReportStopAction", "process-stop", N_("Stop"), nullptr, - N_("Cancel outstanding HTML requests"), - G_CALLBACK(gnc_plugin_page_report_stop_cb) + N_("Cancel outstanding HTML requests") }, }; - guint num_report_actions = G_N_ELEMENTS( report_actions ); + /** The number of display items provided by this plugin. */ + guint num_report_display_items = G_N_ELEMENTS(report_display_items); DEBUG( "property reportId=%d", reportId ); priv = GNC_PLUGIN_PAGE_REPORT_GET_PRIVATE(plugin_page); @@ -1281,7 +1286,7 @@ gnc_plugin_page_report_constr_init(GncPluginPageReport *plugin_page, gint report g_object_set(G_OBJECT(plugin_page), "page-name", name, "page-uri", "default:", - "ui-description", "gnc-plugin-page-report-ui.xml", + "ui-description", "gnc-plugin-page-report.ui", "use-new-window", use_new, nullptr); g_free(name); @@ -1290,17 +1295,25 @@ gnc_plugin_page_report_constr_init(GncPluginPageReport *plugin_page, gint report gnc_plugin_page_add_book(parent, gnc_get_current_book()); /* Create menu and toolbar information */ - action_group = - gnc_plugin_page_create_action_group(parent, - "GncPluginPageReportActions"); - gtk_action_group_add_actions( action_group, - report_actions, - num_report_actions, - plugin_page ); - gnc_plugin_update_actions(action_group, - initially_insensitive_actions, - "sensitive", FALSE); - gnc_plugin_init_short_names (action_group, toolbar_labels); + simple_action_group = gnc_plugin_page_create_action_groupb (parent, "GncPluginPageReportActions"); + g_action_map_add_action_entries (G_ACTION_MAP(simple_action_group), + report_actions, + num_report_actions, + plugin_page); + +// action_group = +// gnc_plugin_page_create_action_group(parent, +// "GncPluginPageReportActions"); +// gtk_action_group_add_actions( action_group, +// report_actions, +// num_report_actions, +// plugin_page ); + +//FIXMEb gnc_plugin_update_actions(action_group, +// initially_insensitive_actions, +// "sensitive", FALSE); + +//FIXMEb gnc_plugin_init_short_names (action_group, toolbar_labels); g_free (saved_reports_path); g_free (report_save_str); @@ -1385,8 +1398,11 @@ gnc_plugin_page_report_set_back_button(GncPluginPageReport *report, int enabled) // GTK ACTION CALLBACKS static void -gnc_plugin_page_report_forw_cb( GtkAction *action, GncPluginPageReport *report ) +gnc_plugin_page_report_forw_cb (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncPluginPageReport *report = (GncPluginPageReport*)user_data; GncPluginPageReportPrivate *priv; gnc_html_history_node * node = nullptr; @@ -1402,8 +1418,11 @@ gnc_plugin_page_report_forw_cb( GtkAction *action, GncPluginPageReport *report ) } static void -gnc_plugin_page_report_back_cb( GtkAction *action, GncPluginPageReport *report ) +gnc_plugin_page_report_back_cb (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncPluginPageReport *report = (GncPluginPageReport*)user_data; GncPluginPageReportPrivate *priv; gnc_html_history_node * node; @@ -1421,12 +1440,15 @@ gnc_plugin_page_report_back_cb( GtkAction *action, GncPluginPageReport *report ) void gnc_plugin_page_report_reload (GncPluginPageReport *report) { - gnc_plugin_page_report_reload_cb (NULL, report); + gnc_plugin_page_report_reload_cb (nullptr, nullptr, report); } static void -gnc_plugin_page_report_reload_cb( GtkAction *action, GncPluginPageReport *report ) +gnc_plugin_page_report_reload_cb (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncPluginPageReport *report = (GncPluginPageReport*)user_data; GncPluginPage *page; GncPluginPageReportPrivate *priv; SCM dirty_report; @@ -1461,8 +1483,11 @@ gnc_plugin_page_report_reload_cb( GtkAction *action, GncPluginPageReport *report } static void -gnc_plugin_page_report_stop_cb( GtkAction *action, GncPluginPageReport *report ) +gnc_plugin_page_report_stop_cb (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncPluginPageReport *report = (GncPluginPageReport*)user_data; GncPluginPageReportPrivate *priv; priv = GNC_PLUGIN_PAGE_REPORT_GET_PRIVATE(report); @@ -1618,8 +1643,11 @@ gnc_get_export_filename (SCM choice, GtkWindow *parent) } static void -gnc_plugin_page_report_save_as_cb( GtkAction *action, GncPluginPageReport *report ) +gnc_plugin_page_report_save_as_cb (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncPluginPageReport *report = (GncPluginPageReport*)user_data; GncPluginPageReportPrivate *priv; SCM save_func; SCM rpt_id; @@ -1649,8 +1677,11 @@ gnc_plugin_page_report_save_as_cb( GtkAction *action, GncPluginPageReport *repor } static void -gnc_plugin_page_report_save_cb( GtkAction *action, GncPluginPageReport *report ) +gnc_plugin_page_report_save_cb (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncPluginPageReport *report = (GncPluginPageReport*)user_data; GncPluginPageReportPrivate *priv; SCM check_func, save_func; SCM rpt_id; @@ -1675,13 +1706,16 @@ gnc_plugin_page_report_save_cb( GtkAction *action, GncPluginPageReport *report ) * So let's create a new report template based on this report * and allow the user to change the name. */ - gnc_plugin_page_report_save_as_cb (action, report); + gnc_plugin_page_report_save_as_cb (simple, nullptr, report); } } static void -gnc_plugin_page_report_export_cb( GtkAction *action, GncPluginPageReport *report ) +gnc_plugin_page_report_export_cb (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncPluginPageReport *report = (GncPluginPageReport*)user_data; GncPluginPageReportPrivate *priv; char * filepath; SCM export_types; @@ -1745,10 +1779,10 @@ gnc_plugin_page_report_export_cb( GtkAction *action, GncPluginPageReport *report g_free (str); } else - gnc_error_dialog (parent, "%s", - _("This report must be upgraded to return a " - "document object with export-string or " - "export-error.")); + gnc_error_dialog (parent, "%s", + _("This report must be upgraded to return a " + "document object with export-string or " + "export-error.")); } result = TRUE; } @@ -1768,8 +1802,11 @@ gnc_plugin_page_report_export_cb( GtkAction *action, GncPluginPageReport *report } static void -gnc_plugin_page_report_options_cb( GtkAction *action, GncPluginPageReport *report ) +gnc_plugin_page_report_options_cb (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncPluginPageReport *report = (GncPluginPageReport*)user_data; GncPluginPageReportPrivate *priv; GtkWindow *parent = GTK_WINDOW (gnc_plugin_page_get_window (GNC_PLUGIN_PAGE (report))); priv = GNC_PLUGIN_PAGE_REPORT_GET_PRIVATE(report); @@ -1934,8 +1971,11 @@ static gchar *report_create_jobname(GncPluginPageReportPrivate *priv) } static void -gnc_plugin_page_report_print_cb( GtkAction *action, GncPluginPageReport *report ) +gnc_plugin_page_report_print_cb (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncPluginPageReport *report = (GncPluginPageReport*)user_data; GncPluginPageReportPrivate *priv = GNC_PLUGIN_PAGE_REPORT_GET_PRIVATE(report); gchar *job_name = report_create_jobname(priv); @@ -1951,8 +1991,11 @@ gnc_plugin_page_report_print_cb( GtkAction *action, GncPluginPageReport *report } static void -gnc_plugin_page_report_exportpdf_cb( GtkAction *action, GncPluginPageReport *report ) +gnc_plugin_page_report_exportpdf_cb(GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncPluginPageReport *report = (GncPluginPageReport*)user_data; GncPluginPageReportPrivate *priv = GNC_PLUGIN_PAGE_REPORT_GET_PRIVATE(report); gchar *job_name = report_create_jobname(priv); GncInvoice *invoice; @@ -1966,19 +2009,19 @@ gnc_plugin_page_report_exportpdf_cb( GtkAction *action, GncPluginPageReport *rep owner = (GncOwner*) gncInvoiceGetOwner(invoice); if (owner) { - QofInstance *inst = qofOwnerGetOwner (owner); - gchar *dirname = nullptr; - qof_instance_get (inst, "export-pdf-dir", &dirname, nullptr); + QofInstance *inst = qofOwnerGetOwner (owner); + gchar *dirname = nullptr; + qof_instance_get (inst, "export-pdf-dir", &dirname, nullptr); // Yes. In the kvp, look up the key for the Export-PDF output // directory. If it exists, prepend this to the job name so that // we can export to PDF. - if (dirname && g_file_test(dirname, - (GFileTest)(G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))) - { - gchar *tmp = g_build_filename(dirname, job_name, nullptr); - g_free(job_name); - job_name = tmp; - } + if (dirname && g_file_test(dirname, + (GFileTest)(G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))) + { + gchar *tmp = g_build_filename(dirname, job_name, nullptr); + g_free(job_name); + job_name = tmp; + } } } @@ -1992,14 +2035,14 @@ gnc_plugin_page_report_exportpdf_cb( GtkAction *action, GncPluginPageReport *rep if (owner) { - /* As this is an invoice report with some owner, we will try - * to look up the chosen output directory from the print - * settings and store it again in the owner kvp. - */ + /* As this is an invoice report with some owner, we will try + * to look up the chosen output directory from the print + * settings and store it again in the owner kvp. + */ GtkPrintSettings *print_settings = gnc_print_get_settings(); if (print_settings && - gtk_print_settings_has_key(print_settings, - GNC_GTK_PRINT_SETTINGS_EXPORT_DIR)) + gtk_print_settings_has_key(print_settings, + GNC_GTK_PRINT_SETTINGS_EXPORT_DIR)) { const char* dirname = gtk_print_settings_get(print_settings, GNC_GTK_PRINT_SETTINGS_EXPORT_DIR); @@ -2009,8 +2052,8 @@ gnc_plugin_page_report_exportpdf_cb( GtkAction *action, GncPluginPageReport *rep { QofInstance *inst = qofOwnerGetOwner(owner); gncOwnerBeginEdit(owner); - qof_instance_set (inst, "export-pdf-dir", dirname); - gncOwnerCommitEdit(owner); + qof_instance_set (inst, "export-pdf-dir", dirname); + gncOwnerCommitEdit(owner); } } } @@ -2019,8 +2062,11 @@ gnc_plugin_page_report_exportpdf_cb( GtkAction *action, GncPluginPageReport *rep } static void -gnc_plugin_page_report_copy_cb(GtkAction *action, GncPluginPageReport *report) +gnc_plugin_page_report_copy_cb (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncPluginPageReport *report = (GncPluginPageReport*)user_data; GncPluginPageReportPrivate *priv; priv = GNC_PLUGIN_PAGE_REPORT_GET_PRIVATE(report); diff --git a/gnucash/gnome/gnc-plugin-page-sx-list.c b/gnucash/gnome/gnc-plugin-page-sx-list.c index ac21349e03..8a3a3d7375 100644 --- a/gnucash/gnome/gnc-plugin-page-sx-list.c +++ b/gnucash/gnome/gnc-plugin-page-sx-list.c @@ -62,6 +62,7 @@ #include "gnc-glib-utils.h" #include "gnc-icons.h" #include "gnc-main-window.h" +#include "gnc-plugin.h" #include "gnc-plugin-page-sx-list.h" #include "gnc-session.h" #include "gnc-sx-instance-dense-cal-adapter.h" @@ -119,38 +120,47 @@ static GncPluginPage *gnc_plugin_page_sx_list_recreate_page (GtkWidget *window, static void gppsl_row_activated_cb (GtkTreeView *tree_view, GtkTreePath *path, GtkTreeViewColumn *column, gpointer user_data); -static void gnc_plugin_page_sx_list_cmd_new (GtkAction *action, GncPluginPageSxList *page); -static void gnc_plugin_page_sx_list_cmd_edit (GtkAction *action, GncPluginPageSxList *page); -static void gnc_plugin_page_sx_list_cmd_delete (GtkAction *action, GncPluginPageSxList *page); -static void gnc_plugin_page_sx_list_cmd_refresh (GtkAction *action, GncPluginPageSxList *page); +static void gnc_plugin_page_sx_list_cmd_new (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_sx_list_cmd_edit (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_sx_list_cmd_delete (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_sx_list_cmd_refresh (GSimpleAction *simple, GVariant *paramter, gpointer user_data); /* Command callbacks */ -static GtkActionEntry gnc_plugin_page_sx_list_actions [] = +static GActionEntry gnc_plugin_page_sx_list_actions [] = { - { "SxListAction", NULL, N_("_Scheduled"), NULL, NULL, NULL }, - { - "SxListNewAction", GNC_ICON_NEW_ACCOUNT, N_("_New"), NULL, - N_("Create a new scheduled transaction"), G_CALLBACK(gnc_plugin_page_sx_list_cmd_new) - }, - { - "SxListEditAction", GNC_ICON_EDIT_ACCOUNT, N_("_Edit"), NULL, - N_("Edit the selected scheduled transaction"), G_CALLBACK(gnc_plugin_page_sx_list_cmd_edit) - }, - { - "SxListDeleteAction", GNC_ICON_DELETE_ACCOUNT, N_("_Delete"), NULL, - N_("Delete the selected scheduled transaction"), G_CALLBACK(gnc_plugin_page_sx_list_cmd_delete) - }, - - /* View menu */ - - { - "ViewRefreshAction", "view-refresh", N_("_Refresh"), "r", - N_("Refresh this window"), G_CALLBACK(gnc_plugin_page_sx_list_cmd_refresh) - }, + { "SxListAction", NULL, NULL, NULL, NULL }, + { "SxListNewAction", gnc_plugin_page_sx_list_cmd_new, NULL, NULL, NULL }, + { "SxListEditAction", gnc_plugin_page_sx_list_cmd_edit, NULL, NULL, NULL }, + { "SxListDeleteAction", gnc_plugin_page_sx_list_cmd_delete, NULL, NULL, NULL }, + { "ViewRefreshAction", gnc_plugin_page_sx_list_cmd_refresh, NULL, NULL, NULL }, }; /** The number of actions provided by this plugin. */ static guint gnc_plugin_page_sx_list_n_actions = G_N_ELEMENTS(gnc_plugin_page_sx_list_actions); +static GncDisplayItem gnc_plugin_page_sx_list_display_items [] = +{ + { "SxListAction", NULL, N_("_Scheduled"), NULL, NULL }, + { + "SxListNewAction", GNC_ICON_NEW_ACCOUNT, N_("_New"), NULL, + N_("Create a new scheduled transaction") + }, + { + "SxListEditAction", GNC_ICON_EDIT_ACCOUNT, N_("_Edit"), NULL, + N_("Edit the selected scheduled transaction") + }, + { + "SxListDeleteAction", GNC_ICON_DELETE_ACCOUNT, N_("_Delete"), NULL, + N_("Delete the selected scheduled transaction") + }, + /* View menu */ + { + "ViewRefreshAction", "view-refresh", N_("_Refresh"), "r", + N_("Refresh this window") + }, +}; +/** The number of display items provided by this plugin. */ +static guint gnc_plugin_page_sx_list_n_display_items = G_N_ELEMENTS(gnc_plugin_page_sx_list_display_items); + GncPluginPage * gnc_plugin_page_sx_list_new (void) { @@ -211,7 +221,8 @@ gnc_plugin_page_sx_list_class_init (GncPluginPageSxListClass *klass) static void gnc_plugin_page_sx_list_init (GncPluginPageSxList *plugin_page) { - GtkActionGroup *action_group; +// GtkActionGroup *action_group; + GSimpleActionGroup *simple_action_group; GncPluginPage *parent; /* Init parent declared variables */ @@ -219,17 +230,15 @@ gnc_plugin_page_sx_list_init (GncPluginPageSxList *plugin_page) g_object_set(G_OBJECT(plugin_page), "page-name", _("Scheduled Transactions"), "page-uri", "default:", - "ui-description", "gnc-plugin-page-sx-list-ui.xml", + "ui-description", "gnc-plugin-page-sx-list.ui", NULL); gnc_plugin_page_add_book (parent, gnc_get_current_book()); - action_group = - gnc_plugin_page_create_action_group (parent, - "GncPluginPageSxListActions"); - gtk_action_group_add_actions (action_group, - gnc_plugin_page_sx_list_actions, - gnc_plugin_page_sx_list_n_actions, - plugin_page); + simple_action_group = gnc_plugin_page_create_action_groupb (parent, "GncPluginPageSxListActions"); + g_action_map_add_action_entries (G_ACTION_MAP(simple_action_group), + gnc_plugin_page_sx_list_actions, + gnc_plugin_page_sx_list_n_actions, + plugin_page); /* gnc_plugin_init_short_names (action_group, toolbar_labels); */ } @@ -379,21 +388,21 @@ gppsl_model_populated_cb (GtkTreeModel *tree_model, GncPluginPageSxList *page) static void gpps_new_cb (GtkMenuItem *menuitem, GncPluginPageSxList *page) { - gnc_plugin_page_sx_list_cmd_new (NULL, page); + gnc_plugin_page_sx_list_cmd_new (NULL, NULL, page); return; } static void gpps_edit_cb (GtkMenuItem *menuitem, GncPluginPageSxList *page) { - gnc_plugin_page_sx_list_cmd_edit (NULL, page); + gnc_plugin_page_sx_list_cmd_edit (NULL, NULL, page); return; } static void gpps_delete_cb (GtkMenuItem *menuitem, GncPluginPageSxList *page) { - gnc_plugin_page_sx_list_cmd_delete (NULL, page); + gnc_plugin_page_sx_list_cmd_delete (NULL, NULL, page); return; } @@ -702,9 +711,12 @@ gnc_plugin_page_sx_list_recreate_page (GtkWidget *window, static void -gnc_plugin_page_sx_list_cmd_new (GtkAction *action, GncPluginPageSxList *page) +gnc_plugin_page_sx_list_cmd_new (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { - GtkWindow *window = GTK_WINDOW(gnc_plugin_page_get_window (GNC_PLUGIN_PAGE(page))); + GncPluginPageSxList *plugin_page = user_data; + GtkWindow *window = GTK_WINDOW(gnc_plugin_page_get_window (GNC_PLUGIN_PAGE(plugin_page))); SchedXaction *new_sx; gboolean new_sx_flag = TRUE; @@ -722,17 +734,20 @@ gnc_plugin_page_sx_list_cmd_new (GtkAction *action, GncPluginPageSxList *page) gnc_sx_set_schedule (new_sx, schedule); } gnc_ui_scheduled_xaction_editor_dialog_create (window, new_sx, new_sx_flag); - gppsl_update_selected_list (page, TRUE, new_sx); + gppsl_update_selected_list (plugin_page, TRUE, new_sx); } static void -gnc_plugin_page_sx_list_cmd_refresh (GtkAction *action, GncPluginPageSxList *page) +gnc_plugin_page_sx_list_cmd_refresh (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncPluginPageSxList *plugin_page = user_data; GncPluginPageSxListPrivate *priv; - g_return_if_fail (GNC_IS_PLUGIN_PAGE_SX_LIST(page)); + g_return_if_fail (GNC_IS_PLUGIN_PAGE_SX_LIST(plugin_page)); - priv = GNC_PLUGIN_PAGE_SX_LIST_GET_PRIVATE(page); + priv = GNC_PLUGIN_PAGE_SX_LIST_GET_PRIVATE(plugin_page); gtk_widget_queue_draw (priv->widget); } @@ -751,10 +766,13 @@ _argument_reorder_fn (GtkTreePath* list_path_data, GncTreeViewSxList* user_tree_ static void -gnc_plugin_page_sx_list_cmd_edit (GtkAction *action, GncPluginPageSxList *page) +gnc_plugin_page_sx_list_cmd_edit (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { - GncPluginPageSxListPrivate *priv = GNC_PLUGIN_PAGE_SX_LIST_GET_PRIVATE(page); - GtkWindow *window = GTK_WINDOW(gnc_plugin_page_get_window (GNC_PLUGIN_PAGE(page))); + GncPluginPageSxList *plugin_page = user_data; + GncPluginPageSxListPrivate *priv = GNC_PLUGIN_PAGE_SX_LIST_GET_PRIVATE(plugin_page); + GtkWindow *window = GTK_WINDOW(gnc_plugin_page_get_window (GNC_PLUGIN_PAGE(plugin_page))); GtkTreeSelection *selection; GList *selected_paths, *to_edit; GtkTreeModel *model; @@ -771,11 +789,11 @@ gnc_plugin_page_sx_list_cmd_edit (GtkAction *action, GncPluginPageSxList *page) (GncGMapFunc)_argument_reorder_fn, priv->tree_view); - gppsl_update_selected_list (page, TRUE, NULL); + gppsl_update_selected_list (plugin_page, TRUE, NULL); for (GList *list = to_edit; list != NULL; list = list->next) { DEBUG ("to-edit [%s]\n", xaccSchedXactionGetName ((SchedXaction*)list->data)); - gppsl_update_selected_list (page, FALSE, list->data); + gppsl_update_selected_list (plugin_page, FALSE, list->data); } g_list_foreach (to_edit, (GFunc)_edit_sx, window); @@ -816,9 +834,12 @@ _destroy_sx(gpointer data, gpointer user_data) static void -gnc_plugin_page_sx_list_cmd_delete (GtkAction *action, GncPluginPageSxList *page) +gnc_plugin_page_sx_list_cmd_delete (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { - GncPluginPageSxListPrivate *priv = GNC_PLUGIN_PAGE_SX_LIST_GET_PRIVATE(page); + GncPluginPageSxList *plugin_page = user_data; + GncPluginPageSxListPrivate *priv = GNC_PLUGIN_PAGE_SX_LIST_GET_PRIVATE(plugin_page); GtkTreeSelection *selection; GList *selected_paths, *to_delete = NULL; GtkTreeModel *model; @@ -838,7 +859,7 @@ gnc_plugin_page_sx_list_cmd_delete (GtkAction *action, GncPluginPageSxList *page (GncGMapFunc)_argument_reorder_fn, priv->tree_view); - window = GTK_WINDOW(gnc_plugin_page_get_window (GNC_PLUGIN_PAGE(page))); + window = GTK_WINDOW(gnc_plugin_page_get_window (GNC_PLUGIN_PAGE(plugin_page))); length = g_list_length (to_delete); @@ -849,11 +870,11 @@ gnc_plugin_page_sx_list_cmd_delete (GtkAction *action, GncPluginPageSxList *page if (gnc_verify_dialog (window, FALSE, "%s", message)) { - gppsl_update_selected_list (page, TRUE, NULL); + gppsl_update_selected_list (plugin_page, TRUE, NULL); for (GList *list = to_delete; list != NULL; list = list->next) { DEBUG("to-delete [%s]\n", xaccSchedXactionGetName ((SchedXaction*)list->data)); - gppsl_update_selected_list (page, FALSE, list->data); + gppsl_update_selected_list (plugin_page, FALSE, list->data); } g_list_foreach (to_delete, (GFunc)_destroy_sx, NULL); } From 8d3eb666d383740b0eba727625d3e231f7fe6bf8 Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Fri, 28 Oct 2022 16:05:43 +0100 Subject: [PATCH 04/77] Add a couple of util functions to find items in the menu bar and toolbar --- gnucash/gnome-utils/gnc-gtk-utils.c | 506 ++++++++++++++++++++++++++++ gnucash/gnome-utils/gnc-gtk-utils.h | 29 ++ 2 files changed, 535 insertions(+) diff --git a/gnucash/gnome-utils/gnc-gtk-utils.c b/gnucash/gnome-utils/gnc-gtk-utils.c index 70686c6902..da63ceb438 100644 --- a/gnucash/gnome-utils/gnc-gtk-utils.c +++ b/gnucash/gnome-utils/gnc-gtk-utils.c @@ -332,3 +332,509 @@ gnc_get_dialog_widget_from_id (GtkDialog *dialog, const gchar *id) GtkWidget *content_area = gtk_dialog_get_content_area (dialog); return find_widget_func (content_area, id); } + + +/** Disable all the actions in a simple action group + * + * @param action_group The GSimpleActionGroup + */ +void +gnc_disable_all_actions_in_group (GSimpleActionGroup *action_group) +{ + gchar **actions; + gint num_actions; + + g_return_if_fail (action_group != NULL); + + actions = g_action_group_list_actions (G_ACTION_GROUP(action_group)); + num_actions = g_strv_length (actions); + + // Disable the actions + for (gint i = 0; i < num_actions; i++) + { + GAction *action = g_action_map_lookup_action (G_ACTION_MAP(action_group), + actions[i]); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE); + } + g_strfreev (actions); +} + + +static void +add_accel_for_menu_lookup (GtkWidget *widget, gpointer user_data) +{ + if (GTK_IS_MENU_ITEM(widget)) + { + GtkMenuItem* menuItem = GTK_MENU_ITEM(widget); + GtkWidget* subMenu = gtk_menu_item_get_submenu (menuItem); + GtkWidget *accel_label = gtk_bin_get_child (GTK_BIN(widget)); + + if (accel_label) + { + guint key; + GdkModifierType mods; + + gtk_accel_label_get_accel (GTK_ACCEL_LABEL(accel_label), &key, &mods); + + if (key > 0) + gtk_widget_add_accelerator (GTK_WIDGET(widget), "activate", + GTK_ACCEL_GROUP(user_data), + key, mods, GTK_ACCEL_VISIBLE); + } + if (GTK_IS_CONTAINER(subMenu)) + gtk_container_foreach (GTK_CONTAINER(subMenu), + add_accel_for_menu_lookup, user_data); + } +} + +/** Add accelerator keys for menu item widgets + * + * @param menu The menu widget. + * + * @param accel_group The accelerator group to use. + */ +void +gnc_add_accelerator_keys_for_menu (GtkWidget *menu, GtkAccelGroup *accel_group) +{ + g_return_if_fail (GTK_IS_WIDGET(menu)); + g_return_if_fail (accel_group != NULL); + + gtk_container_foreach (GTK_CONTAINER(menu), add_accel_for_menu_lookup, accel_group); +} + + +static gpointer +find_menu_item_func (GtkWidget *widget, const gchar *action_name, const gchar *action_label) +{ + GtkWidget *ret = NULL; + + if (GTK_IS_MENU_ITEM(widget)) + { + GtkWidget* subMenu; + + if (action_name) + { + if (GTK_IS_ACTIONABLE(widget)) + { + const gchar *a_name = gtk_actionable_get_action_name (GTK_ACTIONABLE(widget)); + + if (g_strcmp0 (a_name, action_name) == 0) + return widget; + } + } + + if (action_label) + { + GtkWidget *accel_label = gtk_bin_get_child (GTK_BIN(widget)); + + if (accel_label) + { + // use gtk_label_get_text to get text with no underlines + const gchar *al_name = gtk_label_get_label (GTK_LABEL(accel_label)); + + if (g_strcmp0 (al_name, action_label) == 0) + return widget; + } + } + + subMenu = gtk_menu_item_get_submenu (GTK_MENU_ITEM(widget)); + + if (GTK_IS_CONTAINER(subMenu)) + { + GList *container_list = gtk_container_get_children (GTK_CONTAINER(subMenu)); + for (GList *n = container_list; !ret && n; n = n->next) + ret = find_menu_item_func (n->data, action_name, action_label); + g_list_free (container_list); + } + } + return ret; +} + +/** Search the menu for the menu item based on the label or action name + * + * @param menu The menu widget. + * + * @param action_name The GAction name. + * + * @return The menu item widget or NULL. + */ +GtkWidget * +gnc_find_menu_item_by_action_name (GtkWidget *menu, const gchar *action_name) +{ + GtkWidget *ret = NULL; + const gchar *action_label = NULL; + + g_return_val_if_fail (GTK_IS_WIDGET(menu), NULL); + g_return_val_if_fail (action_name != NULL, NULL); + + if (GTK_IS_CONTAINER(menu)) + { + GList *container_list = gtk_container_get_children (GTK_CONTAINER(menu)); + for (GList *n = container_list; !ret && n; n = n->next) + ret = find_menu_item_func (n->data, action_name, action_label); + g_list_free (container_list); + } + return ret; +} + + +/** Search the menu for the menu item based on the action label + * + * @param menu The menu widget. + * + * @param action_label The GtkMenuItem label. + * + * @return The menu item widget or NULL. + */ +GtkWidget * +gnc_find_menu_item_by_action_label (GtkWidget *menu, const gchar *action_label) +{ + GtkWidget *ret = NULL; + const gchar *action_name = NULL; + + g_return_val_if_fail (GTK_IS_WIDGET(menu), NULL); + g_return_val_if_fail (action_label != NULL, NULL); + + if (GTK_IS_CONTAINER(menu)) + { + GList *container_list = gtk_container_get_children (GTK_CONTAINER(menu)); + for (GList *n = container_list; !ret && n; n = n->next) + ret = find_menu_item_func (n->data, action_name, action_label); + g_list_free (container_list); + } + return ret; +} + + +static void +search_menu_item_list (GtkWidget *widget, gpointer user_data) +{ + GList **list = user_data; + + if (GTK_IS_MENU_ITEM(widget)) + { + GtkWidget* subMenu = gtk_menu_item_get_submenu (GTK_MENU_ITEM(widget)); + const gchar *a_name = g_object_get_data (G_OBJECT(widget), "myaction-name"); + + *list = g_list_prepend (*list, widget); + + if (!a_name) + { + GtkWidget *accel_label = gtk_bin_get_child (GTK_BIN(widget)); + + if (accel_label) + { + // use gtk_label_get_text to get text with no underlines + const gchar *al_name = gtk_label_get_label (GTK_LABEL(accel_label)); + + g_object_set_data_full (G_OBJECT(widget), "myaction-name", + g_strdup (al_name), g_free); + } + } + + if (GTK_IS_CONTAINER(subMenu)) + gtk_container_foreach (GTK_CONTAINER(subMenu), + search_menu_item_list, user_data); + } +} + +/** Return a list of menu items + * + * @param menu The menu widget. + * + * @return A GList of menu items or NULL. + */ +GList * +gnc_menu_get_items (GtkWidget *menu) +{ + GList *list = NULL; + + g_return_val_if_fail (GTK_IS_WIDGET(menu), NULL); + + gtk_container_foreach (GTK_CONTAINER(menu), search_menu_item_list, &list); + + return list; +} + +/** Search the toolbar for the tool item based on the action name + * + * @param toolbar The toolbar widget. + * + * @param action_name The GAction name. + * + * @return The tool item widget or NULL. + */ +GtkWidget * +gnc_find_toolbar_item (GtkWidget *toolbar, const gchar *action_name) +{ + GtkWidget *found = NULL; + + g_return_val_if_fail (GTK_IS_TOOLBAR(toolbar), NULL); + g_return_val_if_fail (action_name != NULL, NULL); + + for (gint i = 0; i < gtk_toolbar_get_n_items (GTK_TOOLBAR(toolbar)); i++) + { + GtkToolItem *item = gtk_toolbar_get_nth_item (GTK_TOOLBAR(toolbar), i); + + if (GTK_IS_ACTIONABLE(item)) + { + const gchar *item_action_name = gtk_actionable_get_action_name (GTK_ACTIONABLE(item)); + + if (g_str_has_suffix (item_action_name, action_name)) + { + found = GTK_WIDGET(item); + break; + } + } + } + return found; +} + + +static void +extract_items_from_model (GMenuModel *model, + gint item, + gpointer user_data) +{ + GMenuAttributeIter *iter; + const gchar *key; + GVariant *value; + GncMenuModelSearch *gsm = user_data; + const gchar *action = NULL; + const gchar *label = NULL; + const gchar *tooltip = NULL; + + iter = g_menu_model_iterate_item_attributes (model, item); + while (g_menu_attribute_iter_get_next (iter, &key, &value)) + { + if (g_str_equal (key, "tooltip") && g_variant_is_of_type (value, G_VARIANT_TYPE_STRING)) + tooltip = g_variant_get_string (value, NULL); + else if (g_str_equal (key, "label") && g_variant_is_of_type (value, G_VARIANT_TYPE_STRING)) + label = g_variant_get_string (value, NULL); + else if (g_str_equal (key, "action") && g_variant_is_of_type (value, G_VARIANT_TYPE_STRING)) + action = g_variant_get_string (value, NULL); + + g_variant_unref (value); + } + + if (action && gsm->search_action_name) + { + if (g_str_has_suffix (action, gsm->search_action_name)) + { + gsm->model = model; + gsm->index = item; + gsm->tooltip = tooltip; + gsm->search_action_label = label; + } + } + if (label && gsm->search_action_label) + { + if (g_strcmp0 (label, gsm->search_action_label) == 0) + { + gsm->model = model; + gsm->index = item; + gsm->tooltip = tooltip; + gsm->search_action_name = action; + } + } + g_object_unref (iter); +} + +static void +items_from_model (GMenuModel *model, + gpointer user_data) +{ + GncMenuModelSearch *gsm = user_data; + + for (gint i = 0; i < g_menu_model_get_n_items (model); i++) + { + GMenuLinkIter *iter; + GMenuModel *sub_model; + + if (gsm->model) + return; + + extract_items_from_model (model, i, user_data); + + iter = g_menu_model_iterate_item_links (model, i); + while (g_menu_link_iter_get_next (iter, NULL, &sub_model)) + { + items_from_model (sub_model, user_data); + g_object_unref (sub_model); + } + g_object_unref (iter); + } +} + +gboolean +gnc_menubar_model_find_item (GMenuModel *menu_model, GncMenuModelSearch *gsm) +{ + + g_return_val_if_fail (menu_model != NULL, FALSE); + g_return_val_if_fail (gsm != NULL, FALSE); + + gsm->model = NULL; + + items_from_model (menu_model, gsm); + + if (gsm->model) + return TRUE; + + return FALSE; +} + +GtkWidget * +gnc_menubar_model_find_menu_item (GMenuModel *menu_model, GtkWidget *menu, const gchar *action_name) +{ + GncMenuModelSearch *gsm = g_new0 (GncMenuModelSearch, 1); + GtkWidget *menu_item = NULL; + + gsm->search_action_label = NULL; + gsm->search_action_name = action_name; + + if (gnc_menubar_model_find_item (menu_model, gsm)) + { + menu_item = gnc_find_menu_item_by_action_label (menu, gsm->search_action_label); + } + g_free (gsm); + return menu_item; +} + + +gboolean +gnc_menubar_model_update_item (GMenuModel *menu_model, const gchar *action_name, + const gchar *label, const gchar *tooltip) +{ + GncMenuModelSearch *gsm = g_new0 (GncMenuModelSearch, 1); + GtkWidget *menu_item = NULL; + gboolean found = FALSE; + + gsm->search_action_label = NULL; + gsm->search_action_name = action_name; + + if (gnc_menubar_model_find_item (menu_model, gsm)) + { + GMenuAttributeIter *iter; + const gchar *key; + GVariant *value; + GVariant *old_target = NULL; + const gchar *old_action = NULL; + const gchar *old_label = NULL; + const gchar *old_temp = NULL; + const gchar *old_accel = NULL; + GMenuItem *item; + + iter = g_menu_model_iterate_item_attributes (gsm->model, gsm->index); + while (g_menu_attribute_iter_get_next (iter, &key, &value)) + { + if (g_str_equal (key, "temp") && g_variant_is_of_type (value, G_VARIANT_TYPE_STRING)) + old_temp = g_variant_get_string (value, NULL); + else if (g_str_equal (key, "label") && g_variant_is_of_type (value, G_VARIANT_TYPE_STRING)) + old_label = g_variant_get_string (value, NULL); + else if (g_str_equal (key, "action") && g_variant_is_of_type (value, G_VARIANT_TYPE_STRING)) + old_action = g_variant_get_string (value, NULL); + else if (g_str_equal (key, "accel") && g_variant_is_of_type (value, G_VARIANT_TYPE_STRING)) + old_accel = g_variant_get_string (value, NULL); + else if (g_str_equal (key, "target")) + old_target = g_variant_ref (value); + + g_variant_unref (value); + } + + item = g_menu_item_new (label, old_action); + + if (tooltip) + g_menu_item_set_attribute (item, "tooltip", "s", tooltip); + + if (old_temp) + g_menu_item_set_attribute (item, "temp", "s", old_temp); + + if (old_accel) + g_menu_item_set_attribute (item, "accel", "s", old_accel); + + if (old_target) + { + g_menu_item_set_attribute_value (item, "target", old_target); + g_variant_unref (old_target); + } + + g_menu_remove (G_MENU(gsm->model), gsm->index); + g_menu_insert_item (G_MENU(gsm->model), gsm->index, item); + + found = TRUE; + } + g_free (gsm); + return found; +} + +typedef struct +{ + GMenuModel *model; + gint index; +} to_remove; + +static void +item_to_remove_from_model (GMenuModel *model, + gint item, + GList **remove_list, + const gchar *attrib) +{ + GVariant *value = g_menu_model_get_item_attribute_value (model, item, + attrib, NULL); + + if (value && g_variant_is_of_type (value, G_VARIANT_TYPE_STRING)) + { + to_remove *tr = g_new0 (to_remove, 1); + tr->model = model; + tr->index = item; + + // to keep order appended + *remove_list = g_list_append (*remove_list, tr); + g_variant_unref (value); + } +} + +static void +remove_items_from_model (GMenuModel *model, + GList **remove_list, + const gchar *attrib) +{ + // Note: item high to low + for (gint i = g_menu_model_get_n_items (model) -1; i >= 0; i--) + { + GMenuLinkIter *iter; + GMenuModel *sub_model; + + item_to_remove_from_model (model, i, remove_list, attrib); + + iter = g_menu_model_iterate_item_links (model, i); + while (g_menu_link_iter_get_next (iter, NULL, &sub_model)) + { + remove_items_from_model (sub_model, remove_list, attrib); + g_object_unref (sub_model); + } + g_object_unref (iter); + } +} + +static void +remove_items (gpointer data, gpointer user_data) +{ + to_remove *tr = (to_remove*)data; + g_menu_remove (G_MENU(tr->model), tr->index); + g_free (tr); +} + +void +gnc_menubar_model_remove_items_with_attrib (GMenuModel *menu_model, const gchar *attrib) +{ + GList *remove_list = NULL; + + g_return_if_fail (menu_model != NULL); + g_return_if_fail (attrib != NULL); + + remove_items_from_model (menu_model, &remove_list, attrib); + + g_list_foreach (remove_list, (GFunc)remove_items, NULL); + g_list_free (remove_list); +} diff --git a/gnucash/gnome-utils/gnc-gtk-utils.h b/gnucash/gnome-utils/gnc-gtk-utils.h index b227eec0c8..2902f812d0 100644 --- a/gnucash/gnome-utils/gnc-gtk-utils.h +++ b/gnucash/gnome-utils/gnc-gtk-utils.h @@ -55,6 +55,35 @@ void gnc_style_context_get_border_color (GtkStyleContext *context, GtkWidget *gnc_get_dialog_widget_from_id (GtkDialog *dialog, const gchar *id); +void gnc_disable_all_actions_in_group (GSimpleActionGroup *action_group); + +void gnc_add_accelerator_keys_for_menu (GtkWidget *menu, GtkAccelGroup *accel_group); + +GtkWidget *gnc_find_menu_item_by_action_name (GtkWidget *menu, const gchar *action_name); +GtkWidget *gnc_find_menu_item_by_action_label (GtkWidget *menu, const gchar *action_label); +GList *gnc_menu_get_items (GtkWidget *menu); + +GtkWidget *gnc_find_toolbar_item (GtkWidget *toolbar, const gchar *action_name); + +struct _GncMenuModelSearch +{ + const gchar *search_action_name; + const gchar *search_action_label; + const gchar *tooltip; + GMenuModel *model; + gint index; +}; + +typedef struct _GncMenuModelSearch GncMenuModelSearch; + +gboolean gnc_menubar_model_find_item (GMenuModel *menu_model, GncMenuModelSearch *gsm); +GtkWidget *gnc_menubar_model_find_menu_item (GMenuModel *menu_model, GtkWidget *menu, const gchar *action_name); + +gboolean gnc_menubar_model_update_item (GMenuModel *menu_model, const gchar *action_name, + const gchar *label, const gchar *tooltip); + +void gnc_menubar_model_remove_items_with_attrib (GMenuModel *menu_model, const gchar *attrib); + /** @} */ #endif /* GNC_GTK_UTILS_H */ From 6e29ae278f45079231ac2a902e22f3b765306e9e Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Sun, 30 Oct 2022 13:22:28 +0000 Subject: [PATCH 05/77] Change GtkGroupAction and GtkActions Change GtkGroupAction to GSimpleActionGroup and any remaining GtkActions to GAction. Also comment out any unsure changes that need further investigation. --- gnucash/gnome-utils/gnc-embedded-window.c | 5 +- gnucash/gnome-utils/gnc-main-window.cpp | 937 ++++++++++-------- gnucash/gnome-utils/gnc-main-window.h | 26 +- gnucash/gnome-utils/gnc-plugin-file-history.c | 39 +- .../gnome-utils/gnc-plugin-menu-additions.c | 27 +- gnucash/gnome-utils/gnc-plugin-page.c | 24 +- gnucash/gnome-utils/gnc-plugin-page.h | 8 +- gnucash/gnome-utils/gnc-plugin.c | 37 +- gnucash/gnome-utils/gnc-plugin.h | 13 +- gnucash/gnome/dialog-invoice.c | 4 +- gnucash/gnome/gnc-plugin-basic-commands.c | 30 +- gnucash/gnome/gnc-plugin-budget.c | 8 +- gnucash/gnome/gnc-plugin-business.c | 38 +- gnucash/gnome/gnc-plugin-page-account-tree.c | 23 +- gnucash/gnome/gnc-plugin-page-budget.c | 13 +- gnucash/gnome/gnc-plugin-page-invoice.c | 49 +- gnucash/gnome/gnc-plugin-page-owner-tree.c | 36 +- gnucash/gnome/gnc-plugin-page-register.c | 90 +- gnucash/gnome/gnc-plugin-page-report.cpp | 134 ++- gnucash/gnome/gnc-plugin-page-sx-list.c | 24 +- gnucash/gnucash-gresources.xml | 1 + .../import-export/aqb/gnc-plugin-aqbanking.c | 72 +- gnucash/ui/gnc-main-window.ui | 542 ++++++++++ po/CMakeLists.txt | 1 + 24 files changed, 1409 insertions(+), 772 deletions(-) create mode 100644 gnucash/ui/gnc-main-window.ui diff --git a/gnucash/gnome-utils/gnc-embedded-window.c b/gnucash/gnome-utils/gnc-embedded-window.c index e0855f6f5f..6bd410268c 100644 --- a/gnucash/gnome-utils/gnc-embedded-window.c +++ b/gnucash/gnome-utils/gnc-embedded-window.c @@ -84,6 +84,7 @@ typedef struct GncEmbeddedWindowPrivate * This does not include any action provided by menu or content * plugins. */ GtkActionGroup *action_group; + GSimpleActionGroup *simple_action_group; //FIXMEb added /** The currently selected page. */ GncPluginPage *page; @@ -124,7 +125,7 @@ gnc_embedded_window_open_page (GncEmbeddedWindow *window, gtk_box_pack_end(GTK_BOX(window), page->notebook_page, TRUE, TRUE, 2); gnc_plugin_page_inserted (page); - gnc_plugin_page_merge_actions (page, window->ui_merge); +//FIXMEb gnc_plugin_page_merge_actions (page, window->ui_merge); LEAVE(" "); } @@ -153,7 +154,7 @@ gnc_embedded_window_close_page (GncEmbeddedWindow *window, priv->page = NULL; gnc_plugin_page_removed (page); - gnc_plugin_page_unmerge_actions (page, window->ui_merge); +//FIXMEb gnc_plugin_page_unmerge_actions (page, window->ui_merge); gtk_ui_manager_ensure_update (window->ui_merge); gnc_plugin_page_destroy_widget (page); diff --git a/gnucash/gnome-utils/gnc-main-window.cpp b/gnucash/gnome-utils/gnc-main-window.cpp index f0b50e6a1c..29745bcb5c 100644 --- a/gnucash/gnome-utils/gnc-main-window.cpp +++ b/gnucash/gnome-utils/gnc-main-window.cpp @@ -153,7 +153,7 @@ static guint secs_to_save = 0; /* Declarations *********************************************************/ static void gnc_main_window_class_init (GncMainWindowClass *klass); static void gnc_main_window_init (GncMainWindow *window, - void *data); + void *data); static void gnc_main_window_finalize (GObject *object); static void gnc_main_window_destroy (GtkWidget *widget); @@ -172,40 +172,42 @@ static void gnc_main_window_plugin_removed (GncPlugin *manager, GncPlugin *plugi static void gnc_main_window_engine_commit_error_callback( gpointer data, QofBackendError errcode ); /* Command callbacks */ -static void gnc_main_window_cmd_page_setup (GtkAction *action, GncMainWindow *window); -static void gnc_main_window_cmd_file_properties (GtkAction *action, GncMainWindow *window); -static void gnc_main_window_cmd_file_close (GtkAction *action, GncMainWindow *window); -static void gnc_main_window_cmd_file_quit (GtkAction *action, GncMainWindow *window); -static void gnc_main_window_cmd_edit_cut (GtkAction *action, GncMainWindow *window); -static void gnc_main_window_cmd_edit_copy (GtkAction *action, GncMainWindow *window); -static void gnc_main_window_cmd_edit_paste (GtkAction *action, GncMainWindow *window); -static void gnc_main_window_cmd_edit_preferences (GtkAction *action, GncMainWindow *window); -static void gnc_main_window_cmd_view_refresh (GtkAction *action, GncMainWindow *window); -static void gnc_main_window_cmd_view_toolbar (GtkAction *action, GncMainWindow *window); -static void gnc_main_window_cmd_view_summary (GtkAction *action, GncMainWindow *window); -static void gnc_main_window_cmd_view_statusbar (GtkAction *action, GncMainWindow *window); -static void gnc_main_window_cmd_view_tab_position (GtkAction *action, GtkRadioAction *current, GncMainWindow *window); -static void gnc_main_window_cmd_actions_reset_warnings (GtkAction *action, GncMainWindow *window); -static void gnc_main_window_cmd_actions_rename_page (GtkAction *action, GncMainWindow *window); -static void gnc_main_window_cmd_window_new (GtkAction *action, GncMainWindow *window); -static void gnc_main_window_cmd_window_move_page (GtkAction *action, GncMainWindow *window); +static void gnc_main_window_cmd_page_setup (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_main_window_cmd_file_properties (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_main_window_cmd_file_close (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_main_window_cmd_file_quit (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_main_window_cmd_edit_cut (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_main_window_cmd_edit_copy (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_main_window_cmd_edit_paste (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_main_window_cmd_edit_preferences (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_main_window_cmd_view_refresh (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_main_window_cmd_view_toolbar (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_main_window_cmd_view_summary (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_main_window_cmd_view_statusbar (GSimpleAction *simple, GVariant *paramter, gpointer user_data); + +static void gnc_main_window_cmd_view_tab_position (GSimpleAction *simple, GVariant *parameter, gpointer user_data); + +static void gnc_main_window_cmd_actions_reset_warnings (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_main_window_cmd_actions_rename_page (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_main_window_cmd_window_new (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_main_window_cmd_window_move_page (GSimpleAction *simple, GVariant *paramter, gpointer user_data); #ifndef MAC_INTEGRATION -static void gnc_main_window_cmd_window_raise (GtkAction *action, GtkRadioAction *current, GncMainWindow *window); +static void gnc_main_window_cmd_window_raise (GSimpleAction *simple, GVariant *parameter, gpointer user_data); #endif -static void gnc_main_window_cmd_help_tutorial (GtkAction *action, GncMainWindow *window); -static void gnc_main_window_cmd_help_contents (GtkAction *action, GncMainWindow *window); -static void gnc_main_window_cmd_help_about (GtkAction *action, GncMainWindow *window); +static void gnc_main_window_cmd_help_tutorial (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_main_window_cmd_help_contents (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_main_window_cmd_help_about (GSimpleAction *simple, GVariant *paramter, gpointer user_data); static void do_popup_menu(GncPluginPage *page, GdkEventButton *event); static GtkWidget *gnc_main_window_get_statusbar (GncWindow *window_in); -static void statusbar_notification_lastmodified(void); +static void statusbar_notification_lastmodified (void); static void gnc_main_window_update_tab_position (gpointer prefs, gchar *pref, gpointer user_data); static void gnc_main_window_remove_prefs (GncMainWindow *window); #ifdef MAC_INTEGRATION -static void gnc_quartz_shutdown(GtkosxApplication *theApp, gpointer data); -static gboolean gnc_quartz_should_quit(GtkosxApplication *theApp, GncMainWindow *window); -static void gnc_quartz_set_menu(GncMainWindow* window); +static void gnc_quartz_shutdown (GtkosxApplication *theApp, gpointer data); +static gboolean gnc_quartz_should_quit (GtkosxApplication *theApp, GncMainWindow *window); +static void gnc_quartz_set_menu (GncMainWindow* window); #endif /** The instance private data structure for an embedded window @@ -237,7 +239,7 @@ typedef struct GncMainWindowPrivate * itself. This does not include any action provided by menu * or content plugins. */ GtkActionGroup *action_group; - + GSimpleActionGroup *simple_action_group; //FIXMEb added /** A list of all pages that are installed in this window. */ GList *installed_pages; /** A list of pages in order of use (most recent -> least recent) */ @@ -255,12 +257,13 @@ typedef struct GncMainWindowPrivate GHashTable *merged_actions_table; /** Set when restoring plugin pages */ gboolean restoring_pages; + } GncMainWindowPrivate; GNC_DEFINE_TYPE_WITH_CODE(GncMainWindow, gnc_main_window, GTK_TYPE_WINDOW, G_ADD_PRIVATE (GncMainWindow) G_IMPLEMENT_INTERFACE (GNC_TYPE_WINDOW, - gnc_window_main_window_init)) + gnc_window_main_window_init)) #define GNC_MAIN_WINDOW_GET_PRIVATE(o) \ ((GncMainWindowPrivate*)gnc_main_window_get_instance_private((GncMainWindow*)o)) @@ -275,221 +278,188 @@ typedef struct /** The action group itself. This contains all actions added * by a single menu or content plugin. */ GtkActionGroup *action_group; + GSimpleActionGroup *simple_action_group; //FIXMEb added } MergedActionEntry; /** A holding place for all the signals generated by the main window * code. */ static guint main_window_signals[LAST_SIGNAL] = { 0 }; +static void +toggle_change_state (GSimpleAction *simple, + GVariant *state, + gpointer user_data) +{ + g_simple_action_set_state (simple, state); +} + +static void +radio_change_state (GSimpleAction *simple, + GVariant *state, + gpointer user_data) +{ + g_simple_action_set_state (simple, state); +} /** An array of all of the actions provided by the main window code. * This includes some placeholder actions for the menus that are * visible in the menu bar but have no action associated with * them. */ -static GtkActionEntry gnc_menu_actions [] = +static GActionEntry gnc_menu_actions [] = { - /* Toplevel */ + { "FilePageSetupAction", gnc_main_window_cmd_page_setup, nullptr, nullptr, nullptr }, + { "FilePropertiesAction", gnc_main_window_cmd_file_properties, nullptr, nullptr, nullptr }, + { "FileCloseAction", gnc_main_window_cmd_file_close, nullptr, nullptr, nullptr }, + { "FileQuitAction", gnc_main_window_cmd_file_quit, nullptr, nullptr, nullptr }, + { "EditCutAction", gnc_main_window_cmd_edit_cut, nullptr, nullptr, nullptr }, + { "EditCopyAction", gnc_main_window_cmd_edit_copy, nullptr, nullptr, nullptr }, + { "EditPasteAction", gnc_main_window_cmd_edit_paste, nullptr, nullptr, nullptr }, + { "EditPreferencesAction", gnc_main_window_cmd_edit_preferences, nullptr, nullptr, nullptr }, + { "ViewRefreshAction", gnc_main_window_cmd_view_refresh, nullptr, nullptr, nullptr }, + { "ActionsForgetWarningsAction", gnc_main_window_cmd_actions_reset_warnings, nullptr, nullptr, nullptr }, + { "ActionsRenamePageAction", gnc_main_window_cmd_actions_rename_page, nullptr, nullptr, nullptr }, + { "WindowNewAction", gnc_main_window_cmd_window_new, nullptr, nullptr, nullptr }, + { "WindowMovePageAction", gnc_main_window_cmd_window_move_page, nullptr, nullptr, nullptr }, + { "HelpTutorialAction", gnc_main_window_cmd_help_tutorial, nullptr, nullptr, nullptr }, + { "HelpContentsAction", gnc_main_window_cmd_help_contents, nullptr, nullptr, nullptr }, + { "HelpAboutAction", gnc_main_window_cmd_help_about, nullptr, nullptr, nullptr }, - { "FileAction", nullptr, N_("_File"), nullptr, nullptr, nullptr, }, - { "EditAction", nullptr, N_("_Edit"), nullptr, nullptr, nullptr }, - { "ViewAction", nullptr, N_("_View"), nullptr, nullptr, nullptr }, - { "ActionsAction", nullptr, N_("_Actions"), nullptr, nullptr, nullptr }, - { "TransactionAction", nullptr, N_("Tra_nsaction"), nullptr, nullptr, nullptr }, - { "ReportsAction", nullptr, N_("_Reports"), nullptr, nullptr, nullptr }, - { "ToolsAction", nullptr, N_("_Tools"), nullptr, nullptr, nullptr }, - { "ExtensionsAction", nullptr, N_("E_xtensions"), nullptr, nullptr, nullptr }, - { "WindowsAction", nullptr, N_("_Windows"), nullptr, nullptr, nullptr }, - { "HelpAction", nullptr, N_("_Help"), nullptr, nullptr, nullptr }, + { "ViewToolbarAction", gnc_main_window_cmd_view_toolbar, nullptr, "true", toggle_change_state }, + { "ViewSummaryAction", gnc_main_window_cmd_view_summary, nullptr, "true", toggle_change_state }, + { "ViewStatusbarAction", gnc_main_window_cmd_view_statusbar, nullptr, "true", toggle_change_state }, + { "ViewTabPositionAction", gnc_main_window_cmd_view_tab_position, "n", 0, radio_change_state }, + { "Window0Action", gnc_main_window_cmd_window_raise, "n", 0, radio_change_state }, +}; +/** The number of actions provided by the main window. */ +static guint gnc_menu_n_actions = G_N_ELEMENTS(gnc_menu_actions); + +static GncDisplayItem gnc_menu_display_items [] = +{ /* File menu */ - - { "FileImportAction", nullptr, N_("_Import"), nullptr, nullptr, nullptr }, - { "FileExportAction", nullptr, N_("_Export"), nullptr, nullptr, nullptr }, + { "FileImportAction", nullptr, N_("_Import"), nullptr, nullptr }, + { "FileExportAction", nullptr, N_("_Export"), nullptr, nullptr }, { "FilePrintAction", "document-print", N_("_Print..."), "p", - N_("Print the currently active page"), nullptr + N_("Print the currently active page") }, #ifndef GTK_STOCK_PAGE_SETUP # define GTK_STOCK_PAGE_SETUP nullptr #endif { "FilePageSetupAction", "document-page-setup", N_("Pa_ge Setup..."), "p", - N_("Specify the page size and orientation for printing"), - G_CALLBACK (gnc_main_window_cmd_page_setup) + N_("Specify the page size and orientation for printing") }, { "FilePropertiesAction", "document-properties", N_("Proper_ties"), "Return", - N_("Edit the properties of the current file"), - G_CALLBACK (gnc_main_window_cmd_file_properties) + N_("Edit the properties of the current file") }, { "FileCloseAction", "window-close", N_("_Close"), "W", - N_("Close the currently active page"), - G_CALLBACK (gnc_main_window_cmd_file_close) + N_("Close the currently active page") }, { "FileQuitAction", "application-exit", N_("_Quit"), "Q", - N_("Quit this application"), - G_CALLBACK (gnc_main_window_cmd_file_quit) + N_("Quit this application") }, - /* Edit menu */ - { "EditCutAction", "edit-cut", N_("Cu_t"), "X", - N_("Cut the current selection and copy it to clipboard"), - G_CALLBACK (gnc_main_window_cmd_edit_cut) + N_("Cut the current selection and copy it to clipboard") }, { "EditCopyAction", "edit-copy", N_("_Copy"), "C", - N_("Copy the current selection to clipboard"), - G_CALLBACK (gnc_main_window_cmd_edit_copy) + N_("Copy the current selection to clipboard") }, { "EditPasteAction", "edit-paste", N_("_Paste"), "V", - N_("Paste the clipboard content at the cursor position"), - G_CALLBACK (gnc_main_window_cmd_edit_paste) + N_("Paste the clipboard content at the cursor position") }, { "EditPreferencesAction", "preferences-system", N_("Pr_eferences"), nullptr, - N_("Edit the global preferences of GnuCash"), - G_CALLBACK (gnc_main_window_cmd_edit_preferences) + N_("Edit the global preferences of GnuCash") }, - /* View menu */ - - { "ViewTabPositionAction", NULL, N_("Tab P_osition"), NULL, NULL, NULL }, + { "ViewTabPositionAction", nullptr, N_("Tab P_osition"), nullptr, nullptr }, { "ViewSortByAction", nullptr, N_("_Sort By..."), nullptr, - N_("Select sorting criteria for this page view"), nullptr + N_("Select sorting criteria for this page view") }, { "ViewFilterByAction", nullptr, N_("_Filter By..."), nullptr, - N_("Select the account types that should be displayed."), nullptr + N_("Select the account types that should be displayed.") }, { "ViewRefreshAction", "view-refresh", N_("_Refresh"), "r", - N_("Refresh this window"), - G_CALLBACK (gnc_main_window_cmd_view_refresh) + N_("Refresh this window") }, - /* Actions menu */ - - { "ScrubMenuAction", nullptr, N_("_Check & Repair"), nullptr, nullptr, nullptr }, + { "ScrubMenuAction", nullptr, N_("_Check & Repair"), nullptr, nullptr }, { "ActionsForgetWarningsAction", nullptr, N_("Reset _Warnings..."), nullptr, - N_("Reset the state of all warning messages so they will be shown again."), - G_CALLBACK (gnc_main_window_cmd_actions_reset_warnings) + N_("Reset the state of all warning messages so they will be shown again.") }, { "ActionsRenamePageAction", nullptr, N_("Re_name Page"), nullptr, - N_("Rename this page."), - G_CALLBACK (gnc_main_window_cmd_actions_rename_page) + N_("Rename this page.") }, - /* Windows menu */ - { "WindowNewAction", nullptr, N_("_New Window"), nullptr, - N_("Open a new top-level GnuCash window."), - G_CALLBACK (gnc_main_window_cmd_window_new) + N_("Open a new top-level GnuCash window.") }, { "WindowMovePageAction", nullptr, N_("New Window with _Page"), nullptr, - N_("Move the current page to a new top-level GnuCash window."), - G_CALLBACK (gnc_main_window_cmd_window_move_page) + N_("Move the current page to a new top-level GnuCash window.") }, - /* Help menu */ - { "HelpTutorialAction", "help-browser", N_("Tutorial and Concepts _Guide"), "H", - N_("Open the GnuCash Tutorial"), - G_CALLBACK (gnc_main_window_cmd_help_tutorial) + N_("Open the GnuCash Tutorial") }, { "HelpContentsAction", "help-browser", N_("_Contents"), "F1", - N_("Open the GnuCash Help"), - G_CALLBACK (gnc_main_window_cmd_help_contents) + N_("Open the GnuCash Help") }, { "HelpAboutAction", "help-about", N_("_About"), nullptr, - N_("About GnuCash"), - G_CALLBACK (gnc_main_window_cmd_help_about) + N_("About GnuCash") }, -}; -/** The number of actions provided by the main window. */ -static guint gnc_menu_n_actions = G_N_ELEMENTS (gnc_menu_actions); - -/** An array of all of the toggle action provided by the main window - * code. */ -static GtkToggleActionEntry toggle_actions [] = -{ + /* Toggle actions */ { "ViewToolbarAction", nullptr, N_("_Toolbar"), nullptr, - N_("Show/hide the toolbar on this window"), - G_CALLBACK (gnc_main_window_cmd_view_toolbar), TRUE + N_("Show/hide the toolbar on this window") }, { "ViewSummaryAction", nullptr, N_("Su_mmary Bar"), nullptr, - N_("Show/hide the summary bar on this window"), - G_CALLBACK (gnc_main_window_cmd_view_summary), TRUE + N_("Show/hide the summary bar on this window") }, { "ViewStatusbarAction", nullptr, N_("Stat_us Bar"), nullptr, - N_("Show/hide the status bar on this window"), - G_CALLBACK (gnc_main_window_cmd_view_statusbar), TRUE + N_("Show/hide the status bar on this window") + }, + { "ViewTabPositionAction", nullptr, N_("Tab P_osition"), nullptr, + nullptr + }, + { + "ViewTabPositionTopAction", nullptr, N_("To_p"), nullptr, + N_("Display the notebook tabs at the top of the window.") + }, + { + "ViewTabPositionBottomAction", nullptr, N_("B_ottom"), nullptr, + N_("Display the notebook tabs at the bottom of the window.") + }, + { + "ViewTabPositionLeftAction", nullptr, N_("_Left"), nullptr, + N_("Display the notebook tabs at the left of the window.") + }, + { + "ViewTabPositionRightAction", nullptr, N_("_Right"), nullptr, + N_("Display the notebook tabs at the right of the window.") }, }; -/** The number of toggle actions provided by the main window. */ -static guint n_toggle_actions = G_N_ELEMENTS (toggle_actions); - -/** An array of all of the radio actions provided by the main window - * for tab positions. */ -static GtkRadioActionEntry tab_pos_radio_entries [] = -{ - { - "ViewTabPositionTopAction", NULL, N_("To_p"), NULL, - N_("Display the notebook tabs at the top of the window."), GTK_POS_TOP - }, - { - "ViewTabPositionBottomAction", NULL, N_("B_ottom"), NULL, - N_("Display the notebook tabs at the bottom of the window."), GTK_POS_BOTTOM - }, - { - "ViewTabPositionLeftAction", NULL, N_("_Left"), NULL, - N_("Display the notebook tabs at the left of the window."), GTK_POS_LEFT - }, - { - "ViewTabPositionRightAction", NULL, N_("_Right"), NULL, - N_("Display the notebook tabs at the right of the window."), GTK_POS_RIGHT - }, -}; - -/** The number of radio actions provided by the main window for tab - * positions. */ -static guint n_tab_pos_radio_entries = G_N_ELEMENTS (tab_pos_radio_entries); - -#ifndef MAC_INTEGRATION -/** An array of all of the radio action provided by the main window - * code. */ -static GtkRadioActionEntry radio_entries [] = -{ - { "Window0Action", nullptr, N_("Window _1"), nullptr, nullptr, 0 }, - { "Window1Action", nullptr, N_("Window _2"), nullptr, nullptr, 1 }, - { "Window2Action", nullptr, N_("Window _3"), nullptr, nullptr, 2 }, - { "Window3Action", nullptr, N_("Window _4"), nullptr, nullptr, 3 }, - { "Window4Action", nullptr, N_("Window _5"), nullptr, nullptr, 4 }, - { "Window5Action", nullptr, N_("Window _6"), nullptr, nullptr, 5 }, - { "Window6Action", nullptr, N_("Window _7"), nullptr, nullptr, 6 }, - { "Window7Action", nullptr, N_("Window _8"), nullptr, nullptr, 7 }, - { "Window8Action", nullptr, N_("Window _9"), nullptr, nullptr, 8 }, - { "Window9Action", nullptr, N_("Window _0"), nullptr, nullptr, 9 }, -}; - -/** The number of radio actions provided by the main window. */ -static gsize n_radio_entries = G_N_ELEMENTS (radio_entries); -#endif +/** The number of display items provided by the main window. */ +static guint gnc_menu_n_display_items = G_N_ELEMENTS(gnc_menu_display_items); /** These are the "important" actions provided by the main window. * Their labels will appear when the toolbar is set to "Icons and @@ -712,7 +682,7 @@ static void gnc_main_window_restore_window (GncMainWindow *window, GncMainWindowSaveData *data) { GncMainWindowPrivate *priv; - GtkAction *action; + GAction *action; gint *pos, *geom, *order; gsize length; gboolean max, visible, desired_visibility; @@ -861,10 +831,10 @@ gnc_main_window_restore_window (GncMainWindow *window, GncMainWindowSaveData *da } /* Common view menu items */ - action = gnc_main_window_find_action(window, "ViewToolbarAction"); - visible = gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action)); - desired_visibility = g_key_file_get_boolean(data->key_file, window_group, - TOOLBAR_VISIBLE, &error); + action = gnc_main_window_find_action (window, "ViewToolbarAction"); +//FIXMEb visible = gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action)); + desired_visibility = g_key_file_get_boolean (data->key_file, window_group, + TOOLBAR_VISIBLE, &error); if (error) { g_warning("error reading group %s key %s: %s", @@ -874,13 +844,13 @@ gnc_main_window_restore_window (GncMainWindow *window, GncMainWindowSaveData *da } else if (visible != desired_visibility) { - gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), desired_visibility); +// gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), desired_visibility); } action = gnc_main_window_find_action(window, "ViewSummaryAction"); - visible = gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action)); - desired_visibility = g_key_file_get_boolean(data->key_file, window_group, - SUMMARYBAR_VISIBLE, &error); +//FIXMEb visible = gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action)); + desired_visibility = g_key_file_get_boolean (data->key_file, window_group, + SUMMARYBAR_VISIBLE, &error); if (error) { g_warning("error reading group %s key %s: %s", @@ -890,13 +860,13 @@ gnc_main_window_restore_window (GncMainWindow *window, GncMainWindowSaveData *da } else if (visible != desired_visibility) { - gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), desired_visibility); +// gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), desired_visibility); } action = gnc_main_window_find_action(window, "ViewStatusbarAction"); - visible = gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action)); - desired_visibility = g_key_file_get_boolean(data->key_file, window_group, - STATUSBAR_VISIBLE, &error); +//FIXMEb visible = gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action)); + desired_visibility = g_key_file_get_boolean (data->key_file, window_group, + STATUSBAR_VISIBLE, &error); if (error) { g_warning("error reading group %s key %s: %s", @@ -906,7 +876,7 @@ gnc_main_window_restore_window (GncMainWindow *window, GncMainWindowSaveData *da } else if (visible != desired_visibility) { - gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), desired_visibility); +// gtk_toggle_action_set_active (GTK_TOGGLE_ACTION(action), desired_visibility); } priv->restoring_pages = TRUE; /* Now populate the window with pages. */ @@ -924,8 +894,8 @@ gnc_main_window_restore_window (GncMainWindow *window, GncMainWindowSaveData *da /* Restore page ordering within the notebook. Use +1 notation so the * numbers in the page order match the page sections, at least for * the one window case. */ - order = g_key_file_get_integer_list(data->key_file, window_group, - WINDOW_PAGEORDER, &length, &error); + order = g_key_file_get_integer_list (data->key_file, window_group, + WINDOW_PAGEORDER, &length, &error); if (error) { g_warning("error reading group %s key %s: %s", @@ -1011,7 +981,7 @@ gnc_main_window_restore_all_windows(const GKeyFile *keyfile) void gnc_main_window_restore_default_state(GncMainWindow *window) { - GtkAction *action; + GAction *action; /* The default state should be to have an Account Tree page open * in the window. */ @@ -1019,8 +989,8 @@ gnc_main_window_restore_default_state(GncMainWindow *window) if (!window) window = static_cast(g_list_nth_data(active_windows, 0)); gtk_widget_show (GTK_WIDGET(window)); - action = gnc_main_window_find_action(window, "ViewAccountTreeAction"); - gtk_action_activate(action); + action = gnc_main_window_find_action (window, "ViewAccountTreeAction"); +//FIXMEb gtk_action_activate(action); } /** Save the state of a single page to a disk. This function handles @@ -1069,7 +1039,7 @@ static void gnc_main_window_save_window (GncMainWindow *window, GncMainWindowSaveData *data) { GncMainWindowPrivate *priv; - GtkAction *action; + GAction *action; gint i, num_pages, coords[4], *order; gboolean maximized, minimized, visible; gchar *window_group; @@ -1134,21 +1104,22 @@ gnc_main_window_save_window (GncMainWindow *window, GncMainWindowSaveData *data) maximized ? "maximized" : "not maximized"); /* Common view menu items */ - action = gnc_main_window_find_action(window, "ViewToolbarAction"); - visible = gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action)); - g_key_file_set_boolean(data->key_file, window_group, - TOOLBAR_VISIBLE, visible); - action = gnc_main_window_find_action(window, "ViewSummaryAction"); - visible = gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action)); - g_key_file_set_boolean(data->key_file, window_group, - SUMMARYBAR_VISIBLE, visible); - action = gnc_main_window_find_action(window, "ViewStatusbarAction"); - visible = gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action)); - g_key_file_set_boolean(data->key_file, window_group, - STATUSBAR_VISIBLE, visible); + action = gnc_main_window_find_action (window, "ViewToolbarAction"); +//FIXMEb visible = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION(action)); + visible = TRUE; //just added for testing + g_key_file_set_boolean (data->key_file, window_group, + TOOLBAR_VISIBLE, visible); + action = gnc_main_window_find_action (window, "ViewSummaryAction"); +//FIXMEb visible = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION(action)); + g_key_file_set_boolean (data->key_file, window_group, + SUMMARYBAR_VISIBLE, visible); + action = gnc_main_window_find_action (window, "ViewStatusbarAction"); +//FIXMEb visible = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION(action)); + g_key_file_set_boolean (data->key_file, window_group, + STATUSBAR_VISIBLE, visible); /* Save individual pages in this window */ - g_list_foreach(priv->installed_pages, (GFunc)gnc_main_window_save_page, data); + g_list_foreach (priv->installed_pages, (GFunc)gnc_main_window_save_page, data); g_free(window_group); LEAVE("window %p", window); @@ -1675,9 +1646,9 @@ gnc_main_window_generate_title (GncMainWindow *window) /* Update the menus based upon whether this is an "immutable" page. */ immutable = page && g_object_get_data (G_OBJECT (page), PLUGIN_PAGE_IMMUTABLE); - gnc_plugin_update_actions(priv->action_group, - immutable_page_actions, - "sensitive", !immutable); + gnc_plugin_update_actionsb (priv->simple_action_group, + immutable_page_actions, + "sensitive", !immutable); /* Trigger sensitivity updtates of other actions such as Save/Revert */ g_signal_emit_by_name (window, "page_changed", page); g_free( filename ); @@ -1901,17 +1872,17 @@ gnc_main_window_update_one_menu_action (GncMainWindow *window, struct menu_update *data) { GncMainWindowPrivate *priv; - GtkAction* action; + GAction* action; ENTER("window %p, action %s, label %s, visible %d", window, data->action_name, data->label, data->visible); priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); - action = gtk_action_group_get_action(priv->action_group, data->action_name); + action = g_action_map_lookup_action (G_ACTION_MAP(priv->simple_action_group), data->action_name); if (action) - g_object_set(G_OBJECT(action), - "label", data->label, - "visible", data->visible, - (char *)nullptr); +//FIXMEb g_object_set(G_OBJECT(action), +// "label", data->label, +// "visible", data->visible, +// (char *)nullptr); LEAVE(" "); } @@ -1931,7 +1902,7 @@ static void gnc_main_window_update_radio_button (GncMainWindow *window) { GncMainWindowPrivate *priv; - GtkAction *action, *first_action; + GAction *action, *first_action; GSList *action_list; gchar *action_name; gsize index; @@ -1939,7 +1910,10 @@ gnc_main_window_update_radio_button (GncMainWindow *window) ENTER("window %p", window); /* Show the new entry in all windows. */ - index = g_list_index(active_windows, window); + index = g_list_index (active_windows, window); +//FIXMEb +#ifdef skip + if (index >= n_radio_entries) { LEAVE("window %" G_GSIZE_FORMAT ", only %" G_GSIZE_FORMAT " actions", index, n_radio_entries); @@ -1948,25 +1922,26 @@ gnc_main_window_update_radio_button (GncMainWindow *window) priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); action_name = g_strdup_printf("Window%" G_GSIZE_FORMAT "Action", index); - action = gtk_action_group_get_action(priv->action_group, action_name); + action = g_action_map_lookup_action (G_ACTION_MAP(priv->simple_action_group), action_name); /* Block the signal so as not to affect window ordering (top to * bottom) on the screen */ - action_list = gtk_radio_action_get_group(GTK_RADIO_ACTION(action)); - if (action_list) - { - first_action = static_cast(g_slist_last(action_list)->data); - g_signal_handlers_block_by_func(G_OBJECT(first_action), - (gpointer)gnc_main_window_cmd_window_raise, - window); - DEBUG("blocked signal on %p, set %p active, window %p", first_action, - action, window); - gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), TRUE); - g_signal_handlers_unblock_by_func(G_OBJECT(first_action), - (gpointer)gnc_main_window_cmd_window_raise, - window); +//FIXMEb action_list = gtk_radio_action_get_group (GTK_RADIO_ACTION(action)); +// if (action_list) +// { +// first_action = static_cast(g_slist_last(action_list)->data); +// g_signal_handlers_block_by_func(G_OBJECT(first_action), +// (gpointer)gnc_main_window_cmd_window_raise, +// window); +// DEBUG("blocked signal on %p, set %p active, window %p", first_action, +// action, window); +// gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), TRUE); +// g_signal_handlers_unblock_by_func(G_OBJECT(first_action), +// (gpointer)gnc_main_window_cmd_window_raise, +// window); } g_free(action_name); +#endif LEAVE(" "); } @@ -1992,6 +1967,8 @@ gnc_main_window_update_menu_item (GncMainWindow *window) ENTER("window %p", window); index = g_list_index(active_windows, window); +//FIXMEb +#ifdef skip if (index > n_radio_entries) { LEAVE("skip window %" G_GSIZE_FORMAT " (only %" G_GSIZE_FORMAT " entries)", index, n_radio_entries); @@ -2021,7 +1998,7 @@ gnc_main_window_update_menu_item (GncMainWindow *window) &data); g_free(data.action_name); g_free(data.label); - +#endif LEAVE(" "); } #endif /* !MAC_INTEGRATION */ @@ -2051,6 +2028,8 @@ gnc_main_window_update_all_menu_items (void) nullptr); /* Now hide any entries that aren't being used. */ +//FIXMEb +#ifdef skip data.visible = FALSE; for (gsize i = g_list_length(active_windows); i < n_radio_entries; i++) { @@ -2065,6 +2044,7 @@ gnc_main_window_update_all_menu_items (void) g_free(data.action_name); g_free(label); } +#endif LEAVE(" "); } #endif /* !MAC_INTEGRATION */ @@ -2082,7 +2062,7 @@ gnc_main_window_update_all_menu_items (void) */ static void gnc_main_window_update_tab_close_one_page (GncPluginPage *page, - gpointer user_data) + gpointer user_data) { auto new_value{static_cast(user_data)}; ENTER("page %p, visible %d", page, *new_value); @@ -2820,7 +2800,7 @@ gnc_main_window_init (GncMainWindow *window, void *data) gnc_main_window_setup_window (window); gnc_gobject_tracking_remember(G_OBJECT(window), - G_OBJECT_CLASS(klass)); + G_OBJECT_CLASS(klass)); } @@ -3160,7 +3140,7 @@ gnc_main_window_disconnect (GncMainWindow *window, priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); if (priv->current_page == page) { - gnc_plugin_page_unmerge_actions (page, window->ui_merge); +//FIXMEb gnc_plugin_page_unmerge_actions (page, window->ui_merge); gnc_plugin_page_unselected (page); priv->current_page = nullptr; } @@ -3203,7 +3183,7 @@ gnc_main_window_disconnect (GncMainWindow *window, gnc_plugin_page_removed (page); - gtk_ui_manager_ensure_update (window->ui_merge); +//FIXMEb gtk_ui_manager_ensure_update (window->ui_merge); gnc_window_set_status (GNC_WINDOW(window), page, nullptr); } @@ -3494,16 +3474,17 @@ gnc_main_window_manual_merge_actions (GncMainWindow *window, void gnc_main_window_merge_actions (GncMainWindow *window, const gchar *group_name, - GtkActionEntry *actions, + GActionEntry *actions, guint n_actions, - GtkToggleActionEntry *toggle_actions, - guint n_toggle_actions, + GncDisplayItem *display_items, + guint n_display_items, const gchar *filename, gpointer user_data) { GncMainWindowPrivate *priv; GncMainWindowActionData *data; GError *error = nullptr; + const gchar *resource = "/org/gnucash/"; gchar *pathname; g_return_if_fail (GNC_IS_MAIN_WINDOW (window)); @@ -3512,7 +3493,7 @@ gnc_main_window_merge_actions (GncMainWindow *window, g_return_if_fail (n_actions > 0); g_return_if_fail (filename != nullptr); - pathname = gnc_filepath_locate_ui_file (filename); + pathname = g_strconcat (resource, filename, nullptr); if (pathname == nullptr) return; @@ -3522,31 +3503,36 @@ gnc_main_window_merge_actions (GncMainWindow *window, priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); auto entry{static_cast(g_new0 (MergedActionEntry, 1))}; - entry->action_group = gtk_action_group_new (group_name); - gtk_action_group_set_translation_domain (entry->action_group, PROJECT_NAME); - gtk_action_group_add_actions (entry->action_group, actions, n_actions, data); - if (toggle_actions != nullptr && n_toggle_actions > 0) - { - gtk_action_group_add_toggle_actions (entry->action_group, - toggle_actions, n_toggle_actions, - data); - } - gtk_ui_manager_insert_action_group (window->ui_merge, entry->action_group, 0); - entry->merge_id = gtk_ui_manager_add_ui_from_file (window->ui_merge, pathname, &error); - g_assert(entry->merge_id || error); - if (entry->merge_id) - { - gtk_ui_manager_ensure_update (window->ui_merge); + entry->simple_action_group = g_simple_action_group_new (); + + g_action_map_add_action_entries (G_ACTION_MAP(entry->simple_action_group), + actions, + n_actions, + data); + + gtk_widget_insert_action_group (GTK_WIDGET(window), group_name, + G_ACTION_GROUP(entry->simple_action_group)); + + +//FIXMEb this is where I might need to add GtkBuilder???? + + +//FIXMEb gtk_ui_manager_insert_action_group (window->ui_merge, entry->action_group, 0); +// entry->merge_id = gtk_ui_manager_add_ui_from_file (window->ui_merge, pathname, &error); +// g_assert(entry->merge_id || error); +// if (entry->merge_id) +// { +// gtk_ui_manager_ensure_update (window->ui_merge); g_hash_table_insert (priv->merged_actions_table, g_strdup (group_name), entry); - } - else - { - g_critical("Failed to load ui file.\n Filename %s\n Error %s", - filename, error->message); - g_error_free(error); - g_free(entry); - } - g_free(pathname); +// } +// else +// { +// g_critical("Failed to load ui file.\n Filename %s\n Error %s", +// filename, error->message); +// g_error_free(error); +// g_free(entry); +// } +// g_free(pathname); } @@ -3572,9 +3558,9 @@ gnc_main_window_unmerge_actions (GncMainWindow *window, if (entry == nullptr) return; - gtk_ui_manager_remove_action_group (window->ui_merge, entry->action_group); - gtk_ui_manager_remove_ui (window->ui_merge, entry->merge_id); - gtk_ui_manager_ensure_update (window->ui_merge); +//FIXMEb gtk_ui_manager_remove_action_group (window->ui_merge, entry->action_group); +// gtk_ui_manager_remove_ui (window->ui_merge, entry->merge_id); +// gtk_ui_manager_ensure_update (window->ui_merge); g_hash_table_remove (priv->merged_actions_table, group_name); } @@ -3588,35 +3574,35 @@ gnc_main_window_unmerge_actions (GncMainWindow *window, void gnc_main_window_actions_updated (GncMainWindow *window) { - GtkActionGroup *force; + GSimpleActionGroup *simple_action_group; - g_return_if_fail (GNC_IS_MAIN_WINDOW (window)); + g_return_if_fail (GNC_IS_MAIN_WINDOW(window)); /* Unfortunately gtk_ui_manager_ensure_update doesn't work * here. Force a full update by adding and removing an empty * action group. */ - force = gtk_action_group_new("force_update"); - gtk_ui_manager_insert_action_group (window->ui_merge, force, 0); - gtk_ui_manager_ensure_update (window->ui_merge); - gtk_ui_manager_remove_action_group (window->ui_merge, force); - g_object_unref(force); +//FIXMEb force = gtk_action_group_new("force_update"); +// gtk_ui_manager_insert_action_group (window->ui_merge, force, 0); +// gtk_ui_manager_ensure_update (window->ui_merge); +// gtk_ui_manager_remove_action_group (window->ui_merge, force); +// g_object_unref(force); } -GtkAction * +GAction * gnc_main_window_find_action (GncMainWindow *window, const gchar *name) { - GtkAction *action = nullptr; + GAction *action = nullptr; const GList *groups, *tmp; - groups = gtk_ui_manager_get_action_groups(window->ui_merge); - for (tmp = groups; tmp; tmp = g_list_next(tmp)) - { - action = gtk_action_group_get_action(GTK_ACTION_GROUP(tmp->data), name); - if (action) - break; - } +//FIXMEb groups = gtk_ui_manager_get_action_groups(window->ui_merge); +// for (tmp = groups; tmp; tmp = g_list_next(tmp)) +// { +// action = g_action_map_lookup_action (G_ACTION_MAP(tmp->data), name); +// if (action) +// break; +// } return action; } @@ -3625,7 +3611,7 @@ gnc_main_window_find_action (GncMainWindow *window, const gchar *name) * This function can be used to get an group of action to be * manipulated when the front page of a window has changed. */ -GtkActionGroup * +GSimpleActionGroup * gnc_main_window_get_action_group (GncMainWindow *window, const gchar *group_name) { @@ -3642,17 +3628,18 @@ gnc_main_window_get_action_group (GncMainWindow *window, if (entry == nullptr) return nullptr; - return entry->action_group; + return entry->simple_action_group; } + static void gnc_main_window_update_tab_position (gpointer prefs, gchar *pref, gpointer user_data) { GncMainWindow *window; GtkPositionType position = GTK_POS_TOP; GncMainWindowPrivate *priv; - GtkAction *first_action; - GtkAction *position_action; + GAction *first_action; + GAction *position_action; gsize i; g_return_if_fail (GNC_IS_MAIN_WINDOW(user_data)); @@ -3675,18 +3662,19 @@ gnc_main_window_update_tab_position (gpointer prefs, gchar *pref, gpointer user_ priv = GNC_MAIN_WINDOW_GET_PRIVATE (window); gtk_notebook_set_tab_pos (GTK_NOTEBOOK (priv->notebook), position); - +//FIXMEb +#ifdef skip /* Groups of radio actions use the first action for the callback and all * change events so block/unblock signals on the first radio action. */ - first_action = gtk_action_group_get_action (priv->action_group, - tab_pos_radio_entries[0].name); + first_action = g_action_map_lookup_action (G_ACTION_MAP(priv->simple_action_group), + tab_pos_radio_entries[0].name); for (i = n_tab_pos_radio_entries - 1; i > 0; i--) if (tab_pos_radio_entries[i].value == position) break; - position_action = gtk_action_group_get_action (priv->action_group, - tab_pos_radio_entries[i].name); + position_action = g_action_map_lookup_action (G_ACTION_MAP(priv->simple_action_group), + tab_pos_radio_entries[i].name); g_signal_handlers_block_by_func (G_OBJECT (first_action), (gpointer)gnc_main_window_cmd_view_tab_position, @@ -3695,7 +3683,7 @@ gnc_main_window_update_tab_position (gpointer prefs, gchar *pref, gpointer user_ g_signal_handlers_unblock_by_func (G_OBJECT (first_action), (gpointer)gnc_main_window_cmd_view_tab_position, window); - +#endif gnc_main_window_update_tab_width (NULL, (char*)GNC_PREF_TAB_WIDTH, NULL); LEAVE (""); @@ -3710,7 +3698,7 @@ gnc_main_window_update_edit_actions_sensitivity (GncMainWindow *window, gboolean GncMainWindowPrivate *priv; GncPluginPage *page; GtkWidget *widget = gtk_window_get_focus (GTK_WINDOW (window)); - GtkAction *action; + GAction *action; gboolean can_copy = FALSE, can_cut = FALSE, can_paste = FALSE; priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); @@ -3758,30 +3746,30 @@ gnc_main_window_update_edit_actions_sensitivity (GncMainWindow *window, gboolean } action = gnc_main_window_find_action (window, "EditCopyAction"); - gtk_action_set_sensitive (action, can_copy); - gtk_action_set_visible (action, !hide || can_copy); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), can_copy); +//FIXMEb gtk_action_set_visible (action, !hide || can_copy); action = gnc_main_window_find_action (window, "EditCutAction"); - gtk_action_set_sensitive (action, can_cut); - gtk_action_set_visible (action, !hide || can_cut); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), can_cut); +//FIXMEb gtk_action_set_visible (action, !hide || can_cut); action = gnc_main_window_find_action (window, "EditPasteAction"); - gtk_action_set_sensitive (action, can_paste); - gtk_action_set_visible (action, !hide || can_paste); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), can_paste); +//FIXMEb gtk_action_set_visible (action, !hide || can_paste); } static void gnc_main_window_enable_edit_actions_sensitivity (GncMainWindow *window) { - GtkAction *action; + GAction *action; action = gnc_main_window_find_action (window, "EditCopyAction"); - gtk_action_set_sensitive (action, TRUE); - gtk_action_set_visible (action, TRUE); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), TRUE); +//FIXMEb gtk_action_set_visible (action, TRUE); action = gnc_main_window_find_action (window, "EditCutAction"); - gtk_action_set_sensitive (action, TRUE); - gtk_action_set_visible (action, TRUE); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), TRUE); +//FIXMEb gtk_action_set_visible (action, TRUE); action = gnc_main_window_find_action (window, "EditPasteAction"); - gtk_action_set_sensitive (action, TRUE); - gtk_action_set_visible (action, TRUE); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), TRUE); +//FIXMEb gtk_action_set_visible (action, TRUE); } static void @@ -3802,15 +3790,16 @@ static void gnc_main_window_init_menu_updaters (GncMainWindow *window) { GtkWidget *edit_menu_item, *edit_menu; +//FIXMEb - edit_menu_item = gtk_ui_manager_get_widget - (window->ui_merge, "/menubar/Edit"); - edit_menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (edit_menu_item)); +// edit_menu_item = gtk_ui_manager_get_widget +// (window->ui_merge, "/menubar/Edit"); +// edit_menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (edit_menu_item)); - g_signal_connect (edit_menu, "show", - G_CALLBACK (gnc_main_window_edit_menu_show_cb), window); - g_signal_connect (edit_menu, "hide", - G_CALLBACK (gnc_main_window_edit_menu_hide_cb), window); +// g_signal_connect (edit_menu, "show", +// G_CALLBACK (gnc_main_window_edit_menu_show_cb), window); +// g_signal_connect (edit_menu, "hide", +// G_CALLBACK (gnc_main_window_edit_menu_hide_cb), window); } static void @@ -3831,11 +3820,11 @@ gnc_main_window_window_menu (GncMainWindow *window) g_assert(merge_id); #ifndef MAC_INTEGRATION priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); - gtk_action_group_add_radio_actions (priv->action_group, - radio_entries, n_radio_entries, - 0, - G_CALLBACK(gnc_main_window_cmd_window_raise), - window); +//FIXMEb gtk_action_group_add_radio_actions (priv->action_group, +// radio_entries, n_radio_entries, +// 0, +// G_CALLBACK(gnc_main_window_cmd_window_raise), +// window); #endif }; @@ -3856,11 +3845,15 @@ gnc_main_window_setup_window (GncMainWindow *window) { GncMainWindowPrivate *priv; GtkWidget *main_vbox; - guint merge_id; +// guint merge_id; + GtkBuilder *builder; GncPluginManager *manager; GList *plugins; GError *error = nullptr; gchar *filename; + GMenuModel *menu_model; + GtkWidget *menu_bar; + GtkToolbar *tool_bar; ENTER(" "); @@ -3910,65 +3903,101 @@ gnc_main_window_setup_window (GncMainWindow *window) gtk_progress_bar_set_pulse_step(GTK_PROGRESS_BAR(priv->progressbar), 0.01); - window->ui_merge = gtk_ui_manager_new (); + builder = gtk_builder_new (); + + gtk_builder_add_from_resource (builder, "/org/gnucash/ui/gnc-main-window.ui", &error); + + if (error) + { + g_critical ("Failed to load, Error %s", error->message); + g_error_free (error); + return; //FIXMEb this may need changing + } + + menu_model = (GMenuModel *)gtk_builder_get_object (builder, "mainwin-menu"); + menu_bar = gtk_menu_bar_new_from_model (menu_model); + gtk_container_add (GTK_CONTAINER(priv->menu_dock), menu_bar); //FIXMEb this may need changing + gtk_widget_show (menu_bar); + + tool_bar = (GtkToolbar *)gtk_builder_get_object (builder, "mainwin-toolbar"); + g_object_set (tool_bar, "toolbar-style", GTK_TOOLBAR_BOTH, NULL); + gtk_container_add (GTK_CONTAINER(priv->menu_dock), GTK_WIDGET(tool_bar)); //FIXMEb this may need changing + gtk_widget_show (GTK_WIDGET(tool_bar)); + +//FIXMEb window->ui_merge = gtk_ui_manager_new (); /* Create menu and toolbar information */ - priv->action_group = gtk_action_group_new ("MainWindowActions"); - gtk_action_group_set_translation_domain (priv->action_group, PROJECT_NAME); - gtk_action_group_add_actions (priv->action_group, gnc_menu_actions, - gnc_menu_n_actions, window); - gtk_action_group_add_toggle_actions (priv->action_group, - toggle_actions, n_toggle_actions, - window); - gnc_plugin_update_actions(priv->action_group, - initially_insensitive_actions, - "sensitive", FALSE); - gnc_plugin_update_actions(priv->action_group, - always_insensitive_actions, - "sensitive", FALSE); - gnc_plugin_update_actions(priv->action_group, - always_hidden_actions, - "visible", FALSE); - gnc_plugin_set_important_actions (priv->action_group, - gnc_menu_important_actions); - gtk_ui_manager_insert_action_group (window->ui_merge, priv->action_group, 0); +// priv->action_group = gtk_action_group_new ("MainWindowActions"); + priv->simple_action_group = g_simple_action_group_new (); - g_signal_connect (G_OBJECT (window->ui_merge), "add_widget", - G_CALLBACK (gnc_main_window_add_widget), window); +//FIXMEb gtk_action_group_set_translation_domain (priv->action_group, PROJECT_NAME); + + g_action_map_add_action_entries (G_ACTION_MAP(priv->simple_action_group), + gnc_menu_actions, + gnc_menu_n_actions, + window); + + gnc_plugin_update_actionsb (priv->simple_action_group, + initially_insensitive_actions, + "sensitive", FALSE); + gnc_plugin_update_actionsb (priv->simple_action_group, + always_insensitive_actions, + "sensitive", FALSE); + gnc_plugin_update_actionsb (priv->simple_action_group, + always_hidden_actions, + "visible", FALSE); + +//FIXMEb gnc_plugin_set_important_actions (priv->action_group, +// gnc_menu_important_actions); + +// gtk_ui_manager_insert_action_group (window->ui_merge, priv->action_group, 0); + + gtk_widget_insert_action_group (GTK_WIDGET(window), "mainwin", + G_ACTION_GROUP(priv->simple_action_group)); + +//FIXMEb g_signal_connect (G_OBJECT (window->ui_merge), "add_widget", +// G_CALLBACK (gnc_main_window_add_widget), window); /* Use the "connect-proxy" signal for tooltip display in the status bar */ - g_signal_connect (G_OBJECT (window->ui_merge), "connect-proxy", - G_CALLBACK (gnc_window_connect_proxy), priv->statusbar); +//FIXMEb g_signal_connect (G_OBJECT (window->ui_merge), "connect-proxy", +// G_CALLBACK (gnc_window_connect_proxy), priv->statusbar); - filename = gnc_filepath_locate_ui_file("gnc-main-window-ui.xml"); - /* Can't do much without a ui. */ - g_assert (filename); - merge_id = gtk_ui_manager_add_ui_from_file (window->ui_merge, - filename, &error); - g_assert(merge_id || error); - if (merge_id) - { - gtk_action_group_add_radio_actions (priv->action_group, - tab_pos_radio_entries, - n_tab_pos_radio_entries, - 0, - G_CALLBACK(gnc_main_window_cmd_view_tab_position), - window); - gtk_window_add_accel_group (GTK_WINDOW (window), - gtk_ui_manager_get_accel_group(window->ui_merge)); - gtk_ui_manager_ensure_update (window->ui_merge); - } - else - { - g_critical("Failed to load ui file.\n Filename %s\n Error %s", - filename, error->message); - g_error_free(error); - g_assert(merge_id != 0); - } - g_free(filename); - gnc_main_window_window_menu(window); + +// filename = gnc_filepath_locate_ui_file("gnc-main-window.ui"); + + + +// merge_id = gtk_ui_manager_add_ui_from_file (window->ui_merge, +// filename, &error); +// g_assert(merge_id || error); +// if (merge_id) +// { +//FIXMEb gtk_action_group_add_radio_actions (priv->action_group, +// tab_pos_radio_entries, +// n_tab_pos_radio_entries, +// 0, +// G_CALLBACK(gnc_main_window_cmd_view_tab_position), +// window); + +//FIXMEb gtk_window_add_accel_group (GTK_WINDOW (window), +// gtk_ui_manager_get_accel_group(window->ui_merge)); + +// gtk_ui_manager_ensure_update (window->ui_merge); +// } +// else +// { +// g_critical("Failed to load ui file.\n Filename %s\n Error %s", +// filename, error->message); +// g_error_free(error); +// g_assert(merge_id != 0); +// } +// g_free(filename); + + +//FIXMEb gnc_main_window_window_menu (window); may need to use some thing like this + gnc_prefs_register_cb (GNC_PREFS_GROUP_GENERAL, GNC_PREF_TAB_POSITION_TOP, (gpointer)gnc_main_window_update_tab_position, @@ -3993,11 +4022,11 @@ gnc_main_window_setup_window (GncMainWindow *window) /* Now update the "eXtensions" menu */ if (!gnc_prefs_is_extra_enabled()) { - GtkAction* action; +//FIXMEb GtkAction* action; - action = gtk_action_group_get_action(priv->action_group, - "ExtensionsAction"); - gtk_action_set_visible(action, FALSE); +// action = g_action_map_lookup_action (G_ACTION_MAP(priv->action_group), +// "ExtensionsAction"); +// gtk_action_set_visible (action, FALSE); } /* GncPluginManager stuff */ @@ -4124,17 +4153,18 @@ gnc_main_window_add_widget (GtkUIManager *merge, * @return TRUE if the summarybar should be visible. */ static gboolean -gnc_main_window_show_summarybar (GncMainWindow *window, GtkAction *action) +gnc_main_window_show_summarybar (GncMainWindow *window, GAction *action) { GncMainWindowPrivate *priv; priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); if (action == nullptr) - action = gtk_action_group_get_action(priv->action_group, + action = g_action_map_lookup_action (G_ACTION_MAP(priv->simple_action_group), "ViewSummaryAction"); if (action == nullptr) return TRUE; - return gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action)); +//FIXMEb return gtk_toggle_action_get_active (GTK_TOGGLE_ACTION(action)); + return 1; } /** This function is invoked when the GtkNotebook switches pages. It @@ -4165,7 +4195,7 @@ gnc_main_window_switch_page (GtkNotebook *notebook, if (priv->current_page != nullptr) { page = priv->current_page; - gnc_plugin_page_unmerge_actions (page, window->ui_merge); +//FIXMEb gnc_plugin_page_unmerge_actions (page, window->ui_merge); gnc_plugin_page_unselected (page); } @@ -4184,8 +4214,8 @@ gnc_main_window_switch_page (GtkNotebook *notebook, if (page != nullptr) { /* Update the user interface (e.g. menus and toolbars */ - gnc_plugin_page_merge_actions (page, window->ui_merge); - visible = gnc_main_window_show_summarybar(window, nullptr); +//FIXMEb gnc_plugin_page_merge_actions (page, window->ui_merge); + visible = gnc_main_window_show_summarybar (window, nullptr); gnc_plugin_page_show_summarybar (page, visible); /* Allow page specific actions */ @@ -4197,10 +4227,10 @@ gnc_main_window_switch_page (GtkNotebook *notebook, priv->usage_order = g_list_prepend (priv->usage_order, page); } - gnc_plugin_update_actions(priv->action_group, - multiple_page_actions, - "sensitive", - g_list_length(priv->installed_pages) > 1); + gnc_plugin_update_actionsb (priv->simple_action_group, + multiple_page_actions, + "sensitive", + g_list_length(priv->installed_pages) > 1); gnc_main_window_update_title(window); #ifndef MAC_INTEGRATION @@ -4273,9 +4303,11 @@ gnc_main_window_plugin_removed (GncPlugin *manager, /* Command callbacks */ static void -gnc_main_window_cmd_page_setup (GtkAction *action, - GncMainWindow *window) +gnc_main_window_cmd_page_setup (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindow *window = (GncMainWindow*)user_data; GtkWindow *gtk_window; g_return_if_fail(GNC_IS_MAIN_WINDOW(window)); @@ -4422,14 +4454,20 @@ gnc_book_options_dialog_cb (gboolean modal, gchar *title, GtkWindow* parent) } static void -gnc_main_window_cmd_file_properties (GtkAction *action, GncMainWindow *window) +gnc_main_window_cmd_file_properties (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindow *window = (GncMainWindow*)user_data; gnc_book_options_dialog_cb (FALSE, nullptr, GTK_WINDOW (window)); } static void -gnc_main_window_cmd_file_close (GtkAction *action, GncMainWindow *window) +gnc_main_window_cmd_file_close (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindow *window = (GncMainWindow*)user_data; GncMainWindowPrivate *priv; GncPluginPage *page; @@ -4441,8 +4479,11 @@ gnc_main_window_cmd_file_close (GtkAction *action, GncMainWindow *window) } static void -gnc_main_window_cmd_file_quit (GtkAction *action, GncMainWindow *window) +gnc_main_window_cmd_file_quit (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindow *window = (GncMainWindow*)user_data; if (!gnc_main_window_all_finish_pending()) return; @@ -4450,8 +4491,11 @@ gnc_main_window_cmd_file_quit (GtkAction *action, GncMainWindow *window) } static void -gnc_main_window_cmd_edit_cut (GtkAction *action, GncMainWindow *window) +gnc_main_window_cmd_edit_cut (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindow *window = (GncMainWindow*)user_data; GtkWidget *widget = gtk_window_get_focus (GTK_WINDOW(window)); if (GTK_IS_EDITABLE(widget)) @@ -4471,8 +4515,11 @@ gnc_main_window_cmd_edit_cut (GtkAction *action, GncMainWindow *window) } static void -gnc_main_window_cmd_edit_copy (GtkAction *action, GncMainWindow *window) +gnc_main_window_cmd_edit_copy (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindow *window = (GncMainWindow*)user_data; GtkWidget *widget = gtk_window_get_focus (GTK_WINDOW(window)); if (GTK_IS_EDITABLE(widget)) @@ -4490,8 +4537,11 @@ gnc_main_window_cmd_edit_copy (GtkAction *action, GncMainWindow *window) } static void -gnc_main_window_cmd_edit_paste (GtkAction *action, GncMainWindow *window) +gnc_main_window_cmd_edit_paste (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindow *window = (GncMainWindow*)user_data; GtkWidget *widget = gtk_window_get_focus (GTK_WINDOW(window)); if (GTK_IS_EDITABLE(widget)) @@ -4513,25 +4563,37 @@ gnc_main_window_cmd_edit_paste (GtkAction *action, GncMainWindow *window) } static void -gnc_main_window_cmd_edit_preferences (GtkAction *action, GncMainWindow *window) +gnc_main_window_cmd_edit_preferences (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindow *window = (GncMainWindow*)user_data; gnc_preferences_dialog (GTK_WINDOW(window)); } static void -gnc_main_window_cmd_view_refresh (GtkAction *action, GncMainWindow *window) +gnc_main_window_cmd_view_refresh (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindow *window = (GncMainWindow*)user_data; } static void -gnc_main_window_cmd_actions_reset_warnings (GtkAction *action, GncMainWindow *window) +gnc_main_window_cmd_actions_reset_warnings (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindow *window = (GncMainWindow*)user_data; gnc_reset_warnings_dialog(GTK_WINDOW(window)); } static void -gnc_main_window_cmd_actions_rename_page (GtkAction *action, GncMainWindow *window) +gnc_main_window_cmd_actions_rename_page (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindow *window = (GncMainWindow*)user_data; GncMainWindowPrivate *priv; GncPluginPage *page; GtkWidget *label, *entry; @@ -4560,12 +4622,16 @@ gnc_main_window_cmd_actions_rename_page (GtkAction *action, GncMainWindow *windo } static void -gnc_main_window_cmd_view_toolbar (GtkAction *action, GncMainWindow *window) +gnc_main_window_cmd_view_toolbar (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindow *window = (GncMainWindow*)user_data; GncMainWindowPrivate *priv; priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); - if (gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action))) +//FIXMEb if (gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(simple))) +#ifdef skip { gtk_widget_show (priv->toolbar); } @@ -4573,30 +4639,39 @@ gnc_main_window_cmd_view_toolbar (GtkAction *action, GncMainWindow *window) { gtk_widget_hide (priv->toolbar); } +#endif } static void -gnc_main_window_cmd_view_summary (GtkAction *action, GncMainWindow *window) +gnc_main_window_cmd_view_summary (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindow *window = (GncMainWindow*)user_data; GncMainWindowPrivate *priv; GList *item; gboolean visible; priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); - visible = gnc_main_window_show_summarybar(window, action); +//FIXMEb visible = gnc_main_window_show_summarybar(window, simple); for (item = priv->installed_pages; item; item = g_list_next(item)) { - gnc_plugin_page_show_summarybar(static_cast(item->data), - visible); +// gnc_plugin_page_show_summarybar(static_cast(item->data), +// visible); } } static void -gnc_main_window_cmd_view_statusbar (GtkAction *action, GncMainWindow *window) +gnc_main_window_cmd_view_statusbar (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindow *window = (GncMainWindow*)user_data; GncMainWindowPrivate *priv; priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); +//FIXMEb +#ifdef skip if (gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action))) { gtk_widget_show (priv->statusbar); @@ -4605,11 +4680,15 @@ gnc_main_window_cmd_view_statusbar (GtkAction *action, GncMainWindow *window) { gtk_widget_hide (priv->statusbar); } +#endif } static void -gnc_main_window_cmd_window_new (GtkAction *action, GncMainWindow *window) +gnc_main_window_cmd_window_new (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncMainWindow *window = (GncMainWindow*)user_data; GncMainWindow *new_window; /* Create the new window */ @@ -4620,15 +4699,18 @@ gnc_main_window_cmd_window_new (GtkAction *action, GncMainWindow *window) } static void -gnc_main_window_cmd_window_move_page (GtkAction *action, GncMainWindow *window) +gnc_main_window_cmd_window_move_page (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncMainWindow *window = (GncMainWindow*)user_data; GncMainWindowPrivate *priv; GncMainWindow *new_window; GncPluginPage *page; GtkNotebook *notebook; GtkWidget *tab_widget, *menu_widget; - ENTER("action %p,window %p", action, window); + ENTER("action %p, window %p", simple, window); /* Setup */ priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); @@ -4681,10 +4763,14 @@ gnc_main_window_cmd_window_move_page (GtkAction *action, GncMainWindow *window) } static void -gnc_main_window_cmd_view_tab_position (GtkAction *action, - GtkRadioAction *current, - GncMainWindow *window) +gnc_main_window_cmd_view_tab_position (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindow *window = (GncMainWindow*)user_data; + +//FIXMEb +#ifdef skip auto value{static_cast(gtk_radio_action_get_current_value(current))}; if (value != GTK_POS_TOP && gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_TAB_POSITION_TOP)) @@ -4717,41 +4803,48 @@ gnc_main_window_cmd_view_tab_position (GtkAction *action, gnc_prefs_set_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_TAB_POSITION_RIGHT, TRUE); break; } +#endif } #ifndef MAC_INTEGRATION static void -gnc_main_window_cmd_window_raise (GtkAction *action, - GtkRadioAction *current, - GncMainWindow *old_window) +gnc_main_window_cmd_window_raise (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindow *window = (GncMainWindow*)user_data; GncMainWindow *new_window; gint value; - g_return_if_fail(GTK_IS_ACTION(action)); - g_return_if_fail(GTK_IS_RADIO_ACTION(current)); - g_return_if_fail(GNC_IS_MAIN_WINDOW(old_window)); + g_return_if_fail(GTK_IS_ACTION(simple)); + g_return_if_fail(GNC_IS_MAIN_WINDOW(window)); - ENTER("action %p, current %p, window %p", action, current, old_window); - value = gtk_radio_action_get_current_value(current); - new_window = static_cast(g_list_nth_data(active_windows, value)); - gtk_window_present(GTK_WINDOW(new_window)); + ENTER("action %p, window %p", simple, window); +//FIXMEb value = gtk_radio_action_get_current_value(current); +// new_window = static_cast(g_list_nth_data(active_windows, value)); +// gtk_window_present(GTK_WINDOW(new_window)); /* revert the change in the radio group * impossible while handling "changed" (G_SIGNAL_NO_RECURSE) */ - g_idle_add((GSourceFunc)gnc_main_window_update_radio_button, old_window); +// g_idle_add((GSourceFunc)gnc_main_window_update_radio_button, window); LEAVE(" "); } #endif /* !MAC_INTEGRATION */ static void -gnc_main_window_cmd_help_tutorial (GtkAction *action, GncMainWindow *window) +gnc_main_window_cmd_help_tutorial (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncMainWindow *window = (GncMainWindow*)user_data; gnc_gnome_help (GTK_WINDOW(window), HF_GUIDE, NULL); } static void -gnc_main_window_cmd_help_contents (GtkAction *action, GncMainWindow *window) +gnc_main_window_cmd_help_contents (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncMainWindow *window = (GncMainWindow*)user_data; gnc_gnome_help (GTK_WINDOW(window), HF_HELP, NULL); } @@ -4888,8 +4981,11 @@ add_about_paths (GtkDialog *dialog) * @param window The main window whose menu item was activated. */ static void -gnc_main_window_cmd_help_about (GtkAction *action, GncMainWindow *window) +gnc_main_window_cmd_help_about (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) { + GncMainWindow *window = (GncMainWindow*)user_data; /* Translators: %s will be replaced with the current year */ gchar *copyright = g_strdup_printf(_("Copyright © 1997-%s The GnuCash contributors."), GNC_VCS_REV_YEAR); @@ -5068,7 +5164,8 @@ gnc_main_window_get_progressbar (GncWindow *window_in) static void gnc_main_window_all_ui_set_sensitive (GncWindow *unused, gboolean sensitive) { - +//FIXMEb +#ifdef skip for (auto winp = active_windows; winp; winp = g_list_next(winp)) { auto window{static_cast(winp->data)}; @@ -5088,6 +5185,7 @@ gnc_main_window_all_ui_set_sensitive (GncWindow *unused, gboolean sensitive) gtk_widget_set_sensitive (close_button, sensitive); } } +#endif } @@ -5133,27 +5231,30 @@ gnc_main_window_set_progressbar_window (GncMainWindow *window) static void do_popup_menu(GncPluginPage *page, GdkEventButton *event) { - GtkUIManager *ui_merge; +// GtkUIManager *ui_merge; + GtkBuilder *builder; GtkWidget *menu; g_return_if_fail(GNC_IS_PLUGIN_PAGE(page)); ENTER("page %p, event %p", page, event); - ui_merge = gnc_plugin_page_get_ui_merge(page); - if (ui_merge == nullptr) +//FIXME builder = gnc_plugin_page_get_builder (page); +//I think this should be using builder here instaed of UIManager +#ifdef skip + if (builder == nullptr) { - LEAVE("no ui merge"); + LEAVE("no builder"); return; } - menu = gtk_ui_manager_get_widget(ui_merge, "/MainPopup"); +// menu = gtk_ui_manager_get_widget(ui_merge, "/MainPopup"); if (!menu) { LEAVE("no menu"); return; } gtk_menu_popup_at_pointer (GTK_MENU(menu), (GdkEvent *) event); - +#endif LEAVE(" "); } @@ -5208,20 +5309,20 @@ gnc_main_window_button_press_cb (GtkWidget *whatever, void gnc_main_window_all_action_set_sensitive (const gchar *action_name, - gboolean sensitive) + gboolean sensitive) { for (auto tmp = active_windows; tmp; tmp = g_list_next(tmp)) { auto action{gnc_main_window_find_action (static_cast(tmp->data), action_name)}; - gtk_action_set_sensitive (action, sensitive); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), sensitive); } } -GtkUIManager *gnc_main_window_get_uimanager (GncMainWindow *window) -{ - g_assert(window); - return window->ui_merge; -} +//GtkUIManager *gnc_main_window_get_uimanager (GncMainWindow *window) +//{ +// g_assert(window); +// return window->ui_merge; +//} /** @} */ /** @} */ diff --git a/gnucash/gnome-utils/gnc-main-window.h b/gnucash/gnome-utils/gnc-main-window.h index 6116a9c755..e4300f53d9 100644 --- a/gnucash/gnome-utils/gnc-main-window.h +++ b/gnucash/gnome-utils/gnc-main-window.h @@ -55,6 +55,15 @@ extern "C" /* typedefs & structures */ +typedef struct +{ + const gchar *action_name; + const gchar *icon_name; + const gchar *label; + const gchar *accelerator; + const gchar *tooltip; +} GncDisplayItem; + /** The instance data structure for a main window object. */ typedef struct GncMainWindow { @@ -241,10 +250,9 @@ void gnc_main_window_manual_merge_actions (GncMainWindow *window, * * @param n_entries The number of actions in the array. * - * @param toggle_entries A pointer to an array of GtkToggleActionEntry. - * These are the toggle actions that will be added to the user interface. + * @param display_items A pointer to an array of GncDisplayItem. * - * @param n_toggle_entries The number of toggle actions in the array. + * @param n_display_items The number of display items in the array. * * @param filename The filename containing the user interface * definition that goes with this set of actions. @@ -254,10 +262,10 @@ void gnc_main_window_manual_merge_actions (GncMainWindow *window, */ void gnc_main_window_merge_actions (GncMainWindow *window, const gchar *group_name, - GtkActionEntry *entries, + GActionEntry *entries, guint n_entries, - GtkToggleActionEntry *toggle_entries, - guint n_toggle_entries, + GncDisplayItem *display_items, + guint n_display_items, const gchar *filename, gpointer user_data); @@ -303,8 +311,8 @@ void gnc_main_window_actions_updated (GncMainWindow *window); * specified name. If the name cannot be found, then NULL will be * returned. */ -GtkActionGroup *gnc_main_window_get_action_group (GncMainWindow *window, - const gchar *group_name); +GSimpleActionGroup *gnc_main_window_get_action_group (GncMainWindow *window, + const gchar *group_name); /** Set the window where all progressbar updates should occur. This @@ -424,7 +432,7 @@ void gnc_main_window_all_action_set_sensitive (const gchar *action_name, gboolea * specified name. If the name cannot be found, then NULL will be * returned. */ -GtkAction *gnc_main_window_find_action (GncMainWindow *window, const gchar *name); +GAction *gnc_main_window_find_action (GncMainWindow *window, const gchar *name); /** * Shows all main windows. diff --git a/gnucash/gnome-utils/gnc-plugin-file-history.c b/gnucash/gnome-utils/gnc-plugin-file-history.c index 160d0135e1..e02ba30a9c 100644 --- a/gnucash/gnome-utils/gnc-plugin-file-history.c +++ b/gnucash/gnome-utils/gnc-plugin-file-history.c @@ -407,19 +407,18 @@ gnc_history_update_action (GncMainWindow *window, gint index, const gchar *filename) { - GtkActionGroup *action_group; - GtkAction *action; + GSimpleActionGroup *simple_action_group; + GAction *action; gchar *action_name, *label_name, *tooltip, *old_filename; gint limit; ENTER("window %p, index %d, filename %s", window, index, filename ? filename : "(null)"); /* Get the action group */ - action_group = - gnc_main_window_get_action_group(window, PLUGIN_ACTIONS_NAME); + simple_action_group = gnc_main_window_get_action_group (window, PLUGIN_ACTIONS_NAME); - action_name = g_strdup_printf("RecentFile%dAction", index); - action = gtk_action_group_get_action (action_group, action_name); +//FIXMEb action_name = g_strdup_printf ("RecentFile%dAction", index); +// action = g_action_map_lookup_action (G_ACTION_MAP(simple_action_group), action_name); limit = gnc_prefs_get_int (GNC_PREFS_GROUP_HISTORY, GNC_PREF_HISTORY_MAXFILES); @@ -427,26 +426,26 @@ gnc_history_update_action (GncMainWindow *window, if (filename && (strlen(filename) > 0) && (index < limit)) { /* set the menu label (w/accelerator) */ - label_name = gnc_history_generate_label(index, filename); - tooltip = gnc_history_generate_tooltip(index, filename); - g_object_set(G_OBJECT(action), "label", label_name, - "tooltip", tooltip, - "visible", TRUE, - NULL); - g_free(label_name); - g_free(tooltip); + label_name = gnc_history_generate_label (index, filename); + tooltip = gnc_history_generate_tooltip (index, filename); +//FIXMEb g_object_set(G_OBJECT(action), "label", label_name, +// "tooltip", tooltip, +// "visible", TRUE, +// NULL); +// g_free(label_name); +// g_free(tooltip); /* set the filename for the callback function */ - old_filename = g_object_get_data(G_OBJECT(action), FILENAME_STRING); - if (old_filename) - g_free(old_filename); - g_object_set_data(G_OBJECT(action), FILENAME_STRING, g_strdup(filename)); +//FIXMEb old_filename = g_object_get_data(G_OBJECT(action), FILENAME_STRING); +// if (old_filename) +// g_free(old_filename); +//FIXMEb g_object_set_data(G_OBJECT(action), FILENAME_STRING, g_strdup(filename)); } else { - gtk_action_set_visible(action, FALSE); +//FIXMEb gtk_action_set_visible(action, FALSE); } - g_free(action_name); +// g_free (action_name); LEAVE(""); } diff --git a/gnucash/gnome-utils/gnc-plugin-menu-additions.c b/gnucash/gnome-utils/gnc-plugin-menu-additions.c index 7573484482..448bc71f23 100644 --- a/gnucash/gnome-utils/gnc-plugin-menu-additions.c +++ b/gnucash/gnome-utils/gnc-plugin-menu-additions.c @@ -174,14 +174,14 @@ gnc_main_window_to_scm (GncMainWindow *window) * that had a menu selected. */ static void -gnc_plugin_menu_additions_action_cb (GtkAction *action, +gnc_plugin_menu_additions_action_cb (GAction *action, GncMainWindowActionData *data) { - g_return_if_fail(GTK_IS_ACTION(action)); - g_return_if_fail(data != NULL); + g_return_if_fail (G_IS_SIMPLE_ACTION(action)); + g_return_if_fail (data != NULL); - gnc_extension_invoke_cb(data->data, gnc_main_window_to_scm(data->window)); + gnc_extension_invoke_cb (data->data, gnc_main_window_to_scm (data->window)); } @@ -410,8 +410,8 @@ gnc_menu_additions_menu_setup_one (ExtensionInfo *ext_info, */ static void gnc_plugin_menu_additions_add_to_window (GncPlugin *plugin, - GncMainWindow *window, - GQuark type) + GncMainWindow *window, + GQuark type) { GncPluginMenuAdditionsPerWindow per_window; static GOnce accel_table_init = G_ONCE_INIT; @@ -420,6 +420,8 @@ gnc_plugin_menu_additions_add_to_window (GncPlugin *plugin, ENTER(" "); +//FIXMEb +#ifdef skip per_window.window = window; per_window.ui_manager = window->ui_merge; per_window.group = gtk_action_group_new ("MenuAdditions" ); @@ -446,6 +448,7 @@ gnc_plugin_menu_additions_add_to_window (GncPlugin *plugin, per_window.group, per_window.merge_id); g_slist_free(menu_list); +#endif LEAVE(" "); } @@ -463,19 +466,19 @@ gnc_plugin_menu_additions_add_to_window (GncPlugin *plugin, */ static void gnc_plugin_menu_additions_remove_from_window (GncPlugin *plugin, - GncMainWindow *window, - GQuark type) + GncMainWindow *window, + GQuark type) { - GtkActionGroup *group; + GSimpleActionGroup *simple_action_group; ENTER(" "); /* Have to remove our actions manually. Its only automatic if the * actions name is installed into the plugin class. */ - group = gnc_main_window_get_action_group(window, PLUGIN_ACTIONS_NAME); + simple_action_group = gnc_main_window_get_action_group (window, PLUGIN_ACTIONS_NAME); - if (group && !window->just_plugin_prefs) - gtk_ui_manager_remove_action_group(window->ui_merge, group); +//FIXMEb if (group && !window->just_plugin_prefs) +// gtk_ui_manager_remove_action_group(window->ui_merge, simple_action_group); /* Note: This code does not clean up the per-callback data structures * that are created by the gnc_menu_additions_menu_setup_one() diff --git a/gnucash/gnome-utils/gnc-plugin-page.c b/gnucash/gnome-utils/gnc-plugin-page.c index 1c7617cbf2..dc3eebb592 100644 --- a/gnucash/gnome-utils/gnc-plugin-page.c +++ b/gnucash/gnome-utils/gnc-plugin-page.c @@ -97,7 +97,7 @@ typedef struct _GncPluginPagePrivate char *ui_description; GtkBuilder *builder; //FIXMEb added - GSimpleActionGroup *simple_action_group; //FIXMEb added + GSimpleActionGroup *simple_action_group; //FIXMEb added GList *books; @@ -295,7 +295,7 @@ gnc_plugin_page_unmerge_actions (GncPluginPage *page, } -GtkAction * +GAction * gnc_plugin_page_get_action (GncPluginPage *page, const gchar *name) { GncPluginPagePrivate *priv; @@ -304,9 +304,9 @@ gnc_plugin_page_get_action (GncPluginPage *page, const gchar *name) g_return_val_if_fail (name != NULL, NULL); priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page); - if (!priv->action_group) + if (!priv->simple_action_group) return NULL; - return gtk_action_group_get_action (priv->action_group, name); + return g_action_map_lookup_action (G_ACTION_MAP(priv->simple_action_group), name); } @@ -1092,16 +1092,16 @@ gnc_plugin_page_set_ui_description (GncPluginPage *page, } -/* Retrieve the GtkUIManager object associated with this page. */ -GtkUIManager * -gnc_plugin_page_get_ui_merge (GncPluginPage *page) +/* Retrieve the GtkBuilder object associated with this page. */ +GtkBuilder * +gnc_plugin_page_get_builder (GncPluginPage *page) { GncPluginPagePrivate *priv; g_return_val_if_fail (GNC_IS_PLUGIN_PAGE(page), NULL); priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page); - return priv->ui_merge; + return priv->builder; } @@ -1145,12 +1145,12 @@ GSimpleActionGroup * gnc_plugin_page_create_action_groupb (GncPluginPage *page, const gchar *group_name) { GncPluginPagePrivate *priv; - GSimpleActionGroup *group; + GSimpleActionGroup *simple_action_group; priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page); - group = g_simple_action_group_new (); - priv->simple_action_group = group; - return group; + simple_action_group = g_simple_action_group_new (); + priv->simple_action_group = simple_action_group; + return simple_action_group; } gboolean diff --git a/gnucash/gnome-utils/gnc-plugin-page.h b/gnucash/gnome-utils/gnc-plugin-page.h index 833f37947f..959e30e985 100644 --- a/gnucash/gnome-utils/gnc-plugin-page.h +++ b/gnucash/gnome-utils/gnc-plugin-page.h @@ -525,12 +525,12 @@ void gnc_plugin_page_set_ui_description (GncPluginPage *page, const char *ui_filename); -/** Retrieve the GtkUIManager object associated with this page. +/** Retrieve the GtkBuilder object associated with this page. * * @param page The page whose UI information should be retrieved. * - * @return A pointer to the GtkUIManager object for this page. */ -GtkUIManager *gnc_plugin_page_get_ui_merge (GncPluginPage *page); + * @return A pointer to the GtkBuilder object for this page. */ +GtkBuilder *gnc_plugin_page_get_builder (GncPluginPage *page); /** Retrieve the GtkActionGroup object associated with this page. @@ -568,7 +568,7 @@ GSimpleActionGroup * gnc_plugin_page_create_action_groupb (GncPluginPage *page, * * @return A pointer to the retuested GtkAction object or NULL. */ -GtkAction *gnc_plugin_page_get_action (GncPluginPage *page, const gchar *name); +GAction *gnc_plugin_page_get_action (GncPluginPage *page, const gchar *name); /* Signals */ void gnc_plugin_page_inserted (GncPluginPage *plugin_page); diff --git a/gnucash/gnome-utils/gnc-plugin.c b/gnucash/gnome-utils/gnc-plugin.c index a863f2534a..50bd3bb140 100644 --- a/gnucash/gnome-utils/gnc-plugin.c +++ b/gnucash/gnome-utils/gnc-plugin.c @@ -130,7 +130,7 @@ gnc_plugin_add_to_window (GncPlugin *plugin, GQuark type) { GncPluginClass *klass; - GtkActionGroup *action_group; + GSimpleActionGroup *simple_action_group; g_return_if_fail (GNC_IS_PLUGIN (plugin)); klass = GNC_PLUGIN_GET_CLASS (plugin); @@ -143,19 +143,18 @@ gnc_plugin_add_to_window (GncPlugin *plugin, if (klass->actions_name) { DEBUG ("%s: %d actions to merge with gui from %s", - klass->actions_name, (klass->n_actions + klass->n_toggle_actions), klass->ui_filename); + klass->actions_name, klass->n_actions, klass->ui_filename); gnc_main_window_merge_actions (window, klass->actions_name, - klass->actions, klass->n_actions, - klass->toggle_actions, klass->n_toggle_actions, + klass->actionsb, klass->n_actionsb, + klass->display_items, klass->n_display_items, klass->ui_filename, plugin); - if (klass->important_actions) { - action_group = - gnc_main_window_get_action_group(window, klass->actions_name); - gnc_plugin_set_important_actions(action_group, - klass->important_actions); + simple_action_group = + gnc_main_window_get_action_group (window, klass->actions_name); +//FIXMEb gnc_plugin_set_important_actions (simple_action_group, +// klass->important_actions); } } @@ -231,18 +230,18 @@ gnc_plugin_get_name (GncPlugin *plugin) * * See gnc-plugin.h for documentation on the function arguments. */ void -gnc_plugin_init_short_names (GtkActionGroup *action_group, +gnc_plugin_init_short_names (GSimpleActionGroup *simple_action_group, action_toolbar_labels *toolbar_labels) { - GtkAction *action; + GAction *action; gint i; for (i = 0; toolbar_labels[i].action_name; i++) { /* Add a couple of short labels for the toolbar */ - action = gtk_action_group_get_action (action_group, - toolbar_labels[i].action_name); - gtk_action_set_short_label (action, _(toolbar_labels[i].label)); +//FIXMEb action = g_action_map_lookup_action (G_ACTION_MAP(simple_action_group), +// toolbar_labels[i].action_name); +// gtk_action_set_short_label (action, _(toolbar_labels[i].label)); } } @@ -253,16 +252,16 @@ gnc_plugin_init_short_names (GtkActionGroup *action_group, * * See gnc-plugin.h for documentation on the function arguments. */ void -gnc_plugin_set_important_actions (GtkActionGroup *action_group, +gnc_plugin_set_important_actions (GSimpleActionGroup *simple_action_group, const gchar **name) { - GtkAction *action; + GAction *action; gint i; for (i = 0; name[i]; i++) { - action = gtk_action_group_get_action (action_group, name[i]); - g_object_set (G_OBJECT(action), "is_important", TRUE, NULL); +//FIXMEb action = g_action_map_lookup_action (G_ACTION_MAP(simple_action_group), name[i]); +// g_object_set (G_OBJECT(action), "is_important", TRUE, NULL); } /* If this trips, you've got too many "important" actions. That @@ -312,7 +311,7 @@ gnc_plugin_update_actionsb (GSimpleActionGroup *simple_action_group, for (i = 0; action_names[i]; i++) { - action = g_simple_action_group_lookup (simple_action_group, action_names[i]); + action = g_action_map_lookup_action (G_ACTION_MAP(simple_action_group), action_names[i]); if (action) { //FIXMEb g_object_set (G_OBJECT(action), property_name, value, NULL); diff --git a/gnucash/gnome-utils/gnc-plugin.h b/gnucash/gnome-utils/gnc-plugin.h index b38c4d920f..67662abcad 100644 --- a/gnucash/gnome-utils/gnc-plugin.h +++ b/gnucash/gnome-utils/gnc-plugin.h @@ -96,15 +96,6 @@ G_BEGIN_DECLS /* typedefs & structures */ -typedef struct -{ - const gchar *action_name; - const gchar *stock_id; - const gchar *label; - const gchar *accelerator; - const gchar *tooltip; -} GncDisplayItem; - /** The instance data structure for a menu-only plugin. */ typedef struct { @@ -267,7 +258,7 @@ typedef struct * @param toolbar_labels A pointer to a NULL terminated array of data * action_toolbar_labels items. */ -void gnc_plugin_init_short_names (GtkActionGroup *action_group, +void gnc_plugin_init_short_names (GSimpleActionGroup *simple_action_group, action_toolbar_labels *toolbar_labels); @@ -282,7 +273,7 @@ void gnc_plugin_init_short_names (GtkActionGroup *action_group, * @param name A list of actions names to be marked important. This * list must be NULL terminated. */ -void gnc_plugin_set_important_actions (GtkActionGroup *action_group, +void gnc_plugin_set_important_actions (GSimpleActionGroup *simple_action_group, const gchar **names); diff --git a/gnucash/gnome/dialog-invoice.c b/gnucash/gnome/dialog-invoice.c index 8307cec9f3..facb9fc9c3 100644 --- a/gnucash/gnome/dialog-invoice.c +++ b/gnucash/gnome/dialog-invoice.c @@ -2727,11 +2727,11 @@ gnc_invoice_update_doclink_for_window (GncInvoice *invoice, const gchar *uri) if (g_strcmp0 (uri, "") == 0) // deleted uri { - GtkAction *uri_action; + GAction *uri_action; // update the menu actions uri_action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE(iw->page), "BusinessLinkOpenAction"); - gtk_action_set_sensitive (uri_action, FALSE); + g_simple_action_set_enabled (G_SIMPLE_ACTION(uri_action), FALSE); gtk_widget_hide (doclink_button); } diff --git a/gnucash/gnome/gnc-plugin-basic-commands.c b/gnucash/gnome/gnc-plugin-basic-commands.c index b2b8d7f7d6..47697990da 100644 --- a/gnucash/gnome/gnc-plugin-basic-commands.c +++ b/gnucash/gnome/gnc-plugin-basic-commands.c @@ -321,22 +321,24 @@ gnc_plugin_basic_commands_add_to_window (GncPlugin *plugin, GncMainWindow *window, GQuark type) { - GtkActionGroup *action_group = - gnc_main_window_get_action_group(window, PLUGIN_ACTIONS_NAME); - gnc_plugin_update_actions(action_group, - gnc_plugin_initially_insensitive_actions, - "sensitive", FALSE); - g_signal_connect(window, "page_changed", - G_CALLBACK(gnc_plugin_basic_commands_main_window_page_changed), - plugin); + GSimpleActionGroup *simple_action_group = + gnc_main_window_get_action_group (window, PLUGIN_ACTIONS_NAME); + + gnc_plugin_update_actionsb (simple_action_group, + gnc_plugin_initially_insensitive_actions, + "sensitive", FALSE); + + g_signal_connect (window, "page_changed", + G_CALLBACK(gnc_plugin_basic_commands_main_window_page_changed), + plugin); } /** Update the actions sensitivity */ static void update_inactive_actions (GncPluginPage *plugin_page) { - GncMainWindow *window; - GtkActionGroup *action_group; + GncMainWindow *window; + GSimpleActionGroup *simple_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()); @@ -348,13 +350,13 @@ static void update_inactive_actions (GncPluginPage *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)); + simple_action_group = gnc_main_window_get_action_group(window, PLUGIN_ACTIONS_NAME); + g_return_if_fail (G_IS_SIMPLE_ACTION_GROUP(simple_action_group)); /* Set the action's sensitivity */ - gnc_plugin_update_actions (action_group, readwrite_only_active_actions, + gnc_plugin_update_actionsb (simple_action_group, readwrite_only_active_actions, "sensitive", is_readwrite); - gnc_plugin_update_actions (action_group, dirty_only_active_actions, + gnc_plugin_update_actionsb (simple_action_group, dirty_only_active_actions, "sensitive", is_dirty); } diff --git a/gnucash/gnome/gnc-plugin-budget.c b/gnucash/gnome/gnc-plugin-budget.c index b4b9158838..9df979f37d 100644 --- a/gnucash/gnome/gnc-plugin-budget.c +++ b/gnucash/gnome/gnc-plugin-budget.c @@ -125,12 +125,12 @@ gnc_plugin_budget_new (void) static void page_changed (GncMainWindow *window, GncPluginPage *page, gpointer user_data) { - GtkActionGroup *action_group = + GSimpleActionGroup *simple_action_group = gnc_main_window_get_action_group (window, PLUGIN_ACTIONS_NAME); -//FIXMEb + if (qof_book_is_readonly (gnc_get_current_book())) - gnc_plugin_update_actions (action_group, plugin_writeable_actions, - "sensitive", FALSE); + gnc_plugin_update_actionsb (simple_action_group, plugin_writeable_actions, + "sensitive", FALSE); } static void diff --git a/gnucash/gnome/gnc-plugin-business.c b/gnucash/gnome/gnc-plugin-business.c index 6bf887be7c..f69869f3c4 100644 --- a/gnucash/gnome/gnc-plugin-business.c +++ b/gnucash/gnome/gnc-plugin-business.c @@ -940,8 +940,8 @@ static const gchar *register_bus_txn_actions[] = static void gnc_plugin_business_update_menus (GncPluginPage *plugin_page) { - GncMainWindow *window; - GtkActionGroup *action_group; + GncMainWindow *window; + GSimpleActionGroup *simple_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 @@ -955,8 +955,8 @@ gnc_plugin_business_update_menus (GncPluginPage *plugin_page) 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)); + simple_action_group = gnc_main_window_get_action_group (window, PLUGIN_ACTIONS_NAME); + g_return_if_fail (G_IS_SIMPLE_ACTION_GROUP(simple_action_group)); if (is_txn_register) { @@ -966,13 +966,13 @@ gnc_plugin_business_update_menus (GncPluginPage *plugin_page) 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, + gnc_plugin_update_actionsb (simple_action_group, register_txn_actions, "sensitive", is_txn_register && !is_bus_txn && !is_bus_doc); - gnc_plugin_update_actions (action_group, register_txn_actions, + gnc_plugin_update_actionsb (simple_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, + gnc_plugin_update_actionsb (simple_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, + gnc_plugin_update_actionsb (simple_action_group, register_bus_txn_actions, "visible", is_txn_register && is_bus_txn && !is_bus_doc); } @@ -1090,8 +1090,8 @@ static const gchar* readonly_inactive_actions[] = static void update_inactive_actions (GncPluginPage *plugin_page) { - GncMainWindow *window; - GtkActionGroup *action_group; + GncMainWindow *window; + GSimpleActionGroup *simple_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()); @@ -1106,12 +1106,12 @@ update_inactive_actions (GncPluginPage *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)); + simple_action_group = gnc_main_window_get_action_group (window, PLUGIN_ACTIONS_NAME); + g_return_if_fail (G_IS_SIMPLE_ACTION_GROUP(simple_action_group)); /* Set the action's sensitivity */ - gnc_plugin_update_actions (action_group, readonly_inactive_actions, - "sensitive", is_readwrite); + gnc_plugin_update_actionsb (simple_action_group, readonly_inactive_actions, + "sensitive", is_readwrite); } /* This is the list of actions which are switched invisible or visible @@ -1127,20 +1127,20 @@ static const char* extra_toolbar_actions[] = static void bind_toolbuttons_visibility (GncMainWindow *mainwindow) { - GtkActionGroup *action_group; + GSimpleActionGroup *simple_action_group; const char **iter; g_return_if_fail(mainwindow); g_return_if_fail(GNC_IS_MAIN_WINDOW(mainwindow)); /* Get the action group */ -//FIXMEb action_group = gnc_main_window_get_action_group (mainwindow, PLUGIN_ACTIONS_NAME); -// g_assert(action_group); + simple_action_group = gnc_main_window_get_action_group (mainwindow, PLUGIN_ACTIONS_NAME); + g_assert (simple_action_group); -// for (iter = extra_toolbar_actions; *iter; ++iter) +//FIXMEb for (iter = extra_toolbar_actions; *iter; ++iter) // { /* Set the action's visibility */ -// GtkAction *action = gtk_action_group_get_action (action_group, *iter); +// GAction *action = g_action_map_lookup_action (G_ACTION_MAP(simple_action_group), *iter); // gnc_prefs_bind (GNC_PREFS_GROUP_INVOICE, GNC_PREF_EXTRA_TOOLBUTTONS, G_OBJECT (action), "visible"); // } } diff --git a/gnucash/gnome/gnc-plugin-page-account-tree.c b/gnucash/gnome/gnc-plugin-page-account-tree.c index 46ce1695b7..80b465fc7c 100644 --- a/gnucash/gnome/gnc-plugin-page-account-tree.c +++ b/gnucash/gnome/gnc-plugin-page-account-tree.c @@ -465,7 +465,6 @@ gnc_plugin_page_account_tree_class_init (GncPluginPageAccountTreeClass *klass) static void gnc_plugin_page_account_tree_init (GncPluginPageAccountTree *plugin_page) { -// GtkActionGroup *action_group; GSimpleActionGroup *simple_action_group; GncPluginPageAccountTreePrivate *priv; GncPluginPage *parent; @@ -658,22 +657,22 @@ static void gnc_plugin_page_account_editing_started_cd (gpointer various, GncPluginPageRegister *page) { GncPluginPage *plugin_page = GNC_PLUGIN_PAGE(page); - GtkAction *action = gnc_main_window_find_action (GNC_MAIN_WINDOW(plugin_page->window), + GAction *action = gnc_main_window_find_action (GNC_MAIN_WINDOW(plugin_page->window), "EditDeleteAccountAction"); if (action != NULL) - gtk_action_set_sensitive (action, FALSE); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE); } static void gnc_plugin_page_account_editing_finished_cb (gpointer various, GncPluginPageRegister *page) { GncPluginPage *plugin_page = GNC_PLUGIN_PAGE(page); - GtkAction *action = gnc_main_window_find_action (GNC_MAIN_WINDOW(plugin_page->window), + GAction *action = gnc_main_window_find_action (GNC_MAIN_WINDOW(plugin_page->window), "EditDeleteAccountAction"); if (action != NULL) - gtk_action_set_sensitive (action, TRUE); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), TRUE); } static GtkWidget * @@ -840,7 +839,7 @@ gnc_plugin_page_account_tree_destroy_widget (GncPluginPage *plugin_page) static void update_inactive_actions(GncPluginPage *plugin_page) { GncPluginPageAccountTreePrivate *priv; - GtkActionGroup *action_group; + GSimpleActionGroup *simple_action_group; Account *account = NULL; gboolean allow_write = !qof_book_is_readonly(gnc_get_current_book()); gboolean has_account = FALSE; @@ -859,17 +858,17 @@ static void update_inactive_actions(GncPluginPage *plugin_page) } /* Get the action group */ - action_group = gnc_plugin_page_get_action_group(plugin_page); - g_return_if_fail(GTK_IS_ACTION_GROUP (action_group)); + simple_action_group = gnc_plugin_page_get_action_groupb (plugin_page); + g_return_if_fail (G_IS_SIMPLE_ACTION_GROUP (simple_action_group)); /* Set the action's sensitivity */ - gnc_plugin_update_actions (action_group, readonly_inactive_actions, + gnc_plugin_update_actionsb (simple_action_group, readonly_inactive_actions, "sensitive", allow_write); - gnc_plugin_update_actions (action_group, actions_requiring_account_rw, + gnc_plugin_update_actionsb (simple_action_group, actions_requiring_account_rw, "sensitive", allow_write && has_account); - gnc_plugin_update_actions (action_group, actions_requiring_account_always, + gnc_plugin_update_actionsb (simple_action_group, actions_requiring_account_always, "sensitive", has_account); - gnc_plugin_update_actions (action_group, actions_requiring_subaccounts_rw, + gnc_plugin_update_actionsb (simple_action_group, actions_requiring_subaccounts_rw, "sensitive", allow_write && subaccounts); g_signal_emit (plugin_page, plugin_page_signals[ACCOUNT_SELECTED], 0, account); } diff --git a/gnucash/gnome/gnc-plugin-page-budget.c b/gnucash/gnome/gnc-plugin-page-budget.c index dba4843d22..054493574b 100644 --- a/gnucash/gnome/gnc-plugin-page-budget.c +++ b/gnucash/gnome/gnc-plugin-page-budget.c @@ -236,11 +236,8 @@ typedef enum allperiods_action typedef struct GncPluginPageBudgetPrivate { - GtkActionGroup *action_group; - guint merge_id; - GtkUIManager *ui_merge; GtkBuilder *builder; - GSimpleActionGroup *simple_action_group; + GSimpleActionGroup *simple_action_group; GncBudgetView* budget_view; GtkTreeView *tree_view; @@ -339,7 +336,6 @@ gnc_plugin_page_budget_class_init (GncPluginPageBudgetClass *klass) static void gnc_plugin_page_budget_init (GncPluginPageBudget *plugin_page) { -// GtkActionGroup *action_group; GSimpleActionGroup *simple_action_group; GncPluginPageBudgetPrivate *priv; GncPluginPage *parent; @@ -364,6 +360,7 @@ gnc_plugin_page_budget_init (GncPluginPageBudget *plugin_page) gnc_plugin_page_budget_actions, gnc_plugin_page_budget_n_actions, plugin_page); + //FIXMEb gnc_plugin_init_short_names (action_group, toolbar_labels); if (qof_book_is_readonly (gnc_get_current_book())) @@ -711,7 +708,7 @@ static void gppb_selection_changed_cb (GtkTreeSelection *selection, GncPluginPageBudget *page) { - GtkActionGroup *action_group; + GSimpleActionGroup *simple_action_group; GtkTreeView *view; GList *acct_list; gboolean sensitive; @@ -732,8 +729,8 @@ gppb_selection_changed_cb (GtkTreeSelection *selection, g_list_free (acct_list); } - action_group = gnc_plugin_page_get_action_group (GNC_PLUGIN_PAGE(page)); - gnc_plugin_update_actions (action_group, actions_requiring_account, + simple_action_group = gnc_plugin_page_get_action_group (GNC_PLUGIN_PAGE(page)); + gnc_plugin_update_actionsb (simple_action_group, actions_requiring_account, "sensitive", sensitive); } #endif diff --git a/gnucash/gnome/gnc-plugin-page-invoice.c b/gnucash/gnome/gnc-plugin-page-invoice.c index ce37164267..2ed22f8640 100644 --- a/gnucash/gnome/gnc-plugin-page-invoice.c +++ b/gnucash/gnome/gnc-plugin-page-invoice.c @@ -553,7 +553,6 @@ static void gnc_plugin_page_invoice_init (GncPluginPageInvoice *plugin_page) { GncPluginPage *parent; -// GtkActionGroup *action_group; GSimpleActionGroup *simple_action_group; gboolean use_new; @@ -599,25 +598,25 @@ gnc_plugin_page_invoice_finalize (GObject *object) static void update_doclink_actions (GncPluginPage *plugin_page, gboolean has_uri) { - GtkAction *uri_action; + GAction *uri_action; uri_action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE(plugin_page), "BusinessLinkOpenAction"); - gtk_action_set_sensitive (uri_action, has_uri); + g_simple_action_set_enabled (G_SIMPLE_ACTION(uri_action), has_uri); } static void -gnc_plugin_page_invoice_action_update (GtkActionGroup *action_group, +gnc_plugin_page_invoice_action_update (GSimpleActionGroup *simple_action_group, action_toolbar_labels *action_list, void (*gtkfunc)(gpointer, gpointer)) { - GtkAction *action; + GAction *action; gint i; for (i = 0; action_list[i].action_name; i++) { /* update the action */ - action = gtk_action_group_get_action (action_group, - action_list[i].action_name); + action = g_action_map_lookup_action (G_ACTION_MAP(simple_action_group), + action_list[i].action_name); gtkfunc (action, _(action_list[i].label)); } } @@ -626,7 +625,7 @@ static void gnc_plugin_page_update_reset_layout_action (GncPluginPage *page) { GncPluginPageInvoicePrivate *priv; - GtkAction *layout_action; + GAction *layout_action; gboolean has_default = FALSE; g_return_if_fail (GNC_IS_PLUGIN_PAGE_INVOICE(page)); @@ -636,13 +635,13 @@ gnc_plugin_page_update_reset_layout_action (GncPluginPage *page) layout_action = gnc_plugin_page_get_action (page, "ViewResetLayoutAction"); if (gnc_invoice_window_document_has_user_state (priv->iw)) has_default = TRUE; - gtk_action_set_sensitive (layout_action, has_default); + g_simple_action_set_enabled (G_SIMPLE_ACTION(layout_action), has_default); } void gnc_plugin_page_invoice_update_menus (GncPluginPage *page, gboolean is_posted, gboolean can_unpost) { - GtkActionGroup *action_group; + GSimpleActionGroup *simple_action_group; GncPluginPageInvoicePrivate *priv; GncInvoiceType invoice_type; GncInvoice *invoice; @@ -713,28 +712,28 @@ gnc_plugin_page_invoice_update_menus (GncPluginPage *page, gboolean is_posted, g can_unpost = FALSE; } - action_group = gnc_plugin_page_get_action_group(page); - gnc_plugin_update_actions (action_group, posted_actions, + simple_action_group = gnc_plugin_page_get_action_groupb (page); + gnc_plugin_update_actionsb (simple_action_group, posted_actions, "sensitive", is_posted); - gnc_plugin_update_actions (action_group, unposted_actions, + gnc_plugin_update_actionsb (simple_action_group, unposted_actions, "sensitive", !is_posted); - gnc_plugin_update_actions (action_group, can_unpost_actions, + gnc_plugin_update_actionsb (simple_action_group, can_unpost_actions, "sensitive", can_unpost); - gnc_plugin_update_actions (action_group, invoice_book_readwrite_actions, + gnc_plugin_update_actionsb (simple_action_group, invoice_book_readwrite_actions, "sensitive", !is_readonly); /* update the action labels */ - gnc_plugin_page_invoice_action_update (action_group, label_list, (void*)gtk_action_set_label); + gnc_plugin_page_invoice_action_update (simple_action_group, label_list, (void*)gtk_action_set_label); /* update the action tooltips */ - gnc_plugin_page_invoice_action_update (action_group, tooltip_list, (void*)gtk_action_set_tooltip); + gnc_plugin_page_invoice_action_update (simple_action_group, tooltip_list, (void*)gtk_action_set_tooltip); // if there is no default layout do not enable reset action gnc_plugin_page_update_reset_layout_action (page); /* update the layout action labels */ - gnc_plugin_page_invoice_action_update (action_group, label_layout_list, (void*)gtk_action_set_label); + gnc_plugin_page_invoice_action_update (simple_action_group, label_layout_list, (void*)gtk_action_set_label); /* update the layout action tooltips */ - gnc_plugin_page_invoice_action_update (action_group, tooltip_layout_list, (void*)gtk_action_set_tooltip); + gnc_plugin_page_invoice_action_update (simple_action_group, tooltip_layout_list, (void*)gtk_action_set_tooltip); // update doclink buttons invoice = gnc_invoice_window_get_invoice (priv->iw); @@ -1171,7 +1170,7 @@ gnc_plugin_page_invoice_cmd_sort_changed (GSimpleAction *simple, GncPluginPageInvoicePrivate *priv; invoice_sort_type_t value; - g_return_if_fail(GTK_IS_ACTION(simple)); + g_return_if_fail(G_IS_SIMPLE_ACTION(simple)); g_return_if_fail(GNC_IS_PLUGIN_PAGE_INVOICE(plugin_page)); ENTER("action %p, plugin_page %p)", simple, plugin_page); @@ -1335,7 +1334,7 @@ gnc_plugin_page_invoice_cmd_save_layout (GSimpleAction *simple, GncPluginPageInvoice *plugin_page = user_data; GncPluginPageInvoicePrivate *priv; GtkWindow *parent; - GtkAction *layout_action; + GAction *layout_action; g_return_if_fail (GNC_IS_PLUGIN_PAGE_INVOICE(plugin_page)); @@ -1345,7 +1344,7 @@ gnc_plugin_page_invoice_cmd_save_layout (GSimpleAction *simple, layout_action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE(plugin_page), "ViewResetLayoutAction"); - gtk_action_set_sensitive (layout_action, TRUE); + g_simple_action_set_enabled (G_SIMPLE_ACTION(layout_action), TRUE); LEAVE(" "); } @@ -1358,7 +1357,7 @@ gnc_plugin_page_invoice_cmd_reset_layout (GSimpleAction *simple, GncPluginPageInvoice *plugin_page = user_data; GncPluginPageInvoicePrivate *priv; GtkWindow *parent; - GtkAction *layout_action; + GAction *layout_action; g_return_if_fail (GNC_IS_PLUGIN_PAGE_INVOICE(plugin_page)); @@ -1368,7 +1367,7 @@ gnc_plugin_page_invoice_cmd_reset_layout (GSimpleAction *simple, layout_action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE(plugin_page), "ViewResetLayoutAction"); - gtk_action_set_sensitive (layout_action, FALSE); + g_simple_action_set_enabled (G_SIMPLE_ACTION(layout_action), FALSE); LEAVE(" "); } @@ -1381,7 +1380,6 @@ gnc_plugin_page_invoice_cmd_link (GSimpleAction *simple, GncPluginPageInvoice *plugin_page = user_data; GncPluginPageInvoicePrivate *priv; GtkWindow *parent; - GtkAction *uri_action; GncInvoice *invoice; const gchar *uri; gchar *ret_uri; @@ -1440,7 +1438,6 @@ gnc_plugin_page_invoice_cmd_link_remove (GSimpleAction *simple, GncPluginPageInvoice *plugin_page = user_data; GncPluginPageInvoicePrivate *priv; GtkWindow *parent; - GtkAction *uri_action; GncInvoice *invoice; GtkWidget *doclink_button; diff --git a/gnucash/gnome/gnc-plugin-page-owner-tree.c b/gnucash/gnome/gnc-plugin-page-owner-tree.c index 84e0c08a0b..16d952f78a 100644 --- a/gnucash/gnome/gnc-plugin-page-owner-tree.c +++ b/gnucash/gnome/gnc-plugin-page-owner-tree.c @@ -339,13 +339,11 @@ GncPluginPage * gnc_plugin_page_owner_tree_new (GncOwnerType owner_type) { GncPluginPageOwnerTree *plugin_page; - GncPluginPageOwnerTreePrivate *priv; const GList *item; - - GtkActionGroup *action_group; - GtkAction *action; - gint i; + GSimpleActionGroup *simple_action_group; + GAction *action; + gint i; g_return_val_if_fail( (owner_type != GNC_OWNER_UNDEFINED) && (owner_type != GNC_OWNER_NONE), NULL); @@ -370,13 +368,14 @@ gnc_plugin_page_owner_tree_new (GncOwnerType owner_type) priv->owner_type = owner_type; /* Hide menu and toolbar items that are not relevant for the active owner list */ - action_group = gnc_plugin_page_get_action_group(GNC_PLUGIN_PAGE(plugin_page)); + simple_action_group = gnc_plugin_page_get_action_groupb (GNC_PLUGIN_PAGE(plugin_page)); for (i = 0; action_owners[i].action_name; i++) { - action = gtk_action_group_get_action (action_group, action_owners[i].action_name); - g_object_set (G_OBJECT(action), - "visible", (priv->owner_type == action_owners[i].owner_type), - NULL); + action = g_action_map_lookup_action (G_ACTION_MAP(simple_action_group), + action_owners[i].action_name); +//FIXMEb g_object_set (G_OBJECT(action), +// "visible", (priv->owner_type == action_owners[i].owner_type), +// NULL); } LEAVE("new %s tree page %p", gncOwnerTypeToQofIdType(owner_type), plugin_page); @@ -436,7 +435,6 @@ gnc_plugin_page_owner_tree_class_init (GncPluginPageOwnerTreeClass *klass) static void gnc_plugin_page_owner_tree_init (GncPluginPageOwnerTree *plugin_page) { -// GtkActionGroup *action_group; GSimpleActionGroup *simple_action_group; GncPluginPageOwnerTreePrivate *priv; GncPluginPage *parent; @@ -492,7 +490,7 @@ gnc_plugin_page_owner_tree_finalize (GObject *object) static void update_inactive_actions(GncPluginPage *plugin_page) { - GtkActionGroup *action_group; + GSimpleActionGroup *simple_action_group; gboolean is_sensitive = !qof_book_is_readonly(gnc_get_current_book()); // We are readonly - so we have to switch particular actions to inactive. @@ -500,11 +498,11 @@ static void update_inactive_actions(GncPluginPage *plugin_page) g_return_if_fail(GNC_IS_PLUGIN_PAGE(plugin_page)); /* Get the action group */ - action_group = gnc_plugin_page_get_action_group(plugin_page); - g_return_if_fail(GTK_IS_ACTION_GROUP (action_group)); + simple_action_group = gnc_plugin_page_get_action_groupb (plugin_page); + g_return_if_fail (G_IS_SIMPLE_ACTION_GROUP (simple_action_group)); /* Set the action's sensitivity */ - gnc_plugin_update_actions (action_group, readonly_inactive_actions, + gnc_plugin_update_actionsb (simple_action_group, readonly_inactive_actions, "sensitive", is_sensitive); } @@ -873,7 +871,7 @@ static void gnc_plugin_page_owner_tree_selection_changed_cb (GtkTreeSelection *selection, GncPluginPageOwnerTree *page) { - GtkActionGroup *action_group; + GSimpleActionGroup *simple_action_group; GtkTreeView *view; GncOwner *owner = NULL; gboolean sensitive; @@ -893,10 +891,10 @@ gnc_plugin_page_owner_tree_selection_changed_cb (GtkTreeSelection *selection, sensitive = (owner != NULL); } - action_group = gnc_plugin_page_get_action_group(GNC_PLUGIN_PAGE(page)); - gnc_plugin_update_actions (action_group, actions_requiring_owner_always, + simple_action_group = gnc_plugin_page_get_action_groupb (GNC_PLUGIN_PAGE(page)); + gnc_plugin_update_actionsb (simple_action_group, actions_requiring_owner_always, "sensitive", sensitive); - gnc_plugin_update_actions (action_group, actions_requiring_owner_rw, + gnc_plugin_update_actionsb (simple_action_group, actions_requiring_owner_rw, "sensitive", sensitive && is_readwrite); g_signal_emit (page, plugin_page_signals[OWNER_SELECTED], 0, owner); } diff --git a/gnucash/gnome/gnc-plugin-page-register.c b/gnucash/gnome/gnc-plugin-page-register.c index 11efa31241..1bbd5a3a49 100644 --- a/gnucash/gnome/gnc-plugin-page-register.c +++ b/gnucash/gnome/gnc-plugin-page-register.c @@ -812,7 +812,6 @@ gnc_plugin_page_register_init (GncPluginPageRegister* plugin_page) { GncPluginPageRegisterPrivate* priv; GncPluginPage* parent; -// GtkActionGroup *action_group; GSimpleActionGroup *simple_action_group; gboolean use_new; @@ -1006,7 +1005,7 @@ gnc_plugin_page_register_ui_update (gpointer various, { GncPluginPageRegisterPrivate* priv; SplitRegister* reg; - GtkAction* action; + GAction* action; gboolean expanded, voided, read_only = FALSE, read_only_reg = FALSE; Transaction* trans; GList* invoices; @@ -1020,12 +1019,10 @@ gnc_plugin_page_register_ui_update (gpointer various, expanded = gnc_split_register_current_trans_expanded (reg); action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE (page), "SplitTransactionAction"); - gtk_action_set_sensitive (action, reg->style == REG_STYLE_LEDGER); - g_signal_handlers_block_by_func - (action, gnc_plugin_page_register_cmd_expand_transaction, page); - gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), expanded); - g_signal_handlers_unblock_by_func - (action, gnc_plugin_page_register_cmd_expand_transaction, page); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), reg->style == REG_STYLE_LEDGER); + g_signal_handlers_block_by_func (action, gnc_plugin_page_register_cmd_expand_transaction, page); +//FIXMEb gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), expanded); + g_signal_handlers_unblock_by_func (action, gnc_plugin_page_register_cmd_expand_transaction, page); /* If we are in a readonly book, or possibly a place holder * account register make any modifying action inactive */ @@ -1044,8 +1041,8 @@ gnc_plugin_page_register_ui_update (gpointer various, for (iter = readonly_inactive_actions; *iter; ++iter) { /* Set the action's sensitivity */ - GtkAction* action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE (page), *iter); - gtk_action_set_sensitive (action, TRUE); + GAction* action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE (page), *iter); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), TRUE); } main_window_update_page_set_read_only_icon (GNC_PLUGIN_PAGE(page), FALSE); @@ -1056,26 +1053,26 @@ gnc_plugin_page_register_ui_update (gpointer various, action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE (page), "CutTransactionAction"); - gtk_action_set_sensitive (GTK_ACTION (action), !read_only & !voided); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), !read_only & !voided); action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE (page), "PasteTransactionAction"); - gtk_action_set_sensitive (GTK_ACTION (action), !read_only & !voided); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), !read_only & !voided); action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE (page), "DeleteTransactionAction"); - gtk_action_set_sensitive (GTK_ACTION (action), !read_only & !voided); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), !read_only & !voided); if (cursor_class == CURSOR_CLASS_SPLIT) { action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE (page), "DuplicateTransactionAction"); - gtk_action_set_sensitive (GTK_ACTION (action), !read_only & !voided); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), !read_only & !voided); } action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE (page), "RemoveTransactionSplitsAction"); - gtk_action_set_sensitive (GTK_ACTION (action), !read_only & !voided); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), !read_only & !voided); /* Set 'Void' and 'Unvoid' */ if (read_only) @@ -1083,14 +1080,14 @@ gnc_plugin_page_register_ui_update (gpointer various, action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE (page), "VoidTransactionAction"); - gtk_action_set_sensitive (GTK_ACTION (action), !voided); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), !voided); if (read_only) voided = FALSE; action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE (page), "UnvoidTransactionAction"); - gtk_action_set_sensitive (GTK_ACTION (action), voided); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), voided); } /* Set 'Open and Remove Linked Documents' */ @@ -1099,7 +1096,7 @@ gnc_plugin_page_register_ui_update (gpointer various, if (trans) { uri = xaccTransGetDocLink (trans); - gtk_action_set_sensitive (GTK_ACTION(action), (uri ? TRUE:FALSE)); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), (uri ? TRUE:FALSE)); } /* Set 'ExecAssociatedInvoice' We can determine an invoice from a txn if either @@ -1111,7 +1108,7 @@ gnc_plugin_page_register_ui_update (gpointer various, if (trans) { invoices = invoices_from_transaction (trans); - gtk_action_set_sensitive (GTK_ACTION (action), (invoices != NULL)); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), (invoices != NULL)); g_list_free (invoices); } @@ -1124,8 +1121,8 @@ gnc_plugin_page_register_ui_update (gpointer various, for (iter = readonly_inactive_actions; *iter; ++iter) { /* Set the action's sensitivity */ - GtkAction* action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE (page), *iter); - gtk_action_set_sensitive (action, FALSE); + GAction* action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE (page), *iter); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE); } main_window_update_page_set_read_only_icon (GNC_PLUGIN_PAGE(page), TRUE); } @@ -1137,8 +1134,8 @@ gnc_plugin_page_register_ui_update (gpointer various, iter = tran_vs_split_actions; action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE (page), *iter); label_iter = tran_action_labels; - if (g_strcmp0 (gtk_action_get_label (action), _ (*label_iter)) == 0) - curr_label_trans = TRUE; +//FIXMEb if (g_strcmp0 (gtk_action_get_label (action), _ (*label_iter)) == 0) +// curr_label_trans = TRUE; if ((cursor_class == CURSOR_CLASS_SPLIT) && curr_label_trans) { label_iter = split_action_labels; @@ -1147,8 +1144,8 @@ gnc_plugin_page_register_ui_update (gpointer various, { /* Adjust the action's label and tooltip */ action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE (page), *iter); - gtk_action_set_label (action, _ (*label_iter)); - gtk_action_set_tooltip (action, _ (*tooltip_iter)); +//FIXMEb gtk_action_set_label (action, _ (*label_iter)); +//FIXMEb gtk_action_set_tooltip (action, _ (*tooltip_iter)); ++label_iter; ++tooltip_iter; } @@ -1161,8 +1158,8 @@ gnc_plugin_page_register_ui_update (gpointer various, { /* Adjust the action's label and tooltip */ action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE (page), *iter); - gtk_action_set_label (action, _ (*label_iter)); - gtk_action_set_tooltip (action, _ (*tooltip_iter)); +//FIXMEb gtk_action_set_label (action, _ (*label_iter)); +//FIXMEb gtk_action_set_tooltip (action, _ (*tooltip_iter)); ++label_iter; ++tooltip_iter; } @@ -1174,8 +1171,8 @@ static void gnc_plugin_page_register_ui_initial_state (GncPluginPageRegister* page) { GncPluginPageRegisterPrivate* priv ; - GtkActionGroup* action_group; - GtkAction* action; + GSimpleActionGroup *simple_action_group; + GAction *action; Account* account; SplitRegister* reg; GNCLedgerDisplayType ledger_type; @@ -1184,18 +1181,18 @@ gnc_plugin_page_register_ui_initial_state (GncPluginPageRegister* page) priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page); account = gnc_plugin_page_register_get_account (page); - action_group = gnc_plugin_page_get_action_group (GNC_PLUGIN_PAGE (page)); - gnc_plugin_update_actions (action_group, actions_requiring_account, + simple_action_group = gnc_plugin_page_get_action_groupb (GNC_PLUGIN_PAGE (page)); + gnc_plugin_update_actionsb (simple_action_group, actions_requiring_account, "sensitive", is_readwrite && account != NULL); - gnc_plugin_update_actions (action_group, actions_requiring_priced_account, + gnc_plugin_update_actionsb (simple_action_group, actions_requiring_priced_account, "visible", account && gnc_prefs_is_extra_enabled () && xaccAccountIsPriced (account)); /* Set "style" radio button */ ledger_type = gnc_ledger_display_type (priv->ledger); - gnc_plugin_update_actions (action_group, view_style_actions, + gnc_plugin_update_actionsb (simple_action_group, view_style_actions, "sensitive", ledger_type == LD_SINGLE); reg = gnc_ledger_display_get_split_register (priv->ledger); @@ -1211,20 +1208,19 @@ gnc_plugin_page_register_ui_initial_state (GncPluginPageRegister* page) // } /* Either a match was found, or fell out with i = 0 */ -// action = gtk_action_group_get_action (action_group, radio_entries_2[i].name); +//FIXMEb action = g_action_map_lookup_action (G_ACTION_MAP(simple_action_group), radio_entries_2[i].name); // g_signal_handlers_block_by_func (action, // gnc_plugin_page_register_cmd_style_changed, page); -// gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), TRUE); +//FIXMEb gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), TRUE); // g_signal_handlers_unblock_by_func (action, // gnc_plugin_page_register_cmd_style_changed, page); /* Set "double line" toggle button */ - action = gtk_action_group_get_action (action_group, - "ViewStyleDoubleLineAction"); + action = g_action_map_lookup_action (G_ACTION_MAP(simple_action_group), "ViewStyleDoubleLineAction"); g_signal_handlers_block_by_func (action, gnc_plugin_page_register_cmd_style_double_line, page); - gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), - reg->use_double_line); +//FIXMEb gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), +// reg->use_double_line); g_signal_handlers_unblock_by_func (action, gnc_plugin_page_register_cmd_style_double_line, page); } @@ -1701,7 +1697,7 @@ gnc_plugin_page_register_restore_edit_menu (GncPluginPage* page, GKeyFile* key_file, const gchar* group_name) { - GtkAction* action; + GAction* action; GError* error = NULL; gchar* style_name; gint i; @@ -1848,7 +1844,7 @@ gnc_plugin_page_register_update_edit_menu (GncPluginPage* page, gboolean hide) { GncPluginPageRegisterPrivate* priv; GncPluginPageRegister* reg_page; - GtkAction* action; + GAction* action; gboolean can_copy = FALSE, can_cut = FALSE, can_paste = FALSE; gboolean has_selection; gboolean is_readwrite = !qof_book_is_readonly (gnc_get_current_book()); @@ -1862,14 +1858,14 @@ gnc_plugin_page_register_update_edit_menu (GncPluginPage* page, gboolean hide) can_paste = is_readwrite; action = gnc_plugin_page_get_action (page, "EditCopyAction"); - gtk_action_set_sensitive (action, can_copy); - gtk_action_set_visible (action, !hide || can_copy); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), can_copy); +//FIXMEb gtk_action_set_visible (action, !hide || can_copy); action = gnc_plugin_page_get_action (page, "EditCutAction"); - gtk_action_set_sensitive (action, can_cut); - gtk_action_set_visible (action, !hide || can_cut); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), can_cut); +//FIXMEb gtk_action_set_visible (action, !hide || can_cut); action = gnc_plugin_page_get_action (page, "EditPasteAction"); - gtk_action_set_sensitive (action, can_paste); - gtk_action_set_visible (action, !hide || can_paste); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), can_paste); +//FIXMEb gtk_action_set_visible (action, !hide || can_paste); } static gboolean is_scrubbing = FALSE; diff --git a/gnucash/gnome/gnc-plugin-page-report.cpp b/gnucash/gnome/gnc-plugin-page-report.cpp index 3b983476a0..d4209f884c 100644 --- a/gnucash/gnome/gnc-plugin-page-report.cpp +++ b/gnucash/gnome/gnc-plugin-page-report.cpp @@ -433,7 +433,7 @@ gnc_plugin_page_report_create_widget( GncPluginPage *page ) GncPluginPageReport *report; GncPluginPageReportPrivate *priv; GtkWindow *topLvl; - GtkAction *action; + GAction *action; GtkWidget *webview; URLType type; char * id_name; @@ -446,8 +446,8 @@ gnc_plugin_page_report_create_widget( GncPluginPage *page ) #ifndef WEBKIT1 /* Hide the ExportPdf action for Webkit2 */ action = gnc_plugin_page_get_action (page, "FilePrintPDFAction"); - gtk_action_set_sensitive (action, FALSE); - gtk_action_set_visible (action, FALSE); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE); +//FIXMEb gtk_action_set_visible (action, FALSE); #endif report = GNC_PLUGIN_PAGE_REPORT(page); @@ -580,10 +580,9 @@ gnc_plugin_page_report_setup( GncPluginPage *ppage ) * called after a report is loaded into the gnc_html widget ********************************************************************/ static void -//gnc_plugin_page_report_load_cb(gnc_html * html, URLType type, -gnc_plugin_page_report_load_cb(GncHtml * html, URLType type, - const gchar * location, const gchar * label, - gpointer data) +gnc_plugin_page_report_load_cb (GncHtml * html, URLType type, + const gchar * location, const gchar * label, + gpointer data) { GncPluginPageReport *report = GNC_PLUGIN_PAGE_REPORT(data); GncPluginPageReportPrivate *priv; @@ -1055,17 +1054,17 @@ gnc_plugin_page_report_name_changed (GncPluginPage *page, const gchar *name) static void gnc_plugin_page_report_update_edit_menu (GncPluginPage *page, gboolean hide) { - GtkAction *action; + GAction *action; action = gnc_plugin_page_get_action (page, "EditCopyAction"); - gtk_action_set_sensitive (action, TRUE); - gtk_action_set_visible (action, TRUE); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), TRUE); +//FIXMEb gtk_action_set_visible (action, TRUE); action = gnc_plugin_page_get_action (page, "EditCutAction"); - gtk_action_set_sensitive (action, FALSE); - gtk_action_set_visible (action, !hide); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE); +//FIXMEb gtk_action_set_visible (action, !hide); action = gnc_plugin_page_get_action (page, "EditPasteAction"); - gtk_action_set_sensitive (action, FALSE); - gtk_action_set_visible (action, !hide); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE); +//FIXMEb gtk_action_set_visible (action, !hide); } static gboolean @@ -1209,7 +1208,7 @@ gnc_plugin_page_report_constr_init(GncPluginPageReport *plugin_page, gint report { "ReportReloadAction", gnc_plugin_page_report_reload_cb, nullptr, nullptr, nullptr }, { "ReportStopAction", gnc_plugin_page_report_stop_cb, nullptr, nullptr, nullptr }, }; - guint num_report_actions = G_N_ELEMENTS( report_actions ); + guint num_report_actions = G_N_ELEMENTS(report_actions); static GncDisplayItem report_display_items [] = { @@ -1273,26 +1272,26 @@ gnc_plugin_page_report_constr_init(GncPluginPageReport *plugin_page, gint report /** The number of display items provided by this plugin. */ guint num_report_display_items = G_N_ELEMENTS(report_display_items); - DEBUG( "property reportId=%d", reportId ); + DEBUG("property reportId=%d", reportId); priv = GNC_PLUGIN_PAGE_REPORT_GET_PRIVATE(plugin_page); priv->reportId = reportId; - gnc_plugin_page_report_setup( GNC_PLUGIN_PAGE(plugin_page) ); + gnc_plugin_page_report_setup( GNC_PLUGIN_PAGE(plugin_page)); /* Init parent declared variables */ parent = GNC_PLUGIN_PAGE(plugin_page); use_new = gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL_REPORT, GNC_PREF_USE_NEW); - name = gnc_report_name( priv->initial_report ); - g_object_set(G_OBJECT(plugin_page), - "page-name", name, - "page-uri", "default:", - "ui-description", "gnc-plugin-page-report.ui", - "use-new-window", use_new, - nullptr); - g_free(name); + name = gnc_report_name (priv->initial_report); + g_object_set (G_OBJECT(plugin_page), + "page-name", name, + "page-uri", "default:", + "ui-description", "gnc-plugin-page-report.ui", + "use-new-window", use_new, + nullptr); + g_free (name); /* change me when the system supports multiple books */ - gnc_plugin_page_add_book(parent, gnc_get_current_book()); + gnc_plugin_page_add_book (parent, gnc_get_current_book()); /* Create menu and toolbar information */ simple_action_group = gnc_plugin_page_create_action_groupb (parent, "GncPluginPageReportActions"); @@ -1309,9 +1308,8 @@ gnc_plugin_page_report_constr_init(GncPluginPageReport *plugin_page, gint report // num_report_actions, // plugin_page ); -//FIXMEb gnc_plugin_update_actions(action_group, -// initially_insensitive_actions, -// "sensitive", FALSE); + gnc_plugin_update_actionsb (simple_action_group, initially_insensitive_actions, + "sensitive", FALSE); //FIXMEb gnc_plugin_init_short_names (action_group, toolbar_labels); @@ -1375,23 +1373,21 @@ close_handler (gpointer user_data) } static void -gnc_plugin_page_report_set_fwd_button(GncPluginPageReport *report, int enabled) +gnc_plugin_page_report_set_fwd_button (GncPluginPageReport *report, int enabled) { - GtkAction *act; + GAction *act; - act = gnc_plugin_page_get_action(GNC_PLUGIN_PAGE(report), - "ReportForwAction" ); - gtk_action_set_sensitive(act, enabled); + act = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE(report), "ReportForwAction"); + g_simple_action_set_enabled (G_SIMPLE_ACTION(act), enabled); } static void -gnc_plugin_page_report_set_back_button(GncPluginPageReport *report, int enabled) +gnc_plugin_page_report_set_back_button (GncPluginPageReport *report, int enabled) { - GtkAction *act; + GAction *act; - act = gnc_plugin_page_get_action(GNC_PLUGIN_PAGE(report), - "ReportBackAction" ); - gtk_action_set_sensitive(act, enabled); + act = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE(report), "ReportBackAction"); + g_simple_action_set_enabled (G_SIMPLE_ACTION(act), enabled); } // ------------------------------------------------------------ @@ -1779,10 +1775,10 @@ gnc_plugin_page_report_export_cb (GSimpleAction *simple, g_free (str); } else - gnc_error_dialog (parent, "%s", - _("This report must be upgraded to return a " - "document object with export-string or " - "export-error.")); + gnc_error_dialog (parent, "%s", + _("This report must be upgraded to return a " + "document object with export-string or " + "export-error.")); } result = TRUE; } @@ -1991,9 +1987,9 @@ gnc_plugin_page_report_print_cb (GSimpleAction *simple, } static void -gnc_plugin_page_report_exportpdf_cb(GSimpleAction *simple, - GVariant *parameter, - gpointer user_data) +gnc_plugin_page_report_exportpdf_cb (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { GncPluginPageReport *report = (GncPluginPageReport*)user_data; GncPluginPageReportPrivate *priv = GNC_PLUGIN_PAGE_REPORT_GET_PRIVATE(report); @@ -2009,19 +2005,19 @@ gnc_plugin_page_report_exportpdf_cb(GSimpleAction *simple, owner = (GncOwner*) gncInvoiceGetOwner(invoice); if (owner) { - QofInstance *inst = qofOwnerGetOwner (owner); - gchar *dirname = nullptr; - qof_instance_get (inst, "export-pdf-dir", &dirname, nullptr); + QofInstance *inst = qofOwnerGetOwner (owner); + gchar *dirname = nullptr; + qof_instance_get (inst, "export-pdf-dir", &dirname, nullptr); // Yes. In the kvp, look up the key for the Export-PDF output // directory. If it exists, prepend this to the job name so that // we can export to PDF. - if (dirname && g_file_test(dirname, + if (dirname && g_file_test (dirname, (GFileTest)(G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))) - { - gchar *tmp = g_build_filename(dirname, job_name, nullptr); - g_free(job_name); - job_name = tmp; - } + { + gchar *tmp = g_build_filename (dirname, job_name, nullptr); + g_free (job_name); + job_name = tmp; + } } } @@ -2035,29 +2031,27 @@ gnc_plugin_page_report_exportpdf_cb(GSimpleAction *simple, if (owner) { - /* As this is an invoice report with some owner, we will try - * to look up the chosen output directory from the print - * settings and store it again in the owner kvp. - */ + /* As this is an invoice report with some owner, we will try + * to look up the chosen output directory from the print + * settings and store it again in the owner kvp. + */ GtkPrintSettings *print_settings = gnc_print_get_settings(); - if (print_settings && - gtk_print_settings_has_key(print_settings, - GNC_GTK_PRINT_SETTINGS_EXPORT_DIR)) + if (print_settings && gtk_print_settings_has_key (print_settings, + GNC_GTK_PRINT_SETTINGS_EXPORT_DIR)) { - const char* dirname = gtk_print_settings_get(print_settings, - GNC_GTK_PRINT_SETTINGS_EXPORT_DIR); + const char* dirname = gtk_print_settings_get (print_settings, + GNC_GTK_PRINT_SETTINGS_EXPORT_DIR); // Only store the directory if it exists. - if (g_file_test(dirname, + if (g_file_test (dirname, (GFileTest)(G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))) { - QofInstance *inst = qofOwnerGetOwner(owner); - gncOwnerBeginEdit(owner); - qof_instance_set (inst, "export-pdf-dir", dirname); - gncOwnerCommitEdit(owner); + QofInstance *inst = qofOwnerGetOwner (owner); + gncOwnerBeginEdit (owner); + qof_instance_set (inst, "export-pdf-dir", dirname); + gncOwnerCommitEdit (owner); } } } - g_free (job_name); } diff --git a/gnucash/gnome/gnc-plugin-page-sx-list.c b/gnucash/gnome/gnc-plugin-page-sx-list.c index 8a3a3d7375..83db9d06b1 100644 --- a/gnucash/gnome/gnc-plugin-page-sx-list.c +++ b/gnucash/gnome/gnc-plugin-page-sx-list.c @@ -221,7 +221,6 @@ gnc_plugin_page_sx_list_class_init (GncPluginPageSxListClass *klass) static void gnc_plugin_page_sx_list_init (GncPluginPageSxList *plugin_page) { -// GtkActionGroup *action_group; GSimpleActionGroup *simple_action_group; GncPluginPage *parent; @@ -239,6 +238,7 @@ gnc_plugin_page_sx_list_init (GncPluginPageSxList *plugin_page) gnc_plugin_page_sx_list_actions, gnc_plugin_page_sx_list_n_actions, plugin_page); + /* gnc_plugin_init_short_names (action_group, toolbar_labels); */ } @@ -313,18 +313,17 @@ static void gppsl_selection_changed_cb (GtkTreeSelection *selection, gpointer user_data) { GncPluginPage *page; - GtkAction *edit_action, *delete_action; + GAction *edit_action, *delete_action; gboolean selection_state = TRUE; page = GNC_PLUGIN_PAGE(user_data); edit_action = gnc_plugin_page_get_action (page, "SxListEditAction"); delete_action = gnc_plugin_page_get_action (page, "SxListDeleteAction"); - selection_state - = gtk_tree_selection_count_selected_rows (selection) == 0 - ? FALSE - : TRUE; - gtk_action_set_sensitive (edit_action, selection_state); - gtk_action_set_sensitive (delete_action, selection_state); + selection_state = gtk_tree_selection_count_selected_rows (selection) == 0 + ? FALSE + : TRUE; + g_simple_action_set_enabled (G_SIMPLE_ACTION(edit_action), selection_state); + g_simple_action_set_enabled (G_SIMPLE_ACTION(delete_action), selection_state); } @@ -522,6 +521,14 @@ gnc_plugin_page_sx_list_create_widget (GncPluginPage *plugin_page) priv->instances = GNC_SX_INSTANCE_MODEL(gnc_sx_get_instances (&end, TRUE)); } + { + GAction *edit_action, *delete_action; + edit_action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE(page), "SxListEditAction"); + delete_action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE(page), "SxListDeleteAction"); + g_simple_action_set_enabled (G_SIMPLE_ACTION(edit_action), FALSE); + g_simple_action_set_enabled (G_SIMPLE_ACTION(delete_action), FALSE); + } + { GtkTreeSelection *selection; GtkTreePath *path = gtk_tree_path_new_first (); @@ -544,6 +551,7 @@ gnc_plugin_page_sx_list_create_widget (GncPluginPage *plugin_page) "model-populated", (GCallback)gppsl_model_populated_cb, (gpointer)page); gppsl_selection_changed_cb (selection, page); + gtk_tree_path_free (path); } g_signal_connect (G_OBJECT(priv->tree_view), "button-press-event", diff --git a/gnucash/gnucash-gresources.xml b/gnucash/gnucash-gresources.xml index b152e45f2e..33453eba80 100644 --- a/gnucash/gnucash-gresources.xml +++ b/gnucash/gnucash-gresources.xml @@ -4,5 +4,6 @@ gnucash.css gnucash-fallback.css + ui/gnc-main-window.ui diff --git a/gnucash/import-export/aqb/gnc-plugin-aqbanking.c b/gnucash/import-export/aqb/gnc-plugin-aqbanking.c index b052cc95ff..57d2ed2fe8 100644 --- a/gnucash/import-export/aqb/gnc-plugin-aqbanking.c +++ b/gnucash/import-export/aqb/gnc-plugin-aqbanking.c @@ -104,7 +104,7 @@ static GActionEntry gnc_plugin_actions [] = { "Mt942ImportAction", gnc_plugin_ab_cmd_mt942_import, NULL, NULL, NULL }, { "DtausImportAction", gnc_plugin_ab_cmd_dtaus_import, NULL, NULL, NULL }, { "DtausImportSendAction", gnc_plugin_ab_cmd_dtaus_importsend, NULL, NULL, NULL }, - { MENU_TOGGLE_ACTION_AB_VIEW_LOGWINDOW, gnc_plugin_ab_cmd_view_logwindow, NULL, "TRUE", change_state_logwindow }, + { MENU_TOGGLE_ACTION_AB_VIEW_LOGWINDOW, gnc_plugin_ab_cmd_view_logwindow, NULL, "true", change_state_logwindow }, }; /** The number of actions provided by this plugin. */ static guint gnc_plugin_n_actions = G_N_ELEMENTS(gnc_plugin_actions); @@ -236,20 +236,20 @@ static void gnc_plugin_aqbanking_add_to_window(GncPlugin *plugin, GncMainWindow *window, GQuark type) { - GtkAction *action; + GAction *action; gnc_main_window = window; - g_signal_connect(window, "page_added", - G_CALLBACK(gnc_plugin_ab_main_window_page_added), - plugin); - g_signal_connect(window, "page_changed", - G_CALLBACK(gnc_plugin_ab_main_window_page_changed), - plugin); + g_signal_connect (window, "page_added", + G_CALLBACK(gnc_plugin_ab_main_window_page_added), + plugin); + g_signal_connect (window, "page_changed", + G_CALLBACK(gnc_plugin_ab_main_window_page_changed), + plugin); - action = gnc_main_window_find_action(window, MENU_TOGGLE_ACTION_AB_VIEW_LOGWINDOW); + action = gnc_main_window_find_action (window, MENU_TOGGLE_ACTION_AB_VIEW_LOGWINDOW); - gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), FALSE); +//FIXMEb gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), FALSE); } static void @@ -307,7 +307,7 @@ gnc_plugin_ab_main_window_page_added(GncMainWindow *window, GncPluginPage *page, static void update_inactive_actions(GncPluginPage *plugin_page) { GncMainWindow *window; - GtkActionGroup *action_group; + GSimpleActionGroup *simple_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()); @@ -318,11 +318,11 @@ static void update_inactive_actions(GncPluginPage *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)); + simple_action_group = gnc_main_window_get_action_group (window, PLUGIN_ACTIONS_NAME); + g_return_if_fail (G_IS_SIMPLE_ACTION_GROUP(simple_action_group)); /* Set the action's sensitivity */ - gnc_plugin_update_actions (action_group, readonly_inactive_actions, + gnc_plugin_update_actionsb (simple_action_group, readonly_inactive_actions, "sensitive", is_readwrite); } @@ -357,40 +357,40 @@ gnc_plugin_ab_account_selected(GncPluginPage *plugin_page, Account *account, gpointer user_data) { GncMainWindow *window; - GtkActionGroup *action_group; + GSimpleActionGroup *simple_action_group; const gchar *bankcode = NULL; const gchar *accountid = NULL; g_return_if_fail(GNC_IS_PLUGIN_PAGE(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)); + simple_action_group = gnc_main_window_get_action_group (window, PLUGIN_ACTIONS_NAME); + g_return_if_fail (G_IS_SIMPLE_ACTION_GROUP(simple_action_group)); if (account) { bankcode = gnc_ab_get_account_bankcode(account); accountid = gnc_ab_get_account_accountid(account); - gnc_plugin_update_actions(action_group, need_account_actions, - "sensitive", - (account && bankcode && *bankcode - && accountid && *accountid)); - gnc_plugin_update_actions(action_group, need_account_actions, - "visible", TRUE); + gnc_plugin_update_actionsb (simple_action_group, need_account_actions, + "sensitive", + (account && bankcode && *bankcode + && accountid && *accountid)); + gnc_plugin_update_actionsb (simple_action_group, need_account_actions, + "visible", TRUE); #if (AQBANKING_VERSION_INT < 60400) - gnc_plugin_update_actions(action_group, inactive_account_actions, - "sensitive", FALSE); - gnc_plugin_update_actions(action_group, inactive_account_actions, - "visible", FALSE); + gnc_plugin_update_actionsb (simple_action_group, inactive_account_actions, + "sensitive", FALSE); + gnc_plugin_update_actionsb (simple_action_group, inactive_account_actions, + "visible", FALSE); #endif } else { - gnc_plugin_update_actions(action_group, need_account_actions, - "sensitive", FALSE); - gnc_plugin_update_actions(action_group, need_account_actions, - "visible", FALSE); + gnc_plugin_update_actionsb (simple_action_group, need_account_actions, + "sensitive", FALSE); + gnc_plugin_update_actionsb (simple_action_group, need_account_actions, + "visible", FALSE); } } @@ -462,14 +462,14 @@ main_window_to_account(GncMainWindow *window) void gnc_plugin_aqbanking_set_logwindow_visible(gboolean logwindow_visible) { - GtkAction *action; + GAction *action; - action = gnc_main_window_find_action(gnc_main_window, - MENU_TOGGLE_ACTION_AB_VIEW_LOGWINDOW); + action = gnc_main_window_find_action (gnc_main_window, + MENU_TOGGLE_ACTION_AB_VIEW_LOGWINDOW); if (action) { - gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), - logwindow_visible); +//FIXMEb gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), +// logwindow_visible); } } diff --git a/gnucash/ui/gnc-main-window.ui b/gnucash/ui/gnc-main-window.ui new file mode 100644 index 0000000000..4deaf579a3 --- /dev/null +++ b/gnucash/ui/gnc-main-window.ui @@ -0,0 +1,542 @@ + + + + + + + + _File + mainwin.FileAction +
+ + Placeholder + mainwin.FilePlaceholder0 + action-disabled + + + _Import + mainwin.FileImportAction + + ImportPlaceholder + mainwin.FilePlaceholder1 + action-disabled + + +
+
+ + SavePlaceholder + mainwin.FilePlaceholder2 + action-disabled + +
+
+ + _Print + mainwin.FilePrintAction + <Primary>p + Print the currently active page + + + Pa_ge Setup... + mainwin.FilePageSetupAction + <Primary><Shift>p + Specify the page size and orientation for printing + + + PdfPlaceholder + mainwin.FilePlaceholder3 + action-disabled + + + _Export + mainwin.FileExportAction + + ExportPlaceholder + mainwin.FilePlaceholder4 + action-disabled + + +
+
+ + Proper_ties + mainwin.FilePropertiesAction + <Alt>Return + Edit the properties of the current file + +
+
+ + RecentPlaceholder + mainwin.FilePlaceholder5 + action-disabled + +
+
+ + _Close + mainwin.FileCloseAction + <Primary>w + Close the currently active page + + + _Quit + mainwin.FileQuitAction + <Primary>q + Quit this application + action-disabled + +
+
+ + + _Edit + mainwin.EditAction +
+ + Placeholder + mainwin.EditPlaceholder0 + action-disabled + + + Cu_t + mainwin.EditCutAction + <Primary>x + Cut the current selection and copy it to clipboard + + + _Copy + mainwin.EditCopyAction + <Primary>c + Copy the current selection to clipboard + + + _Paste + mainwin.EditPasteAction + <Primary>v + Paste the clipboard content at the cursor position + +
+
+ + Placeholder + mainwin.EditPlaceholder1 + action-disabled + +
+
+ + Placeholder + mainwin.EditPlaceholder2 + action-disabled + +
+
+ + FindPlaceholder + mainwin.EditPlaceholder3 + action-disabled + +
+
+ + Pr_eferences + mainwin.EditPreferencesAction + Edit the global preferences of GnuCash + action-disabled + +
+
+ + StylePlaceholder + mainwin.EditPlaceholder4 + action-disabled + + + TaxPlaceholder + mainwin.EditPlaceholder5 + action-disabled + +
+
+ + + _View + mainwin.ViewAction +
+ + Placeholder + mainwin.ViewPlaceholder0 + action-disabled + + + _Toolbar + mainwin.ViewToolbarAction + Show/hide the toolbar on this window + + + Su_mmary Bar + mainwin.ViewSummaryAction + Show/hide the summary bar on this window + + + Stat_us Bar + mainwin.ViewStatusbarAction + Show/hide the status bar on this window + + + Tab P_osition + + To_p + mainwin.ViewTabPositionAction + 0 + Display the notebook tabs at the top of the window + + + B_ottom + mainwin.ViewTabPositionAction + 1 + Display the notebook tabs at the bottom of the window + + + _Left + mainwin.ViewTabPositionAction + 2 + Display the notebook tabs at the left of the window + + + _Right + mainwin.ViewTabPositionAction + 3 + Display the notebook tabs at the right of the window + + +
+
+ + Placeholder + mainwin.ViewPlaceholder1 + action-disabled + +
+
+ + Placeholder + mainwin.ViewPlaceholder2 + action-disabled + + + RefreshPlaceholder + mainwin.ViewPlaceholder3 + action-disabled + + + AccoutTreePlaceholder + mainwin.ViewPlaceholder4 + action-disabled + +
+
+ + + Tra_nsaction + mainwin.TransactionAction + action-disabled +
+ + Placeholder + mainwin.TransPlaceholder0 + action-disabled + +
+
+ + + _Actions + mainwin.ActionsAction +
+ + Placeholder + mainwin.ActionsPlaceholder0 + action-disabled + + + OnlinePlaceholder + mainwin.ActionsPlaceholder1 + action-disabled + + + SchedPlaceholder + mainwin.ActionsPlaceholder2 + action-disabled + + + BudgetPlaceholder + mainwin.ActionsPlaceholder3 + action-disabled + +
+
+ + Placeholder + mainwin.ActionsPlaceholder4 + action-disabled + +
+
+ + Placeholder + mainwin.ActionsPlaceholder5 + action-disabled + +
+
+ + Placeholder + mainwin.ActionsPlaceholder6 + action-disabled + +
+
+ + Reset _Warnings... + mainwin.ActionsForgetWarningsAction + Reset the state of all warning messages so they will be shown again + + + Re_name Page + mainwin.ActionsRenamePageAction + Rename this page + +
+
+ + + _Business + mainwin.BusinessAction + action-disabled +
+ + Placeholder + mainwin.BusinessPlaceholder0 + action-disabled + +
+
+ + + _Scheduled + mainwin.ScheduledAction + action-disabled +
+ + Placeholder + mainwin.SchedulePlaceholder0 + action-disabled + +
+
+ + + _Reports + mainwin.ReportsAction +
+ + Placeholder + mainwin.ReportsPlaceholder0 + action-disabled + +
+
+ + Placeholder + mainwin.ReportsPlaceholder1 + action-disabled + +
+
+ + + _Tools + mainwin.ToolsAction +
+ + OnlinePlaceholder + mainwin.ToolsPlaceholder0 + action-disabled + + + ToolsPlaceholder + mainwin.ToolsPlaceholder1 + action-disabled + + + JournalPlaceholder + mainwin.ToolsPlaceholder2 + action-disabled + +
+
+ + + E_xtensions + mainwin.ExtensionsAction + action-disabled +
+ + Placeholder + mainwin.ExtensionsPlaceholder0 + action-disabled + +
+
+ + + _Windows + mainwin.WindowsAction +
+ + Placeholder + mainwin.WindowsPlaceholder0 + action-disabled + + + _New Window + mainwin.WindowNewAction + Open a new top-level GnuCash window + + + New Window with _Page + mainwin.WindowMovePageAction + Move the current page to a new top-level GnuCash window + +
+
+ + WinPlaceholder + mainwin.WindowsPlaceholder1 + action-disabled + +
+
+ + + _Help + mainwin.HelpAction +
+ + Placeholder + mainwin.HelpPlaceholder0 + action-disabled + + + Tutorial and Concepts _Guide + mainwin.HelpTutorialAction + <Primary>h + Open the GnuCash Tutorial + + + ToDPlaceholder + mainwin.HelpPlaceholder1 + action-disabled + + + _Contents + mainwin.HelpContentsAction + F1 + Open the GnuCash Help + + + _About + mainwin.HelpAboutAction + About GnuCash + +
+
+ +
+ + + + + + + TestAction + mainwin.TestAction + + + + + + True + False + + + True + False + Save the current file + gnc-plugin-basic-commands-actions.FileSaveAction + _Save + True + document-save + + + False + True + + + + + True + False + Close the currently active page + mainwin.FileCloseAction + _Close + True + window-close + + + False + True + + + + + True + False + + + False + True + + + + + True + False + Open the New Invoice dialog + ToolbarNewInvoiceAction + gnc-plugin-business-actions.ToolbarNewInvoiceAction + New _Invoice... + True + gnc-invoice-new + + + False + True + + + + + True + False + + + False + True + + + + +
diff --git a/po/CMakeLists.txt b/po/CMakeLists.txt index 2996af6a2c..62e141011c 100644 --- a/po/CMakeLists.txt +++ b/po/CMakeLists.txt @@ -54,6 +54,7 @@ function(make_gnucash_potfiles) ${CMAKE_SOURCE_DIR}/*.keys.in ${CMAKE_SOURCE_DIR}/*.scm ${CMAKE_SOURCE_DIR}/*.py ${CMAKE_SOURCE_DIR}/*/qofbookslots.h ${CMAKE_SOURCE_DIR}/*/gnc-commodity.h + ${CMAKE_SOURCE_DIR}/*.ui ) # Only consider files in a selection of the source directories and From 6f21d4228d45134bd03bb3dba0f68d682a2e8a9d Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Fri, 28 Oct 2022 16:08:05 +0100 Subject: [PATCH 06/77] Initial changes for the main window --- gnucash/gnome-utils/gnc-main-window.cpp | 151 +++++++++++++++++------- gnucash/gnome-utils/gnc-main-window.h | 13 +- gnucash/gnome-utils/gnc-plugin-page.c | 77 +++++++++++- gnucash/gnome-utils/gnc-plugin-page.h | 15 ++- gnucash/gnome-utils/gnc-plugin.c | 24 ++-- 5 files changed, 214 insertions(+), 66 deletions(-) diff --git a/gnucash/gnome-utils/gnc-main-window.cpp b/gnucash/gnome-utils/gnc-main-window.cpp index 29745bcb5c..24a163f9d4 100644 --- a/gnucash/gnome-utils/gnc-main-window.cpp +++ b/gnucash/gnome-utils/gnc-main-window.cpp @@ -219,8 +219,12 @@ typedef struct GncMainWindowPrivate * manager and stored here when the UI manager provides them * to the main window. */ GtkWidget *menu_dock; - /** The toolbar created by the UI manager. This pointer - * provides easy access for showing/hiding the toolbar. */ + /** The menubar */ + GtkWidget *menubar; //FIXMEb added + /** The menubar_model */ + GMenuModel *menubar_model; //FIXMEb added + /** The toolbar. This pointer provides easy access for + * showing/hiding the toolbar. */ GtkWidget *toolbar; /** The notebook containing all the pages in this window. */ GtkWidget *notebook; @@ -2020,12 +2024,13 @@ gnc_main_window_update_all_menu_items (void) ENTER(""); /* First update the entries for all existing windows */ - g_list_foreach(active_windows, - (GFunc)gnc_main_window_update_menu_item, - nullptr); - g_list_foreach(active_windows, - (GFunc)gnc_main_window_update_radio_button, - nullptr); + g_list_foreach (active_windows, + (GFunc)gnc_main_window_update_menu_item, + nullptr); + + g_list_foreach (active_windows, + (GFunc)gnc_main_window_update_radio_button, + nullptr); /* Now hide any entries that aren't being used. */ //FIXMEb @@ -3589,21 +3594,49 @@ gnc_main_window_actions_updated (GncMainWindow *window) // g_object_unref(force); } + +struct group_iterate +{ + GAction *action; + const gchar *name; +}; + +static void +group_foreach_cb (gpointer key, gpointer item, gpointer arg) +{ + struct group_iterate *iter = static_cast(arg); + GAction *action; + + if (iter->action) + return; + + auto entry{static_cast(item)}; + + action = g_action_map_lookup_action (G_ACTION_MAP(entry->simple_action_group), + iter->name); + + if (action) + iter->action = action; +} GAction * gnc_main_window_find_action (GncMainWindow *window, const gchar *name) { + GncMainWindowPrivate *priv; GAction *action = nullptr; - const GList *groups, *tmp; + struct group_iterate iter; -//FIXMEb groups = gtk_ui_manager_get_action_groups(window->ui_merge); -// for (tmp = groups; tmp; tmp = g_list_next(tmp)) -// { -// action = g_action_map_lookup_action (G_ACTION_MAP(tmp->data), name); -// if (action) -// break; -// } - return action; + priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); + + if (priv->merged_actions_table == nullptr) + return nullptr; + + iter.action = nullptr; + iter.name = name; + + g_hash_table_foreach (priv->merged_actions_table, group_foreach_cb, &iter); + + return iter.action; } @@ -3632,6 +3665,7 @@ gnc_main_window_get_action_group (GncMainWindow *window, } + static void gnc_main_window_update_tab_position (gpointer prefs, gchar *pref, gpointer user_data) { @@ -3814,12 +3848,15 @@ gnc_main_window_window_menu (GncMainWindow *window) #endif GError *error = nullptr; g_assert(filename); - merge_id = gtk_ui_manager_add_ui_from_file(window->ui_merge, filename, - &error); + merge_id = gtk_ui_manager_add_ui_from_file (window->ui_merge, filename, + &error); g_free(filename); g_assert(merge_id); #ifndef MAC_INTEGRATION priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); + +//FIXMEb Not sure what here, may need to move some stuff from below. + //FIXMEb gtk_action_group_add_radio_actions (priv->action_group, // radio_entries, n_radio_entries, // 0, @@ -3851,9 +3888,6 @@ gnc_main_window_setup_window (GncMainWindow *window) GList *plugins; GError *error = nullptr; gchar *filename; - GMenuModel *menu_model; - GtkWidget *menu_bar; - GtkToolbar *tool_bar; ENTER(" "); @@ -3914,15 +3948,15 @@ gnc_main_window_setup_window (GncMainWindow *window) return; //FIXMEb this may need changing } - menu_model = (GMenuModel *)gtk_builder_get_object (builder, "mainwin-menu"); - menu_bar = gtk_menu_bar_new_from_model (menu_model); - gtk_container_add (GTK_CONTAINER(priv->menu_dock), menu_bar); //FIXMEb this may need changing - gtk_widget_show (menu_bar); + priv->menubar_model = (GMenuModel *)gtk_builder_get_object (builder, "mainwin-menu"); + priv->menubar = gtk_menu_bar_new_from_model (priv->menubar_model); + gtk_container_add (GTK_CONTAINER(priv->menu_dock), priv->menubar); //FIXMEb this may need changing + gtk_widget_show (GTK_WIDGET(priv->menubar)); - tool_bar = (GtkToolbar *)gtk_builder_get_object (builder, "mainwin-toolbar"); - g_object_set (tool_bar, "toolbar-style", GTK_TOOLBAR_BOTH, NULL); - gtk_container_add (GTK_CONTAINER(priv->menu_dock), GTK_WIDGET(tool_bar)); //FIXMEb this may need changing - gtk_widget_show (GTK_WIDGET(tool_bar)); + priv->toolbar = (GtkWidget *)gtk_builder_get_object (builder, "mainwin-toolbar"); + g_object_set (priv->toolbar, "toolbar-style", GTK_TOOLBAR_BOTH, NULL); + gtk_container_add (GTK_CONTAINER(priv->menu_dock), GTK_WIDGET(priv->toolbar)); //FIXMEb this may need changing + gtk_widget_show (GTK_WIDGET(priv->toolbar)); //FIXMEb window->ui_merge = gtk_ui_manager_new (); @@ -3974,12 +4008,6 @@ gnc_main_window_setup_window (GncMainWindow *window) // g_assert(merge_id || error); // if (merge_id) // { -//FIXMEb gtk_action_group_add_radio_actions (priv->action_group, -// tab_pos_radio_entries, -// n_tab_pos_radio_entries, -// 0, -// G_CALLBACK(gnc_main_window_cmd_view_tab_position), -// window); //FIXMEb gtk_window_add_accel_group (GTK_WINDOW (window), // gtk_ui_manager_get_accel_group(window->ui_merge)); @@ -5318,11 +5346,52 @@ gnc_main_window_all_action_set_sensitive (const gchar *action_name, } } -//GtkUIManager *gnc_main_window_get_uimanager (GncMainWindow *window) -//{ -// g_assert(window); -// return window->ui_merge; -//} +GtkWidget * +gnc_main_window_get_menu (GncMainWindow *window) +{ + GncMainWindowPrivate *priv; + + g_return_val_if_fail (GNC_IS_MAIN_WINDOW(window), nullptr); + + priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); + + return priv->menubar; +} + + +GMenuModel * +gnc_main_window_get_menu_model (GncMainWindow *window) +{ + GncMainWindowPrivate *priv; + + g_return_val_if_fail (GNC_IS_MAIN_WINDOW(window), nullptr); + + priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); + + return priv->menubar_model; +} + +void +gnc_main_window_update_toolbar (GncMainWindow *window, GncPluginPage *page) +{ + GncMainWindowPrivate *priv; + GtkBuilder *builder; + + g_return_if_fail (GNC_IS_MAIN_WINDOW(window)); + g_return_if_fail (GNC_IS_PLUGIN_PAGE(page)); + + priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); + + builder = gnc_plugin_page_get_builder (page); + + if (builder) + { + gtk_container_remove (GTK_CONTAINER(priv->menu_dock), priv->toolbar); + priv->toolbar = (GtkWidget *)gtk_builder_get_object (builder, "mainwin-toolbar"); + g_object_set (priv->toolbar, "toolbar-style", GTK_TOOLBAR_BOTH, NULL); + gtk_container_add (GTK_CONTAINER(priv->menu_dock), priv->toolbar); + } +} /** @} */ /** @} */ diff --git a/gnucash/gnome-utils/gnc-main-window.h b/gnucash/gnome-utils/gnc-main-window.h index e4300f53d9..2e800fc305 100644 --- a/gnucash/gnome-utils/gnc-main-window.h +++ b/gnucash/gnome-utils/gnc-main-window.h @@ -173,12 +173,6 @@ void gnc_main_window_foreach_page (GncMainWindowPageFunc fn, */ GncPluginPage *gnc_main_window_get_current_page (GncMainWindow *window); - -/** Returns the pointer to the GtkUIManager which is used for the menu - * item merging. */ -GtkUIManager *gnc_main_window_get_uimanager (GncMainWindow *window); - - /** Update the name of the page in the main window. * * @param page The page to be updated. @@ -188,7 +182,6 @@ void main_window_update_page_name (GncPluginPage *page, const gchar *name_in); - /** Update the color on the page tabs in the main window. * * @param page The page to be updated. @@ -434,6 +427,12 @@ void gnc_main_window_all_action_set_sensitive (const gchar *action_name, gboolea */ GAction *gnc_main_window_find_action (GncMainWindow *window, const gchar *name); +GtkWidget *gnc_main_window_get_menu (GncMainWindow *window); //FIXMEb added + +GMenuModel *gnc_main_window_get_menu_model (GncMainWindow *window); //FIXMEb added + +void gnc_main_window_update_toolbar (GncMainWindow *window, GncPluginPage *page); //FIXMEb added + /** * Shows all main windows. **/ diff --git a/gnucash/gnome-utils/gnc-plugin-page.c b/gnucash/gnome-utils/gnc-plugin-page.c index dc3eebb592..2bf79ad0f1 100644 --- a/gnucash/gnome-utils/gnc-plugin-page.c +++ b/gnucash/gnome-utils/gnc-plugin-page.c @@ -98,6 +98,8 @@ typedef struct _GncPluginPagePrivate GtkBuilder *builder; //FIXMEb added GSimpleActionGroup *simple_action_group; //FIXMEb added + const gchar *simple_action_group_name; //FIXMEb added + GtkAccelGroup *accel_group; //FIXMEb added GList *books; @@ -272,6 +274,34 @@ gnc_plugin_page_merge_actions (GncPluginPage *page, priv->ui_description); } +void +gnc_plugin_page_merge_actionsb (GncPluginPage *page, + GtkWidget *window) +{ + GncPluginPagePrivate *priv; + GError *error = NULL; + gchar *resource; + + g_return_if_fail (GNC_IS_PLUGIN_PAGE(page)); + + priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page); + + priv->builder = gtk_builder_new (); + + resource = g_strconcat ("/org/gnucash/ui/", priv->ui_description, NULL); + + gtk_builder_set_translation_domain (priv->builder, PROJECT_NAME); + + gtk_builder_add_from_resource (priv->builder, resource, &error); + + if (error) + { + g_critical ("Failed to load ui resource %s, Error %s", resource, error->message); + g_error_free (error); + } + g_free (resource); +} + /* Remove the actions for a content page from the specified window. */ void @@ -522,6 +552,7 @@ gnc_plugin_page_init (GncPluginPage *page, void *data) priv->uri = NULL; priv->page_changed_id = 0; priv->focus_source_id = 0; + priv->accel_group = NULL; page->window = NULL; page->summarybar = NULL; @@ -1074,6 +1105,29 @@ gnc_plugin_page_get_ui_description (GncPluginPage *page) } +const gchar * +gnc_plugin_page_get_simple_action_group_name (GncPluginPage *page) +{ + GncPluginPagePrivate *priv; + + g_return_val_if_fail (GNC_IS_PLUGIN_PAGE(page), NULL); + + priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page); + + return priv->simple_action_group_name; + +// GncPluginPageClass *klass; + +// g_return_val_if_fail (GNC_IS_PLUGIN_PAGE(page), NULL); +// klass = GNC_PLUGIN_PAGE_GET_CLASS(page); + +// if (klass->actions_name) +// return klass->actions_name; +// else +// return NULL; +} + + /* Set an alternate UI for the specified page. This alternate ui * may only use actions specified in the source for the page. */ void @@ -1144,15 +1198,26 @@ gnc_plugin_page_create_action_group (GncPluginPage *page, const gchar *group_nam GSimpleActionGroup * gnc_plugin_page_create_action_groupb (GncPluginPage *page, const gchar *group_name) { - GncPluginPagePrivate *priv; - GSimpleActionGroup *simple_action_group; + GncPluginPagePrivate *priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page); + + priv->simple_action_group = g_simple_action_group_new (); + priv->simple_action_group_name = group_name; - priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page); - simple_action_group = g_simple_action_group_new (); - priv->simple_action_group = simple_action_group; - return simple_action_group; + return priv->simple_action_group; } +GtkAccelGroup * +gnc_plugin_page_get_accel_group (GncPluginPage *page) +{ + GncPluginPagePrivate *priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page); + + if (priv->accel_group == NULL) + priv->accel_group = gtk_accel_group_new (); + + return priv->accel_group; +} + + gboolean gnc_plugin_page_finish_pending (GncPluginPage *page) { diff --git a/gnucash/gnome-utils/gnc-plugin-page.h b/gnucash/gnome-utils/gnc-plugin-page.h index 959e30e985..f2d03d2f68 100644 --- a/gnucash/gnome-utils/gnc-plugin-page.h +++ b/gnucash/gnome-utils/gnc-plugin-page.h @@ -87,6 +87,11 @@ typedef struct /** The textual name of this plugin. */ const gchar *plugin_name; + /** A name for the set of actions that will be added by this + * plugin. The actual name is irrelevant, as long as it is + * unique within GnuCash. */ + const gchar *actions_name; //FIXMEb added + /* Signals */ void (* inserted) (GncPluginPage *plugin_page); void (* removed) (GncPluginPage *plugin_page); @@ -290,7 +295,8 @@ GncPluginPage *gnc_plugin_page_recreate_page (GtkWidget *window, */ void gnc_plugin_page_merge_actions (GncPluginPage *plugin_page, GtkUIManager *merge); - +void gnc_plugin_page_merge_actionsb (GncPluginPage *plugin_page, + GtkWidget *window); //FIXMEb added /** Remove the actions for a content page from the specified window. * @@ -510,6 +516,7 @@ void gnc_plugin_page_set_use_new_window (GncPluginPage *page, */ const char *gnc_plugin_page_get_ui_description (GncPluginPage *page); +const gchar *gnc_plugin_page_get_simple_action_group_name (GncPluginPage *page); //FIXMEb added /** Set an alternate UI for the specified page. This alternate ui * may only use actions specified in the source for the page. @@ -530,7 +537,7 @@ void gnc_plugin_page_set_ui_description (GncPluginPage *page, * @param page The page whose UI information should be retrieved. * * @return A pointer to the GtkBuilder object for this page. */ -GtkBuilder *gnc_plugin_page_get_builder (GncPluginPage *page); +GtkBuilder *gnc_plugin_page_get_builder (GncPluginPage *page); //FIXMEb added /** Retrieve the GtkActionGroup object associated with this page. @@ -543,6 +550,10 @@ GtkBuilder *gnc_plugin_page_get_builder (GncPluginPage *page); GtkActionGroup *gnc_plugin_page_get_action_group (GncPluginPage *page); GSimpleActionGroup *gnc_plugin_page_get_action_groupb (GncPluginPage *page); //FIXMEb added + + +GtkAccelGroup *gnc_plugin_page_get_accel_group (GncPluginPage *page); //FIXMEb added + /** Create the GtkActionGroup object associated with this page. * * @param page The page whose menu/toolbar action group should be diff --git a/gnucash/gnome-utils/gnc-plugin.c b/gnucash/gnome-utils/gnc-plugin.c index 50bd3bb140..c16e5fd3ac 100644 --- a/gnucash/gnome-utils/gnc-plugin.c +++ b/gnucash/gnome-utils/gnc-plugin.c @@ -301,26 +301,30 @@ gnc_plugin_update_actions (GtkActionGroup *action_group, } void gnc_plugin_update_actionsb (GSimpleActionGroup *simple_action_group, - const gchar **action_names, - const gchar *property_name, - gboolean value) + const gchar **action_names, + const gchar *property_name, + gboolean value) { - GAction *action; - gint i; - + GAction *action; + gint i; for (i = 0; action_names[i]; i++) { action = g_action_map_lookup_action (G_ACTION_MAP(simple_action_group), action_names[i]); if (action) { -//FIXMEb g_object_set (G_OBJECT(action), property_name, value, NULL); +//FIXMEb property_name could be 'sensitive' or 'visible' + if (g_strcmp0 (property_name, "sensitive") == 0) + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), value); + else + { +//FIXMEb visible is done on the menu item, could also be linked to the action being sensitive + } } else { -//FIXMEb g_warning("No such action with name '%s' in action group %s (size %d)", -// action_names[i], gtk_action_group_get_name(simple_action_group), -// g_list_length(gtk_action_group_list_actions(simple_action_group))); + g_warning ("No such action with name '%s' in action group %p)", + action_names[i], simple_action_group); } } } From 3aab744fe7aee0a3914d6a777cb38623e3ba0507 Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Fri, 28 Oct 2022 16:12:18 +0100 Subject: [PATCH 07/77] Initial change to add default plugin menu items --- gnucash/gnome-utils/gnc-main-window.cpp | 62 +++++++++++++++++++++---- gnucash/gnome-utils/gnc-main-window.h | 9 +++- gnucash/gnome-utils/gnc-plugin.c | 1 + gnucash/gnome-utils/gnc-plugin.h | 4 ++ 4 files changed, 65 insertions(+), 11 deletions(-) diff --git a/gnucash/gnome-utils/gnc-main-window.cpp b/gnucash/gnome-utils/gnc-main-window.cpp index 24a163f9d4..57e05d017f 100644 --- a/gnucash/gnome-utils/gnc-main-window.cpp +++ b/gnucash/gnome-utils/gnc-main-window.cpp @@ -3470,6 +3470,53 @@ gnc_main_window_manual_merge_actions (GncMainWindow *window, } +static void +update_menu_model (GncMainWindow *window, const gchar *ui_filename, + const gchar **ui_updates) +{ + GncMainWindowPrivate *priv; + GError *error = nullptr; + const gchar *resource = "/org/gnucash/"; + gchar *res_name; + GtkBuilder *builder = gtk_builder_new (); + GMenuModel *menu_model_part; + GncMenuModelSearch *gsm = g_new0 (GncMenuModelSearch, 1); + + g_return_if_fail (GNC_IS_MAIN_WINDOW (window)); + g_return_if_fail (ui_filename != nullptr); + g_return_if_fail (ui_updates != nullptr); + + priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); + + gtk_builder_set_translation_domain (builder, PROJECT_NAME); + res_name = g_strconcat ("/org/gnucash/ui/", ui_filename, NULL); + + gtk_builder_add_from_resource (builder, res_name, &error); + + if (error) + { + g_critical ("Failed to load, Error %s", error->message); + g_error_free (error); + return; //FIXMEb this may need changing + } + + for (gint i = 0; ui_updates[i]; i++) + { + menu_model_part = (GMenuModel *)gtk_builder_get_object (builder, ui_updates[i]); + + gsm->search_action_label = nullptr; + gsm->search_action_name = ui_updates[i]; + + if (gnc_menubar_model_find_item (priv->menubar_model, gsm)) + g_menu_insert_section (G_MENU(gsm->model), gsm->index, NULL, G_MENU_MODEL(menu_model_part)); + else + PERR("Could not find '%s' in menu model", ui_updates[i]); + } + g_free (gsm); + g_object_unref (builder); +} + + /* Add a set of actions to the specified window. This function * should not need to be called directly by plugin implementors. * Correctly assigning values to the GncPluginClass fields during @@ -3483,24 +3530,17 @@ gnc_main_window_merge_actions (GncMainWindow *window, guint n_actions, GncDisplayItem *display_items, guint n_display_items, - const gchar *filename, + const gchar **ui_updates, + const gchar *ui_filename, gpointer user_data) { GncMainWindowPrivate *priv; GncMainWindowActionData *data; - GError *error = nullptr; - const gchar *resource = "/org/gnucash/"; - gchar *pathname; g_return_if_fail (GNC_IS_MAIN_WINDOW (window)); g_return_if_fail (group_name != nullptr); g_return_if_fail (actions != nullptr); g_return_if_fail (n_actions > 0); - g_return_if_fail (filename != nullptr); - - pathname = g_strconcat (resource, filename, nullptr); - if (pathname == nullptr) - return; data = g_new0 (GncMainWindowActionData, 1); data->window = window; @@ -3518,6 +3558,8 @@ gnc_main_window_merge_actions (GncMainWindow *window, gtk_widget_insert_action_group (GTK_WIDGET(window), group_name, G_ACTION_GROUP(entry->simple_action_group)); + update_menu_model (window, ui_filename, ui_updates); + //FIXMEb this is where I might need to add GtkBuilder???? @@ -3594,7 +3636,7 @@ gnc_main_window_actions_updated (GncMainWindow *window) // g_object_unref(force); } - + struct group_iterate { GAction *action; diff --git a/gnucash/gnome-utils/gnc-main-window.h b/gnucash/gnome-utils/gnc-main-window.h index 2e800fc305..61abce5119 100644 --- a/gnucash/gnome-utils/gnc-main-window.h +++ b/gnucash/gnome-utils/gnc-main-window.h @@ -64,6 +64,12 @@ typedef struct const gchar *tooltip; } GncDisplayItem; +typedef struct +{ + const gchar *actions; + const gchar *update_type; +} GncMenuUpdate; + /** The instance data structure for a main window object. */ typedef struct GncMainWindow { @@ -259,7 +265,8 @@ void gnc_main_window_merge_actions (GncMainWindow *window, guint n_entries, GncDisplayItem *display_items, guint n_display_items, - const gchar *filename, + const gchar **ui_updates, + const gchar *ui_filename, gpointer user_data); diff --git a/gnucash/gnome-utils/gnc-plugin.c b/gnucash/gnome-utils/gnc-plugin.c index c16e5fd3ac..b2cb4dfcbb 100644 --- a/gnucash/gnome-utils/gnc-plugin.c +++ b/gnucash/gnome-utils/gnc-plugin.c @@ -147,6 +147,7 @@ gnc_plugin_add_to_window (GncPlugin *plugin, gnc_main_window_merge_actions (window, klass->actions_name, klass->actionsb, klass->n_actionsb, klass->display_items, klass->n_display_items, + klass->ui_updates, klass->ui_filename, plugin); if (klass->important_actions) diff --git a/gnucash/gnome-utils/gnc-plugin.h b/gnucash/gnome-utils/gnc-plugin.h index 67662abcad..dc69f2e938 100644 --- a/gnucash/gnome-utils/gnc-plugin.h +++ b/gnucash/gnome-utils/gnc-plugin.h @@ -128,6 +128,10 @@ typedef struct /** The number of display_items in the display item array. */ guint n_display_items; //FIXMEb added + /** An array of ui updates for the menu model */ + const gchar **ui_updates; //FIXMEb added + + GtkActionEntry *actions; /** The number of actions in the actions array. */ guint n_actions; From 3f5767c1ff6726cc146ab907ae79c92d2bbc434f Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Fri, 28 Oct 2022 16:12:57 +0100 Subject: [PATCH 08/77] Add gnc-plugin-basic-commands menu items --- gnucash/gnome/gnc-plugin-basic-commands.c | 115 +++----------------- gnucash/gnucash-gresources.xml | 1 + gnucash/ui/gnc-plugin-basic-commands.ui | 123 ++++++++++++++++++++++ 3 files changed, 136 insertions(+), 103 deletions(-) create mode 100644 gnucash/ui/gnc-plugin-basic-commands.ui diff --git a/gnucash/gnome/gnc-plugin-basic-commands.c b/gnucash/gnome/gnc-plugin-basic-commands.c index 47697990da..8935a7fabf 100644 --- a/gnucash/gnome/gnc-plugin-basic-commands.c +++ b/gnucash/gnome/gnc-plugin-basic-commands.c @@ -131,108 +131,18 @@ static GActionEntry gnc_plugin_actions [] = /** The number of actions provided by this plugin. */ static guint gnc_plugin_n_actions = G_N_ELEMENTS(gnc_plugin_actions); -static GncDisplayItem gnc_plugin_display_items [] = +/** The default menu items that need to be add to the menu */ +static const gchar *gnc_plugin_load_ui_items [] = { - /* File menu */ - { - "FileNewAction", "document-new", N_("New _File"), "n", - N_("Create a new file") - }, - { - "FileOpenAction", "document-open", N_("_Open..."), "o", - N_("Open an existing GnuCash file") - }, - { - "FileSaveAction", "document-save", N_("_Save"), "s", - N_("Save the current file") - }, - { - "FileSaveAsAction", "document-save-as", N_("Save _As..."), "s", - N_("Save this file with a different name") - }, - { - "FileRevertAction", "document-revert", N_("Re_vert"), NULL, - N_("Reload the current database, reverting all unsaved changes") - }, - { - "FileExportAccountsAction", "go-next", - N_("Export _Accounts"), NULL, - N_("Export the account hierarchy to a new GnuCash datafile") - }, - - /* Edit menu */ - { - "EditFindTransactionsAction", "edit-find", N_("_Find..."), "f", - N_("Find transactions with a search") - }, - { - "EditTaxOptionsAction", NULL, - /* Translators: remember to reuse this - translation in dialog-account.glade */ - N_("Ta_x Report Options"), NULL, - /* Translators: currently implemented are - US: income tax and - DE: VAT - So adjust this string */ - N_("Setup relevant accounts for tax reports, e.g. US income tax") - }, - - /* Actions menu */ - { "ActionsScheduledTransactionsAction", NULL, N_("_Scheduled Transactions"), NULL, NULL }, - { - "ActionsScheduledTransactionEditorAction", NULL, N_("_Scheduled Transaction Editor"), NULL, - N_("The list of Scheduled Transactions") - }, - { - "ActionsSinceLastRunAction", NULL, N_("Since _Last Run..."), NULL, - N_("Create Scheduled Transactions since the last time run") - }, - { - "ActionsMortgageLoanAction", NULL, N_("_Mortgage & Loan Repayment..."), NULL, - N_("Setup scheduled transactions for repayment of a loan") - }, - { "ActionsBudgetAction", NULL, N_("B_udget"), NULL, NULL }, -#ifdef CLOSE_BOOKS_ACTUALLY_WORKS - { - "ActionsCloseBooksAction", NULL, N_("Close _Books"), NULL, - N_("Archive old data using accounting periods") - }, -#endif // CLOSE_BOOKS_ACTUALLY_WORKS - - /* Tools menu */ - { - "ToolsPriceEditorAction", NULL, N_("_Price Database"), NULL, - N_("View and edit the prices for stocks and mutual funds") - }, - { - "ToolsCommodityEditorAction", NULL, N_("_Security Editor"), NULL, - N_("View and edit the commodities for stocks and mutual funds") - }, - { - "ToolsFinancialCalculatorAction", NULL, N_("_Loan Repayment Calculator"), NULL, - N_("Use the loan/mortgage repayment calculator") - }, - { - "ToolsBookCloseAction", NULL, N_("_Close Book"), NULL, - N_("Close the Book at the end of the Period") - }, - { - "ToolsImapEditorAction", NULL, N_("_Import Map Editor"), NULL, - N_("View and Delete Bayesian and non-Bayesian information") - }, - { - "ToolsTransLinkedDocsAction", NULL, N_("_Transaction Linked Documents"), NULL, - N_("View all Transaction Linked Documents") - }, - - /* Help menu */ - { - "HelpTipsOfTheDayAction", NULL, N_("_Tips Of The Day"), NULL, - N_("View the Tips of the Day") - }, + "FilePlaceholder0", + "FilePlaceholder2", + "FilePlaceholder4", + "EditPlaceholder5", + "ActionsPlaceholder2", + "ToolsPlaceholder1", + "HelpPlaceholder1", + NULL, }; -/** The number of display items provided by this plugin. */ -static guint gnc_plugin_n_display_items = G_N_ELEMENTS(gnc_plugin_display_items); /** These are the "important" actions provided by the basic commands * plugin. Their labels will appear when the toolbar is set to @@ -321,7 +231,7 @@ gnc_plugin_basic_commands_add_to_window (GncPlugin *plugin, GncMainWindow *window, GQuark type) { - GSimpleActionGroup *simple_action_group = + GSimpleActionGroup *simple_action_group = gnc_main_window_get_action_group (window, PLUGIN_ACTIONS_NAME); gnc_plugin_update_actionsb (simple_action_group, @@ -402,10 +312,9 @@ gnc_plugin_basic_commands_class_init (GncPluginBasicCommandsClass *klass) plugin_class->actions_name = PLUGIN_ACTIONS_NAME; plugin_class->actionsb = gnc_plugin_actions; plugin_class->n_actionsb = gnc_plugin_n_actions; - plugin_class->display_items = gnc_plugin_display_items; - plugin_class->n_display_items = gnc_plugin_n_display_items; plugin_class->important_actions = gnc_plugin_important_actions; plugin_class->ui_filename = PLUGIN_UI_FILENAME; + plugin_class->ui_updates = gnc_plugin_load_ui_items; } diff --git a/gnucash/gnucash-gresources.xml b/gnucash/gnucash-gresources.xml index 33453eba80..6cd1b60dbf 100644 --- a/gnucash/gnucash-gresources.xml +++ b/gnucash/gnucash-gresources.xml @@ -5,5 +5,6 @@ gnucash.css gnucash-fallback.css ui/gnc-main-window.ui + ui/gnc-plugin-basic-commands.ui diff --git a/gnucash/ui/gnc-plugin-basic-commands.ui b/gnucash/ui/gnc-plugin-basic-commands.ui new file mode 100644 index 0000000000..ad4648893a --- /dev/null +++ b/gnucash/ui/gnc-plugin-basic-commands.ui @@ -0,0 +1,123 @@ + + + + + + New _File + gnc-plugin-basic-commands-actions.FileNewAction + <Primary>n + Create a new file + + + _Open... + gnc-plugin-basic-commands-actions.FileOpenAction + <Primary>o + Open an existing GnuCash file + + + + + + _Save + gnc-plugin-basic-commands-actions.FileSaveAction + <Primary>s + Save the current file + + + Save _As... + gnc-plugin-basic-commands-actions.FileSaveAsAction + <Primary><Shift>s + Save this file with a different name + + + Re_vert + gnc-plugin-basic-commands-actions.FileRevertAction + Reload the current database, reverting all unsaved changes + + + + + + Export _Accounts + gnc-plugin-basic-commands-actions.FileExportAccountsAction + Export the account hierarchy to a new GnuCash datafile + + + + + + + Ta_x Report Options + gnc-plugin-basic-commands-actions.EditTaxOptionsAction + + Setup relevant accounts for tax reports, e.g. US income tax + yes + + + + + + _Scheduled Transactions + gnc-plugin-basic-commands-actions.ActionsScheduledTransactionsAction +
+ + _Scheduled Transaction Editor + gnc-plugin-basic-commands-actions.ActionsScheduledTransactionEditorAction + The list of Scheduled Transactions + + + Since _Last Run... + gnc-plugin-basic-commands-actions.ActionsSinceLastRunAction + Create Scheduled Transactions since the last time run + + + _Mortgage & Loan Repayment... + gnc-plugin-basic-commands-actions.ActionsMortgageLoanAction + Setup scheduled transactions for repayment of a loan + +
+
+
+ + + + _Price Database + gnc-plugin-basic-commands-actions.ToolsPriceEditorAction + View and edit the prices for stocks and mutual funds + + + _Security Editor + gnc-plugin-basic-commands-actions.ToolsCommodityEditorAction + View and edit the commodities for stocks and mutual funds + + + _Loan Repayment Calculator + gnc-plugin-basic-commands-actions.ToolsFinancialCalculatorAction + Use the loan/mortgage repayment calculator + + + _Close Book + gnc-plugin-basic-commands-actions.ToolsBookCloseAction + Close the Book at the end of the Period + + + _Import Map Editor + gnc-plugin-basic-commands-actions.ToolsImapEditorAction + View and Delete Bayesian and non-Bayesian information + + + _Transaction Linked Documents + gnc-plugin-basic-commands-actions.ToolsTransLinkedDocsAction + View all Transaction Linked Documents + + + + + + _Tips Of The Day + gnc-plugin-basic-commands-actions.HelpTipsOfTheDayAction + View the Tips of the Day + + + +
From 96e25abdce0edbe8363908b2f8274e89976f17b5 Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Sun, 30 Oct 2022 13:28:59 +0000 Subject: [PATCH 09/77] Add similar changes to the rest of the plugins --- gnucash/gnome/gnc-plugin-account-tree.c | 16 +- gnucash/gnome/gnc-plugin-budget.c | 26 +-- gnucash/gnome/gnc-plugin-business.c | 162 +----------------- gnucash/gnome/gnc-plugin-register.c | 14 +- gnucash/gnome/gnc-plugin-report-system.c | 15 +- gnucash/gnucash-gresources.xml | 15 ++ .../import-export/aqb/gnc-plugin-aqbanking.c | 64 +------ .../bi-import/gnc-plugin-bi-import.c | 15 +- .../csv-exp/gnc-plugin-csv-export.c | 23 +-- .../csv-imp/gnc-plugin-csv-import.c | 22 +-- .../gnc-plugin-customer-import.c | 16 +- .../log-replay/gnc-plugin-log-replay.c | 14 +- gnucash/import-export/ofx/gnc-plugin-ofx.c | 14 +- .../qif-imp/gnc-plugin-qif-import.c | 14 +- gnucash/ui/gnc-main-window.ui | 54 +++++- gnucash/ui/gnc-plugin-account-tree.ui | 12 ++ gnucash/ui/gnc-plugin-aqbanking.ui | 69 ++++++++ gnucash/ui/gnc-plugin-bi-import.ui | 12 ++ gnucash/ui/gnc-plugin-budget.ui | 33 ++++ gnucash/ui/gnc-plugin-business.ui | 157 +++++++++++++++++ gnucash/ui/gnc-plugin-csv-export.ui | 22 +++ gnucash/ui/gnc-plugin-csv-import.ui | 22 +++ gnucash/ui/gnc-plugin-customer-import.ui | 12 ++ gnucash/ui/gnc-plugin-log-replay.ui | 12 ++ gnucash/ui/gnc-plugin-ofx.ui | 12 ++ gnucash/ui/gnc-plugin-qif-import.ui | 12 ++ gnucash/ui/gnc-plugin-register.ui | 12 ++ gnucash/ui/gnc-plugin-report-system.ui | 12 ++ 28 files changed, 536 insertions(+), 347 deletions(-) create mode 100644 gnucash/ui/gnc-plugin-account-tree.ui create mode 100644 gnucash/ui/gnc-plugin-aqbanking.ui create mode 100644 gnucash/ui/gnc-plugin-bi-import.ui create mode 100644 gnucash/ui/gnc-plugin-budget.ui create mode 100644 gnucash/ui/gnc-plugin-business.ui create mode 100644 gnucash/ui/gnc-plugin-csv-export.ui create mode 100644 gnucash/ui/gnc-plugin-csv-import.ui create mode 100644 gnucash/ui/gnc-plugin-customer-import.ui create mode 100644 gnucash/ui/gnc-plugin-log-replay.ui create mode 100644 gnucash/ui/gnc-plugin-ofx.ui create mode 100644 gnucash/ui/gnc-plugin-qif-import.ui create mode 100644 gnucash/ui/gnc-plugin-register.ui create mode 100644 gnucash/ui/gnc-plugin-report-system.ui diff --git a/gnucash/gnome/gnc-plugin-account-tree.c b/gnucash/gnome/gnc-plugin-account-tree.c index a13859ba2b..4f392a1894 100644 --- a/gnucash/gnome/gnc-plugin-account-tree.c +++ b/gnucash/gnome/gnc-plugin-account-tree.c @@ -60,15 +60,12 @@ static GActionEntry gnc_plugin_actions [] = /** The number of actions provided by this plugin. */ static guint gnc_plugin_n_actions = G_N_ELEMENTS(gnc_plugin_actions); -static GncDisplayItem gnc_plugin_display_items [] = - { - { - "ViewAccountTreeAction", NULL, N_("New Accounts _Page"), NULL, - N_("Open a new Account Tree page") - }, +/** The default menu items that need to be add to the menu */ +static const gchar *gnc_plugin_load_ui_items [] = +{ + "ViewPlaceholder5", + NULL, }; -/** The number of display items provided by this plugin. */ -static guint gnc_plugin_n_display_items = G_N_ELEMENTS(gnc_plugin_display_items); /** The instance private data structure for an account tree plugin. */ typedef struct GncPluginAccountTreePrivate @@ -125,9 +122,8 @@ gnc_plugin_account_tree_class_init (GncPluginAccountTreeClass *klass) plugin_class->actions_name = PLUGIN_ACTIONS_NAME; plugin_class->actionsb = gnc_plugin_actions; plugin_class->n_actionsb = gnc_plugin_n_actions; - plugin_class->display_items = gnc_plugin_display_items; - plugin_class->n_display_items = gnc_plugin_n_display_items; plugin_class->ui_filename = PLUGIN_UI_FILENAME; + plugin_class->ui_updates = gnc_plugin_load_ui_items; } diff --git a/gnucash/gnome/gnc-plugin-budget.c b/gnucash/gnome/gnc-plugin-budget.c index 9df979f37d..a39b570bb0 100644 --- a/gnucash/gnome/gnc-plugin-budget.c +++ b/gnucash/gnome/gnc-plugin-budget.c @@ -66,27 +66,12 @@ static GActionEntry gnc_plugin_actions [] = /** The number of actions provided by this plugin. */ static guint gnc_plugin_n_actions = G_N_ELEMENTS(gnc_plugin_actions); -static GncDisplayItem gnc_plugin_display_items [] = +/** The default menu items that need to be add to the menu */ +static const gchar *gnc_plugin_load_ui_items [] = { - { - "NewBudgetAction", NULL, N_("_New Budget"), NULL, - N_("Create a new Budget.") - }, - { - "OpenBudgetAction", NULL, N_("_Open Budget"), NULL, - N_("Open an existing Budget in a new tab. If none exists a new budget will be created.") - }, - { - "CopyBudgetAction", NULL, N_("_Copy Budget"), NULL, - N_("Copy an existing Budget.") - }, - { - "DeleteBudgetAction", NULL, N_("_Delete Budget"), NULL, - N_("Delete an existing Budget.") - }, + "ActionsPlaceholder3", + NULL, }; -/** The number of display items provided by this plugin. */ -static guint gnc_plugin_n_display_items = G_N_ELEMENTS(gnc_plugin_display_items); static const gchar *plugin_writeable_actions[] = { @@ -161,9 +146,8 @@ gnc_plugin_budget_class_init (GncPluginBudgetClass *klass) plugin_class->actions_name = PLUGIN_ACTIONS_NAME; plugin_class->actionsb = gnc_plugin_actions; plugin_class->n_actionsb = gnc_plugin_n_actions; - plugin_class->display_items = gnc_plugin_display_items; - plugin_class->n_display_items = gnc_plugin_n_display_items; plugin_class->ui_filename = PLUGIN_UI_FILENAME; + plugin_class->ui_updates = gnc_plugin_load_ui_items; plugin_class->add_to_window = add_to_window; plugin_class->remove_from_window = remove_from_window; diff --git a/gnucash/gnome/gnc-plugin-business.c b/gnucash/gnome/gnc-plugin-business.c index f69869f3c4..5926221e4b 100644 --- a/gnucash/gnome/gnc-plugin-business.c +++ b/gnucash/gnome/gnc-plugin-business.c @@ -161,165 +161,18 @@ static GActionEntry gnc_plugin_actions [] = { "BusinessTestInitDataAction", gnc_plugin_business_cmd_test_init_data, NULL, NULL, NULL }, { "ToolbarNewInvoiceAction", gnc_plugin_business_cmd_customer_new_invoice, NULL, NULL, NULL }, { "RegisterAssignPayment", gnc_plugin_business_cmd_assign_payment, NULL, NULL, NULL }, -//FIXMEb { "RegisterEditPayment", gnc_plugin_business_cmd_assign_payment, NULL, NULL, NULL }, + { "RegisterEditPayment", gnc_plugin_business_cmd_assign_payment, NULL, NULL, NULL }, }; /** The number of actions provided by this plugin. */ static guint gnc_plugin_n_actions = G_N_ELEMENTS(gnc_plugin_actions); -static GncDisplayItem gnc_plugin_display_items [] = +/** The default menu items that need to be add to the menu */ +static const gchar *gnc_plugin_load_ui_items [] = { - /* Toplevel */ - { "BusinessAction", NULL, N_("_Business"), NULL, NULL }, - - /* Customer submenu */ - { "CustomerMenuAction", NULL, N_("_Customer"), NULL, NULL }, - { - "CustomerOverviewPageAction", NULL, N_("Customers Overview"), NULL, - N_("Open a Customer overview page") - }, - { - "CustomerNewCustomerOpenAction", NULL, N_("_New Customer..."), NULL, - N_("Open the New Customer dialog") - }, - { - "CustomerFindCustomerOpenAction", NULL, N_("_Find Customer..."), NULL, - N_("Open the Find Customer dialog") - }, - { - "CustomerNewInvoiceOpenAction", NULL, N_("New _Invoice..."), NULL, - N_("Open the New Invoice dialog") - }, - { - "CustomerFindInvoiceOpenAction", NULL, N_("Find In_voice..."), NULL, - N_("Open the Find Invoice dialog") - }, - { - "CustomerNewJobOpenAction", NULL, N_("New _Job..."), NULL, - N_("Open the New Job dialog") - }, - { - "CustomerFindJobOpenAction", NULL, N_("Find Jo_b..."), NULL, - N_("Open the Find Job dialog") - }, - { - "CustomerProcessPaymentAction", NULL, N_("_Process Payment..."), NULL, - N_("Open the Process Payment dialog") - }, - - /* Vendor submenu */ - { - "VendorOverviewPageAction", NULL, N_("Vendors Overview"), NULL, - N_("Open a Vendor overview page") - }, - { "VendorMenuAction", NULL, N_("_Vendor"), NULL, NULL }, - { - "VendorNewVendorOpenAction", NULL, N_("_New Vendor..."), NULL, - N_("Open the New Vendor dialog") - }, - { - "VendorFindVendorOpenAction", NULL, N_("_Find Vendor..."), NULL, - N_("Open the Find Vendor dialog") - }, - { - "VendorNewBillOpenAction", NULL, N_("New _Bill..."), NULL, - N_("Open the New Bill dialog") - }, - { - "VendorFindBillOpenAction", NULL, N_("Find Bi_ll..."), NULL, - N_("Open the Find Bill dialog") - }, - { - "VendorNewJobOpenAction", NULL, N_("New _Job..."), NULL, - N_("Open the New Job dialog") - }, - { - "VendorFindJobOpenAction", NULL, N_("Find Jo_b..."), NULL, - N_("Open the Find Job dialog") - }, - { - "VendorProcessPaymentAction", NULL, N_("_Process Payment..."), NULL, - N_("Open the Process Payment dialog") - }, - - /* Employee submenu */ - { - "EmployeeOverviewPageAction", NULL, N_("Employees Overview"), NULL, - N_("Open a Employee overview page") - }, - { "EmployeeMenuAction", NULL, N_("_Employee"), NULL, NULL }, - { - "EmployeeNewEmployeeOpenAction", NULL, N_("_New Employee..."), NULL, - N_("Open the New Employee dialog") - }, - { - "EmployeeFindEmployeeOpenAction", NULL, N_("_Find Employee..."), NULL, - N_("Open the Find Employee dialog") - }, - { - "EmployeeNewExpenseVoucherOpenAction", NULL, N_("New _Expense Voucher..."), NULL, - N_("Open the New Expense Voucher dialog") - }, - { - "EmployeeFindExpenseVoucherOpenAction", NULL, N_("Find Expense _Voucher..."), NULL, - N_("Open the Find Expense Voucher dialog") - }, - { - "EmployeeProcessPaymentAction", NULL, N_("_Process Payment..."), NULL, - N_("Open the Process Payment dialog") - }, - - /* Other menu items */ - { - "BusinessLinkedDocsAction", NULL, N_("Business Linked Documents"), NULL, - N_("View all Linked Business Documents") - }, - { - "TaxTablesOpenAction", NULL, N_("Sales _Tax Table"), NULL, - N_("View and edit the list of Sales Tax Tables (GST/VAT)") - }, - { - "BillingTermsOpenAction", NULL, N_("_Billing Terms Editor"), NULL, - N_("View and edit the list of Billing Terms") - }, - { - "BillsDueReminderOpenAction", NULL, N_("Bills _Due Reminder"), NULL, - N_("Open the Bills Due Reminder dialog") - }, - { - "InvoicesDueReminderOpenAction", NULL, N_("Invoices _Due Reminder"), NULL, - N_("Open the Invoices Due Reminder dialog") - }, - { "ExportMenuAction", NULL, N_("E_xport"), NULL, NULL }, - - /* Extensions Menu */ - { "BusinessTestAction", NULL, N_("_Business"), NULL, NULL }, - { - "BusinessTestSearchAction", NULL, N_("Test Search Dialog"), NULL, - N_("Test Search Dialog") - }, - { - "BusinessTestInitDataAction", NULL, N_("Initialize Test Data"), NULL, - N_("Initialize Test Data") - }, - - /* Toolbar */ - { - "ToolbarNewInvoiceAction", GNC_ICON_INVOICE_NEW, N_("New _Invoice..."), NULL, - N_("Open the New Invoice dialog") - }, - - /* Register popup menu */ - { - "RegisterAssignPayment", NULL, N_("Assign as payment..."), NULL, - N_("Assign the selected transaction as payment") - }, - { - "RegisterEditPayment", NULL, N_("Edit payment..."), NULL, - N_("Edit the payment this transaction is a part of") - }, + "BusinessPlaceholder0", + "BusinessPlaceholder1", + NULL, }; -/** The number of display items provided by this plugin. */ -static guint gnc_plugin_n_display_items = G_N_ELEMENTS(gnc_plugin_display_items); /************************************************************ * Plugin Function Implementation * @@ -375,9 +228,8 @@ gnc_plugin_business_class_init (GncPluginBusinessClass *klass) plugin_class->actions_name = PLUGIN_ACTIONS_NAME; plugin_class->actionsb = gnc_plugin_actions; plugin_class->n_actionsb = gnc_plugin_n_actions; - plugin_class->display_items = gnc_plugin_display_items; - plugin_class->n_display_items = gnc_plugin_n_display_items; plugin_class->ui_filename = PLUGIN_UI_FILENAME; + plugin_class->ui_updates = gnc_plugin_load_ui_items; } static void diff --git a/gnucash/gnome/gnc-plugin-register.c b/gnucash/gnome/gnc-plugin-register.c index 6cfdf995f9..bb0c580e91 100644 --- a/gnucash/gnome/gnc-plugin-register.c +++ b/gnucash/gnome/gnc-plugin-register.c @@ -54,15 +54,12 @@ static GActionEntry gnc_plugin_actions [] = /** The number of actions provided by this plugin. */ static guint gnc_plugin_n_actions = G_N_ELEMENTS(gnc_plugin_actions); -static GncDisplayItem gnc_plugin_display_items [] = +/** The default menu items that need to be add to the menu */ +static const gchar *gnc_plugin_load_ui_items [] = { - { - "ToolsGeneralJournalAction", NULL, N_("_General Journal"), NULL, - N_("Open general journal window") - }, + "ToolsPlaceholder2", + NULL, }; -/** The number of display items provided by this plugin. */ -static guint gnc_plugin_n_display_items = G_N_ELEMENTS(gnc_plugin_display_items); typedef struct GncPluginRegisterPrivate { @@ -143,9 +140,8 @@ gnc_plugin_register_class_init (GncPluginRegisterClass *klass) plugin_class->actions_name = PLUGIN_ACTIONS_NAME; plugin_class->actionsb = gnc_plugin_actions; plugin_class->n_actionsb = gnc_plugin_n_actions; - plugin_class->display_items = gnc_plugin_display_items; - plugin_class->n_display_items = gnc_plugin_n_display_items; plugin_class->ui_filename = PLUGIN_UI_FILENAME; + plugin_class->ui_updates = gnc_plugin_load_ui_items; } static void diff --git a/gnucash/gnome/gnc-plugin-report-system.c b/gnucash/gnome/gnc-plugin-report-system.c index 35de4b19f4..e9d55b61f4 100644 --- a/gnucash/gnome/gnc-plugin-report-system.c +++ b/gnucash/gnome/gnc-plugin-report-system.c @@ -56,16 +56,12 @@ static GActionEntry gnc_plugin_actions [] = /** The number of actions provided by this plugin. */ static guint gnc_plugin_n_actions = G_N_ELEMENTS (gnc_plugin_actions); -static GncDisplayItem gnc_plugin_display_items [] = +/** The default menu items that need to be add to the menu */ +static const gchar *gnc_plugin_load_ui_items [] = { - /* Menu Items */ - { - "EditStyleSheetsAction", NULL, N_("St_yle Sheets"), NULL, - N_("Edit report style sheets") - }, + "EditPlaceholder4", + NULL, }; -/** The number of display items provided by this plugin. */ -static guint gnc_plugin_n_display_items = G_N_ELEMENTS (gnc_plugin_display_items); typedef struct GncPluginReportSystemPrivate { @@ -100,9 +96,8 @@ gnc_plugin_report_system_class_init (GncPluginReportSystemClass *klass) plugin_class->actions_name = PLUGIN_ACTIONS_NAME; plugin_class->actionsb = gnc_plugin_actions; plugin_class->n_actionsb = gnc_plugin_n_actions; - plugin_class->display_items = gnc_plugin_display_items; - plugin_class->n_display_items = gnc_plugin_n_display_items; plugin_class->ui_filename = PLUGIN_UI_FILENAME; + plugin_class->ui_updates = gnc_plugin_load_ui_items; } static void diff --git a/gnucash/gnucash-gresources.xml b/gnucash/gnucash-gresources.xml index 6cd1b60dbf..8979d20d7e 100644 --- a/gnucash/gnucash-gresources.xml +++ b/gnucash/gnucash-gresources.xml @@ -5,6 +5,21 @@ gnucash.css gnucash-fallback.css ui/gnc-main-window.ui + ui/gnc-plugin-account-tree.ui ui/gnc-plugin-basic-commands.ui + ui/gnc-plugin-bi-import.ui + ui/gnc-plugin-budget.ui + ui/gnc-plugin-business.ui + ui/gnc-plugin-csv-export.ui + ui/gnc-plugin-csv-import.ui + ui/gnc-plugin-customer-import.ui + ui/gnc-plugin-log-replay.ui + ui/gnc-plugin-register.ui + ui/gnc-plugin-report-system.ui + + ui/gnc-plugin-ofx.ui + ui/gnc-plugin-aqbanking.ui + + ui/gnc-plugin-qif-import.ui diff --git a/gnucash/import-export/aqb/gnc-plugin-aqbanking.c b/gnucash/import-export/aqb/gnc-plugin-aqbanking.c index 57d2ed2fe8..1fd4b69ab7 100644 --- a/gnucash/import-export/aqb/gnc-plugin-aqbanking.c +++ b/gnucash/import-export/aqb/gnc-plugin-aqbanking.c @@ -100,67 +100,20 @@ static GActionEntry gnc_plugin_actions [] = { "ABIssueSepaIntTransAction", gnc_plugin_ab_cmd_issue_sepainternaltransaction, NULL, NULL, NULL }, { "ABIssueIntTransAction", gnc_plugin_ab_cmd_issue_inttransaction, NULL, NULL, NULL }, { "ABIssueSepaDirectDebitAction", gnc_plugin_ab_cmd_issue_sepa_direct_debit, NULL, NULL, NULL }, - { "Mt940ImportAction", gnc_plugin_ab_cmd_mt940_import, NULL, NULL, NULL }, - { "Mt942ImportAction", gnc_plugin_ab_cmd_mt942_import, NULL, NULL, NULL }, - { "DtausImportAction", gnc_plugin_ab_cmd_dtaus_import, NULL, NULL, NULL }, - { "DtausImportSendAction", gnc_plugin_ab_cmd_dtaus_importsend, NULL, NULL, NULL }, + { "AQBankingImportAction", gnc_plugin_ab_cmd_aqb_import, NULL, NULL, NULL }, { MENU_TOGGLE_ACTION_AB_VIEW_LOGWINDOW, gnc_plugin_ab_cmd_view_logwindow, NULL, "true", change_state_logwindow }, }; /** The number of actions provided by this plugin. */ static guint gnc_plugin_n_actions = G_N_ELEMENTS(gnc_plugin_actions); -static GncDisplayItem gnc_plugin_display_items [] = +/** The default menu items that need to be add to the menu */ +static const gchar *gnc_plugin_load_ui_items [] = { - /* Menus */ - { "OnlineActionsAction", NULL, N_("_Online Actions"), NULL, NULL }, - - /* Menu Items */ - { - "ABSetupAction", NULL, N_("_Online Banking Setup..."), NULL, - N_("Initial setup of Online Banking access (HBCI, or OFX DirectConnect, using AqBanking)") - }, - { - "ABGetBalanceAction", NULL, N_("Get _Balance"), NULL, - N_("Get the account balance online through Online Banking") - }, - { - "ABGetTransAction", NULL, N_("Get _Transactions..."), NULL, - N_("Get the transactions online through Online Banking") - }, - { - "ABIssueSepaTransAction", NULL, - /* Translators: https://en.wikipedia.org/wiki/Single_Euro_Payments_Area */ - N_("Issue _SEPA Transaction..."), NULL, - N_("Issue a new international European (SEPA) transaction online through Online Banking") - }, - { - "ABIssueSepaIntTransAction", NULL, - N_("Issue SEPA I_nternal Transaction..."), NULL, - N_("Issue a new internal European (SEPA) transaction online through Online Banking") - }, - { - "ABIssueIntTransAction", NULL, N_("_Internal Transaction..."), NULL, - N_("Issue a new bank-internal transaction online through Online Banking") - }, - { - "ABIssueSepaDirectDebitAction", NULL, N_("Issue SEPA Direct _Debit..."), NULL, - N_("Issue a new international European (SEPA) direct debit note online through Online Banking") - }, - - /* File -> Import menu item */ - { - "AQBankingImportAction", "go-previous", N_("Import using AQBanking"), - NULL, N_("Import into GnuCash any file format supported by AQBanking."), - G_CALLBACK(gnc_plugin_ab_cmd_aqb_import) - }, - { - MENU_TOGGLE_ACTION_AB_VIEW_LOGWINDOW, NULL, - N_("Show _log window"), NULL, - N_("Show the online banking log window.") - }, + "FilePlaceholder1", + "ToolsPlaceholder0", + "ActionsPlaceholder1", + NULL, }; -/** The number of display items provided by this plugin. */ -static guint gnc_plugin_n_display_items = G_N_ELEMENTS(gnc_plugin_display_items); static const gchar *need_account_actions[] = { @@ -216,9 +169,8 @@ gnc_plugin_aqbanking_class_init(GncPluginAqBankingClass *klass) plugin_class->actions_name = PLUGIN_ACTIONS_NAME; plugin_class->actionsb = gnc_plugin_actions; plugin_class->n_actionsb = gnc_plugin_n_actions; - plugin_class->display_items = gnc_plugin_display_items; - plugin_class->n_display_items = gnc_plugin_n_display_items; plugin_class->ui_filename = PLUGIN_UI_FILENAME; + plugin_class->ui_updates = gnc_plugin_load_ui_items; plugin_class->add_to_window = gnc_plugin_aqbanking_add_to_window; plugin_class->remove_from_window = gnc_plugin_aqbanking_remove_from_window; } diff --git a/gnucash/import-export/bi-import/gnc-plugin-bi-import.c b/gnucash/import-export/bi-import/gnc-plugin-bi-import.c index aad0903f46..dd8c60e5ba 100644 --- a/gnucash/import-export/bi-import/gnc-plugin-bi-import.c +++ b/gnucash/import-export/bi-import/gnc-plugin-bi-import.c @@ -58,16 +58,12 @@ static GActionEntry gnc_plugin_actions [] = /** The number of actions provided by this plugin. */ static guint gnc_plugin_n_actions = G_N_ELEMENTS(gnc_plugin_actions); -static GncDisplayItem gnc_plugin_display_items [] = +/** The default menu items that need to be add to the menu */ +static const gchar *gnc_plugin_load_ui_items [] = { - /* Menu Items */ - { "ImportMenuAction", NULL, N_("_Import"), NULL, NULL }, - { "bi_importAction", "go-previous", N_("Import Bills & _Invoices..."), - NULL, N_("Import bills and invoices from a CSV text file") - }, + "FilePlaceholder1", + NULL, }; -/** The number of display items provided by this plugin. */ -static guint gnc_plugin_n_display_items = G_N_ELEMENTS(gnc_plugin_display_items); /************************************************************ * Object Implementation * @@ -96,9 +92,8 @@ gnc_plugin_bi_import_class_init (GncPluginbi_importClass *klass) plugin_class->actions_name = PLUGIN_ACTIONS_NAME; plugin_class->actionsb = gnc_plugin_actions; plugin_class->n_actionsb = gnc_plugin_n_actions; - plugin_class->display_items = gnc_plugin_display_items; - plugin_class->n_display_items = gnc_plugin_n_display_items; plugin_class->ui_filename = PLUGIN_UI_FILENAME; + plugin_class->ui_updates = gnc_plugin_load_ui_items; } static void diff --git a/gnucash/import-export/csv-exp/gnc-plugin-csv-export.c b/gnucash/import-export/csv-exp/gnc-plugin-csv-export.c index 3cc7ac56e7..85666ca9a8 100644 --- a/gnucash/import-export/csv-exp/gnc-plugin-csv-export.c +++ b/gnucash/import-export/csv-exp/gnc-plugin-csv-export.c @@ -54,24 +54,12 @@ static GActionEntry gnc_plugin_actions [] = /** The number of actions provided by this plugin. */ static guint gnc_plugin_n_actions = G_N_ELEMENTS(gnc_plugin_actions); -static GncDisplayItem gnc_plugin_display_items [] = +/** The default menu items that need to be add to the menu */ +static const gchar *gnc_plugin_load_ui_items [] = { - { - "CsvExportTreeAction", "go-next", N_("Export Account T_ree to CSV..."), NULL, - N_("Export the Account Tree to a CSV file") - }, - { - "CsvExportTransAction", "go-next", N_("Export _Transactions to CSV..."), NULL, - N_("Export the Transactions to a CSV file") - }, - { - "CsvExportRegisterAction", "go-next", N_("Export A_ctive Register to CSV...") - /* _A is already used by Export Accounts */, NULL, - N_("Export the Active Register to a CSV file") - }, + "FilePlaceholder4", + NULL, }; -/** The number of display items provided by this plugin. */ -static guint gnc_plugin_n_display_items = G_N_ELEMENTS(gnc_plugin_display_items); typedef struct GncPluginCsvExportPrivate { @@ -108,9 +96,8 @@ gnc_plugin_csv_export_class_init (GncPluginCsvExportClass *klass) plugin_class->actions_name = PLUGIN_ACTIONS_NAME; plugin_class->actionsb = gnc_plugin_actions; plugin_class->n_actionsb = gnc_plugin_n_actions; - plugin_class->display_items = gnc_plugin_display_items; - plugin_class->n_display_items = gnc_plugin_n_display_items; plugin_class->ui_filename = PLUGIN_UI_FILENAME; + plugin_class->ui_updates = gnc_plugin_load_ui_items; } static void diff --git a/gnucash/import-export/csv-imp/gnc-plugin-csv-import.c b/gnucash/import-export/csv-imp/gnc-plugin-csv-import.c index d331a2e144..c2a08e8993 100644 --- a/gnucash/import-export/csv-imp/gnc-plugin-csv-import.c +++ b/gnucash/import-export/csv-imp/gnc-plugin-csv-import.c @@ -53,23 +53,12 @@ static GActionEntry gnc_plugin_actions [] = /** The number of actions provided by this plugin. */ static guint gnc_plugin_n_actions = G_N_ELEMENTS(gnc_plugin_actions); -static GncDisplayItem gnc_plugin_display_items [] = +/** The default menu items that need to be add to the menu */ +static const gchar *gnc_plugin_load_ui_items [] = { - { - "CsvImportAccountAction", "go-previous", N_("Import _Accounts from CSV..."), NULL, - N_("Import Accounts from a CSV file") - }, - { - "CsvImportTransAction", "go-previous", N_("Import _Transactions from CSV..."), NULL, - N_("Import Transactions from a CSV file") - }, - { - "CsvImportPriceAction", "go-previous", N_("Import _Prices from a CSV file..."), NULL, - N_("Import Prices from a CSV file") - }, + "FilePlaceholder1", + NULL, }; -/** The number of display items provided by this plugin. */ -static guint gnc_plugin_n_display_items = G_N_ELEMENTS(gnc_plugin_display_items); typedef struct GncPluginCsvImportPrivate { @@ -106,9 +95,8 @@ gnc_plugin_csv_import_class_init (GncPluginCsvImportClass *klass) plugin_class->actions_name = PLUGIN_ACTIONS_NAME; plugin_class->actionsb = gnc_plugin_actions; plugin_class->n_actionsb = gnc_plugin_n_actions; - plugin_class->display_items = gnc_plugin_display_items; - plugin_class->n_display_items = gnc_plugin_n_display_items; plugin_class->ui_filename = PLUGIN_UI_FILENAME; + plugin_class->ui_updates = gnc_plugin_load_ui_items; } static void diff --git a/gnucash/import-export/customer-import/gnc-plugin-customer-import.c b/gnucash/import-export/customer-import/gnc-plugin-customer-import.c index 660e063cf3..b1886b7a74 100644 --- a/gnucash/import-export/customer-import/gnc-plugin-customer-import.c +++ b/gnucash/import-export/customer-import/gnc-plugin-customer-import.c @@ -58,17 +58,12 @@ static GActionEntry gnc_plugin_actions [] = /** The number of actions provided by this plugin. */ static guint gnc_plugin_n_actions = G_N_ELEMENTS(gnc_plugin_actions); -static GncDisplayItem gnc_plugin_display_items [] = +/** The default menu items that need to be add to the menu */ +static const gchar *gnc_plugin_load_ui_items [] = { - /* Menu Items */ - { "ImportMenuAction", NULL, N_("_Import"), NULL, NULL }, - /* Menu entry with label and tooltip */ - { "customer_importAction", "go-previous", N_("Import _Customers & Vendors..."), - NULL, N_("Import Customers and Vendors from a CSV text file.") - }, + "FilePlaceholder1", + NULL, }; -/** The number of display items provided by this plugin. */ -static guint gnc_plugin_n_display_items = G_N_ELEMENTS(gnc_plugin_display_items); /************************************************************ * Object Implementation * @@ -97,9 +92,8 @@ gnc_plugin_customer_import_class_init (GncPlugincustomer_importClass *klass) plugin_class->actions_name = PLUGIN_ACTIONS_NAME; plugin_class->actionsb = gnc_plugin_actions; plugin_class->n_actionsb = gnc_plugin_n_actions; - plugin_class->display_items = gnc_plugin_display_items; - plugin_class->n_display_items = gnc_plugin_n_display_items; plugin_class->ui_filename = PLUGIN_UI_FILENAME; + plugin_class->ui_updates = gnc_plugin_load_ui_items; } static void diff --git a/gnucash/import-export/log-replay/gnc-plugin-log-replay.c b/gnucash/import-export/log-replay/gnc-plugin-log-replay.c index 47ecfe5184..5e63e59b8c 100644 --- a/gnucash/import-export/log-replay/gnc-plugin-log-replay.c +++ b/gnucash/import-export/log-replay/gnc-plugin-log-replay.c @@ -49,15 +49,12 @@ static GActionEntry gnc_plugin_actions [] = /** The number of actions provided by this plugin. */ static guint gnc_plugin_n_actions = G_N_ELEMENTS(gnc_plugin_actions); -static GncDisplayItem gnc_plugin_display_items [] = +/** The default menu items that need to be add to the menu */ +static const gchar *gnc_plugin_load_ui_items [] = { - { - "LogReplayAction", "go-previous", N_("_Replay GnuCash .log file..."), NULL, - N_("Replay a GnuCash log file after a crash. This cannot be undone.") - }, + "FilePlaceholder1", + NULL, }; -/** The number of display items provided by this plugin. */ -static guint gnc_plugin_n_display_items = G_N_ELEMENTS(gnc_plugin_display_items); typedef struct GncPluginLogreplayPrivate { @@ -94,9 +91,8 @@ gnc_plugin_log_replay_class_init (GncPluginLogreplayClass *klass) plugin_class->actions_name = PLUGIN_ACTIONS_NAME; plugin_class->actionsb = gnc_plugin_actions; plugin_class->n_actionsb = gnc_plugin_n_actions; - plugin_class->display_items = gnc_plugin_display_items; - plugin_class->n_display_items = gnc_plugin_n_display_items; plugin_class->ui_filename = PLUGIN_UI_FILENAME; + plugin_class->ui_updates = gnc_plugin_load_ui_items; } static void diff --git a/gnucash/import-export/ofx/gnc-plugin-ofx.c b/gnucash/import-export/ofx/gnc-plugin-ofx.c index a3707c2dd7..61cf493026 100644 --- a/gnucash/import-export/ofx/gnc-plugin-ofx.c +++ b/gnucash/import-export/ofx/gnc-plugin-ofx.c @@ -47,15 +47,12 @@ static GActionEntry gnc_plugin_actions [] = /** The number of actions provided by this plugin. */ static guint gnc_plugin_n_actions = G_N_ELEMENTS(gnc_plugin_actions); -static GncDisplayItem gnc_plugin_display_items [] = +/** The default menu items that need to be add to the menu */ +static const gchar *gnc_plugin_load_ui_items [] = { - { - "OfxImportAction", "go-previous", N_("Import _OFX/QFX..."), NULL, - N_("Process an OFX/QFX response file") - }, + "FilePlaceholder1", + NULL, }; -/** The number of display items provided by this plugin. */ -static guint gnc_plugin_n_display_items = G_N_ELEMENTS(gnc_plugin_display_items); typedef struct GncPluginOfxPrivate { @@ -92,9 +89,8 @@ gnc_plugin_ofx_class_init (GncPluginOfxClass *klass) plugin_class->actions_name = PLUGIN_ACTIONS_NAME; plugin_class->actionsb = gnc_plugin_actions; plugin_class->n_actionsb = gnc_plugin_n_actions; - plugin_class->display_items = gnc_plugin_display_items; - plugin_class->n_display_items = gnc_plugin_n_display_items; plugin_class->ui_filename = PLUGIN_UI_FILENAME; + plugin_class->ui_updates = gnc_plugin_load_ui_items; } static void diff --git a/gnucash/import-export/qif-imp/gnc-plugin-qif-import.c b/gnucash/import-export/qif-imp/gnc-plugin-qif-import.c index 77dbfbb28b..3718286272 100644 --- a/gnucash/import-export/qif-imp/gnc-plugin-qif-import.c +++ b/gnucash/import-export/qif-imp/gnc-plugin-qif-import.c @@ -49,15 +49,12 @@ static GActionEntry gnc_plugin_actions [] = /** The number of actions provided by this plugin. */ static guint gnc_plugin_n_actions = G_N_ELEMENTS(gnc_plugin_actions); -static GncDisplayItem gnc_plugin_display_items [] = +/** The default menu items that need to be add to the menu */ +static const gchar *gnc_plugin_load_ui_items [] = { - { - "QIFImportAction", "go-previous", N_("Import _QIF..."), NULL, - N_("Import a Quicken QIF file") - }, + "FilePlaceholder1", + NULL, }; -/** The number of display items provided by this plugin. */ -static guint gnc_plugin_n_display_items = G_N_ELEMENTS(gnc_plugin_display_items); typedef struct GncPluginQifImportPrivate { @@ -94,9 +91,8 @@ gnc_plugin_qif_import_class_init (GncPluginQifImportClass *klass) plugin_class->actions_name = PLUGIN_ACTIONS_NAME; plugin_class->actionsb = gnc_plugin_actions; plugin_class->n_actionsb = gnc_plugin_n_actions; - plugin_class->display_items = gnc_plugin_display_items; - plugin_class->n_display_items = gnc_plugin_n_display_items; plugin_class->ui_filename = PLUGIN_UI_FILENAME; + plugin_class->ui_updates = gnc_plugin_load_ui_items; } static void diff --git a/gnucash/ui/gnc-main-window.ui b/gnucash/ui/gnc-main-window.ui index 4deaf579a3..fa1ce1045c 100644 --- a/gnucash/ui/gnc-main-window.ui +++ b/gnucash/ui/gnc-main-window.ui @@ -158,6 +158,11 @@ mainwin.EditPlaceholder5 action-disabled + + OptionsPlaceholder + mainwin.EditPlaceholder6 + action-disabled + @@ -226,14 +231,23 @@ mainwin.ViewPlaceholder2 action-disabled + +
+ + Placeholder + mainwin.ViewPlaceholder3 + action-disabled + +
+
RefreshPlaceholder - mainwin.ViewPlaceholder3 + mainwin.ViewPlaceholder4 action-disabled AccoutTreePlaceholder - mainwin.ViewPlaceholder4 + mainwin.ViewPlaceholder5 action-disabled
@@ -250,6 +264,34 @@ action-disabled +
+ + Placeholder + mainwin.TransPlaceholder1 + action-disabled + +
+
+ + Placeholder + mainwin.TransPlaceholder2 + action-disabled + +
+
+ + Placeholder + mainwin.TransPlaceholder3 + action-disabled + +
+
+ + Placeholder + mainwin.TransPlaceholder4 + action-disabled + +
@@ -315,7 +357,6 @@ _Business mainwin.BusinessAction - action-disabled
Placeholder @@ -323,6 +364,13 @@ action-disabled
+
+ + Placeholder + mainwin.BusinessPlaceholder1 + action-disabled + +
diff --git a/gnucash/ui/gnc-plugin-account-tree.ui b/gnucash/ui/gnc-plugin-account-tree.ui new file mode 100644 index 0000000000..9cfd6954c3 --- /dev/null +++ b/gnucash/ui/gnc-plugin-account-tree.ui @@ -0,0 +1,12 @@ + + + + + + New Accounts _Page + gnc-plugin-account-tree-actions.ViewAccountTreeAction + Open a new Account Tree page + + + + diff --git a/gnucash/ui/gnc-plugin-aqbanking.ui b/gnucash/ui/gnc-plugin-aqbanking.ui new file mode 100644 index 0000000000..dfa61c2342 --- /dev/null +++ b/gnucash/ui/gnc-plugin-aqbanking.ui @@ -0,0 +1,69 @@ + + + + + + Import using AQBanking + gnc-plugin-aqbanking-actions.AQBankingImportAction + Import into GnuCash any file format supported by AQBanking + + + + + + _Online Actions + gnc-plugin-aqbanking-actions.OnlineActionsAction +
+ + Get _Balance + gnc-plugin-aqbanking-actions.ABGetBalanceAction + The list of Scheduled Transactions + + + Get _Transactions... + gnc-plugin-aqbanking-actions.ABGetTransAction + Get the transactions online through Online Banking + +
+
+ + + Issue _SEPA Transaction... + gnc-plugin-aqbanking-actions.ABIssueSepaTransAction + Issue a new international European (SEPA) transaction online through Online Banking + + + Issue SEPA I_nternal Transaction... + gnc-plugin-aqbanking-actions.ABIssueSepaIntTransAction + Issue a new internal European (SEPA) transaction online through Online Banking + + + _Internal Transaction... + gnc-plugin-aqbanking-actions.ABIssueIntTransAction + Issue a new bank-internal transaction online through Online Banking + + + Issue SEPA Direct _Debit... + gnc-plugin-aqbanking-actions.ABIssueSepaDirectDebitAction + Issue a new international European (SEPA) direct debit note online through Online Banking + +
+
+ + Show _log window + gnc-plugin-aqbanking-actions.ABViewLogwindowAction + Show the online banking log window + +
+
+
+ + + + _Online Banking Setup... + gnc-plugin-aqbanking-actions.ABSetupAction + Initial setup of Online Banking access (HBCI, or OFX DirectConnect, using AqBanking) + + + +
diff --git a/gnucash/ui/gnc-plugin-bi-import.ui b/gnucash/ui/gnc-plugin-bi-import.ui new file mode 100644 index 0000000000..5c0b8b1620 --- /dev/null +++ b/gnucash/ui/gnc-plugin-bi-import.ui @@ -0,0 +1,12 @@ + + + + + + Import Bills & _Invoices... + gnc-plugin-bi-import-actions.bi_importAction + Import bills and invoices from a CSV text file + + + + diff --git a/gnucash/ui/gnc-plugin-budget.ui b/gnucash/ui/gnc-plugin-budget.ui new file mode 100644 index 0000000000..8b3b0153c6 --- /dev/null +++ b/gnucash/ui/gnc-plugin-budget.ui @@ -0,0 +1,33 @@ + + + + + + B_udget + gnc-plugin-budget-actions.ActionsBudgetAction +
+ + _New Budget + gnc-plugin-budget-actions.NewBudgetAction + Create a new Budget + + + _Open Budget + gnc-plugin-budget-actions.OpenBudgetAction + Open an existing Budget in a new tab. If none exists a new budget will be created + + + _Copy Budget + gnc-plugin-budget-actions.CopyBudgetAction + Copy an existing Budget + + + _Delete Budget + gnc-plugin-budget-actions.DeleteBudgetAction + Delete an existing Budget + +
+
+
+ +
diff --git a/gnucash/ui/gnc-plugin-business.ui b/gnucash/ui/gnc-plugin-business.ui new file mode 100644 index 0000000000..93f4c30548 --- /dev/null +++ b/gnucash/ui/gnc-plugin-business.ui @@ -0,0 +1,157 @@ + + + + + + _Customer + gnc-plugin-business-actions.CustomerMenuAction + + Customers Overview + gnc-plugin-business-actions.CustomerOverviewPageAction + Open a Customer overview page + + + _New Customer... + gnc-plugin-business-actions.CustomerNewCustomerOpenAction + Open the New Customer dialog + + + _Find Customer... + gnc-plugin-business-actions.CustomerFindCustomerOpenAction + Open the Find Customer dialog + + + New _Invoice... + gnc-plugin-business-actions.CustomerNewInvoiceOpenAction + Open the New Invoice dialog + + + Find In_voice... + gnc-plugin-business-actions.CustomerFindInvoiceOpenAction + Open the Find Invoice dialog + + + New _Job... + gnc-plugin-business-actions.CustomerNewJobOpenAction + Open the New Job dialog + + + Find Jo_b... + gnc-plugin-business-actions.CustomerFindJobOpenAction + Open the Find Job dialog + + + _Process Payment... + gnc-plugin-business-actions.CustomerProcessPaymentAction + Open the Process Payment dialog + + + Invoices _Due Reminder + gnc-plugin-business-actions.InvoicesDueReminderOpenAction + Open the Invoices Due Reminder dialog + + + + _Vendor + gnc-plugin-business-actions.VendorMenuAction + + Vendors Overview + gnc-plugin-business-actions.VendorOverviewPageAction + Open a Vendor overview page + + + _New Vendor... + gnc-plugin-business-actions.VendorNewVendorOpenAction + Open the New Vendor dialog + + + _Find Vendor... + gnc-plugin-business-actions.VendorFindVendorOpenAction + Open the Find Vendor dialog + + + New _Bill... + gnc-plugin-business-actions.VendorNewBillOpenAction + Open the New Bill dialog + + + Find Bi_ll... + gnc-plugin-business-actions.VendorFindBillOpenAction + Open the Find Bill dialog + + + New _Job... + gnc-plugin-business-actions.VendorNewJobOpenAction + Open the New Job dialog + + + Find Jo_b... + gnc-plugin-business-actions.VendorFindJobOpenAction + Open the Find Job dialog + + + _Process Payment... + gnc-plugin-business-actions.VendorProcessPaymentAction + Open the Process Payment dialog + + + Bills _Due Reminder + gnc-plugin-business-actions.BillsDueReminderOpenAction + Open the Bills Due Reminder dialog + + + + _Employee + gnc-plugin-business-actions.EmployeeMenuAction + + Employees Overview + gnc-plugin-business-actions.EmployeeOverviewPageAction + Open a Employee overview page + + + _New Employee... + gnc-plugin-business-actions.EmployeeNewEmployeeOpenAction + Open the New Employee dialog + + + _Find Employee... + gnc-plugin-business-actions.EmployeeFindEmployeeOpenAction + Open the Find Employee dialog + + + New _Expense Voucher... + gnc-plugin-business-actions.EmployeeNewExpenseVoucherOpenAction + Open the New Voucher dialog + + + Find Expense _Voucher... + gnc-plugin-business-actions.EmployeeFindExpenseVoucherOpenAction + Open the Find Expense Voucher dialog + + + _Process Payment... + gnc-plugin-business-actions.EmployeeProcessPaymentAction + Open the Process Payment dialog + + + + Business Linked Documents + gnc-plugin-business-actions.BusinessLinkedDocsAction + View all Linked Business Documents + + + + + + Sales _Tax Table + gnc-plugin-business-actions.TaxTablesOpenAction + View and edit the list of Sales Tax Tables (GST/VAT) + + + _Billing Terms Editor + gnc-plugin-business-actions.BillingTermsOpenAction + View and edit the list of Billing Terms + + + + diff --git a/gnucash/ui/gnc-plugin-csv-export.ui b/gnucash/ui/gnc-plugin-csv-export.ui new file mode 100644 index 0000000000..c827d3c760 --- /dev/null +++ b/gnucash/ui/gnc-plugin-csv-export.ui @@ -0,0 +1,22 @@ + + + + + + Export Account T_ree to CSV... + gnc-plugin-csv-export-actions.CsvExportTreeAction + Export the Account Tree to a CSV file + + + Export _Transactions to CSV... + gnc-plugin-csv-export-actions.CsvExportTransAction + Export the Transactions to a CSV file + + + Export A_ctive Register to CSV... + gnc-plugin-csv-export-actions.CsvExportRegisterAction + Export the Active Register to a CSV file + + + + diff --git a/gnucash/ui/gnc-plugin-csv-import.ui b/gnucash/ui/gnc-plugin-csv-import.ui new file mode 100644 index 0000000000..b2c4fc3b5d --- /dev/null +++ b/gnucash/ui/gnc-plugin-csv-import.ui @@ -0,0 +1,22 @@ + + + + + + Import _Accounts from CSV... + gnc-plugin-csv-import-actions.CsvImportAccountAction + Import Accounts from a CSV file + + + Import _Transactions from CSV... + gnc-plugin-csv-import-actions.CsvImportTransAction + Import Transactions from a CSV file + + + Import _Prices from a CSV file... + gnc-plugin-csv-import-actions.CsvImportPriceAction + Import Prices from a CSV file + + + + diff --git a/gnucash/ui/gnc-plugin-customer-import.ui b/gnucash/ui/gnc-plugin-customer-import.ui new file mode 100644 index 0000000000..24e70be9bb --- /dev/null +++ b/gnucash/ui/gnc-plugin-customer-import.ui @@ -0,0 +1,12 @@ + + + + + + Import _Customers & Vendors... + gnc-plugin-customer-import-actions.customer_importAction + Import Customers and Vendors from a CSV text file + + + + diff --git a/gnucash/ui/gnc-plugin-log-replay.ui b/gnucash/ui/gnc-plugin-log-replay.ui new file mode 100644 index 0000000000..bde5c67a11 --- /dev/null +++ b/gnucash/ui/gnc-plugin-log-replay.ui @@ -0,0 +1,12 @@ + + + + + + _Replay GnuCash .log file... + gnc-plugin-log-replay-actions.LogReplayAction + Replay a GnuCash log file after a crash. This cannot be undone + + + + diff --git a/gnucash/ui/gnc-plugin-ofx.ui b/gnucash/ui/gnc-plugin-ofx.ui new file mode 100644 index 0000000000..55c25411f9 --- /dev/null +++ b/gnucash/ui/gnc-plugin-ofx.ui @@ -0,0 +1,12 @@ + + + + + + Import _OFX/QFX... + gnc-plugin-ofx-actions.OfxImportAction + Process an OFX/QFX response file + + + + diff --git a/gnucash/ui/gnc-plugin-qif-import.ui b/gnucash/ui/gnc-plugin-qif-import.ui new file mode 100644 index 0000000000..7a27b60b1a --- /dev/null +++ b/gnucash/ui/gnc-plugin-qif-import.ui @@ -0,0 +1,12 @@ + + + + + + Import _QIF... + gnc-plugin-qif-import-actions.QIFImportAction + Import a Quicken QIF file + + + + diff --git a/gnucash/ui/gnc-plugin-register.ui b/gnucash/ui/gnc-plugin-register.ui new file mode 100644 index 0000000000..dfc96febe7 --- /dev/null +++ b/gnucash/ui/gnc-plugin-register.ui @@ -0,0 +1,12 @@ + + + + + + _General Journal + gnc-plugin-register-actions.ToolsGeneralJournalAction + Open general journal window + + + + diff --git a/gnucash/ui/gnc-plugin-report-system.ui b/gnucash/ui/gnc-plugin-report-system.ui new file mode 100644 index 0000000000..69a6fe00f2 --- /dev/null +++ b/gnucash/ui/gnc-plugin-report-system.ui @@ -0,0 +1,12 @@ + + + + + + St_yle Sheets + gnc-plugin-report-system-actions.EditStyleSheetsAction + Edit report style sheets + + + + From dcde7952ba6443bf54cbd0aec7642ba59324d34a Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Fri, 28 Oct 2022 16:17:16 +0100 Subject: [PATCH 10/77] Update for the file/window/tab radio buttons --- gnucash/gnome-utils/gnc-main-window.cpp | 460 ++++++++++-------- gnucash/gnome-utils/gnc-plugin-file-history.c | 109 +++-- gnucash/gnucash-gresources.xml | 1 + gnucash/ui/gnc-main-window.ui | 6 + gnucash/ui/gnc-plugin-file-history.ui | 12 + 5 files changed, 358 insertions(+), 230 deletions(-) create mode 100644 gnucash/ui/gnc-plugin-file-history.ui diff --git a/gnucash/gnome-utils/gnc-main-window.cpp b/gnucash/gnome-utils/gnc-main-window.cpp index 57e05d017f..ad070dd829 100644 --- a/gnucash/gnome-utils/gnc-main-window.cpp +++ b/gnucash/gnome-utils/gnc-main-window.cpp @@ -118,6 +118,7 @@ enum #define GNC_PREF_TAB_OPEN_ADJACENT "tab-open-adjacent" #define GNC_MAIN_WINDOW_NAME "GncMainWindow" +#define GNC_MAIN_WINDOW_MAX_NUMBER 10 #define DIALOG_BOOK_OPTIONS_CM_CLASS "dialog-book-options" @@ -332,8 +333,8 @@ static GActionEntry gnc_menu_actions [] = { "ViewSummaryAction", gnc_main_window_cmd_view_summary, nullptr, "true", toggle_change_state }, { "ViewStatusbarAction", gnc_main_window_cmd_view_statusbar, nullptr, "true", toggle_change_state }, - { "ViewTabPositionAction", gnc_main_window_cmd_view_tab_position, "n", 0, radio_change_state }, - { "Window0Action", gnc_main_window_cmd_window_raise, "n", 0, radio_change_state }, + { "ViewTabPositionAction", gnc_main_window_cmd_view_tab_position, "i", "@i 0", radio_change_state }, + { "Window0Action", gnc_main_window_cmd_window_raise, "i", "@i 0", radio_change_state }, }; /** The number of actions provided by the main window. */ static guint gnc_menu_n_actions = G_N_ELEMENTS(gnc_menu_actions); @@ -689,7 +690,7 @@ gnc_main_window_restore_window (GncMainWindow *window, GncMainWindowSaveData *da GAction *action; gint *pos, *geom, *order; gsize length; - gboolean max, visible, desired_visibility; + gboolean max; gchar *window_group; gsize page_start, page_count, i; GError *error = nullptr; @@ -836,51 +837,69 @@ gnc_main_window_restore_window (GncMainWindow *window, GncMainWindowSaveData *da /* Common view menu items */ action = gnc_main_window_find_action (window, "ViewToolbarAction"); -//FIXMEb visible = gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action)); - desired_visibility = g_key_file_get_boolean (data->key_file, window_group, - TOOLBAR_VISIBLE, &error); - if (error) + if (action) { - g_warning("error reading group %s key %s: %s", - window_group, TOOLBAR_VISIBLE, error->message); - g_error_free(error); - error = nullptr; - } - else if (visible != desired_visibility) - { -// gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), desired_visibility); + GVariant *state = g_action_get_state (G_ACTION(action)); + gboolean visible = g_variant_get_boolean (state); + gboolean desired_visibility = g_key_file_get_boolean (data->key_file, window_group, + TOOLBAR_VISIBLE, &error); + + if (error) + { + g_warning ("error reading group %s key %s: %s", + window_group, TOOLBAR_VISIBLE, error->message); + g_error_free (error); + error = nullptr; + } + else if (visible != desired_visibility) + { + g_action_activate (action, nullptr); + } + g_variant_unref (state); } - action = gnc_main_window_find_action(window, "ViewSummaryAction"); -//FIXMEb visible = gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action)); - desired_visibility = g_key_file_get_boolean (data->key_file, window_group, - SUMMARYBAR_VISIBLE, &error); - if (error) + action = gnc_main_window_find_action (window, "ViewSummaryAction"); + if (action) { - g_warning("error reading group %s key %s: %s", - window_group, TOOLBAR_VISIBLE, error->message); - g_error_free(error); - error = nullptr; - } - else if (visible != desired_visibility) - { -// gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), desired_visibility); + GVariant *state = g_action_get_state (G_ACTION(action)); + gboolean visible = g_variant_get_boolean (state); + gboolean desired_visibility = g_key_file_get_boolean (data->key_file, window_group, + SUMMARYBAR_VISIBLE, &error); + + if (error) + { + g_warning ("error reading group %s key %s: %s", + window_group, SUMMARYBAR_VISIBLE, error->message); + g_error_free (error); + error = nullptr; + } + else if (visible != desired_visibility) + { + g_action_activate (action, nullptr); + } + g_variant_unref (state); } - action = gnc_main_window_find_action(window, "ViewStatusbarAction"); -//FIXMEb visible = gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action)); - desired_visibility = g_key_file_get_boolean (data->key_file, window_group, - STATUSBAR_VISIBLE, &error); - if (error) + action = gnc_main_window_find_action (window, "ViewStatusbarAction"); + if (action) { - g_warning("error reading group %s key %s: %s", - window_group, TOOLBAR_VISIBLE, error->message); - g_error_free(error); - error = nullptr; - } - else if (visible != desired_visibility) - { -// gtk_toggle_action_set_active (GTK_TOGGLE_ACTION(action), desired_visibility); + GVariant *state = g_action_get_state (G_ACTION(action)); + gboolean visible = g_variant_get_boolean (state); + gboolean desired_visibility = g_key_file_get_boolean (data->key_file, window_group, + STATUSBAR_VISIBLE, &error); + + if (error) + { + g_warning ("error reading group %s key %s: %s", + window_group, STATUSBAR_VISIBLE, error->message); + g_error_free (error); + error = nullptr; + } + else if (visible != desired_visibility) + { + g_action_activate (action, nullptr); + } + g_variant_unref (state); } priv->restoring_pages = TRUE; /* Now populate the window with pages. */ @@ -1045,7 +1064,7 @@ gnc_main_window_save_window (GncMainWindow *window, GncMainWindowSaveData *data) GncMainWindowPrivate *priv; GAction *action; gint i, num_pages, coords[4], *order; - gboolean maximized, minimized, visible; + gboolean maximized, minimized, visible = true; gchar *window_group; /* Setup */ @@ -1109,16 +1128,30 @@ gnc_main_window_save_window (GncMainWindow *window, GncMainWindowSaveData *data) /* Common view menu items */ action = gnc_main_window_find_action (window, "ViewToolbarAction"); -//FIXMEb visible = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION(action)); - visible = TRUE; //just added for testing + if (action) + { + GVariant *state = g_action_get_state (G_ACTION(action)); + visible = g_variant_get_boolean (state); + g_variant_unref (state); + } g_key_file_set_boolean (data->key_file, window_group, TOOLBAR_VISIBLE, visible); action = gnc_main_window_find_action (window, "ViewSummaryAction"); -//FIXMEb visible = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION(action)); + if (action) + { + GVariant *state = g_action_get_state (G_ACTION(action)); + visible = g_variant_get_boolean (state); + g_variant_unref (state); + } g_key_file_set_boolean (data->key_file, window_group, SUMMARYBAR_VISIBLE, visible); action = gnc_main_window_find_action (window, "ViewStatusbarAction"); -//FIXMEb visible = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION(action)); + if (action) + { + GVariant *state = g_action_get_state (G_ACTION(action)); + visible = g_variant_get_boolean (state); + g_variant_unref (state); + } g_key_file_set_boolean (data->key_file, window_group, STATUSBAR_VISIBLE, visible); @@ -1843,31 +1876,33 @@ statusbar_notification_lastmodified() /** This data structure is used to describe the requested state of a - * GtkRadioAction, and us used to pass data among several - * functions. */ + * GAction, and is used to pass data among several functions. */ struct menu_update { - /** The name of the GtkRadioAction to be updated. */ + /** The name of the GAction to be updated. */ gchar *action_name; - /** The new label for this GtkRadioAction. */ + /** The new label for this GAction. */ gchar *label; - /** Whether or not the GtkRadioAction should be visible. */ + /** Whether or not the GAction should be visible. */ gboolean visible; + + /** Index number in active windows list */ + gint index; }; #ifndef MAC_INTEGRATION -/** Update the label on the specified GtkRadioAction in the specified - * window. This action is displayed as a menu item in the "Windows" - * menu. This function will end up being called whenever the front - * page is changed in any window, or whenever a window is added or - * deleted. +/** Update the label on the menu item specified by the GAction in the + * specified window. This action is displayed as a menu item in the + * "Windows" menu. This function will end up being called whenever the + * front page is changed in any window, or whenever a window is added + * or deleted. * * @param window The window whose menu item should be updated. * - * @param data A data structure containing the name of the - * GtkRadioAction, and describing the new state for this action. + * @param data A data structure containing the name of the GAction and + * describing the new state for this action. * * @internal */ @@ -1876,17 +1911,44 @@ gnc_main_window_update_one_menu_action (GncMainWindow *window, struct menu_update *data) { GncMainWindowPrivate *priv; - GAction* action; + GncMenuModelSearch *gsm = g_new0 (GncMenuModelSearch, 1); + GMenuItem *item; + gint pos; ENTER("window %p, action %s, label %s, visible %d", window, data->action_name, data->label, data->visible); priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); - action = g_action_map_lookup_action (G_ACTION_MAP(priv->simple_action_group), data->action_name); - if (action) -//FIXMEb g_object_set(G_OBJECT(action), -// "label", data->label, -// "visible", data->visible, -// (char *)nullptr); + + gsm->search_action_label = nullptr; + gsm->search_action_name = "WindowsPlaceholder1"; // placeholder + + if (!gnc_menubar_model_find_item (priv->menubar_model, gsm)) + { + LEAVE("Could not find placeholder 'WindowsPlaceholder1' for windows entries"); + g_free (gsm); + return; + } + + pos = gsm->index + data->index + 1; + + if (!data->visible) + { + if (pos < g_menu_model_get_n_items (gsm->model)) + g_menu_remove (G_MENU(gsm->model), pos); + + g_free (gsm); + LEAVE(" "); + return; + } + + item = g_menu_item_new (data->label, "mainwin.Window0Action"); + g_menu_item_set_attribute (item, "target", "i", data->index); + + if (pos < g_menu_model_get_n_items (gsm->model)) + g_menu_remove (G_MENU(gsm->model), pos); + g_menu_insert_item (G_MENU(gsm->model), pos, item); + + g_free (gsm); LEAVE(" "); } @@ -1906,46 +1968,38 @@ static void gnc_main_window_update_radio_button (GncMainWindow *window) { GncMainWindowPrivate *priv; - GAction *action, *first_action; + GAction *action; GSList *action_list; - gchar *action_name; gsize index; ENTER("window %p", window); /* Show the new entry in all windows. */ index = g_list_index (active_windows, window); -//FIXMEb -#ifdef skip - if (index >= n_radio_entries) + if (index >= GNC_MAIN_WINDOW_MAX_NUMBER) { - LEAVE("window %" G_GSIZE_FORMAT ", only %" G_GSIZE_FORMAT " actions", index, n_radio_entries); + LEAVE("window %" G_GSIZE_FORMAT ", only %d actions", index, GNC_MAIN_WINDOW_MAX_NUMBER); return; } priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); - action_name = g_strdup_printf("Window%" G_GSIZE_FORMAT "Action", index); - action = g_action_map_lookup_action (G_ACTION_MAP(priv->simple_action_group), action_name); + + action = g_action_map_lookup_action (G_ACTION_MAP(priv->simple_action_group), + "Window0Action"); /* Block the signal so as not to affect window ordering (top to * bottom) on the screen */ -//FIXMEb action_list = gtk_radio_action_get_group (GTK_RADIO_ACTION(action)); -// if (action_list) -// { -// first_action = static_cast(g_slist_last(action_list)->data); -// g_signal_handlers_block_by_func(G_OBJECT(first_action), -// (gpointer)gnc_main_window_cmd_window_raise, -// window); -// DEBUG("blocked signal on %p, set %p active, window %p", first_action, -// action, window); -// gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), TRUE); -// g_signal_handlers_unblock_by_func(G_OBJECT(first_action), -// (gpointer)gnc_main_window_cmd_window_raise, -// window); - } - g_free(action_name); -#endif + g_signal_handlers_block_by_func (G_OBJECT(action), + (gpointer)gnc_main_window_cmd_window_raise, + window); + + DEBUG("blocked signal on action %p, window %p", action, window); + g_action_change_state (G_ACTION(action), g_variant_new_int32 (index)); + + g_signal_handlers_unblock_by_func (G_OBJECT(action), + (gpointer)gnc_main_window_cmd_window_raise, + window); LEAVE(" "); } @@ -1970,39 +2024,42 @@ gnc_main_window_update_menu_item (GncMainWindow *window) gsize index; ENTER("window %p", window); - index = g_list_index(active_windows, window); -//FIXMEb -#ifdef skip - if (index > n_radio_entries) + + index = g_list_index (active_windows, window); + + if (index >= GNC_MAIN_WINDOW_MAX_NUMBER) { - LEAVE("skip window %" G_GSIZE_FORMAT " (only %" G_GSIZE_FORMAT " entries)", index, n_radio_entries); + LEAVE("skip window %" G_GSIZE_FORMAT " (only %d entries)", index, GNC_MAIN_WINDOW_MAX_NUMBER); return; } /* Figure out the label name. Add the accelerator if possible. */ - title = gnc_main_window_generate_title(window); - strings = g_strsplit(title, "_", 0); - g_free(title); - expanded = g_strjoinv("__", strings); - if (index < 10) + title = gnc_main_window_generate_title (window); + strings = g_strsplit (title, "_", 0); + g_free (title); + expanded = g_strjoinv ("__", strings); + if (index < GNC_MAIN_WINDOW_MAX_NUMBER) { - data.label = g_strdup_printf("_%" G_GSIZE_FORMAT " %s", (index + 1) % 10, expanded); - g_free(expanded); + data.label = g_strdup_printf ("_%" G_GSIZE_FORMAT " %s", (index + 1) % 10, expanded); + g_free (expanded); } else { data.label = expanded; } - g_strfreev(strings); + g_strfreev (strings); data.visible = TRUE; - data.action_name = g_strdup_printf("Window%" G_GSIZE_FORMAT "Action", index); - g_list_foreach(active_windows, - (GFunc)gnc_main_window_update_one_menu_action, - &data); - g_free(data.action_name); - g_free(data.label); -#endif + data.action_name = g_strdup_printf ("Window%" G_GSIZE_FORMAT "Action", index); + data.index = index; + + g_list_foreach (active_windows, + (GFunc)gnc_main_window_update_one_menu_action, + &data); + + g_free (data.action_name); + g_free (data.label); + LEAVE(" "); } #endif /* !MAC_INTEGRATION */ @@ -2020,7 +2077,6 @@ static void gnc_main_window_update_all_menu_items (void) { struct menu_update data; - gchar *label; ENTER(""); /* First update the entries for all existing windows */ @@ -2033,23 +2089,21 @@ gnc_main_window_update_all_menu_items (void) nullptr); /* Now hide any entries that aren't being used. */ -//FIXMEb -#ifdef skip data.visible = FALSE; - for (gsize i = g_list_length(active_windows); i < n_radio_entries; i++) + // need i to descend from GNC_MAIN_WINDOW_MAX_NUMBER + for (gsize i = GNC_MAIN_WINDOW_MAX_NUMBER - 1; i > 0 && i >= g_list_length (active_windows); i--) { - data.action_name = g_strdup_printf("Window%" G_GSIZE_FORMAT "Action", i); - label = g_strdup_printf("Window _%" G_GSIZE_FORMAT, (i - 1) % 10); - data.label = gettext(label); + data.index = i; + data.action_name = g_strdup_printf ("Window%dAction", data.index); + data.label = g_strdup_printf ("mywin%" G_GSIZE_FORMAT, i % 10); - g_list_foreach(active_windows, - (GFunc)gnc_main_window_update_one_menu_action, - &data); + g_list_foreach (active_windows, + (GFunc)gnc_main_window_update_one_menu_action, + &data); - g_free(data.action_name); - g_free(label); + g_free (data.action_name); + g_free (data.label); } -#endif LEAVE(" "); } #endif /* !MAC_INTEGRATION */ @@ -3713,10 +3767,9 @@ gnc_main_window_update_tab_position (gpointer prefs, gchar *pref, gpointer user_ { GncMainWindow *window; GtkPositionType position = GTK_POS_TOP; + gint item = 0; GncMainWindowPrivate *priv; - GAction *first_action; - GAction *position_action; - gsize i; + GAction *action; g_return_if_fail (GNC_IS_MAIN_WINDOW(user_data)); @@ -3730,37 +3783,36 @@ gnc_main_window_update_tab_position (gpointer prefs, gchar *pref, gpointer user_ return; if (gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_TAB_POSITION_BOTTOM)) + { position = GTK_POS_BOTTOM; + item = 1; + } else if (gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_TAB_POSITION_LEFT)) + { position = GTK_POS_LEFT; + item = 2; + } else if (gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_TAB_POSITION_RIGHT)) + { position = GTK_POS_RIGHT; + item = 3; + } - priv = GNC_MAIN_WINDOW_GET_PRIVATE (window); - gtk_notebook_set_tab_pos (GTK_NOTEBOOK (priv->notebook), position); -//FIXMEb -#ifdef skip - /* Groups of radio actions use the first action for the callback and all - * change events so block/unblock signals on the first radio action. */ - first_action = g_action_map_lookup_action (G_ACTION_MAP(priv->simple_action_group), - tab_pos_radio_entries[0].name); + priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); + gtk_notebook_set_tab_pos (GTK_NOTEBOOK(priv->notebook), position); - for (i = n_tab_pos_radio_entries - 1; i > 0; i--) - if (tab_pos_radio_entries[i].value == position) - break; + action = g_action_map_lookup_action (G_ACTION_MAP(priv->simple_action_group), + "ViewTabPositionAction"); - position_action = g_action_map_lookup_action (G_ACTION_MAP(priv->simple_action_group), - tab_pos_radio_entries[i].name); - - g_signal_handlers_block_by_func (G_OBJECT (first_action), + g_signal_handlers_block_by_func (G_OBJECT(action), (gpointer)gnc_main_window_cmd_view_tab_position, window); - gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (position_action), TRUE); - g_signal_handlers_unblock_by_func (G_OBJECT (first_action), + g_action_change_state (G_ACTION(action), g_variant_new_int32 (item)); + g_signal_handlers_unblock_by_func (G_OBJECT(action), (gpointer)gnc_main_window_cmd_view_tab_position, window); -#endif - gnc_main_window_update_tab_width (NULL, (char*)GNC_PREF_TAB_WIDTH, NULL); + + gnc_main_window_update_tab_width (nullptr, (char*)GNC_PREF_TAB_WIDTH, nullptr); LEAVE (""); } @@ -4092,10 +4144,11 @@ gnc_main_window_setup_window (GncMainWindow *window) /* Now update the "eXtensions" menu */ if (!gnc_prefs_is_extra_enabled()) { -//FIXMEb GtkAction* action; +//FIXMEb GAction* action; -// action = g_action_map_lookup_action (G_ACTION_MAP(priv->action_group), -// "ExtensionsAction"); +// action = g_action_map_lookup_action (G_ACTION_MAP(priv->simple_action_group), +// "ExtensionsAction"); +// this may need to be disabled and 'hidden when disabled added to ui. // gtk_action_set_visible (action, FALSE); } @@ -4225,16 +4278,23 @@ gnc_main_window_add_widget (GtkUIManager *merge, static gboolean gnc_main_window_show_summarybar (GncMainWindow *window, GAction *action) { - GncMainWindowPrivate *priv; + GncMainWindowPrivate *priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); + GVariant *state; + gboolean visible; - priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); if (action == nullptr) action = g_action_map_lookup_action (G_ACTION_MAP(priv->simple_action_group), "ViewSummaryAction"); if (action == nullptr) return TRUE; -//FIXMEb return gtk_toggle_action_get_active (GTK_TOGGLE_ACTION(action)); - return 1; + + state = g_action_get_state (G_ACTION(action)); + + visible = g_variant_get_boolean (state); + + g_variant_unref (state); + + return visible; } /** This function is invoked when the GtkNotebook switches pages. It @@ -4284,7 +4344,7 @@ gnc_main_window_switch_page (GtkNotebook *notebook, if (page != nullptr) { /* Update the user interface (e.g. menus and toolbars */ -//FIXMEb gnc_plugin_page_merge_actions (page, window->ui_merge); + gnc_plugin_page_merge_actionsb (page, GTK_WIDGET(window)); visible = gnc_main_window_show_summarybar (window, nullptr); gnc_plugin_page_show_summarybar (page, visible); @@ -4697,19 +4757,19 @@ gnc_main_window_cmd_view_toolbar (GSimpleAction *simple, gpointer user_data) { GncMainWindow *window = (GncMainWindow*)user_data; - GncMainWindowPrivate *priv; + GncMainWindowPrivate *priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); + GVariant *state = g_action_get_state (G_ACTION(simple)); priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); -//FIXMEb if (gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(simple))) -#ifdef skip - { + + g_action_change_state (G_ACTION(simple), g_variant_new_boolean (!g_variant_get_boolean (state))); + + if (!g_variant_get_boolean (state)) gtk_widget_show (priv->toolbar); - } else - { gtk_widget_hide (priv->toolbar); - } -#endif + + g_variant_unref (state); } static void @@ -4718,16 +4778,18 @@ gnc_main_window_cmd_view_summary (GSimpleAction *simple, gpointer user_data) { GncMainWindow *window = (GncMainWindow*)user_data; - GncMainWindowPrivate *priv; + GncMainWindowPrivate *priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); GList *item; gboolean visible; - priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); -//FIXMEb visible = gnc_main_window_show_summarybar(window, simple); - for (item = priv->installed_pages; item; item = g_list_next(item)) + visible = gnc_main_window_show_summarybar (window, G_ACTION(simple)); + + g_action_change_state (G_ACTION(simple), g_variant_new_boolean (!visible)); + + for (item = priv->installed_pages; item; item = g_list_next (item)) { -// gnc_plugin_page_show_summarybar(static_cast(item->data), -// visible); + gnc_plugin_page_show_summarybar (static_cast(item->data), + !visible); } } @@ -4737,20 +4799,19 @@ gnc_main_window_cmd_view_statusbar (GSimpleAction *simple, gpointer user_data) { GncMainWindow *window = (GncMainWindow*)user_data; - GncMainWindowPrivate *priv; + GncMainWindowPrivate *priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); + GVariant *state = g_action_get_state (G_ACTION(simple)); priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); -//FIXMEb -#ifdef skip - if (gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action))) - { + + g_action_change_state (G_ACTION(simple), g_variant_new_boolean (!g_variant_get_boolean (state))); + + if (!g_variant_get_boolean (state)) gtk_widget_show (priv->statusbar); - } else - { gtk_widget_hide (priv->statusbar); - } -#endif + + g_variant_unref (state); } static void @@ -4838,42 +4899,44 @@ gnc_main_window_cmd_view_tab_position (GSimpleAction *simple, gpointer user_data) { GncMainWindow *window = (GncMainWindow*)user_data; + gint item = g_variant_get_int32 (parameter); -//FIXMEb -#ifdef skip - auto value{static_cast(gtk_radio_action_get_current_value(current))}; + g_action_change_state (G_ACTION(simple), parameter); - if (value != GTK_POS_TOP && gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_TAB_POSITION_TOP)) + if (item < 0 || item > 3) + return; + + if (item != 0 && gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_TAB_POSITION_TOP)) gnc_prefs_set_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_TAB_POSITION_TOP, FALSE); - if (value != GTK_POS_BOTTOM && gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_TAB_POSITION_BOTTOM)) + if (item != 1 && gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_TAB_POSITION_BOTTOM)) gnc_prefs_set_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_TAB_POSITION_BOTTOM, FALSE); - if (value != GTK_POS_LEFT && gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_TAB_POSITION_LEFT)) + if (item != 2 && gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_TAB_POSITION_LEFT)) gnc_prefs_set_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_TAB_POSITION_LEFT, FALSE); - if (value != GTK_POS_RIGHT && gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_TAB_POSITION_RIGHT)) + if (item != 3 && gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_TAB_POSITION_RIGHT)) gnc_prefs_set_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_TAB_POSITION_RIGHT, FALSE); - switch (value) + switch (item) { - case GTK_POS_TOP: + case 0: gnc_prefs_set_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_TAB_POSITION_TOP, TRUE); break; - case GTK_POS_BOTTOM: + case 1: gnc_prefs_set_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_TAB_POSITION_BOTTOM, TRUE); break; - case GTK_POS_LEFT: + case 2: gnc_prefs_set_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_TAB_POSITION_LEFT, TRUE); break; - case GTK_POS_RIGHT: + case 3: gnc_prefs_set_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_TAB_POSITION_RIGHT, TRUE); break; } -#endif + } #ifndef MAC_INTEGRATION @@ -4884,18 +4947,23 @@ gnc_main_window_cmd_window_raise (GSimpleAction *simple, { GncMainWindow *window = (GncMainWindow*)user_data; GncMainWindow *new_window; - gint value; + gint item; - g_return_if_fail(GTK_IS_ACTION(simple)); - g_return_if_fail(GNC_IS_MAIN_WINDOW(window)); + g_return_if_fail (G_IS_SIMPLE_ACTION(simple)); + g_return_if_fail (GNC_IS_MAIN_WINDOW(window)); + + item = g_variant_get_int32 (parameter); + + ENTER("action %p, window %p, item %d", simple, window, item); + + g_action_change_state (G_ACTION(simple), parameter); + + new_window = static_cast(g_list_nth_data (active_windows, item)); + gtk_window_present (GTK_WINDOW(new_window)); - ENTER("action %p, window %p", simple, window); -//FIXMEb value = gtk_radio_action_get_current_value(current); -// new_window = static_cast(g_list_nth_data(active_windows, value)); -// gtk_window_present(GTK_WINDOW(new_window)); /* revert the change in the radio group * impossible while handling "changed" (G_SIGNAL_NO_RECURSE) */ -// g_idle_add((GSourceFunc)gnc_main_window_update_radio_button, window); + g_idle_add ((GSourceFunc)gnc_main_window_update_radio_button, window); LEAVE(" "); } #endif /* !MAC_INTEGRATION */ diff --git a/gnucash/gnome-utils/gnc-plugin-file-history.c b/gnucash/gnome-utils/gnc-plugin-file-history.c index e02ba30a9c..b42726ed85 100644 --- a/gnucash/gnome-utils/gnc-plugin-file-history.c +++ b/gnucash/gnome-utils/gnc-plugin-file-history.c @@ -44,6 +44,7 @@ #include "gnc-engine.h" #include "gnc-prefs.h" #include "gnc-uri-utils.h" +#include "gnc-gtk-utils.h" static GObjectClass *parent_class = NULL; @@ -96,6 +97,12 @@ static GActionEntry gnc_plugin_actions [] = /** The number of actions provided by this plugin. */ static guint gnc_plugin_n_actions = G_N_ELEMENTS(gnc_plugin_actions); +/** The default menu items that need to be add to the menu */ +static const gchar *gnc_plugin_load_ui_items [] = +{ + "FilePlaceholder5", + NULL, +}; /** The instance private data for a file history plugin. This data * structure is unused. */ @@ -407,45 +414,67 @@ gnc_history_update_action (GncMainWindow *window, gint index, const gchar *filename) { - GSimpleActionGroup *simple_action_group; - GAction *action; - gchar *action_name, *label_name, *tooltip, *old_filename; + GncMenuModelSearch *gsm = g_new0 (GncMenuModelSearch, 1); + GtkWidget *menu_item = NULL; + gchar *action_name; gint limit; + gboolean add_item = FALSE; + gint pos; ENTER("window %p, index %d, filename %s", window, index, filename ? filename : "(null)"); - /* Get the action group */ - simple_action_group = gnc_main_window_get_action_group (window, PLUGIN_ACTIONS_NAME); -//FIXMEb action_name = g_strdup_printf ("RecentFile%dAction", index); -// action = g_action_map_lookup_action (G_ACTION_MAP(simple_action_group), action_name); + action_name = g_strdup_printf ("RecentFile%dAction", index); + + gsm->search_action_label = NULL; + gsm->search_action_name = action_name; + + if (!gnc_menubar_model_find_item (gnc_main_window_get_menu_model(window), gsm)) // could not find action_name + { + add_item = TRUE; + gsm->search_action_name = "FilePlaceholder5"; // placeholder + + if (!gnc_menubar_model_find_item (gnc_main_window_get_menu_model(window), gsm)) + { + LEAVE("Could not find 'menu_item' with action name '%s'", action_name); + g_free (gsm); + g_free (action_name); + return; + } + else + pos = gsm->index + index; + } + else + pos = gsm->index; limit = gnc_prefs_get_int (GNC_PREFS_GROUP_HISTORY, GNC_PREF_HISTORY_MAXFILES); if (filename && (strlen(filename) > 0) && (index < limit)) { - /* set the menu label (w/accelerator) */ - label_name = gnc_history_generate_label (index, filename); - tooltip = gnc_history_generate_tooltip (index, filename); -//FIXMEb g_object_set(G_OBJECT(action), "label", label_name, -// "tooltip", tooltip, -// "visible", TRUE, -// NULL); -// g_free(label_name); -// g_free(tooltip); + GMenuItem *item; + gchar *label_name = gnc_history_generate_label (index, filename); + gchar *tooltip = gnc_history_generate_tooltip (index, filename); + gchar *full_action_name = g_strconcat (PLUGIN_ACTIONS_NAME, ".", + action_name, NULL); - /* set the filename for the callback function */ -//FIXMEb old_filename = g_object_get_data(G_OBJECT(action), FILENAME_STRING); -// if (old_filename) -// g_free(old_filename); -//FIXMEb g_object_set_data(G_OBJECT(action), FILENAME_STRING, g_strdup(filename)); + item = g_menu_item_new (label_name, full_action_name); + + g_menu_item_set_attribute (item, "tooltip", "s", tooltip); + + if (!add_item) + g_menu_remove (G_MENU(gsm->model), pos); + + g_menu_insert_item (G_MENU(gsm->model), pos, item); + +//FIXMEb tooltip needs fixing to status bar and accelerator ? + + g_free (full_action_name); + g_free (label_name); + g_free (tooltip); } - else - { -//FIXMEb gtk_action_set_visible(action, FALSE); - } -// g_free (action_name); + g_free (gsm); + g_free (action_name); LEAVE(""); } @@ -465,6 +494,7 @@ gnc_history_update_menus (GncMainWindow *window) guint i; ENTER(""); + for (i = 0; i < MAX_HISTORY_FILES; i++) { pref = gnc_history_index_to_pref_name(i); @@ -548,6 +578,7 @@ gnc_plugin_file_history_class_init (GncPluginFileHistoryClass *klass) plugin_class->actionsb = gnc_plugin_actions; plugin_class->n_actionsb = gnc_plugin_n_actions; plugin_class->ui_filename = PLUGIN_UI_FILENAME; + plugin_class->ui_updates = gnc_plugin_load_ui_items; } G_DEFINE_TYPE_WITH_PRIVATE(GncPluginFileHistory, gnc_plugin_file_history, GNC_TYPE_PLUGIN) @@ -661,21 +692,31 @@ gnc_plugin_file_history_cmd_open_file (GSimpleAction *simple, { GncMainWindowActionData *data = user_data; - gchar *filename; + gchar *filename, *pref, *index; + const gchar *action_name; - g_return_if_fail(GTK_IS_ACTION(simple)); - g_return_if_fail(data != NULL); + g_return_if_fail (G_IS_SIMPLE_ACTION(simple)); + g_return_if_fail (data != NULL); + + // action name will be of the form 'RecentFile1Action' + action_name = g_action_get_name (G_ACTION(simple)); + + index = g_utf8_substring (action_name, 10, 11); + + pref = gnc_history_index_to_pref_name (atoi (index)); + filename = gnc_prefs_get_string (GNC_PREFS_GROUP_HISTORY, pref); + + PINFO("File to open is '%s' on action '%s'", filename, action_name); - /* DRH - Do we need to close all open windows but the first? - * Which progress bar should we be using? One in a window, or - * in a new "file loading" dialog??? - */ - filename = g_object_get_data(G_OBJECT(simple), FILENAME_STRING); gnc_window_set_progressbar_window (GNC_WINDOW(data->window)); /* also opens new account page */ gnc_file_open_file (GTK_WINDOW (data->window), filename, /*open_readonly*/ FALSE); gnc_window_set_progressbar_window (NULL); + + g_free (pref); + g_free (filename); + g_free (index); } /** @} */ diff --git a/gnucash/gnucash-gresources.xml b/gnucash/gnucash-gresources.xml index 8979d20d7e..283b60d557 100644 --- a/gnucash/gnucash-gresources.xml +++ b/gnucash/gnucash-gresources.xml @@ -13,6 +13,7 @@ ui/gnc-plugin-csv-export.ui ui/gnc-plugin-csv-import.ui ui/gnc-plugin-customer-import.ui + ui/gnc-plugin-file-history.ui ui/gnc-plugin-log-replay.ui ui/gnc-plugin-register.ui ui/gnc-plugin-report-system.ui diff --git a/gnucash/ui/gnc-main-window.ui b/gnucash/ui/gnc-main-window.ui index fa1ce1045c..8ed6641b39 100644 --- a/gnucash/ui/gnc-main-window.ui +++ b/gnucash/ui/gnc-main-window.ui @@ -466,6 +466,12 @@ mainwin.WindowsPlaceholder1 action-disabled + + Window0Action + mainwin.Window0Action + 0 + action-disabled +
diff --git a/gnucash/ui/gnc-plugin-file-history.ui b/gnucash/ui/gnc-plugin-file-history.ui new file mode 100644 index 0000000000..c944bd6a04 --- /dev/null +++ b/gnucash/ui/gnc-plugin-file-history.ui @@ -0,0 +1,12 @@ + + + + + + RecentFile0Action + gnc-plugin-file-history-actions.RecentFile0Action + Edit the properties of the current file + + + + From fb5acb26730497111af925d55a17807a86f6f89d Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Fri, 28 Oct 2022 16:17:57 +0100 Subject: [PATCH 11/77] Menu changes for cut/copy and paste --- gnucash/gnome-utils/gnc-main-window.cpp | 210 +++++++++++++++++++----- gnucash/gnome-utils/gnc-main-window.h | 4 + 2 files changed, 173 insertions(+), 41 deletions(-) diff --git a/gnucash/gnome-utils/gnc-main-window.cpp b/gnucash/gnome-utils/gnc-main-window.cpp index ad070dd829..9106a30cf0 100644 --- a/gnucash/gnome-utils/gnc-main-window.cpp +++ b/gnucash/gnome-utils/gnc-main-window.cpp @@ -173,6 +173,7 @@ static void gnc_main_window_plugin_removed (GncPlugin *manager, GncPlugin *plugi static void gnc_main_window_engine_commit_error_callback( gpointer data, QofBackendError errcode ); /* Command callbacks */ +static void gnc_main_window_cmd_redirect (GSimpleAction *simple, GVariant *paramter, gpointer user_data); static void gnc_main_window_cmd_page_setup (GSimpleAction *simple, GVariant *paramter, gpointer user_data); static void gnc_main_window_cmd_file_properties (GSimpleAction *simple, GVariant *paramter, gpointer user_data); static void gnc_main_window_cmd_file_close (GSimpleAction *simple, GVariant *paramter, gpointer user_data); @@ -210,6 +211,8 @@ static void gnc_quartz_shutdown (GtkosxApplication *theApp, gpointer data); static gboolean gnc_quartz_should_quit (GtkosxApplication *theApp, GncMainWindow *window); static void gnc_quartz_set_menu (GncMainWindow* window); #endif +static void gnc_main_window_init_menu_updaters (GncMainWindow *window); + /** The instance private data structure for an embedded window * object. */ @@ -315,26 +318,32 @@ static GActionEntry gnc_menu_actions [] = { "FilePageSetupAction", gnc_main_window_cmd_page_setup, nullptr, nullptr, nullptr }, { "FilePropertiesAction", gnc_main_window_cmd_file_properties, nullptr, nullptr, nullptr }, { "FileCloseAction", gnc_main_window_cmd_file_close, nullptr, nullptr, nullptr }, + { "FilePrintAction", gnc_main_window_cmd_redirect, nullptr, nullptr, nullptr }, { "FileQuitAction", gnc_main_window_cmd_file_quit, nullptr, nullptr, nullptr }, + { "EditCutAction", gnc_main_window_cmd_edit_cut, nullptr, nullptr, nullptr }, { "EditCopyAction", gnc_main_window_cmd_edit_copy, nullptr, nullptr, nullptr }, { "EditPasteAction", gnc_main_window_cmd_edit_paste, nullptr, nullptr, nullptr }, { "EditPreferencesAction", gnc_main_window_cmd_edit_preferences, nullptr, nullptr, nullptr }, - { "ViewRefreshAction", gnc_main_window_cmd_view_refresh, nullptr, nullptr, nullptr }, + { "ActionsForgetWarningsAction", gnc_main_window_cmd_actions_reset_warnings, nullptr, nullptr, nullptr }, { "ActionsRenamePageAction", gnc_main_window_cmd_actions_rename_page, nullptr, nullptr, nullptr }, - { "WindowNewAction", gnc_main_window_cmd_window_new, nullptr, nullptr, nullptr }, - { "WindowMovePageAction", gnc_main_window_cmd_window_move_page, nullptr, nullptr, nullptr }, - { "HelpTutorialAction", gnc_main_window_cmd_help_tutorial, nullptr, nullptr, nullptr }, - { "HelpContentsAction", gnc_main_window_cmd_help_contents, nullptr, nullptr, nullptr }, - { "HelpAboutAction", gnc_main_window_cmd_help_about, nullptr, nullptr, nullptr }, + { "ViewSortByAction", nullptr, nullptr, nullptr, nullptr }, + { "ViewFilterByAction", nullptr, nullptr, nullptr, nullptr }, + { "ViewRefreshAction", gnc_main_window_cmd_view_refresh, nullptr, nullptr, nullptr }, { "ViewToolbarAction", gnc_main_window_cmd_view_toolbar, nullptr, "true", toggle_change_state }, { "ViewSummaryAction", gnc_main_window_cmd_view_summary, nullptr, "true", toggle_change_state }, { "ViewStatusbarAction", gnc_main_window_cmd_view_statusbar, nullptr, "true", toggle_change_state }, - { "ViewTabPositionAction", gnc_main_window_cmd_view_tab_position, "i", "@i 0", radio_change_state }, + + { "WindowNewAction", gnc_main_window_cmd_window_new, nullptr, nullptr, nullptr }, + { "WindowMovePageAction", gnc_main_window_cmd_window_move_page, nullptr, nullptr, nullptr }, { "Window0Action", gnc_main_window_cmd_window_raise, "i", "@i 0", radio_change_state }, + + { "HelpTutorialAction", gnc_main_window_cmd_help_tutorial, nullptr, nullptr, nullptr }, + { "HelpContentsAction", gnc_main_window_cmd_help_contents, nullptr, nullptr, nullptr }, + { "HelpAboutAction", gnc_main_window_cmd_help_about, nullptr, nullptr, nullptr }, }; /** The number of actions provided by the main window. */ static guint gnc_menu_n_actions = G_N_ELEMENTS(gnc_menu_actions); @@ -1002,7 +1011,7 @@ gnc_main_window_restore_all_windows(const GKeyFile *keyfile) } void -gnc_main_window_restore_default_state(GncMainWindow *window) +gnc_main_window_restore_default_state (GncMainWindow *window) { GAction *action; @@ -3694,7 +3703,8 @@ gnc_main_window_actions_updated (GncMainWindow *window) struct group_iterate { GAction *action; - const gchar *name; + const gchar *group_name; + const gchar *action_name; }; static void @@ -3706,10 +3716,16 @@ group_foreach_cb (gpointer key, gpointer item, gpointer arg) if (iter->action) return; + if (iter->group_name != nullptr) + { + if (g_strcmp0 (iter->group_name, (gchar*)key) != 0) + return; + } + auto entry{static_cast(item)}; action = g_action_map_lookup_action (G_ACTION_MAP(entry->simple_action_group), - iter->name); + iter->action_name); if (action) iter->action = action; @@ -3717,6 +3733,22 @@ group_foreach_cb (gpointer key, gpointer item, gpointer arg) GAction * gnc_main_window_find_action (GncMainWindow *window, const gchar *name) +{ + GncMainWindowPrivate *priv; + GAction *action = nullptr; + + priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); + + action = g_action_map_lookup_action (G_ACTION_MAP(priv->simple_action_group), + name); + + return action; +} + +GAction * +gnc_main_window_find_action_in_group (GncMainWindow *window, + const gchar *group_name, + const gchar *name) { GncMainWindowPrivate *priv; GAction *action = nullptr; @@ -3728,7 +3760,8 @@ gnc_main_window_find_action (GncMainWindow *window, const gchar *name) return nullptr; iter.action = nullptr; - iter.name = name; + iter.action_name = name; + iter.group_name = group_name; g_hash_table_foreach (priv->merged_actions_table, group_foreach_cb, &iter); @@ -3827,10 +3860,11 @@ gnc_main_window_update_edit_actions_sensitivity (GncMainWindow *window, gboolean GncPluginPage *page; GtkWidget *widget = gtk_window_get_focus (GTK_WINDOW (window)); GAction *action; - gboolean can_copy = FALSE, can_cut = FALSE, can_paste = FALSE; + gboolean can_copy = false, can_cut = false, can_paste = false; priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); page = priv->current_page; + if (page && GNC_PLUGIN_PAGE_GET_CLASS(page)->update_edit_menu_actions) { (GNC_PLUGIN_PAGE_GET_CLASS(page)->update_edit_menu_actions)(page, hide); @@ -3865,23 +3899,21 @@ gnc_main_window_update_edit_actions_sensitivity (GncMainWindow *window, gboolean { #ifdef ORIGINAL_EPIPHANY_CODE /* For now we assume all actions are possible */ - can_copy = can_cut = can_paste = TRUE; + can_copy = can_cut = can_paste = true; #else /* If its not a GtkEditable, we don't know what to do * with it. */ - can_copy = can_cut = can_paste = FALSE; + can_copy = can_cut = can_paste = false; #endif } - action = gnc_main_window_find_action (window, "EditCopyAction"); g_simple_action_set_enabled (G_SIMPLE_ACTION(action), can_copy); -//FIXMEb gtk_action_set_visible (action, !hide || can_copy); + action = gnc_main_window_find_action (window, "EditCutAction"); g_simple_action_set_enabled (G_SIMPLE_ACTION(action), can_cut); -//FIXMEb gtk_action_set_visible (action, !hide || can_cut); + action = gnc_main_window_find_action (window, "EditPasteAction"); g_simple_action_set_enabled (G_SIMPLE_ACTION(action), can_paste); -//FIXMEb gtk_action_set_visible (action, !hide || can_paste); } static void @@ -3890,14 +3922,14 @@ gnc_main_window_enable_edit_actions_sensitivity (GncMainWindow *window) GAction *action; action = gnc_main_window_find_action (window, "EditCopyAction"); - g_simple_action_set_enabled (G_SIMPLE_ACTION(action), TRUE); -//FIXMEb gtk_action_set_visible (action, TRUE); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), true); + action = gnc_main_window_find_action (window, "EditCutAction"); - g_simple_action_set_enabled (G_SIMPLE_ACTION(action), TRUE); -//FIXMEb gtk_action_set_visible (action, TRUE); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), true); + action = gnc_main_window_find_action (window, "EditPasteAction"); - g_simple_action_set_enabled (G_SIMPLE_ACTION(action), TRUE); -//FIXMEb gtk_action_set_visible (action, TRUE); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), true); + } static void @@ -3917,17 +3949,26 @@ gnc_main_window_edit_menu_hide_cb (GtkWidget *menu, static void gnc_main_window_init_menu_updaters (GncMainWindow *window) { + GncMainWindowPrivate *priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); + GncMenuModelSearch *gsm = g_new0 (GncMenuModelSearch, 1); GtkWidget *edit_menu_item, *edit_menu; -//FIXMEb -// edit_menu_item = gtk_ui_manager_get_widget -// (window->ui_merge, "/menubar/Edit"); -// edit_menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (edit_menu_item)); + gsm->search_action_label = nullptr; + gsm->search_action_name = "EditAction"; -// g_signal_connect (edit_menu, "show", -// G_CALLBACK (gnc_main_window_edit_menu_show_cb), window); -// g_signal_connect (edit_menu, "hide", -// G_CALLBACK (gnc_main_window_edit_menu_hide_cb), window); + if (!gnc_menubar_model_find_item (priv->menubar_model, gsm)) + return; + + edit_menu_item = gnc_find_menu_item_by_action_label (priv->menubar, + gsm->search_action_label); + + edit_menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM(edit_menu_item)); + + g_signal_connect (edit_menu, "show", + G_CALLBACK(gnc_main_window_edit_menu_show_cb), window); + g_signal_connect (edit_menu, "hide", + G_CALLBACK(gnc_main_window_edit_menu_hide_cb), window); + g_free (gsm); } static void @@ -3971,6 +4012,36 @@ gnc_main_window_page_focus_in (GtkWidget *widget, GdkEvent *event, return FALSE; } +static GAction * +gnc_main_window_get_redirect (GncMainWindow *window, const gchar *action_name) +{ + GncMainWindowPrivate *priv; + GAction *action = nullptr; + const gchar *group_name; + + g_return_val_if_fail (GNC_IS_MAIN_WINDOW (window), nullptr); + g_return_val_if_fail (action_name != nullptr, nullptr); + + priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); + + group_name = gnc_plugin_page_get_simple_action_group_name (priv->current_page); + + PINFO("action anme is '%s', group_name is '%s'", action_name, group_name); + + if (group_name) + { + action = gnc_main_window_find_action_in_group (window, group_name, action_name); + + if (!action) + action = gnc_plugin_page_get_action (priv->current_page, action_name); + } + + PINFO("Redirect action is %p for action anme '%s' and group_name '%s'", + action, action_name, group_name); + return action; +} + + static void gnc_main_window_setup_window (GncMainWindow *window) { @@ -3979,6 +4050,8 @@ gnc_main_window_setup_window (GncMainWindow *window) // guint merge_id; GtkBuilder *builder; GncPluginManager *manager; + GtkAccelGroup *accel_group = gtk_accel_group_new (); + GtkWidget *extra_item; GList *plugins; GError *error = nullptr; gchar *filename; @@ -4032,7 +4105,7 @@ gnc_main_window_setup_window (GncMainWindow *window) 0.01); builder = gtk_builder_new (); - + gtk_builder_set_translation_domain (builder, PROJECT_NAME); gtk_builder_add_from_resource (builder, "/org/gnucash/ui/gnc-main-window.ui", &error); if (error) @@ -4047,6 +4120,10 @@ gnc_main_window_setup_window (GncMainWindow *window) gtk_container_add (GTK_CONTAINER(priv->menu_dock), priv->menubar); //FIXMEb this may need changing gtk_widget_show (GTK_WIDGET(priv->menubar)); + // need to add the accelerator keys + gtk_window_add_accel_group (GTK_WINDOW(window), accel_group); + gnc_add_accelerator_keys_for_menu (GTK_WIDGET(priv->menubar), accel_group); + priv->toolbar = (GtkWidget *)gtk_builder_get_object (builder, "mainwin-toolbar"); g_object_set (priv->toolbar, "toolbar-style", GTK_TOOLBAR_BOTH, NULL); gtk_container_add (GTK_CONTAINER(priv->menu_dock), GTK_WIDGET(priv->toolbar)); //FIXMEb this may need changing @@ -4056,6 +4133,7 @@ gnc_main_window_setup_window (GncMainWindow *window) /* Create menu and toolbar information */ // priv->action_group = gtk_action_group_new ("MainWindowActions"); + priv->simple_action_group = g_simple_action_group_new (); //FIXMEb gtk_action_group_set_translation_domain (priv->action_group, PROJECT_NAME); @@ -4090,13 +4168,8 @@ gnc_main_window_setup_window (GncMainWindow *window) //FIXMEb g_signal_connect (G_OBJECT (window->ui_merge), "connect-proxy", // G_CALLBACK (gnc_window_connect_proxy), priv->statusbar); - - - // filename = gnc_filepath_locate_ui_file("gnc-main-window.ui"); - - // merge_id = gtk_ui_manager_add_ui_from_file (window->ui_merge, // filename, &error); // g_assert(merge_id || error); @@ -4136,11 +4209,10 @@ gnc_main_window_setup_window (GncMainWindow *window) GNC_PREF_TAB_POSITION_RIGHT, (gpointer)gnc_main_window_update_tab_position, window); - gnc_main_window_update_tab_position(nullptr, nullptr, window); + gnc_main_window_update_tab_position (nullptr, nullptr, window); - gnc_main_window_init_menu_updaters(window); + gnc_main_window_init_menu_updaters (window); - /* Testing */ /* Now update the "eXtensions" menu */ if (!gnc_prefs_is_extra_enabled()) { @@ -4432,6 +4504,26 @@ gnc_main_window_plugin_removed (GncPlugin *manager, /* Command callbacks */ +static void +gnc_main_window_cmd_redirect (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) +{ + GncMainWindow *window = (GncMainWindow*)user_data; + GAction *redirect_action; + + PINFO("Redirect action_is %p, name is '%s'", simple, g_action_get_name (G_ACTION(simple))); + + redirect_action = gnc_main_window_get_redirect (window, g_action_get_name (G_ACTION(simple))); + + if (redirect_action) + { + PINFO("Found action %p", redirect_action); + g_action_activate (redirect_action, nullptr); + return; + } +} + static void gnc_main_window_cmd_page_setup (GSimpleAction *simple, GVariant *parameter, @@ -4627,6 +4719,18 @@ gnc_main_window_cmd_edit_cut (GSimpleAction *simple, { GncMainWindow *window = (GncMainWindow*)user_data; GtkWidget *widget = gtk_window_get_focus (GTK_WINDOW(window)); + GAction *redirect_action; + + PINFO("Copy action_is %p, name is '%s'", simple, g_action_get_name (G_ACTION(simple))); + + redirect_action = gnc_main_window_get_redirect (window, g_action_get_name (G_ACTION(simple))); + + if (redirect_action) + { + PINFO("Found action %p", redirect_action); + g_action_activate (redirect_action, nullptr); + return; + } if (GTK_IS_EDITABLE(widget)) { @@ -4651,6 +4755,18 @@ gnc_main_window_cmd_edit_copy (GSimpleAction *simple, { GncMainWindow *window = (GncMainWindow*)user_data; GtkWidget *widget = gtk_window_get_focus (GTK_WINDOW(window)); + GAction *redirect_action; + + PINFO("Copy action_is %p, name is '%s'", simple, g_action_get_name (G_ACTION(simple))); + + redirect_action = gnc_main_window_get_redirect (window, g_action_get_name (G_ACTION(simple))); + + if (redirect_action) + { + PINFO("Found action %p", redirect_action); + g_action_activate (redirect_action, nullptr); + return; + } if (GTK_IS_EDITABLE(widget)) { @@ -4673,6 +4789,18 @@ gnc_main_window_cmd_edit_paste (GSimpleAction *simple, { GncMainWindow *window = (GncMainWindow*)user_data; GtkWidget *widget = gtk_window_get_focus (GTK_WINDOW(window)); + GAction *redirect_action; + + PINFO("Paste action_is %p, name is '%s'", simple, g_action_get_name (G_ACTION(simple))); + + redirect_action = gnc_main_window_get_redirect (window, g_action_get_name (G_ACTION(simple))); + + if (redirect_action) + { + PINFO("Found action %p", redirect_action); + g_action_activate (redirect_action, nullptr); + return; + } if (GTK_IS_EDITABLE(widget)) { diff --git a/gnucash/gnome-utils/gnc-main-window.h b/gnucash/gnome-utils/gnc-main-window.h index 61abce5119..8b9c839d43 100644 --- a/gnucash/gnome-utils/gnc-main-window.h +++ b/gnucash/gnome-utils/gnc-main-window.h @@ -434,6 +434,10 @@ void gnc_main_window_all_action_set_sensitive (const gchar *action_name, gboolea */ GAction *gnc_main_window_find_action (GncMainWindow *window, const gchar *name); +GAction *gnc_main_window_find_action_in_group (GncMainWindow *window, + const gchar *group_name, + const gchar *name); //FIXMEb added + GtkWidget *gnc_main_window_get_menu (GncMainWindow *window); //FIXMEb added GMenuModel *gnc_main_window_get_menu_model (GncMainWindow *window); //FIXMEb added From b3a24034c8efe4ea6cc1bd81f5559e2a5283cbad Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Fri, 28 Oct 2022 16:21:24 +0100 Subject: [PATCH 12/77] Start of changes to load main window menu items on page focus --- gnucash/gnome-utils/gnc-main-window.cpp | 324 ++++++++++++++++++++++-- gnucash/gnome-utils/gnc-main-window.h | 14 + gnucash/gnome-utils/gnc-plugin-page.c | 29 +++ gnucash/gnome-utils/gnc-plugin-page.h | 3 + gnucash/ui/gnc-main-window.ui | 14 + 5 files changed, 361 insertions(+), 23 deletions(-) diff --git a/gnucash/gnome-utils/gnc-main-window.cpp b/gnucash/gnome-utils/gnc-main-window.cpp index 9106a30cf0..303da45a21 100644 --- a/gnucash/gnome-utils/gnc-main-window.cpp +++ b/gnucash/gnome-utils/gnc-main-window.cpp @@ -95,6 +95,7 @@ enum { PAGE_ADDED, PAGE_CHANGED, + MENU_CHANGED, //FIXMEb added LAST_SIGNAL }; @@ -266,6 +267,13 @@ typedef struct GncMainWindowPrivate /** Set when restoring plugin pages */ gboolean restoring_pages; + const gchar *previous_plugin_page_name; //FIXMEb added + const gchar *previous_menu_qualifier; //FIXMEb added + GtkAccelGroup *previous_plugin_page_accel_group; //FIXMEb added + + GHashTable *display_item_hash; //FIXMEb added + gint num_item_q; //FIXMEb temp added + } GncMainWindowPrivate; GNC_DEFINE_TYPE_WITH_CODE(GncMainWindow, gnc_main_window, GTK_TYPE_WINDOW, @@ -329,6 +337,8 @@ static GActionEntry gnc_menu_actions [] = { "ActionsForgetWarningsAction", gnc_main_window_cmd_actions_reset_warnings, nullptr, nullptr, nullptr }, { "ActionsRenamePageAction", gnc_main_window_cmd_actions_rename_page, nullptr, nullptr, nullptr }, + { "TransactionAction", nullptr, nullptr, nullptr, nullptr }, + { "ViewSortByAction", nullptr, nullptr, nullptr, nullptr }, { "ViewFilterByAction", nullptr, nullptr, nullptr, nullptr }, { "ViewRefreshAction", gnc_main_window_cmd_view_refresh, nullptr, nullptr, nullptr }, @@ -337,6 +347,8 @@ static GActionEntry gnc_menu_actions [] = { "ViewStatusbarAction", gnc_main_window_cmd_view_statusbar, nullptr, "true", toggle_change_state }, { "ViewTabPositionAction", gnc_main_window_cmd_view_tab_position, "i", "@i 0", radio_change_state }, + { "ScheduledAction", nullptr, nullptr, nullptr, nullptr }, + { "WindowNewAction", gnc_main_window_cmd_window_new, nullptr, nullptr, nullptr }, { "WindowMovePageAction", gnc_main_window_cmd_window_move_page, nullptr, nullptr, nullptr }, { "Window0Action", gnc_main_window_cmd_window_raise, "i", "@i 0", radio_change_state }, @@ -703,6 +715,7 @@ gnc_main_window_restore_window (GncMainWindow *window, GncMainWindowSaveData *da gchar *window_group; gsize page_start, page_count, i; GError *error = nullptr; + GtkAccelGroup *accel_group = gtk_accel_group_new (); /* Setup */ ENTER("window %p, data %p (key file %p, window %d)", @@ -844,6 +857,11 @@ gnc_main_window_restore_window (GncMainWindow *window, GncMainWindowSaveData *da gtk_window_maximize(GTK_WINDOW(window)); } +//FIXMEb not sure if this is in the right place + // need to add the accelerator keys + gtk_window_add_accel_group (GTK_WINDOW(window), accel_group); + gnc_add_accelerator_keys_for_menu (GTK_WIDGET(priv->menubar), accel_group); + /* Common view menu items */ action = gnc_main_window_find_action (window, "ViewToolbarAction"); if (action) @@ -2814,6 +2832,24 @@ gnc_main_window_class_init (GncMainWindowClass *klass) G_TYPE_NONE, 1, G_TYPE_OBJECT); + /** + * GncMainWindow::menu_changed: + * @param window: the #GncMainWindow + * @param page: the #GncPluginPage + * + * The "menu_changed" signal is emitted when the menu has been + * changed. This can be used to adjust other menu actions. + */ + main_window_signals[MENU_CHANGED] = + g_signal_new ("menu_changed", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (GncMainWindowClass, menu_changed), + nullptr, nullptr, + g_cclosure_marshal_VOID__OBJECT, + G_TYPE_NONE, 1, + G_TYPE_OBJECT); + gnc_prefs_register_cb (GNC_PREFS_GROUP_GENERAL, GNC_PREF_SHOW_CLOSE_BUTTON, (gpointer)gnc_main_window_update_tab_close, @@ -2858,6 +2894,14 @@ gnc_main_window_init (GncMainWindow *window, void *data) priv->restoring_pages = FALSE; + priv->display_item_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, nullptr); + priv->num_item_q = 0; //FIXMEb temp addded + + + priv->previous_plugin_page_name = nullptr; + priv->previous_menu_qualifier = nullptr; + priv->previous_plugin_page_accel_group = nullptr; + /* Get the show_color_tabs value preference */ priv->show_color_tabs = gnc_prefs_get_bool(GNC_PREFS_GROUP_GENERAL, GNC_PREF_TAB_COLOR); @@ -2995,6 +3039,8 @@ gnc_main_window_destroy (GtkWidget *widget) g_hash_table_destroy (priv->merged_actions_table); priv->merged_actions_table = nullptr; + g_hash_table_destroy (priv->display_item_hash); + /* GncPluginManager stuff */ manager = gnc_plugin_manager_get (); plugins = gnc_plugin_manager_get_plugins (manager); @@ -3621,8 +3667,8 @@ gnc_main_window_merge_actions (GncMainWindow *window, gtk_widget_insert_action_group (GTK_WIDGET(window), group_name, G_ACTION_GROUP(entry->simple_action_group)); - update_menu_model (window, ui_filename, ui_updates); - + if (ui_filename) + update_menu_model (window, ui_filename, ui_updates); //FIXMEb this is where I might need to add GtkBuilder???? @@ -3793,6 +3839,226 @@ gnc_main_window_get_action_group (GncMainWindow *window, return entry->simple_action_group; } +//FIXMEb## + + +GtkWidget * +gnc_main_window_toolbar_find_menu_item (GncMainWindow *window, const gchar *action_name) +{ + GncMainWindowPrivate *priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); + return gnc_find_toolbar_item (priv->toolbar, action_name); +} + +GtkWidget * +gnc_main_window_menu_find_menu_item (GncMainWindow *window, const gchar *action_name) +{ + GncMainWindowPrivate *priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); + GncMenuModelSearch *gsm = g_new0 (GncMenuModelSearch, 1); + GtkWidget *menu_item = GTK_WIDGET(g_hash_table_lookup (priv->display_item_hash, action_name)); + + priv->num_item_q++; //FIXMEb temp added + + if (!menu_item) + { + gsm->search_action_label = nullptr; + gsm->search_action_name = action_name; + + if (gnc_menubar_model_find_item (priv->menubar_model, gsm)) + { + menu_item = gnc_find_menu_item_by_action_label (priv->menubar, + gsm->search_action_label); + + g_hash_table_insert (priv->display_item_hash, g_strdup (action_name), menu_item); + } + } + g_free (gsm); + return menu_item; +} + + +void +gnc_main_window_menu_item_vis_by_action (GncMainWindow *window, + const gchar **action_names, + gboolean vis) +{ + GncMainWindowPrivate *priv; + + g_return_if_fail (GNC_IS_MAIN_WINDOW(window)); + + priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); + + for (gint i = 0; action_names[i]; i++) + { + GtkWidget *tool_item = gnc_find_toolbar_item (priv->toolbar, action_names[i]); + GtkWidget *menu_item = gnc_main_window_menu_find_menu_item (window, action_names[i]); + + if (menu_item) + { + PINFO("Found menu_item %p with action name '%s', seting vis to '%s'", + menu_item, action_names[i], vis ? "true" : "false"); + gtk_widget_set_visible (menu_item, vis); + } + else + { + PINFO("Did not find menu_item with action name '%s' to set vis '%s'", action_names[i], vis ? "true" : "false"); + } + + if (tool_item) + { + PINFO("Found tool_item %p with action name '%s', seting vis to '%s'", + tool_item, action_names[i], vis ? "true" : "false"); + gtk_widget_set_visible (tool_item, vis); + } + else + { + PINFO("Did not find tool_item with action name '%s' to set vis '%s'\n", action_names[i], vis ? "true" : "false"); + } + } +} + + +static void +gnc_main_window_update_toolbar (GncMainWindow *window, GncPluginPage *page, + const gchar *toolbar_qualifier) +{ + GncMainWindowPrivate *priv; + GtkBuilder *builder; + GAction *action = gnc_main_window_find_action (window, "ViewToolbarAction"); + + g_return_if_fail (GNC_IS_MAIN_WINDOW(window)); + g_return_if_fail (GNC_IS_PLUGIN_PAGE(page)); + + priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); + + builder = gnc_plugin_page_get_builder (page); + + if (builder) + { + gchar *toolbar_name; + gtk_container_remove (GTK_CONTAINER(priv->menu_dock), priv->toolbar); + + if (toolbar_qualifier) + toolbar_name = g_strconcat ("mainwin-toolbar-", toolbar_qualifier, nullptr); + else + toolbar_name = g_strdup ("mainwin-toolbar"); + + priv->toolbar = (GtkWidget *)gtk_builder_get_object (builder, toolbar_name); + + if (!priv->toolbar) + priv->toolbar = (GtkWidget *)gtk_builder_get_object (builder, "mainwin-toolbar"); + + g_object_set (priv->toolbar, "toolbar-style", GTK_TOOLBAR_BOTH, NULL); + gtk_container_add (GTK_CONTAINER(priv->menu_dock), priv->toolbar); + g_free (toolbar_name); + } + + // set visibility of toolbar + if (action) + { + GVariant *state = g_action_get_state (G_ACTION(action)); + gtk_widget_set_visible (priv->toolbar, g_variant_get_boolean (state)); + g_variant_unref (state); + } +} + + +void +gnc_main_window_update_menu (GncMainWindow *window, GncPluginPage *page, + const gchar **ui_updates) +{ + GncMainWindowPrivate *priv; + GtkAccelGroup *accel_group; + const gchar *plugin_page_actions_group_name; + GtkBuilder *builder; + const gchar *menu_qualifier; + + GMenuModel *menu_model_part; + GncMenuModelSearch *gsm = g_new0 (GncMenuModelSearch, 1); + + + g_return_if_fail (GNC_IS_MAIN_WINDOW(window)); + g_return_if_fail (page != nullptr); + g_return_if_fail (ui_updates != nullptr); + + priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); + + builder = gnc_plugin_page_get_builder (page); + + if (!builder) + return; + + menu_qualifier = gnc_plugin_page_get_menu_qualifier (page); + + plugin_page_actions_group_name = gnc_plugin_page_get_simple_action_group_name (page); + + if (!plugin_page_actions_group_name) + return; + + gtk_widget_insert_action_group (GTK_WIDGET(window), gnc_plugin_page_get_simple_action_group_name (page), + G_ACTION_GROUP(gnc_plugin_page_get_action_groupb (page))); + + if ((g_strcmp0 (priv->previous_plugin_page_name, + plugin_page_actions_group_name) == 0) && + (g_strcmp0 (priv->previous_menu_qualifier, + menu_qualifier) == 0)) + return; + + priv->previous_plugin_page_name = plugin_page_actions_group_name; + priv->previous_menu_qualifier = menu_qualifier; + + gnc_main_window_update_toolbar (window, page, menu_qualifier); + + + PERR("Display Item Hash size %d", g_hash_table_size (priv->display_item_hash)); //FIXMEb temp added + PERR("Display Item Q %d", priv->num_item_q); //FIXMEb temp added + + // reset hash table and remove added menu items + g_hash_table_remove_all (priv->display_item_hash); + gnc_menubar_model_remove_items_with_attrib (priv->menubar_model, "temp"); + priv->num_item_q = 0; //FIXMEb temp added + + for (gint i = 0; ui_updates[i]; i++) + { + gchar *menu_name; + + if (menu_qualifier) + menu_name = g_strconcat (ui_updates[i], "-", menu_qualifier, nullptr); + else + menu_name = g_strdup (ui_updates[i]); + + menu_model_part = (GMenuModel *)gtk_builder_get_object (builder, menu_name); + + if (!menu_model_part) + menu_model_part = (GMenuModel *)gtk_builder_get_object (builder, ui_updates[i]); + + gsm->search_action_label = nullptr; + gsm->search_action_name = ui_updates[i]; + + if (gnc_menubar_model_find_item (priv->menubar_model, gsm)) + { + g_menu_insert_section (G_MENU(gsm->model), gsm->index, NULL, G_MENU_MODEL(menu_model_part)); + } + else + PERR("Could not find '%s' in menu model", ui_updates[i]); + + g_free (menu_name); + } + + // remove existing accelerator group + if (priv->previous_plugin_page_accel_group) + gtk_window_remove_accel_group (GTK_WINDOW(window), priv->previous_plugin_page_accel_group); + + priv->previous_plugin_page_accel_group = gnc_plugin_page_get_accel_group (page); + + // need to add the accelerator keys + gnc_add_accelerator_keys_for_menu (priv->menubar, priv->previous_plugin_page_accel_group); + gtk_window_add_accel_group (GTK_WINDOW(window), priv->previous_plugin_page_accel_group); + + // need to signal menu has been changed + g_signal_emit_by_name (window, "menu_changed", page); + + g_free (gsm); +} static void @@ -3950,17 +4216,9 @@ static void gnc_main_window_init_menu_updaters (GncMainWindow *window) { GncMainWindowPrivate *priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); - GncMenuModelSearch *gsm = g_new0 (GncMenuModelSearch, 1); GtkWidget *edit_menu_item, *edit_menu; - gsm->search_action_label = nullptr; - gsm->search_action_name = "EditAction"; - - if (!gnc_menubar_model_find_item (priv->menubar_model, gsm)) - return; - - edit_menu_item = gnc_find_menu_item_by_action_label (priv->menubar, - gsm->search_action_label); + edit_menu_item = gnc_main_window_menu_find_menu_item (window, "EditAction"); edit_menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM(edit_menu_item)); @@ -3968,7 +4226,6 @@ gnc_main_window_init_menu_updaters (GncMainWindow *window) G_CALLBACK(gnc_main_window_edit_menu_show_cb), window); g_signal_connect (edit_menu, "hide", G_CALLBACK(gnc_main_window_edit_menu_hide_cb), window); - g_free (gsm); } static void @@ -4149,9 +4406,9 @@ gnc_main_window_setup_window (GncMainWindow *window) gnc_plugin_update_actionsb (priv->simple_action_group, always_insensitive_actions, "sensitive", FALSE); - gnc_plugin_update_actionsb (priv->simple_action_group, - always_hidden_actions, - "visible", FALSE); + + gnc_main_window_menu_item_vis_by_action (window, + always_hidden_actions, false); //FIXMEb gnc_plugin_set_important_actions (priv->action_group, // gnc_menu_important_actions); @@ -5495,32 +5752,53 @@ gnc_main_window_set_progressbar_window (GncMainWindow *window) * request). */ static void -do_popup_menu(GncPluginPage *page, GdkEventButton *event) +do_popup_menu (GncPluginPage *page, GdkEventButton *event) { -// GtkUIManager *ui_merge; GtkBuilder *builder; + GMenuModel *menu_model; GtkWidget *menu; + const gchar *menu_qualifier; + gchar *popup_menu_name; - g_return_if_fail(GNC_IS_PLUGIN_PAGE(page)); + g_return_if_fail (GNC_IS_PLUGIN_PAGE(page)); ENTER("page %p, event %p", page, event); -//FIXME builder = gnc_plugin_page_get_builder (page); -//I think this should be using builder here instaed of UIManager -#ifdef skip + + builder = gnc_plugin_page_get_builder (page); + + menu_qualifier = gnc_plugin_page_get_menu_qualifier (page); + if (builder == nullptr) { LEAVE("no builder"); return; } + gtk_builder_set_translation_domain (builder, PROJECT_NAME); + + if (menu_qualifier) + popup_menu_name = g_strconcat ("mainwin-popup-", menu_qualifier, NULL); + else + popup_menu_name = g_strdup ("mainwin-popup"); + + menu_model = (GMenuModel *)gtk_builder_get_object (builder, popup_menu_name); + + if (!menu_model) + menu_model = (GMenuModel *)gtk_builder_get_object (builder, "mainwin-popup"); + + menu = gtk_menu_new_from_model (menu_model); + +//FIXMEb maybe i should save these once built to reuse -// menu = gtk_ui_manager_get_widget(ui_merge, "/MainPopup"); if (!menu) { LEAVE("no menu"); return; } + gtk_menu_attach_to_widget (GTK_MENU(menu), GTK_WIDGET(page->window), nullptr); gtk_menu_popup_at_pointer (GTK_MENU(menu), (GdkEvent *) event); -#endif + + g_free (popup_menu_name); + LEAVE(" "); } diff --git a/gnucash/gnome-utils/gnc-main-window.h b/gnucash/gnome-utils/gnc-main-window.h index 8b9c839d43..22655ff6eb 100644 --- a/gnucash/gnome-utils/gnc-main-window.h +++ b/gnucash/gnome-utils/gnc-main-window.h @@ -91,6 +91,8 @@ typedef struct GncPluginPage *page); void (*page_changed) (GncMainWindow *window, GncPluginPage *page); + void (*menu_changed) (GncMainWindow *window, + GncPluginPage *page); //FIXMEb added } GncMainWindowClass; typedef struct @@ -297,6 +299,15 @@ void gnc_main_window_unmerge_actions (GncMainWindow *window, */ void gnc_main_window_actions_updated (GncMainWindow *window); +void gnc_main_window_menu_item_vis_by_action (GncMainWindow *window, + const gchar **action_names, + gboolean vis); //FIXMEb added + +GtkWidget *gnc_main_window_menu_find_menu_item (GncMainWindow *window, + const gchar *action_name); //FIXMEb added + +GtkWidget * gnc_main_window_toolbar_find_menu_item (GncMainWindow *window, + const gchar *action_name); //FIXMEb added /** Retrieve a specific set of user interface actions from a window. * This function can be used to get an group of action to be @@ -444,6 +455,9 @@ GMenuModel *gnc_main_window_get_menu_model (GncMainWindow *window); //FIXMEb add void gnc_main_window_update_toolbar (GncMainWindow *window, GncPluginPage *page); //FIXMEb added +void gnc_main_window_update_menu (GncMainWindow *window, GncPluginPage *page, + const gchar **ui_updates); //FIXMEb added + /** * Shows all main windows. **/ diff --git a/gnucash/gnome-utils/gnc-plugin-page.c b/gnucash/gnome-utils/gnc-plugin-page.c index 2bf79ad0f1..3cd3f729be 100644 --- a/gnucash/gnome-utils/gnc-plugin-page.c +++ b/gnucash/gnome-utils/gnc-plugin-page.c @@ -100,6 +100,7 @@ typedef struct _GncPluginPagePrivate GSimpleActionGroup *simple_action_group; //FIXMEb added const gchar *simple_action_group_name; //FIXMEb added GtkAccelGroup *accel_group; //FIXMEb added + const gchar *menu_qualifier; //FIXMEb added GList *books; @@ -553,6 +554,7 @@ gnc_plugin_page_init (GncPluginPage *page, void *data) priv->page_changed_id = 0; priv->focus_source_id = 0; priv->accel_group = NULL; + priv->menu_qualifier = NULL; page->window = NULL; page->summarybar = NULL; @@ -1159,6 +1161,33 @@ gnc_plugin_page_get_builder (GncPluginPage *page) } +/* Retrieve the menu qualifier associated with this page. */ +const gchar * +gnc_plugin_page_get_menu_qualifier (GncPluginPage *page) +{ + GncPluginPagePrivate *priv; + + g_return_val_if_fail (GNC_IS_PLUGIN_PAGE(page), NULL); + + priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page); + return priv->menu_qualifier; +} + + +void +gnc_plugin_page_set_menu_qualifier (GncPluginPage *page, + const char *menu_qualifier) +{ + GncPluginPagePrivate *priv; + + g_return_if_fail (GNC_IS_PLUGIN_PAGE(page)); + + priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page); + + priv->menu_qualifier = menu_qualifier; +} + + /* Retrieve the GtkActionGroup object associated with this page. */ GtkActionGroup * gnc_plugin_page_get_action_group(GncPluginPage *page) diff --git a/gnucash/gnome-utils/gnc-plugin-page.h b/gnucash/gnome-utils/gnc-plugin-page.h index f2d03d2f68..30a64ecf4b 100644 --- a/gnucash/gnome-utils/gnc-plugin-page.h +++ b/gnucash/gnome-utils/gnc-plugin-page.h @@ -539,6 +539,9 @@ void gnc_plugin_page_set_ui_description (GncPluginPage *page, * @return A pointer to the GtkBuilder object for this page. */ GtkBuilder *gnc_plugin_page_get_builder (GncPluginPage *page); //FIXMEb added +const gchar * gnc_plugin_page_get_menu_qualifier (GncPluginPage *page); //FIXMEb added +void gnc_plugin_page_set_menu_qualifier (GncPluginPage *page, + const char *menu_qualifier); //FIXMEb added /** Retrieve the GtkActionGroup object associated with this page. * diff --git a/gnucash/ui/gnc-main-window.ui b/gnucash/ui/gnc-main-window.ui index 8ed6641b39..1999cc6584 100644 --- a/gnucash/ui/gnc-main-window.ui +++ b/gnucash/ui/gnc-main-window.ui @@ -371,6 +371,20 @@ action-disabled +
+ + Placeholder + mainwin.BusinessPlaceholder2 + action-disabled + +
+
+ + Placeholder + mainwin.BusinessPlaceholder3 + action-disabled + +
From 846dddaf24600186c88fad947dc1a52c88bfe0c0 Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Fri, 28 Oct 2022 16:25:10 +0100 Subject: [PATCH 13/77] Changes for account plugin pages --- gnucash/gnome/gnc-plugin-page-account-tree.c | 132 ++++-- gnucash/gnucash-gresources.xml | 2 + gnucash/ui/gnc-plugin-page-account-tree.ui | 434 +++++++++++++++++++ 3 files changed, 534 insertions(+), 34 deletions(-) create mode 100644 gnucash/ui/gnc-plugin-page-account-tree.ui diff --git a/gnucash/gnome/gnc-plugin-page-account-tree.c b/gnucash/gnome/gnc-plugin-page-account-tree.c index 80b465fc7c..35fe19dbc8 100644 --- a/gnucash/gnome/gnc-plugin-page-account-tree.c +++ b/gnucash/gnome/gnc-plugin-page-account-tree.c @@ -47,6 +47,7 @@ #include "dialog-transfer.h" #include "dialog-utils.h" #include "assistant-hierarchy.h" +#include "assistant-stock-transaction.h" #include "gnc-account-sel.h" #include "gnc-component-manager.h" #include "gnc-engine.h" @@ -136,16 +137,14 @@ static GncPluginPage *gnc_plugin_page_account_tree_recreate_page (GtkWidget *win /* Callbacks */ static void gnc_plugin_page_account_tree_summarybar_position_changed(gpointer prefs, gchar* pref, gpointer user_data); -static gboolean gnc_plugin_page_account_tree_button_press_cb (GtkWidget *widget, - GdkEventButton *event, - GncPluginPage *page); -static void gnc_plugin_page_account_tree_double_click_cb (GtkTreeView *treeview, - GtkTreePath *path, - GtkTreeViewColumn *col, - GncPluginPageAccountTree *page); +static gboolean gnc_plugin_page_account_tree_button_press_cb (GtkWidget *widget, GdkEventButton *event, GncPluginPage *page); +static void gnc_plugin_page_account_tree_double_click_cb (GtkTreeView *treeview, + GtkTreePath *path, + GtkTreeViewColumn *col, + GncPluginPageAccountTree *page); static void gnc_plugin_page_account_tree_selection_changed_cb (GtkTreeSelection *selection, - GncPluginPageAccountTree *page); + GncPluginPageAccountTree *page); void gppat_populate_trans_mas_list(GtkToggleButton *sa_mrb, GtkWidget *dialog); void gppat_set_insensitive_iff_rb_active(GtkWidget *widget, GtkToggleButton *b); @@ -165,6 +164,7 @@ static void gnc_plugin_page_account_tree_cmd_refresh (GSimpleAction *simple, GVa static void gnc_plugin_page_account_tree_cmd_autoclear (GSimpleAction *simple, GVariant *paramter, gpointer user_data); static void gnc_plugin_page_account_tree_cmd_transfer (GSimpleAction *simple, GVariant *paramter, gpointer user_data); static void gnc_plugin_page_account_tree_cmd_stock_split (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_account_tree_cmd_stock_assistant (GSimpleAction *simple, GVariant *paramter, gpointer user_data); static void gnc_plugin_page_account_tree_cmd_edit_tax_options (GSimpleAction *simple, GVariant *paramter, gpointer user_data); static void gnc_plugin_page_account_tree_cmd_lots (GSimpleAction *simple, GVariant *paramter, gpointer user_data); static void gnc_plugin_page_account_tree_cmd_scrub (GSimpleAction *simple, GVariant *paramter, gpointer user_data); @@ -189,8 +189,8 @@ static GActionEntry gnc_plugin_page_account_tree_actions [] = { { "FileNewAccountAction", gnc_plugin_page_account_tree_cmd_new_account, NULL, NULL, NULL }, { "FileAddAccountHierarchyAssistantAction", gnc_plugin_page_account_tree_cmd_file_new_hierarchy, NULL, NULL, NULL }, - { "FileOpenAccountAction", gnc_plugin_page_account_tree_cmd_open_account, NULL, NULL, NULL }, - { "FileOpenSubaccountsAction", gnc_plugin_page_account_tree_cmd_open_subaccounts, NULL, NULL, NULL }, + { "EditOpenAccountAction", gnc_plugin_page_account_tree_cmd_open_account, NULL, NULL, NULL }, + { "EditOpenSubaccountsAction", gnc_plugin_page_account_tree_cmd_open_subaccounts, NULL, NULL, NULL }, { "EditEditAccountAction", gnc_plugin_page_account_tree_cmd_edit_account, NULL, NULL, NULL }, { "EditDeleteAccountAction", gnc_plugin_page_account_tree_cmd_delete_account, NULL, NULL, NULL }, { "EditCascadeAccountAction", gnc_plugin_page_account_tree_cmd_cascade_account_properties, NULL, NULL, NULL }, @@ -204,6 +204,7 @@ static GActionEntry gnc_plugin_page_account_tree_actions [] = { "ActionsAutoClearAction", gnc_plugin_page_account_tree_cmd_autoclear, NULL, NULL, NULL }, { "ActionsTransferAction", gnc_plugin_page_account_tree_cmd_transfer, NULL, NULL, NULL }, { "ActionsStockSplitAction", gnc_plugin_page_account_tree_cmd_stock_split, NULL, NULL, NULL }, + { "ActionsStockAssistantAction", gnc_plugin_page_account_tree_cmd_stock_assistant, NULL, NULL, NULL }, { "ActionsLotsAction", gnc_plugin_page_account_tree_cmd_lots, NULL, NULL, NULL }, { "ScrubAction", gnc_plugin_page_account_tree_cmd_scrub, NULL, NULL, NULL }, { "ScrubSubAction", gnc_plugin_page_account_tree_cmd_scrub_sub, NULL, NULL, NULL }, @@ -224,11 +225,11 @@ static GncDisplayItem gnc_plugin_page_account_tree_display_items [] = N_("Extend the current book by merging with new account type categories") }, { - "FileOpenAccountAction", GNC_ICON_OPEN_ACCOUNT, N_("Open _Account"), NULL, + "EditOpenAccountAction", GNC_ICON_OPEN_ACCOUNT, N_("Open _Account"), NULL, N_("Open the selected account") }, { - "FileOpenSubaccountsAction", GNC_ICON_OPEN_ACCOUNT, N_("Open _SubAccounts"), NULL, + "EditOpenSubaccountsAction", GNC_ICON_OPEN_ACCOUNT, N_("Open _SubAccounts"), NULL, N_("Open the selected account and all its subaccounts") }, /* Edit menu */ @@ -313,6 +314,25 @@ static GncDisplayItem gnc_plugin_page_account_tree_display_items [] = /** The number of display items provided by this plugin. */ static guint gnc_plugin_page_account_tree_n_display_items = G_N_ELEMENTS(gnc_plugin_page_account_tree_display_items); + +/** The default menu items that need to be add to the menu */ +static const gchar *gnc_plugin_load_ui_items [] = +{ + "EditPlaceholder1", + "EditPlaceholder2", + "EditPlaceholder3", + "EditPlaceholder5", + "ViewPlaceholder1", + "ViewPlaceholder4", + "ActionsPlaceholder4", + "ActionsPlaceholder5", + "ActionsPlaceholder6", + NULL, +}; + + + + /** Actions that require an account to be selected before they are * enabled, and the book is in read-write mode. */ static const gchar *actions_requiring_account_rw[] = @@ -337,12 +357,18 @@ static const gchar *actions_requiring_subaccounts_rw[] = * enabled. Those actions can be selected even if the book is in readonly mode. */ static const gchar *actions_requiring_account_always[] = { - "FileOpenAccountAction", - "FileOpenSubaccountsAction", + "EditOpenAccountAction", + "EditOpenSubaccountsAction", "ActionsLotsAction", NULL }; +static const gchar* actions_requiring_priced_account[] = +{ + "ActionsStockAssistantAction", + NULL +}; + /* This is the list of actions which are switched inactive in a read-only book. */ static const gchar* readonly_inactive_actions[] = { @@ -363,8 +389,8 @@ static const gchar* readonly_inactive_actions[] = /** Short labels for use on the toolbar buttons. */ static action_toolbar_labels toolbar_labels[] = { - { "FileOpenAccountAction", N_("Open") }, - { "EditEditAccountAction", N_("Edit") }, + { "FileOpenAccountAction", N_("Open") }, + { "EditEditAccountAction", N_("Edit") }, { "FileNewAccountAction", N_("New") }, { "EditDeleteAccountAction", N_("Delete") }, { NULL, NULL }, @@ -465,7 +491,7 @@ gnc_plugin_page_account_tree_class_init (GncPluginPageAccountTreeClass *klass) static void gnc_plugin_page_account_tree_init (GncPluginPageAccountTree *plugin_page) { - GSimpleActionGroup *simple_action_group; + GSimpleActionGroup *simple_action_group = NULL; GncPluginPageAccountTreePrivate *priv; GncPluginPage *parent; const GList *page_list; @@ -475,24 +501,24 @@ gnc_plugin_page_account_tree_init (GncPluginPageAccountTree *plugin_page) /* Init parent declared variables */ parent = GNC_PLUGIN_PAGE(plugin_page); - g_object_set(G_OBJECT(plugin_page), - "page-name", _("Accounts"), - "page-uri", "default:", - "ui-description", "gnc-plugin-page-account-tree.ui", - NULL); + g_object_set (G_OBJECT(plugin_page), + "page-name", _("Accounts"), + "page-uri", "default:", + "ui-description", "gnc-plugin-page-account-tree.ui", + NULL); g_signal_connect (G_OBJECT (plugin_page), "selected", G_CALLBACK (gnc_plugin_page_account_tree_selected), plugin_page); /* change me when the system supports multiple books */ - gnc_plugin_page_add_book(parent, gnc_get_current_book()); + gnc_plugin_page_add_book (parent, gnc_get_current_book()); /* Is this the first accounts page? */ page_list = - gnc_gobject_tracking_get_list(GNC_PLUGIN_PAGE_ACCOUNT_TREE_NAME); + gnc_gobject_tracking_get_list (GNC_PLUGIN_PAGE_ACCOUNT_TREE_NAME); if (!page_list || plugin_page == page_list->data) { - g_object_set_data(G_OBJECT(plugin_page), PLUGIN_PAGE_IMMUTABLE, - GINT_TO_POINTER(1)); + g_object_set_data (G_OBJECT(plugin_page), PLUGIN_PAGE_IMMUTABLE, + GINT_TO_POINTER(1)); } /* Create menu and toolbar information */ @@ -620,6 +646,20 @@ gnc_plugin_page_account_tree_focus_widget (GncPluginPage *account_plugin_page) GncPluginPageAccountTreePrivate *priv = GNC_PLUGIN_PAGE_ACCOUNT_TREE_GET_PRIVATE(account_plugin_page); GtkTreeView *view = GTK_TREE_VIEW(priv->tree_view); + /* Disable the Transaction Menu */ + GAction *action = gnc_main_window_find_action (GNC_MAIN_WINDOW(account_plugin_page->window), "TransactionAction"); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE); + /* Disable the Schedule menu */ + action = gnc_main_window_find_action (GNC_MAIN_WINDOW(account_plugin_page->window), "ScheduledAction"); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE); + + gnc_main_window_update_menu (GNC_MAIN_WINDOW(account_plugin_page->window), account_plugin_page, + gnc_plugin_load_ui_items); + + /* Disable the FilePrintAction */ + action = gnc_main_window_find_action (GNC_MAIN_WINDOW(account_plugin_page->window), "FilePrintAction"); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE); + if (!gtk_widget_is_focus (GTK_WIDGET(view))) gtk_widget_grab_focus (GTK_WIDGET(view)); } @@ -658,7 +698,7 @@ gnc_plugin_page_account_editing_started_cd (gpointer various, GncPluginPageRegis { GncPluginPage *plugin_page = GNC_PLUGIN_PAGE(page); GAction *action = gnc_main_window_find_action (GNC_MAIN_WINDOW(plugin_page->window), - "EditDeleteAccountAction"); + "EditDeleteAccountAction"); if (action != NULL) g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE); @@ -669,7 +709,7 @@ gnc_plugin_page_account_editing_finished_cb (gpointer various, GncPluginPageRegi { GncPluginPage *plugin_page = GNC_PLUGIN_PAGE(page); GAction *action = gnc_main_window_find_action (GNC_MAIN_WINDOW(plugin_page->window), - "EditDeleteAccountAction"); + "EditDeleteAccountAction"); if (action != NULL) g_simple_action_set_enabled (G_SIMPLE_ACTION(action), TRUE); @@ -836,12 +876,13 @@ gnc_plugin_page_account_tree_destroy_widget (GncPluginPage *plugin_page) LEAVE("widget destroyed"); } -static void update_inactive_actions(GncPluginPage *plugin_page) +static void +update_inactive_actions (GncPluginPage *plugin_page) { GncPluginPageAccountTreePrivate *priv; - GSimpleActionGroup *simple_action_group; + GSimpleActionGroup *simple_action_group = NULL; Account *account = NULL; - gboolean allow_write = !qof_book_is_readonly(gnc_get_current_book()); + gboolean allow_write = !qof_book_is_readonly (gnc_get_current_book()); gboolean has_account = FALSE; gboolean subaccounts = FALSE; @@ -870,6 +911,8 @@ static void update_inactive_actions(GncPluginPage *plugin_page) "sensitive", has_account); gnc_plugin_update_actionsb (simple_action_group, actions_requiring_subaccounts_rw, "sensitive", allow_write && subaccounts); + gnc_plugin_update_actionsb (simple_action_group, actions_requiring_priced_account, + "sensitive", account && xaccAccountIsPriced (account)); g_signal_emit (plugin_page, plugin_page_signals[ACCOUNT_SELECTED], 0, account); } @@ -877,7 +920,8 @@ static void update_inactive_actions(GncPluginPage *plugin_page) * Called when this page is selected. * * Update the toolbar button sensitivity. */ -static void gnc_plugin_page_account_tree_selected (GObject *object, gpointer user_data) +static void +gnc_plugin_page_account_tree_selected (GObject *object, gpointer user_data) { GncPluginPage *plugin_page = GNC_PLUGIN_PAGE (object); g_return_if_fail (GNC_IS_PLUGIN_PAGE (plugin_page)); @@ -1601,7 +1645,7 @@ gnc_plugin_page_account_tree_cmd_delete_account (GSimpleAction *simple, adopter_match (&adopt.subtrans, GTK_WINDOW (window))) break; } - filter = g_object_get_data (G_OBJECT (dialog), DELETE_DIALOG_FILTER); + filter = g_object_get_data (G_OBJECT (dialog), DELETE_DIALOG_FILTER); gtk_widget_destroy(dialog); g_list_free(filter); if (confirm_delete_account (simple, page, adopt.trans.new_account, @@ -1700,7 +1744,8 @@ confirm_delete_account (GSimpleAction *simple, GncPluginPageAccountTree *page, return response; } -void do_delete_account (Account* account, Account* saa, Account* sta, Account* ta) +void +do_delete_account (Account* account, Account* saa, Account* sta, Account* ta) { GList *acct_list, *ptr; const GncGUID *guid; @@ -1877,6 +1922,25 @@ gnc_plugin_page_account_tree_cmd_stock_split (GSimpleAction *simple, gnc_stock_split_dialog (window, account); } +static void +gnc_plugin_page_account_tree_cmd_stock_assistant (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) +{ + GncPluginPageAccountTree *page = user_data; + Account *account; + GtkWidget *window; + + ENTER ("(action %p, page %p)", simple, page); + + g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); + account = gnc_plugin_page_account_tree_get_current_account (page); + window = GNC_PLUGIN_PAGE(page)->window; + gnc_stock_transaction_assistant (window, account); + + LEAVE (" "); +} + static void gnc_plugin_page_account_tree_cmd_edit_tax_options (GSimpleAction *simple, GVariant *paramter, diff --git a/gnucash/gnucash-gresources.xml b/gnucash/gnucash-gresources.xml index 283b60d557..9e4094b101 100644 --- a/gnucash/gnucash-gresources.xml +++ b/gnucash/gnucash-gresources.xml @@ -18,6 +18,8 @@ ui/gnc-plugin-register.ui ui/gnc-plugin-report-system.ui + ui/gnc-plugin-page-account-tree.ui + ui/gnc-plugin-ofx.ui ui/gnc-plugin-aqbanking.ui diff --git a/gnucash/ui/gnc-plugin-page-account-tree.ui b/gnucash/ui/gnc-plugin-page-account-tree.ui new file mode 100644 index 0000000000..b449ce79d8 --- /dev/null +++ b/gnucash/ui/gnc-plugin-page-account-tree.ui @@ -0,0 +1,434 @@ + + + + + + _Edit Account + GncPluginPageAccountTreeActions.EditEditAccountAction + <Primary>e + Edit the selected account + yes + + + _Delete Account + GncPluginPageAccountTreeActions.EditDeleteAccountAction + Delete + Edit the selected account + yes + + + F_ind Account + GncPluginPageAccountTreeActions.EditFindAccountAction + <Primary>i + Find an account + yes + + + _Cascade Account Properties... + GncPluginPageAccountTreeActions.EditCascadeAccountAction + Cascade selected properties for account + yes + + + _Renumber Subaccounts... + GncPluginPageAccountTreeActions.EditRenumberSubaccountsAction + Renumber the children of the selected account + yes + + + + + + Open _Account + GncPluginPageAccountTreeActions.EditOpenAccountAction + Open the selected account + yes + + + Open _SubAccounts + GncPluginPageAccountTreeActions.EditOpenSubaccountsAction + Open the selected account and all its subaccounts + yes + + + + + + _Find... + gnc-plugin-basic-commands-actions.EditFindTransactionsAction + <Primary>f + Find transactions with a search + yes + + + + + + + Ta_x Report Options + GncPluginPageAccountTreeActions.EditTaxOptionsAction + + Setup relevant accounts for tax reports, e.g. US income tax + yes + + + + + + + + _Filter By... + GncPluginPageAccountTreeActions.ViewFilterByAction + yes + + + + + + _Refresh + GncPluginPageAccountTreeActions.ViewRefreshAction + <Primary>r + Refresh this window + yes + + + + + + + + New _Account... + GncPluginPageAccountTreeActions.FileNewAccountAction + Create a new Account + yes + + + New Account _Hierarchy... + GncPluginPageAccountTreeActions.FileAddAccountHierarchyAssistantAction + Extend the current book by merging with new account type categories + yes + + + + + + _Transfer... + GncPluginPageAccountTreeActions.ActionsTransferAction + <Primary>t + Transfer funds from one account to another + yes + + + _Reconcile... + GncPluginPageAccountTreeActions.ActionsReconcileAction + Reconcile the selected account + yes + + + _Auto-clear... + GncPluginPageAccountTreeActions.ActionsAutoClearAction + Automatically clear individual transactions, so as to reach a certain cleared amount + yes + + + Stock Ass_istant + GncPluginPageAccountTreeActions.ActionsStockAssistantAction + Stock Assistant + yes + + + Stoc_k Split... + GncPluginPageAccountTreeActions.ActionsStockSplitAction + Record a stock split or a stock merger + yes + + + View _Lots... + GncPluginPageAccountTreeActions.ActionsLotsAction + Bring up the lot viewer/editor window + yes + + + + + + _Check & Repair + mainwin.ScrubMenuAction + yes + + Check & Repair A_ccount + GncPluginPageAccountTreeActions.ScrubAction + Check for and repair unbalanced transactions and orphan splits in this account + yes + + + Check & Repair Su_baccounts + GncPluginPageAccountTreeActions.ScrubSubAction + Check for and repair unbalanced transactions and orphan splits in this account and its subaccounts + yes + + + Check & Repair A_ll + GncPluginPageAccountTreeActions.ScrubAllAction + Check for and repair unbalanced transactions and orphan splits in all accounts + yes + + + + + + + + +
+ + _Filter By... + GncPluginPageAccountTreeActions.ViewFilterByAction + Filter accounts + + + Re_name Page + mainwin.ActionsRenamePageAction + Rename this page + +
+
+ + Open _Account + GncPluginPageAccountTreeActions.EditOpenAccountAction + Open the selected account + + + Open _SubAccounts + GncPluginPageAccountTreeActions.EditOpenSubaccountsAction + Open the selected account and all its subaccounts + + + Edit _Account + GncPluginPageAccountTreeActions.EditEditAccountAction + Edit the selected account + + + _Cascade Account Properties... + GncPluginPageAccountTreeActions.EditCascadeAccountAction + Cascade selected properties for account + + + F_ind Account + GncPluginPageAccountTreeActions.EditFindAccountPopupAction + Find an account + +
+
+ + _Reconcile... + GncPluginPageAccountTreeActions.ActionsReconcileAction + Reconcile the selected account + + + _Auto-clear... + GncPluginPageAccountTreeActions.ActionsAutoClearAction + Automatically clear individual transactions, given a cleared amount + + + _Transfer... + GncPluginPageAccountTreeActions.ActionsTransferAction + Transfer funds from one account to another + + + Stoc_k Split... + GncPluginPageAccountTreeActions.ActionsStockSplitAction + Record a stock split or a stock merger + + + View _Lots... + GncPluginPageAccountTreeActions.ActionsLotsAction + Bring up the lot viewer/editor window + +
+
+ + New _Account... + GncPluginPageAccountTreeActions.FileNewAccountAction + Create a new Account + + + _Delete Account... + GncPluginPageAccountTreeActions.EditDeleteAccountAction + Delete selected account + +
+
+ + _Check & Repair + GncPluginPageAccountTreeActions.ScrubMenuAction + + _Check & Repair A_ccount + GncPluginPageAccountTreeActions.ScrubAction + Check for and repair unbalanced transactions and orphan splits in this account + + + Check & Repair Su_baccounts + GncPluginPageAccountTreeActions.ScrubSubAction + Check for and repair unbalanced transactions and orphan splits in this account and its subaccounts + + + Check & Repair A_ll + GncPluginPageAccountTreeActions.ScrubAllAction + Check for and repair unbalanced transactions and orphan splits in all accounts + + +
+
+ + + + True + False + + + True + False + _Save + gnc-plugin-basic-commands-actions.FileSaveAction + Save the current file + True + document-save + + + False + True + + + + + True + False + _Close + mainwin.FileCloseAction + Close the currently active page + True + window-close + + + False + True + + + + + True + False + + + False + True + + + + + True + False + New _Invoice... + gnc-plugin-business-actions.ToolbarNewInvoiceAction + Open the New Invoice dialog + True + gnc-invoice-new + + + False + True + + + + + True + False + + + False + True + + + + + True + False + Open _Account + GncPluginPageAccountTreeActions.EditOpenAccountAction + Open the selected account + True + gnc-account-open + + + False + True + + + + + True + False + Edit _Account + GncPluginPageAccountTreeActions.EditEditAccountAction + Edit the selected account + True + gnc-account-edit + + + False + True + + + + + True + False + + + False + True + + + + + True + False + New _Account... + GncPluginPageAccountTreeActions.FileNewAccountAction + Create a new Account + True + gnc-account-new + + + False + True + + + + + True + False + _Delete Account... + GncPluginPageAccountTreeActions.EditDeleteAccountAction + Delete selected account + True + gnc-account-delete + + + False + True + + + + + + + + + + + + + +
From 5bcb73a6a006462358c44cd1bcc5ac27fccc26c8 Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Fri, 28 Oct 2022 16:25:44 +0100 Subject: [PATCH 14/77] Changes for register plugin pages --- gnucash/gnome/gnc-plugin-page-register.c | 247 +++++--- gnucash/gnucash-gresources.xml | 1 + gnucash/ui/gnc-plugin-page-register.ui | 709 +++++++++++++++++++++++ 3 files changed, 884 insertions(+), 73 deletions(-) create mode 100644 gnucash/ui/gnc-plugin-page-register.ui diff --git a/gnucash/gnome/gnc-plugin-page-register.c b/gnucash/gnome/gnc-plugin-page-register.c index 1bbd5a3a49..7afefd0123 100644 --- a/gnucash/gnome/gnc-plugin-page-register.c +++ b/gnucash/gnome/gnc-plugin-page-register.c @@ -87,6 +87,7 @@ #include "window-report.h" #include "engine-helpers.h" #include "qofbookslots.h" +#include "gnc-gtk-utils.h" /* This static indicates the debugging module that this .o belongs to. */ static QofLogModule log_module = GNC_MOD_GUI; @@ -244,7 +245,7 @@ static GncInvoice* invoice_from_split (Split* split); static GList* invoices_from_transaction (Transaction* trans); static void -change_toggle_state (GSimpleAction *simple, +toggle_change_state (GSimpleAction *simple, GVariant *state, gpointer user_data) { @@ -252,7 +253,7 @@ change_toggle_state (GSimpleAction *simple, } static void -change_radio_state (GSimpleAction *simple, +radio_change_state (GSimpleAction *simple, GVariant *state, gpointer user_data) { @@ -341,9 +342,9 @@ static GActionEntry gnc_plugin_page_register_actions [] = { "ReportsAccountReportAction", gnc_plugin_page_register_cmd_account_report, NULL, NULL, NULL }, { "ReportsAcctTransReportAction", gnc_plugin_page_register_cmd_transaction_report, NULL, NULL, NULL }, - { "ViewStyleDoubleLineAction", gnc_plugin_page_register_cmd_style_double_line, NULL, "FALSE", change_toggle_state }, - { "SplitTransactionAction", gnc_plugin_page_register_cmd_expand_transaction, NULL, "FALSE", change_toggle_state }, - { "ViewStyleRadioAction", gnc_plugin_page_register_cmd_style_changed, "n", 0, change_radio_state }, + { "ViewStyleDoubleLineAction", gnc_plugin_page_register_cmd_style_double_line, NULL, "false", toggle_change_state }, + { "SplitTransactionAction", gnc_plugin_page_register_cmd_expand_transaction, NULL, "false", toggle_change_state }, + { "ViewStyleRadioAction", gnc_plugin_page_register_cmd_style_changed, "i", "@i 0", radio_change_state }, }; static guint gnc_plugin_page_register_n_actions = G_N_ELEMENTS(gnc_plugin_page_register_actions); @@ -519,10 +520,57 @@ static GncDisplayItem gnc_plugin_page_register_display_items [] = "ReportsAcctTransReportAction", NULL, N_ ("Account Report - Single Transaction"), NULL, N_ ("Open a register report for the selected Transaction") }, + /* Toggles and radio */ + { + "ViewStyleDoubleLineAction", NULL, N_ ("_Double Line"), NULL, + N_ ("Show a second line with \"Action\", \"Notes\", and \"Linked Document\" for each transaction.") + }, + { + "SplitTransactionAction", GNC_ICON_SPLIT_TRANS, N_ ("S_plit Transaction"), NULL, + N_ ("Show all splits in the current transaction") + }, + /* Translators: This is a menu item in the View menu */ + { + "ViewStyleBasicAction", NULL, N_ ("_Basic Ledger"), NULL, + N_ ("Show transactions on one or two lines") + }, + /* Translators: This is a menu item in the View menu */ + { + "ViewStyleAutoSplitAction", NULL, N_ ("_Auto-Split Ledger"), NULL, + N_ ("Show transactions on one or two lines and expand the current transaction") + }, + /* Translators: This is a menu item in the View menu */ + { + "ViewStyleJournalAction", NULL, N_ ("Transaction _Journal"), NULL, + N_ ("Show expanded transactions with all splits") + } }; /** The number of display items provided by this plugin. */ static guint gnc_plugin_page_register_n_display_items = G_N_ELEMENTS(gnc_plugin_page_register_display_items); +/** The default menu items that need to be add to the menu */ +static const gchar *gnc_plugin_load_ui_items [] = +{ + "EditPlaceholder1", + "EditPlaceholder2", + "EditPlaceholder3", + "EditPlaceholder5", + "ViewPlaceholder1", + "ViewPlaceholder2", + "ViewPlaceholder3", + "ViewPlaceholder4", + "TransPlaceholder0", + "TransPlaceholder1", + "TransPlaceholder2", + "TransPlaceholder3", + "TransPlaceholder4", + "ActionsPlaceholder4", + "ActionsPlaceholder5", + "ActionsPlaceholder6", + "ReportsPlaceholder1", + NULL, +}; + /** These are the "important" actions provided by the register page. * Their labels will appear when the toolbar is set to "Icons and * important text" (e.g. GTK_TOOLBAR_BOTH_HORIZ) mode. */ @@ -549,6 +597,7 @@ static const gchar* view_style_actions[] = "ViewStyleBasicAction", "ViewStyleAutoSplitAction", "ViewStyleJournalAction", + "ViewStyleRadioAction", NULL }; @@ -835,15 +884,6 @@ gnc_plugin_page_register_init (GncPluginPageRegister* plugin_page) gnc_plugin_page_register_n_actions, plugin_page); -//FIXMEb gtk_action_group_add_toggle_actions (action_group, -// toggle_entries, n_toggle_entries, -// plugin_page); -//FIXMEb gtk_action_group_add_radio_actions (action_group, -// radio_entries_2, n_radio_entries_2, -// REG_STYLE_LEDGER, -// G_CALLBACK (gnc_plugin_page_register_cmd_style_changed), -// plugin_page); - //FIXMEb gnc_plugin_init_short_names (action_group, toolbar_labels); //FIXMEb gnc_plugin_set_important_actions (action_group, important_actions); @@ -905,6 +945,16 @@ gnc_plugin_page_register_focus_widget (GncPluginPage* register_plugin_page) { GNCSplitReg *gsr = gnc_plugin_page_register_get_gsr (GNC_PLUGIN_PAGE(register_plugin_page)); + /* Enable the Transaction menu */ + GAction *action = gnc_main_window_find_action (GNC_MAIN_WINDOW(register_plugin_page->window), "TransactionAction"); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), TRUE); + /* Disable the Schedule menu */ + action = gnc_main_window_find_action (GNC_MAIN_WINDOW(register_plugin_page->window), "ScheduledAction"); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE); + + gnc_main_window_update_menu (GNC_MAIN_WINDOW(register_plugin_page->window), register_plugin_page, + gnc_plugin_load_ui_items); + gnc_plugin_page_register_ui_update (NULL, GNC_PLUGIN_PAGE_REGISTER(register_plugin_page)); gnc_split_reg_focus_on_sheet (gsr); @@ -1006,30 +1056,62 @@ gnc_plugin_page_register_ui_update (gpointer various, GncPluginPageRegisterPrivate* priv; SplitRegister* reg; GAction* action; + GNCLedgerDisplayType ledger_type; gboolean expanded, voided, read_only = FALSE, read_only_reg = FALSE; Transaction* trans; GList* invoices; CursorClass cursor_class; const char* uri; + Account *account; /* Set 'Split Transaction' */ priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page); reg = gnc_ledger_display_get_split_register (priv->ledger); cursor_class = gnc_split_register_get_current_cursor_class (reg); expanded = gnc_split_register_current_trans_expanded (reg); - action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE (page), - "SplitTransactionAction"); + + action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE(page), "SplitTransactionAction"); g_simple_action_set_enabled (G_SIMPLE_ACTION(action), reg->style == REG_STYLE_LEDGER); + + /* Set "style" radio button */ + ledger_type = gnc_ledger_display_type (priv->ledger); + action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE(page), "ViewStyleRadioAction"); + + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), ledger_type != LD_GL); + g_action_change_state (G_ACTION(action), g_variant_new_int32 (reg->style)); + + /* Set double line */ + action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE(page), "ViewStyleDoubleLineAction"); + g_action_change_state (G_ACTION(action), g_variant_new_boolean (reg->use_double_line)); + + /* Split Expand */ + action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE(page), "SplitTransactionAction"); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), reg->style == REG_STYLE_LEDGER); + g_signal_handlers_block_by_func (action, gnc_plugin_page_register_cmd_expand_transaction, page); -//FIXMEb gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), expanded); + g_action_change_state (G_ACTION(action), g_variant_new_boolean (expanded)); g_signal_handlers_unblock_by_func (action, gnc_plugin_page_register_cmd_expand_transaction, page); + /* Enable the FilePrintAction */ + action = gnc_main_window_find_action (GNC_MAIN_WINDOW(GNC_PLUGIN_PAGE(page)->window), "FilePrintAction"); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), TRUE); + /* If we are in a readonly book, or possibly a place holder * account register make any modifying action inactive */ if (qof_book_is_readonly (gnc_get_current_book()) || gnc_split_reg_get_read_only (priv->gsr)) read_only_reg = TRUE; + account = gnc_plugin_page_register_get_account (page); + + gnc_plugin_update_actionsb (gnc_plugin_page_get_action_groupb (GNC_PLUGIN_PAGE(page)), + actions_requiring_account, "sensitive", + !read_only_reg && account != NULL); + + gnc_plugin_update_actionsb (gnc_plugin_page_get_action_groupb (GNC_PLUGIN_PAGE(page)), + actions_requiring_priced_account, "sensitive", + account && xaccAccountIsPriced (account)); + /* Set available actions based on read only */ trans = gnc_split_register_get_current_trans (reg); @@ -1041,7 +1123,7 @@ gnc_plugin_page_register_ui_update (gpointer various, for (iter = readonly_inactive_actions; *iter; ++iter) { /* Set the action's sensitivity */ - GAction* action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE (page), *iter); + GAction* action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE(page), *iter); g_simple_action_set_enabled (G_SIMPLE_ACTION(action), TRUE); } main_window_update_page_set_read_only_icon (GNC_PLUGIN_PAGE(page), FALSE); @@ -1051,26 +1133,26 @@ gnc_plugin_page_register_ui_update (gpointer various, voided = xaccTransHasSplitsInState (trans, VREC); - action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE (page), + action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE(page), "CutTransactionAction"); g_simple_action_set_enabled (G_SIMPLE_ACTION(action), !read_only & !voided); - action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE (page), + action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE(page), "PasteTransactionAction"); g_simple_action_set_enabled (G_SIMPLE_ACTION(action), !read_only & !voided); - action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE (page), + action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE(page), "DeleteTransactionAction"); g_simple_action_set_enabled (G_SIMPLE_ACTION(action), !read_only & !voided); if (cursor_class == CURSOR_CLASS_SPLIT) { - action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE (page), + action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE(page), "DuplicateTransactionAction"); g_simple_action_set_enabled (G_SIMPLE_ACTION(action), !read_only & !voided); } - action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE (page), + action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE(page), "RemoveTransactionSplitsAction"); g_simple_action_set_enabled (G_SIMPLE_ACTION(action), !read_only & !voided); @@ -1078,14 +1160,14 @@ gnc_plugin_page_register_ui_update (gpointer various, if (read_only) voided = TRUE; - action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE (page), + action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE(page), "VoidTransactionAction"); g_simple_action_set_enabled (G_SIMPLE_ACTION(action), !voided); if (read_only) voided = FALSE; - action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE (page), + action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE(page), "UnvoidTransactionAction"); g_simple_action_set_enabled (G_SIMPLE_ACTION(action), voided); } @@ -1103,7 +1185,7 @@ gnc_plugin_page_register_ui_update (gpointer various, - it is an invoice transaction - it has splits with an invoice associated with it */ - action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE (page), + action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE(page), "JumpLinkedInvoiceAction"); if (trans) { @@ -1112,7 +1194,7 @@ gnc_plugin_page_register_ui_update (gpointer various, g_list_free (invoices); } - gnc_plugin_business_split_reg_ui_update (GNC_PLUGIN_PAGE (page)); + gnc_plugin_business_split_reg_ui_update (GNC_PLUGIN_PAGE(page)); /* If we are read only, make any modifying action inactive */ if (read_only_reg) @@ -1121,7 +1203,7 @@ gnc_plugin_page_register_ui_update (gpointer various, for (iter = readonly_inactive_actions; *iter; ++iter) { /* Set the action's sensitivity */ - GAction* action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE (page), *iter); + GAction* action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE(page), *iter); g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE); } main_window_update_page_set_read_only_icon (GNC_PLUGIN_PAGE(page), TRUE); @@ -1129,22 +1211,39 @@ gnc_plugin_page_register_ui_update (gpointer various, /* Modifying action descriptions based on cursor class */ { + GtkWidget *menu_item; const char** iter, **label_iter, **tooltip_iter; gboolean curr_label_trans = FALSE; iter = tran_vs_split_actions; - action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE (page), *iter); + action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE(page), *iter); label_iter = tran_action_labels; -//FIXMEb if (g_strcmp0 (gtk_action_get_label (action), _ (*label_iter)) == 0) -// curr_label_trans = TRUE; + + menu_item = gnc_main_window_menu_find_menu_item (GNC_MAIN_WINDOW(GNC_PLUGIN_PAGE(page)->window), + *iter); + + if (menu_item == NULL) + return; + + PINFO("menu_item %p label is '%s', iter label is '%s'", menu_item, + gtk_menu_item_get_label (GTK_MENU_ITEM(menu_item)), _(*label_iter)); + + if (g_strcmp0 (gtk_menu_item_get_label (GTK_MENU_ITEM(menu_item)), _ (*label_iter)) == 0) + curr_label_trans = TRUE; if ((cursor_class == CURSOR_CLASS_SPLIT) && curr_label_trans) { label_iter = split_action_labels; tooltip_iter = split_action_tips; for (iter = tran_vs_split_actions; *iter; ++iter) { + GtkWidget *menu_item = gnc_main_window_menu_find_menu_item (GNC_MAIN_WINDOW(GNC_PLUGIN_PAGE(page)->window), + *iter); + + PINFO("split menu_item %p label is '%s', iter label is '%s'", menu_item, + gtk_menu_item_get_label (GTK_MENU_ITEM(menu_item)), *iter); + /* Adjust the action's label and tooltip */ action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE (page), *iter); -//FIXMEb gtk_action_set_label (action, _ (*label_iter)); + gtk_menu_item_set_label (GTK_MENU_ITEM(menu_item), _ (*label_iter)); //FIXMEb gtk_action_set_tooltip (action, _ (*tooltip_iter)); ++label_iter; ++tooltip_iter; @@ -1156,9 +1255,15 @@ gnc_plugin_page_register_ui_update (gpointer various, tooltip_iter = tran_action_tips; for (iter = tran_vs_split_actions; *iter; ++iter) { + GtkWidget *menu_item = gnc_main_window_menu_find_menu_item (GNC_MAIN_WINDOW(GNC_PLUGIN_PAGE(page)->window), + *iter); + + PINFO("trans menu_item %p label is '%s', iter label is '%s'", menu_item, + gtk_menu_item_get_label (GTK_MENU_ITEM(menu_item)), *iter); + /* Adjust the action's label and tooltip */ action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE (page), *iter); -//FIXMEb gtk_action_set_label (action, _ (*label_iter)); + gtk_menu_item_set_label (GTK_MENU_ITEM(menu_item), _ (*label_iter)); //FIXMEb gtk_action_set_tooltip (action, _ (*tooltip_iter)); ++label_iter; ++tooltip_iter; @@ -1181,7 +1286,11 @@ gnc_plugin_page_register_ui_initial_state (GncPluginPageRegister* page) priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page); account = gnc_plugin_page_register_get_account (page); - simple_action_group = gnc_plugin_page_get_action_groupb (GNC_PLUGIN_PAGE (page)); + + /* Get the action group */ + simple_action_group = gnc_plugin_page_get_action_groupb (GNC_PLUGIN_PAGE(page)); + g_return_if_fail (G_IS_SIMPLE_ACTION_GROUP(simple_action_group)); + gnc_plugin_update_actionsb (simple_action_group, actions_requiring_account, "sensitive", is_readwrite && account != NULL); @@ -1192,35 +1301,22 @@ gnc_plugin_page_register_ui_initial_state (GncPluginPageRegister* page) /* Set "style" radio button */ ledger_type = gnc_ledger_display_type (priv->ledger); - gnc_plugin_update_actionsb (simple_action_group, view_style_actions, - "sensitive", ledger_type == LD_SINGLE); + action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE(page), "ViewStyleRadioAction"); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), ledger_type == LD_SINGLE); reg = gnc_ledger_display_get_split_register (priv->ledger); -//FIXMEb for (i = n_radio_entries_2 - 1; i > 0; i--) -// { -// DEBUG (" index %d: comparing %x to %x", i, radio_entries_2[i].value, -// reg->style); -// if (radio_entries_2[i].value == reg->style) -// { -// DEBUG ("match"); -// break; -// } -// } - /* Either a match was found, or fell out with i = 0 */ -//FIXMEb action = g_action_map_lookup_action (G_ACTION_MAP(simple_action_group), radio_entries_2[i].name); -// g_signal_handlers_block_by_func (action, -// gnc_plugin_page_register_cmd_style_changed, page); -//FIXMEb gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), TRUE); -// g_signal_handlers_unblock_by_func (action, -// gnc_plugin_page_register_cmd_style_changed, page); + g_signal_handlers_block_by_func (action, + gnc_plugin_page_register_cmd_style_changed, page); + g_action_change_state (G_ACTION(action), g_variant_new_int32 (reg->style)); + g_signal_handlers_unblock_by_func (action, + gnc_plugin_page_register_cmd_style_changed, page); /* Set "double line" toggle button */ - action = g_action_map_lookup_action (G_ACTION_MAP(simple_action_group), "ViewStyleDoubleLineAction"); + action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE(page), "ViewStyleDoubleLineAction"); g_signal_handlers_block_by_func (action, gnc_plugin_page_register_cmd_style_double_line, page); -//FIXMEb gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), -// reg->use_double_line); + g_action_change_state (G_ACTION(action), g_variant_new_boolean (reg->use_double_line)); g_signal_handlers_unblock_by_func (action, gnc_plugin_page_register_cmd_style_double_line, page); } @@ -1698,6 +1794,7 @@ gnc_plugin_page_register_restore_edit_menu (GncPluginPage* page, const gchar* group_name) { GAction* action; + GVariant *state; GError* error = NULL; gchar* style_name; gint i; @@ -1722,16 +1819,22 @@ gnc_plugin_page_register_restore_edit_menu (GncPluginPage* page, if (i <= REG_STYLE_JOURNAL) { DEBUG ("Setting style: %d", i); -//FIXMEb action = gnc_plugin_page_get_action (page, radio_entries_2[i].name); -// gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), TRUE); + action = gnc_plugin_page_get_action (page, "ViewStyleRadioAction"); + g_action_activate (G_ACTION(action), g_variant_new_int32 (i)); } /* Update the double line action on this page */ - use_double_line = - g_key_file_get_boolean (key_file, group_name, KEY_DOUBLE_LINE, &error); + use_double_line = g_key_file_get_boolean (key_file, group_name, + KEY_DOUBLE_LINE, &error); DEBUG ("Setting double_line_mode: %d", use_double_line); -//FIXMEb action = gnc_plugin_page_get_action (page, "ViewStyleDoubleLineAction"); -// gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), use_double_line); + action = gnc_plugin_page_get_action (page, "ViewStyleDoubleLineAction"); + + state = g_action_get_state (G_ACTION(action)); + + if (use_double_line != g_variant_get_boolean (state)) + g_action_activate (G_ACTION(action), NULL); + + g_variant_unref (state); LEAVE (" "); } @@ -1859,13 +1962,10 @@ gnc_plugin_page_register_update_edit_menu (GncPluginPage* page, gboolean hide) action = gnc_plugin_page_get_action (page, "EditCopyAction"); g_simple_action_set_enabled (G_SIMPLE_ACTION(action), can_copy); -//FIXMEb gtk_action_set_visible (action, !hide || can_copy); action = gnc_plugin_page_get_action (page, "EditCutAction"); g_simple_action_set_enabled (G_SIMPLE_ACTION(action), can_cut); -//FIXMEb gtk_action_set_visible (action, !hide || can_cut); action = gnc_plugin_page_get_action (page, "EditPasteAction"); g_simple_action_set_enabled (G_SIMPLE_ACTION(action), can_paste); -//FIXMEb gtk_action_set_visible (action, !hide || can_paste); } static gboolean is_scrubbing = FALSE; @@ -4359,7 +4459,6 @@ gnc_plugin_page_register_cmd_style_changed (GSimpleAction *simple, GncPluginPageRegister* page = user_data; GncPluginPageRegisterPrivate* priv; SplitRegisterStyle value; - gint current; ENTER ("(action %p, page %p)", simple, page); @@ -4367,10 +4466,11 @@ gnc_plugin_page_register_cmd_style_changed (GSimpleAction *simple, priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page); - current = g_variant_get_int16 (parameter); + value = (SplitRegisterStyle)g_variant_get_int32 (parameter); -//FIXMEb value = gtk_radio_action_get_current_value (current); -// gnc_split_reg_change_style (priv->gsr, value, priv->enable_refresh); + g_action_change_state (G_ACTION(simple), parameter); + + gnc_split_reg_change_style (priv->gsr, value, priv->enable_refresh); gnc_plugin_page_register_ui_update (NULL, page); LEAVE (" "); @@ -4396,10 +4496,10 @@ gnc_plugin_page_register_cmd_style_double_line (GSimpleAction *simple, state = g_action_get_state (G_ACTION(simple)); - use_double_line = g_variant_get_boolean (state); - g_action_change_state (G_ACTION(simple), g_variant_new_boolean (!g_variant_get_boolean (state))); + use_double_line = !g_variant_get_boolean (state); + if (use_double_line != reg->use_double_line) { gnc_split_register_config (reg, reg->type, reg->style, use_double_line); @@ -4871,7 +4971,7 @@ gnc_plugin_page_register_cmd_expand_transaction (GSimpleAction *simple, g_action_change_state (G_ACTION(simple), g_variant_new_boolean (!g_variant_get_boolean (state))); - expand = g_variant_get_boolean (state); + expand = !g_variant_get_boolean (state); gnc_split_register_expand_current_trans (reg, expand); g_variant_unref (state); @@ -5005,7 +5105,8 @@ gnc_plugin_page_register_cmd_schedule (GSimpleAction *simple, LEAVE (" "); } -static void scrub_split (Split *split) +static void +scrub_split (Split *split) { Account *acct; Transaction *trans; diff --git a/gnucash/gnucash-gresources.xml b/gnucash/gnucash-gresources.xml index 9e4094b101..224de420b9 100644 --- a/gnucash/gnucash-gresources.xml +++ b/gnucash/gnucash-gresources.xml @@ -19,6 +19,7 @@ ui/gnc-plugin-report-system.ui ui/gnc-plugin-page-account-tree.ui + ui/gnc-plugin-page-register.ui ui/gnc-plugin-ofx.ui ui/gnc-plugin-aqbanking.ui diff --git a/gnucash/ui/gnc-plugin-page-register.ui b/gnucash/ui/gnc-plugin-page-register.ui new file mode 100644 index 0000000000..744ba60389 --- /dev/null +++ b/gnucash/ui/gnc-plugin-page-register.ui @@ -0,0 +1,709 @@ + + + + + + Assign as payment... + gnc-plugin-business-actions.RegisterAssignPayment + Assign the selected transaction as payment + yes + action-disabled + + + Edit payment... + gnc-plugin-business-actions.RegisterEditPayment + Edit the payment this transaction is a part of + yes + action-disabled + + + + + + _Edit Account + GncPluginPageRegisterActions.EditEditAccountAction + <Primary>e + Edit the selected account + yes + + + F_ind Account + GncPluginPageRegisterActions.EditFindAccountAction + <Primary>i + Find an account + yes + + + + + + _Find... + gnc-plugin-basic-commands-actions.EditFindTransactionsAction + <Primary>f + Find transactions with a search + yes + + + + + + + Ta_x Report Options + GncPluginPageRegisterActions.EditTaxOptionsAction + + Setup relevant accounts for tax reports, e.g. US income tax + yes + + + + + + _Basic Ledger + GncPluginPageRegisterActions.ViewStyleRadioAction + 0 + Show transactions on one or two lines + yes + + + _Auto-Split Ledger + GncPluginPageRegisterActions.ViewStyleRadioAction + 1 + Show transactions on one or two lines and expand the current transaction + yes + + + Transaction _Journal + GncPluginPageRegisterActions.ViewStyleRadioAction + 2 + Show expanded transactions with all splits + yes + + + + + + _Double Line + GncPluginPageRegisterActions.ViewStyleDoubleLineAction + Show a second line with \"Action\", \"Notes\", and \"Linked Document\" for each transaction + yes + + + + + + + _Sort By... + GncPluginPageRegisterActions.ViewSortByAction + yes + + + _Filter By... + GncPluginPageRegisterActions.ViewFilterByAction + yes + + + + + + _Refresh + GncPluginPageRegisterActions.ViewRefreshAction + <Primary>r + Refresh this window + yes + + + + + + Cu_t Transaction + GncPluginPageRegisterActions.CutTransactionAction + Cut the selected transaction into clipboard + yes + + + _Copy Transaction + GncPluginPageRegisterActions.CopyTransactionAction + Copy the selected transaction into clipboard + yes + + + _Paste Transaction + GncPluginPageRegisterActions.PasteTransactionAction + Paste the transaction from the clipboard + yes + + + Dup_licate Transaction + GncPluginPageRegisterActions.DuplicateTransactionAction + Make a copy of the current transaction + yes + + + _Delete Transaction + GncPluginPageRegisterActions.DeleteTransactionAction + Delete the current transaction + yes + + + Remo_ve Other Splits + GncPluginPageRegisterActions.RemoveTransactionSplitsAction + Remove all splits in the current transaction + yes + + + + + + _Enter Transaction + GncPluginPageRegisterActions.RecordTransactionAction + Record the current transaction + yes + + + Ca_ncel Transaction + GncPluginPageRegisterActions.CancelTransactionAction + Cancel the current transaction + yes + + + + + + _Void Transaction + GncPluginPageRegisterActions.VoidTransactionAction + Void the current transaction + yes + + + _Unvoid Transaction + GncPluginPageRegisterActions.UnvoidTransactionAction + Unvoid the current transaction + yes + + + Add _Reversing Transaction + GncPluginPageRegisterActions.ReverseTransactionAction + Add a reversing transaction + yes + + + + + + Manage Document Link... + GncPluginPageRegisterActions.LinkTransactionAction + Add, change, or unlink the document linked with the current transaction + yes + + + _Open Linked Document + GncPluginPageRegisterActions.LinkedTransactionOpenAction + Open the linked document for the current transaction + yes + + + + + + Jump to Invoice + GncPluginPageRegisterActions.JumpLinkedInvoiceAction + Jump to the linked bill, invoice, or voucher + yes + + + + + + _Transfer... + GncPluginPageRegisterActions.ActionsTransferAction + <Primary>t + Transfer funds from one account to another + yes + + + _Reconcile... + GncPluginPageRegisterActions.ActionsReconcileAction + Reconcile the selected account + yes + + + _Auto-clear... + GncPluginPageRegisterActions.ActionsAutoClearAction + Automatically clear individual transactions, so as to reach a certain cleared amount + yes + + + Stock Ass_istant + GncPluginPageRegisterActions.ActionsStockAssistantAction + Stock Assistant + yes + + + Stoc_k Split... + GncPluginPageRegisterActions.ActionsStockSplitAction + Record a stock split or a stock merger + yes + + + View _Lots... + GncPluginPageRegisterActions.ActionsLotsAction + Bring up the lot viewer/editor window + yes + + + + + + _Blank Transaction + GncPluginPageRegisterActions.BlankTransactionAction + <Primary>Page_Down + Move to the blank transaction at the bottom of the register + yes + + + _Got to Date + GncPluginPageRegisterActions.GotoDateAction + <Primary>g + Move to the split at the specified date + yes + + + S_plit Transaction + GncPluginPageRegisterActions.SplitTransactionAction + Show all splits in the current transaction + yes + + + Edit E_xchange Rate + GncPluginPageRegisterActions.EditExchangeRateAction + Edit the exchange rate for the current transaction + yes + + + Sche_dule... + GncPluginPageRegisterActions.ScheduleTransactionAction + Create a Scheduled Transaction with the current transaction as a template + yes + + + _Jump to the other account + GncPluginPageRegisterActions.JumpTransactionAction + Open a new register tab for the other account with focus on this transaction + yes + + + + + + _Check & Repair + mainwin.ScrubMenuAction + yes + + All Transactions + GncPluginPageRegisterActions.ScrubAllAction + yes + + + This transaction + GncPluginPageRegisterActions.ScrubCurrentAction + yes + + + + + + + Account Report + GncPluginPageRegisterActions.ReportsAccountReportAction + Open a register report for this Account + yes + + + Account Report - Single Transaction + GncPluginPageRegisterActions.ReportsAcctTransReportAction + Open a register report for the selected Transaction + yes + + + + +
+ + _Sort By... + GncPluginPageRegisterActions.ViewSortByAction + Filter accounts + + + _Filter By... + GncPluginPageRegisterActions.ViewFilterByAction + Filter accounts + + + Re_name Page + mainwin.ActionsRenamePageAction + Rename this page + +
+
+ + Dup_licate Transaction + GncPluginPageRegisterActions.DuplicateTransactionAction + Make a copy of the current transaction + + + _Delete Transaction + GncPluginPageRegisterActions.DeleteTransactionAction + Delete the current transaction + + + Remo_ve Other Splits + GncPluginPageRegisterActions.RemoveTransactionSplitsAction + Remove all splits in the current transaction + +
+
+ + _Enter Transaction + GncPluginPageRegisterActions.RecordTransactionAction + Record the current transaction + + + Ca_ncel Transaction + GncPluginPageRegisterActions.CancelTransactionAction + Cancel the current transaction + +
+
+ + _Manage Document Link... + GncPluginPageRegisterActions.LinkTransactionAction + Add, change, or unlink the document linked with the current transaction + + + _Open Linked Document + GncPluginPageRegisterActions.LinkedTransactionOpenAction + Open the linked document for the current transaction + +
+
+ + Jump to Invoice + GncPluginPageRegisterActions.JumpLinkedInvoiceAction + Jump to the linked bill, invoice, or voucher + +
+
+ + _Blank Transaction + GncPluginPageRegisterActions.BlankTransactionAction + Move to the blank transaction at the bottom of the register + + + _Go to Date + GncPluginPageRegisterActions.GotoDateAction + Move to the split at the specified date + + + S_plit Transaction + GncPluginPageRegisterActions.SplitTransactionAction + Show all splits in the current transaction + + + Edit E_xchange Rate + GncPluginPageRegisterActions.EditExchangeRateAction + Edit the exchange rate for the current transaction + + + Sche_dule... + GncPluginPageRegisterActions.ScheduleTransactionAction + Create a Scheduled Transaction with the current transaction as a template + + + _Jump to the other account + GncPluginPageRegisterActions.JumpTransactionAction + Open a new register tab for the other account with focus on this transaction + +
+
+ + Assign as payment... + gnc-plugin-business-actions.RegisterAssignPayment + Assign the selected transaction as payment + action-disabled + + + Edit payment... + gnc-plugin-business-actions.RegisterEditPayment + Edit the payment this transaction is a part of + action-disabled + +
+
+ + + + True + False + + + True + False + _Save + gnc-plugin-basic-commands-actions.FileSaveAction + Save the current file + True + document-save + + + False + True + + + + + True + False + _Close + mainwin.FileCloseAction + Close the currently active page + True + window-close + + + False + True + + + + + True + False + + + False + True + + + + + True + False + New _Invoice... + gnc-plugin-business-actions.ToolbarNewInvoiceAction + Open the New Invoice dialog + True + gnc-invoice-new + + + False + True + + + + + True + False + + + False + True + + + + + True + False + Dup_licate Transaction + GncPluginPageRegisterActions.DuplicateTransactionAction + Make a copy of the current transaction + True + edit-copy + + + False + True + + + + + True + False + _Delete Transaction + GncPluginPageRegisterActions.DeleteTransactionAction + Delete the current transaction + True + edit-delete + + + False + True + + + + + True + False + + + False + True + + + + + True + False + _Enter Transaction + GncPluginPageRegisterActions.RecordTransactionAction + Record the current transaction + True + list-add + + + False + True + + + + + True + False + Ca_ncel Transaction + GncPluginPageRegisterActions.CancelTransactionAction + Cancel the current transaction + True + process-stop + + + False + True + + + + + True + False + + + False + True + + + + + True + False + _Blank Transaction + GncPluginPageRegisterActions.BlankTransactionAction + Move to the blank transaction at the bottom of the register + True + go-bottom + + + False + True + + + + + True + False + S_plit Transaction + GncPluginPageRegisterActions.SplitTransactionAction + Show all splits in the current transaction + True + gnc-split-trans + + + False + True + + + + + True + False + _Jump to the other account + GncPluginPageRegisterActions.JumpTransactionAction + Open a new register tab for the other account with focus on this transaction + True + gnc-jumpto + + + False + True + + + + + True + False + Sche_dule... + GncPluginPageRegisterActions.ScheduleTransactionAction + Create a Scheduled Transaction with the current transaction as a template + True + gnc-sx-new + + + False + True + + + + + True + False + + + False + True + + + + + True + False + _Transfer... + GncPluginPageRegisterActions.ActionsTransferAction + Transfer funds from one account to another + True + gnc-transfer + + + False + True + + + + + True + False + _Reconcile... + GncPluginPageRegisterActions.ActionsReconcileAction + Reconcile the selected account + True + edit-select-all + + + False + True + + + + + True + False + Stoc_k Split... + GncPluginPageRegisterActions.ActionsStockAssistantAction + Stock Assistant + True + applications-utilities + + + False + True + + + + +
From 161dad7a4c4d000b27621ffaf6bd13c84a3e82f7 Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Fri, 28 Oct 2022 16:26:24 +0100 Subject: [PATCH 15/77] Changes for budget plugin pages --- gnucash/gnome/gnc-plugin-page-budget.c | 56 +++++ gnucash/gnucash-gresources.xml | 1 + gnucash/ui/gnc-plugin-page-budget.ui | 288 +++++++++++++++++++++++++ 3 files changed, 345 insertions(+) create mode 100644 gnucash/ui/gnc-plugin-page-budget.ui diff --git a/gnucash/gnome/gnc-plugin-page-budget.c b/gnucash/gnome/gnc-plugin-page-budget.c index 054493574b..afbfd4c8e3 100644 --- a/gnucash/gnome/gnc-plugin-page-budget.c +++ b/gnucash/gnome/gnc-plugin-page-budget.c @@ -120,6 +120,7 @@ static void gnc_plugin_page_budget_cmd_allperiods_budget (GSimpleAction *simple, static void gnc_plugin_page_budget_cmd_refresh (GSimpleAction *simple, GVariant *parameter, gpointer user_data); static void gnc_plugin_page_budget_cmd_budget_note (GSimpleAction *simple, GVariant *parameter, gpointer user_data); static void gnc_plugin_page_budget_cmd_budget_report (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_page_budget_cmd_edit_tax_options (GSimpleAction *simple, GVariant *parameter, gpointer user_data); static void allperiods_budget_helper (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data); @@ -137,6 +138,7 @@ static GActionEntry gnc_plugin_page_budget_actions [] = { "BudgetReportAction", gnc_plugin_page_budget_cmd_budget_report, NULL, NULL, NULL }, { "ViewFilterByAction", gnc_plugin_page_budget_cmd_view_filter_by, NULL, NULL, NULL }, { "ViewRefreshAction", gnc_plugin_page_budget_cmd_refresh, NULL, NULL, NULL }, + { "EditTaxOptionsAction", gnc_plugin_page_budget_cmd_edit_tax_options, NULL, NULL, NULL }, }; static guint gnc_plugin_page_budget_n_actions = G_N_ELEMENTS(gnc_plugin_page_budget_actions); @@ -193,6 +195,18 @@ static GncDisplayItem gnc_plugin_page_budget_display_items [] = /** The number of display items provided by this plugin. */ static guint gnc_plugin_page_budget_n_display_items = G_N_ELEMENTS(gnc_plugin_page_budget_display_items); +/** The default menu items that need to be add to the menu */ +static const gchar *gnc_plugin_load_ui_items [] = +{ + "EditPlaceholder1", + "EditPlaceholder3", + "EditPlaceholder5", + "EditPlaceholder6", + "ViewPlaceholder1", + "ViewPlaceholder4", + NULL, +}; + static const gchar *writeable_actions[] = { /* actions which must be disabled on a readonly book. */ @@ -419,6 +433,16 @@ gnc_plugin_page_budget_focus_widget (GncPluginPage *budget_plugin_page) GncBudgetView *budget_view = priv->budget_view; GtkWidget *account_view = gnc_budget_view_get_account_tree_view (budget_view); + /* Disable the Transaction Menu */ + GAction *action = gnc_main_window_find_action (GNC_MAIN_WINDOW(budget_plugin_page->window), "TransactionAction"); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE); + /* Disable the Schedule menu */ + action = gnc_main_window_find_action (GNC_MAIN_WINDOW(budget_plugin_page->window), "ScheduledAction"); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE); + + gnc_main_window_update_menu (GNC_MAIN_WINDOW(budget_plugin_page->window), budget_plugin_page, + gnc_plugin_load_ui_items); + if (!gtk_widget_is_focus (GTK_WIDGET(account_view))) gtk_widget_grab_focus (GTK_WIDGET(account_view)); } @@ -811,6 +835,38 @@ gnc_plugin_page_budget_cmd_delete_budget (GSimpleAction *simple, } +static void +gnc_plugin_page_budget_cmd_edit_tax_options (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) +{ + GncPluginPageBudget *page = user_data; + GncPluginPageBudgetPrivate *priv; + GtkTreeSelection *selection; + Account *account = NULL; + GtkWidget *window; + + page = GNC_PLUGIN_PAGE_BUDGET(page); + + g_return_if_fail (GNC_IS_PLUGIN_PAGE_BUDGET(page)); + + ENTER ("(action %p, page %p)", simple, page); + priv = GNC_PLUGIN_PAGE_BUDGET_GET_PRIVATE(page); + + selection = gnc_budget_view_get_selection (priv->budget_view); + window = GNC_PLUGIN_PAGE(page)->window; + + if (gtk_tree_selection_count_selected_rows (selection) == 1) + { + GList *acc_list = gnc_budget_view_get_selected_accounts (priv->budget_view); + GList *node = g_list_first (acc_list); + account = acc_list->data; + g_list_free (acc_list); + } + gnc_tax_info_dialog (window, account); + LEAVE (" "); +} + /******************************/ /* Options Dialog */ /******************************/ diff --git a/gnucash/gnucash-gresources.xml b/gnucash/gnucash-gresources.xml index 224de420b9..e3320694d3 100644 --- a/gnucash/gnucash-gresources.xml +++ b/gnucash/gnucash-gresources.xml @@ -19,6 +19,7 @@ ui/gnc-plugin-report-system.ui ui/gnc-plugin-page-account-tree.ui + ui/gnc-plugin-page-budget.ui ui/gnc-plugin-page-register.ui ui/gnc-plugin-ofx.ui diff --git a/gnucash/ui/gnc-plugin-page-budget.ui b/gnucash/ui/gnc-plugin-page-budget.ui new file mode 100644 index 0000000000..a187e2f2d6 --- /dev/null +++ b/gnucash/ui/gnc-plugin-page-budget.ui @@ -0,0 +1,288 @@ + + + + + + Esti_mate Budget... + GncPluginPageBudgetActions.EstimateBudgetAction + Edit the selected account + yes + + + _All Periods... + GncPluginPageBudgetActions.AllPeriodsBudgetAction + Estimate a budget value for the selected accounts from past transactions + yes + + + _Delete Budget... + GncPluginPageBudgetActions.DeleteBudgetAction + Select this or another budget and delete it + yes + + + Edit Note + GncPluginPageBudgetActions.BudgetNoteAction + Edit note for the selected account and period + yes + + + Budget Report + GncPluginPageBudgetActions.BudgetReportAction + Run the budget report + yes + + + + + + _Find... + gnc-plugin-basic-commands-actions.EditFindTransactionsAction + <Primary>f + Find transactions with a search + yes + + + + + + + Ta_x Report Options + GncPluginPageBudgetActions.EditTaxOptionsAction + + Setup relevant accounts for tax reports, e.g. US income tax + yes + + + + + + Budget _Options... + GncPluginPageBudgetActions.OptionsBudgetAction + Edit this budget's options + yes + + + + + + _Filter By... + GncPluginPageBudgetActions.ViewFilterByAction + yes + + + + + + _Refresh + GncPluginPageBudgetActions.ViewRefreshAction + <Primary>r + Refresh this window + yes + + + + + + _Test + mainwin.TestAction + + + + + + True + False + + + True + False + _Save + gnc-plugin-basic-commands-actions.FileSaveAction + Save the current file + True + document-save + + + False + True + + + + + True + False + _Close + mainwin.FileCloseAction + Close the currently active page + True + window-close + + + False + True + + + + + True + False + + + False + True + + + + + True + False + New _Invoice... + gnc-plugin-business-actions.ToolbarNewInvoiceAction + Open the New Invoice dialog + True + gnc-invoice-new + + + False + True + + + + + True + False + + + False + True + + + + + True + False + Open _Account + GncPluginPageBudgetActions.EditOpenAccountAction + Open the selected account + True + gnc-account-open + + + False + True + + + + + True + False + + + False + True + + + + + True + False + Budget _Options... + GncPluginPageBudgetActions.OptionsBudgetAction + Edit this budget's options + True + document-properties + + + False + True + + + + + True + False + + + False + True + + + + + True + False + Esti_mate Budget... + GncPluginPageBudgetActions.EstimateBudgetAction + Estimate a budget value for the selected accounts from past transactions + True + system-run + + + False + True + + + + + True + False + _All Periods... + GncPluginPageBudgetActions.AllPeriodsBudgetAction + Edit budget for all periods for the selected accounts + True + system-run + + + False + True + + + + + True + False + _Delete Budget... + GncPluginPageBudgetActions.DeleteBudgetAction + Select this or another budget and delete it + True + gnc-account-delete + + + False + True + + + + + True + False + Edit Note + GncPluginPageBudgetActions.BudgetNoteAction + Edit note for the selected account and period + True + text-x-generic + + + False + True + + + + + True + False + Budget Report + GncPluginPageBudgetActions.BudgetReportAction + Run the budget report + True + system-run + + + False + True + + + + + From 273b7439aa362dc1e23dcf0cb2aeb440f787be17 Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Sun, 30 Oct 2022 13:29:59 +0000 Subject: [PATCH 16/77] Changes for sx plugin pages --- gnucash/gnome/gnc-plugin-page-sx-list.c | 78 ++++++---- gnucash/gnucash-gresources.xml | 1 + gnucash/ui/gnc-plugin-page-sx-list.ui | 190 ++++++++++++++++++++++++ 3 files changed, 241 insertions(+), 28 deletions(-) create mode 100644 gnucash/ui/gnc-plugin-page-sx-list.ui diff --git a/gnucash/gnome/gnc-plugin-page-sx-list.c b/gnucash/gnome/gnc-plugin-page-sx-list.c index 83db9d06b1..40be33ced3 100644 --- a/gnucash/gnome/gnc-plugin-page-sx-list.c +++ b/gnucash/gnome/gnc-plugin-page-sx-list.c @@ -124,6 +124,7 @@ static void gnc_plugin_page_sx_list_cmd_new (GSimpleAction *simple, GVariant *pa static void gnc_plugin_page_sx_list_cmd_edit (GSimpleAction *simple, GVariant *paramter, gpointer user_data); static void gnc_plugin_page_sx_list_cmd_delete (GSimpleAction *simple, GVariant *paramter, gpointer user_data); static void gnc_plugin_page_sx_list_cmd_refresh (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_sx_list_cmd_edit_tax_options (GSimpleAction *simple, GVariant *paramter, gpointer user_data); /* Command callbacks */ static GActionEntry gnc_plugin_page_sx_list_actions [] = @@ -133,6 +134,7 @@ static GActionEntry gnc_plugin_page_sx_list_actions [] = { "SxListEditAction", gnc_plugin_page_sx_list_cmd_edit, NULL, NULL, NULL }, { "SxListDeleteAction", gnc_plugin_page_sx_list_cmd_delete, NULL, NULL, NULL }, { "ViewRefreshAction", gnc_plugin_page_sx_list_cmd_refresh, NULL, NULL, NULL }, + { "EditTaxOptionsAction", gnc_plugin_page_sx_list_cmd_edit_tax_options, NULL, NULL, NULL }, }; /** The number of actions provided by this plugin. */ static guint gnc_plugin_page_sx_list_n_actions = G_N_ELEMENTS(gnc_plugin_page_sx_list_actions); @@ -161,6 +163,17 @@ static GncDisplayItem gnc_plugin_page_sx_list_display_items [] = /** The number of display items provided by this plugin. */ static guint gnc_plugin_page_sx_list_n_display_items = G_N_ELEMENTS(gnc_plugin_page_sx_list_display_items); +/** The default menu items that need to be add to the menu */ +static const gchar *gnc_plugin_load_ui_items [] = +{ + "EditPlaceholder3", + "EditPlaceholder5", + "ViewPlaceholder4", + "SchedulePlaceholder0", + NULL, +}; + + GncPluginPage * gnc_plugin_page_sx_list_new (void) { @@ -188,6 +201,16 @@ gnc_plugin_page_sx_list_focus_widget (GncPluginPage *sx_plugin_page) GncPluginPageSxListPrivate *priv = GNC_PLUGIN_PAGE_SX_LIST_GET_PRIVATE(sx_plugin_page); GtkTreeView *tree_view = priv->tree_view; + /* Disable the Transaction Menu */ + GAction *action = gnc_main_window_find_action (GNC_MAIN_WINDOW(sx_plugin_page->window), "TransactionAction"); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE); + /* Enable the Schedule Menu */ + action = gnc_main_window_find_action (GNC_MAIN_WINDOW(sx_plugin_page->window), "ScheduledAction"); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), TRUE); + + gnc_main_window_update_menu (GNC_MAIN_WINDOW(sx_plugin_page->window), sx_plugin_page, + gnc_plugin_load_ui_items); + if (GTK_IS_TREE_VIEW(tree_view)) { if (!gtk_widget_is_focus (GTK_WIDGET(tree_view))) @@ -384,26 +407,6 @@ gppsl_model_populated_cb (GtkTreeModel *tree_model, GncPluginPageSxList *page) } } -static void -gpps_new_cb (GtkMenuItem *menuitem, GncPluginPageSxList *page) -{ - gnc_plugin_page_sx_list_cmd_new (NULL, NULL, page); - return; -} - -static void -gpps_edit_cb (GtkMenuItem *menuitem, GncPluginPageSxList *page) -{ - gnc_plugin_page_sx_list_cmd_edit (NULL, NULL, page); - return; -} - -static void -gpps_delete_cb (GtkMenuItem *menuitem, GncPluginPageSxList *page) -{ - gnc_plugin_page_sx_list_cmd_delete (NULL, NULL, page); - return; -} static void treeview_popup (GtkTreeView *treeview, GdkEvent *event, GncPluginPageSxList *page) @@ -413,21 +416,27 @@ treeview_popup (GtkTreeView *treeview, GdkEvent *event, GncPluginPageSxList *pag GtkTreeSelection *selection = gtk_tree_view_get_selection (tree_view); gint count_selection = gtk_tree_selection_count_selected_rows (selection); GtkWidget *menu, *menuitem; + gchar *full_action_name; + const gchar *group_name = gnc_plugin_page_get_simple_action_group_name (GNC_PLUGIN_PAGE(page)); menu = gtk_menu_new(); menuitem = gtk_menu_item_new_with_mnemonic (_("_New")); - g_signal_connect (menuitem, "activate", G_CALLBACK(gpps_new_cb), page); + full_action_name = g_strconcat (group_name, ".SxListNewAction", NULL); + gtk_actionable_set_action_name (GTK_ACTIONABLE(menuitem), full_action_name); + g_free (full_action_name); gtk_menu_shell_append (GTK_MENU_SHELL(menu), menuitem); menuitem = gtk_menu_item_new_with_mnemonic (_("_Edit")); - g_signal_connect (menuitem, "activate", G_CALLBACK(gpps_edit_cb), page); - gtk_widget_set_sensitive (menuitem, count_selection > 0); + full_action_name = g_strconcat (group_name, ".SxListEditAction", NULL); + gtk_actionable_set_action_name (GTK_ACTIONABLE(menuitem), full_action_name); + g_free (full_action_name); gtk_menu_shell_append (GTK_MENU_SHELL(menu), menuitem); menuitem = gtk_menu_item_new_with_mnemonic (_("_Delete")); - g_signal_connect (menuitem, "activate", G_CALLBACK(gpps_delete_cb), page); - gtk_widget_set_sensitive (menuitem, count_selection > 0); + full_action_name = g_strconcat (group_name, ".SxListDeleteAction", NULL); + gtk_actionable_set_action_name (GTK_ACTIONABLE(menuitem), full_action_name); + g_free (full_action_name); gtk_menu_shell_append (GTK_MENU_SHELL(menu), menuitem); gtk_menu_attach_to_widget (GTK_MENU (menu), GTK_WIDGET (priv->tree_view), NULL); @@ -542,15 +551,13 @@ gnc_plugin_page_sx_list_create_widget (GncPluginPage *plugin_page) selection = gtk_tree_view_get_selection (priv->tree_view); gtk_tree_selection_set_mode (selection, GTK_SELECTION_MULTIPLE); - gtk_tree_selection_select_path (selection, path); - gtk_tree_path_free (path); g_signal_connect (G_OBJECT(selection), "changed", (GCallback)gppsl_selection_changed_cb, (gpointer)page); g_signal_connect (G_OBJECT(priv->tree_view), "row-activated", (GCallback)gppsl_row_activated_cb, (gpointer)page); g_signal_connect (G_OBJECT(gtk_tree_view_get_model (GTK_TREE_VIEW(priv->tree_view))), "model-populated", (GCallback)gppsl_model_populated_cb, (gpointer)page); - gppsl_selection_changed_cb (selection, page); + gtk_tree_selection_select_path (selection, path); gtk_tree_path_free (path); } @@ -810,6 +817,21 @@ gnc_plugin_page_sx_list_cmd_edit (GSimpleAction *simple, g_list_free (selected_paths); } + +static void +gnc_plugin_page_sx_list_cmd_edit_tax_options (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) +{ + GncPluginPageSxList *plugin_page = user_data; + GtkWidget *window = GTK_WIDGET(gnc_plugin_page_get_window (GNC_PLUGIN_PAGE(plugin_page))); + + ENTER ("(action %p, page %p)", simple, plugin_page); + gnc_tax_info_dialog (window, NULL); + LEAVE (" "); +} + + static void gppsl_row_activated_cb (GtkTreeView *tree_view, GtkTreePath *path, diff --git a/gnucash/gnucash-gresources.xml b/gnucash/gnucash-gresources.xml index e3320694d3..39d0c02904 100644 --- a/gnucash/gnucash-gresources.xml +++ b/gnucash/gnucash-gresources.xml @@ -21,6 +21,7 @@ ui/gnc-plugin-page-account-tree.ui ui/gnc-plugin-page-budget.ui ui/gnc-plugin-page-register.ui + ui/gnc-plugin-page-sx-list.ui ui/gnc-plugin-ofx.ui ui/gnc-plugin-aqbanking.ui diff --git a/gnucash/ui/gnc-plugin-page-sx-list.ui b/gnucash/ui/gnc-plugin-page-sx-list.ui new file mode 100644 index 0000000000..5ff5a5a912 --- /dev/null +++ b/gnucash/ui/gnc-plugin-page-sx-list.ui @@ -0,0 +1,190 @@ + + + + + + _Find... + gnc-plugin-basic-commands-actions.EditFindTransactionsAction + <Primary>f + Find transactions with a search + yes + + + + + + + Ta_x Report Options + GncPluginPageSxListActions.EditTaxOptionsAction + + Setup relevant accounts for tax reports, e.g. US income tax + yes + + + + + + _Refresh + GncPluginPageSxListActions.ViewRefreshAction + <Primary>r + Refresh this window + yes + + + + + + _New + GncPluginPageSxListActions.SxListNewAction + Create a new scheduled transaction + yes + + + _Edit + GncPluginPageSxListActions.SxListEditAction + Edit the selected scheduled transaction + yes + + + _Delete + GncPluginPageSxListActions.SxListDeleteAction + Delete the selected scheduled transaction + yes + + + + + + + _Test + mainwin.TestAction + + + + + + True + False + + + True + False + _Save + gnc-plugin-basic-commands-actions.FileSaveAction + Save the current file + True + document-save + + + False + True + + + + + True + False + _Close + mainwin.FileCloseAction + Close the currently active page + True + window-close + + + False + True + + + + + True + False + + + False + True + + + + + True + False + New _Invoice... + gnc-plugin-business-actions.ToolbarNewInvoiceAction + Open the New Invoice dialog + True + gnc-invoice-new + + + False + True + + + + + True + False + + + False + True + + + + + True + False + _New + GncPluginPageSxListActions.SxListNewAction + Create a new scheduled transaction + True + gnc-account-open + + + False + True + + + + + True + False + _Edit + GncPluginPageSxListActions.SxListEditAction + Edit the selected scheduled transaction + True + gnc-account-edit + + + False + True + + + + + True + False + + + False + True + + + + + True + False + _Delete + GncPluginPageSxListActions.SxListDeleteAction + Delete the selected scheduled transaction + True + gnc-account-delete + + + False + True + + + + + From db15edd8f31a0677a8b0bad7865c4ba7346839b8 Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Fri, 28 Oct 2022 16:27:37 +0100 Subject: [PATCH 17/77] Changes for business pages --- gnucash/gnome/gnc-plugin-business.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/gnucash/gnome/gnc-plugin-business.c b/gnucash/gnome/gnc-plugin-business.c index 5926221e4b..3b1fb55e12 100644 --- a/gnucash/gnome/gnc-plugin-business.c +++ b/gnucash/gnome/gnc-plugin-business.c @@ -121,8 +121,6 @@ static GncMainWindow *last_window = NULL; static GActionEntry gnc_plugin_actions [] = { - { "BusinessAction", NULL, NULL, NULL, NULL }, - { "CustomerMenuAction", NULL, NULL, NULL, NULL }, { "CustomerOverviewPageAction", gnc_plugin_business_cmd_customer_page, NULL, NULL, NULL }, { "CustomerNewCustomerOpenAction", gnc_plugin_business_cmd_customer_new_customer, NULL, NULL, NULL }, { "CustomerFindCustomerOpenAction", gnc_plugin_business_cmd_customer_find_customer, NULL, NULL, NULL }, @@ -132,7 +130,6 @@ static GActionEntry gnc_plugin_actions [] = { "CustomerFindJobOpenAction", gnc_plugin_business_cmd_customer_find_job, NULL, NULL, NULL }, { "CustomerProcessPaymentAction", gnc_plugin_business_cmd_customer_process_payment, NULL, NULL, NULL }, - { "VendorMenuAction", NULL, NULL, NULL, NULL }, { "VendorOverviewPageAction", gnc_plugin_business_cmd_vendor_page, NULL, NULL, NULL }, { "VendorNewVendorOpenAction", gnc_plugin_business_cmd_vendor_new_vendor, NULL, NULL, NULL }, { "VendorFindVendorOpenAction", gnc_plugin_business_cmd_vendor_find_vendor, NULL, NULL, NULL }, @@ -142,7 +139,6 @@ static GActionEntry gnc_plugin_actions [] = { "VendorFindJobOpenAction", gnc_plugin_business_cmd_vendor_find_job, NULL, NULL, NULL }, { "VendorProcessPaymentAction", gnc_plugin_business_cmd_vendor_process_payment, NULL, NULL, NULL }, - { "EmployeeMenuAction", NULL, NULL, NULL, NULL }, { "EmployeeOverviewPageAction", gnc_plugin_business_cmd_employee_page, NULL, NULL, NULL }, { "EmployeeNewEmployeeOpenAction", gnc_plugin_business_cmd_employee_new_employee, NULL, NULL, NULL }, { "EmployeeFindEmployeeOpenAction", gnc_plugin_business_cmd_employee_find_employee, NULL, NULL, NULL }, @@ -156,7 +152,6 @@ static GActionEntry gnc_plugin_actions [] = { "BillsDueReminderOpenAction", gnc_plugin_business_cmd_bills_due_reminder, NULL, NULL, NULL }, { "InvoicesDueReminderOpenAction", gnc_plugin_business_cmd_invoices_due_reminder, NULL, NULL, NULL }, - { "BusinessTestAction", NULL, NULL, NULL, NULL }, { "BusinessTestSearchAction", gnc_plugin_business_cmd_test_search, NULL, NULL, NULL }, { "BusinessTestInitDataAction", gnc_plugin_business_cmd_test_init_data, NULL, NULL, NULL }, { "ToolbarNewInvoiceAction", gnc_plugin_business_cmd_customer_new_invoice, NULL, NULL, NULL }, @@ -792,7 +787,6 @@ static const gchar *register_bus_txn_actions[] = static void gnc_plugin_business_update_menus (GncPluginPage *plugin_page) { - GncMainWindow *window; GSimpleActionGroup *simple_action_group; gboolean is_txn_register, is_bus_txn = FALSE, is_bus_doc = FALSE; @@ -805,9 +799,8 @@ gnc_plugin_business_update_menus (GncPluginPage *plugin_page) 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)); - simple_action_group = gnc_main_window_get_action_group (window, PLUGIN_ACTIONS_NAME); + simple_action_group = gnc_main_window_get_action_group (GNC_MAIN_WINDOW(plugin_page->window), + PLUGIN_ACTIONS_NAME); g_return_if_fail (G_IS_SIMPLE_ACTION_GROUP(simple_action_group)); if (is_txn_register) From 97f28ab56b571b4d70f9d391c3d975ba6d1bdc42 Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Fri, 28 Oct 2022 16:28:09 +0100 Subject: [PATCH 18/77] Changes for business owner pages --- gnucash/gnome/gnc-plugin-page-owner-tree.c | 90 ++- gnucash/gnucash-gresources.xml | 1 + gnucash/ui/gnc-plugin-page-owner-tree.ui | 685 +++++++++++++++++++++ 3 files changed, 759 insertions(+), 17 deletions(-) create mode 100644 gnucash/ui/gnc-plugin-page-owner-tree.ui diff --git a/gnucash/gnome/gnc-plugin-page-owner-tree.c b/gnucash/gnome/gnc-plugin-page-owner-tree.c index 16d952f78a..b4375ec463 100644 --- a/gnucash/gnome/gnc-plugin-page-owner-tree.c +++ b/gnucash/gnome/gnc-plugin-page-owner-tree.c @@ -70,7 +70,7 @@ static QofLogModule log_module = GNC_MOD_GUI; #define PLUGIN_PAGE_ACCT_TREE_CM_CLASS "plugin-page-owner-tree" #define DELETE_DIALOG_FILTER "filter" -#define DELETE_DIALOG_OWNER "owner" +#define DELETE_DIALOG_OWNER "owner" enum { @@ -107,6 +107,7 @@ static GtkWidget *gnc_plugin_page_owner_tree_create_widget (GncPluginPage *plugi static void gnc_plugin_page_owner_tree_destroy_widget (GncPluginPage *plugin_page); static void gnc_plugin_page_owner_tree_save_page (GncPluginPage *plugin_page, GKeyFile *file, const gchar *group); static GncPluginPage *gnc_plugin_page_owner_tree_recreate_page (GtkWidget *window, GKeyFile *file, const gchar *group); +static void set_menu_and_toolbar_qualifier (GncPluginPage *plugin_page); /* Callbacks */ static gboolean gnc_plugin_page_owner_tree_button_press_cb (GtkWidget *widget, @@ -132,7 +133,7 @@ static void gnc_plugin_page_owner_tree_cmd_new_invoice (GSimpleAction *simple, G static void gnc_plugin_page_owner_tree_cmd_owners_report (GSimpleAction *simple, GVariant *parameter, gpointer user_data); static void gnc_plugin_page_owner_tree_cmd_owner_report (GSimpleAction *simple, GVariant *parameter, gpointer user_data); static void gnc_plugin_page_owner_tree_cmd_process_payment (GSimpleAction *simple, GVariant *parameter, gpointer user_data); - +static void gnc_plugin_page_owner_tree_cmd_edit_tax (GSimpleAction *simple, GVariant *parameter, gpointer user_data); static guint plugin_page_signals[LAST_SIGNAL] = { 0 }; @@ -152,6 +153,7 @@ static GActionEntry gnc_plugin_page_owner_tree_actions [] = { "ViewFilterByAction", gnc_plugin_page_owner_tree_cmd_view_filter_by, NULL, NULL, NULL }, { "ViewRefreshAction", gnc_plugin_page_owner_tree_cmd_refresh, NULL, NULL, NULL }, + { "EditTaxOptionsAction", gnc_plugin_page_owner_tree_cmd_edit_tax, NULL, NULL, NULL }, { "OTNewBillAction", gnc_plugin_page_owner_tree_cmd_new_invoice, NULL, NULL, NULL }, { "OTNewInvoiceAction", gnc_plugin_page_owner_tree_cmd_new_invoice, NULL, NULL, NULL }, { "OTNewVoucherAction", gnc_plugin_page_owner_tree_cmd_new_invoice, NULL, NULL, NULL }, @@ -249,6 +251,18 @@ static GncDisplayItem gnc_plugin_page_owner_tree_display_items [] = /** The number of display items provided by this plugin. */ static guint gnc_plugin_page_owner_tree_n_display_items = G_N_ELEMENTS(gnc_plugin_page_owner_tree_display_items); +/** The default menu items that need to be add to the menu */ +static const gchar *gnc_plugin_load_ui_items [] = +{ + "EditPlaceholder2", + "EditPlaceholder3", + "EditPlaceholder5", + "ViewPlaceholder1", + "ViewPlaceholder4", + "ReportsPlaceholder1", + NULL, +}; + /** Actions that require an owner to be selected before they are * enabled. These ones are only sensitive in a read-write book. */ static const gchar *actions_requiring_owner_rw[] = @@ -367,17 +381,6 @@ gnc_plugin_page_owner_tree_new (GncOwnerType owner_type) priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(plugin_page); priv->owner_type = owner_type; - /* Hide menu and toolbar items that are not relevant for the active owner list */ - simple_action_group = gnc_plugin_page_get_action_groupb (GNC_PLUGIN_PAGE(plugin_page)); - for (i = 0; action_owners[i].action_name; i++) - { - action = g_action_map_lookup_action (G_ACTION_MAP(simple_action_group), - action_owners[i].action_name); -//FIXMEb g_object_set (G_OBJECT(action), -// "visible", (priv->owner_type == action_owners[i].owner_type), -// NULL); - } - LEAVE("new %s tree page %p", gncOwnerTypeToQofIdType(owner_type), plugin_page); return GNC_PLUGIN_PAGE(plugin_page); } @@ -394,6 +397,21 @@ gnc_plugin_page_owner_focus_widget (GncPluginPage *owner_plugin_page) GncPluginPageOwnerTreePrivate *priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(owner_plugin_page); GtkTreeView *tree_view = priv->tree_view; + /* Disable the Transaction Menu */ + GAction *action = gnc_main_window_find_action (GNC_MAIN_WINDOW(owner_plugin_page->window), "TransactionAction"); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE); + /* Disable the Schedule menu */ + action = gnc_main_window_find_action (GNC_MAIN_WINDOW(owner_plugin_page->window), "ScheduledAction"); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE); + /* Disable the FilePrintAction */ + action = gnc_main_window_find_action (GNC_MAIN_WINDOW(owner_plugin_page->window), "FilePrintAction"); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE); + + set_menu_and_toolbar_qualifier (owner_plugin_page); + + gnc_main_window_update_menu (GNC_MAIN_WINDOW(owner_plugin_page->window), owner_plugin_page, + gnc_plugin_load_ui_items); + if (GTK_IS_TREE_VIEW(tree_view)) { if (!gtk_widget_is_focus (GTK_WIDGET(tree_view))) @@ -453,7 +471,7 @@ gnc_plugin_page_owner_tree_init (GncPluginPageOwnerTree *plugin_page) G_CALLBACK (gnc_plugin_page_owner_tree_selected), plugin_page); /* change me when the system supports multiple books */ - gnc_plugin_page_add_book(parent, gnc_get_current_book()); + gnc_plugin_page_add_book (parent, gnc_get_current_book()); /* Create menu and toolbar information */ simple_action_group = gnc_plugin_page_create_action_groupb (parent, "GncPluginPageOwnerTreeActions"); @@ -461,8 +479,8 @@ gnc_plugin_page_owner_tree_init (GncPluginPageOwnerTree *plugin_page) gnc_plugin_page_owner_tree_actions, gnc_plugin_page_owner_tree_n_actions, plugin_page); -//FIXMEb gnc_plugin_init_short_names (action_group, toolbar_labels); +//FIXMEb gnc_plugin_init_short_names (action_group, toolbar_labels); /* Init filter */ priv->fd.show_inactive = TRUE; @@ -488,7 +506,8 @@ gnc_plugin_page_owner_tree_finalize (GObject *object) LEAVE(" "); } -static void update_inactive_actions(GncPluginPage *plugin_page) +static void +update_inactive_actions(GncPluginPage *plugin_page) { GSimpleActionGroup *simple_action_group; gboolean is_sensitive = !qof_book_is_readonly(gnc_get_current_book()); @@ -499,13 +518,33 @@ static void update_inactive_actions(GncPluginPage *plugin_page) /* Get the action group */ simple_action_group = gnc_plugin_page_get_action_groupb (plugin_page); - g_return_if_fail (G_IS_SIMPLE_ACTION_GROUP (simple_action_group)); + g_return_if_fail (G_IS_SIMPLE_ACTION_GROUP(simple_action_group)); /* Set the action's sensitivity */ gnc_plugin_update_actionsb (simple_action_group, readonly_inactive_actions, "sensitive", is_sensitive); } +static void +set_menu_and_toolbar_qualifier (GncPluginPage *plugin_page) +{ + GncPluginPageOwnerTree *page = GNC_PLUGIN_PAGE_OWNER_TREE(plugin_page); + GncPluginPageOwnerTreePrivate *priv; + + g_return_if_fail (GNC_IS_PLUGIN_PAGE_OWNER_TREE(page)); + + priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(page); + + if (priv->owner_type == GNC_OWNER_CUSTOMER) + gnc_plugin_page_set_menu_qualifier (plugin_page, "c"); + else if (priv->owner_type == GNC_OWNER_VENDOR) + gnc_plugin_page_set_menu_qualifier (plugin_page, "v"); + else if (priv->owner_type == GNC_OWNER_EMPLOYEE) + gnc_plugin_page_set_menu_qualifier (plugin_page, "e"); + else + gnc_plugin_page_set_menu_qualifier (plugin_page, NULL); +} + static void gnc_plugin_page_owner_tree_selected (GObject *object, gpointer user_data) { @@ -685,6 +724,8 @@ gnc_plugin_page_owner_tree_create_widget (GncPluginPage *plugin_page) G_CALLBACK(gnc_plugin_page_inserted_cb), NULL); + set_menu_and_toolbar_qualifier (plugin_page); + LEAVE("widget = %p", priv->widget); return priv->widget; } @@ -1180,6 +1221,21 @@ gnc_plugin_page_owner_tree_cmd_refresh (GSimpleAction *simple, gtk_widget_queue_draw (priv->widget); } +static void +gnc_plugin_page_owner_tree_cmd_edit_tax (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) +{ + GncPluginPageOwnerTree *plugin_page = user_data; + GtkWidget *parent; + + g_return_if_fail (GNC_IS_PLUGIN_PAGE_OWNER_TREE(plugin_page)); + + parent = GTK_WIDGET(gnc_plugin_page_get_window (GNC_PLUGIN_PAGE(plugin_page))); + + gnc_tax_info_dialog (parent, NULL); +} + static void gnc_plugin_page_owner_tree_cmd_new_invoice (GSimpleAction *simple, GVariant *parameter, diff --git a/gnucash/gnucash-gresources.xml b/gnucash/gnucash-gresources.xml index 39d0c02904..d133d4e6ac 100644 --- a/gnucash/gnucash-gresources.xml +++ b/gnucash/gnucash-gresources.xml @@ -20,6 +20,7 @@ ui/gnc-plugin-page-account-tree.ui ui/gnc-plugin-page-budget.ui + ui/gnc-plugin-page-owner-tree.ui ui/gnc-plugin-page-register.ui ui/gnc-plugin-page-sx-list.ui diff --git a/gnucash/ui/gnc-plugin-page-owner-tree.ui b/gnucash/ui/gnc-plugin-page-owner-tree.ui new file mode 100644 index 0000000000..743f94055d --- /dev/null +++ b/gnucash/ui/gnc-plugin-page-owner-tree.ui @@ -0,0 +1,685 @@ + + + + + + E_dit Customer + GncPluginPageOwnerTreeActions.OTEditCustomerAction + <Primary>e + Edit the selected customer + yes + + + _New Customer... + GncPluginPageOwnerTreeActions.OTNewCustomerAction + Create a new customer + yes + + + + + + E_dit Vendor + GncPluginPageOwnerTreeActions.OTEditVendorAction + <Primary>e + Edit the selected vendor + yes + + + _New Vendor... + GncPluginPageOwnerTreeActions.OTNewVendorAction + Create a new vendor + yes + + + + + + E_dit Employee + GncPluginPageOwnerTreeActions.OTEditEmployeeAction + <Primary>e + Edit the selected employee + yes + + + _New Employee... + GncPluginPageOwnerTreeActions.OTNewEmployeeAction + Create a new employee + yes + + + + + + + _Find... + gnc-plugin-basic-commands-actions.EditFindTransactionsAction + <Primary>f + Find transactions with a search + yes + + + + + + + Ta_x Report Options + GncPluginPageOwnerTreeActions.EditTaxOptionsAction + + Setup relevant accounts for tax reports, e.g. US income tax + yes + + + + + + _Filter By... + GncPluginPageOwnerTreeActions.ViewFilterByAction + yes + + + + + + _Refresh + GncPluginPageOwnerTreeActions.ViewRefreshAction + <Primary>r + Refresh this window + yes + + + + + + Customer Report + GncPluginPageOwnerTreeActions.OTCustomerReportAction + Show customer report + yes + + + Customer Listing + GncPluginPageOwnerTreeActions.OTCustomerListingReportAction + Show customer aging overview for all customers + yes + + + + + + Vendor Report + GncPluginPageOwnerTreeActions.OTVendorReportAction + Show vendor report + yes + + + Vendor Listing + GncPluginPageOwnerTreeActions.OTVendorListingReportAction + Show vendor aging overview for all vendors + yes + + + + + + Employee Report + GncPluginPageOwnerTreeActions.OTEmployeeReportAction + Show employee report + yes + + + + + +
+ + Re_name Page + mainwin.ActionsRenamePageAction + Rename this page + +
+
+ + E_dit Customer + GncPluginPageOwnerTreeActions.OTEditCustomerAction + Edit the selected customer + +
+
+ + New _Invoice... + GncPluginPageOwnerTreeActions.OTNewInvoiceAction + Create a new invoice + + + Customer Report + GncPluginPageOwnerTreeActions.OTCustomerReportAction + Show customer report + + + Process Payment + GncPluginPageOwnerTreeActions.OTProcessPaymentAction + Process Payment + +
+
+ + +
+ + Re_name Page + mainwin.ActionsRenamePageAction + Rename this page + +
+
+ + E_dit Vendor + GncPluginPageOwnerTreeActions.OTEditVendorAction + Edit the selected vendor + +
+
+ + New _Bill... + GncPluginPageOwnerTreeActions.OTNewBillAction + Create a new bill + + + Vendor Report + GncPluginPageOwnerTreeActions.OTVendorReportAction + Show vendor report + + + Process Payment + GncPluginPageOwnerTreeActions.OTProcessPaymentAction + Process Payment + +
+
+ + +
+ + Re_name Page + mainwin.ActionsRenamePageAction + Rename this page + +
+
+ + E_dit Employee + GncPluginPageOwnerTreeActions.OTEditEmployeeAction + Edit the selected customer + +
+
+ + New _Voucher... + GncPluginPageOwnerTreeActions.OTNewVoucherAction + Create a new voucher + + + Employee Report + GncPluginPageOwnerTreeActions.OTEmployeeReportAction + Show employee report + + + Process Payment + GncPluginPageOwnerTreeActions.OTProcessPaymentAction + Process Payment + +
+
+ + + + True + False + + + True + False + _Save + gnc-plugin-basic-commands-actions.FileSaveAction + Save the current file + True + document-save + + + False + True + + + + + True + False + _Close + mainwin.FileCloseAction + Close the currently active page + True + window-close + + + False + True + + + + + True + False + + + False + True + + + + + True + False + New _Invoice... + gnc-plugin-business-actions.ToolbarNewInvoiceAction + Open the New Invoice dialog + True + gnc-invoice-new + + + False + True + + + + + True + False + + + False + True + + + + + True + False + _New Customer... + GncPluginPageOwnerTreeActions.OTNewCustomerAction + Create a new customer + True + gnc-account-new + + + False + True + + + + + True + False + E_dit Customer + GncPluginPageOwnerTreeActions.OTEditCustomerAction + Edit the selected customer + True + gnc-account-edit + + + False + True + + + + + True + False + + + False + True + + + + + True + False + New _Invoice... + GncPluginPageOwnerTreeActions.OTNewInvoiceAction + Create a new invoice + True + gnc-invoice-pay + + + False + True + + + + + True + False + Customer Listing + GncPluginPageOwnerTreeActions.OTCustomerListingReportAction + Show customer aging overview for all customers + True + document-print-preview + + + False + True + + + + + True + False + Process Payment + GncPluginPageOwnerTreeActions.OTProcessPaymentAction + Process Payment + True + gnc-invoice-pay + + + False + True + + + + + + True + False + + + True + False + _Save + gnc-plugin-basic-commands-actions.FileSaveAction + Save the current file + True + document-save + + + False + True + + + + + True + False + _Close + mainwin.FileCloseAction + Close the currently active page + True + window-close + + + False + True + + + + + True + False + + + False + True + + + + + True + False + New _Invoice... + gnc-plugin-business-actions.ToolbarNewInvoiceAction + Open the New Invoice dialog + True + gnc-invoice-new + + + False + True + + + + + True + False + + + False + True + + + + + True + False + _New Vendor... + GncPluginPageOwnerTreeActions.OTNewVendorAction + Create a new vendor + True + gnc-account-new + + + False + True + + + + + True + False + E_dit Vendor + GncPluginPageOwnerTreeActions.OTEditVendorAction + Edit the selected vendor + True + gnc-account-edit + + + False + True + + + + + True + False + + + False + True + + + + + True + False + New _Bill... + GncPluginPageOwnerTreeActions.OTNewBillAction + Create a new bill + True + gnc-invoice-pay + + + False + True + + + + + True + False + Vendor Listing + GncPluginPageOwnerTreeActions.OTVendorListingReportAction + Show vendor aging overview for all vendors + True + document-print-preview + + + False + True + + + + + True + False + Process Payment + GncPluginPageOwnerTreeActions.OTProcessPaymentAction + Process Payment + True + gnc-invoice-pay + + + False + True + + + + + + True + False + + + True + False + _Save + gnc-plugin-basic-commands-actions.FileSaveAction + Save the current file + True + document-save + + + False + True + + + + + True + False + _Close + mainwin.FileCloseAction + Close the currently active page + True + window-close + + + False + True + + + + + True + False + + + False + True + + + + + True + False + New _Invoice... + gnc-plugin-business-actions.ToolbarNewInvoiceAction + Open the New Invoice dialog + True + gnc-invoice-new + + + False + True + + + + + True + False + + + False + True + + + + + True + False + _New Employee... + GncPluginPageOwnerTreeActions.OTNewEmployeeAction + Create a new employee + True + gnc-account-new + + + False + True + + + + + True + False + E_dit Employee + GncPluginPageOwnerTreeActions.OTEditEmployeeAction + Edit the selected employee + True + gnc-account-edit + + + False + True + + + + + True + False + + + False + True + + + + + True + False + New _Voucher... + GncPluginPageOwnerTreeActions.OTNewVoucherAction + Create a new voucher + True + gnc-invoice-pay + + + False + True + + + + + True + False + Process Payment + GncPluginPageOwnerTreeActions.OTProcessPaymentAction + Process Payment + True + gnc-invoice-pay + + + False + True + + + + +
From 95cfd2e68d5db6d903f7f0841c10f51d9821dab9 Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Fri, 28 Oct 2022 16:28:46 +0100 Subject: [PATCH 19/77] Changes for business invoice pages --- gnucash/gnome/gnc-plugin-page-invoice.c | 134 ++++-- gnucash/gnucash-gresources.xml | 1 + gnucash/ui/gnc-plugin-page-invoice.ui | 556 ++++++++++++++++++++++++ 3 files changed, 658 insertions(+), 33 deletions(-) create mode 100644 gnucash/ui/gnc-plugin-page-invoice.ui diff --git a/gnucash/gnome/gnc-plugin-page-invoice.c b/gnucash/gnome/gnc-plugin-page-invoice.c index 2ed22f8640..bb02e4111e 100644 --- a/gnucash/gnome/gnc-plugin-page-invoice.c +++ b/gnucash/gnome/gnc-plugin-page-invoice.c @@ -46,6 +46,7 @@ #include "dialog-doclink.h" #include "dialog-doclink-utils.h" #include "gncInvoice.h" +#include "gnc-ui.h" /* This static indicates the debugging module that this .o belongs to. */ static QofLogModule log_module = GNC_MOD_GUI; @@ -90,13 +91,14 @@ static void gnc_plugin_page_invoice_cmd_link_open (GSimpleAction *simple, GVaria static void gnc_plugin_page_invoice_cmd_company_report (GSimpleAction *simple, GVariant *paramter, gpointer user_data); static void gnc_plugin_page_invoice_cmd_entryUp (GSimpleAction *simple, GVariant *paramter, gpointer user_data); static void gnc_plugin_page_invoice_cmd_entryDown (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_invoice_cmd_edit_tax (GSimpleAction *simple, GVariant *paramter, gpointer user_data); static void gnc_plugin_page_redraw_help_cb (GnucashRegister *gsr, GncPluginPageInvoice *invoice_page); static void gnc_plugin_page_invoice_refresh_cb (GHashTable *changes, gpointer user_data); static void -change_radio_state (GSimpleAction *simple, +radio_change_state (GSimpleAction *simple, GVariant *state, gpointer user_data) { @@ -108,7 +110,6 @@ change_radio_state (GSimpleAction *simple, ************************************************************/ static GActionEntry gnc_plugin_page_invoice_actions [] = { - { "SortOrderAction", NULL, NULL, NULL, NULL }, { "FileNewAccountAction", gnc_plugin_page_invoice_cmd_new_account, NULL, NULL, NULL }, { "FilePrintAction", gnc_plugin_page_invoice_cmd_print, NULL, NULL, NULL }, { "EditCutAction", gnc_plugin_page_invoice_cmd_cut, NULL, NULL, NULL }, @@ -118,6 +119,7 @@ static GActionEntry gnc_plugin_page_invoice_actions [] = { "EditDuplicateInvoiceAction", gnc_plugin_page_invoice_cmd_duplicateInvoice, NULL, NULL, NULL }, { "EditPostInvoiceAction", gnc_plugin_page_invoice_cmd_post, NULL, NULL, NULL }, { "EditUnpostInvoiceAction", gnc_plugin_page_invoice_cmd_unpost, NULL, NULL, NULL }, + { "EditTaxOptionsAction", gnc_plugin_page_invoice_cmd_edit_tax, NULL, NULL, NULL }, { "ViewRefreshAction", gnc_plugin_page_invoice_cmd_refresh, NULL, NULL, NULL }, { "ViewSaveLayoutAction", gnc_plugin_page_invoice_cmd_save_layout, NULL, NULL, NULL }, { "ViewResetLayoutAction", gnc_plugin_page_invoice_cmd_reset_layout, NULL, NULL, NULL }, @@ -133,7 +135,7 @@ static GActionEntry gnc_plugin_page_invoice_actions [] = { "BusinessLinkOpenAction", gnc_plugin_page_invoice_cmd_link_open, NULL, NULL, NULL }, { "ToolsProcessPaymentAction", gnc_plugin_page_invoice_cmd_pay_invoice, NULL, NULL, NULL }, { "ReportsCompanyReportAction", gnc_plugin_page_invoice_cmd_company_report, NULL, NULL, NULL }, - { "SortOrderRadio", gnc_plugin_page_invoice_cmd_sort_changed, "n", 0, change_radio_state }, + { "SortOrderRadioAction", gnc_plugin_page_invoice_cmd_sort_changed, "i", "@i 0", radio_change_state }, }; static guint gnc_plugin_page_invoice_n_actions = G_N_ELEMENTS(gnc_plugin_page_invoice_actions); @@ -246,6 +248,23 @@ static GncDisplayItem gnc_plugin_page_invoice_display_items [] = /** The number of display items provided by this plugin. */ static guint gnc_plugin_page_invoice_n_display_items = G_N_ELEMENTS(gnc_plugin_page_invoice_display_items); +/** The default menu items that need to be add to the menu */ +static const gchar *gnc_plugin_load_ui_items [] = +{ + "EditPlaceholder1", + "EditPlaceholder3", + "EditPlaceholder5", + "ViewPlaceholder1", + "ViewPlaceholder2", + "ViewPlaceholder4", + "ActionsPlaceholder4", + "ActionsPlaceholder5", + "BusinessPlaceholder2", + "BusinessPlaceholder3", + "ReportsPlaceholder1", + NULL, +}; + static const gchar *invoice_book_readwrite_actions[] = { // Only insert actions here which are not yet in posted_actions and unposted_actions! @@ -464,6 +483,9 @@ typedef struct GncPluginPageInvoicePrivate InvoiceWindow *iw; GtkWidget *widget; + gboolean is_posted; + gboolean can_unpost; + gboolean is_readonly; gint component_manager_id; } GncPluginPageInvoicePrivate; @@ -576,12 +598,6 @@ gnc_plugin_page_invoice_init (GncPluginPageInvoice *plugin_page) gnc_plugin_page_invoice_n_actions, plugin_page); -//FIXMEb gtk_action_group_add_radio_actions (action_group, -// radio_entries, n_radio_entries, -// REG_STYLE_LEDGER, -// G_CALLBACK(gnc_plugin_page_invoice_cmd_sort_changed), -// plugin_page); - //FIXMEb gnc_plugin_init_short_names (action_group, toolbar_labels); } @@ -598,26 +614,31 @@ gnc_plugin_page_invoice_finalize (GObject *object) static void update_doclink_actions (GncPluginPage *plugin_page, gboolean has_uri) { - GAction *uri_action; - - uri_action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE(plugin_page), "BusinessLinkOpenAction"); + GAction *uri_action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE(plugin_page), + "BusinessLinkOpenAction"); g_simple_action_set_enabled (G_SIMPLE_ACTION(uri_action), has_uri); } static void -gnc_plugin_page_invoice_action_update (GSimpleActionGroup *simple_action_group, - action_toolbar_labels *action_list, - void (*gtkfunc)(gpointer, gpointer)) +gnc_plugin_page_invoice_action_update (GncPluginPage *plugin_page, + action_toolbar_labels *action_list) { - GAction *action; - gint i; - - for (i = 0; action_list[i].action_name; i++) + GtkWidget *menu_item; + GtkWidget *tool_item; +//FIXMEb this may need changing to update the menu model instead of the GtkMenuItem + for (gint i = 0; (action_list[i].action_name != NULL); i++) { - /* update the action */ - action = g_action_map_lookup_action (G_ACTION_MAP(simple_action_group), - action_list[i].action_name); - gtkfunc (action, _(action_list[i].label)); + menu_item = gnc_main_window_menu_find_menu_item (GNC_MAIN_WINDOW(GNC_PLUGIN_PAGE(plugin_page)->window), + action_list[i].action_name); + + if (menu_item) + gtk_menu_item_set_label (GTK_MENU_ITEM(menu_item), _(action_list[i].label)); + + tool_item = gnc_main_window_toolbar_find_menu_item (GNC_MAIN_WINDOW(GNC_PLUGIN_PAGE(plugin_page)->window), + action_list[i].action_name); + + if (tool_item) + gtk_tool_button_set_label (GTK_TOOL_BUTTON(tool_item), _(action_list[i].label)); } } @@ -641,7 +662,9 @@ gnc_plugin_page_update_reset_layout_action (GncPluginPage *page) void gnc_plugin_page_invoice_update_menus (GncPluginPage *page, gboolean is_posted, gboolean can_unpost) { + GncMainWindow *window; GSimpleActionGroup *simple_action_group; + GAction *action; GncPluginPageInvoicePrivate *priv; GncInvoiceType invoice_type; GncInvoice *invoice; @@ -656,9 +679,19 @@ gnc_plugin_page_invoice_update_menus (GncPluginPage *page, gboolean is_posted, g g_return_if_fail (GNC_IS_PLUGIN_PAGE_INVOICE(page)); + window = (GncMainWindow*)gnc_plugin_page_get_window (GNC_PLUGIN_PAGE(page)); + + if (gnc_main_window_get_current_page (window) != page) + return; + priv = GNC_PLUGIN_PAGE_INVOICE_GET_PRIVATE(page); invoice_type = gnc_invoice_get_type_from_window(priv->iw); + // lets remember these settings + priv->is_posted = is_posted; + priv->can_unpost = can_unpost; + priv->is_readonly = is_readonly; + switch (invoice_type) { case GNC_INVOICE_CUST_INVOICE: label_list = invoice_action_labels; @@ -712,6 +745,10 @@ gnc_plugin_page_invoice_update_menus (GncPluginPage *page, gboolean is_posted, g can_unpost = FALSE; } + /* Enable the FilePrintAction */ + action = gnc_main_window_find_action (window, "FilePrintAction"); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), TRUE); + simple_action_group = gnc_plugin_page_get_action_groupb (page); gnc_plugin_update_actionsb (simple_action_group, posted_actions, "sensitive", is_posted); @@ -723,17 +760,17 @@ gnc_plugin_page_invoice_update_menus (GncPluginPage *page, gboolean is_posted, g "sensitive", !is_readonly); /* update the action labels */ - gnc_plugin_page_invoice_action_update (simple_action_group, label_list, (void*)gtk_action_set_label); + gnc_plugin_page_invoice_action_update (page, label_list); /* update the action tooltips */ - gnc_plugin_page_invoice_action_update (simple_action_group, tooltip_list, (void*)gtk_action_set_tooltip); +//FIXMRb gnc_plugin_page_invoice_action_update (simple_action_group, tooltip_list, (void*)gtk_action_set_tooltip); // if there is no default layout do not enable reset action gnc_plugin_page_update_reset_layout_action (page); /* update the layout action labels */ - gnc_plugin_page_invoice_action_update (simple_action_group, label_layout_list, (void*)gtk_action_set_label); + gnc_plugin_page_invoice_action_update (page, label_layout_list); /* update the layout action tooltips */ - gnc_plugin_page_invoice_action_update (simple_action_group, tooltip_layout_list, (void*)gtk_action_set_tooltip); +//FIXMEb gnc_plugin_page_invoice_action_update (simple_action_group, tooltip_layout_list, (void*)gtk_action_set_tooltip); // update doclink buttons invoice = gnc_invoice_window_get_invoice (priv->iw); @@ -759,6 +796,18 @@ gnc_plugin_page_invoice_focus_widget (GncPluginPage *invoice_plugin_page) GtkWidget *notes = gnc_invoice_get_notes(priv->iw); GnucashSheet *sheet; + /* Disable the Transaction Menu */ + GAction *action = gnc_main_window_find_action (GNC_MAIN_WINDOW(invoice_plugin_page->window), "TransactionAction"); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE); + /* Disable the Schedule menu */ + action = gnc_main_window_find_action (GNC_MAIN_WINDOW(invoice_plugin_page->window), "ScheduledAction"); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE); + + gnc_main_window_update_menu (GNC_MAIN_WINDOW(invoice_plugin_page->window), invoice_plugin_page, + gnc_plugin_load_ui_items); + + gnc_plugin_page_invoice_update_menus (invoice_plugin_page, priv->is_posted, priv->can_unpost); + // if there is no default layout do not enable reset action gnc_plugin_page_update_reset_layout_action (invoice_plugin_page); @@ -1111,6 +1160,22 @@ gnc_plugin_page_invoice_cmd_edit (GSimpleAction *simple, LEAVE(" "); } +static void +gnc_plugin_page_invoice_cmd_edit_tax (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) +{ + GncPluginPageInvoice *plugin_page = user_data; + GtkWidget *parent; + + g_return_if_fail (GNC_IS_PLUGIN_PAGE_INVOICE(plugin_page)); + + ENTER("(action %p, plugin_page %p)", simple, plugin_page); + parent = GTK_WIDGET(gnc_plugin_page_get_window (GNC_PLUGIN_PAGE(plugin_page))); + gnc_tax_info_dialog (parent, NULL); + LEAVE(" "); +} + static void gnc_plugin_page_invoice_cmd_duplicateInvoice (GSimpleAction *simple, GVariant *paramter, @@ -1166,18 +1231,21 @@ gnc_plugin_page_invoice_cmd_sort_changed (GSimpleAction *simple, GVariant *parameter, gpointer user_data) { - GncPluginPageInvoice *plugin_page = user_data; GncPluginPageInvoicePrivate *priv; invoice_sort_type_t value; + GncPluginPageInvoice *plugin_page = user_data; + gint item; - g_return_if_fail(G_IS_SIMPLE_ACTION(simple)); - g_return_if_fail(GNC_IS_PLUGIN_PAGE_INVOICE(plugin_page)); + g_return_if_fail (G_IS_SIMPLE_ACTION(simple)); + g_return_if_fail (GNC_IS_PLUGIN_PAGE_INVOICE(plugin_page)); - ENTER("action %p, plugin_page %p)", simple, plugin_page); + ENTER("action %p, plugin_page (%p), item is %d", + simple, plugin_page, g_variant_get_int32 (parameter)); priv = GNC_PLUGIN_PAGE_INVOICE_GET_PRIVATE(plugin_page); -//FIXMEb value = gtk_radio_action_get_current_value(current); -// gnc_invoice_window_sort (priv->iw, value); + item = g_variant_get_int32 (parameter); + g_action_change_state (G_ACTION(simple), parameter); + gnc_invoice_window_sort (priv->iw, item); LEAVE(" "); } diff --git a/gnucash/gnucash-gresources.xml b/gnucash/gnucash-gresources.xml index d133d4e6ac..a619419d65 100644 --- a/gnucash/gnucash-gresources.xml +++ b/gnucash/gnucash-gresources.xml @@ -20,6 +20,7 @@ ui/gnc-plugin-page-account-tree.ui ui/gnc-plugin-page-budget.ui + ui/gnc-plugin-page-invoice.ui ui/gnc-plugin-page-owner-tree.ui ui/gnc-plugin-page-register.ui ui/gnc-plugin-page-sx-list.ui diff --git a/gnucash/ui/gnc-plugin-page-invoice.ui b/gnucash/ui/gnc-plugin-page-invoice.ui new file mode 100644 index 0000000000..5048d76efd --- /dev/null +++ b/gnucash/ui/gnc-plugin-page-invoice.ui @@ -0,0 +1,556 @@ + + + + + + EditEditInvoiceAction + GncPluginPageInvoiceActions.EditEditInvoiceAction + Edit this invoice + yes + + + EditDuplicateInvoiceAction + GncPluginPageInvoiceActions.EditDuplicateInvoiceAction + Create a new invoice as a duplicate of the current one + yes + + + EditPostInvoiceAction + GncPluginPageInvoiceActions.EditPostInvoiceAction + Post this invoice to your Chart of Accounts + yes + + + EditUnpostInvoiceAction + GncPluginPageInvoiceActions.EditUnpostInvoiceAction + Unpost this invoice and make it editable + yes + + + + + + _Find... + gnc-plugin-basic-commands-actions.EditFindTransactionsAction + <Primary>f + Find transactions with a search + yes + + + + + + + Ta_x Report Options + GncPluginPageAccountTreeActions.EditTaxOptionsAction + + Setup relevant accounts for tax reports, e.g. US income tax + yes + + + + + + ViewSaveLayoutAction + GncPluginPageInvoiceActions.ViewSaveLayoutAction + Use the current layout as default for all customer invoices and credit notes + yes + + + ViewResetLayoutAction + GncPluginPageInvoiceActions.ViewResetLayoutAction + Reset default layout for all customer invoices and credit notes back to built-in defaults and update the current page accordingly + yes + + + + + + Sort _Order + GncPluginPageInvoiceActions.SortOrderAction + yes +
+ + _Standard + GncPluginPageInvoiceActions.SortOrderRadioAction + 0 + yes + + + _Date + GncPluginPageInvoiceActions.SortOrderRadioAction + 1 + yes + + + Date of _Entry + GncPluginPageInvoiceActions.SortOrderRadioAction + 2 + yes + + + _Quantity + GncPluginPageInvoiceActions.SortOrderRadioAction + 4 + yes + + + _Price + GncPluginPageInvoiceActions.SortOrderRadioAction + 5 + yes + + + Descri_ption + GncPluginPageInvoiceActions.SortOrderRadioAction + 3 + yes + +
+
+
+ + + + _Refresh + GncPluginPageInvoiceActions.ViewRefreshAction + <Primary>r + Refresh this window + yes + + + + + + _Enter + GncPluginPageInvoiceActions.RecordEntryAction + Record the current entry + yes + + + _Cancel + GncPluginPageInvoiceActions.CancelEntryAction + Cancel the current entry + yes + + + _Delete + GncPluginPageInvoiceActions.DeleteEntryAction + Delete the current entry + yes + + + _Blank + GncPluginPageInvoiceActions.BlankEntryAction + Move to the blank entry at the bottom + yes + + + + + + Dup_licate Entry + GncPluginPageInvoiceActions.DuplicateEntryAction + Make a copy of the current entry + yes + + + Move Entry _Up + GncPluginPageInvoiceActions.EntryUpAction + Move the current entry one row upwards + yes + + + Move Entry Do_wn + GncPluginPageInvoiceActions.EntryDownAction + Move the current entry one row downwards + yes + + + + + + BusinessLinkAction + GncPluginPageInvoiceActions.BusinessLinkAction + Manage link of an external document to this item + yes + + + BusinessLinkOpenAction + GncPluginPageInvoiceActions.BusinessLinkOpenAction + Open the linked document + yes + + + + + + ToolsProcessPaymentAction + GncPluginPageInvoiceActions.ToolsProcessPaymentAction + Enter a payment for the owner of this invoice + yes + + + + + + _Company Report + GncPluginPageInvoiceActions.ReportsCompanyReportAction + Open a company report window for the owner of this invoice + yes + + + + + +
+ + Re_name Page + mainwin.ActionsRenamePageAction + Rename this page + +
+
+ + _Enter + GncPluginPageInvoiceActions.RecordEntryAction + Record the current entry + + + _Cancel + GncPluginPageInvoiceActions.CancelEntryAction + Cancel the current entry + + + _Delete + GncPluginPageInvoiceActions.DeleteEntryAction + Delete the current entry + +
+
+ + Dup_licate Entry + GncPluginPageInvoiceActions.DuplicateEntryAction + Make a copy of the current entry + + + Move Entry _Up + GncPluginPageInvoiceActions.EntryUpAction + Move the current entry one row upwards + + + Move Entry Do_wn + GncPluginPageInvoiceActions.EntryDownAction + Move the current entry one row downwards + + + _Blank + GncPluginPageInvoiceActions.BlankEntryAction + Move to the blank entry at the bottom of the Invoice + +
+
+ + + + True + False + + + True + False + _Save + gnc-plugin-basic-commands-actions.FileSaveAction + Save the current file + True + document-save + + + False + True + + + + + True + False + _Print Invoice + gnc-plugin-business-actions.FilePrintAction + Make a printable invoice + True + document-print + + + False + True + + + + + True + False + _Close + mainwin.FileCloseAction + Close the currently active page + True + window-close + + + False + True + + + + + True + False + + + False + True + + + + + True + False + New _Invoice... + gnc-plugin-business-actions.ToolbarNewInvoiceAction + Open the New Invoice dialog + True + gnc-invoice-new + + + False + True + + + + + True + False + + + False + True + + + + + True + False + New _Invoice + GncPluginPageInvoiceActions.BusinessNewInvoiceAction + Create a new invoice for the same owner as the current one + True + gnc-invoice-new + + + False + True + + + + + True + False + _Edit Invoice + GncPluginPageInvoiceActions.EditEditInvoiceAction + Edit this invoice + True + gnc-invoice-edit + + + False + True + + + + + True + False + _Duplicate Invoice + GncPluginPageInvoiceActions.EditDuplicateInvoiceAction + Create a new invoice as a duplicate of the current one + True + gnc-invoice-duplicate + + + False + True + + + + + True + False + + + False + True + + + + + True + False + _Enter + GncPluginPageInvoiceActions.RecordEntryAction + Record the current entry + True + list-add + + + False + True + + + + + True + False + _Cancel + GncPluginPageInvoiceActions.CancelEntryAction + Cancel the current entry + True + process-stop + + + False + True + + + + + True + False + _Delete + GncPluginPageInvoiceActions.DeleteEntryAction + Delete the current entry + True + edit-delete + + + False + True + + + + + True + False + Dup_licate Entry + GncPluginPageInvoiceActions.DuplicateEntryAction + Make a copy of the current entry + True + edit-copy + + + False + True + + + + + True + False + Move Entry _Up + GncPluginPageInvoiceActions.EntryUpAction + Move the current entry one row upwards + True + pan-up-symbolic + + + False + True + + + + + True + False + Move Entry Do_wn + GncPluginPageInvoiceActions.EntryDownAction + Move the current entry one row downwards + True + pan-down-symbolic + + + False + True + + + + + True + False + _Blank + GncPluginPageInvoiceActions.BlankEntryAction + Move to the blank entry at the bottom of the Invoice + True + go-bottom + + + False + True + + + + + True + False + + + False + True + + + + + True + False + _Post Invoice + GncPluginPageInvoiceActions.EditPostInvoiceAction + Post this invoice to your Chart of Accounts + True + gnc-invoice-post + + + False + True + + + + + True + False + _Unpost Invoice + GncPluginPageInvoiceActions.EditUnpostInvoiceAction + Unpost this invoice and make it editable + True + gnc-invoice-unpost + + + False + True + + + + + True + False + _Pay Invoice + GncPluginPageInvoiceActions.ToolsProcessPaymentAction + Enter a payment for the owner of this invoice + True + gnc-invoice-pay + + + False + True + + + + +
+ From 1f44b693965d789eadd9a6429bc6264ed865243a Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Sun, 30 Oct 2022 13:30:39 +0000 Subject: [PATCH 20/77] Changes for Aqbanking plugin --- .../import-export/aqb/gnc-plugin-aqbanking.c | 51 ++++++++++--------- 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/gnucash/import-export/aqb/gnc-plugin-aqbanking.c b/gnucash/import-export/aqb/gnc-plugin-aqbanking.c index 1fd4b69ab7..8ff7ade8b3 100644 --- a/gnucash/import-export/aqb/gnc-plugin-aqbanking.c +++ b/gnucash/import-export/aqb/gnc-plugin-aqbanking.c @@ -199,9 +199,15 @@ gnc_plugin_aqbanking_add_to_window(GncPlugin *plugin, GncMainWindow *window, G_CALLBACK(gnc_plugin_ab_main_window_page_changed), plugin); - action = gnc_main_window_find_action (window, MENU_TOGGLE_ACTION_AB_VIEW_LOGWINDOW); + action = gnc_main_window_find_action_in_group (window, PLUGIN_ACTIONS_NAME, + MENU_TOGGLE_ACTION_AB_VIEW_LOGWINDOW); -//FIXMEb gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), FALSE); + if (action) + { + GVariant *state = g_action_get_state (G_ACTION(action)); + g_action_change_state (G_ACTION(action), g_variant_new_boolean (FALSE)); + g_variant_unref (state); + } } static void @@ -269,13 +275,13 @@ static void update_inactive_actions(GncPluginPage *plugin_page) return; window = GNC_MAIN_WINDOW(plugin_page->window); - g_return_if_fail(GNC_IS_MAIN_WINDOW(window)); + g_return_if_fail (GNC_IS_MAIN_WINDOW(window)); simple_action_group = gnc_main_window_get_action_group (window, PLUGIN_ACTIONS_NAME); g_return_if_fail (G_IS_SIMPLE_ACTION_GROUP(simple_action_group)); /* Set the action's sensitivity */ gnc_plugin_update_actionsb (simple_action_group, readonly_inactive_actions, - "sensitive", is_readwrite); + "sensitive", is_readwrite); } @@ -284,19 +290,19 @@ static void update_inactive_actions(GncPluginPage *plugin_page) * the page that is currently selected. */ static void -gnc_plugin_ab_main_window_page_changed(GncMainWindow *window, - GncPluginPage *page, gpointer user_data) +gnc_plugin_ab_main_window_page_changed (GncMainWindow *window, + GncPluginPage *page, gpointer user_data) { - Account *account = main_window_to_account(window); + Account *account = main_window_to_account (window); /* Make sure not to call this with a NULL GncPluginPage */ if (page) { // Update the menu items according to the selected account - gnc_plugin_ab_account_selected(page, account, user_data); + gnc_plugin_ab_account_selected (page, account, user_data); // Also update the action sensitivity due to read-only - update_inactive_actions(page); + update_inactive_actions (page); } } @@ -305,8 +311,8 @@ gnc_plugin_ab_main_window_page_changed(GncMainWindow *window, * selecting another register page. Update the aqbanking menus appropriately. */ static void -gnc_plugin_ab_account_selected(GncPluginPage *plugin_page, Account *account, - gpointer user_data) +gnc_plugin_ab_account_selected (GncPluginPage *plugin_page, Account *account, + gpointer user_data) { GncMainWindow *window; GSimpleActionGroup *simple_action_group; @@ -328,21 +334,19 @@ gnc_plugin_ab_account_selected(GncPluginPage *plugin_page, Account *account, "sensitive", (account && bankcode && *bankcode && accountid && *accountid)); - gnc_plugin_update_actionsb (simple_action_group, need_account_actions, - "visible", TRUE); + gnc_main_window_menu_item_vis_by_action (window, need_account_actions, TRUE); + #if (AQBANKING_VERSION_INT < 60400) gnc_plugin_update_actionsb (simple_action_group, inactive_account_actions, "sensitive", FALSE); - gnc_plugin_update_actionsb (simple_action_group, inactive_account_actions, - "visible", FALSE); + gnc_main_window_menu_item_vis_by_action (window, inactive_account_actions, FALSE); #endif } else { gnc_plugin_update_actionsb (simple_action_group, need_account_actions, "sensitive", FALSE); - gnc_plugin_update_actionsb (simple_action_group, need_account_actions, - "visible", FALSE); + gnc_main_window_menu_item_vis_by_action (window, need_account_actions, FALSE); } } @@ -412,16 +416,15 @@ main_window_to_account(GncMainWindow *window) } void -gnc_plugin_aqbanking_set_logwindow_visible(gboolean logwindow_visible) +gnc_plugin_aqbanking_set_logwindow_visible (gboolean logwindow_visible) { - GAction *action; - - action = gnc_main_window_find_action (gnc_main_window, - MENU_TOGGLE_ACTION_AB_VIEW_LOGWINDOW); + GAction *action = gnc_main_window_find_action_in_group (gnc_main_window, PLUGIN_ACTIONS_NAME, + MENU_TOGGLE_ACTION_AB_VIEW_LOGWINDOW); if (action) { -//FIXMEb gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), -// logwindow_visible); + GVariant *state = g_action_get_state (G_ACTION(action)); + g_action_change_state (G_ACTION(action), g_variant_new_boolean (logwindow_visible)); + g_variant_unref (state); } } From a2ec925a1eeb180652628ea00cd9e17cc7e65939 Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Fri, 28 Oct 2022 16:29:55 +0100 Subject: [PATCH 21/77] Changes for report plugin pages --- gnucash/gnome-utils/gnc-menu-extensions.c | 66 ++-- gnucash/gnome-utils/gnc-menu-extensions.h | 22 +- .../gnome-utils/gnc-plugin-menu-additions.c | 232 +++++++++----- .../gnome-utils/gnc-plugin-menu-additions.h | 2 +- gnucash/gnome/gnc-plugin-page-report.cpp | 286 ++++++++++------- gnucash/gnome/report-menus.scm | 2 +- gnucash/gnucash-gresources.xml | 1 + gnucash/ui/gnc-plugin-page-report.ui | 287 ++++++++++++++++++ 8 files changed, 668 insertions(+), 230 deletions(-) create mode 100644 gnucash/ui/gnc-plugin-page-report.ui diff --git a/gnucash/gnome-utils/gnc-menu-extensions.c b/gnucash/gnome-utils/gnc-menu-extensions.c index eea7b72412..36666feffe 100644 --- a/gnucash/gnome-utils/gnc-menu-extensions.c +++ b/gnucash/gnome-utils/gnc-menu-extensions.c @@ -74,7 +74,7 @@ initialize_getters() static gboolean -gnc_extension_type (SCM extension, GtkUIManagerItemType *type) +gnc_extension_type (SCM extension, GNCMenuItemTypes *type) { char *string; @@ -89,15 +89,15 @@ gnc_extension_type (SCM extension, GtkUIManagerItemType *type) if (g_strcmp0(string, "menu-item") == 0) { - *type = GTK_UI_MANAGER_MENUITEM; + *type = GNC_MENU_ITEM; } else if (g_strcmp0(string, "menu") == 0) { - *type = GTK_UI_MANAGER_MENU; + *type = GNC_SUB_MENU_ITEM; } else if (g_strcmp0(string, "separator") == 0) { - *type = GTK_UI_MANAGER_SEPARATOR; + *type = GNC_SEPARATOR_ITEM; } else { @@ -261,10 +261,10 @@ gnc_create_extension_info (SCM extension) gchar* name; gchar* guid; - ext_info = g_new0(ExtensionInfo, 1); + ext_info = g_new0 (ExtensionInfo, 1); ext_info->extension = extension; - gnc_extension_path(extension, &ext_info->path); - if (!gnc_extension_type( extension, &ext_info->type )) + gnc_extension_path (extension, &ext_info->path); + if (!gnc_extension_type (extension, &ext_info->type)) { /* Can't parse the type passed to us. Bail now. */ g_free(ext_info); @@ -272,29 +272,29 @@ gnc_create_extension_info (SCM extension) } /* Get all the pieces */ - name = gnc_extension_name(extension); - guid = gnc_extension_guid(extension); - ext_info->ae.label = g_strdup(gettext(name)); - ext_info->ae.name = gnc_ext_gen_action_name(guid); - ext_info->ae.tooltip = gnc_extension_documentation(extension); - ext_info->ae.stock_id = NULL; - ext_info->ae.accelerator = NULL; - ext_info->ae.callback = NULL; - g_free(name); - g_free(guid); + name = gnc_extension_name (extension); + guid = gnc_extension_guid (extension); + ext_info->action_label = g_strdup (gettext (name)); + ext_info->action_name = gnc_ext_gen_action_name (guid); + ext_info->action_tooltip = gnc_extension_documentation (extension); + g_free (name); + g_free (guid); - tmp = g_strdup_printf("%s/%s", ext_info->path, ext_info->ae.label); - ext_info->sort_key = g_utf8_collate_key(tmp, -1); + tmp = g_strdup_printf ("%s/%s", ext_info->path, ext_info->action_label); + ext_info->sort_key = g_utf8_collate_key (tmp, -1); g_free(tmp); switch (ext_info->type) { - case GTK_UI_MANAGER_MENU: + case GNC_SUB_MENU_ITEM: typeStr = "menu"; break; - case GTK_UI_MANAGER_MENUITEM: + case GNC_MENU_ITEM: typeStr = "menuitem"; break; + case GNC_SEPARATOR_ITEM: + typeStr = "sepitem"; + break; default: typeStr = "unk"; break; @@ -302,31 +302,31 @@ gnc_create_extension_info (SCM extension) ext_info->typeStr = typeStr; DEBUG( "extension: %s/%s [%s] tip [%s] type %s\n", - ext_info->path, ext_info->ae.label, ext_info->ae.name, - ext_info->ae.tooltip, ext_info->typeStr ); + ext_info->path, ext_info->action_label, ext_info->action_name, + ext_info->action_tooltip, ext_info->typeStr ); - scm_gc_protect_object(extension); + scm_gc_protect_object (extension); /* need to append so we can run them in order */ - extension_list = g_slist_append(extension_list, ext_info); + extension_list = g_slist_append (extension_list, ext_info); return TRUE; } static void -cleanup_extension_info(gpointer extension_info, gpointer not_used) +cleanup_extension_info (gpointer extension_info, gpointer not_used) { ExtensionInfo *ext_info = extension_info; if (ext_info->extension) - scm_gc_unprotect_object(ext_info->extension); + scm_gc_unprotect_object (ext_info->extension); - g_free(ext_info->sort_key); - g_free((gchar *)ext_info->ae.name); - g_free((gchar *)ext_info->ae.label); - g_free((gchar *)ext_info->ae.tooltip); - g_free(ext_info->path); - g_free(ext_info); + g_free (ext_info->sort_key); + g_free ((gchar *)ext_info->action_name); + g_free ((gchar *)ext_info->action_label); + g_free ((gchar *)ext_info->action_tooltip); + g_free (ext_info->path); + g_free (ext_info); } diff --git a/gnucash/gnome-utils/gnc-menu-extensions.h b/gnucash/gnome-utils/gnc-menu-extensions.h index 122e3bd763..060ab1e3f9 100644 --- a/gnucash/gnome-utils/gnc-menu-extensions.h +++ b/gnucash/gnome-utils/gnc-menu-extensions.h @@ -25,21 +25,29 @@ #include +typedef enum +{ + GNC_MENU_ITEM, + GNC_SUB_MENU_ITEM, + GNC_SEPARATOR_ITEM, +} GNCMenuItemTypes; + typedef struct _ExtensionInfo { SCM extension; - GtkActionEntry ae; + gchar *action_label; + gchar *action_name; + gchar *action_tooltip; + gchar *path; gchar *sort_key; const gchar *typeStr; - GtkUIManagerItemType type; + + GNCMenuItemTypes type; gboolean accel_assigned; } ExtensionInfo; - -#define ADDITIONAL_MENUS_PLACEHOLDER "AdditionalMenusPlaceholder" - GSList *gnc_extensions_get_menu_list (void); void gnc_extension_invoke_cb (SCM extension, SCM window); @@ -49,11 +57,11 @@ void gnc_extension_invoke_cb (SCM extension, SCM window); * @param extension A scheme object describing the menu to be * inserted. Functions written in C should use the gnc-plugin code. */ -void gnc_add_scm_extension(SCM extension); +void gnc_add_scm_extension (SCM extension); /** This function releases any memory being held by the 'extensions' * code. It is called from the window shutdown code. */ -void gnc_extensions_shutdown(void); +void gnc_extensions_shutdown (void); #endif diff --git a/gnucash/gnome-utils/gnc-plugin-menu-additions.c b/gnucash/gnome-utils/gnc-plugin-menu-additions.c index 448bc71f23..4cca8b300c 100644 --- a/gnucash/gnome-utils/gnc-plugin-menu-additions.c +++ b/gnucash/gnome-utils/gnc-plugin-menu-additions.c @@ -26,7 +26,7 @@ /** @addtogroup MenuPlugins @{ */ -/** @addtogroup PluginMenuAdditions Non-GtkAction Menu Support +/** @addtogroup PluginMenuAdditions Non-GAction Menu Support @{ */ /** @file gnc-plugin-menu-additions.c @brief Functions providing menu items from scheme code. @@ -45,6 +45,7 @@ #include "gnc-window.h" #include "gnc-ui.h" #include "gnc-menu-extensions.h" +#include "gnc-gtk-utils.h" static GObjectClass *parent_class = NULL; @@ -54,6 +55,7 @@ static void gnc_plugin_menu_additions_finalize (GObject *object); static void gnc_plugin_menu_additions_add_to_window (GncPlugin *plugin, GncMainWindow *window, GQuark type); static void gnc_plugin_menu_additions_remove_from_window (GncPlugin *plugin, GncMainWindow *window, GQuark type); +static void gnc_plugin_menu_additions_action_new_cb (GSimpleAction *simple, GVariant *parameter, gpointer user_data); /* Command callbacks */ @@ -65,7 +67,7 @@ static QofLogModule log_module = GNC_MOD_GUI; /** Private data for this plugin. This data structure is unused. */ typedef struct GncPluginMenuAdditionsPrivate { - gpointer dummy; + GHashTable *item_hash; } GncPluginMenuAdditionsPrivate; #define GNC_PLUGIN_MENU_ADDITIONS_GET_PRIVATE(o) \ @@ -80,11 +82,21 @@ typedef struct _GncPluginMenuAdditionsPerWindow window. This plugin must maintain its own data because of the way the menus are currently built. */ GncMainWindow *window; - GtkUIManager *ui_manager; - GtkActionGroup *group; - gint merge_id; + GHashTable *item_hash; + GHashTable *build_menu_hash; + GMenu *report_menu; + GMenu *sub_menu; } GncPluginMenuAdditionsPerWindow; +/** An array of all of the actions provided by the account tree + * plugin. */ +static GActionEntry gnc_plugin_actions [] = +{ + { "AdditionsAction", gnc_plugin_menu_additions_action_new_cb, "s", NULL, NULL }, +}; +/** The number of actions provided by this plugin. */ +static guint gnc_plugin_n_actions = G_N_ELEMENTS(gnc_plugin_actions); + /************************************************************ * Object Implementation * ************************************************************/ @@ -105,8 +117,11 @@ gnc_plugin_menu_additions_class_init (GncPluginMenuAdditionsClass *klass) plugin_class->plugin_name = GNC_PLUGIN_MENU_ADDITIONS_NAME; /* function overrides */ - plugin_class->add_to_window = gnc_plugin_menu_additions_add_to_window; + plugin_class->add_to_window = gnc_plugin_menu_additions_add_to_window; plugin_class->remove_from_window = gnc_plugin_menu_additions_remove_from_window; + plugin_class->actions_name = PLUGIN_ACTIONS_NAME; + plugin_class->actionsb = gnc_plugin_actions; + plugin_class->n_actionsb = gnc_plugin_n_actions; } static void @@ -119,9 +134,15 @@ gnc_plugin_menu_additions_init (GncPluginMenuAdditions *plugin) static void gnc_plugin_menu_additions_finalize (GObject *object) { - g_return_if_fail (GNC_IS_PLUGIN_MENU_ADDITIONS (object)); + GncPluginMenuAdditionsPrivate *priv; + g_return_if_fail (GNC_IS_PLUGIN_MENU_ADDITIONS(object)); ENTER("plugin %p", object); + + priv = GNC_PLUGIN_MENU_ADDITIONS_GET_PRIVATE(object); + + g_hash_table_destroy (priv->item_hash); + G_OBJECT_CLASS (parent_class)->finalize (object); LEAVE(""); } @@ -161,27 +182,34 @@ gnc_main_window_to_scm (GncMainWindow *window) return SWIG_NewPointerObj(window, main_window_type, 0); } - -/** The user has selected one of the items added by this plugin. - * Invoke the callback function that was registered along with the - * menu item. - * - * @param action A pointer to the action selected by the user. This - * action represents one of the items in the file history menu. - * - * @param data A pointer to the gnc-main-window data to be used by - * this function. This is mainly to find out which window it was - * that had a menu selected. - */ static void -gnc_plugin_menu_additions_action_cb (GAction *action, - GncMainWindowActionData *data) +gnc_plugin_menu_additions_action_new_cb (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + GncMainWindowActionData *data = user_data; + GncPluginMenuAdditionsPrivate *priv; + GncMainWindowActionData *cb_data; + gsize length; + const gchar *action_name; - g_return_if_fail (G_IS_SIMPLE_ACTION(action)); - g_return_if_fail (data != NULL); + g_return_if_fail (G_IS_SIMPLE_ACTION(simple)); - gnc_extension_invoke_cb (data->data, gnc_main_window_to_scm (data->window)); + ENTER(""); + priv = GNC_PLUGIN_MENU_ADDITIONS_GET_PRIVATE(data->data); + + action_name = g_variant_get_string (parameter, &length); + + PINFO("action name is '%s'", action_name); + + cb_data = g_hash_table_lookup (priv->item_hash, action_name); + + if (cb_data) + { + PINFO("Found action in table"); + gnc_extension_invoke_cb (cb_data->data, gnc_main_window_to_scm (cb_data->window)); + } + LEAVE(""); } @@ -201,9 +229,9 @@ gnc_menu_additions_sort (ExtensionInfo *a, ExtensionInfo *b) { if (a->type == b->type) return strcmp(a->sort_key, b->sort_key); - else if (a->type == GTK_UI_MANAGER_MENU) + else if (a->type == GNC_SUB_MENU_ITEM) return -1; - else if (b->type == GTK_UI_MANAGER_MENU) + else if (b->type == GNC_SUB_MENU_ITEM) return 1; else return 0; @@ -238,23 +266,23 @@ gnc_menu_additions_do_preassigned_accel (ExtensionInfo *info, GHashTable *table) gchar *map, *new_map, *accel_key; const gchar *ptr; - ENTER("Checking %s/%s [%s]", info->path, info->ae.label, info->ae.name); + ENTER("Checking %s/%s [%s]", info->path, info->action_label, info->action_name); if (info->accel_assigned) { LEAVE("Already processed"); return; } - if (!g_utf8_validate(info->ae.label, -1, NULL)) + if (!g_utf8_validate(info->action_label, -1, NULL)) { - g_warning("Extension menu label '%s' is not valid utf8.", info->ae.label); + g_warning ("Extension menu label '%s' is not valid utf8.", info->action_label); info->accel_assigned = TRUE; LEAVE("Label is invalid utf8"); return; } /* Was an accelerator pre-assigned in the source? */ - ptr = g_utf8_strchr(info->ae.label, -1, '_'); + ptr = g_utf8_strchr (info->action_label, -1, '_'); if (ptr == NULL) { LEAVE("not preassigned"); @@ -298,7 +326,7 @@ gnc_menu_additions_assign_accel (ExtensionInfo *info, GHashTable *table) gint len; gboolean map_allocated = FALSE; - ENTER("Checking %s/%s [%s]", info->path, info->ae.label, info->ae.name); + ENTER("Checking %s/%s [%s]", info->path, info->action_label, info->action_name); if (info->accel_assigned) { LEAVE("Already processed"); @@ -314,7 +342,7 @@ gnc_menu_additions_assign_accel (ExtensionInfo *info, GHashTable *table) } DEBUG("map '%s', path %s", map, info->path); - for (ptr = info->ae.label; *ptr; ptr = g_utf8_next_char(ptr)) + for (ptr = info->action_label; *ptr; ptr = g_utf8_next_char(ptr)) { uni = g_utf8_get_char(ptr); if (!g_unichar_isalpha(uni)) @@ -340,13 +368,13 @@ gnc_menu_additions_assign_accel (ExtensionInfo *info, GHashTable *table) } /* Now build a new string in the form "_". */ - start = g_strndup(info->ae.label, ptr - info->ae.label); + start = g_strndup (info->action_label, ptr - info->action_label); DEBUG("start %p, len %ld, text '%s'", start, g_utf8_strlen(start, -1), start); new_label = g_strconcat(start, "_", ptr, (gchar *)NULL); g_free(start); - DEBUG("label '%s' -> '%s'", info->ae.label, new_label); - g_free((gchar *)info->ae.label); - info->ae.label = new_label; + DEBUG("label '%s' -> '%s'", info->action_label, new_label); + g_free((gchar *)info->action_label); + info->action_label = new_label; /* Now build a new map. Old one freed automatically. */ new_map = g_strconcat(map, buf, (gchar *)NULL); @@ -376,26 +404,78 @@ gnc_menu_additions_menu_setup_one (ExtensionInfo *ext_info, GncPluginMenuAdditionsPerWindow *per_window) { GncMainWindowActionData *cb_data; + GMenuItem *item_path, *item_with_full_path; + gchar *full_path = NULL; + GMenuItem *gmenu_item = NULL; - DEBUG( "Adding %s/%s [%s] as [%s]", ext_info->path, ext_info->ae.label, - ext_info->ae.name, ext_info->typeStr ); + DEBUG("Adding %s/%s [%s] as [%s]", ext_info->path, ext_info->action_label, + ext_info->action_name, ext_info->typeStr ); cb_data = g_new0 (GncMainWindowActionData, 1); cb_data->window = per_window->window; cb_data->data = ext_info->extension; - if (ext_info->type == GTK_UI_MANAGER_MENUITEM) - ext_info->ae.callback = (GCallback)gnc_plugin_menu_additions_action_cb; + g_hash_table_insert (per_window->item_hash, g_strdup (ext_info->action_name), cb_data); - gtk_action_group_add_actions_full(per_window->group, &ext_info->ae, 1, - cb_data, g_free); - gtk_ui_manager_add_ui(per_window->ui_manager, per_window->merge_id, - ext_info->path, ext_info->ae.label, ext_info->ae.name, - ext_info->type, FALSE); - gtk_ui_manager_ensure_update(per_window->ui_manager); + if (g_str_has_suffix (ext_info->path, "_Custom")) + return; + + full_path = g_strconcat (ext_info->path, "/", ext_info->action_label, NULL); + + item_path = g_hash_table_lookup (per_window->build_menu_hash, ext_info->path); + item_with_full_path = g_hash_table_lookup (per_window->build_menu_hash, full_path); +//FIXMEb This needs refactoring + + if (!item_path && !item_with_full_path) + { + if (g_strcmp0 (ext_info->typeStr, "menuitem") == 0) + { + gmenu_item = g_menu_item_new (ext_info->action_label, NULL); + g_menu_item_set_action_and_target_value (gmenu_item, "gnc-plugin-menu-additions-actions.AdditionsAction", + g_variant_new_string (ext_info->action_name)); + + g_menu_item_set_attribute (gmenu_item, "tooltip", "s", ext_info->action_tooltip); + } + + if (g_strcmp0 (ext_info->typeStr, "menu") == 0) + { + GMenuModel *sub_menu = G_MENU_MODEL(g_menu_new ()); + + gmenu_item = g_menu_item_new_submenu (ext_info->action_label, sub_menu); + g_object_set_data (G_OBJECT(gmenu_item), "sub-menu", sub_menu); + } + g_menu_append_item (G_MENU(per_window->report_menu), gmenu_item); + } + + if (item_path && !item_with_full_path) + { + GMenuModel *sub_menu = G_MENU_MODEL(g_object_get_data (G_OBJECT(item_path), "sub-menu")); + + if (g_strcmp0 (ext_info->typeStr, "menuitem") == 0) + { + gmenu_item = g_menu_item_new (ext_info->action_label, NULL); + g_menu_item_set_action_and_target_value (gmenu_item, "gnc-plugin-menu-additions-actions.AdditionsAction", + g_variant_new_string (ext_info->action_name)); + + g_menu_item_set_attribute (gmenu_item, "tooltip", "s", ext_info->action_tooltip); + } + + if (g_strcmp0 (ext_info->typeStr, "menu") == 0) + { + GMenuModel *sub_menu = G_MENU_MODEL(g_menu_new ()); + + gmenu_item = g_menu_item_new_submenu (ext_info->action_label, sub_menu); + g_object_set_data (G_OBJECT(gmenu_item), "sub-menu", sub_menu); + } + g_menu_append_item (G_MENU(sub_menu), gmenu_item); + } + g_hash_table_insert (per_window->build_menu_hash, g_strdup (full_path), gmenu_item); + + g_free (full_path); } + /** Initialize the report menu and other additional menus. This * function is called as part of the initialization of a window, when * the plugin menu items are being added to the menu structure. @@ -413,42 +493,54 @@ gnc_plugin_menu_additions_add_to_window (GncPlugin *plugin, GncMainWindow *window, GQuark type) { + GncPluginMenuAdditionsPrivate *priv = GNC_PLUGIN_MENU_ADDITIONS_GET_PRIVATE(plugin); GncPluginMenuAdditionsPerWindow per_window; static GOnce accel_table_init = G_ONCE_INIT; static GHashTable *table; GSList *menu_list; + GMenuModel *menubar_model = gnc_main_window_get_menu_model (window); + GncMenuModelSearch *gsm = g_new0 (GncMenuModelSearch, 1); ENTER(" "); -//FIXMEb -#ifdef skip per_window.window = window; - per_window.ui_manager = window->ui_merge; - per_window.group = gtk_action_group_new ("MenuAdditions" ); - gtk_action_group_set_translation_domain (per_window.group, PROJECT_NAME); - per_window.merge_id = gtk_ui_manager_new_merge_id(window->ui_merge); - gtk_ui_manager_insert_action_group(window->ui_merge, per_window.group, 0); + per_window.item_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); - menu_list = g_slist_sort(gnc_extensions_get_menu_list(), - (GCompareFunc)gnc_menu_additions_sort); + per_window.build_menu_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); + per_window.report_menu = g_menu_new (); + + menu_list = g_slist_sort (gnc_extensions_get_menu_list(), + (GCompareFunc)gnc_menu_additions_sort); /* Assign accelerators */ - table = g_once(&accel_table_init, gnc_menu_additions_init_accel_table, NULL); - g_slist_foreach(menu_list, + table = g_once (&accel_table_init, gnc_menu_additions_init_accel_table, NULL); + g_slist_foreach (menu_list, (GFunc)gnc_menu_additions_do_preassigned_accel, table); - g_slist_foreach(menu_list, (GFunc)gnc_menu_additions_assign_accel, table); + g_slist_foreach (menu_list, (GFunc)gnc_menu_additions_assign_accel, table); /* Add to window. */ - g_slist_foreach(menu_list, (GFunc)gnc_menu_additions_menu_setup_one, - &per_window); + g_slist_foreach (menu_list, (GFunc)gnc_menu_additions_menu_setup_one, + &per_window); - /* Tell the window code about the actions that were just added - * behind its back (so to speak) */ - gnc_main_window_manual_merge_actions (window, PLUGIN_ACTIONS_NAME, - per_window.group, per_window.merge_id); + priv->item_hash = per_window.item_hash; + + // add the report menu to the window + gsm->search_action_label = NULL; + gsm->search_action_name = "ReportsPlaceholder0"; + + if (gnc_menubar_model_find_item (menubar_model, gsm)) + { + g_menu_insert_section (G_MENU(gsm->model), gsm->index, NULL, G_MENU_MODEL(per_window.report_menu)); + } + else + PERR("Could not find 'ReportsAction' in menu model"); + + g_hash_table_destroy (per_window.build_menu_hash); + + g_slist_free (menu_list); + + g_free (gsm); - g_slist_free(menu_list); -#endif LEAVE(" "); } @@ -477,12 +569,8 @@ gnc_plugin_menu_additions_remove_from_window (GncPlugin *plugin, * actions name is installed into the plugin class. */ simple_action_group = gnc_main_window_get_action_group (window, PLUGIN_ACTIONS_NAME); -//FIXMEb if (group && !window->just_plugin_prefs) -// gtk_ui_manager_remove_action_group(window->ui_merge, simple_action_group); - - /* Note: This code does not clean up the per-callback data structures - * that are created by the gnc_menu_additions_menu_setup_one() - * function. Its not much memory and shouldn't be a problem. */ + if (simple_action_group && !window->just_plugin_prefs) + gtk_widget_insert_action_group (GTK_WIDGET(window), PLUGIN_ACTIONS_NAME, NULL); LEAVE(" "); } diff --git a/gnucash/gnome-utils/gnc-plugin-menu-additions.h b/gnucash/gnome-utils/gnc-plugin-menu-additions.h index 43be7c916d..5ba45ceb5f 100644 --- a/gnucash/gnome-utils/gnc-plugin-menu-additions.h +++ b/gnucash/gnome-utils/gnc-plugin-menu-additions.h @@ -22,7 +22,7 @@ /** @addtogroup MenuPlugins @{ */ -/** @addtogroup PluginMenuAdditions Non-GtkAction Menu Support +/** @addtogroup PluginMenuAdditions Non-GAction Menu Support @{ */ /** @file gnc-plugin-menu-additions.h @brief Functions providing menu items from scheme code. diff --git a/gnucash/gnome/gnc-plugin-page-report.cpp b/gnucash/gnome/gnc-plugin-page-report.cpp index d4209f884c..b76126e3f8 100644 --- a/gnucash/gnome/gnc-plugin-page-report.cpp +++ b/gnucash/gnome/gnc-plugin-page-report.cpp @@ -132,6 +132,7 @@ typedef struct GncPluginPageReportPrivate /// the gnc_html abstraction this PluginPage contains // gnc_html *html; GncHtml *html; + gboolean webkit2; /// the container the above HTML widget is in. GtkContainer *container; @@ -174,6 +175,7 @@ static void gnc_plugin_page_report_option_change_cb(gpointer data); void gnc_plugin_page_report_remove_edited_report(GncPluginPageReportPrivate *priv, SCM report); void gnc_plugin_page_report_add_edited_report(GncPluginPageReportPrivate *priv, SCM report); +static void gnc_plugin_page_report_menu_updates (GncPluginPage *plugin_page); void gnc_plugin_page_report_raise_editor(SCM report); static void gnc_plugin_page_report_forw_cb (GSimpleAction *simple, GVariant *parameter, gpointer user_data); @@ -187,6 +189,97 @@ static void gnc_plugin_page_report_options_cb (GSimpleAction *simple, GVariant * static void gnc_plugin_page_report_print_cb (GSimpleAction *simple, GVariant *parameter, gpointer user_data); static void gnc_plugin_page_report_exportpdf_cb (GSimpleAction *simple, GVariant *parameter, gpointer user_data); static void gnc_plugin_page_report_copy_cb (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_page_report_edit_tax_cb (GSimpleAction *simple, GVariant *parameter, gpointer user_data); + +static GActionEntry report_actions[] = +{ + { "FilePrintAction", gnc_plugin_page_report_print_cb, nullptr, nullptr, nullptr }, + { "FilePrintPDFAction", gnc_plugin_page_report_exportpdf_cb, nullptr, nullptr, nullptr }, + { "EditCopyAction", gnc_plugin_page_report_copy_cb, nullptr, nullptr, nullptr }, + { "EditTaxOptionsAction", gnc_plugin_page_report_edit_tax_cb, nullptr, nullptr, nullptr }, + { "ViewRefreshAction", gnc_plugin_page_report_reload_cb, nullptr, nullptr, nullptr }, + { "ReportSaveAction", gnc_plugin_page_report_save_cb, nullptr, nullptr, nullptr }, + { "ReportSaveAsAction", gnc_plugin_page_report_save_as_cb, nullptr, nullptr, nullptr }, + { "ReportExportAction", gnc_plugin_page_report_export_cb, nullptr, nullptr, nullptr }, + { "ReportOptionsAction", gnc_plugin_page_report_options_cb, nullptr, nullptr, nullptr }, + { "ReportBackAction", gnc_plugin_page_report_back_cb, nullptr, nullptr, nullptr }, + { "ReportForwAction", gnc_plugin_page_report_forw_cb, nullptr, nullptr, nullptr }, + { "ReportReloadAction", gnc_plugin_page_report_reload_cb, nullptr, nullptr, nullptr }, + { "ReportStopAction", gnc_plugin_page_report_stop_cb, nullptr, nullptr, nullptr }, +}; +static guint num_report_actions = G_N_ELEMENTS(report_actions); + +static GncDisplayItem report_display_items [] = +{ + { + "FilePrintAction", "document-print", N_("_Print Report..."), "p", + N_("Print the current report") + }, + { + "FilePrintPDFAction", GNC_ICON_PDF_EXPORT, N_("Export as P_DF..."), nullptr, + N_("Export the current report as a PDF document") + }, + { + "EditCutAction", "edit-cut", N_("Cu_t"), "X", + N_("Cut the current selection and copy it to clipboard") + }, + { + "EditCopyAction", "edit-copy", N_("_Copy"), "C", + N_("Copy the current selection to clipboard") + }, + { + "EditPasteAction", "edit-paste", N_("_Paste"), "V", + N_("Paste the clipboard content at the cursor position") + }, + { + "ViewRefreshAction", "view-refresh", N_("_Refresh"), "r", + N_("Refresh this window") + }, + { + "ReportSaveAction", "document-save", N_("Save _Report Configuration"), "s", + nullptr + }, + { + "ReportSaveAsAction", "document-save-as", N_("Save Report Configuration As..."), "s", + nullptr + }, + { + "ReportExportAction", "go-next", N_("Export _Report"), nullptr, + N_("Export HTML-formatted report to file") + }, + { + "ReportOptionsAction", "document-properties", N_("_Report Options"), nullptr, + N_("Edit report options") + }, + { + "ReportBackAction", "go-previous", N_("Back"), nullptr, + N_("Move back one step in the history") + }, + { + "ReportForwAction", "go-next", N_("Forward"), nullptr, + N_("Move forward one step in the history") + }, + { + "ReportReloadAction", "view-refresh", N_("Reload"), nullptr, + N_("Reload the current page") + }, + { + "ReportStopAction", "process-stop", N_("Stop"), nullptr, + N_("Cancel outstanding HTML requests") + }, +}; +/** The number of display items provided by this plugin. */ +static guint report_n_display_items = G_N_ELEMENTS(report_display_items); + +/** The default menu items that need to be add to the menu */ +static const gchar *gnc_plugin_load_ui_items [] = +{ + "FilePlaceholder3", + "FilePlaceholder4", + "EditPlaceholder6", + "ReportsPlaceholder1", + NULL, +}; static void gnc_plugin_page_report_get_property( GObject *obj, @@ -249,10 +342,23 @@ gnc_plugin_page_report_focus_widget (GncPluginPage *report_plugin_page) { GncPluginPageReportPrivate *priv = GNC_PLUGIN_PAGE_REPORT_GET_PRIVATE(report_plugin_page); GtkWidget *window; + GAction *action; if (!priv) return FALSE; + /* Disable the Transaction Menu */ + action = gnc_main_window_find_action (GNC_MAIN_WINDOW(report_plugin_page->window), "TransactionAction"); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE); + /* Disable the Schedule menu */ + action = gnc_main_window_find_action (GNC_MAIN_WINDOW(report_plugin_page->window), "ScheduledAction"); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE); + + gnc_main_window_update_menu (GNC_MAIN_WINDOW(report_plugin_page->window), report_plugin_page, + gnc_plugin_load_ui_items); + + gnc_plugin_page_report_menu_updates (report_plugin_page); + window = gnc_plugin_page_get_window (report_plugin_page); if (window && !gnc_main_window_is_restoring_pages (GNC_MAIN_WINDOW(window))) @@ -443,16 +549,14 @@ gnc_plugin_page_report_create_widget( GncPluginPage *page ) ENTER("page %p", page); -#ifndef WEBKIT1 - /* Hide the ExportPdf action for Webkit2 */ - action = gnc_plugin_page_get_action (page, "FilePrintPDFAction"); - g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE); -//FIXMEb gtk_action_set_visible (action, FALSE); -#endif - report = GNC_PLUGIN_PAGE_REPORT(page); priv = GNC_PLUGIN_PAGE_REPORT_GET_PRIVATE(report); +#ifndef WEBKIT1 + /* Hide the ExportPdf action for Webkit2 */ + priv->webkit2 = TRUE; +#endif + topLvl = gnc_ui_get_main_window (nullptr); // priv->html = gnc_html_new( topLvl ); priv->html = gnc_html_factory_create_html(); @@ -1054,17 +1158,15 @@ gnc_plugin_page_report_name_changed (GncPluginPage *page, const gchar *name) static void gnc_plugin_page_report_update_edit_menu (GncPluginPage *page, gboolean hide) { + GncMainWindow *window = (GncMainWindow*)gnc_plugin_page_get_window (GNC_PLUGIN_PAGE(page)); GAction *action; - action = gnc_plugin_page_get_action (page, "EditCopyAction"); + action = gnc_main_window_find_action (window, "EditCopyAction"); g_simple_action_set_enabled (G_SIMPLE_ACTION(action), TRUE); -//FIXMEb gtk_action_set_visible (action, TRUE); - action = gnc_plugin_page_get_action (page, "EditCutAction"); + action = gnc_main_window_find_action (window, "EditCutAction"); g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE); -//FIXMEb gtk_action_set_visible (action, !hide); - action = gnc_plugin_page_get_action (page, "EditPasteAction"); + action = gnc_main_window_find_action (window, "EditPasteAction"); g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE); -//FIXMEb gtk_action_set_visible (action, !hide); } static gboolean @@ -1177,14 +1279,13 @@ gnc_plugin_page_report_constructor(GType this_type, guint n_properties, GObjectC } static void -gnc_plugin_page_report_constr_init(GncPluginPageReport *plugin_page, gint reportId) +gnc_plugin_page_report_menu_updates (GncPluginPage *plugin_page) { GncPluginPageReportPrivate *priv; -// GtkActionGroup *action_group; - GSimpleActionGroup *simple_action_group; - GncPluginPage *parent; - gboolean use_new; - gchar *name; + GncPluginPageReport *report; + GncMainWindow *window; + GAction *action; + gchar *saved_reports_path = gnc_build_userdata_path (SAVED_REPORTS_FILE); gchar *report_save_str = g_strdup_printf ( _("Update the current report's saved configuration. " @@ -1193,88 +1294,41 @@ gnc_plugin_page_report_constr_init(GncPluginPageReport *plugin_page, gint report _("Add the current report's configuration to the 'Reports->Saved Report Configurations' menu. " "The report configuration will be saved in the file %s."), saved_reports_path); - static GActionEntry report_actions[] = - { - { "FilePrintAction", gnc_plugin_page_report_print_cb, nullptr, nullptr, nullptr }, - { "FilePrintPDFAction", gnc_plugin_page_report_exportpdf_cb, nullptr, nullptr, nullptr }, - { "EditCopyAction", gnc_plugin_page_report_copy_cb, nullptr, nullptr, nullptr }, - { "ViewRefreshAction", gnc_plugin_page_report_reload_cb, nullptr, nullptr, nullptr }, - { "ReportSaveAction", gnc_plugin_page_report_save_cb, nullptr, nullptr, nullptr }, - { "ReportSaveAsAction", gnc_plugin_page_report_save_as_cb, nullptr, nullptr, nullptr }, - { "ReportExportAction", gnc_plugin_page_report_export_cb, nullptr, nullptr, nullptr }, - { "ReportOptionsAction", gnc_plugin_page_report_options_cb, nullptr, nullptr, nullptr }, - { "ReportBackAction", gnc_plugin_page_report_back_cb, nullptr, nullptr, nullptr }, - { "ReportForwAction", gnc_plugin_page_report_forw_cb, nullptr, nullptr, nullptr }, - { "ReportReloadAction", gnc_plugin_page_report_reload_cb, nullptr, nullptr, nullptr }, - { "ReportStopAction", gnc_plugin_page_report_stop_cb, nullptr, nullptr, nullptr }, - }; - guint num_report_actions = G_N_ELEMENTS(report_actions); + report = GNC_PLUGIN_PAGE_REPORT(plugin_page); + priv = GNC_PLUGIN_PAGE_REPORT_GET_PRIVATE(report); - static GncDisplayItem report_display_items [] = + window = (GncMainWindow*)gnc_plugin_page_get_window (GNC_PLUGIN_PAGE(plugin_page)); + +//FIXMEb probably needs changing in model { "ReportSaveAction", N_("Save Report Configuration"), true, report_save_str }; +//FIXMEb probably needs changing in model { "ReportSaveAsAction", N_("Save Report Configuration As..."), true, report_saveas_str }; + + /* Enable the FilePrintAction */ + action = gnc_main_window_find_action (window, "FilePrintAction"); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), true); + + if (priv->webkit2) { - { - "FilePrintAction", "document-print", N_("_Print Report..."), "p", - N_("Print the current report") - }, - { - "FilePrintPDFAction", GNC_ICON_PDF_EXPORT, N_("Export as P_DF..."), nullptr, - N_("Export the current report as a PDF document") - }, - { - "EditCutAction", "edit-cut", N_("Cu_t"), "X", - N_("Cut the current selection and copy it to clipboard") - }, - { - "EditCopyAction", "edit-copy", N_("_Copy"), "C", - N_("Copy the current selection to clipboard") - }, - { - "EditPasteAction", "edit-paste", N_("_Paste"), "V", - N_("Paste the clipboard content at the cursor position") - }, - { - "ViewRefreshAction", "view-refresh", N_("_Refresh"), "r", - N_("Refresh this window") - }, - { - "ReportSaveAction", "document-save", N_("Save _Report Configuration"), "s", - report_save_str - }, - { - "ReportSaveAsAction", "document-save-as", N_("Save Report Configuration As..."), "s", - report_saveas_str - }, - { - "ReportExportAction", "go-next", N_("Export _Report"), nullptr, - N_("Export HTML-formatted report to file") - }, - { - "ReportOptionsAction", "document-properties", N_("_Report Options"), nullptr, - N_("Edit report options") - }, - { - "ReportBackAction", "go-previous", N_("Back"), nullptr, - N_("Move back one step in the history") - }, - { - "ReportForwAction", "go-next", N_("Forward"), nullptr, - N_("Move forward one step in the history") - }, - { - "ReportReloadAction", "view-refresh", N_("Reload"), nullptr, - N_("Reload the current page") - }, - { - "ReportStopAction", "process-stop", N_("Stop"), nullptr, - N_("Cancel outstanding HTML requests") - }, - }; - /** The number of display items provided by this plugin. */ - guint num_report_display_items = G_N_ELEMENTS(report_display_items); + GtkWidget *pdf_item = gnc_main_window_menu_find_menu_item (window, "FilePrintPDFAction"); + gtk_widget_hide (pdf_item); + } + g_free (saved_reports_path); + g_free (report_save_str); + g_free (report_saveas_str); +} + +static void +gnc_plugin_page_report_constr_init (GncPluginPageReport *plugin_page, gint reportId) +{ + GncPluginPageReportPrivate *priv; + GSimpleActionGroup *simple_action_group; + GncPluginPage *parent; + gboolean use_new; + gchar *name; DEBUG("property reportId=%d", reportId); priv = GNC_PLUGIN_PAGE_REPORT_GET_PRIVATE(plugin_page); priv->reportId = reportId; + priv->webkit2 = FALSE; gnc_plugin_page_report_setup( GNC_PLUGIN_PAGE(plugin_page)); @@ -1300,22 +1354,10 @@ gnc_plugin_page_report_constr_init(GncPluginPageReport *plugin_page, gint report num_report_actions, plugin_page); -// action_group = -// gnc_plugin_page_create_action_group(parent, -// "GncPluginPageReportActions"); -// gtk_action_group_add_actions( action_group, -// report_actions, -// num_report_actions, -// plugin_page ); - gnc_plugin_update_actionsb (simple_action_group, initially_insensitive_actions, "sensitive", FALSE); //FIXMEb gnc_plugin_init_short_names (action_group, toolbar_labels); - - g_free (saved_reports_path); - g_free (report_save_str); - g_free (report_saveas_str); } GncPluginPage* @@ -1375,19 +1417,19 @@ close_handler (gpointer user_data) static void gnc_plugin_page_report_set_fwd_button (GncPluginPageReport *report, int enabled) { - GAction *act; - - act = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE(report), "ReportForwAction"); - g_simple_action_set_enabled (G_SIMPLE_ACTION(act), enabled); + GAction *action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE(report), + "ReportForwAction"); + if (action != NULL) + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), enabled); } static void gnc_plugin_page_report_set_back_button (GncPluginPageReport *report, int enabled) { - GAction *act; - - act = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE(report), "ReportBackAction"); - g_simple_action_set_enabled (G_SIMPLE_ACTION(act), enabled); + GAction *action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE(report), + "ReportBackAction"); + if (action != NULL) + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), enabled); } // ------------------------------------------------------------ @@ -1638,6 +1680,18 @@ gnc_get_export_filename (SCM choice, GtkWindow *parent) return filepath; } +static void +gnc_plugin_page_report_edit_tax_cb (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) +{ + GncPluginPageReport *report = (GncPluginPageReport*)user_data; + GtkWidget *window; + + window = GNC_PLUGIN_PAGE(report)->window; + gnc_tax_info_dialog (window, nullptr); +} + static void gnc_plugin_page_report_save_as_cb (GSimpleAction *simple, GVariant *parameter, @@ -1702,7 +1756,7 @@ gnc_plugin_page_report_save_cb (GSimpleAction *simple, * So let's create a new report template based on this report * and allow the user to change the name. */ - gnc_plugin_page_report_save_as_cb (simple, nullptr, report); + gnc_plugin_page_report_save_as_cb (simple, parameter, report); } } diff --git a/gnucash/gnome/report-menus.scm b/gnucash/gnome/report-menus.scm index 4eb08fa286..5082a6355a 100644 --- a/gnucash/gnome/report-menus.scm +++ b/gnucash/gnome/report-menus.scm @@ -90,7 +90,7 @@ (N_ "Saved Report Configurations") "4d3dcdc8890b11df99dd94cddfd72085" (N_ "Manage and run saved report configurations") - (list "Reports/SavedReportConfigs") + (list "Reports/ZSavedReportConfigs") ;; Added Z so it is last in list (lambda (window) (gnc:debug "called into custom report dialog, window is " window) (gnc-ui-custom-report window)))) diff --git a/gnucash/gnucash-gresources.xml b/gnucash/gnucash-gresources.xml index a619419d65..c6dbf21cc8 100644 --- a/gnucash/gnucash-gresources.xml +++ b/gnucash/gnucash-gresources.xml @@ -23,6 +23,7 @@ ui/gnc-plugin-page-invoice.ui ui/gnc-plugin-page-owner-tree.ui ui/gnc-plugin-page-register.ui + ui/gnc-plugin-page-report.ui ui/gnc-plugin-page-sx-list.ui ui/gnc-plugin-ofx.ui diff --git a/gnucash/ui/gnc-plugin-page-report.ui b/gnucash/ui/gnc-plugin-page-report.ui new file mode 100644 index 0000000000..6cf2bb68ca --- /dev/null +++ b/gnucash/ui/gnc-plugin-page-report.ui @@ -0,0 +1,287 @@ + + + + + + _Report Options + GncPluginPageReportActions.ReportOptionsAction + Edit report style sheets + yes + + + + + + Export as P_DF... + GncPluginPageReportActions.FilePrintPDFAction + Export the current report as a PDF document + yes + + + + + + Export _Report + GncPluginPageReportActions.ReportExportAction + Export HTML-formatted report to file + yes + + + + + + Save _Report Configuration + GncPluginPageReportActions.ReportSaveAction + <Primary><Alt>s + Update the current report's saved configuration + yes + + + Save Report Configuration As... + GncPluginPageReportActions.ReportSaveAsAction + <Primary><Alt><Shift>s + Add the current report's configuration to the 'Reports->Saved Report Configurations' menu + yes + + + + + + + _Test + mainwin.TestAction + + + + + + True + False + + + True + False + _Save + gnc-plugin-basic-commands-actions.FileSaveAction + Save the current file + True + document-save + + + False + True + + + + + True + False + _Close + mainwin.FileCloseAction + Close the currently active page + True + window-close + + + False + True + + + + + True + False + + + False + True + + + + + True + False + New _Invoice... + gnc-plugin-business-actions.ToolbarNewInvoiceAction + Open the New Invoice dialog + True + gnc-invoice-new + + + False + True + + + + + True + False + + + False + True + + + + + True + False + Back + GncPluginPageReportActions.ReportBackAction + Move back one step in the history + True + go-previous + + + False + True + + + + + True + False + Forward + GncPluginPageReportActions.ReportForwAction + Move forward one step in the history + True + go-next + + + False + True + + + + + True + False + Reload + GncPluginPageReportActions.ReportReloadAction + Reload the current page + True + view-refresh + + + False + True + + + + + True + False + Stop + GncPluginPageReportActions.ReportStopAction + Cancel outstanding HTML requests + True + process-stop + + + False + True + + + + + True + False + + + False + True + + + + + True + False + _Report Options + GncPluginPageReportActions.ReportOptionsAction + Edit report options + True + document-properties + + + False + True + + + + + True + False + Save _Report Configuration + GncPluginPageReportActions.ReportSaveAction + Update the current report's saved configuration + True + document-save + + + False + True + + + + + True + False + Save Report Configuration As... + GncPluginPageReportActions.ReportSaveAsAction + Add the current report's configuration to the 'Reports->Saved Report Configurations' menu + True + document-save-as + + + False + True + + + + + True + False + Export _Report + GncPluginPageReportActions.ReportExportAction + Export HTML-formatted report to file + True + go-next + + + False + True + + + + + True + False + _Print Report... + GncPluginPageReportActions.FilePrintAction + Print the current report + True + document-print + + + False + True + + + + + True + False + Export as P_DF... + GncPluginPageReportActions.FilePrintPDFAction + Export the current report as a PDF document + True + gnc-gnome-pdf + + + False + True + + + + + From c0f117eda5bbcfd3a8eceb240017cdbe1cfe9a8c Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Fri, 28 Oct 2022 16:33:22 +0100 Subject: [PATCH 22/77] Changes for embedded window and sx dialog --- gnucash/gnome-utils/gnc-embedded-window.c | 185 ++++++++++------ gnucash/gnome-utils/gnc-embedded-window.h | 15 +- gnucash/gnome-utils/gnc-main-window.cpp | 76 +++++-- gnucash/gnome-utils/gnc-window.c | 36 ++++ gnucash/gnome-utils/gnc-window.h | 20 +- gnucash/gnome/dialog-sx-editor.c | 23 +- gnucash/gnome/gnc-plugin-page-register.c | 93 ++++---- gnucash/gnucash-gresources.xml | 1 + gnucash/ui/gnc-embedded-register-window.ui | 239 +++++++++++++++++++++ 9 files changed, 538 insertions(+), 150 deletions(-) create mode 100644 gnucash/ui/gnc-embedded-register-window.ui diff --git a/gnucash/gnome-utils/gnc-embedded-window.c b/gnucash/gnome-utils/gnc-embedded-window.c index 6bd410268c..fc11a7836f 100644 --- a/gnucash/gnome-utils/gnc-embedded-window.c +++ b/gnucash/gnome-utils/gnc-embedded-window.c @@ -39,6 +39,7 @@ #include "gnc-ui.h" #include "gnc-window.h" #include "dialog-utils.h" +#include "gnc-gtk-utils.h" /** Names of signals generated by the embedded window. */ enum @@ -72,8 +73,12 @@ typedef struct GncEmbeddedWindowPrivate * stored here when the UI manager provides them to the main * window. */ GtkWidget *menu_dock; - /* The toolbar created by the UI manager. This pointer provides - * easy access for showing/hiding the toolbar. */ + /** The menubar */ + GtkWidget *menubar; //FIXMEb added + /** The menubar_model */ + GMenuModel *menubar_model; //FIXMEb added + /** The toolbar. This pointer provides easy access for + * showing/hiding the toolbar. */ GtkWidget *toolbar; /** A pointer to the status bar at the bottom edge of the window. * This pointer provides easy access for updating/showing/hiding @@ -83,7 +88,6 @@ typedef struct GncEmbeddedWindowPrivate /** The group of all actions provided by the main window itself. * This does not include any action provided by menu or content * plugins. */ - GtkActionGroup *action_group; GSimpleActionGroup *simple_action_group; //FIXMEb added /** The currently selected page. */ @@ -155,7 +159,7 @@ gnc_embedded_window_close_page (GncEmbeddedWindow *window, gnc_plugin_page_removed (page); //FIXMEb gnc_plugin_page_unmerge_actions (page, window->ui_merge); - gtk_ui_manager_ensure_update (window->ui_merge); +// gtk_ui_manager_ensure_update (window->ui_merge); gnc_plugin_page_destroy_widget (page); g_object_unref(page); @@ -237,8 +241,8 @@ gnc_embedded_window_init (GncEmbeddedWindow *window, void *data) gnc_embedded_window_setup_window (window); - gnc_gobject_tracking_remember(G_OBJECT(window), - G_OBJECT_CLASS(klass)); + gnc_gobject_tracking_remember (G_OBJECT(window), + G_OBJECT_CLASS(klass)); LEAVE(" "); } @@ -275,6 +279,7 @@ gnc_embedded_window_dispose (GObject *object) ENTER("object %p", object); window = GNC_EMBEDDED_WINDOW (object); priv = GNC_EMBEDDED_WINDOW_GET_PRIVATE(window); + if (priv->page) { DEBUG("unreffing page %p (count currently %d)", priv->page, @@ -288,30 +293,6 @@ gnc_embedded_window_dispose (GObject *object) } -static void -gnc_embedded_window_add_widget (GtkUIManager *merge, - GtkWidget *widget, - GncEmbeddedWindow *window) -{ - GncEmbeddedWindowPrivate *priv; - - ENTER("merge %p, new widget %p, window %p", merge, widget, window); - priv = GNC_EMBEDDED_WINDOW_GET_PRIVATE(window); - if (GTK_IS_TOOLBAR (widget)) - { - priv->toolbar = widget; - gtk_toolbar_set_style (GTK_TOOLBAR(priv->toolbar), - GTK_TOOLBAR_BOTH); - gtk_toolbar_set_icon_size (GTK_TOOLBAR(priv->toolbar), - GTK_ICON_SIZE_SMALL_TOOLBAR); - } - - gtk_box_pack_start (GTK_BOX (priv->menu_dock), widget, FALSE, FALSE, 0); - gtk_widget_show (widget); - LEAVE(" "); -} - - /** Initialize the data structures of a gnucash embedded window. * * @param window The object to initialize. */ @@ -335,15 +316,11 @@ gnc_embedded_window_setup_window (GncEmbeddedWindow *window) gtk_widget_show (priv->statusbar); gtk_box_pack_end (GTK_BOX (window), priv->statusbar, FALSE, TRUE, 0); - window->ui_merge = gtk_ui_manager_new (); - g_signal_connect (G_OBJECT (window->ui_merge), "add_widget", - G_CALLBACK (gnc_embedded_window_add_widget), window); - /* Use the "connect-proxy" signal for tooltip display in the status bar */ - g_signal_connect (G_OBJECT (window->ui_merge), "connect-proxy", - G_CALLBACK (gnc_window_connect_proxy), priv->statusbar); +//FIXMEb g_signal_connect (G_OBJECT (window->ui_merge), "connect-proxy", +// G_CALLBACK (gnc_window_connect_proxy), priv->statusbar); - priv->action_group = NULL; + priv->simple_action_group = NULL; LEAVE(" "); } @@ -351,7 +328,7 @@ gnc_embedded_window_setup_window (GncEmbeddedWindow *window) /** Create a new gnc embedded window plugin. */ GncEmbeddedWindow * gnc_embedded_window_new (const gchar *action_group_name, - GtkActionEntry *action_entries, + GActionEntry *action_entries, gint n_action_entries, const gchar *ui_filename, GtkWidget *enclosing_win, @@ -362,48 +339,59 @@ gnc_embedded_window_new (const gchar *action_group_name, GncEmbeddedWindow *window; gchar *ui_fullname; GError *error = NULL; - guint merge_id; + GtkBuilder *builder; + GtkAccelGroup *accel_group; ENTER("group %s, first %p, num %d, ui file %s, parent %p, add accelerators %d, user data %p", action_group_name, action_entries, n_action_entries, ui_filename, enclosing_win, add_accelerators, user_data); + window = g_object_new (GNC_TYPE_EMBEDDED_WINDOW, NULL); priv = GNC_EMBEDDED_WINDOW_GET_PRIVATE(window); - /* Determine the full pathname of the ui file */ - ui_fullname = gnc_filepath_locate_ui_file (ui_filename); - g_return_val_if_fail (ui_fullname != NULL, NULL); + builder = gtk_builder_new (); + gtk_builder_set_translation_domain (builder, PROJECT_NAME); + + ui_fullname = g_strconcat ("/org/gnucash/ui/", ui_filename, NULL); + + gtk_builder_add_from_resource (builder, ui_fullname, &error); + + if (error) + { + g_critical ("Failed to load, Error %s", error->message); + g_error_free (error); + return NULL; //FIXMEb this may need changing + } + + priv->menubar_model = (GMenuModel *)gtk_builder_get_object (builder, "embeddedwin-menu"); + + priv->menubar = gtk_menu_bar_new_from_model (priv->menubar_model); + gtk_container_add (GTK_CONTAINER(priv->menu_dock), priv->menubar); //FIXMEb this may need changing + gtk_widget_show (GTK_WIDGET(priv->menubar)); + + priv->toolbar = (GtkWidget *)gtk_builder_get_object (builder, "embeddedwin-toolbar"); + g_object_set (priv->toolbar, "toolbar-style", GTK_TOOLBAR_BOTH, NULL); + gtk_container_add (GTK_CONTAINER(priv->menu_dock), GTK_WIDGET(priv->toolbar)); //FIXMEb this may need changing + gtk_widget_show (GTK_WIDGET(priv->toolbar)); + + priv->simple_action_group = g_simple_action_group_new (); + + g_action_map_add_action_entries (G_ACTION_MAP(priv->simple_action_group), + action_entries, + n_action_entries, + user_data); + + gtk_widget_insert_action_group (GTK_WIDGET(window), "embeddedwin", + G_ACTION_GROUP(priv->simple_action_group)); priv->parent_window = enclosing_win; - /* Create menu and toolbar information */ - priv->action_group = gtk_action_group_new (action_group_name); - gtk_action_group_set_translation_domain(priv->action_group, PROJECT_NAME); - gtk_action_group_add_actions (priv->action_group, action_entries, - n_action_entries, user_data); - gtk_ui_manager_insert_action_group (window->ui_merge, priv->action_group, 0); - merge_id = gtk_ui_manager_add_ui_from_file (window->ui_merge, ui_fullname, - &error); + // need to add the accelerator keys + accel_group = gtk_accel_group_new (); + gtk_window_add_accel_group (GTK_WINDOW(enclosing_win), accel_group); + gnc_add_accelerator_keys_for_menu (GTK_WIDGET(priv->menubar), accel_group); - /* Error checking */ - g_assert(merge_id || error); - if (error) - { - g_critical("Failed to load ui file.\n Filename %s\n Error %s", - ui_fullname, error->message); - g_error_free(error); - g_free(ui_fullname); - LEAVE("window %p", window); - return window; - } - - /* Add accelerators (if wanted) */ - if (add_accelerators) - gtk_window_add_accel_group (GTK_WINDOW(enclosing_win), - gtk_ui_manager_get_accel_group(window->ui_merge)); - - gtk_ui_manager_ensure_update (window->ui_merge); - g_free(ui_fullname); + g_free (ui_fullname); LEAVE("window %p", window); return window; } @@ -447,6 +435,58 @@ gnc_embedded_window_get_statusbar (GncWindow *window_in) } +/** Retrieve the menu bar associated with an embedded window object. + * This function is called via a vector off a generic window + * interface. + * + * @param window_in A pointer to a generic window. */ +static GtkWidget * +gnc_embedded_window_get_menubar (GncWindow *window) +{ + GncEmbeddedWindowPrivate *priv; + + g_return_val_if_fail (GNC_IS_EMBEDDED_WINDOW(window), NULL); + + priv = GNC_EMBEDDED_WINDOW_GET_PRIVATE(window); + + return priv->menubar; +} + +/** Retrieve the tool bar associated with an embedded window object. + * This function is called via a vector off a generic window + * interface. + * + * @param window_in A pointer to a generic window. */ +static GtkWidget * +gnc_embedded_window_get_toolbar (GncWindow *window) +{ + GncEmbeddedWindowPrivate *priv; + + g_return_val_if_fail (GNC_IS_EMBEDDED_WINDOW(window), NULL); + + priv = GNC_EMBEDDED_WINDOW_GET_PRIVATE(window); + + return priv->toolbar; +} + +/** Retrieve the display hash table associated with an embedded window object. + * This function is called via a vector off a generic window + * interface. + * + * @param window_in A pointer to a generic window. */ +static GMenuModel * +gnc_embedded_window_get_menubar_model (GncWindow *window) +{ + GncEmbeddedWindowPrivate *priv; + + g_return_val_if_fail (GNC_IS_EMBEDDED_WINDOW(window), NULL); + + priv = GNC_EMBEDDED_WINDOW_GET_PRIVATE(window); + + return priv->menubar_model; +} + + /** Initialize the generic window interface for an embedded window. * * @param iface A pointer to the interface data structure to @@ -454,6 +494,9 @@ gnc_embedded_window_get_statusbar (GncWindow *window_in) static void gnc_window_embedded_window_init (GncWindowIface *iface) { - iface->get_gtk_window = gnc_embedded_window_get_gtk_window; - iface->get_statusbar = gnc_embedded_window_get_statusbar; + iface->get_gtk_window = gnc_embedded_window_get_gtk_window; + iface->get_statusbar = gnc_embedded_window_get_statusbar; + iface->get_menubar = gnc_embedded_window_get_menubar; + iface->get_toolbar = gnc_embedded_window_get_toolbar; + iface->get_menubar_model = gnc_embedded_window_get_menubar_model; } diff --git a/gnucash/gnome-utils/gnc-embedded-window.h b/gnucash/gnome-utils/gnc-embedded-window.h index d893982951..86774b174f 100644 --- a/gnucash/gnome-utils/gnc-embedded-window.h +++ b/gnucash/gnome-utils/gnc-embedded-window.h @@ -57,9 +57,6 @@ typedef struct { /** The parent object for an embedded window. */ GtkBox vbox; - /** A pointer to the UI Manager data structure for the whole - * window. */ - GtkUIManager *ui_merge; } GncEmbeddedWindow; @@ -88,12 +85,12 @@ GType gnc_embedded_window_get_type (void); * @return A pointer to the new object. */ GncEmbeddedWindow *gnc_embedded_window_new (const gchar *action_group_name, - GtkActionEntry *action_entries, - gint n_action_entries, - const gchar *ui_filename, - GtkWidget *enclosing_win, - gboolean add_accelerators, - gpointer user_data); + GActionEntry *action_entries, + gint n_action_entries, + const gchar *ui_filename, + GtkWidget *enclosing_win, + gboolean add_accelerators, + gpointer user_data); /** Display a data plugin page in a window. diff --git a/gnucash/gnome-utils/gnc-main-window.cpp b/gnucash/gnome-utils/gnc-main-window.cpp index 303da45a21..6ffab83c60 100644 --- a/gnucash/gnome-utils/gnc-main-window.cpp +++ b/gnucash/gnome-utils/gnc-main-window.cpp @@ -3853,25 +3853,16 @@ GtkWidget * gnc_main_window_menu_find_menu_item (GncMainWindow *window, const gchar *action_name) { GncMainWindowPrivate *priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); - GncMenuModelSearch *gsm = g_new0 (GncMenuModelSearch, 1); GtkWidget *menu_item = GTK_WIDGET(g_hash_table_lookup (priv->display_item_hash, action_name)); priv->num_item_q++; //FIXMEb temp added if (!menu_item) { - gsm->search_action_label = nullptr; - gsm->search_action_name = action_name; + menu_item = gnc_menubar_model_find_menu_item (priv->menubar_model, priv->menubar, action_name); - if (gnc_menubar_model_find_item (priv->menubar_model, gsm)) - { - menu_item = gnc_find_menu_item_by_action_label (priv->menubar, - gsm->search_action_label); - - g_hash_table_insert (priv->display_item_hash, g_strdup (action_name), menu_item); - } + g_hash_table_insert (priv->display_item_hash, g_strdup (action_name), menu_item); } - g_free (gsm); return menu_item; } @@ -5684,6 +5675,58 @@ gnc_main_window_get_progressbar (GncWindow *window_in) } +/** Retrieve the menu bar associated with a main window object. + * This function is called via a vector off a generic window + * interface. + * + * @param window_in A pointer to a generic window. */ +static GtkWidget * +gnc_main_window_get_menubar (GncWindow *window) +{ + GncMainWindowPrivate *priv; + + g_return_val_if_fail (GNC_IS_MAIN_WINDOW(window), nullptr); + + priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); + + return priv->menubar; +} + +/** Retrieve the tool bar associated with a main window object. + * This function is called via a vector off a generic window + * interface. + * + * @param window_in A pointer to a generic window. */ +static GtkWidget * +gnc_main_window_get_toolbar (GncWindow *window) +{ + GncMainWindowPrivate *priv; + + g_return_val_if_fail (GNC_IS_MAIN_WINDOW(window), nullptr); + + priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); + + return priv->toolbar; +} + +/** Retrieve the display hash table associated with a main window object. + * This function is called via a vector off a generic window + * interface. + * + * @param window_in A pointer to a generic window. */ +static GMenuModel * +gnc_main_window_get_menubar_model (GncWindow *window) +{ + GncMainWindowPrivate *priv; + + g_return_val_if_fail (GNC_IS_MAIN_WINDOW(window), nullptr); + + priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); + + return priv->menubar_model; +} + + static void gnc_main_window_all_ui_set_sensitive (GncWindow *unused, gboolean sensitive) { @@ -5719,10 +5762,13 @@ gnc_main_window_all_ui_set_sensitive (GncWindow *unused, gboolean sensitive) static void gnc_window_main_window_init (GncWindowIface *iface) { - iface->get_gtk_window = gnc_main_window_get_gtk_window; - iface->get_statusbar = gnc_main_window_get_statusbar; - iface->get_progressbar = gnc_main_window_get_progressbar; - iface->ui_set_sensitive = gnc_main_window_all_ui_set_sensitive; + iface->get_gtk_window = gnc_main_window_get_gtk_window; + iface->get_statusbar = gnc_main_window_get_statusbar; + iface->get_progressbar = gnc_main_window_get_progressbar; + iface->ui_set_sensitive = gnc_main_window_all_ui_set_sensitive; + iface->get_menubar = gnc_main_window_get_menubar; + iface->get_toolbar = gnc_main_window_get_toolbar; + iface->get_menubar_model = gnc_main_window_get_menubar_model; } diff --git a/gnucash/gnome-utils/gnc-window.c b/gnucash/gnome-utils/gnc-window.c index fecacd4f92..a13ea630e7 100644 --- a/gnucash/gnome-utils/gnc-window.c +++ b/gnucash/gnome-utils/gnc-window.c @@ -101,6 +101,42 @@ gnc_window_get_progressbar (GncWindow *window) return GNC_WINDOW_GET_IFACE (window)->get_progressbar (window); } +GtkWidget * +gnc_window_get_menubar (GncWindow *window) +{ + g_return_val_if_fail (GNC_WINDOW(window), NULL); + + /* optional */ + if (GNC_WINDOW_GET_IFACE(window)->get_menubar == NULL) + return NULL; + + return GNC_WINDOW_GET_IFACE(window)->get_menubar (window); +} + +GtkWidget * +gnc_window_get_toolbar (GncWindow *window) +{ + g_return_val_if_fail (GNC_WINDOW(window), NULL); + + /* optional */ + if (GNC_WINDOW_GET_IFACE(window)->get_toolbar == NULL) + return NULL; + + return GNC_WINDOW_GET_IFACE(window)->get_toolbar (window); +} + +GMenuModel * +gnc_window_get_menubar_model (GncWindow *window) +{ + g_return_val_if_fail (GNC_WINDOW(window), NULL); + + /* optional */ + if (GNC_WINDOW_GET_IFACE(window)->get_menubar_model == NULL) + return NULL; + + return GNC_WINDOW_GET_IFACE(window)->get_menubar_model (window); +} + /************************************************************ * Auxiliary status bar functions * ************************************************************/ diff --git a/gnucash/gnome-utils/gnc-window.h b/gnucash/gnome-utils/gnc-window.h index c8144dc16d..830c90afd1 100644 --- a/gnucash/gnome-utils/gnc-window.h +++ b/gnucash/gnome-utils/gnc-window.h @@ -60,9 +60,12 @@ typedef struct GTypeInterface parent; /* Virtual Table */ - GtkWindow * (* get_gtk_window) (GncWindow *window); - GtkWidget * (* get_statusbar) (GncWindow *window); - GtkWidget * (* get_progressbar) (GncWindow *window); + GtkWindow * (* get_gtk_window) (GncWindow *window); + GtkWidget * (* get_statusbar) (GncWindow *window); + GtkWidget * (* get_progressbar) (GncWindow *window); + GtkWidget * (* get_menubar) (GncWindow *window); + GtkWidget * (* get_toolbar) (GncWindow *window); + GMenuModel * (* get_menubar_model) (GncWindow *window); void (* ui_set_sensitive) (GncWindow *window, gboolean sensitive); } GncWindowIface; @@ -78,16 +81,19 @@ void gnc_window_set_progressbar_window (GncWindow *window); GncWindow *gnc_window_get_progressbar_window (void); GtkWidget *gnc_window_get_progressbar (GncWindow *window); void gnc_window_show_progress (const char *message, double percentage); +GtkWidget *gnc_window_get_menubar (GncWindow *window); +GtkWidget *gnc_window_get_toolbar (GncWindow *window); +GMenuModel *gnc_window_get_menubar_model (GncWindow *window); /** This callback functions will set the statusbar text to the * "tooltip" property of the currently selected GtkAction - * + * * @param merge A pointer to the ui manager - * + * * @param action A pointer to the action - * + * * @param proxy A pointer to the proxy - * + * * @param statusbar A pointer to the statusbar widget */ void gnc_window_connect_proxy (GtkUIManager *merge, diff --git a/gnucash/gnome/dialog-sx-editor.c b/gnucash/gnome/dialog-sx-editor.c index 31287efddb..d749b4f5ed 100644 --- a/gnucash/gnome/dialog-sx-editor.c +++ b/gnucash/gnome/dialog-sx-editor.c @@ -162,14 +162,14 @@ static gboolean sxed_confirmed_cancel (GncSxEditorDialog *sxed); static gboolean editor_component_sx_equality (gpointer find_data, gpointer user_data); -static GtkActionEntry gnc_sxed_menu_entries [] = +static GActionEntry gnc_sxed_menu_entries [] = { - { "EditAction", NULL, N_("_Edit"), NULL, NULL, NULL }, - { "TransactionAction", NULL, N_("_Transaction"), NULL, NULL, NULL }, - { "ViewAction", NULL, N_("_View"), NULL, NULL, NULL }, - { "ActionsAction", NULL, N_("_Actions"), NULL, NULL, NULL }, + { "EditAction", NULL, NULL, NULL, NULL }, + { "TransactionAction", NULL, NULL, NULL, NULL }, + { "ViewAction", NULL, NULL, NULL, NULL }, + { "ActionsAction", NULL, NULL, NULL, NULL }, }; -static guint gnc_sxed_menu_n_entries = G_N_ELEMENTS (gnc_sxed_menu_entries); +static guint gnc_sxed_menu_n_entries = G_N_ELEMENTS(gnc_sxed_menu_entries); /** Implementations *****************************************************/ @@ -1354,10 +1354,10 @@ schedXact_editor_create_ledger (GncSxEditorDialog *sxed) /* First the embedded window */ main_vbox = GTK_WIDGET (gtk_builder_get_object (sxed->builder, "register_vbox")); sxed->embed_window = - gnc_embedded_window_new ("SXWindowActions", + gnc_embedded_window_new ("embedded-win", gnc_sxed_menu_entries, gnc_sxed_menu_n_entries, - "gnc-sxed-window-ui.xml", + "gnc-embedded-register-window.ui", sxed->dialog, FALSE, /* no accelerators */ sxed); @@ -1366,8 +1366,11 @@ schedXact_editor_create_ledger (GncSxEditorDialog *sxed) /* Now create the register plugin page. */ sxed->plugin_page = gnc_plugin_page_register_new_ledger (sxed->ledger); - gnc_plugin_page_set_ui_description (sxed->plugin_page, - "gnc-sxed-window-ui-full.xml"); + + gtk_widget_insert_action_group (GTK_WIDGET(sxed->embed_window), + gnc_plugin_page_get_simple_action_group_name (sxed->plugin_page), + G_ACTION_GROUP(gnc_plugin_page_get_action_groupb (sxed->plugin_page))); + gnc_plugin_page_register_set_options (sxed->plugin_page, NUM_LEDGER_LINES_DEFAULT, FALSE); gnc_embedded_window_open_page (sxed->embed_window, sxed->plugin_page); diff --git a/gnucash/gnome/gnc-plugin-page-register.c b/gnucash/gnome/gnc-plugin-page-register.c index 7afefd0123..749c80beea 100644 --- a/gnucash/gnome/gnc-plugin-page-register.c +++ b/gnucash/gnome/gnc-plugin-page-register.c @@ -943,17 +943,22 @@ gnc_plugin_page_register_focus_widget (GncPluginPage* register_plugin_page) { if (GNC_IS_PLUGIN_PAGE_REGISTER (register_plugin_page)) { + GncWindow* gnc_window = GNC_WINDOW(GNC_PLUGIN_PAGE(register_plugin_page)->window); GNCSplitReg *gsr = gnc_plugin_page_register_get_gsr (GNC_PLUGIN_PAGE(register_plugin_page)); - /* Enable the Transaction menu */ - GAction *action = gnc_main_window_find_action (GNC_MAIN_WINDOW(register_plugin_page->window), "TransactionAction"); - g_simple_action_set_enabled (G_SIMPLE_ACTION(action), TRUE); - /* Disable the Schedule menu */ - action = gnc_main_window_find_action (GNC_MAIN_WINDOW(register_plugin_page->window), "ScheduledAction"); - g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE); + if (GNC_IS_MAIN_WINDOW(GNC_PLUGIN_PAGE(register_plugin_page)->window)) + { + /* Enable the Transaction menu */ + GAction *action = gnc_main_window_find_action (GNC_MAIN_WINDOW(register_plugin_page->window), "TransactionAction"); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), TRUE); + /* Disable the Schedule menu */ + action = gnc_main_window_find_action (GNC_MAIN_WINDOW(register_plugin_page->window), "ScheduledAction"); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE); - gnc_main_window_update_menu (GNC_MAIN_WINDOW(register_plugin_page->window), register_plugin_page, - gnc_plugin_load_ui_items); + gnc_main_window_update_menu (GNC_MAIN_WINDOW(register_plugin_page->window), + register_plugin_page, + gnc_plugin_load_ui_items); + } gnc_plugin_page_register_ui_update (NULL, GNC_PLUGIN_PAGE_REGISTER(register_plugin_page)); @@ -1063,6 +1068,7 @@ gnc_plugin_page_register_ui_update (gpointer various, CursorClass cursor_class; const char* uri; Account *account; + GncWindow* gnc_window = GNC_WINDOW(GNC_PLUGIN_PAGE(page)->window); /* Set 'Split Transaction' */ priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page); @@ -1093,8 +1099,11 @@ gnc_plugin_page_register_ui_update (gpointer various, g_signal_handlers_unblock_by_func (action, gnc_plugin_page_register_cmd_expand_transaction, page); /* Enable the FilePrintAction */ - action = gnc_main_window_find_action (GNC_MAIN_WINDOW(GNC_PLUGIN_PAGE(page)->window), "FilePrintAction"); - g_simple_action_set_enabled (G_SIMPLE_ACTION(action), TRUE); + if (GNC_IS_MAIN_WINDOW(GNC_PLUGIN_PAGE(page)->window)) + { + action = gnc_main_window_find_action (GNC_MAIN_WINDOW(GNC_PLUGIN_PAGE(page)->window), "FilePrintAction"); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), TRUE); + } /* If we are in a readonly book, or possibly a place holder * account register make any modifying action inactive */ @@ -1139,7 +1148,7 @@ gnc_plugin_page_register_ui_update (gpointer various, action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE(page), "PasteTransactionAction"); - g_simple_action_set_enabled (G_SIMPLE_ACTION(action), !read_only & !voided); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), !read_only & !voided); action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE(page), "DeleteTransactionAction"); @@ -1211,64 +1220,72 @@ gnc_plugin_page_register_ui_update (gpointer various, /* Modifying action descriptions based on cursor class */ { - GtkWidget *menu_item; + GncMenuModelSearch *gsm = g_new0 (GncMenuModelSearch, 1); + GtkWidget *menu_item = NULL; + gboolean found = FALSE; const char** iter, **label_iter, **tooltip_iter; gboolean curr_label_trans = FALSE; iter = tran_vs_split_actions; - action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE(page), *iter); label_iter = tran_action_labels; - menu_item = gnc_main_window_menu_find_menu_item (GNC_MAIN_WINDOW(GNC_PLUGIN_PAGE(page)->window), - *iter); + gsm->search_action_label = NULL; + gsm->search_action_name = *iter; - if (menu_item == NULL) + found = gnc_menubar_model_find_item (gnc_window_get_menubar_model (gnc_window), gsm); + + PINFO("Test for action '%s', found is %d, iter label is '%s'", *iter, found, _(*label_iter)); + + if (!found) + { + g_free (gsm); return; + } - PINFO("menu_item %p label is '%s', iter label is '%s'", menu_item, - gtk_menu_item_get_label (GTK_MENU_ITEM(menu_item)), _(*label_iter)); - - if (g_strcmp0 (gtk_menu_item_get_label (GTK_MENU_ITEM(menu_item)), _ (*label_iter)) == 0) + if (g_strcmp0 (gsm->search_action_label, _(*label_iter)) == 0) curr_label_trans = TRUE; + + g_free (gsm); + if ((cursor_class == CURSOR_CLASS_SPLIT) && curr_label_trans) { + gboolean found = FALSE; label_iter = split_action_labels; tooltip_iter = split_action_tips; for (iter = tran_vs_split_actions; *iter; ++iter) { - GtkWidget *menu_item = gnc_main_window_menu_find_menu_item (GNC_MAIN_WINDOW(GNC_PLUGIN_PAGE(page)->window), - *iter); - - PINFO("split menu_item %p label is '%s', iter label is '%s'", menu_item, - gtk_menu_item_get_label (GTK_MENU_ITEM(menu_item)), *iter); - /* Adjust the action's label and tooltip */ - action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE (page), *iter); - gtk_menu_item_set_label (GTK_MENU_ITEM(menu_item), _ (*label_iter)); -//FIXMEb gtk_action_set_tooltip (action, _ (*tooltip_iter)); + found = gnc_menubar_model_update_item (gnc_window_get_menubar_model (gnc_window), + *iter, _(*label_iter), _(*tooltip_iter)); + + PINFO("split model_item action '%s', found is %d, iter label is '%s'", + *iter, found, _(*label_iter)); + ++label_iter; ++tooltip_iter; } } else if ((cursor_class == CURSOR_CLASS_TRANS) && !curr_label_trans) { + gboolean found = FALSE; label_iter = tran_action_labels; tooltip_iter = tran_action_tips; for (iter = tran_vs_split_actions; *iter; ++iter) { - GtkWidget *menu_item = gnc_main_window_menu_find_menu_item (GNC_MAIN_WINDOW(GNC_PLUGIN_PAGE(page)->window), - *iter); - - PINFO("trans menu_item %p label is '%s', iter label is '%s'", menu_item, - gtk_menu_item_get_label (GTK_MENU_ITEM(menu_item)), *iter); - /* Adjust the action's label and tooltip */ - action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE (page), *iter); - gtk_menu_item_set_label (GTK_MENU_ITEM(menu_item), _ (*label_iter)); -//FIXMEb gtk_action_set_tooltip (action, _ (*tooltip_iter)); + found = gnc_menubar_model_update_item (gnc_window_get_menubar_model (gnc_window), + *iter, _(*label_iter), _(*tooltip_iter)); + + PINFO("trans model_item action '%s', found is %d, iter label is '%s'", + *iter, found, _(*label_iter)); + ++label_iter; ++tooltip_iter; } } + // need to add the accelerator keys, currently there are none +//FIXMEb +// gnc_add_accelerator_keys_for_menu (gnc_window_get_menubar (gnc_window), +// gnc_plugin_page_get_accel_group (GNC_PLUGIN_PAGE(page))); } } diff --git a/gnucash/gnucash-gresources.xml b/gnucash/gnucash-gresources.xml index c6dbf21cc8..c3ccd7b7a4 100644 --- a/gnucash/gnucash-gresources.xml +++ b/gnucash/gnucash-gresources.xml @@ -4,6 +4,7 @@ gnucash.css gnucash-fallback.css + ui/gnc-embedded-register-window.ui ui/gnc-main-window.ui ui/gnc-plugin-account-tree.ui ui/gnc-plugin-basic-commands.ui diff --git a/gnucash/ui/gnc-embedded-register-window.ui b/gnucash/ui/gnc-embedded-register-window.ui new file mode 100644 index 0000000000..85e31a82ed --- /dev/null +++ b/gnucash/ui/gnc-embedded-register-window.ui @@ -0,0 +1,239 @@ + + + + + _Edit + embeddedwin.EditAction +
+ + Cu_t + GncPluginPageRegisterActions.EditCutAction + <Primary>x + Cut the current selection and copy it to clipboard + + + _Copy + GncPluginPageRegisterActions.EditCopyAction + <Primary>c + Copy the current selection to clipboard + + + _Paste + GncPluginPageRegisterActions.EditPasteAction + <Primary>v + Paste the clipboard content at the cursor position + +
+
+ + _Transaction + embeddedwin.TransactionAction +
+ + CutTransactionAction + GncPluginPageRegisterActions.CutTransactionAction + Cut the selected transaction into clipboard + + + CopyTransactionAction + GncPluginPageRegisterActions.CopyTransactionAction + Copy the selected transaction into clipboard + + + PasteTransactionAction + GncPluginPageRegisterActions.PasteTransactionAction + Paste the transaction from the clipboard + + + DuplicateTransactionAction + GncPluginPageRegisterActions.DuplicateTransactionAction + Make a copy of the current transaction + + + DeleteTransactionAction + GncPluginPageRegisterActions.DeleteTransactionAction + Delete the current transaction + + + Remo_ve Other Splits + GncPluginPageRegisterActions.RemoveTransactionSplitsAction + Remove all splits in the current transaction + +
+
+ + _Enter Transaction + GncPluginPageRegisterActions.RecordTransactionAction + Record the current transaction + + + Ca_ncel Transaction + GncPluginPageRegisterActions.CancelTransactionAction + Cancel the current transaction + +
+
+ + _View + embeddedwin.ViewAction +
+ + _Double Line + GncPluginPageRegisterActions.ViewStyleDoubleLineAction + Show a second line with \"Action\", \"Notes\", and \"Linked Document\" for each transaction + +
+
+ + _Action + membeddedwin.ActionsAction +
+ + _Transfer... + GncPluginPageRegisterActions.ActionsTransferAction + <Primary>t + Transfer funds from one account to another + + + _Blank Transaction + GncPluginPageRegisterActions.BlankTransactionAction + <Primary>Page_Down + Move to the blank transaction at the bottom of the register + +
+
+
+ + + +
+ + Dup_licate Transaction + GncPluginPageRegisterActions.DuplicateTransactionAction + Make a copy of the current transaction + + + _Delete Transaction + GncPluginPageRegisterActions.DeleteTransactionAction + Delete the current transaction + + + Remo_ve Other Splits + GncPluginPageRegisterActions.RemoveTransactionSplitsAction + Remove all splits in the current transaction + +
+
+ + _Enter Transaction + GncPluginPageRegisterActions.RecordTransactionAction + Record the current transaction + + + Ca_ncel Transaction + GncPluginPageRegisterActions.CancelTransactionAction + Cancel the current transaction + +
+
+ + _Blank Transaction + GncPluginPageRegisterActions.BlankTransactionAction + Move to the blank transaction at the bottom of the register + +
+
+ + + + True + False + + + True + False + Duplicate + GncPluginPageRegisterActions.DuplicateTransactionAction + Make a copy of the current transaction + True + edit-copy + + + False + True + + + + + True + False + Delete + GncPluginPageRegisterActions.DeleteTransactionAction + Delete the current transaction + True + edit-delete + + + False + True + + + + + True + False + + + False + True + + + + + True + False + Enter + GncPluginPageRegisterActions.RecordTransactionAction + Record the current transaction + True + list-add + + + False + True + + + + + True + False + Cancel + GncPluginPageRegisterActions.CancelTransactionAction + Cancel the current transaction + True + process-stop + + + False + True + + + + + True + False + Blank + GncPluginPageRegisterActions.BlankTransactionAction + Move to the blank transaction at the bottom of the register + True + go-bottom + + + False + True + + + + +
+ From 103d82dcc34abece921f549803dbe1716bc99dc0 Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Fri, 28 Oct 2022 16:34:04 +0100 Subject: [PATCH 23/77] Change to use short labels in toolbar This commit adds the ability to use short labels on the toolbar, any toolbar items with a short name defined will be updated all the time. --- gnucash/gnome-utils/gnc-main-window.cpp | 16 +++++ gnucash/gnome-utils/gnc-main-window.h | 18 +++++ gnucash/gnome-utils/gnc-plugin.c | 22 ++++--- gnucash/gnome-utils/gnc-plugin.h | 6 +- gnucash/gnome/gnc-plugin-page-account-tree.c | 8 ++- gnucash/gnome/gnc-plugin-page-budget.c | 7 +- gnucash/gnome/gnc-plugin-page-invoice.c | 38 +++++++---- gnucash/gnome/gnc-plugin-page-owner-tree.c | 7 +- gnucash/gnome/gnc-plugin-page-register.c | 6 +- gnucash/gnome/gnc-plugin-page-report.cpp | 69 ++++++++++++++------ gnucash/gnome/gnc-plugin-page-sx-list.c | 2 - 11 files changed, 142 insertions(+), 57 deletions(-) diff --git a/gnucash/gnome-utils/gnc-main-window.cpp b/gnucash/gnome-utils/gnc-main-window.cpp index 6ffab83c60..e99f9699c6 100644 --- a/gnucash/gnome-utils/gnc-main-window.cpp +++ b/gnucash/gnome-utils/gnc-main-window.cpp @@ -3908,6 +3908,22 @@ gnc_main_window_menu_item_vis_by_action (GncMainWindow *window, } +void +gnc_main_window_init_short_names (GncMainWindow *window, + GncToolBarShortNames *toolbar_labels) +{ + GncMainWindowPrivate *priv; + + g_return_if_fail (GNC_IS_MAIN_WINDOW(window)); + g_return_if_fail (toolbar_labels != nullptr); + + priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); + + gnc_plugin_init_short_names (priv->toolbar, + toolbar_labels); +} + + static void gnc_main_window_update_toolbar (GncMainWindow *window, GncPluginPage *page, const gchar *toolbar_qualifier) diff --git a/gnucash/gnome-utils/gnc-main-window.h b/gnucash/gnome-utils/gnc-main-window.h index 22655ff6eb..d3d720ed5e 100644 --- a/gnucash/gnome-utils/gnc-main-window.h +++ b/gnucash/gnome-utils/gnc-main-window.h @@ -309,6 +309,24 @@ GtkWidget *gnc_main_window_menu_find_menu_item (GncMainWindow *window, GtkWidget * gnc_main_window_toolbar_find_menu_item (GncMainWindow *window, const gchar *action_name); //FIXMEb added +/** A structure for defining alternate action names for use in the + * toolbar. All toolbar buttons are homogeneous in size and are sized + * to fit the longest label. Therefore, this structure should be + * used if an action name is more than one word. This way the menu + * can have the label "Whizzy Feature", while the toolbar button only + * has the label "Whizzy". */ +typedef struct +{ + /** The name of the action. */ + const char *action_name; + /** The alternate toolbar label to use */ + const char *short_label; +} GncToolBarShortNames; //FIXMEb added + +void gnc_main_window_init_short_names (GncMainWindow *window, + GncToolBarShortNames *toolbar_labels); //FIXMEb added + + /** Retrieve a specific set of user interface actions from a window. * This function can be used to get an group of action to be * manipulated when the front page of a window has changed. diff --git a/gnucash/gnome-utils/gnc-plugin.c b/gnucash/gnome-utils/gnc-plugin.c index b2cb4dfcbb..ea8e838670 100644 --- a/gnucash/gnome-utils/gnc-plugin.c +++ b/gnucash/gnome-utils/gnc-plugin.c @@ -42,6 +42,7 @@ #include "gnc-filepath-utils.h" #include "gnc-gnome-utils.h" #include "gnc-gobject-utils.h" +#include "gnc-gtk-utils.h" /** The debugging module that this .o belongs to. */ static QofLogModule log_module = GNC_MOD_GUI; @@ -231,18 +232,21 @@ gnc_plugin_get_name (GncPlugin *plugin) * * See gnc-plugin.h for documentation on the function arguments. */ void -gnc_plugin_init_short_names (GSimpleActionGroup *simple_action_group, - action_toolbar_labels *toolbar_labels) +gnc_plugin_init_short_names (GtkWidget *toolbar, + GncToolBarShortNames *toolbar_labels) { - GAction *action; - gint i; + g_return_if_fail (toolbar != NULL); + g_return_if_fail (toolbar_labels != NULL); - for (i = 0; toolbar_labels[i].action_name; i++) + for (gint i = 0; (toolbar_labels[i].action_name); i++) { - /* Add a couple of short labels for the toolbar */ -//FIXMEb action = g_action_map_lookup_action (G_ACTION_MAP(simple_action_group), -// toolbar_labels[i].action_name); -// gtk_action_set_short_label (action, _(toolbar_labels[i].label)); + GtkWidget *tool_item = gnc_find_toolbar_item (toolbar, toolbar_labels[i].action_name); + + if (!tool_item) + continue; + + gtk_tool_button_set_label (GTK_TOOL_BUTTON(tool_item), _(toolbar_labels[i].short_label)); + gtk_tool_button_set_use_underline (GTK_TOOL_BUTTON(tool_item), TRUE); } } diff --git a/gnucash/gnome-utils/gnc-plugin.h b/gnucash/gnome-utils/gnc-plugin.h index dc69f2e938..727dd5ef5e 100644 --- a/gnucash/gnome-utils/gnc-plugin.h +++ b/gnucash/gnome-utils/gnc-plugin.h @@ -260,10 +260,10 @@ typedef struct * group. * * @param toolbar_labels A pointer to a NULL terminated array of data - * action_toolbar_labels items. + * GncToolBarShortNames items. */ -void gnc_plugin_init_short_names (GSimpleActionGroup *simple_action_group, - action_toolbar_labels *toolbar_labels); +void gnc_plugin_init_short_names (GtkWidget *toolbar, + GncToolBarShortNames *toolbar_labels); /** Mark certain actions as "important". This means that their labels diff --git a/gnucash/gnome/gnc-plugin-page-account-tree.c b/gnucash/gnome/gnc-plugin-page-account-tree.c index 35fe19dbc8..6c6b5f10ab 100644 --- a/gnucash/gnome/gnc-plugin-page-account-tree.c +++ b/gnucash/gnome/gnc-plugin-page-account-tree.c @@ -387,9 +387,9 @@ static const gchar* readonly_inactive_actions[] = }; /** Short labels for use on the toolbar buttons. */ -static action_toolbar_labels toolbar_labels[] = +static GncToolBarShortNames toolbar_labels[] = { - { "FileOpenAccountAction", N_("Open") }, + { "EditOpenAccountAction", N_("Open") }, { "EditEditAccountAction", N_("Edit") }, { "FileNewAccountAction", N_("New") }, { "EditDeleteAccountAction", N_("Delete") }, @@ -527,7 +527,6 @@ gnc_plugin_page_account_tree_init (GncPluginPageAccountTree *plugin_page) gnc_plugin_page_account_tree_actions, gnc_plugin_page_account_tree_n_actions, plugin_page); -//FIXMEb gnc_plugin_init_short_names (action_group, toolbar_labels); /* Visible types */ priv->fd.visible_types = -1; /* Start with all types */ @@ -656,6 +655,9 @@ gnc_plugin_page_account_tree_focus_widget (GncPluginPage *account_plugin_page) gnc_main_window_update_menu (GNC_MAIN_WINDOW(account_plugin_page->window), account_plugin_page, gnc_plugin_load_ui_items); + // setup any short toolbar names + gnc_main_window_init_short_names (GNC_MAIN_WINDOW(account_plugin_page->window), toolbar_labels); + /* Disable the FilePrintAction */ action = gnc_main_window_find_action (GNC_MAIN_WINDOW(account_plugin_page->window), "FilePrintAction"); g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE); diff --git a/gnucash/gnome/gnc-plugin-page-budget.c b/gnucash/gnome/gnc-plugin-page-budget.c index afbfd4c8e3..33e8c995cc 100644 --- a/gnucash/gnome/gnc-plugin-page-budget.c +++ b/gnucash/gnome/gnc-plugin-page-budget.c @@ -228,7 +228,7 @@ static const gchar *actions_requiring_account[] = #endif /** Short labels for use on the toolbar buttons. */ -static action_toolbar_labels toolbar_labels[] = +static GncToolBarShortNames toolbar_labels[] = { { "OpenAccountAction", N_("Open") }, { "DeleteBudgetAction", N_("Delete") }, @@ -375,8 +375,6 @@ gnc_plugin_page_budget_init (GncPluginPageBudget *plugin_page) gnc_plugin_page_budget_n_actions, plugin_page); -//FIXMEb gnc_plugin_init_short_names (action_group, toolbar_labels); - if (qof_book_is_readonly (gnc_get_current_book())) gnc_plugin_update_actionsb (simple_action_group, writeable_actions, "sensitive", FALSE); @@ -443,6 +441,9 @@ gnc_plugin_page_budget_focus_widget (GncPluginPage *budget_plugin_page) gnc_main_window_update_menu (GNC_MAIN_WINDOW(budget_plugin_page->window), budget_plugin_page, gnc_plugin_load_ui_items); + // setup any short toolbar names + gnc_main_window_init_short_names (GNC_MAIN_WINDOW(budget_plugin_page->window), toolbar_labels); + if (!gtk_widget_is_focus (GTK_WIDGET(account_view))) gtk_widget_grab_focus (GTK_WIDGET(account_view)); } diff --git a/gnucash/gnome/gnc-plugin-page-invoice.c b/gnucash/gnome/gnc-plugin-page-invoice.c index bb02e4111e..33518ceaab 100644 --- a/gnucash/gnome/gnc-plugin-page-invoice.c +++ b/gnucash/gnome/gnc-plugin-page-invoice.c @@ -460,7 +460,8 @@ static action_toolbar_labels creditnote_action_tooltips[] = { }; /** Short labels for use on the toolbar buttons. */ -static action_toolbar_labels toolbar_labels[] = { +static GncToolBarShortNames toolbar_labels[] = +{ {"RecordEntryAction", N_("Enter")}, {"CancelEntryAction", N_("Cancel")}, {"DeleteEntryAction", N_("Delete")}, @@ -597,8 +598,6 @@ gnc_plugin_page_invoice_init (GncPluginPageInvoice *plugin_page) gnc_plugin_page_invoice_actions, gnc_plugin_page_invoice_n_actions, plugin_page); - -//FIXMEb gnc_plugin_init_short_names (action_group, toolbar_labels); } static void @@ -621,7 +620,8 @@ update_doclink_actions (GncPluginPage *plugin_page, gboolean has_uri) static void gnc_plugin_page_invoice_action_update (GncPluginPage *plugin_page, - action_toolbar_labels *action_list) + action_toolbar_labels *action_list, + action_toolbar_labels *tooltip_list) { GtkWidget *menu_item; GtkWidget *tool_item; @@ -640,6 +640,21 @@ gnc_plugin_page_invoice_action_update (GncPluginPage *plugin_page, if (tool_item) gtk_tool_button_set_label (GTK_TOOL_BUTTON(tool_item), _(action_list[i].label)); } +//FIXMEb this may need changing to update the menu model instead of the GtkMenuItem + for (gint i = 0; (tooltip_list[i].action_name != NULL); i++) + { + menu_item = gnc_main_window_menu_find_menu_item (GNC_MAIN_WINDOW(GNC_PLUGIN_PAGE(plugin_page)->window), + tooltip_list[i].action_name); + + if (menu_item) + gtk_widget_set_tooltip_text (GTK_WIDGET(menu_item), _(tooltip_list[i].label)); + + tool_item = gnc_main_window_toolbar_find_menu_item (GNC_MAIN_WINDOW(GNC_PLUGIN_PAGE(plugin_page)->window), + tooltip_list[i].action_name); + + if (tool_item) + gtk_widget_set_tooltip_text (GTK_WIDGET(tool_item), _(tooltip_list[i].label)); + } } static void @@ -759,18 +774,14 @@ gnc_plugin_page_invoice_update_menus (GncPluginPage *page, gboolean is_posted, g gnc_plugin_update_actionsb (simple_action_group, invoice_book_readwrite_actions, "sensitive", !is_readonly); - /* update the action labels */ - gnc_plugin_page_invoice_action_update (page, label_list); - /* update the action tooltips */ -//FIXMRb gnc_plugin_page_invoice_action_update (simple_action_group, tooltip_list, (void*)gtk_action_set_tooltip); + /* update the action labels and tooltips */ + gnc_plugin_page_invoice_action_update (page, label_list, tooltip_list); // if there is no default layout do not enable reset action gnc_plugin_page_update_reset_layout_action (page); - /* update the layout action labels */ - gnc_plugin_page_invoice_action_update (page, label_layout_list); - /* update the layout action tooltips */ -//FIXMEb gnc_plugin_page_invoice_action_update (simple_action_group, tooltip_layout_list, (void*)gtk_action_set_tooltip); + /* update the layout action labels and tooltips */ + gnc_plugin_page_invoice_action_update (page, label_layout_list, tooltip_layout_list); // update doclink buttons invoice = gnc_invoice_window_get_invoice (priv->iw); @@ -808,6 +819,9 @@ gnc_plugin_page_invoice_focus_widget (GncPluginPage *invoice_plugin_page) gnc_plugin_page_invoice_update_menus (invoice_plugin_page, priv->is_posted, priv->can_unpost); + // setup any short toolbar names + gnc_main_window_init_short_names (GNC_MAIN_WINDOW(invoice_plugin_page->window), toolbar_labels); + // if there is no default layout do not enable reset action gnc_plugin_page_update_reset_layout_action (invoice_plugin_page); diff --git a/gnucash/gnome/gnc-plugin-page-owner-tree.c b/gnucash/gnome/gnc-plugin-page-owner-tree.c index b4375ec463..8c81e7eea1 100644 --- a/gnucash/gnome/gnc-plugin-page-owner-tree.c +++ b/gnucash/gnome/gnc-plugin-page-owner-tree.c @@ -301,7 +301,7 @@ static const gchar* readonly_inactive_actions[] = /** Short labels for use on the toolbar buttons. */ -static action_toolbar_labels toolbar_labels[] = +static GncToolBarShortNames toolbar_labels[] = { { "OTEditVendorAction", N_("Edit") }, { "OTEditCustomerAction", N_("Edit") }, @@ -412,6 +412,9 @@ gnc_plugin_page_owner_focus_widget (GncPluginPage *owner_plugin_page) gnc_main_window_update_menu (GNC_MAIN_WINDOW(owner_plugin_page->window), owner_plugin_page, gnc_plugin_load_ui_items); + // setup any short toolbar names + gnc_main_window_init_short_names (GNC_MAIN_WINDOW(owner_plugin_page->window), toolbar_labels); + if (GTK_IS_TREE_VIEW(tree_view)) { if (!gtk_widget_is_focus (GTK_WIDGET(tree_view))) @@ -480,8 +483,6 @@ gnc_plugin_page_owner_tree_init (GncPluginPageOwnerTree *plugin_page) gnc_plugin_page_owner_tree_n_actions, plugin_page); -//FIXMEb gnc_plugin_init_short_names (action_group, toolbar_labels); - /* Init filter */ priv->fd.show_inactive = TRUE; priv->fd.show_zero_total = TRUE; diff --git a/gnucash/gnome/gnc-plugin-page-register.c b/gnucash/gnome/gnc-plugin-page-register.c index 749c80beea..28b242d0a7 100644 --- a/gnucash/gnome/gnc-plugin-page-register.c +++ b/gnucash/gnome/gnc-plugin-page-register.c @@ -608,7 +608,7 @@ static const gchar* actions_requiring_priced_account[] = }; /** Short labels for use on the toolbar buttons. */ -static action_toolbar_labels toolbar_labels[] = +static GncToolBarShortNames toolbar_labels[] = { { "ActionsTransferAction", N_ ("Transfer") }, { "RecordTransactionAction", N_ ("Enter") }, @@ -884,7 +884,6 @@ gnc_plugin_page_register_init (GncPluginPageRegister* plugin_page) gnc_plugin_page_register_n_actions, plugin_page); -//FIXMEb gnc_plugin_init_short_names (action_group, toolbar_labels); //FIXMEb gnc_plugin_set_important_actions (action_group, important_actions); priv->lines_default = DEFAULT_LINES_AMOUNT; @@ -960,6 +959,9 @@ gnc_plugin_page_register_focus_widget (GncPluginPage* register_plugin_page) gnc_plugin_load_ui_items); } + // setup any short toolbar names + gnc_plugin_init_short_names (gnc_window_get_toolbar (gnc_window), toolbar_labels); + gnc_plugin_page_register_ui_update (NULL, GNC_PLUGIN_PAGE_REGISTER(register_plugin_page)); gnc_split_reg_focus_on_sheet (gsr); diff --git a/gnucash/gnome/gnc-plugin-page-report.cpp b/gnucash/gnome/gnc-plugin-page-report.cpp index b76126e3f8..6d9e17a93b 100644 --- a/gnucash/gnome/gnc-plugin-page-report.cpp +++ b/gnucash/gnome/gnc-plugin-page-report.cpp @@ -281,6 +281,22 @@ static const gchar *gnc_plugin_load_ui_items [] = NULL, }; +/** Short labels for use on the toolbar buttons. */ +static GncToolBarShortNames toolbar_labels[] = +{ + { "FilePrintAction", N_("Print") }, + { "ReportExportAction", N_("Export") }, + { "ReportOptionsAction", N_("Options") }, + /* Translators: This string is meant to be a short alternative for "Save Report Configuration" + to be used as toolbar button label. */ + { "ReportSaveAction", N_("Save Config") }, + /* Translators: This string is meant to be a short alternative for "Save Report Configuration As..." + to be used as toolbar button label. */ + { "ReportSaveAsAction", N_("Save Config As...") }, + { "FilePrintPDFAction", N_("Make Pdf") }, + { nullptr, nullptr }, +}; + static void gnc_plugin_page_report_get_property( GObject *obj, guint prop_id, @@ -357,6 +373,9 @@ gnc_plugin_page_report_focus_widget (GncPluginPage *report_plugin_page) gnc_main_window_update_menu (GNC_MAIN_WINDOW(report_plugin_page->window), report_plugin_page, gnc_plugin_load_ui_items); + // setup any short toolbar names + gnc_main_window_init_short_names (GNC_MAIN_WINDOW(report_plugin_page->window), toolbar_labels); + gnc_plugin_page_report_menu_updates (report_plugin_page); window = gnc_plugin_page_get_window (report_plugin_page); @@ -1225,22 +1244,6 @@ gnc_plugin_page_report_destroy(GncPluginPageReportPrivate * priv) scm_gc_unprotect_object(priv->edited_reports); } -/** Short labels for use on the toolbar buttons. */ -static action_toolbar_labels toolbar_labels[] = -{ - { "FilePrintAction", N_("Print") }, - { "ReportExportAction", N_("Export") }, - { "ReportOptionsAction", N_("Options") }, - /* Translators: This string is meant to be a short alternative for "Save Report Configuration" - to be used as toolbar button label. */ - { "ReportSaveAction", N_("Save Config") }, - /* Translators: This string is meant to be a short alternative for "Save Report Configuration As..." - to be used as toolbar button label. */ - { "ReportSaveAsAction", N_("Save Config As...") }, - { "FilePrintPDFAction", N_("Make Pdf") }, - { nullptr, nullptr }, -}; - static const gchar *initially_insensitive_actions[] = { nullptr @@ -1278,12 +1281,37 @@ gnc_plugin_page_report_constructor(GType this_type, guint n_properties, GObjectC return obj; } + + +static void +gnc_plugin_page_report_menu_update (GncPluginPage *plugin_page, + action_toolbar_labels *tooltip_list) +{ + GtkWidget *menu_item; + GtkWidget *tool_item; +//FIXMEb this may need changing to update the menu model instead of the GtkMenuItem + for (gint i = 0; (tooltip_list[i].action_name != NULL); i++) + { + menu_item = gnc_main_window_menu_find_menu_item (GNC_MAIN_WINDOW(GNC_PLUGIN_PAGE(plugin_page)->window), + tooltip_list[i].action_name); + if (menu_item) + gtk_widget_set_tooltip_text (GTK_WIDGET(menu_item), _(tooltip_list[i].label)); + + tool_item = gnc_main_window_toolbar_find_menu_item (GNC_MAIN_WINDOW(GNC_PLUGIN_PAGE(plugin_page)->window), + tooltip_list[i].action_name); + if (tool_item) + gtk_widget_set_tooltip_text (GTK_WIDGET(tool_item), _(tooltip_list[i].label)); + } +} + + static void gnc_plugin_page_report_menu_updates (GncPluginPage *plugin_page) { GncPluginPageReportPrivate *priv; GncPluginPageReport *report; GncMainWindow *window; + action_toolbar_labels tooltip_list[3]; GAction *action; gchar *saved_reports_path = gnc_build_userdata_path (SAVED_REPORTS_FILE); @@ -1299,8 +1327,11 @@ gnc_plugin_page_report_menu_updates (GncPluginPage *plugin_page) window = (GncMainWindow*)gnc_plugin_page_get_window (GNC_PLUGIN_PAGE(plugin_page)); -//FIXMEb probably needs changing in model { "ReportSaveAction", N_("Save Report Configuration"), true, report_save_str }; -//FIXMEb probably needs changing in model { "ReportSaveAsAction", N_("Save Report Configuration As..."), true, report_saveas_str }; + tooltip_list[0] = { "ReportSaveAction", report_save_str }; + tooltip_list[1] = { "ReportSaveAsAction", report_saveas_str }; + tooltip_list[2] = { nullptr, nullptr }; + + gnc_plugin_page_report_menu_update (plugin_page, tooltip_list); /* Enable the FilePrintAction */ action = gnc_main_window_find_action (window, "FilePrintAction"); @@ -1356,8 +1387,6 @@ gnc_plugin_page_report_constr_init (GncPluginPageReport *plugin_page, gint repor gnc_plugin_update_actionsb (simple_action_group, initially_insensitive_actions, "sensitive", FALSE); - -//FIXMEb gnc_plugin_init_short_names (action_group, toolbar_labels); } GncPluginPage* diff --git a/gnucash/gnome/gnc-plugin-page-sx-list.c b/gnucash/gnome/gnc-plugin-page-sx-list.c index 40be33ced3..7e77a36d63 100644 --- a/gnucash/gnome/gnc-plugin-page-sx-list.c +++ b/gnucash/gnome/gnc-plugin-page-sx-list.c @@ -261,8 +261,6 @@ gnc_plugin_page_sx_list_init (GncPluginPageSxList *plugin_page) gnc_plugin_page_sx_list_actions, gnc_plugin_page_sx_list_n_actions, plugin_page); - - /* gnc_plugin_init_short_names (action_group, toolbar_labels); */ } From 464c3340d18350dc9ff68de52a46887d894b19fd Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Fri, 28 Oct 2022 16:34:43 +0100 Subject: [PATCH 24/77] Remove setup for important actions --- gnucash/gnome-utils/gnc-main-window.cpp | 12 --------- gnucash/gnome-utils/gnc-plugin.c | 32 ----------------------- gnucash/gnome-utils/gnc-plugin.h | 20 -------------- gnucash/gnome/gnc-plugin-basic-commands.c | 10 ------- gnucash/gnome/gnc-plugin-page-register.c | 11 -------- 5 files changed, 85 deletions(-) diff --git a/gnucash/gnome-utils/gnc-main-window.cpp b/gnucash/gnome-utils/gnc-main-window.cpp index e99f9699c6..39fb5f2692 100644 --- a/gnucash/gnome-utils/gnc-main-window.cpp +++ b/gnucash/gnome-utils/gnc-main-window.cpp @@ -487,16 +487,6 @@ static GncDisplayItem gnc_menu_display_items [] = /** The number of display items provided by the main window. */ static guint gnc_menu_n_display_items = G_N_ELEMENTS(gnc_menu_display_items); -/** These are the "important" actions provided by the main window. - * Their labels will appear when the toolbar is set to "Icons and - * important text" (e.g. GTK_TOOLBAR_BOTH_HORIZ) mode. */ -static const gchar *gnc_menu_important_actions[] = -{ - "FileCloseAction", - nullptr, -}; - - /** The following are in the main window so they will always be * present in the menu structure, but they are never sensitive. * These actions should be overridden in child windows where they @@ -4417,8 +4407,6 @@ gnc_main_window_setup_window (GncMainWindow *window) gnc_main_window_menu_item_vis_by_action (window, always_hidden_actions, false); -//FIXMEb gnc_plugin_set_important_actions (priv->action_group, -// gnc_menu_important_actions); // gtk_ui_manager_insert_action_group (window->ui_merge, priv->action_group, 0); diff --git a/gnucash/gnome-utils/gnc-plugin.c b/gnucash/gnome-utils/gnc-plugin.c index ea8e838670..58e70ebefa 100644 --- a/gnucash/gnome-utils/gnc-plugin.c +++ b/gnucash/gnome-utils/gnc-plugin.c @@ -150,14 +150,6 @@ gnc_plugin_add_to_window (GncPlugin *plugin, klass->display_items, klass->n_display_items, klass->ui_updates, klass->ui_filename, plugin); - - if (klass->important_actions) - { - simple_action_group = - gnc_main_window_get_action_group (window, klass->actions_name); -//FIXMEb gnc_plugin_set_important_actions (simple_action_group, -// klass->important_actions); - } } /* @@ -251,30 +243,6 @@ gnc_plugin_init_short_names (GtkWidget *toolbar, } -/** Mark certain actions as "important". This means that their labels - * will appear when the toolbar is set to "Icons and important text" - * (e.g. GTK_TOOLBAR_BOTH_HORIZ) mode. - * - * See gnc-plugin.h for documentation on the function arguments. */ -void -gnc_plugin_set_important_actions (GSimpleActionGroup *simple_action_group, - const gchar **name) -{ - GAction *action; - gint i; - - for (i = 0; name[i]; i++) - { -//FIXMEb action = g_action_map_lookup_action (G_ACTION_MAP(simple_action_group), name[i]); -// g_object_set (G_OBJECT(action), "is_important", TRUE, NULL); - } - - /* If this trips, you've got too many "important" actions. That - * can't *all* be that important, can they? */ - g_assert(i <= 3); -} - - /* Update a property of existing UI actions. This function can * modify actions making them visible, invisible, sensitive, or * insensitive. diff --git a/gnucash/gnome-utils/gnc-plugin.h b/gnucash/gnome-utils/gnc-plugin.h index 727dd5ef5e..8b78489c75 100644 --- a/gnucash/gnome-utils/gnc-plugin.h +++ b/gnucash/gnome-utils/gnc-plugin.h @@ -140,11 +140,6 @@ typedef struct GtkToggleActionEntry *toggle_actions; /** The number of toggle actions in the toggle actions array. */ guint n_toggle_actions; - /** A NULL terminated list of actions that should be considered - * important. In the toolbar, these actions will display the - * action name when the toolbar is in "text beside icons" - * mode. */ - const gchar **important_actions; /** The relative name of the XML file describing the * menu/toolbar action items. */ const gchar *ui_filename; @@ -266,21 +261,6 @@ void gnc_plugin_init_short_names (GtkWidget *toolbar, GncToolBarShortNames *toolbar_labels); -/** Mark certain actions as "important". This means that their labels - * will appear when the toolbar is set to "Icons and important text" - * (e.g. GTK_TOOLBAR_BOTH_HORIZ) mode. - * - * @param action_group The group of all actions associated with a - * plugin or plugin page. All actions to me modified must be in this - * group. - * - * @param name A list of actions names to be marked important. This - * list must be NULL terminated. - */ -void gnc_plugin_set_important_actions (GSimpleActionGroup *simple_action_group, - const gchar **names); - - /** Update a property on a set of existing GtkActions. This function * can be easily used to make a list of actions visible, invisible, * sensitive, or insensitive. diff --git a/gnucash/gnome/gnc-plugin-basic-commands.c b/gnucash/gnome/gnc-plugin-basic-commands.c index 8935a7fabf..ab31edc8b4 100644 --- a/gnucash/gnome/gnc-plugin-basic-commands.c +++ b/gnucash/gnome/gnc-plugin-basic-commands.c @@ -144,15 +144,6 @@ static const gchar *gnc_plugin_load_ui_items [] = NULL, }; -/** These are the "important" actions provided by the basic commands - * plugin. Their labels will appear when the toolbar is set to - * "Icons and important text" (e.g. GTK_TOOLBAR_BOTH_HORIZ) mode. */ -static const gchar *gnc_plugin_important_actions[] = -{ - "FileSaveAction", - NULL, -}; - /** The following items should be made insensitive at startup time. The * sensitivity will be changed by some later event. */ static const gchar *gnc_plugin_initially_insensitive_actions[] = @@ -312,7 +303,6 @@ gnc_plugin_basic_commands_class_init (GncPluginBasicCommandsClass *klass) plugin_class->actions_name = PLUGIN_ACTIONS_NAME; plugin_class->actionsb = gnc_plugin_actions; plugin_class->n_actionsb = gnc_plugin_n_actions; - plugin_class->important_actions = gnc_plugin_important_actions; plugin_class->ui_filename = PLUGIN_UI_FILENAME; plugin_class->ui_updates = gnc_plugin_load_ui_items; } diff --git a/gnucash/gnome/gnc-plugin-page-register.c b/gnucash/gnome/gnc-plugin-page-register.c index 28b242d0a7..527be7b13f 100644 --- a/gnucash/gnome/gnc-plugin-page-register.c +++ b/gnucash/gnome/gnc-plugin-page-register.c @@ -571,15 +571,6 @@ static const gchar *gnc_plugin_load_ui_items [] = NULL, }; -/** These are the "important" actions provided by the register page. - * Their labels will appear when the toolbar is set to "Icons and - * important text" (e.g. GTK_TOOLBAR_BOTH_HORIZ) mode. */ -static const gchar* important_actions[] = -{ - "SplitTransactionAction", - NULL, -}; - /** Actions that require an account to be selected before they are * enabled. */ static const gchar* actions_requiring_account[] = @@ -884,8 +875,6 @@ gnc_plugin_page_register_init (GncPluginPageRegister* plugin_page) gnc_plugin_page_register_n_actions, plugin_page); -//FIXMEb gnc_plugin_set_important_actions (action_group, important_actions); - priv->lines_default = DEFAULT_LINES_AMOUNT; priv->read_only = FALSE; priv->fd.cleared_match = CLEARED_ALL; From 505f3e519e9da5fe8bda32946109862acf1e46d0 Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Fri, 28 Oct 2022 16:35:25 +0100 Subject: [PATCH 25/77] Remove last bits of gtk toggle actions --- gnucash/gnome-utils/gnc-plugin.c | 2 +- gnucash/gnome-utils/gnc-plugin.h | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/gnucash/gnome-utils/gnc-plugin.c b/gnucash/gnome-utils/gnc-plugin.c index 58e70ebefa..71929c6c87 100644 --- a/gnucash/gnome-utils/gnc-plugin.c +++ b/gnucash/gnome-utils/gnc-plugin.c @@ -197,7 +197,7 @@ gnc_plugin_remove_from_window (GncPlugin *plugin, if (klass->actions_name && !window->just_plugin_prefs) { DEBUG ("%s: %d actions to unmerge", - klass->actions_name, (klass->n_actions + klass->n_toggle_actions)); + klass->actions_name, (klass->n_actions)); gnc_main_window_unmerge_actions (window, klass->actions_name); } LEAVE (""); diff --git a/gnucash/gnome-utils/gnc-plugin.h b/gnucash/gnome-utils/gnc-plugin.h index 8b78489c75..e9c70df5c3 100644 --- a/gnucash/gnome-utils/gnc-plugin.h +++ b/gnucash/gnome-utils/gnc-plugin.h @@ -135,11 +135,6 @@ typedef struct GtkActionEntry *actions; /** The number of actions in the actions array. */ guint n_actions; - /** An array of toggle actions that should automatically be added to - * any GnuCash "main" content window that is opened. */ - GtkToggleActionEntry *toggle_actions; - /** The number of toggle actions in the toggle actions array. */ - guint n_toggle_actions; /** The relative name of the XML file describing the * menu/toolbar action items. */ const gchar *ui_filename; From 02911eab20fce5008e8afd98cd74b4da3af0fcc1 Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Fri, 28 Oct 2022 16:36:05 +0100 Subject: [PATCH 26/77] Replace gnc_plugin_update_actions Replace gnc_plugin_update_actions with new version based on GSimpleActionGroup --- gnucash/gnome-utils/gnc-main-window.cpp | 12 ++++----- gnucash/gnome-utils/gnc-plugin.c | 26 +------------------ gnucash/gnome-utils/gnc-plugin.h | 6 +---- gnucash/gnome/gnc-plugin-basic-commands.c | 6 ++--- gnucash/gnome/gnc-plugin-budget.c | 2 +- gnucash/gnome/gnc-plugin-business.c | 10 +++---- gnucash/gnome/gnc-plugin-page-account-tree.c | 11 ++++---- gnucash/gnome/gnc-plugin-page-budget.c | 4 +-- gnucash/gnome/gnc-plugin-page-invoice.c | 8 +++--- gnucash/gnome/gnc-plugin-page-owner-tree.c | 6 ++--- gnucash/gnome/gnc-plugin-page-register.c | 16 ++++++------ gnucash/gnome/gnc-plugin-page-report.cpp | 4 +-- .../import-export/aqb/gnc-plugin-aqbanking.c | 10 +++---- 13 files changed, 47 insertions(+), 74 deletions(-) diff --git a/gnucash/gnome-utils/gnc-main-window.cpp b/gnucash/gnome-utils/gnc-main-window.cpp index 39fb5f2692..897bf3bf53 100644 --- a/gnucash/gnome-utils/gnc-main-window.cpp +++ b/gnucash/gnome-utils/gnc-main-window.cpp @@ -1700,9 +1700,9 @@ gnc_main_window_generate_title (GncMainWindow *window) /* Update the menus based upon whether this is an "immutable" page. */ immutable = page && g_object_get_data (G_OBJECT (page), PLUGIN_PAGE_IMMUTABLE); - gnc_plugin_update_actionsb (priv->simple_action_group, - immutable_page_actions, - "sensitive", !immutable); + gnc_plugin_update_actions (priv->simple_action_group, + immutable_page_actions, + "sensitive", !immutable); /* Trigger sensitivity updtates of other actions such as Save/Revert */ g_signal_emit_by_name (window, "page_changed", page); g_free( filename ); @@ -4397,10 +4397,10 @@ gnc_main_window_setup_window (GncMainWindow *window) gnc_menu_n_actions, window); - gnc_plugin_update_actionsb (priv->simple_action_group, + gnc_plugin_update_actions (priv->simple_action_group, initially_insensitive_actions, "sensitive", FALSE); - gnc_plugin_update_actionsb (priv->simple_action_group, + gnc_plugin_update_actions (priv->simple_action_group, always_insensitive_actions, "sensitive", FALSE); @@ -4681,7 +4681,7 @@ gnc_main_window_switch_page (GtkNotebook *notebook, priv->usage_order = g_list_prepend (priv->usage_order, page); } - gnc_plugin_update_actionsb (priv->simple_action_group, + gnc_plugin_update_actions (priv->simple_action_group, multiple_page_actions, "sensitive", g_list_length(priv->installed_pages) > 1); diff --git a/gnucash/gnome-utils/gnc-plugin.c b/gnucash/gnome-utils/gnc-plugin.c index 71929c6c87..2c103d894d 100644 --- a/gnucash/gnome-utils/gnc-plugin.c +++ b/gnucash/gnome-utils/gnc-plugin.c @@ -249,31 +249,7 @@ gnc_plugin_init_short_names (GtkWidget *toolbar, * * See gnc-plugin.h for documentation on the function arguments. */ void -gnc_plugin_update_actions (GtkActionGroup *action_group, - const gchar **action_names, - const gchar *property_name, - gboolean value) -{ - GtkAction *action; - gint i; - - for (i = 0; action_names[i]; i++) - { - action = gtk_action_group_get_action (action_group, action_names[i]); - if (action) - { - g_object_set (G_OBJECT(action), property_name, value, NULL); - } - else - { - g_warning("No such action with name '%s' in action group %s (size %d)", - action_names[i], gtk_action_group_get_name(action_group), - g_list_length(gtk_action_group_list_actions(action_group))); - } - } -} -void -gnc_plugin_update_actionsb (GSimpleActionGroup *simple_action_group, +gnc_plugin_update_actions (GSimpleActionGroup *simple_action_group, const gchar **action_names, const gchar *property_name, gboolean value) diff --git a/gnucash/gnome-utils/gnc-plugin.h b/gnucash/gnome-utils/gnc-plugin.h index e9c70df5c3..3e91d7f8fa 100644 --- a/gnucash/gnome-utils/gnc-plugin.h +++ b/gnucash/gnome-utils/gnc-plugin.h @@ -274,11 +274,7 @@ void gnc_plugin_init_short_names (GtkWidget *toolbar, * @param value A boolean specifying the new state for the specified * property. */ -void gnc_plugin_update_actions (GtkActionGroup *action_group, - const gchar **action_names, - const gchar *property_name, - gboolean value); -void gnc_plugin_update_actionsb (GSimpleActionGroup *simple_action_group, +void gnc_plugin_update_actions (GSimpleActionGroup *simple_action_group, const gchar **action_names, const gchar *property_name, gboolean value); //FIXMEb added diff --git a/gnucash/gnome/gnc-plugin-basic-commands.c b/gnucash/gnome/gnc-plugin-basic-commands.c index ab31edc8b4..d4e6cff6fe 100644 --- a/gnucash/gnome/gnc-plugin-basic-commands.c +++ b/gnucash/gnome/gnc-plugin-basic-commands.c @@ -225,7 +225,7 @@ gnc_plugin_basic_commands_add_to_window (GncPlugin *plugin, GSimpleActionGroup *simple_action_group = gnc_main_window_get_action_group (window, PLUGIN_ACTIONS_NAME); - gnc_plugin_update_actionsb (simple_action_group, + gnc_plugin_update_actions (simple_action_group, gnc_plugin_initially_insensitive_actions, "sensitive", FALSE); @@ -255,9 +255,9 @@ static void update_inactive_actions (GncPluginPage *plugin_page) g_return_if_fail (G_IS_SIMPLE_ACTION_GROUP(simple_action_group)); /* Set the action's sensitivity */ - gnc_plugin_update_actionsb (simple_action_group, readwrite_only_active_actions, + gnc_plugin_update_actions (simple_action_group, readwrite_only_active_actions, "sensitive", is_readwrite); - gnc_plugin_update_actionsb (simple_action_group, dirty_only_active_actions, + gnc_plugin_update_actions (simple_action_group, dirty_only_active_actions, "sensitive", is_dirty); } diff --git a/gnucash/gnome/gnc-plugin-budget.c b/gnucash/gnome/gnc-plugin-budget.c index a39b570bb0..36a570251c 100644 --- a/gnucash/gnome/gnc-plugin-budget.c +++ b/gnucash/gnome/gnc-plugin-budget.c @@ -114,7 +114,7 @@ page_changed (GncMainWindow *window, GncPluginPage *page, gpointer user_data) gnc_main_window_get_action_group (window, PLUGIN_ACTIONS_NAME); if (qof_book_is_readonly (gnc_get_current_book())) - gnc_plugin_update_actionsb (simple_action_group, plugin_writeable_actions, + gnc_plugin_update_actions (simple_action_group, plugin_writeable_actions, "sensitive", FALSE); } diff --git a/gnucash/gnome/gnc-plugin-business.c b/gnucash/gnome/gnc-plugin-business.c index 3b1fb55e12..bf29abdf04 100644 --- a/gnucash/gnome/gnc-plugin-business.c +++ b/gnucash/gnome/gnc-plugin-business.c @@ -811,13 +811,13 @@ gnc_plugin_business_update_menus (GncPluginPage *plugin_page) 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_actionsb (simple_action_group, register_txn_actions, + gnc_plugin_update_actions (simple_action_group, register_txn_actions, "sensitive", is_txn_register && !is_bus_txn && !is_bus_doc); - gnc_plugin_update_actionsb (simple_action_group, register_txn_actions, + gnc_plugin_update_actions (simple_action_group, register_txn_actions, "visible", is_txn_register && !is_bus_txn && !is_bus_doc); - gnc_plugin_update_actionsb (simple_action_group, register_bus_txn_actions, + gnc_plugin_update_actions (simple_action_group, register_bus_txn_actions, "sensitive", is_txn_register && is_bus_txn && !is_bus_doc); - gnc_plugin_update_actionsb (simple_action_group, register_bus_txn_actions, + gnc_plugin_update_actions (simple_action_group, register_bus_txn_actions, "visible", is_txn_register && is_bus_txn && !is_bus_doc); } @@ -955,7 +955,7 @@ update_inactive_actions (GncPluginPage *plugin_page) g_return_if_fail (G_IS_SIMPLE_ACTION_GROUP(simple_action_group)); /* Set the action's sensitivity */ - gnc_plugin_update_actionsb (simple_action_group, readonly_inactive_actions, + gnc_plugin_update_actions (simple_action_group, readonly_inactive_actions, "sensitive", is_readwrite); } diff --git a/gnucash/gnome/gnc-plugin-page-account-tree.c b/gnucash/gnome/gnc-plugin-page-account-tree.c index 6c6b5f10ab..3723a3c26a 100644 --- a/gnucash/gnome/gnc-plugin-page-account-tree.c +++ b/gnucash/gnome/gnc-plugin-page-account-tree.c @@ -905,16 +905,17 @@ update_inactive_actions (GncPluginPage *plugin_page) g_return_if_fail (G_IS_SIMPLE_ACTION_GROUP (simple_action_group)); /* Set the action's sensitivity */ - gnc_plugin_update_actionsb (simple_action_group, readonly_inactive_actions, + gnc_plugin_update_actions (simple_action_group, readonly_inactive_actions, "sensitive", allow_write); - gnc_plugin_update_actionsb (simple_action_group, actions_requiring_account_rw, + gnc_plugin_update_actions (simple_action_group, actions_requiring_account_rw, "sensitive", allow_write && has_account); - gnc_plugin_update_actionsb (simple_action_group, actions_requiring_account_always, + gnc_plugin_update_actions (simple_action_group, actions_requiring_account_always, "sensitive", has_account); - gnc_plugin_update_actionsb (simple_action_group, actions_requiring_subaccounts_rw, + gnc_plugin_update_actions (simple_action_group, actions_requiring_subaccounts_rw, "sensitive", allow_write && subaccounts); - gnc_plugin_update_actionsb (simple_action_group, actions_requiring_priced_account, + gnc_plugin_update_actions (simple_action_group, actions_requiring_priced_account, "sensitive", account && xaccAccountIsPriced (account)); + g_signal_emit (plugin_page, plugin_page_signals[ACCOUNT_SELECTED], 0, account); } diff --git a/gnucash/gnome/gnc-plugin-page-budget.c b/gnucash/gnome/gnc-plugin-page-budget.c index 33e8c995cc..a901c6ff2f 100644 --- a/gnucash/gnome/gnc-plugin-page-budget.c +++ b/gnucash/gnome/gnc-plugin-page-budget.c @@ -376,7 +376,7 @@ gnc_plugin_page_budget_init (GncPluginPageBudget *plugin_page) plugin_page); if (qof_book_is_readonly (gnc_get_current_book())) - gnc_plugin_update_actionsb (simple_action_group, writeable_actions, + gnc_plugin_update_actions (simple_action_group, writeable_actions, "sensitive", FALSE); /* Visible types */ @@ -755,7 +755,7 @@ gppb_selection_changed_cb (GtkTreeSelection *selection, } simple_action_group = gnc_plugin_page_get_action_group (GNC_PLUGIN_PAGE(page)); - gnc_plugin_update_actionsb (simple_action_group, actions_requiring_account, + gnc_plugin_update_actions (simple_action_group, actions_requiring_account, "sensitive", sensitive); } #endif diff --git a/gnucash/gnome/gnc-plugin-page-invoice.c b/gnucash/gnome/gnc-plugin-page-invoice.c index 33518ceaab..a9f6179a71 100644 --- a/gnucash/gnome/gnc-plugin-page-invoice.c +++ b/gnucash/gnome/gnc-plugin-page-invoice.c @@ -765,13 +765,13 @@ gnc_plugin_page_invoice_update_menus (GncPluginPage *page, gboolean is_posted, g g_simple_action_set_enabled (G_SIMPLE_ACTION(action), TRUE); simple_action_group = gnc_plugin_page_get_action_groupb (page); - gnc_plugin_update_actionsb (simple_action_group, posted_actions, + gnc_plugin_update_actions (simple_action_group, posted_actions, "sensitive", is_posted); - gnc_plugin_update_actionsb (simple_action_group, unposted_actions, + gnc_plugin_update_actions (simple_action_group, unposted_actions, "sensitive", !is_posted); - gnc_plugin_update_actionsb (simple_action_group, can_unpost_actions, + gnc_plugin_update_actions (simple_action_group, can_unpost_actions, "sensitive", can_unpost); - gnc_plugin_update_actionsb (simple_action_group, invoice_book_readwrite_actions, + gnc_plugin_update_actions (simple_action_group, invoice_book_readwrite_actions, "sensitive", !is_readonly); /* update the action labels and tooltips */ diff --git a/gnucash/gnome/gnc-plugin-page-owner-tree.c b/gnucash/gnome/gnc-plugin-page-owner-tree.c index 8c81e7eea1..501321b691 100644 --- a/gnucash/gnome/gnc-plugin-page-owner-tree.c +++ b/gnucash/gnome/gnc-plugin-page-owner-tree.c @@ -522,7 +522,7 @@ update_inactive_actions(GncPluginPage *plugin_page) g_return_if_fail (G_IS_SIMPLE_ACTION_GROUP(simple_action_group)); /* Set the action's sensitivity */ - gnc_plugin_update_actionsb (simple_action_group, readonly_inactive_actions, + gnc_plugin_update_actions (simple_action_group, readonly_inactive_actions, "sensitive", is_sensitive); } @@ -934,9 +934,9 @@ gnc_plugin_page_owner_tree_selection_changed_cb (GtkTreeSelection *selection, } simple_action_group = gnc_plugin_page_get_action_groupb (GNC_PLUGIN_PAGE(page)); - gnc_plugin_update_actionsb (simple_action_group, actions_requiring_owner_always, + gnc_plugin_update_actions (simple_action_group, actions_requiring_owner_always, "sensitive", sensitive); - gnc_plugin_update_actionsb (simple_action_group, actions_requiring_owner_rw, + gnc_plugin_update_actions (simple_action_group, actions_requiring_owner_rw, "sensitive", sensitive && is_readwrite); g_signal_emit (page, plugin_page_signals[OWNER_SELECTED], 0, owner); } diff --git a/gnucash/gnome/gnc-plugin-page-register.c b/gnucash/gnome/gnc-plugin-page-register.c index 527be7b13f..ed2b434c82 100644 --- a/gnucash/gnome/gnc-plugin-page-register.c +++ b/gnucash/gnome/gnc-plugin-page-register.c @@ -1104,13 +1104,13 @@ gnc_plugin_page_register_ui_update (gpointer various, account = gnc_plugin_page_register_get_account (page); - gnc_plugin_update_actionsb (gnc_plugin_page_get_action_groupb (GNC_PLUGIN_PAGE(page)), - actions_requiring_account, "sensitive", - !read_only_reg && account != NULL); + gnc_plugin_update_actions (gnc_plugin_page_get_action_groupb (GNC_PLUGIN_PAGE(page)), + actions_requiring_account, "sensitive", + !read_only_reg && account != NULL); - gnc_plugin_update_actionsb (gnc_plugin_page_get_action_groupb (GNC_PLUGIN_PAGE(page)), - actions_requiring_priced_account, "sensitive", - account && xaccAccountIsPriced (account)); + gnc_plugin_update_actions (gnc_plugin_page_get_action_groupb (GNC_PLUGIN_PAGE(page)), + actions_requiring_priced_account, "sensitive", + account && xaccAccountIsPriced (account)); /* Set available actions based on read only */ trans = gnc_split_register_get_current_trans (reg); @@ -1299,10 +1299,10 @@ gnc_plugin_page_register_ui_initial_state (GncPluginPageRegister* page) simple_action_group = gnc_plugin_page_get_action_groupb (GNC_PLUGIN_PAGE(page)); g_return_if_fail (G_IS_SIMPLE_ACTION_GROUP(simple_action_group)); - gnc_plugin_update_actionsb (simple_action_group, actions_requiring_account, + gnc_plugin_update_actions (simple_action_group, actions_requiring_account, "sensitive", is_readwrite && account != NULL); - gnc_plugin_update_actionsb (simple_action_group, actions_requiring_priced_account, + gnc_plugin_update_actions (simple_action_group, actions_requiring_priced_account, "visible", account && gnc_prefs_is_extra_enabled () && xaccAccountIsPriced (account)); diff --git a/gnucash/gnome/gnc-plugin-page-report.cpp b/gnucash/gnome/gnc-plugin-page-report.cpp index 6d9e17a93b..b34d0168e3 100644 --- a/gnucash/gnome/gnc-plugin-page-report.cpp +++ b/gnucash/gnome/gnc-plugin-page-report.cpp @@ -1385,8 +1385,8 @@ gnc_plugin_page_report_constr_init (GncPluginPageReport *plugin_page, gint repor num_report_actions, plugin_page); - gnc_plugin_update_actionsb (simple_action_group, initially_insensitive_actions, - "sensitive", FALSE); + gnc_plugin_update_actions (simple_action_group, initially_insensitive_actions, + "sensitive", FALSE); } GncPluginPage* diff --git a/gnucash/import-export/aqb/gnc-plugin-aqbanking.c b/gnucash/import-export/aqb/gnc-plugin-aqbanking.c index 8ff7ade8b3..7fc2caeaae 100644 --- a/gnucash/import-export/aqb/gnc-plugin-aqbanking.c +++ b/gnucash/import-export/aqb/gnc-plugin-aqbanking.c @@ -280,8 +280,8 @@ static void update_inactive_actions(GncPluginPage *plugin_page) g_return_if_fail (G_IS_SIMPLE_ACTION_GROUP(simple_action_group)); /* Set the action's sensitivity */ - gnc_plugin_update_actionsb (simple_action_group, readonly_inactive_actions, - "sensitive", is_readwrite); + gnc_plugin_update_actions (simple_action_group, readonly_inactive_actions, + "sensitive", is_readwrite); } @@ -330,21 +330,21 @@ gnc_plugin_ab_account_selected (GncPluginPage *plugin_page, Account *account, bankcode = gnc_ab_get_account_bankcode(account); accountid = gnc_ab_get_account_accountid(account); - gnc_plugin_update_actionsb (simple_action_group, need_account_actions, + gnc_plugin_update_actions (simple_action_group, need_account_actions, "sensitive", (account && bankcode && *bankcode && accountid && *accountid)); gnc_main_window_menu_item_vis_by_action (window, need_account_actions, TRUE); #if (AQBANKING_VERSION_INT < 60400) - gnc_plugin_update_actionsb (simple_action_group, inactive_account_actions, + gnc_plugin_update_actions (simple_action_group, inactive_account_actions, "sensitive", FALSE); gnc_main_window_menu_item_vis_by_action (window, inactive_account_actions, FALSE); #endif } else { - gnc_plugin_update_actionsb (simple_action_group, need_account_actions, + gnc_plugin_update_actions (simple_action_group, need_account_actions, "sensitive", FALSE); gnc_main_window_menu_item_vis_by_action (window, need_account_actions, FALSE); } From 078d7875d3aef5246dd5c8a6d47154bc964d7f3b Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Fri, 28 Oct 2022 16:36:51 +0100 Subject: [PATCH 27/77] Change all references to plugin_class->actionsb Change all references to plugin_class->actionsb and n_actionsb to plugin_class->actions and n_actions --- gnucash/gnome-utils/gnc-plugin-file-history.c | 4 ++-- gnucash/gnome-utils/gnc-plugin-menu-additions.c | 4 ++-- gnucash/gnome-utils/gnc-plugin.c | 2 +- gnucash/gnome-utils/gnc-plugin.h | 8 ++------ gnucash/gnome/gnc-plugin-account-tree.c | 4 ++-- gnucash/gnome/gnc-plugin-basic-commands.c | 4 ++-- gnucash/gnome/gnc-plugin-budget.c | 4 ++-- gnucash/gnome/gnc-plugin-business.c | 6 +++--- gnucash/gnome/gnc-plugin-register.c | 4 ++-- gnucash/gnome/gnc-plugin-report-system.c | 4 ++-- gnucash/import-export/aqb/gnc-plugin-aqbanking.c | 4 ++-- gnucash/import-export/bi-import/gnc-plugin-bi-import.c | 6 +++--- gnucash/import-export/csv-exp/gnc-plugin-csv-export.c | 4 ++-- gnucash/import-export/csv-imp/gnc-plugin-csv-import.c | 4 ++-- .../customer-import/gnc-plugin-customer-import.c | 4 ++-- gnucash/import-export/log-replay/gnc-plugin-log-replay.c | 4 ++-- gnucash/import-export/ofx/gnc-plugin-ofx.c | 4 ++-- gnucash/import-export/qif-imp/gnc-plugin-qif-import.c | 4 ++-- libgnucash/gnc-module/example/gnc-plugin.example.c | 4 ++-- 19 files changed, 39 insertions(+), 43 deletions(-) diff --git a/gnucash/gnome-utils/gnc-plugin-file-history.c b/gnucash/gnome-utils/gnc-plugin-file-history.c index b42726ed85..3116ce5794 100644 --- a/gnucash/gnome-utils/gnc-plugin-file-history.c +++ b/gnucash/gnome-utils/gnc-plugin-file-history.c @@ -575,8 +575,8 @@ gnc_plugin_file_history_class_init (GncPluginFileHistoryClass *klass) /* widget addition/removal */ plugin_class->actions_name = PLUGIN_ACTIONS_NAME; - plugin_class->actionsb = gnc_plugin_actions; - plugin_class->n_actionsb = gnc_plugin_n_actions; + plugin_class->actions = gnc_plugin_actions; + plugin_class->n_actions = gnc_plugin_n_actions; plugin_class->ui_filename = PLUGIN_UI_FILENAME; plugin_class->ui_updates = gnc_plugin_load_ui_items; } diff --git a/gnucash/gnome-utils/gnc-plugin-menu-additions.c b/gnucash/gnome-utils/gnc-plugin-menu-additions.c index 4cca8b300c..b5303126d1 100644 --- a/gnucash/gnome-utils/gnc-plugin-menu-additions.c +++ b/gnucash/gnome-utils/gnc-plugin-menu-additions.c @@ -120,8 +120,8 @@ gnc_plugin_menu_additions_class_init (GncPluginMenuAdditionsClass *klass) plugin_class->add_to_window = gnc_plugin_menu_additions_add_to_window; plugin_class->remove_from_window = gnc_plugin_menu_additions_remove_from_window; plugin_class->actions_name = PLUGIN_ACTIONS_NAME; - plugin_class->actionsb = gnc_plugin_actions; - plugin_class->n_actionsb = gnc_plugin_n_actions; + plugin_class->actions = gnc_plugin_actions; + plugin_class->n_actions = gnc_plugin_n_actions; } static void diff --git a/gnucash/gnome-utils/gnc-plugin.c b/gnucash/gnome-utils/gnc-plugin.c index 2c103d894d..0229eca6a0 100644 --- a/gnucash/gnome-utils/gnc-plugin.c +++ b/gnucash/gnome-utils/gnc-plugin.c @@ -146,7 +146,7 @@ gnc_plugin_add_to_window (GncPlugin *plugin, DEBUG ("%s: %d actions to merge with gui from %s", klass->actions_name, klass->n_actions, klass->ui_filename); gnc_main_window_merge_actions (window, klass->actions_name, - klass->actionsb, klass->n_actionsb, + klass->actions, klass->n_actions, klass->display_items, klass->n_display_items, klass->ui_updates, klass->ui_filename, plugin); diff --git a/gnucash/gnome-utils/gnc-plugin.h b/gnucash/gnome-utils/gnc-plugin.h index 3e91d7f8fa..eab3e421c8 100644 --- a/gnucash/gnome-utils/gnc-plugin.h +++ b/gnucash/gnome-utils/gnc-plugin.h @@ -119,9 +119,9 @@ typedef struct const gchar *actions_name; /** An array of actions that should automatically be added to * any GnuCash "main" content window that is opened. */ - GActionEntry *actionsb; //FIXMEb added + GActionEntry *actions; //FIXMEb added /** The number of actions in the actions array. */ - guint n_actionsb; //FIXMEb added + guint n_actions; //FIXMEb added /** An array of display items (menu / toolbar entries) */ GncDisplayItem *display_items; //FIXMEb added @@ -131,10 +131,6 @@ typedef struct /** An array of ui updates for the menu model */ const gchar **ui_updates; //FIXMEb added - - GtkActionEntry *actions; - /** The number of actions in the actions array. */ - guint n_actions; /** The relative name of the XML file describing the * menu/toolbar action items. */ const gchar *ui_filename; diff --git a/gnucash/gnome/gnc-plugin-account-tree.c b/gnucash/gnome/gnc-plugin-account-tree.c index 4f392a1894..b9a78b67e5 100644 --- a/gnucash/gnome/gnc-plugin-account-tree.c +++ b/gnucash/gnome/gnc-plugin-account-tree.c @@ -120,8 +120,8 @@ gnc_plugin_account_tree_class_init (GncPluginAccountTreeClass *klass) /* widget addition/removal */ plugin_class->actions_name = PLUGIN_ACTIONS_NAME; - plugin_class->actionsb = gnc_plugin_actions; - plugin_class->n_actionsb = gnc_plugin_n_actions; + plugin_class->actions = gnc_plugin_actions; + plugin_class->n_actions = gnc_plugin_n_actions; plugin_class->ui_filename = PLUGIN_UI_FILENAME; plugin_class->ui_updates = gnc_plugin_load_ui_items; } diff --git a/gnucash/gnome/gnc-plugin-basic-commands.c b/gnucash/gnome/gnc-plugin-basic-commands.c index d4e6cff6fe..8d1ba7bfeb 100644 --- a/gnucash/gnome/gnc-plugin-basic-commands.c +++ b/gnucash/gnome/gnc-plugin-basic-commands.c @@ -301,8 +301,8 @@ gnc_plugin_basic_commands_class_init (GncPluginBasicCommandsClass *klass) /* widget addition/removal */ plugin_class->actions_name = PLUGIN_ACTIONS_NAME; - plugin_class->actionsb = gnc_plugin_actions; - plugin_class->n_actionsb = gnc_plugin_n_actions; + plugin_class->actions = gnc_plugin_actions; + plugin_class->n_actions = gnc_plugin_n_actions; plugin_class->ui_filename = PLUGIN_UI_FILENAME; plugin_class->ui_updates = gnc_plugin_load_ui_items; } diff --git a/gnucash/gnome/gnc-plugin-budget.c b/gnucash/gnome/gnc-plugin-budget.c index 36a570251c..5bf1192399 100644 --- a/gnucash/gnome/gnc-plugin-budget.c +++ b/gnucash/gnome/gnc-plugin-budget.c @@ -144,8 +144,8 @@ gnc_plugin_budget_class_init (GncPluginBudgetClass *klass) plugin_class->plugin_name = GNC_PLUGIN_BUDGET_NAME; plugin_class->actions_name = PLUGIN_ACTIONS_NAME; - plugin_class->actionsb = gnc_plugin_actions; - plugin_class->n_actionsb = gnc_plugin_n_actions; + plugin_class->actions = gnc_plugin_actions; + plugin_class->n_actions = gnc_plugin_n_actions; plugin_class->ui_filename = PLUGIN_UI_FILENAME; plugin_class->ui_updates = gnc_plugin_load_ui_items; plugin_class->add_to_window = add_to_window; diff --git a/gnucash/gnome/gnc-plugin-business.c b/gnucash/gnome/gnc-plugin-business.c index bf29abdf04..af2f316e17 100644 --- a/gnucash/gnome/gnc-plugin-business.c +++ b/gnucash/gnome/gnc-plugin-business.c @@ -221,10 +221,10 @@ gnc_plugin_business_class_init (GncPluginBusinessClass *klass) /* widget addition/removal */ plugin_class->actions_name = PLUGIN_ACTIONS_NAME; - plugin_class->actionsb = gnc_plugin_actions; - plugin_class->n_actionsb = gnc_plugin_n_actions; + plugin_class->actions = gnc_plugin_actions; + plugin_class->n_actions = gnc_plugin_n_actions; plugin_class->ui_filename = PLUGIN_UI_FILENAME; - plugin_class->ui_updates = gnc_plugin_load_ui_items; + plugin_class->ui_updates = gnc_plugin_load_ui_items; } static void diff --git a/gnucash/gnome/gnc-plugin-register.c b/gnucash/gnome/gnc-plugin-register.c index bb0c580e91..9e0b5c715b 100644 --- a/gnucash/gnome/gnc-plugin-register.c +++ b/gnucash/gnome/gnc-plugin-register.c @@ -138,8 +138,8 @@ gnc_plugin_register_class_init (GncPluginRegisterClass *klass) /* widget addition/removal */ plugin_class->actions_name = PLUGIN_ACTIONS_NAME; - plugin_class->actionsb = gnc_plugin_actions; - plugin_class->n_actionsb = gnc_plugin_n_actions; + plugin_class->actions = gnc_plugin_actions; + plugin_class->n_actions = gnc_plugin_n_actions; plugin_class->ui_filename = PLUGIN_UI_FILENAME; plugin_class->ui_updates = gnc_plugin_load_ui_items; } diff --git a/gnucash/gnome/gnc-plugin-report-system.c b/gnucash/gnome/gnc-plugin-report-system.c index e9d55b61f4..c42a9f6472 100644 --- a/gnucash/gnome/gnc-plugin-report-system.c +++ b/gnucash/gnome/gnc-plugin-report-system.c @@ -94,8 +94,8 @@ gnc_plugin_report_system_class_init (GncPluginReportSystemClass *klass) /* widget addition/removal */ plugin_class->actions_name = PLUGIN_ACTIONS_NAME; - plugin_class->actionsb = gnc_plugin_actions; - plugin_class->n_actionsb = gnc_plugin_n_actions; + plugin_class->actions = gnc_plugin_actions; + plugin_class->n_actions = gnc_plugin_n_actions; plugin_class->ui_filename = PLUGIN_UI_FILENAME; plugin_class->ui_updates = gnc_plugin_load_ui_items; } diff --git a/gnucash/import-export/aqb/gnc-plugin-aqbanking.c b/gnucash/import-export/aqb/gnc-plugin-aqbanking.c index 7fc2caeaae..1d195832b5 100644 --- a/gnucash/import-export/aqb/gnc-plugin-aqbanking.c +++ b/gnucash/import-export/aqb/gnc-plugin-aqbanking.c @@ -167,8 +167,8 @@ gnc_plugin_aqbanking_class_init(GncPluginAqBankingClass *klass) /* widget addition/removal */ plugin_class->actions_name = PLUGIN_ACTIONS_NAME; - plugin_class->actionsb = gnc_plugin_actions; - plugin_class->n_actionsb = gnc_plugin_n_actions; + plugin_class->actions = gnc_plugin_actions; + plugin_class->n_actions = gnc_plugin_n_actions; plugin_class->ui_filename = PLUGIN_UI_FILENAME; plugin_class->ui_updates = gnc_plugin_load_ui_items; plugin_class->add_to_window = gnc_plugin_aqbanking_add_to_window; diff --git a/gnucash/import-export/bi-import/gnc-plugin-bi-import.c b/gnucash/import-export/bi-import/gnc-plugin-bi-import.c index dd8c60e5ba..88e1d2192b 100644 --- a/gnucash/import-export/bi-import/gnc-plugin-bi-import.c +++ b/gnucash/import-export/bi-import/gnc-plugin-bi-import.c @@ -90,10 +90,10 @@ gnc_plugin_bi_import_class_init (GncPluginbi_importClass *klass) /* widget addition/removal */ plugin_class->actions_name = PLUGIN_ACTIONS_NAME; - plugin_class->actionsb = gnc_plugin_actions; - plugin_class->n_actionsb = gnc_plugin_n_actions; + plugin_class->actions = gnc_plugin_actions; + plugin_class->n_actions = gnc_plugin_n_actions; plugin_class->ui_filename = PLUGIN_UI_FILENAME; - plugin_class->ui_updates = gnc_plugin_load_ui_items; + plugin_class->ui_updates = gnc_plugin_load_ui_items; } static void diff --git a/gnucash/import-export/csv-exp/gnc-plugin-csv-export.c b/gnucash/import-export/csv-exp/gnc-plugin-csv-export.c index 85666ca9a8..37e83566f8 100644 --- a/gnucash/import-export/csv-exp/gnc-plugin-csv-export.c +++ b/gnucash/import-export/csv-exp/gnc-plugin-csv-export.c @@ -94,8 +94,8 @@ gnc_plugin_csv_export_class_init (GncPluginCsvExportClass *klass) /* widget addition/removal */ plugin_class->actions_name = PLUGIN_ACTIONS_NAME; - plugin_class->actionsb = gnc_plugin_actions; - plugin_class->n_actionsb = gnc_plugin_n_actions; + plugin_class->actions = gnc_plugin_actions; + plugin_class->n_actions = gnc_plugin_n_actions; plugin_class->ui_filename = PLUGIN_UI_FILENAME; plugin_class->ui_updates = gnc_plugin_load_ui_items; } diff --git a/gnucash/import-export/csv-imp/gnc-plugin-csv-import.c b/gnucash/import-export/csv-imp/gnc-plugin-csv-import.c index c2a08e8993..6a3afdad14 100644 --- a/gnucash/import-export/csv-imp/gnc-plugin-csv-import.c +++ b/gnucash/import-export/csv-imp/gnc-plugin-csv-import.c @@ -93,8 +93,8 @@ gnc_plugin_csv_import_class_init (GncPluginCsvImportClass *klass) /* widget addition/removal */ plugin_class->actions_name = PLUGIN_ACTIONS_NAME; - plugin_class->actionsb = gnc_plugin_actions; - plugin_class->n_actionsb = gnc_plugin_n_actions; + plugin_class->actions = gnc_plugin_actions; + plugin_class->n_actions = gnc_plugin_n_actions; plugin_class->ui_filename = PLUGIN_UI_FILENAME; plugin_class->ui_updates = gnc_plugin_load_ui_items; } diff --git a/gnucash/import-export/customer-import/gnc-plugin-customer-import.c b/gnucash/import-export/customer-import/gnc-plugin-customer-import.c index b1886b7a74..e78794031f 100644 --- a/gnucash/import-export/customer-import/gnc-plugin-customer-import.c +++ b/gnucash/import-export/customer-import/gnc-plugin-customer-import.c @@ -90,8 +90,8 @@ gnc_plugin_customer_import_class_init (GncPlugincustomer_importClass *klass) /* widget addition/removal */ plugin_class->actions_name = PLUGIN_ACTIONS_NAME; - plugin_class->actionsb = gnc_plugin_actions; - plugin_class->n_actionsb = gnc_plugin_n_actions; + plugin_class->actions = gnc_plugin_actions; + plugin_class->n_actions = gnc_plugin_n_actions; plugin_class->ui_filename = PLUGIN_UI_FILENAME; plugin_class->ui_updates = gnc_plugin_load_ui_items; } diff --git a/gnucash/import-export/log-replay/gnc-plugin-log-replay.c b/gnucash/import-export/log-replay/gnc-plugin-log-replay.c index 5e63e59b8c..526a3e1600 100644 --- a/gnucash/import-export/log-replay/gnc-plugin-log-replay.c +++ b/gnucash/import-export/log-replay/gnc-plugin-log-replay.c @@ -89,8 +89,8 @@ gnc_plugin_log_replay_class_init (GncPluginLogreplayClass *klass) /* widget addition/removal */ plugin_class->actions_name = PLUGIN_ACTIONS_NAME; - plugin_class->actionsb = gnc_plugin_actions; - plugin_class->n_actionsb = gnc_plugin_n_actions; + plugin_class->actions = gnc_plugin_actions; + plugin_class->n_actions = gnc_plugin_n_actions; plugin_class->ui_filename = PLUGIN_UI_FILENAME; plugin_class->ui_updates = gnc_plugin_load_ui_items; } diff --git a/gnucash/import-export/ofx/gnc-plugin-ofx.c b/gnucash/import-export/ofx/gnc-plugin-ofx.c index 61cf493026..4d72b8d978 100644 --- a/gnucash/import-export/ofx/gnc-plugin-ofx.c +++ b/gnucash/import-export/ofx/gnc-plugin-ofx.c @@ -87,8 +87,8 @@ gnc_plugin_ofx_class_init (GncPluginOfxClass *klass) /* widget addition/removal */ plugin_class->actions_name = PLUGIN_ACTIONS_NAME; - plugin_class->actionsb = gnc_plugin_actions; - plugin_class->n_actionsb = gnc_plugin_n_actions; + plugin_class->actions = gnc_plugin_actions; + plugin_class->n_actions = gnc_plugin_n_actions; plugin_class->ui_filename = PLUGIN_UI_FILENAME; plugin_class->ui_updates = gnc_plugin_load_ui_items; } diff --git a/gnucash/import-export/qif-imp/gnc-plugin-qif-import.c b/gnucash/import-export/qif-imp/gnc-plugin-qif-import.c index 3718286272..451cbf9edb 100644 --- a/gnucash/import-export/qif-imp/gnc-plugin-qif-import.c +++ b/gnucash/import-export/qif-imp/gnc-plugin-qif-import.c @@ -89,8 +89,8 @@ gnc_plugin_qif_import_class_init (GncPluginQifImportClass *klass) /* widget addition/removal */ plugin_class->actions_name = PLUGIN_ACTIONS_NAME; - plugin_class->actionsb = gnc_plugin_actions; - plugin_class->n_actionsb = gnc_plugin_n_actions; + plugin_class->actions = gnc_plugin_actions; + plugin_class->n_actions = gnc_plugin_n_actions; plugin_class->ui_filename = PLUGIN_UI_FILENAME; plugin_class->ui_updates = gnc_plugin_load_ui_items; } diff --git a/libgnucash/gnc-module/example/gnc-plugin.example.c b/libgnucash/gnc-module/example/gnc-plugin.example.c index 3be4ce1174..491b305e8f 100644 --- a/libgnucash/gnc-module/example/gnc-plugin.example.c +++ b/libgnucash/gnc-module/example/gnc-plugin.example.c @@ -88,8 +88,8 @@ gnc_plugin_example_class_init (GncPluginexampleClass *klass) /* widget addition/removal */ plugin_class->actions_name = PLUGIN_ACTIONS_NAME; - plugin_class->actionsb = gnc_plugin_actions; - plugin_class->n_actionsb = gnc_plugin_n_actions; + plugin_class->actions = gnc_plugin_actions; + plugin_class->n_actions = gnc_plugin_n_actions; plugin_class->display_items = gnc_plugin_display_items; plugin_class->n_display_items = gnc_plugin_n_display_items; plugin_class->ui_filename = PLUGIN_UI_FILENAME; From cc0094da22fc023ccaefdd8ccab32b8cfea51e87 Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Fri, 28 Oct 2022 16:37:28 +0100 Subject: [PATCH 28/77] Replace gnc_plugin_page_get/create_action_group Replace gnc_plugin_page_get/create_action_group with the new versions that deal with GSimpleActionGroup's --- gnucash/gnome-utils/gnc-main-window.cpp | 2 +- gnucash/gnome-utils/gnc-plugin-page.c | 30 ++------------------ gnucash/gnome-utils/gnc-plugin-page.h | 18 ++++++------ gnucash/gnome/dialog-sx-editor.c | 2 +- gnucash/gnome/gnc-plugin-page-account-tree.c | 4 +-- gnucash/gnome/gnc-plugin-page-budget.c | 2 +- gnucash/gnome/gnc-plugin-page-invoice.c | 4 +-- gnucash/gnome/gnc-plugin-page-owner-tree.c | 6 ++-- gnucash/gnome/gnc-plugin-page-register.c | 8 +++--- gnucash/gnome/gnc-plugin-page-report.cpp | 2 +- gnucash/gnome/gnc-plugin-page-sx-list.c | 2 +- 11 files changed, 26 insertions(+), 54 deletions(-) diff --git a/gnucash/gnome-utils/gnc-main-window.cpp b/gnucash/gnome-utils/gnc-main-window.cpp index 897bf3bf53..c38f94fc4f 100644 --- a/gnucash/gnome-utils/gnc-main-window.cpp +++ b/gnucash/gnome-utils/gnc-main-window.cpp @@ -3992,7 +3992,7 @@ gnc_main_window_update_menu (GncMainWindow *window, GncPluginPage *page, return; gtk_widget_insert_action_group (GTK_WIDGET(window), gnc_plugin_page_get_simple_action_group_name (page), - G_ACTION_GROUP(gnc_plugin_page_get_action_groupb (page))); + G_ACTION_GROUP(gnc_plugin_page_get_action_group (page))); if ((g_strcmp0 (priv->previous_plugin_page_name, plugin_page_actions_group_name) == 0) && diff --git a/gnucash/gnome-utils/gnc-plugin-page.c b/gnucash/gnome-utils/gnc-plugin-page.c index 3cd3f729be..978978abc3 100644 --- a/gnucash/gnome-utils/gnc-plugin-page.c +++ b/gnucash/gnome-utils/gnc-plugin-page.c @@ -1187,20 +1187,8 @@ gnc_plugin_page_set_menu_qualifier (GncPluginPage *page, priv->menu_qualifier = menu_qualifier; } - -/* Retrieve the GtkActionGroup object associated with this page. */ -GtkActionGroup * -gnc_plugin_page_get_action_group(GncPluginPage *page) -{ - GncPluginPagePrivate *priv; - - g_return_val_if_fail (GNC_IS_PLUGIN_PAGE(page), NULL); - - priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page); - return priv->action_group; -} GSimpleActionGroup * -gnc_plugin_page_get_action_groupb (GncPluginPage *page) +gnc_plugin_page_get_action_group (GncPluginPage *page) { GncPluginPagePrivate *priv; @@ -1210,22 +1198,8 @@ gnc_plugin_page_get_action_groupb (GncPluginPage *page) return priv->simple_action_group; } -/* Create the GtkActionGroup object associated with this page. */ -GtkActionGroup * -gnc_plugin_page_create_action_group (GncPluginPage *page, const gchar *group_name) -{ - GncPluginPagePrivate *priv; - GtkActionGroup *group; - - priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page); - group = gtk_action_group_new (group_name); - gtk_action_group_set_translation_domain (group, PROJECT_NAME); - priv->action_group = group; - return group; -} - GSimpleActionGroup * -gnc_plugin_page_create_action_groupb (GncPluginPage *page, const gchar *group_name) +gnc_plugin_page_create_action_group (GncPluginPage *page, const gchar *group_name) { GncPluginPagePrivate *priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page); diff --git a/gnucash/gnome-utils/gnc-plugin-page.h b/gnucash/gnome-utils/gnc-plugin-page.h index 30a64ecf4b..bf079734b9 100644 --- a/gnucash/gnome-utils/gnc-plugin-page.h +++ b/gnucash/gnome-utils/gnc-plugin-page.h @@ -543,21 +543,20 @@ const gchar * gnc_plugin_page_get_menu_qualifier (GncPluginPage *page); //FIXMEb void gnc_plugin_page_set_menu_qualifier (GncPluginPage *page, const char *menu_qualifier); //FIXMEb added -/** Retrieve the GtkActionGroup object associated with this page. +/** Retrieve the GSimpleActionGroup object associated with this page. * * @param page The page whose menu/toolbar action group should be * retrieved. * - * @return A pointer to the GtkActionGroup object for this page. + * @return A pointer to the GSimpleActionGroup object for this page. */ -GtkActionGroup *gnc_plugin_page_get_action_group (GncPluginPage *page); -GSimpleActionGroup *gnc_plugin_page_get_action_groupb (GncPluginPage *page); //FIXMEb added +GSimpleActionGroup *gnc_plugin_page_get_action_group (GncPluginPage *page); //FIXMEb added GtkAccelGroup *gnc_plugin_page_get_accel_group (GncPluginPage *page); //FIXMEb added -/** Create the GtkActionGroup object associated with this page. +/** Create the GSimpleActionGroup object associated with this page. * * @param page The page whose menu/toolbar action group should be * created. @@ -566,13 +565,12 @@ GtkAccelGroup *gnc_plugin_page_get_accel_group (GncPluginPage *page); //FIXMEb a * name is used to associate key bindings with actions, so it should * be consistent across all pages of the same type. * - * @return A pointer to the newly created GtkActionGroup object for + * @return A pointer to the newly created GSimpleActionGroup object for * this page. */ -GtkActionGroup * gnc_plugin_page_create_action_group (GncPluginPage *page, - const gchar *group_name); -GSimpleActionGroup * gnc_plugin_page_create_action_groupb (GncPluginPage *page, - const gchar *group_name); //FIXMEb added +GSimpleActionGroup * gnc_plugin_page_create_action_group (GncPluginPage *page, + const gchar *group_name); //FIXMEb added + /** Retrieve a GtkAction object associated with this page. * * @param page The page whose menu/toolbar action group should be diff --git a/gnucash/gnome/dialog-sx-editor.c b/gnucash/gnome/dialog-sx-editor.c index d749b4f5ed..e11d96c6c3 100644 --- a/gnucash/gnome/dialog-sx-editor.c +++ b/gnucash/gnome/dialog-sx-editor.c @@ -1369,7 +1369,7 @@ schedXact_editor_create_ledger (GncSxEditorDialog *sxed) gtk_widget_insert_action_group (GTK_WIDGET(sxed->embed_window), gnc_plugin_page_get_simple_action_group_name (sxed->plugin_page), - G_ACTION_GROUP(gnc_plugin_page_get_action_groupb (sxed->plugin_page))); + G_ACTION_GROUP(gnc_plugin_page_get_action_group (sxed->plugin_page))); gnc_plugin_page_register_set_options (sxed->plugin_page, NUM_LEDGER_LINES_DEFAULT, FALSE); diff --git a/gnucash/gnome/gnc-plugin-page-account-tree.c b/gnucash/gnome/gnc-plugin-page-account-tree.c index 3723a3c26a..ecbf1a1566 100644 --- a/gnucash/gnome/gnc-plugin-page-account-tree.c +++ b/gnucash/gnome/gnc-plugin-page-account-tree.c @@ -522,7 +522,7 @@ gnc_plugin_page_account_tree_init (GncPluginPageAccountTree *plugin_page) } /* Create menu and toolbar information */ - simple_action_group = gnc_plugin_page_create_action_groupb (parent, "GncPluginPageAccountTreeActions"); + simple_action_group = gnc_plugin_page_create_action_group (parent, "GncPluginPageAccountTreeActions"); g_action_map_add_action_entries (G_ACTION_MAP(simple_action_group), gnc_plugin_page_account_tree_actions, gnc_plugin_page_account_tree_n_actions, @@ -901,7 +901,7 @@ update_inactive_actions (GncPluginPage *plugin_page) } /* Get the action group */ - simple_action_group = gnc_plugin_page_get_action_groupb (plugin_page); + simple_action_group = gnc_plugin_page_get_action_group (plugin_page); g_return_if_fail (G_IS_SIMPLE_ACTION_GROUP (simple_action_group)); /* Set the action's sensitivity */ diff --git a/gnucash/gnome/gnc-plugin-page-budget.c b/gnucash/gnome/gnc-plugin-page-budget.c index a901c6ff2f..cc739b7705 100644 --- a/gnucash/gnome/gnc-plugin-page-budget.c +++ b/gnucash/gnome/gnc-plugin-page-budget.c @@ -369,7 +369,7 @@ gnc_plugin_page_budget_init (GncPluginPageBudget *plugin_page) gnc_plugin_page_add_book (parent, gnc_get_current_book()); /* Create menu and toolbar information */ - simple_action_group = gnc_plugin_page_create_action_groupb (parent, "GncPluginPageBudgetActions"); + simple_action_group = gnc_plugin_page_create_action_group (parent, "GncPluginPageBudgetActions"); g_action_map_add_action_entries (G_ACTION_MAP(simple_action_group), gnc_plugin_page_budget_actions, gnc_plugin_page_budget_n_actions, diff --git a/gnucash/gnome/gnc-plugin-page-invoice.c b/gnucash/gnome/gnc-plugin-page-invoice.c index a9f6179a71..4496c72000 100644 --- a/gnucash/gnome/gnc-plugin-page-invoice.c +++ b/gnucash/gnome/gnc-plugin-page-invoice.c @@ -593,7 +593,7 @@ gnc_plugin_page_invoice_init (GncPluginPageInvoice *plugin_page) gnc_plugin_page_add_book (parent, gnc_get_current_book()); /* Create menu and toolbar information */ - simple_action_group = gnc_plugin_page_create_action_groupb (parent,"GncPluginPageInvoiceActions"); + simple_action_group = gnc_plugin_page_create_action_group (parent,"GncPluginPageInvoiceActions"); g_action_map_add_action_entries (G_ACTION_MAP(simple_action_group), gnc_plugin_page_invoice_actions, gnc_plugin_page_invoice_n_actions, @@ -764,7 +764,7 @@ gnc_plugin_page_invoice_update_menus (GncPluginPage *page, gboolean is_posted, g action = gnc_main_window_find_action (window, "FilePrintAction"); g_simple_action_set_enabled (G_SIMPLE_ACTION(action), TRUE); - simple_action_group = gnc_plugin_page_get_action_groupb (page); + simple_action_group = gnc_plugin_page_get_action_group (page); gnc_plugin_update_actions (simple_action_group, posted_actions, "sensitive", is_posted); gnc_plugin_update_actions (simple_action_group, unposted_actions, diff --git a/gnucash/gnome/gnc-plugin-page-owner-tree.c b/gnucash/gnome/gnc-plugin-page-owner-tree.c index 501321b691..add750aa02 100644 --- a/gnucash/gnome/gnc-plugin-page-owner-tree.c +++ b/gnucash/gnome/gnc-plugin-page-owner-tree.c @@ -477,7 +477,7 @@ gnc_plugin_page_owner_tree_init (GncPluginPageOwnerTree *plugin_page) gnc_plugin_page_add_book (parent, gnc_get_current_book()); /* Create menu and toolbar information */ - simple_action_group = gnc_plugin_page_create_action_groupb (parent, "GncPluginPageOwnerTreeActions"); + simple_action_group = gnc_plugin_page_create_action_group (parent, "GncPluginPageOwnerTreeActions"); g_action_map_add_action_entries (G_ACTION_MAP(simple_action_group), gnc_plugin_page_owner_tree_actions, gnc_plugin_page_owner_tree_n_actions, @@ -518,7 +518,7 @@ update_inactive_actions(GncPluginPage *plugin_page) g_return_if_fail(GNC_IS_PLUGIN_PAGE(plugin_page)); /* Get the action group */ - simple_action_group = gnc_plugin_page_get_action_groupb (plugin_page); + simple_action_group = gnc_plugin_page_get_action_group (plugin_page); g_return_if_fail (G_IS_SIMPLE_ACTION_GROUP(simple_action_group)); /* Set the action's sensitivity */ @@ -933,7 +933,7 @@ gnc_plugin_page_owner_tree_selection_changed_cb (GtkTreeSelection *selection, sensitive = (owner != NULL); } - simple_action_group = gnc_plugin_page_get_action_groupb (GNC_PLUGIN_PAGE(page)); + simple_action_group = gnc_plugin_page_get_action_group (GNC_PLUGIN_PAGE(page)); gnc_plugin_update_actions (simple_action_group, actions_requiring_owner_always, "sensitive", sensitive); gnc_plugin_update_actions (simple_action_group, actions_requiring_owner_rw, diff --git a/gnucash/gnome/gnc-plugin-page-register.c b/gnucash/gnome/gnc-plugin-page-register.c index ed2b434c82..829f2606f5 100644 --- a/gnucash/gnome/gnc-plugin-page-register.c +++ b/gnucash/gnome/gnc-plugin-page-register.c @@ -869,7 +869,7 @@ gnc_plugin_page_register_init (GncPluginPageRegister* plugin_page) NULL); /* Create menu and toolbar information */ - simple_action_group = gnc_plugin_page_create_action_groupb (parent, "GncPluginPageRegisterActions"); + simple_action_group = gnc_plugin_page_create_action_group (parent, "GncPluginPageRegisterActions"); g_action_map_add_action_entries (G_ACTION_MAP(simple_action_group), gnc_plugin_page_register_actions, gnc_plugin_page_register_n_actions, @@ -1104,11 +1104,11 @@ gnc_plugin_page_register_ui_update (gpointer various, account = gnc_plugin_page_register_get_account (page); - gnc_plugin_update_actions (gnc_plugin_page_get_action_groupb (GNC_PLUGIN_PAGE(page)), + gnc_plugin_update_actions (gnc_plugin_page_get_action_group (GNC_PLUGIN_PAGE(page)), actions_requiring_account, "sensitive", !read_only_reg && account != NULL); - gnc_plugin_update_actions (gnc_plugin_page_get_action_groupb (GNC_PLUGIN_PAGE(page)), + gnc_plugin_update_actions (gnc_plugin_page_get_action_group (GNC_PLUGIN_PAGE(page)), actions_requiring_priced_account, "sensitive", account && xaccAccountIsPriced (account)); @@ -1296,7 +1296,7 @@ gnc_plugin_page_register_ui_initial_state (GncPluginPageRegister* page) account = gnc_plugin_page_register_get_account (page); /* Get the action group */ - simple_action_group = gnc_plugin_page_get_action_groupb (GNC_PLUGIN_PAGE(page)); + simple_action_group = gnc_plugin_page_get_action_group (GNC_PLUGIN_PAGE(page)); g_return_if_fail (G_IS_SIMPLE_ACTION_GROUP(simple_action_group)); gnc_plugin_update_actions (simple_action_group, actions_requiring_account, diff --git a/gnucash/gnome/gnc-plugin-page-report.cpp b/gnucash/gnome/gnc-plugin-page-report.cpp index b34d0168e3..7a71b69194 100644 --- a/gnucash/gnome/gnc-plugin-page-report.cpp +++ b/gnucash/gnome/gnc-plugin-page-report.cpp @@ -1379,7 +1379,7 @@ gnc_plugin_page_report_constr_init (GncPluginPageReport *plugin_page, gint repor gnc_plugin_page_add_book (parent, gnc_get_current_book()); /* Create menu and toolbar information */ - simple_action_group = gnc_plugin_page_create_action_groupb (parent, "GncPluginPageReportActions"); + simple_action_group = gnc_plugin_page_create_action_group (parent, "GncPluginPageReportActions"); g_action_map_add_action_entries (G_ACTION_MAP(simple_action_group), report_actions, num_report_actions, diff --git a/gnucash/gnome/gnc-plugin-page-sx-list.c b/gnucash/gnome/gnc-plugin-page-sx-list.c index 7e77a36d63..55f2b6b40e 100644 --- a/gnucash/gnome/gnc-plugin-page-sx-list.c +++ b/gnucash/gnome/gnc-plugin-page-sx-list.c @@ -256,7 +256,7 @@ gnc_plugin_page_sx_list_init (GncPluginPageSxList *plugin_page) NULL); gnc_plugin_page_add_book (parent, gnc_get_current_book()); - simple_action_group = gnc_plugin_page_create_action_groupb (parent, "GncPluginPageSxListActions"); + simple_action_group = gnc_plugin_page_create_action_group (parent, "GncPluginPageSxListActions"); g_action_map_add_action_entries (G_ACTION_MAP(simple_action_group), gnc_plugin_page_sx_list_actions, gnc_plugin_page_sx_list_n_actions, From 17151a3e5e1d7fdf258201de18d967b65c859616 Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Sun, 30 Oct 2022 13:31:40 +0000 Subject: [PATCH 29/77] Remove remaining old ...ui.xml files --- gnucash/import-export/aqb/CMakeLists.txt | 9 -- gnucash/import-export/ofx/CMakeLists.txt | 9 +- .../import-export/ofx/gnc-plugin-ofx-ui.xml | 11 -- gnucash/ui/CMakeLists.txt | 28 ---- gnucash/ui/gnc-main-window-ui.xml | 145 ------------------ gnucash/ui/gnc-plugin-account-tree-ui.xml | 9 -- gnucash/ui/gnc-plugin-basic-commands-ui.xml | 82 ---------- gnucash/ui/gnc-plugin-bi-import-ui.xml | 11 -- gnucash/ui/gnc-plugin-budget-ui.xml | 15 -- gnucash/ui/gnc-plugin-business-ui.xml | 81 ---------- gnucash/ui/gnc-plugin-csv-export-ui.xml | 13 -- gnucash/ui/gnc-plugin-csv-import-ui.xml | 13 -- gnucash/ui/gnc-plugin-customer-import-ui.xml | 11 -- gnucash/ui/gnc-plugin-file-history-ui.xml | 19 --- gnucash/ui/gnc-plugin-log-replay-ui.xml | 11 -- .../ui/gnc-plugin-page-account-tree-ui.xml | 79 ---------- gnucash/ui/gnc-plugin-page-budget-ui.xml | 37 ----- gnucash/ui/gnc-plugin-page-invoice-ui.xml | 97 ------------ gnucash/ui/gnc-plugin-page-owner-tree-ui.xml | 61 -------- gnucash/ui/gnc-plugin-page-register-ui.xml | 119 -------------- gnucash/ui/gnc-plugin-page-report-ui.xml | 50 ------ gnucash/ui/gnc-plugin-page-sx-list-ui.xml | 20 --- gnucash/ui/gnc-plugin-page-sx-list2-ui.xml | 22 --- gnucash/ui/gnc-plugin-page-sxregister-ui.xml | 54 ------- gnucash/ui/gnc-plugin-qif-import-ui.xml | 12 -- gnucash/ui/gnc-plugin-register-ui.xml | 9 -- gnucash/ui/gnc-plugin-report-system-ui.xml | 9 -- gnucash/ui/gnc-sxed-to-create-window-ui.xml | 3 - gnucash/ui/gnc-sxed-window-ui-full.xml | 62 -------- gnucash/ui/gnc-sxed-window-ui.xml | 3 - gnucash/ui/gnc-windows-menu-ui-quartz.xml | 11 -- gnucash/ui/gnc-windows-menu-ui.xml | 21 --- 32 files changed, 1 insertion(+), 1135 deletions(-) delete mode 100644 gnucash/import-export/ofx/gnc-plugin-ofx-ui.xml delete mode 100644 gnucash/ui/gnc-main-window-ui.xml delete mode 100644 gnucash/ui/gnc-plugin-account-tree-ui.xml delete mode 100644 gnucash/ui/gnc-plugin-basic-commands-ui.xml delete mode 100644 gnucash/ui/gnc-plugin-bi-import-ui.xml delete mode 100644 gnucash/ui/gnc-plugin-budget-ui.xml delete mode 100644 gnucash/ui/gnc-plugin-business-ui.xml delete mode 100644 gnucash/ui/gnc-plugin-csv-export-ui.xml delete mode 100644 gnucash/ui/gnc-plugin-csv-import-ui.xml delete mode 100644 gnucash/ui/gnc-plugin-customer-import-ui.xml delete mode 100644 gnucash/ui/gnc-plugin-file-history-ui.xml delete mode 100644 gnucash/ui/gnc-plugin-log-replay-ui.xml delete mode 100644 gnucash/ui/gnc-plugin-page-account-tree-ui.xml delete mode 100644 gnucash/ui/gnc-plugin-page-budget-ui.xml delete mode 100644 gnucash/ui/gnc-plugin-page-invoice-ui.xml delete mode 100644 gnucash/ui/gnc-plugin-page-owner-tree-ui.xml delete mode 100644 gnucash/ui/gnc-plugin-page-register-ui.xml delete mode 100644 gnucash/ui/gnc-plugin-page-report-ui.xml delete mode 100644 gnucash/ui/gnc-plugin-page-sx-list-ui.xml delete mode 100644 gnucash/ui/gnc-plugin-page-sx-list2-ui.xml delete mode 100644 gnucash/ui/gnc-plugin-page-sxregister-ui.xml delete mode 100644 gnucash/ui/gnc-plugin-qif-import-ui.xml delete mode 100644 gnucash/ui/gnc-plugin-register-ui.xml delete mode 100644 gnucash/ui/gnc-plugin-report-system-ui.xml delete mode 100644 gnucash/ui/gnc-sxed-to-create-window-ui.xml delete mode 100644 gnucash/ui/gnc-sxed-window-ui-full.xml delete mode 100644 gnucash/ui/gnc-sxed-window-ui.xml delete mode 100644 gnucash/ui/gnc-windows-menu-ui-quartz.xml delete mode 100644 gnucash/ui/gnc-windows-menu-ui.xml diff --git a/gnucash/import-export/aqb/CMakeLists.txt b/gnucash/import-export/aqb/CMakeLists.txt index 8c36159d79..a275638fbd 100644 --- a/gnucash/import-export/aqb/CMakeLists.txt +++ b/gnucash/import-export/aqb/CMakeLists.txt @@ -41,8 +41,6 @@ set (aqbanking_noinst_HEADERS set(aqbanking_GLADE assistant-ab-initial.glade dialog-ab.glade dialog-ab-pref.glade) -set(aqbanking_UI gnc-plugin-aqbanking-ui.xml) - if(WITH_AQBANKING) add_library (gncmod-aqbanking ${aqbanking_SOURCES} @@ -84,15 +82,8 @@ endif() # No headers to install - install(FILES ${aqbanking_GLADE} DESTINATION ${CMAKE_INSTALL_DATADIR}/gnucash/gtkbuilder) - install(FILES ${aqbanking_UI} DESTINATION ${CMAKE_INSTALL_DATADIR}/gnucash/ui) - - foreach(ui_file ${aqbanking_UI}) - configure_file(${ui_file} ${DATADIR_BUILD}/gnucash/ui/${ui_file} COPYONLY) - endforeach() - foreach(glade_file ${aqbanking_GLADE}) configure_file(${glade_file} ${DATADIR_BUILD}/gnucash/gtkbuilder/${glade_file} COPYONLY) endforeach() diff --git a/gnucash/import-export/ofx/CMakeLists.txt b/gnucash/import-export/ofx/CMakeLists.txt index 1de28d8717..8a9a254602 100644 --- a/gnucash/import-export/ofx/CMakeLists.txt +++ b/gnucash/import-export/ofx/CMakeLists.txt @@ -15,8 +15,6 @@ set(ofx_noinst_HEADERS gnc-plugin-ofx.h ) -set(ofx_UI gnc-plugin-ofx-ui.xml) - if (WITH_OFX) add_library(gncmod-ofx ${ofx_SOURCES} ${ofx_noinst_HEADERS}) @@ -36,12 +34,7 @@ endif() ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/gnucash RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) - install(FILES ${ofx_UI} DESTINATION ${CMAKE_INSTALL_DATADIR}/gnucash/ui) - - foreach(ui_file ${ofx_UI}) - configure_file(${ui_file} ${DATADIR_BUILD}/gnucash/ui/${ui_file} COPYONLY) - endforeach() endif() -set_local_dist(ofx_DIST_local CMakeLists.txt ${ofx_SOURCES} ${ofx_noinst_HEADERS} ${ofx_UI}) +set_local_dist(ofx_DIST_local CMakeLists.txt ${ofx_SOURCES} ${ofx_noinst_HEADERS} ) set(ofx_DIST ${ofx_DIST_local} ${test_ofx_DIST} ${ofx_gschema_DIST} PARENT_SCOPE) diff --git a/gnucash/import-export/ofx/gnc-plugin-ofx-ui.xml b/gnucash/import-export/ofx/gnc-plugin-ofx-ui.xml deleted file mode 100644 index 4a33faa06e..0000000000 --- a/gnucash/import-export/ofx/gnc-plugin-ofx-ui.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/gnucash/ui/CMakeLists.txt b/gnucash/ui/CMakeLists.txt index 6cf27defd1..6e7f6276c5 100644 --- a/gnucash/ui/CMakeLists.txt +++ b/gnucash/ui/CMakeLists.txt @@ -1,33 +1,5 @@ set (ui_SOURCES - gnc-main-window-ui.xml - gnc-plugin-account-tree-ui.xml - gnc-plugin-basic-commands-ui.xml - gnc-plugin-bi-import-ui.xml - gnc-plugin-budget-ui.xml - gnc-plugin-business-ui.xml - gnc-plugin-csv-export-ui.xml - gnc-plugin-csv-import-ui.xml - gnc-plugin-customer-import-ui.xml - gnc-plugin-file-history-ui.xml - gnc-plugin-log-replay-ui.xml - gnc-plugin-page-account-tree-ui.xml - gnc-plugin-page-budget-ui.xml - gnc-plugin-page-invoice-ui.xml - gnc-plugin-page-owner-tree-ui.xml - gnc-plugin-page-register-ui.xml - gnc-plugin-page-report-ui.xml - gnc-plugin-page-sx-list2-ui.xml - gnc-plugin-page-sx-list-ui.xml - gnc-plugin-page-sxregister-ui.xml - gnc-plugin-qif-import-ui.xml - gnc-plugin-register-ui.xml - gnc-plugin-report-system-ui.xml gnc-reconcile-window-ui.xml - gnc-sxed-to-create-window-ui.xml - gnc-sxed-window-ui-full.xml - gnc-sxed-window-ui.xml - gnc-windows-menu-ui-quartz.xml - gnc-windows-menu-ui.xml osx_accel_map) foreach (ui_file ${ui_SOURCES}) diff --git a/gnucash/ui/gnc-main-window-ui.xml b/gnucash/ui/gnc-main-window-ui.xml deleted file mode 100644 index 64068dafc0..0000000000 --- a/gnucash/ui/gnc-main-window-ui.xml +++ /dev/null @@ -1,145 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/gnucash/ui/gnc-plugin-account-tree-ui.xml b/gnucash/ui/gnc-plugin-account-tree-ui.xml deleted file mode 100644 index dd8f23e31c..0000000000 --- a/gnucash/ui/gnc-plugin-account-tree-ui.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/gnucash/ui/gnc-plugin-basic-commands-ui.xml b/gnucash/ui/gnc-plugin-basic-commands-ui.xml deleted file mode 100644 index 3c898b86b2..0000000000 --- a/gnucash/ui/gnc-plugin-basic-commands-ui.xml +++ /dev/null @@ -1,82 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/gnucash/ui/gnc-plugin-bi-import-ui.xml b/gnucash/ui/gnc-plugin-bi-import-ui.xml deleted file mode 100644 index 1eba4f04a0..0000000000 --- a/gnucash/ui/gnc-plugin-bi-import-ui.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/gnucash/ui/gnc-plugin-budget-ui.xml b/gnucash/ui/gnc-plugin-budget-ui.xml deleted file mode 100644 index 3e9cb8cd6e..0000000000 --- a/gnucash/ui/gnc-plugin-budget-ui.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/gnucash/ui/gnc-plugin-business-ui.xml b/gnucash/ui/gnc-plugin-business-ui.xml deleted file mode 100644 index f3939abdab..0000000000 --- a/gnucash/ui/gnc-plugin-business-ui.xml +++ /dev/null @@ -1,81 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/gnucash/ui/gnc-plugin-csv-export-ui.xml b/gnucash/ui/gnc-plugin-csv-export-ui.xml deleted file mode 100644 index 47dd5d8c45..0000000000 --- a/gnucash/ui/gnc-plugin-csv-export-ui.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/gnucash/ui/gnc-plugin-csv-import-ui.xml b/gnucash/ui/gnc-plugin-csv-import-ui.xml deleted file mode 100644 index 756cb66805..0000000000 --- a/gnucash/ui/gnc-plugin-csv-import-ui.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/gnucash/ui/gnc-plugin-customer-import-ui.xml b/gnucash/ui/gnc-plugin-customer-import-ui.xml deleted file mode 100644 index 51a45a012d..0000000000 --- a/gnucash/ui/gnc-plugin-customer-import-ui.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/gnucash/ui/gnc-plugin-file-history-ui.xml b/gnucash/ui/gnc-plugin-file-history-ui.xml deleted file mode 100644 index 6e97cfd396..0000000000 --- a/gnucash/ui/gnc-plugin-file-history-ui.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/gnucash/ui/gnc-plugin-log-replay-ui.xml b/gnucash/ui/gnc-plugin-log-replay-ui.xml deleted file mode 100644 index a211fde4b0..0000000000 --- a/gnucash/ui/gnc-plugin-log-replay-ui.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/gnucash/ui/gnc-plugin-page-account-tree-ui.xml b/gnucash/ui/gnc-plugin-page-account-tree-ui.xml deleted file mode 100644 index 2769ed834a..0000000000 --- a/gnucash/ui/gnc-plugin-page-account-tree-ui.xml +++ /dev/null @@ -1,79 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/gnucash/ui/gnc-plugin-page-budget-ui.xml b/gnucash/ui/gnc-plugin-page-budget-ui.xml deleted file mode 100644 index 0dc5eeb123..0000000000 --- a/gnucash/ui/gnc-plugin-page-budget-ui.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/gnucash/ui/gnc-plugin-page-invoice-ui.xml b/gnucash/ui/gnc-plugin-page-invoice-ui.xml deleted file mode 100644 index 1874687119..0000000000 --- a/gnucash/ui/gnc-plugin-page-invoice-ui.xml +++ /dev/null @@ -1,97 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/gnucash/ui/gnc-plugin-page-owner-tree-ui.xml b/gnucash/ui/gnc-plugin-page-owner-tree-ui.xml deleted file mode 100644 index 1952f3f6cf..0000000000 --- a/gnucash/ui/gnc-plugin-page-owner-tree-ui.xml +++ /dev/null @@ -1,61 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/gnucash/ui/gnc-plugin-page-register-ui.xml b/gnucash/ui/gnc-plugin-page-register-ui.xml deleted file mode 100644 index cc57ebdb92..0000000000 --- a/gnucash/ui/gnc-plugin-page-register-ui.xml +++ /dev/null @@ -1,119 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/gnucash/ui/gnc-plugin-page-report-ui.xml b/gnucash/ui/gnc-plugin-page-report-ui.xml deleted file mode 100644 index c46173f0a2..0000000000 --- a/gnucash/ui/gnc-plugin-page-report-ui.xml +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/gnucash/ui/gnc-plugin-page-sx-list-ui.xml b/gnucash/ui/gnc-plugin-page-sx-list-ui.xml deleted file mode 100644 index b9dafdc3dd..0000000000 --- a/gnucash/ui/gnc-plugin-page-sx-list-ui.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/gnucash/ui/gnc-plugin-page-sx-list2-ui.xml b/gnucash/ui/gnc-plugin-page-sx-list2-ui.xml deleted file mode 100644 index 81f2be297a..0000000000 --- a/gnucash/ui/gnc-plugin-page-sx-list2-ui.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - diff --git a/gnucash/ui/gnc-plugin-page-sxregister-ui.xml b/gnucash/ui/gnc-plugin-page-sxregister-ui.xml deleted file mode 100644 index 1c6d961318..0000000000 --- a/gnucash/ui/gnc-plugin-page-sxregister-ui.xml +++ /dev/null @@ -1,54 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/gnucash/ui/gnc-plugin-qif-import-ui.xml b/gnucash/ui/gnc-plugin-qif-import-ui.xml deleted file mode 100644 index 3cd182e0b3..0000000000 --- a/gnucash/ui/gnc-plugin-qif-import-ui.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/gnucash/ui/gnc-plugin-register-ui.xml b/gnucash/ui/gnc-plugin-register-ui.xml deleted file mode 100644 index 34dc08e3f8..0000000000 --- a/gnucash/ui/gnc-plugin-register-ui.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/gnucash/ui/gnc-plugin-report-system-ui.xml b/gnucash/ui/gnc-plugin-report-system-ui.xml deleted file mode 100644 index 15ecbd00d6..0000000000 --- a/gnucash/ui/gnc-plugin-report-system-ui.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/gnucash/ui/gnc-sxed-to-create-window-ui.xml b/gnucash/ui/gnc-sxed-to-create-window-ui.xml deleted file mode 100644 index e3f2f0ea37..0000000000 --- a/gnucash/ui/gnc-sxed-to-create-window-ui.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/gnucash/ui/gnc-sxed-window-ui-full.xml b/gnucash/ui/gnc-sxed-window-ui-full.xml deleted file mode 100644 index c2a41d35f5..0000000000 --- a/gnucash/ui/gnc-sxed-window-ui-full.xml +++ /dev/null @@ -1,62 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/gnucash/ui/gnc-sxed-window-ui.xml b/gnucash/ui/gnc-sxed-window-ui.xml deleted file mode 100644 index be31e4d47e..0000000000 --- a/gnucash/ui/gnc-sxed-window-ui.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/gnucash/ui/gnc-windows-menu-ui-quartz.xml b/gnucash/ui/gnc-windows-menu-ui-quartz.xml deleted file mode 100644 index 9613e97372..0000000000 --- a/gnucash/ui/gnc-windows-menu-ui-quartz.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/gnucash/ui/gnc-windows-menu-ui.xml b/gnucash/ui/gnc-windows-menu-ui.xml deleted file mode 100644 index 78fab67236..0000000000 --- a/gnucash/ui/gnc-windows-menu-ui.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - From 68bf71de4f865660d954824cfea76ce63d80973d Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Fri, 28 Oct 2022 16:42:16 +0100 Subject: [PATCH 30/77] Fix Edit/Assign payment in business plugin --- gnucash/gnome/gnc-plugin-business.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/gnucash/gnome/gnc-plugin-business.c b/gnucash/gnome/gnc-plugin-business.c index af2f316e17..e1e1534a32 100644 --- a/gnucash/gnome/gnc-plugin-business.c +++ b/gnucash/gnome/gnc-plugin-business.c @@ -798,6 +798,10 @@ gnc_plugin_business_update_menus (GncPluginPage *plugin_page) if (!GNC_IS_MAIN_WINDOW(plugin_page->window)) return; + // We are readonly - we have already set particular actions to inactive. + if (qof_book_is_readonly (gnc_get_current_book())) + return; + is_txn_register = GNC_IS_PLUGIN_PAGE_REGISTER(plugin_page); simple_action_group = gnc_main_window_get_action_group (GNC_MAIN_WINDOW(plugin_page->window), PLUGIN_ACTIONS_NAME); @@ -813,12 +817,9 @@ gnc_plugin_business_update_menus (GncPluginPage *plugin_page) // Change visibility and also sensitivity according to whether we are in a txn register gnc_plugin_update_actions (simple_action_group, register_txn_actions, "sensitive", is_txn_register && !is_bus_txn && !is_bus_doc); - gnc_plugin_update_actions (simple_action_group, register_txn_actions, - "visible", is_txn_register && !is_bus_txn && !is_bus_doc); + gnc_plugin_update_actions (simple_action_group, register_bus_txn_actions, "sensitive", is_txn_register && is_bus_txn && !is_bus_doc); - gnc_plugin_update_actions (simple_action_group, register_bus_txn_actions, - "visible", is_txn_register && is_bus_txn && !is_bus_doc); } @@ -827,8 +828,8 @@ gnc_plugin_business_main_window_page_changed (GncMainWindow *window, GncPluginPage *page, gpointer user_data) { - gnc_plugin_business_update_menus(page); update_inactive_actions(page); + gnc_plugin_business_update_menus(page); } From 2b84d6cf4a768ce4144719159a3718b752dc9330 Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Fri, 28 Oct 2022 16:43:02 +0100 Subject: [PATCH 31/77] Fix displaying of the extra menu --- gnucash/gnome-utils/gnc-main-window.cpp | 10 +++++----- gnucash/gnome/gnc-plugin-business.c | 1 + gnucash/ui/gnc-plugin-business.ui | 19 +++++++++++++++++++ 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/gnucash/gnome-utils/gnc-main-window.cpp b/gnucash/gnome-utils/gnc-main-window.cpp index c38f94fc4f..b54c3d38f0 100644 --- a/gnucash/gnome-utils/gnc-main-window.cpp +++ b/gnucash/gnome-utils/gnc-main-window.cpp @@ -349,6 +349,8 @@ static GActionEntry gnc_menu_actions [] = { "ScheduledAction", nullptr, nullptr, nullptr, nullptr }, + { "ExtensionsAction", nullptr, nullptr, nullptr, nullptr }, + { "WindowNewAction", gnc_main_window_cmd_window_new, nullptr, nullptr, nullptr }, { "WindowMovePageAction", gnc_main_window_cmd_window_move_page, nullptr, nullptr, nullptr }, { "Window0Action", gnc_main_window_cmd_window_raise, "i", "@i 0", radio_change_state }, @@ -4468,12 +4470,10 @@ gnc_main_window_setup_window (GncMainWindow *window) /* Now update the "eXtensions" menu */ if (!gnc_prefs_is_extra_enabled()) { -//FIXMEb GAction* action; + GAction* action = g_action_map_lookup_action (G_ACTION_MAP(priv->simple_action_group), + "ExtensionsAction"); -// action = g_action_map_lookup_action (G_ACTION_MAP(priv->simple_action_group), -// "ExtensionsAction"); -// this may need to be disabled and 'hidden when disabled added to ui. -// gtk_action_set_visible (action, FALSE); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), false); } /* GncPluginManager stuff */ diff --git a/gnucash/gnome/gnc-plugin-business.c b/gnucash/gnome/gnc-plugin-business.c index e1e1534a32..b330fb6c8b 100644 --- a/gnucash/gnome/gnc-plugin-business.c +++ b/gnucash/gnome/gnc-plugin-business.c @@ -166,6 +166,7 @@ static const gchar *gnc_plugin_load_ui_items [] = { "BusinessPlaceholder0", "BusinessPlaceholder1", + "ExtensionsPlaceholder0", NULL, }; diff --git a/gnucash/ui/gnc-plugin-business.ui b/gnucash/ui/gnc-plugin-business.ui index 93f4c30548..54476bec3f 100644 --- a/gnucash/ui/gnc-plugin-business.ui +++ b/gnucash/ui/gnc-plugin-business.ui @@ -154,4 +154,23 @@ + + + _Business + gnc-plugin-business-actions.BusinessTestAction +
+ + Test Search Dialog + gnc-plugin-business-actions.BusinessTestSearchAction + Test Search Dialog + + + Initialize Test Data + gnc-plugin-business-actions.BusinessTestInitDataAction + Initialize Test Data + +
+
+
+ From 3d54212e11ea2bb86139e1bae1a7904498a60a39 Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Fri, 28 Oct 2022 16:43:38 +0100 Subject: [PATCH 32/77] Fix visibility of StockAssistant --- gnucash/gnome/gnc-plugin-page-register.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/gnucash/gnome/gnc-plugin-page-register.c b/gnucash/gnome/gnc-plugin-page-register.c index 829f2606f5..8c043cdc58 100644 --- a/gnucash/gnome/gnc-plugin-page-register.c +++ b/gnucash/gnome/gnc-plugin-page-register.c @@ -1089,11 +1089,20 @@ gnc_plugin_page_register_ui_update (gpointer various, g_action_change_state (G_ACTION(action), g_variant_new_boolean (expanded)); g_signal_handlers_unblock_by_func (action, gnc_plugin_page_register_cmd_expand_transaction, page); - /* Enable the FilePrintAction */ + account = gnc_plugin_page_register_get_account (page); + + /* Done like this as the register can be displayed in embedded window */ if (GNC_IS_MAIN_WINDOW(GNC_PLUGIN_PAGE(page)->window)) { + /* Enable the FilePrintAction */ action = gnc_main_window_find_action (GNC_MAIN_WINDOW(GNC_PLUGIN_PAGE(page)->window), "FilePrintAction"); g_simple_action_set_enabled (G_SIMPLE_ACTION(action), TRUE); + + /* Set the vis of the StockAssistant */ + gnc_main_window_menu_item_vis_by_action (GNC_MAIN_WINDOW(GNC_PLUGIN_PAGE(page)->window), + actions_requiring_priced_account, + account && gnc_prefs_is_extra_enabled () && + xaccAccountIsPriced (account)); } /* If we are in a readonly book, or possibly a place holder @@ -1102,8 +1111,6 @@ gnc_plugin_page_register_ui_update (gpointer various, gnc_split_reg_get_read_only (priv->gsr)) read_only_reg = TRUE; - account = gnc_plugin_page_register_get_account (page); - gnc_plugin_update_actions (gnc_plugin_page_get_action_group (GNC_PLUGIN_PAGE(page)), actions_requiring_account, "sensitive", !read_only_reg && account != NULL); @@ -1302,11 +1309,6 @@ gnc_plugin_page_register_ui_initial_state (GncPluginPageRegister* page) gnc_plugin_update_actions (simple_action_group, actions_requiring_account, "sensitive", is_readwrite && account != NULL); - gnc_plugin_update_actions (simple_action_group, actions_requiring_priced_account, - "visible", account && - gnc_prefs_is_extra_enabled () && - xaccAccountIsPriced (account)); - /* Set "style" radio button */ ledger_type = gnc_ledger_display_type (priv->ledger); action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE(page), "ViewStyleRadioAction"); From a381fbcf4ef4f8bf859b0e68d41d3c2cddaee9a5 Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Fri, 28 Oct 2022 16:44:21 +0100 Subject: [PATCH 33/77] Redfine gnc_plugin_update_actions As this function does not deal with action visibility any more, remove the property_name parameter, rename and update all occurrences. --- gnucash/gnome-utils/gnc-main-window.cpp | 25 +++++++------ gnucash/gnome-utils/gnc-plugin.c | 36 ++++++------------- gnucash/gnome-utils/gnc-plugin.h | 23 +++++------- gnucash/gnome/gnc-plugin-basic-commands.c | 14 ++++---- gnucash/gnome/gnc-plugin-budget.c | 4 +-- gnucash/gnome/gnc-plugin-business.c | 12 +++---- gnucash/gnome/gnc-plugin-page-account-tree.c | 20 +++++------ gnucash/gnome/gnc-plugin-page-budget.c | 8 ++--- gnucash/gnome/gnc-plugin-page-invoice.c | 16 ++++----- gnucash/gnome/gnc-plugin-page-owner-tree.c | 12 +++---- gnucash/gnome/gnc-plugin-page-register.c | 16 ++++----- gnucash/gnome/gnc-plugin-page-report.cpp | 4 +-- .../import-export/aqb/gnc-plugin-aqbanking.c | 17 ++++----- 13 files changed, 90 insertions(+), 117 deletions(-) diff --git a/gnucash/gnome-utils/gnc-main-window.cpp b/gnucash/gnome-utils/gnc-main-window.cpp index b54c3d38f0..b38238a5ef 100644 --- a/gnucash/gnome-utils/gnc-main-window.cpp +++ b/gnucash/gnome-utils/gnc-main-window.cpp @@ -1702,9 +1702,9 @@ gnc_main_window_generate_title (GncMainWindow *window) /* Update the menus based upon whether this is an "immutable" page. */ immutable = page && g_object_get_data (G_OBJECT (page), PLUGIN_PAGE_IMMUTABLE); - gnc_plugin_update_actions (priv->simple_action_group, - immutable_page_actions, - "sensitive", !immutable); + gnc_plugin_set_actions_enabled (priv->simple_action_group, + immutable_page_actions, + !immutable); /* Trigger sensitivity updtates of other actions such as Save/Revert */ g_signal_emit_by_name (window, "page_changed", page); g_free( filename ); @@ -4399,12 +4399,12 @@ gnc_main_window_setup_window (GncMainWindow *window) gnc_menu_n_actions, window); - gnc_plugin_update_actions (priv->simple_action_group, - initially_insensitive_actions, - "sensitive", FALSE); - gnc_plugin_update_actions (priv->simple_action_group, - always_insensitive_actions, - "sensitive", FALSE); + gnc_plugin_set_actions_enabled (priv->simple_action_group, + initially_insensitive_actions, + FALSE); + gnc_plugin_set_actions_enabled (priv->simple_action_group, + always_insensitive_actions, + FALSE); gnc_main_window_menu_item_vis_by_action (window, always_hidden_actions, false); @@ -4681,10 +4681,9 @@ gnc_main_window_switch_page (GtkNotebook *notebook, priv->usage_order = g_list_prepend (priv->usage_order, page); } - gnc_plugin_update_actions (priv->simple_action_group, - multiple_page_actions, - "sensitive", - g_list_length(priv->installed_pages) > 1); + gnc_plugin_set_actions_enabled (priv->simple_action_group, + multiple_page_actions, + g_list_length (priv->installed_pages) > 1); gnc_main_window_update_title(window); #ifndef MAC_INTEGRATION diff --git a/gnucash/gnome-utils/gnc-plugin.c b/gnucash/gnome-utils/gnc-plugin.c index 0229eca6a0..318808da34 100644 --- a/gnucash/gnome-utils/gnc-plugin.c +++ b/gnucash/gnome-utils/gnc-plugin.c @@ -243,38 +243,22 @@ gnc_plugin_init_short_names (GtkWidget *toolbar, } -/* Update a property of existing UI actions. This function can - * modify actions making them visible, invisible, sensitive, or - * insensitive. - * - * See gnc-plugin.h for documentation on the function arguments. */ +/* Update the sensitivity of an action */ void -gnc_plugin_update_actions (GSimpleActionGroup *simple_action_group, - const gchar **action_names, - const gchar *property_name, - gboolean value) +gnc_plugin_set_actions_enabled (GSimpleActionGroup *simple_action_group, + const gchar **action_names, gboolean enable) { - GAction *action; - gint i; + g_return_if_fail (simple_action_group != NULL); - for (i = 0; action_names[i]; i++) + for (gint i = 0; action_names[i]; i++) { - action = g_action_map_lookup_action (G_ACTION_MAP(simple_action_group), action_names[i]); + GAction *action = g_action_map_lookup_action (G_ACTION_MAP(simple_action_group), + action_names[i]); if (action) - { -//FIXMEb property_name could be 'sensitive' or 'visible' - if (g_strcmp0 (property_name, "sensitive") == 0) - g_simple_action_set_enabled (G_SIMPLE_ACTION(action), value); - else - { -//FIXMEb visible is done on the menu item, could also be linked to the action being sensitive - } - } + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), enable); else - { - g_warning ("No such action with name '%s' in action group %p)", - action_names[i], simple_action_group); - } + PERR("No such action with name '%s' in action group %p)", + action_names[i], simple_action_group); } } diff --git a/gnucash/gnome-utils/gnc-plugin.h b/gnucash/gnome-utils/gnc-plugin.h index eab3e421c8..612937606d 100644 --- a/gnucash/gnome-utils/gnc-plugin.h +++ b/gnucash/gnome-utils/gnc-plugin.h @@ -252,28 +252,21 @@ void gnc_plugin_init_short_names (GtkWidget *toolbar, GncToolBarShortNames *toolbar_labels); -/** Update a property on a set of existing GtkActions. This function - * can be easily used to make a list of actions visible, invisible, - * sensitive, or insensitive. +/** This function sets the sensitivity of a GAction in a specific + * group. * - * @param action_group The group of all actions associated with a - * plugin or plugin page. All actions to be modified must be - * contained in this group. + * @param simple_action_group The group of all actions associated with a + * plugin or plugin page. * * @param action_names A NULL terminated list of actions names that * should be modified. * - * @param property_name The property name to be changed on the - * specified actions. The only two GtkAction properties that it makes - * sense to modify are "visible" and "sensitive". - * - * @param value A boolean specifying the new state for the specified + * @param enable A boolean specifying the new state for the specified * property. */ -void gnc_plugin_update_actions (GSimpleActionGroup *simple_action_group, - const gchar **action_names, - const gchar *property_name, - gboolean value); //FIXMEb added +void gnc_plugin_set_actions_enabled (GSimpleActionGroup *simple_action_group, + const gchar **action_names, + gboolean enable); //FIXMEb added /** Load a new set of actions into an existing UI. The actions from * the provided group will be merged into the pre-existing ui, as diff --git a/gnucash/gnome/gnc-plugin-basic-commands.c b/gnucash/gnome/gnc-plugin-basic-commands.c index 8d1ba7bfeb..4ea7e0270f 100644 --- a/gnucash/gnome/gnc-plugin-basic-commands.c +++ b/gnucash/gnome/gnc-plugin-basic-commands.c @@ -225,9 +225,9 @@ gnc_plugin_basic_commands_add_to_window (GncPlugin *plugin, GSimpleActionGroup *simple_action_group = gnc_main_window_get_action_group (window, PLUGIN_ACTIONS_NAME); - gnc_plugin_update_actions (simple_action_group, - gnc_plugin_initially_insensitive_actions, - "sensitive", FALSE); + gnc_plugin_set_actions_enabled (simple_action_group, + gnc_plugin_initially_insensitive_actions, + FALSE); g_signal_connect (window, "page_changed", G_CALLBACK(gnc_plugin_basic_commands_main_window_page_changed), @@ -255,10 +255,10 @@ static void update_inactive_actions (GncPluginPage *plugin_page) g_return_if_fail (G_IS_SIMPLE_ACTION_GROUP(simple_action_group)); /* Set the action's sensitivity */ - gnc_plugin_update_actions (simple_action_group, readwrite_only_active_actions, - "sensitive", is_readwrite); - gnc_plugin_update_actions (simple_action_group, dirty_only_active_actions, - "sensitive", is_dirty); + gnc_plugin_set_actions_enabled (simple_action_group, readwrite_only_active_actions, + is_readwrite); + gnc_plugin_set_actions_enabled (simple_action_group, dirty_only_active_actions, + is_dirty); } static void diff --git a/gnucash/gnome/gnc-plugin-budget.c b/gnucash/gnome/gnc-plugin-budget.c index 5bf1192399..9f0e9578b0 100644 --- a/gnucash/gnome/gnc-plugin-budget.c +++ b/gnucash/gnome/gnc-plugin-budget.c @@ -114,8 +114,8 @@ page_changed (GncMainWindow *window, GncPluginPage *page, gpointer user_data) gnc_main_window_get_action_group (window, PLUGIN_ACTIONS_NAME); if (qof_book_is_readonly (gnc_get_current_book())) - gnc_plugin_update_actions (simple_action_group, plugin_writeable_actions, - "sensitive", FALSE); + gnc_plugin_set_actions_enabled (simple_action_group, plugin_writeable_actions, + FALSE); } static void diff --git a/gnucash/gnome/gnc-plugin-business.c b/gnucash/gnome/gnc-plugin-business.c index b330fb6c8b..14fe290145 100644 --- a/gnucash/gnome/gnc-plugin-business.c +++ b/gnucash/gnome/gnc-plugin-business.c @@ -816,11 +816,11 @@ gnc_plugin_business_update_menus (GncPluginPage *plugin_page) 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 (simple_action_group, register_txn_actions, - "sensitive", is_txn_register && !is_bus_txn && !is_bus_doc); + gnc_plugin_set_actions_enabled (simple_action_group, register_txn_actions, + is_txn_register && !is_bus_txn && !is_bus_doc); - gnc_plugin_update_actions (simple_action_group, register_bus_txn_actions, - "sensitive", is_txn_register && is_bus_txn && !is_bus_doc); + gnc_plugin_set_actions_enabled (simple_action_group, register_bus_txn_actions, + is_txn_register && is_bus_txn && !is_bus_doc); } @@ -957,8 +957,8 @@ update_inactive_actions (GncPluginPage *plugin_page) g_return_if_fail (G_IS_SIMPLE_ACTION_GROUP(simple_action_group)); /* Set the action's sensitivity */ - gnc_plugin_update_actions (simple_action_group, readonly_inactive_actions, - "sensitive", is_readwrite); + gnc_plugin_set_actions_enabled (simple_action_group, readonly_inactive_actions, + is_readwrite); } /* This is the list of actions which are switched invisible or visible diff --git a/gnucash/gnome/gnc-plugin-page-account-tree.c b/gnucash/gnome/gnc-plugin-page-account-tree.c index ecbf1a1566..5ebe80882f 100644 --- a/gnucash/gnome/gnc-plugin-page-account-tree.c +++ b/gnucash/gnome/gnc-plugin-page-account-tree.c @@ -905,16 +905,16 @@ update_inactive_actions (GncPluginPage *plugin_page) g_return_if_fail (G_IS_SIMPLE_ACTION_GROUP (simple_action_group)); /* Set the action's sensitivity */ - gnc_plugin_update_actions (simple_action_group, readonly_inactive_actions, - "sensitive", allow_write); - gnc_plugin_update_actions (simple_action_group, actions_requiring_account_rw, - "sensitive", allow_write && has_account); - gnc_plugin_update_actions (simple_action_group, actions_requiring_account_always, - "sensitive", has_account); - gnc_plugin_update_actions (simple_action_group, actions_requiring_subaccounts_rw, - "sensitive", allow_write && subaccounts); - gnc_plugin_update_actions (simple_action_group, actions_requiring_priced_account, - "sensitive", account && xaccAccountIsPriced (account)); + gnc_plugin_set_actions_enabled (simple_action_group, readonly_inactive_actions, + allow_write); + gnc_plugin_set_actions_enabled (simple_action_group, actions_requiring_account_rw, + allow_write && has_account); + gnc_plugin_set_actions_enabled (simple_action_group, actions_requiring_account_always, + has_account); + gnc_plugin_set_actions_enabled (simple_action_group, actions_requiring_subaccounts_rw, + allow_write && subaccounts); + gnc_plugin_set_actions_enabled (simple_action_group, actions_requiring_priced_account, + account && xaccAccountIsPriced (account)); g_signal_emit (plugin_page, plugin_page_signals[ACCOUNT_SELECTED], 0, account); } diff --git a/gnucash/gnome/gnc-plugin-page-budget.c b/gnucash/gnome/gnc-plugin-page-budget.c index cc739b7705..0f87144018 100644 --- a/gnucash/gnome/gnc-plugin-page-budget.c +++ b/gnucash/gnome/gnc-plugin-page-budget.c @@ -376,8 +376,8 @@ gnc_plugin_page_budget_init (GncPluginPageBudget *plugin_page) plugin_page); if (qof_book_is_readonly (gnc_get_current_book())) - gnc_plugin_update_actions (simple_action_group, writeable_actions, - "sensitive", FALSE); + gnc_plugin_set_actions_enabled (simple_action_group, writeable_actions, + FALSE); /* Visible types */ priv->fd.visible_types = -1; /* Start with all types */ @@ -755,8 +755,8 @@ gppb_selection_changed_cb (GtkTreeSelection *selection, } simple_action_group = gnc_plugin_page_get_action_group (GNC_PLUGIN_PAGE(page)); - gnc_plugin_update_actions (simple_action_group, actions_requiring_account, - "sensitive", sensitive); + gnc_plugin_set_actions_enabled (simple_action_group, actions_requiring_account, + sensitive); } #endif diff --git a/gnucash/gnome/gnc-plugin-page-invoice.c b/gnucash/gnome/gnc-plugin-page-invoice.c index 4496c72000..22752a3a15 100644 --- a/gnucash/gnome/gnc-plugin-page-invoice.c +++ b/gnucash/gnome/gnc-plugin-page-invoice.c @@ -765,14 +765,14 @@ gnc_plugin_page_invoice_update_menus (GncPluginPage *page, gboolean is_posted, g g_simple_action_set_enabled (G_SIMPLE_ACTION(action), TRUE); simple_action_group = gnc_plugin_page_get_action_group (page); - gnc_plugin_update_actions (simple_action_group, posted_actions, - "sensitive", is_posted); - gnc_plugin_update_actions (simple_action_group, unposted_actions, - "sensitive", !is_posted); - gnc_plugin_update_actions (simple_action_group, can_unpost_actions, - "sensitive", can_unpost); - gnc_plugin_update_actions (simple_action_group, invoice_book_readwrite_actions, - "sensitive", !is_readonly); + gnc_plugin_set_actions_enabled (simple_action_group, posted_actions, + is_posted); + gnc_plugin_set_actions_enabled (simple_action_group, unposted_actions, + !is_posted); + gnc_plugin_set_actions_enabled (simple_action_group, can_unpost_actions, + can_unpost); + gnc_plugin_set_actions_enabled (simple_action_group, invoice_book_readwrite_actions, + !is_readonly); /* update the action labels and tooltips */ gnc_plugin_page_invoice_action_update (page, label_list, tooltip_list); diff --git a/gnucash/gnome/gnc-plugin-page-owner-tree.c b/gnucash/gnome/gnc-plugin-page-owner-tree.c index add750aa02..cdcd8d9d84 100644 --- a/gnucash/gnome/gnc-plugin-page-owner-tree.c +++ b/gnucash/gnome/gnc-plugin-page-owner-tree.c @@ -522,8 +522,8 @@ update_inactive_actions(GncPluginPage *plugin_page) g_return_if_fail (G_IS_SIMPLE_ACTION_GROUP(simple_action_group)); /* Set the action's sensitivity */ - gnc_plugin_update_actions (simple_action_group, readonly_inactive_actions, - "sensitive", is_sensitive); + gnc_plugin_set_actions_enabled (simple_action_group, readonly_inactive_actions, + is_sensitive); } static void @@ -934,10 +934,10 @@ gnc_plugin_page_owner_tree_selection_changed_cb (GtkTreeSelection *selection, } simple_action_group = gnc_plugin_page_get_action_group (GNC_PLUGIN_PAGE(page)); - gnc_plugin_update_actions (simple_action_group, actions_requiring_owner_always, - "sensitive", sensitive); - gnc_plugin_update_actions (simple_action_group, actions_requiring_owner_rw, - "sensitive", sensitive && is_readwrite); + gnc_plugin_set_actions_enabled (simple_action_group, actions_requiring_owner_always, + sensitive); + gnc_plugin_set_actions_enabled (simple_action_group, actions_requiring_owner_rw, + sensitive && is_readwrite); g_signal_emit (page, plugin_page_signals[OWNER_SELECTED], 0, owner); } diff --git a/gnucash/gnome/gnc-plugin-page-register.c b/gnucash/gnome/gnc-plugin-page-register.c index 8c043cdc58..d8f08f913a 100644 --- a/gnucash/gnome/gnc-plugin-page-register.c +++ b/gnucash/gnome/gnc-plugin-page-register.c @@ -1111,13 +1111,13 @@ gnc_plugin_page_register_ui_update (gpointer various, gnc_split_reg_get_read_only (priv->gsr)) read_only_reg = TRUE; - gnc_plugin_update_actions (gnc_plugin_page_get_action_group (GNC_PLUGIN_PAGE(page)), - actions_requiring_account, "sensitive", - !read_only_reg && account != NULL); + gnc_plugin_set_actions_enabled (gnc_plugin_page_get_action_group (GNC_PLUGIN_PAGE(page)), + actions_requiring_account, + !read_only_reg && account != NULL); - gnc_plugin_update_actions (gnc_plugin_page_get_action_group (GNC_PLUGIN_PAGE(page)), - actions_requiring_priced_account, "sensitive", - account && xaccAccountIsPriced (account)); + gnc_plugin_set_actions_enabled (gnc_plugin_page_get_action_group (GNC_PLUGIN_PAGE(page)), + actions_requiring_priced_account, + account && xaccAccountIsPriced (account)); /* Set available actions based on read only */ trans = gnc_split_register_get_current_trans (reg); @@ -1306,8 +1306,8 @@ gnc_plugin_page_register_ui_initial_state (GncPluginPageRegister* page) simple_action_group = gnc_plugin_page_get_action_group (GNC_PLUGIN_PAGE(page)); g_return_if_fail (G_IS_SIMPLE_ACTION_GROUP(simple_action_group)); - gnc_plugin_update_actions (simple_action_group, actions_requiring_account, - "sensitive", is_readwrite && account != NULL); + gnc_plugin_set_actions_enabled (simple_action_group, actions_requiring_account, + is_readwrite && account != NULL); /* Set "style" radio button */ ledger_type = gnc_ledger_display_type (priv->ledger); diff --git a/gnucash/gnome/gnc-plugin-page-report.cpp b/gnucash/gnome/gnc-plugin-page-report.cpp index 7a71b69194..113c065645 100644 --- a/gnucash/gnome/gnc-plugin-page-report.cpp +++ b/gnucash/gnome/gnc-plugin-page-report.cpp @@ -1385,8 +1385,8 @@ gnc_plugin_page_report_constr_init (GncPluginPageReport *plugin_page, gint repor num_report_actions, plugin_page); - gnc_plugin_update_actions (simple_action_group, initially_insensitive_actions, - "sensitive", FALSE); + gnc_plugin_set_actions_enabled (simple_action_group, initially_insensitive_actions, + FALSE); } GncPluginPage* diff --git a/gnucash/import-export/aqb/gnc-plugin-aqbanking.c b/gnucash/import-export/aqb/gnc-plugin-aqbanking.c index 1d195832b5..8c3e6e2577 100644 --- a/gnucash/import-export/aqb/gnc-plugin-aqbanking.c +++ b/gnucash/import-export/aqb/gnc-plugin-aqbanking.c @@ -280,8 +280,8 @@ static void update_inactive_actions(GncPluginPage *plugin_page) g_return_if_fail (G_IS_SIMPLE_ACTION_GROUP(simple_action_group)); /* Set the action's sensitivity */ - gnc_plugin_update_actions (simple_action_group, readonly_inactive_actions, - "sensitive", is_readwrite); + gnc_plugin_set_actions_enabled (simple_action_group, readonly_inactive_actions, + is_readwrite); } @@ -330,22 +330,19 @@ gnc_plugin_ab_account_selected (GncPluginPage *plugin_page, Account *account, bankcode = gnc_ab_get_account_bankcode(account); accountid = gnc_ab_get_account_accountid(account); - gnc_plugin_update_actions (simple_action_group, need_account_actions, - "sensitive", - (account && bankcode && *bankcode - && accountid && *accountid)); + gnc_plugin_set_actions_enabled (simple_action_group, need_account_actions, + (account && bankcode && *bankcode + && accountid && *accountid)); gnc_main_window_menu_item_vis_by_action (window, need_account_actions, TRUE); #if (AQBANKING_VERSION_INT < 60400) - gnc_plugin_update_actions (simple_action_group, inactive_account_actions, - "sensitive", FALSE); + gnc_plugin_set_actions_enabled (simple_action_group, inactive_account_actions, FALSE); gnc_main_window_menu_item_vis_by_action (window, inactive_account_actions, FALSE); #endif } else { - gnc_plugin_update_actions (simple_action_group, need_account_actions, - "sensitive", FALSE); + gnc_plugin_set_actions_enabled (simple_action_group, need_account_actions, FALSE); gnc_main_window_menu_item_vis_by_action (window, need_account_actions, FALSE); } From e85f5f8d8d708a371f74d11d2b06cb2895f1418c Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Fri, 28 Oct 2022 16:44:58 +0100 Subject: [PATCH 34/77] Fix binding extra business tool bar item to preference setting --- gnucash/gnome/gnc-plugin-business.c | 71 ++++++++++++++++++++++------- 1 file changed, 55 insertions(+), 16 deletions(-) diff --git a/gnucash/gnome/gnc-plugin-business.c b/gnucash/gnome/gnc-plugin-business.c index 14fe290145..a71e87e01f 100644 --- a/gnucash/gnome/gnc-plugin-business.c +++ b/gnucash/gnome/gnc-plugin-business.c @@ -52,6 +52,8 @@ #include "gnc-prefs.h" #include "gnc-main-window.h" +#include "gnc-window.h" +#include "gnc-gtk-utils.h" #include "gnc-plugin-page-register.h" @@ -104,6 +106,7 @@ static void gnc_plugin_business_cmd_test_init_data (GSimpleAction *simple, GVari static void gnc_plugin_business_cmd_assign_payment (GSimpleAction *simple, GVariant *parameter, gpointer user_data); static void update_inactive_actions (GncPluginPage *page); +static void bind_extra_toolbuttons_visibility (GncMainWindow *mainwindow); #define PLUGIN_ACTIONS_NAME "gnc-plugin-business-actions" #define PLUGIN_UI_FILENAME "gnc-plugin-business.ui" @@ -823,7 +826,6 @@ gnc_plugin_business_update_menus (GncPluginPage *plugin_page) is_txn_register && is_bus_txn && !is_bus_doc); } - static void gnc_plugin_business_main_window_page_changed (GncMainWindow *window, GncPluginPage *page, @@ -833,6 +835,17 @@ gnc_plugin_business_main_window_page_changed (GncMainWindow *window, gnc_plugin_business_update_menus(page); } +static void +gnc_plugin_business_main_window_menu_changed (GncMainWindow *window, + GncPluginPage *page, + gpointer user_data) +{ + if (page == gnc_main_window_get_current_page (window)) + { + gnc_plugin_business_main_window_page_changed (window, page, user_data); + bind_extra_toolbuttons_visibility (window); + } +} void gnc_plugin_business_split_reg_ui_update (GncPluginPage *plugin_page) @@ -972,24 +985,48 @@ static const char* extra_toolbar_actions[] = /* Bind the visibility of the extra toolbar buttons to the * enable_toolbuttons preference. */ static void -bind_toolbuttons_visibility (GncMainWindow *mainwindow) +bind_extra_toolbuttons_visibility (GncMainWindow *mainwindow) { - GSimpleActionGroup *simple_action_group; + GtkWidget *toolbar; const char **iter; - g_return_if_fail(mainwindow); - g_return_if_fail(GNC_IS_MAIN_WINDOW(mainwindow)); + g_return_if_fail (mainwindow); + g_return_if_fail (GNC_IS_MAIN_WINDOW(mainwindow)); - /* Get the action group */ - simple_action_group = gnc_main_window_get_action_group (mainwindow, PLUGIN_ACTIONS_NAME); - g_assert (simple_action_group); + toolbar = gnc_window_get_toolbar (GNC_WINDOW(mainwindow)); -//FIXMEb for (iter = extra_toolbar_actions; *iter; ++iter) -// { - /* Set the action's visibility */ -// GAction *action = g_action_map_lookup_action (G_ACTION_MAP(simple_action_group), *iter); -// gnc_prefs_bind (GNC_PREFS_GROUP_INVOICE, GNC_PREF_EXTRA_TOOLBUTTONS, G_OBJECT (action), "visible"); -// } + if (!toolbar) + return; + + // Set the 'extra' tool items visibility + for (iter = extra_toolbar_actions; *iter; ++iter) + { + GtkWidget *tool_item = gnc_find_toolbar_item (toolbar, *iter); + + if (tool_item) + { + gnc_prefs_bind (GNC_PREFS_GROUP_INVOICE, + GNC_PREF_EXTRA_TOOLBUTTONS, + G_OBJECT(tool_item), "visible"); + } + } + + // Set the 'extra' tool item separator visibility + for (gint i = 0; i < gtk_toolbar_get_n_items (GTK_TOOLBAR(toolbar)); i++) + { + GtkToolItem *tool_item = gtk_toolbar_get_nth_item (GTK_TOOLBAR(toolbar), i); + + if (GTK_IS_SEPARATOR_TOOL_ITEM(tool_item)) + { + if (g_str_has_prefix (gtk_buildable_get_name (GTK_BUILDABLE(tool_item)), + "extra_separator")) + { + gnc_prefs_bind (GNC_PREFS_GROUP_INVOICE, + GNC_PREF_EXTRA_TOOLBUTTONS, + G_OBJECT(tool_item), "visible"); + } + } + } } /** @@ -1003,11 +1040,13 @@ gnc_plugin_business_add_to_window (GncPlugin *plugin, GncMainWindow *mainwindow, GQuark type) { - bind_toolbuttons_visibility (mainwindow); - g_signal_connect (mainwindow, "page_changed", G_CALLBACK(gnc_plugin_business_main_window_page_changed), plugin); + + g_signal_connect (mainwindow, "menu_changed", + G_CALLBACK(gnc_plugin_business_main_window_menu_changed), + plugin); } static const char* invoice_printreport_values[] = From ea419b3b2c6cfd2f59a54f92ee0bef0eb77f24a3 Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Fri, 28 Oct 2022 16:45:41 +0100 Subject: [PATCH 35/77] Fix creating a new file --- gnucash/gnome-utils/gnc-main-window.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/gnucash/gnome-utils/gnc-main-window.cpp b/gnucash/gnome-utils/gnc-main-window.cpp index b38238a5ef..1c7f7843f3 100644 --- a/gnucash/gnome-utils/gnc-main-window.cpp +++ b/gnucash/gnome-utils/gnc-main-window.cpp @@ -1031,8 +1031,10 @@ gnc_main_window_restore_default_state (GncMainWindow *window) if (!window) window = static_cast(g_list_nth_data(active_windows, 0)); gtk_widget_show (GTK_WIDGET(window)); - action = gnc_main_window_find_action (window, "ViewAccountTreeAction"); -//FIXMEb gtk_action_activate(action); + action = gnc_main_window_find_action_in_group (window, + "gnc-plugin-account-tree-actions", + "ViewAccountTreeAction"); + g_action_activate (action, nullptr); } /** Save the state of a single page to a disk. This function handles From c9abdb1373ff49533a87c7d13d35c94f0fd130cf Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Fri, 28 Oct 2022 16:48:46 +0100 Subject: [PATCH 36/77] Remove some GtkUIManger functions --- gnucash/gnome-utils/gnc-embedded-window.c | 5 -- gnucash/gnome-utils/gnc-main-window.cpp | 9 +-- gnucash/gnome-utils/gnc-plugin-page.c | 70 -------------------- gnucash/gnome-utils/gnc-plugin-page.h | 18 +----- gnucash/gnome-utils/gnc-plugin.c | 79 ----------------------- gnucash/gnome-utils/gnc-plugin.h | 18 ------ 6 files changed, 4 insertions(+), 195 deletions(-) diff --git a/gnucash/gnome-utils/gnc-embedded-window.c b/gnucash/gnome-utils/gnc-embedded-window.c index fc11a7836f..118c530fc0 100644 --- a/gnucash/gnome-utils/gnc-embedded-window.c +++ b/gnucash/gnome-utils/gnc-embedded-window.c @@ -128,8 +128,6 @@ gnc_embedded_window_open_page (GncEmbeddedWindow *window, gtk_box_pack_end(GTK_BOX(window), page->notebook_page, TRUE, TRUE, 2); gnc_plugin_page_inserted (page); - -//FIXMEb gnc_plugin_page_merge_actions (page, window->ui_merge); LEAVE(" "); } @@ -158,9 +156,6 @@ gnc_embedded_window_close_page (GncEmbeddedWindow *window, priv->page = NULL; gnc_plugin_page_removed (page); -//FIXMEb gnc_plugin_page_unmerge_actions (page, window->ui_merge); -// gtk_ui_manager_ensure_update (window->ui_merge); - gnc_plugin_page_destroy_widget (page); g_object_unref(page); LEAVE(" "); diff --git a/gnucash/gnome-utils/gnc-main-window.cpp b/gnucash/gnome-utils/gnc-main-window.cpp index 1c7f7843f3..a21327d7f3 100644 --- a/gnucash/gnome-utils/gnc-main-window.cpp +++ b/gnucash/gnome-utils/gnc-main-window.cpp @@ -3248,7 +3248,6 @@ gnc_main_window_disconnect (GncMainWindow *window, priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); if (priv->current_page == page) { -//FIXMEb gnc_plugin_page_unmerge_actions (page, window->ui_merge); gnc_plugin_page_unselected (page); priv->current_page = nullptr; } @@ -3291,7 +3290,6 @@ gnc_main_window_disconnect (GncMainWindow *window, gnc_plugin_page_removed (page); -//FIXMEb gtk_ui_manager_ensure_update (window->ui_merge); gnc_window_set_status (GNC_WINDOW(window), page, nullptr); } @@ -3708,9 +3706,7 @@ gnc_main_window_unmerge_actions (GncMainWindow *window, if (entry == nullptr) return; -//FIXMEb gtk_ui_manager_remove_action_group (window->ui_merge, entry->action_group); -// gtk_ui_manager_remove_ui (window->ui_merge, entry->merge_id); -// gtk_ui_manager_ensure_update (window->ui_merge); + gtk_widget_insert_action_group (GTK_WIDGET(window), group_name, nullptr); g_hash_table_remove (priv->merged_actions_table, group_name); } @@ -4651,7 +4647,6 @@ gnc_main_window_switch_page (GtkNotebook *notebook, if (priv->current_page != nullptr) { page = priv->current_page; -//FIXMEb gnc_plugin_page_unmerge_actions (page, window->ui_merge); gnc_plugin_page_unselected (page); } @@ -4670,7 +4665,7 @@ gnc_main_window_switch_page (GtkNotebook *notebook, if (page != nullptr) { /* Update the user interface (e.g. menus and toolbars */ - gnc_plugin_page_merge_actionsb (page, GTK_WIDGET(window)); + gnc_plugin_page_merge_actions (page, GTK_WIDGET(window)); visible = gnc_main_window_show_summarybar (window, nullptr); gnc_plugin_page_show_summarybar (page, visible); diff --git a/gnucash/gnome-utils/gnc-plugin-page.c b/gnucash/gnome-utils/gnc-plugin-page.c index 978978abc3..9c97884b84 100644 --- a/gnucash/gnome-utils/gnc-plugin-page.c +++ b/gnucash/gnome-utils/gnc-plugin-page.c @@ -91,9 +91,6 @@ static guint signals[LAST_SIGNAL] = { 0 }; typedef struct _GncPluginPagePrivate { /** The group of all actions provided by this plugin. */ - GtkActionGroup *action_group; - GtkUIManager *ui_merge; - guint merge_id; char *ui_description; GtkBuilder *builder; //FIXMEb added @@ -258,25 +255,8 @@ gnc_plugin_page_recreate_page(GtkWidget *window, } -/* Add the actions for a content page to the specified window. */ void gnc_plugin_page_merge_actions (GncPluginPage *page, - GtkUIManager *ui_merge) -{ - GncPluginPagePrivate *priv; - - g_return_if_fail (GNC_IS_PLUGIN_PAGE(page)); - - priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page); - priv->ui_merge = ui_merge; - gtk_action_group_set_sensitive (priv->action_group, TRUE); - priv->merge_id = gnc_plugin_add_actions (priv->ui_merge, - priv->action_group, - priv->ui_description); -} - -void -gnc_plugin_page_merge_actionsb (GncPluginPage *page, GtkWidget *window) { GncPluginPagePrivate *priv; @@ -304,28 +284,6 @@ gnc_plugin_page_merge_actionsb (GncPluginPage *page, } -/* Remove the actions for a content page from the specified window. */ -void -gnc_plugin_page_unmerge_actions (GncPluginPage *page, - GtkUIManager *ui_merge) -{ - GncPluginPagePrivate *priv; - - priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page); - - g_return_if_fail (GNC_IS_PLUGIN_PAGE(page)); - g_return_if_fail (priv->merge_id != 0); - g_return_if_fail (priv->action_group != NULL); - - gtk_ui_manager_remove_ui (ui_merge, priv->merge_id); - gtk_action_group_set_sensitive (priv->action_group, FALSE); - gtk_ui_manager_remove_action_group (ui_merge, priv->action_group); - - priv->ui_merge = NULL; - priv->merge_id = 0; -} - - GAction * gnc_plugin_page_get_action (GncPluginPage *page, const gchar *name) { @@ -473,28 +431,6 @@ gnc_plugin_page_class_init (GncPluginPageClass *klass) NULL, G_PARAM_READWRITE)); - g_object_class_install_property - (gobject_class, - PROP_UI_MERGE, - g_param_spec_object ("ui-merge", - "UI Merge", - "A pointer to the GtkUIManager object that " - "represents this pages menu hierarchy.", - GTK_TYPE_UI_MANAGER, - G_PARAM_READABLE)); - - g_object_class_install_property - (gobject_class, - PROP_ACTION_GROUP, - g_param_spec_object ("action-group", - "Action Group", - "A pointer to the GtkActionGroup object that " - "represents this pages available menu/toolbar " - "actions.", - GTK_TYPE_ACTION_GROUP, - G_PARAM_READABLE)); - - signals[INSERTED] = g_signal_new ("inserted", @@ -671,12 +607,6 @@ gnc_plugin_page_get_property (GObject *object, case PROP_UI_DESCRIPTION: g_value_set_string (value, priv->ui_description); break; - case PROP_UI_MERGE: - g_value_take_object (value, priv->ui_merge); - break; - case PROP_ACTION_GROUP: - g_value_take_object (value, priv->action_group); - break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; diff --git a/gnucash/gnome-utils/gnc-plugin-page.h b/gnucash/gnome-utils/gnc-plugin-page.h index bf079734b9..6797f64101 100644 --- a/gnucash/gnome-utils/gnc-plugin-page.h +++ b/gnucash/gnome-utils/gnc-plugin-page.h @@ -290,24 +290,10 @@ GncPluginPage *gnc_plugin_page_recreate_page (GtkWidget *window, * @param plugin_page A pointer to the page whose actions should be * added to the user interface. * - * @param merge A pointer to the UI manager data structure for a - * window. + * @param merge A pointer to the window. */ void gnc_plugin_page_merge_actions (GncPluginPage *plugin_page, - GtkUIManager *merge); -void gnc_plugin_page_merge_actionsb (GncPluginPage *plugin_page, - GtkWidget *window); //FIXMEb added - -/** Remove the actions for a content page from the specified window. - * - * @param plugin_page A pointer to the page whose actions should be - * removed from the user interface. - * - * @param merge A pointer to the UI manager data structure for a - * window. - */ -void gnc_plugin_page_unmerge_actions (GncPluginPage *plugin_page, - GtkUIManager *merge); + GtkWidget *window); //FIXMEb added /** Retrieve the textual name of a plugin. diff --git a/gnucash/gnome-utils/gnc-plugin.c b/gnucash/gnome-utils/gnc-plugin.c index 318808da34..a85aff94b8 100644 --- a/gnucash/gnome-utils/gnc-plugin.c +++ b/gnucash/gnome-utils/gnc-plugin.c @@ -262,84 +262,5 @@ gnc_plugin_set_actions_enabled (GSimpleActionGroup *simple_action_group, } } -/** Load a new set of actions into an existing UI. - * - * See gnc-plugin.h for documentation on the function arguments. */ -gint -gnc_plugin_add_actions (GtkUIManager *ui_merge, - GtkActionGroup *action_group, - const gchar *filename) -{ - GError *error = NULL; - gchar *pathname; - gint merge_id; - - g_return_val_if_fail (ui_merge, 0); - g_return_val_if_fail (action_group, 0); - g_return_val_if_fail (filename, 0); - - ENTER("ui_merge %p, action_group %p, filename %s", - ui_merge, action_group, filename); - gtk_ui_manager_insert_action_group (ui_merge, action_group, 0); - - pathname = gnc_filepath_locate_ui_file (filename); - if (pathname == NULL) - { - LEAVE("fail"); - return 0; - } - - merge_id = gtk_ui_manager_add_ui_from_file (ui_merge, pathname, &error); - DEBUG("merge_id is %d", merge_id); - - g_assert(merge_id || error); - if (merge_id) - { - gtk_ui_manager_ensure_update (ui_merge); - } - else - { - g_critical("Failed to load ui file.\n Filename %s\n Error %s", - filename, error->message); - g_error_free(error); - } - - g_free(pathname); - LEAVE(" "); - return merge_id; -} - -#if 0 -static void -gnc_plugin_base_init (gpointer klass) -{ - static gboolean initialized = FALSE; - - if (!initialized) - { - initialized = TRUE; - - signals[MERGE_ACTIONS] = g_signal_new ("merge-actions", - G_OBJECT_CLASS_TYPE (klass), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (GncPluginClass, merge_actions), - NULL, NULL, - g_cclosure_marshal_VOID__POINTER, - G_TYPE_NONE, - 1, - GTK_TYPE_MENU_MERGE); - signals[UNMERGE_ACTIONS] = g_signal_new ("unmerge-actions", - G_OBJECT_CLASS_TYPE (klass), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (GncPluginClass, unmerge_actions), - NULL, NULL, - g_cclosure_marshal_VOID__POINTER, - G_TYPE_NONE, - 1, - GTK_TYPE_MENU_MERGE); - } -} -#endif - /** @} */ /** @} */ diff --git a/gnucash/gnome-utils/gnc-plugin.h b/gnucash/gnome-utils/gnc-plugin.h index 612937606d..d0a1281f46 100644 --- a/gnucash/gnome-utils/gnc-plugin.h +++ b/gnucash/gnome-utils/gnc-plugin.h @@ -268,24 +268,6 @@ void gnc_plugin_set_actions_enabled (GSimpleActionGroup *simple_action_group, const gchar **action_names, gboolean enable); //FIXMEb added -/** Load a new set of actions into an existing UI. The actions from - * the provided group will be merged into the pre-existing ui, as - * directed by the specified file. - * - * @param ui_merge A pointer to the UI manager data structure for a - * window. - * - * @param action_group The set of actions provided by a given plugin. - * - * @param filename The name of the ui description file. This file - * name will be searched for in the ui directory. - * - * @return The merge_id number for the newly merged UI. If an error - * occurred, the return value is 0. - */ -gint gnc_plugin_add_actions (GtkUIManager *ui_merge, - GtkActionGroup *action_group, - const gchar *filename); G_END_DECLS #endif /* __GNC_PLUGIN_H */ From 42d13eb6f4c8b7479875316aa8c23f5382af242a Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Fri, 28 Oct 2022 16:49:20 +0100 Subject: [PATCH 37/77] Remove some more GtkUIManager functions from gnc-main-window --- gnucash/gnome-utils/gnc-main-window.cpp | 71 ++++--------------------- gnucash/gnome-utils/gnc-main-window.h | 30 ++++------- 2 files changed, 22 insertions(+), 79 deletions(-) diff --git a/gnucash/gnome-utils/gnc-main-window.cpp b/gnucash/gnome-utils/gnc-main-window.cpp index a21327d7f3..04f146ff5e 100644 --- a/gnucash/gnome-utils/gnc-main-window.cpp +++ b/gnucash/gnome-utils/gnc-main-window.cpp @@ -247,7 +247,6 @@ typedef struct GncMainWindowPrivate /** The group of all actions provided by the main window * itself. This does not include any action provided by menu * or content plugins. */ - GtkActionGroup *action_group; GSimpleActionGroup *simple_action_group; //FIXMEb added /** A list of all pages that are installed in this window. */ GList *installed_pages; @@ -288,12 +287,8 @@ GNC_DEFINE_TYPE_WITH_CODE(GncMainWindow, gnc_main_window, GTK_TYPE_WINDOW, * that has been installed in this window. */ typedef struct { - /** The merge identifier for this action group. This number - * is provided by the UI manager. */ - guint merge_id; /** The action group itself. This contains all actions added * by a single menu or content plugin. */ - GtkActionGroup *action_group; GSimpleActionGroup *simple_action_group; //FIXMEb added } MergedActionEntry; @@ -3551,22 +3546,19 @@ gnc_main_window_get_current_page (GncMainWindow *window) void gnc_main_window_manual_merge_actions (GncMainWindow *window, const gchar *group_name, - GtkActionGroup *group, - guint merge_id) + GSimpleActionGroup *group) { GncMainWindowPrivate *priv; MergedActionEntry *entry; g_return_if_fail (GNC_IS_MAIN_WINDOW (window)); g_return_if_fail (group_name != nullptr); - g_return_if_fail (GTK_IS_ACTION_GROUP(group)); - g_return_if_fail (merge_id > 0); + g_return_if_fail (G_IS_SIMPLE_ACTION_GROUP(group)); priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); entry = g_new0 (MergedActionEntry, 1); - entry->action_group = group; - entry->merge_id = merge_id; - gtk_ui_manager_ensure_update (window->ui_merge); + entry->simple_action_group = group; + g_hash_table_insert (priv->merged_actions_table, g_strdup (group_name), entry); } @@ -4228,19 +4220,19 @@ gnc_main_window_init_menu_updaters (GncMainWindow *window) static void gnc_main_window_window_menu (GncMainWindow *window) { - guint merge_id; +// guint merge_id; #ifdef MAC_INTEGRATION - gchar *filename = gnc_filepath_locate_ui_file("gnc-windows-menu-ui-quartz.xml"); + gchar *filename = gnc_filepath_locate_ui_file ("gnc-windows-menu-ui-quartz.xml"); #else - gchar *filename = gnc_filepath_locate_ui_file("gnc-windows-menu-ui.xml"); + gchar *filename = gnc_filepath_locate_ui_file ("gnc-windows-menu-ui.xml"); GncMainWindowPrivate *priv; #endif GError *error = nullptr; g_assert(filename); - merge_id = gtk_ui_manager_add_ui_from_file (window->ui_merge, filename, - &error); - g_free(filename); - g_assert(merge_id); +//FIXMEb merge_id = gtk_ui_manager_add_ui_from_file (window->ui_merge, filename, +// &error); + g_free (filename); +// g_assert(merge_id); #ifndef MAC_INTEGRATION priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); @@ -4301,7 +4293,6 @@ gnc_main_window_setup_window (GncMainWindow *window) { GncMainWindowPrivate *priv; GtkWidget *main_vbox; -// guint merge_id; GtkBuilder *builder; GncPluginManager *manager; GtkAccelGroup *accel_group = gtk_accel_group_new (); @@ -4383,15 +4374,8 @@ gnc_main_window_setup_window (GncMainWindow *window) gtk_container_add (GTK_CONTAINER(priv->menu_dock), GTK_WIDGET(priv->toolbar)); //FIXMEb this may need changing gtk_widget_show (GTK_WIDGET(priv->toolbar)); -//FIXMEb window->ui_merge = gtk_ui_manager_new (); - - /* Create menu and toolbar information */ -// priv->action_group = gtk_action_group_new ("MainWindowActions"); - priv->simple_action_group = g_simple_action_group_new (); -//FIXMEb gtk_action_group_set_translation_domain (priv->action_group, PROJECT_NAME); - g_action_map_add_action_entries (G_ACTION_MAP(priv->simple_action_group), gnc_menu_actions, gnc_menu_n_actions, @@ -4407,42 +4391,9 @@ gnc_main_window_setup_window (GncMainWindow *window) gnc_main_window_menu_item_vis_by_action (window, always_hidden_actions, false); - -// gtk_ui_manager_insert_action_group (window->ui_merge, priv->action_group, 0); - gtk_widget_insert_action_group (GTK_WIDGET(window), "mainwin", G_ACTION_GROUP(priv->simple_action_group)); -//FIXMEb g_signal_connect (G_OBJECT (window->ui_merge), "add_widget", -// G_CALLBACK (gnc_main_window_add_widget), window); - - /* Use the "connect-proxy" signal for tooltip display in the status bar */ -//FIXMEb g_signal_connect (G_OBJECT (window->ui_merge), "connect-proxy", -// G_CALLBACK (gnc_window_connect_proxy), priv->statusbar); - -// filename = gnc_filepath_locate_ui_file("gnc-main-window.ui"); - -// merge_id = gtk_ui_manager_add_ui_from_file (window->ui_merge, -// filename, &error); -// g_assert(merge_id || error); -// if (merge_id) -// { - -//FIXMEb gtk_window_add_accel_group (GTK_WINDOW (window), -// gtk_ui_manager_get_accel_group(window->ui_merge)); - -// gtk_ui_manager_ensure_update (window->ui_merge); -// } -// else -// { -// g_critical("Failed to load ui file.\n Filename %s\n Error %s", -// filename, error->message); -// g_error_free(error); -// g_assert(merge_id != 0); -// } -// g_free(filename); - - //FIXMEb gnc_main_window_window_menu (window); may need to use some thing like this gnc_prefs_register_cb (GNC_PREFS_GROUP_GENERAL, diff --git a/gnucash/gnome-utils/gnc-main-window.h b/gnucash/gnome-utils/gnc-main-window.h index d3d720ed5e..12e368f1f9 100644 --- a/gnucash/gnome-utils/gnc-main-window.h +++ b/gnucash/gnome-utils/gnc-main-window.h @@ -73,18 +73,15 @@ typedef struct /** The instance data structure for a main window object. */ typedef struct GncMainWindow { - GtkWindow gtk_window; /**< The parent object for a main window. */ - GtkUIManager *ui_merge; /**< A pointer to the UI Manager data - structure for the whole window. */ - gboolean window_quitting; /**< Set to TRUE when quitting from this window. */ + GtkWindow gtk_window; /**< The parent object for a main window. */ + gboolean window_quitting; /**< Set to TRUE when quitting from this window. */ gboolean just_plugin_prefs; /**< Just remove preferences only from plugins */ } GncMainWindow; /** The class data structure for a main window object. */ typedef struct { - GtkWindowClass gtk_window; /**< The parent class for a - main window. */ + GtkWindowClass gtk_window; /**< The parent class for a main window. */ /* callbacks */ void (*page_added) (GncMainWindow *window, @@ -154,12 +151,12 @@ void gnc_main_window_open_page (GncMainWindow *window, void gnc_main_window_close_page (GncPluginPage *page); -/* Iterator function to walk all pages in all windows, calling the - * specified function for each page. +/** Iterator function to walk all pages in all windows, calling the + * specified function for each page. * - * @param entry A pointer to the function to be called. + * @param entry A pointer to the function to be called. * - * @param user_data A data pointer passed to each call of the function. + * @param user_data A data pointer passed to each call of the function. */ void gnc_main_window_foreach_page (GncMainWindowPageFunc fn, gpointer user_data); @@ -221,16 +218,11 @@ main_window_update_page_set_read_only_icon (GncPluginPage *page, * should be unique among all groups added to the window, and will be * needed to remove the actions from this window. * - * @param group A pointer to an array of GtkActions. These are the - * actions that will be added to the user interface. - * - * @param merge_id A merge identifier retrieved from a call to - * gtk_ui_manager_new_merge_id(). + * @param group A pointer to the GSimpleActionGroup. */ void gnc_main_window_manual_merge_actions (GncMainWindow *window, - const gchar *group_name, - GtkActionGroup *group, - guint merge_id); + const gchar *group_name, + GSimpleActionGroup *group); /** Add a set of actions to the specified window. This function @@ -246,7 +238,7 @@ void gnc_main_window_manual_merge_actions (GncMainWindow *window, * should be unique among all groups added to the window, and will be * needed to remove the actions from this window. * - * @param entries A pointer to an array of GtkActionEntry. These + * @param entries A pointer to an array of GActionEntry. These * are the actions that will be added to the user interface. * * @param n_entries The number of actions in the array. From a33b63fbae273cc0940cf3e8b405ac89b5f6fbad Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Fri, 28 Oct 2022 16:49:58 +0100 Subject: [PATCH 38/77] Misc changes to remove references to GtkUIManger --- gnucash/gnome-utils/gnc-main-window.cpp | 55 +------------------------ gnucash/gnome-utils/gnc-window.c | 6 ++- gnucash/gnome-utils/gnc-window.h | 8 ++-- gnucash/gnome/dialog-sx-editor.c | 2 +- 4 files changed, 10 insertions(+), 61 deletions(-) diff --git a/gnucash/gnome-utils/gnc-main-window.cpp b/gnucash/gnome-utils/gnc-main-window.cpp index 04f146ff5e..5f2cdb472b 100644 --- a/gnucash/gnome-utils/gnc-main-window.cpp +++ b/gnucash/gnome-utils/gnc-main-window.cpp @@ -166,7 +166,6 @@ static void gnc_main_window_update_all_menu_items (void); #endif /* Callbacks */ -static void gnc_main_window_add_widget (GtkUIManager *merge, GtkWidget *widget, GncMainWindow *window); static void gnc_main_window_switch_page (GtkNotebook *notebook, gpointer *notebook_page, gint pos, GncMainWindow *window); static void gnc_main_window_page_reordered (GtkNotebook *notebook, GtkWidget *child, guint pos, GncMainWindow *window); static void gnc_main_window_plugin_added (GncPlugin *manager, GncPlugin *plugin, GncMainWindow *window); @@ -2021,8 +2020,7 @@ gnc_main_window_update_radio_button (GncMainWindow *window) /** In every window that the user has open, update the "Window" menu * item that points to the specified window. This keeps the "Window" - * menu items consistent across all open windows. (These items - * cannot be shared because of the way the GtkUIManager code works.) + * menu items consistent across all open windows. * * This function is called whenever the user switches pages in a * window, or whenever a window is added or deleted. @@ -4217,35 +4215,6 @@ gnc_main_window_init_menu_updaters (GncMainWindow *window) G_CALLBACK(gnc_main_window_edit_menu_hide_cb), window); } -static void -gnc_main_window_window_menu (GncMainWindow *window) -{ -// guint merge_id; -#ifdef MAC_INTEGRATION - gchar *filename = gnc_filepath_locate_ui_file ("gnc-windows-menu-ui-quartz.xml"); -#else - gchar *filename = gnc_filepath_locate_ui_file ("gnc-windows-menu-ui.xml"); - GncMainWindowPrivate *priv; -#endif - GError *error = nullptr; - g_assert(filename); -//FIXMEb merge_id = gtk_ui_manager_add_ui_from_file (window->ui_merge, filename, -// &error); - g_free (filename); -// g_assert(merge_id); -#ifndef MAC_INTEGRATION - priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); - -//FIXMEb Not sure what here, may need to move some stuff from below. - -//FIXMEb gtk_action_group_add_radio_actions (priv->action_group, -// radio_entries, n_radio_entries, -// 0, -// G_CALLBACK(gnc_main_window_cmd_window_raise), -// window); -#endif -}; - /* This is used to prevent the tab having focus */ static gboolean gnc_main_window_page_focus_in (GtkWidget *widget, GdkEvent *event, @@ -4394,8 +4363,6 @@ gnc_main_window_setup_window (GncMainWindow *window) gtk_widget_insert_action_group (GTK_WIDGET(window), "mainwin", G_ACTION_GROUP(priv->simple_action_group)); -//FIXMEb gnc_main_window_window_menu (window); may need to use some thing like this - gnc_prefs_register_cb (GNC_PREFS_GROUP_GENERAL, GNC_PREF_TAB_POSITION_TOP, (gpointer)gnc_main_window_update_tab_position, @@ -4515,26 +4482,6 @@ gnc_quartz_set_menu(GncMainWindow* window) #endif //MAC_INTEGRATION /* Callbacks */ -static void -gnc_main_window_add_widget (GtkUIManager *merge, - GtkWidget *widget, - GncMainWindow *window) -{ - GncMainWindowPrivate *priv; - - priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); - if (GTK_IS_TOOLBAR (widget)) - { - priv->toolbar = widget; - gtk_toolbar_set_style (GTK_TOOLBAR(priv->toolbar), - GTK_TOOLBAR_BOTH); - gtk_toolbar_set_icon_size (GTK_TOOLBAR(priv->toolbar), - GTK_ICON_SIZE_SMALL_TOOLBAR); - } - - gtk_box_pack_start (GTK_BOX (priv->menu_dock), widget, FALSE, FALSE, 0); - gtk_widget_show (widget); -} /** Should a summary bar be visible in this window? In order to * prevent synchronization issues, the "ViewSummaryBar" diff --git a/gnucash/gnome-utils/gnc-window.c b/gnucash/gnome-utils/gnc-window.c index a13ea630e7..0cd6168671 100644 --- a/gnucash/gnome-utils/gnc-window.c +++ b/gnucash/gnome-utils/gnc-window.c @@ -265,7 +265,7 @@ gnc_window_show_progress (const char *message, double percentage) typedef struct _ActionStatus ActionStatus; struct _ActionStatus { - GtkAction *action; + GAction *action; GtkWidget *statusbar; }; @@ -310,9 +310,10 @@ unset_tip (GtkWidget *widget) gtk_statusbar_pop (GTK_STATUSBAR (data->statusbar), 0); } +#ifdef skip //FIXMEb void gnc_window_connect_proxy (GtkUIManager *merge, - GtkAction *action, + GAction *action, GtkWidget *proxy, GtkWidget *statusbar) { @@ -344,4 +345,5 @@ gnc_window_connect_proxy (GtkUIManager *merge, } } } +#endif /* CS: end copied code from gtk+/test/testmerge.c */ diff --git a/gnucash/gnome-utils/gnc-window.h b/gnucash/gnome-utils/gnc-window.h index 830c90afd1..83dd06e625 100644 --- a/gnucash/gnome-utils/gnc-window.h +++ b/gnucash/gnome-utils/gnc-window.h @@ -96,10 +96,10 @@ GMenuModel *gnc_window_get_menubar_model (GncWindow *window); * * @param statusbar A pointer to the statusbar widget */ -void gnc_window_connect_proxy (GtkUIManager *merge, - GtkAction *action, - GtkWidget *proxy, - GtkWidget *statusbar); +//FIXMEbvoid gnc_window_connect_proxy (GtkUIManager *merge, +// GAction *action, +// GtkWidget *proxy, +// GtkWidget *statusbar); G_END_DECLS diff --git a/gnucash/gnome/dialog-sx-editor.c b/gnucash/gnome/dialog-sx-editor.c index e11d96c6c3..f814b4a7bc 100644 --- a/gnucash/gnome/dialog-sx-editor.c +++ b/gnucash/gnome/dialog-sx-editor.c @@ -1284,7 +1284,7 @@ gnc_ui_scheduled_xaction_editor_dialog_create (GtkWindow *parent, /* populate */ schedXact_editor_populate (sxed); - /* Do not call show_all here. Screws up the gtkuimanager code */ + /* Do not call show_all here */ gtk_widget_show (sxed->dialog); gtk_notebook_set_current_page (GTK_NOTEBOOK (sxed->notebook), 0); From 54c79aef4204b63695a93a6e62ac275803ac3191 Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Fri, 28 Oct 2022 16:50:39 +0100 Subject: [PATCH 39/77] Remove gnc_main_window_actions_updated from gnc_main_window --- gnucash/gnome-utils/gnc-main-window.cpp | 24 ------------------- gnucash/gnome-utils/gnc-main-window.h | 12 ---------- gnucash/gnome-utils/gnc-plugin-file-history.c | 1 - 3 files changed, 37 deletions(-) diff --git a/gnucash/gnome-utils/gnc-main-window.cpp b/gnucash/gnome-utils/gnc-main-window.cpp index 5f2cdb472b..4b1239ce20 100644 --- a/gnucash/gnome-utils/gnc-main-window.cpp +++ b/gnucash/gnome-utils/gnc-main-window.cpp @@ -3702,30 +3702,6 @@ gnc_main_window_unmerge_actions (GncMainWindow *window, } -/* Force a full update of the user interface for the specified - * window. This can be an expensive function, but is needed because - * the gtk ui manager doesn't always seem to update properly when - * actions are changed. - */ -void -gnc_main_window_actions_updated (GncMainWindow *window) -{ - GSimpleActionGroup *simple_action_group; - - g_return_if_fail (GNC_IS_MAIN_WINDOW(window)); - - /* Unfortunately gtk_ui_manager_ensure_update doesn't work - * here. Force a full update by adding and removing an empty - * action group. - */ -//FIXMEb force = gtk_action_group_new("force_update"); -// gtk_ui_manager_insert_action_group (window->ui_merge, force, 0); -// gtk_ui_manager_ensure_update (window->ui_merge); -// gtk_ui_manager_remove_action_group (window->ui_merge, force); -// g_object_unref(force); -} - - struct group_iterate { GAction *action; diff --git a/gnucash/gnome-utils/gnc-main-window.h b/gnucash/gnome-utils/gnc-main-window.h index 12e368f1f9..8a0d49430c 100644 --- a/gnucash/gnome-utils/gnc-main-window.h +++ b/gnucash/gnome-utils/gnc-main-window.h @@ -279,18 +279,6 @@ void gnc_main_window_unmerge_actions (GncMainWindow *window, const gchar *group_name); -/** Force a full update of the user interface for the specified - * window. This can be an expensive function, but is needed because - * the gtk ui manager doesn't always seem to update properly when - * actions are changed. - * - * @param window A pointer to the window whose user interface should - * be updated. - * - * @attention Is this function still needed? - */ -void gnc_main_window_actions_updated (GncMainWindow *window); - void gnc_main_window_menu_item_vis_by_action (GncMainWindow *window, const gchar **action_names, gboolean vis); //FIXMEb added diff --git a/gnucash/gnome-utils/gnc-plugin-file-history.c b/gnucash/gnome-utils/gnc-plugin-file-history.c index 3116ce5794..2b016d758b 100644 --- a/gnucash/gnome-utils/gnc-plugin-file-history.c +++ b/gnucash/gnome-utils/gnc-plugin-file-history.c @@ -547,7 +547,6 @@ gnc_plugin_history_list_changed (gpointer prefs, gnc_history_update_action (window, index, filename); g_free (filename); - gnc_main_window_actions_updated (window); LEAVE(""); } From e0b55dd707b8b825083ed456f8294964032b6a2b Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Fri, 28 Oct 2022 16:51:17 +0100 Subject: [PATCH 40/77] Remove function gnc_main_window_all_ui_set_sensitive Do not think it is needed... --- gnucash/gnome-utils/gnc-main-window.cpp | 29 ------------------------- 1 file changed, 29 deletions(-) diff --git a/gnucash/gnome-utils/gnc-main-window.cpp b/gnucash/gnome-utils/gnc-main-window.cpp index 4b1239ce20..32281cb30a 100644 --- a/gnucash/gnome-utils/gnc-main-window.cpp +++ b/gnucash/gnome-utils/gnc-main-window.cpp @@ -5601,34 +5601,6 @@ gnc_main_window_get_menubar_model (GncWindow *window) } -static void -gnc_main_window_all_ui_set_sensitive (GncWindow *unused, gboolean sensitive) -{ -//FIXMEb -#ifdef skip - for (auto winp = active_windows; winp; winp = g_list_next(winp)) - { - auto window{static_cast(winp->data)}; - auto priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); - - auto groups = gtk_ui_manager_get_action_groups(window->ui_merge); - for (auto groupp = groups; groupp; groupp = g_list_next(groupp)) - { - gtk_action_group_set_sensitive(GTK_ACTION_GROUP(groupp->data), sensitive); - } - - for (auto tmp = priv->installed_pages; tmp; tmp = g_list_next(tmp)) - { - auto close_button{static_cast(g_object_get_data(static_cast(tmp->data), PLUGIN_PAGE_CLOSE_BUTTON))}; - if (!close_button) - continue; - gtk_widget_set_sensitive (close_button, sensitive); - } - } -#endif -} - - /** Initialize the generic window interface for a main window. * * @param iface A pointer to the interface data structure to @@ -5639,7 +5611,6 @@ gnc_window_main_window_init (GncWindowIface *iface) iface->get_gtk_window = gnc_main_window_get_gtk_window; iface->get_statusbar = gnc_main_window_get_statusbar; iface->get_progressbar = gnc_main_window_get_progressbar; - iface->ui_set_sensitive = gnc_main_window_all_ui_set_sensitive; iface->get_menubar = gnc_main_window_get_menubar; iface->get_toolbar = gnc_main_window_get_toolbar; iface->get_menubar_model = gnc_main_window_get_menubar_model; From 4f8643674bcaa2726a6558cb0c40f53dca4ac2b8 Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Fri, 28 Oct 2022 16:52:00 +0100 Subject: [PATCH 41/77] Remove all references to GncDisplayItem --- gnucash/gnome-utils/gnc-main-window.cpp | 129 ----------- gnucash/gnome-utils/gnc-main-window.h | 15 -- gnucash/gnome-utils/gnc-plugin.c | 1 - gnucash/gnome-utils/gnc-plugin.h | 5 - gnucash/gnome/gnc-plugin-page-account-tree.c | 102 --------- gnucash/gnome/gnc-plugin-page-budget.c | 53 ----- gnucash/gnome/gnc-plugin-page-invoice.c | 109 ---------- gnucash/gnome/gnc-plugin-page-owner-tree.c | 84 -------- gnucash/gnome/gnc-plugin-page-register.c | 200 ------------------ gnucash/gnome/gnc-plugin-page-report.cpp | 62 ------ gnucash/gnome/gnc-plugin-page-sx-list.c | 24 --- gnucash/ui/gnc-plugin-page-register.ui | 7 + .../gnc-module/example/gnc-plugin.example.c | 12 -- 13 files changed, 7 insertions(+), 796 deletions(-) diff --git a/gnucash/gnome-utils/gnc-main-window.cpp b/gnucash/gnome-utils/gnc-main-window.cpp index 32281cb30a..184c44da0f 100644 --- a/gnucash/gnome-utils/gnc-main-window.cpp +++ b/gnucash/gnome-utils/gnc-main-window.cpp @@ -356,133 +356,6 @@ static GActionEntry gnc_menu_actions [] = /** The number of actions provided by the main window. */ static guint gnc_menu_n_actions = G_N_ELEMENTS(gnc_menu_actions); -static GncDisplayItem gnc_menu_display_items [] = -{ - /* File menu */ - { "FileImportAction", nullptr, N_("_Import"), nullptr, nullptr }, - { "FileExportAction", nullptr, N_("_Export"), nullptr, nullptr }, - { - "FilePrintAction", "document-print", N_("_Print..."), "p", - N_("Print the currently active page") - }, -#ifndef GTK_STOCK_PAGE_SETUP -# define GTK_STOCK_PAGE_SETUP nullptr -#endif - { - "FilePageSetupAction", "document-page-setup", N_("Pa_ge Setup..."), "p", - N_("Specify the page size and orientation for printing") - }, - { - "FilePropertiesAction", "document-properties", N_("Proper_ties"), "Return", - N_("Edit the properties of the current file") - }, - { - "FileCloseAction", "window-close", N_("_Close"), "W", - N_("Close the currently active page") - }, - { - "FileQuitAction", "application-exit", N_("_Quit"), "Q", - N_("Quit this application") - }, - /* Edit menu */ - { - "EditCutAction", "edit-cut", N_("Cu_t"), "X", - N_("Cut the current selection and copy it to clipboard") - }, - { - "EditCopyAction", "edit-copy", N_("_Copy"), "C", - N_("Copy the current selection to clipboard") - }, - { - "EditPasteAction", "edit-paste", N_("_Paste"), "V", - N_("Paste the clipboard content at the cursor position") - }, - { - "EditPreferencesAction", "preferences-system", N_("Pr_eferences"), nullptr, - N_("Edit the global preferences of GnuCash") - }, - /* View menu */ - { "ViewTabPositionAction", nullptr, N_("Tab P_osition"), nullptr, nullptr }, - { - "ViewSortByAction", nullptr, N_("_Sort By..."), nullptr, - N_("Select sorting criteria for this page view") - }, - { - "ViewFilterByAction", nullptr, N_("_Filter By..."), nullptr, - N_("Select the account types that should be displayed.") - }, - { - "ViewRefreshAction", "view-refresh", N_("_Refresh"), "r", - N_("Refresh this window") - }, - /* Actions menu */ - { "ScrubMenuAction", nullptr, N_("_Check & Repair"), nullptr, nullptr }, - { - "ActionsForgetWarningsAction", nullptr, N_("Reset _Warnings..."), nullptr, - N_("Reset the state of all warning messages so they will be shown again.") - }, - { - "ActionsRenamePageAction", nullptr, N_("Re_name Page"), nullptr, - N_("Rename this page.") - }, - /* Windows menu */ - { - "WindowNewAction", nullptr, N_("_New Window"), nullptr, - N_("Open a new top-level GnuCash window.") - }, - { - "WindowMovePageAction", nullptr, N_("New Window with _Page"), nullptr, - N_("Move the current page to a new top-level GnuCash window.") - }, - /* Help menu */ - { - "HelpTutorialAction", "help-browser", N_("Tutorial and Concepts _Guide"), "H", - N_("Open the GnuCash Tutorial") - }, - { - "HelpContentsAction", "help-browser", N_("_Contents"), "F1", - N_("Open the GnuCash Help") - }, - { - "HelpAboutAction", "help-about", N_("_About"), nullptr, - N_("About GnuCash") - }, - /* Toggle actions */ - { - "ViewToolbarAction", nullptr, N_("_Toolbar"), nullptr, - N_("Show/hide the toolbar on this window") - }, - { - "ViewSummaryAction", nullptr, N_("Su_mmary Bar"), nullptr, - N_("Show/hide the summary bar on this window") - }, - { - "ViewStatusbarAction", nullptr, N_("Stat_us Bar"), nullptr, - N_("Show/hide the status bar on this window") - }, - { "ViewTabPositionAction", nullptr, N_("Tab P_osition"), nullptr, - nullptr - }, - { - "ViewTabPositionTopAction", nullptr, N_("To_p"), nullptr, - N_("Display the notebook tabs at the top of the window.") - }, - { - "ViewTabPositionBottomAction", nullptr, N_("B_ottom"), nullptr, - N_("Display the notebook tabs at the bottom of the window.") - }, - { - "ViewTabPositionLeftAction", nullptr, N_("_Left"), nullptr, - N_("Display the notebook tabs at the left of the window.") - }, - { - "ViewTabPositionRightAction", nullptr, N_("_Right"), nullptr, - N_("Display the notebook tabs at the right of the window.") - }, -}; -/** The number of display items provided by the main window. */ -static guint gnc_menu_n_display_items = G_N_ELEMENTS(gnc_menu_display_items); - /** The following are in the main window so they will always be * present in the menu structure, but they are never sensitive. * These actions should be overridden in child windows where they @@ -3619,8 +3492,6 @@ gnc_main_window_merge_actions (GncMainWindow *window, const gchar *group_name, GActionEntry *actions, guint n_actions, - GncDisplayItem *display_items, - guint n_display_items, const gchar **ui_updates, const gchar *ui_filename, gpointer user_data) diff --git a/gnucash/gnome-utils/gnc-main-window.h b/gnucash/gnome-utils/gnc-main-window.h index 8a0d49430c..87bdd5fd03 100644 --- a/gnucash/gnome-utils/gnc-main-window.h +++ b/gnucash/gnome-utils/gnc-main-window.h @@ -55,15 +55,6 @@ extern "C" /* typedefs & structures */ -typedef struct -{ - const gchar *action_name; - const gchar *icon_name; - const gchar *label; - const gchar *accelerator; - const gchar *tooltip; -} GncDisplayItem; - typedef struct { const gchar *actions; @@ -243,10 +234,6 @@ void gnc_main_window_manual_merge_actions (GncMainWindow *window, * * @param n_entries The number of actions in the array. * - * @param display_items A pointer to an array of GncDisplayItem. - * - * @param n_display_items The number of display items in the array. - * * @param filename The filename containing the user interface * definition that goes with this set of actions. * @@ -257,8 +244,6 @@ void gnc_main_window_merge_actions (GncMainWindow *window, const gchar *group_name, GActionEntry *entries, guint n_entries, - GncDisplayItem *display_items, - guint n_display_items, const gchar **ui_updates, const gchar *ui_filename, gpointer user_data); diff --git a/gnucash/gnome-utils/gnc-plugin.c b/gnucash/gnome-utils/gnc-plugin.c index a85aff94b8..327bceb029 100644 --- a/gnucash/gnome-utils/gnc-plugin.c +++ b/gnucash/gnome-utils/gnc-plugin.c @@ -147,7 +147,6 @@ gnc_plugin_add_to_window (GncPlugin *plugin, klass->actions_name, klass->n_actions, klass->ui_filename); gnc_main_window_merge_actions (window, klass->actions_name, klass->actions, klass->n_actions, - klass->display_items, klass->n_display_items, klass->ui_updates, klass->ui_filename, plugin); } diff --git a/gnucash/gnome-utils/gnc-plugin.h b/gnucash/gnome-utils/gnc-plugin.h index d0a1281f46..9ab2ccee25 100644 --- a/gnucash/gnome-utils/gnc-plugin.h +++ b/gnucash/gnome-utils/gnc-plugin.h @@ -123,11 +123,6 @@ typedef struct /** The number of actions in the actions array. */ guint n_actions; //FIXMEb added - /** An array of display items (menu / toolbar entries) */ - GncDisplayItem *display_items; //FIXMEb added - /** The number of display_items in the display item array. */ - guint n_display_items; //FIXMEb added - /** An array of ui updates for the menu model */ const gchar **ui_updates; //FIXMEb added diff --git a/gnucash/gnome/gnc-plugin-page-account-tree.c b/gnucash/gnome/gnc-plugin-page-account-tree.c index 5ebe80882f..d2486c4ebd 100644 --- a/gnucash/gnome/gnc-plugin-page-account-tree.c +++ b/gnucash/gnome/gnc-plugin-page-account-tree.c @@ -213,108 +213,6 @@ static GActionEntry gnc_plugin_page_account_tree_actions [] = /** The number of actions provided by this plugin. */ static guint gnc_plugin_page_account_tree_n_actions = G_N_ELEMENTS(gnc_plugin_page_account_tree_actions); -static GncDisplayItem gnc_plugin_page_account_tree_display_items [] = -{ - /* File menu */ - { - "FileNewAccountAction", GNC_ICON_NEW_ACCOUNT, N_("New _Account..."), NULL, - N_("Create a new Account") - }, - { - "FileAddAccountHierarchyAssistantAction", GNC_ICON_NEW_ACCOUNT, N_("New Account _Hierarchy..."), NULL, - N_("Extend the current book by merging with new account type categories") - }, - { - "EditOpenAccountAction", GNC_ICON_OPEN_ACCOUNT, N_("Open _Account"), NULL, - N_("Open the selected account") - }, - { - "EditOpenSubaccountsAction", GNC_ICON_OPEN_ACCOUNT, N_("Open _SubAccounts"), NULL, - N_("Open the selected account and all its subaccounts") - }, - /* Edit menu */ - { - "EditEditAccountAction", GNC_ICON_EDIT_ACCOUNT, N_("Edit _Account"), "e", - N_("Edit the selected account") - }, - { - "EditDeleteAccountAction", GNC_ICON_DELETE_ACCOUNT, N_("_Delete Account..."), "Delete", - N_("Delete selected account") - }, - { - "EditCascadeAccountAction", NULL, N_("_Cascade Account Properties..."), NULL, - N_("Cascade selected properties for account") - }, - { - "EditFindAccountAction", "edit-find", N_("F_ind Account"), "i", - N_("Find an account") - }, - { - "EditFindAccountPopupAction", "edit-find", N_("F_ind Account"), "i", - N_("Find an account") - }, - { - "EditRenumberSubaccountsAction", NULL, N_("_Renumber Subaccounts..."), NULL, - N_("Renumber the children of the selected account") - }, - { - "EditTaxOptionsAction", NULL, - /* Translators: remember to reuse this - translation in dialog-account.glade */ - N_("Ta_x Report Options"), NULL, - /* Translators: currently implemented are - US: income tax and - DE: VAT - So adjust this string */ - N_("Setup relevant accounts for tax reports, e.g. US income tax") - }, - /* View menu */ - { - "ViewFilterByAction", NULL, N_("_Filter By..."), NULL, NULL - }, - { - "ViewRefreshAction", "view-refresh", N_("_Refresh"), "r", - N_("Refresh this window") - }, - /* Actions menu */ - { - "ActionsReconcileAction", NULL, N_("_Reconcile..."), NULL, - N_("Reconcile the selected account") - }, - { - "ActionsAutoClearAction", NULL, N_("_Auto-clear..."), NULL, - N_("Automatically clear individual transactions, given a cleared amount") - }, - { - "ActionsTransferAction", NULL, N_("_Transfer..."), "t", - N_("Transfer funds from one account to another") - }, - { - "ActionsStockSplitAction", NULL, N_("Stoc_k Split..."), NULL, - N_("Record a stock split or a stock merger") - }, - { - "ActionsLotsAction", NULL, N_("View _Lots..."), NULL, - N_("Bring up the lot viewer/editor window") - }, - { - "ScrubAction", NULL, N_("Check & Repair A_ccount"), NULL, - N_("Check for and repair unbalanced transactions and orphan splits " "in this account") - }, - { - "ScrubSubAction", NULL, N_("Check & Repair Su_baccounts"), NULL, - N_("Check for and repair unbalanced transactions and orphan splits " - "in this account and its subaccounts") - }, - { - "ScrubAllAction", NULL, N_("Check & Repair A_ll"), NULL, - N_("Check for and repair unbalanced transactions and orphan splits " "in all accounts") - }, -}; -/** The number of display items provided by this plugin. */ -static guint gnc_plugin_page_account_tree_n_display_items = G_N_ELEMENTS(gnc_plugin_page_account_tree_display_items); - - /** The default menu items that need to be add to the menu */ static const gchar *gnc_plugin_load_ui_items [] = { diff --git a/gnucash/gnome/gnc-plugin-page-budget.c b/gnucash/gnome/gnc-plugin-page-budget.c index 0f87144018..b1f51cadce 100644 --- a/gnucash/gnome/gnc-plugin-page-budget.c +++ b/gnucash/gnome/gnc-plugin-page-budget.c @@ -142,59 +142,6 @@ static GActionEntry gnc_plugin_page_budget_actions [] = }; static guint gnc_plugin_page_budget_n_actions = G_N_ELEMENTS(gnc_plugin_page_budget_actions); -static GncDisplayItem gnc_plugin_page_budget_display_items [] = -{ - /* File menu */ - { - "OpenAccountAction", GNC_ICON_OPEN_ACCOUNT, N_("Open _Account"), NULL, - N_("Open the selected account.") - }, - { - "OpenSubaccountsAction", GNC_ICON_OPEN_ACCOUNT, - N_("Open _Subaccounts"), NULL, - N_("Open the selected account and all its subaccounts.") - }, - /* Edit menu */ - { - "DeleteBudgetAction", GNC_ICON_DELETE_BUDGET, N_("_Delete Budget..."), - NULL, N_("Select this or another budget and delete it.") - }, - { - "OptionsBudgetAction", "document-properties", N_("Budget _Options..."), - NULL, N_("Edit this budget's options.") - }, - { - "EstimateBudgetAction", "system-run", N_("Esti_mate Budget..."), - NULL, - N_("Estimate a budget value for the selected accounts from past transactions.") - }, - { - "AllPeriodsBudgetAction", "system-run", N_("_All Periods..."), - NULL, - N_("Edit budget for all periods for the selected accounts.") - }, - { - "BudgetNoteAction", "text-x-generic", N_("Edit Note"), - NULL, - N_("Edit note for the selected account and period.") - }, - { - "BudgetReportAction", "system-run", N_("Budget Report"), - NULL, - N_("Run the budget report.") - }, - /* View menu */ - { - "ViewFilterByAction", NULL, N_("_Filter By..."), NULL, NULL - }, - { - "ViewRefreshAction", "view-refresh", N_("_Refresh"), "r", - N_("Refresh this window.") - }, -}; -/** The number of display items provided by this plugin. */ -static guint gnc_plugin_page_budget_n_display_items = G_N_ELEMENTS(gnc_plugin_page_budget_display_items); - /** The default menu items that need to be add to the menu */ static const gchar *gnc_plugin_load_ui_items [] = { diff --git a/gnucash/gnome/gnc-plugin-page-invoice.c b/gnucash/gnome/gnc-plugin-page-invoice.c index 22752a3a15..50245a310e 100644 --- a/gnucash/gnome/gnc-plugin-page-invoice.c +++ b/gnucash/gnome/gnc-plugin-page-invoice.c @@ -139,115 +139,6 @@ static GActionEntry gnc_plugin_page_invoice_actions [] = }; static guint gnc_plugin_page_invoice_n_actions = G_N_ELEMENTS(gnc_plugin_page_invoice_actions); -static GncDisplayItem gnc_plugin_page_invoice_display_items [] = -{ - { "SortOrderAction", NULL, N_("Sort _Order"), NULL, NULL }, - /* File menu */ - { - "FileNewAccountAction", GNC_ICON_NEW_ACCOUNT, N_("New _Account..."), NULL, - N_("Create a new account") - }, - { - "FilePrintAction", "document-print", N_("_Print Invoice"), "p", - N_("Make a printable invoice") - }, - /* Edit menu */ - { - "EditCutAction", "edit-cut", N_("_Cut"), "X", - NULL - }, - { - "EditCopyAction", "edit-copy", N_("Copy"), "C", - NULL - }, - { - "EditPasteAction", "edit-paste", N_("_Paste"), "V", - NULL - }, - { - "EditEditInvoiceAction", GNC_ICON_INVOICE_EDIT, "_Edit Invoice", NULL, - "Edit this invoice" - }, - { - "EditDuplicateInvoiceAction", GNC_ICON_INVOICE_DUPLICATE, "_Duplicate Invoice", - NULL, "Create a new invoice as a duplicate of the current one" - }, - { - "EditPostInvoiceAction", GNC_ICON_INVOICE_POST, "_Post Invoice", NULL, - "Post this invoice to your Chart of Accounts" - }, - { - "EditUnpostInvoiceAction", GNC_ICON_INVOICE_UNPOST, "_Unpost Invoice", NULL, - "Unpost this invoice and make it editable" - }, - /* View menu */ - { - "ViewRefreshAction", "view-refresh", N_("_Refresh"), "r", - N_("Refresh this window") - }, - { - "ViewSaveLayoutAction", NULL, "_Use as Default Layout for Customer Documents", NULL, - "Use the current layout as default for all customer invoices and credit notes" - }, - { - "ViewResetLayoutAction", NULL, "_Reset Default Layout for Customer Documents", NULL, - "Reset default layout for all customer invoices and credit notes back to built-in defaults and update the current page accordingly" - }, - /* Actions menu */ - { - "RecordEntryAction", "list-add", N_("_Enter"), NULL, - N_("Record the current entry") - }, - { - "CancelEntryAction", "process-stop", N_("_Cancel"), NULL, - N_("Cancel the current entry") - }, - { - "DeleteEntryAction", "edit-delete", N_("_Delete"), NULL, - N_("Delete the current entry") - }, - { - "BlankEntryAction", "go-bottom", N_("_Blank"), NULL, - "Move to the blank entry at the bottom of the Invoice" - }, - { - "DuplicateEntryAction", "edit-copy", N_("Dup_licate Entry"), NULL, - N_("Make a copy of the current entry") - }, - { - "EntryUpAction", "pan-up-symbolic", N_("Move Entry _Up"), NULL, - N_("Move the current entry one row upwards") - }, - { - "EntryDownAction", "pan-down-symbolic", N_("Move Entry Do_wn"), NULL, - N_("Move the current entry one row downwards") - }, - /* Business menu */ - { - "BusinessNewInvoiceAction", GNC_ICON_INVOICE_NEW, "New _Invoice", "", - "Create a new invoice for the same owner as the current one" - }, - { - "BusinessLinkAction", NULL, "_Manage Document Link...", NULL, - "Manage link of an external document to this item." - }, - { - "BusinessLinkOpenAction", NULL, "_Open Linked Document", NULL, - "Open the linked document" - }, - { - "ToolsProcessPaymentAction", GNC_ICON_INVOICE_PAY, "_Pay Invoice", NULL, - "Enter a payment for the owner of this invoice" - }, - /* Reports menu */ - { - "ReportsCompanyReportAction", NULL, N_("_Company Report"), NULL, - "Open a company report window for the owner of this invoice" - }, -}; -/** The number of display items provided by this plugin. */ -static guint gnc_plugin_page_invoice_n_display_items = G_N_ELEMENTS(gnc_plugin_page_invoice_display_items); - /** The default menu items that need to be add to the menu */ static const gchar *gnc_plugin_load_ui_items [] = { diff --git a/gnucash/gnome/gnc-plugin-page-owner-tree.c b/gnucash/gnome/gnc-plugin-page-owner-tree.c index cdcd8d9d84..2598c84cbb 100644 --- a/gnucash/gnome/gnc-plugin-page-owner-tree.c +++ b/gnucash/gnome/gnc-plugin-page-owner-tree.c @@ -167,90 +167,6 @@ static GActionEntry gnc_plugin_page_owner_tree_actions [] = /** The number of actions provided by this plugin. */ static guint gnc_plugin_page_owner_tree_n_actions = G_N_ELEMENTS(gnc_plugin_page_owner_tree_actions); -static GncDisplayItem gnc_plugin_page_owner_tree_display_items [] = -{ - /* Edit menu */ - { - "OTEditVendorAction", GNC_ICON_EDIT_ACCOUNT, N_("E_dit Vendor"), "e", - N_("Edit the selected vendor") - }, - { - "OTEditCustomerAction", GNC_ICON_EDIT_ACCOUNT, N_("E_dit Customer"), "e", - N_("Edit the selected customer") - }, - { - "OTEditEmployeeAction", GNC_ICON_EDIT_ACCOUNT, N_("E_dit Employee"), "e", - N_("Edit the selected employee") - }, - { - "OTNewVendorAction", GNC_ICON_NEW_ACCOUNT, N_("_New Vendor..."), NULL, - N_("Create a new vendor") - }, - { - "OTNewCustomerAction", GNC_ICON_NEW_ACCOUNT, N_("_New Customer..."), NULL, - N_("Create a new customer") - }, - { - "OTNewEmployeeAction", GNC_ICON_NEW_ACCOUNT, N_("_New Employee..."), NULL, - N_("Create a new employee") - }, -#if 0 /* Disabled due to crash */ - { - "EditDeleteOwnerAction", GNC_ICON_DELETE_ACCOUNT, N_("_Delete Owner..."), "Delete", - N_("Delete selected owner") - }, -#endif /* Disabled due to crash */ - - /* View menu */ - { - "ViewFilterByAction", NULL, N_("_Filter By..."), NULL, NULL - }, - { - "ViewRefreshAction", "view-refresh", N_("_Refresh"), "r", - N_("Refresh this window") - }, - - /* Business menu */ - { - "OTNewBillAction", GNC_ICON_INVOICE_NEW, N_("New _Bill..."), NULL, - N_("Create a new bill") - }, - { - "OTNewInvoiceAction", GNC_ICON_INVOICE_NEW, N_("New _Invoice..."), NULL, - N_("Create a new invoice") - }, - { - "OTNewVoucherAction", GNC_ICON_INVOICE_NEW, N_("New _Voucher..."), NULL, - N_("Create a new voucher") - }, - { - "OTVendorListingReportAction", "document-print-preview", N_("Vendor Listing"), NULL, - N_("Show vendor aging overview for all vendors") - }, - { - "OTCustomerListingReportAction", "document-print-preview", N_("Customer Listing"), NULL, - N_("Show customer aging overview for all customers") - }, - { - "OTVendorReportAction", NULL, N_("Vendor Report"), NULL, - N_("Show vendor report") - }, - { - "OTCustomerReportAction", NULL, N_("Customer Report"), NULL, - N_("Show customer report") - }, - { - "OTEmployeeReportAction", NULL, N_("Employee Report"), NULL, - N_("Show employee report") - }, - { - "OTProcessPaymentAction", GNC_ICON_INVOICE_PAY, - N_("Process Payment"), NULL, N_("Process Payment") - }, - }; -/** The number of display items provided by this plugin. */ -static guint gnc_plugin_page_owner_tree_n_display_items = G_N_ELEMENTS(gnc_plugin_page_owner_tree_display_items); - /** The default menu items that need to be add to the menu */ static const gchar *gnc_plugin_load_ui_items [] = { diff --git a/gnucash/gnome/gnc-plugin-page-register.c b/gnucash/gnome/gnc-plugin-page-register.c index d8f08f913a..f9eef0323d 100644 --- a/gnucash/gnome/gnc-plugin-page-register.c +++ b/gnucash/gnome/gnc-plugin-page-register.c @@ -348,206 +348,6 @@ static GActionEntry gnc_plugin_page_register_actions [] = }; static guint gnc_plugin_page_register_n_actions = G_N_ELEMENTS(gnc_plugin_page_register_actions); -static GncDisplayItem gnc_plugin_page_register_display_items [] = -{ - /* File menu */ - { - "FilePrintAction", "document-print", N_ ("_Print Checks..."), "p", NULL - }, - /* Edit menu */ - { - "EditCutAction", "edit-cut", N_ ("Cu_t"), "X", - N_ ("Cut the current selection and copy it to clipboard") - }, - { - "EditCopyAction", "edit-copy", N_ ("_Copy"), "C", - N_ ("Copy the current selection to clipboard") - }, - { - "EditPasteAction", "edit-paste", N_ ("_Paste"), "V", - N_ ("Paste the clipboard content at the cursor position") - }, - { - "EditEditAccountAction", GNC_ICON_EDIT_ACCOUNT, N_ ("Edit _Account"), "e", - N_ ("Edit the selected account") - }, - { - "EditFindAccountAction", "edit-find", N_ ("F_ind Account"), "i", - N_ ("Find an account") - }, - { - "EditFindTransactionsAction", "edit-find", N_ ("_Find..."), "f", - N_ ("Find transactions with a search") - }, - { - "EditTaxOptionsAction", NULL, - /* Translators: remember to reuse this - translation in dialog-account.glade */ - N_("Ta_x Report Options"), NULL, - /* Translators: currently implemented are - US: income tax and - DE: VAT - So adjust this string */ - N_("Setup relevant accounts for tax reports, e.g. US income tax") - }, - /* Transaction menu */ - { - "CutTransactionAction", "edit-cut", CUT_TRANSACTION_LABEL, "", - CUT_TRANSACTION_TIP - }, - { - "CopyTransactionAction", "edit-copy", COPY_TRANSACTION_LABEL, "", - COPY_TRANSACTION_TIP - }, - { - "PasteTransactionAction", "edit-paste", PASTE_TRANSACTION_LABEL, "", - PASTE_TRANSACTION_TIP - }, - { - "DuplicateTransactionAction", "edit-copy", DUPLICATE_TRANSACTION_LABEL, "", - DUPLICATE_TRANSACTION_TIP - }, - { - "DeleteTransactionAction", "edit-delete", DELETE_TRANSACTION_LABEL, NULL, - DELETE_TRANSACTION_TIP - }, - { - "RemoveTransactionSplitsAction", "edit-clear", N_ ("Remo_ve Other Splits"), NULL, - N_ ("Remove all splits in the current transaction") - }, - { - "RecordTransactionAction", "list-add", N_ ("_Enter Transaction"), NULL, - N_ ("Record the current transaction") - }, - { - "CancelTransactionAction", "process-stop", N_ ("Ca_ncel Transaction"), NULL, - N_ ("Cancel the current transaction") - }, - { - "VoidTransactionAction", NULL, N_ ("_Void Transaction"), NULL, NULL - }, - { - "UnvoidTransactionAction", NULL, N_ ("_Unvoid Transaction"), NULL, NULL - }, - { - "ReverseTransactionAction", NULL, N_ ("Add _Reversing Transaction"), NULL, NULL - }, - { - "LinkTransactionAction", NULL, LINK_TRANSACTION_LABEL, NULL, - LINK_TRANSACTION_TIP - }, - { - "LinkedTransactionOpenAction", NULL, LINK_TRANSACTION_OPEN_LABEL, NULL, - LINK_TRANSACTION_OPEN_TIP - }, - { - "JumpLinkedInvoiceAction", NULL, JUMP_LINKED_INVOICE_LABEL, NULL, - JUMP_LINKED_INVOICE_TIP - }, - /* View menu */ - { - "ViewSortByAction", NULL, N_ ("_Sort By..."), NULL, NULL - }, - { - "ViewFilterByAction", NULL, N_ ("_Filter By..."), NULL, NULL - }, - { - "ViewRefreshAction", "view-refresh", N_ ("_Refresh"), "r", - N_ ("Refresh this window") - }, - /* Actions menu */ - { - "ActionsTransferAction", GNC_ICON_TRANSFER, N_ ("_Transfer..."), "t", - N_ ("Transfer funds from one account to another") - }, - { - "ActionsReconcileAction", "edit-select-all", N_ ("_Reconcile..."), NULL, - N_ ("Reconcile the selected account") - }, - { - "ActionsAutoClearAction", "edit-select-all", N_ ("_Auto-clear..."), NULL, - N_ ("Automatically clear individual transactions, so as to reach a certain cleared amount") - }, - { - "ActionsStockAssistantAction", "applications-utilities", - N_ ("Stock Ass_istant"), NULL, N_ ("Stock Assistant") - }, - { - "ActionsStockSplitAction", NULL, N_ ("Stoc_k Split..."), NULL, - N_ ("Record a stock split or a stock merger") - }, - { - "ActionsLotsAction", NULL, N_ ("View _Lots..."), NULL, - N_ ("Bring up the lot viewer/editor window") - }, - { - "BlankTransactionAction", "go-bottom", N_ ("_Blank Transaction"), "Page_Down", - N_ ("Move to the blank transaction at the bottom of the register") - }, - { - "GotoDateAction", "x-office-calendar", N_ ("_Go to Date"), "G", - N_ ("Move to the split at the specified date") - }, - { - "EditExchangeRateAction", NULL, N_ ("Edit E_xchange Rate"), NULL, - N_ ("Edit the exchange rate for the current transaction") - }, - { -/* Translators: This is a menu item that will open a register tab for the - account of the first other account in the current transaction's split list - with focus on the current transaction's entry in that register. */ - "JumpTransactionAction", GNC_ICON_JUMP_TO, N_ ("_Jump to the other account"), NULL, - N_ ("Open a new register tab for the other account with focus on this transaction.") - }, - { - "ScheduleTransactionAction", GNC_ICON_SCHEDULE, N_ ("Sche_dule..."), NULL, - N_ ("Create a Scheduled Transaction with the current transaction as a template") - }, - { - "ScrubAllAction", NULL, - /* Translators: The following 2 are Scrub actions in register view */ - N_ ("_All transactions"), NULL, NULL - }, - { - "ScrubCurrentAction", NULL, N_ ("_This transaction"), NULL, NULL - }, - /* Reports menu */ - { - "ReportsAccountReportAction", NULL, N_ ("Account Report"), NULL, - N_ ("Open a register report for this Account") - }, - { - "ReportsAcctTransReportAction", NULL, N_ ("Account Report - Single Transaction"), NULL, - N_ ("Open a register report for the selected Transaction") - }, - /* Toggles and radio */ - { - "ViewStyleDoubleLineAction", NULL, N_ ("_Double Line"), NULL, - N_ ("Show a second line with \"Action\", \"Notes\", and \"Linked Document\" for each transaction.") - }, - { - "SplitTransactionAction", GNC_ICON_SPLIT_TRANS, N_ ("S_plit Transaction"), NULL, - N_ ("Show all splits in the current transaction") - }, - /* Translators: This is a menu item in the View menu */ - { - "ViewStyleBasicAction", NULL, N_ ("_Basic Ledger"), NULL, - N_ ("Show transactions on one or two lines") - }, - /* Translators: This is a menu item in the View menu */ - { - "ViewStyleAutoSplitAction", NULL, N_ ("_Auto-Split Ledger"), NULL, - N_ ("Show transactions on one or two lines and expand the current transaction") - }, - /* Translators: This is a menu item in the View menu */ - { - "ViewStyleJournalAction", NULL, N_ ("Transaction _Journal"), NULL, - N_ ("Show expanded transactions with all splits") - } -}; -/** The number of display items provided by this plugin. */ -static guint gnc_plugin_page_register_n_display_items = G_N_ELEMENTS(gnc_plugin_page_register_display_items); - /** The default menu items that need to be add to the menu */ static const gchar *gnc_plugin_load_ui_items [] = { diff --git a/gnucash/gnome/gnc-plugin-page-report.cpp b/gnucash/gnome/gnc-plugin-page-report.cpp index 113c065645..a246c61405 100644 --- a/gnucash/gnome/gnc-plugin-page-report.cpp +++ b/gnucash/gnome/gnc-plugin-page-report.cpp @@ -209,68 +209,6 @@ static GActionEntry report_actions[] = }; static guint num_report_actions = G_N_ELEMENTS(report_actions); -static GncDisplayItem report_display_items [] = -{ - { - "FilePrintAction", "document-print", N_("_Print Report..."), "p", - N_("Print the current report") - }, - { - "FilePrintPDFAction", GNC_ICON_PDF_EXPORT, N_("Export as P_DF..."), nullptr, - N_("Export the current report as a PDF document") - }, - { - "EditCutAction", "edit-cut", N_("Cu_t"), "X", - N_("Cut the current selection and copy it to clipboard") - }, - { - "EditCopyAction", "edit-copy", N_("_Copy"), "C", - N_("Copy the current selection to clipboard") - }, - { - "EditPasteAction", "edit-paste", N_("_Paste"), "V", - N_("Paste the clipboard content at the cursor position") - }, - { - "ViewRefreshAction", "view-refresh", N_("_Refresh"), "r", - N_("Refresh this window") - }, - { - "ReportSaveAction", "document-save", N_("Save _Report Configuration"), "s", - nullptr - }, - { - "ReportSaveAsAction", "document-save-as", N_("Save Report Configuration As..."), "s", - nullptr - }, - { - "ReportExportAction", "go-next", N_("Export _Report"), nullptr, - N_("Export HTML-formatted report to file") - }, - { - "ReportOptionsAction", "document-properties", N_("_Report Options"), nullptr, - N_("Edit report options") - }, - { - "ReportBackAction", "go-previous", N_("Back"), nullptr, - N_("Move back one step in the history") - }, - { - "ReportForwAction", "go-next", N_("Forward"), nullptr, - N_("Move forward one step in the history") - }, - { - "ReportReloadAction", "view-refresh", N_("Reload"), nullptr, - N_("Reload the current page") - }, - { - "ReportStopAction", "process-stop", N_("Stop"), nullptr, - N_("Cancel outstanding HTML requests") - }, -}; -/** The number of display items provided by this plugin. */ -static guint report_n_display_items = G_N_ELEMENTS(report_display_items); - /** The default menu items that need to be add to the menu */ static const gchar *gnc_plugin_load_ui_items [] = { diff --git a/gnucash/gnome/gnc-plugin-page-sx-list.c b/gnucash/gnome/gnc-plugin-page-sx-list.c index 55f2b6b40e..d8ebff4e97 100644 --- a/gnucash/gnome/gnc-plugin-page-sx-list.c +++ b/gnucash/gnome/gnc-plugin-page-sx-list.c @@ -139,30 +139,6 @@ static GActionEntry gnc_plugin_page_sx_list_actions [] = /** The number of actions provided by this plugin. */ static guint gnc_plugin_page_sx_list_n_actions = G_N_ELEMENTS(gnc_plugin_page_sx_list_actions); -static GncDisplayItem gnc_plugin_page_sx_list_display_items [] = -{ - { "SxListAction", NULL, N_("_Scheduled"), NULL, NULL }, - { - "SxListNewAction", GNC_ICON_NEW_ACCOUNT, N_("_New"), NULL, - N_("Create a new scheduled transaction") - }, - { - "SxListEditAction", GNC_ICON_EDIT_ACCOUNT, N_("_Edit"), NULL, - N_("Edit the selected scheduled transaction") - }, - { - "SxListDeleteAction", GNC_ICON_DELETE_ACCOUNT, N_("_Delete"), NULL, - N_("Delete the selected scheduled transaction") - }, - /* View menu */ - { - "ViewRefreshAction", "view-refresh", N_("_Refresh"), "r", - N_("Refresh this window") - }, -}; -/** The number of display items provided by this plugin. */ -static guint gnc_plugin_page_sx_list_n_display_items = G_N_ELEMENTS(gnc_plugin_page_sx_list_display_items); - /** The default menu items that need to be add to the menu */ static const gchar *gnc_plugin_load_ui_items [] = { diff --git a/gnucash/ui/gnc-plugin-page-register.ui b/gnucash/ui/gnc-plugin-page-register.ui index 744ba60389..045acde234 100644 --- a/gnucash/ui/gnc-plugin-page-register.ui +++ b/gnucash/ui/gnc-plugin-page-register.ui @@ -58,6 +58,7 @@ + _Basic Ledger GncPluginPageRegisterActions.ViewStyleRadioAction 0 @@ -65,6 +66,7 @@ yes + _Auto-Split Ledger GncPluginPageRegisterActions.ViewStyleRadioAction 1 @@ -72,6 +74,7 @@ yes + Transaction _Journal GncPluginPageRegisterActions.ViewStyleRadioAction 2 @@ -286,6 +289,9 @@ yes + _Jump to the other account GncPluginPageRegisterActions.JumpTransactionAction Open a new register tab for the other account with focus on this transaction @@ -295,6 +301,7 @@ + _Check & Repair mainwin.ScrubMenuAction yes diff --git a/libgnucash/gnc-module/example/gnc-plugin.example.c b/libgnucash/gnc-module/example/gnc-plugin.example.c index 491b305e8f..b55899d17c 100644 --- a/libgnucash/gnc-module/example/gnc-plugin.example.c +++ b/libgnucash/gnc-module/example/gnc-plugin.example.c @@ -53,16 +53,6 @@ static GActionEntry gnc_plugin_actions [] = /** The number of actions provided by this plugin. */ static guint gnc_plugin_n_actions = G_N_ELEMENTS(gnc_plugin_actions); -static GncDisplayItem gnc_plugin_display_items [] = -{ - /* Menu Items */ - { "exampleAction", NULL, N_("example description..."), NULL, - N_("example tooltip") - }, -}; -/** The number of display items provided by this plugin. */ -static guint gnc_plugin_n_display_items = G_N_ELEMENTS(gnc_plugin_display_items); - /************************************************************ * Object Implementation * ************************************************************/ @@ -90,8 +80,6 @@ gnc_plugin_example_class_init (GncPluginexampleClass *klass) plugin_class->actions_name = PLUGIN_ACTIONS_NAME; plugin_class->actions = gnc_plugin_actions; plugin_class->n_actions = gnc_plugin_n_actions; - plugin_class->display_items = gnc_plugin_display_items; - plugin_class->n_display_items = gnc_plugin_n_display_items; plugin_class->ui_filename = PLUGIN_UI_FILENAME; } From 5f3235134a0baa1bda800e08ce6b9b32e62e6c61 Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Fri, 28 Oct 2022 16:52:41 +0100 Subject: [PATCH 42/77] Setup redirection of tool bar tooltips This commit redirects the tool bar tooltips to the window status bar --- gnucash/gnome-utils/gnc-embedded-window.c | 4 - gnucash/gnome-utils/gnc-gtk-utils.c | 65 ++++++++++++++++ gnucash/gnome-utils/gnc-gtk-utils.h | 3 + gnucash/gnome-utils/gnc-main-window.cpp | 3 + gnucash/gnome-utils/gnc-plugin.c | 17 ++++ gnucash/gnome-utils/gnc-plugin.h | 4 + gnucash/gnome-utils/gnc-window.c | 94 +---------------------- gnucash/gnome-utils/gnc-window.h | 17 +--- gnucash/gnome/gnc-plugin-page-invoice.c | 15 ++-- gnucash/gnome/gnc-plugin-page-register.c | 8 ++ gnucash/gnome/gnc-plugin-page-report.cpp | 15 ++-- 11 files changed, 120 insertions(+), 125 deletions(-) diff --git a/gnucash/gnome-utils/gnc-embedded-window.c b/gnucash/gnome-utils/gnc-embedded-window.c index 118c530fc0..3e0e21c5f4 100644 --- a/gnucash/gnome-utils/gnc-embedded-window.c +++ b/gnucash/gnome-utils/gnc-embedded-window.c @@ -311,10 +311,6 @@ gnc_embedded_window_setup_window (GncEmbeddedWindow *window) gtk_widget_show (priv->statusbar); gtk_box_pack_end (GTK_BOX (window), priv->statusbar, FALSE, TRUE, 0); - /* Use the "connect-proxy" signal for tooltip display in the status bar */ -//FIXMEb g_signal_connect (G_OBJECT (window->ui_merge), "connect-proxy", -// G_CALLBACK (gnc_window_connect_proxy), priv->statusbar); - priv->simple_action_group = NULL; LEAVE(" "); } diff --git a/gnucash/gnome-utils/gnc-gtk-utils.c b/gnucash/gnome-utils/gnc-gtk-utils.c index da63ceb438..e3c770fff9 100644 --- a/gnucash/gnome-utils/gnc-gtk-utils.c +++ b/gnucash/gnome-utils/gnc-gtk-utils.c @@ -838,3 +838,68 @@ gnc_menubar_model_remove_items_with_attrib (GMenuModel *menu_model, const gchar g_list_foreach (remove_list, (GFunc)remove_items, NULL); g_list_free (remove_list); } + +static void +statusbar_push (GtkWidget *statusbar, const gchar *text) +{ + gtk_statusbar_push (GTK_STATUSBAR(statusbar), 0, + text ? text : " "); +} + +static void +statusbar_pop (GtkWidget *statusbar) +{ + gtk_statusbar_pop (GTK_STATUSBAR(statusbar), 0); +} + +static gboolean +tool_item_enter_event (GtkWidget *button, GdkEvent *event, + gpointer user_data) +{ + GtkWidget *tool_item = gtk_widget_get_parent (button); + gchar *tooltip = gtk_widget_get_tooltip_text (tool_item); + statusbar_push (user_data, tooltip); + g_free (tooltip); + return FALSE; +} + +static gboolean +tool_item_leave_event (GtkWidget *button, GdkEvent *event, + gpointer user_data) +{ + statusbar_pop (user_data); + return FALSE; +} + +/** Setup the callbacks for tool bar items so the tooltip can be + * displayed in the status bar. + * + * @param tool_item The toolbar tool item widget. + * + * @param statusbar The statusbar widget to display the tooltip. + */ +void +gnc_tool_item_setup_tooltip_to_statusbar_callback (GtkWidget *tool_item, + GtkWidget *statusbar) +{ + GtkWidget *child; + + g_return_if_fail (tool_item != NULL); + g_return_if_fail (statusbar != NULL); + + child = gtk_bin_get_child (GTK_BIN(tool_item)); + + gtk_widget_add_events (GTK_WIDGET(child), + GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK + | GDK_FOCUS_CHANGE_MASK); + + g_signal_connect (child, "enter-notify-event", + G_CALLBACK (tool_item_enter_event), + statusbar); + + g_signal_connect (child, "leave-notify-event", + G_CALLBACK (tool_item_leave_event), + statusbar); + + g_object_set (G_OBJECT(tool_item), "has-tooltip", FALSE, NULL); +} diff --git a/gnucash/gnome-utils/gnc-gtk-utils.h b/gnucash/gnome-utils/gnc-gtk-utils.h index 2902f812d0..84c0c6d0e1 100644 --- a/gnucash/gnome-utils/gnc-gtk-utils.h +++ b/gnucash/gnome-utils/gnc-gtk-utils.h @@ -65,6 +65,9 @@ GList *gnc_menu_get_items (GtkWidget *menu); GtkWidget *gnc_find_toolbar_item (GtkWidget *toolbar, const gchar *action_name); +void gnc_tool_item_setup_tooltip_to_statusbar_callback (GtkWidget *tool_item, + GtkWidget *statusbar); + struct _GncMenuModelSearch { const gchar *search_action_name; diff --git a/gnucash/gnome-utils/gnc-main-window.cpp b/gnucash/gnome-utils/gnc-main-window.cpp index 184c44da0f..3ffa4699e9 100644 --- a/gnucash/gnome-utils/gnc-main-window.cpp +++ b/gnucash/gnome-utils/gnc-main-window.cpp @@ -3793,6 +3793,9 @@ gnc_main_window_update_toolbar (GncMainWindow *window, GncPluginPage *page, gtk_widget_set_visible (priv->toolbar, g_variant_get_boolean (state)); g_variant_unref (state); } + + // add tooltip redirect call backs + gnc_plugin_add_toolbar_tooltip_callbacks (priv->toolbar, priv->statusbar); } diff --git a/gnucash/gnome-utils/gnc-plugin.c b/gnucash/gnome-utils/gnc-plugin.c index 327bceb029..a19925255b 100644 --- a/gnucash/gnome-utils/gnc-plugin.c +++ b/gnucash/gnome-utils/gnc-plugin.c @@ -261,5 +261,22 @@ gnc_plugin_set_actions_enabled (GSimpleActionGroup *simple_action_group, } } +void +gnc_plugin_add_toolbar_tooltip_callbacks (GtkWidget *toolbar, GtkWidget *statusbar) +{ + g_return_if_fail (GTK_IS_TOOLBAR(toolbar)); + g_return_if_fail (GTK_IS_STATUSBAR(statusbar)); + + for (gint i = 0; i < gtk_toolbar_get_n_items (GTK_TOOLBAR(toolbar)); i++) + { + GtkToolItem *item = gtk_toolbar_get_nth_item (GTK_TOOLBAR(toolbar), i); + + if (GTK_IS_ACTIONABLE(item)) + gnc_tool_item_setup_tooltip_to_statusbar_callback (GTK_WIDGET(item), statusbar); + } +} + + + /** @} */ /** @} */ diff --git a/gnucash/gnome-utils/gnc-plugin.h b/gnucash/gnome-utils/gnc-plugin.h index 9ab2ccee25..2e5bcbfe97 100644 --- a/gnucash/gnome-utils/gnc-plugin.h +++ b/gnucash/gnome-utils/gnc-plugin.h @@ -263,6 +263,10 @@ void gnc_plugin_set_actions_enabled (GSimpleActionGroup *simple_action_group, const gchar **action_names, gboolean enable); //FIXMEb added + +void gnc_plugin_add_toolbar_tooltip_callbacks (GtkWidget *toolbar, + GtkWidget *statusbar); //FIXMEb added + G_END_DECLS #endif /* __GNC_PLUGIN_H */ diff --git a/gnucash/gnome-utils/gnc-window.c b/gnucash/gnome-utils/gnc-window.c index 0cd6168671..88117856bc 100644 --- a/gnucash/gnome-utils/gnc-window.c +++ b/gnucash/gnome-utils/gnc-window.c @@ -78,7 +78,7 @@ gnc_window_get_gtk_window (GncWindow *window) return GNC_WINDOW_GET_IFACE (window)->get_gtk_window (window); } -static GtkWidget * +GtkWidget * gnc_window_get_statusbar (GncWindow *window) { g_return_val_if_fail(GNC_WINDOW (window), NULL); @@ -255,95 +255,3 @@ gnc_window_show_progress (const char *message, double percentage) while (gtk_events_pending ()) gtk_main_iteration (); } - - -/* CS: This callback functions will set the statusbar text to the - * "tooltip" property of the currently selected GtkAction. - * - * This code is directly copied from gtk+/test/testmerge.c. - * Thanks to (L)GPL! */ -typedef struct _ActionStatus ActionStatus; -struct _ActionStatus -{ - GAction *action; - GtkWidget *statusbar; -}; - -static void -action_status_destroy (gpointer data) -{ - ActionStatus *action_status = data; - - g_object_unref (action_status->action); - g_object_unref (action_status->statusbar); - - g_free (action_status); -} - -static void -set_tip (GtkWidget *widget) -{ - ActionStatus *data; - gchar *tooltip; - - data = g_object_get_data (G_OBJECT (widget), "action-status"); - - if (data) - { - g_object_get (data->action, "tooltip", &tooltip, NULL); - - gtk_statusbar_push (GTK_STATUSBAR (data->statusbar), 0, - tooltip ? tooltip : " "); - - g_free (tooltip); - } -} - -static void -unset_tip (GtkWidget *widget) -{ - ActionStatus *data; - - data = g_object_get_data (G_OBJECT (widget), "action-status"); - - if (data) - gtk_statusbar_pop (GTK_STATUSBAR (data->statusbar), 0); -} - -#ifdef skip //FIXMEb -void -gnc_window_connect_proxy (GtkUIManager *merge, - GAction *action, - GtkWidget *proxy, - GtkWidget *statusbar) -{ - if (GTK_IS_MENU_ITEM (proxy)) - { - ActionStatus *data; - - data = g_object_get_data (G_OBJECT (proxy), "action-status"); - if (data) - { - g_object_unref (data->action); - g_object_unref (data->statusbar); - - data->action = g_object_ref (action); - data->statusbar = g_object_ref (statusbar); - } - else - { - data = g_new0 (ActionStatus, 1); - - data->action = g_object_ref (action); - data->statusbar = g_object_ref (statusbar); - - g_object_set_data_full (G_OBJECT (proxy), "action-status", - data, action_status_destroy); - - g_signal_connect (proxy, "select", G_CALLBACK (set_tip), NULL); - g_signal_connect (proxy, "deselect", G_CALLBACK (unset_tip), NULL); - } - } -} -#endif -/* CS: end copied code from gtk+/test/testmerge.c */ diff --git a/gnucash/gnome-utils/gnc-window.h b/gnucash/gnome-utils/gnc-window.h index 83dd06e625..6b06f3050c 100644 --- a/gnucash/gnome-utils/gnc-window.h +++ b/gnucash/gnome-utils/gnc-window.h @@ -83,24 +83,9 @@ GtkWidget *gnc_window_get_progressbar (GncWindow *window); void gnc_window_show_progress (const char *message, double percentage); GtkWidget *gnc_window_get_menubar (GncWindow *window); GtkWidget *gnc_window_get_toolbar (GncWindow *window); +GtkWidget *gnc_window_get_statusbar (GncWindow *window); GMenuModel *gnc_window_get_menubar_model (GncWindow *window); -/** This callback functions will set the statusbar text to the - * "tooltip" property of the currently selected GtkAction - * - * @param merge A pointer to the ui manager - * - * @param action A pointer to the action - * - * @param proxy A pointer to the proxy - * - * @param statusbar A pointer to the statusbar widget - */ -//FIXMEbvoid gnc_window_connect_proxy (GtkUIManager *merge, -// GAction *action, -// GtkWidget *proxy, -// GtkWidget *statusbar); - G_END_DECLS #endif /* __GNC_WINDOW_H */ diff --git a/gnucash/gnome/gnc-plugin-page-invoice.c b/gnucash/gnome/gnc-plugin-page-invoice.c index 50245a310e..f6f90ff4b5 100644 --- a/gnucash/gnome/gnc-plugin-page-invoice.c +++ b/gnucash/gnome/gnc-plugin-page-invoice.c @@ -537,14 +537,17 @@ gnc_plugin_page_invoice_action_update (GncPluginPage *plugin_page, menu_item = gnc_main_window_menu_find_menu_item (GNC_MAIN_WINDOW(GNC_PLUGIN_PAGE(plugin_page)->window), tooltip_list[i].action_name); - if (menu_item) - gtk_widget_set_tooltip_text (GTK_WIDGET(menu_item), _(tooltip_list[i].label)); + if (menu_item) + gtk_widget_set_tooltip_text (GTK_WIDGET(menu_item), _(tooltip_list[i].label)); - tool_item = gnc_main_window_toolbar_find_menu_item (GNC_MAIN_WINDOW(GNC_PLUGIN_PAGE(plugin_page)->window), - tooltip_list[i].action_name); + tool_item = gnc_main_window_toolbar_find_menu_item (GNC_MAIN_WINDOW(GNC_PLUGIN_PAGE(plugin_page)->window), + tooltip_list[i].action_name); - if (tool_item) - gtk_widget_set_tooltip_text (GTK_WIDGET(tool_item), _(tooltip_list[i].label)); + if (tool_item) + { + gtk_widget_set_tooltip_text (GTK_WIDGET(tool_item), _(tooltip_list[i].label)); + g_object_set (G_OBJECT(tool_item), "has-tooltip", FALSE, NULL); + } } } diff --git a/gnucash/gnome/gnc-plugin-page-register.c b/gnucash/gnome/gnc-plugin-page-register.c index f9eef0323d..3bc3c6545d 100644 --- a/gnucash/gnome/gnc-plugin-page-register.c +++ b/gnucash/gnome/gnc-plugin-page-register.c @@ -747,6 +747,14 @@ gnc_plugin_page_register_focus_widget (GncPluginPage* register_plugin_page) register_plugin_page, gnc_plugin_load_ui_items); } + else + { + GtkWidget *toolbar = gnc_window_get_toolbar (gnc_window); + GtkWidget *statusbar = gnc_window_get_statusbar (gnc_window); + + // add tooltip redirect call backs + gnc_plugin_add_toolbar_tooltip_callbacks (toolbar, statusbar); + } // setup any short toolbar names gnc_plugin_init_short_names (gnc_window_get_toolbar (gnc_window), toolbar_labels); diff --git a/gnucash/gnome/gnc-plugin-page-report.cpp b/gnucash/gnome/gnc-plugin-page-report.cpp index a246c61405..875b76e4dd 100644 --- a/gnucash/gnome/gnc-plugin-page-report.cpp +++ b/gnucash/gnome/gnc-plugin-page-report.cpp @@ -1232,13 +1232,16 @@ gnc_plugin_page_report_menu_update (GncPluginPage *plugin_page, { menu_item = gnc_main_window_menu_find_menu_item (GNC_MAIN_WINDOW(GNC_PLUGIN_PAGE(plugin_page)->window), tooltip_list[i].action_name); - if (menu_item) - gtk_widget_set_tooltip_text (GTK_WIDGET(menu_item), _(tooltip_list[i].label)); + if (menu_item) + gtk_widget_set_tooltip_text (GTK_WIDGET(menu_item), _(tooltip_list[i].label)); - tool_item = gnc_main_window_toolbar_find_menu_item (GNC_MAIN_WINDOW(GNC_PLUGIN_PAGE(plugin_page)->window), - tooltip_list[i].action_name); - if (tool_item) - gtk_widget_set_tooltip_text (GTK_WIDGET(tool_item), _(tooltip_list[i].label)); + tool_item = gnc_main_window_toolbar_find_menu_item (GNC_MAIN_WINDOW(GNC_PLUGIN_PAGE(plugin_page)->window), + tooltip_list[i].action_name); + if (tool_item) + { + gtk_widget_set_tooltip_text (GTK_WIDGET(tool_item), _(tooltip_list[i].label)); + g_object_set (G_OBJECT(tool_item), "has-tooltip", FALSE, NULL); + } } } From 21b95765c0d8bed5756451340ecd8c75c8e01a22 Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Fri, 28 Oct 2022 16:53:19 +0100 Subject: [PATCH 43/77] Setup redirection of menu bar tooltips This commit redirects the menu bar tooltips to the window status bar --- gnucash/gnome-utils/gnc-gtk-utils.c | 59 ++++++++++++++++++++++++ gnucash/gnome-utils/gnc-gtk-utils.h | 3 ++ gnucash/gnome-utils/gnc-main-window.cpp | 3 ++ gnucash/gnome-utils/gnc-plugin.c | 17 +++++++ gnucash/gnome-utils/gnc-plugin.h | 3 ++ gnucash/gnome/gnc-plugin-page-register.c | 5 +- 6 files changed, 89 insertions(+), 1 deletion(-) diff --git a/gnucash/gnome-utils/gnc-gtk-utils.c b/gnucash/gnome-utils/gnc-gtk-utils.c index e3c770fff9..f39bcae81a 100644 --- a/gnucash/gnome-utils/gnc-gtk-utils.c +++ b/gnucash/gnome-utils/gnc-gtk-utils.c @@ -852,6 +852,65 @@ statusbar_pop (GtkWidget *statusbar) gtk_statusbar_pop (GTK_STATUSBAR(statusbar), 0); } +static void +menu_item_select_cb (GtkWidget *menu_item, gpointer user_data) +{ + GtkWidget *accel_label = gtk_bin_get_child (GTK_BIN(menu_item)); + GMenuModel *menubar_model = g_object_get_data (G_OBJECT(user_data), "menu-model"); + + if (!menubar_model) + return; + + if (accel_label) + { + GncMenuModelSearch *gsm = g_new0 (GncMenuModelSearch, 1); + + gsm->search_action_label = gtk_label_get_label (GTK_LABEL(accel_label)); + gsm->search_action_name = NULL; + + if (gnc_menubar_model_find_item (menubar_model, gsm)) + { + if (gsm->model) + statusbar_push (user_data, gsm->tooltip); + } + g_free (gsm); + } +} + +static void +menu_item_deselect_cb (GtkWidget *menu_item, gpointer user_data) +{ + statusbar_pop (user_data); +} + +/** Setup the callbacks for menu bar items so the tooltip can be + * displayed in the status bar. + * + * @param menu_item The menubar menu item widget. + * + * @param statusbar The statusbar widget to display the tooltip. + */ +void +gnc_menu_item_setup_tooltip_to_statusbar_callback (GtkWidget *menu_item, + GtkWidget *statusbar) +{ + g_return_if_fail (menu_item != NULL); + g_return_if_fail (statusbar != NULL); + + if (GPOINTER_TO_INT(g_object_get_data(G_OBJECT(menu_item), "added-callbacks"))) + return; + + g_signal_connect (menu_item, "select", + G_CALLBACK(menu_item_select_cb), + statusbar); + g_signal_connect (menu_item, "deselect", + G_CALLBACK(menu_item_deselect_cb), + statusbar); + g_object_set (G_OBJECT(menu_item), "has-tooltip", FALSE, NULL); + g_object_set_data (G_OBJECT(menu_item), "added-callbacks", GINT_TO_POINTER(1)); +} + + static gboolean tool_item_enter_event (GtkWidget *button, GdkEvent *event, gpointer user_data) diff --git a/gnucash/gnome-utils/gnc-gtk-utils.h b/gnucash/gnome-utils/gnc-gtk-utils.h index 84c0c6d0e1..f0da494b65 100644 --- a/gnucash/gnome-utils/gnc-gtk-utils.h +++ b/gnucash/gnome-utils/gnc-gtk-utils.h @@ -65,6 +65,9 @@ GList *gnc_menu_get_items (GtkWidget *menu); GtkWidget *gnc_find_toolbar_item (GtkWidget *toolbar, const gchar *action_name); +void gnc_menu_item_setup_tooltip_to_statusbar_callback (GtkWidget *menu_item, + GtkWidget *statusbar); + void gnc_tool_item_setup_tooltip_to_statusbar_callback (GtkWidget *tool_item, GtkWidget *statusbar); diff --git a/gnucash/gnome-utils/gnc-main-window.cpp b/gnucash/gnome-utils/gnc-main-window.cpp index 3ffa4699e9..bd49cbd981 100644 --- a/gnucash/gnome-utils/gnc-main-window.cpp +++ b/gnucash/gnome-utils/gnc-main-window.cpp @@ -3881,6 +3881,9 @@ gnc_main_window_update_menu (GncMainWindow *window, GncPluginPage *page, g_free (menu_name); } + // add tooltip redirect call backs + gnc_plugin_add_menu_tooltip_callbacks (priv->menubar, priv->menubar_model, priv->statusbar); + // remove existing accelerator group if (priv->previous_plugin_page_accel_group) gtk_window_remove_accel_group (GTK_WINDOW(window), priv->previous_plugin_page_accel_group); diff --git a/gnucash/gnome-utils/gnc-plugin.c b/gnucash/gnome-utils/gnc-plugin.c index a19925255b..d09d8a9891 100644 --- a/gnucash/gnome-utils/gnc-plugin.c +++ b/gnucash/gnome-utils/gnc-plugin.c @@ -261,6 +261,23 @@ gnc_plugin_set_actions_enabled (GSimpleActionGroup *simple_action_group, } } +void +gnc_plugin_add_menu_tooltip_callbacks (GtkWidget *menubar, + GMenuModel *menubar_model, + GtkWidget *statusbar) +{ + GList *menu_item_list = gnc_menu_get_items (menubar); + + for (GList *node = menu_item_list; node; node = node->next) + { + GtkWidget *menu_item = node->data; + + gnc_menu_item_setup_tooltip_to_statusbar_callback (menu_item, statusbar); + g_object_set_data (G_OBJECT(statusbar), "menu-model", menubar_model); + } + g_list_free (menu_item_list); +} + void gnc_plugin_add_toolbar_tooltip_callbacks (GtkWidget *toolbar, GtkWidget *statusbar) { diff --git a/gnucash/gnome-utils/gnc-plugin.h b/gnucash/gnome-utils/gnc-plugin.h index 2e5bcbfe97..bab96b5da8 100644 --- a/gnucash/gnome-utils/gnc-plugin.h +++ b/gnucash/gnome-utils/gnc-plugin.h @@ -263,6 +263,9 @@ void gnc_plugin_set_actions_enabled (GSimpleActionGroup *simple_action_group, const gchar **action_names, gboolean enable); //FIXMEb added +void gnc_plugin_add_menu_tooltip_callbacks (GtkWidget *menubar, + GMenuModel *menubar_model, + GtkWidget *statusbar); //FIXMEb added void gnc_plugin_add_toolbar_tooltip_callbacks (GtkWidget *toolbar, GtkWidget *statusbar); //FIXMEb added diff --git a/gnucash/gnome/gnc-plugin-page-register.c b/gnucash/gnome/gnc-plugin-page-register.c index 3bc3c6545d..fa4eb73ba0 100644 --- a/gnucash/gnome/gnc-plugin-page-register.c +++ b/gnucash/gnome/gnc-plugin-page-register.c @@ -750,10 +750,13 @@ gnc_plugin_page_register_focus_widget (GncPluginPage* register_plugin_page) else { GtkWidget *toolbar = gnc_window_get_toolbar (gnc_window); - GtkWidget *statusbar = gnc_window_get_statusbar (gnc_window); + GtkWidget *menubar = gnc_window_get_menubar (gnc_window); + GMenuModel *menubar_model = gnc_window_get_menubar_model (gnc_window); + GtkWidget *statusbar = gnc_window_get_statusbar (gnc_window); // add tooltip redirect call backs gnc_plugin_add_toolbar_tooltip_callbacks (toolbar, statusbar); + gnc_plugin_add_menu_tooltip_callbacks (menubar, menubar_model, statusbar); } // setup any short toolbar names From 9ed102d461d5313be26c3d5962afa669c20dc5d1 Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Fri, 28 Oct 2022 16:54:12 +0100 Subject: [PATCH 44/77] Main window changes for mac's --- gnucash/gnome-utils/gnc-main-window.cpp | 68 +++++++++++++------------ 1 file changed, 36 insertions(+), 32 deletions(-) mode change 100644 => 100755 gnucash/gnome-utils/gnc-main-window.cpp diff --git a/gnucash/gnome-utils/gnc-main-window.cpp b/gnucash/gnome-utils/gnc-main-window.cpp old mode 100644 new mode 100755 index bd49cbd981..1e0d7ae497 --- a/gnucash/gnome-utils/gnc-main-window.cpp +++ b/gnucash/gnome-utils/gnc-main-window.cpp @@ -347,8 +347,9 @@ static GActionEntry gnc_menu_actions [] = { "WindowNewAction", gnc_main_window_cmd_window_new, nullptr, nullptr, nullptr }, { "WindowMovePageAction", gnc_main_window_cmd_window_move_page, nullptr, nullptr, nullptr }, +#ifndef MAC_INTEGRATION { "Window0Action", gnc_main_window_cmd_window_raise, "i", "@i 0", radio_change_state }, - +#endif { "HelpTutorialAction", gnc_main_window_cmd_help_tutorial, nullptr, nullptr, nullptr }, { "HelpContentsAction", gnc_main_window_cmd_help_contents, nullptr, nullptr, nullptr }, { "HelpAboutAction", gnc_main_window_cmd_help_about, nullptr, nullptr, nullptr }, @@ -4287,50 +4288,53 @@ gnc_quartz_should_quit (GtkosxApplication *theApp, GncMainWindow *window) } static void -gnc_quartz_set_menu(GncMainWindow* window) +gnc_quartz_set_menu (GncMainWindow* window) { + GncMainWindowPrivate *priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); auto theApp{static_cast(g_object_new(GTKOSX_TYPE_APPLICATION, nullptr))}; - GtkWidget *menu; - GtkWidget *item; + GtkWidget *item = nullptr; + GAction *action; - menu = gtk_ui_manager_get_widget (window->ui_merge, "/menubar"); - if (GTK_IS_MENU_ITEM (menu)) - menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (menu)); - gtk_widget_hide(menu); - gtkosx_application_set_menu_bar (theApp, GTK_MENU_SHELL (menu)); + gtk_widget_hide (priv->menubar); + gtk_widget_set_no_show_all (priv->menubar, true); - item = gtk_ui_manager_get_widget (window->ui_merge, - "/menubar/File/FileQuit"); - if (GTK_IS_MENU_ITEM (item)) - gtk_widget_hide (GTK_WIDGET (item)); + gtkosx_application_set_menu_bar (theApp, GTK_MENU_SHELL(priv->menubar)); - item = gtk_ui_manager_get_widget (window->ui_merge, - "/menubar/Help/HelpAbout"); - if (GTK_IS_MENU_ITEM (item)) + // File Quit + item = gnc_main_window_menu_find_menu_item (window, "FileQuitAction"); + if (item) + gtk_widget_hide (GTK_WIDGET(item)); + + // Help About + item = gnc_main_window_menu_find_menu_item (window, "HelpAboutAction"); + if (item) { - gtkosx_application_insert_app_menu_item (theApp, GTK_WIDGET (item), 0); + gtk_widget_hide (item); + gtkosx_application_insert_app_menu_item (theApp, GTK_WIDGET(item), 0); } - item = gtk_ui_manager_get_widget (window->ui_merge, - "/menubar/Edit/EditPreferences"); - if (GTK_IS_MENU_ITEM (item)) + // Edit Preferences + item = gnc_main_window_menu_find_menu_item (window, "EditPreferencesAction"); + if (item) { - gtkosx_application_insert_app_menu_item (theApp, - gtk_separator_menu_item_new (), 1); - gtkosx_application_insert_app_menu_item (theApp, GTK_WIDGET (item), 2); + gtk_widget_hide (GTK_WIDGET(item)); + gtkosx_application_insert_app_menu_item (theApp, GTK_WIDGET(item), 2); } - item = gtk_ui_manager_get_widget (window->ui_merge, - "/menubar/Help"); - gtkosx_application_set_help_menu(theApp, GTK_MENU_ITEM(item)); - item = gtk_ui_manager_get_widget (window->ui_merge, - "/menubar/Windows"); - gtkosx_application_set_window_menu(theApp, GTK_MENU_ITEM(item)); - g_signal_connect(theApp, "NSApplicationBlockTermination", - G_CALLBACK(gnc_quartz_should_quit), window); + // Help Menu + item = gnc_main_window_menu_find_menu_item (window, "HelpAction"); + if (item) + gtkosx_application_set_help_menu (theApp, GTK_MENU_ITEM(item)); + // Windows Menu + item = gnc_main_window_menu_find_menu_item (window, "WindowsAction"); + if (item) + gtkosx_application_set_window_menu (theApp, GTK_MENU_ITEM(item)); + + g_signal_connect (theApp, "NSApplicationBlockTermination", + G_CALLBACK(gnc_quartz_should_quit), window); + gtkosx_application_set_use_quartz_accelerators (theApp, FALSE); g_object_unref (theApp); - } #endif //MAC_INTEGRATION From c68dcccebb3e1235bc62bb5b7fa4cb1887f3ee38 Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Fri, 28 Oct 2022 16:54:52 +0100 Subject: [PATCH 45/77] Changes to window menu entries Change the maximum number of windows from a macro to a 'constexpr'. Also added an info dialogue to advise when limit reached, no new window entries will be added to the Windows menu. --- gnucash/gnome-utils/gnc-main-window.cpp | 39 +++++++++++++++---------- gnucash/ui/gnc-main-window.ui | 2 +- 2 files changed, 25 insertions(+), 16 deletions(-) mode change 100755 => 100644 gnucash/gnome-utils/gnc-main-window.cpp diff --git a/gnucash/gnome-utils/gnc-main-window.cpp b/gnucash/gnome-utils/gnc-main-window.cpp old mode 100755 new mode 100644 index 1e0d7ae497..50f316ec20 --- a/gnucash/gnome-utils/gnc-main-window.cpp +++ b/gnucash/gnome-utils/gnc-main-window.cpp @@ -119,7 +119,6 @@ enum #define GNC_PREF_TAB_OPEN_ADJACENT "tab-open-adjacent" #define GNC_MAIN_WINDOW_NAME "GncMainWindow" -#define GNC_MAIN_WINDOW_MAX_NUMBER 10 #define DIALOG_BOOK_OPTIONS_CM_CLASS "dialog-book-options" @@ -136,6 +135,9 @@ enum **/ extern gboolean gnc_book_options_dialog_apply_helper(GncOptionDB * options); +/** Max number of windows allowed */ +constexpr auto gnc_main_window_max_number {10}; + /* Static Globals *******************************************************/ /** The debugging module that this .o belongs to. */ @@ -348,7 +350,7 @@ static GActionEntry gnc_menu_actions [] = { "WindowNewAction", gnc_main_window_cmd_window_new, nullptr, nullptr, nullptr }, { "WindowMovePageAction", gnc_main_window_cmd_window_move_page, nullptr, nullptr, nullptr }, #ifndef MAC_INTEGRATION - { "Window0Action", gnc_main_window_cmd_window_raise, "i", "@i 0", radio_change_state }, + { "WindowAction", gnc_main_window_cmd_window_raise, "i", "@i 0", radio_change_state }, #endif { "HelpTutorialAction", gnc_main_window_cmd_help_tutorial, nullptr, nullptr, nullptr }, { "HelpContentsAction", gnc_main_window_cmd_help_contents, nullptr, nullptr, nullptr }, @@ -1804,8 +1806,9 @@ gnc_main_window_update_one_menu_action (GncMainWindow *window, GMenuItem *item; gint pos; - ENTER("window %p, action %s, label %s, visible %d", window, - data->action_name, data->label, data->visible); + ENTER("window %p, action %s, label %s, index %d, visible %d", window, + data->action_name, data->label, data->index, data->visible); + priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); gsm->search_action_label = nullptr; @@ -1830,7 +1833,7 @@ gnc_main_window_update_one_menu_action (GncMainWindow *window, return; } - item = g_menu_item_new (data->label, "mainwin.Window0Action"); + item = g_menu_item_new (data->label, "mainwin.WindowAction"); g_menu_item_set_attribute (item, "target", "i", data->index); if (pos < g_menu_model_get_n_items (gsm->model)) @@ -1866,16 +1869,16 @@ gnc_main_window_update_radio_button (GncMainWindow *window) /* Show the new entry in all windows. */ index = g_list_index (active_windows, window); - if (index >= GNC_MAIN_WINDOW_MAX_NUMBER) + if (index >= gnc_main_window_max_number) { - LEAVE("window %" G_GSIZE_FORMAT ", only %d actions", index, GNC_MAIN_WINDOW_MAX_NUMBER); + LEAVE("window %" G_GSIZE_FORMAT ", only %d actions", index, gnc_main_window_max_number); return; } priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); action = g_action_map_lookup_action (G_ACTION_MAP(priv->simple_action_group), - "Window0Action"); + "WindowAction"); /* Block the signal so as not to affect window ordering (top to * bottom) on the screen */ @@ -1915,9 +1918,9 @@ gnc_main_window_update_menu_item (GncMainWindow *window) index = g_list_index (active_windows, window); - if (index >= GNC_MAIN_WINDOW_MAX_NUMBER) + if (index >= gnc_main_window_max_number) { - LEAVE("skip window %" G_GSIZE_FORMAT " (only %d entries)", index, GNC_MAIN_WINDOW_MAX_NUMBER); + LEAVE("skip window %" G_GSIZE_FORMAT " (only %d entries)", index, gnc_main_window_max_number); return; } @@ -1926,7 +1929,7 @@ gnc_main_window_update_menu_item (GncMainWindow *window) strings = g_strsplit (title, "_", 0); g_free (title); expanded = g_strjoinv ("__", strings); - if (index < GNC_MAIN_WINDOW_MAX_NUMBER) + if (index < gnc_main_window_max_number) { data.label = g_strdup_printf ("_%" G_GSIZE_FORMAT " %s", (index + 1) % 10, expanded); g_free (expanded); @@ -1938,14 +1941,14 @@ gnc_main_window_update_menu_item (GncMainWindow *window) g_strfreev (strings); data.visible = TRUE; - data.action_name = g_strdup_printf ("Window%" G_GSIZE_FORMAT "Action", index); +// data.action_name = g_strdup_printf ("Window%" G_GSIZE_FORMAT "Action", index); data.index = index; g_list_foreach (active_windows, (GFunc)gnc_main_window_update_one_menu_action, &data); - g_free (data.action_name); +// g_free (data.action_name); g_free (data.label); LEAVE(" "); @@ -1978,8 +1981,8 @@ gnc_main_window_update_all_menu_items (void) /* Now hide any entries that aren't being used. */ data.visible = FALSE; - // need i to descend from GNC_MAIN_WINDOW_MAX_NUMBER - for (gsize i = GNC_MAIN_WINDOW_MAX_NUMBER - 1; i > 0 && i >= g_list_length (active_windows); i--) + // need i to descend from gnc_main_window_max_number + for (gsize i = gnc_main_window_max_number - 1; i > 0 && i >= g_list_length (active_windows); i--) { data.index = i; data.action_name = g_strdup_printf ("Window%dAction", data.index); @@ -4988,6 +4991,12 @@ gnc_main_window_cmd_window_move_page (GSimpleAction *simple, return; } +#ifndef MAC_INTEGRATION + if (gnc_list_length_cmp (active_windows, gnc_main_window_max_number) == 0) + gnc_info_dialog (GTK_WINDOW(window), "%s", + _("The maximum number of window menu entries reached, no more entries will be added.")); +#endif /* !MAC_INTEGRATION */ + notebook = GTK_NOTEBOOK (priv->notebook); tab_widget = gtk_notebook_get_tab_label (notebook, page->notebook_page); menu_widget = gtk_notebook_get_menu_label (notebook, page->notebook_page); diff --git a/gnucash/ui/gnc-main-window.ui b/gnucash/ui/gnc-main-window.ui index 1999cc6584..a9bbf7487c 100644 --- a/gnucash/ui/gnc-main-window.ui +++ b/gnucash/ui/gnc-main-window.ui @@ -482,7 +482,7 @@ Window0Action - mainwin.Window0Action + mainwin.WindowAction 0 action-disabled From 46c1dd00962c0cf3e86d48e5d3e3e113770daaf6 Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Fri, 28 Oct 2022 16:57:36 +0100 Subject: [PATCH 46/77] Fix accelerator keys for multiple windows. Simplify adding accelerator keys to windows by just adding one group to each window and update that group when menu changes. --- gnucash/gnome-utils/gnc-main-window.cpp | 40 ++++++++++++------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/gnucash/gnome-utils/gnc-main-window.cpp b/gnucash/gnome-utils/gnc-main-window.cpp index 50f316ec20..6fe67c0f37 100644 --- a/gnucash/gnome-utils/gnc-main-window.cpp +++ b/gnucash/gnome-utils/gnc-main-window.cpp @@ -269,7 +269,9 @@ typedef struct GncMainWindowPrivate const gchar *previous_plugin_page_name; //FIXMEb added const gchar *previous_menu_qualifier; //FIXMEb added - GtkAccelGroup *previous_plugin_page_accel_group; //FIXMEb added + + /** The accelerator group for the window */ + GtkAccelGroup *accel_group; //FIXMEb added GHashTable *display_item_hash; //FIXMEb added gint num_item_q; //FIXMEb temp added @@ -577,7 +579,6 @@ gnc_main_window_restore_window (GncMainWindow *window, GncMainWindowSaveData *da gchar *window_group; gsize page_start, page_count, i; GError *error = nullptr; - GtkAccelGroup *accel_group = gtk_accel_group_new (); /* Setup */ ENTER("window %p, data %p (key file %p, window %d)", @@ -719,10 +720,8 @@ gnc_main_window_restore_window (GncMainWindow *window, GncMainWindowSaveData *da gtk_window_maximize(GTK_WINDOW(window)); } -//FIXMEb not sure if this is in the right place // need to add the accelerator keys - gtk_window_add_accel_group (GTK_WINDOW(window), accel_group); - gnc_add_accelerator_keys_for_menu (GTK_WIDGET(priv->menubar), accel_group); + gnc_add_accelerator_keys_for_menu (GTK_WIDGET(priv->menubar), priv->accel_group); /* Common view menu items */ action = gnc_main_window_find_action (window, "ViewToolbarAction"); @@ -2764,7 +2763,9 @@ gnc_main_window_init (GncMainWindow *window, void *data) priv->previous_plugin_page_name = nullptr; priv->previous_menu_qualifier = nullptr; - priv->previous_plugin_page_accel_group = nullptr; + + priv->accel_group = gtk_accel_group_new (); + gtk_window_add_accel_group (GTK_WINDOW(window), priv->accel_group); /* Get the show_color_tabs value preference */ priv->show_color_tabs = gnc_prefs_get_bool(GNC_PREFS_GROUP_GENERAL, GNC_PREF_TAB_COLOR); @@ -3808,7 +3809,6 @@ gnc_main_window_update_menu (GncMainWindow *window, GncPluginPage *page, const gchar **ui_updates) { GncMainWindowPrivate *priv; - GtkAccelGroup *accel_group; const gchar *plugin_page_actions_group_name; GtkBuilder *builder; const gchar *menu_qualifier; @@ -3888,15 +3888,8 @@ gnc_main_window_update_menu (GncMainWindow *window, GncPluginPage *page, // add tooltip redirect call backs gnc_plugin_add_menu_tooltip_callbacks (priv->menubar, priv->menubar_model, priv->statusbar); - // remove existing accelerator group - if (priv->previous_plugin_page_accel_group) - gtk_window_remove_accel_group (GTK_WINDOW(window), priv->previous_plugin_page_accel_group); - - priv->previous_plugin_page_accel_group = gnc_plugin_page_get_accel_group (page); - // need to add the accelerator keys - gnc_add_accelerator_keys_for_menu (priv->menubar, priv->previous_plugin_page_accel_group); - gtk_window_add_accel_group (GTK_WINDOW(window), priv->previous_plugin_page_accel_group); + gnc_add_accelerator_keys_for_menu (priv->menubar, priv->accel_group); // need to signal menu has been changed g_signal_emit_by_name (window, "menu_changed", page); @@ -4113,6 +4106,14 @@ gnc_main_window_get_redirect (GncMainWindow *window, const gchar *action_name) return action; } +static void +main_window_realize_cb (GtkWidget *widget, gpointer user_data) +{ + GncMainWindow *window = (GncMainWindow*)user_data; + GncMainWindowPrivate *priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); + + gnc_add_accelerator_keys_for_menu (GTK_WIDGET(priv->menubar), priv->accel_group); +} static void gnc_main_window_setup_window (GncMainWindow *window) @@ -4121,7 +4122,6 @@ gnc_main_window_setup_window (GncMainWindow *window) GtkWidget *main_vbox; GtkBuilder *builder; GncPluginManager *manager; - GtkAccelGroup *accel_group = gtk_accel_group_new (); GtkWidget *extra_item; GList *plugins; GError *error = nullptr; @@ -4191,10 +4191,6 @@ gnc_main_window_setup_window (GncMainWindow *window) gtk_container_add (GTK_CONTAINER(priv->menu_dock), priv->menubar); //FIXMEb this may need changing gtk_widget_show (GTK_WIDGET(priv->menubar)); - // need to add the accelerator keys - gtk_window_add_accel_group (GTK_WINDOW(window), accel_group); - gnc_add_accelerator_keys_for_menu (GTK_WIDGET(priv->menubar), accel_group); - priv->toolbar = (GtkWidget *)gtk_builder_get_object (builder, "mainwin-toolbar"); g_object_set (priv->toolbar, "toolbar-style", GTK_TOOLBAR_BOTH, NULL); gtk_container_add (GTK_CONTAINER(priv->menu_dock), GTK_WIDGET(priv->toolbar)); //FIXMEb this may need changing @@ -4260,6 +4256,10 @@ gnc_main_window_setup_window (GncMainWindow *window) g_signal_connect (G_OBJECT (manager), "plugin-removed", G_CALLBACK (gnc_main_window_plugin_removed), window); + // need to add the accelerator keys this way, mainly for --nofile + g_signal_connect (G_OBJECT(window), "realize", + G_CALLBACK(main_window_realize_cb), window); + LEAVE(" "); } From 19cfbd6cd395025482474c6b8e50af24e4928b51 Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Fri, 28 Oct 2022 16:58:12 +0100 Subject: [PATCH 47/77] Hide the Transaction and Schedule menus at Window setup --- gnucash/gnome-utils/gnc-main-window.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/gnucash/gnome-utils/gnc-main-window.cpp b/gnucash/gnome-utils/gnc-main-window.cpp index 6fe67c0f37..ff3cd126cd 100644 --- a/gnucash/gnome-utils/gnc-main-window.cpp +++ b/gnucash/gnome-utils/gnc-main-window.cpp @@ -4126,6 +4126,7 @@ gnc_main_window_setup_window (GncMainWindow *window) GList *plugins; GError *error = nullptr; gchar *filename; + GAction *action; ENTER(" "); @@ -4236,6 +4237,13 @@ gnc_main_window_setup_window (GncMainWindow *window) gnc_main_window_init_menu_updaters (window); + /* Disable the Transaction menu */ + action = gnc_main_window_find_action (window, "TransactionAction"); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE); + /* Disable the Schedule menu */ + action = gnc_main_window_find_action (window, "ScheduledAction"); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE); + /* Now update the "eXtensions" menu */ if (!gnc_prefs_is_extra_enabled()) { From 239820c5a6bfb917b206a35517981b98e8f5d27a Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Fri, 28 Oct 2022 16:58:44 +0100 Subject: [PATCH 48/77] Fix the binding of the extra business items when gnucash started with --nofile --- gnucash/gnome-utils/gnc-main-window.cpp | 4 ++++ gnucash/gnome/gnc-plugin-business.c | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/gnucash/gnome-utils/gnc-main-window.cpp b/gnucash/gnome-utils/gnc-main-window.cpp index ff3cd126cd..9b754a1a1e 100644 --- a/gnucash/gnome-utils/gnc-main-window.cpp +++ b/gnucash/gnome-utils/gnc-main-window.cpp @@ -4113,6 +4113,10 @@ main_window_realize_cb (GtkWidget *widget, gpointer user_data) GncMainWindowPrivate *priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); gnc_add_accelerator_keys_for_menu (GTK_WIDGET(priv->menubar), priv->accel_group); + + /* need to signal menu has been changed, this will call the + business function 'bind_extra_toolbuttons_visibility' */ + g_signal_emit_by_name (window, "menu_changed", nullptr); } static void diff --git a/gnucash/gnome/gnc-plugin-business.c b/gnucash/gnome/gnc-plugin-business.c index a71e87e01f..dbaae7f947 100644 --- a/gnucash/gnome/gnc-plugin-business.c +++ b/gnucash/gnome/gnc-plugin-business.c @@ -840,9 +840,11 @@ gnc_plugin_business_main_window_menu_changed (GncMainWindow *window, GncPluginPage *page, gpointer user_data) { + // page could be NULL when gnucash started with --nofile if (page == gnc_main_window_get_current_page (window)) { - gnc_plugin_business_main_window_page_changed (window, page, user_data); + if (page) + gnc_plugin_business_main_window_page_changed (window, page, user_data); bind_extra_toolbuttons_visibility (window); } } From d0d76c279a763f7f56dfa100199778ac279d8429 Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Fri, 28 Oct 2022 16:59:19 +0100 Subject: [PATCH 49/77] Remove the hash table merged_actions_table There is no need to remember the simple action groups added to the main window. --- gnucash/gnome-utils/gnc-main-window.cpp | 146 ++++-------------------- 1 file changed, 23 insertions(+), 123 deletions(-) diff --git a/gnucash/gnome-utils/gnc-main-window.cpp b/gnucash/gnome-utils/gnc-main-window.cpp index 9b754a1a1e..91842b2838 100644 --- a/gnucash/gnome-utils/gnc-main-window.cpp +++ b/gnucash/gnome-utils/gnc-main-window.cpp @@ -259,11 +259,6 @@ typedef struct GncMainWindowPrivate gint event_handler_id; /** Array for window position. */ gint pos[2]; - /** A hash table of all action groups that have been installed - * into this window. The keys are the name of an action - * group, the values are structures of type - * MergedActionEntry. */ - GHashTable *merged_actions_table; /** Set when restoring plugin pages */ gboolean restoring_pages; @@ -286,15 +281,6 @@ GNC_DEFINE_TYPE_WITH_CODE(GncMainWindow, gnc_main_window, GTK_TYPE_WINDOW, #define GNC_MAIN_WINDOW_GET_PRIVATE(o) \ ((GncMainWindowPrivate*)gnc_main_window_get_instance_private((GncMainWindow*)o)) -/** This data structure maintains information about one action groups - * that has been installed in this window. */ -typedef struct -{ - /** The action group itself. This contains all actions added - * by a single menu or content plugin. */ - GSimpleActionGroup *simple_action_group; //FIXMEb added -} MergedActionEntry; - /** A holding place for all the signals generated by the main window * code. */ static guint main_window_signals[LAST_SIGNAL] = { 0 }; @@ -2746,8 +2732,6 @@ gnc_main_window_init (GncMainWindow *window, void *data) GncMainWindowClass *klass = (GncMainWindowClass*)data; priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); - priv->merged_actions_table = - g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); // Set the name for this dialog so it can be easily manipulated with css gtk_widget_set_name (GTK_WIDGET(window), "gnc-id-main-window"); @@ -2760,7 +2744,6 @@ gnc_main_window_init (GncMainWindow *window, void *data) priv->display_item_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, nullptr); priv->num_item_q = 0; //FIXMEb temp addded - priv->previous_plugin_page_name = nullptr; priv->previous_menu_qualifier = nullptr; @@ -2882,7 +2865,7 @@ gnc_main_window_destroy (GtkWidget *widget) /* Do these things once */ priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); - if (priv->merged_actions_table) + if (priv->event_handler_id > 0) { /* Close any pages in this window */ @@ -2901,9 +2884,6 @@ gnc_main_window_destroy (GtkWidget *widget) qof_event_unregister_handler(priv->event_handler_id); priv->event_handler_id = 0; - g_hash_table_destroy (priv->merged_actions_table); - priv->merged_actions_table = nullptr; - g_hash_table_destroy (priv->display_item_hash); /* GncPluginManager stuff */ @@ -3424,18 +3404,12 @@ gnc_main_window_manual_merge_actions (GncMainWindow *window, const gchar *group_name, GSimpleActionGroup *group) { - GncMainWindowPrivate *priv; - MergedActionEntry *entry; - - g_return_if_fail (GNC_IS_MAIN_WINDOW (window)); + g_return_if_fail (GNC_IS_MAIN_WINDOW(window)); g_return_if_fail (group_name != nullptr); g_return_if_fail (G_IS_SIMPLE_ACTION_GROUP(group)); - priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); - entry = g_new0 (MergedActionEntry, 1); - entry->simple_action_group = group; - - g_hash_table_insert (priv->merged_actions_table, g_strdup (group_name), entry); + gtk_widget_insert_action_group (GTK_WIDGET(window), group_name, + G_ACTION_GROUP(group)); } @@ -3503,8 +3477,9 @@ gnc_main_window_merge_actions (GncMainWindow *window, { GncMainWindowPrivate *priv; GncMainWindowActionData *data; + GSimpleActionGroup *simple_action_group; - g_return_if_fail (GNC_IS_MAIN_WINDOW (window)); + g_return_if_fail (GNC_IS_MAIN_WINDOW(window)); g_return_if_fail (group_name != nullptr); g_return_if_fail (actions != nullptr); g_return_if_fail (n_actions > 0); @@ -3514,39 +3489,19 @@ gnc_main_window_merge_actions (GncMainWindow *window, data->data = user_data; priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); - auto entry{static_cast(g_new0 (MergedActionEntry, 1))}; - entry->simple_action_group = g_simple_action_group_new (); - g_action_map_add_action_entries (G_ACTION_MAP(entry->simple_action_group), + simple_action_group = g_simple_action_group_new (); + + g_action_map_add_action_entries (G_ACTION_MAP(simple_action_group), actions, n_actions, data); gtk_widget_insert_action_group (GTK_WIDGET(window), group_name, - G_ACTION_GROUP(entry->simple_action_group)); + G_ACTION_GROUP(simple_action_group)); if (ui_filename) update_menu_model (window, ui_filename, ui_updates); - -//FIXMEb this is where I might need to add GtkBuilder???? - - -//FIXMEb gtk_ui_manager_insert_action_group (window->ui_merge, entry->action_group, 0); -// entry->merge_id = gtk_ui_manager_add_ui_from_file (window->ui_merge, pathname, &error); -// g_assert(entry->merge_id || error); -// if (entry->merge_id) -// { -// gtk_ui_manager_ensure_update (window->ui_merge); - g_hash_table_insert (priv->merged_actions_table, g_strdup (group_name), entry); -// } -// else -// { -// g_critical("Failed to load ui file.\n Filename %s\n Error %s", -// filename, error->message); -// g_error_free(error); -// g_free(entry); -// } -// g_free(pathname); } @@ -3559,54 +3514,10 @@ void gnc_main_window_unmerge_actions (GncMainWindow *window, const gchar *group_name) { - GncMainWindowPrivate *priv; - g_return_if_fail (GNC_IS_MAIN_WINDOW (window)); g_return_if_fail (group_name != nullptr); - priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); - if (priv->merged_actions_table == nullptr) - return; - auto entry{static_cast(g_hash_table_lookup (priv->merged_actions_table, group_name))}; - - if (entry == nullptr) - return; - gtk_widget_insert_action_group (GTK_WIDGET(window), group_name, nullptr); - - g_hash_table_remove (priv->merged_actions_table, group_name); -} - - -struct group_iterate -{ - GAction *action; - const gchar *group_name; - const gchar *action_name; -}; - -static void -group_foreach_cb (gpointer key, gpointer item, gpointer arg) -{ - struct group_iterate *iter = static_cast(arg); - GAction *action; - - if (iter->action) - return; - - if (iter->group_name != nullptr) - { - if (g_strcmp0 (iter->group_name, (gchar*)key) != 0) - return; - } - - auto entry{static_cast(item)}; - - action = g_action_map_lookup_action (G_ACTION_MAP(entry->simple_action_group), - iter->action_name); - - if (action) - iter->action = action; } GAction * @@ -3615,6 +3526,9 @@ gnc_main_window_find_action (GncMainWindow *window, const gchar *name) GncMainWindowPrivate *priv; GAction *action = nullptr; + g_return_val_if_fail (GNC_IS_MAIN_WINDOW(window), nullptr); + g_return_val_if_fail (name != nullptr, nullptr); + priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); action = g_action_map_lookup_action (G_ACTION_MAP(priv->simple_action_group), @@ -3628,22 +3542,17 @@ gnc_main_window_find_action_in_group (GncMainWindow *window, const gchar *group_name, const gchar *name) { - GncMainWindowPrivate *priv; GAction *action = nullptr; - struct group_iterate iter; - priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); + g_return_val_if_fail (GNC_IS_MAIN_WINDOW(window), nullptr); + g_return_val_if_fail (group_name != nullptr, nullptr); + g_return_val_if_fail (name != nullptr, nullptr); - if (priv->merged_actions_table == nullptr) - return nullptr; + auto action_group = gtk_widget_get_action_group (GTK_WIDGET(window), group_name); + if (action_group) + action = g_action_map_lookup_action (G_ACTION_MAP(action_group), name); - iter.action = nullptr; - iter.action_name = name; - iter.group_name = group_name; - - g_hash_table_foreach (priv->merged_actions_table, group_foreach_cb, &iter); - - return iter.action; + return action; } @@ -3655,20 +3564,11 @@ GSimpleActionGroup * gnc_main_window_get_action_group (GncMainWindow *window, const gchar *group_name) { - GncMainWindowPrivate *priv; - - g_return_val_if_fail (GNC_IS_MAIN_WINDOW (window), nullptr); + g_return_val_if_fail (GNC_IS_MAIN_WINDOW(window), nullptr); g_return_val_if_fail (group_name != nullptr, nullptr); - priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); - if (priv->merged_actions_table == nullptr) - return nullptr; - auto entry{static_cast(g_hash_table_lookup (priv->merged_actions_table, group_name))}; - - if (entry == nullptr) - return nullptr; - - return entry->simple_action_group; + auto action_group = gtk_widget_get_action_group (GTK_WIDGET(window), group_name); + return (GSimpleActionGroup*)action_group; } //FIXMEb## From 0aaf11ac25214de5e8d2958d1bf8e22310d7c500 Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Fri, 28 Oct 2022 17:00:01 +0100 Subject: [PATCH 50/77] Use GtkApplicationWindow as basis for GncMainWindow Geert's changes... As a GtkApplicationWindow also implements the GActionMap interface it can be used directly instead of the GSimpleActionGroup that was set up to maintain our actions. As a GtkApplicationWindow is not a GSimpleActionGroup (the other object to implement GActionMap) this also needed a minor change in the function signature of gnc_plugin_set_actions_enabled. --- gnucash/gnome-utils/gnc-main-window.cpp | 47 ++++++++----------- gnucash/gnome-utils/gnc-main-window.h | 8 ++-- gnucash/gnome-utils/gnc-plugin.c | 8 ++-- gnucash/gnome-utils/gnc-plugin.h | 5 +- gnucash/gnome/gnc-plugin-basic-commands.c | 6 +-- gnucash/gnome/gnc-plugin-budget.c | 2 +- gnucash/gnome/gnc-plugin-business.c | 6 +-- gnucash/gnome/gnc-plugin-page-account-tree.c | 10 ++-- gnucash/gnome/gnc-plugin-page-budget.c | 4 +- gnucash/gnome/gnc-plugin-page-invoice.c | 8 ++-- gnucash/gnome/gnc-plugin-page-owner-tree.c | 6 +-- gnucash/gnome/gnc-plugin-page-register.c | 6 +-- gnucash/gnome/gnc-plugin-page-report.cpp | 2 +- .../import-export/aqb/gnc-plugin-aqbanking.c | 8 ++-- 14 files changed, 58 insertions(+), 68 deletions(-) diff --git a/gnucash/gnome-utils/gnc-main-window.cpp b/gnucash/gnome-utils/gnc-main-window.cpp index 91842b2838..f2ee2959fe 100644 --- a/gnucash/gnome-utils/gnc-main-window.cpp +++ b/gnucash/gnome-utils/gnc-main-window.cpp @@ -244,11 +244,6 @@ typedef struct GncMainWindowPrivate * window that is contained in the status bar. This pointer * provides easy access for updating the progressbar. */ GtkWidget *progressbar; - - /** The group of all actions provided by the main window - * itself. This does not include any action provided by menu - * or content plugins. */ - GSimpleActionGroup *simple_action_group; //FIXMEb added /** A list of all pages that are installed in this window. */ GList *installed_pages; /** A list of pages in order of use (most recent -> least recent) */ @@ -273,7 +268,7 @@ typedef struct GncMainWindowPrivate } GncMainWindowPrivate; -GNC_DEFINE_TYPE_WITH_CODE(GncMainWindow, gnc_main_window, GTK_TYPE_WINDOW, +GNC_DEFINE_TYPE_WITH_CODE(GncMainWindow, gnc_main_window, GTK_TYPE_APPLICATION_WINDOW, G_ADD_PRIVATE (GncMainWindow) G_IMPLEMENT_INTERFACE (GNC_TYPE_WINDOW, gnc_window_main_window_init)) @@ -1559,7 +1554,7 @@ gnc_main_window_generate_title (GncMainWindow *window) /* Update the menus based upon whether this is an "immutable" page. */ immutable = page && g_object_get_data (G_OBJECT (page), PLUGIN_PAGE_IMMUTABLE); - gnc_plugin_set_actions_enabled (priv->simple_action_group, + gnc_plugin_set_actions_enabled (G_ACTION_MAP(window), immutable_page_actions, !immutable); /* Trigger sensitivity updtates of other actions such as Save/Revert */ @@ -1862,7 +1857,7 @@ gnc_main_window_update_radio_button (GncMainWindow *window) priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); - action = g_action_map_lookup_action (G_ACTION_MAP(priv->simple_action_group), + action = g_action_map_lookup_action (G_ACTION_MAP(window), "WindowAction"); /* Block the signal so as not to affect window ordering (top to @@ -3531,7 +3526,7 @@ gnc_main_window_find_action (GncMainWindow *window, const gchar *name) priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); - action = g_action_map_lookup_action (G_ACTION_MAP(priv->simple_action_group), + action = g_action_map_lookup_action (G_ACTION_MAP(window), name); return action; @@ -3550,7 +3545,7 @@ gnc_main_window_find_action_in_group (GncMainWindow *window, auto action_group = gtk_widget_get_action_group (GTK_WIDGET(window), group_name); if (action_group) - action = g_action_map_lookup_action (G_ACTION_MAP(action_group), name); + action = g_action_map_lookup_action (G_ACTION_MAP(window), name); return action; } @@ -3837,7 +3832,7 @@ gnc_main_window_update_tab_position (gpointer prefs, gchar *pref, gpointer user_ priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); gtk_notebook_set_tab_pos (GTK_NOTEBOOK(priv->notebook), position); - action = g_action_map_lookup_action (G_ACTION_MAP(priv->simple_action_group), + action = g_action_map_lookup_action (G_ACTION_MAP(window), "ViewTabPositionAction"); g_signal_handlers_block_by_func (G_OBJECT(action), @@ -4091,6 +4086,11 @@ gnc_main_window_setup_window (GncMainWindow *window) return; //FIXMEb this may need changing } + g_action_map_add_action_entries (G_ACTION_MAP(window), + gnc_menu_actions, + gnc_menu_n_actions, + window); + priv->menubar_model = (GMenuModel *)gtk_builder_get_object (builder, "mainwin-menu"); priv->menubar = gtk_menu_bar_new_from_model (priv->menubar_model); gtk_container_add (GTK_CONTAINER(priv->menu_dock), priv->menubar); //FIXMEb this may need changing @@ -4101,17 +4101,10 @@ gnc_main_window_setup_window (GncMainWindow *window) gtk_container_add (GTK_CONTAINER(priv->menu_dock), GTK_WIDGET(priv->toolbar)); //FIXMEb this may need changing gtk_widget_show (GTK_WIDGET(priv->toolbar)); - priv->simple_action_group = g_simple_action_group_new (); - - g_action_map_add_action_entries (G_ACTION_MAP(priv->simple_action_group), - gnc_menu_actions, - gnc_menu_n_actions, - window); - - gnc_plugin_set_actions_enabled (priv->simple_action_group, + gnc_plugin_set_actions_enabled (G_ACTION_MAP(window), initially_insensitive_actions, FALSE); - gnc_plugin_set_actions_enabled (priv->simple_action_group, + gnc_plugin_set_actions_enabled (G_ACTION_MAP(window), always_insensitive_actions, FALSE); @@ -4119,7 +4112,7 @@ gnc_main_window_setup_window (GncMainWindow *window) always_hidden_actions, false); gtk_widget_insert_action_group (GTK_WIDGET(window), "mainwin", - G_ACTION_GROUP(priv->simple_action_group)); + G_ACTION_GROUP(window)); gnc_prefs_register_cb (GNC_PREFS_GROUP_GENERAL, GNC_PREF_TAB_POSITION_TOP, @@ -4143,17 +4136,15 @@ gnc_main_window_setup_window (GncMainWindow *window) /* Disable the Transaction menu */ action = gnc_main_window_find_action (window, "TransactionAction"); - g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), false); /* Disable the Schedule menu */ action = gnc_main_window_find_action (window, "ScheduledAction"); - g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), false); /* Now update the "eXtensions" menu */ if (!gnc_prefs_is_extra_enabled()) { - GAction* action = g_action_map_lookup_action (G_ACTION_MAP(priv->simple_action_group), - "ExtensionsAction"); - + action = gnc_main_window_find_action (window, "ExtensionsAction"); g_simple_action_set_enabled (G_SIMPLE_ACTION(action), false); } @@ -4275,7 +4266,7 @@ gnc_main_window_show_summarybar (GncMainWindow *window, GAction *action) gboolean visible; if (action == nullptr) - action = g_action_map_lookup_action (G_ACTION_MAP(priv->simple_action_group), + action = g_action_map_lookup_action (G_ACTION_MAP(window), "ViewSummaryAction"); if (action == nullptr) return TRUE; @@ -4348,7 +4339,7 @@ gnc_main_window_switch_page (GtkNotebook *notebook, priv->usage_order = g_list_prepend (priv->usage_order, page); } - gnc_plugin_set_actions_enabled (priv->simple_action_group, + gnc_plugin_set_actions_enabled (G_ACTION_MAP(window), multiple_page_actions, g_list_length (priv->installed_pages) > 1); diff --git a/gnucash/gnome-utils/gnc-main-window.h b/gnucash/gnome-utils/gnc-main-window.h index 87bdd5fd03..b70ac8cc04 100644 --- a/gnucash/gnome-utils/gnc-main-window.h +++ b/gnucash/gnome-utils/gnc-main-window.h @@ -64,15 +64,15 @@ typedef struct /** The instance data structure for a main window object. */ typedef struct GncMainWindow { - GtkWindow gtk_window; /**< The parent object for a main window. */ - gboolean window_quitting; /**< Set to TRUE when quitting from this window. */ - gboolean just_plugin_prefs; /**< Just remove preferences only from plugins */ + GtkApplicationWindow gtk_application_window; /**< The parent object for a main window. */ + gboolean window_quitting; /**< Set to TRUE when quitting from this window. */ + gboolean just_plugin_prefs; /**< Just remove preferences only from plugins */ } GncMainWindow; /** The class data structure for a main window object. */ typedef struct { - GtkWindowClass gtk_window; /**< The parent class for a main window. */ + GtkApplicationWindowClass gtk_application_window; /**< The parent class for a main window. */ /* callbacks */ void (*page_added) (GncMainWindow *window, diff --git a/gnucash/gnome-utils/gnc-plugin.c b/gnucash/gnome-utils/gnc-plugin.c index d09d8a9891..f4c3217a01 100644 --- a/gnucash/gnome-utils/gnc-plugin.c +++ b/gnucash/gnome-utils/gnc-plugin.c @@ -244,20 +244,20 @@ gnc_plugin_init_short_names (GtkWidget *toolbar, /* Update the sensitivity of an action */ void -gnc_plugin_set_actions_enabled (GSimpleActionGroup *simple_action_group, +gnc_plugin_set_actions_enabled (GActionMap *action_map, const gchar **action_names, gboolean enable) { - g_return_if_fail (simple_action_group != NULL); + g_return_if_fail (action_map != NULL); for (gint i = 0; action_names[i]; i++) { - GAction *action = g_action_map_lookup_action (G_ACTION_MAP(simple_action_group), + GAction *action = g_action_map_lookup_action (G_ACTION_MAP(action_map), action_names[i]); if (action) g_simple_action_set_enabled (G_SIMPLE_ACTION(action), enable); else PERR("No such action with name '%s' in action group %p)", - action_names[i], simple_action_group); + action_names[i], action_map); } } diff --git a/gnucash/gnome-utils/gnc-plugin.h b/gnucash/gnome-utils/gnc-plugin.h index bab96b5da8..89c18d9c17 100644 --- a/gnucash/gnome-utils/gnc-plugin.h +++ b/gnucash/gnome-utils/gnc-plugin.h @@ -250,8 +250,7 @@ void gnc_plugin_init_short_names (GtkWidget *toolbar, /** This function sets the sensitivity of a GAction in a specific * group. * - * @param simple_action_group The group of all actions associated with a - * plugin or plugin page. + * @param action_map The action map associated with the window. * * @param action_names A NULL terminated list of actions names that * should be modified. @@ -259,7 +258,7 @@ void gnc_plugin_init_short_names (GtkWidget *toolbar, * @param enable A boolean specifying the new state for the specified * property. */ -void gnc_plugin_set_actions_enabled (GSimpleActionGroup *simple_action_group, +void gnc_plugin_set_actions_enabled (GActionMap *action_map, const gchar **action_names, gboolean enable); //FIXMEb added diff --git a/gnucash/gnome/gnc-plugin-basic-commands.c b/gnucash/gnome/gnc-plugin-basic-commands.c index 4ea7e0270f..c3b8749276 100644 --- a/gnucash/gnome/gnc-plugin-basic-commands.c +++ b/gnucash/gnome/gnc-plugin-basic-commands.c @@ -225,7 +225,7 @@ gnc_plugin_basic_commands_add_to_window (GncPlugin *plugin, GSimpleActionGroup *simple_action_group = gnc_main_window_get_action_group (window, PLUGIN_ACTIONS_NAME); - gnc_plugin_set_actions_enabled (simple_action_group, + gnc_plugin_set_actions_enabled (G_ACTION_MAP(simple_action_group), gnc_plugin_initially_insensitive_actions, FALSE); @@ -255,9 +255,9 @@ static void update_inactive_actions (GncPluginPage *plugin_page) g_return_if_fail (G_IS_SIMPLE_ACTION_GROUP(simple_action_group)); /* Set the action's sensitivity */ - gnc_plugin_set_actions_enabled (simple_action_group, readwrite_only_active_actions, + gnc_plugin_set_actions_enabled (G_ACTION_MAP(simple_action_group), readwrite_only_active_actions, is_readwrite); - gnc_plugin_set_actions_enabled (simple_action_group, dirty_only_active_actions, + gnc_plugin_set_actions_enabled (G_ACTION_MAP(simple_action_group), dirty_only_active_actions, is_dirty); } diff --git a/gnucash/gnome/gnc-plugin-budget.c b/gnucash/gnome/gnc-plugin-budget.c index 9f0e9578b0..5a8fa21b8f 100644 --- a/gnucash/gnome/gnc-plugin-budget.c +++ b/gnucash/gnome/gnc-plugin-budget.c @@ -114,7 +114,7 @@ page_changed (GncMainWindow *window, GncPluginPage *page, gpointer user_data) gnc_main_window_get_action_group (window, PLUGIN_ACTIONS_NAME); if (qof_book_is_readonly (gnc_get_current_book())) - gnc_plugin_set_actions_enabled (simple_action_group, plugin_writeable_actions, + gnc_plugin_set_actions_enabled (G_ACTION_MAP(simple_action_group), plugin_writeable_actions, FALSE); } diff --git a/gnucash/gnome/gnc-plugin-business.c b/gnucash/gnome/gnc-plugin-business.c index dbaae7f947..b877be8dc7 100644 --- a/gnucash/gnome/gnc-plugin-business.c +++ b/gnucash/gnome/gnc-plugin-business.c @@ -819,10 +819,10 @@ gnc_plugin_business_update_menus (GncPluginPage *plugin_page) is_bus_doc = (xaccTransGetTxnType (trans) == TXN_TYPE_INVOICE); } // Change visibility and also sensitivity according to whether we are in a txn register - gnc_plugin_set_actions_enabled (simple_action_group, register_txn_actions, + gnc_plugin_set_actions_enabled (G_ACTION_MAP(simple_action_group), register_txn_actions, is_txn_register && !is_bus_txn && !is_bus_doc); - gnc_plugin_set_actions_enabled (simple_action_group, register_bus_txn_actions, + gnc_plugin_set_actions_enabled (G_ACTION_MAP(simple_action_group), register_bus_txn_actions, is_txn_register && is_bus_txn && !is_bus_doc); } @@ -972,7 +972,7 @@ update_inactive_actions (GncPluginPage *plugin_page) g_return_if_fail (G_IS_SIMPLE_ACTION_GROUP(simple_action_group)); /* Set the action's sensitivity */ - gnc_plugin_set_actions_enabled (simple_action_group, readonly_inactive_actions, + gnc_plugin_set_actions_enabled (G_ACTION_MAP(simple_action_group), readonly_inactive_actions, is_readwrite); } diff --git a/gnucash/gnome/gnc-plugin-page-account-tree.c b/gnucash/gnome/gnc-plugin-page-account-tree.c index d2486c4ebd..6295ce9beb 100644 --- a/gnucash/gnome/gnc-plugin-page-account-tree.c +++ b/gnucash/gnome/gnc-plugin-page-account-tree.c @@ -803,15 +803,15 @@ update_inactive_actions (GncPluginPage *plugin_page) g_return_if_fail (G_IS_SIMPLE_ACTION_GROUP (simple_action_group)); /* Set the action's sensitivity */ - gnc_plugin_set_actions_enabled (simple_action_group, readonly_inactive_actions, + gnc_plugin_set_actions_enabled (G_ACTION_MAP(simple_action_group), readonly_inactive_actions, allow_write); - gnc_plugin_set_actions_enabled (simple_action_group, actions_requiring_account_rw, + gnc_plugin_set_actions_enabled (G_ACTION_MAP(simple_action_group), actions_requiring_account_rw, allow_write && has_account); - gnc_plugin_set_actions_enabled (simple_action_group, actions_requiring_account_always, + gnc_plugin_set_actions_enabled (G_ACTION_MAP(simple_action_group), actions_requiring_account_always, has_account); - gnc_plugin_set_actions_enabled (simple_action_group, actions_requiring_subaccounts_rw, + gnc_plugin_set_actions_enabled (G_ACTION_MAP(simple_action_group), actions_requiring_subaccounts_rw, allow_write && subaccounts); - gnc_plugin_set_actions_enabled (simple_action_group, actions_requiring_priced_account, + gnc_plugin_set_actions_enabled (G_ACTION_MAP(simple_action_group), actions_requiring_priced_account, account && xaccAccountIsPriced (account)); g_signal_emit (plugin_page, plugin_page_signals[ACCOUNT_SELECTED], 0, account); diff --git a/gnucash/gnome/gnc-plugin-page-budget.c b/gnucash/gnome/gnc-plugin-page-budget.c index b1f51cadce..113c55e9f3 100644 --- a/gnucash/gnome/gnc-plugin-page-budget.c +++ b/gnucash/gnome/gnc-plugin-page-budget.c @@ -323,7 +323,7 @@ gnc_plugin_page_budget_init (GncPluginPageBudget *plugin_page) plugin_page); if (qof_book_is_readonly (gnc_get_current_book())) - gnc_plugin_set_actions_enabled (simple_action_group, writeable_actions, + gnc_plugin_set_actions_enabled (G_ACTION_MAP(simple_action_group), writeable_actions, FALSE); /* Visible types */ @@ -702,7 +702,7 @@ gppb_selection_changed_cb (GtkTreeSelection *selection, } simple_action_group = gnc_plugin_page_get_action_group (GNC_PLUGIN_PAGE(page)); - gnc_plugin_set_actions_enabled (simple_action_group, actions_requiring_account, + gnc_plugin_set_actions_enabled (G_ACTION_MAP(simple_action_group), actions_requiring_account, sensitive); } #endif diff --git a/gnucash/gnome/gnc-plugin-page-invoice.c b/gnucash/gnome/gnc-plugin-page-invoice.c index f6f90ff4b5..861f23caf9 100644 --- a/gnucash/gnome/gnc-plugin-page-invoice.c +++ b/gnucash/gnome/gnc-plugin-page-invoice.c @@ -659,13 +659,13 @@ gnc_plugin_page_invoice_update_menus (GncPluginPage *page, gboolean is_posted, g g_simple_action_set_enabled (G_SIMPLE_ACTION(action), TRUE); simple_action_group = gnc_plugin_page_get_action_group (page); - gnc_plugin_set_actions_enabled (simple_action_group, posted_actions, + gnc_plugin_set_actions_enabled (G_ACTION_MAP(simple_action_group), posted_actions, is_posted); - gnc_plugin_set_actions_enabled (simple_action_group, unposted_actions, + gnc_plugin_set_actions_enabled (G_ACTION_MAP(simple_action_group), unposted_actions, !is_posted); - gnc_plugin_set_actions_enabled (simple_action_group, can_unpost_actions, + gnc_plugin_set_actions_enabled (G_ACTION_MAP(simple_action_group), can_unpost_actions, can_unpost); - gnc_plugin_set_actions_enabled (simple_action_group, invoice_book_readwrite_actions, + gnc_plugin_set_actions_enabled (G_ACTION_MAP(simple_action_group), invoice_book_readwrite_actions, !is_readonly); /* update the action labels and tooltips */ diff --git a/gnucash/gnome/gnc-plugin-page-owner-tree.c b/gnucash/gnome/gnc-plugin-page-owner-tree.c index 2598c84cbb..779728b6f3 100644 --- a/gnucash/gnome/gnc-plugin-page-owner-tree.c +++ b/gnucash/gnome/gnc-plugin-page-owner-tree.c @@ -438,7 +438,7 @@ update_inactive_actions(GncPluginPage *plugin_page) g_return_if_fail (G_IS_SIMPLE_ACTION_GROUP(simple_action_group)); /* Set the action's sensitivity */ - gnc_plugin_set_actions_enabled (simple_action_group, readonly_inactive_actions, + gnc_plugin_set_actions_enabled (G_ACTION_MAP(simple_action_group), readonly_inactive_actions, is_sensitive); } @@ -850,9 +850,9 @@ gnc_plugin_page_owner_tree_selection_changed_cb (GtkTreeSelection *selection, } simple_action_group = gnc_plugin_page_get_action_group (GNC_PLUGIN_PAGE(page)); - gnc_plugin_set_actions_enabled (simple_action_group, actions_requiring_owner_always, + gnc_plugin_set_actions_enabled (G_ACTION_MAP(simple_action_group), actions_requiring_owner_always, sensitive); - gnc_plugin_set_actions_enabled (simple_action_group, actions_requiring_owner_rw, + gnc_plugin_set_actions_enabled (G_ACTION_MAP(simple_action_group), actions_requiring_owner_rw, sensitive && is_readwrite); g_signal_emit (page, plugin_page_signals[OWNER_SELECTED], 0, owner); } diff --git a/gnucash/gnome/gnc-plugin-page-register.c b/gnucash/gnome/gnc-plugin-page-register.c index fa4eb73ba0..9d5813b5f2 100644 --- a/gnucash/gnome/gnc-plugin-page-register.c +++ b/gnucash/gnome/gnc-plugin-page-register.c @@ -922,11 +922,11 @@ gnc_plugin_page_register_ui_update (gpointer various, gnc_split_reg_get_read_only (priv->gsr)) read_only_reg = TRUE; - gnc_plugin_set_actions_enabled (gnc_plugin_page_get_action_group (GNC_PLUGIN_PAGE(page)), + gnc_plugin_set_actions_enabled (G_ACTION_MAP(gnc_plugin_page_get_action_group (GNC_PLUGIN_PAGE(page))), actions_requiring_account, !read_only_reg && account != NULL); - gnc_plugin_set_actions_enabled (gnc_plugin_page_get_action_group (GNC_PLUGIN_PAGE(page)), + gnc_plugin_set_actions_enabled (G_ACTION_MAP(gnc_plugin_page_get_action_group (GNC_PLUGIN_PAGE(page))), actions_requiring_priced_account, account && xaccAccountIsPriced (account)); @@ -1117,7 +1117,7 @@ gnc_plugin_page_register_ui_initial_state (GncPluginPageRegister* page) simple_action_group = gnc_plugin_page_get_action_group (GNC_PLUGIN_PAGE(page)); g_return_if_fail (G_IS_SIMPLE_ACTION_GROUP(simple_action_group)); - gnc_plugin_set_actions_enabled (simple_action_group, actions_requiring_account, + gnc_plugin_set_actions_enabled (G_ACTION_MAP(simple_action_group), actions_requiring_account, is_readwrite && account != NULL); /* Set "style" radio button */ diff --git a/gnucash/gnome/gnc-plugin-page-report.cpp b/gnucash/gnome/gnc-plugin-page-report.cpp index 875b76e4dd..b731cf7d90 100644 --- a/gnucash/gnome/gnc-plugin-page-report.cpp +++ b/gnucash/gnome/gnc-plugin-page-report.cpp @@ -1326,7 +1326,7 @@ gnc_plugin_page_report_constr_init (GncPluginPageReport *plugin_page, gint repor num_report_actions, plugin_page); - gnc_plugin_set_actions_enabled (simple_action_group, initially_insensitive_actions, + gnc_plugin_set_actions_enabled (G_ACTION_MAP(simple_action_group), initially_insensitive_actions, FALSE); } diff --git a/gnucash/import-export/aqb/gnc-plugin-aqbanking.c b/gnucash/import-export/aqb/gnc-plugin-aqbanking.c index 8c3e6e2577..7469d101bd 100644 --- a/gnucash/import-export/aqb/gnc-plugin-aqbanking.c +++ b/gnucash/import-export/aqb/gnc-plugin-aqbanking.c @@ -280,7 +280,7 @@ static void update_inactive_actions(GncPluginPage *plugin_page) g_return_if_fail (G_IS_SIMPLE_ACTION_GROUP(simple_action_group)); /* Set the action's sensitivity */ - gnc_plugin_set_actions_enabled (simple_action_group, readonly_inactive_actions, + gnc_plugin_set_actions_enabled (G_ACTION_MAP(simple_action_group), readonly_inactive_actions, is_readwrite); } @@ -330,19 +330,19 @@ gnc_plugin_ab_account_selected (GncPluginPage *plugin_page, Account *account, bankcode = gnc_ab_get_account_bankcode(account); accountid = gnc_ab_get_account_accountid(account); - gnc_plugin_set_actions_enabled (simple_action_group, need_account_actions, + gnc_plugin_set_actions_enabled (G_ACTION_MAP(simple_action_group), need_account_actions, (account && bankcode && *bankcode && accountid && *accountid)); gnc_main_window_menu_item_vis_by_action (window, need_account_actions, TRUE); #if (AQBANKING_VERSION_INT < 60400) - gnc_plugin_set_actions_enabled (simple_action_group, inactive_account_actions, FALSE); + gnc_plugin_set_actions_enabled (G_ACTION_MAP(simple_action_group), inactive_account_actions, FALSE); gnc_main_window_menu_item_vis_by_action (window, inactive_account_actions, FALSE); #endif } else { - gnc_plugin_set_actions_enabled (simple_action_group, need_account_actions, FALSE); + gnc_plugin_set_actions_enabled (G_ACTION_MAP(simple_action_group), need_account_actions, FALSE); gnc_main_window_menu_item_vis_by_action (window, need_account_actions, FALSE); } From bb5fa1220964a48b3caba0e061ff5939824987b1 Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Mon, 31 Oct 2022 10:41:09 +0000 Subject: [PATCH 51/77] Update the menu and tool utils A descriptions for the util functions. --- gnucash/gnome-utils/gnc-gtk-utils.c | 183 +++++++++++++++++++--------- gnucash/gnome-utils/gnc-gtk-utils.h | 4 + 2 files changed, 128 insertions(+), 59 deletions(-) diff --git a/gnucash/gnome-utils/gnc-gtk-utils.c b/gnucash/gnome-utils/gnc-gtk-utils.c index f39bcae81a..b9b8840d8a 100644 --- a/gnucash/gnome-utils/gnc-gtk-utils.c +++ b/gnucash/gnome-utils/gnc-gtk-utils.c @@ -450,7 +450,7 @@ find_menu_item_func (GtkWidget *widget, const gchar *action_name, const gchar *a return ret; } -/** Search the menu for the menu item based on the label or action name +/** Search the menu for the menu item based on action name * * @param menu The menu widget. * @@ -507,38 +507,23 @@ gnc_find_menu_item_by_action_label (GtkWidget *menu, const gchar *action_label) static void -search_menu_item_list (GtkWidget *widget, gpointer user_data) +menu_item_list (GtkWidget *widget, gpointer user_data) { GList **list = user_data; if (GTK_IS_MENU_ITEM(widget)) { GtkWidget* subMenu = gtk_menu_item_get_submenu (GTK_MENU_ITEM(widget)); - const gchar *a_name = g_object_get_data (G_OBJECT(widget), "myaction-name"); *list = g_list_prepend (*list, widget); - if (!a_name) - { - GtkWidget *accel_label = gtk_bin_get_child (GTK_BIN(widget)); - - if (accel_label) - { - // use gtk_label_get_text to get text with no underlines - const gchar *al_name = gtk_label_get_label (GTK_LABEL(accel_label)); - - g_object_set_data_full (G_OBJECT(widget), "myaction-name", - g_strdup (al_name), g_free); - } - } - if (GTK_IS_CONTAINER(subMenu)) gtk_container_foreach (GTK_CONTAINER(subMenu), - search_menu_item_list, user_data); + menu_item_list, user_data); } } -/** Return a list of menu items +/** Return a list of GtkMenuItems * * @param menu The menu widget. * @@ -551,11 +536,33 @@ gnc_menu_get_items (GtkWidget *menu) g_return_val_if_fail (GTK_IS_WIDGET(menu), NULL); - gtk_container_foreach (GTK_CONTAINER(menu), search_menu_item_list, &list); + gtk_container_foreach (GTK_CONTAINER(menu), menu_item_list, &list); return list; } + +struct find_tool_item_struct +{ + GtkWidget *found_tool_item; + const gchar *action_name; +}; + +static void +find_tool_action (GtkWidget *widget, gpointer user_data) +{ + struct find_tool_item_struct *ftis = user_data; + + if (GTK_IS_ACTIONABLE(widget)) + { + // this returns the full action name + const gchar *item_action_name = gtk_actionable_get_action_name (GTK_ACTIONABLE(widget)); + + if (g_str_has_suffix (item_action_name, ftis->action_name)) + ftis->found_tool_item = GTK_WIDGET(widget); + } +} + /** Search the toolbar for the tool item based on the action name * * @param toolbar The toolbar widget. @@ -567,27 +574,17 @@ gnc_menu_get_items (GtkWidget *menu) GtkWidget * gnc_find_toolbar_item (GtkWidget *toolbar, const gchar *action_name) { - GtkWidget *found = NULL; + struct find_tool_item_struct ftis; g_return_val_if_fail (GTK_IS_TOOLBAR(toolbar), NULL); g_return_val_if_fail (action_name != NULL, NULL); - for (gint i = 0; i < gtk_toolbar_get_n_items (GTK_TOOLBAR(toolbar)); i++) - { - GtkToolItem *item = gtk_toolbar_get_nth_item (GTK_TOOLBAR(toolbar), i); + ftis.action_name = action_name; + ftis.found_tool_item = NULL; - if (GTK_IS_ACTIONABLE(item)) - { - const gchar *item_action_name = gtk_actionable_get_action_name (GTK_ACTIONABLE(item)); + gtk_container_foreach (GTK_CONTAINER(toolbar), find_tool_action, &ftis); - if (g_str_has_suffix (item_action_name, action_name)) - { - found = GTK_WIDGET(item); - break; - } - } - } - return found; + return ftis.found_tool_item; } @@ -607,11 +604,14 @@ extract_items_from_model (GMenuModel *model, iter = g_menu_model_iterate_item_attributes (model, item); while (g_menu_attribute_iter_get_next (iter, &key, &value)) { - if (g_str_equal (key, "tooltip") && g_variant_is_of_type (value, G_VARIANT_TYPE_STRING)) + if (g_str_equal (key, GNC_MENU_ATTRIBUTE_TOOLTIP) && + g_variant_is_of_type (value, G_VARIANT_TYPE_STRING)) tooltip = g_variant_get_string (value, NULL); - else if (g_str_equal (key, "label") && g_variant_is_of_type (value, G_VARIANT_TYPE_STRING)) + else if (g_str_equal (key, G_MENU_ATTRIBUTE_LABEL) && + g_variant_is_of_type (value, G_VARIANT_TYPE_STRING)) label = g_variant_get_string (value, NULL); - else if (g_str_equal (key, "action") && g_variant_is_of_type (value, G_VARIANT_TYPE_STRING)) + else if (g_str_equal (key, G_MENU_ATTRIBUTE_ACTION) && + g_variant_is_of_type (value, G_VARIANT_TYPE_STRING)) action = g_variant_get_string (value, NULL); g_variant_unref (value); @@ -666,6 +666,19 @@ items_from_model (GMenuModel *model, } } +/** Find a GtkMenu item from the action name. This is done by first finding + * the action name in the GMenuModel and then doing a search for the + * label text in the GtkMenu. + * + * NOTE: This is done this way as the action_name field of the GtkMenuItem + * is not populated from the model. + * + * @param menu_model The GMenuModel of the menu. + * + * @param gsm The GncMenuModelSearch structure. + * + * @return TRUE if GMenuModel item found or FALSE if not. + */ gboolean gnc_menubar_model_find_item (GMenuModel *menu_model, GncMenuModelSearch *gsm) { @@ -683,32 +696,72 @@ gnc_menubar_model_find_item (GMenuModel *menu_model, GncMenuModelSearch *gsm) return FALSE; } + +/** Find a GtkMenu item from the action name. This is done by first finding + * the action name in the GMenuModel and then doing a search for the + * label text in the GtkMenu. + * + * NOTE: This is done this way as the action_name field of the GtkMenuItem + * is not populated from the model. + * + * @param menu_model The GMenuModel of the menu. + * + * @param menu The GtkMenu built from the model. + * + * @param action_name The action name of the menu item to find. + * + * @return The GtkMenuItem if found or NULL + */ GtkWidget * gnc_menubar_model_find_menu_item (GMenuModel *menu_model, GtkWidget *menu, const gchar *action_name) { - GncMenuModelSearch *gsm = g_new0 (GncMenuModelSearch, 1); + GncMenuModelSearch *gsm; GtkWidget *menu_item = NULL; + g_return_val_if_fail (menu_model != NULL, NULL); + g_return_val_if_fail (menu != NULL, NULL); + g_return_val_if_fail (action_name != NULL, NULL); + + gsm = g_new0 (GncMenuModelSearch, 1); + gsm->search_action_label = NULL; gsm->search_action_name = action_name; if (gnc_menubar_model_find_item (menu_model, gsm)) - { menu_item = gnc_find_menu_item_by_action_label (menu, gsm->search_action_label); - } + g_free (gsm); return menu_item; } +/** Update the GMenuModel item based on the action name by copying + * existing item, removing it and inserting a new one in same location. + * + * @param menu_model The GMenuModel of the menu. + * + * @param action_name The action name to update. + * + * @param label The new menu label text. + * + * @param tooltip The new tooltip text if any. + * + * @return TRUE if item found and updated or FALSE if not. + */ gboolean gnc_menubar_model_update_item (GMenuModel *menu_model, const gchar *action_name, const gchar *label, const gchar *tooltip) { - GncMenuModelSearch *gsm = g_new0 (GncMenuModelSearch, 1); + GncMenuModelSearch *gsm; GtkWidget *menu_item = NULL; gboolean found = FALSE; + g_return_val_if_fail (menu_model != NULL, FALSE); + g_return_val_if_fail (action_name != NULL, FALSE); + g_return_val_if_fail (label != NULL, FALSE); + + gsm = g_new0 (GncMenuModelSearch, 1); + gsm->search_action_label = NULL; gsm->search_action_name = action_name; @@ -727,15 +780,19 @@ gnc_menubar_model_update_item (GMenuModel *menu_model, const gchar *action_name, iter = g_menu_model_iterate_item_attributes (gsm->model, gsm->index); while (g_menu_attribute_iter_get_next (iter, &key, &value)) { - if (g_str_equal (key, "temp") && g_variant_is_of_type (value, G_VARIANT_TYPE_STRING)) + if (g_str_equal (key, GNC_MENU_ATTRIBUTE_TEMPORARY) && + g_variant_is_of_type (value, G_VARIANT_TYPE_STRING)) old_temp = g_variant_get_string (value, NULL); - else if (g_str_equal (key, "label") && g_variant_is_of_type (value, G_VARIANT_TYPE_STRING)) + else if (g_str_equal (key, G_MENU_ATTRIBUTE_LABEL) && + g_variant_is_of_type (value, G_VARIANT_TYPE_STRING)) old_label = g_variant_get_string (value, NULL); - else if (g_str_equal (key, "action") && g_variant_is_of_type (value, G_VARIANT_TYPE_STRING)) + else if (g_str_equal (key, G_MENU_ATTRIBUTE_ACTION) && + g_variant_is_of_type (value, G_VARIANT_TYPE_STRING)) old_action = g_variant_get_string (value, NULL); - else if (g_str_equal (key, "accel") && g_variant_is_of_type (value, G_VARIANT_TYPE_STRING)) + else if (g_str_equal (key, GNC_MENU_ATTRIBUTE_ACCELERATOR) && + g_variant_is_of_type (value, G_VARIANT_TYPE_STRING)) old_accel = g_variant_get_string (value, NULL); - else if (g_str_equal (key, "target")) + else if (g_str_equal (key, G_MENU_ATTRIBUTE_TARGET)) old_target = g_variant_ref (value); g_variant_unref (value); @@ -744,29 +801,28 @@ gnc_menubar_model_update_item (GMenuModel *menu_model, const gchar *action_name, item = g_menu_item_new (label, old_action); if (tooltip) - g_menu_item_set_attribute (item, "tooltip", "s", tooltip); + g_menu_item_set_attribute (item, GNC_MENU_ATTRIBUTE_TOOLTIP, "s", tooltip); if (old_temp) - g_menu_item_set_attribute (item, "temp", "s", old_temp); + g_menu_item_set_attribute (item, GNC_MENU_ATTRIBUTE_TEMPORARY, "s", old_temp); if (old_accel) - g_menu_item_set_attribute (item, "accel", "s", old_accel); + g_menu_item_set_attribute (item, GNC_MENU_ATTRIBUTE_ACCELERATOR, "s", old_accel); if (old_target) { - g_menu_item_set_attribute_value (item, "target", old_target); + g_menu_item_set_attribute_value (item, G_MENU_ATTRIBUTE_TARGET, old_target); g_variant_unref (old_target); } - g_menu_remove (G_MENU(gsm->model), gsm->index); g_menu_insert_item (G_MENU(gsm->model), gsm->index, item); - found = TRUE; } g_free (gsm); return found; } + typedef struct { GMenuModel *model; @@ -788,7 +844,7 @@ item_to_remove_from_model (GMenuModel *model, tr->model = model; tr->index = item; - // to keep order appended + // to keep the order append *remove_list = g_list_append (*remove_list, tr); g_variant_unref (value); } @@ -825,6 +881,13 @@ remove_items (gpointer data, gpointer user_data) g_free (tr); } +/** Remove GMenuModel entries based on having an attribute value equal + * to attrib, it does not matter what the value is. + * + * @param menu_model The GMenuModel of the menu. + * + * @param attrib The attribute to look for. + */ void gnc_menubar_model_remove_items_with_attrib (GMenuModel *menu_model, const gchar *attrib) { @@ -839,6 +902,7 @@ gnc_menubar_model_remove_items_with_attrib (GMenuModel *menu_model, const gchar g_list_free (remove_list); } + static void statusbar_push (GtkWidget *statusbar, const gchar *text) { @@ -853,10 +917,10 @@ statusbar_pop (GtkWidget *statusbar) } static void -menu_item_select_cb (GtkWidget *menu_item, gpointer user_data) +menu_item_select_cb (GtkWidget *menu_item, GtkWidget *statusbar) { GtkWidget *accel_label = gtk_bin_get_child (GTK_BIN(menu_item)); - GMenuModel *menubar_model = g_object_get_data (G_OBJECT(user_data), "menu-model"); + GMenuModel *menubar_model = g_object_get_data (G_OBJECT(statusbar), "menu-model"); if (!menubar_model) return; @@ -871,16 +935,16 @@ menu_item_select_cb (GtkWidget *menu_item, gpointer user_data) if (gnc_menubar_model_find_item (menubar_model, gsm)) { if (gsm->model) - statusbar_push (user_data, gsm->tooltip); + statusbar_push (statusbar, gsm->tooltip); } g_free (gsm); } } static void -menu_item_deselect_cb (GtkWidget *menu_item, gpointer user_data) +menu_item_deselect_cb (GtkWidget *menu_item, GtkWidget *statusbar) { - statusbar_pop (user_data); + statusbar_pop (statusbar); } /** Setup the callbacks for menu bar items so the tooltip can be @@ -907,6 +971,7 @@ gnc_menu_item_setup_tooltip_to_statusbar_callback (GtkWidget *menu_item, G_CALLBACK(menu_item_deselect_cb), statusbar); g_object_set (G_OBJECT(menu_item), "has-tooltip", FALSE, NULL); + g_object_set_data (G_OBJECT(menu_item), "added-callbacks", GINT_TO_POINTER(1)); } diff --git a/gnucash/gnome-utils/gnc-gtk-utils.h b/gnucash/gnome-utils/gnc-gtk-utils.h index f0da494b65..43e2c0375e 100644 --- a/gnucash/gnome-utils/gnc-gtk-utils.h +++ b/gnucash/gnome-utils/gnc-gtk-utils.h @@ -41,6 +41,10 @@ @{ */ +#define GNC_MENU_ATTRIBUTE_ACCELERATOR "accel" +#define GNC_MENU_ATTRIBUTE_TOOLTIP "tooltip" +#define GNC_MENU_ATTRIBUTE_TEMPORARY "temp" + void gnc_cbwe_set_by_string(GtkComboBox *cbwe, const gchar *text); void gnc_cbwe_add_completion (GtkComboBox *cbwe); void gnc_cbwe_require_list_item (GtkComboBox *cbwe); From 7abd26f895b353147005ce4d150b8d0b8fb75299 Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Mon, 31 Oct 2022 10:48:33 +0000 Subject: [PATCH 52/77] Use the added defines for the g_menu_item_set_attribute function --- gnucash/gnome-utils/gnc-main-window.cpp | 5 +++-- gnucash/gnome-utils/gnc-plugin-file-history.c | 4 +--- gnucash/gnome-utils/gnc-plugin-menu-additions.c | 4 ++-- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/gnucash/gnome-utils/gnc-main-window.cpp b/gnucash/gnome-utils/gnc-main-window.cpp index f2ee2959fe..442ffbff5b 100644 --- a/gnucash/gnome-utils/gnc-main-window.cpp +++ b/gnucash/gnome-utils/gnc-main-window.cpp @@ -1814,7 +1814,7 @@ gnc_main_window_update_one_menu_action (GncMainWindow *window, } item = g_menu_item_new (data->label, "mainwin.WindowAction"); - g_menu_item_set_attribute (item, "target", "i", data->index); + g_menu_item_set_attribute (item, G_MENU_ATTRIBUTE_TARGET, "i", data->index); if (pos < g_menu_model_get_n_items (gsm->model)) g_menu_remove (G_MENU(gsm->model), pos); @@ -3750,7 +3750,8 @@ gnc_main_window_update_menu (GncMainWindow *window, GncPluginPage *page, // reset hash table and remove added menu items g_hash_table_remove_all (priv->display_item_hash); - gnc_menubar_model_remove_items_with_attrib (priv->menubar_model, "temp"); + gnc_menubar_model_remove_items_with_attrib (priv->menubar_model, + GNC_MENU_ATTRIBUTE_TEMPORARY); priv->num_item_q = 0; //FIXMEb temp added for (gint i = 0; ui_updates[i]; i++) diff --git a/gnucash/gnome-utils/gnc-plugin-file-history.c b/gnucash/gnome-utils/gnc-plugin-file-history.c index 2b016d758b..558f5e5e5b 100644 --- a/gnucash/gnome-utils/gnc-plugin-file-history.c +++ b/gnucash/gnome-utils/gnc-plugin-file-history.c @@ -460,15 +460,13 @@ gnc_history_update_action (GncMainWindow *window, item = g_menu_item_new (label_name, full_action_name); - g_menu_item_set_attribute (item, "tooltip", "s", tooltip); + g_menu_item_set_attribute (item, GNC_MENU_ATTRIBUTE_TOOLTIP, "s", tooltip); if (!add_item) g_menu_remove (G_MENU(gsm->model), pos); g_menu_insert_item (G_MENU(gsm->model), pos, item); -//FIXMEb tooltip needs fixing to status bar and accelerator ? - g_free (full_action_name); g_free (label_name); g_free (tooltip); diff --git a/gnucash/gnome-utils/gnc-plugin-menu-additions.c b/gnucash/gnome-utils/gnc-plugin-menu-additions.c index b5303126d1..20a585de01 100644 --- a/gnucash/gnome-utils/gnc-plugin-menu-additions.c +++ b/gnucash/gnome-utils/gnc-plugin-menu-additions.c @@ -434,7 +434,7 @@ gnc_menu_additions_menu_setup_one (ExtensionInfo *ext_info, g_menu_item_set_action_and_target_value (gmenu_item, "gnc-plugin-menu-additions-actions.AdditionsAction", g_variant_new_string (ext_info->action_name)); - g_menu_item_set_attribute (gmenu_item, "tooltip", "s", ext_info->action_tooltip); + g_menu_item_set_attribute (gmenu_item, GNC_MENU_ATTRIBUTE_TOOLTIP, "s", ext_info->action_tooltip); } if (g_strcmp0 (ext_info->typeStr, "menu") == 0) @@ -457,7 +457,7 @@ gnc_menu_additions_menu_setup_one (ExtensionInfo *ext_info, g_menu_item_set_action_and_target_value (gmenu_item, "gnc-plugin-menu-additions-actions.AdditionsAction", g_variant_new_string (ext_info->action_name)); - g_menu_item_set_attribute (gmenu_item, "tooltip", "s", ext_info->action_tooltip); + g_menu_item_set_attribute (gmenu_item, GNC_MENU_ATTRIBUTE_TOOLTIP, "s", ext_info->action_tooltip); } if (g_strcmp0 (ext_info->typeStr, "menu") == 0) From ab3ae3fada4b9e0ff9040c986872e97a3cc1f3eb Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Mon, 31 Oct 2022 11:45:45 +0000 Subject: [PATCH 53/77] Rename main window toolbar function. Rename the main window function gnc_main_window_toolbar_find_menu_item to gnc_main_window_toolbar_find_tool_item --- gnucash/gnome-utils/gnc-main-window.cpp | 10 ++++++++-- gnucash/gnome-utils/gnc-main-window.h | 12 +++++++++++- gnucash/gnome/gnc-plugin-page-invoice.c | 4 ++-- gnucash/gnome/gnc-plugin-page-report.cpp | 2 +- 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/gnucash/gnome-utils/gnc-main-window.cpp b/gnucash/gnome-utils/gnc-main-window.cpp index 442ffbff5b..34163a2d8c 100644 --- a/gnucash/gnome-utils/gnc-main-window.cpp +++ b/gnucash/gnome-utils/gnc-main-window.cpp @@ -3570,9 +3570,15 @@ gnc_main_window_get_action_group (GncMainWindow *window, GtkWidget * -gnc_main_window_toolbar_find_menu_item (GncMainWindow *window, const gchar *action_name) +gnc_main_window_toolbar_find_tool_item (GncMainWindow *window, const gchar *action_name) { - GncMainWindowPrivate *priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); + GncMainWindowPrivate *priv; + + g_return_val_if_fail (GNC_IS_MAIN_WINDOW(window), nullptr); + g_return_val_if_fail (action_name != nullptr, nullptr); + + priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); + return gnc_find_toolbar_item (priv->toolbar, action_name); } diff --git a/gnucash/gnome-utils/gnc-main-window.h b/gnucash/gnome-utils/gnc-main-window.h index b70ac8cc04..c1373e4a80 100644 --- a/gnucash/gnome-utils/gnc-main-window.h +++ b/gnucash/gnome-utils/gnc-main-window.h @@ -271,7 +271,17 @@ void gnc_main_window_menu_item_vis_by_action (GncMainWindow *window, GtkWidget *gnc_main_window_menu_find_menu_item (GncMainWindow *window, const gchar *action_name); //FIXMEb added -GtkWidget * gnc_main_window_toolbar_find_menu_item (GncMainWindow *window, +/** Find the toolbar item with the given action name for the window + * specified. + * + * @param window A pointer to the window whose user interface should + * be updated. + * + * @param action_name The action name of the tool item to find. + * + * @return The found tool item widget or NULL. + */ +GtkWidget * gnc_main_window_toolbar_find_tool_item (GncMainWindow *window, const gchar *action_name); //FIXMEb added /** A structure for defining alternate action names for use in the diff --git a/gnucash/gnome/gnc-plugin-page-invoice.c b/gnucash/gnome/gnc-plugin-page-invoice.c index 861f23caf9..0732c71629 100644 --- a/gnucash/gnome/gnc-plugin-page-invoice.c +++ b/gnucash/gnome/gnc-plugin-page-invoice.c @@ -525,7 +525,7 @@ gnc_plugin_page_invoice_action_update (GncPluginPage *plugin_page, if (menu_item) gtk_menu_item_set_label (GTK_MENU_ITEM(menu_item), _(action_list[i].label)); - tool_item = gnc_main_window_toolbar_find_menu_item (GNC_MAIN_WINDOW(GNC_PLUGIN_PAGE(plugin_page)->window), + tool_item = gnc_main_window_toolbar_find_tool_item (GNC_MAIN_WINDOW(GNC_PLUGIN_PAGE(plugin_page)->window), action_list[i].action_name); if (tool_item) @@ -540,7 +540,7 @@ gnc_plugin_page_invoice_action_update (GncPluginPage *plugin_page, if (menu_item) gtk_widget_set_tooltip_text (GTK_WIDGET(menu_item), _(tooltip_list[i].label)); - tool_item = gnc_main_window_toolbar_find_menu_item (GNC_MAIN_WINDOW(GNC_PLUGIN_PAGE(plugin_page)->window), + tool_item = gnc_main_window_toolbar_find_tool_item (GNC_MAIN_WINDOW(GNC_PLUGIN_PAGE(plugin_page)->window), tooltip_list[i].action_name); if (tool_item) diff --git a/gnucash/gnome/gnc-plugin-page-report.cpp b/gnucash/gnome/gnc-plugin-page-report.cpp index b731cf7d90..da1a624d2f 100644 --- a/gnucash/gnome/gnc-plugin-page-report.cpp +++ b/gnucash/gnome/gnc-plugin-page-report.cpp @@ -1235,7 +1235,7 @@ gnc_plugin_page_report_menu_update (GncPluginPage *plugin_page, if (menu_item) gtk_widget_set_tooltip_text (GTK_WIDGET(menu_item), _(tooltip_list[i].label)); - tool_item = gnc_main_window_toolbar_find_menu_item (GNC_MAIN_WINDOW(GNC_PLUGIN_PAGE(plugin_page)->window), + tool_item = gnc_main_window_toolbar_find_tool_item (GNC_MAIN_WINDOW(GNC_PLUGIN_PAGE(plugin_page)->window), tooltip_list[i].action_name); if (tool_item) { From e00bcf581d74e87069509789be560e4efa8d1942 Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Mon, 31 Oct 2022 11:59:18 +0000 Subject: [PATCH 54/77] Add function description for gnc_main_window_menu_find_menu_item --- gnucash/gnome-utils/gnc-main-window.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/gnucash/gnome-utils/gnc-main-window.h b/gnucash/gnome-utils/gnc-main-window.h index c1373e4a80..167d8f752d 100644 --- a/gnucash/gnome-utils/gnc-main-window.h +++ b/gnucash/gnome-utils/gnc-main-window.h @@ -268,6 +268,16 @@ void gnc_main_window_menu_item_vis_by_action (GncMainWindow *window, const gchar **action_names, gboolean vis); //FIXMEb added +/** Find the menu item with the given action name for the window + * specified. + * + * @param window A pointer to the window whose user interface should + * be updated. + * + * @param action_name The action name of the tool item to find. + * + * @return The found menu item widget or NULL. + */ GtkWidget *gnc_main_window_menu_find_menu_item (GncMainWindow *window, const gchar *action_name); //FIXMEb added From 5c498a1c9ba8fa9c67d4162117bec4e089fbe7d4 Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Mon, 31 Oct 2022 15:28:23 +0000 Subject: [PATCH 55/77] Rename gnc_main_window_menu_item_vis_by_action Rename the main window function gnc_main_window_menu_item_vis_by_action to gnc_main_window_set_vis_of_items_by_action as it deals with menu and toolbar items. --- gnucash/gnome-utils/gnc-main-window.cpp | 20 +++++++++---------- gnucash/gnome-utils/gnc-main-window.h | 18 +++++++++++++---- gnucash/gnome/gnc-plugin-page-register.c | 8 ++++---- .../import-export/aqb/gnc-plugin-aqbanking.c | 16 ++++++++++----- 4 files changed, 38 insertions(+), 24 deletions(-) diff --git a/gnucash/gnome-utils/gnc-main-window.cpp b/gnucash/gnome-utils/gnc-main-window.cpp index 34163a2d8c..33f9a05192 100644 --- a/gnucash/gnome-utils/gnc-main-window.cpp +++ b/gnucash/gnome-utils/gnc-main-window.cpp @@ -3601,9 +3601,9 @@ gnc_main_window_menu_find_menu_item (GncMainWindow *window, const gchar *action_ void -gnc_main_window_menu_item_vis_by_action (GncMainWindow *window, - const gchar **action_names, - gboolean vis) +gnc_main_window_set_vis_of_items_by_action (GncMainWindow *window, + const gchar **action_names, + gboolean vis) { GncMainWindowPrivate *priv; @@ -3623,9 +3623,8 @@ gnc_main_window_menu_item_vis_by_action (GncMainWindow *window, gtk_widget_set_visible (menu_item, vis); } else - { - PINFO("Did not find menu_item with action name '%s' to set vis '%s'", action_names[i], vis ? "true" : "false"); - } + PINFO("Did not find menu_item with action name '%s' to set vis '%s'", + action_names[i], vis ? "true" : "false"); if (tool_item) { @@ -3634,9 +3633,8 @@ gnc_main_window_menu_item_vis_by_action (GncMainWindow *window, gtk_widget_set_visible (tool_item, vis); } else - { - PINFO("Did not find tool_item with action name '%s' to set vis '%s'\n", action_names[i], vis ? "true" : "false"); - } + PINFO("Did not find tool_item with action name '%s' to set vis '%s'", + action_names[i], vis ? "true" : "false"); } } @@ -4115,8 +4113,8 @@ gnc_main_window_setup_window (GncMainWindow *window) always_insensitive_actions, FALSE); - gnc_main_window_menu_item_vis_by_action (window, - always_hidden_actions, false); + gnc_main_window_set_vis_of_items_by_action (window, always_hidden_actions, + false); gtk_widget_insert_action_group (GTK_WIDGET(window), "mainwin", G_ACTION_GROUP(window)); diff --git a/gnucash/gnome-utils/gnc-main-window.h b/gnucash/gnome-utils/gnc-main-window.h index 167d8f752d..5040019795 100644 --- a/gnucash/gnome-utils/gnc-main-window.h +++ b/gnucash/gnome-utils/gnc-main-window.h @@ -263,10 +263,20 @@ void gnc_main_window_merge_actions (GncMainWindow *window, void gnc_main_window_unmerge_actions (GncMainWindow *window, const gchar *group_name); - -void gnc_main_window_menu_item_vis_by_action (GncMainWindow *window, - const gchar **action_names, - gboolean vis); //FIXMEb added +/** Show or hide menu and toolbar items based on a NULL terminated + * list of action names + * + * @param window A pointer to the window whose user interface should + * be updated. + * + * @param action_names A NULL terminated list of actions names that + * should be modified. + * + * @param vis Whether to show or hide the widget items + */ +void gnc_main_window_set_vis_of_items_by_action (GncMainWindow *window, + const gchar **action_names, + gboolean vis); //FIXMEb added /** Find the menu item with the given action name for the window * specified. diff --git a/gnucash/gnome/gnc-plugin-page-register.c b/gnucash/gnome/gnc-plugin-page-register.c index 9d5813b5f2..0a2c8c41df 100644 --- a/gnucash/gnome/gnc-plugin-page-register.c +++ b/gnucash/gnome/gnc-plugin-page-register.c @@ -910,10 +910,10 @@ gnc_plugin_page_register_ui_update (gpointer various, g_simple_action_set_enabled (G_SIMPLE_ACTION(action), TRUE); /* Set the vis of the StockAssistant */ - gnc_main_window_menu_item_vis_by_action (GNC_MAIN_WINDOW(GNC_PLUGIN_PAGE(page)->window), - actions_requiring_priced_account, - account && gnc_prefs_is_extra_enabled () && - xaccAccountIsPriced (account)); + gnc_main_window_set_vis_of_items_by_action (GNC_MAIN_WINDOW(GNC_PLUGIN_PAGE(page)->window), + actions_requiring_priced_account, + account && gnc_prefs_is_extra_enabled () && + xaccAccountIsPriced (account)); } /* If we are in a readonly book, or possibly a place holder diff --git a/gnucash/import-export/aqb/gnc-plugin-aqbanking.c b/gnucash/import-export/aqb/gnc-plugin-aqbanking.c index 7469d101bd..ab48cc8625 100644 --- a/gnucash/import-export/aqb/gnc-plugin-aqbanking.c +++ b/gnucash/import-export/aqb/gnc-plugin-aqbanking.c @@ -333,17 +333,22 @@ gnc_plugin_ab_account_selected (GncPluginPage *plugin_page, Account *account, gnc_plugin_set_actions_enabled (G_ACTION_MAP(simple_action_group), need_account_actions, (account && bankcode && *bankcode && accountid && *accountid)); - gnc_main_window_menu_item_vis_by_action (window, need_account_actions, TRUE); + gnc_main_window_set_vis_of_items_by_action (window, need_account_actions, + TRUE); #if (AQBANKING_VERSION_INT < 60400) - gnc_plugin_set_actions_enabled (G_ACTION_MAP(simple_action_group), inactive_account_actions, FALSE); - gnc_main_window_menu_item_vis_by_action (window, inactive_account_actions, FALSE); + gnc_plugin_set_actions_enabled (G_ACTION_MAP(simple_action_group), + inactive_account_actions, FALSE); + gnc_main_window_set_vis_of_items_by_action (window, inactive_account_actions, + FALSE); #endif } else { - gnc_plugin_set_actions_enabled (G_ACTION_MAP(simple_action_group), need_account_actions, FALSE); - gnc_main_window_menu_item_vis_by_action (window, need_account_actions, FALSE); + gnc_plugin_set_actions_enabled (G_ACTION_MAP(simple_action_group), + need_account_actions, FALSE); + gnc_main_window_set_vis_of_items_by_action (window, need_account_actions, + FALSE); } } @@ -417,6 +422,7 @@ gnc_plugin_aqbanking_set_logwindow_visible (gboolean logwindow_visible) { GAction *action = gnc_main_window_find_action_in_group (gnc_main_window, PLUGIN_ACTIONS_NAME, MENU_TOGGLE_ACTION_AB_VIEW_LOGWINDOW); + if (action) { GVariant *state = g_action_get_state (G_ACTION(action)); From d6ae799e7442091342de43729b10f1fd5c8a3aa5 Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Mon, 31 Oct 2022 15:33:02 +0000 Subject: [PATCH 56/77] Remove a couple of unused functions --- gnucash/gnome-utils/gnc-main-window.cpp | 35 ------------------------- gnucash/gnome-utils/gnc-main-window.h | 5 ---- 2 files changed, 40 deletions(-) diff --git a/gnucash/gnome-utils/gnc-main-window.cpp b/gnucash/gnome-utils/gnc-main-window.cpp index 33f9a05192..456d9c3010 100644 --- a/gnucash/gnome-utils/gnc-main-window.cpp +++ b/gnucash/gnome-utils/gnc-main-window.cpp @@ -5551,19 +5551,6 @@ gnc_main_window_all_action_set_sensitive (const gchar *action_name, } } -GtkWidget * -gnc_main_window_get_menu (GncMainWindow *window) -{ - GncMainWindowPrivate *priv; - - g_return_val_if_fail (GNC_IS_MAIN_WINDOW(window), nullptr); - - priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); - - return priv->menubar; -} - - GMenuModel * gnc_main_window_get_menu_model (GncMainWindow *window) { @@ -5576,27 +5563,5 @@ gnc_main_window_get_menu_model (GncMainWindow *window) return priv->menubar_model; } -void -gnc_main_window_update_toolbar (GncMainWindow *window, GncPluginPage *page) -{ - GncMainWindowPrivate *priv; - GtkBuilder *builder; - - g_return_if_fail (GNC_IS_MAIN_WINDOW(window)); - g_return_if_fail (GNC_IS_PLUGIN_PAGE(page)); - - priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); - - builder = gnc_plugin_page_get_builder (page); - - if (builder) - { - gtk_container_remove (GTK_CONTAINER(priv->menu_dock), priv->toolbar); - priv->toolbar = (GtkWidget *)gtk_builder_get_object (builder, "mainwin-toolbar"); - g_object_set (priv->toolbar, "toolbar-style", GTK_TOOLBAR_BOTH, NULL); - gtk_container_add (GTK_CONTAINER(priv->menu_dock), priv->toolbar); - } -} - /** @} */ /** @} */ diff --git a/gnucash/gnome-utils/gnc-main-window.h b/gnucash/gnome-utils/gnc-main-window.h index 5040019795..784c5a3512 100644 --- a/gnucash/gnome-utils/gnc-main-window.h +++ b/gnucash/gnome-utils/gnc-main-window.h @@ -460,14 +460,9 @@ GAction *gnc_main_window_find_action (GncMainWindow *window, const gchar *name); GAction *gnc_main_window_find_action_in_group (GncMainWindow *window, const gchar *group_name, - const gchar *name); //FIXMEb added - -GtkWidget *gnc_main_window_get_menu (GncMainWindow *window); //FIXMEb added GMenuModel *gnc_main_window_get_menu_model (GncMainWindow *window); //FIXMEb added -void gnc_main_window_update_toolbar (GncMainWindow *window, GncPluginPage *page); //FIXMEb added - void gnc_main_window_update_menu (GncMainWindow *window, GncPluginPage *page, const gchar **ui_updates); //FIXMEb added From 79285097ff97cba408efe257ba1449fbeb07c8e9 Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Mon, 31 Oct 2022 15:35:59 +0000 Subject: [PATCH 57/77] Rename gnc_main_window_update_menu Rename the main windoe function gnc_main_window_update_menu to gnc_main_window_update_menu_and_toolbar as it deals with the menu and toolbar --- gnucash/gnome-utils/gnc-main-window.cpp | 14 ++++++-------- gnucash/gnome-utils/gnc-main-window.h | 14 ++++++++++++-- gnucash/gnome/gnc-plugin-page-account-tree.c | 5 +++-- gnucash/gnome/gnc-plugin-page-budget.c | 5 +++-- gnucash/gnome/gnc-plugin-page-invoice.c | 5 +++-- gnucash/gnome/gnc-plugin-page-owner-tree.c | 5 +++-- gnucash/gnome/gnc-plugin-page-register.c | 14 +++++++------- gnucash/gnome/gnc-plugin-page-report.cpp | 5 +++-- gnucash/gnome/gnc-plugin-page-sx-list.c | 5 +++-- 9 files changed, 43 insertions(+), 29 deletions(-) diff --git a/gnucash/gnome-utils/gnc-main-window.cpp b/gnucash/gnome-utils/gnc-main-window.cpp index 456d9c3010..792401f9d7 100644 --- a/gnucash/gnome-utils/gnc-main-window.cpp +++ b/gnucash/gnome-utils/gnc-main-window.cpp @@ -3704,8 +3704,9 @@ gnc_main_window_update_toolbar (GncMainWindow *window, GncPluginPage *page, void -gnc_main_window_update_menu (GncMainWindow *window, GncPluginPage *page, - const gchar **ui_updates) +gnc_main_window_update_menu_and_toolbar (GncMainWindow *window, + GncPluginPage *page, + const gchar **ui_updates) { GncMainWindowPrivate *priv; const gchar *plugin_page_actions_group_name; @@ -3715,7 +3716,6 @@ gnc_main_window_update_menu (GncMainWindow *window, GncPluginPage *page, GMenuModel *menu_model_part; GncMenuModelSearch *gsm = g_new0 (GncMenuModelSearch, 1); - g_return_if_fail (GNC_IS_MAIN_WINDOW(window)); g_return_if_fail (page != nullptr); g_return_if_fail (ui_updates != nullptr); @@ -3748,13 +3748,12 @@ gnc_main_window_update_menu (GncMainWindow *window, GncPluginPage *page, gnc_main_window_update_toolbar (window, page, menu_qualifier); - PERR("Display Item Hash size %d", g_hash_table_size (priv->display_item_hash)); //FIXMEb temp added PERR("Display Item Q %d", priv->num_item_q); //FIXMEb temp added // reset hash table and remove added menu items g_hash_table_remove_all (priv->display_item_hash); - gnc_menubar_model_remove_items_with_attrib (priv->menubar_model, + gnc_menubar_model_remove_items_with_attrib (priv->menubar_model, GNC_MENU_ATTRIBUTE_TEMPORARY); priv->num_item_q = 0; //FIXMEb temp added @@ -3776,9 +3775,8 @@ gnc_main_window_update_menu (GncMainWindow *window, GncPluginPage *page, gsm->search_action_name = ui_updates[i]; if (gnc_menubar_model_find_item (priv->menubar_model, gsm)) - { - g_menu_insert_section (G_MENU(gsm->model), gsm->index, NULL, G_MENU_MODEL(menu_model_part)); - } + g_menu_insert_section (G_MENU(gsm->model), gsm->index, + nullptr, G_MENU_MODEL(menu_model_part)); else PERR("Could not find '%s' in menu model", ui_updates[i]); diff --git a/gnucash/gnome-utils/gnc-main-window.h b/gnucash/gnome-utils/gnc-main-window.h index 784c5a3512..1a1a7ad23e 100644 --- a/gnucash/gnome-utils/gnc-main-window.h +++ b/gnucash/gnome-utils/gnc-main-window.h @@ -463,8 +463,18 @@ GAction *gnc_main_window_find_action_in_group (GncMainWindow *window, GMenuModel *gnc_main_window_get_menu_model (GncMainWindow *window); //FIXMEb added -void gnc_main_window_update_menu (GncMainWindow *window, GncPluginPage *page, - const gchar **ui_updates); //FIXMEb added +/** Update the main window menu with the placeholders listed in + * ui_updates and load the page specific toolbar. + * + * @param window The window which should be checked for the action. + * + * @param page The plugin page calling this function. + * + * @param ui_updates A NULL terminated list of placeholders to load + */ +void gnc_main_window_update_menu_and_toolbar (GncMainWindow *window, + GncPluginPage *page, + const gchar **ui_updates); //FIXMEb added /** * Shows all main windows. diff --git a/gnucash/gnome/gnc-plugin-page-account-tree.c b/gnucash/gnome/gnc-plugin-page-account-tree.c index 6295ce9beb..e3ae5ec897 100644 --- a/gnucash/gnome/gnc-plugin-page-account-tree.c +++ b/gnucash/gnome/gnc-plugin-page-account-tree.c @@ -550,8 +550,9 @@ gnc_plugin_page_account_tree_focus_widget (GncPluginPage *account_plugin_page) action = gnc_main_window_find_action (GNC_MAIN_WINDOW(account_plugin_page->window), "ScheduledAction"); g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE); - gnc_main_window_update_menu (GNC_MAIN_WINDOW(account_plugin_page->window), account_plugin_page, - gnc_plugin_load_ui_items); + gnc_main_window_update_menu_and_toolbar (GNC_MAIN_WINDOW(account_plugin_page->window), + account_plugin_page, + gnc_plugin_load_ui_items); // setup any short toolbar names gnc_main_window_init_short_names (GNC_MAIN_WINDOW(account_plugin_page->window), toolbar_labels); diff --git a/gnucash/gnome/gnc-plugin-page-budget.c b/gnucash/gnome/gnc-plugin-page-budget.c index 113c55e9f3..1996ff45b4 100644 --- a/gnucash/gnome/gnc-plugin-page-budget.c +++ b/gnucash/gnome/gnc-plugin-page-budget.c @@ -385,8 +385,9 @@ gnc_plugin_page_budget_focus_widget (GncPluginPage *budget_plugin_page) action = gnc_main_window_find_action (GNC_MAIN_WINDOW(budget_plugin_page->window), "ScheduledAction"); g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE); - gnc_main_window_update_menu (GNC_MAIN_WINDOW(budget_plugin_page->window), budget_plugin_page, - gnc_plugin_load_ui_items); + gnc_main_window_update_menu_and_toolbar (GNC_MAIN_WINDOW(budget_plugin_page->window), + budget_plugin_page, + gnc_plugin_load_ui_items); // setup any short toolbar names gnc_main_window_init_short_names (GNC_MAIN_WINDOW(budget_plugin_page->window), toolbar_labels); diff --git a/gnucash/gnome/gnc-plugin-page-invoice.c b/gnucash/gnome/gnc-plugin-page-invoice.c index 0732c71629..5a2ebc3b71 100644 --- a/gnucash/gnome/gnc-plugin-page-invoice.c +++ b/gnucash/gnome/gnc-plugin-page-invoice.c @@ -708,8 +708,9 @@ gnc_plugin_page_invoice_focus_widget (GncPluginPage *invoice_plugin_page) action = gnc_main_window_find_action (GNC_MAIN_WINDOW(invoice_plugin_page->window), "ScheduledAction"); g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE); - gnc_main_window_update_menu (GNC_MAIN_WINDOW(invoice_plugin_page->window), invoice_plugin_page, - gnc_plugin_load_ui_items); + gnc_main_window_update_menu_and_toolbar (GNC_MAIN_WINDOW(invoice_plugin_page->window), + invoice_plugin_page, + gnc_plugin_load_ui_items); gnc_plugin_page_invoice_update_menus (invoice_plugin_page, priv->is_posted, priv->can_unpost); diff --git a/gnucash/gnome/gnc-plugin-page-owner-tree.c b/gnucash/gnome/gnc-plugin-page-owner-tree.c index 779728b6f3..5ed950ab1b 100644 --- a/gnucash/gnome/gnc-plugin-page-owner-tree.c +++ b/gnucash/gnome/gnc-plugin-page-owner-tree.c @@ -325,8 +325,9 @@ gnc_plugin_page_owner_focus_widget (GncPluginPage *owner_plugin_page) set_menu_and_toolbar_qualifier (owner_plugin_page); - gnc_main_window_update_menu (GNC_MAIN_WINDOW(owner_plugin_page->window), owner_plugin_page, - gnc_plugin_load_ui_items); + gnc_main_window_update_menu_and_toolbar (GNC_MAIN_WINDOW(owner_plugin_page->window), + owner_plugin_page, + gnc_plugin_load_ui_items); // setup any short toolbar names gnc_main_window_init_short_names (GNC_MAIN_WINDOW(owner_plugin_page->window), toolbar_labels); diff --git a/gnucash/gnome/gnc-plugin-page-register.c b/gnucash/gnome/gnc-plugin-page-register.c index 0a2c8c41df..55c8f1cb2d 100644 --- a/gnucash/gnome/gnc-plugin-page-register.c +++ b/gnucash/gnome/gnc-plugin-page-register.c @@ -743,14 +743,14 @@ gnc_plugin_page_register_focus_widget (GncPluginPage* register_plugin_page) action = gnc_main_window_find_action (GNC_MAIN_WINDOW(register_plugin_page->window), "ScheduledAction"); g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE); - gnc_main_window_update_menu (GNC_MAIN_WINDOW(register_plugin_page->window), - register_plugin_page, - gnc_plugin_load_ui_items); + gnc_main_window_update_menu_and_toolbar (GNC_MAIN_WINDOW(register_plugin_page->window), + register_plugin_page, + gnc_plugin_load_ui_items); } else { GtkWidget *toolbar = gnc_window_get_toolbar (gnc_window); - GtkWidget *menubar = gnc_window_get_menubar (gnc_window); + GtkWidget *menubar = gnc_window_get_menubar (gnc_window); GMenuModel *menubar_model = gnc_window_get_menubar_model (gnc_window); GtkWidget *statusbar = gnc_window_get_statusbar (gnc_window); @@ -1066,7 +1066,7 @@ gnc_plugin_page_register_ui_update (gpointer various, found = gnc_menubar_model_update_item (gnc_window_get_menubar_model (gnc_window), *iter, _(*label_iter), _(*tooltip_iter)); - PINFO("split model_item action '%s', found is %d, iter label is '%s'", + PINFO("split model_item action '%s', found is %d, iter label is '%s'", *iter, found, _(*label_iter)); ++label_iter; @@ -1084,7 +1084,7 @@ gnc_plugin_page_register_ui_update (gpointer various, found = gnc_menubar_model_update_item (gnc_window_get_menubar_model (gnc_window), *iter, _(*label_iter), _(*tooltip_iter)); - PINFO("trans model_item action '%s', found is %d, iter label is '%s'", + PINFO("trans model_item action '%s', found is %d, iter label is '%s'", *iter, found, _(*label_iter)); ++label_iter; @@ -1093,7 +1093,7 @@ gnc_plugin_page_register_ui_update (gpointer various, } // need to add the accelerator keys, currently there are none //FIXMEb -// gnc_add_accelerator_keys_for_menu (gnc_window_get_menubar (gnc_window), +// gnc_add_accelerator_keys_for_menu (gnc_window_get_menubar (gnc_window), // gnc_plugin_page_get_accel_group (GNC_PLUGIN_PAGE(page))); } } diff --git a/gnucash/gnome/gnc-plugin-page-report.cpp b/gnucash/gnome/gnc-plugin-page-report.cpp index da1a624d2f..4ab8a8894f 100644 --- a/gnucash/gnome/gnc-plugin-page-report.cpp +++ b/gnucash/gnome/gnc-plugin-page-report.cpp @@ -308,8 +308,9 @@ gnc_plugin_page_report_focus_widget (GncPluginPage *report_plugin_page) action = gnc_main_window_find_action (GNC_MAIN_WINDOW(report_plugin_page->window), "ScheduledAction"); g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE); - gnc_main_window_update_menu (GNC_MAIN_WINDOW(report_plugin_page->window), report_plugin_page, - gnc_plugin_load_ui_items); + gnc_main_window_update_menu_and_toolbar (GNC_MAIN_WINDOW(report_plugin_page->window), + report_plugin_page, + gnc_plugin_load_ui_items); // setup any short toolbar names gnc_main_window_init_short_names (GNC_MAIN_WINDOW(report_plugin_page->window), toolbar_labels); diff --git a/gnucash/gnome/gnc-plugin-page-sx-list.c b/gnucash/gnome/gnc-plugin-page-sx-list.c index d8ebff4e97..e57df8ae09 100644 --- a/gnucash/gnome/gnc-plugin-page-sx-list.c +++ b/gnucash/gnome/gnc-plugin-page-sx-list.c @@ -184,8 +184,9 @@ gnc_plugin_page_sx_list_focus_widget (GncPluginPage *sx_plugin_page) action = gnc_main_window_find_action (GNC_MAIN_WINDOW(sx_plugin_page->window), "ScheduledAction"); g_simple_action_set_enabled (G_SIMPLE_ACTION(action), TRUE); - gnc_main_window_update_menu (GNC_MAIN_WINDOW(sx_plugin_page->window), sx_plugin_page, - gnc_plugin_load_ui_items); + gnc_main_window_update_menu_and_toolbar (GNC_MAIN_WINDOW(sx_plugin_page->window), + sx_plugin_page, + gnc_plugin_load_ui_items); if (GTK_IS_TREE_VIEW(tree_view)) { From 959c870f031a64c7457c33351fb99bc5e40ebbb7 Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Mon, 31 Oct 2022 15:38:20 +0000 Subject: [PATCH 58/77] Add some main window function descriptions --- gnucash/gnome-utils/gnc-main-window.cpp | 31 ++++++++++++--------- gnucash/gnome-utils/gnc-main-window.h | 36 +++++++++++++++++++++---- 2 files changed, 50 insertions(+), 17 deletions(-) diff --git a/gnucash/gnome-utils/gnc-main-window.cpp b/gnucash/gnome-utils/gnc-main-window.cpp index 792401f9d7..32cd252d8e 100644 --- a/gnucash/gnome-utils/gnc-main-window.cpp +++ b/gnucash/gnome-utils/gnc-main-window.cpp @@ -3516,18 +3516,18 @@ gnc_main_window_unmerge_actions (GncMainWindow *window, } GAction * -gnc_main_window_find_action (GncMainWindow *window, const gchar *name) +gnc_main_window_find_action (GncMainWindow *window, const gchar *action_name) { GncMainWindowPrivate *priv; GAction *action = nullptr; g_return_val_if_fail (GNC_IS_MAIN_WINDOW(window), nullptr); - g_return_val_if_fail (name != nullptr, nullptr); + g_return_val_if_fail (action_name != nullptr, nullptr); priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); action = g_action_map_lookup_action (G_ACTION_MAP(window), - name); + action_name); return action; } @@ -3535,17 +3535,17 @@ gnc_main_window_find_action (GncMainWindow *window, const gchar *name) GAction * gnc_main_window_find_action_in_group (GncMainWindow *window, const gchar *group_name, - const gchar *name) + const gchar *action_name) { GAction *action = nullptr; g_return_val_if_fail (GNC_IS_MAIN_WINDOW(window), nullptr); g_return_val_if_fail (group_name != nullptr, nullptr); - g_return_val_if_fail (name != nullptr, nullptr); + g_return_val_if_fail (action_name != nullptr, nullptr); auto action_group = gtk_widget_get_action_group (GTK_WIDGET(window), group_name); if (action_group) - action = g_action_map_lookup_action (G_ACTION_MAP(window), name); + action = g_action_map_lookup_action (G_ACTION_MAP(window), action_name); return action; } @@ -3585,8 +3585,15 @@ gnc_main_window_toolbar_find_tool_item (GncMainWindow *window, const gchar *acti GtkWidget * gnc_main_window_menu_find_menu_item (GncMainWindow *window, const gchar *action_name) { - GncMainWindowPrivate *priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); - GtkWidget *menu_item = GTK_WIDGET(g_hash_table_lookup (priv->display_item_hash, action_name)); + GncMainWindowPrivate *priv; + GtkWidget *menu_item; + + g_return_val_if_fail (GNC_IS_MAIN_WINDOW(window), nullptr); + g_return_val_if_fail (action_name != nullptr, nullptr); + + priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); + + menu_item = GTK_WIDGET(g_hash_table_lookup (priv->display_item_hash, action_name)); priv->num_item_q++; //FIXMEb temp added @@ -3650,8 +3657,7 @@ gnc_main_window_init_short_names (GncMainWindow *window, priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); - gnc_plugin_init_short_names (priv->toolbar, - toolbar_labels); + gnc_plugin_init_short_names (priv->toolbar, toolbar_labels); } @@ -3661,7 +3667,7 @@ gnc_main_window_update_toolbar (GncMainWindow *window, GncPluginPage *page, { GncMainWindowPrivate *priv; GtkBuilder *builder; - GAction *action = gnc_main_window_find_action (window, "ViewToolbarAction"); + GAction *action; g_return_if_fail (GNC_IS_MAIN_WINDOW(window)); g_return_if_fail (GNC_IS_PLUGIN_PAGE(page)); @@ -3690,6 +3696,8 @@ gnc_main_window_update_toolbar (GncMainWindow *window, GncPluginPage *page, g_free (toolbar_name); } + action = gnc_main_window_find_action (window, "ViewToolbarAction"); + // set visibility of toolbar if (action) { @@ -3697,7 +3705,6 @@ gnc_main_window_update_toolbar (GncMainWindow *window, GncPluginPage *page, gtk_widget_set_visible (priv->toolbar, g_variant_get_boolean (state)); g_variant_unref (state); } - // add tooltip redirect call backs gnc_plugin_add_toolbar_tooltip_callbacks (priv->toolbar, priv->statusbar); } diff --git a/gnucash/gnome-utils/gnc-main-window.h b/gnucash/gnome-utils/gnc-main-window.h index 1a1a7ad23e..6e6ad8f79d 100644 --- a/gnucash/gnome-utils/gnc-main-window.h +++ b/gnucash/gnome-utils/gnc-main-window.h @@ -209,7 +209,7 @@ main_window_update_page_set_read_only_icon (GncPluginPage *page, * should be unique among all groups added to the window, and will be * needed to remove the actions from this window. * - * @param group A pointer to the GSimpleActionGroup. + * @param group A pointer to the GSimpleActionGroup. */ void gnc_main_window_manual_merge_actions (GncMainWindow *window, const gchar *group_name, @@ -318,6 +318,14 @@ typedef struct const char *short_label; } GncToolBarShortNames; //FIXMEb added + +/** Update the labels of the toolbar items with short names. + * + * @param window The window that conatins a tool bar to update. + * + * @param toolbar_labels A pointer to a NULL terminated array of data + * GncToolBarShortNames items. + */ void gnc_main_window_init_short_names (GncMainWindow *window, GncToolBarShortNames *toolbar_labels); //FIXMEb added @@ -446,21 +454,39 @@ gboolean gnc_main_window_all_finish_pending (void); * this action. */ void gnc_main_window_all_action_set_sensitive (const gchar *action_name, gboolean sensitive); -/** Find action in main window. +/** Find the GAction in the main window. * * @param window The window which should be checked for the action. * - * @param name The name of the command to be retrieved. + * @param action_name The name of the command to be retrieved. * * @return A pointer to a GtkAction that was added with the * specified name. If the name cannot be found, then NULL will be * returned. */ -GAction *gnc_main_window_find_action (GncMainWindow *window, const gchar *name); +GAction *gnc_main_window_find_action (GncMainWindow *window, + const gchar *action_name); -GAction *gnc_main_window_find_action_in_group (GncMainWindow *window, +/** Find the GAction in a specific action group for window. + * + * @param window The window which should be checked for the action. + * + * @param group_name The name of the action group to search. + * + * @param name The name of the command to be retrieved. + * + * @return A pointer to the GAction if found or NULL will be returned. + */ +GAction *gnc_main_window_find_action_in_group (GncMainWindow *window, const gchar *group_name, + const gchar *action_name); //FIXMEb added +/** Return the GMenuModel for the main window menu bar. + * + * @param window The window for the menu bar. + * + * @return The GMenuModel or NULL. + */ GMenuModel *gnc_main_window_get_menu_model (GncMainWindow *window); //FIXMEb added /** Update the main window menu with the placeholders listed in From 1f8f1c3679b4c5db7835aa88925ecc861598815c Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Wed, 2 Nov 2022 15:01:53 +0000 Subject: [PATCH 59/77] Fix updating of the menu for the configuration items Change the updating of the main window menu items from the GtkMenu item to the GMenuModel as this will allow the tooltips to be picked up for showing in the status bar. --- gnucash/gnome-utils/gnc-main-window.cpp | 39 ++++++++++++++++++++++++ gnucash/gnome-utils/gnc-main-window.h | 28 +++++++++++++++++ gnucash/gnome-utils/gnc-plugin.h | 2 ++ gnucash/gnome/gnc-plugin-page-report.cpp | 36 +++++++++++----------- 4 files changed, 87 insertions(+), 18 deletions(-) diff --git a/gnucash/gnome-utils/gnc-main-window.cpp b/gnucash/gnome-utils/gnc-main-window.cpp index 32cd252d8e..fd3afa4823 100644 --- a/gnucash/gnome-utils/gnc-main-window.cpp +++ b/gnucash/gnome-utils/gnc-main-window.cpp @@ -3607,6 +3607,45 @@ gnc_main_window_menu_find_menu_item (GncMainWindow *window, const gchar *action_ } +void +gnc_main_window_menu_add_accelerator_keys (GncMainWindow *window) +{ + GncMainWindowPrivate *priv; + + g_return_if_fail (GNC_IS_MAIN_WINDOW(window)); + + priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); + + gnc_add_accelerator_keys_for_menu (priv->menubar, priv->accel_group); +} + + +gboolean +gnc_main_window_update_menu_for_action (GncMainWindow *window, + const gchar *action_name, + const gchar *label, + const gchar *tooltip) +{ + GncMainWindowPrivate *priv; + gboolean found = false; + + g_return_val_if_fail (GNC_IS_MAIN_WINDOW(window), false); + g_return_val_if_fail (action_name != nullptr, false); + g_return_val_if_fail (label != nullptr, false); + + priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); + + found = gnc_menubar_model_update_item (priv->menubar_model, action_name, + _(label), _(tooltip)); + + // add tooltip redirect call backs + gnc_plugin_add_menu_tooltip_callbacks (priv->menubar, + priv->menubar_model, + priv->statusbar); + + return found; +} + void gnc_main_window_set_vis_of_items_by_action (GncMainWindow *window, const gchar **action_names, diff --git a/gnucash/gnome-utils/gnc-main-window.h b/gnucash/gnome-utils/gnc-main-window.h index 6e6ad8f79d..54c9dc6735 100644 --- a/gnucash/gnome-utils/gnc-main-window.h +++ b/gnucash/gnome-utils/gnc-main-window.h @@ -304,6 +304,34 @@ GtkWidget *gnc_main_window_menu_find_menu_item (GncMainWindow *window, GtkWidget * gnc_main_window_toolbar_find_tool_item (GncMainWindow *window, const gchar *action_name); //FIXMEb added +/** Find the GMenuModel item given the action name for the window + * specified. + * + * @param window A pointer to the window whose user interface should + * be updated. + * + * @param action_name The action name of the menu item to find. + * + * @param label The new label for the menu item. + * + * @param tooltip The new tooltip for the menu item, optional. + * + * @return TRUE if menu item found and updated or FALSE. + */ +gboolean gnc_main_window_update_menu_for_action (GncMainWindow *window, + const gchar *action_name, + const gchar *label, + const gchar *tooltip); //FIXMEb added + +/** Scan the main window menu and add accelerator keys to main window + * accelerator group. + * + * @param window A pointer to the window whose user interface should + * be updated. + * + */ +void gnc_main_window_menu_add_accelerator_keys (GncMainWindow *window); //FIXMEb added + /** A structure for defining alternate action names for use in the * toolbar. All toolbar buttons are homogeneous in size and are sized * to fit the longest label. Therefore, this structure should be diff --git a/gnucash/gnome-utils/gnc-plugin.h b/gnucash/gnome-utils/gnc-plugin.h index 89c18d9c17..859aa06d3c 100644 --- a/gnucash/gnome-utils/gnc-plugin.h +++ b/gnucash/gnome-utils/gnc-plugin.h @@ -225,6 +225,8 @@ typedef struct const char *action_name; /** The alternate toolbar label to use */ const char *label; + /** The tooltip for the label */ + const char *tooltip; } action_toolbar_labels; diff --git a/gnucash/gnome/gnc-plugin-page-report.cpp b/gnucash/gnome/gnc-plugin-page-report.cpp index 4ab8a8894f..11c20d45da 100644 --- a/gnucash/gnome/gnc-plugin-page-report.cpp +++ b/gnucash/gnome/gnc-plugin-page-report.cpp @@ -61,6 +61,7 @@ extern "C" #include "gnc-html-factory.h" #include "gnc-file.h" #include "gnc-filepath-utils.h" +#include "gnc-gtk-utils.h" #include "gnc-plugin.h" #include "gnc-plugin-page-report.h" #include "gnc-plugin-file-history.h" @@ -1220,33 +1221,32 @@ gnc_plugin_page_report_constructor(GType this_type, guint n_properties, GObjectC return obj; } - - static void gnc_plugin_page_report_menu_update (GncPluginPage *plugin_page, action_toolbar_labels *tooltip_list) { - GtkWidget *menu_item; + GncMainWindow *window = GNC_MAIN_WINDOW(GNC_PLUGIN_PAGE(plugin_page)->window); GtkWidget *tool_item; -//FIXMEb this may need changing to update the menu model instead of the GtkMenuItem - for (gint i = 0; (tooltip_list[i].action_name != NULL); i++) - { - menu_item = gnc_main_window_menu_find_menu_item (GNC_MAIN_WINDOW(GNC_PLUGIN_PAGE(plugin_page)->window), - tooltip_list[i].action_name); - if (menu_item) - gtk_widget_set_tooltip_text (GTK_WIDGET(menu_item), _(tooltip_list[i].label)); - tool_item = gnc_main_window_toolbar_find_tool_item (GNC_MAIN_WINDOW(GNC_PLUGIN_PAGE(plugin_page)->window), + for (gint i = 0; (tooltip_list[i].action_name != nullptr); i++) + { + gboolean found = gnc_main_window_update_menu_for_action (window, + tooltip_list[i].action_name, + _(tooltip_list[i].label), + _(tooltip_list[i].tooltip)); + + tool_item = gnc_main_window_toolbar_find_tool_item (window, tooltip_list[i].action_name); if (tool_item) - { - gtk_widget_set_tooltip_text (GTK_WIDGET(tool_item), _(tooltip_list[i].label)); - g_object_set (G_OBJECT(tool_item), "has-tooltip", FALSE, NULL); + { // only need to update the tooltip here + gtk_widget_set_tooltip_text (GTK_WIDGET(tool_item), _(tooltip_list[i].tooltip)); + g_object_set (G_OBJECT(tool_item), "has-tooltip", false, nullptr); } } + // need to add the accelerator keys for the updated menu items + gnc_main_window_menu_add_accelerator_keys (window); } - static void gnc_plugin_page_report_menu_updates (GncPluginPage *plugin_page) { @@ -1269,9 +1269,9 @@ gnc_plugin_page_report_menu_updates (GncPluginPage *plugin_page) window = (GncMainWindow*)gnc_plugin_page_get_window (GNC_PLUGIN_PAGE(plugin_page)); - tooltip_list[0] = { "ReportSaveAction", report_save_str }; - tooltip_list[1] = { "ReportSaveAsAction", report_saveas_str }; - tooltip_list[2] = { nullptr, nullptr }; + tooltip_list[0] = { "ReportSaveAction", N_("Save _Report Configuration"), report_save_str }; + tooltip_list[1] = { "ReportSaveAsAction", N_("Save Report Configuration As..."), report_saveas_str }; + tooltip_list[2] = { nullptr, nullptr, nullptr }; gnc_plugin_page_report_menu_update (plugin_page, tooltip_list); From 37a9721bf2825e7f4d5ab0620460bf4079550250 Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Wed, 2 Nov 2022 15:06:20 +0000 Subject: [PATCH 60/77] Fix updating of the menu for invoice, bill and expense Change the updating of the main window menu items from the GtkMenu item to the GMenuModel as this will allow the tooltips to be picked up for showing in the status bar. --- gnucash/gnome/gnc-plugin-page-invoice.c | 247 ++++++++---------------- 1 file changed, 79 insertions(+), 168 deletions(-) diff --git a/gnucash/gnome/gnc-plugin-page-invoice.c b/gnucash/gnome/gnc-plugin-page-invoice.c index 5a2ebc3b71..416337d528 100644 --- a/gnucash/gnome/gnc-plugin-page-invoice.c +++ b/gnucash/gnome/gnc-plugin-page-invoice.c @@ -47,6 +47,7 @@ #include "dialog-doclink-utils.h" #include "gncInvoice.h" #include "gnc-ui.h" +#include "gnc-gtk-utils.h" /* This static indicates the debugging module that this .o belongs to. */ static QofLogModule log_module = GNC_MOD_GUI; @@ -196,158 +197,93 @@ static const gchar *can_unpost_actions[] = static action_toolbar_labels invoice_action_labels[] = { - {"FilePrintAction", N_("_Print Invoice")}, - {"EditEditInvoiceAction", N_("_Edit Invoice")}, - {"EditDuplicateInvoiceAction", N_("_Duplicate Invoice")}, - {"EditPostInvoiceAction", N_("_Post Invoice")}, - {"EditUnpostInvoiceAction", N_("_Unpost Invoice")}, - {"BusinessNewInvoiceAction", N_("New _Invoice")}, - {"ToolsProcessPaymentAction", N_("_Pay Invoice")}, - {"BusinessLinkAction", N_("_Manage Document Link...")}, - {"BusinessLinkOpenAction", N_("_Open Linked Document")}, - {NULL, NULL}, + {"FilePrintAction", N_("_Print Invoice"), N_("Make a printable invoice")}, + {"EditEditInvoiceAction", N_("_Edit Invoice"), N_("Edit this invoice")}, + {"EditDuplicateInvoiceAction", N_("_Duplicate Invoice"), N_("Create a new invoice as a duplicate of the current one")}, + {"EditPostInvoiceAction", N_("_Post Invoice"), N_("Post this invoice to your Chart of Accounts")}, + {"EditUnpostInvoiceAction", N_("_Unpost Invoice"), N_("Unpost this invoice and make it editable")}, + {"BusinessNewInvoiceAction", N_("New _Invoice"), N_("Create a new invoice for the same owner as the current one")}, + {"BlankEntryAction", N_("Blank"), N_("Move to the blank entry at the bottom of the invoice")}, + {"ToolsProcessPaymentAction", N_("_Pay Invoice"), N_("Enter a payment for the owner of this invoice") }, + {"ReportsCompanyReportAction", N_("_Company Report"), N_("Open a customer report window for the owner of this invoice") }, + {"BusinessLinkAction", N_("_Manage Document Link..."), N_("Manage Document Link")}, + {"BusinessLinkOpenAction", N_("_Open Linked Document"), N_("Open Linked Document")}, + {NULL, NULL, NULL}, }; static action_toolbar_labels invoice_action_layout_labels[] = { - {"ViewSaveLayoutAction", N_("_Use as Default Layout for Customer Documents")}, - {"ViewResetLayoutAction", N_("_Reset Default Layout for Customer Documents")}, - {NULL, NULL}, + {"ViewSaveLayoutAction", N_("_Use as Default Layout for Customer Documents"), + N_("Use the current layout as default for all customer invoices and credit notes")}, + {"ViewResetLayoutAction", N_("_Reset Default Layout for Customer Documents"), + N_("Reset default layout for all customer invoices and credit notes back to built-in defaults and update the current page accordingly")}, + {NULL, NULL, NULL}, }; static action_toolbar_labels bill_action_labels[] = { - {"FilePrintAction", N_("_Print Bill")}, - {"EditEditInvoiceAction", N_("_Edit Bill")}, - {"EditDuplicateInvoiceAction", N_("_Duplicate Bill")}, - {"EditPostInvoiceAction", N_("_Post Bill")}, - {"EditUnpostInvoiceAction", N_("_Unpost Bill")}, - {"BusinessNewInvoiceAction", N_("New _Bill")}, - {"ToolsProcessPaymentAction", N_("_Pay Bill")}, - {"BusinessLinkAction", N_("_Manage Document Link...")}, - {"BusinessLinkOpenAction", N_("_Open Linked Document")}, - {NULL, NULL}, + {"FilePrintAction", N_("_Print Bill"), N_("Make a printable bill")}, + {"EditEditInvoiceAction", N_("_Edit Bill"), N_("Edit this bill")}, + {"EditDuplicateInvoiceAction", N_("_Duplicate Bill"), N_("Create a new bill as a duplicate of the current one")}, + {"EditPostInvoiceAction", N_("_Post Bill"), N_("Post this bill to your Chart of Accounts")}, + {"EditUnpostInvoiceAction", N_("_Unpost Bill"), N_("Unpost this bill and make it editable")}, + {"BusinessNewInvoiceAction", N_("New _Bill"), N_("Create a new bill for the same owner as the current one")}, + {"BlankEntryAction", N_("Blank"), N_("Move to the blank entry at the bottom of the bill")}, + {"ToolsProcessPaymentAction", N_("_Pay Bill"), N_("Enter a payment for the owner of this bill") }, + {"ReportsCompanyReportAction", N_("_Company Report"), N_("Open a vendor report window for the owner of this bill") }, + {"BusinessLinkAction", N_("_Manage Document Link..."), N_("Manage Document Link")}, + {"BusinessLinkOpenAction", N_("_Open Linked Document"), N_("Open Linked Document")}, + {NULL, NULL, NULL}, }; static action_toolbar_labels bill_action_layout_labels[] = { - {"ViewSaveLayoutAction", N_("_Use as Default Layout for Vendor Documents")}, - {"ViewResetLayoutAction", N_("_Reset Default Layout for Vendor Documents")}, - {NULL, NULL}, + {"ViewSaveLayoutAction", N_("_Use as Default Layout for Vendor Documents"), + N_("Use the current layout as default for all vendor bills and credit notes")}, + {"ViewResetLayoutAction", N_("_Reset Default Layout for Vendor Documents"), + N_("Reset default layout for all vendor bills and credit notes back to built-in defaults and update the current page accordingly")}, + {NULL, NULL, NULL}, }; static action_toolbar_labels voucher_action_labels[] = { - {"FilePrintAction", N_("_Print Voucher")}, - {"EditEditInvoiceAction", N_("_Edit Voucher")}, - {"EditDuplicateInvoiceAction", N_("_Duplicate Voucher")}, - {"EditPostInvoiceAction", N_("_Post Voucher")}, - {"EditUnpostInvoiceAction", N_("_Unpost Voucher")}, - {"BusinessNewInvoiceAction", N_("New _Voucher")}, - {"ToolsProcessPaymentAction", N_("_Pay Voucher")}, - {"BusinessLinkAction", N_("_Manage Document Link...")}, - {"BusinessLinkOpenAction", N_("_Open Linked Document")}, - {NULL, NULL}, + {"FilePrintAction", N_("_Print Voucher"), N_("Make a printable voucher")}, + {"EditEditInvoiceAction", N_("_Edit Voucher"), N_("Edit this voucher")}, + {"EditDuplicateInvoiceAction", N_("_Duplicate Voucher"), N_("Create a new voucher as a duplicate of the current one")}, + {"EditPostInvoiceAction", N_("_Post Voucher"), N_("Post this voucher to your Chart of Accounts")}, + {"EditUnpostInvoiceAction", N_("_Unpost Voucher"), N_("Unpost this voucher and make it editable")}, + {"BusinessNewInvoiceAction", N_("New _Voucher"), N_("Create a new voucher for the same owner as the current one")}, + {"BlankEntryAction", N_("Blank"), N_("Move to the blank entry at the bottom of the voucher")}, + {"ToolsProcessPaymentAction", N_("_Pay Voucher"), N_("Enter a payment for the owner of this voucher") }, + {"ReportsCompanyReportAction", N_("_Company Report"), N_("Open a employee report window for the owner of this voucher") }, + {"BusinessLinkAction", N_("_Manage Document Link..."), N_("Manage Document Link")}, + {"BusinessLinkOpenAction", N_("_Open Linked Document"), N_("Open Linked Document")}, + {NULL, NULL, NULL}, }; static action_toolbar_labels voucher_action_layout_labels[] = { - {"ViewSaveLayoutAction", N_("_Use as Default Layout for Employee Documents")}, - {"ViewResetLayoutAction", N_("_Reset Default Layout for Employee Documents")}, - {NULL, NULL}, + {"ViewSaveLayoutAction", N_("_Use as Default Layout for Employee Documents"), + N_("Use the current layout as default for all employee vouchers and credit notes")}, + {"ViewResetLayoutAction", N_("_Reset Default Layout for Employee Documents"), + N_("Reset default layout for all employee vouchers and credit notes back to built-in defaults and update the current page accordingly")}, + {NULL, NULL, NULL}, }; static action_toolbar_labels creditnote_action_labels[] = { - {"FilePrintAction", N_("_Print Credit Note")}, - {"EditEditInvoiceAction", N_("_Edit Credit Note")}, - {"EditDuplicateInvoiceAction", N_("_Duplicate Credit Note")}, - {"EditPostInvoiceAction", N_("_Post Credit Note")}, - {"EditUnpostInvoiceAction", N_("_Unpost Credit Note")}, - {"BusinessNewInvoiceAction", N_("New _Credit Note")}, - {"ToolsProcessPaymentAction", N_("_Pay Credit Note")}, - {"BusinessLinkAction", N_("_Manage Document Link...")}, - {"BusinessLinkOpenAction", N_("_Open Linked Document")}, - {NULL, NULL}, -}; - - -static action_toolbar_labels invoice_action_tooltips[] = { - {"FilePrintAction", N_("Make a printable invoice")}, - {"EditEditInvoiceAction", N_("Edit this invoice")}, - {"EditDuplicateInvoiceAction", N_("Create a new invoice as a duplicate of the current one")}, - {"EditPostInvoiceAction", N_("Post this invoice to your Chart of Accounts")}, - {"EditUnpostInvoiceAction", N_("Unpost this invoice and make it editable")}, - {"BusinessNewInvoiceAction", N_("Create a new invoice for the same owner as the current one")}, - {"BlankEntryAction", N_("Move to the blank entry at the bottom of the invoice")}, - {"ToolsProcessPaymentAction", N_("Enter a payment for the owner of this invoice") }, - {"ReportsCompanyReportAction", N_("Open a customer report window for the owner of this invoice") }, - {"BusinessLinkAction", N_("Manage Document Link")}, - {"BusinessLinkOpenAction", N_("Open Linked Document")}, - {NULL, NULL}, -}; - -static action_toolbar_labels invoice_action_layout_tooltips[] = { - {"ViewSaveLayoutAction", N_("Use the current layout as default for all customer invoices and credit notes")}, - {"ViewResetLayoutAction", N_("Reset default layout for all customer invoices and credit notes back to built-in defaults and update the current page accordingly")}, - {NULL, NULL}, -}; - -static action_toolbar_labels bill_action_tooltips[] = { - {"FilePrintAction", N_("Make a printable bill")}, - {"EditEditInvoiceAction", N_("Edit this bill")}, - {"EditDuplicateInvoiceAction", N_("Create a new bill as a duplicate of the current one")}, - {"EditPostInvoiceAction", N_("Post this bill to your Chart of Accounts")}, - {"EditUnpostInvoiceAction", N_("Unpost this bill and make it editable")}, - {"BusinessNewInvoiceAction", N_("Create a new bill for the same owner as the current one")}, - {"BlankEntryAction", N_("Move to the blank entry at the bottom of the bill")}, - {"ToolsProcessPaymentAction", N_("Enter a payment for the owner of this bill") }, - {"ReportsCompanyReportAction", N_("Open a vendor report window for the owner of this bill") }, - {"BusinessLinkAction", N_("Manage Document Link")}, - {"BusinessLinkOpenAction", N_("Open Linked Document")}, - {NULL, NULL}, -}; - -static action_toolbar_labels bill_action_layout_tooltips[] = { - {"ViewSaveLayoutAction", N_("Use the current layout as default for all vendor bills and credit notes")}, - {"ViewResetLayoutAction", N_("Reset default layout for all vendor bills and credit notes back to built-in defaults and update the current page accordingly")}, - {NULL, NULL}, -}; - -static action_toolbar_labels voucher_action_tooltips[] = { - {"FilePrintAction", N_("Make a printable voucher")}, - {"EditEditInvoiceAction", N_("Edit this voucher")}, - {"EditDuplicateInvoiceAction", N_("Create a new voucher as a duplicate of the current one")}, - {"EditPostInvoiceAction", N_("Post this voucher to your Chart of Accounts")}, - {"EditUnpostInvoiceAction", N_("Unpost this voucher and make it editable")}, - {"BusinessNewInvoiceAction", N_("Create a new voucher for the same owner as the current one")}, - {"BlankEntryAction", N_("Move to the blank entry at the bottom of the voucher")}, - {"ToolsProcessPaymentAction", N_("Enter a payment for the owner of this voucher") }, - {"ReportsCompanyReportAction", N_("Open a employee report window for the owner of this voucher") }, - {"BusinessLinkAction", N_("Manage Document Link")}, - {"BusinessLinkOpenAction", N_("Open Linked Document")}, - {NULL, NULL}, -}; - -static action_toolbar_labels voucher_action_layout_tooltips[] = { - {"ViewSaveLayoutAction", N_("Use the current layout as default for all employee vouchers and credit notes")}, - {"ViewResetLayoutAction", N_("Reset default layout for all employee vouchers and credit notes back to built-in defaults and update the current page accordingly")}, - {NULL, NULL}, -}; - -static action_toolbar_labels creditnote_action_tooltips[] = { - {"FilePrintAction", N_("Make a printable credit note")}, - {"EditEditInvoiceAction", N_("Edit this credit note")}, - {"EditDuplicateInvoiceAction", N_("Create a new credit note as a duplicate of the current one")}, - {"EditPostInvoiceAction", N_("Post this credit note to your Chart of Accounts")}, - {"EditUnpostInvoiceAction", N_("Unpost this credit note and make it editable")}, - {"BusinessNewInvoiceAction", N_("Create a new credit note for the same owner as the current one")}, - {"BlankEntryAction", N_("Move to the blank entry at the bottom of the credit note")}, - {"ToolsProcessPaymentAction", N_("Enter a payment for the owner of this credit note") }, - {"ReportsCompanyReportAction", N_("Open a company report window for the owner of this credit note") }, - {"BusinessLinkAction", N_("Manage Document Link...")}, - {"BusinessLinkOpenAction", N_("Open Linked Document")}, - {NULL, NULL}, + {"FilePrintAction", N_("_Print Credit Note"), N_("Make a printable credit note")}, + {"EditEditInvoiceAction", N_("_Edit Credit Note"), N_("Edit this credit note")}, + {"EditDuplicateInvoiceAction", N_("_Duplicate Credit Note"), N_("Create a new credit note as a duplicate of the current one")}, + {"EditPostInvoiceAction", N_("_Post Credit Note"), N_("Post this credit note to your Chart of Accounts")}, + {"EditUnpostInvoiceAction", N_("_Unpost Credit Note"), N_("Unpost this credit note and make it editable")}, + {"BusinessNewInvoiceAction", N_("New _Credit Note"), N_("Create a new credit note for the same owner as the current one")}, + {"BlankEntryAction", N_("Blank"), N_("Move to the blank entry at the bottom of the credit note")}, + {"ToolsProcessPaymentAction", N_("_Pay Credit Note"), N_("Enter a payment for the owner of this credit note") }, + {"ReportsCompanyReportAction", N_("_Company Report"), N_("Open a company report window for the owner of this credit note") }, + {"BusinessLinkAction", N_("_Manage Document Link..."), N_("Manage Document Link...")}, + {"BusinessLinkOpenAction", N_("_Open Linked Document"), N_("Open Linked Document")}, + {NULL, NULL, NULL}, }; /** Short labels for use on the toolbar buttons. */ @@ -511,44 +447,30 @@ update_doclink_actions (GncPluginPage *plugin_page, gboolean has_uri) static void gnc_plugin_page_invoice_action_update (GncPluginPage *plugin_page, - action_toolbar_labels *action_list, - action_toolbar_labels *tooltip_list) + action_toolbar_labels *action_list) { - GtkWidget *menu_item; + GncMainWindow *window = GNC_MAIN_WINDOW(GNC_PLUGIN_PAGE(plugin_page)->window); GtkWidget *tool_item; -//FIXMEb this may need changing to update the menu model instead of the GtkMenuItem + for (gint i = 0; (action_list[i].action_name != NULL); i++) { - menu_item = gnc_main_window_menu_find_menu_item (GNC_MAIN_WINDOW(GNC_PLUGIN_PAGE(plugin_page)->window), - action_list[i].action_name); + gboolean found = gnc_main_window_update_menu_for_action (window, + action_list[i].action_name, + _(action_list[i].label), + _(action_list[i].tooltip)); - if (menu_item) - gtk_menu_item_set_label (GTK_MENU_ITEM(menu_item), _(action_list[i].label)); - - tool_item = gnc_main_window_toolbar_find_tool_item (GNC_MAIN_WINDOW(GNC_PLUGIN_PAGE(plugin_page)->window), - action_list[i].action_name); - - if (tool_item) - gtk_tool_button_set_label (GTK_TOOL_BUTTON(tool_item), _(action_list[i].label)); - } -//FIXMEb this may need changing to update the menu model instead of the GtkMenuItem - for (gint i = 0; (tooltip_list[i].action_name != NULL); i++) - { - menu_item = gnc_main_window_menu_find_menu_item (GNC_MAIN_WINDOW(GNC_PLUGIN_PAGE(plugin_page)->window), - tooltip_list[i].action_name); - - if (menu_item) - gtk_widget_set_tooltip_text (GTK_WIDGET(menu_item), _(tooltip_list[i].label)); - - tool_item = gnc_main_window_toolbar_find_tool_item (GNC_MAIN_WINDOW(GNC_PLUGIN_PAGE(plugin_page)->window), - tooltip_list[i].action_name); + tool_item = gnc_main_window_toolbar_find_tool_item (window, + action_list[i].action_name); if (tool_item) { - gtk_widget_set_tooltip_text (GTK_WIDGET(tool_item), _(tooltip_list[i].label)); + gtk_tool_button_set_label (GTK_TOOL_BUTTON(tool_item), _(action_list[i].label)); + gtk_widget_set_tooltip_text (GTK_WIDGET(tool_item), _(action_list[i].tooltip)); g_object_set (G_OBJECT(tool_item), "has-tooltip", FALSE, NULL); } } + // need to add the accelerator keys for the updated menu items + gnc_main_window_menu_add_accelerator_keys (window); } static void @@ -579,9 +501,7 @@ gnc_plugin_page_invoice_update_menus (GncPluginPage *page, gboolean is_posted, g GncInvoice *invoice; gint i, j; action_toolbar_labels *label_list; - action_toolbar_labels *tooltip_list; action_toolbar_labels *label_layout_list; - action_toolbar_labels *tooltip_layout_list; gboolean has_uri = FALSE; gboolean is_readonly = qof_book_is_readonly(gnc_get_current_book()); @@ -604,25 +524,20 @@ gnc_plugin_page_invoice_update_menus (GncPluginPage *page, gboolean is_posted, g switch (invoice_type) { case GNC_INVOICE_CUST_INVOICE: label_list = invoice_action_labels; - tooltip_list = invoice_action_tooltips; break; case GNC_INVOICE_VEND_INVOICE: label_list = bill_action_labels; - tooltip_list = bill_action_tooltips; break; case GNC_INVOICE_EMPL_INVOICE: label_list = voucher_action_labels; - tooltip_list = voucher_action_tooltips; break; case GNC_INVOICE_CUST_CREDIT_NOTE: // fallthrough case GNC_INVOICE_VEND_CREDIT_NOTE: // fallthrough case GNC_INVOICE_EMPL_CREDIT_NOTE: // fallthrough label_list = creditnote_action_labels; - tooltip_list = creditnote_action_tooltips; break; default: // catches GNC_INVOICE_UNDEFINED, use invoice by default label_list = invoice_action_labels; - tooltip_list = invoice_action_tooltips; } // layout actions @@ -630,21 +545,17 @@ gnc_plugin_page_invoice_update_menus (GncPluginPage *page, gboolean is_posted, g case GNC_INVOICE_CUST_INVOICE: case GNC_INVOICE_CUST_CREDIT_NOTE: label_layout_list = invoice_action_layout_labels; - tooltip_layout_list = invoice_action_layout_tooltips; break; case GNC_INVOICE_VEND_INVOICE: case GNC_INVOICE_VEND_CREDIT_NOTE: label_layout_list = bill_action_layout_labels; - tooltip_layout_list = bill_action_layout_tooltips; break; case GNC_INVOICE_EMPL_INVOICE: case GNC_INVOICE_EMPL_CREDIT_NOTE: label_layout_list = voucher_action_layout_labels; - tooltip_layout_list = voucher_action_layout_tooltips; break; default: // catches GNC_INVOICE_UNDEFINED, use invoice by default label_layout_list = invoice_action_layout_labels; - tooltip_layout_list = invoice_action_layout_tooltips; } if (is_readonly) @@ -669,13 +580,13 @@ gnc_plugin_page_invoice_update_menus (GncPluginPage *page, gboolean is_posted, g !is_readonly); /* update the action labels and tooltips */ - gnc_plugin_page_invoice_action_update (page, label_list, tooltip_list); + gnc_plugin_page_invoice_action_update (page, label_list); // if there is no default layout do not enable reset action gnc_plugin_page_update_reset_layout_action (page); /* update the layout action labels and tooltips */ - gnc_plugin_page_invoice_action_update (page, label_layout_list, tooltip_layout_list); + gnc_plugin_page_invoice_action_update (page, label_layout_list); // update doclink buttons invoice = gnc_invoice_window_get_invoice (priv->iw); From d3b1da6e56b41dd2bafee8bf2873c09f845f4340 Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Wed, 2 Nov 2022 15:07:53 +0000 Subject: [PATCH 61/77] Fix missing menu tooltips in the register Re-add the callbacks for the tooltip redirection when the menu items are updated. --- gnucash/gnome/gnc-plugin-page-register.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gnucash/gnome/gnc-plugin-page-register.c b/gnucash/gnome/gnc-plugin-page-register.c index 55c8f1cb2d..b9ba64f923 100644 --- a/gnucash/gnome/gnc-plugin-page-register.c +++ b/gnucash/gnome/gnc-plugin-page-register.c @@ -1091,8 +1091,12 @@ gnc_plugin_page_register_ui_update (gpointer various, ++tooltip_iter; } } + // now add the callbacks to the replaced menu items. + gnc_plugin_add_menu_tooltip_callbacks (gnc_window_get_menubar (gnc_window), + gnc_window_get_menubar_model (gnc_window), + gnc_window_get_statusbar (gnc_window)); + // need to add the accelerator keys, currently there are none -//FIXMEb // gnc_add_accelerator_keys_for_menu (gnc_window_get_menubar (gnc_window), // gnc_plugin_page_get_accel_group (GNC_PLUGIN_PAGE(page))); } From 04a56f6c281e9b8c2468fc933575217adabc2b5d Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Wed, 2 Nov 2022 15:20:32 +0000 Subject: [PATCH 62/77] Remove tracking GtkAccelGroup from plugin page as not required --- gnucash/gnome-utils/gnc-plugin-page.c | 14 -------------- gnucash/gnome-utils/gnc-plugin-page.h | 4 ---- gnucash/gnome/gnc-plugin-page-register.c | 4 ---- 3 files changed, 22 deletions(-) diff --git a/gnucash/gnome-utils/gnc-plugin-page.c b/gnucash/gnome-utils/gnc-plugin-page.c index 9c97884b84..6b967636e9 100644 --- a/gnucash/gnome-utils/gnc-plugin-page.c +++ b/gnucash/gnome-utils/gnc-plugin-page.c @@ -96,7 +96,6 @@ typedef struct _GncPluginPagePrivate GtkBuilder *builder; //FIXMEb added GSimpleActionGroup *simple_action_group; //FIXMEb added const gchar *simple_action_group_name; //FIXMEb added - GtkAccelGroup *accel_group; //FIXMEb added const gchar *menu_qualifier; //FIXMEb added GList *books; @@ -489,7 +488,6 @@ gnc_plugin_page_init (GncPluginPage *page, void *data) priv->uri = NULL; priv->page_changed_id = 0; priv->focus_source_id = 0; - priv->accel_group = NULL; priv->menu_qualifier = NULL; page->window = NULL; @@ -1139,18 +1137,6 @@ gnc_plugin_page_create_action_group (GncPluginPage *page, const gchar *group_nam return priv->simple_action_group; } -GtkAccelGroup * -gnc_plugin_page_get_accel_group (GncPluginPage *page) -{ - GncPluginPagePrivate *priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page); - - if (priv->accel_group == NULL) - priv->accel_group = gtk_accel_group_new (); - - return priv->accel_group; -} - - gboolean gnc_plugin_page_finish_pending (GncPluginPage *page) { diff --git a/gnucash/gnome-utils/gnc-plugin-page.h b/gnucash/gnome-utils/gnc-plugin-page.h index 6797f64101..f1eb32f79f 100644 --- a/gnucash/gnome-utils/gnc-plugin-page.h +++ b/gnucash/gnome-utils/gnc-plugin-page.h @@ -538,10 +538,6 @@ void gnc_plugin_page_set_menu_qualifier (GncPluginPage *page, */ GSimpleActionGroup *gnc_plugin_page_get_action_group (GncPluginPage *page); //FIXMEb added - - -GtkAccelGroup *gnc_plugin_page_get_accel_group (GncPluginPage *page); //FIXMEb added - /** Create the GSimpleActionGroup object associated with this page. * * @param page The page whose menu/toolbar action group should be diff --git a/gnucash/gnome/gnc-plugin-page-register.c b/gnucash/gnome/gnc-plugin-page-register.c index b9ba64f923..6335a5231b 100644 --- a/gnucash/gnome/gnc-plugin-page-register.c +++ b/gnucash/gnome/gnc-plugin-page-register.c @@ -1095,10 +1095,6 @@ gnc_plugin_page_register_ui_update (gpointer various, gnc_plugin_add_menu_tooltip_callbacks (gnc_window_get_menubar (gnc_window), gnc_window_get_menubar_model (gnc_window), gnc_window_get_statusbar (gnc_window)); - - // need to add the accelerator keys, currently there are none -// gnc_add_accelerator_keys_for_menu (gnc_window_get_menubar (gnc_window), -// gnc_plugin_page_get_accel_group (GNC_PLUGIN_PAGE(page))); } } From 58805c2a402a500df43a9b111ee104da69796bbb Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Wed, 2 Nov 2022 15:33:10 +0000 Subject: [PATCH 63/77] Remove actions_name from plugin page as not required. --- gnucash/gnome-utils/gnc-plugin-page.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/gnucash/gnome-utils/gnc-plugin-page.h b/gnucash/gnome-utils/gnc-plugin-page.h index f1eb32f79f..561c87eee4 100644 --- a/gnucash/gnome-utils/gnc-plugin-page.h +++ b/gnucash/gnome-utils/gnc-plugin-page.h @@ -87,11 +87,6 @@ typedef struct /** The textual name of this plugin. */ const gchar *plugin_name; - /** A name for the set of actions that will be added by this - * plugin. The actual name is irrelevant, as long as it is - * unique within GnuCash. */ - const gchar *actions_name; //FIXMEb added - /* Signals */ void (* inserted) (GncPluginPage *plugin_page); void (* removed) (GncPluginPage *plugin_page); From bf648f6ed5521ea954b85a050103ad28e36006a3 Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Fri, 4 Nov 2022 17:25:48 +0000 Subject: [PATCH 64/77] Update some function descriptions --- gnucash/gnome-utils/gnc-main-window.cpp | 4 --- gnucash/gnome-utils/gnc-main-window.h | 4 +-- gnucash/gnome-utils/gnc-plugin-page.h | 37 +++++++++++++++++++++---- 3 files changed, 33 insertions(+), 12 deletions(-) diff --git a/gnucash/gnome-utils/gnc-main-window.cpp b/gnucash/gnome-utils/gnc-main-window.cpp index fd3afa4823..85cdf43851 100644 --- a/gnucash/gnome-utils/gnc-main-window.cpp +++ b/gnucash/gnome-utils/gnc-main-window.cpp @@ -5205,10 +5205,6 @@ add_about_paths (GtkDialog *dialog) } /** Create and display the "about" dialog for gnucash. - * - * @param action The GtkAction for the "about" menu item. - * - * @param window The main window whose menu item was activated. */ static void gnc_main_window_cmd_help_about (GSimpleAction *simple, diff --git a/gnucash/gnome-utils/gnc-main-window.h b/gnucash/gnome-utils/gnc-main-window.h index 54c9dc6735..34331440f1 100644 --- a/gnucash/gnome-utils/gnc-main-window.h +++ b/gnucash/gnome-utils/gnc-main-window.h @@ -367,7 +367,7 @@ void gnc_main_window_init_short_names (GncMainWindow *window, * @param group_name The name of a set of actions. This must be a * name provided when the actions were installed. * - * @return A pointer to a GtkActionGroup that was added with the + * @return A pointer to a GSimpleActionGroup that was added with the * specified name. If the name cannot be found, then NULL will be * returned. */ @@ -488,7 +488,7 @@ void gnc_main_window_all_action_set_sensitive (const gchar *action_name, gboolea * * @param action_name The name of the command to be retrieved. * - * @return A pointer to a GtkAction that was added with the + * @return A pointer to a GAction that was added with the * specified name. If the name cannot be found, then NULL will be * returned. */ diff --git a/gnucash/gnome-utils/gnc-plugin-page.h b/gnucash/gnome-utils/gnc-plugin-page.h index 561c87eee4..1c16ee8243 100644 --- a/gnucash/gnome-utils/gnc-plugin-page.h +++ b/gnucash/gnome-utils/gnc-plugin-page.h @@ -497,7 +497,6 @@ void gnc_plugin_page_set_use_new_window (GncPluginPage *page, */ const char *gnc_plugin_page_get_ui_description (GncPluginPage *page); -const gchar *gnc_plugin_page_get_simple_action_group_name (GncPluginPage *page); //FIXMEb added /** Set an alternate UI for the specified page. This alternate ui * may only use actions specified in the source for the page. @@ -510,7 +509,7 @@ const gchar *gnc_plugin_page_get_simple_action_group_name (GncPluginPage *page); * @param ui_filename The filename (no path) of the alternate UI. */ void gnc_plugin_page_set_ui_description (GncPluginPage *page, - const char *ui_filename); + const char *ui_filename); /** Retrieve the GtkBuilder object associated with this page. @@ -520,7 +519,22 @@ void gnc_plugin_page_set_ui_description (GncPluginPage *page, * @return A pointer to the GtkBuilder object for this page. */ GtkBuilder *gnc_plugin_page_get_builder (GncPluginPage *page); //FIXMEb added + +/** Retrieve the menu qualifier for this page. + * + * @param page The page whose quailifier string should be retrieved. + * + * @return A qualifier string for this page. + */ const gchar * gnc_plugin_page_get_menu_qualifier (GncPluginPage *page); //FIXMEb added + +/** Set a qualifier string for this page. This string is used when there + * is more than one menu associated with the page. + * + * @param page The page whose qualifier string should be updated. + * + * @param menu_qualifier A string to be used as for the qualifier. + */ void gnc_plugin_page_set_menu_qualifier (GncPluginPage *page, const char *menu_qualifier); //FIXMEb added @@ -548,16 +562,27 @@ GSimpleActionGroup *gnc_plugin_page_get_action_group (GncPluginPage *page); //FI GSimpleActionGroup * gnc_plugin_page_create_action_group (GncPluginPage *page, const gchar *group_name); //FIXMEb added -/** Retrieve a GtkAction object associated with this page. +/** Retrieve the simple action group name associated with this plugin + * page. + * + * @param page The page whose simple action group should be retrieved. + * + * @return The simple action group name associated with this plugin. + */ +const gchar *gnc_plugin_page_get_simple_action_group_name (GncPluginPage *page); //FIXMEb added + + +/** Retrieve a GAction object associated with this page. * * @param page The page whose menu/toolbar action group should be * retrieved. * - * @param name The name of the GtkAction to find. + * @param action_name The name of the GAction to find. * - * @return A pointer to the retuested GtkAction object or NULL. + * @return A pointer to the requested GAction object or NULL. */ -GAction *gnc_plugin_page_get_action (GncPluginPage *page, const gchar *name); +GAction *gnc_plugin_page_get_action (GncPluginPage *page, + const gchar *action_name); /* Signals */ void gnc_plugin_page_inserted (GncPluginPage *plugin_page); From e16217a219b1f83b11dd9df240120caae4faea25 Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Fri, 4 Nov 2022 17:32:27 +0000 Subject: [PATCH 65/77] Fix the file print menu item Create a placeholder for the file print item as the label can change for different pages. Also fix the sensitivity depending on page. --- gnucash/gnome-utils/gnc-plugin-file-history.c | 4 ++-- gnucash/gnome/gnc-plugin-basic-commands.c | 4 +++- gnucash/gnome/gnc-plugin-page-account-tree.c | 1 + gnucash/gnome/gnc-plugin-page-budget.c | 5 ++++- gnucash/gnome/gnc-plugin-page-invoice.c | 1 + gnucash/gnome/gnc-plugin-page-owner-tree.c | 1 + gnucash/gnome/gnc-plugin-page-register.c | 1 + gnucash/gnome/gnc-plugin-page-report.cpp | 1 + gnucash/gnome/gnc-plugin-page-sx-list.c | 4 ++++ .../csv-exp/gnc-plugin-csv-export.c | 2 +- gnucash/ui/gnc-main-window.ui | 13 +++++------ gnucash/ui/gnc-plugin-basic-commands.ui | 22 ++++++++++++++++++- gnucash/ui/gnc-plugin-csv-export.ui | 2 +- gnucash/ui/gnc-plugin-file-history.ui | 2 +- gnucash/ui/gnc-plugin-page-account-tree.ui | 10 +++++++++ gnucash/ui/gnc-plugin-page-budget.ui | 10 +++++++++ gnucash/ui/gnc-plugin-page-invoice.ui | 10 +++++++++ gnucash/ui/gnc-plugin-page-owner-tree.ui | 10 +++++++++ gnucash/ui/gnc-plugin-page-register.ui | 9 ++++++++ gnucash/ui/gnc-plugin-page-report.ui | 14 ++++++++++-- gnucash/ui/gnc-plugin-page-sx-list.ui | 10 +++++++++ 21 files changed, 119 insertions(+), 17 deletions(-) diff --git a/gnucash/gnome-utils/gnc-plugin-file-history.c b/gnucash/gnome-utils/gnc-plugin-file-history.c index 558f5e5e5b..39d74631a0 100644 --- a/gnucash/gnome-utils/gnc-plugin-file-history.c +++ b/gnucash/gnome-utils/gnc-plugin-file-history.c @@ -100,7 +100,7 @@ static guint gnc_plugin_n_actions = G_N_ELEMENTS(gnc_plugin_actions); /** The default menu items that need to be add to the menu */ static const gchar *gnc_plugin_load_ui_items [] = { - "FilePlaceholder5", + "FilePlaceholder6", NULL, }; @@ -432,7 +432,7 @@ gnc_history_update_action (GncMainWindow *window, if (!gnc_menubar_model_find_item (gnc_main_window_get_menu_model(window), gsm)) // could not find action_name { add_item = TRUE; - gsm->search_action_name = "FilePlaceholder5"; // placeholder + gsm->search_action_name = "FilePlaceholder6"; // placeholder if (!gnc_menubar_model_find_item (gnc_main_window_get_menu_model(window), gsm)) { diff --git a/gnucash/gnome/gnc-plugin-basic-commands.c b/gnucash/gnome/gnc-plugin-basic-commands.c index c3b8749276..610bd7da60 100644 --- a/gnucash/gnome/gnc-plugin-basic-commands.c +++ b/gnucash/gnome/gnc-plugin-basic-commands.c @@ -136,7 +136,9 @@ static const gchar *gnc_plugin_load_ui_items [] = { "FilePlaceholder0", "FilePlaceholder2", - "FilePlaceholder4", + "FilePlaceholder3", + "FilePlaceholder5", + "EditPlaceholder3", "EditPlaceholder5", "ActionsPlaceholder2", "ToolsPlaceholder1", diff --git a/gnucash/gnome/gnc-plugin-page-account-tree.c b/gnucash/gnome/gnc-plugin-page-account-tree.c index e3ae5ec897..1793216f4a 100644 --- a/gnucash/gnome/gnc-plugin-page-account-tree.c +++ b/gnucash/gnome/gnc-plugin-page-account-tree.c @@ -216,6 +216,7 @@ static guint gnc_plugin_page_account_tree_n_actions = G_N_ELEMENTS(gnc_plugin_pa /** The default menu items that need to be add to the menu */ static const gchar *gnc_plugin_load_ui_items [] = { + "FilePlaceholder3", "EditPlaceholder1", "EditPlaceholder2", "EditPlaceholder3", diff --git a/gnucash/gnome/gnc-plugin-page-budget.c b/gnucash/gnome/gnc-plugin-page-budget.c index 1996ff45b4..ff754f8f47 100644 --- a/gnucash/gnome/gnc-plugin-page-budget.c +++ b/gnucash/gnome/gnc-plugin-page-budget.c @@ -127,7 +127,6 @@ static void allperiods_budget_helper (GtkTreeModel *model, GtkTreePath *path, static GActionEntry gnc_plugin_page_budget_actions [] = { - { "FakeToplevel", NULL, NULL, NULL, NULL }, { "OpenAccountAction", gnc_plugin_page_budget_cmd_open_account, NULL, NULL, NULL }, { "OpenSubaccountsAction", gnc_plugin_page_budget_cmd_open_subaccounts, NULL, NULL, NULL }, { "DeleteBudgetAction", gnc_plugin_page_budget_cmd_delete_budget, NULL, NULL, NULL }, @@ -145,6 +144,7 @@ static guint gnc_plugin_page_budget_n_actions = G_N_ELEMENTS(gnc_plugin_page_bud /** The default menu items that need to be add to the menu */ static const gchar *gnc_plugin_load_ui_items [] = { + "FilePlaceholder3", "EditPlaceholder1", "EditPlaceholder3", "EditPlaceholder5", @@ -384,6 +384,9 @@ gnc_plugin_page_budget_focus_widget (GncPluginPage *budget_plugin_page) /* Disable the Schedule menu */ action = gnc_main_window_find_action (GNC_MAIN_WINDOW(budget_plugin_page->window), "ScheduledAction"); g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE); + /* Disable the FilePrintAction */ + action = gnc_main_window_find_action (GNC_MAIN_WINDOW(budget_plugin_page->window), "FilePrintAction"); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE); gnc_main_window_update_menu_and_toolbar (GNC_MAIN_WINDOW(budget_plugin_page->window), budget_plugin_page, diff --git a/gnucash/gnome/gnc-plugin-page-invoice.c b/gnucash/gnome/gnc-plugin-page-invoice.c index 416337d528..62ee94b512 100644 --- a/gnucash/gnome/gnc-plugin-page-invoice.c +++ b/gnucash/gnome/gnc-plugin-page-invoice.c @@ -143,6 +143,7 @@ static guint gnc_plugin_page_invoice_n_actions = G_N_ELEMENTS(gnc_plugin_page_in /** The default menu items that need to be add to the menu */ static const gchar *gnc_plugin_load_ui_items [] = { + "FilePlaceholder3", "EditPlaceholder1", "EditPlaceholder3", "EditPlaceholder5", diff --git a/gnucash/gnome/gnc-plugin-page-owner-tree.c b/gnucash/gnome/gnc-plugin-page-owner-tree.c index 5ed950ab1b..fea6c5d98e 100644 --- a/gnucash/gnome/gnc-plugin-page-owner-tree.c +++ b/gnucash/gnome/gnc-plugin-page-owner-tree.c @@ -170,6 +170,7 @@ static guint gnc_plugin_page_owner_tree_n_actions = G_N_ELEMENTS(gnc_plugin_page /** The default menu items that need to be add to the menu */ static const gchar *gnc_plugin_load_ui_items [] = { + "FilePlaceholder3", "EditPlaceholder2", "EditPlaceholder3", "EditPlaceholder5", diff --git a/gnucash/gnome/gnc-plugin-page-register.c b/gnucash/gnome/gnc-plugin-page-register.c index 6335a5231b..78fd5a8a11 100644 --- a/gnucash/gnome/gnc-plugin-page-register.c +++ b/gnucash/gnome/gnc-plugin-page-register.c @@ -351,6 +351,7 @@ static guint gnc_plugin_page_register_n_actions = G_N_ELEMENTS(gnc_plugin_page_r /** The default menu items that need to be add to the menu */ static const gchar *gnc_plugin_load_ui_items [] = { + "FilePlaceholder3", "EditPlaceholder1", "EditPlaceholder2", "EditPlaceholder3", diff --git a/gnucash/gnome/gnc-plugin-page-report.cpp b/gnucash/gnome/gnc-plugin-page-report.cpp index 11c20d45da..13e5efa4c6 100644 --- a/gnucash/gnome/gnc-plugin-page-report.cpp +++ b/gnucash/gnome/gnc-plugin-page-report.cpp @@ -215,6 +215,7 @@ static const gchar *gnc_plugin_load_ui_items [] = { "FilePlaceholder3", "FilePlaceholder4", + "FilePlaceholder5", "EditPlaceholder6", "ReportsPlaceholder1", NULL, diff --git a/gnucash/gnome/gnc-plugin-page-sx-list.c b/gnucash/gnome/gnc-plugin-page-sx-list.c index e57df8ae09..d80b87cb3e 100644 --- a/gnucash/gnome/gnc-plugin-page-sx-list.c +++ b/gnucash/gnome/gnc-plugin-page-sx-list.c @@ -142,6 +142,7 @@ static guint gnc_plugin_page_sx_list_n_actions = G_N_ELEMENTS(gnc_plugin_page_sx /** The default menu items that need to be add to the menu */ static const gchar *gnc_plugin_load_ui_items [] = { + "FilePlaceholder3", "EditPlaceholder3", "EditPlaceholder5", "ViewPlaceholder4", @@ -183,6 +184,9 @@ gnc_plugin_page_sx_list_focus_widget (GncPluginPage *sx_plugin_page) /* Enable the Schedule Menu */ action = gnc_main_window_find_action (GNC_MAIN_WINDOW(sx_plugin_page->window), "ScheduledAction"); g_simple_action_set_enabled (G_SIMPLE_ACTION(action), TRUE); + /* Disable the FilePrintAction */ + action = gnc_main_window_find_action (GNC_MAIN_WINDOW(sx_plugin_page->window), "FilePrintAction"); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE); gnc_main_window_update_menu_and_toolbar (GNC_MAIN_WINDOW(sx_plugin_page->window), sx_plugin_page, diff --git a/gnucash/import-export/csv-exp/gnc-plugin-csv-export.c b/gnucash/import-export/csv-exp/gnc-plugin-csv-export.c index 37e83566f8..0e41ba7b69 100644 --- a/gnucash/import-export/csv-exp/gnc-plugin-csv-export.c +++ b/gnucash/import-export/csv-exp/gnc-plugin-csv-export.c @@ -57,7 +57,7 @@ static guint gnc_plugin_n_actions = G_N_ELEMENTS(gnc_plugin_actions); /** The default menu items that need to be add to the menu */ static const gchar *gnc_plugin_load_ui_items [] = { - "FilePlaceholder4", + "FilePlaceholder5", NULL, }; diff --git a/gnucash/ui/gnc-main-window.ui b/gnucash/ui/gnc-main-window.ui index a9bbf7487c..13f5a04145 100644 --- a/gnucash/ui/gnc-main-window.ui +++ b/gnucash/ui/gnc-main-window.ui @@ -32,10 +32,9 @@
- _Print - mainwin.FilePrintAction - <Primary>p - Print the currently active page + PrintPlaceholder + mainwin.FilePlaceholder3 + action-disabled Pa_ge Setup... @@ -45,7 +44,7 @@ PdfPlaceholder - mainwin.FilePlaceholder3 + mainwin.FilePlaceholder4 action-disabled @@ -53,7 +52,7 @@ mainwin.FileExportAction ExportPlaceholder - mainwin.FilePlaceholder4 + mainwin.FilePlaceholder5 action-disabled @@ -69,7 +68,7 @@
RecentPlaceholder - mainwin.FilePlaceholder5 + mainwin.FilePlaceholder6 action-disabled
diff --git a/gnucash/ui/gnc-plugin-basic-commands.ui b/gnucash/ui/gnc-plugin-basic-commands.ui index ad4648893a..250957fd2d 100644 --- a/gnucash/ui/gnc-plugin-basic-commands.ui +++ b/gnucash/ui/gnc-plugin-basic-commands.ui @@ -36,7 +36,17 @@
- + + + _Print + mainwin.FilePrintAction + <Primary>p + Print the currently active page + yes + + + + Export _Accounts gnc-plugin-basic-commands-actions.FileExportAccountsAction @@ -44,6 +54,16 @@ + + + _Find... + gnc-plugin-basic-commands-actions.EditFindTransactionsAction + <Primary>f + Find transactions with a search + yes + + + diff --git a/gnucash/ui/gnc-plugin-csv-export.ui b/gnucash/ui/gnc-plugin-csv-export.ui index c827d3c760..cf0d102c31 100644 --- a/gnucash/ui/gnc-plugin-csv-export.ui +++ b/gnucash/ui/gnc-plugin-csv-export.ui @@ -1,7 +1,7 @@ - + Export Account T_ree to CSV... gnc-plugin-csv-export-actions.CsvExportTreeAction diff --git a/gnucash/ui/gnc-plugin-file-history.ui b/gnucash/ui/gnc-plugin-file-history.ui index c944bd6a04..14b9293743 100644 --- a/gnucash/ui/gnc-plugin-file-history.ui +++ b/gnucash/ui/gnc-plugin-file-history.ui @@ -1,7 +1,7 @@ - + RecentFile0Action gnc-plugin-file-history-actions.RecentFile0Action diff --git a/gnucash/ui/gnc-plugin-page-account-tree.ui b/gnucash/ui/gnc-plugin-page-account-tree.ui index b449ce79d8..aea226eec3 100644 --- a/gnucash/ui/gnc-plugin-page-account-tree.ui +++ b/gnucash/ui/gnc-plugin-page-account-tree.ui @@ -1,6 +1,16 @@ + + + _Print + mainwin.FilePrintAction + <Primary>p + Print the currently active page + yes + + + _Edit Account diff --git a/gnucash/ui/gnc-plugin-page-budget.ui b/gnucash/ui/gnc-plugin-page-budget.ui index a187e2f2d6..b2b14db74f 100644 --- a/gnucash/ui/gnc-plugin-page-budget.ui +++ b/gnucash/ui/gnc-plugin-page-budget.ui @@ -1,6 +1,16 @@ + + + _Print + mainwin.FilePrintAction + <Primary>p + Print the currently active page + yes + + + Esti_mate Budget... diff --git a/gnucash/ui/gnc-plugin-page-invoice.ui b/gnucash/ui/gnc-plugin-page-invoice.ui index 5048d76efd..3baed0ee8e 100644 --- a/gnucash/ui/gnc-plugin-page-invoice.ui +++ b/gnucash/ui/gnc-plugin-page-invoice.ui @@ -1,6 +1,16 @@ + + + _Print + GncPluginPageInvoiceActions.FilePrintAction + <Primary>p + Print the currently active page + yes + + + EditEditInvoiceAction diff --git a/gnucash/ui/gnc-plugin-page-owner-tree.ui b/gnucash/ui/gnc-plugin-page-owner-tree.ui index 743f94055d..b57a0445e2 100644 --- a/gnucash/ui/gnc-plugin-page-owner-tree.ui +++ b/gnucash/ui/gnc-plugin-page-owner-tree.ui @@ -1,6 +1,16 @@ + + + _Print + mainwin.FilePrintAction + <Primary>p + Print the currently active page + yes + + + E_dit Customer diff --git a/gnucash/ui/gnc-plugin-page-register.ui b/gnucash/ui/gnc-plugin-page-register.ui index 045acde234..5550cd5bc7 100644 --- a/gnucash/ui/gnc-plugin-page-register.ui +++ b/gnucash/ui/gnc-plugin-page-register.ui @@ -1,6 +1,15 @@ + + + _Print Cheques + GncPluginPageRegisterActions.FilePrintAction + <Primary>p + yes + + + Assign as payment... diff --git a/gnucash/ui/gnc-plugin-page-report.ui b/gnucash/ui/gnc-plugin-page-report.ui index 6cf2bb68ca..742d944d85 100644 --- a/gnucash/ui/gnc-plugin-page-report.ui +++ b/gnucash/ui/gnc-plugin-page-report.ui @@ -1,6 +1,16 @@ + + + _Print Report + GncPluginPageReportActions.FilePrintAction + <Primary>p + Print the current report + yes + + + _Report Options @@ -10,7 +20,7 @@ - + Export as P_DF... GncPluginPageReportActions.FilePrintPDFAction @@ -19,7 +29,7 @@ - + Export _Report GncPluginPageReportActions.ReportExportAction diff --git a/gnucash/ui/gnc-plugin-page-sx-list.ui b/gnucash/ui/gnc-plugin-page-sx-list.ui index 5ff5a5a912..1ce4863f1d 100644 --- a/gnucash/ui/gnc-plugin-page-sx-list.ui +++ b/gnucash/ui/gnc-plugin-page-sx-list.ui @@ -1,6 +1,16 @@ + + + _Print + mainwin.FilePrintAction + <Primary>p + Print the currently active page + yes + + + _Find... From 7cc870aac0e2db411aebe9937712941516aea340 Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Sat, 5 Nov 2022 16:03:36 +0000 Subject: [PATCH 66/77] Remove some unused variables --- gnucash/gnome-utils/gnc-plugin-page.c | 2 -- gnucash/gnome-utils/gnc-plugin.c | 1 - 2 files changed, 3 deletions(-) diff --git a/gnucash/gnome-utils/gnc-plugin-page.c b/gnucash/gnome-utils/gnc-plugin-page.c index 6b967636e9..55cdc1c5dd 100644 --- a/gnucash/gnome-utils/gnc-plugin-page.c +++ b/gnucash/gnome-utils/gnc-plugin-page.c @@ -80,8 +80,6 @@ enum PROP_STATUSBAR_TEXT, PROP_USE_NEW_WINDOW, PROP_UI_DESCRIPTION, - PROP_UI_MERGE, - PROP_ACTION_GROUP, }; static guint signals[LAST_SIGNAL] = { 0 }; diff --git a/gnucash/gnome-utils/gnc-plugin.c b/gnucash/gnome-utils/gnc-plugin.c index f4c3217a01..6f77b2e886 100644 --- a/gnucash/gnome-utils/gnc-plugin.c +++ b/gnucash/gnome-utils/gnc-plugin.c @@ -131,7 +131,6 @@ gnc_plugin_add_to_window (GncPlugin *plugin, GQuark type) { GncPluginClass *klass; - GSimpleActionGroup *simple_action_group; g_return_if_fail (GNC_IS_PLUGIN (plugin)); klass = GNC_PLUGIN_GET_CLASS (plugin); From 007f5fbcdd5a1e7eebb5ff2cfda8bc5181112fa2 Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Sat, 5 Nov 2022 16:07:09 +0000 Subject: [PATCH 67/77] Add a couple of descriptions to plugin functions Add a couple of descriptions to plugin functions and also change to use container for each for tool bar tooltip add callbacks function. --- gnucash/gnome-utils/gnc-plugin.c | 29 ++++++++++++++++++----------- gnucash/gnome-utils/gnc-plugin.h | 16 ++++++++++++++++ 2 files changed, 34 insertions(+), 11 deletions(-) diff --git a/gnucash/gnome-utils/gnc-plugin.c b/gnucash/gnome-utils/gnc-plugin.c index 6f77b2e886..0f8a742284 100644 --- a/gnucash/gnome-utils/gnc-plugin.c +++ b/gnucash/gnome-utils/gnc-plugin.c @@ -265,34 +265,41 @@ gnc_plugin_add_menu_tooltip_callbacks (GtkWidget *menubar, GMenuModel *menubar_model, GtkWidget *statusbar) { - GList *menu_item_list = gnc_menu_get_items (menubar); + GList *menu_item_list; + + g_return_if_fail (GTK_IS_MENU_BAR(menubar)); + g_return_if_fail (G_IS_MENU_MODEL(menubar_model)); + g_return_if_fail (GTK_IS_STATUSBAR(statusbar)); + + menu_item_list = gnc_menu_get_items (menubar); for (GList *node = menu_item_list; node; node = node->next) { GtkWidget *menu_item = node->data; gnc_menu_item_setup_tooltip_to_statusbar_callback (menu_item, statusbar); - g_object_set_data (G_OBJECT(statusbar), "menu-model", menubar_model); } + g_object_set_data (G_OBJECT(statusbar), "menu-model", menubar_model); g_list_free (menu_item_list); } +static void +for_each_tool_action (GtkWidget *widget, gpointer user_data) +{ + GtkWidget *statusbar = user_data; + + if (GTK_IS_ACTIONABLE(widget)) + gnc_tool_item_setup_tooltip_to_statusbar_callback (widget, statusbar); +} + void gnc_plugin_add_toolbar_tooltip_callbacks (GtkWidget *toolbar, GtkWidget *statusbar) { g_return_if_fail (GTK_IS_TOOLBAR(toolbar)); g_return_if_fail (GTK_IS_STATUSBAR(statusbar)); - for (gint i = 0; i < gtk_toolbar_get_n_items (GTK_TOOLBAR(toolbar)); i++) - { - GtkToolItem *item = gtk_toolbar_get_nth_item (GTK_TOOLBAR(toolbar), i); - - if (GTK_IS_ACTIONABLE(item)) - gnc_tool_item_setup_tooltip_to_statusbar_callback (GTK_WIDGET(item), statusbar); - } + gtk_container_foreach (GTK_CONTAINER(toolbar), for_each_tool_action, statusbar); } - - /** @} */ /** @} */ diff --git a/gnucash/gnome-utils/gnc-plugin.h b/gnucash/gnome-utils/gnc-plugin.h index 859aa06d3c..faa7585d0d 100644 --- a/gnucash/gnome-utils/gnc-plugin.h +++ b/gnucash/gnome-utils/gnc-plugin.h @@ -264,10 +264,26 @@ void gnc_plugin_set_actions_enabled (GActionMap *action_map, const gchar **action_names, gboolean enable); //FIXMEb added +/** This function adds the tooltip callbacks to make the tooltips + * appear in the status bar. + * + * @param menubar The main window menu bar widget. + * + * @param menubar_model The GMenuModel used to create the menubar. + * + * @param statusbar The status bar widget in the main window. + */ void gnc_plugin_add_menu_tooltip_callbacks (GtkWidget *menubar, GMenuModel *menubar_model, GtkWidget *statusbar); //FIXMEb added +/** This function adds the tooltip callbacks to make the tooltips + * appear in the status bar. + * + * @param toolbar The main window tool bar widget. + * + * @param statusbar The status bar widget in the main window. + */ void gnc_plugin_add_toolbar_tooltip_callbacks (GtkWidget *toolbar, GtkWidget *statusbar); //FIXMEb added From 4fd868f89eaa2f217c2f0dcfcb5fa17051bce5be Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Sat, 5 Nov 2022 16:39:15 +0000 Subject: [PATCH 68/77] Add a couple of changes dealing with GtKBuilder object --- gnucash/gnome-utils/gnc-embedded-window.c | 2 ++ gnucash/gnome-utils/gnc-main-window.cpp | 7 +++---- gnucash/gnome-utils/gnc-plugin-page.c | 8 ++++---- gnucash/gnome-utils/gnc-plugin-page.h | 5 +---- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/gnucash/gnome-utils/gnc-embedded-window.c b/gnucash/gnome-utils/gnc-embedded-window.c index 3e0e21c5f4..7ff112bb43 100644 --- a/gnucash/gnome-utils/gnc-embedded-window.c +++ b/gnucash/gnome-utils/gnc-embedded-window.c @@ -365,6 +365,8 @@ gnc_embedded_window_new (const gchar *action_group_name, gtk_container_add (GTK_CONTAINER(priv->menu_dock), GTK_WIDGET(priv->toolbar)); //FIXMEb this may need changing gtk_widget_show (GTK_WIDGET(priv->toolbar)); + g_object_unref (builder); + priv->simple_action_group = g_simple_action_group_new (); g_action_map_add_action_entries (G_ACTION_MAP(priv->simple_action_group), diff --git a/gnucash/gnome-utils/gnc-main-window.cpp b/gnucash/gnome-utils/gnc-main-window.cpp index 85cdf43851..0695f5f416 100644 --- a/gnucash/gnome-utils/gnc-main-window.cpp +++ b/gnucash/gnome-utils/gnc-main-window.cpp @@ -4150,6 +4150,8 @@ gnc_main_window_setup_window (GncMainWindow *window) gtk_container_add (GTK_CONTAINER(priv->menu_dock), GTK_WIDGET(priv->toolbar)); //FIXMEb this may need changing gtk_widget_show (GTK_WIDGET(priv->toolbar)); + g_object_unref (builder); + gnc_plugin_set_actions_enabled (G_ACTION_MAP(window), initially_insensitive_actions, FALSE); @@ -4375,7 +4377,7 @@ gnc_main_window_switch_page (GtkNotebook *notebook, if (page != nullptr) { /* Update the user interface (e.g. menus and toolbars */ - gnc_plugin_page_merge_actions (page, GTK_WIDGET(window)); + gnc_plugin_page_merge_actions (page); visible = gnc_main_window_show_summarybar (window, nullptr); gnc_plugin_page_show_summarybar (page, visible); @@ -5502,7 +5504,6 @@ do_popup_menu (GncPluginPage *page, GdkEventButton *event) LEAVE("no builder"); return; } - gtk_builder_set_translation_domain (builder, PROJECT_NAME); if (menu_qualifier) popup_menu_name = g_strconcat ("mainwin-popup-", menu_qualifier, NULL); @@ -5516,8 +5517,6 @@ do_popup_menu (GncPluginPage *page, GdkEventButton *event) menu = gtk_menu_new_from_model (menu_model); -//FIXMEb maybe i should save these once built to reuse - if (!menu) { LEAVE("no menu"); diff --git a/gnucash/gnome-utils/gnc-plugin-page.c b/gnucash/gnome-utils/gnc-plugin-page.c index 55cdc1c5dd..da709f2f3a 100644 --- a/gnucash/gnome-utils/gnc-plugin-page.c +++ b/gnucash/gnome-utils/gnc-plugin-page.c @@ -253,8 +253,7 @@ gnc_plugin_page_recreate_page(GtkWidget *window, void -gnc_plugin_page_merge_actions (GncPluginPage *page, - GtkWidget *window) +gnc_plugin_page_merge_actions (GncPluginPage *page) { GncPluginPagePrivate *priv; GError *error = NULL; @@ -264,7 +263,8 @@ gnc_plugin_page_merge_actions (GncPluginPage *page, priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page); - priv->builder = gtk_builder_new (); + if (!priv->builder) + priv->builder = gtk_builder_new (); resource = g_strconcat ("/org/gnucash/ui/", priv->ui_description, NULL); @@ -1128,7 +1128,7 @@ GSimpleActionGroup * gnc_plugin_page_create_action_group (GncPluginPage *page, const gchar *group_name) { GncPluginPagePrivate *priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page); - + priv->simple_action_group = g_simple_action_group_new (); priv->simple_action_group_name = group_name; diff --git a/gnucash/gnome-utils/gnc-plugin-page.h b/gnucash/gnome-utils/gnc-plugin-page.h index 1c16ee8243..0aab763ae2 100644 --- a/gnucash/gnome-utils/gnc-plugin-page.h +++ b/gnucash/gnome-utils/gnc-plugin-page.h @@ -284,11 +284,8 @@ GncPluginPage *gnc_plugin_page_recreate_page (GtkWidget *window, * * @param plugin_page A pointer to the page whose actions should be * added to the user interface. - * - * @param merge A pointer to the window. */ -void gnc_plugin_page_merge_actions (GncPluginPage *plugin_page, - GtkWidget *window); //FIXMEb added +void gnc_plugin_page_merge_actions (GncPluginPage *plugin_page); //FIXMEb added /** Retrieve the textual name of a plugin. From 4fc12837c107b34c03dcfcf3698e72925ad3d2a8 Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Sat, 5 Nov 2022 16:40:28 +0000 Subject: [PATCH 69/77] Remove all references to 'page-uri' for plugin pages Do not think it is required. --- gnucash/gnome-utils/gnc-plugin-page.c | 49 -------------------- gnucash/gnome-utils/gnc-plugin-page.h | 19 -------- gnucash/gnome/gnc-plugin-page-account-tree.c | 1 - gnucash/gnome/gnc-plugin-page-budget.c | 1 - gnucash/gnome/gnc-plugin-page-invoice.c | 2 - gnucash/gnome/gnc-plugin-page-owner-tree.c | 1 - gnucash/gnome/gnc-plugin-page-register.c | 1 - gnucash/gnome/gnc-plugin-page-report.cpp | 1 - gnucash/gnome/gnc-plugin-page-sx-list.c | 1 - 9 files changed, 76 deletions(-) diff --git a/gnucash/gnome-utils/gnc-plugin-page.c b/gnucash/gnome-utils/gnc-plugin-page.c index da709f2f3a..08c6a1021b 100644 --- a/gnucash/gnome-utils/gnc-plugin-page.c +++ b/gnucash/gnome-utils/gnc-plugin-page.c @@ -75,7 +75,6 @@ enum PROP_0, PROP_PAGE_NAME, PROP_PAGE_COLOR, - PROP_PAGE_URI, PROP_BOOK, PROP_STATUSBAR_TEXT, PROP_USE_NEW_WINDOW, @@ -388,15 +387,6 @@ gnc_plugin_page_class_init (GncPluginPageClass *klass) NULL, G_PARAM_READWRITE)); - g_object_class_install_property - (gobject_class, - PROP_PAGE_URI, - g_param_spec_string ("page-uri", - "Page URI", - "The uri for this page.", - NULL, - G_PARAM_READWRITE)); - g_object_class_install_property (gobject_class, PROP_STATUSBAR_TEXT, @@ -483,7 +473,6 @@ gnc_plugin_page_init (GncPluginPage *page, void *data) priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page); priv->page_name = NULL; priv->page_color = NULL; - priv->uri = NULL; priv->page_changed_id = 0; priv->focus_source_id = 0; priv->menu_qualifier = NULL; @@ -525,9 +514,6 @@ gnc_plugin_page_finalize (GObject *object) if (priv->page_color) g_free (priv->page_color); - if (priv->uri) - g_free (priv->uri); - if (priv->statusbar_text) g_free (priv->statusbar_text); @@ -591,9 +577,6 @@ gnc_plugin_page_get_property (GObject *object, case PROP_PAGE_COLOR: g_value_set_string (value, priv->page_color); break; - case PROP_PAGE_URI: - g_value_set_string (value, priv->uri); - break; case PROP_STATUSBAR_TEXT: g_value_set_string (value, priv->statusbar_text); break; @@ -646,9 +629,6 @@ gnc_plugin_page_set_property (GObject *object, case PROP_PAGE_COLOR: gnc_plugin_page_set_page_color (page, g_value_get_string (value)); break; - case PROP_PAGE_URI: - gnc_plugin_page_set_uri (page, g_value_get_string (value)); - break; case PROP_STATUSBAR_TEXT: gnc_plugin_page_set_statusbar_text (page, g_value_get_string (value)); break; @@ -933,35 +913,6 @@ gnc_plugin_page_disconnect_page_changed (GncPluginPage *page) } -/* Retrieve the Uniform Resource Identifier for this page. */ -const gchar * -gnc_plugin_page_get_uri (GncPluginPage *page) -{ - GncPluginPagePrivate *priv; - - g_return_val_if_fail (GNC_IS_PLUGIN_PAGE(page), NULL); - - priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page); - return priv->uri; -} - - -/* Set the Uniform Resource Identifier for this page. */ -void -gnc_plugin_page_set_uri (GncPluginPage *page, const gchar *name) -{ - GncPluginPagePrivate *priv; - - g_return_if_fail (GNC_IS_PLUGIN_PAGE(page)); - - priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page); - if (priv->uri) - g_free (priv->uri); - - priv->uri = g_strdup (name); -} - - /* Retrieve the statusbar text associated with this page. */ const gchar * gnc_plugin_page_get_statusbar_text (GncPluginPage *page) diff --git a/gnucash/gnome-utils/gnc-plugin-page.h b/gnucash/gnome-utils/gnc-plugin-page.h index 0aab763ae2..757d2b23e9 100644 --- a/gnucash/gnome-utils/gnc-plugin-page.h +++ b/gnucash/gnome-utils/gnc-plugin-page.h @@ -424,25 +424,6 @@ void gnc_plugin_page_inserted_cb (GncPluginPage *page, gpointer user_data); void gnc_plugin_page_disconnect_page_changed (GncPluginPage *page); -/** Retrieve the Uniform Resource Identifier for this page. - * - * @param page The page whose URI should be retrieved. - * - * @return The URI for this page. This string is owned by the page and - * should not be freed by the caller. - */ -const gchar *gnc_plugin_page_get_uri (GncPluginPage *page); - - -/** Set the Uniform Resource Identifier for this page. - * - * @param page The page whose URI should be set. - * - * @param name The new URI for the page. - */ -void gnc_plugin_page_set_uri (GncPluginPage *page, const char *name); - - /** Retrieve the statusbar text associated with this page. * * @param page The page whose statusbar should text be retrieved. diff --git a/gnucash/gnome/gnc-plugin-page-account-tree.c b/gnucash/gnome/gnc-plugin-page-account-tree.c index 1793216f4a..e5b1e9f127 100644 --- a/gnucash/gnome/gnc-plugin-page-account-tree.c +++ b/gnucash/gnome/gnc-plugin-page-account-tree.c @@ -402,7 +402,6 @@ gnc_plugin_page_account_tree_init (GncPluginPageAccountTree *plugin_page) parent = GNC_PLUGIN_PAGE(plugin_page); g_object_set (G_OBJECT(plugin_page), "page-name", _("Accounts"), - "page-uri", "default:", "ui-description", "gnc-plugin-page-account-tree.ui", NULL); g_signal_connect (G_OBJECT (plugin_page), "selected", diff --git a/gnucash/gnome/gnc-plugin-page-budget.c b/gnucash/gnome/gnc-plugin-page-budget.c index ff754f8f47..b9c4ee22d8 100644 --- a/gnucash/gnome/gnc-plugin-page-budget.c +++ b/gnucash/gnome/gnc-plugin-page-budget.c @@ -308,7 +308,6 @@ gnc_plugin_page_budget_init (GncPluginPageBudget *plugin_page) parent = GNC_PLUGIN_PAGE(plugin_page); g_object_set (G_OBJECT(plugin_page), "page-name", _("Budget"), - "page-uri", "default:", "ui-description", "gnc-plugin-page-budget.ui", NULL); diff --git a/gnucash/gnome/gnc-plugin-page-invoice.c b/gnucash/gnome/gnc-plugin-page-invoice.c index 62ee94b512..8721d81a0f 100644 --- a/gnucash/gnome/gnc-plugin-page-invoice.c +++ b/gnucash/gnome/gnc-plugin-page-invoice.c @@ -374,7 +374,6 @@ gnc_plugin_page_invoice_new (InvoiceWindow *iw) plugin_page = GNC_PLUGIN_PAGE(invoice_page); gnc_plugin_page_invoice_update_title(plugin_page); - gnc_plugin_page_set_uri(plugin_page, "default:"); priv->component_manager_id = 0; return plugin_page; @@ -412,7 +411,6 @@ gnc_plugin_page_invoice_init (GncPluginPageInvoice *plugin_page) use_new = gnc_prefs_get_bool (GNC_PREFS_GROUP_INVOICE, GNC_PREF_USE_NEW); g_object_set(G_OBJECT(plugin_page), "page-name", _("Invoice"), - "page-uri", "default:", "ui-description", "gnc-plugin-page-invoice.ui", "use-new-window", use_new, (char *)NULL); diff --git a/gnucash/gnome/gnc-plugin-page-owner-tree.c b/gnucash/gnome/gnc-plugin-page-owner-tree.c index fea6c5d98e..a08a57ed01 100644 --- a/gnucash/gnome/gnc-plugin-page-owner-tree.c +++ b/gnucash/gnome/gnc-plugin-page-owner-tree.c @@ -385,7 +385,6 @@ gnc_plugin_page_owner_tree_init (GncPluginPageOwnerTree *plugin_page) parent = GNC_PLUGIN_PAGE(plugin_page); g_object_set(G_OBJECT(plugin_page), "page-name", _("Owners"), - "page-uri", "default:", "ui-description", "gnc-plugin-page-owner-tree.ui", NULL); g_signal_connect (G_OBJECT (plugin_page), "selected", diff --git a/gnucash/gnome/gnc-plugin-page-register.c b/gnucash/gnome/gnc-plugin-page-register.c index 78fd5a8a11..f289204235 100644 --- a/gnucash/gnome/gnc-plugin-page-register.c +++ b/gnucash/gnome/gnc-plugin-page-register.c @@ -664,7 +664,6 @@ gnc_plugin_page_register_init (GncPluginPageRegister* plugin_page) GNC_PREF_USE_NEW); g_object_set (G_OBJECT (plugin_page), "page-name", _ ("General Journal"), - "page-uri", "default:", "ui-description", "gnc-plugin-page-register.ui", "use-new-window", use_new, NULL); diff --git a/gnucash/gnome/gnc-plugin-page-report.cpp b/gnucash/gnome/gnc-plugin-page-report.cpp index 13e5efa4c6..f6f12f1470 100644 --- a/gnucash/gnome/gnc-plugin-page-report.cpp +++ b/gnucash/gnome/gnc-plugin-page-report.cpp @@ -1312,7 +1312,6 @@ gnc_plugin_page_report_constr_init (GncPluginPageReport *plugin_page, gint repor name = gnc_report_name (priv->initial_report); g_object_set (G_OBJECT(plugin_page), "page-name", name, - "page-uri", "default:", "ui-description", "gnc-plugin-page-report.ui", "use-new-window", use_new, nullptr); diff --git a/gnucash/gnome/gnc-plugin-page-sx-list.c b/gnucash/gnome/gnc-plugin-page-sx-list.c index d80b87cb3e..59dcff1120 100644 --- a/gnucash/gnome/gnc-plugin-page-sx-list.c +++ b/gnucash/gnome/gnc-plugin-page-sx-list.c @@ -232,7 +232,6 @@ gnc_plugin_page_sx_list_init (GncPluginPageSxList *plugin_page) parent = GNC_PLUGIN_PAGE(plugin_page); g_object_set(G_OBJECT(plugin_page), "page-name", _("Scheduled Transactions"), - "page-uri", "default:", "ui-description", "gnc-plugin-page-sx-list.ui", NULL); From 6e8e5b760a271e420e93cd94038d69de6f5d4ace Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Sat, 5 Nov 2022 16:44:00 +0000 Subject: [PATCH 70/77] Move gnc_plugin_page_get_simple_action_group in source file. --- gnucash/gnome-utils/gnc-plugin-page.c | 35 +++++++++------------------ 1 file changed, 12 insertions(+), 23 deletions(-) diff --git a/gnucash/gnome-utils/gnc-plugin-page.c b/gnucash/gnome-utils/gnc-plugin-page.c index 08c6a1021b..ee570f4b11 100644 --- a/gnucash/gnome-utils/gnc-plugin-page.c +++ b/gnucash/gnome-utils/gnc-plugin-page.c @@ -984,29 +984,6 @@ gnc_plugin_page_get_ui_description (GncPluginPage *page) } -const gchar * -gnc_plugin_page_get_simple_action_group_name (GncPluginPage *page) -{ - GncPluginPagePrivate *priv; - - g_return_val_if_fail (GNC_IS_PLUGIN_PAGE(page), NULL); - - priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page); - - return priv->simple_action_group_name; - -// GncPluginPageClass *klass; - -// g_return_val_if_fail (GNC_IS_PLUGIN_PAGE(page), NULL); -// klass = GNC_PLUGIN_PAGE_GET_CLASS(page); - -// if (klass->actions_name) -// return klass->actions_name; -// else -// return NULL; -} - - /* Set an alternate UI for the specified page. This alternate ui * may only use actions specified in the source for the page. */ void @@ -1086,6 +1063,18 @@ gnc_plugin_page_create_action_group (GncPluginPage *page, const gchar *group_nam return priv->simple_action_group; } +const gchar * +gnc_plugin_page_get_simple_action_group_name (GncPluginPage *page) +{ + GncPluginPagePrivate *priv; + + g_return_val_if_fail (GNC_IS_PLUGIN_PAGE(page), NULL); + + priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page); + + return priv->simple_action_group_name; +} + gboolean gnc_plugin_page_finish_pending (GncPluginPage *page) { From 86f6528d0a4461c5f1b92bd20aaf2adfd076c3a4 Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Sun, 6 Nov 2022 12:42:39 +0000 Subject: [PATCH 71/77] Need to free the GncMainWindowActionData When hash table item_hash is destroyed, the GncMainWindowActionData structures need to be freed. --- gnucash/gnome-utils/gnc-plugin-menu-additions.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gnucash/gnome-utils/gnc-plugin-menu-additions.c b/gnucash/gnome-utils/gnc-plugin-menu-additions.c index 20a585de01..65f8705a2a 100644 --- a/gnucash/gnome-utils/gnc-plugin-menu-additions.c +++ b/gnucash/gnome-utils/gnc-plugin-menu-additions.c @@ -504,7 +504,7 @@ gnc_plugin_menu_additions_add_to_window (GncPlugin *plugin, ENTER(" "); per_window.window = window; - per_window.item_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); + per_window.item_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); per_window.build_menu_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); per_window.report_menu = g_menu_new (); From bfaecdffa83d6bfe8756e1390ef2f76dd2b74e48 Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Sun, 6 Nov 2022 12:45:28 +0000 Subject: [PATCH 72/77] Refactor the adding of the tooltips to the report menu items --- .../gnome-utils/gnc-plugin-menu-additions.c | 59 ++++++++----------- 1 file changed, 26 insertions(+), 33 deletions(-) diff --git a/gnucash/gnome-utils/gnc-plugin-menu-additions.c b/gnucash/gnome-utils/gnc-plugin-menu-additions.c index 65f8705a2a..114a7fc074 100644 --- a/gnucash/gnome-utils/gnc-plugin-menu-additions.c +++ b/gnucash/gnome-utils/gnc-plugin-menu-additions.c @@ -140,7 +140,7 @@ gnc_plugin_menu_additions_finalize (GObject *object) ENTER("plugin %p", object); priv = GNC_PLUGIN_MENU_ADDITIONS_GET_PRIVATE(object); - + g_hash_table_destroy (priv->item_hash); G_OBJECT_CLASS (parent_class)->finalize (object); @@ -389,6 +389,29 @@ gnc_menu_additions_assign_accel (ExtensionInfo *info, GHashTable *table) LEAVE("assigned"); } +static GMenuItem * +setup_tooltip_for_gmenu_item (ExtensionInfo *ext_info) +{ + GMenuItem *gmenu_item = NULL; + + if (g_strcmp0 (ext_info->typeStr, "menuitem") == 0) + { + gmenu_item = g_menu_item_new (ext_info->action_label, NULL); + g_menu_item_set_action_and_target_value (gmenu_item, "gnc-plugin-menu-additions-actions.AdditionsAction", + g_variant_new_string (ext_info->action_name)); + + g_menu_item_set_attribute (gmenu_item, GNC_MENU_ATTRIBUTE_TOOLTIP, "s", ext_info->action_tooltip); + } + + if (g_strcmp0 (ext_info->typeStr, "menu") == 0) + { + GMenuModel *sub_menu = G_MENU_MODEL(g_menu_new ()); + + gmenu_item = g_menu_item_new_submenu (ext_info->action_label, sub_menu); + g_object_set_data (G_OBJECT(gmenu_item), "sub-menu", sub_menu); + } + return gmenu_item; +} /** Add one extension item to the UI manager. This function creates a * per-callback data structure for easy access to the opaque Scheme @@ -424,26 +447,11 @@ gnc_menu_additions_menu_setup_one (ExtensionInfo *ext_info, item_path = g_hash_table_lookup (per_window->build_menu_hash, ext_info->path); item_with_full_path = g_hash_table_lookup (per_window->build_menu_hash, full_path); -//FIXMEb This needs refactoring if (!item_path && !item_with_full_path) { - if (g_strcmp0 (ext_info->typeStr, "menuitem") == 0) - { - gmenu_item = g_menu_item_new (ext_info->action_label, NULL); - g_menu_item_set_action_and_target_value (gmenu_item, "gnc-plugin-menu-additions-actions.AdditionsAction", - g_variant_new_string (ext_info->action_name)); + gmenu_item = setup_tooltip_for_gmenu_item (ext_info); - g_menu_item_set_attribute (gmenu_item, GNC_MENU_ATTRIBUTE_TOOLTIP, "s", ext_info->action_tooltip); - } - - if (g_strcmp0 (ext_info->typeStr, "menu") == 0) - { - GMenuModel *sub_menu = G_MENU_MODEL(g_menu_new ()); - - gmenu_item = g_menu_item_new_submenu (ext_info->action_label, sub_menu); - g_object_set_data (G_OBJECT(gmenu_item), "sub-menu", sub_menu); - } g_menu_append_item (G_MENU(per_window->report_menu), gmenu_item); } @@ -451,22 +459,8 @@ gnc_menu_additions_menu_setup_one (ExtensionInfo *ext_info, { GMenuModel *sub_menu = G_MENU_MODEL(g_object_get_data (G_OBJECT(item_path), "sub-menu")); - if (g_strcmp0 (ext_info->typeStr, "menuitem") == 0) - { - gmenu_item = g_menu_item_new (ext_info->action_label, NULL); - g_menu_item_set_action_and_target_value (gmenu_item, "gnc-plugin-menu-additions-actions.AdditionsAction", - g_variant_new_string (ext_info->action_name)); + gmenu_item = setup_tooltip_for_gmenu_item (ext_info); - g_menu_item_set_attribute (gmenu_item, GNC_MENU_ATTRIBUTE_TOOLTIP, "s", ext_info->action_tooltip); - } - - if (g_strcmp0 (ext_info->typeStr, "menu") == 0) - { - GMenuModel *sub_menu = G_MENU_MODEL(g_menu_new ()); - - gmenu_item = g_menu_item_new_submenu (ext_info->action_label, sub_menu); - g_object_set_data (G_OBJECT(gmenu_item), "sub-menu", sub_menu); - } g_menu_append_item (G_MENU(sub_menu), gmenu_item); } g_hash_table_insert (per_window->build_menu_hash, g_strdup (full_path), gmenu_item); @@ -475,7 +469,6 @@ gnc_menu_additions_menu_setup_one (ExtensionInfo *ext_info, } - /** Initialize the report menu and other additional menus. This * function is called as part of the initialization of a window, when * the plugin menu items are being added to the menu structure. From 48e5ce87eb047560e3a2ee18f78cff3b45ee6b78 Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Sun, 6 Nov 2022 12:46:06 +0000 Subject: [PATCH 73/77] Fix missing g_free for the main window 'res_name'. --- gnucash/gnome-utils/gnc-main-window.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/gnucash/gnome-utils/gnc-main-window.cpp b/gnucash/gnome-utils/gnc-main-window.cpp index 0695f5f416..2c6dfcd17a 100644 --- a/gnucash/gnome-utils/gnc-main-window.cpp +++ b/gnucash/gnome-utils/gnc-main-window.cpp @@ -3430,6 +3430,7 @@ update_menu_model (GncMainWindow *window, const gchar *ui_filename, res_name = g_strconcat ("/org/gnucash/ui/", ui_filename, NULL); gtk_builder_add_from_resource (builder, res_name, &error); + g_free (res_name); if (error) { From e6b95f011d4c1e9b7d194b1221c3aeca5b7d8043 Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Sat, 5 Nov 2022 16:44:53 +0000 Subject: [PATCH 74/77] Remove depreciated GtkUIManager and friends from Reconcile window --- gnucash/gnome/window-reconcile.c | 405 +++++++++++++---------------- gnucash/gnucash-gresources.xml | 2 + gnucash/ui/gnc-reconcile-window.ui | 289 ++++++++++++++++++++ 3 files changed, 473 insertions(+), 223 deletions(-) create mode 100644 gnucash/ui/gnc-reconcile-window.ui diff --git a/gnucash/gnome/window-reconcile.c b/gnucash/gnome/window-reconcile.c index a76b347bfc..c207de3cbe 100644 --- a/gnucash/gnome/window-reconcile.c +++ b/gnucash/gnome/window-reconcile.c @@ -49,6 +49,7 @@ #include "gnc-event.h" #include "gnc-filepath-utils.h" #include "gnc-gnome-utils.h" +#include "gnc-gtk-utils.h" //#include "gnc-main-window.h" #include "gnc-plugin-page-register.h" #include "gnc-prefs.h" @@ -78,8 +79,9 @@ struct _RecnWindow GtkWidget *window; /* The reconcile window */ - GtkUIManager *ui_merge; - GtkActionGroup *action_group; + GtkBuilder *builder; /* The builder object */ + GSimpleActionGroup *simple_action_group; /* The action group for the window */ + GncPluginPage *page; GtkWidget *starting; /* The starting balance */ @@ -133,9 +135,9 @@ static void recn_destroy_cb (GtkWidget *w, gpointer data); static void recn_cancel (RecnWindow *recnData); static gboolean recn_delete_cb (GtkWidget *widget, GdkEvent *event, gpointer data); static gboolean recn_key_press_cb (GtkWidget *widget, GdkEventKey *event, gpointer data); -static void recnFinishCB (GtkAction *action, RecnWindow *recnData); -static void recnPostponeCB (GtkAction *action, gpointer data); -static void recnCancelCB (GtkAction *action, gpointer data); +static void recnFinishCB (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void recnPostponeCB (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void recnCancelCB (GSimpleAction *simple, GVariant *parameter, gpointer user_data); void gnc_start_recn_children_changed (GtkWidget *widget, startRecnWindowData *data); void gnc_start_recn_interest_clicked_cb (GtkButton *button, startRecnWindowData *data); @@ -145,24 +147,14 @@ static char * gnc_recn_make_window_name (Account *account); static void gnc_recn_set_window_name (RecnWindow *recnData); static gboolean find_by_account (gpointer find_data, gpointer user_data); - /** GLOBALS ************************************************************/ /* This static indicates the debugging module that this .o belongs to. */ G_GNUC_UNUSED static QofLogModule log_module = GNC_MOD_GUI; static time64 gnc_reconcile_last_statement_date = 0; - /** IMPLEMENTATIONS *************************************************/ -/** An array of all of the actions provided by the main window code. - * This includes some placeholder actions for the menus that are - * visible in the menu bar but have no action associated with - * them. */ -static GtkActionEntry recnWindow_actions []; -/** The number of actions provided by the main window. */ -static guint recnWindow_n_actions; - static gpointer commodity_compare(Account *account, gpointer user_data) { gboolean equal = gnc_commodity_equiv (xaccAccountGetCommodity (account), @@ -265,7 +257,7 @@ recnRecalculateBalance (RecnWindow *recnData) gchar *datestr; GNCPrintAmountInfo print_info; gboolean reverse_balance, include_children; - GtkAction *action; + GAction *action; account = recn_get_account (recnData); if (!account) @@ -301,13 +293,13 @@ recnRecalculateBalance (RecnWindow *recnData) gnc_add_colorized_amount (recnData->reconciled, reconciled, print_info, reverse_balance); gnc_add_colorized_amount (recnData->difference, diff, print_info, reverse_balance); - action = gtk_action_group_get_action (recnData->action_group, - "RecnFinishAction"); - gtk_action_set_sensitive(action, gnc_numeric_zero_p (diff)); + action = g_action_map_lookup_action (G_ACTION_MAP(recnData->simple_action_group), + "RecnFinishAction"); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), gnc_numeric_zero_p (diff)); - action = gtk_action_group_get_action (recnData->action_group, - "TransBalanceAction"); - gtk_action_set_sensitive(action, !gnc_numeric_zero_p (diff)); + action = g_action_map_lookup_action (G_ACTION_MAP(recnData->simple_action_group), + "TransBalanceAction"); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), !gnc_numeric_zero_p (diff)); return diff; } @@ -859,7 +851,7 @@ gnc_reconcile_window_set_sensitivity(RecnWindow *recnData) { gboolean sensitive = FALSE; GNCReconcileView *view; - GtkAction *action; + GAction *action; view = GNC_RECONCILE_VIEW(recnData->debit); if (gnc_reconcile_view_num_selected(view) == 1) @@ -869,12 +861,13 @@ gnc_reconcile_window_set_sensitivity(RecnWindow *recnData) if (gnc_reconcile_view_num_selected(view) == 1) sensitive = TRUE; - action = gtk_action_group_get_action (recnData->action_group, - "TransEditAction"); - gtk_action_set_sensitive(action, sensitive); - action = gtk_action_group_get_action (recnData->action_group, - "TransDeleteAction"); - gtk_action_set_sensitive(action, sensitive); + action = g_action_map_lookup_action (G_ACTION_MAP(recnData->simple_action_group), + "TransEditAction"); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), sensitive); + + action = g_action_map_lookup_action (G_ACTION_MAP(recnData->simple_action_group), + "TransDeleteAction"); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), sensitive); sensitive = FALSE; @@ -886,12 +879,13 @@ gnc_reconcile_window_set_sensitivity(RecnWindow *recnData) if (gnc_reconcile_view_num_selected(view) > 0) sensitive = TRUE; - action = gtk_action_group_get_action (recnData->action_group, - "TransRecAction"); - gtk_action_set_sensitive(action, sensitive); - action = gtk_action_group_get_action (recnData->action_group, - "TransUnRecAction"); - gtk_action_set_sensitive(action, sensitive); + action = g_action_map_lookup_action (G_ACTION_MAP(recnData->simple_action_group), + "TransRecAction"); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), sensitive); + + action = g_action_map_lookup_action (G_ACTION_MAP(recnData->simple_action_group), + "TransUnRecAction"); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), sensitive); } @@ -929,11 +923,14 @@ gnc_reconcile_window_row_cb(GNCReconcileView *view, gpointer item, static void do_popup_menu(RecnWindow *recnData, GdkEventButton *event) { - GtkWidget *menu = gtk_ui_manager_get_widget (recnData->ui_merge, "/MainPopup"); + GMenuModel *menu_model = (GMenuModel *)gtk_builder_get_object (recnData->builder, + "recwin-popup"); + GtkWidget *menu = gtk_menu_new_from_model (menu_model); if (!menu) return; + gtk_menu_attach_to_widget (GTK_MENU(menu), GTK_WIDGET(recnData->window), NULL); gtk_menu_popup_at_pointer (GTK_MENU(menu), (GdkEvent *) event); } @@ -969,23 +966,25 @@ gnc_reconcile_window_button_press_cb (GtkWidget *widget, GdkEventButton *event, RecnWindow *recnData) { - GNCQueryView *qview = GNC_QUERY_VIEW(widget); - GtkTreeSelection *selection; - GtkTreePath *path; - if (event->button == 3 && event->type == GDK_BUTTON_PRESS) { + GNCQueryView *qview = GNC_QUERY_VIEW(widget); + GtkTreePath *path; /* Get tree path for row that was clicked */ - gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(qview), - (gint) event->x, - (gint) event->y, - &path, NULL, NULL, NULL); + gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW(qview), + (gint) event->x, + (gint) event->y, + &path, NULL, NULL, NULL); - selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(qview)); - gtk_tree_selection_select_path(selection, path); - gtk_tree_path_free(path); - do_popup_menu(recnData, event); + if (path) + { + GtkTreeSelection *selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(qview)); + + gtk_tree_selection_select_path (selection, path); + gtk_tree_path_free (path); + } + do_popup_menu (recnData, event); return TRUE; } return FALSE; @@ -1196,17 +1195,21 @@ gnc_reconcile_window_get_current_split(RecnWindow *recnData) static void -gnc_ui_reconcile_window_help_cb(GtkWidget *widget, gpointer data) +gnc_ui_reconcile_window_help_cb (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { - RecnWindow *recnData = data; + RecnWindow *recnData = user_data; gnc_gnome_help (GTK_WINDOW(recnData->window), HF_HELP, HL_RECNWIN); } static void -gnc_ui_reconcile_window_change_cb(GtkAction *action, gpointer data) +gnc_ui_reconcile_window_change_cb (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { - RecnWindow *recnData = data; + RecnWindow *recnData = user_data; Account *account = recn_get_account (recnData); gnc_numeric new_ending = recnData->new_ending; time64 statement_date = recnData->statement_date; @@ -1224,9 +1227,11 @@ gnc_ui_reconcile_window_change_cb(GtkAction *action, gpointer data) static void -gnc_ui_reconcile_window_balance_cb(GtkButton *button, gpointer data) +gnc_ui_reconcile_window_balance_cb (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { - RecnWindow *recnData = data; + RecnWindow *recnData = user_data; GNCSplitReg *gsr; Account *account; gnc_numeric balancing_amount; @@ -1254,9 +1259,11 @@ gnc_ui_reconcile_window_balance_cb(GtkButton *button, gpointer data) static void -gnc_ui_reconcile_window_rec_cb(GtkButton *button, gpointer data) +gnc_ui_reconcile_window_rec_cb (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { - RecnWindow *recnData = data; + RecnWindow *recnData = user_data; GNCReconcileView *debit, *credit; debit = GNC_RECONCILE_VIEW(recnData->debit); @@ -1268,9 +1275,11 @@ gnc_ui_reconcile_window_rec_cb(GtkButton *button, gpointer data) static void -gnc_ui_reconcile_window_unrec_cb(GtkButton *button, gpointer data) +gnc_ui_reconcile_window_unrec_cb (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { - RecnWindow *recnData = data; + RecnWindow *recnData = user_data; GNCReconcileView *debit, *credit; debit = GNC_RECONCILE_VIEW(recnData->debit); @@ -1363,9 +1372,11 @@ gnc_reconcile_window_delete_set_next_selection (RecnWindow *recnData, Split *spl static void -gnc_ui_reconcile_window_delete_cb(GtkButton *button, gpointer data) +gnc_ui_reconcile_window_delete_cb (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { - RecnWindow *recnData = data; + RecnWindow *recnData = user_data; Transaction *trans; Split *split, *next_split; @@ -1398,9 +1409,11 @@ gnc_ui_reconcile_window_delete_cb(GtkButton *button, gpointer data) static void -gnc_ui_reconcile_window_edit_cb(GtkButton *button, gpointer data) +gnc_ui_reconcile_window_edit_cb (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { - RecnWindow *recnData = data; + RecnWindow *recnData = user_data; GNCSplitReg *gsr; Split *split; @@ -1450,9 +1463,11 @@ gnc_recn_set_window_name(RecnWindow *recnData) static void -gnc_recn_edit_account_cb(GtkAction *action, gpointer data) +gnc_recn_edit_account_cb (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { - RecnWindow *recnData = data; + RecnWindow *recnData = user_data; Account *account = recn_get_account (recnData); if (account == NULL) @@ -1463,9 +1478,11 @@ gnc_recn_edit_account_cb(GtkAction *action, gpointer data) static void -gnc_recn_xfer_cb(GtkAction *action, gpointer data) +gnc_recn_xfer_cb (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { - RecnWindow *recnData = data; + RecnWindow *recnData = user_data; Account *account = recn_get_account (recnData); if (account == NULL) @@ -1476,9 +1493,11 @@ gnc_recn_xfer_cb(GtkAction *action, gpointer data) static void -gnc_recn_scrub_cb(GtkAction *action, gpointer data) +gnc_recn_scrub_cb (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { - RecnWindow *recnData = data; + RecnWindow *recnData = user_data; Account *account = recn_get_account (recnData); if (account == NULL) @@ -1498,9 +1517,11 @@ gnc_recn_scrub_cb(GtkAction *action, gpointer data) static void -gnc_recn_open_cb(GtkAction *action, gpointer data) +gnc_recn_open_cb (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { - RecnWindow *recnData = data; + RecnWindow *recnData = user_data; gnc_reconcile_window_open_register(recnData); } @@ -1751,6 +1772,30 @@ recnWindow_add_widget (GtkUIManager *merge, } +static GActionEntry recWindow_actions_entries [] = +{ + { "RecnChangeInfoAction", gnc_ui_reconcile_window_change_cb, NULL, NULL, NULL }, + { "RecnFinishAction", recnFinishCB, NULL, NULL, NULL }, + { "RecnPostponeAction", recnPostponeCB, NULL, NULL, NULL }, + { "RecnCancelAction", recnCancelCB, NULL, NULL, NULL }, + + { "AccountOpenAccountAction", gnc_recn_open_cb, NULL, NULL, NULL }, + { "AccountEditAccountAction", gnc_recn_edit_account_cb, NULL, NULL, NULL }, + { "AccountTransferAction", gnc_recn_xfer_cb, NULL, NULL, NULL }, + { "AccountCheckRepairAction", gnc_recn_scrub_cb, NULL, NULL, NULL }, + + { "TransBalanceAction", gnc_ui_reconcile_window_balance_cb, NULL, NULL, NULL }, + { "TransEditAction", gnc_ui_reconcile_window_edit_cb, NULL, NULL, NULL }, + { "TransDeleteAction", gnc_ui_reconcile_window_delete_cb, NULL, NULL, NULL }, + { "TransRecAction", gnc_ui_reconcile_window_rec_cb, NULL, NULL, NULL }, + { "TransUnRecAction", gnc_ui_reconcile_window_unrec_cb, NULL, NULL, NULL }, + + { "HelpHelpAction", gnc_ui_reconcile_window_help_cb, NULL, NULL, NULL }, +}; +/** The number of actions provided by the reconcile window. */ +static guint recnWindow_n_actions_entries = G_N_ELEMENTS(recWindow_actions_entries); + + /********************************************************************\ * recnWindowWithBalance * @@ -1815,48 +1860,51 @@ recnWindowWithBalance (GtkWidget *parent, Account *account, gnc_numeric new_endi gtk_box_pack_start(GTK_BOX (vbox), dock, FALSE, TRUE, 0); { - gchar *filename; - gint merge_id; - GtkAction *action; - GtkActionGroup *action_group; + GtkToolbar *tool_bar; + GMenuModel *menu_model; + GtkWidget *menu_bar; + GtkAccelGroup *accel_group = gtk_accel_group_new (); + const gchar *ui = "/org/gnucash/ui/gnc-reconcile-window.ui"; GError *error = NULL; - recnData->ui_merge = gtk_ui_manager_new (); - g_signal_connect (recnData->ui_merge, "add_widget", - G_CALLBACK (recnWindow_add_widget), dock); + recnData->builder = gtk_builder_new (); - action_group = gtk_action_group_new ("ReconcileWindowActions"); - recnData->action_group = action_group; - gtk_action_group_set_translation_domain(action_group, PROJECT_NAME); - gtk_action_group_add_actions (action_group, recnWindow_actions, - recnWindow_n_actions, recnData); - action = - gtk_action_group_get_action (action_group, "AccountOpenAccountAction"); - g_object_set (G_OBJECT(action), "short_label", _("Open"), NULL); + gtk_builder_add_from_resource (recnData->builder, ui, &error); - gtk_ui_manager_insert_action_group (recnData->ui_merge, action_group, 0); + gtk_builder_set_translation_domain (recnData->builder, PROJECT_NAME); - filename = gnc_filepath_locate_ui_file("gnc-reconcile-window-ui.xml"); - /* Can't do much without a ui. */ - g_assert (filename); - - merge_id = gtk_ui_manager_add_ui_from_file (recnData->ui_merge, - filename, &error); - g_assert(merge_id || error); - if (merge_id) + if (error) { - gtk_window_add_accel_group (GTK_WINDOW (recnData->window), - gtk_ui_manager_get_accel_group(recnData->ui_merge)); - gtk_ui_manager_ensure_update (recnData->ui_merge); + g_critical ("Failed to load ui resource %s, Error %s", ui, error->message); + g_error_free (error); + gnc_unregister_gui_component_by_data (WINDOW_RECONCILE_CM_CLASS, recnData); + g_free (recnData); + return NULL; } - else - { - g_critical("Failed to load ui file.\n Filename %s\n Error %s", - filename, error->message); - g_error_free(error); - g_assert(merge_id != 0); - } - g_free(filename); + + menu_model = (GMenuModel *)gtk_builder_get_object (recnData->builder, "recwin-menu"); + menu_bar = gtk_menu_bar_new_from_model (menu_model); + gtk_container_add (GTK_CONTAINER(vbox), menu_bar); + + tool_bar = (GtkToolbar *)gtk_builder_get_object (recnData->builder, "recwin-toolbar"); + g_object_set (tool_bar, "toolbar-style", GTK_TOOLBAR_BOTH, NULL); + + gtk_container_add (GTK_CONTAINER(vbox), GTK_WIDGET(tool_bar)); + + gtk_window_add_accel_group (GTK_WINDOW(recnData->window), accel_group); + + // need to add the accelerator keys + gnc_add_accelerator_keys_for_menu (menu_bar, accel_group); + + recnData->simple_action_group = g_simple_action_group_new (); + + g_action_map_add_action_entries (G_ACTION_MAP(recnData->simple_action_group), + recWindow_actions_entries, + recnWindow_n_actions_entries, + recnData); + + gtk_widget_insert_action_group (GTK_WIDGET(recnData->window), "recwin", + G_ACTION_GROUP(recnData->simple_action_group)); } g_signal_connect(recnData->window, "popup-menu", @@ -2059,15 +2107,15 @@ use Find Transactions to find them, unreconcile, and re-reconcile.")); #ifdef MAC_INTEGRATION { - GtkWidget *menubar = gtk_ui_manager_get_widget (recnData->ui_merge, - "/menubar"); - GtkosxApplication *theApp = g_object_new (GTKOSX_TYPE_APPLICATION, - NULL); - if (GTK_IS_MENU_ITEM (menubar)) - menubar = gtk_menu_item_get_submenu (GTK_MENU_ITEM (menubar)); - gtk_widget_hide (menubar); - gtkosx_application_set_menu_bar (theApp, GTK_MENU_SHELL (menubar)); - g_object_unref (theApp); +//FIXME GtkWidget *menubar = gtk_ui_manager_get_widget (recnData->ui_merge, +// "/menubar"); +// GtkosxApplication *theApp = g_object_new (GTKOSX_TYPE_APPLICATION, +// NULL); +// if (GTK_IS_MENU_ITEM (menubar)) +// menubar = gtk_menu_item_get_submenu (GTK_MENU_ITEM (menubar)); +// gtk_widget_hide (menubar); +// gtkosx_application_set_menu_bar (theApp, GTK_MENU_SHELL (menubar)); +// g_object_unref (theApp); } #endif recnRecalculateBalance(recnData); @@ -2132,6 +2180,8 @@ static void recn_destroy_cb (GtkWidget *w, gpointer data) { RecnWindow *recnData = data; + gchar **actions = g_action_group_list_actions (G_ACTION_GROUP(recnData->simple_action_group)); + gint num_actions = g_strv_length (actions); gnc_unregister_gui_component_by_data (WINDOW_RECONCILE_CM_CLASS, recnData); @@ -2139,8 +2189,12 @@ recn_destroy_cb (GtkWidget *w, gpointer data) gnc_resume_gui_refresh (); //Disable the actions, the handlers try to access recnData - gtk_action_group_set_sensitive(recnData->action_group, FALSE); - + for (gint i = 0; i < num_actions; i++) + { + GAction *action = g_simple_action_group_lookup (recnData->simple_action_group, actions[i]); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE); + } + g_strfreev (actions); g_free (recnData); } @@ -2280,8 +2334,11 @@ acct_traverse_descendants (Account *acct, AccountProc fn) * Return: none * \********************************************************************/ static void -recnFinishCB (GtkAction *action, RecnWindow *recnData) +recnFinishCB (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { + RecnWindow *recnData = user_data; gboolean auto_payment; Account *account; time64 date; @@ -2340,9 +2397,11 @@ recnFinishCB (GtkAction *action, RecnWindow *recnData) * Return: none * \********************************************************************/ static void -recnPostponeCB (GtkAction *action, gpointer data) +recnPostponeCB (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { - RecnWindow *recnData = data; + RecnWindow *recnData = user_data; Account *account; { @@ -2370,110 +2429,10 @@ recnPostponeCB (GtkAction *action, gpointer data) static void -recnCancelCB (GtkAction *action, gpointer data) +recnCancelCB (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) { - RecnWindow *recnData = data; + RecnWindow *recnData = user_data; recn_cancel(recnData); } - - -/** An array of all of the actions provided by the main window code. - * This includes some placeholder actions for the menus that are - * visible in the menu bar but have no action associated with - * them. */ -static GtkActionEntry recnWindow_actions [] = -{ - /* Toplevel */ - - { "ReconcileMenuAction", NULL, N_("_Reconcile"), NULL, NULL, NULL, }, - { "AccountMenuAction", NULL, N_("_Account"), NULL, NULL, NULL, }, - { "TransactionMenuAction", NULL, N_("_Transaction"), NULL, NULL, NULL, }, - { "HelpMenuAction", NULL, N_("_Help"), NULL, NULL, NULL, }, - - /* Reconcile menu */ - - { - "RecnChangeInfoAction", NULL, N_("_Reconcile Information..."), NULL, - N_("Change the reconcile information " - "including statement date and ending balance."), - G_CALLBACK (gnc_ui_reconcile_window_change_cb) - }, - { - "RecnFinishAction", "system-run", N_("_Finish"), "w", - N_("Finish the reconciliation of this account"), - G_CALLBACK(recnFinishCB) - }, - { - "RecnPostponeAction", "go-previous", N_("_Postpone"), "p", - N_("Postpone the reconciliation of this account"), - G_CALLBACK(recnPostponeCB) - }, - { - "RecnCancelAction", "process-stop", N_("_Cancel"), NULL, - N_("Cancel the reconciliation of this account"), - G_CALLBACK(recnCancelCB) - }, - - /* Account menu */ - - { - "AccountOpenAccountAction", "go-jump", N_("_Open Account"), NULL, - N_("Open the account"), - G_CALLBACK(gnc_recn_open_cb) - }, - { - "AccountEditAccountAction", NULL, N_("_Edit Account"), NULL, - N_("Edit the main account for this register"), - G_CALLBACK(gnc_recn_edit_account_cb) - }, - { - "AccountTransferAction", NULL, N_("_Transfer..."), NULL, - N_("Transfer funds from one account to another"), - G_CALLBACK(gnc_recn_xfer_cb) - }, - { - "AccountCheckRepairAction", NULL, N_("_Check & Repair"), NULL, - N_("Check for and repair unbalanced transactions and orphan splits " - "in this account"), - G_CALLBACK(gnc_recn_scrub_cb) - }, - - /* Transaction menu */ - - { - "TransBalanceAction", "document-new", N_("_Balance"), "b", - N_("Add a new balancing entry to the account"), - G_CALLBACK(gnc_ui_reconcile_window_balance_cb) - }, - { - "TransEditAction", "document-properties", N_("_Edit"), "e", - N_("Edit the current transaction"), - G_CALLBACK(gnc_ui_reconcile_window_edit_cb) - }, - { - "TransDeleteAction", "edit-delete", N_("_Delete"), "d", - N_("Delete the selected transaction"), - G_CALLBACK(gnc_ui_reconcile_window_delete_cb) - }, - { - "TransRecAction", "emblem-default", N_("_Reconcile Selection"), "r", - N_("Reconcile the selected transactions"), - G_CALLBACK(gnc_ui_reconcile_window_rec_cb) - }, - { - "TransUnRecAction", "edit-clear", N_("_Unreconcile Selection"), "u", - N_("Unreconcile the selected transactions"), - G_CALLBACK(gnc_ui_reconcile_window_unrec_cb) - }, - - /* Help menu */ - - { - "HelpHelpAction", NULL, N_("_Help"), NULL, - N_("Open the GnuCash help window"), - G_CALLBACK(gnc_ui_reconcile_window_help_cb) - }, -}; - -/** The number of actions provided by the main window. */ -static guint recnWindow_n_actions = G_N_ELEMENTS (recnWindow_actions); diff --git a/gnucash/gnucash-gresources.xml b/gnucash/gnucash-gresources.xml index c3ccd7b7a4..780271d70d 100644 --- a/gnucash/gnucash-gresources.xml +++ b/gnucash/gnucash-gresources.xml @@ -31,5 +31,7 @@ ui/gnc-plugin-aqbanking.ui ui/gnc-plugin-qif-import.ui + + ui/gnc-reconcile-window.ui diff --git a/gnucash/ui/gnc-reconcile-window.ui b/gnucash/ui/gnc-reconcile-window.ui new file mode 100644 index 0000000000..049433fcf0 --- /dev/null +++ b/gnucash/ui/gnc-reconcile-window.ui @@ -0,0 +1,289 @@ + + + + + _Reconcile +
+ + _Reconcile Information... + recwin.RecnChangeInfoAction + +
+
+ + _Finish + recwin.RecnFinishAction + <Primary>w + + + _Postpone + recwin.RecnPostponeAction + <Primary>p + + + _Cancel + recwin.RecnCancelAction + +
+
+ + _Account +
+ + _Open Account + recwin.AccountOpenAccountAction + + + _Edit Account + recwin.AccountEditAccountAction + +
+
+ + _Transfer... + recwin.AccountTransferAction + +
+
+ + _Check & Repair + recwin.AccountCheckRepairAction + +
+
+ + _Transaction +
+ + _Balance + recwin.TransBalanceAction + <Primary>b + + + _Edit + recwin.TransEditAction + <Primary>e + + + _Reconcile Selection + recwin.TransRecAction + <Primary>r + + + _Unreconcile Selection + recwin.TransUnRecAction + <Primary>u + + + _Delete + recwin.TransDeleteAction + <Primary>d + +
+
+ + _Help +
+ + _Help + recwin.HelpHelpAction + +
+
+
+ + + + + _Balance + recwin.TransBalanceAction + + + _Edit + recwin.TransEditAction + + + _Reconcile Selection + recwin.TransRecAction + + + _Unreconcile Selection + recwin.TransUnRecAction + + + _Delete + recwin.TransDeleteAction + + + + + + True + False + + + True + False + Add a new balancing entry to the account + recwin.TransBalanceAction + _Balance + True + document-new + + + False + True + + + + + + True + False + recwin.TransEditAction + Edit the current transaction + _Edit + True + document-properties + + + False + True + + + + + + True + False + Reconcile the selected transactions + recwin.TransRecAction + Reconcile Selection + True + emblem-default + + + False + True + + + + + + True + False + Unreconcile the selected transactions + recwin.TransUnRecAction + Unreconcile Selection + True + edit-clear + + + False + True + + + + + + True + False + Delete the selected transaction + recwin.TransDeleteAction + _Delete + True + edit-delete + + + False + True + + + + + + True + False + + + False + True + + + + + + True + False + Open the account + recwin.AccountOpenAccountAction + _Open + True + go-jump + + + False + True + + + + + + True + False + + + False + True + + + + + + True + False + Finish the reconciliation of this account + recwin.RecnFinishAction + _Finish + True + system-run + + + False + True + + + + + + True + False + Postpone the reconciliation of this account + recwin.RecnPostponeAction + _Postpone + True + go-previous + + + False + True + + + + + + True + False + Cancel the reconciliation of this account + recwin.RecnCancelAction + _Cancel + True + process-stop + + + False + True + + + +
From 1890c6ccfb1fbfa6063bf34c8a2e406b6e41c9d5 Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Sat, 5 Nov 2022 16:45:55 +0000 Subject: [PATCH 75/77] Reimplement macOS menubar for reconcile window --- gnucash/gnome/window-reconcile.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/gnucash/gnome/window-reconcile.c b/gnucash/gnome/window-reconcile.c index c207de3cbe..eb5091f0e8 100644 --- a/gnucash/gnome/window-reconcile.c +++ b/gnucash/gnome/window-reconcile.c @@ -1866,7 +1866,10 @@ recnWindowWithBalance (GtkWidget *parent, Account *account, gnc_numeric new_endi GtkAccelGroup *accel_group = gtk_accel_group_new (); const gchar *ui = "/org/gnucash/ui/gnc-reconcile-window.ui"; GError *error = NULL; - +#ifdef MAC_INTEGRATION + GtkosxApplication *theApp = g_object_new (GTKOSX_TYPE_APPLICATION, + NULL); +#endif recnData->builder = gtk_builder_new (); gtk_builder_add_from_resource (recnData->builder, ui, &error); @@ -1885,8 +1888,18 @@ recnWindowWithBalance (GtkWidget *parent, Account *account, gnc_numeric new_endi menu_model = (GMenuModel *)gtk_builder_get_object (recnData->builder, "recwin-menu"); menu_bar = gtk_menu_bar_new_from_model (menu_model); gtk_container_add (GTK_CONTAINER(vbox), menu_bar); +#if MAC_INTEGRATION + gtk_widget_hide (menu_bar); + gtk_widget_set_no_show_all (menu_bar, TRUE); + if (GTK_IS_MENU_ITEM (menu_bar)) + menu_bar = gtk_menu_item_get_submenu (GTK_MENU_ITEM (menu_bar)); + gtkosx_application_set_menu_bar (theApp, GTK_MENU_SHELL (menu_bar)); + g_object_unref (theApp); + theApp = NULL; +#endif tool_bar = (GtkToolbar *)gtk_builder_get_object (recnData->builder, "recwin-toolbar"); + g_object_set (tool_bar, "toolbar-style", GTK_TOOLBAR_BOTH, NULL); gtk_container_add (GTK_CONTAINER(vbox), GTK_WIDGET(tool_bar)); @@ -2105,19 +2118,6 @@ use Find Transactions to find them, unreconcile, and re-reconcile.")); gnc_reconcile_window_set_titles(recnData); -#ifdef MAC_INTEGRATION - { -//FIXME GtkWidget *menubar = gtk_ui_manager_get_widget (recnData->ui_merge, -// "/menubar"); -// GtkosxApplication *theApp = g_object_new (GTKOSX_TYPE_APPLICATION, -// NULL); -// if (GTK_IS_MENU_ITEM (menubar)) -// menubar = gtk_menu_item_get_submenu (GTK_MENU_ITEM (menubar)); -// gtk_widget_hide (menubar); -// gtkosx_application_set_menu_bar (theApp, GTK_MENU_SHELL (menubar)); -// g_object_unref (theApp); - } -#endif recnRecalculateBalance(recnData); gnc_window_adjust_for_screen(GTK_WINDOW(recnData->window)); From f16f3f67eb9d4cb96d9f21814af3877760af37a6 Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Sat, 5 Nov 2022 16:46:37 +0000 Subject: [PATCH 76/77] Remove gnc-reconcile-window-ui.xml --- gnucash/ui/CMakeLists.txt | 1 - gnucash/ui/gnc-reconcile-window-ui.xml | 54 -------------------------- 2 files changed, 55 deletions(-) delete mode 100644 gnucash/ui/gnc-reconcile-window-ui.xml diff --git a/gnucash/ui/CMakeLists.txt b/gnucash/ui/CMakeLists.txt index 6e7f6276c5..233e778e69 100644 --- a/gnucash/ui/CMakeLists.txt +++ b/gnucash/ui/CMakeLists.txt @@ -1,5 +1,4 @@ set (ui_SOURCES - gnc-reconcile-window-ui.xml osx_accel_map) foreach (ui_file ${ui_SOURCES}) diff --git a/gnucash/ui/gnc-reconcile-window-ui.xml b/gnucash/ui/gnc-reconcile-window-ui.xml deleted file mode 100644 index d44dfc87a4..0000000000 --- a/gnucash/ui/gnc-reconcile-window-ui.xml +++ /dev/null @@ -1,54 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - From cc91c7d3c610d4b53b35652afb148e97d03f803b Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Sat, 5 Nov 2022 16:47:19 +0000 Subject: [PATCH 77/77] Remove surplus function recnWindow_add_widget --- gnucash/gnome/window-reconcile.c | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/gnucash/gnome/window-reconcile.c b/gnucash/gnome/window-reconcile.c index eb5091f0e8..5745ef2aeb 100644 --- a/gnucash/gnome/window-reconcile.c +++ b/gnucash/gnome/window-reconcile.c @@ -1755,23 +1755,6 @@ recnWindow (GtkWidget *parent, Account *account) } -static void -recnWindow_add_widget (GtkUIManager *merge, - GtkWidget *widget, - GtkBox *dock) -{ - if (GTK_IS_TOOLBAR (widget)) - { - gtk_toolbar_set_style (GTK_TOOLBAR(widget), - GTK_TOOLBAR_BOTH); - gtk_toolbar_set_icon_size (GTK_TOOLBAR(widget), - GTK_ICON_SIZE_SMALL_TOOLBAR); - } - gtk_box_pack_start (GTK_BOX (dock), widget, FALSE, FALSE, 0); - gtk_widget_show (widget); -} - - static GActionEntry recWindow_actions_entries [] = { { "RecnChangeInfoAction", gnc_ui_reconcile_window_change_cb, NULL, NULL, NULL }, @@ -1900,7 +1883,9 @@ recnWindowWithBalance (GtkWidget *parent, Account *account, gnc_numeric new_endi #endif tool_bar = (GtkToolbar *)gtk_builder_get_object (recnData->builder, "recwin-toolbar"); - g_object_set (tool_bar, "toolbar-style", GTK_TOOLBAR_BOTH, NULL); + gtk_toolbar_set_style (GTK_TOOLBAR(tool_bar), GTK_TOOLBAR_BOTH); + gtk_toolbar_set_icon_size (GTK_TOOLBAR(tool_bar), + GTK_ICON_SIZE_SMALL_TOOLBAR); gtk_container_add (GTK_CONTAINER(vbox), GTK_WIDGET(tool_bar));