示例#1
0
文件: playback.py 项目: twa022/exaile
    def __init__(self, player):
        Gtk.ProgressBar.__init__(self)
        self.__player = player

        try:
            awidget = self.get_accessible()
            awidget.set_role(Atk.Role.AUDIO)
        except Exception:
            logger.debug("Exception setting ATK role", exc_info=True)

        self.set_show_text(True)

        self.reset()

        self.formatter = ProgressBarFormatter(player)
        self.__timer_id = None
        self.__events = (
            'playback_track_start',
            'playback_player_end',
            'playback_toggle_pause',
            'playback_error',
        )

        for e in self.__events:
            event.add_ui_callback(getattr(self, 'on_%s' % e), e, self.__player)
示例#2
0
文件: __init__.py 项目: exaile/exaile
    def __init__(self, exaile):
        """
            Connects events to the player object, loads settings and cache
        """
        scrobbler.set_user_agent(exaile.get_user_agent_string('audioscrobbler'))
        self.connected = False
        self.connecting = False
        self.use_menu = False
        self.exaile = exaile
        self.cachefile = os.path.join(xdg.get_data_dirs()[0], "audioscrobbler.cache")
        self.get_options('', '', 'plugin/ascrobbler/cache_size')
        self.get_options('', '', 'plugin/ascrobbler/user')
        self.load_cache()
        event.add_ui_callback(self.get_options, 'plugin_ascrobbler_option_set')
        event.add_callback(self._save_cache_cb, 'quit_application')

        # enable accelerator
        def toggle_submit(*x):
            logger.debug('Toggling AudioScrobbler submissions.')
            settings.set_option('plugin/ascrobbler/submit', not self.submit)

        self.accelerator = Accelerator(
            '<Primary>b', _('Toggle AudioScrobbler submit'), toggle_submit
        )
        providers.register('mainwindow-accelerators', self.accelerator)
示例#3
0
    def _setup_widgets(self):
        """
            Sets up the widgets for the files panel
        """
        self.directory = self.tree.render_icon(
            Gtk.STOCK_DIRECTORY, Gtk.IconSize.SMALL_TOOLBAR)
        self.track = icons.MANAGER.pixbuf_from_icon_name(
            'audio-x-generic', Gtk.IconSize.SMALL_TOOLBAR)
        self.back = self.builder.get_object('files_back_button')
        self.back.connect('clicked', self.go_back)
        self.forward = self.builder.get_object('files_forward_button')
        self.forward.connect('clicked', self.go_forward)
        self.up = self.builder.get_object('files_up_button')
        self.up.connect('clicked', self.go_up)
        self.builder.get_object('files_refresh_button').connect('clicked',
            self.refresh)
        self.builder.get_object('files_home_button').connect('clicked',
            self.go_home)

        # Set up the location bar
        self.location_bar = self.builder.get_object('files_entry')
        self.location_bar.connect('changed', self.on_location_bar_changed)
        event.add_ui_callback(self.fill_libraries_location,
            'libraries_modified', self.collection)
        self.fill_libraries_location()
        self.entry = self.location_bar.get_children()[0]
        self.entry.connect('activate', self.entry_activate)

        # Set up the search entry
        self.filter = guiutil.SearchEntry(self.builder.get_object('files_search_entry'))
        self.filter.connect('activate', lambda *e:
            self.load_directory(self.current, history=False,
                keyword=unicode(self.filter.get_text(), 'utf-8')))
示例#4
0
文件: playback.py 项目: exaile/exaile
    def __init__(self, player):
        Gtk.ProgressBar.__init__(self)
        self.__player = player

        try:
            awidget = self.get_accessible()
            awidget.set_role(Atk.Role.AUDIO)
        except Exception:
            logger.debug("Exception setting ATK role", exc_info=True)

        self.set_show_text(True)

        self.reset()

        self.formatter = ProgressBarFormatter(player)
        self.__timer_id = None
        self.__events = (
            'playback_track_start',
            'playback_player_end',
            'playback_toggle_pause',
            'playback_error',
        )

        for e in self.__events:
            event.add_ui_callback(getattr(self, 'on_%s' % e), e, self.__player)
示例#5
0
文件: __init__.py 项目: unkie/exaile
    def __init__(self, exaile):
        """
        Connects events to the player object, loads settings and cache
        """
        scrobbler.set_user_agent(
            exaile.get_user_agent_string('audioscrobbler'))
        self.connected = False
        self.connecting = False
        self.use_menu = False
        self.exaile = exaile
        self.cachefile = os.path.join(xdg.get_data_dirs()[0],
                                      "audioscrobbler.cache")
        self.get_options('', '', 'plugin/ascrobbler/cache_size')
        self.get_options('', '', 'plugin/ascrobbler/user')
        self.load_cache()
        event.add_ui_callback(self.get_options, 'plugin_ascrobbler_option_set')
        event.add_callback(self._save_cache_cb, 'quit_application')

        # enable accelerator
        def toggle_submit(*x):
            logger.debug('Toggling AudioScrobbler submissions.')
            settings.set_option('plugin/ascrobbler/submit', not self.submit)

        self.accelerator = Accelerator('<Primary>b',
                                       _('Toggle AudioScrobbler submit'),
                                       toggle_submit)
        providers.register('mainwindow-accelerators', self.accelerator)
示例#6
0
    def set_auto_update(self, auto_update):
        """
            Sets whether the info pane shall
            be automatically updated or not

            :param auto_update: enable or disable
                automatic updating
            :type auto_update: bool
        """
        if auto_update != self.__auto_update:
            self.__auto_update = auto_update

            p_evts = ['playback_player_end', 'playback_track_start',
                      'playback_toggle_pause', 'playback_error']
            events = ['track_tags_changed', 'cover_set', 'cover_removed']

            if auto_update:
                for e in p_evts:
                    event.add_ui_callback(getattr(self, 'on_%s' % e), e, self.__player)
                for e in events:
                    event.add_ui_callback(getattr(self, 'on_%s' % e), e)

                self.set_track(self.__player.current)
            else:
                for e in p_evts:
                    event.remove_callback(getattr(self, 'on_%s' % e), e, self.__player)
                for e in events:
                    event.remove_callback(getattr(self, 'on_%s' % e), e)
