Ejemplo n.º 1
0
    def __init__(self):
        """ Constructor """
        modules.Module.__init__(self, {
                                           consts.MSG_CMD_EXPLORER_ADD:    self.onAddExplorer,
                                           consts.MSG_CMD_EXPLORER_REMOVE: self.onRemoveExplorer,
                                           consts.MSG_CMD_EXPLORER_RENAME: self.onRenameExplorer,
                                      })

        # Attributes
        self.store           = gtk.ListStore(gtk.gdk.Pixbuf, gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_INT, gobject.TYPE_BOOLEAN)
        self.combo           = prefs.getWidgetsTree().get_object('combo-explorer')
        txtRenderer          = gtk.CellRendererText()
        pixRenderer          = gtk.CellRendererPixbuf()
        self.timeout         = None
        self.notebook        = prefs.getWidgetsTree().get_object('notebook-explorer')
        self.allExplorers    = {}
        self.notebookPages   = {}
        self.currExplorerIdx = 0
        # Setup the combo box
        txtRenderer.set_property('xpad', 6)
        self.combo.pack_start(pixRenderer, False)
        self.combo.add_attribute(pixRenderer, 'pixbuf', ROW_PIXBUF)
        self.combo.pack_start(txtRenderer, True)
        self.combo.add_attribute(txtRenderer, 'markup', ROW_NAME)
        self.combo.set_sensitive(False)
        self.combo.set_cell_data_func(txtRenderer, self.__cellDataFunction)
        self.combo.set_model(self.store)
        # Setup the notebook
        label = gtk.Label(_('Please select an explorer\nin the combo box below.'))
        label.show()
        self.notebook.append_page(label)
        # GTK handlers
        self.combo.connect('changed', self.onChanged)
Ejemplo n.º 2
0
    def __init__(self):
        """ Constructor """
        modules.Module.__init__(self, (consts.MSG_CMD_EXPLORER_ADD, consts.MSG_CMD_EXPLORER_REMOVE, consts.MSG_CMD_EXPLORER_RENAME))
        # Attributes
        self.combo        = prefs.getWidgetsTree().get_widget('combo-explorer')
        self.widgets      = {}
        self.notebook     = prefs.getWidgetsTree().get_widget('notebook-explorer')
        self.explorers    = {}
        self.currExplorer = None
        # Setup the combo box
        txtRenderer = gtk.CellRendererText()
        pixRenderer = gtk.CellRendererPixbuf()

        self.combo.pack_start(pixRenderer, False)
        self.combo.add_attribute(pixRenderer, 'pixbuf', ROW_PIXBUF)
        self.combo.pack_start(txtRenderer, True)
        self.combo.add_attribute(txtRenderer, 'markup', ROW_NAME)
        self.combo.set_sensitive(False)
        self.combo.set_row_separator_func(lambda model, iter: model.get_value(iter, ROW_IS_SEPARATOR))
        self.combo.set_cell_data_func(txtRenderer, self.__cellDataFunction)
        txtRenderer.set_property('xpad', 6)
        # Setup the liststore
        self.store = gtk.ListStore(gtk.gdk.Pixbuf, gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_BOOLEAN, gobject.TYPE_BOOLEAN)
        self.combo.set_model(self.store)
        # Setup the notebook
        label = gtk.Label(_('Please select an explorer\nin the combo box below.'))
        label.show()
        self.notebook.append_page(label)
        # GTK handlers
        self.combo.connect('changed', self.onChanged)
 def onAppStarted(self):
     """ Real initialization function, called when this module has been loaded """
     self.title     = consts.appName
     self.window    = prefs.getWidgetsTree().get_widget('win-main')
     self.statusbar = prefs.getWidgetsTree().get_widget('statusbar')
     self.contextId = self.statusbar.get_context_id('tracklist info')
     # Initial status
     self.onNewTracklist(0, 0)
     self.onNewTrack(None)
    def onAppStarted(self):
        """ Real initialization function, called when this module has been loaded """
        self.window  = prefs.getWidgetsTree().get_object('win-main')
        self.status1 = prefs.getWidgetsTree().get_object('lbl-status1')
        self.status2 = prefs.getWidgetsTree().get_object('lbl-status2')

        # Current player status
        self.paused    = False
        self.playtime  = 0
        self.tracklist = []
        self.selTracks = []
        self.currTrack = None
Ejemplo n.º 5
0
    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
Ejemplo n.º 6
0
    def onAppStarted(self):
        """ Real initialization function, called when this module has been loaded """
        self.currTrackLength = 0
        self.sclBeingDragged = False

        # Widgets
        wTree             = prefs.getWidgetsTree()
        self.btnStop      = wTree.get_object('btn-stop')
        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')
        self.btnVolume    = wTree.get_object('btn-volume')
        self.lblElapsed   = wTree.get_object('lbl-elapsedTime')
        self.lblRemaining = wTree.get_object('lbl-remainingTime')

        # Don't show the volume button when using playbin2 and pulseaudio together (#511589)
        if not tools.isPulseAudioRunning() or prefs.getCmdLine()[0].playbin or prefs.getCmdLine()[0].volume_button:
            self.btnVolume.show()

        # Restore the volume
        volume = prefs.get(__name__, 'volume', PREFS_DEFAULT_VOLUME)
        self.btnVolume.set_value(volume)
        modules.postMsg(consts.MSG_CMD_SET_VOLUME, {'value': volume})

        # GTK handlers
        self.btnStop.connect('clicked', lambda widget: modules.postMsg(consts.MSG_CMD_STOP))
        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.btnVolume.connect('value-changed', self.onVolumeValueChanged)
        self.sclSeek.connect('button-press-event', self.onSeekButtonPressed)
        self.sclSeek.connect('button-release-event', self.onSeekButtonReleased)
Ejemplo n.º 7
0
    def onAppStarted(self):
        """ Real initialization function, called when this module has been loaded """
        self.currTrackLength = 0
        self.sclBeingDragged = False
        # Widgets
        wTree             = prefs.getWidgetsTree()
#        self.btnStop      = wTree.get_widget('btn-stop')
        self.btnPlay      = wTree.get_widget('btn-play')
#        self.btnNext      = wTree.get_widget('btn-next')
        self.btnPrev      = wTree.get_widget('btn-previous')
        self.sclSeek      = wTree.get_widget('scl-position')
        self.btnVolume    = wTree.get_widget('btn-volume')
        self.lblElapsed   = wTree.get_widget('lbl-elapsedTime')
        self.lblRemaining = wTree.get_widget('lbl-remainingTime')

        # Initial state
        self.onStopped()
        self.btnPlay.set_sensitive(False)
        # GTK handlers
#        self.btnStop.connect('clicked',      lambda widget: modules.postMsg(consts.MSG_CMD_STOP))
#        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.onSeekChangeValue)
        # We need to keep the handler ID for this one to be able to disconnect it when needed
        self.seekHandler   = self.sclSeek.connect('value-changed',   self.onSeekValueChanged)
        self.volumeHandler = self.btnVolume.connect('value-changed', self.onVolumeValueChanged)
        # We must make sure that the handler will be called: this is not the case if the new value is the same as the old one
        volumeValue = prefs.get(__name__, 'volume', PREFS_DEFAULT_VOLUME)
        if self.btnVolume.get_value() != volumeValue: self.btnVolume.set_value(volumeValue)
        else:                                         self.onVolumeValueChanged(self.btnVolume, volumeValue)
Ejemplo n.º 8
0
 def onModLoaded(self):
     """ Install the Status icon """
     self.volume           = 0
     self.tooltip          = consts.appName
     self.isPaused         = False
     self.icoPause         = None
     self.popupMenu        = None
     self.isPlaying        = False
     self.icoNormal        = None
     self.mainWindow       = prefs.getWidgetsTree().get_object('win-main')
     self.trackHasNext     = False
     self.trackHasPrev     = False
     self.emptyTracklist   = True
     self.isMainWinVisible = True
     # The status icon does not support RGBA, so make sure to use the RGB color map when creating it
     gtk.widget_push_colormap(self.mainWindow.get_screen().get_rgb_colormap())
     self.statusIcon = gtk.StatusIcon()
     gtk.widget_pop_colormap()
     # GTK+ handlers
     self.statusIcon.connect('activate',           self.toggleWinVisibility)
     self.statusIcon.connect('popup-menu',         self.onPopupMenu)
     self.statusIcon.connect('size-changed',       self.renderIcons)
     self.statusIcon.connect('scroll-event',       self.onScroll)
     self.statusIcon.connect('button-press-event', self.onButtonPressed)
     # Install everything
     self.statusIcon.set_tooltip(consts.appName)
     self.onNewTrack(None)
     self.statusIcon.set_visible(True)
Ejemplo n.º 9
0
    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
Ejemplo n.º 10
0
def __addMenuItem(label, callback, accelerator):
    """ This is the 'real' addMenuItem function, which must be executed in the GTK main loop """
    global mAccelGroup, mSeparator

    menu = prefs.getWidgetsTree().get_object('menu-edit')

    # Remove all menu items
    if len(mMenuItems) != 0:
        menu.remove(mSeparator)
        for menuitem in mMenuItems.itervalues():
            menu.remove(menuitem)

    # Create a new menu item for the module
    menuitem = gtk.MenuItem(label)
    menuitem.connect('activate', callback)
    menuitem.show()
    mMenuItems[label] = menuitem

    # Add an accelerator if needed
    if accelerator is not None:
        if mAccelGroup is None:
            mAccelGroup = gtk.AccelGroup()
            prefs.getWidgetsTree().get_object('win-main').add_accel_group(mAccelGroup)

        key, mod = gtk.accelerator_parse(accelerator)
        menuitem.add_accelerator('activate', mAccelGroup, key, mod, gtk.ACCEL_VISIBLE)

    # Create the separator?
    if mSeparator is None:
        mSeparator = gtk.SeparatorMenuItem()
        mSeparator.show()

    # Re-add items alphabetically, including the new one
    menu.insert(mSeparator, 0)
    for item in sorted(mMenuItems.items(), key = lambda item: item[0], reverse = True):
        menu.insert(item[1], 0)
Ejemplo n.º 11
0
def __delMenuItem(label):
    """ This is the 'real' delMenuItem function, which must be executed in the GTK main loop """
    # Make sure the menu item is there
    if label not in mMenuItems:
        return

    menu = prefs.getWidgetsTree().get_object('menu-edit')

    # Remove all current menu items
    menu.remove(mSeparator)
    for menuitem in mMenuItems.itervalues():
        menu.remove(menuitem)

    # Delete the given menu item
    del mMenuItems[label]

    # Re-add items if needed
    if len(mMenuItems) != 0:
        menu.insert(mSeparator, 0)
        for item in sorted(mMenuItems.items(), key = lambda item: item[0], reverse = True):
            menu.insert(item[1], 0)
Ejemplo n.º 12
0
    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.SHADOW_IN)
        self.scrolled.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        self.scrolled.show()

        left_vbox = prefs.getWidgetsTree().get_object('vbox3')
        left_vbox.pack_start(self.scrolled)

        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)
Ejemplo n.º 13
0
 def RaiseWindow(self):
     """ Raises the window """
     prefs.getWidgetsTree().get_object('win-main').present()
Ejemplo n.º 14
0
Archivo: DBus.py Proyecto: csryan/pogo
 def RaiseWindow(self):
     """ Raises the window """
     prefs.getWidgetsTree().get_object('win-main').present()
Ejemplo n.º 15
0
    def onAppStarted(self):
        """ Real initialization function, called when this module has been loaded """
        self.currTrackLength = 0
        self.sclBeingDragged = False

        # 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)

        # Left mouse click jumps to current position
        self.sclSeek.connect('button-press-event', self.onSeekButtonPressed)
        self.sclSeek.connect('button-release-event', self.onSeekButtonReleased)

        # Add pref button

        self.uimanager = gtk.UIManager()
        self.main_window = wTree.get_object('win-main')

        menu_xml = '''
        <ui>
        <popup name="ButtonMenu">
            <menuitem action="Options"/>
            <menuitem action="About"/>
        </popup>
        </ui>'''

        # Create an ActionGroup
        actiongroup = gtk.ActionGroup('MainActionGroup')

        # Create actions
        actiongroup.add_actions([
            ('ButtonMenu', None, None),
            #('Quit', gtk.STOCK_QUIT, None, None, None,
            #    lambda widget: self.onDelete(self.main_window, None)),
            ('Options', gtk.STOCK_PREFERENCES, None,
                '<Ctrl>p', None, lambda item: modules.showPreferences()),
            #('Help', gtk.STOCK_HELP, None,
            #    '<Ctrl>h', None, self.on_help_menu_item_activate),
            ('About', gtk.STOCK_ABOUT, None,
                None, None, self.onAbout),
            ])

        # Add the actiongroup to the uimanager
        self.uimanager.insert_action_group(actiongroup, 0)

        # Add a UI description
        self.uimanager.add_ui_from_string(menu_xml)

        # Create a Menu
        button_menu = self.uimanager.get_widget('/ButtonMenu')

        menu_button = gtk.MenuToolButton(None, None)
        hbox = menu_button.get_child()
        button, toggle_button = hbox.get_children()
        hbox.remove(button)

        img = gtk.image_new_from_stock(gtk.STOCK_PREFERENCES,
                                       gtk.ICON_SIZE_SMALL_TOOLBAR)

        arrow = toggle_button.get_child()
        toggle_button.remove(arrow)
        hbox = gtk.HBox()
        hbox.add(img)
        toggle_button.add(hbox)
        menu_button.show()


        toolbar_hbox = wTree.get_object('hbox4')
        toolbar_hbox.pack_end(menu_button, False)
        # Move it to the right
        toolbar_hbox.reorder_child(menu_button, 0)
        menu_button.set_menu(button_menu)

        self.set_tooltips(self.uimanager)
        accelgroup = self.uimanager.get_accel_group()
        self.main_window.add_accel_group(accelgroup)