def __init__(self, parent, collection): """ Initializes the dialog """ self.parent = parent self.collection = collection builder = gtk.Builder() builder.add_from_file(xdg.get_data_path('ui', 'collection_manager.ui')) self.dialog = builder.get_object('CollectionManager') self.dialog.set_transient_for(self.parent) self.view = builder.get_object('view') self.model = builder.get_object('model') self.remove_button = builder.get_object('remove_button') self.message = dialogs.MessageBar( parent=builder.get_object('content_area'), buttons=gtk.BUTTONS_CLOSE) builder.connect_signals(self) selection = self.view.get_selection() selection.connect('changed', self.on_selection_changed) for location, library in collection.libraries.iteritems(): self.model.append( [location, library.monitored, library.startup_scan])
def __init__(self, exaile): self.exaile = exaile self.do_shutdown = False # add menuitem to tools menu providers.register( 'menubar-tools-menu', menu.simple_separator('plugin-sep', ['track-properties'])) item = menu.check_menu_item( 'shutdown', ['plugin-sep'], _('Shutdown after Playback'), # checked func # callback func lambda *x: self.do_shutdown, lambda w, n, p, c: self.on_toggled(w)) providers.register('menubar-tools-menu', item) self.countdown = None self.counter = 10 self.message = dialogs.MessageBar( parent=exaile.gui.builder.get_object('player_box'), buttons=gtk.BUTTONS_CLOSE) self.message.connect('response', self.on_response)
def __init__(self, preferences, widget): """ Initializes the preferences item expects the name of the widget in the designer file, the default for this setting, an optional function to be called when the value is changed, and an optional function to be called when this setting is applied """ self.widget = widget self.preferences = preferences if self.restart_required: self.message = dialogs.MessageBar( parent=preferences.builder.get_object('preferences_box'), type=gtk.MESSAGE_QUESTION, buttons=gtk.BUTTONS_CLOSE, text=_('Restart Exaile?')) self.message.set_secondary_text( _('A restart is required for this change to take effect.')) button = self.message.add_button(_('Restart'), gtk.RESPONSE_ACCEPT) button.set_image(gtk.image_new_from_stock( gtk.STOCK_REFRESH, gtk.ICON_SIZE_BUTTON)) self.message.connect('response', self.on_message_response) self._set_value() self._setup_change()
def __init__(self, plugin, selected_playlist=None): self.plugin = plugin guiutil.initialize_from_xml(self) self.info_bar = dialogs.MessageBar(self.info_bar, type=Gtk.MessageType.ERROR, buttons=Gtk.ButtonsType.CLOSE) self.__build_template_list() self.__build_playlist_list(selected_playlist) self.__initialize_presets() self.__tag_widgets = [] self.window.show_all() def tag_data_key(td): if td: return td.translated_name # convenience td = tag_data.values() # Add grouptagger to the list gt = get_default_tagdata('__grouptagger') gt.translated_name = _('GroupTagger') td.append(gt) self.__sorted_tags = sorted(td, key=tag_data_key) # setup the selected template guiutil.persist_selection(self.template_list, 0, 'plugin/playlistanalyzer/last_tmpl')
def __init__(self, preferences, widget): """ Initializes the preferences item expects the name of the widget in the designer file, the default for this setting, an optional function to be called when the value is changed, and an optional function to be called when this setting is applied """ self.widget = widget self.preferences = preferences if self.restart_required: self.message = dialogs.MessageBar( parent=preferences.builder.get_object('preferences_box'), type=Gtk.MessageType.QUESTION, buttons=Gtk.ButtonsType.CLOSE, text=_('Restart Exaile?')) self.message.set_secondary_text( _('A restart is required for this change to take effect.')) button = self.message.add_button(_('Restart'), Gtk.ResponseType.ACCEPT) button.set_image( Gtk.Image.new_from_icon_name('view-refresh', Gtk.IconSize.BUTTON)) self.message.connect('response', self.on_message_response) self._set_value() self._setup_change()
def __init__(self, parent, collection: xl.collection.Collection): """ Initializes the dialog """ Gtk.Dialog.__init__(self) self.init_template() self.parent = parent self.collection = collection self.set_transient_for(self.parent) self.message = dialogs.MessageBar(parent=self.content_area, buttons=Gtk.ButtonsType.CLOSE) for location, library in collection.libraries.items(): self.model.append( [location, library.monitored, library.startup_scan]) # Override the data function for location_column, so that it # displays parsed location names instead of escaped URIs def display_parsed_location(column, cell, model, iter, *data): location_uri = model.get(iter, 0)[0] # first column location = Gio.File.new_for_uri(location_uri) cell.set_property("text", location.get_parse_name()) self.location_column.set_cell_data_func(self.location_cellrenderer, display_parsed_location)
def __init__(self, preferences, widget): """ Sets up the message """ widgets.Button.__init__(self, preferences, widget) self.message = dialogs.MessageBar( parent=preferences.builder.get_object('preferences_box'), buttons=gtk.BUTTONS_CLOSE)
def __init__(self, parent, track, search=None): """ Expects the parent control, a track, an an optional search string """ GObject.GObject.__init__(self) self.parent = parent self.builder = Gtk.Builder() self.builder.add_from_file(xdg.get_data_path('ui', 'coverchooser.ui')) self.builder.connect_signals(self) self.window = self.builder.get_object('CoverChooser') self.window.set_title( _("Cover options for %(artist)s - %(album)s") % { 'artist': track.get_tag_display('artist'), 'album': track.get_tag_display('album'), } ) self.window.set_transient_for(parent) self.message = dialogs.MessageBar( parent=self.builder.get_object('main_container'), buttons=Gtk.ButtonsType.CLOSE, ) self.message.connect('response', self.on_message_response) self.track = track self.covers = [] self.current = 0 self.cover = guiutil.ScalableImageWidget() self.cover.set_image_size(350, 350) self.cover_image_box = self.builder.get_object('cover_image_box') self.stack = self.builder.get_object('stack') self.stack_ready = self.builder.get_object('stack_ready') self.size_label = self.builder.get_object('size_label') self.source_label = self.builder.get_object('source_label') self.covers_model = self.builder.get_object('covers_model') self.previews_box = self.builder.get_object('previews_box') self.previews_box.set_no_show_all(True) self.previews_box.hide() self.previews_box.set_model(None) self.set_button = self.builder.get_object('set_button') self.set_button.set_sensitive(False) self.window.show_all() self.stopper = threading.Event() self.fetcher_thread = threading.Thread( target=self.fetch_cover, name='Coverfetcher' ) self.fetcher_thread.start()
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)
def __init__(self, parent, collection): """ Initializes the window """ GObject.GObject.__init__(self) # List of identifiers of albums without covers self.outstanding = [] # Map of album identifiers and their tracks self.album_tracks = {} self.outstanding_text = _('{outstanding} covers left to fetch') self.completed_text = _('All covers fetched') self.cover_size = (90, 90) self.default_cover_pixbuf = pixbuf_from_data( COVER_MANAGER.get_default_cover(), self.cover_size ) builder = Gtk.Builder() builder.add_from_file(xdg.get_data_path('ui', 'covermanager.ui')) builder.connect_signals(self) self.window = builder.get_object('window') self.window.set_transient_for(parent) self.message = dialogs.MessageBar( parent=builder.get_object('content_area'), buttons=Gtk.ButtonsType.CLOSE ) self.previews_box = builder.get_object('previews_box') self.model = builder.get_object('covers_model') # Map of album identifiers and model paths self.model_path_cache = {} self.menu = CoverMenu(self) self.menu.attach_to_widget(self.previews_box, lambda menu, widget: True) self.progress_bar = builder.get_object('progressbar') self.progress_bar.set_text(_('Collecting albums and covers...')) self.progress_bar.pulse_timeout = GLib.timeout_add( 100, self.on_progress_pulse_timeout ) self.close_button = builder.get_object('close_button') self.stop_button = builder.get_object('stop_button') self.stop_button.set_sensitive(False) self.fetch_button = builder.get_object('fetch_button') self.window.show_all() self.stopper = threading.Event() thread = threading.Thread( target=self.prefetch, name='CoverPrefetch', args=(collection,) ) thread.daemon = True thread.start()
def __init__(self, preferences, widget): """ Sets up the message """ widgets.Button.__init__(self, preferences, widget) self.message = dialogs.MessageBar( parent=preferences.builder.get_object('preferences_box'), buttons=Gtk.ButtonsType.CLOSE) self.errors = { pylast.STATUS_INVALID_API_KEY: _('The API key is invalid.') }
def __init__(self, parent, collection): """ Initializes the dialog """ Gtk.Dialog.__init__(self) self.init_template() self.parent = parent self.collection = collection self.set_transient_for(self.parent) self.message = dialogs.MessageBar(parent=self.content_area, buttons=Gtk.ButtonsType.CLOSE) for location, library in collection.libraries.iteritems(): self.model.append( [location, library.monitored, library.startup_scan])
def __init__(self, parent, tracks, current_position=0, with_extras=False): """ :param parent: the parent window for modal operation :type parent: :class:`Gtk.Window` :param tracks: the tracks to process :type tracks: list of :class:`xl.trax.Track` objects :param current_position: the position of the currently selected track in the list :type current_position: int :param with_extras: whether there are extra, non-selected tracks in `tracks` (currently happens when only 1 track is selected) :type with_extras: bool """ GObject.GObject.__init__(self) self.builder = Gtk.Builder() self.builder.add_from_file( xdg.get_data_path('ui', 'trackproperties_dialog.ui')) self.builder.connect_signals(self) self.dialog = self.builder.get_object('TrackPropertiesDialog') self.dialog.set_transient_for(parent) self.__default_attributes = Pango.AttrList() self.__changed_attributes = Pango.AttrList() self.message = dialogs.MessageBar( parent=self.builder.get_object('main_content'), buttons=Gtk.ButtonsType.CLOSE, ) self.remove_tag_button = self.builder.get_object('remove_tag_button') self.cur_track_label = self.builder.get_object('current_track_label') self.apply_button = self.builder.get_object('apply_button') self.prev_button = self.builder.get_object('prev_track_button') self.next_button = self.builder.get_object('next_track_button') self.tags_grid = self.builder.get_object('tags_grid') self.properties_grid = self.builder.get_object('properties_grid') self.rows = [] self.new_tag_combo = self.builder.get_object('new_tag_combo') self.new_tag_combo_list = Gtk.ListStore(str, str) for tag, tag_info in tag_data.items(): if tag_info is not None and tag_info.editable: self.new_tag_combo_list.append((tag, tag_info.translated_name)) self.new_tag_combo_list.set_sort_column_id(1, Gtk.SortType.ASCENDING) self.new_tag_combo.set_model(self.new_tag_combo_list) self.add_tag_button = self.builder.get_object('add_tag_button') self.add_tag_button.set_sensitive(False) # Show these tags for all tracks, no matter what def_tags = [ 'tracknumber', 'title', 'artist', 'albumartist', 'album', 'discnumber', 'date', 'genre', 'cover', 'comment', '__startoffset', '__stopoffset', 'lyrics', ] self.def_tags = OrderedDict([(tag, tag_data[tag]) for tag in def_tags]) # Store the tracks and a working copy self.tracks = tracks self.trackdata = self._tags_copy(tracks) self.trackdata_original = self._tags_copy(tracks) self.current_position = current_position self._build_from_track(self.current_position) self._setup_position() self.dialog.show() self.rows[0].field.grab_focus()
def __init__(self, parent, track, search=None): """ Expects the parent control, a track, an an optional search string """ gobject.GObject.__init__(self) self.parent = parent self.builder = gtk.Builder() self.builder.add_from_file(xdg.get_data_path('ui/coverchooser.ui')) self.builder.connect_signals(self) self.window = self.builder.get_object('CoverChooser') self.window.set_title(_("Cover options for %(artist)s - %(album)s") % { 'artist': track.get_tag_display('artist'), 'album': track.get_tag_display('album') }) self.window.set_transient_for(parent) self.message = dialogs.MessageBar( parent=self.builder.get_object('main_container'), buttons=gtk.BUTTONS_CLOSE ) self.message.connect('response', self.on_message_response) self.track = track self.covers = [] self.current = 0 self.cover = guiutil.ScalableImageWidget() self.cover.set_image_size(350, 350) self.cover_image_box = self.builder.get_object('cover_image_box') self.loading_indicator = gtk.Alignment() self.loading_indicator.props.xalign = 0.5 self.loading_indicator.props.yalign = 0.5 self.loading_indicator.set_size_request(350, 350) self.cover_image_box.pack_start(self.loading_indicator) try: spinner = gtk.Spinner() spinner.set_size_request(100, 100) spinner.start() self.loading_indicator.add(spinner) except AttributeError: # Older than GTK 2.20 and PyGTK 2.22 self.loading_indicator.add(gtk.Label(_('Loading...'))) self.size_label = self.builder.get_object('size_label') self.source_label = self.builder.get_object('source_label') self.covers_model = self.builder.get_object('covers_model') self.previews_box = self.builder.get_object('previews_box') self.previews_box.set_no_show_all(True) self.previews_box.hide() self.previews_box.set_model(None) self.set_button = self.builder.get_object('set_button') self.set_button.set_sensitive(False) self.window.show_all() self.stopper = threading.Event() self.fetcher_thread = threading.Thread(target=self.fetch_cover, name='Coverfetcher') self.fetcher_thread.start()
def _setup_widgets(self): """ Sets up the various widgets """ # TODO: Maybe make this stackable self.message = dialogs.MessageBar( parent=self.builder.get_object('player_box'), buttons=Gtk.ButtonsType.CLOSE) self.info_area = MainWindowTrackInfoPane(player.PLAYER) self.info_area.set_auto_update(True) self.info_area.set_border_width(3) self.info_area.hide() self.info_area.set_no_show_all(True) guiutil.gtk_widget_replace(self.builder.get_object('info_area'), self.info_area) self.volume_control = playback.VolumeControl(player.PLAYER) self.info_area.get_action_area().pack_end(self.volume_control, False, False, 0) if settings.get_option('gui/use_alpha', False): screen = self.window.get_screen() visual = screen.get_rgba_visual() self.window.set_visual(visual) self.window.connect('screen-changed', self.on_screen_changed) self._update_alpha() self._update_dark_hint() playlist_area = self.builder.get_object('playlist_area') self.playlist_container = PlaylistContainer('saved_tabs', player.PLAYER) for notebook in self.playlist_container.notebooks: notebook.connect_after('switch-page', self.on_playlist_container_switch_page) page = notebook.get_current_tab() if page is not None: selection = page.view.get_selection() selection.connect('changed', self.on_playlist_view_selection_changed) playlist_area.pack_start(self.playlist_container, True, True, 3) self.splitter = self.builder.get_object('splitter') # In most (all?) RTL locales, the playback controls should still be LTR. # Just in case that's not always the case, we provide a hidden option to # force RTL layout instead. This can be removed once we're more certain # that the default behavior (always LTR) is correct. controls_direction = (Gtk.TextDirection.RTL if settings.get_option('gui/rtl_playback_controls') else Gtk.TextDirection.LTR) self.play_image = Gtk.Image.new_from_icon_name( 'media-playback-start', Gtk.IconSize.SMALL_TOOLBAR) self.play_image.set_direction(controls_direction) self.pause_image = Gtk.Image.new_from_icon_name( 'media-playback-pause', Gtk.IconSize.SMALL_TOOLBAR) self.pause_image.set_direction(controls_direction) play_toolbar = self.builder.get_object('play_toolbar') play_toolbar.set_direction(controls_direction) for button in ('playpause', 'next', 'prev', 'stop'): widget = self.builder.get_object('%s_button' % button) setattr(self, '%s_button' % button, widget) widget.get_child().set_direction(controls_direction) self.progress_bar = playback.SeekProgressBar(player.PLAYER) self.progress_bar.get_child().set_direction(controls_direction) # Don't expand vertically; looks awful on Adwaita. self.progress_bar.set_valign(Gtk.Align.CENTER) guiutil.gtk_widget_replace( self.builder.get_object('playback_progressbar_dummy'), self.progress_bar) self.stop_button.toggle_spat = False self.stop_button.add_events(Gdk.EventMask.POINTER_MOTION_MASK) self.stop_button.connect('motion-notify-event', self.on_stop_button_motion_notify_event) self.stop_button.connect('leave-notify-event', self.on_stop_button_leave_notify_event) self.stop_button.connect('key-press-event', self.on_stop_button_key_press_event) self.stop_button.connect('key-release-event', self.on_stop_button_key_release_event) self.stop_button.connect('focus-out-event', self.on_stop_button_focus_out_event) self.stop_button.connect('button-press-event', self.on_stop_button_press_event) self.stop_button.connect('button-release-event', self.on_stop_button_release_event) self.stop_button.drag_dest_set( Gtk.DestDefaults.ALL, [ Gtk.TargetEntry.new("exaile-index-list", Gtk.TargetFlags.SAME_APP, 0) ], Gdk.DragAction.COPY, ) self.stop_button.connect('drag-motion', self.on_stop_button_drag_motion) self.stop_button.connect('drag-leave', self.on_stop_button_drag_leave) self.stop_button.connect('drag-data-received', self.on_stop_button_drag_data_received) self.statusbar = info.Statusbar(self.builder.get_object('status_bar')) event.add_ui_callback(self.on_exaile_loaded, 'exaile_loaded')
def _setup_widgets(self): """ Sets up the various widgets """ # TODO: Maybe make this stackable self.message = dialogs.MessageBar( parent=self.builder.get_object('player_box'), buttons=gtk.BUTTONS_CLOSE) self.message.connect('response', self.on_messagebar_response) self.info_area = MainWindowTrackInfoPane(player.PLAYER) self.info_area.set_auto_update(True) self.info_area.set_padding(3, 3, 3, 3) self.info_area.hide_all() self.info_area.set_no_show_all(True) guiutil.gtk_widget_replace(self.builder.get_object('info_area'), self.info_area) self.volume_control = playback.VolumeControl(player.PLAYER) self.info_area.get_action_area().pack_start(self.volume_control) if settings.get_option('gui/use_alpha', False): screen = self.window.get_screen() colormap = screen.get_rgba_colormap() if colormap is not None: self.window.set_app_paintable(True) self.window.set_colormap(colormap) self.window.connect('expose-event', self.on_expose_event) self.window.connect('screen-changed', self.on_screen_changed) playlist_area = self.builder.get_object('playlist_area') self.playlist_container = PlaylistContainer('saved_tabs', player.PLAYER) for notebook in self.playlist_container.notebooks: notebook.connect_after('switch-page', self.on_playlist_container_switch_page) page = notebook.get_current_tab() if page is not None: selection = page.view.get_selection() selection.connect('changed', self.on_playlist_view_selection_changed) playlist_area.pack_start(self.playlist_container, padding=3) self.splitter = self.builder.get_object('splitter') self.progress_bar = playback.SeekProgressBar(player.PLAYER) guiutil.gtk_widget_replace( self.builder.get_object('playback_progressbar'), self.progress_bar) for button in ('playpause', 'next', 'prev', 'stop'): setattr(self, '%s_button' % button, self.builder.get_object('%s_button' % button)) self.stop_button.add_events(gtk.gdk.POINTER_MOTION_MASK) self.stop_button.connect('motion-notify-event', self.on_stop_button_motion_notify_event) self.stop_button.connect('leave-notify-event', self.on_stop_button_leave_notify_event) self.stop_button.connect('key-press-event', self.on_stop_button_key_press_event) self.stop_button.connect('key-release-event', self.on_stop_button_key_release_event) self.stop_button.connect('focus-out-event', self.on_stop_button_focus_out_event) self.stop_button.connect('button-press-event', self.on_stop_button_press_event) self.stop_button.connect('button-release-event', self.on_stop_button_release_event) self.stop_button.drag_dest_set( gtk.DEST_DEFAULT_ALL, [("exaile-index-list", gtk.TARGET_SAME_APP, 0)], gtk.gdk.ACTION_COPY) self.stop_button.connect('drag-motion', self.on_stop_button_drag_motion) self.stop_button.connect('drag-leave', self.on_stop_button_drag_leave) self.stop_button.connect('drag-data-received', self.on_stop_button_drag_data_received) self.statusbar = info.Statusbar(self.builder.get_object('status_bar')) event.add_callback(self.on_exaile_loaded, 'exaile_loaded')