Ejemplo n.º 1
0
    def update_metadata(self,table,mp):
        """Write data back to the mediapackage"""
        for child in table.get_children():
            if child.name in DCTERMS:
                if child.name in ["creator", "contributor", "subject"]:
                    if child.get_text() == "":
                        mp.metadata_episode[child.name] = None
                    else:
                        mp.metadata_episode[child.name] = child.get_text().strip()

                elif child.name in [ "ispartof", "isPartOf" ]:
                    identifier = child.get_model()[child.get_active_iter()][1]
                    series = listseries.getSeriesbyId(identifier)
                    if series:
                        mp.setSeries(series["list"])
                        if not mp.getCatalogs("dublincore/series") and mp.getURI():
                            new_series = mediapackage.Catalog(os.path.join(mp.getURI(),"series.xml"),mimetype="text/xml",flavor="dublincore/series")
                            mp.add(new_series)                    
                    else: 
                        mp.setSeries(None)
                        catalog= mp.getCatalogs("dublincore/series")
                        if catalog:
                            mp.remove(catalog[0])
                else:
                    mp.metadata_episode[child.name]=child.get_text()
Ejemplo n.º 2
0
    def fill_metadata(self,table,mp,button,blocked=set(),mandatory=set()):
        """
        Fill the table with available data, empty otherwise
        """        
        for child in table.get_children():
            table.remove(child) #FIXME maybe change the glade to avoid removing any widget
        table.resize(1,2) 
        row = 1

        for meta in DCTERMS:
            t=gtk.Label(metadata[meta])
            t.set_justify(gtk.JUSTIFY_LEFT)
            t.set_alignment(0,0)
            modification = str(int(self.hprop*16))+"px"        
            t.modify_font(pango.FontDescription(modification))
            t.set_width_chars(15)

            # Switch the INSENSITIVE state colour to red, so that we can mark the mandatory parameters
            t.modify_fg(gtk.STATE_INSENSITIVE, gtk.gdk.color_parse('red'))            
            
            if meta in ["ispartof", "isPartOf"]:
                try:
                    default_series = listseries.getSeriesbyId(mp.metadata_series['identifier'])['id']
                except TypeError:
                    default_series = None
                
                d = ComboBoxEntryExt(self.par, self.series_list, default=default_series, empty_label = self.empty_series_label)
                d.set_name(meta)
            else:
                d=gtk.Entry()
                d.set_name(meta)
                try:
                    d.set_text(mp.metadata_episode[meta] or '')
                except KeyError:
                    d.set_text('')
                
            if meta in blocked:
                d.set_sensitive(False)

            if meta in mandatory:
                d.connect_after('changed', self.check_mandatory, button)
                self.mandatory[d] = t
            
            if meta == "created": # currently Unused
                d.connect("button-press-event",self.edit_date)
            if meta == "title":
                d.set_tooltip_text(d.get_text())

            d.modify_font(pango.FontDescription(modification))

            table.attach(t,0,1,row-1,row,False,False,0,0)
            table.attach(d,1,2,row-1,row,gtk.EXPAND|gtk.FILL,False,0,0)
            row=row+1
Ejemplo n.º 3
0
    def fill_metadata(self, table, mp, button, blocked=set(), mandatory=set()):
        """
        Fill the table with available data, empty otherwise
        """
        row = 1

        for meta in DCTERMS:
            t = Gtk.Label(label=metadata[meta])
            t.set_justify(Gtk.Justification.LEFT)
            t.set_alignment(0, 0)
            t.set_width_chars(15)

            # Switch the INSENSITIVE state colour to red, so that we can mark the mandatory parameters
            t.modify_fg(Gtk.StateType.INSENSITIVE, Gdk.color_parse("red"))

            if meta in ["ispartof", "isPartOf"]:
                try:
                    default_series = listseries.getSeriesbyId(mp.metadata_series["identifier"])["id"]
                except TypeError:
                    default_series = None

                d = ComboBoxEntryExt(
                    self.par, self.series_list, default=default_series, empty_label=self.empty_series_label
                )
                d.set_name(meta)
            else:
                d = Gtk.Entry()
                d.set_name(meta)
                try:
                    d.set_text(mp.metadata_episode[meta] or "")
                except KeyError:
                    d.set_text("")

            if meta in blocked:
                d.set_sensitive(False)

            if meta in mandatory:
                d.connect_after("changed", self.check_mandatory, button)
                self.mandatory[d] = t

            if meta == "created":  # currently Unused
                d.connect("button-press-event", self.edit_date)
            if meta == "title":
                d.set_tooltip_text(d.get_text())

            table.attach(t, 0, row - 1, 1, 1)
            table.attach(d, 1, row - 1, 2, 1)
            row = row + 1
