[Users] [PATCH 4/8] osx: make sure that dialog windows are menu-less

Igor Mammedov imammedo at redhat.com
Tue Jan 20 22:14:38 CET 2015


on linux, when modal dialog is opened application menu shortcuts
are not active and user can type characters even if they are
menu shortcuts.
However on OSX it's not so and if shortcut is a normal character
that user tries to type into input field of dialog window,
keystroke will be intercepted by menu and result in connected action.

To fix issue assign empty menu when creating toplevel windows so that
menu-less dialogs wouldn't have any menu/accelerators by default to
avoid issue.
Windows that have a dedicater menu install it after gtkut_window_new(),
so initial empty menu is replaced explicitly for them later
(mainwindow, compose, addressbook)

Signed-off-by: Igor Mammedov <imammedo at redhat.com>
---
 src/account.c      | 1 +
 src/cm_osx.c       | 8 ++++++++
 src/cm_osx.h       | 2 ++
 src/gtk/gtkutils.c | 2 ++
 src/gtk/gtkutils.h | 1 +
 5 files changed, 14 insertions(+)

diff --git a/src/account.c b/src/account.c
index 2d79c41..911819f 100644
--- a/src/account.c
+++ b/src/account.c
@@ -54,6 +54,7 @@
 #include "filtering.h"
 #include "prefs_actions.h"
 #include "hooks.h"
+#include "cm_osx.h"
 
 enum {
 	ACCOUNT_IS_DEFAULT,
diff --git a/src/cm_osx.c b/src/cm_osx.c
index 6e9804e..983a41b 100644
--- a/src/cm_osx.c
+++ b/src/cm_osx.c
@@ -19,3 +19,11 @@ void claws_mail_osx_set_menu(GtkWidget *menu)
 	gtk_widget_hide (menu);
 	gtkosx_application_set_menu_bar(theApp, GTK_MENU_SHELL(menu));
 }
+
+void claws_mail_osx_set_empty_menu(GtkWidget *window)
+{
+	GtkWidget *empty_menu = gtk_menu_bar_new();
+	gtk_widget_set_parent(empty_menu, window);
+
+	claws_mail_osx_set_menu(empty_menu);
+}
diff --git a/src/cm_osx.h b/src/cm_osx.h
index c763eba..485e7b8 100644
--- a/src/cm_osx.h
+++ b/src/cm_osx.h
@@ -5,9 +5,11 @@
 #ifdef MAC_INTEGRATION
 void claws_mail_osx_init(GtkWidget *window);
 void claws_mail_osx_set_menu(GtkWidget *menu);
+void claws_mail_osx_set_empty_menu(GtkWidget *window);
 #else
 static inline void claws_mail_osx_init(GtkWidget *window) {}
 static inline void claws_mail_osx_set_menu(GtkWidget *menu) {}
+static inline void claws_mail_osx_set_empty_menu(GtkWidget *window) {}
 #endif
 
 #endif
diff --git a/src/gtk/gtkutils.c b/src/gtk/gtkutils.c
index 8cdbd72..b2ea708 100644
--- a/src/gtk/gtkutils.c
+++ b/src/gtk/gtkutils.c
@@ -59,6 +59,7 @@
 #include "manage_window.h"
 #include "manual.h"
 #include "combobox.h"
+#include "cm_osx.h"
 
 gboolean gtkut_get_font_size(GtkWidget *widget,
 			     gint *width, gint *height)
@@ -1537,6 +1538,7 @@ GtkWidget *gtkut_window_new		(GtkWindowType	 type,
 {
 	GtkWidget *window = gtk_window_new(type);
 	gtk_window_set_role(GTK_WINDOW(window), class);
+	claws_mail_osx_set_empty_menu(window);
 	return window;
 }
 
diff --git a/src/gtk/gtkutils.h b/src/gtk/gtkutils.h
index 39a8a32..425a1cd 100644
--- a/src/gtk/gtkutils.h
+++ b/src/gtk/gtkutils.h
@@ -33,6 +33,7 @@
 #endif
 
 #include "gtkcmctree.h"
+#include "cm_osx.h"
 
 #ifndef GDK_KEY_Escape
 #include "gdkkeysyms-new.h"
-- 
1.9.3 (Apple Git-50)




More information about the Users mailing list