From 85f462feb589839376adbde18c3543eaa9a93fdb Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Tue, 7 Mar 2023 12:58:27 +0000 Subject: [PATCH] On a Mac, some keyboard short cuts are missing Sync the menu bar after the menus have been updated. --- gnucash/gnome-utils/gnc-main-window.cpp | 9 +++++++-- gnucash/gnome/window-reconcile.c | 27 ++++++++++++++++++------- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/gnucash/gnome-utils/gnc-main-window.cpp b/gnucash/gnome-utils/gnc-main-window.cpp index a2701328b9..cde480ebd2 100644 --- a/gnucash/gnome-utils/gnc-main-window.cpp +++ b/gnucash/gnome-utils/gnc-main-window.cpp @@ -3764,7 +3764,9 @@ gnc_main_window_update_menu_and_toolbar (GncMainWindow *window, GMenuModel *menu_model_part; GncMenuModelSearch *gsm = g_new0 (GncMenuModelSearch, 1); - +#ifdef MAC_INTEGRATION + auto theApp{static_cast(g_object_new(GTKOSX_TYPE_APPLICATION, nullptr))}; +#endif g_return_if_fail (GNC_IS_MAIN_WINDOW(window)); g_return_if_fail (page != nullptr); g_return_if_fail (ui_updates != nullptr); @@ -3833,7 +3835,10 @@ gnc_main_window_update_menu_and_toolbar (GncMainWindow *window, // need to add the accelerator keys gnc_add_accelerator_keys_for_menu (priv->menubar, priv->accel_group); - +#ifdef MAC_INTEGRATION + gtkosx_application_sync_menubar (theApp); + g_object_unref (theApp); +#endif // need to signal menu has been changed g_signal_emit_by_name (window, "menu_changed", page); diff --git a/gnucash/gnome/window-reconcile.c b/gnucash/gnome/window-reconcile.c index b43f4208cb..691730955e 100644 --- a/gnucash/gnome/window-reconcile.c +++ b/gnucash/gnome/window-reconcile.c @@ -1778,6 +1778,15 @@ static GActionEntry recWindow_actions_entries [] = /** The number of actions provided by the reconcile window. */ static guint recnWindow_n_actions_entries = G_N_ELEMENTS(recWindow_actions_entries); +#ifdef MAC_INTEGRATION +/* Enable GtkMenuItem accelerators */ +static gboolean +can_activate_cb(GtkWidget *widget, guint signal_id, gpointer data) +{ + //return gtk_widget_is_sensitive (widget); + return TRUE; +} +#endif /********************************************************************\ * recnWindowWithBalance @@ -1849,10 +1858,7 @@ recnWindowWithBalance (GtkWidget *parent, Account *account, gnc_numeric new_endi GtkAccelGroup *accel_group = gtk_accel_group_new (); const gchar *ui = GNUCASH_RESOURCE_PREFIX "/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); @@ -1871,15 +1877,14 @@ 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 +#ifdef MAC_INTEGRATION + GtkosxApplication *theApp = g_object_new (GTKOSX_TYPE_APPLICATION, NULL); 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"); @@ -1894,6 +1899,14 @@ recnWindowWithBalance (GtkWidget *parent, Account *account, gnc_numeric new_endi // need to add the accelerator keys gnc_add_accelerator_keys_for_menu (menu_bar, accel_group); +#ifdef MAC_INTEGRATION + gtkosx_application_sync_menubar (theApp); + g_signal_connect (menu_bar, "can-activate-accel", + G_CALLBACK(can_activate_cb), NULL); + g_object_unref (theApp); + theApp = NULL; +#endif + recnData->simple_action_group = g_simple_action_group_new (); g_action_map_add_action_entries (G_ACTION_MAP(recnData->simple_action_group),