def onAppStarted(self): """ Real initialization function, called when this module has been loaded """ self.window = prefs.getWidgetsTree().get_object('win-main') # Current player status self.paused = False self.currTrack = None
def onAppStarted(self): """ Real initialization function, called when this module has been loaded """ self.currTrackLength = 0 # Widgets wTree = prefs.getWidgetsTree() self.btnPlay = wTree.get_object('btn-play') self.btnNext = wTree.get_object('btn-next') self.btnPrev = wTree.get_object('btn-previous') self.sclSeek = wTree.get_object('scl-position') # GTK handlers self.btnNext.connect( 'clicked', lambda widget: modules.postMsg(consts.MSG_CMD_NEXT)) self.btnPrev.connect( 'clicked', lambda widget: modules.postMsg(consts.MSG_CMD_PREVIOUS)) self.btnPlay.connect( 'clicked', lambda widget: modules.postMsg(consts.MSG_CMD_TOGGLE_PAUSE)) self.sclSeek.connect('change-value', self.onSeekChangingValue) self.sclSeek.connect('value-changed', self.onSeekValueChanged) self.sclSeek.hide() # Add preferences button. preferences_img = Gtk.Image.new_from_icon_name( 'preferences-system', Gtk.IconSize.SMALL_TOOLBAR) preferences_button = Gtk.ToolButton.new(preferences_img, None) toolbar_hbox = wTree.get_object('hbox4') toolbar_hbox.pack_end(preferences_button, False, False, 0) # Move button to the right. toolbar_hbox.reorder_child(preferences_button, 0) preferences_button.connect('clicked', lambda item: modules.showPreferences()) preferences_button.show_all()
def onAppStarted(self): """ The module has been loaded """ self.tree = None self.cfgWin = None self.scrolled = Gtk.ScrolledWindow() self.treeState = prefs.get(__name__, 'saved-states', None) self.scrolled.set_shadow_type(Gtk.ShadowType.IN) self.scrolled.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) self.scrolled.show() left_vbox = prefs.getWidgetsTree().get_object('vbox3') left_vbox.pack_start(self.scrolled, True, True, 0) self.static_paths = ['/', consts.dirBaseUsr] self.displaying_results = False self.populate_tree() music_paths = self.get_music_paths_from_tree() modules.postMsg(consts.MSG_EVT_MUSIC_PATHS_CHANGED, {'paths': music_paths}) self.tree.connect('drag-begin', self.onDragBegin)
def on_add_dir(self, widget): parent = prefs.getWidgetsTree().get_object('win-main') path = fileChooser.openDirectory(parent, _('Choose a directory')) if path is None: return if os.path.isdir(path): if path in self.static_paths: errorMsgBox( None, _('Invalid Folder'), _('You cannot add your root or home folder to the music directories' )) return self.add_dir(path) music_paths = self.get_music_paths_from_tree() modules.postMsg(consts.MSG_EVT_MUSIC_PATHS_CHANGED, {'paths': music_paths}) self.set_info_text() else: errorMsgBox( None, _('This path does not exist'), '"%s"\n' % path + _('Please select an existing directory.'))
def RaiseWindow(self): """ Raises the window """ prefs.getWidgetsTree().get_object('win-main').present()