예제 #1
0
 def build_pixbuf(self):
     if self.annotation is None:
         pixbuf=png_to_pixbuf(self.controller.package.imagecache.not_yet_available_image,
                              width=self.width)
     elif 'overlay' in self.presentation:
         pixbuf=overlay_svg_as_pixbuf(self.annotation.rootPackage.imagecache[self.annotation.fragment.begin],
                                      self.annotation.content.data,
                                      width=self.width)
     elif 'snapshot' in self.presentation:
         if 'timestamp' in self.presentation:
             pixbuf=overlay_svg_as_pixbuf(self.annotation.rootPackage.imagecache[self.annotation.fragment.begin],
                                          helper.format_time(self.annotation.fragment.begin),
                                          width=self.width)
         else:
             pixbuf=png_to_pixbuf(self.annotation.rootPackage.imagecache[self.annotation.fragment.begin],
                                  width=self.width)
     elif 'timestamp' in self.presentation:
         # Generate only a timestamp
         pixbuf = self.render_text(helper.format_time(self.annotation.fragment.begin))
     elif 'content' in self.presentation:
         # Display text
         pixbuf = self.render_text(self.controller.get_title(self.annotation))
     else:
         pixbuf=png_to_pixbuf(self.controller.package.imagecache.not_yet_available_image,
                              width=self.width)
     pixbuf.as_html=self.as_html
     pixbuf._placeholder=self
     pixbuf._tag='span'
     pixbuf._attr=[]
     return pixbuf
예제 #2
0
 def build_pixbuf(self):
     if self.annotation is None:
         pixbuf=png_to_pixbuf(self.controller.package.imagecache.not_yet_available_image,
                              width=self.width)
     elif 'overlay' in self.presentation:
         pixbuf=overlay_svg_as_pixbuf(self.annotation.rootPackage.imagecache[self.annotation.fragment.begin],
                                      self.annotation.content.data,
                                      width=self.width)
     elif 'snapshot' in self.presentation:
         if 'timestamp' in self.presentation:
             pixbuf=overlay_svg_as_pixbuf(self.annotation.rootPackage.imagecache[self.annotation.fragment.begin],
                                          helper.format_time(self.annotation.fragment.begin),
                                          width=self.width)
         else:
             pixbuf=png_to_pixbuf(self.annotation.rootPackage.imagecache[self.annotation.fragment.begin],
                                  width=self.width)
     elif 'timestamp' in self.presentation:
         # Generate only a timestamp
         pixbuf = self.render_text(helper.format_time(self.annotation.fragment.begin))
     elif 'content' in self.presentation:
         # Display text
         pixbuf = self.render_text(self.controller.get_title(self.annotation))
     else:
         pixbuf=png_to_pixbuf(self.controller.package.imagecache.not_yet_available_image,
                              width=self.width)
     pixbuf.as_html=self.as_html
     pixbuf._placeholder=self
     pixbuf._tag='span'
     pixbuf._attr=[]
     return pixbuf
예제 #3
0
파일: widget.py 프로젝트: oaubert/advene2
 def set_cursor(wid, t=None, precision=None):
     if t is None:
         t=self.annotation
     if precision is None:
         precision=config.data.preferences['bookmark-snapshot-precision']
     # FIXME not multi-media compatible
     cache=self.controller.gui.imagecache
     if self.no_image_pixbuf is None:
         self.no_image_pixbuf=png_to_pixbuf(ImageCache.not_yet_available_image, width=config.data.preferences['drag-snapshot-width'])
     if not t == w._current:
         if isinstance(t, long) or isinstance(t, int):
             if cache.is_initialized(t, epsilon=precision):
                 begin.set_from_pixbuf(png_to_pixbuf (cache.get(t, epsilon=precision), width=config.data.preferences['drag-snapshot-width']))
             elif begin.get_pixbuf() != self.no_image_pixbuf:
                 begin.set_from_pixbuf(self.no_image_pixbuf)
             end.hide()
             padding.hide()
             l.set_text(helper.format_time(t))
         elif isinstance(t, Annotation):
             cache=self.controller.imagecache[t.media.url]
             # It can be an annotation
             begin.set_from_pixbuf(png_to_pixbuf (cache.get(t.begin), width=config.data.preferences['drag-snapshot-width']))
             end.set_from_pixbuf(png_to_pixbuf (cache.get(t.end), width=config.data.preferences['drag-snapshot-width']))
             end.show()
             padding.show()
             if widgets:
                 l.set_text(_("Set of %s annotations") % len(widgets))
             else:
                 l.set_text(self.controller.get_title(t))
     wid._current=t
     return True
