From 9b61b1ff7b43142986c05941d07172e10f7d1e08 Mon Sep 17 00:00:00 2001 From: Tomeu Vizoso Date: Tue, 6 Jan 2009 13:30:20 +0100 Subject: [PATCH 1/4] #3060 Add the possibility of filtering the object chooser by data type --- src/sugar/graphics/objectchooser.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/sugar/graphics/objectchooser.py b/src/sugar/graphics/objectchooser.py index 1188b044..a772ae42 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, + data_type=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._data_type = data_type 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._data_type is None: + data_type = '' + else: + data_type = self._data_type + + self._chooser_id = journal.ChooseObject(self._parent_xid, data_type) gtk.gdk.threads_leave() try: From 9a3cbbfe3399106348c2fed184dee98d41349469 Mon Sep 17 00:00:00 2001 From: Tomeu Vizoso Date: Tue, 6 Jan 2009 19:17:48 +0100 Subject: [PATCH 2/4] Rename parameter to what_filter --- src/sugar/graphics/objectchooser.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/sugar/graphics/objectchooser.py b/src/sugar/graphics/objectchooser.py index a772ae42..fb3703de 100644 --- a/src/sugar/graphics/objectchooser.py +++ b/src/sugar/graphics/objectchooser.py @@ -33,7 +33,7 @@ J_DBUS_PATH = '/org/laptop/Journal' class ObjectChooser(object): def __init__(self, title=None, parent=None, flags=None, buttons=None, - data_type=None): + what_filter=None): # For backwards compatibility: # - We ignore title, flags and buttons. # - 'parent' can be a xid or a gtk.Window @@ -55,7 +55,7 @@ class ObjectChooser(object): self._bus = None self._chooser_id = None self._response_code = gtk.RESPONSE_NONE - self._data_type = data_type + self._what_filter = what_filter def run(self): self._object_id = None @@ -76,12 +76,12 @@ class ObjectChooser(object): journal.connect_to_signal('ObjectChooserCancelled', self.__chooser_cancelled_cb) - if self._data_type is None: - data_type = '' + if self._what_filter is None: + what_filter = '' else: - data_type = self._data_type + what_filter = self._what_filter - self._chooser_id = journal.ChooseObject(self._parent_xid, data_type) + self._chooser_id = journal.ChooseObject(self._parent_xid, what_filter) gtk.gdk.threads_leave() try: From e56b381bd354ec9365c149f40068d3654c8ba783 Mon Sep 17 00:00:00 2001 From: Tomeu Vizoso Date: Mon, 12 Jan 2009 13:46:17 +0100 Subject: [PATCH 3/4] Add the file_name property to MenuItem and reduce a bit the size of its icons --- src/sugar/graphics/menuitem.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/sugar/graphics/menuitem.py b/src/sugar/graphics/menuitem.py index 954df1bc..c1be49a0 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,15 @@ 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) From bbd8c14cf11a7b5e26e6d344b2f79ba6b6726c29 Mon Sep 17 00:00:00 2001 From: Tomeu Vizoso Date: Mon, 12 Jan 2009 13:47:34 +0100 Subject: [PATCH 4/4] pylint nitpick --- src/sugar/graphics/menuitem.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/sugar/graphics/menuitem.py b/src/sugar/graphics/menuitem.py index c1be49a0..a357d78c 100644 --- a/src/sugar/graphics/menuitem.py +++ b/src/sugar/graphics/menuitem.py @@ -43,7 +43,8 @@ class MenuItem(gtk.ImageMenuItem): label.show() if icon_name is not None: - icon = Icon(icon_name=icon_name, icon_size=gtk.ICON_SIZE_SMALL_TOOLBAR) + 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)