示例#7
0
    def set_auto_update(self, auto_update):
        """
            Sets whether the info pane shall
            be automatically updated or not

            :param auto_update: enable or disable
                automatic updating
            :type auto_update: bool
        """
        if auto_update != self.__auto_update:
            self.__auto_update = auto_update

            p_evts = ['playback_player_end', 'playback_track_start',
                      'playback_toggle_pause', 'playback_error']
            events = ['track_tags_changed', 'cover_set', 'cover_removed']

            if auto_update:
                for e in p_evts:
                    event.add_ui_callback(getattr(self, 'on_%s' % e), e, self.__player)
                for e in events:
                    event.add_ui_callback(getattr(self, 'on_%s' % e), e)

                self.set_track(self.__player.current)
            else:
                for e in p_evts:
                    event.remove_callback(getattr(self, 'on_%s' % e), e, self.__player)
                for e in events:
                    event.remove_callback(getattr(self, 'on_%s' % e), e)
示例#8
0
    def __init__(self, parent, name):
        panel.Panel.__init__(self, parent, name, _('Lyrics'))

        self.__lyrics_found = []
        self.__css_provider = Gtk.CssProvider()

        WIDGET_LIST = \
            ['lyrics_top_box', 'refresh_button', 'refresh_button_stack',
             'refresh_icon', 'refresh_spinner', 'track_text',
             'scrolled_window', 'lyrics_text', 'lyrics_source_label',
             'track_text_buffer', 'lyrics_text_buffer']
        for name in WIDGET_LIST:
            setattr(self, '_' + LyricsPanel.__name__ + '__' + name,
                    self.builder.get_object(name))
        self.__initialize_widgets()

        event.add_ui_callback(self.__on_playback_track_start,
                              'playback_track_start')
        event.add_ui_callback(self.__on_track_tags_changed,
                              'track_tags_changed')
        event.add_ui_callback(self.__on_playback_player_end,
                              'playback_player_end')
        event.add_ui_callback(self.__on_lyrics_search_method_added,
                              'lyrics_search_method_added')
        event.add_ui_callback(self.__on_option_set,
                              'plugin_lyricsviewer_option_set')

        self.__update_lyrics()
示例#9
0
    def _connect_events(self):
        event.add_ui_callback(self.refresh_playlists, 'track_tags_changed')
        event.add_ui_callback(
            self._on_playlist_added, 'playlist_added', self.playlist_manager
        )

        self.tree.connect('key-release-event', self.on_key_released)
示例#10
0
    def __init__(self):
        Gtk.Box.__init__(self)
        providers.ProviderHandler.__init__(self, 'minimode-controls')

        self.__dirty = True
        self.__controls = {}

        event.add_ui_callback(self.on_option_set, 'plugin_minimode_option_set')
示例#11
0
    def __init__(self):
        Formatter.__init__(self, self.get_option_value())

        self.track_formatter = TrackFormatter('')
        self.progress_formatter = ProgressTextFormatter(
            self.props.format, player.PLAYER)

        event.add_ui_callback(self.on_option_set, 'plugin_minimode_option_set')
示例#12
0
    def __init__(self):
        providers.ProviderHandler.__init__(self, 'playback-markers')

        self.__events = ('playback_track_start', 'playback_track_end')
        self.__timeout_id = None

        for e in self.__events:
            event.add_ui_callback(getattr(self, 'on_%s' % e), e)
示例#13
0
文件: widgets.py 项目: exaile/exaile
 def __init__(self):
     event.add_ui_callback(self.on_option_set, 'option_set')
     GLib.idle_add(
         self.on_option_set,
         'option_set',
         settings,
         self.condition_preference_names[0],
     )
示例#14
0
 def __init__(self, player):
     Playlist.__init__( self, _('History') )
     
     # catch the history
     event.add_ui_callback( self.__on_playback_track_start, 'playback_track_start', player )
     
     if player.is_paused() or player.is_playing():
         self.__on_playback_track_start( 'playback_track_start', player, player.current )
示例#15
0
文件: widgets.py 项目: lh77x7/exaile
 def __init__(self):
     event.add_ui_callback(self.on_option_set, 'option_set')
     GLib.idle_add(
         self.on_option_set,
         'option_set',
         settings,
         self.condition_preference_names[0],
     )
示例#16
0
文件: playback.py 项目: twa022/exaile
    def __init__(self):
        providers.ProviderHandler.__init__(self, 'playback-markers')

        self.__events = ('playback_track_start', 'playback_track_end')
        self.__timeout_id = None

        for e in self.__events:
            event.add_ui_callback(getattr(self, 'on_%s' % e), e)
示例#17
0
文件: __init__.py 项目: che2/exaile
 def __init__(self, player):
     Playlist.__init__( self, _('History') )
     
     # catch the history
     event.add_ui_callback( self.__on_playback_track_start, 'playback_track_start', player )
     
     if player.is_paused() or player.is_playing():
         self.__on_playback_track_start( 'playback_track_start', player, player.current )
示例#18
0
文件: controls.py 项目: exaile/exaile
    def __init__(self):
        Gtk.Box.__init__(self)
        providers.ProviderHandler.__init__(self, 'minimode-controls')

        self.__dirty = True
        self.__controls = {}

        event.add_ui_callback(self.on_option_set, 'plugin_minimode_option_set')
示例#19
0
    def __init__(self, exaile):
        """
            Sets up the mini mode main window and
            options to access it
        """
        Gtk.Window.__init__(self)
        self.set_title('Exaile Mini Mode')
        self.set_resizable(False)

        self.exaile_window = exaile.gui.main.window

        controls.register()

        self.box = controls.ControlBox()
        self.box.set_spacing(3)
        self.border_frame = Gtk.Frame()
        self.border_frame.add(self.box)
        self.add(self.border_frame)

        self.accelerator = Accelerator('<Primary><Alt>M', _('Mini Mode'),
                                       self.on_menuitem_activate)

        self.menuitem = menu.simple_menu_item('minimode', ['clear-playlist'],
                                              icon_name='exaile-minimode',
                                              callback=self.accelerator)

        providers.register('menubar-view-menu', self.menuitem)
        providers.register('mainwindow-accelerators', self.accelerator)

        self.mainbutton = Gtk.Button(label=_('Mini Mode'))
        self.mainbutton.set_image(
            Gtk.Image.new_from_icon_name('exaile-minimode',
                                         Gtk.IconSize.BUTTON))
        self.mainbutton.connect('clicked', self.on_mainbutton_clicked)
        action_area = exaile.gui.main.info_area.get_action_area()
        action_area.pack_end(self.mainbutton, False, False, 6)

        self.__active = False
        self.__dirty = True
        # XXX: Until defaults are implemented in xl.settings
        self.__defaults = {
            'plugin/minimode/always_on_top': True,
            'plugin/minimode/show_in_panel': False,
            'plugin/minimode/on_all_desktops': True,
            'plugin/minimode/display_window_decorations': True,
            'plugin/minimode/window_decoration_type': 'full',
            'plugin/minimode/use_alpha': False,
            'plugin/minimode/transparency': 0.3,
            'plugin/minimode/horizontal_position': 10,
            'plugin/minimode/vertical_position': 10
        }

        exaile.gui.main.connect('main-visible-toggle',
                                self.on_main_visible_toggle)
        event.add_ui_callback(self.on_option_set, 'plugin_minimode_option_set')
        self.on_option_set('plugin_minimode_option_set', settings,
                           'plugin/minimode/button_in_mainwindow')
示例#20
0
文件: controls.py 项目: exaile/exaile
    def __init__(self):
        Formatter.__init__(self, self.get_option_value())

        self.track_formatter = TrackFormatter('')
        self.progress_formatter = ProgressTextFormatter(
            self.props.format, player.PLAYER
        )

        event.add_ui_callback(self.on_option_set, 'plugin_minimode_option_set')
示例#21
0
    def __init__(self):
        ElementBin.__init__(self, name=self.name)
        self.rglimit = Gst.ElementFactory.make("rglimiter", None)
        self.elements[50] = self.rglimit
        self.audioconvert = Gst.ElementFactory.make("audioconvert", None)
        self.elements[60] = self.audioconvert
        self.setup_elements()

        event.add_ui_callback(self._on_option_set, "replaygain_option_set")
        self._on_option_set("replaygain_option_set", None, "replaygain/clipping-protection")
示例#22
0
    def __init__(self, preferences, builder):
        """
            Initializes the manager
        """
        self.preferences = preferences
        builder.connect_signals(self)
        self.plugins = main.exaile().plugins

        self.message = dialogs.MessageBar(
            parent=builder.get_object('preferences_pane'),
            buttons=Gtk.ButtonsType.CLOSE)
        self.message.connect('response', self.on_messagebar_response)

        self.list = builder.get_object('plugin_tree')
        self.enabled_cellrenderer = builder.get_object('enabled_cellrenderer')

        if main.exaile().options.Debug:
            reload_cellrenderer = common.ClickableCellRendererPixbuf()
            reload_cellrenderer.props.icon_name = 'view-refresh'
            reload_cellrenderer.props.xalign = 1
            reload_cellrenderer.connect('clicked',
                                        self.on_reload_cellrenderer_clicked)

            name_column = builder.get_object('name_column')
            name_column.pack_start(reload_cellrenderer, True)
            name_column.add_attribute(reload_cellrenderer, 'visible', 3)

        self.version_label = builder.get_object('version_label')
        self.author_label = builder.get_object('author_label')
        self.name_label = builder.get_object('name_label')
        self.description = builder.get_object('description_view')

        self.model = builder.get_object('model')
        self.filter_model = self.model.filter_new()

        self.show_incompatible_cb = builder.get_object('show_incompatible_cb')
        self.show_broken_cb = builder.get_object('show_broken_cb')

        self.filter_model.set_visible_func(self._model_visible_func)

        self.status_column = builder.get_object('status_column')
        self._set_status_visible()

        selection = self.list.get_selection()
        selection.connect('changed', self.on_selection_changed)
        self._load_plugin_list()

        self._evt_rm1 = event.add_ui_callback(self.on_plugin_event,
                                              'plugin_enabled', None, True)
        self._evt_rm2 = event.add_ui_callback(self.on_plugin_event,
                                              'plugin_disabled', None, False)
        self.list.connect('destroy', self.on_destroy)

        GLib.idle_add(selection.select_path, (0, ))
        GLib.idle_add(self.list.grab_focus)