예제 #4
0
 def set_cursor(wid, t=None, precision=None):
     if t is None:
         t=self.annotation
     if precision is None:
         precision=config.data.preferences['bookmark-snapshot-precision']
     cache=self.controller.package.imagecache
     if self.no_image_pixbuf is None:
         self.no_image_pixbuf=png_to_pixbuf(ImageCache.not_yet_available_image, width=config.data.preferences['drag-snapshot-width'])
     if not t == w._current:
         if isinstance(t, long) or isinstance(t, int):
             if cache.is_initialized(t, epsilon=precision):
                 begin.set_from_pixbuf(png_to_pixbuf (cache.get(t, epsilon=precision), width=config.data.preferences['drag-snapshot-width']))
             elif begin.get_pixbuf() != self.no_image_pixbuf:
                 begin.set_from_pixbuf(self.no_image_pixbuf)
             end.hide()
             padding.hide()
             l.set_text(helper.format_time(t))
         elif isinstance(t, Annotation):
             # It can be an annotation
             begin.set_from_pixbuf(png_to_pixbuf (cache.get(t.fragment.begin), width=config.data.preferences['drag-snapshot-width']))
             end.set_from_pixbuf(png_to_pixbuf (cache.get(t.fragment.end), width=config.data.preferences['drag-snapshot-width']))
             end.show()
             padding.show()
             if widgets:
                 l.set_text(_("Set of %s annotations") % len(widgets))
             else:
                 l.set_text(self.controller.get_title(t))
     wid._current=t
     return True
예제 #5
0
파일: widget.py 프로젝트: oaubert/advene
 def set_cursor(wid, t=None, precision=None):
     if t is None:
         t = self.annotation
     if precision is None:
         precision = config.data.preferences['bookmark-snapshot-precision']
     if self.no_image_pixbuf is None:
         self.no_image_pixbuf = png_to_pixbuf(self.controller.get_snapshot(position=-1), width=config.data.preferences['drag-snapshot-width'])
     if not t == w._current:
         if isinstance(t, int):
             snap = self.controller.get_snapshot(position=t, annotation=self.annotation, precision=precision)
             if snap.is_default:
                 pixbuf = self.no_image_pixbuf
             else:
                 pixbuf = png_to_pixbuf(snap, width=config.data.preferences['drag-snapshot-width'])
             begin.set_from_pixbuf(pixbuf)
             end.hide()
             padding.hide()
             l.set_text(helper.format_time(t))
         elif isinstance(t, Annotation):
             # It can be an annotation
             begin.set_from_pixbuf(png_to_pixbuf(self.controller.get_snapshot(annotation=t),
                                                 width=config.data.preferences['drag-snapshot-width']))
             end.set_from_pixbuf(png_to_pixbuf(self.controller.get_snapshot(annotation=t, position=t.fragment.end),
                                               width=config.data.preferences['drag-snapshot-width']))
             end.show()
             padding.show()
             if widgets:
                 l.set_text(_("Set of %s annotations") % len(widgets))
             else:
                 l.set_text(self.controller.get_title(t))
     wid._current=t
     return True
