Add default menubar and toolbar items for OS X. Prevent preferences from being added to the menubar twice which causes a segfault on OS X.

This commit is contained in:
John Schember 2011-04-08 20:40:10 -04:00
parent 87be713558
commit f7ca790c90
2 changed files with 34 additions and 12 deletions

View File

@ -13,7 +13,7 @@ from PyQt4.Qt import QVariant, QFileInfo, QObject, SIGNAL, QBuffer, Qt, \
ORG_NAME = 'KovidsBrain' ORG_NAME = 'KovidsBrain'
APP_UID = 'libprs500' APP_UID = 'libprs500'
from calibre.constants import islinux, iswindows, isfreebsd, isfrozen from calibre.constants import islinux, iswindows, isfreebsd, isfrozen, isosx
from calibre.utils.config import Config, ConfigProxy, dynamic, JSONConfig from calibre.utils.config import Config, ConfigProxy, dynamic, JSONConfig
from calibre.utils.localization import set_qt_translator from calibre.utils.localization import set_qt_translator
from calibre.ebooks.metadata.meta import get_metadata, metadata_from_formats from calibre.ebooks.metadata.meta import get_metadata, metadata_from_formats
@ -23,25 +23,45 @@ from calibre.utils.date import UNDEFINED_DATE
# Setup gprefs {{{ # Setup gprefs {{{
gprefs = JSONConfig('gui') gprefs = JSONConfig('gui')
gprefs.defaults['action-layout-menubar'] = () if isosx:
gprefs.defaults['action-layout-menubar'] = (
gprefs.defaults['action-layout-menubar-device'] = () 'Add Books', 'Edit Metadata', 'Convert Books',
'Choose Library', 'Save To Disk', 'Preferences',
gprefs.defaults['action-layout-toolbar'] = ( 'Help',
)
gprefs.defaults['action-layout-menubar-device'] = (
'Add Books', 'Edit Metadata', 'Convert Books',
'Location Manager', 'Location Manager',
'Send To Device', 'Preferences', 'Help',
)
gprefs.defaults['action-layout-toolbar'] = (
'Add Books', 'Edit Metadata', None, 'Convert Books', 'View', None,
'Choose Library', 'Donate', None, 'Fetch News', 'Save To Disk',
'Connect Share', None, 'Remove Books',
)
gprefs.defaults['action-layout-toolbar-device'] = (
'Add Books', 'Edit Metadata', None, 'Convert Books', 'View',
'Send To Device', None, None, 'Location Manager', None, None,
'Fetch News', 'Save To Disk', 'Connect Share', None,
'Remove Books',
)
else:
gprefs.defaults['action-layout-menubar'] = ()
gprefs.defaults['action-layout-menubar-device'] = ()
gprefs.defaults['action-layout-toolbar'] = (
'Add Books', 'Edit Metadata', None, 'Convert Books', 'View', None, 'Add Books', 'Edit Metadata', None, 'Convert Books', 'View', None,
'Choose Library', 'Donate', None, 'Fetch News', 'Save To Disk', 'Choose Library', 'Donate', None, 'Fetch News', 'Save To Disk',
'Connect Share', None, 'Remove Books', None, 'Help', 'Preferences', 'Connect Share', None, 'Remove Books', None, 'Help', 'Preferences',
) )
gprefs.defaults['action-layout-toolbar-device'] = (
gprefs.defaults['action-layout-toolbar-child'] = ()
gprefs.defaults['action-layout-toolbar-device'] = (
'Add Books', 'Edit Metadata', None, 'Convert Books', 'View', 'Add Books', 'Edit Metadata', None, 'Convert Books', 'View',
'Send To Device', None, None, 'Location Manager', None, None, 'Send To Device', None, None, 'Location Manager', None, None,
'Fetch News', 'Save To Disk', 'Connect Share', None, 'Fetch News', 'Save To Disk', 'Connect Share', None,
'Remove Books', None, 'Help', 'Preferences', 'Remove Books', None, 'Help', 'Preferences',
) )
gprefs.defaults['action-layout-toolbar-child'] = ()
gprefs.defaults['action-layout-context-menu'] = ( gprefs.defaults['action-layout-context-menu'] = (
'Edit Metadata', 'Send To Device', 'Save To Disk', 'Edit Metadata', 'Send To Device', 'Save To Disk',
'Connect Share', 'Copy To Library', None, 'Connect Share', 'Copy To Library', None,

View File

@ -298,10 +298,12 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
# Ensure preferences are showing in either the toolbar or # Ensure preferences are showing in either the toolbar or
# the menubar. # the menubar.
pref_in_toolbar = self.models['toolbar'][1].has_action('Preferences') pref_in_toolbar = self.models['toolbar'][1].has_action('Preferences')
pref_in_menubar = self.models['menubar'][1].has_action('Preferences')
lm_in_toolbar = self.models['toolbar-device'][1].has_action('Location Manager') lm_in_toolbar = self.models['toolbar-device'][1].has_action('Location Manager')
if not pref_in_toolbar: lm_in_menubar = self.models['menubar-device'][1].has_action('Location Manager')
if not pref_in_toolbar and not pref_in_menubar:
self.models['menubar'][1].add(['Preferences']) self.models['menubar'][1].add(['Preferences'])
if not lm_in_toolbar: if not lm_in_toolbar and not lm_in_menubar:
self.models['menubar-device'][1].add(['Location Manager']) self.models['menubar-device'][1].add(['Location Manager'])
# Save data. # Save data.