Make buddy icon selection a bit more consistent

This commit is contained in:
Dan Williams 2007-02-26 11:10:24 -05:00
parent df1f01552d
commit a1f5684944
2 changed files with 52 additions and 7 deletions

View File

@ -22,6 +22,7 @@ class Glive(gobject.GObject):
}
def __init__(self, parent, width, height):
gobject.GObject.__init__(self)
self._parent = parent
#check out the halfpipe, d00d.
@ -150,7 +151,7 @@ class LiveVideoSlot(gtk.EventBox):
self.unset_flags(gtk.DOUBLE_BUFFERED)
self.connect('focus-in-event', self.focus_in)
self.connect('focus-out-event', self.focus_out)
self.connect("button-press-event", self.button_press)
self.connect("button-press-event", self._button_press_event_cb)
self.playa = Glive(self, width, height)
self.playa.connect('new-picture', self._new_picture_cb)
@ -159,7 +160,7 @@ class LiveVideoSlot(gtk.EventBox):
def _new_picture_cb(self, playa, pixbuf):
self.emit('pixbuf', pixbuf)
def _new_sink_sb(self, playa, sink):
def _new_sink_cb(self, playa, sink):
if (self.imagesink != None):
assert self.window.xid
self.imagesink = None
@ -167,6 +168,9 @@ class LiveVideoSlot(gtk.EventBox):
self.imagesink = sink
self.imagesink.set_xwindow_id(self.window.xid)
def _button_press_event_cb(self, widget, event):
self.takeSnapshot()
def focus_in(self, widget, event, args=None):
self.play()

View File

@ -36,6 +36,21 @@ _VIDEO_WIDTH = 320
_VIDEO_HEIGHT = 240
class IntroImage(gtk.EventBox):
__gtype_name__ = "IntroImage"
def __init__(self, **kwargs):
gtk.EventBox.__init__(self, **kwargs)
self._image = gtk.Image()
self.add(self._image)
def set_pixbuf(self, pixbuf):
if pixbuf:
self._image.set_from_pixbuf(pixbuf)
else:
self._image.clear()
class IntroFallbackVideo(gtk.EventBox):
__gtype_name__ = "IntroFallbackVideo"
@ -48,9 +63,15 @@ class IntroFallbackVideo(gtk.EventBox):
self._image = gtk.Image()
self._image.set_from_stock(gtk.STOCK_OPEN, -1)
self.add(self._image)
self.connect('button-press-event', self._button_press_cb)
self.connect('button-press-event', self._button_press_event_cb)
def _button_press_cb(self, widget, event):
def play(self):
pass
def stop(self):
pass
def _button_press_event_cb(self, widget, event):
filt = gtk.FileFilter()
filt.add_pixbuf_formats()
chooser = gtk.FileChooserDialog(_("Pick a buddy picture"), \
@ -60,9 +81,6 @@ class IntroFallbackVideo(gtk.EventBox):
if resp == gtk.RESPONSE_ACCEPT:
fname = chooser.get_filename()
pixbuf = gtk.gdk.pixbuf_new_from_file(fname)
(w, h) = self.get_size_request()
img_pixbuf = pixbuf.scale_simple(w, h, gtk.gdk.INTERP_BILINEAR)
self._image.set_from_pixbuf(img_pixbuf)
self.emit('pixbuf', pixbuf)
chooser.hide()
chooser.destroy()
@ -95,11 +113,34 @@ class VideoBox(hippo.CanvasBox, hippo.CanvasItem):
self._video_widget = hippo.CanvasWidget()
self._video_widget.props.widget = self._video
self.append(self._video_widget)
self._video.play()
self._img = IntroImage()
self._img.set_size_request(_VIDEO_WIDTH, _VIDEO_HEIGHT)
self._img.connect('button-press-event', self._clear_image_cb)
self._img_widget = hippo.CanvasWidget()
self._img_widget.props.widget = self._img
def _clear_image_cb(self, widget, event):
del self._pixbuf
self._pixbuf = None
self.remove(self._img_widget)
self._img.set_pixbuf(None)
self.append(self._video_widget)
self._video.play()
def _new_pixbuf_cb(self, widget, pixbuf):
if self._pixbuf:
del self._pixbuf
self._pixbuf = pixbuf
self._video.stop()
self.remove(self._video_widget)
scaled = pixbuf.scale_simple(_VIDEO_WIDTH, _VIDEO_HEIGHT, gtk.gdk.INTERP_BILINEAR)
self._img.set_pixbuf(scaled)
self._img.show_all()
self.append(self._img_widget)
def get_pixbuf(self):
return self._pixbuf