예제 #1
0
파일: labels.py 프로젝트: chrisz/paperwork
    def edit(self, main_window):
        """
        Open the edit dialog, and update the label according to user changes
        """
        widget_tree = load_uifile("labeledit.glade")

        dialog = widget_tree.get_object("dialogLabelEditor")
        name_entry = widget_tree.get_object("entryLabelName")
        color_chooser = widget_tree.get_object("colorselectionLabelColor")

        name_entry.set_text(self.label.name)
        color_chooser.set_current_color(self.label.color)

        dialog.set_transient_for(main_window)
        dialog.add_button("Cancel", gtk.RESPONSE_CANCEL)
        dialog.add_button("Ok", gtk.RESPONSE_OK)
        response = dialog.run()

        if (response == gtk.RESPONSE_OK
            and name_entry.get_text().strip() == ""):
            response = gtk.RESPONSE_CANCEL
        if (response == gtk.RESPONSE_OK):
            print "Label validated"
            self.label.name = unicode(name_entry.get_text())
            self.label.color = color_chooser.get_current_color()
        else:
            print "Label editing cancelled"

        dialog.destroy()

        print "Label after editing: %s" % (self.label)
        return (response == gtk.RESPONSE_OK)
예제 #2
0
파일: labels.py 프로젝트: chrisz/paperwork
    def edit(self, main_window):
        """
        Open the edit dialog, and update the label according to user changes
        """
        widget_tree = load_uifile("labeledit.glade")

        dialog = widget_tree.get_object("dialogLabelEditor")
        name_entry = widget_tree.get_object("entryLabelName")
        color_chooser = widget_tree.get_object("colorselectionLabelColor")

        name_entry.set_text(self.label.name)
        color_chooser.set_current_color(self.label.color)

        dialog.set_transient_for(main_window)
        dialog.add_button("Cancel", gtk.RESPONSE_CANCEL)
        dialog.add_button("Ok", gtk.RESPONSE_OK)
        response = dialog.run()

        if (response == gtk.RESPONSE_OK
                and name_entry.get_text().strip() == ""):
            response = gtk.RESPONSE_CANCEL
        if (response == gtk.RESPONSE_OK):
            print "Label validated"
            self.label.name = unicode(name_entry.get_text())
            self.label.color = color_chooser.get_current_color()
        else:
            print "Label editing cancelled"

        dialog.destroy()

        print "Label after editing: %s" % (self.label)
        return (response == gtk.RESPONSE_OK)
예제 #3
0
    def edit(self, main_window):
        """
        Open the edit dialog, and update the label according to user changes
        """
        widget_tree = load_uifile("labeledit.glade")

        dialog = widget_tree.get_object("dialogLabelEditor")
        name_entry = widget_tree.get_object("entryLabelName")
        color_chooser = widget_tree.get_object("colorselectionLabelColor")

        name_entry.set_text(self.label.name)
        name_entry.connect("changed", self.__on_label_entry_changed)
        color_chooser.set_current_color(self.label.color)

        dialog.set_transient_for(main_window)
        dialog.add_button(_("Cancel"), Gtk.ResponseType.CANCEL)
        self.__ok_button = dialog.add_button(_("Ok"), Gtk.ResponseType.OK)

        self.__on_label_entry_changed(name_entry)

        response = dialog.run()

        if response == Gtk.ResponseType.OK and name_entry.get_text().strip() == "":
            response = Gtk.ResponseType.CANCEL
        if response == Gtk.ResponseType.OK:
            print "Label validated"
            self.label.name = unicode(name_entry.get_text(), encoding="utf-8")
            self.label.color = color_chooser.get_current_color()
        else:
            print "Label editing cancelled"

        dialog.destroy()

        print "Label after editing: %s" % (self.label)
        return response == Gtk.ResponseType.OK
예제 #4
0
    def __init__(self, main_window):
        self.__widget_tree = load_uifile("aboutdialog.glade")

        self.__dialog = self.__widget_tree.get_object("aboutdialog")
        assert(self.__dialog)
        self.__dialog.set_transient_for(main_window)

        self.__dialog.connect("response", lambda x, y: x.destroy())
예제 #5
0
    def __init__(self, main_window):
        self.__widget_tree = load_uifile("aboutdialog.glade")

        self.__dialog = self.__widget_tree.get_object("aboutdialog")
        assert (self.__dialog)
        self.__dialog.set_transient_for(main_window)

        self.__dialog.connect("response", lambda x, y: x.destroy())
예제 #6
0
파일: page_edit.py 프로젝트: rzr/paperwork
    def __init__(self, main_window, page):
        self.page = page

        widget_tree = load_uifile("pageeditingdialog.glade")

        self.__dialog = widget_tree.get_object("dialogPageEditing")
        self.__dialog.set_transient_for(main_window.window)

        self.__original_img_widgets = {
            'img': widget_tree.get_object("imageOriginal"),
            'scrolledwindow': widget_tree.get_object("scrolledwindowOriginal"),
            'eventbox': widget_tree.get_object("eventboxOriginal"),
            'viewport': widget_tree.get_object("viewportOriginal")
        }
        self.__result_img_widget = widget_tree.get_object("imageResult")
        self.__buttons = {
            'cutting': widget_tree.get_object("togglebuttonCutting"),
            'rotate': {
                'clockwise': (widget_tree.get_object("buttonRotateClockwise"),
                              90),
                'counter_clockwise':
                (widget_tree.get_object("buttonRotateCounterClockwise"), -90),
            }
        }

        self.__cut_grips = None

        self.__original_img_widgets['viewport'].connect(
            "size-allocate",
            lambda widget, size: GObject.idle_add(self.__on_size_allocated_cb))
        self.__buttons['cutting'].connect(
            "toggled",
            lambda widget: GObject.idle_add(
                self.__on_cutting_button_toggled_cb))
        self.__buttons['rotate']['clockwise'][0].connect(
            "clicked",
            lambda widget:
            GObject.idle_add(self.__on_rotate_activated_cb, widget))
        self.__buttons['rotate']['counter_clockwise'][0].connect(
            "clicked",
            lambda widget:
            GObject.idle_add(self.__on_rotate_activated_cb, widget))

        self.page = page
        self.imgs = {
            'orig': (1.0, self.page.img)
        }

        self.__changes = []
예제 #7
0
    def __init__(self, main_window, config, doc):
        self.__main_win = main_window
        self.__config = config
        self.doc = doc

        widget_tree = load_uifile("doceditdialog.glade")
        self.date = {
            'year': {
                'view': widget_tree.get_object("spinbuttonYear"),
                'model': widget_tree.get_object("adjustmentYear"),
            },
            'month': {
                'view': widget_tree.get_object("spinbuttonMonth"),
                'model': widget_tree.get_object("adjustmentMonth"),
            },
            'day': {
                'view': widget_tree.get_object("spinbuttonDay"),
                'model': widget_tree.get_object("adjustmentDay"),
            },
            'box': widget_tree.get_object("boxDate")
        }
        self.text = {
            'view': widget_tree.get_object("textviewText"),
            'model': widget_tree.get_object("textbufferText"),
        }

        self.__change_widget_order_according_to_locale()

        self.refresh_date()
        self.refresh_text()

        self.dialog = widget_tree.get_object("dialogDocEdit")
        self.dialog.set_transient_for(self.__main_win.window)

        try:
            while True:
                ret = self.dialog.run()
                if ret != 0:
                    logger.info("Doc edit: Cancelling changes")
                    break
                else:
                    logger.info("Doc edit: Applying changes")
                    if self.apply_changes():
                        break
        finally:
            self.dialog.destroy()
예제 #8
0
    def __init__(self, main_window, config, doc):
        self.__main_win = main_window
        self.__config = config
        self.doc = doc

        widget_tree = load_uifile("doceditdialog.glade")
        self.date = {
            'year': {
                'view': widget_tree.get_object("spinbuttonYear"),
                'model': widget_tree.get_object("adjustmentYear"),
            },
            'month': {
                'view': widget_tree.get_object("spinbuttonMonth"),
                'model': widget_tree.get_object("adjustmentMonth"),
            },
            'day': {
                'view': widget_tree.get_object("spinbuttonDay"),
                'model': widget_tree.get_object("adjustmentDay"),
            },
            'box': widget_tree.get_object("boxDate")
        }
        self.text = {
            'view': widget_tree.get_object("textviewText"),
            'model': widget_tree.get_object("textbufferText"),
        }

        self.__change_widget_order_according_to_locale()

        self.refresh_date()
        self.refresh_text()

        self.dialog = widget_tree.get_object("dialogDocEdit")
        self.dialog.set_transient_for(self.__main_win.window)

        try:
            while True:
                ret = self.dialog.run()
                if ret != 0:
                    logger.info("Doc edit: Cancelling changes")
                    break
                else:
                    logger.info("Doc edit: Applying changes")
                    if self.apply_changes():
                        break
        finally:
            self.dialog.destroy()
예제 #9
0
    def edit(self, main_window):
        """
        Open the edit dialog, and update the label according to user changes
        """
        widget_tree = load_uifile("labeledit.glade")

        dialog = widget_tree.get_object("dialogLabelEditor")
        name_entry = widget_tree.get_object("entryLabelName")
        color_chooser = widget_tree.get_object("colorselectionLabelColor")

        name_entry.set_text(self.label.name)
        name_entry.connect("changed", self.__on_label_entry_changed)
        color_chooser.set_current_color(self.label.color)

        dialog.set_transient_for(main_window)
        dialog.add_button(_("Cancel"), Gtk.ResponseType.CANCEL)
        self.__ok_button = dialog.add_button(_("Ok"), Gtk.ResponseType.OK)

        self.__on_label_entry_changed(name_entry)

        response = dialog.run()

        if (response == Gtk.ResponseType.OK
                and name_entry.get_text().strip() == ""):
            response = Gtk.ResponseType.CANCEL

        if (response == Gtk.ResponseType.OK):
            logger.info("Label validated")
            self.label.name = unicode(name_entry.get_text(), encoding='utf-8')
            self.label.color = color_chooser.get_current_color()
        else:
            logger.info("Label editing cancelled")

        dialog.destroy()

        logger.info("Label after editing: %s" % self.label)
        return (response == Gtk.ResponseType.OK)
