Example #1
0
 def _response(self, dialog, response):
     if response == Gtk.ResponseType.OK:
         dialog = filechooser.StandAloneFileChooserDialog(
             Gtk.FileChooserAction.SAVE)
         src_path = self.file_handler.get_path_to_base()
         dialog.set_current_directory(os.path.dirname(src_path))
         dialog.set_save_name('%s.cbz' % os.path.splitext(
             os.path.basename(src_path))[0])
         dialog.filechooser.set_extra_widget(Gtk.Label(label=
             _('Archives are stored as ZIP files.')))
         dialog.run()
         paths = dialog.get_paths()
         dialog.destroy()
         if paths:
             self._pack_archive(paths[0])
     elif response == Gtk.ResponseType.HELP: # Actually "Import"
         dialog = filechooser.StandAloneFileChooserDialog()
         dialog.run()
         paths = dialog.get_paths()
         dialog.destroy()
         for path in paths:
             if filehandler.is_image_file(path):
                 self._image_area.add_extra_image(path)
             elif os.path.isfile(path):
                 self._other_area.add_extra_file(path)
     else:
         _close_dialog()
         self.kill = True
Example #2
0
File: edit.py Project: zeldin/Comix
 def _response(self, dialog, response):
     if response == gtk.RESPONSE_OK:
         dialog = filechooser.StandAloneFileChooserDialog(
             gtk.FILE_CHOOSER_ACTION_SAVE)
         src_path = self.file_handler.get_path_to_base()
         dialog.set_current_directory(os.path.dirname(src_path))
         dialog.set_save_name('%s.cbz' % os.path.splitext(
             os.path.basename(src_path))[0])
         dialog.filechooser.set_extra_widget(gtk.Label(
             _('Archives are stored as ZIP files.')))
         dialog.run()
         paths = dialog.get_paths()
         dialog.destroy()
         if paths:
             self._pack_archive(paths[0])
     elif response == gtk.RESPONSE_HELP: # Actually "Import"
         dialog = filechooser.StandAloneFileChooserDialog()
         dialog.run()
         paths = dialog.get_paths()
         dialog.destroy()
         for path in paths:
             if filehandler.is_image_file(path):
                 self._image_area.add_extra_image(path)
             elif os.path.isfile(path):
                 self._other_area.add_extra_file(path)
     else:
         _close_dialog()
         self.kill = True
Example #3
0
def run():
    """Run the program."""
    # Use gettext translations as found in the source dir, otherwise based on
    # the install path.
    exec_path = os.path.abspath(sys.argv[0])
    base_dir = os.path.dirname(os.path.dirname(exec_path))
    if os.path.isdir(os.path.join(base_dir, 'messages')):
        gettext.install('comix', os.path.join(base_dir, 'messages'),
            unicode=True)
    else:
        gettext.install('comix', os.path.join(base_dir, 'share/locale'),
            unicode=True)

    fullscreen = False
    show_library = False
    open_path = None
    open_page = 1
    try:
        opts, args = getopt.gnu_getopt(sys.argv[1:], 'fhl',
            ['fullscreen', 'help', 'library'])
    except getopt.GetoptError:
        print_help()
    for opt, value in opts:
        if opt in ('-h', '--help'):
            print_help()
        elif opt in ('-f', '--fullscreen'):
            fullscreen = True
        elif opt in ('-l', '--library'):
            show_library = True

    if not os.path.exists(constants.DATA_DIR):
        os.makedirs(constants.DATA_DIR, 0700)
    if not os.path.exists(constants.CONFIG_DIR):
        os.makedirs(constants.CONFIG_DIR, 0700)
    deprecated.move_files_to_xdg_dirs()
    preferences.read_preferences_file()

    GLib.set_application_name("Comix")
    Gtk.Window.set_default_icon_name("comix");

    icons.load_icons()
    
    if len(args) >= 1:
        param_path = os.path.abspath(args[0])
        if os.path.isdir(param_path):
            dir_files = os.listdir(param_path)
            dir_files.sort(locale.strcoll)
            for filename in dir_files:
                full_path = os.path.join(param_path, filename)
                if filehandler.is_image_file(full_path):
                    open_path = full_path
                    break
        else:
            open_path = param_path
    elif preferences.prefs['auto load last file']:
        open_path = preferences.prefs['path to last file']
        open_page = preferences.prefs['page of last file']
    
    window = main.MainWindow(fullscreen=fullscreen, show_library=show_library,
        open_path=open_path, open_page=open_page)
    deprecated.check_for_deprecated_files(window)
    try:
        Gtk.main()
    except KeyboardInterrupt: # Will not always work because of threading.
        window.terminate_program()
Example #4
0
def run():
    """Run the program."""
    # Use gettext translations as found in the source dir, otherwise based on
    # the install path.
    exec_path = os.path.abspath(sys.argv[0])
    base_dir = os.path.dirname(os.path.dirname(exec_path))
    if os.path.isdir(os.path.join(base_dir, 'messages')):
        gettext.install('comix', os.path.join(base_dir, 'messages'),
            unicode=True)
    else:
        gettext.install('comix', os.path.join(base_dir, 'share/locale'),
            unicode=True)

    fullscreen = False
    show_library = False
    open_path = None
    open_page = 1
    try:
        opts, args = getopt.gnu_getopt(sys.argv[1:], 'fhl',
            ['fullscreen', 'help', 'library'])
    except getopt.GetoptError:
        print_help()
    for opt, value in opts:
        if opt in ('-h', '--help'):
            print_help()
        elif opt in ('-f', '--fullscreen'):
            fullscreen = True
        elif opt in ('-l', '--library'):
            show_library = True

    if not os.path.exists(constants.DATA_DIR):
        os.makedirs(constants.DATA_DIR, 0700)
    if not os.path.exists(constants.CONFIG_DIR):
        os.makedirs(constants.CONFIG_DIR, 0700)
    deprecated.move_files_to_xdg_dirs()
    preferences.read_preferences_file()
    icons.load_icons()
    
    if len(args) >= 1:
        param_path = os.path.abspath(args[0])
        if os.path.isdir(param_path):
            dir_files = os.listdir(param_path)
            dir_files.sort(locale.strcoll)
            for filename in dir_files:
                full_path = os.path.join(param_path, filename)
                if filehandler.is_image_file(full_path):
                    open_path = full_path
                    break
        else:
            open_path = param_path
    elif preferences.prefs['auto load last file']:
        open_path = preferences.prefs['path to last file']
        open_page = preferences.prefs['page of last file']
    
    window = main.MainWindow(fullscreen=fullscreen, show_library=show_library,
        open_path=open_path, open_page=open_page)
    deprecated.check_for_deprecated_files(window)
    try:
        gtk.main()
    except KeyboardInterrupt: # Will not always work because of threading.
        window.terminate_program()