88class MoreOptionsDialog (Adw .AlertDialog ):
99 def __init__ (self , parent ):
1010 super ().__init__ ()
11- self .parent = parent
11+ self .parent = parent # Connect this dialog with MainWindow class
12+
1213 self .set_heading (_ ("More options" ))
1314
1415 # Box for this dialog
@@ -18,6 +19,21 @@ def __init__(self, parent):
1819 self .set_extra_child (self .msBox )
1920
2021 # Periodic saving section
22+ self .load_periodic_saving_section ()
23+
24+ # Manual saving section
25+ self .load_manual_saving_section ()
26+
27+ # Call _expand_periodic_row() method to expand "Periodic saving" section
28+ self ._expand_periodic_row ()
29+
30+ # add response of this dialog
31+ self .add_response ('cancel' , _ ("Cancel" ))
32+ self .add_response ('ok' , _ ("Apply" ))
33+ self .set_response_appearance ('ok' , Adw .ResponseAppearance .SUGGESTED )
34+ self .connect ('response' , self .msDialog_closed )
35+
36+ def load_periodic_saving_section (self ):
2137 # Expander row for showing options of the periodic saving
2238 self .periodic_row = Adw .ExpanderRow .new ()
2339 self .periodic_row .set_title (_ ("Periodic saving" ))
@@ -50,7 +66,7 @@ def __init__(self, parent):
5066 self .filefrmtButton .add_css_class ('destructive-action' )
5167 self .filefrmtButton .set_valign (Gtk .Align .CENTER )
5268 self .filefrmtButton .set_tooltip_text (_ ("Reset to default" ))
53- self .filefrmtButton .connect ("clicked" , self .reset_fileformat )
69+ self .filefrmtButton .connect ("clicked" , self ._reset_fileformat )
5470
5571 # Entry for selecting file name format
5672 self .filefrmtEntry = Adw .EntryRow .new ()
@@ -63,7 +79,7 @@ def __init__(self, parent):
6379 self .folderButton = Gtk .Button .new_from_icon_name ("document-open-symbolic" )
6480 self .folderButton .set_valign (Gtk .Align .CENTER )
6581 self .folderButton .set_tooltip_text (_ ("Choose another folder" ))
66- self .folderButton .connect ("clicked" , self .open_file_dialog )
82+ self .folderButton .connect ("clicked" , self ._open_file_dialog )
6783
6884 # Adw.ActionRow for showing folder for periodic saving
6985 self .dirRow = Adw .ActionRow .new ()
@@ -87,7 +103,7 @@ def __init__(self, parent):
87103 self .pswdgenButton .connect ("clicked" , self ._get_generated_password )
88104 self .cpwdRow .add_suffix (self .pswdgenButton )
89105
90- # Manual saving section
106+ def load_manual_saving_section ( self ):
91107 self .manRow = Adw .ExpanderRow .new ()
92108 self .manRow .set_title (_ ("Manual saving" ))
93109 self .manRow .set_expanded (True )
@@ -97,7 +113,7 @@ def __init__(self, parent):
97113 self .encryptSwitch = Gtk .Switch .new ()
98114 self .archSwitch = Gtk .Switch .new ()
99115 self .encryptSwitch .set_valign (Gtk .Align .CENTER )
100- self .encryptSwitch .connect ('notify::active' , self .set_encryptswitch_sensitivity )
116+ self .encryptSwitch .connect ('notify::active' , self ._set_encryptswitch_sensitivity )
101117 if settings ["enable-encryption" ] == True :
102118 self .encryptSwitch .set_active (True )
103119 self .archSwitch .set_sensitive (False )
@@ -112,7 +128,7 @@ def __init__(self, parent):
112128
113129 # action row and switch for showing the "Save a configuration without creating the archive" option
114130 self .archSwitch .set_valign (Gtk .Align .CENTER )
115- self .archSwitch .connect ('notify::active' , self .set_archswitch_sensitivity )
131+ self .archSwitch .connect ('notify::active' , self ._set_archswitch_sensitivity )
116132 if settings ["save-without-archive" ] == True :
117133 self .archSwitch .set_active (True )
118134 self .encryptSwitch .set_sensitive (False )
@@ -123,46 +139,43 @@ def __init__(self, parent):
123139 self .archRow .set_activatable_widget (self .archSwitch )
124140 self .manRow .add_row (self .archRow )
125141
126- self ._expand_periodic_row ()
127-
128- # add response of this dialog
129- self .add_response ('cancel' , _ ("Cancel" ))
130- self .add_response ('ok' , _ ("Apply" ))
131- self .set_response_appearance ('ok' , Adw .ResponseAppearance .SUGGESTED )
132- self .connect ('response' , self .msDialog_closed )
133-
142+ # Get an encrypted password from the {DATA}/password file
134143 def _get_password_from_file (self ):
135144 if os .path .exists (f"{ DATA } /password" ):
136145 p = PasswordStore ()
137146 self .cpwdRow .set_text (p .password )
138147 else :
139148 self .cpwdRow .set_text ("" )
140149
150+ # Call MainWindow's method (self.parent) to get auto-generated password
141151 def _get_generated_password (self , w ):
142152 self .password = self .parent ._password_generator ()
143153 self .cpwdRow .set_text (self .password )
144154
145- def open_file_dialog (self , w ):
155+ # Open the file chooser dialog for selecting the periodic saving folder
156+ # by calling the MainWindow's method (self.parent)
157+ def _open_file_dialog (self , w ):
146158 self .parent .select_pb_folder (w = "" )
147159
148- # reset the file name format entry to the default value
149- def reset_fileformat (self , w ):
160+ # Reset the file name format entry to the default value
161+ def _reset_fileformat (self , w ):
150162 self .filefrmtEntry .set_text ("Latest_configuration" )
151163
152- # set sensitivity of the encryptSwitch
153- def set_encryptswitch_sensitivity (self , GParamBoolean , encryptSwitch ):
164+ # Set sensitivity of the encryptSwitch
165+ def _set_encryptswitch_sensitivity (self , GParamBoolean , encryptSwitch ):
154166 if self .encryptSwitch .get_active ():
155167 self .archSwitch .set_sensitive (False )
156168 else :
157169 self .archSwitch .set_sensitive (True )
158170
159- # set sensitivity of the archSwitch
160- def set_archswitch_sensitivity (self , GParamBoolean , archSwitch ):
171+ # Set sensitivity of the archSwitch
172+ def _set_archswitch_sensitivity (self , GParamBoolean , archSwitch ):
161173 if self .archSwitch .get_active ():
162174 self .encryptSwitch .set_sensitive (False )
163175 else :
164176 self .encryptSwitch .set_sensitive (True )
165177
178+ # Expand "Periodic saving" row if the below file exists
166179 def _expand_periodic_row (self ):
167180 if os .path .exists (f"{ CACHE } /expand_pb_row" ):
168181 self .periodic_row .set_expanded (True )
@@ -206,6 +219,8 @@ def _save_password(self):
206219 except :
207220 pass
208221
222+ # Open the "Set up the sync file" dialog after clicking on the Apply button
223+ # in this dialog, if the below file exists
209224 def _call_set_dialog (self ):
210225 if os .path .exists (f"{ CACHE } /expand_pb_row" ):
211226 self .parent ._open_SetDialog ()
0 commit comments