예제 #10
0
    def __init__(self, main_window, config):
        gobject.GObject.__init__(self)

        self.scanned_pages = 0

        self.__config = config

        widget_tree = load_uifile("multiscan.glade")

        self.lists = {
            'docs' : {
                'gui': widget_tree.get_object("treeviewScanList"),
                'model': widget_tree.get_object("liststoreScanList"),
                'columns' : {
                    'nb_pages' : \
                        widget_tree.get_object("treeviewcolumnNbPages"),
                },
                'include_current_doc': False,
            },
        }

        self.removeDocButton = widget_tree.get_object("buttonRemoveDoc")
        self.removeDocButton.set_sensitive(False)

        actions = {
            'add_doc' : (
                [widget_tree.get_object("buttonAddDoc")],
                ActionAddDoc(self, config),
            ),
            'select_doc' : (
                [widget_tree.get_object("treeviewScanList")],
                ActionSelectDoc(self),
            ),
            'start_edit_doc' : (
                [widget_tree.get_object("buttonEditDoc")],
                ActionStartEditDoc(self),
            ),
            'end_edit_doc' : (
                [widget_tree.get_object("cellrenderertextNbPages")],
                ActionEndEditDoc(self),
            ),
            'del_doc' : (
                [self.removeDocButton],
                ActionRemoveDoc(self),
            ),
            'cancel' : (
                [widget_tree.get_object("buttonCancel")],
                ActionCancel(self)
            ),
            'scan' : (
                [widget_tree.get_object("buttonOk")],
                ActionScan(self, config, main_window.docsearch, main_window.doc),
            ),
        }

        for action in ['add_doc', 'select_doc', 'start_edit_doc',
                       'end_edit_doc', 'del_doc',
                       'scan', 'cancel']:
            actions[action][1].connect(actions[action][0])

        self.to_disable_on_scan = [
            actions['add_doc'][0][0],
            actions['start_edit_doc'][0][0],
            actions['del_doc'][0][0],
            actions['scan'][0][0],
        ]

        self.lists['docs']['model'].clear()
        if len(main_window.doc.pages) > 0 and main_window.doc.can_edit:
            self.lists['docs']['model'].append([
                _("Current document (%s)") % (str(main_window.doc)),
                "0",  # nb_pages
                True,  # can_edit (nb_pages)
                0,  # scan_progress_int
                "",  # scan_progress_txt
                False,  # can_delete
            ])
            self.lists['docs']['include_current_doc'] = True
        else:
            # add a first document to the list (the user will need one anyway)
            actions['add_doc'][1].do()

        self.scan_queue = WorkerQueue("Mutiple scans")
        self.scan_queue.connect("queue-start", lambda queue: \
                gobject.idle_add(self.__on_global_scan_start_cb, queue))
        self.scan_queue.connect("queue-stop", lambda queue, exc: \
                gobject.idle_add(self.__on_global_scan_end_cb, queue, exc))
        self.scan_queue.connect("scan-start", lambda worker, page, total: \
                gobject.idle_add(self.__on_scan_start_cb, worker, page, total))
        self.scan_queue.connect("ocr-start", lambda worker, page, total: \
                gobject.idle_add(self.__on_ocr_start_cb, worker, page, total))
        self.scan_queue.connect("scan-done", lambda worker, page, total: \
                gobject.idle_add(self.__on_scan_done_cb, worker, page, total))

        self.dialog = widget_tree.get_object("dialogMultiscan")
        self.dialog.connect("destroy", self.__on_destroy)


        self.dialog.set_transient_for(main_window.window)
        self.dialog.set_visible(True)
