diff --git a/src/sugar/graphics/menuitem.py b/src/sugar/graphics/menuitem.py index 954df1bc..a357d78c 100644 --- a/src/sugar/graphics/menuitem.py +++ b/src/sugar/graphics/menuitem.py @@ -29,7 +29,7 @@ from sugar.graphics.icon import Icon class MenuItem(gtk.ImageMenuItem): def __init__(self, text_label=None, icon_name=None, text_maxlen=0, - xo_color=None): + xo_color=None, file_name=None): gobject.GObject.__init__(self) self._accelerator = None @@ -42,8 +42,16 @@ class MenuItem(gtk.ImageMenuItem): self.add(label) label.show() - if icon_name: - icon = Icon(icon_name=icon_name, icon_size=gtk.ICON_SIZE_MENU) + if icon_name is not None: + icon = Icon(icon_name=icon_name, + icon_size=gtk.ICON_SIZE_SMALL_TOOLBAR) + if xo_color is not None: + icon.props.xo_color = xo_color + self.set_image(icon) + icon.show() + + elif file_name is not None: + icon = Icon(file=file_name, icon_size=gtk.ICON_SIZE_SMALL_TOOLBAR) if xo_color is not None: icon.props.xo_color = xo_color self.set_image(icon) diff --git a/src/sugar/graphics/objectchooser.py b/src/sugar/graphics/objectchooser.py index 1188b044..fb3703de 100644 --- a/src/sugar/graphics/objectchooser.py +++ b/src/sugar/graphics/objectchooser.py @@ -32,7 +32,8 @@ J_DBUS_INTERFACE = 'org.laptop.Journal' J_DBUS_PATH = '/org/laptop/Journal' class ObjectChooser(object): - def __init__(self, title=None, parent=None, flags=None, buttons=None): + def __init__(self, title=None, parent=None, flags=None, buttons=None, + what_filter=None): # For backwards compatibility: # - We ignore title, flags and buttons. # - 'parent' can be a xid or a gtk.Window @@ -54,6 +55,7 @@ class ObjectChooser(object): self._bus = None self._chooser_id = None self._response_code = gtk.RESPONSE_NONE + self._what_filter = what_filter def run(self): self._object_id = None @@ -73,7 +75,13 @@ class ObjectChooser(object): self.__chooser_response_cb) journal.connect_to_signal('ObjectChooserCancelled', self.__chooser_cancelled_cb) - self._chooser_id = journal.ChooseObject(self._parent_xid) + + if self._what_filter is None: + what_filter = '' + else: + what_filter = self._what_filter + + self._chooser_id = journal.ChooseObject(self._parent_xid, what_filter) gtk.gdk.threads_leave() try: