51
51
self.window = self.toplevel.get_widget('window_main')
52
52
self.window.show_all()
54
self.comm = OliveCommunicator(self.toplevel)
54
self.pref = OlivePreferences()
55
self.comm = OliveCommunicator(self.toplevel, self.pref)
55
56
handler = OliveHandler(self.gladefile, self.comm)
57
58
# Dictionary for signal_autoconnect
58
59
dic = { "on_window_main_destroy": gtk.main_quit,
59
"on_quit_activate": gtk.main_quit,
60
"on_window_main_delete_event": handler.on_window_main_delete_event,
61
"on_quit_activate": handler.on_window_main_delete_event,
60
62
"on_about_activate": handler.on_about_activate,
61
63
"on_menuitem_add_files_activate": handler.on_menuitem_add_files_activate,
62
64
"on_menuitem_remove_file_activate": handler.on_menuitem_remove_file_activate,
228
240
widget.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.WATCH))
230
242
widget.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.LEFT_PTR))
232
244
gtk.main_iteration(0)
246
class OlivePreferences:
247
""" A class which handles Olive's preferences. """
249
""" Initialize the Preferences class. """
252
# Some default options
253
self.defaults = { 'strict_commit': False,
254
'dotted_files' : False }
256
# Create a config parser object
257
self.config = ConfigParser.RawConfigParser()
259
# Load the configuration
260
if sys.platform == 'win32':
261
# Windows - no dotted files
262
self.config.read([os.path.expanduser('~/olive.conf')])
264
self.config.read([os.path.expanduser('~/.olive.conf')])
266
def _get_default(self, option):
267
""" Get the default option for a preference. """
269
ret = self.defaults[option]
276
""" Refresh the configuration. """
277
# First write out the changes
279
# Then load the configuration again
280
if sys.platform == 'win32':
281
# Windows - no dotted files
282
self.config.read([os.path.expanduser('~/olive.conf')])
284
self.config.read([os.path.expanduser('~/.olive.conf')])
287
""" Write the configuration to the appropriate files. """
288
if sys.platform == 'win32':
289
# Windows - no dotted files
290
fp = open(os.path.expanduser('~/olive.conf'), 'w')
291
self.config.write(fp)
294
fp = open(os.path.expanduser('~/.olive.conf'), 'w')
295
self.config.write(fp)
298
def get_strict_commit(self):
299
""" Get strict commit preference. """
300
if self.config.has_option('preferences', 'strict_commit'):
301
return self.config.getboolean('preferences', 'strict_commit')
303
return self._get_default('strict_commit')
305
def set_strict_commit(self, value):
306
""" Set strict commit preference. """
307
if self.config.has_section('preferences'):
308
self.config.set('preferences', 'strict_commit', value)
310
self.config.add_section('preferences')
311
self.config.set('preferences', 'strict_commit', value)
313
def get_dotted_files(self):
314
""" Get dotted files preference. """
315
if self.config.has_option('preferences', 'dotted_files'):
316
return self.config.getboolean('preferences', 'dotted_files')
318
return self._get_default('dotted_files')
320
def set_dotted_files(self, value):
321
""" Set dotted files preference. """
322
if self.config.has_section('preferences'):
323
self.config.set('preferences', 'dotted_files', value)
325
self.config.add_section('preferences')
326
self.config.set('preferences', 'dotted_files', value)
328
def get_bookmarks(self):
329
""" Return the list of bookmarks. """
330
bookmarks = self.config.sections()
331
if self.config.has_section('preferences'):
332
bookmarks.remove('preferences')
335
def add_bookmark(self, path):
336
""" Add bookmark. """
338
self.config.add_section(path)
339
except DuplicateSectionError:
344
def del_bookmark(self, path):
345
""" Remove bookmark. """
346
return self.config.remove_section(path)