示例#1
0
def __update_maps():

    from xl.metadata.tags import tag_data

    for tag, data in tag_data.iteritems():

        if data is None:
            continue

        # don't catch this KeyError -- if it fails, fix it!
        criteria = __criteria_types[data.type]

        if criteria is None:
            continue

        CRITERIA.append((data.name, criteria))

        _NMAP[data.name] = tag
示例#2
0
def __update_maps():
    
    from xl.metadata.tags import tag_data
    
    for tag, data in tag_data.iteritems():
        
        if data is None:
            continue
        
        # don't catch this KeyError -- if it fails, fix it!
        criteria = __criteria_types[data.type]
        
        if criteria is None:
            continue
            
        CRITERIA.append((data.name, criteria))
        
        _NMAP[data.name] = tag
示例#3
0
    def _attach_sort_widgets(cls, dialog, tag, reverse):
        # Add sort widgets
        from xl.metadata.tags import tag_data

        dialog.sort_enable = sort_enable = Gtk.CheckButton.new_with_label(
            _('Sort by:'))

        def _on_sort_enable_changed(ck):
            sort_tags.set_sensitive(ck.get_active())
            sort_order.set_sensitive(ck.get_active())

        sort_enable.connect('toggled', _on_sort_enable_changed)

        dialog.sort_tags = sort_tags = Gtk.ComboBoxText.new()
        sort_tags.set_wrap_width(5)
        for k, v in sorted(tag_data.iteritems()):
            if v:
                sort_tags.append(k, v.translated_name)

        dialog.sort_order = sort_order = Gtk.ComboBoxText.new()
        sort_order.append("False", _("Ascending"))
        sort_order.append("True", _("Descending"))

        box = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, 5)
        box.pack_start(sort_enable, False, False, 0)
        box.pack_start(sort_tags, False, False, 0)
        box.pack_start(sort_order, False, False, 0)
        box.show_all()

        dialog.get_content_area().pack_start(box, False, False, 5)

        # Set it up
        if tag is None:
            sort_enable.set_active(False)
            sort_order.set_active_id("False")
        else:
            sort_enable.set_active(True)
            sort_tags.set_active_id(tag)
            sort_order.set_active_id(str(reverse))

        _on_sort_enable_changed(sort_enable)
示例#4
0
    def _attach_sort_widgets(cls, dialog, tag, reverse):
        # Add sort widgets
        from xl.metadata.tags import tag_data

        dialog.sort_enable = sort_enable = Gtk.CheckButton.new_with_label(_('Sort by:'))

        def _on_sort_enable_changed(ck):
            sort_tags.set_sensitive(ck.get_active())
            sort_order.set_sensitive(ck.get_active())

        sort_enable.connect('toggled', _on_sort_enable_changed)

        dialog.sort_tags = sort_tags = Gtk.ComboBoxText.new()
        sort_tags.set_wrap_width(5)
        for k, v in sorted(tag_data.iteritems()):
            if v:
                sort_tags.append(k, v.translated_name)

        dialog.sort_order = sort_order = Gtk.ComboBoxText.new()
        sort_order.append("False", _("Ascending"))
        sort_order.append("True", _("Descending"))

        box = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, 5)
        box.pack_start(sort_enable, False, False, 0)
        box.pack_start(sort_tags, False, False, 0)
        box.pack_start(sort_order, False, False, 0)
        box.show_all()

        dialog.get_content_area().pack_start(box, False, False, 5)

        # Set it up
        if tag is None:
            sort_enable.set_active(False)
            sort_order.set_active_id("False")
        else:
            sort_enable.set_active(True)
            sort_tags.set_active_id(tag)
            sort_order.set_active_id(str(reverse))

        _on_sort_enable_changed(sort_enable)
示例#5
0
def __update_maps():

    from xl.metadata.tags import tag_data

    for tag, data in tag_data.iteritems():

        if data is None:
            continue

        # don't catch this KeyError -- if it fails, fix it!
        criteria = _criteria_types[data.type]

        if criteria is None:
            continue

        CRITERIA.append((data.name, criteria))

        _NMAP[data.name] = tag

    for k, v in _NMAP.iteritems():
        if v in _REV_NMAP:
            raise ValueError("_REV_NMAP Internal error: '%s', '%s'" % (k, v))
        _REV_NMAP[v] = k
示例#6
0
    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_container'),
            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_table = self.builder.get_object('tags_table')
        self.properties_table = self.builder.get_object('properties_table')
        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.iteritems():
            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',
            'album',
            'discnumber',
            'date',
            'genre',
            'cover',
            'comment',
            '__startoffset',
            '__stopoffset'
        ]
        
        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.dialog.resize(600, 350)
        self.dialog.show()

        self.rows[0].field.grab_focus()
示例#7
0
    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_container'),
            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.iteritems():
            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', '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()