diff --git a/src/calibre/gui2/__init__.py b/src/calibre/gui2/__init__.py index 726e711107..214ce90f91 100644 --- a/src/calibre/gui2/__init__.py +++ b/src/calibre/gui2/__init__.py @@ -872,6 +872,8 @@ class Application(QApplication): QApplication.setDesktopFileName(override_program_name) QApplication.setAttribute(Qt.AA_ShareOpenGLContexts, True) # needed for webengine QApplication.__init__(self, qargs) + if isosx: + plugins['cocoa'][0].disable_cocoa_ui_elements() self.setAttribute(Qt.AA_UseHighDpiPixmaps) self.setAttribute(Qt.AA_SynthesizeTouchForUnhandledMouseEvents, False) try: diff --git a/src/calibre/utils/cocoa.m b/src/calibre/utils/cocoa.m index ed228bed3c..41f8fa4bd9 100644 --- a/src/calibre/utils/cocoa.m +++ b/src/calibre/utils/cocoa.m @@ -5,10 +5,29 @@ * Distributed under terms of the GPL3 license. */ +#import +#import +#import -#include #include +void +disable_window_tabbing(void) { + if ([NSWindow respondsToSelector:@selector(allowsAutomaticWindowTabbing)]) + NSWindow.allowsAutomaticWindowTabbing = NO; +} + +void +remove_cocoa_menu_items(void) { + // Remove (disable) the "Start Dictation..." and "Emoji & Symbols" menu + // items from the "Edit" menu + [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"NSDisabledDictationMenuItem"]; + [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"NSDisabledCharacterPaletteMenuItem"]; + + // Remove (don't have) the "Enter Full Screen" menu item from the "View" menu + [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"NSFullScreenMenuItemEverywhere"]; +} + void activate_cocoa_multithreading(void) { if (![NSThread isMultiThreaded]) [[NSThread new] start]; diff --git a/src/calibre/utils/cocoa_wrapper.c b/src/calibre/utils/cocoa_wrapper.c index 5f68e313e1..31ead5da7f 100644 --- a/src/calibre/utils/cocoa_wrapper.c +++ b/src/calibre/utils/cocoa_wrapper.c @@ -11,6 +11,8 @@ extern double cocoa_cursor_blink_time(void); extern void cocoa_send_notification(const char *identitifer, const char *title, const char *subtitle, const char *informativeText, const char* path_to_image); extern const char* cocoa_send2trash(const char *utf8_path); extern void activate_cocoa_multithreading(void); +extern void disable_window_tabbing(void); +extern void remove_cocoa_menu_items(void); static PyObject *notification_activated_callback = NULL; @@ -70,11 +72,23 @@ enable_cocoa_multithreading(PyObject *self, PyObject *args) { Py_RETURN_NONE; } +static PyObject* +disable_cocoa_ui_elements(PyObject *self, PyObject *args) { + PyObject *tabbing = Py_True, *menu_items = Py_True; + if (!PyArg_ParseTuple(args, "|OO", &tabbing, &menu_items)) return NULL; + if (PyObject_IsTrue(tabbing)) disable_window_tabbing(); + if (PyObject_IsTrue(menu_items) remove_cocoa_menu_items(); + Py_RETURN_NONE; +} + + + static PyMethodDef module_methods[] = { {"cursor_blink_time", (PyCFunction)cursor_blink_time, METH_NOARGS, ""}, {"enable_cocoa_multithreading", (PyCFunction)enable_cocoa_multithreading, METH_NOARGS, ""}, {"set_notification_activated_callback", (PyCFunction)set_notification_activated_callback, METH_O, ""}, {"send_notification", (PyCFunction)send_notification, METH_VARARGS, ""}, + {"disable_cocoa_ui_elements", (PyCFunction)disable_cocoa_ui_elements, METH_VARARGS, ""}, {"send2trash", (PyCFunction)send2trash, METH_VARARGS, ""}, {NULL, NULL, 0, NULL} /* Sentinel */ };