def build_widget(self): vb=gtk.VBox() buttons = gtk.HBox() b=gtk.Button(stock=gtk.STOCK_REFRESH) b.set_tooltip_text(_("Refresh missing snapshots")) b.connect("clicked", lambda b: self.refresh_snapshots()) buttons.pack_start(b, expand=True) vb.pack_start(buttons, expand=False) l = gtk.Label(_("Click on a frame to select its time.")) vb.pack_start(l, expand=False) hb=gtk.HBox() ar = gtk.Arrow(gtk.ARROW_LEFT, gtk.SHADOW_IN) ar.set_tooltip_text(_("Scroll to see more frames")) hb.pack_start(ar, expand=False) r = None for i in xrange(self.count): border = GenericColorButtonWidget('border') border.default_size=(3, 110) border.local_color=self.black_color if r is not None: # Previous TimestampRepresentation -> right border r.right_border = border r = TimestampRepresentation(0, self.controller, width=100, visible_label=True, epsilon=30) self.frames.append(r) r.connect("clicked", self.select_time) r.left_border = border hb.pack_start(border, expand=False) hb.pack_start(r, expand=False) # Last right border border = GenericColorButtonWidget('border') border.default_size=(3, 110) border.local_color=self.black_color r.right_border = border hb.pack_start(border, expand=False) ar = gtk.Arrow(gtk.ARROW_RIGHT, gtk.SHADOW_IN) ar.set_tooltip_text(_("Scroll to see more frames")) hb.pack_start(ar, expand=False) hb.set_style(get_color_style(hb, 'black', 'black')) hb.connect('scroll-event', self.handle_scroll_event) hb.connect('key-press-event', self.handle_key_press) vb.add(hb) self.update_timestamp(self.timestamp) return vb
def set_bgcolor(self, color): if color is None: color='black' if color != self._bgcolor: style = get_color_style(self, color, 'white') self.set_style(style) self.box.set_style(style) self.image.set_style(style) self.label.set_style(style) self._bgcolor = color
def build_widget(self): v=gtk.HBox() style=get_color_style(v, 'black', 'white') v.set_style(style) def create_label(text, widget): eb=gtk.EventBox() l=gtk.Label(text) l.set_single_line_mode(True) eb.add(l) l.set_style(style) eb.set_style(style) widget.pack_start(eb) return l self.label=create_label('', v) v.show_all() return v
def _drag_begin(self, widget, context): # set_icon_widget is broken ATM in recent gtk on win32. if config.data.os == 'win32': return GenericColorButtonWidget._drag_begin(self, widget, context) try: widgets=self.container.get_selected_annotation_widgets() if not widget in widgets: widgets=[] except AttributeError: widgets=[] w=gtk.Window(gtk.WINDOW_POPUP) w.set_decorated(False) # Set white on black background style=get_color_style(w, 'black', 'white') w.set_style(style) v=gtk.VBox() v.set_style(style) h=gtk.HBox() h.set_style(style) begin=gtk.Image() h.pack_start(begin, expand=False) padding=gtk.HBox() # Padding h.pack_start(padding, expand=True) end=gtk.Image() h.pack_start(end, expand=False) v.pack_start(h, expand=False) l=gtk.Label() l.set_ellipsize(pango.ELLIPSIZE_END) l.set_style(style) v.pack_start(l, expand=False) 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 w.add(v) w.show_all() w._current=None w.set_cursor = set_cursor.__get__(w) w.set_cursor() w.set_size_request(long(2.5 * config.data.preferences['drag-snapshot-width']), -1) widget._icon=w context.set_icon_widget(w, 0, 0) return True
def _drag_begin(self, widget, context): # set_icon_widget is broken ATM in recent gtk on win32. if config.data.os == 'win32': return GenericColorButtonWidget._drag_begin(self, widget, context) try: widgets=self.container.get_selected_annotation_widgets() if not widget in widgets: widgets=[] except AttributeError: widgets=[] w=gtk.Window(gtk.WINDOW_POPUP) w.set_decorated(False) # Set white on black background style=get_color_style(w, 'black', 'white') w.set_style(style) v=gtk.VBox() v.set_style(style) h=gtk.HBox() h.set_style(style) begin=gtk.Image() h.pack_start(begin, expand=False) padding=gtk.HBox() # Padding h.pack_start(padding, expand=True) end=gtk.Image() h.pack_start(end, expand=False) v.pack_start(h, expand=False) l=gtk.Label() l.set_ellipsize(pango.ELLIPSIZE_END) l.set_style(style) v.pack_start(l, expand=False) 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 w.add(v) w.show_all() w._current=None w.set_cursor = set_cursor.__get__(w) w.set_cursor() w.set_size_request(long(2.5 * config.data.preferences['drag-snapshot-width']), -1) widget._icon=w context.set_icon_widget(w, 0, 0) return True
def build_widget(self): vb=gtk.VBox() l = gtk.Label(self.label) vb.pack_start(l, expand=False) hb=gtk.HBox() eb = gtk.EventBox() ar = gtk.Arrow(gtk.ARROW_LEFT, gtk.SHADOW_IN) ar.set_tooltip_text(_("Click to see more frames or scroll with the mouse wheel")) eb.connect('button-press-event', lambda b,e: self.update_offset(-1)) eb.add(ar) hb.pack_start(eb, expand=False) r = None for i in xrange(self.count): border = GenericColorButtonWidget('border') border.default_size=(3, 110) border.local_color=self.black_color if r is not None: # Previous TimestampRepresentation -> right border r.right_border = border r = TimestampRepresentation(0, self.controller, width=100, visible_label=True, epsilon=(1000 / config.data.preferences['default-fps'] - 10)) self.frames.append(r) r.connect("clicked", self.select_time) r.left_border = border def enter_bookmark(widget, event): if self.border_mode == 'left': b=widget.left_border elif self.border_mode == 'right': b=widget.right_border b.old_color = b.local_color b.set_color(self.mouseover_color) return False def leave_bookmark(widget, event): if self.border_mode == 'left': b=widget.left_border elif self.border_mode == 'right': b=widget.right_border b.set_color(b.old_color) return False if self.border_mode in ('left', 'right'): r.connect('enter-notify-event', enter_bookmark) r.connect('leave-notify-event', leave_bookmark) hb.pack_start(border, expand=False) hb.pack_start(r, expand=False) # Last right border border = GenericColorButtonWidget('border') border.default_size=(3, 110) border.local_color=self.black_color r.right_border = border hb.pack_start(border, expand=False) eb = gtk.EventBox() ar = gtk.Arrow(gtk.ARROW_RIGHT, gtk.SHADOW_IN) ar.set_tooltip_text(_("Click to see more frames or scroll with the mouse wheel")) eb.connect('button-press-event', lambda b,e: self.update_offset(+1)) eb.add(ar) hb.pack_start(eb, expand=False) hb.set_style(get_color_style(hb, 'black', 'black')) hb.connect('scroll-event', self.handle_scroll_event) hb.connect('key-press-event', self.handle_key_press) vb.add(hb) self.update_timestamp(self.timestamp) return vb