# Path: mcomix/preferences.py
# def read_preferences_file():
# def write_preferences_file():
# 
# Path: mcomix/file_chooser_base_dialog.py
# class _BaseFileChooserDialog(gtk.Dialog):
#     def __init__(self, action=gtk.FILE_CHOOSER_ACTION_OPEN):
#     def add_filter(self, name, mimes, patterns=[]):
#     def _filter(self, filter_info, data):
#     def collect_files_from_subdir(self, path, filter, recursive=False):
#     def set_save_name(self, name):
#     def set_current_directory(self, path):
#     def should_open_recursive(self):
#     def _response(self, widget, response):
#     def _update_preview(self, *args):
#     def _preview_thumbnail_finished(self, filepath, pixbuf):
#     def _current_file(self):


import gtk
from mcomix.preferences import prefs
from mcomix import file_chooser_base_dialog
        self.filechooser.set_select_multiple(True)

        ffilter = gtk.FileFilter()
        ffilter.add_pixbuf_formats()
        ffilter.set_name(_('All images'))
        self.filechooser.add_filter(ffilter)
        self.add_filter(_('JPEG images'), ('image/jpeg',), ('*.jpg', '*.jpeg'))
        self.add_filter(_('PNG images'), ('image/png',), ('*.png',))
        self.add_filter(_('GIF images'), ('image/gif',), ('*.gif',))
        self.add_filter(_('TIFF images'), ('image/tiff',), ('*.tiff',))
        self.add_filter(_('BMP images'), ('image/bmp',), ('*.bmp',))

        filters = self.filechooser.list_filters()
        try:
            # When setting this to the first filter ("All files"), this
            # fails on some GTK+ versions and sets the filter to "blank".
            # The effect is the same though (i.e. display all files), and
            # there is no solution that I know of, so we'll have to live
            # with it. It only happens the second time a dialog is created
            # though, which is very strange.
            self.filechooser.set_filter(filters[
                prefs['last filter in main filechooser']])
        except:
            self.filechooser.set_filter(filters[0])

    def files_chosen(self, paths):
        if paths:
            try: # For some reason this fails sometimes (GTK+ bug?)
                filter_index = self.filechooser.list_filters().index(
                    self.filechooser.get_filter())

# Path: mcomix/preferences.py
# def read_preferences_file():
# def write_preferences_file():
# 
# Path: mcomix/file_chooser_base_dialog.py
# class _BaseFileChooserDialog(gtk.Dialog):
#     def __init__(self, action=gtk.FILE_CHOOSER_ACTION_OPEN):
#     def add_filter(self, name, mimes, patterns=[]):
#     def _filter(self, filter_info, data):
#     def collect_files_from_subdir(self, path, filter, recursive=False):
#     def set_save_name(self, name):
#     def set_current_directory(self, path):
#     def should_open_recursive(self):
#     def _response(self, widget, response):
#     def _update_preview(self, *args):
#     def _preview_thumbnail_finished(self, filepath, pixbuf):
#     def _current_file(self):


# Path: mcomix/file_chooser_main_dialog.py
import gtk
from mcomix.preferences import prefs
from mcomix import file_chooser_base_dialog

        self.filechooser.set_select_multiple(True)

        ffilter = gtk.FileFilter()
        ffilter.add_pixbuf_formats()
        ffilter.set_name(_('All images'))
        self.filechooser.add_filter(ffilter)
        self.add_filter(_('JPEG images'), ('image/jpeg',), ('*.jpg', '*.jpeg'))
        self.add_filter(_('PNG images'), ('image/png',), ('*.png',))
        self.add_filter(_('GIF images'), ('image/gif',), ('*.gif',))
        self.add_filter(_('TIFF images'), ('image/tiff',), ('*.tiff',))
        self.add_filter(_('BMP images'), ('image/bmp',), ('*.bmp',))

        filters = self.filechooser.list_filters()
        try:
            # When setting this to the first filter ("All files"), this
            # fails on some GTK+ versions and sets the filter to "blank".
            # The effect is the same though (i.e. display all files), and
            # there is no solution that I know of, so we'll have to live
            # with it. It only happens the second time a dialog is created
            # though, which is very strange.
            self.filechooser.set_filter(filters[
                prefs['last filter in main filechooser']])
        except:
            self.filechooser.set_filter(filters[0])

    def files_chosen(self, paths):
        if paths:
            try: # For some reason this fails sometimes (GTK+ bug?)
                filter_index = self.filechooser.list_filters().index(
                    self.filechooser.get_filter())

                prefs['last filter in main filechooser'] = filter_index