예제 #6
0
 def set_cursor(wid, t=None, precision=None):
     if t is None:
         t = self.annotation
     if precision is None:
         precision = config.data.preferences[
             'bookmark-snapshot-precision']
     if self.no_image_pixbuf is None:
         self.no_image_pixbuf = png_to_pixbuf(
             self.controller.get_snapshot(position=-1),
             width=config.data.preferences['drag-snapshot-width'])
     if not t == w._current:
         if isinstance(t, int):
             snap = self.controller.get_snapshot(
                 position=t,
                 annotation=self.annotation,
                 precision=precision)
             if snap.is_default:
                 pixbuf = self.no_image_pixbuf
             else:
                 pixbuf = png_to_pixbuf(
                     snap,
                     width=config.data.
                     preferences['drag-snapshot-width'])
             begin.set_from_pixbuf(pixbuf)
             if resize:
                 end.set_from_pixbuf(resize_pixbuf[resize])
                 l.set_text(helper.format_time(t))
             else:
                 end.hide()
                 padding.hide()
                 l.set_text(helper.format_time(t))
         elif isinstance(t, Annotation):
             # It can be an annotation
             begin.set_from_pixbuf(
                 png_to_pixbuf(
                     self.controller.get_snapshot(annotation=t),
                     width=config.data.
                     preferences['drag-snapshot-width']))
             end.set_from_pixbuf(
                 png_to_pixbuf(self.controller.get_snapshot(
                     annotation=t, position=t.fragment.end),
                               width=config.data.
                               preferences['drag-snapshot-width']))
             end.show()
             padding.show()
             if widgets:
                 l.set_text(_("Set of %s annotations") % len(widgets))
             else:
                 l.set_text(self.controller.get_title(t))
     wid._current = t
     return True
예제 #7
0
파일: widget.py 프로젝트: oaubert/advene2
 def refresh(self):
     """Update the display of the widget according to self._value and self.width
     """
     if self._value is None:
         v=-1
     else:
         v=self._value
     if self.width < 9:
         self.image.hide()
         self.set_size_request(6, 12)
     else:
         ic=self.controller.gui.imagecache
         if ic is None:
             png=ImageCache.not_yet_available_image
         else:
             png=ic.get(v, epsilon=self.epsilon)
         if png == ImageCache.not_yet_available_image and 'async-snapshot' in self.controller.player.player_capabilities:
             self.controller.queue_action(self.controller.update_snapshot, v)
         self.image.set_from_pixbuf(png_to_pixbuf(png, width=self.width))
         self.set_size_request(-1, -1)
         self.image.show()
     ts=helper.format_time(self._value)
     self.label.set_markup(self._text % { 'timestamp': ts })
     if self.visible_label and self.label.get_child_requisition()[0] <= 1.2 * self.image.get_child_requisition()[0]:
         self.label.show()
     else:
         self.label.hide()
     self.set_tooltip_text(ts)
     return True
예제 #8
0
 def refresh(self):
     """Update the display of the widget according to self._value and self.width
     """
     if self._value is None:
         v=-1
     else:
         v=self._value
     if self.width < 9:
         self.image.hide()
         self.set_size_request(6, 12)
     else:
         ic=self.controller.package.imagecache
         png = ic.get(v, epsilon=self.epsilon)
         if png == ic.not_yet_available_image and 'async-snapshot' in self.controller.player.player_capabilities:
             self.controller.queue_action(self.controller.update_snapshot, v)
         self.image.set_from_pixbuf(png_to_pixbuf(png, width=self.width))
         self.set_size_request(-1, -1)
         self.image.show()
     ts=helper.format_time(self._value)
     self.label.set_markup(self._text % { 'timestamp': ts })
     if self.visible_label and self.label.get_child_requisition()[0] <= 1.2 * self.image.get_child_requisition()[0]:
         self.label.show()
     else:
         self.label.hide()
     self.set_tooltip_text(ts)
     return True
예제 #9
0
 def refresh(self):
     """Update the display of the widget according to self._value and self.width
     """
     if self._value is None:
         v = -1
     else:
         v = self._value
     if self.width < 9:
         self.image.hide()
         self.set_size_request(6, 12)
     else:
         png = self.controller.get_snapshot(position=v,
                                            media=self._media,
                                            precision=self.precision)
         self.valid_screenshot = not png.is_default
         self.image.set_from_pixbuf(
             png_to_pixbuf(bytes(png), width=self.width))
         self.set_size_request(-1, -1)
         self.image.show()
     ts = helper.format_time(self._value)
     self.label.set_markup(self._text % {'timestamp': ts})
     self.label.get_style_context().add_class("timestamp_label")
     if (self.visible_label and self.label.get_child_requisition().width <=
             1.2 * self.image.get_child_requisition().width):
         self.label.show()
     else:
         self.label.hide()
     self.set_tooltip_text(ts)
     return True
예제 #10
0
파일: table.py 프로젝트: oaubert/advene
    def build_model(self, elements, custom_data=None):
        """Build the ListStore containing the data.

        See set_element docstring for the custom_data method explanation.
        """
        if custom_data is not None:
            custom = custom_data
        else:
            def custom(a):
                return tuple()
        args = (object, str, str, str, int, int, str, str, str, GdkPixbuf.Pixbuf, str, str) + custom(None)
        l=Gtk.ListStore(*args)
        if not elements:
            return l
        for a in elements:
            if isinstance(a, Annotation):
                l.append( (a,
                           self.controller.get_title(a),
                           self.controller.get_title(a.type),
                           a.id,
                           a.fragment.begin,
                           a.fragment.end,
                           helper.format_time(a.fragment.duration),
                           helper.format_time(a.fragment.begin),
                           helper.format_time(a.fragment.end),
                           png_to_pixbuf(self.controller.get_snapshot(annotation=a),
                                         height=32),
                           self.controller.get_element_color(a),
                           a.ownerPackage.getTitle()
                           ) + custom(a),
                          )
        return l
예제 #11
0
파일: widget.py 프로젝트: oaubert/advene
 def refresh(self):
     """Update the display of the widget according to self._value and self.width
     """
     if self._value is None:
         v=-1
     else:
         v=self._value
     if self.width < 9:
         self.image.hide()
         self.set_size_request(6, 12)
     else:
         png = self.controller.get_snapshot(position=v, media=self._media, precision=self.precision)
         self.valid_screenshot = not png.is_default
         self.image.set_from_pixbuf(png_to_pixbuf(bytes(png), width=self.width))
         self.set_size_request(-1, -1)
         self.image.show()
     ts=helper.format_time(self._value)
     self.label.set_markup(self._text % { 'timestamp': ts })
     self.label.get_style_context().add_class("timestamp_label")
     if self.visible_label and self.label.get_child_requisition().width <= 1.2 * self.image.get_child_requisition().width:
         self.label.show()
     else:
         self.label.hide()
     self.set_tooltip_text(ts)
     return True
예제 #12
0
    def build_model(self, elements, custom_data=None):
        """Build the ListStore containing the data.

        See set_element docstring for the custom_data method explanation.
        """
        if custom_data is not None:
            custom = custom_data
        else:

            def custom(a):
                return tuple()

        args = (object, str, str, str, int, int, str, str, str,
                GdkPixbuf.Pixbuf, str, str) + custom(None)
        l = Gtk.ListStore(*args)
        if not elements:
            return l
        for a in elements:
            if isinstance(a, Annotation):
                l.append(
                    (a, self.controller.get_title(a),
                     self.controller.get_title(a.type), a.id, a.fragment.begin,
                     a.fragment.end, helper.format_time(a.fragment.duration),
                     helper.format_time(
                         a.fragment.begin), helper.format_time(a.fragment.end),
                     png_to_pixbuf(self.controller.get_snapshot(annotation=a),
                                   height=32),
                     self.controller.get_element_color(a),
                     a.ownerPackage.getTitle()) + custom(a), )
        return l
예제 #13
0
파일: table.py 프로젝트: oaubert/advene2
 def update_snapshot(self, context, parameters):
     pos=long(context.globals['position'])
     eps=self.controller.gui.imagecache.epsilon
     for r in self.widget.treeview.get_model():
         if abs(r[4] - pos) <= eps:
             # Update pixbuf
             r[9] = png_to_pixbuf(self.controller.gui.imagecache[pos],
                                  height=32)
예제 #14
0
파일: table.py 프로젝트: oaubert/advene
 def update_snapshot(self, context, parameters):
     pos = int(context.globals['position'])
     media = context.globals['media']
     eps = self.controller.package.imagecache.precision
     for r in self.widget.treeview.get_model():
         if (r[COLUMN_ELEMENT].media == media
             and abs(r[COLUMN_BEGIN] - pos) <= eps):
             # Update pixbuf
             r[COLUMN_PIXBUF] = png_to_pixbuf(self.controller.package.imagecache[pos],
                                              height=32)
예제 #15
0
 def update_snapshot(self, context, parameters):
     pos = int(context.globals['position'])
     media = context.globals['media']
     eps = self.controller.package.imagecache.precision
     for r in self.widget.treeview.get_model():
         if (r[COLUMN_ELEMENT].media == media
                 and abs(r[COLUMN_BEGIN] - pos) <= eps):
             # Update pixbuf
             r[COLUMN_PIXBUF] = png_to_pixbuf(
                 self.controller.package.imagecache[pos], height=32)
예제 #16
0
    def build_pixbuf(self):
        if self.annotation is None:
            pixbuf=png_to_pixbuf(self.controller.gui.imagecache.not_yet_available_image,
                                 width=self.width)
        elif 'overlay' in self.presentation:
            pixbuf=overlay_svg_as_pixbuf(self.controller.imagecache[self.annotation.media.url][self.annotation.begin],
                                         self.annotation.content.data,
                                         width=self.width)
        elif 'snapshot' in self.presentation:
            if 'timestamp' in self.presentation:
                pixbuf=overlay_svg_as_pixbuf(self.controller.imagecache[self.annotation.media.url][self.annotation.begin],
                                             helper.format_time(self.annotation.begin),
                                             width=self.width)
            else:
                pixbuf=png_to_pixbuf(self.controller.imagecache[self.annotation.media.url][self.annotation.begin],
                                     width=self.width)
        elif 'timestamp' in self.presentation:
            # Generate only a timestamp 
            # FIXME: hardcoded value in viewBox is bad... We should find out the appropriate size.
            loader = gtk.gdk.PixbufLoader('svg')
            loader.write("""<svg version='1'> preserveAspectRatio="xMinYMin meet" viewBox="0 0 220 20">
<text x='0' y='10' fill="black" font-size="12" stroke="black" font-family="sans-serif">
%s
  </text>
</svg>
""" % helper.format_time(self.annotation.begin))
            loader.close ()
            pixbuf = loader.get_pixbuf ()
        else:
            pixbuf=png_to_pixbuf(self.controller.gui.imagecache.not_yet_available_image,
                                 width=self.width)
        pixbuf.as_html=self.as_html
        pixbuf._placeholder=self
        pixbuf._tag='span'
        pixbuf._attr=[]
        return pixbuf
예제 #17
0
파일: table.py 프로젝트: oaubert/advene2
    def build_model(self, elements):
        """Build the ListStore containing the data.

        """
        l=gtk.ListStore(object, str, str, str, long, long, str, str, str, gtk.gdk.Pixbuf, str)
        if not elements:
            return l
        for a in elements:
            if isinstance(a, Annotation):
                l.append( (a,
                           self.controller.get_title(a),
                           self.controller.get_title(a.type),
                           a.id,
                           a.begin,
                           a.end,
                           helper.format_time(a.duration),
                           helper.format_time(a.begin),
                           helper.format_time(a.end),
                           png_to_pixbuf(self.controller.imagecache[a.media.url][a.begin],
                                         height=32),
                           self.controller.get_element_color(a),
                           ) )
        return l