mime_type is better than glob syntax for filefilter; also fix logic

This commit is contained in:
Nikos Kouremenos 2005-11-14 15:54:13 +00:00
parent 17b5ff7022
commit 51601d42cc
2 changed files with 10 additions and 16 deletions

View File

@ -2057,11 +2057,8 @@ class ManageEmoticonsWindow:
filter.add_mime_type('image/png') filter.add_mime_type('image/png')
filter.add_mime_type('image/jpeg') filter.add_mime_type('image/jpeg')
filter.add_mime_type('image/gif') filter.add_mime_type('image/gif')
filter.add_pattern('*.png') filter.add_mime_type('image/tiff')
filter.add_pattern('*.jpg') filter.add_mime_type('image/x-xpixmap') # xpm
filter.add_pattern('*.gif')
filter.add_pattern('*.tif')
filter.add_pattern('*.xpm')
dialog.add_filter(filter) dialog.add_filter(filter)
dialog.set_filter(filter) dialog.set_filter(filter)
dialog.set_use_preview_label(False) dialog.set_use_preview_label(False)

View File

@ -175,19 +175,16 @@ class VcardWindow:
filtr.add_mime_type('image/png') filtr.add_mime_type('image/png')
filtr.add_mime_type('image/jpeg') filtr.add_mime_type('image/jpeg')
filtr.add_mime_type('image/gif') filtr.add_mime_type('image/gif')
filtr.add_pattern('*.png') filtr.add_mime_type('image/tiff')
filtr.add_pattern('*.jpg') filtr.add_mime_type('image/x-xpixmap') # xpm
filtr.add_pattern('*.gif')
filtr.add_pattern('*.tif')
filtr.add_pattern('*.xpm')
dialog.add_filter(filtr) dialog.add_filter(filtr)
dialog.set_filter(filtr) dialog.set_filter(filtr)
dialog.set_use_preview_label(False) dialog.set_use_preview_label(False)
dialog.set_preview_widget(gtk.Image()) dialog.set_preview_widget(gtk.Image())
dialog.connect('selection-changed', self.update_preview) dialog.connect('selection-changed', self.update_preview)
ok = False done = False
while not ok: while not done:
response = dialog.run() response = dialog.run()
if response == gtk.RESPONSE_OK: if response == gtk.RESPONSE_OK:
f = dialog.get_filename() f = dialog.get_filename()
@ -203,12 +200,12 @@ class VcardWindow:
_('The file must not be more than 8 kilobytes.')).get_response() _('The file must not be more than 8 kilobytes.')).get_response()
continue continue
if self.image_is_ok(f): if self.image_is_ok(f):
ok = True done = True
else: else: # Cancel or WM X button
ok = True done = True
dialog.destroy() dialog.destroy()
if f: if response == gtk.RESPONSE_OK:
fd = open(f, 'rb') fd = open(f, 'rb')
data = fd.read() data = fd.read()
pixbuf = gtkgui_helpers.get_pixbuf_from_data(data) pixbuf = gtkgui_helpers.get_pixbuf_from_data(data)