Ejemplo n.º 4
0
    def update_metadata(self, table, mp):
        """Write data back to the mediapackage"""
        for child in table.get_children():
            if child.name in DCTERMS:
                if child.name in ["creator", "contributor", "subject"]:
                    if child.get_text() == "":
                        mp.metadata_episode[child.name] = None
                    else:
                        mp.metadata_episode[
                            child.name] = child.get_text().strip()

                elif child.name == "ispartof" or child.name == "isPartOf":
                    result = child.get_active_text()
                    model = child.get_model()
                    iterator = model.get_iter_first()
                    while iterator != None:
                        if model[iterator][0] == result:
                            break
                        iterator = model.iter_next(iterator)
                    identifier = model[iterator][1]
                    series = None
                    if result != NO_SERIES:
                        series = listseries.getSeriesbyId(identifier)

                    if series != None:
                        mp.setSeries(series["list"])
                        if not mp.getCatalogs(
                                "dublincore/series") and mp.getURI():
                            new_series = mediapackage.Catalog(
                                path.join(mp.getURI(), "series.xml"),
                                mimetype="text/xml",
                                flavor="dublincore/series")
                            mp.add(new_series)
                    else:
                        mp.setSeries(None)

                        catalog = mp.getCatalogs("dublincore/series")
                        if catalog:
                            mp.remove(catalog[0])
                else:
                    mp.metadata_episode[child.name] = child.get_text()
Ejemplo n.º 5
0
def on_rec(button):
    dispatcher = context.get_dispatcher()
    dispatcher.emit("disable-no-audio")
    global recorder_ui
    global metadata

    mp = recorder_ui.mediapackage

    # Add default metadata to the MP
    mp.metadata_episode.update(metadata)

    # Check the series
    try:
        del (mp.metadata_episode['isPartOf'])
        mp.metadata_series = list_series.getSeriesbyId(
            metadata['isPartOf'])['list']
    except (TypeError, KeyError):
        # There was no series specified, so no change was needed
        pass

    series_list = list_series.get_series()

    arguments = {
        'package': mp,
        'series_list': series_list,
        'title': _("New Recording"),
        'subtitle': _("New Recording"),
        'ok_label': _("Start"),
    }

    if len(series_list) <= 1:
        arguments['empty_series_label'] = None

    popup = MetadataClass(**arguments)

    if popup.return_value == -8:
        recorder_ui.on_rec()
    dispatcher.emit("enable-no-audio")
Ejemplo n.º 6
0
def on_rec(button):
    dispatcher = context.get_dispatcher()    
    dispatcher.emit("disable-no-audio")
    global recorder_ui
    global metadata

    mp = recorder_ui.mediapackage
    
    # Add default metadata to the MP
    mp.metadata_episode.update(metadata)
    
    # Check the series
    try:
        del(mp.metadata_episode['isPartOf'])
        mp.metadata_series = list_series.getSeriesbyId(metadata['isPartOf'])['list']
    except (TypeError, KeyError):
        # There was no series specified, so no change was needed
        pass

    series_list = list_series.get_series()

    arguments = { 'package': mp,
                  'series_list': series_list,
                  'title': _("New Recording"),
                  'subtitle': _("New Recording"),
                  'ok_label': _("Start"),
                  }
    
    if len(series_list) <= 1:
        arguments['empty_series_label'] = None
        
    popup = MetadataClass(**arguments)
    
    if popup.return_value == -8:
        recorder_ui.on_rec()
    dispatcher.emit("enable-no-audio")
Ejemplo n.º 7
0
    def update_metadata(self,table,mp):
        """Write data back to the mediapackage"""
        for child in table.get_children():
            if child.name in DCTERMS:
                if child.name in ["creator", "contributor", "subject"]:
                    if child.get_text() == "":
                        mp.metadata_episode[child.name] = None
                    else:
                        mp.metadata_episode[child.name] = child.get_text().strip()

                elif child.name == "ispartof" or child.name == "isPartOf":                 
                    result=child.get_active_text()
                    model = child.get_model()
                    iterator = model.get_iter_first()
                    while iterator != None:
                        if model[iterator][0] == result:
                            break
                        iterator = model.iter_next(iterator)                        
                    identifier = model[iterator][1]
                    series = None
                    if result != NO_SERIES:
                        series = listseries.getSeriesbyId(identifier)

                    if series != None:
                        mp.setSeries(series["list"])
                        if not mp.getCatalogs("dublincore/series") and mp.getURI():
                            new_series = mediapackage.Catalog(path.join(mp.getURI(),"series.xml"),mimetype="text/xml",flavor="dublincore/series")
                            mp.add(new_series)
                    else: 
                        mp.setSeries(None)

                        catalog= mp.getCatalogs("dublincore/series")
                        if catalog:
                            mp.remove(catalog[0])
                else:
                    mp.metadata_episode[child.name]=child.get_text()
Ejemplo n.º 8
0
    def update_metadata(self,table,mp):
        """Write data back to the mediapackage"""
        for child in table.get_children():
            if child.name in DCTERMS:
                if child.name == "creator":
                    if child.get_text() != "":                        
                        new = list(child.get_text().strip().split(','))
                        splitted = map(self.strip_spaces, new)
                        mp.setCreators(splitted)
                    else:
                        mp.setCreators(list())
                elif child.name == "contributor":
                    if child.get_text() != "":
                        new = list(child.get_text().strip().split(','))
                        splitted = map(self.strip_spaces, new)
                        mp.setContributors(splitted)
                    else:
                        mp.setContributors(list())
                elif child.name == "subject":
                    if child.get_text() != "":
                        new = list(child.get_text().strip().split(','))
                        splitted = map(self.strip_spaces, new)
                        mp.setSubjects(splitted)
                    else:
                        mp.setSubjects(list())
                elif child.name == "ispartof" or child.name == "isPartOf":
                    result=child.get_active_text()
                    model = child.get_model()
                    iterator = model.get_iter_first()
                    while iterator != None:
                        if model[iterator][0] == result:
                            break
                        iterator = model.iter_next(iterator)                        
                    identifier = model[iterator][1]
                    series = None
                    if result != NO_SERIES:
                        series = listseries.getSeriesbyId(identifier)

                    if series != None:
                        mp.series = series["id"]
                        mp.series_title = series["name"]

                        if not mp.getCatalogs("dublincore/series") and mp.getURI():
                            new_series = mediapackage.Catalog(path.join(mp.getURI(),"series.xml"),mimetype="text/xml",flavor="dublincore/series")
                            mp.add(new_series)

                    else: 
                        mp.series = None
                        mp.series_title = None

                        catalog= mp.getCatalogs("dublincore/series")
                        if catalog:
                            mp.remove(catalog[0])

                else:
                    mp.metadata_episode[child.name]=child.get_text()

        #mp.setTitle(mp.metadata_episode['title']) # WARNING title is a property
        mp.setLanguage(mp.metadata_episode['language'])
        mp.metadata_episode['creator']=mp.creators
        mp.metadata_episode['contributor']=mp.contributors
        mp.metadata_episode['subject']=mp.subjects
Ejemplo n.º 9
0
    def update_metadata(self,table,mp):
        """Write data back to the mediapackage"""
        for child in table.get_children():
            if child.name in DCTERMS:
                if child.name == "creator":
                    if child.get_text() != "":                        
                        new = list(child.get_text().strip().split(','))
                        splitted = map(self.strip_spaces, new)
                        mp.setCreators(splitted)
                    else:
                        mp.setCreators(list())
                elif child.name == "contributor":
                    if child.get_text() != "":
                        new = list(child.get_text().strip().split(','))
                        splitted = map(self.strip_spaces, new)
                        mp.setContributors(splitted)
                    else:
                        mp.setContributors(list())
                elif child.name == "subject":
                    if child.get_text() != "":
                        new = list(child.get_text().strip().split(','))
                        splitted = map(self.strip_spaces, new)
                        mp.setSubjects(splitted)
                    else:
                        mp.setSubjects(list())
                elif child.name == "ispartof" or child.name == "isPartOf":
                    result=child.get_active_text()
                    model = child.get_model()
                    iterator = model.get_iter_first()
                    while iterator != None:
                        if model[iterator][0] == result:
                            break
                        iterator = model.iter_next(iterator)                        
                    identifier = model[iterator][1]
                    series = None
                    if result != NO_SERIES:
                        series = listseries.getSeriesbyId(identifier)

                    if series != None:
                        mp.series = series["id"]
                        mp.series_title = series["name"]

                        if not mp.getCatalogs("dublincore/series") and mp.getURI():
                            new_series = mediapackage.Catalog(path.join(mp.getURI(),"series.xml"),mimetype="text/xml",flavor="dublincore/series")
                            mp.add(new_series)

                    else: 
                        mp.series = None
                        mp.series_title = None

                        catalog= mp.getCatalogs("dublincore/series")
                        if catalog:
                            mp.remove(catalog[0])

                else:
                    mp.metadata_episode[child.name]=child.get_text()

        #mp.setTitle(mp.metadata_episode['title']) # WARNING title is a property
        mp.setLanguage(mp.metadata_episode['language'])
        mp.metadata_episode['creator']=mp.creators
        mp.metadata_episode['contributor']=mp.contributors
        mp.metadata_episode['subject']=mp.subjects