def help(constructor, identity, style, flags, aemreference, commandname=''): id = (constructor, identity, style) if id not in _cache: if constructor == 'path': appobj = appscript.app(identity) elif constructor == 'pid': appobj = appscript.app(pid=identity) elif constructor == 'url': appobj = appscript.app(url=identity) elif constructor == 'aemapp': appobj = appscript.app(aemapp=aem.Application(desc=identity)) elif constructor == 'current': appobj = appscript.app() else: raise RuntimeError, 'Unknown constructor: %r' % constructor output = StringIO() helpobj = Help(appobj, style, output) _cache[id] = (appobj, helpobj, output) ref, helpobj, output = _cache[id] output.truncate(0) if aemreference is not None: ref = ref.AS_newreference(aemreference) if commandname: ref = getattr(ref, commandname) helpobj.help(flags, ref) s = output.getvalue() if NSUserDefaults.standardUserDefaults().boolForKey_(u'enableLineWrap'): res = [] textwrapper = textwrap.TextWrapper(width=NSUserDefaults.standardUserDefaults().integerForKey_(u'lineWrap'), subsequent_indent=' ' * 12) for line in s.split('\n'): res.append(textwrapper.fill(line)) s = u'\n'.join(res) return s
def interfaceStyle(): '''Returns "dark" if using Dark Mode, otherwise "light"''' # running under Mojave or later or undocumented pref is set if (int(os.uname()[2].split('.')[0]) >= 18 or NSUserDefaults.standardUserDefaults().boolForKey_("AllowDarkModeOnUnsupportedOSes")): interfaceType = NSUserDefaults.standardUserDefaults().stringForKey_("AppleInterfaceStyle") if interfaceType == "Dark": return "dark" return "light"
def awakeFromNib(self): # Initialise our session and selected state parameters self.session = None self.columns = [[]] self.selectedResource = None self.selectedDetails = None self.selectedData = None # Cache some useful icons self.fileImage = NSWorkspace.sharedWorkspace().iconForFileType_( NSPlainFileType) self.fileImage.setSize_(NSSize(16, 16)) self.directoryImage = NSWorkspace.sharedWorkspace().iconForFile_( "/usr/") self.directoryImage.setSize_(NSSize(16, 16)) # Initialise the toolbar self._toolbarItems = {} self._toolbarDefaultItemIdentifiers = [] self._toolbarAllowedItemIdentifiers = [] self.createToolbar() # Set up browser view container = self.mainSplitterView.subviews()[0] container.addSubview_(self.columnView) container.addSubview_(self.listView) self.currentBrowserView = None self.setBrowserView(self.BROWSERVIEW_COLUMNS) self.browser.setMaxVisibleColumns_(7) self.browser.setMinColumnWidth_(150) # Set up data view container = self.mainSplitterView.subviews()[1] container.addSubview_(self.propertiesView) container.addSubview_(self.dataView) self.currentDataView = None self.setDataView(self.DATAVIEW_PROPERTIES) self.text.setString_("") self.pathLabel.setStringValue_("No server specified") # Get preferences lastServer = NSUserDefaults.standardUserDefaults().stringForKey_( "LastServer") if lastServer and len(lastServer): self.serverText.setStringValue_(lastServer) lastPath = NSUserDefaults.standardUserDefaults().stringForKey_( "LastPath") if lastPath and len(lastPath): self.pathText.setStringValue_(lastPath) else: self.pathText.setStringValue_("/") lastUser = NSUserDefaults.standardUserDefaults().stringForKey_( "LastUser") if lastUser and len(lastUser): self.userText.setStringValue_(lastUser)
def _load_defaults(self): if not hasattr(build_number, 'frozen'): debugging = objc.YES self.exceptiondelegate = PyObjCExceptionDelegate.alloc().init() NSExceptionHandler.defaultExceptionHandler().setExceptionHandlingMask_(NSLogAndHandleEveryExceptionMask) NSExceptionHandler.defaultExceptionHandler().setDelegate_(self.exceptiondelegate) else: debugging = objc.NO if self.using_xui: NSUserDefaults.standardUserDefaults().registerDefaults_({'WebKitDeveloperExtras': debugging})
def init(): if not NSUserDefaults.standardUserDefaults().integerForKey_(u'lineWrap'): NSUserDefaults.standardUserDefaults().setInteger_forKey_( 78, u'lineWrap') aemreceive.installeventhandler( help, 'AppSHelp', ('Cons', 'constructor', aem.kae.typeChar), ('Iden', 'identity', aem.kae.typeWildCard), ('Styl', 'style', aem.kae.typeChar), ('Flag', 'flags', aem.kae.typeChar), ('aRef', 'aemreference', aem.kae.typeWildCard), ('CNam', 'commandname', aem.kae.typeChar))
def init(): if not NSUserDefaults.standardUserDefaults().integerForKey_(u'lineWrap'): NSUserDefaults.standardUserDefaults().setInteger_forKey_(78, u'lineWrap') aemreceive.installeventhandler(help, 'AppSHelp', ('Cons', 'constructor', aem.kae.typeChar), ('Iden', 'identity', aem.kae.typeWildCard), ('Styl', 'style', aem.kae.typeChar), ('Flag', 'flags', aem.kae.typeChar), ('aRef', 'aemreference', aem.kae.typeWildCard), ('CNam', 'commandname', aem.kae.typeChar) )
def awakeFromNib(self): # Initialise our session and selected state parameters self.session = None self.columns = [[]] self.selectedResource = None self.selectedDetails = None self.selectedData = None # Cache some useful icons self.fileImage = NSWorkspace.sharedWorkspace().iconForFileType_(NSPlainFileType) self.fileImage.setSize_(NSSize(16, 16)) self.directoryImage = NSWorkspace.sharedWorkspace().iconForFile_("/usr/") self.directoryImage.setSize_(NSSize(16, 16)) # Initialise the toolbar self._toolbarItems = {} self._toolbarDefaultItemIdentifiers = [] self._toolbarAllowedItemIdentifiers = [] self.createToolbar() # Set up browser view container = self.mainSplitterView.subviews()[0] container.addSubview_(self.columnView) container.addSubview_(self.listView) self.currentBrowserView = None self.setBrowserView(self.BROWSERVIEW_COLUMNS) self.browser.setMaxVisibleColumns_(7) self.browser.setMinColumnWidth_(150) # Set up data view container = self.mainSplitterView.subviews()[1] container.addSubview_(self.propertiesView) container.addSubview_(self.dataView) self.currentDataView = None self.setDataView(self.DATAVIEW_PROPERTIES) self.text.setString_("") self.pathLabel.setStringValue_("No server specified") # Get preferences lastServer = NSUserDefaults.standardUserDefaults().stringForKey_("LastServer") if lastServer and len(lastServer): self.serverText.setStringValue_(lastServer) lastPath = NSUserDefaults.standardUserDefaults().stringForKey_("LastPath") if lastPath and len(lastPath): self.pathText.setStringValue_(lastPath) else: self.pathText.setStringValue_("/") lastUser = NSUserDefaults.standardUserDefaults().stringForKey_("LastUser") if lastUser and len(lastUser): self.userText.setStringValue_(lastUser)
def initWithTrayIcon_usingXUI_(self, tray_icon, using_xui): self = super(TrayIconView, self).init() if self is None: return try: defaults = NSUserDefaults.standardUserDefaults() if defaults.boolForKey_('NSGrayBackground'): defaults.setBool_forKey_(0, 'NSGrayBackground') assert not defaults.boolForKey_('NSGrayBackground'), "User has NSGrayBackground set in their defaults, and changing it didn't work" except Exception: unhandled_exc_handler() try: self.canDisplayBadgeCount = using_xui self.badgeCount = 0 self.shouldDrawAttentionRequest = False self.setupImages() self.setupLayers() self.tray_icon = tray_icon self.tray_icon_has_images = True self.menu_is_visible = False self.flashing_state = None self.flash_timer = None self.busy_timer = None self._menu = None self.updateIcon_(TrayController.CONNECTING) self.updateMenu_(()) try: self.status_item = NSStatusBar.systemStatusBar().statusItemWithLength_(self.desiredWidth()) except Exception: try: defaults = NSUserDefaults.standardUserDefaults() except Exception: unhandled_exc_handler() else: if defaults.boolForKey_('NSGrayBackground'): raise Exception("User has NSGrayBackground set in their defaults (and we couldn't fix it to not affect the NSStatusItem)") else: raise unhandled_exc_handler() else: self.status_item.setView_(self) NSNotificationCenter.defaultCenter().addObserver_selector_name_object_(self, self.windowDidMove_, NSWindowDidMoveNotification, self.window()) except Exception: self.tray_icon_has_images = False unhandled_exc_handler() return self
def initialize(cls): # Register ourselves as a Mail.app plugin and add an entry for our # 'Fill Text' and Wrap Text' actions to the Edit menu. application = NSApplication.sharedApplication() bundle = NSBundle.bundleWithIdentifier_('uk.me.cdw.MailWrap') cls.registerBundle() editmenu = application.mainMenu().itemAtIndex_(2).submenu() editmenu.addItem_(NSMenuItem.separatorItem()) mask = NSCommandKeyMask | NSAlternateKeyMask editmenu.addItemWithTitle_action_keyEquivalent_('Fill Text', 'fillText', '\\').setKeyEquivalentModifierMask_(mask) mask = NSCommandKeyMask editmenu.addItemWithTitle_action_keyEquivalent_('Wrap Text', 'wrapText', "\\").setKeyEquivalentModifierMask_(mask) # Read our configuration settings if present. Otherwise, set the # correct default values. defaults = NSUserDefaults.standardUserDefaults() defaults = defaults.dictionaryForKey_('MailWrap') or {} ComposeViewController._fixAttribution = defaults.get('FixAttribution', False) EditingMessageWebView._bulletLists = defaults.get('BulletLists', True) EditingMessageWebView._indentWidth = int(defaults.get('IndentWidth', 2)) EditingMessageWebView._wrapWidth = int(defaults.get('WrapWidth', 72)) # Report the plugin name and version to the com.apple.mail log. version = bundle.objectForInfoDictionaryKey_('CFBundleVersion') NSLog('Loaded MailWrap %s' % version)
def initialize(cls): # Register ourselves as a Mail.app plugin and add an entry for our # 'Fill Text' and Wrap Text' actions to the Edit menu. application = NSApplication.sharedApplication() bundle = NSBundle.bundleWithIdentifier_('uk.me.cdw.MailWrap') cls.registerBundle() editmenu = application.mainMenu().itemAtIndex_(2).submenu() editmenu.addItem_(NSMenuItem.separatorItem()) mask = NSCommandKeyMask editmenu.addItemWithTitle_action_keyEquivalent_( 'Fill Text', 'fillText', '\\').setKeyEquivalentModifierMask_(mask) mask = NSCommandKeyMask | NSAlternateKeyMask editmenu.addItemWithTitle_action_keyEquivalent_( 'Wrap Text', 'wrapText', '\\').setKeyEquivalentModifierMask_(mask) # Read our configuration settings if present. Otherwise, set the # correct default values. defaults = NSUserDefaults.standardUserDefaults() defaults = defaults.dictionaryForKey_('MailWrap') or {} ComposeViewController._fixAttribution = defaults.get( 'FixAttribution', True) EditingMessageWebView._bulletLists = defaults.get('BulletLists', True) EditingMessageWebView._indentWidth = int(defaults.get( 'IndentWidth', 2)) EditingMessageWebView._wrapWidth = int(defaults.get('WrapWidth', 76)) # Report the plugin name and version to the com.apple.mail log. version = bundle.objectForInfoDictionaryKey_('CFBundleVersion') NSLog('Loaded MailWrap %s' % version)
def __init__(self, version, updater): # set version self.version = version # set updater self.updater = updater # keep state of 'toggle key' self.toggle_key_active = False # read user defaults (preferences) self.prefs = NSUserDefaults.standardUserDefaults() # register some default values self.prefs.registerDefaults_( dict(MailTrackOption=True, MailTrackEnableDebugging=False, MailTrackDisabled=False)) # set log level logger.setLevel(self.is_debugging and logger.DEBUG or logger.WARNING) logger.debug('debug logging active') # add menu item for quick enable/disable Menu.alloc().initWithApp_(self).inject() # check update interval self.check_update_interval = self.prefs.int[ "MailTrackCheckUpdateInterval"] or 0 # check if we're running in a different Mail version as before self.check_version()
def __init__(self, version, updater): # set version self.version = version # set updater self.updater = updater # keep state of 'toggle key' self.toggle_key_active = False # read user defaults (preferences) self.prefs = NSUserDefaults.standardUserDefaults() # register some default values self.prefs.registerDefaults_(dict( QuoteFixFixReply = True, QuoteFixFixReplyAll = True, QuoteFixFixForward = True, QuoteFixFixDraft = False, QuoteFixFixNewMessage = False, )) # set log level logger.setLevel(self.is_debugging and logger.DEBUG or logger.WARNING) logger.debug('debug logging active') # add menu item for quick enable/disable Menu.alloc().initWithApp_(self).inject() # check update interval self.check_update_interval = self.prefs.int["QuoteFixCheckUpdateInterval"] or 0 # check if we're running in a different Mail version as before self.check_version()
def __setup(self, defaultsPlistName=None): NSUserDefaults.resetStandardUserDefaults() prefs = NSUserDefaults.standardUserDefaults() self.defaults = self.__defaults(defaultsPlistName) domain_data = prefs.persistentDomainForName_(self.__bundleID) if domain_data: self.data = domain_data else: self.data = NSDictionary.dictionary()
def __setup(self, defaultsPlistName=None): NSUserDefaults.resetStandardUserDefaults() prefs = NSUserDefaults.standardUserDefaults() self.defaults = self.__defaults(defaultsPlistName) domainData = prefs.persistentDomainForName_(self.__bundleID) if domainData: self.data = domainData else: self.data = NSDictionary.dictionary()
def applicationDidFinishLaunching_(self, aNotification): d = {'StderrColor': NSArchiver.archivedDataWithRootObject_(NSColor.redColor()), 'StdoutColor': NSArchiver.archivedDataWithRootObject_(NSColor.blueColor()), 'CodeColor': NSArchiver.archivedDataWithRootObject_(NSColor.blackColor()), } defaults = NSUserDefaults.standardUserDefaults() defaults.registerDefaults_(d) self.textView.setFont_(self.font()) self._stderrColor = NSUnarchiver.unarchiveObjectWithData_(defaults['StderrColor']) self._stdoutColor = NSUnarchiver.unarchiveObjectWithData_(defaults['StdoutColor']) self._codeColor = NSUnarchiver.unarchiveObjectWithData_(defaults['CodeColor']) self._executeWithRedirectedIO_args_kwds_(self._interp, (), {})
def startupOKAction_(self, btn): """ User clicked OK in the server setup sheet. """ # Create the actual session. server = self.serverText.stringValue() path = self.pathText.stringValue() user = self.userText.stringValue() pswd = self.passwordText.stringValue() self.session = Session(server, path, user, pswd, logging=False) self.window.setTitle_(self.serverText.stringValue()) self.pathLabel.setStringValue_(self.session.path) NSUserDefaults.standardUserDefaults().setObject_forKey_(server, "LastServer") NSUserDefaults.standardUserDefaults().setObject_forKey_(path, "LastPath") NSUserDefaults.standardUserDefaults().setObject_forKey_(user, "LastUser") # List the root resource. self.progress.startAnimation_(self) resources = self.session.getRoot().listChildren() self.progress.stopAnimation_(self) self.columns = [resources] # Done with the sheet. self.startupSheet.close() NSApplication.sharedApplication().endSheet_(self.startupSheet) # Force reload of browser pane views. self.browser.loadColumnZero() self.list.reloadItem_(None)
def startupOKAction_(self, btn): """ User clicked OK in the server setup sheet. """ # Create the actual session. server = self.serverText.stringValue() path = self.pathText.stringValue() user = self.userText.stringValue() pswd = self.passwordText.stringValue() self.session = Session(server, path, user, pswd, logging=False) self.window.setTitle_(self.serverText.stringValue()) self.pathLabel.setStringValue_(self.session.path) NSUserDefaults.standardUserDefaults().setObject_forKey_( server, "LastServer") NSUserDefaults.standardUserDefaults().setObject_forKey_( path, "LastPath") NSUserDefaults.standardUserDefaults().setObject_forKey_( user, "LastUser") # List the root resource. self.progress.startAnimation_(self) resources = self.session.getRoot().listChildren() self.progress.stopAnimation_(self) self.columns = [resources] # Done with the sheet. self.startupSheet.close() NSApplication.sharedApplication().endSheet_(self.startupSheet) # Force reload of browser pane views. self.browser.loadColumnZero() self.list.reloadItem_(None)
def prefsSetStyle(self, sender): style = self.prefsWindow.style.getItem() self._changePref(self, 'windowStyle', style) if style == 'System': style = NSUserDefaults.standardUserDefaults().stringForKey_( 'AppleInterfaceStyle') if style == 'Dark': winAppearance = 'NSAppearanceNameVibrantDark' else: winAppearance = 'NSAppearanceNameVibrantLight' appearance = NSAppearance.appearanceNamed_(winAppearance) self.w._window.setAppearance_(appearance) self.prefsWindow._window.setAppearance_(appearance)
def save(data): data = data.copy() try: for k, v in data.iteritems(): if v is None: data[k] = "" elif k == prefs.MOVIES_DIRECTORY.key: if isinstance(v, str): data[k] = filename_type_to_os_filename(v) plist = Conversion.propertyListFromPythonCollection(data) except: print "WARNING!! Error while converting the settings dictionary to a property list:" print data raise else: domain = bundle.getBundleIdentifier() defaults = NSUserDefaults.standardUserDefaults() defaults.setPersistentDomain_forName_(plist, domain) defaults.synchronize()
def load(): domain = bundle.getBundleIdentifier() plist = NSUserDefaults.standardUserDefaults().persistentDomainForName_(domain) try: pydict = Conversion.pythonCollectionFromPropertyList(plist) except: print "WARNING!! Error while converting the preference property list to python dictionary:" print plist # Sanitize the dictionary we just got, some value might be of type which can # cause massive problems when being pickled. if pydict is not None: for k, v in pydict.iteritems(): if type(v) is objc._pythonify.OC_PythonFloat: pydict[k] = float(v) elif type(v) is objc._pythonify.OC_PythonInt: pydict[k] = int(v) elif type(v) is objc._pythonify.OC_PythonLong: pydict[k] = long(v) elif k == prefs.MOVIES_DIRECTORY.key: pydict[k] = os_filename_to_filename_type(v) return pydict
def load(): domain = bundle.getBundleIdentifier() plist = NSUserDefaults.standardUserDefaults().persistentDomainForName_( domain) try: pydict = Conversion.pythonCollectionFromPropertyList(plist) except: print "WARNING!! Error while converting the preference property list to python dictionary:" print plist # Sanitize the dictionary we just got, some value might be of type which can # cause massive problems when being pickled. if pydict is not None: for k, v in pydict.iteritems(): if type(v) is objc._pythonify.OC_PythonFloat: pydict[k] = float(v) elif type(v) is objc._pythonify.OC_PythonInt: pydict[k] = int(v) elif type(v) is objc._pythonify.OC_PythonLong: pydict[k] = long(v) elif k == prefs.MOVIES_DIRECTORY.key: pydict[k] = os_filename_to_filename_type(v) return pydict
from subprocess import Popen import textwrap import aem, appscript from aemreceive import * from osaterminology.dom import aeteparser from osaterminology.renderers import textdoc, inheritance, relationships from appscript import reference, terminology, terminologyparser __all__ = ['Help'] from AppKit import NSUserDefaults if not NSUserDefaults.standardUserDefaults().stringForKey_(u'rubyInterpreter'): NSUserDefaults.standardUserDefaults().setObject_forKey_(u'/usr/bin/ruby', u'rubyInterpreter') if not NSUserDefaults.standardUserDefaults().integerForKey_(u'lineWrap'): NSUserDefaults.standardUserDefaults().setInteger_forKey_(78, u'lineWrap') ####### # Data renderers class DefaultRenderer: def rendervalue(self, value, prettyprint=False): return prettyprint and pformat(value) or repr(value) renderreference = rendervalue
def __setitem__(self, key, value): mutableData = self.data.mutableCopy() mutableData[key] = value self.data = mutableData prefs = NSUserDefaults.standardUserDefaults() prefs.setPersistentDomain_forName_(self.data, self.__bundleID)
def Defaults(): return NSUserDefaults.standardUserDefaults()
def savePreferences(self): for key in self.preferenceKeys: if key in self.preferences: NSUserDefaults.standardUserDefaults().setObject_forKey_( self.preferences[key], "de.yanone.speedPunk.%s" % (key))
def loadPreferences(self): for key in self.preferenceKeys: value = NSUserDefaults.standardUserDefaults().objectForKey_( "de.yanone.speedPunk.%s" % (key)) self.preferences[key] = value setattr(self, key, value)
def _findrubyinterpreter(): return NSUserDefaults.standardUserDefaults().stringForKey_( u'rubyInterpreter')
def get(descriptor): if descriptor == prefs.MOVIES_DIRECTORY: return os.path.join(MOVIES_DIRECTORY_PARENT, "Miro") elif descriptor == prefs.NON_VIDEO_DIRECTORY: return os.path.expanduser('~/Desktop') elif descriptor == prefs.GETTEXT_PATHNAME: return os.path.abspath(resources.path("../locale")) elif descriptor == prefs.RUN_AT_STARTUP: defaults = NSUserDefaults.standardUserDefaults() lwdomain = defaults.persistentDomainForName_('loginwindow') lwdomain = Conversion.pythonCollectionFromPropertyList(lwdomain) if lwdomain is None: lwdomain = dict() if 'AutoLaunchedApplicationDictionary' not in lwdomain: lwdomain['AutoLaunchedApplicationDictionary'] = list() launchedApps = lwdomain['AutoLaunchedApplicationDictionary'] ourPath = NSBundle.mainBundle().bundlePath() ourEntry = None for entry in launchedApps: if entry.get('Path') == ourPath: ourEntry = entry break return ourEntry is None elif descriptor == prefs.SUPPORT_DIRECTORY: path = os.path.join(SUPPORT_DIRECTORY_PARENT, "Miro") os.environ['APPDATA'] = path # This is for the Bittorent module try: os.makedirs(path) except: pass return path elif descriptor == prefs.ICON_CACHE_DIRECTORY: return _makeSupportFilePath('icon-cache') elif descriptor == prefs.SQLITE_PATHNAME: return _makeSupportFilePath('sqlitedb') elif descriptor == prefs.LOG_PATHNAME: return _makeSupportFilePath('dtv-log') elif descriptor == prefs.DOWNLOADER_LOG_PATHNAME: return _makeSupportFilePath('dtv-downloader-log') elif descriptor == prefs.HTTP_PROXY_ACTIVE: return _getProxyInfo('HTTPEnable', 0) == 1 elif descriptor == prefs.HTTP_PROXY_HOST: return _getProxyInfo('HTTPProxy') elif descriptor == prefs.HTTP_PROXY_PORT: return _getProxyInfo('HTTPPort', 0) elif descriptor == prefs.HTTP_PROXY_IGNORE_HOSTS: return _getProxyInfo('ExceptionsList', list()) elif descriptor == prefs.HTTP_PROXY_AUTHORIZATION_USERNAME: return _getProxyAuthInfo('username') elif descriptor == prefs.HTTP_PROXY_AUTHORIZATION_PASSWORD: return _getProxyAuthInfo('password') return descriptor.default
# Creates all of MacVim document icons. import os import sys fontname = '' facename = None # http://www.macresearch.org/cocoa-scientists-part-xx-python-scriptersmeet-cocoa try: # Make us independent of sysprefs->appearance->antialias fonts smaller than... # Needs to happen before docerator is imported. from AppKit import NSUserDefaults prefs = NSUserDefaults.standardUserDefaults() prefs.setInteger_forKey_(4, 'AppleAntiAliasingThreshold') import docerator import loadfont from Foundation import NSString from AppKit import * dont_create = False except Exception, e: print e dont_create = True # most likely because we're on tiger # icon types LARGE = 0 # 512, 128, 32, 16; about 96kB SMALL = 1 # 128, 32, 16; about 36kB
def __init__(self, parent): super(QMainWindow, self).__init__(parent) uic.loadUi('ui/mainWindow.ui', self) self.play_btn.clicked.connect(self.play_btn_clicked) self.stop_btn.clicked.connect(self.stop_btn_clicked) self.fullscreen_btn.clicked.connect(self.switch_fullscreen_mode) self.volume_slider.sliderMoved.connect(self.volume_changed) self.tv_channel_list.channelActivated.connect(self.activated_channel) self.radio_channel_list.channelActivated.connect( self.activated_channel) self.video_player.playback_started.connect(self.video_playback_started) self.video_player.playback_paused.connect(self.video_playback_paused) self.video_player.playback_stopped.connect(self.video_playback_stopped) self.video_player.playback_error.connect(self.video_playback_error) self.video_player.volume_changed.connect(self.video_volume_changed) self.video_player.chromecast_available.connect( self.chromecast_available) self.video_player.chromecast_connected.connect( self.chromecast_connected) self.chlist_manager = ChannelListManager() self.chlist_manager.channel_added.connect(self.channel_added) self.chlist_manager.channellist_available.connect( self.channel_list_available) self.statusbar.addPermanentWidget(self.bottom_bar, 1) self.splitter.setStretchFactor(1, 1) self.progress_bar.hide() self.progress_label.setText(self.tr("Idle")) self.video_player.set_volume(self.volume_slider.value()) self.channellist_show_actiongroup = QActionGroup(self) self.channellist_show_actiongroup.triggered.connect( self.show_channel_list) chlist_showall_action = QAction(self.tr("All"), self.menu_show_chlist) chlist_showall_action.setCheckable(True) chlist_showall_action.setChecked(True) chlist_showall_action.setActionGroup(self.channellist_show_actiongroup) self.menu_show_chlist.addAction(chlist_showall_action) os_type = platform.system() log.info('Detected OS type: {0}'.format(os_type)) if os_type == 'Darwin': from AppKit import NSWindow, NSUserDefaults NSWindow.setAllowsAutomaticWindowTabbing_(False) NSUserDefaults.standardUserDefaults().setBool_forKey_( False, "NSFullScreenMenuItemEverywhere") self.playlist_tab_widget.setDocumentMode(True) channel_list_action = self.menubar.actions()[0].menu().actions()[0] preferences_list_action = self.menubar.actions()[0].menu().actions( )[1] self.menubar.removeAction(self.menubar.actions()[0]) channel_list_action.menu().addAction(preferences_list_action) self.menubar.insertAction(self.menubar.actions()[0], channel_list_action) self.load_settings() # Set custom icons self.play_btn.setIcon(TXIcon('icons/play-button.svg')) self.stop_btn.setIcon(TXIcon('icons/stop-button.svg')) self.fullscreen_btn.setIcon(TXIcon('icons/fullscreen.svg')) self.cast_btn.setIcon(TXIcon('icons/cast.svg')) self.cast_label_pixmap.setHidden(True) self.cast_label.setHidden(True) self.cast_btn.hide()
import aem, appscript from aemreceive import * from osaterminology.dom import aeteparser from osaterminology.renderers import textdoc, inheritance, relationships from appscript import reference, terminology, terminologyparser from rubyrenderer import RubyRenderer __all__ = ['Help'] from AppKit import NSUserDefaults if not NSUserDefaults.standardUserDefaults().integerForKey_(u'lineWrap'): NSUserDefaults.standardUserDefaults().setInteger_forKey_(78, u'lineWrap') ####### # Data renderers class PythonRenderer: def rendervalue(self, value, prettyprint=False): return prettyprint and pformat(value) or repr(value) ####### ###################################################################### # PRIVATE
def __setitem__(self, key, value): mutable_data = self.data.mutableCopy() mutable_data[key] = value self.data = mutable_data prefs = NSUserDefaults.standardUserDefaults() prefs.setPersistentDomain_forName_(self.data, self.__bundleID)
import aem, appscript from aem import kae from aemreceive import * from osaterminology.dom import aeteparser from osaterminology.renderers import textdoc, inheritance, relationships from appscript import reference, terminology, terminologyparser from rubyrenderer import RubyRenderer __all__ = ['Help'] from AppKit import NSUserDefaults if not NSUserDefaults.standardUserDefaults().integerForKey_(u'lineWrap'): NSUserDefaults.standardUserDefaults().setInteger_forKey_(78, u'lineWrap') ####### # Data renderers class PythonRenderer: def rendervalue(self, value, prettyprint=False): return prettyprint and pformat(value) or repr(value) ####### ###################################################################### # PRIVATE
def interfaceStyle(): '''Returns "dark" if using Dark Mode, otherwise "light"''' interfaceType = NSUserDefaults.standardUserDefaults().stringForKey_("AppleInterfaceStyle") if interfaceType == "Dark": return "dark" return "light"
from subprocess import Popen import textwrap import aem, appscript from aemreceive import * from osaterminology.dom import aeteparser from osaterminology.renderers import textdoc, inheritance, relationships from appscript import reference, terminology, terminologyparser __all__ = ['Help'] from AppKit import NSUserDefaults if not NSUserDefaults.standardUserDefaults().stringForKey_(u'rubyInterpreter'): NSUserDefaults.standardUserDefaults().setObject_forKey_( u'/usr/bin/ruby', u'rubyInterpreter') if not NSUserDefaults.standardUserDefaults().integerForKey_(u'lineWrap'): NSUserDefaults.standardUserDefaults().setInteger_forKey_(78, u'lineWrap') ####### # Data renderers class DefaultRenderer: def rendervalue(self, value, prettyprint=False): return prettyprint and pformat(value) or repr(value) renderreference = rendervalue
def _findrubyinterpreter(): return NSUserDefaults.standardUserDefaults().stringForKey_(u'rubyInterpreter')
# Creates all of MacVim document icons. # http://www.macresearch.org/cocoa-scientists-part-xx-python-scriptersmeet-cocoa try: # Make us independent of sysprefs->appearance->antialias fonts smaller than... # Needs to happen before docerator is imported. from AppKit import NSUserDefaults prefs = NSUserDefaults.standardUserDefaults() prefs.setInteger_forKey_(4, 'AppleAntiAliasingThreshold') import docerator # Load Envy Code R from a file and register it under its postscript name # Thanks to DamienG for this font (redistributed with permission): # http://damieng.com/blog/2008/05/26/envy-code-r-preview-7-coding-font-released import loadfont loadfont.loadfont('Envy Code R Bold.ttf') from Foundation import NSString from AppKit import * dont_create = False except: dont_create = True # most likely because we're on tiger import os import sys # icon types LARGE = 0 # 512, 128, 32, 16; about 96kB SMALL = 1 # 128, 32, 16; about 36kB
def is_dark(): return NSUserDefaults.standardUserDefaults().stringForKey_( "AppleInterfaceStyle") == "Dark"
def loadPreferences(self): for key in self.preferenceKeys: self.preferences[key] = NSUserDefaults.standardUserDefaults( ).objectForKey_("de.yanone.speedPunk.%s" % (key))