class SelfStock(Stock): def __init__(self): super(SelfStock,self).__init__("Self", None) spider = identity_spider.IdentitySpider() self._mugshot = mugshot.get_mugshot() self._mugshot.connect("self-changed", self._handle_self_changed) self._mugshot.get_self() self._mugshot.connect('whereim-added', self._handle_whereim_added) self._box = hippo.CanvasBox() self._namephoto_box = hippo.CanvasBox(orientation=hippo.ORIENTATION_HORIZONTAL) self._photo = CanvasURLImage() self._photo.connect("button-press-event", lambda button, event: self._on_edit_self()) #self._photo.set_property("image-name", '/usr/share/pixmaps/nobody.png') self._namephoto_box.append(self._photo) self._name = hippo.CanvasText(text=spider.get_self_name()) self._photo.connect("button-press-event", lambda button, event: self._on_edit_self()) self.append_bull(self._namephoto_box, self._name) self._box.append(self._namephoto_box) self._whereim_box = hippo.CanvasBox(orientation=hippo.ORIENTATION_HORIZONTAL, spacing=2) self._whereim_box.set_property("padding-top", 4) self._box.append(self._whereim_box) self._whereim = {} self._mugshot.get_whereim() def _on_edit_self(self): libbig.run_program('gnome-about-me', []) def get_content(self, size): return self._box def set_size(self, size): super(SelfStock, self).set_size(size) def _handle_self_changed(self, mugshot, myself): logging.debug("self (%s) changed" % (myself.get_guid(),)) self._photo.set_url(myself.get_photo_url()) self._name.set_property("text", myself.get_name()) def _handle_whereim_added(self, mugshot, acct): name = acct.get_name() self._whereim[name] = ExternalAccountIcon(acct) logging.debug("appending external account %s" % (name,)) self._whereim_box.append(self._whereim[name])
def __init__(self, **kwargs): kwargs['orientation'] = hippo.ORIENTATION_HORIZONTAL hippo.CanvasBox.__init__(self, **kwargs) self._entity = None self._photo = CanvasURLImage(scale_width=30, scale_height=30, border=1, border_color=0x000000ff) self.append(self._photo) self._name = hippo.CanvasText(xalign=hippo.ALIGNMENT_FILL, yalign=hippo.ALIGNMENT_START, size_mode=hippo.CANVAS_SIZE_ELLIPSIZE_END) self.append(self._name) self.set_size(bigboard.Stock.SIZE_BULL) self.connect('button-press-event', self._handle_button_press) self.connect('button-release-event', self._handle_button_release) self.connect('motion-notify-event', self._handle_motion) self._pressed = False self._hovered = False
def __init__(self): super(SelfStock,self).__init__("Self", None) spider = identity_spider.IdentitySpider() self._mugshot = mugshot.get_mugshot() self._mugshot.connect("self-changed", self._handle_self_changed) self._mugshot.get_self() self._mugshot.connect('whereim-added', self._handle_whereim_added) self._box = hippo.CanvasBox() self._namephoto_box = hippo.CanvasBox(orientation=hippo.ORIENTATION_HORIZONTAL) self._photo = CanvasURLImage() self._photo.connect("button-press-event", lambda button, event: self._on_edit_self()) #self._photo.set_property("image-name", '/usr/share/pixmaps/nobody.png') self._namephoto_box.append(self._photo) self._name = hippo.CanvasText(text=spider.get_self_name()) self._photo.connect("button-press-event", lambda button, event: self._on_edit_self()) self.append_bull(self._namephoto_box, self._name) self._box.append(self._namephoto_box) self._whereim_box = hippo.CanvasBox(orientation=hippo.ORIENTATION_HORIZONTAL, spacing=2) self._whereim_box.set_property("padding-top", 4) self._box.append(self._whereim_box) self._whereim = {} self._mugshot.get_whereim()
def __init__(self, acct): CanvasURLImage.__init__(self) self.set_acct(acct)
class EntityItem(hippo.CanvasBox): def __init__(self, **kwargs): kwargs['orientation'] = hippo.ORIENTATION_HORIZONTAL hippo.CanvasBox.__init__(self, **kwargs) self._entity = None self._photo = CanvasURLImage(scale_width=30, scale_height=30, border=1, border_color=0x000000ff) self.append(self._photo) self._name = hippo.CanvasText(xalign=hippo.ALIGNMENT_FILL, yalign=hippo.ALIGNMENT_START, size_mode=hippo.CANVAS_SIZE_ELLIPSIZE_END) self.append(self._name) self.set_size(bigboard.Stock.SIZE_BULL) self.connect('button-press-event', self._handle_button_press) self.connect('button-release-event', self._handle_button_release) self.connect('motion-notify-event', self._handle_motion) self._pressed = False self._hovered = False def _update_color(self): if self._pressed: self.set_property('background-color', 0x00000088) elif self._hovered: self.set_property('background-color', 0x00000033) else: self.set_property('background-color', 0x00000000) def _handle_button_press(self, self2, event): if event.button != 1: return False self._pressed = True self._update_color() def _handle_button_release(self, self2, event): if event.button != 1: return False self._pressed = False self._update_color() def _handle_motion(self, self2, event): if event.detail == hippo.MOTION_DETAIL_ENTER: self._hovered = True elif event.detail == hippo.MOTION_DETAIL_LEAVE: self._hovered = False self._update_color() def set_entity(self, entity): if self._entity == entity: return self._entity = entity self._update() def set_size(self, size): if size == bigboard.Stock.SIZE_BULL: self.set_child_visible(self._name, True) self._photo.set_property('xalign', hippo.ALIGNMENT_START) self._photo.set_property('yalign', hippo.ALIGNMENT_START) else: self.set_child_visible(self._name, False) self._photo.set_property('xalign', hippo.ALIGNMENT_CENTER) self._photo.set_property('yalign', hippo.ALIGNMENT_CENTER) def _update(self): if not self._entity: return self._name.set_property("text", self._entity.get_name()) if self._entity.get_photo_url(): self._photo.set_url(self._entity.get_photo_url()) def get_screen_coords(self): return self.get_context().translate_to_screen(self)