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] 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)) {