def update_disc_usage (self):
        if not self.update:
            return
        if self.source.total_duration > self.disc_size:
            self.__capacity_exceeded.show ()
            
        else:
            self.__capacity_exceeded.hide ()

        # Flush events so progressbar redrawing gets done
        while gtk.events_pending():
            gtk.main_iteration(True)
        
        if self.source.total_duration > 0:
            duration = self.__disc_size - self.source.total_duration
            if duration > 0:
                dur = _("%s remaining")  % self.__hig_duration (duration)
            else:
                dur = _("%s overlaping") % self.__hig_duration (abs (duration))
        else:
            dur = _("Empty")
        
        self.__usage_label.set_text (dur)
            
        e = operations.Event(self)
        for l in self.listeners:
            l.on_contents_changed (e)
 def delete_many (self, indexes):
     assert isinstance(indexes, list)
     rows = []
     indexes.sort()
     low = indexes[0] - 1
     # Remove duplicate entries
     for i in indexes:
         if low == i:
             indexes.remove (i)
         low = i
     # Now decrement the offsets
     for i in range (len (indexes)):
         indexes[i] -= i
     
     # Remove the elements directly
     for i in indexes:
         # Copy native row
         r = dict(self.model.get(i))
         rows.append(r)
         self.__total_duration -= r['duration']
         del self.model[i]
     
     # Warn the listeners
     rows = tuple(rows)
     e = operations.Event(self)
     for l in self.listeners:
         l.on_musics_removed (e, rows)
Esempio n. 3
0
    def before_operation_starts(self, event, operation):
        e = operations.Event(self.parent)
        m = self.get_music_from_uri(operation.music)
        assert m

        for l in self.parent.listeners:
            if isinstance(l, FetchMusicListListener):
                l.before_music_fetched(e, m)
 def __set_disc_size (self, size):
     assert size in AudioMastering.disc_sizes
     self.__disc_size = size
     self.__size_list.set_active (AudioMastering.disc_sizes.index(size))
     self.update_disc_usage()
     e = operations.Event (self)
     for l in self.listeners:
         if hasattr (l, "on_disc_size_changed"):
             l.on_disc_size_changed (e)
 def __delitem__ (self, index):
     # Copy native row
     row = dict(self[index])
     del self.model[index]
     self.__total_duration -= row['duration']
     rows = (row,)
     if not self.__freezed:
         e = operations.Event (self)
         for l in self.listeners:
             l.on_musics_removed (e, rows)
    def append (self, row):
        row = self.__correct_row(row)
        self.model.append (row)
        self.__total_duration += int(row['duration'])

        if not self.__freezed:
            e = operations.Event (self)
            rows = (row,)
            for l in self.listeners:
                l.on_musics_added (e, rows)
 def append_many (self, rows):
     self.__freezed = True
     for row in rows:
         self.append (row)
     self.__freezed = False
     
     rows = tuple(rows)
     e = operations.Event(self)
     for l in self.listeners:
         l.on_musics_added (e, rows)
    def insert (self, index, row):

        row = self.__correct_row(row)
        self.model.insert_before (self.model.get_iter (index), row)
        self.__total_duration += int (row['duration'])

        if not self.__freezed:
            e = operations.Event (self)
            rows = (row,)
            for l in self.listeners:
                l.on_musics_added (e, rows)
Esempio n. 9
0
    def on_finished(self, event):
        try:
            duration = int(self.__metadata["duration"]) / gst.SECOND
        except KeyError:
            duration = 0
        self.__metadata["duration"] = duration

        evt = operations.Event(self)
        self._notify("on_metadata", evt, self.__metadata)

        self.__metadata = None
        self.__element = None
        self._send_finished_event(operations.SUCCESSFUL)
Esempio n. 10
0
 def clear (self):
     rows = []
     for row in iter(self.model):
         # Copy each element
         rows.append(dict(row))
     
     self.model.clear()
     self.__total_duration = 0
     
     rows = tuple(rows)
     e = operations.Event (self)
     for l in self.listeners:
         l.on_musics_removed(e, rows)
Esempio n. 11
0
    def on_finished(self, event):
        self.duration_counter = 0

        if event.id == operations.ERROR:
            self._propagate(event)
            return

        duration = int(self.__metadata.get("duration", 0)) / gst.SECOND

        if duration == 0:
            self._send_finished_event(operations.ERROR)
            return

        self.__metadata["duration"] = duration

        evt = operations.Event(self)
        self._notify("on_metadata", evt, self.__metadata)

        self.__metadata = None
        self.__element = None
        self._send_finished_event(operations.SUCCESSFUL)
Esempio n. 12
0
    def on_finished(self, event):
        if event.id == operations.ERROR:
            self._propagate(event)
            return

        try:
            duration = int(self.__metadata["duration"]) / gst.SECOND
        except KeyError:
            duration = 0

        if duration == -1 or duration == 0:
            self._send_finished_event(operations.ERROR)
            return

        self.__metadata["duration"] = duration

        evt = operations.Event(self)
        self._notify("on_metadata", evt, self.__metadata)

        self.__metadata = None
        self.__element = None
        self._send_finished_event(operations.SUCCESSFUL)
Esempio n. 13
0
    def on_finished(self, event):
        # When the operation is finished we send the metadata
        success = event.id == operations.ABORTED
        if success:
            # We've completed the operation successfully
            if self.__metadata.has_key("duration"):
                self.__metadata["duration"] /= gst.SECOND
            else:
                self.__metadata["duration"] = self.__oper.element.query(
                    gst.QUERY_TOTAL, gst.FORMAT_TIME) / gst.SECOND
            evt = operations.Event(self)

            for l in self.listeners:
                l.on_metadata(evt, self.__metadata)
            self.__metadata = None
            self.__element = None

        if success:
            success = operations.SUCCESSFUL
        else:
            success = operations.ERROR

        self._send_finished_event(success)
Esempio n. 14
0
 def __selection_changed (self, treeselection):
     e = operations.Event (self)
     for l in self.listeners:
         l.on_selection_changed (e)
Esempio n. 15
0
 def _on_error(self, error):
     event = operations.Event(self)
     self._notify("on_error", event, error)
     self._finalize(operations.ERROR, error)
Esempio n. 16
0
 def _on_eos(self):
     event = operations.Event(self)
     self._notify("on_eos", event)
     self._finalize(operations.SUCCESSFUL)
Esempio n. 17
0
 def _on_tag(self, taglist):
     event = operations.Event(self)
     self._notify("on_tag", event, taglist)