Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if self.__settings_win.grips is not None:
coords = self.__settings_win.grips.get_coords()
self.__config['scanner_calibration'].value = (
self.__settings_win.calibration['resolution'], coords)
self.__config.write()
self.__settings_win.hide()
if need_reindex:
self.__settings_win.emit("need-reindex")
self.__settings_win.emit("config-changed")
class ActionScanCalibration(SimpleAction):
enabled = True
def __init__(self, settings_win):
self.settings_win = settings_win
super(ActionScanCalibration, self).__init__("Scan calibration sheet")
def do(self):
win = self.settings_win
setting = win.device_settings['devid']
idx = setting['gui'].get_active()
assert(idx >= 0)
devid = setting['stores']['loaded'][idx][1]
setting = win.device_settings['source']
idx = setting['gui'].get_active()
if idx >= 0:
valid_exts = self.__main_win.export['exporter'].get_file_extensions()
if valid_exts:
has_valid_ext = False
for valid_ext in valid_exts:
if filepath.lower().endswith(valid_ext.lower()):
has_valid_ext = True
break
if not has_valid_ext:
filepath += ".%s" % valid_exts[0]
self.__main_win.export['export_path'].set_text(filepath)
self.__main_win.export['buttons']['ok'].set_sensitive(True)
class BasicActionEndExport(SimpleAction):
def __init__(self, main_win, name):
super().__init__(name)
self.main_win = main_win
def hide_dialog(self):
if self.main_win.export['dialog']:
self.main_win.global_page_box.remove(self.main_win.export['dialog'])
self.main_win.export['dialog'].set_visible(False)
self.main_win.export['dialog'] = None
self.main_win.export['exporter'] = None
for button in self.main_win.actions['open_view_settings'][0]:
button.set_sensitive(True)
# force refresh of the current page
self.main_win.show_page(self.main_win.page, force_refresh=True)
b"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
b"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\377\377\377\377\377\377\377\0\0"
b"\0\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
b"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\0\0\0\0\0\0\0\377\0\0\0"
b"\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
b"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\0\0\0\0\0"
b"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
b"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
)
DROPPER_WIDTH = 17
DROPPER_HEIGHT = 17
DROPPER_X_HOT = 2
DROPPER_Y_HOT = 16
class PickColorAction(SimpleAction):
"""
Hack taken from libgtk3/gtk/deprecated/gtkcolorsel.c
"""
def __init__(self, label_editor):
super(PickColorAction, self).__init__("Pick color")
self.__editor = label_editor
self.__dropper_grab_widget = None
self.__grab_time = None
self.__has_grab = False
self.__pointer_device = None
def do(self):
self._get_screen_color()
def _make_picker_cursor(self, display):
if os.name == 'nt':
Starts a new docume.
"""
def __init__(self, doclist, main_win):
SimpleAction.__init__(self, "New document")
self.__doclist = doclist
self.__main_win = main_win
def do(self):
SimpleAction.do(self)
self.__main_win.allow_multiselect = False
self.__doclist.open_new_doc()
self.__doclist.gui['scrollbars'].get_vadjustment().set_value(0)
class ActionUpdateSearchResults(SimpleAction):
"""
Update search results
"""
def __init__(self, main_window, refresh_pages=True):
SimpleAction.__init__(self, "Update search results")
self.__main_win = main_window
self.__refresh_pages = refresh_pages
def do(self):
SimpleAction.do(self)
self.__main_win.refresh_doc_list()
if self.__refresh_pages:
self.__main_win.refresh_boxes()
def do(self):
SimpleAction.do(self)
date_entry = self.__main_win.doc_properties_panel.widgets['name']
date_txt = date_entry.get_text()
# make sure the format is standardized
valid = True
try:
date = BasicDoc.parse_name(date_txt)
logger.info("Valid date: {}".format(date_txt))
css = "GtkEntry { color: black; background: #70CC70; }"
except ValueError:
logger.info("Invalid date: {}".format(date_txt))
valid = False
css = "GtkEntry { color: black; background: #CC3030; }"
if valid and date == self.__main_win.doc_properties_panel.doc.date:
css = "GtkEntry { color: black; background: #CCCCCC; }"
GObject.type_register(JobImporter)
class JobFactoryImporter(JobFactory):
def __init__(self, main_win, config):
JobFactory.__init__(self, "Importer")
self._main_win = main_win
self._config = config
def make(self, importer, file_uri):
return JobImporter(self, next(self.id_generator),
self._main_win, self._config,
importer, file_uri)
class ActionNewDocument(SimpleAction):
"""
Starts a new docume.
"""
def __init__(self, doclist, main_win):
SimpleAction.__init__(self, "New document")
self.__doclist = doclist
self.__main_win = main_win
def do(self):
SimpleAction.do(self)
self.__main_win.allow_multiselect = False
self.__doclist.open_new_doc()
self.__doclist.gui['scrollbars'].get_vadjustment().set_value(0)
docs_gui = self.__dialog.lists['docs']['gui']
(model, selection_iter) = docs_gui.get_selection().get_selected()
if selection_iter is None:
logger.warning("No doc selected")
return
model.remove(selection_iter)
for (line_idx, line) in enumerate(
self.__dialog.lists['docs']['model']
):
if not self.__dialog.lists['docs']['include_current_doc']:
line[0] = _("Document %d") % (line_idx + 1)
elif line_idx != 0:
line[0] = _("Document %d") % line_idx
class ActionStartEditDoc(SimpleAction):
def __init__(self, multiscan_dialog):
SimpleAction.__init__(self, "Start doc edit in multi-scan list")
self.__dialog = multiscan_dialog
def do(self):
SimpleAction.do(self)
docs_gui = self.__dialog.lists['docs']['gui']
(model, selection_iter) = docs_gui.get_selection().get_selected()
if selection_iter is None:
logger.warning("No doc selected")
return
self.__dialog.lists['docs']['gui'].set_cursor(
model.get_path(selection_iter),
self.__dialog.lists['docs']['columns']['nb_pages'],
start_editing=True)
self.__main_win.popovers['view_settings'].set_relative_to(
self.__main_win.actions['open_view_settings'][0][0])
self.__main_win.popovers['view_settings'].set_visible(True)
class ActionShowDocumentAsPaged(SimpleAction):
def __init__(self, main_window):
SimpleAction.__init__(self, "Show document page per page")
self.__main_win = main_window
def do(self):
SimpleAction.do(self)
self.__main_win.set_layout('paged')
class ActionShowDocumentAsGrid(SimpleAction):
def __init__(self, main_window):
SimpleAction.__init__(self, "Show document as a grid")
self.__main_win = main_window
def do(self):
SimpleAction.do(self)
self.__main_win.set_layout('grid')
class ActionSwitchSorting(SimpleAction):
def __init__(self, main_window, config):
SimpleAction.__init__(self, "Switch sorting")
self.__main_win = main_window
self.__config = config
self.__upd_search_results_action = \
ActionUpdateSearchResults(main_window, refresh_pages=False)
self.__main_win.schedulers['index'].schedule(job)
class ActionOpenDiagnostic(SimpleAction):
def __init__(self, main_window):
SimpleAction.__init__(self, "Opening diagnostic dialog")
self.__main_win = main_window
self.diag = None # used to prevent gc
def do(self):
SimpleAction.do(self)
self.diag = DiagDialog(self.__main_win)
self.diag.show()
class ActionOpenActivation(SimpleAction):
def __init__(self, main_window, config):
SimpleAction.__init__(self, "Opening activaton dialog")
self.__config = config
self.__main_win = main_window
self.diag = None # used to prevent gc
def do(self):
SimpleAction.do(self)
self.diag = activation.ActivationDialog(self.__main_win, self.__config)
self.diag.show()
class ActionAbout(SimpleAction):
def __init__(self, main_window):
SimpleAction.__init__(self, "Opening about dialog")
self.__main_win = main_window
def do(self):
SimpleAction.do(self)
selection = self.__dialog.lists['docs']['gui'].get_selection()
if selection is None:
logger.warning("No doc selected")
return
(model, selection_iter) = selection.get_selected()
if selection_iter is None:
logger.warning("No doc selected")
return
val = model.get_value(selection_iter, 5)
self.__dialog.removeDocButton.set_sensitive(val)
class ActionRemoveDoc(SimpleAction):
def __init__(self, multiscan_dialog):
SimpleAction.__init__(self, "Add doc to the multi-scan list")
self.__dialog = multiscan_dialog
def do(self):
SimpleAction.do(self)
docs_gui = self.__dialog.lists['docs']['gui']
(model, selection_iter) = docs_gui.get_selection().get_selected()
if selection_iter is None:
logger.warning("No doc selected")
return
model.remove(selection_iter)
for (line_idx, line) in enumerate(
self.__dialog.lists['docs']['model']
):
if not self.__dialog.lists['docs']['include_current_doc']: