コード例 #1
0
ファイル: AppDelegate.py プロジェクト: JulianEberius/minispot
 def focusSearchWindow_(self, sender):
     if self.search_window.isKeyWindow():
         NSApp.hide_(None)
     else:
         NSApp.arrangeInFront_(None)
         self.search_window.makeKeyAndOrderFront_(None)
         NSApp.activateIgnoringOtherApps_(True)
         self.search_window.makeFirstResponder_(self.search_box)
コード例 #2
0
ファイル: AppDelegate.py プロジェクト: JulianEberius/minispot
    def awakeFromNib(self):
        self.state = "album_browsing"
        self.selected_album = None
        self.selected_album_details = None
        self.track_names = []
        self.img_cache = {}
        self.result = []
        self.last_query = None

        # configuration
        self.config = {}
        config_path = abspath(expanduser("~/.minispot"))
        if isfile(config_path):
            with open(config_path) as conf_file:
                self.config = json.load(conf_file)
        else:
            with open(config_path, "w") as conf_file:
                json.dump(self.config, conf_file, indent=4)

        # ui setup
        self._initStatusBarItem()
        self._initTableView()
        NSApp.hide_(None)

        # spotify
        self.spotify = Spotify.alloc().init()
        logged_in = self.spotify.login_saved_credentials()
        if not logged_in:
            self.display_login_window()

        self.addObserver_forKeyPath_options_context_(self, "spotify.login_state", 0, None)
        self.addObserver_forKeyPath_options_context_(self, "spotify.current_track", 0, None)

        # hotkeys
        self.hotkey = hotkeys.register_key_from_string("alt+ctrl+f", self, "focusSearchWindow:")
        self.hotkey = hotkeys.register_key_from_string("alt+ctrl+x", self, "exit:")
        self.hotkey = hotkeys.register_key_from_string("alt+ctrl+n", self, "nextTrack:")
        self.hotkey = hotkeys.register_key_from_string("alt+ctrl+r", self, "previousTrack:")
        self.hotkey = hotkeys.register_key_from_string("alt+ctrl+p", self, "togglePause:")