def hide(self): if self._animator: self._animator.stop() self._animator = animator.Animator(0.5) self._animator.add(_Animation(self, 0.0)) self._animator.start() self.mode = None
def show(self, mode): if self.visible: return if self._animator: self._animator.stop() self.mode = mode self._animator = animator.Animator(0.5) self._animator.add(_Animation(self, 1.0)) self._animator.start()
def __init__(self, **kwargs): self._group_id = None self._invoker = None self._invoker_hids = [] self._cursor_x = 0 self._cursor_y = 0 self._alignment = None self._up = False self._old_alloc = None self._palette_state = None self._popup_anim = animator.Animator(.5, 10) self._popup_anim.add(_PopupAnimation(self)) self._popdown_anim = animator.Animator(0.6, 10) self._popdown_anim.add(_PopdownAnimation(self)) gobject.GObject.__init__(self, **kwargs) self.set_decorated(False) self.set_resizable(False) # Just assume xthickness and ythickness are the same self.set_border_width(self.get_style().xthickness) accel_group = gtk.AccelGroup() self.set_data('sugar-accel-group', accel_group) self.add_accel_group(accel_group) self.set_group_id('default') self.connect('show', self.__show_cb) self.connect('hide', self.__hide_cb) self.connect('realize', self.__realize_cb) self.connect('destroy', self.__destroy_cb) self.connect('enter-notify-event', self.__enter_notify_event_cb) self.connect('leave-notify-event', self.__leave_notify_event_cb) self._mouse_detector = MouseSpeedDetector(self, 200, 5) self._mouse_detector.connect('motion-slow', self._mouse_slow_cb)
def __init__(self): gobject.GObject.__init__(self) self._box = hippo.CanvasBox() self._box.props.background_color = style.COLOR_WHITE.get_int() self.set_root(self._box) self._layout = _Layout() self._box.set_layout(self._layout) self._my_icon = BuddyIcon(buddy=get_owner_instance(), size=style.XLARGE_ICON_SIZE) self._box.append(self._my_icon) self._animator = animator.Animator(0.3) self._animator.connect('completed', self._animation_completed_cb)
def __init__(self, label=None, accel_path=None, menu_after_content=False, text_maxlen=60, **kwargs): # DEPRECATED: label is passed with the primary-text property, # accel_path is set via the invoker property, and menu_after_content # is not used self._primary_text = None self._secondary_text = None self._icon = None self._icon_visible = True self._palette_state = self.PRIMARY palette_box = gtk.VBox() primary_box = gtk.HBox() palette_box.pack_start(primary_box, expand=False) primary_box.show() self._icon_box = gtk.HBox() self._icon_box.set_size_request(style.GRID_CELL_SIZE, -1) primary_box.pack_start(self._icon_box, expand=False) labels_box = gtk.VBox() self._label_alignment = gtk.Alignment(xalign=0, yalign=0.5, xscale=1, yscale=0.33) self._label_alignment.set_padding(0, 0, style.DEFAULT_SPACING, style.DEFAULT_SPACING) self._label_alignment.add(labels_box) self._label_alignment.show() primary_box.pack_start(self._label_alignment, expand=True) labels_box.show() self._label = gtk.AccelLabel('') self._label.set_alignment(0, 0.5) if text_maxlen > 0: self._label.set_max_width_chars(text_maxlen) self._label.set_ellipsize(pango.ELLIPSIZE_MIDDLE) labels_box.pack_start(self._label, expand=True) self._secondary_label = gtk.Label() self._secondary_label.set_alignment(0, 0.5) if text_maxlen > 0: self._secondary_label.set_max_width_chars(text_maxlen) self._secondary_label.set_ellipsize(pango.ELLIPSIZE_END) labels_box.pack_start(self._secondary_label, expand=True) self._secondary_box = gtk.VBox() palette_box.pack_start(self._secondary_box) self._separator = gtk.HSeparator() self._secondary_box.pack_start(self._separator) self._menu_content_separator = gtk.HSeparator() self._secondary_anim = animator.Animator(2.0, 10) self._secondary_anim.add(_SecondaryAnimation(self)) # we init after initializing all of our containers PaletteWindow.__init__(self, **kwargs) primary_box.set_size_request( -1, style.GRID_CELL_SIZE - 2 * self.get_border_width()) self._full_request = [0, 0] self._menu_box = None self._content = None # we set these for backward compatibility if label is not None: self.props.primary_text = label self._add_menu() self._secondary_box.pack_start(self._menu_content_separator) self._add_content() self.action_bar = PaletteActionBar() self._secondary_box.pack_start(self.action_bar) self.action_bar.show() self.add(palette_box) palette_box.show() # The menu is not shown here until an item is added self.menu = _Menu(self) self.menu.connect('item-inserted', self.__menu_item_inserted_cb) self.connect('realize', self.__realize_cb) self.connect('show', self.__show_cb) self.connect('hide', self.__hide_cb) self.connect('notify::invoker', self.__notify_invoker_cb) self.connect('destroy', self.__destroy_cb)