2020DATA_DIR = appdirs .user_data_dir (APPNAME )
2121
2222
23+ class SettingsData :
24+ '''Class for managing current user's application settings'''
25+
26+ def __init__ (self ):
27+ pass
28+
2329class UserData :
2430 '''Class for storing current user's application data'''
2531
@@ -460,24 +466,23 @@ def __init__(self):
460466 self .builder = pgBuilder ()
461467 self .builder .add_from_file (os .path .join (CURRENT_DIR , 'mainwindow.ui' ))
462468
463- self .mainwindow = self .builder .get_object ('mainwindow' )
469+ self .mainwindow = self .builder .get_object ('MainWindow' )
470+ self .settings_dialog = self .builder .get_object ('SettingsDialog' , self .mainwindow )
464471 self .notebook = self .builder .get_object ('AppNotebook' )
465472 self .tabs = {
466473 'join' : self .builder .get_object ('JoinFrame' ),
467474 'split' : self .builder .get_object ('SplitFrame' ),
468475 'bg' : self .builder .get_object ('BgFrame' ),
469476 'rotate' : self .builder .get_object ('RotateFrame' ),
470477 }
471- self .mainwindow .bind_all ('<Control-j>' , self .select_tab_join )
472- self .mainwindow .bind_all ('<Control-s>' , self .select_tab_split )
473- self .mainwindow .bind_all ('<Control-b>' , self .select_tab_bg )
474- self .mainwindow .bind_all ('<Control-r>' , self .select_tab_rotate )
478+
475479 self .mainmenu = self .builder .get_object ('MainMenu' )
476480 self .mainwindow .config (menu = self .mainmenu )
477481
478482 self .builder .connect_callbacks (self )
479483
480484 self .user_data = UserData ()
485+ self .settings_data = SettingsData ()
481486
482487 self .jointab = JoinTabManager (self )
483488 self .splittab = SplitTabManager (self )
@@ -486,15 +491,23 @@ def __init__(self):
486491
487492 # boy oh boy if there's anyway to do these callsbacks more elegantly, please let me gain that knowledge!
488493 def select_tab_join (self , * args , ** kwargs ):
494+ '''Gets called when menu item "View > Join Files" is selected.
495+ Pops appropriate tab into view.'''
489496 self .notebook .select (self .tabs ['join' ])
490497
491498 def select_tab_split (self , * args , ** kwargs ):
499+ '''Gets called when menu item "View > Split File" is selected.
500+ Pops appropriate tab into view.'''
492501 self .notebook .select (self .tabs ['split' ])
493502
494503 def select_tab_bg (self , * args , ** kwargs ):
504+ '''Gets called when menu item "View > Background/Stamp/Number" is selected.
505+ Pops appropriate tab into view.'''
495506 self .notebook .select (self .tabs ['bg' ])
496507
497508 def select_tab_rotate (self , * args , ** kwargs ):
509+ '''Gets called when menu item "View > Rotate Pages" is selected.
510+ Pops appropriate tab into view.'''
498511 self .notebook .select (self .tabs ['rotate' ])
499512
500513 def jointab_add_file (self ):
@@ -552,6 +565,21 @@ def rotatetab_open_file(self):
552565 def rotatetab_save_as (self ):
553566 self .rotatetab .save_as ()
554567
568+ def show_settings (self , * args , ** kwargs ):
569+ '''Shows the settings dialog. The close event is handled by `self.close_settings()`
570+ and all the settings management is handled there. Args and kwargs are included in
571+ method definition in case it is triggered by the keyboard shortcut, in which
572+ case `event` gets passed into the call.'''
573+ self .settings_dialog .run ()
574+ # load data from settings and update widgets in dialog accordingly
575+
576+ def close_settings (self , * args , ** kwargs ):
577+ # save settings and close it up
578+ self .settings_dialog .close ()
579+
580+ def cancel_settings (self , * args , ** kwargs ):
581+ pass
582+
555583 def get_file_dialog (self , func , widget_title = 'Choose File(s) …' ):
556584 f = func (
557585 initialdir = self .user_data .filedialog_path ,
0 commit comments