Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGonzalo Odiard <godiard@gmail.com>2011-11-07 20:23:12 (GMT)
committer Gonzalo Odiard <godiard@gmail.com>2011-11-07 20:23:12 (GMT)
commitc240475e3e8e90ef10350fa7522e734844678a15 (patch)
tree5a15946955d623e533250ee37993d15548a3e787
parent4ae8db71b38f874f73f47da935e27ea02b4e4ded (diff)
Add filter to select only images in the object chooser user to insert a image
Signed-off-by: Gonzalo Odiard <gonzalo@laptop.org>
-rw-r--r--toolbox.py34
1 files changed, 8 insertions, 26 deletions
diff --git a/toolbox.py b/toolbox.py
index 8cacf92..25248ad 100644
--- a/toolbox.py
+++ b/toolbox.py
@@ -813,32 +813,14 @@ class ImageToolbar(gtk.Toolbar):
return spin
def insertImage(self, widget, activity):
- # FIXME: this should be a ObjectChooser
- # TODO: add a filter to display images only.
- #dialog = gtk.FileChooserDialog(title=(_('Open File...')),
- #action=gtk.FILE_CHOOSER_ACTION_OPEN,
- #buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
- #gtk.STOCK_OK, gtk.RESPONSE_OK))
- #dialog.show_all()
-
- #logging.debug('Importing image from file')
- #response = dialog.run()
-
- #if response == gtk.RESPONSE_OK:
- #file_path = dialog.get_filename()
- #logging.debug('file selected')
- #logging.debug(file_path)
- ##file_path = decode_path((file_path,))[0]
- ##open(activity, file_path)
- #activity.area.loadImage(file_path,widget,True)
- #elif response == gtk.RESPONSE_CANCEL:
- #logging.debug('Closed, no files selected')
-
- #dialog.destroy()
-
- chooser = ObjectChooser(_('Choose image'), self._activity,
- gtk.DIALOG_MODAL |
- gtk.DIALOG_DESTROY_WITH_PARENT)
+ try:
+ chooser = ObjectChooser(_('Choose image'),
+ self._activity, gtk.DIALOG_MODAL |
+ gtk.DIALOG_DESTROY_WITH_PARENT, what_filter='Image')
+ except:
+ chooser = ObjectChooser(_('Choose image'),
+ self._activity, gtk.DIALOG_MODAL |
+ gtk.DIALOG_DESTROY_WITH_PARENT)
try:
result = chooser.run()
if result == gtk.RESPONSE_ACCEPT: