Debian Codegraph @

lios/preferences.py

raw symbols ◀ ▶ SCIP
1 Debian patch touch this file
1 #!/usr/bin/env python3
2 ###########################################################################
3 # Lios - Linux-Intelligent-Ocr-Solution
4 # Copyright (C) 2011-2015 Nalin.x.Linux GPL-3
5 #
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 ###########################################################################
19
20
21 import configparser
22 import shutil
23 from lios.ui.gtk import widget
24 from lios.ui.gtk import containers
25 from lios.ui.gtk import loop
26 from lios.ui.gtk import dialog
27
28 from lios import speech
29 from lios import localization
30
31 _ = localization._
32
33
34 class lios_preferences:
35 def __init__(self):
36
37 #Setting Default Values
38 self.font="Georgia 14";self.highlight_font="Georgia 14";
39 self.highlight_color="#000000000000";
40 self.background_highlight_color="#34346565a4a4";
41 self.speech_module=-1;self.speech_language=-1;self.speech_person=-1;
42 self.speech_rate=0;self.speech_pitch=0;self.speech_volume=100;
43 self.time_between_repeated_scanning=0;self.scan_resolution=300;
44 self.scan_driver=1;self.scanner_cache_calibration=0;
45 self.scan_brightness=50;self.scan_area=0;self.insert_position=2;
46 self.ocr_engine=0;self.language=0;self.language_2=0;self.language_3=0;
47 self.mode_of_rotation=0;self.number_of_pages_to_scan=100;
48 self.give_page_number = 1;self.page_numbering_type=0;
49 self.starting_page_number=1;self.scanner_mode_switching=0;
50 self.run_text_cleaner=0;self.rotation_angle=00;
51
52
53 def set_avalable_scanner_drivers(self,list):
54 self.available_scanner_drivers = list
55
56 def set_avalable_ocr_engines(self,list):
57 self.available_ocr_engine_list = list
58
59 # FUNCTION TO Read PREFERENCES #
60 def set_from_file(self,filename):
61 config = configparser.ConfigParser()
62 if config.read(filename) != []:
63 try:
64 self.time_between_repeated_scanning=int(config.get('cfg',"time_between_repeated_scanning"))
65 self.scan_resolution=int(config.get('cfg',"scan_resolution"))
66 self.scan_brightness=int(config.get('cfg',"scan_brightness"))
67 self.ocr_engine=int(config.get('cfg',"ocr_engine"))
68 self.scan_area=int(config.get('cfg',"scan_area"))
69 self.scan_driver=int(config.get('cfg',"scan_driver"))
70 self.insert_position=int(config.get('cfg',"insert_position"))
71 self.language=int(config.get('cfg',"language"))
72 self.language_2=int(config.get('cfg',"language_2"))
73 self.language_3=int(config.get('cfg',"language_3"))
74 self.speech_module=int(config.get('cfg',"speech_module"))
75 self.speech_language=int(config.get('cfg',"speech_language"))
76 self.speech_person=int(config.get('cfg',"speech_person"))
77 self.speech_rate=int(config.get('cfg',"speech_rate"))
78 self.speech_volume=int(config.get('cfg',"speech_volume"))
79 self.speech_pitch=int(config.get('cfg',"speech_pitch"))
80 self.number_of_pages_to_scan=int(config.get('cfg',"number_of_pages_to_scan"))#pages
81 self.mode_of_rotation = int(config.get('cfg',"mode_of_rotation"))
82 self.rotation_angle = int(config.get('cfg',"rotation_angle"))
83 self.give_page_number=int(config.get('cfg',"give_page_number"))
84 self.page_numbering_type=int(config.get('cfg',"numbering_type"))
85 self.scanner_mode_switching=int(config.get('cfg',"scanner_mode_switching"))
86 self.run_text_cleaner=int(config.get('cfg',"run_text_cleaner"))
87 self.scanner_cache_calibration=int(config.get('cfg',"scanner_cache_calibration"))
88 self.starting_page_number=int(config.get('cfg',"starting_page_number"))
89 self.highlight_color=config.get('cfg',"highlight_color")
90 self.background_highlight_color=config.get('cfg',"highlight_background_color")
91 self.font=config.get('cfg',"font")
92 self.highlight_font=config.get('cfg',"highlight_font")
93 self.require_scanner_refresh = True
94 except:
95 self.__init__()
96 else:
97 self.__init__()
98
99 # Set speech module, language and person if speech_module is not set
100 def set_default_speech_module_and_language(self):
101 if(self.speech_module == -1):
•102 try:
103 test = speech.Speech()
104 output_modules_list = test.list_output_modules()
105 if("espeak-ng" in output_modules_list):
106 self.speech_module = output_modules_list.index('espeak-ng')
107 test.set_output_module('espeak-ng')
108 elif("espeak" in output_modules_list):
109 self.speech_module = output_modules_list.index('espeak')
110 test.set_output_module('espeak')
111
112 # if espeak or espeak-ng set language
113 if(self.speech_module != -1):
114 import locale
115 language_code, encoding = locale.getdefaultlocale()
116 localeValues = language_code.split('_')
117 language = localeValues[0]
118 language_person_dict = test.get_language_person_dict()
119 if(language in language_person_dict.keys()):
120 self.speech_language = list(language_person_dict.keys()).index(language)
121 self.speech_person=0;
122 else:
123 self.speech_module=0;self.speech_language=0;self.speech_person=0;
124
125 #Closing
126 test.close()
127 except:
128 self.speech_module=0;self.speech_language=0;self.speech_person=0;
•129 pass
130
131 def save_to_file(self,filename):
132 #Removing old configuration file
133 try:
134 os.remove(filename)
135 except:
136 pass
137 config = configparser.ConfigParser()
138 config.add_section('cfg')
139 config.set('cfg',"time_between_repeated_scanning",str(self.time_between_repeated_scanning))
140 config.set('cfg',"scan_resolution",str(self.scan_resolution))
141 config.set('cfg',"scan_brightness",str(self.scan_brightness))
142 config.set('cfg',"ocr_engine",str(self.ocr_engine))
143 config.set('cfg',"insert_position",str(self.insert_position))
144 config.set('cfg',"scan_area",str(self.scan_area))
145 config.set('cfg',"scan_driver",str(self.scan_driver))
146 config.set('cfg',"language",str(self.language))
147 config.set('cfg',"language_2",str(self.language_2))
148 config.set('cfg',"language_3",str(self.language_3))
149 config.set('cfg',"speech_module",str(self.speech_module))
150 config.set('cfg',"speech_language",str(self.speech_language))
151 config.set('cfg',"speech_person",str(self.speech_person))
152 config.set('cfg',"speech_pitch",str(self.speech_pitch))
153 config.set('cfg',"speech_volume",str(self.speech_volume))
154 config.set('cfg',"speech_rate",str(self.speech_rate))
155 config.set('cfg',"number_of_pages_to_scan",str(self.number_of_pages_to_scan))
156 config.set('cfg',"mode_of_rotation",str(self.mode_of_rotation))
157 config.set('cfg',"rotation_angle",str(self.rotation_angle))
158 config.set('cfg',"give_page_number",str(self.give_page_number))
159 config.set('cfg',"numbering_type",str(self.page_numbering_type))
160 config.set('cfg',"scanner_mode_switching",str(self.scanner_mode_switching))
161 config.set('cfg',"run_text_cleaner",str(self.run_text_cleaner))
162 config.set('cfg',"scanner_cache_calibration",str(self.scanner_cache_calibration))
163 config.set('cfg',"starting_page_number",str(self.starting_page_number))
164 config.set('cfg',"highlight_color",str(self.highlight_color))
165 config.set('cfg',"highlight_background_color",str(self.background_highlight_color))
166 config.set('cfg',"font",str(self.font))
167 config.set('cfg',"highlight_font",str(self.highlight_font))
168 with open(filename, 'w') as configfile:
169 config.write(configfile)
170
171
172 def update_page_number(self):
173 loop.acquire_lock()
174 if (self.page_numbering_type == 0):
175 self.starting_page_number = self.starting_page_number + 1
176 else:
177 self.starting_page_number = self.starting_page_number + 2
178 loop.release_lock()
179
180 def get_page_number_as_string(self):
181 if (self.page_numbering_type == 0):
182 return ("{0}".format(self.starting_page_number))
183 else:
184 return ("{0}-{1}".format(self.starting_page_number,self.starting_page_number + 1))
185
186
187 #Function for manipulating preferences
188 def open_configure_dialog(self,page=0):
189 def change_engine(*data):
190 index_engine = combobox_engine.get_active()
191 combobox_language.clear()
192 combobox_language_2.clear()
193 combobox_language_3.clear()
194 combobox_language_2.add_item("---")
195 combobox_language_3.add_item("---")
196
197 for item in self.available_ocr_engine_list[index_engine][1]:
198 combobox_language.add_item(item)
199 combobox_language_2.add_item(item)
200 combobox_language_3.add_item(item)
201 combobox_language.set_active(self.language)
202 combobox_language_2.set_active(self.language_2)
203 combobox_language_3.set_active(self.language_3)
204
205 if (self.available_ocr_engine_list[index_engine][2] == True):
206 label_language_2.set_sensitive(True)
207 label_language_3.set_sensitive(True)
208 combobox_language_2.set_sensitive(True)
209 combobox_language_3.set_sensitive(True)
210 else:
211 label_language_2.set_sensitive(False)
212 label_language_3.set_sensitive(False)
213 combobox_language_2.set_sensitive(False)
214 combobox_language_3.set_sensitive(False)
215
216
217
218 def change_speech_module(*data):
219 module_index = combobox_speech_module.get_active()
220
221 test = speech.Speech()
222 output_modules_list = test.list_output_modules()
223 test.set_output_module(output_modules_list[module_index])
224
225 self.speech_language_person_dict = test.get_language_person_dict()
226 test.close()
227
228 # Disconnecting for preventng function calls while clearing
229 # combobox_speech_language or adding each language to the same
230 try:
231 combobox_speech_language.disconnect_by_func(change_speech_language)
232 except(TypeError):
233 pass
234
235 combobox_speech_language.clear()
236
237 if(len(self.speech_language_person_dict.keys()) == 0):
238 combobox_speech_language.add_item(_("Default"))
239 self.speech_language = 0
240 else:
241 for item in self.speech_language_person_dict.keys():
242 combobox_speech_language.add_item(item)
243
244 combobox_speech_language.connect_change_callback_function(change_speech_language)
245
246
247 if(self.speech_language < len(self.speech_language_person_dict.keys())):
248 combobox_speech_language.set_active(self.speech_language)
249 else:
250 combobox_speech_language.set_active(0)
251 self.speech_language = 0
252
253 def change_speech_language(*data):
254 combobox_speech_person.clear()
255
256 # For users having preferences from old version
257 if(self.speech_person == -1):
258 self.speech_person = 0
259
260 if(len(list(self.speech_language_person_dict.keys())) == 0):
261 combobox_speech_person.add_item(_("Default"))
262 combobox_speech_person.set_active(0)
263 self.speech_person = 0
264 return
265
266 index_language = combobox_speech_language.get_active()
267 language = list(self.speech_language_person_dict.keys())[index_language]
268
269 for item in self.speech_language_person_dict[language]:
270 combobox_speech_person.add_item(item)
271
272 if(self.speech_person >= len(self.speech_language_person_dict[language])):
273 self.speech_person = 0
274 combobox_speech_person.set_active(self.speech_person)
275
276 def change_mode_of_rotation(*data):
277 if(combobox_mode_of_rotation.get_active() == 2):
278 combobox_angle.show()
279 self.label_angle.show()
280 else:
281 combobox_angle.hide()
282 self.label_angle.hide()
283
284
285 self.require_scanner_refresh = False
286
287 #Notebook
288 notebook = containers.NoteBook()
289 notebook.show_all()
290
291 #GENERAL - PAGE #########
292 label_font = widget.Label(_("Font"))
293 fontbutton_font = widget.FontButton()
294 fontbutton_font.set_font_name(self.font)
295 label_font.set_mnemonic_widget(fontbutton_font)
296
297 label_highlight_font = widget.Label(_("Highlight Font"))
298 fontbutton_highlight_font = widget.FontButton()
299 fontbutton_highlight_font.set_font_name(self.highlight_font)
300 label_highlight_font.set_mnemonic_widget(fontbutton_highlight_font)
301
302 label_highlight_color = widget.Label(_("Highlight Color"))
303 colorbutton_highlight = widget.ColorButton()
304 colorbutton_highlight.set_color_from_string(self.highlight_color)
305 label_highlight_color.set_mnemonic_widget(colorbutton_highlight)
306
307 label_highlight_background = widget.Label(_("Highlight Background"))
308 colorbutton_highlight_background = widget.ColorButton()
309 colorbutton_highlight_background.set_color_from_string(self.background_highlight_color)
310 label_highlight_background.set_mnemonic_widget(colorbutton_highlight_background)
311
312 label_speech_module = widget.Label(_("Speech Module"))
313 combobox_speech_module = widget.ComboBox()
314 for item in speech.Speech().list_output_modules():
315 combobox_speech_module.add_item(item)
316 combobox_speech_module.connect_change_callback_function(change_speech_module)
317 label_speech_module.set_mnemonic_widget(combobox_speech_module)
318
319 label_speech_language = widget.Label(_("Speech Language"))
320 combobox_speech_language = widget.ComboBox()
321 label_speech_language.set_mnemonic_widget(combobox_speech_language)
322
323 label_speech_person = widget.Label(_("Speech Person"))
324 combobox_speech_person = widget.ComboBox()
325 label_speech_person.set_mnemonic_widget(combobox_speech_person)
326
327 combobox_speech_module.set_active(self.speech_module)
328
329 label_speech_rate = widget.Label(_("Speech Rate"))
330 spin_speech_rate = widget.SpinButton(self.speech_rate,-100,100,1,10,0)
331 label_speech_rate.set_mnemonic_widget(spin_speech_rate)
332 label_speech_volume = widget.Label(_("Speech Volume"))
333 spin_speech_volume = widget.SpinButton(self.speech_volume,-100,100,1,10,0)
334 label_speech_volume.set_mnemonic_widget(spin_speech_volume)
335 label_speech_pitch = widget.Label(_("Speech Pitch"))
336 spin_speech_pitch = widget.SpinButton(self.speech_pitch,-100,100,1,10,0)
337 label_speech_pitch.set_mnemonic_widget(spin_speech_pitch)
338
339
340 grid_general = containers.Grid()
341 grid_general.add_widgets(
342 [(label_font,1,1),(fontbutton_font,1,1),containers.Grid.NEW_ROW,
343 (label_highlight_font,1,1),(fontbutton_highlight_font,1,1),containers.Grid.NEW_ROW,
344 (label_highlight_color,1,1),(colorbutton_highlight,1,1),containers.Grid.NEW_ROW,
345 (label_highlight_background,1,1),(colorbutton_highlight_background,1,1),containers.Grid.NEW_ROW,
346 (label_speech_module,1,1),(combobox_speech_module,1,1),containers.Grid.NEW_ROW,
347 (label_speech_language,1,1),(combobox_speech_language,1,1),containers.Grid.NEW_ROW,
348 (label_speech_person,1,1),(combobox_speech_person,1,1),containers.Grid.NEW_ROW,
349 (label_speech_rate,1,1),(spin_speech_rate,1,1),containers.Grid.NEW_ROW,
350 (label_speech_pitch,1,1),(spin_speech_pitch,1,1),containers.Grid.NEW_ROW,
351 (label_speech_volume,1,1),(spin_speech_volume,1,1)])
352 notebook.add_page(_("General"),grid_general)
353 grid_general.show_all()
354
355 #RECOGNITION - PAGE ########
356 #Engine
357 label_engine = widget.Label(_("Engine"))
358 combobox_engine = widget.ComboBox()
359 combobox_engine.connect_change_callback_function(change_engine)
360 label_engine.set_mnemonic_widget(combobox_engine)
361
362 for item in self.available_ocr_engine_list:
363 combobox_engine.add_item(item[0])
364
365 #Language
366 label_language = widget.Label(_("Language"))
367 combobox_language = widget.ComboBox()
368 label_language.set_mnemonic_widget(combobox_language)
369
370 #Language 2
371 label_language_2 = widget.Label(_("Language - 2"))
372 combobox_language_2 = widget.ComboBox()
373 label_language_2.set_mnemonic_widget(combobox_language_2)
374
375 #Language 3
376 label_language_3 = widget.Label(_("Language - 3"))
377 combobox_language_3 = widget.ComboBox()
378 label_language_3.set_mnemonic_widget(combobox_language_3)
379
380 #setting current engine - This can't be done before creating language combobox
381 combobox_engine.set_active(self.ocr_engine)
382 combobox_language.set_active(self.language)
383 combobox_language_2.set_active(self.language_2)
384 combobox_language_3.set_active(self.language_3)
385
386 #Run text cleaner
387 checkbutton_run_text_cleaner = widget.CheckButton(_("Run Text Cleaner"))
388 checkbutton_run_text_cleaner.set_active(self.run_text_cleaner)
389
390 #insert_position
391 label_insert_position = widget.Label(_("Insert Position"))
392 combobox_insert_position = widget.ComboBox()
393 combobox_insert_position.add_item(_("Start"))
394 combobox_insert_position.add_item(_("Cursor"))
395 combobox_insert_position.add_item(_("End"))
396 combobox_insert_position.set_active(self.insert_position)
397 label_insert_position.set_mnemonic_widget(combobox_insert_position)
398
399 #Seperator
400 seperator_1 = widget.Separator()
401
402 #Mode of Rotation
403 label_mode_of_rotation = widget.Label(_("Mode Of Rotation"))
404 combobox_mode_of_rotation = widget.ComboBox()
405 combobox_mode_of_rotation.add_item(_("Full Automatic"))
406 combobox_mode_of_rotation.add_item(_("Partial Automatic"))
407 combobox_mode_of_rotation.add_item(_("Manual"))
408 combobox_mode_of_rotation.connect_change_callback_function(change_mode_of_rotation)
409 label_mode_of_rotation.set_mnemonic_widget(combobox_mode_of_rotation)
410
411 #Angle
412 self.label_angle = widget.Label(_("Angle"))
413 combobox_angle = widget.ComboBox()
414 combobox_angle.add_item(_("00"))
415 combobox_angle.add_item(_("90"))
416 combobox_angle.add_item(_("180"))
417 combobox_angle.add_item(_("270"))
418 self.label_angle.set_mnemonic_widget(combobox_angle)
419
420 #Seperator 2
421 seperator_2 = widget.Separator()
422
423 #Give page number
424 checkbutton_give_page_number = widget.CheckButton(_("Give Page Number"))
425 checkbutton_give_page_number.set_active(self.give_page_number)
426
427 #Page-Numbering
428 label_numbering_type = widget.Label(_("Page Numbering Type"))
429 combobox_numbering_type = widget.ComboBox()
430 combobox_numbering_type.add_item(_("Single Page"))
431 combobox_numbering_type.add_item(_("Double Page"))
432 combobox_numbering_type.set_active(self.page_numbering_type)
433 label_numbering_type.set_mnemonic_widget(combobox_numbering_type)
434
435 #Starting Page Number
436 label_starting_page_number = widget.Label(_("Starting Page Number"))
437 spin_starting_page_number = widget.SpinButton(0,0,100000,1,5,0)
438 spin_starting_page_number.set_value(self.starting_page_number)
439 label_starting_page_number.set_mnemonic_widget(spin_starting_page_number)
440
441 grid_recognition = containers.Grid()
442 grid_recognition.add_widgets([
443 (label_engine,1,1),(combobox_engine,1,1),containers.Grid.NEW_ROW,
444 (label_language,1,1),(combobox_language,1,1),containers.Grid.NEW_ROW,
445 (label_language_2,1,1),(combobox_language_2,1,1),containers.Grid.NEW_ROW,
446 (label_language_3,1,1),(combobox_language_3,1,1),containers.Grid.NEW_ROW,
447 (checkbutton_run_text_cleaner,1,1),containers.Grid.NEW_ROW,
448 (label_insert_position,1,1),(combobox_insert_position,1,1),containers.Grid.NEW_ROW,
449 (seperator_1,2,1),containers.Grid.NEW_ROW,
450 (label_mode_of_rotation,1,1),(combobox_mode_of_rotation,1,1),containers.Grid.NEW_ROW,
451 (self.label_angle,1,1),(combobox_angle,1,1),containers.Grid.NEW_ROW,
452 (seperator_2,2,1),containers.Grid.NEW_ROW,
453 (checkbutton_give_page_number,1,1),containers.Grid.NEW_ROW,
454 (label_numbering_type,1,1), (combobox_numbering_type,1,1),containers.Grid.NEW_ROW,
455 (label_starting_page_number,1,1),
456 (spin_starting_page_number,1,1)])
457 notebook.add_page(_("Recognition"),grid_recognition)
458 grid_recognition.show_all()
459
460 #setting current mode of rotation - This can't be done before creating angle combobox
461 #also it should be here because the show_all function of grid will make angle combobox show again
462 combobox_mode_of_rotation.set_active(self.mode_of_rotation)
463 combobox_angle.set_active(self.rotation_angle)
464
465
466 #SCANNING - PAGE ##############
467 label_resolution = widget.Label(_("Resolution"))
468 spin_resolution = widget.SpinButton(300,100,1200,1,5,0)
469 spin_resolution.set_value(self.scan_resolution)
470 label_resolution.set_mnemonic_widget(spin_resolution)
471
472 label_brightness = widget.Label(_("Brightness"))
473 spin_brightness = widget.SpinButton(50,0,100,1,5,0)
474 spin_brightness.set_value(self.scan_brightness)
475 label_brightness.set_mnemonic_widget(spin_brightness)
476
477 label_scan_area = widget.Label(_("Scan Area"))
478 combobox_scan_area = widget.ComboBox()
479 label_scan_area.set_mnemonic_widget(combobox_scan_area)
480 combobox_scan_area.add_item(_("Full Scan Area"))
481 combobox_scan_area.add_item(_("Three Quarters"))
482 combobox_scan_area.add_item(_("Two Quarters"))
483 combobox_scan_area.add_item(_("One Quarter"))
484 combobox_scan_area.set_active(self.scan_area)
485
486 label_scan_driver = widget.Label(_("Driver"))
487 combobox_scan_driver = widget.ComboBox()
488 label_scan_driver.set_mnemonic_widget(combobox_scan_driver)
489 for item in self.available_scanner_drivers:
490 combobox_scan_driver.add_item(item)
491 combobox_scan_driver.set_active(self.scan_driver)
492
493 sparator_3 = widget.Separator()
494
495 label_number_of_pages_to_scan = widget.Label(_("Number of Pages to Scan"))
496 spin_number_of_pages_to_scan = widget.SpinButton(10,2,100,1,5,0)
497 spin_number_of_pages_to_scan.set_value(self.number_of_pages_to_scan)
498 label_number_of_pages_to_scan.set_mnemonic_widget(spin_number_of_pages_to_scan)
499
500 label_time_bitween_repeted_scanning = widget.Label(_("Time Bitween Repeted Scanning"))
501 spin_time_bitween_repeted_scanning = widget.SpinButton(0,0,30,1,5,0)
502 spin_time_bitween_repeted_scanning.set_value(self.time_between_repeated_scanning)
503 label_time_bitween_repeted_scanning.set_mnemonic_widget(spin_time_bitween_repeted_scanning)
504
505 sparator_4 = widget.Separator()
506
507 checkbutton_scan_mode_switching = widget.CheckButton(_("Change to binary or linear if possible"))
508 checkbutton_scan_mode_switching.set_active(self.scanner_mode_switching)
509
510 checkbutton_scanner_cache_calibration = widget.CheckButton(_("Cache Calibration"))
511 checkbutton_scanner_cache_calibration.set_active(self.scanner_cache_calibration)
512
513 grid_scanning = containers.Grid()
514 grid_scanning.add_widgets([
515 (label_resolution,1,1),(spin_resolution,1,1),containers.Grid.NEW_ROW,
516 (label_brightness,1,1),(spin_brightness,1,1),containers.Grid.NEW_ROW,
517 (label_scan_area,1,1),(combobox_scan_area,1,1),containers.Grid.NEW_ROW,
518 (label_scan_driver,1,1),(combobox_scan_driver,1,1),containers.Grid.NEW_ROW,
519 (sparator_3,2,1),containers.Grid.NEW_ROW,
520 (label_number_of_pages_to_scan,1,1),(spin_number_of_pages_to_scan,1,1),containers.Grid.NEW_ROW,
521 (label_time_bitween_repeted_scanning,1,1),(spin_time_bitween_repeted_scanning,1,1),containers.Grid.NEW_ROW,
522 (sparator_4,2,1),containers.Grid.NEW_ROW,
523 (checkbutton_scan_mode_switching,2,1),containers.Grid.NEW_ROW,
524 (checkbutton_scanner_cache_calibration,2,1)])
525
526 notebook.add_page(_("Scanning"),grid_scanning)
527 grid_scanning.show_all()
528
529 #Setting page
530 notebook.set_current_page(page)
531
532 dlg = dialog.Dialog(_("Lios Preferences"),(_("Apply"),dialog.Dialog.BUTTON_ID_1,_("Close"),dialog.Dialog.BUTTON_ID_2))
533 dlg.add_widget(notebook)
534 if (dlg.run()==True):
535 self.font=fontbutton_font.get_font_name();
536
537 self.highlight_font=fontbutton_highlight_font.get_font_name();
538 self.highlight_color=colorbutton_highlight.get_color_as_string()
539 self.background_highlight_color=colorbutton_highlight_background.get_color_as_string()
540
541 self.ocr_engine=combobox_engine.get_active()
542 self.language=combobox_language.get_active()
543 self.language_2=combobox_language_2.get_active()
544 self.language_3=combobox_language_3.get_active()
545 self.speech_module=combobox_speech_module.get_active()
546 self.speech_language=combobox_speech_language.get_active()
547 self.speech_person=combobox_speech_person.get_active()
548 self.speech_rate=spin_speech_rate.get_value()
549 self.speech_pitch=spin_speech_pitch.get_value()
550 self.speech_volume=spin_speech_volume.get_value()
551 self.insert_position=combobox_insert_position.get_active();
552 self.mode_of_rotation=combobox_mode_of_rotation.get_active()
553 self.rotation_angle = combobox_angle.get_active()
554 self.give_page_number=int(checkbutton_give_page_number.get_active())
555 self.page_numbering_type=combobox_numbering_type.get_active();
556 self.starting_page_number=spin_starting_page_number.get_value_as_int();
557
558 self.scan_resolution = spin_resolution.get_value_as_int();
559 self.scan_brightness=spin_brightness.get_value_as_int();
560 self.scan_area=combobox_scan_area.get_active();
561 self.scan_driver=combobox_scan_driver.get_active();
562 self.number_of_pages_to_scan=spin_number_of_pages_to_scan.get_value_as_int();
563 self.time_between_repeated_scanning=spin_time_bitween_repeted_scanning.get_value_as_int();
564 self.scanner_mode_switching=int(checkbutton_scan_mode_switching.get_active())
565 self.run_text_cleaner=int(checkbutton_run_text_cleaner.get_active())
566 self.scanner_cache_calibration=int(checkbutton_scanner_cache_calibration.get_active())
567
568 dlg.destroy()
569 return True
570 dlg.destroy()
571 return False
572
573
574 if "__main__" == __name__:
575 a = lios_preferences()
576 a.set_avalable_ocr_engines([])
577 a.set_avalable_scanner_drivers([])
578 a.open_configure_dialog()
579 a.open_configure_dialog()
580
581 loop.start_main_loop()
582
583
584
585