示例#23
0
文件: plugin.py 项目: Zarokka/exaile
    def __init__(self, preferences, builder):
        """
            Initializes the manager
        """
        self.preferences = preferences
        builder.connect_signals(self)
        self.plugins = main.exaile().plugins

        self.message = dialogs.MessageBar(
            parent=builder.get_object('preferences_pane'),
            buttons=Gtk.ButtonsType.CLOSE
        )
        self.message.connect('response', self.on_messagebar_response)

        self.list = builder.get_object('plugin_tree')
        self.enabled_cellrenderer = builder.get_object('enabled_cellrenderer')

        if main.exaile().options.Debug:
            reload_cellrenderer = common.ClickableCellRendererPixbuf()
            reload_cellrenderer.props.icon_name = 'view-refresh'
            reload_cellrenderer.props.xalign = 1
            reload_cellrenderer.connect('clicked',
                self.on_reload_cellrenderer_clicked)

            name_column = builder.get_object('name_column')
            name_column.pack_start(reload_cellrenderer, True)
            name_column.add_attribute(reload_cellrenderer, 'visible', 3)

        self.version_label = builder.get_object('version_label')
        self.author_label = builder.get_object('author_label')
        self.name_label = builder.get_object('name_label')
        self.description = builder.get_object('description_view')
        
        self.model = builder.get_object('model')
        self.filter_model = self.model.filter_new()
        
        self.show_incompatible_cb = builder.get_object('show_incompatible_cb')
        self.show_broken_cb = builder.get_object('show_broken_cb')
        
        self.filter_model.set_visible_func(self._model_visible_func)
        
        self.status_column = builder.get_object('status_column')
        self._set_status_visible()

        selection = self.list.get_selection()
        selection.connect('changed', self.on_selection_changed)
        self._load_plugin_list()
        
        self._evt_rm1 = event.add_ui_callback(self.on_plugin_event, 'plugin_enabled', None, True)
        self._evt_rm2 = event.add_ui_callback(self.on_plugin_event, 'plugin_disabled', None, False)
        self.list.connect('destroy', self.on_destroy)
        
        GLib.idle_add(selection.select_path, (0,))
        GLib.idle_add(self.list.grab_focus)
示例#24
0
    def __init__(self):
        ElementBin.__init__(self, name=self.name)
        self.rglimit = Gst.ElementFactory.make("rglimiter", None)
        self.elements[50] = self.rglimit
        self.audioconvert = Gst.ElementFactory.make("audioconvert", None)
        self.elements[60] = self.audioconvert
        self.setup_elements()

        event.add_ui_callback(self._on_option_set, "replaygain_option_set")
        self._on_option_set("replaygain_option_set", None,
                            "replaygain/clipping-protection")
示例#25
0
 def run(self):
     """
         Runs the thread
     """
     event.add_ui_callback(self.on_track_transfer_progress,
                           'track_transfer_progress', self.device.transfer)
     try:
         self.device.start_transfer()
     finally:
         event.remove_callback(self.on_track_transfer_progress,
                               'track_transfer_progress', self.device.transfer)
示例#26
0
 def run(self):
     """
         Runs the thread
     """
     event.add_ui_callback(self.on_track_transfer_progress,
         'track_transfer_progress', self.device.transfer)
     try:
         self.device.start_transfer()
     finally:
         event.remove_callback(self.on_track_transfer_progress,
             'track_transfer_progress', self.device.transfer)
示例#27
0
    def on_toggled(self, menuitem):
        """
            Enables or disables defered shutdown
        """
        if menuitem.get_active():
            self.do_shutdown = True
            event.add_ui_callback(self.on_playback_player_end, "playback_player_end")

            self.message.show_info(_("Shutdown scheduled"), _("Computer will be shutdown at the end of playback."))
        else:
            self.disable_shutdown()
示例#28
0
文件: playback.py 项目: twa022/exaile
    def __init__(self, player):
        Gtk.Box.__init__(self)
        self.init_template()

        self.button.add_events(Gdk.EventMask.KEY_PRESS_MASK | Gdk.EventMask.SCROLL_MASK)

        self.__volume_setting = '%s/volume' % player._name
        self.restore_volume = settings.get_option(self.__volume_setting, 1)
        self.icon_names = ['low', 'medium', 'high']
        self.__update(self.restore_volume)

        event.add_ui_callback(self.on_option_set, '%s_option_set' % player._name)
示例#29
0
    def __init__(self, player):
        Gtk.Box.__init__(self)
        self.init_template()
        
        self.button.add_events(Gdk.EventMask.KEY_PRESS_MASK | Gdk.EventMask.SCROLL_MASK)
        
        self.__volume_setting = '%s/volume' % player._name
        self.restore_volume = settings.get_option(self.__volume_setting, 1)
        self.icon_names = ['low', 'medium', 'high']
        self.__update(self.restore_volume)

        event.add_ui_callback(self.on_option_set, '%s_option_set' % player._name)
示例#30
0
    def __init__(self, container, index, player, font):
        if self.__class__ == Column:
            raise NotImplementedError("Can't instantiate "
                                      "abstract class %s" %
                                      repr(self.__class__))

        self.container = container
        self.player = player
        self.settings_width_name = "gui/col_width_%s" % self.name
        self.cellrenderer = self.renderer()
        self.extrasize = 0

        self._setup_font(font)

        if index == 2:
            super(Column, self).__init__(self.display)
            self.icon_cellr = Gtk.CellRendererPixbuf()
            pbufsize = self.get_icon_height()
            self.icon_cellr.set_fixed_size(pbufsize, pbufsize)
            self.extrasize = pbufsize
            self.icon_cellr.set_property('xalign', 0.0)
            self.pack_start(self.icon_cellr, False)
            self.pack_start(self.cellrenderer, True)
            self.set_attributes(self.icon_cellr, pixbuf=1)
            self.set_attributes(self.cellrenderer,
                                **{self.dataproperty: index})
        else:
            super(Column, self).__init__(self.display, self.cellrenderer,
                                         **{self.dataproperty: index})
        self.set_cell_data_func(self.cellrenderer, self.data_func)

        try:
            self.cellrenderer.set_property('ellipsize',
                                           Pango.EllipsizeMode.END)
        except TypeError:  #cellrenderer doesn't do ellipsize - eg. rating
            pass

        for name, val in self.cellproperties.iteritems():
            self.cellrenderer.set_property(name, val)

        self.set_reorderable(True)
        self.set_clickable(True)
        self.set_sizing(
            Gtk.TreeViewColumnSizing.FIXED)  # needed for fixed-height mode
        self.set_sort_order(Gtk.SortType.DESCENDING)

        # hack to allow button press events on the header to be detected
        self.set_widget(Gtk.Label(label=self.display))

        self.connect('notify::width', self.on_width_changed)
        self._setup_sizing()

        event.add_ui_callback(self.on_option_set, "gui_option_set")
示例#31
0
文件: __init__.py 项目: exaile/exaile
    def __init__(self):
        ElementBin.__init__(self, name=self.name)
        self.audioconvert = Gst.ElementFactory.make("audioconvert", None)
        self.elements[40] = self.audioconvert
        self.rgvol = Gst.ElementFactory.make("rgvolume", None)
        self.elements[50] = self.rgvol
        self.setup_elements()

        event.add_ui_callback(self._on_option_set, "replaygain_option_set")

        # load settings
        for x in ("album-mode", "pre-amp", "fallback-gain"):
            self._on_option_set("replaygain_option_set", None, "replaygain/%s" % x)
示例#32
0
    def __init__(self):
        ElementBin.__init__(self, name=self.name)
        self.audioconvert = Gst.ElementFactory.make("audioconvert", None)
        self.elements[40] = self.audioconvert
        self.rgvol = Gst.ElementFactory.make("rgvolume", None)
        self.elements[50] = self.rgvol
        self.setup_elements()

        event.add_ui_callback(self._on_option_set, "replaygain_option_set")

        # load settings
        for x in ("album-mode", "pre-amp", "fallback-gain"):
            self._on_option_set("replaygain_option_set", None, "replaygain/%s" % x)
示例#33
0
    def __init__(self, container, player, font, size_ratio):
        if self.__class__ == Column:
            raise NotImplementedError("Can't instantiate "
                                      "abstract class %s" %
                                      repr(self.__class__))

        self._size_ratio = size_ratio
        self.container = container
        self.player = player
        self.settings_width_name = "gui/col_width_%s" % self.name
        self.cellrenderer = self.renderer()
        self.destroyed = False

        super(Column, self).__init__(self.display)
        self.props.min_width = 3

        self.pack_start(self.cellrenderer, True)
        self.set_cell_data_func(self.cellrenderer, self.data_func)

        try:
            self.cellrenderer.set_property('font-desc', font)
        except TypeError:
            pass  # not all cells have a font

        try:
            self.cellrenderer.set_property('ellipsize',
                                           Pango.EllipsizeMode.END)
        except TypeError:  # cellrenderer doesn't do ellipsize - eg. rating
            pass

        for name, val in self.cellproperties.iteritems():
            self.cellrenderer.set_property(name, val)

        self.set_reorderable(True)
        self.set_clickable(True)
        self.set_sizing(
            Gtk.TreeViewColumnSizing.FIXED)  # needed for fixed-height mode
        self.set_sort_order(Gtk.SortType.DESCENDING)

        # hack to allow button press events on the header to be detected
        self.set_widget(Gtk.Label(label=self.display))

        # Save the width of the column when it changes; save the notify id so
        # we don't emit an event when we're programmatically setting the width
        self._width_notify = self.connect('notify::width',
                                          self.on_width_changed)
        self._setup_sizing()

        event.add_ui_callback(self.on_option_set,
                              "gui_option_set",
                              destroy_with=container)
示例#34
0
    def on_toggled(self, menuitem):
        """
            Enables or disables defered shutdown
        """
        if menuitem.get_active():
            self.do_shutdown = True
            event.add_ui_callback(self.on_playback_player_end,
                                  'playback_player_end')

            self.message.show_info(
                _('Shutdown scheduled'),
                _('Computer will be shutdown at the end of playback.'))
        else:
            self.disable_shutdown()
示例#35
0
 def __init__(self):
     self.notify = Notify.Notification.new('Exaile')
     self.exaile = None
     self.icon = None
     self.pauseicon = 'notification-audio-pause'
     self.resumeicon = 'notification-audio-play'
     self.stopicon = 'notification-audio-stop'
     # TRANSLATORS: title of a track if it is unknown
     self.unknown = _('Unknown')
     self.summary = None
     self.body = None
     self.gui_callback = False
     self.tray_connection = -1
     event.add_ui_callback(self.on_tray_toggled, 'tray_icon_toggled')
示例#36
0
 def __init__(self):
     self.notify         = Notify.Notification.new('Exaile')
     self.exaile         = None
     self.icon           = None
     self.pauseicon      = 'notification-audio-pause'
     self.resumeicon     = 'notification-audio-play'
     self.stopicon       = 'notification-audio-stop'
     # TRANSLATORS: title of a track if it is unknown
     self.unknown        = _('Unknown')
     self.summary        = None
     self.body           = None
     self.gui_callback   = False
     self.tray_connection= -1
     event.add_ui_callback(self.on_tray_toggled, 'tray_icon_toggled')
示例#37
0
文件: devices.py 项目: twa022/exaile
    def __init__(self, parent, main):
        Gtk.Window.__init__(self)
        self.init_template()

        self.main = main
        self.device_manager = self.main.exaile.devices
        self.set_transient_for(parent)

        # GtkListStore self.model: first column (PyObject) should really be of
        # type devices.Device, but that doesn't work with GtkBuilder.

        self.populate_tree()
        event.add_ui_callback(self.populate_tree, 'device_added')
        event.add_ui_callback(self.populate_tree, 'device_removed')
示例#38
0
    def __init__(self, container, index, player, font):
        if self.__class__ == Column:
            raise NotImplementedError("Can't instantiate "
                "abstract class %s" % repr(self.__class__))

        self.container = container
        self.player = player
        self.settings_width_name = "gui/col_width_%s" % self.name
        self.cellrenderer = self.renderer()
        self.extrasize = 0
        
        self._setup_font(font)

        if index == 2:
            super(Column, self).__init__(self.display)
            self.icon_cellr = Gtk.CellRendererPixbuf()
            pbufsize = self.get_icon_height()
            self.icon_cellr.set_fixed_size(pbufsize, pbufsize)
            self.extrasize = pbufsize
            self.icon_cellr.set_property('xalign', 0.0)
            self.pack_start(self.icon_cellr, False)
            self.pack_start(self.cellrenderer, True)
            self.set_attributes(self.icon_cellr, pixbuf=1)
            self.set_attributes(self.cellrenderer, **{self.dataproperty: index})
        else:
            super(Column, self).__init__(self.display, self.cellrenderer,
                **{self.dataproperty: index})
        self.set_cell_data_func(self.cellrenderer, self.data_func)

        try:
            self.cellrenderer.set_property('ellipsize', Pango.EllipsizeMode.END)
        except TypeError: #cellrenderer doesn't do ellipsize - eg. rating
            pass
            
        for name, val in self.cellproperties.iteritems():
            self.cellrenderer.set_property(name, val)

        self.set_reorderable(True)
        self.set_clickable(True)
        self.set_sizing(Gtk.TreeViewColumnSizing.FIXED) # needed for fixed-height mode
        self.set_sort_order(Gtk.SortType.DESCENDING)

        # hack to allow button press events on the header to be detected
        self.set_widget(Gtk.Label(label=self.display))

        self.connect('notify::width', self.on_width_changed)
        self._setup_sizing()

        event.add_ui_callback(self.on_option_set, "gui_option_set")
示例#39
0
    def __init__(self, player):
        Gtk.ProgressBar.__init__(self)
        self.__player = player

        self.set_show_text(True)

        self.reset()

        self.formatter = ProgressBarFormatter(player)
        self.__timer_id = None
        self.__events = ('playback_track_start', 'playback_player_end',
                         'playback_toggle_pause', 'playback_error')

        for e in self.__events:
            event.add_ui_callback(getattr(self, 'on_%s' % e), e, self.__player)
示例#40
0
文件: radio.py 项目: exaile/exaile
    def _connect_events(self):
        """
            Connects events used in this panel
        """

        self.builder.connect_signals(
            {'on_add_button_clicked': self._on_add_button_clicked}
        )
        self.tree.connect('row-expanded', self.on_row_expand)
        self.tree.connect('row-collapsed', self.on_collapsed)
        self.tree.connect('row-activated', self.on_row_activated)
        self.tree.connect('key-release-event', self.on_key_released)

        event.add_ui_callback(self._add_driver_cb, 'station_added', self.manager)
        event.add_ui_callback(self._remove_driver_cb, 'station_removed', self.manager)
示例#41
0
    def __init__(self, player):
        Gtk.ProgressBar.__init__(self)
        self.__player = player

        self.set_show_text(True)

        self.reset()

        self.formatter = ProgressBarFormatter(player)
        self.__timer_id = None
        self.__events = ('playback_track_start', 'playback_player_end',
                         'playback_toggle_pause', 'playback_error')

        for e in self.__events:
            event.add_ui_callback(getattr(self, 'on_%s' % e), e, self.__player)
示例#42
0
    def __init__(self, container, player, font, size_ratio):
        if self.__class__ == Column:
            raise NotImplementedError(
                "Can't instantiate " "abstract class %s" % repr(self.__class__)
            )

        self._size_ratio = size_ratio
        self.container = container
        self.player = player
        self.settings_width_name = "gui/col_width_%s" % self.name
        self.cellrenderer = self.renderer()
        self.destroyed = False

        super(Column, self).__init__(self.display)
        self.props.min_width = 3

        self.pack_start(self.cellrenderer, True)
        self.set_cell_data_func(self.cellrenderer, self.data_func)

        try:
            self.cellrenderer.set_property('font-desc', font)
        except TypeError:
            pass  # not all cells have a font

        try:
            self.cellrenderer.set_property('ellipsize', Pango.EllipsizeMode.END)
        except TypeError:  # cellrenderer doesn't do ellipsize - eg. rating
            pass

        for name, val in self.cellproperties.iteritems():
            self.cellrenderer.set_property(name, val)

        self.set_reorderable(True)
        self.set_clickable(True)
        self.set_sizing(Gtk.TreeViewColumnSizing.FIXED)  # needed for fixed-height mode
        self.set_sort_order(Gtk.SortType.DESCENDING)

        # hack to allow button press events on the header to be detected
        self.set_widget(Gtk.Label(label=self.display))

        # Save the width of the column when it changes; save the notify id so
        # we don't emit an event when we're programmatically setting the width
        self._width_notify = self.connect('notify::width', self.on_width_changed)
        self._setup_sizing()

        event.add_ui_callback(
            self.on_option_set, "gui_option_set", destroy_with=container
        )
示例#43
0
文件: __init__.py 项目: exaile/exaile
    def __handle_init(self, can_continue, caps):
        exaile = self.__exaile
        if exaile is None:  # Plugin has been disabled in the mean time
            return

        if can_continue:  # check again, might have changed
            if exaile.loading:
                xl_event.add_ui_callback(self.__init_notifier, 'gui_loaded', None, caps)
            else:
                self.__init_notifier(caps)
        else:
            LOGGER.warning("Disabling NotifyPlugin.")
            exaile.plugins.disable_plugin(__name__)
            if exaile.loading is not True:
                # TODO: send error to GUI
                pass
示例#44
0
 def __enable_new_plugin(self, plugin):
     '''Sets up a new-style plugin. See helloworld plugin for details'''
     
     if hasattr(plugin, 'on_gui_loaded'):
         if self.exaile.loading:
             event.add_ui_callback(self.__on_new_plugin_loaded, 'gui_loaded',
                                None, plugin.on_gui_loaded)
         else:
             plugin.on_gui_loaded()
         
     if hasattr(plugin, 'on_exaile_loaded'):
         if self.exaile.loading:
             event.add_ui_callback(self.__on_new_plugin_loaded, 'exaile_loaded',
                                None, plugin.on_exaile_loaded)
         else:
             plugin.on_exaile_loaded()
示例#45
0
    def __handle_init(self, can_continue, caps):
        exaile = self.__exaile
        if exaile is None:  # Plugin has been disabled in the mean time
            return

        if can_continue:  # check again, might have changed
            if exaile.loading:
                xl_event.add_ui_callback(self.__init_notifier, 'gui_loaded', None, caps)
            else:
                self.__init_notifier(caps)
        else:
            LOGGER.warning("Disabling NotifyPlugin.")
            exaile.plugins.disable_plugin(__name__)
            if not exaile.loading:
                # TODO: send error to GUI
                pass
示例#46
0
文件: radio.py 项目: unkie/exaile
    def _connect_events(self):
        """
        Connects events used in this panel
        """

        self.builder.connect_signals(
            {'on_add_button_clicked': self._on_add_button_clicked})
        self.tree.connect('row-expanded', self.on_row_expand)
        self.tree.connect('row-collapsed', self.on_collapsed)
        self.tree.connect('row-activated', self.on_row_activated)
        self.tree.connect('key-release-event', self.on_key_released)

        event.add_ui_callback(self._add_driver_cb, 'station_added',
                              self.manager)
        event.add_ui_callback(self._remove_driver_cb, 'station_removed',
                              self.manager)
示例#47
0
    def __init__(self, exaile):
        self.name = 'lyricsviewer'
        self.exaile = exaile
        self.lyrics_found = []

        self._initialize_widgets()
        self._panel = None

        event.add_ui_callback(self.playback_cb, 'playback_track_start')
        event.add_ui_callback(self.on_track_tags_changed, 'track_tags_changed')
        event.add_ui_callback(self.end_cb, 'playback_player_end')
        event.add_ui_callback(self.search_method_added_cb,
                              'lyrics_search_method_added')
        event.add_ui_callback(self.on_option_set,
                              'plugin_lyricsviewer_option_set')

        self.update_lyrics()
示例#48
0
    def __init__(self):
        playback.MoveMarkerMenuItem.__init__(self, 'repeat-segment', [],
                                             _('Repeat Segment'),
                                             'media-playlist-repeat')
        providers.ProviderHandler.__init__(self, 'playback-markers')

        self.beginning_marker = playback.Marker()
        self.beginning_marker.name = 'repeat-beginning'
        self.beginning_marker.props.anchor = playback.Anchor.NORTH_WEST
        self.beginning_marker.props.label = _('Repeat Beginning')
        self.end_marker = playback.Marker()
        self.end_marker.name = 'repeat-end'
        self.end_marker.props.anchor = playback.Anchor.NORTH_EAST
        self.end_marker.props.label = _('Repeat End')
        self.end_marker.connect('reached', self.on_end_marker_reached)

        event.add_ui_callback(self.on_playback_track_end, 'playback_track_end')
示例#49
0
    def __init__(self):
        playback.MoveMarkerMenuItem.__init__(self,
            'repeat-segment', [], _('Repeat Segment'),
            'media-playlist-repeat')
        providers.ProviderHandler.__init__(self,
            'playback-markers')

        self.beginning_marker = playback.Marker()
        self.beginning_marker.name = 'repeat-beginning'
        self.beginning_marker.props.anchor = playback.Anchor.NORTH_WEST
        self.beginning_marker.props.label = _('Repeat Beginning')
        self.end_marker = playback.Marker()
        self.end_marker.name = 'repeat-end'
        self.end_marker.props.anchor = playback.Anchor.NORTH_EAST
        self.end_marker.props.label = _('Repeat End')
        self.end_marker.connect('reached', self.on_end_marker_reached)

        event.add_ui_callback(self.on_playback_track_end, 'playback_track_end')
示例#50
0
文件: __init__.py 项目: exaile/exaile
    def __init__(self, namespace):
        Gtk.Window.__init__(self)
        self.set_title(_("IPython Console - Exaile"))
        self.set_size_request(750, 550)
        self.set_resizable(True)

        self.__ipv = IPView(namespace)
        self.__ipv.connect('destroy', lambda *_widget: self.destroy())
        self.__ipv.updateNamespace({'self': self})  # Expose self to IPython

        # make it scrollable
        scrolled_window = Gtk.ScrolledWindow()
        scrolled_window.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
        scrolled_window.add(self.__ipv)
        scrolled_window.show_all()
        self.add(scrolled_window)

        event.add_ui_callback(self.on_option_set, SETTINGS_STRING)
示例#51
0
    def __init__(self, namespace):
        Gtk.Window.__init__(self)
        self.set_title(_("IPython Console - Exaile"))
        self.set_size_request(750, 550)
        self.set_resizable(True)

        self.__ipv = IPView(namespace)
        self.__ipv.connect('destroy', lambda *_widget: self.destroy())
        self.__ipv.updateNamespace({'self': self})  # Expose self to IPython

        # make it scrollable
        scrolled_window = Gtk.ScrolledWindow()
        scrolled_window.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
        scrolled_window.add(self.__ipv)
        scrolled_window.show_all()
        self.add(scrolled_window)

        event.add_ui_callback(self.on_option_set, SETTINGS_STRING)
示例#52
0
    def __init__(
            self,
            parent,
            collection,
            name=None,
            _show_collection_empty_message=False,
            label=_('Collection'),
    ):
        """
            Initializes the collection panel

            @param parent: the parent dialog
            @param collection: the xl.collection.Collection instance
            @param name: an optional name for this panel
        """
        panel.Panel.__init__(self, parent, name, label)

        self._show_collection_empty_message = _show_collection_empty_message
        self.collection = collection
        self.use_alphabet = settings.get_option('gui/use_alphabet', True)
        self.panel_stack = self.builder.get_object('CollectionPanel')
        self.panel_content = self.builder.get_object('CollectionPanelContent')
        self.panel_empty = self.builder.get_object('CollectionPanelEmpty')
        self.choice = self.builder.get_object('collection_combo_box')
        self._search_num = 0
        self._refresh_id = 0
        self.start_count = 0
        self.keyword = ''
        self.orders = DEFAULT_ORDERS[:]
        self._setup_tree()
        self._setup_widgets()
        self._check_collection_empty()
        self._setup_images()
        self._connect_events()
        self.order = None
        self.tracks = []
        self.sorted_tracks = []

        event.add_ui_callback(self._check_collection_empty,
                              'libraries_modified', collection)

        self.menu = menus.CollectionContextMenu(self)

        self.load_tree()
示例#53
0
    def connect_events(self):
        """
            Connects various callbacks with events
        """
        self.connect('button-press-event', self.on_button_press_event)
        self.connect('scroll-event', self.on_scroll_event)

        event.add_ui_callback(self.on_playback_change_state, 'playback_player_end', player.PLAYER)
        event.add_ui_callback(self.on_playback_change_state, 'playback_track_start', player.PLAYER)
        event.add_ui_callback(self.on_playback_change_state, 'playback_toggle_pause', player.PLAYER)
        event.add_ui_callback(self.on_playback_change_state, 'playback_error', player.PLAYER)
示例#54
0
文件: tray.py 项目: hayate891/exaile
    def connect_events(self):
        """
            Connects various callbacks with events
        """
        self.connect('button-press-event', self.on_button_press_event)
        self.connect('scroll-event', self.on_scroll_event)

        event.add_ui_callback(self.on_playback_change_state, 'playback_player_end', player.PLAYER)
        event.add_ui_callback(self.on_playback_change_state, 'playback_track_start', player.PLAYER)
        event.add_ui_callback(self.on_playback_change_state, 'playback_toggle_pause', player.PLAYER)
        event.add_ui_callback(self.on_playback_change_state, 'playback_error', player.PLAYER)
示例#55
0
    def __init__(self, namespace):
        ip.IPythonView.__init__(self)
        event.add_ui_callback(self.__on_option_set, SETTINGS_STRING)
        self.set_wrap_mode(Gtk.WrapMode.CHAR)

        self.updateNamespace(namespace)  # expose exaile (passed in)

        # prevent exit and quit - freezes window? does bad things
        self.updateNamespace({'exit': None,
                              'quit': None})

        style_context = self.get_style_context()
        self.__css_provider = Gtk.CssProvider()
        style_context.add_provider(self.__css_provider,
                                   Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)
        # Trigger setup through options
        for option in ('text_color', 'background_color', 'font'):
            self.__on_option_set(None, xl_settings,
                                 'plugin/ipconsole/{option}'.format(option=option))
示例#56
0
文件: devices.py 项目: exaile/exaile
    def __init__(self, parent, main):
        Gtk.Window.__init__(self)
        self.init_template()

        self.main = main
        self.device_manager = self.main.exaile.devices
        self.set_transient_for(parent)

        # TODO: make these actually work.  For now, they are hidden
        self.btn_add.destroy()
        self.btn_edit.destroy()
        self.btn_remove.destroy()

        # GtkListStore self.model: first column (PyObject) should really be of
        # type devices.Device, but that doesn't work with GtkBuilder.

        self.populate_tree()
        event.add_ui_callback(self.populate_tree, 'device_added')
        event.add_ui_callback(self.populate_tree, 'device_removed')
示例#57
0
    def __init__(self, exaile):
        self.name = 'lyricsviewer'
        self.exaile = exaile
        self.notebook = exaile.gui.panel_notebook
        self.source_url = ""
        self.lyrics_found = []

        self._initialize_widgets()
        self._panel = None

        event.add_ui_callback(self.playback_cb, 'playback_track_start')
        event.add_ui_callback(self.on_track_tags_changed, 'track_tags_changed')
        event.add_ui_callback(self.end_cb, 'playback_player_end')
        event.add_ui_callback(self.search_method_added_cb,
                'lyrics_search_method_added')
        event.add_ui_callback(self.on_option_set, 'plugin_lyricsviewer_option_set')
        #self.style_handler = self.notebook.connect('style-set', self.set_style)

        self.update_lyrics()
示例#58
0
文件: __init__.py 项目: exaile/exaile
    def __init__(self, namespace):
        ip.IPythonView.__init__(self)
        event.add_ui_callback(self.__on_option_set, SETTINGS_STRING)
        self.set_wrap_mode(Gtk.WrapMode.CHAR)

        self.updateNamespace(namespace)  # expose exaile (passed in)

        # prevent exit and quit - freezes window? does bad things
        self.updateNamespace({'exit': None, 'quit': None})

        style_context = self.get_style_context()
        self.__css_provider = Gtk.CssProvider()
        style_context.add_provider(
            self.__css_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
        )
        # Trigger setup through options
        for option in ('text_color', 'background_color', 'font'):
            self.__on_option_set(
                None, xl_settings, 'plugin/ipconsole/{option}'.format(option=option)
            )
示例#59
0
文件: controls.py 项目: exaile/exaile
    def __init__(self):
        Gtk.ComboBox.__init__(self)
        BaseControl.__init__(self)
        QueueAdapter.__init__(self, player.QUEUE)

        self.formatter = TrackFormatter('')
        self.model = Gtk.ListStore(object)
        self.set_model(self.model)

        self.synchronize()

        renderer = Gtk.CellRendererText()
        self.pack_start(renderer, True)
        self.set_cell_data_func(renderer, self.data_func)
        self.set_size_request(200, 0)

        event.add_ui_callback(self.on_option_set, 'plugin_minimode_option_set')
        self.on_option_set(
            'plugin_minimode_option_set', settings, 'plugin/minimode/track_title_format'
        )