diff options
author | Pootle User <translate@rt.laptop.org> | 2008-01-11 14:18:06 (GMT) |
---|---|---|
committer | Pootle User <translate@rt.laptop.org> | 2008-01-11 14:18:06 (GMT) |
commit | b59a81b885214699147bfc5fd8b3631b9bcd5dcb (patch) | |
tree | 90731d6b34eb8c0efe522e5f3d280304e50a95fc /lib | |
parent | 438e7461e7eb44dd9834ced522266577e86b9528 (diff) | |
parent | 676035742349f01f608eae50c4662fa3578a4c8b (diff) |
Merge branch 'master' of git+ssh://dev.laptop.org/git/sugar
Diffstat (limited to 'lib')
-rw-r--r-- | lib/sugar/activity/activity.py | 16 | ||||
-rw-r--r-- | lib/sugar/graphics/menuitem.py | 7 | ||||
-rw-r--r-- | lib/sugar/graphics/palette.py | 9 |
3 files changed, 28 insertions, 4 deletions
diff --git a/lib/sugar/activity/activity.py b/lib/sugar/activity/activity.py index d9886f9..f6dbd37 100644 --- a/lib/sugar/activity/activity.py +++ b/lib/sugar/activity/activity.py @@ -838,12 +838,24 @@ class Activity(Window, gtk.Container): if response_id == gtk.RESPONSE_OK: self.close(skip_save=True) - def close(self, skip_save=False): + def can_close(self): + """Activities should override this function if they want to perform + extra checks before actually closing.""" + + return True + + def close(self, force=False, skip_save=False): """Request that the activity be stopped and saved to the Journal Activities should not override this method, but should implement write_file() to - do any state saving instead. + do any state saving instead. If the application wants to control wether it can + close, it should override can_close(). """ + + if not force: + if not self.can_close(): + return + try: if not skip_save: self.save() diff --git a/lib/sugar/graphics/menuitem.py b/lib/sugar/graphics/menuitem.py index 1b90843..908cc1f 100644 --- a/lib/sugar/graphics/menuitem.py +++ b/lib/sugar/graphics/menuitem.py @@ -18,11 +18,16 @@ import gtk from sugar.graphics.icon import Icon +import pango + class MenuItem(gtk.ImageMenuItem): - def __init__(self, text_label=None, icon_name=None): + def __init__(self, text_label=None, icon_name=None, text_maxlen=0): gtk.ImageMenuItem.__init__(self, text_label) if icon_name: icon = Icon(icon_name=icon_name, icon_size=gtk.ICON_SIZE_MENU) self.set_image(icon) icon.show() + if text_maxlen > 0: + self.child.set_ellipsize(pango.ELLIPSIZE_MIDDLE) + self.child.set_max_width_chars(text_maxlen) diff --git a/lib/sugar/graphics/palette.py b/lib/sugar/graphics/palette.py index a24a806..3a27923 100644 --- a/lib/sugar/graphics/palette.py +++ b/lib/sugar/graphics/palette.py @@ -21,6 +21,7 @@ import gtk import gobject import time import hippo +import pango from sugar.graphics import palettegroup from sugar.graphics import animator @@ -140,7 +141,8 @@ class Palette(gtk.Window): gobject.TYPE_NONE, ([])) } - def __init__(self, label, accel_path=None, menu_after_content=False): + def __init__(self, label, accel_path=None, menu_after_content=False, + text_maxlen=0): gtk.Window.__init__(self) self.set_decorated(False) @@ -178,6 +180,11 @@ class Palette(gtk.Window): - 2*self.get_border_width()) self._label.set_alignment(0, 0.5) self._label.set_padding(style.DEFAULT_SPACING, 0) + + if text_maxlen > 0: + self._label.set_max_width_chars(text_maxlen) + self._label.set_ellipsize(pango.ELLIPSIZE_MIDDLE) + vbox.pack_start(self._label, False) self._secondary_box = gtk.VBox() |