Modify gnc_menubar_model_update_item

Add the action target as a parameter so that actions with a specific
target can be updated.
This commit is contained in:
Robert Fewell 2023-04-02 11:25:16 +01:00
parent 98c11d620a
commit 0dc0fcd774
4 changed files with 10 additions and 7 deletions

View File

@ -799,6 +799,8 @@ gnc_menubar_model_find_menu_item (GMenuModel *menu_model, GtkWidget *menu, const
* @param menu_model The GMenuModel of the menu.
*
* @param action_name The action name to update.
*
* @param target The action target if required, else NULL.
*
* @param label The new menu label text.
*
@ -810,8 +812,8 @@ gnc_menubar_model_find_menu_item (GMenuModel *menu_model, GtkWidget *menu, const
*/
gboolean
gnc_menubar_model_update_item (GMenuModel *menu_model, const gchar *action_name,
const gchar *label, const gchar *accel_name,
const gchar *tooltip)
const gchar *target, const gchar *label,
const gchar *accel_name, const gchar *tooltip)
{
GncMenuModelSearch *gsm;
gboolean found = FALSE;
@ -823,6 +825,7 @@ gnc_menubar_model_update_item (GMenuModel *menu_model, const gchar *action_name,
gsm->search_action_label = NULL;
gsm->search_action_name = action_name;
gsm->search_action_target = target;
if (gnc_menubar_model_find_item (menu_model, gsm))
{

View File

@ -95,8 +95,8 @@ gboolean gnc_menubar_model_find_item (GMenuModel *menu_model, GncMenuModelSearch
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 *accel_name,
const gchar *tooltip);
const gchar *target, const gchar *label,
const gchar *accel_name, const gchar *tooltip);
void gnc_menubar_model_remove_items_with_attrib (GMenuModel *menu_model, const gchar *attrib);

View File

@ -3641,7 +3641,7 @@ gnc_main_window_update_menu_for_action (GncMainWindow *window,
priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
found = gnc_menubar_model_update_item (priv->menubar_model, action_name,
_(label), nullptr, _(tooltip));
nullptr, _(label), nullptr, _(tooltip));
// add tooltip redirect call backs
gnc_plugin_add_menu_tooltip_callbacks (priv->menubar,

View File

@ -1073,7 +1073,7 @@ gnc_plugin_page_register_ui_update (gpointer various,
{
/* Adjust the action's label and tooltip */
found = gnc_menubar_model_update_item (gnc_window_get_menubar_model (gnc_window),
*iter, _(*label_iter), NULL, _(*tooltip_iter));
*iter, NULL, _(*label_iter), NULL, _(*tooltip_iter));
PINFO("split model_item action '%s', found is %d, iter label is '%s'",
*iter, found, _(*label_iter));
@ -1091,7 +1091,7 @@ gnc_plugin_page_register_ui_update (gpointer various,
{
/* Adjust the action's label and tooltip */
found = gnc_menubar_model_update_item (gnc_window_get_menubar_model (gnc_window),
*iter, _(*label_iter), NULL, _(*tooltip_iter));
*iter, NULL, _(*label_iter), NULL, _(*tooltip_iter));
PINFO("trans model_item action '%s', found is %d, iter label is '%s'",
*iter, found, _(*label_iter));