def __init__(self, library, songs, parent=None): super(SongProperties, self).__init__(dialog=False) self.set_transient_for(qltk.get_top_parent(parent)) default_width = 600 config_suffix = "" if len(songs) <= 1: default_width -= 200 config_suffix += "single" self.set_default_size(default_width, 400) self.enable_window_tracking("quodlibet_properties", size_suffix=config_suffix) self.auto_save_on_change = config.getboolean( 'editing', 'auto_save_changes', False) paned = ConfigRPaned("memory", "quodlibet_properties_pos", 0.4) notebook = qltk.Notebook() notebook.props.scrollable = True pages = [] pages.extend([Ctr(self, library) for Ctr in [EditTags, TagsFromPath, RenameFiles]]) if len(songs) > 1: pages.append(TrackNumbers(self, library)) for page in pages: page.show() notebook.append_page(page) fbasemodel = ObjectStore() fmodel = ObjectModelSort(model=fbasemodel) fview = HintedTreeView(model=fmodel) fview.connect('button-press-event', self.__pre_selection_changed) fview.set_rules_hint(True) selection = fview.get_selection() selection.set_mode(Gtk.SelectionMode.MULTIPLE) self.__save = None render = Gtk.CellRendererText() c1 = Gtk.TreeViewColumn(_('File'), render) if fview.supports_hints(): render.set_property('ellipsize', Pango.EllipsizeMode.END) render.set_property('xpad', 3) def cell_data(column, cell, model, iter_, data): entry = model.get_value(iter_) cell.set_property('text', entry.name) c1.set_cell_data_func(render, cell_data) def sort_func(model, a, b, data): a = model.get_value(a) b = model.get_value(b) return cmp(a.name, b.name) fmodel.set_sort_func(100, sort_func) c1.set_sort_column_id(100) fview.append_column(c1) sw = ScrolledWindow() sw.add(fview) sw.set_shadow_type(Gtk.ShadowType.IN) sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) # only show the list if there are is more than one song if len(songs) > 1: sw.show_all() paned.pack1(sw, shrink=False, resize=True) for song in songs: fbasemodel.append(row=[_ListEntry(song)]) self.connect("changed", self.__on_changed) selection.select_all() paned.pack2(notebook, shrink=False, resize=True) csig = selection.connect('changed', self.__selection_changed) connect_destroy(library, 'changed', self.__on_library_changed, fbasemodel, fview) connect_destroy(library, 'removed', self.__on_library_removed, fbasemodel, selection, csig) self.emit('changed', songs) self.add(paned) paned.set_position(175) notebook.show() paned.show()
def __init__(self, parent): if self.is_not_unique(): return super(PluginWindow, self).__init__() self.set_title(_("Plugins") + " - Quod Libet") self.set_border_width(12) self.set_default_size(655, 404) self.set_transient_for(parent) hbox = gtk.HBox(spacing=12) vbox = gtk.VBox(spacing=6) sw = gtk.ScrolledWindow() sw.set_policy(gtk.POLICY_NEVER, gtk.POLICY_ALWAYS) tv = HintedTreeView() model = gtk.ListStore(object, object) filter = model.filter_new() tv.set_model(filter) tv.set_rules_hint(True) filter_entry = ClearEntry() filter_entry.connect("changed", lambda s: filter.refilter()) combo_store = gtk.ListStore(str, int) filter_combo = gtk.ComboBox(combo_store) cell = gtk.CellRendererText() filter_combo.pack_start(cell, True) filter_combo.add_attribute(cell, "text", 0) filter_combo.connect("changed", lambda s: filter.refilter()) combo_sep = lambda model, iter: model[iter][1] == SEP filter_combo.set_row_separator_func(combo_sep) fb = gtk.HBox(spacing=6) fb.pack_start(filter_combo, expand=False) filter_entry.enable_clear_button() fb.pack_start(filter_entry) render = gtk.CellRendererToggle() def cell_data(col, render, model, iter): row = model[iter] render.set_active(row[1].enabled(row[0])) render.connect('toggled', self.__toggled, filter) column = gtk.TreeViewColumn("enabled", render) column.set_cell_data_func(render, cell_data) tv.append_column(column) render = gtk.CellRendererPixbuf() def cell_data2(col, render, model, iter): icon = getattr(model[iter][0], 'PLUGIN_ICON', gtk.STOCK_EXECUTE) if gtk.stock_lookup(icon): render.set_property('stock-id', icon) else: render.set_property('icon-name', icon) column = gtk.TreeViewColumn("image", render) column.set_cell_data_func(render, cell_data2) tv.append_column(column) render = gtk.CellRendererText() render.set_property('ellipsize', pango.ELLIPSIZE_END) render.set_property('xalign', 0.0) column = gtk.TreeViewColumn("name", render) def cell_data3(col, render, model, iter): render.set_property('text', model[iter][0].PLUGIN_NAME) column.set_cell_data_func(render, cell_data3) column.set_expand(True) tv.append_column(column) sw.add(tv) sw.set_shadow_type(gtk.SHADOW_IN) sw.set_size_request(250, -1) tv.set_headers_visible(False) bbox = gtk.HBox(homogeneous=True, spacing=12) errors = qltk.Button(_("Show _Errors"), gtk.STOCK_DIALOG_WARNING) errors.set_focus_on_click(False) bbox.pack_start(errors) refresh = gtk.Button(stock=gtk.STOCK_REFRESH) refresh.set_focus_on_click(False) bbox.pack_start(refresh) vbox.pack_start(fb, expand=False) vbox.pack_start(sw) vbox.pack_start(bbox, expand=False) hbox.pack_start(vbox, expand=False) selection = tv.get_selection() desc = WrapLabel() desc.set_selectable(True) selection.connect('changed', self.__description, desc) prefs = gtk.Frame() prefs.set_shadow_type(gtk.SHADOW_NONE) close = gtk.Button(stock=gtk.STOCK_CLOSE) close.connect('clicked', lambda *x: self.destroy()) bb_align = gtk.Alignment(0, 1, 1, 0) bb = gtk.HButtonBox() bb.set_layout(gtk.BUTTONBOX_END) bb.pack_start(close) bb_align.add(bb) vb2 = gtk.VBox(spacing=12) vb2.pack_start(desc, expand=False) vb2.pack_start(prefs, expand=False) vb2.pack_start(bb_align) hbox.pack_start(vb2, expand=True) self.add(hbox) selection.connect('changed', self.__preferences, prefs) refresh.connect('clicked', self.__refresh, tv, desc, errors, filter_combo, combo_store) errors.connect('clicked', self.__show_errors) tv.get_selection().emit('changed') refresh.clicked() self.connect('destroy', self.__destroy) filter.set_visible_func( self.__filter, (filter_entry, filter_combo, combo_store)) self.show_all() filter_entry.grab_focus() restore_id = config.get("memory", "plugin_selection") def restore_sel(row): return row[0].PLUGIN_ID == restore_id if not tv.select_by_func(restore_sel, one=True) and tv.get_model(): tv.set_cursor((0,))
def __init__(self, library, songs, parent=None): super(SongProperties, self).__init__(dialog=False) self.set_transient_for(qltk.get_top_parent(parent)) default_width = 600 config_suffix = "" if len(songs) <= 1: default_width -= 200 config_suffix += "single" self.set_default_size(default_width, 400) self.enable_window_tracking("quodlibet_properties", size_suffix=config_suffix) self.auto_save_on_change = config.getboolean('editing', 'auto_save_changes', False) paned = Gtk.HPaned() notebook = qltk.Notebook() pages = [] pages.extend([ Ctr(self, library) for Ctr in [EditTags, TagsFromPath, RenameFiles] ]) if len(songs) > 1: pages.append(TrackNumbers(self, library)) for page in pages: page.show() notebook.append_page(page) self.set_border_width(12) fbasemodel = Gtk.ListStore(object, str) fmodel = Gtk.TreeModelSort(model=fbasemodel) fview = HintedTreeView(fmodel) fview.connect('button-press-event', self.__pre_selection_changed) fview.set_rules_hint(True) selection = fview.get_selection() selection.set_mode(Gtk.SelectionMode.MULTIPLE) self.__save = None if len(songs) > 1: render = Gtk.CellRendererText() c1 = Gtk.TreeViewColumn(_('File'), render, text=1) render.set_property('ellipsize', Pango.EllipsizeMode.END) c1.set_sort_column_id(1) fview.append_column(c1) sw = Gtk.ScrolledWindow() sw.add(fview) sw.set_shadow_type(Gtk.ShadowType.IN) sw.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC) sw.show_all() paned.pack1(sw, shrink=False, resize=True) # Invisible selections behave a little strangely. So, when # handling this selection, there's a lot of if len(model) == 1 # checks that "hardcode" the first row being selected. for song in songs: fbasemodel.append(row=[song, fsdecode(song("~basename"))]) self.connect_object('changed', SongProperties.__set_title, self) selection.select_all() paned.pack2(notebook, shrink=False, resize=True) csig = selection.connect('changed', self.__selection_changed) s1 = library.connect('changed', self.__refresh, fbasemodel, fview) s2 = library.connect('removed', self.__remove, fbasemodel, selection, csig) self.connect_object('destroy', library.disconnect, s1) self.connect_object('destroy', library.disconnect, s2) self.connect_object('changed', self.set_pending, None) self.emit('changed', songs) self.add(paned) paned.set_position(175) notebook.show() paned.show()
def __init__(self, library, songs, parent=None): super(SongProperties, self).__init__(dialog=False) self.set_transient_for(qltk.get_top_parent(parent)) default_width = 600 config_suffix = "" if len(songs) <= 1: default_width -= 200 config_suffix += "single" self.set_default_size(default_width, 400) self.enable_window_tracking("quodlibet_properties", size_suffix=config_suffix) self.auto_save_on_change = config.getboolean( 'editing', 'auto_save_changes', False) paned = gtk.HPaned() notebook = qltk.Notebook() pages = [] pages.extend([Ctr(self, library) for Ctr in [EditTags, TagsFromPath, RenameFiles]]) if len(songs) > 1: pages.append(TrackNumbers(self, library)) for page in pages: notebook.append_page(page) self.set_border_width(12) fbasemodel = gtk.ListStore(object, str) fmodel = gtk.TreeModelSort(fbasemodel) fview = HintedTreeView(fmodel) fview.connect('button-press-event', self.__pre_selection_changed) fview.set_rules_hint(True) selection = fview.get_selection() selection.set_mode(gtk.SELECTION_MULTIPLE) self.__save = None if len(songs) > 1: render = gtk.CellRendererText() c1 = gtk.TreeViewColumn(_('File'), render, text=1) render.set_property('ellipsize', pango.ELLIPSIZE_END) c1.set_sort_column_id(1) fview.append_column(c1) sw = gtk.ScrolledWindow() sw.add(fview) sw.set_shadow_type(gtk.SHADOW_IN) sw.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) sw.show_all() paned.pack1(sw, shrink=True, resize=True) # Invisible selections behave a little strangely. So, when # handling this selection, there's a lot of if len(model) == 1 # checks that "hardcode" the first row being selected. for song in songs: fbasemodel.append(row=[song, util.fsdecode(song("~basename"))]) self.connect_object('changed', SongProperties.__set_title, self) selection.select_all() paned.pack2(notebook, shrink=False, resize=True) csig = selection.connect('changed', self.__selection_changed) s1 = library.connect( 'changed', self.__refresh, fbasemodel, fview) s2 = library.connect( 'removed', self.__remove, fbasemodel, selection, csig) self.connect_object('destroy', library.disconnect, s1) self.connect_object('destroy', library.disconnect, s2) self.connect_object('changed', self.set_pending, None) self.emit('changed', songs) self.add(paned) paned.set_position(175) notebook.show() paned.show() self.show()