예제 #11
0
    def __init__(self, mainwindow_gui, config):
        gobject.GObject.__init__(self)
        widget_tree = load_uifile("settingswindow.glade")

        self.window = widget_tree.get_object("windowSettings")
        self.window.set_transient_for(mainwindow_gui)

        self.__config = config

        self.workdir_chooser = widget_tree.get_object("filechooserbutton")

        actions = {
            "apply": ([widget_tree.get_object("buttonSettingsOk")],
                      ActionApplySettings(self, config)),
            "cancel": ([widget_tree.get_object("buttonSettingsCancel")],
                       ActionCancelSettings(self, config)),
            "select_scanner": ([widget_tree.get_object("comboboxDevices")],
                               ActionSelectScanner(self)),
            "scan_calibration":
            ([widget_tree.get_object("buttonScanCalibration")],
             ActionScanCalibration(self))
        }

        self.device_settings = {
            "devid": {
                'gui': widget_tree.get_object("comboboxDevices"),
                'stores': {
                    'loading': widget_tree.get_object("liststoreLoading"),
                    'loaded': widget_tree.get_object("liststoreDevice"),
                },
                'nb_elements': 0,
                'active_idx': -1,
            },
            "resolution": {
                'gui': widget_tree.get_object("comboboxResolution"),
                'stores': {
                    'loading': widget_tree.get_object("liststoreLoading"),
                    'loaded': widget_tree.get_object("liststoreResolution"),
                },
                'nb_elements': 0,
                'active_idx': -1,
            },
        }

        self.ocr_settings = {
            "lang": {
                'gui': widget_tree.get_object("comboboxLang"),
                'store': widget_tree.get_object("liststoreOcrLang"),
            }
        }

        self.calibration = {
            "scan_button":
            widget_tree.get_object("buttonScanCalibration"),
            "image_gui":
            widget_tree.get_object("imageCalibration"),
            "image_viewport":
            widget_tree.get_object("viewportCalibration"),
            "images": [],  # array of tuples : (resize factor, PIL image)
            "image_eventbox":
            widget_tree.get_object("eventboxCalibration"),
            "image_scrollbars":
            widget_tree.get_object("scrolledwindowCalibration"),
        }

        self.grips = CalibrationGripHandler(config, self)

        self.progressbar = widget_tree.get_object("progressbarScan")
        self.__scan_start = 0.0

        self.workers = {
            "device_finder":
            WorkerDeviceFinder(config.scanner_devid),
            "resolution_finder":
            WorkerResolutionFinder(config.scanner_resolution,
                                   config.RECOMMENDED_RESOLUTION),
            "scan":
            WorkerCalibrationScan(self.calibration['image_viewport']),
            "progress_updater":
            WorkerProgressUpdater("calibration scan", self.progressbar)
        }

        ocr_tools = pyocr.get_available_tools()
        if len(ocr_tools) <= 0:
            ocr_langs = []
        else:
            ocr_langs = ocr_tools[0].get_available_languages()
        ocr_langs = self.__get_short_to_long_langs(ocr_langs)
        ocr_langs.sort(key=lambda lang: lang[1])
        ocr_langs.insert(0, (None, _("Disable OCR")))

        self.ocr_settings['lang']['store'].clear()
        for (short_lang, long_lang) in ocr_langs:
            self.ocr_settings['lang']['store'].append([long_lang, short_lang])

        for action in [
                "apply", "cancel", "select_scanner", "scan_calibration"
        ]:
            actions[action][1].connect(actions[action][0])

        self.workers['device_finder'].connect(
            'device-finding-start',
            lambda worker: gobject.idle_add(self.__on_device_finding_start_cb))
        self.workers['device_finder'].connect(
                'device-found',
                lambda worker, user_name, store_name, active: \
                    gobject.idle_add(self.__on_value_found_cb,
                                     self.device_settings['devid'],
                                     user_name, store_name, active))
        self.workers['device_finder'].connect(
            'device-finding-end', lambda worker: gobject.idle_add(
                self.__on_finding_end_cb, self.device_settings['devid']))

        self.workers['resolution_finder'].connect(
            'resolution-finding-start',
            lambda worker: gobject.idle_add(self.__on_finding_start_cb, self.
                                            device_settings['resolution']))
        self.workers['resolution_finder'].connect(
                'resolution-found',
                lambda worker, user_name, store_name, active: \
                    gobject.idle_add(self.__on_value_found_cb,
                                     self.device_settings['resolution'],
                                     user_name, store_name, active))
        self.workers['resolution_finder'].connect(
            'resolution-finding-end', lambda worker: gobject.idle_add(
                self.__on_finding_end_cb, self.device_settings['resolution']))

        self.workers['scan'].connect('calibration-scan-start',
                                     lambda worker: self.__on_scan_start())
        self.workers['scan'].connect(
            'calibration-scan-done',
            lambda worker, img: self.__on_scan_done(img))
        self.workers['scan'].connect(
            'calibration-resize-done',
            lambda worker, factor, img: self.__on_resize_done(factor, img))

        self.calibration['image_eventbox'].connect(
            "button-press-event",
            lambda x, ev: self.grips.on_mouse_button_pressed_cb(ev))
        self.calibration['image_eventbox'].connect(
            "motion-notify-event",
            lambda x, ev: self.grips.on_mouse_motion(ev))
        self.calibration['image_eventbox'].connect(
            "button-release-event",
            lambda x, ev: self.grips.on_mouse_button_released_cb(ev))
        self.calibration['image_eventbox'].add_events(
            gtk.gdk.POINTER_MOTION_MASK)

        self.window.connect("destroy", self.__on_destroy)

        self.display_config(config)

        self.window.set_visible(True)

        # Must be connected after the window has been displayed.
        # Otherwise, if "disable OCR" is already selected in the config
        # it will display a warning popup even before the dialog has been
        # displayed
        self.ocr_settings['lang']['gui'].connect("changed",
                                                 self.__on_ocr_lang_changed)

        self.workers['device_finder'].start()
예제 #12
0
    def __init__(self, mainwindow_gui, config):
        gobject.GObject.__init__(self)
        widget_tree = load_uifile("settingswindow.glade")

        self.window = widget_tree.get_object("windowSettings")
        self.window.set_transient_for(mainwindow_gui)

        self.__config = config

        self.workdir_chooser = widget_tree.get_object("filechooserbutton")

        actions = {
            "apply" : (
                [widget_tree.get_object("buttonSettingsOk")],
                ActionApplySettings(self, config)
            ),
            "cancel" : (
                [widget_tree.get_object("buttonSettingsCancel")],
                ActionCancelSettings(self, config)
            ),
            "select_scanner" : (
                [widget_tree.get_object("comboboxDevices")],
                ActionSelectScanner(self)
            ),
            "scan_calibration" : (
                [widget_tree.get_object("buttonScanCalibration")],
                ActionScanCalibration(self)
            )
        }

        self.device_settings = {
            "devid" : {
                'gui' : widget_tree.get_object("comboboxDevices"),
                'stores' : {
                    'loading' : widget_tree.get_object("liststoreLoading"),
                    'loaded'  : widget_tree.get_object("liststoreDevice"),
                },
                'nb_elements' : 0,
                'active_idx' : -1,
            },
            "resolution" : {
                'gui' : widget_tree.get_object("comboboxResolution"),
                'stores' : {
                    'loading' : widget_tree.get_object("liststoreLoading"),
                    'loaded' : widget_tree.get_object("liststoreResolution"),
                },
                'nb_elements' : 0,
                'active_idx' : -1,
            },
        }

        self.ocr_settings = {
            "lang" : {
                'gui' : widget_tree.get_object("comboboxLang"),
                'store' : widget_tree.get_object("liststoreOcrLang"),
            }
        }

        self.calibration = {
            "scan_button" : widget_tree.get_object("buttonScanCalibration"),
            "image_gui" : widget_tree.get_object("imageCalibration"),
            "image_viewport" : widget_tree.get_object("viewportCalibration"),
            "images" : [],  # array of tuples : (resize factor, PIL image)
            "image_eventbox" : widget_tree.get_object("eventboxCalibration"),
            "image_scrollbars" : widget_tree.get_object("scrolledwindowCalibration"),
        }

        self.grips = CalibrationGripHandler(config, self)

        self.progressbar = widget_tree.get_object("progressbarScan")
        self.__scan_start = 0.0

        self.workers = {
            "device_finder" : WorkerDeviceFinder(config.scanner_devid),
            "resolution_finder" : WorkerResolutionFinder(
                    config.scanner_resolution,
                    config.RECOMMENDED_RESOLUTION),
            "scan" : WorkerCalibrationScan(
                    self.calibration['image_viewport']),
            "progress_updater" : WorkerProgressUpdater("calibration scan",
                                                       self.progressbar)
        }

        ocr_tools = pyocr.get_available_tools()
        if len(ocr_tools) <= 0:
            ocr_langs = []
        else:
            ocr_langs = ocr_tools[0].get_available_languages()
        ocr_langs = self.__get_short_to_long_langs(ocr_langs)
        ocr_langs.sort(key=lambda lang: lang[1])
        ocr_langs.insert(0, (None, _("Disable OCR")))

        self.ocr_settings['lang']['store'].clear()
        for (short_lang, long_lang) in ocr_langs:
            self.ocr_settings['lang']['store'].append([long_lang, short_lang])

        for action in ["apply", "cancel", "select_scanner", "scan_calibration"]:
            actions[action][1].connect(actions[action][0])

        self.workers['device_finder'].connect(
                'device-finding-start',
                lambda worker: gobject.idle_add(
                    self.__on_device_finding_start_cb))
        self.workers['device_finder'].connect(
                'device-found',
                lambda worker, user_name, store_name, active: \
                    gobject.idle_add(self.__on_value_found_cb,
                                     self.device_settings['devid'],
                                     user_name, store_name, active))
        self.workers['device_finder'].connect(
                'device-finding-end',
                lambda worker: gobject.idle_add(
                    self.__on_finding_end_cb,
                    self.device_settings['devid']))

        self.workers['resolution_finder'].connect(
                'resolution-finding-start',
                lambda worker: gobject.idle_add(
                    self.__on_finding_start_cb,
                    self.device_settings['resolution']))
        self.workers['resolution_finder'].connect(
                'resolution-found',
                lambda worker, user_name, store_name, active: \
                    gobject.idle_add(self.__on_value_found_cb,
                                     self.device_settings['resolution'],
                                     user_name, store_name, active))
        self.workers['resolution_finder'].connect(
                'resolution-finding-end',
                lambda worker: gobject.idle_add(
                    self.__on_finding_end_cb,
                    self.device_settings['resolution']))

        self.workers['scan'].connect('calibration-scan-start',
                lambda worker: self.__on_scan_start())
        self.workers['scan'].connect('calibration-scan-done',
                lambda worker, img: self.__on_scan_done(img))
        self.workers['scan'].connect('calibration-resize-done',
                lambda worker, factor, img: self.__on_resize_done(factor, img))

        self.calibration['image_eventbox'].connect("button-press-event",
                lambda x, ev: self.grips.on_mouse_button_pressed_cb(ev))
        self.calibration['image_eventbox'].connect("motion-notify-event",
                lambda x, ev: self.grips.on_mouse_motion(ev))
        self.calibration['image_eventbox'].connect("button-release-event",
                lambda x, ev: self.grips.on_mouse_button_released_cb(ev))
        self.calibration['image_eventbox'].add_events(
                gtk.gdk.POINTER_MOTION_MASK)

        self.window.connect("destroy", self.__on_destroy)

        self.display_config(config)

        self.window.set_visible(True)

        # Must be connected after the window has been displayed.
        # Otherwise, if "disable OCR" is already selected in the config
        # it will display a warning popup even before the dialog has been
        # displayed
        self.ocr_settings['lang']['gui'].connect(
            "changed", self.__on_ocr_lang_changed)

        self.workers['device_finder'].start()
예제 #13
0
 def __init__(self, main_window):
     self.__widget_tree = load_uifile("aboutdialog.glade")
     self.__aboutdialog = self.__widget_tree.get_object("aboutdialog")
     self.__aboutdialog.set_transient_for(main_window)
     assert(self.__aboutdialog)
     self.__connect_signals()
예제 #14
0
    def __init__(self, main_window, config):
        gobject.GObject.__init__(self)

        self.scanned_pages = 0

        self.__config = config

        widget_tree = load_uifile("multiscan.glade")

        self.lists = {
            "docs": {
                "gui": widget_tree.get_object("treeviewScanList"),
                "model": widget_tree.get_object("liststoreScanList"),
                "columns": {"nb_pages": widget_tree.get_object("treeviewcolumnNbPages")},
                "include_current_doc": False,
            }
        }

        self.lists["docs"]["model"].clear()
        if len(main_window.doc.pages) > 0:
            self.lists["docs"]["model"].append(
                [
                    _("Current document (%s)") % (str(main_window.doc)),
                    "0",  # nb_pages
                    True,  # can_edit (nb_pages)
                    0,  # scan_progress_int
                    "",  # scan_progress_txt
                    False,  # can_delete
                ]
            )
            self.lists["docs"]["include_current_doc"] = True

        self.removeDocButton = widget_tree.get_object("buttonRemoveDoc")
        self.removeDocButton.set_sensitive(False)

        actions = {
            "add_doc": ([widget_tree.get_object("buttonAddDoc")], ActionAddDoc(self, config)),
            "select_doc": ([widget_tree.get_object("treeviewScanList")], ActionSelectDoc(self)),
            "start_edit_doc": ([widget_tree.get_object("buttonEditDoc")], ActionStartEditDoc(self)),
            "end_edit_doc": ([widget_tree.get_object("cellrenderertextNbPages")], ActionEndEditDoc(self)),
            "del_doc": ([self.removeDocButton], ActionRemoveDoc(self)),
            "cancel": ([widget_tree.get_object("buttonCancel")], ActionCancel(self)),
            "scan": ([widget_tree.get_object("buttonOk")], ActionScan(self, config, main_window.doc)),
        }

        for action in ["add_doc", "select_doc", "start_edit_doc", "end_edit_doc", "del_doc", "scan", "cancel"]:
            actions[action][1].connect(actions[action][0])

        self.to_disable_on_scan = [
            actions["add_doc"][0][0],
            actions["start_edit_doc"][0][0],
            actions["del_doc"][0][0],
            actions["scan"][0][0],
        ]

        self.scan_queue = WorkerQueue("Mutiple scans")
        self.scan_queue.connect("queue-start", lambda queue: gobject.idle_add(self.__on_global_scan_start_cb, queue))
        self.scan_queue.connect(
            "queue-stop", lambda queue, exc: gobject.idle_add(self.__on_global_scan_end_cb, queue, exc)
        )
        self.scan_queue.connect(
            "scan-start", lambda worker, page, total: gobject.idle_add(self.__on_scan_start_cb, worker, page, total)
        )
        self.scan_queue.connect(
            "ocr-start", lambda worker, page, total: gobject.idle_add(self.__on_ocr_start_cb, worker, page, total)
        )
        self.scan_queue.connect(
            "scan-done", lambda worker, page, total: gobject.idle_add(self.__on_scan_done_cb, worker, page, total)
        )

        self.dialog = widget_tree.get_object("dialogMultiscan")
        self.dialog.set_transient_for(main_window.window)
        self.dialog.set_visible(True)
예제 #15
0
    def __init__(self, main_window, config):
        GObject.GObject.__init__(self)

        self.scanned_pages = 0

        self.__config = config

        widget_tree = load_uifile("multiscan.glade")

        self.lists = {
            'docs' : {
                'gui': widget_tree.get_object("treeviewScanList"),
                'model': widget_tree.get_object("liststoreScanList"),
                'columns' : {
                    'nb_pages' : \
                        widget_tree.get_object("treeviewcolumnNbPages"),
                },
                'include_current_doc': False,
            },
        }

        self.removeDocButton = widget_tree.get_object("buttonRemoveDoc")
        self.removeDocButton.set_sensitive(False)

        actions = {
            'add_doc': (
                [widget_tree.get_object("buttonAddDoc")],
                ActionAddDoc(self, config),
            ),
            'select_doc': (
                [widget_tree.get_object("treeviewScanList")],
                ActionSelectDoc(self),
            ),
            'start_edit_doc': (
                [widget_tree.get_object("buttonEditDoc")],
                ActionStartEditDoc(self),
            ),
            'end_edit_doc': (
                [widget_tree.get_object("cellrenderertextNbPages")],
                ActionEndEditDoc(self),
            ),
            'del_doc': (
                [self.removeDocButton],
                ActionRemoveDoc(self),
            ),
            'cancel':
            ([widget_tree.get_object("buttonCancel")], ActionCancel(self)),
            'scan': (
                [widget_tree.get_object("buttonOk")],
                ActionScan(self, config, main_window.docsearch,
                           main_window.doc),
            ),
        }

        for action in [
                'add_doc', 'select_doc', 'start_edit_doc', 'end_edit_doc',
                'del_doc', 'scan', 'cancel'
        ]:
            actions[action][1].connect(actions[action][0])

        self.to_disable_on_scan = [
            actions['add_doc'][0][0],
            actions['start_edit_doc'][0][0],
            actions['del_doc'][0][0],
            actions['scan'][0][0],
        ]

        self.lists['docs']['model'].clear()
        if len(main_window.doc.pages) > 0 and main_window.doc.can_edit:
            self.lists['docs']['model'].append([
                _("Current document (%s)") % (str(main_window.doc)),
                "0",  # nb_pages
                True,  # can_edit (nb_pages)
                0,  # scan_progress_int
                "",  # scan_progress_txt
                False,  # can_delete
            ])
            self.lists['docs']['include_current_doc'] = True
        else:
            # add a first document to the list (the user will need one anyway)
            actions['add_doc'][1].do()

        self.scan_queue = IndependentWorkerQueue("Mutiple scans")
        self.scan_queue.connect("queue-start", lambda queue: \
                GObject.idle_add(self.__on_global_scan_start_cb, queue))
        self.scan_queue.connect("queue-stop", lambda queue, exc: \
                GObject.idle_add(self.__on_global_scan_end_cb, queue, exc))
        self.scan_queue.connect("scan-start", lambda worker, page, total: \
                GObject.idle_add(self.__on_scan_start_cb, worker, page, total))
        self.scan_queue.connect("ocr-start", lambda worker, page, total: \
                GObject.idle_add(self.__on_ocr_start_cb, worker, page, total))
        self.scan_queue.connect("scan-done", lambda worker, page, total: \
                GObject.idle_add(self.__on_scan_done_cb, worker, page, total))

        self.dialog = widget_tree.get_object("dialogMultiscan")
        self.dialog.connect("destroy", self.__on_destroy)

        self.dialog.set_transient_for(main_window.window)
        self.dialog.set_visible(True)
예제 #16
0
    def __init__(self, main_window, config):
        GObject.GObject.__init__(self)

        self.schedulers = {
            'main': main_window.schedulers['main'],
        }

        self.scanned_pages = 0

        self.__config = config

        widget_tree = load_uifile("multiscan.glade")

        self.lists = {
            'docs': {
                'gui': widget_tree.get_object("treeviewScanList"),
                'model': widget_tree.get_object("liststoreScanList"),
                'columns': {
                    'nb_pages':
                    widget_tree.get_object("treeviewcolumnNbPages"),
                },
                'include_current_doc': False,
            },
        }

        self.removeDocButton = widget_tree.get_object("buttonRemoveDoc")
        self.removeDocButton.set_sensitive(False)

        self.job_factories = {
            'scan': JobFactoryDocScan(self, self.__config,
                                      main_window.docsearch)
        }

        actions = {
            'add_doc': (
                [widget_tree.get_object("buttonAddDoc")],
                ActionAddDoc(self, config),
            ),
            'select_doc': (
                [widget_tree.get_object("treeviewScanList")],
                ActionSelectDoc(self),
            ),
            'start_edit_doc': (
                [widget_tree.get_object("buttonEditDoc")],
                ActionStartEditDoc(self),
            ),
            'end_edit_doc': (
                [widget_tree.get_object("cellrenderertextNbPages")],
                ActionEndEditDoc(self),
            ),
            'del_doc': (
                [self.removeDocButton],
                ActionRemoveDoc(self),
            ),
            'cancel': (
                [widget_tree.get_object("buttonCancel")],
                ActionCancel(self)
            ),
            'scan': (
                [widget_tree.get_object("buttonOk")],
                ActionScan(self, config, main_window.docsearch,
                           main_window.doc),
            ),
        }

        for action in ['add_doc', 'select_doc', 'start_edit_doc',
                       'end_edit_doc', 'del_doc',
                       'scan', 'cancel']:
            actions[action][1].connect(actions[action][0])

        self.to_disable_on_scan = [
            actions['add_doc'][0][0],
            actions['start_edit_doc'][0][0],
            actions['del_doc'][0][0],
            actions['scan'][0][0],
        ]

        self.lists['docs']['model'].clear()
        if len(main_window.doc.pages) > 0 and main_window.doc.can_edit:
            self.lists['docs']['model'].append([
                _("Current document (%s)") % (str(main_window.doc)),
                "0",  # nb_pages
                True,  # can_edit (nb_pages)
                0,  # scan_progress_int
                "",  # scan_progress_txt
                False,  # can_delete
            ])
            self.lists['docs']['include_current_doc'] = True
        else:
            # add a first document to the list (the user will need one anyway)
            actions['add_doc'][1].do()

        self.dialog = widget_tree.get_object("dialogMultiscan")
        self.dialog.connect("destroy", self.__on_destroy)

        self.dialog.set_transient_for(main_window.window)
        self.dialog.set_visible(True)
예제 #17
0
    def __init__(self, main_window, config):
        GObject.GObject.__init__(self)

        self.schedulers = {
            'main': main_window.schedulers['main'],
        }

        self.scanned_pages = 0

        self.__config = config

        widget_tree = load_uifile("multiscan.glade")

        self.lists = {
            'docs': {
                'gui': widget_tree.get_object("treeviewScanList"),
                'model': widget_tree.get_object("liststoreScanList"),
                'columns': {
                    'nb_pages':
                    widget_tree.get_object("treeviewcolumnNbPages"),
                },
                'include_current_doc': False,
            },
        }

        self.removeDocButton = widget_tree.get_object("buttonRemoveDoc")
        self.removeDocButton.set_sensitive(False)

        self.job_factories = {
            'scan': JobFactoryDocScan(self, self.__config,
                                      main_window.docsearch)
        }

        actions = {
            'add_doc': (
                [widget_tree.get_object("buttonAddDoc")],
                ActionAddDoc(self, config),
            ),
            'select_doc': (
                [widget_tree.get_object("treeviewScanList")],
                ActionSelectDoc(self),
            ),
            'start_edit_doc': (
                [widget_tree.get_object("buttonEditDoc")],
                ActionStartEditDoc(self),
            ),
            'end_edit_doc': (
                [widget_tree.get_object("cellrenderertextNbPages")],
                ActionEndEditDoc(self),
            ),
            'del_doc': (
                [self.removeDocButton],
                ActionRemoveDoc(self),
            ),
            'cancel': (
                [widget_tree.get_object("buttonCancel")],
                ActionCancel(self)
            ),
            'scan': (
                [widget_tree.get_object("buttonOk")],
                ActionScan(self, config, main_window.docsearch,
                           main_window.doc),
            ),
        }

        for action in ['add_doc', 'select_doc', 'start_edit_doc',
                       'end_edit_doc', 'del_doc',
                       'scan', 'cancel']:
            actions[action][1].connect(actions[action][0])

        self.to_disable_on_scan = [
            actions['add_doc'][0][0],
            actions['start_edit_doc'][0][0],
            actions['del_doc'][0][0],
            actions['scan'][0][0],
        ]

        self.lists['docs']['model'].clear()
        if len(main_window.doc.pages) > 0 and main_window.doc.can_edit:
            self.lists['docs']['model'].append([
                _("Current document (%s)") % (str(main_window.doc)),
                "0",  # nb_pages
                True,  # can_edit (nb_pages)
                0,  # scan_progress_int
                "",  # scan_progress_txt
                False,  # can_delete
            ])
            self.lists['docs']['include_current_doc'] = True
        else:
            # add a first document to the list (the user will need one anyway)
            actions['add_doc'][1].do()

        self.dialog = widget_tree.get_object("dialogMultiscan")
        self.dialog.connect("destroy", self.__on_destroy)

        self.dialog.set_transient_for(main_window.window)
        self.dialog.set_visible(True)