mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-08 15:54:57 +01:00
use new GDK modal notification to (try to) desensitize global app menu items
This commit is contained in:
parent
b544ac832c
commit
ce6a2d73d8
1 changed files with 32 additions and 3 deletions
|
|
@ -41,10 +41,13 @@
|
||||||
#import <Foundation/NSString.h>
|
#import <Foundation/NSString.h>
|
||||||
#import <Foundation/NSNotification.h>
|
#import <Foundation/NSNotification.h>
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#define UNUSED_PARAMETER(a) (void) (a)
|
#define UNUSED_PARAMETER(a) (void) (a)
|
||||||
|
|
||||||
// #define DEBUG(format, ...) g_printerr ("%s: " format, G_STRFUNC, ## __VA_ARGS__)
|
#define DEBUG(format, ...) g_printerr ("%s: " format, G_STRFUNC, ## __VA_ARGS__)
|
||||||
#define DEBUG(format, ...)
|
//#define DEBUG(format, ...)
|
||||||
|
|
||||||
/* TODO
|
/* TODO
|
||||||
*
|
*
|
||||||
|
|
@ -56,6 +59,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static gint _exiting = 0;
|
static gint _exiting = 0;
|
||||||
|
static std::vector<GtkMenuItem*> global_menu_items;
|
||||||
|
|
||||||
static guint
|
static guint
|
||||||
gdk_quartz_keyval_to_ns_keyval (guint keyval)
|
gdk_quartz_keyval_to_ns_keyval (guint keyval)
|
||||||
|
|
@ -1092,6 +1096,11 @@ add_menu_item (NSMenu* cocoa_menu, GtkWidget* menu_item, int index)
|
||||||
cocoa_menu_item_update_submenu (cocoa_item, menu_item);
|
cocoa_menu_item_update_submenu (cocoa_item, menu_item);
|
||||||
|
|
||||||
[ cocoa_item release];
|
[ cocoa_item release];
|
||||||
|
|
||||||
|
if (GTK_IS_CHECK_MENU_ITEM (menu_item)) {
|
||||||
|
GtkMenuItem* mitem = GTK_MENU_ITEM(menu_item);
|
||||||
|
global_menu_items.push_back (mitem);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
@ -1448,12 +1457,32 @@ namespace Gtk {
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
static void
|
||||||
|
gdk_quartz_modal_notify (GdkWindow*, gboolean modal)
|
||||||
|
{
|
||||||
|
for (auto & mitem : global_menu_items) {
|
||||||
|
|
||||||
|
GNSMenuItem *cocoa_item;
|
||||||
|
cocoa_item = cocoa_menu_item_get (GTK_WIDGET(mitem));
|
||||||
|
|
||||||
|
if (cocoa_item) {
|
||||||
|
[cocoa_item setEnabled:!modal];
|
||||||
|
}
|
||||||
|
|
||||||
|
GtkAction* act = gtk_activatable_get_related_action (GTK_ACTIVATABLE(mitem));
|
||||||
|
if (act) {
|
||||||
|
gtk_action_set_sensitive (act, !modal);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Basic setup */
|
/* Basic setup */
|
||||||
|
|
||||||
extern "C" int
|
extern "C" int
|
||||||
gtk_application_init ()
|
gtk_application_init ()
|
||||||
{
|
{
|
||||||
|
gdk_window_set_modal_notify (gdk_quartz_modal_notify);
|
||||||
|
|
||||||
_main_menubar = [[NSMenu alloc] initWithTitle: @""];
|
_main_menubar = [[NSMenu alloc] initWithTitle: @""];
|
||||||
|
|
||||||
if (!_main_menubar)
|
if (!_main_menubar)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue