# HG changeset patch # User Erik Grinaker # Date 1090950870 0 # Node ID 9b3c9903350d6654128a459470db753e4a05b5d7 # Parent db7970bbbb932ee8a83b5d3c66707078c9472e50 rewrote config handling diff -r db7970bbbb932ee8a83b5d3c66707078c9472e50 -r 9b3c9903350d6654128a459470db753e4a05b5d7 ChangeLog --- a/ChangeLog Thu Jul 15 23:50:31 2004 +0000 +++ b/ChangeLog Tue Jul 27 17:54:30 2004 +0000 @@ -2,6 +2,10 @@ ---------------[ xxxx-xx-xx : 0.3.1 ]--------------- +2004-07-27 Erik Grinaker + + * rewrote the app configuration handling + 2004-07-15 Erik Grinaker * when adding an entry the default type is Generic (not Folder) diff -r db7970bbbb932ee8a83b5d3c66707078c9472e50 -r 9b3c9903350d6654128a459470db753e4a05b5d7 TODO --- a/TODO Thu Jul 15 23:50:31 2004 +0000 +++ b/TODO Tue Jul 27 17:54:30 2004 +0000 @@ -23,6 +23,7 @@ - use themed icons when possible - make the EntryDropdown display the icon on the button as well as in the menu +- restructure the configuration layout - use a combo box for the username field - use a fileentry widget for file fields (key file, certificate) - use a spin button for integer fields (port) diff -r db7970bbbb932ee8a83b5d3c66707078c9472e50 -r 9b3c9903350d6654128a459470db753e4a05b5d7 src/lib/data.py --- a/src/lib/data.py Thu Jul 15 23:50:31 2004 +0000 +++ b/src/lib/data.py Tue Jul 27 17:54:30 2004 +0000 @@ -23,7 +23,7 @@ # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # -import revelation, gobject, gtk +import revelation, gobject, gtk, gconf ENTRYSTORE_COL_NAME = 0 @@ -52,6 +52,177 @@ +class ConfigError(Exception): + "Config error exception" + pass + + + +class Config(gobject.GObject): + "Configuration interface" + + def __init__(self, basedir = "/apps/revelation"): + gobject.GObject.__init__(self) + + self.basedir = basedir + self.callbacks = {} + + self.client = gconf.client_get_default() + self.client.add_dir(self.basedir, gconf.CLIENT_PRELOAD_NONE) + + + def __cb_bind_entry_get(self, config, value, widget): + "Callback which handles update notifications for entry widgets" + + widget.set_text(str(value)) + + + def __cb_bind_entry_set(self, widget, key): + "Callback which updates config entries fro bound entry widgets" + + self.set(key, widget.get_text()) + + + def __cb_bind_spin_get(self, config, value, widget): + "Callback which handles update notifications for spin buttons" + + widget.set_value(value) + + + def __cb_bind_spin_set(self, widget, key): + "Callback which updates config entries from bound spin buttons" + + self.set(key, widget.get_value_as_int()) + + + def __cb_bind_toggle_get(self, config, value, widget): + "Callback which handles update notifications for toggle widgets" + + widget.set_active(value) + + + def __cb_bind_toggle_set(self, widget, key): + "Callback which updates config entries for bound toggle widgets" + + self.set(key, widget.get_active()) + + + def __cb_bind_unrealize(self, widget, id): + "Disconnects a bound widget callback when the widget is unrealized" + + self.client.notify_remove(id) + del self.callbacks[id] + + + def __cb_notify(self, client, id, entry, data): + "Callback for handling notifications" + + print "Config callbacks: ", len(self.callbacks), id + + # get the value contents + value = entry.get_value() + + if value.type == gconf.VALUE_STRING: + v = value.get_string() + + elif value.type == gconf.VALUE_BOOL: + v = value.get_bool() + + elif value.type == gconf.VALUE_INT: + v = value.get_int() + + # look up and call the callback + callback = self.callbacks[id]["callback"] + data = self.callbacks[id]["data"] + + callback(self, v, data) + + + def bind_widget(self, key, widget): + "Binds a gtk widget to a gconf key" + + if isinstance(widget, gtk.CheckMenuItem) or isinstance(widget, gtk.ToggleButton): + signal, cb_get, cb_set = "toggled", self.__cb_bind_toggle_get, self.__cb_bind_toggle_set + + elif isinstance(widget, gtk.SpinButton): + signal, cb_get, cb_set = "changed", self.__cb_bind_spin_get, self.__cb_bind_spin_set + + elif isinstance(widget, revelation.widget.FileEntry): + signal, cb_get, cb_set = "changed", self.__cb_bind_entry_get, self.__cb_bind_entry_set + widget = widget.entry + + elif isinstance(widget, gtk.Entry): + signal, cb_get, cb_set = "changed", self.__cb_bind_entry_get, self.__cb_bind_entry_set + + else: + raise ConfigError + + id = self.notify_add(key, cb_get, widget) + widget.connect(signal, cb_set, key) + widget.connect("unrealize", self.__cb_bind_unrealize, id) + + + def get(self, key): + "Looks up a config value" + + value = self.client.get(self.keypath(key)) + + if value is None: + raise ConfigError + + elif value.type == gconf.VALUE_STRING: + return value.get_string() + + elif value.type == gconf.VALUE_INT: + return value.get_int() + + elif value.type == gconf.VALUE_BOOL: + return value.get_bool() + + + def notify_add(self, key, callback, data = None): + "Adds a callback for a key change" + + id = self.client.notify_add(self.keypath(key), self.__cb_notify) + + self.callbacks[id] = { + "callback" : callback, + "data" : data + } + + # call the callback to set an initial state + callback(self, self.get(key), data) + + return id + + + def keypath(self, key): + "Generates an absolute key path" + + return self.basedir + "/" + key + + + def set(self, key, value): + "Sets a configuration value" + + v = self.client.get(self.keypath(key)) + + if v is None: + raise ConfigError + + if v.type == gconf.VALUE_STRING: + v.set_string(value) + + elif v.type == gconf.VALUE_BOOL: + v.set_bool(value) + + elif v.type == gconf.VALUE_INT: + v.set_int(value) + + self.client.set(self.keypath(key), v) + + + class EntrySearch(gobject.GObject): "Does entry searching in entrystores" diff -r db7970bbbb932ee8a83b5d3c66707078c9472e50 -r 9b3c9903350d6654128a459470db753e4a05b5d7 src/lib/dialog.py --- a/src/lib/dialog.py Thu Jul 15 23:50:31 2004 +0000 +++ b/src/lib/dialog.py Tue Jul 27 17:54:30 2004 +0000 @@ -422,40 +422,56 @@ section = self.add_section("Account data") for field in fields: - if field.id == revelation.entry.FIELD_GENERIC_PASSWORD: + + if field.type == revelation.entry.FIELD_TYPE_PASSWORD: entry = revelation.widget.PasswordEntry() - elif field.type == revelation.entry.FIELD_TYPE_PASSWORD: - entry = revelation.widget.PasswordEntry(None, gtk.FALSE) - else: entry = revelation.widget.Entry() entry.set_text(field.value) entry.connect("changed", self.__cb_entry_field_changed, field.id) self.tooltips.set_tip(entry, field.description) - section.add_inputrow(field.name, entry) + + if field.id == revelation.entry.FIELD_GENERIC_PASSWORD: + hbox = gtk.HBox() + hbox.set_spacing(6) + section.add_inputrow(field.name, hbox) + + hbox.pack_start(entry) + + button = gtk.Button("Generate") + button.connect("clicked", lambda w: entry.set_text(revelation.misc.generate_password())) + hbox.pack_start(button, gtk.FALSE, gtk.FALSE) + + + else: + section.add_inputrow(field.name, entry) self.show_all() class Find(Property): + "A dialog for searching for entries" - def __init__(self, parent): + def __init__(self, parent, config): Property.__init__( self, parent, "Find an entry", [ [ gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE ], [ revelation.stock.STOCK_PREVIOUS, RESPONSE_PREVIOUS ], [ revelation.stock.STOCK_NEXT, RESPONSE_NEXT ] ] ) + self.config = config + section = self.add_section("Find an entry") - # set up inputs + # the search string entry self.entry_phrase = revelation.widget.Entry() self.tooltips.set_tip(self.entry_phrase, "The text to search for") self.entry_phrase.connect("changed", self.__cb_entry_changed) section.add_inputrow("Search for", self.entry_phrase) + # the account type dropdown self.dropdown = revelation.widget.EntryDropdown() self.tooltips.set_tip(self.dropdown, "The account type to search for") item = self.dropdown.get_item(0) @@ -464,19 +480,20 @@ item.type = None section.add_inputrow("Account type", self.dropdown) + # folder search checkbutton check = revelation.widget.CheckButton("Search for folders as well") self.tooltips.set_tip(check, "When enabled, folder names and descriptions will also be searched") - check.gconf_bind("/apps/revelation/search/folders") + self.config.bind_widget("search/folders", check) section.add_inputrow(None, check) check = revelation.widget.CheckButton("Only search in name and description") self.tooltips.set_tip(check, "When enabled, only entry names and descriptions will be searched") - check.gconf_bind("/apps/revelation/search/namedesc") + self.config.bind_widget("search/namedesc", check) section.add_inputrow(None, check) check = revelation.widget.CheckButton("Case sensitive") self.tooltips.set_tip(check, "When enabled, searches will be case sensitive") - check.gconf_bind("/apps/revelation/search/casesens") + self.config.bind_widget("search/casesens", check) section.add_inputrow(None, check) # set up initial states @@ -565,55 +582,80 @@ class Preferences(Property): + "The preference dialog" - def __init__(self, parent): + def __init__(self, parent, config): Property.__init__(self, parent, "Preferences", [ [ gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE ] ]) + self.config = config self.__init_section_file() self.__init_section_pwgen() def __init_section_file(self): + "Sets up the file section" + self.section_file = self.add_section("File Handling") + # check-button for autoloading a file self.check_autoload = revelation.widget.CheckButton("Open file on startup") - self.check_autoload.gconf_bind("/apps/revelation/file/autoload") - self.check_autoload.connect("toggled", self.__cb_file_autoload) - self.tooltips.set_tip(self.check_autoload, "When enabled, a file will be opened when the program is started") self.section_file.add_inputrow(None, self.check_autoload) + self.config.bind_widget("file/autoload", self.check_autoload) + self.tooltips.set_tip(self.check_autoload, "When enabled, a file will be opened when the program is started") + + + # entry for file to autoload self.entry_autoload_file = revelation.widget.FileEntry("Select File to Automatically Open") - self.entry_autoload_file.gconf_bind("/apps/revelation/file/autoload_file") self.entry_autoload_file.set_sensitive(self.check_autoload.get_active()) - self.tooltips.set_tip(self.entry_autoload_file, "A file to be opened when the program is started") self.section_file.add_inputrow("File to open", self.entry_autoload_file) + self.config.bind_widget("file/autoload_file", self.entry_autoload_file) + self.tooltips.set_tip(self.entry_autoload_file, "A file to be opened when the program is started") + + + # check-button for autosave self.check_autosave = revelation.widget.CheckButton("Autosave data when changed") - self.check_autosave.gconf_bind("/apps/revelation/file/autosave") - self.tooltips.set_tip(self.check_autosave, "Automatically saves the data file when an entry is added, modified or removed") self.section_file.add_inputrow(None, self.check_autosave) + self.tooltips.set_tip(self.check_autosave, "Automatically saves the data file when an entry is added, modified or removed") + self.config.bind_widget("file/autosave", self.check_autosave) + + + self.check_autoload.connect("toggled", self.__cb_autoload) + def __init_section_pwgen(self): + "Sets up the password generator section" + self.section_pwgen = self.add_section("Password Generator") + # password length spinbutton self.spin_pwlen = revelation.widget.SpinButton() self.spin_pwlen.set_range(4, 32) - self.spin_pwlen.gconf_bind("/apps/revelation/passwordgen/length") - self.tooltips.set_tip(self.spin_pwlen, "The number of characters in generated passwords - 8 or more are recommended") self.section_pwgen.add_inputrow("Password length", self.spin_pwlen) + self.config.bind_widget("passwordgen/length", self.spin_pwlen) + self.tooltips.set_tip(self.spin_pwlen, "The number of characters in generated passwords - 8 or more are recommended") + + + # checkbox for avoiding ambiguous characters in password self.check_ambiguous = revelation.widget.CheckButton("Avoid ambiguous characters") - self.check_ambiguous.gconf_bind("/apps/revelation/passwordgen/avoid_ambiguous") - self.tooltips.set_tip(self.check_ambiguous, "When enabled, generated passwords will not contain ambiguous characters - like 0 (zero) and O (capital o)") self.section_pwgen.add_inputrow(None, self.check_ambiguous) + self.tooltips.set_tip(self.check_ambiguous, "When enabled, generated passwords will not contain ambiguous characters - like 0 (zero) and O (capital o)") + self.config.bind_widget("passwordgen/avoid_ambiguous", self.check_ambiguous) - def __cb_file_autoload(self, object, data = None): + + def __cb_autoload(self, widget, data = None): + "Sets the autoload file entry sensitivity based on the autoload checkbutton state" + self.entry_autoload_file.set_sensitive(self.check_autoload.get_active()) def run(self): + "Runs the preference dialog" + self.show_all() Property.run(self) self.destroy() diff -r db7970bbbb932ee8a83b5d3c66707078c9472e50 -r 9b3c9903350d6654128a459470db753e4a05b5d7 src/lib/widget.py --- a/src/lib/widget.py Thu Jul 15 23:50:31 2004 +0000 +++ b/src/lib/widget.py Tue Jul 27 17:54:30 2004 +0000 @@ -23,34 +23,7 @@ # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # -import gobject, gtk, gtk.gdk, gnome.ui, revelation, gconf, os.path - - -class GConfHandler: - """Abstract class which handles synchronization between - a widget and a gconf key""" - - def __cb_get(self, client, id, entry, data): - self.gconf_cb_get(self.gconf, self.gconf_key) - - def __cb_set(self, object, data = None): - self.gconf_cb_set(self.gconf, self.gconf_key) - - def __cb_unrealize(self, object, data = None): - self.gconf.notify_remove(self.gconf_conn) - - def gconf_bind(self, key, cb_get, cb_set, setsignal): - self.gconf = gconf.client_get_default() - self.gconf_key = key - self.gconf_cb_get = cb_get - self.gconf_cb_set = cb_set - - cb_get(self.gconf, self.gconf_key) - self.gconf_conn = self.gconf.notify_add(key, self.__cb_get) - self.connect("unrealize", self.__cb_unrealize) - - if cb_set != None and setsignal != None: - self.connect(setsignal, self.__cb_set) +import gobject, gtk, gtk.gdk, gnome.ui, revelation, os.path, gconf # first, some simple subclasses - replacements for gtk widgets @@ -115,23 +88,14 @@ -class CheckButton(gtk.CheckButton, GConfHandler): +class CheckButton(gtk.CheckButton): def __init__(self, label = None): gtk.CheckButton.__init__(self, label) - def __cb_gconf_get(self, client, key): - self.set_active(client.get_bool(key)) - def __cb_gconf_set(self, client, key): - client.set_bool(key, self.get_active()) - def gconf_bind(self, key): - GConfHandler.gconf_bind(self, key, self.__cb_gconf_get, self.__cb_gconf_set, "toggled") - - - -class Entry(gtk.Entry, GConfHandler): +class Entry(gtk.Entry): def __init__(self, text = None): gtk.Entry.__init__(self) @@ -139,18 +103,6 @@ self.set_text(text) - def __cb_gconf_get(self, client, key): - self.set_text(client.get_string(key)) - - - def __cb_gconf_set(self, client, key): - client.set_string(key, self.get_text()) - - - def gconf_bind(self, key): - GConfHandler.gconf_bind(self, key, self.__cb_gconf_get, self.__cb_gconf_set, "changed") - - def set_text(self, text): if text == None: text = "" @@ -191,13 +143,10 @@ fsel.destroy() - def gconf_bind(self, key): - self.entry.gconf_bind(key) - - def get_filename(self): return self.entry.get_text() + def set_filename(self, filename): self.entry.set_text(os.path.normpath(filename)) self.entry.set_position(-1) @@ -365,22 +314,13 @@ -class SpinButton(gtk.SpinButton, GConfHandler): +class SpinButton(gtk.SpinButton): def __init__(self, adjustment = None, climb_rate = 0.0, digits = 0): gtk.SpinButton.__init__(self, adjustment, climb_rate, digits) self.set_increments(1, 1) self.set_numeric(gtk.TRUE) - def __cb_gconf_get(self, client, key): - self.set_value(client.get_int(key)) - - def __cb_gconf_set(self, client, key): - client.set_int(key, self.get_value_as_int()) - - def gconf_bind(self, key): - GConfHandler.gconf_bind(self, key, self.__cb_gconf_get, self.__cb_gconf_set, "value-changed") - class TreeStore(gtk.TreeStore): @@ -699,63 +639,59 @@ -class PasswordEntry(gtk.HBox, GConfHandler): +class PasswordEntry(Entry): + "An entry which edits a password (follows the 'show passwords' preference" - def __init__(self, value = None, generator = gtk.TRUE, ignorehide = gtk.FALSE): - gtk.HBox.__init__(self) + def __init__(self, password = None): + Entry.__init__(self, password) - self.entry = revelation.widget.Entry(value) - self.entry.connect("changed", self.__cb_changed) - self.pack_start(self.entry) + c = gconf.client_get_default() + c.notify_add("/apps/revelation/view/passwords", self.__cb_gconf_password) - if ignorehide == gtk.FALSE: - self.gconf_bind("/apps/revelation/view/passwords", self.__cb_gconf_password, None, None) + self.set_visibility(c.get_bool("/apps/revelation/view/passwords")) - if generator == gtk.TRUE: - self.pwgen = gtk.Button("Generate") - self.pwgen.connect("clicked", self.__cb_generate) - self.pack_start(self.pwgen, gtk.FALSE, gtk.FALSE) + def __cb_gconf_password(self, client, id, entry, data): + "Callback which shows or hides the password" - def __cb_changed(self, widget, data = None): - self.emit("changed") + self.set_visibility(entry.get_value().get_bool()) - def __cb_gconf_password(self, client, key): - self.set_visibility(client.get_bool(key)) - def __cb_generate(self, object, data = None): - self.entry.set_text(revelation.misc.generate_password()) - - def get_text(self): - return self.entry.get_text() - - def set_activates_default(self, activates): - self.entry.set_activates_default(activates) - - def set_text(self, text): - self.entry.set_text(text) - - def set_visibility(self, visibility): - self.entry.set_visibility(visibility) - -gobject.signal_new("changed", PasswordEntry, gobject.SIGNAL_ACTION, gobject.TYPE_BOOLEAN, ()) - - - -class PasswordLabel(Label, GConfHandler): +class PasswordLabel(Label): + "A label which displays a passwords (follows the 'show passwords' preference)" def __init__(self, password, justify = gtk.JUSTIFY_LEFT): Label.__init__(self, password, justify) self.password = password - self.gconf_bind("/apps/revelation/view/passwords", self.__cb_gconf_password, None, None) + c = gconf.client_get_default() + c.notify_add("/apps/revelation/view/passwords", self.__cb_gconf_password) - def __cb_gconf_password(self, client, key): - if client.get_bool(key) == gtk.TRUE: - Label.set_markup(self, self.password) - self.set_selectable(gtk.TRUE) + if c.get_bool("/apps/revelation/view/passwords") == gtk.FALSE: + self.hide_password() + + + def __cb_gconf_password(self, client, id, entry, data): + "Callback which displays or hides the password" + + if entry.get_value().get_bool() == gtk.TRUE: + self.show_password() + else: - Label.set_text(self, "******") - self.set_selectable(gtk.FALSE) + self.hide_password() + + def hide_password(self): + "Hides the password" + + self.set_text("******") + self.set_selectable(gtk.FALSE) + + + def show_password(self): + "Shows the password" + + self.set_text(self.password) + self.set_selectable(gtk.FALSE) + diff -r db7970bbbb932ee8a83b5d3c66707078c9472e50 -r 9b3c9903350d6654128a459470db753e4a05b5d7 src/revelation --- a/src/revelation Thu Jul 15 23:50:31 2004 +0000 +++ b/src/revelation Tue Jul 27 17:54:30 2004 +0000 @@ -24,7 +24,8 @@ import pygtk pygtk.require("2.0") -import gtk, gnome, gnome.ui, revelation, os, os.path, sys, gobject, gc, gconf + +import gtk, gnome, revelation, os, os.path, sys, gobject class Revelation(revelation.widget.App): @@ -37,7 +38,6 @@ self.connect("file-changed", self.__cb_state_file) self.connect("delete_event", self.__cb_quit) - gtk.window_set_default_icon_list( gtk.gdk.pixbuf_new_from_file(revelation.DATADIR + "/pixmaps/revelation.png"), gtk.gdk.pixbuf_new_from_file(revelation.DATADIR + "/pixmaps/revelation-16x16.png") @@ -66,18 +66,13 @@ def __init_facilities(self): "Sets up various application facilities" - self.gconf = gconf.client_get_default() + self.config = revelation.data.Config() self.icons = revelation.stock.IconFactory(self) self.data = revelation.data.EntryStore() self.clipboard = revelation.data.EntryClipboard() self.undoqueue = revelation.data.UndoQueue(self.data) self.finder = revelation.data.EntrySearch(self.data) - self.gconf.add_dir("/apps/revelation", gconf.CLIENT_PRELOAD_NONE) - self.gconf.notify_add("/apps/revelation/view/statusbar", self.__cb_gconf_statusbar) - self.gconf.notify_add("/apps/revelation/view/toolbar", self.__cb_gconf_toolbar) - self.gconf.notify_add("/apps/revelation/view/passwords", self.__cb_gconf_view_passwords) - self.clipboard.connect("copy", self.__cb_state_clipboard) self.clipboard.connect("cut", self.__cb_state_clipboard) @@ -100,7 +95,7 @@ alignment = gtk.Alignment(0.5, 0.4, 0, 0) alignment.add(self.dataview) - self.hpaned = revelation.widget.HPaned(scrolledwindow, alignment, self.gconf.get_int("/apps/revelation/view/pane-position")) + self.hpaned = revelation.widget.HPaned(scrolledwindow, alignment, self.config.get("view/pane-position")) self.set_contents(self.hpaned) @@ -144,13 +139,13 @@ ("/Edit/_Select All", "A", "Select all entries", lambda w,d: self.tree.select_all(), 0, ""), ("/Edit/_Deselect All", "A", "Deselect all entries", lambda w,d: self.tree.unselect_all(), 0, ""), ("/Edit/sep5", None, None, None, 0, ""), - ("/Edit/Prefere_nces", None, "Edit preferences", lambda w,d: revelation.dialog.Preferences(self).run(), 0, "", gtk.STOCK_PREFERENCES), + ("/Edit/Prefere_nces", None, "Edit preferences", lambda w,d: revelation.dialog.Preferences(self, self.config).run(), 0, "", gtk.STOCK_PREFERENCES), ("/_View", None, None, None, 0, ""), - ("/View/_Toolbar", None, "Toggle display of the toolbar", self.__cb_state_toolbar, 0, ""), - ("/View/_Statusbar", None, "Toggle display of the statusbar", self.__cb_state_statusbar, 0, ""), + ("/View/_Toolbar", None, "Toggle display of the toolbar", None, 0, ""), + ("/View/_Statusbar", None, "Toggle display of the statusbar", None, 0, ""), ("/View/sep1", None, None, None, 0, ""), - ("/View/Show _Passwords", "P", "Show passwords", self.__cb_state_showpasswords, 0, ""), + ("/View/Show _Passwords", "P", "Show passwords", None, 0, ""), ("/_Help", None, None, None, 0, ""), ("/Help/_Homepage", None, "Visit the Revelation homepage", lambda w,d: gnome.url_show(revelation.URL), 0, "", gtk.STOCK_HOME), @@ -163,7 +158,7 @@ def __init_states(self): "Sets the initial application state" - self.set_default_size(self.gconf.get_int("/apps/revelation/view/window-width"), self.gconf.get_int("/apps/revelation/view/window-height")) + self.set_default_size(self.config.get("view/window-width"), self.config.get("view/window-height")) self.tree.select(None) self.dataview.display_info() @@ -171,7 +166,6 @@ self.if_menu.get_widget("
/Edit/Find Previous").set_sensitive(gtk.FALSE) self.if_menu.get_widget("
/Edit/Undo").set_sensitive(gtk.FALSE) self.if_menu.get_widget("
/Edit/Redo").set_sensitive(gtk.FALSE) - self.if_menu.get_widget("
/View/Show Passwords").set_active(self.gconf.get_bool("/apps/revelation/view/passwords")) self.file = None self.password = None @@ -179,17 +173,12 @@ self.show_all() - if self.gconf.get_bool("/apps/revelation/view/toolbar") == gtk.TRUE: - self.if_menu.get_widget("
/View/Toolbar").set_active(gtk.TRUE) + self.config.bind_widget("view/passwords", self.if_menu.get_widget("
/View/Show Passwords")) + self.config.bind_widget("view/statusbar", self.if_menu.get_widget("
/View/Statusbar")) + self.config.bind_widget("view/toolbar", self.if_menu.get_widget("
/View/Toolbar")) - else: - self.toolbar.hide() - - if self.gconf.get_bool("/apps/revelation/view/statusbar") == gtk.TRUE: - self.if_menu.get_widget("
/View/Statusbar").set_active(gtk.TRUE) - - else: - self.statusbar.hide() + self.config.notify_add("view/statusbar", self.__cb_config_statusbar) + self.config.notify_add("view/toolbar", self.__cb_config_toolbar) def __init_toolbar(self): @@ -207,35 +196,25 @@ - # gconf callbacks - def __cb_gconf_statusbar(self, client, id, entry, data): - "GConf callback for statusbar changes" + # config callbacks + def __cb_config_statusbar(self, config, value, data): + "Config callback for statusbar changes" - if entry.get_value().get_bool() == gtk.TRUE: + if value == gtk.TRUE: self.statusbar.show() - self.if_menu.get_widget("
/View/Statusbar").set_active(gtk.TRUE) else: self.statusbar.hide() - self.if_menu.get_widget("
/View/Statusbar").set_active(gtk.FALSE) - def __cb_gconf_toolbar(self, client, id, entry, data): - "GConf callback for toolbar changes" + def __cb_config_toolbar(self, config, value, data): + "Config callback for toolbar changes" - if entry.get_value().get_bool() == gtk.TRUE: + if value == gtk.TRUE: self.toolbar.show() - self.if_menu.get_widget("
/View/Toolbar").set_active(gtk.TRUE) else: self.toolbar.hide() - self.if_menu.get_widget("
/View/Toolbar").set_active(gtk.FALSE) - - - def __cb_gconf_view_passwords(self, client, id, entry, data): - "GConf callback for view password changes" - - self.if_menu.get_widget("
/View/Show Passwords").set_active(entry.get_value().get_bool()) @@ -288,26 +267,6 @@ self.if_menu.get_widget("
/Edit/Find Previous").set_sensitive(self.finder.string != "") - def __cb_state_showpasswords(self, widget, data = None): - "Sets states for show passwords related items" - - self.gconf.set_bool("/apps/revelation/view/passwords", self.if_menu.get_widget("
/View/Show Passwords").get_active()) - - - def __cb_state_statusbar(self, widget, data = None): - "Sets statusbar-related states" - - active = self.if_menu.get_widget("
/View/Statusbar").get_active() - self.gconf.set_bool("/apps/revelation/view/statusbar", active) - - - def __cb_state_toolbar(self, widget, data = None): - "Sets toolbar-related states" - - active = self.if_menu.get_widget("
/View/Toolbar").get_active() - self.gconf.set_bool("/apps/revelation/view/toolbar", active) - - def __cb_state_undo(self, widget, data = None): "Sets states for undo-related ui items" @@ -406,9 +365,9 @@ # various private methods def __entry_find(self, parent, direction = revelation.data.SEARCH_NEXT): - self.finder.folders = self.gconf.get_bool("/apps/revelation/search/folders") - self.finder.casesens = self.gconf.get_bool("/apps/revelation/search/casesens") - self.finder.namedesc = self.gconf.get_bool("/apps/revelation/search/namedesc") + self.finder.folders = self.config.get("search/folders") + self.finder.casesens = self.config.get("search/casesens") + self.finder.namedesc = self.config.get("search/namedesc") match = self.finder.find(self.tree.get_active(), direction) @@ -424,7 +383,7 @@ if self.file is None or self.password is None: return - if not self.gconf.get_bool("/apps/revelation/file/autosave"): + if not self.client.get("file/autosave"): return self.file_save(self.file, self.password) @@ -644,7 +603,7 @@ def entry_find(self): - dialog = revelation.dialog.Find(self) + dialog = revelation.dialog.Find(self, self.config) dialog.entry_phrase.set_text(self.finder.string) dialog.dropdown.set_type(self.finder.type) @@ -869,9 +828,9 @@ return gtk.FALSE width, height = self.get_size() - self.gconf.set_int("/apps/revelation/view/window-width", width) - self.gconf.set_int("/apps/revelation/view/window-height", height) - self.gconf.set_int("/apps/revelation/view/pane-position", self.hpaned.get_position()) + self.config.set("view/window-width", width) + self.config.set("view/window-height", height) + self.config.set("view/pane-position", self.hpaned.get_position()) gtk.mainquit() return gtk.TRUE @@ -897,8 +856,8 @@ def run(self, file = None): if file is not None: self.file_open(file) - elif self.gconf.get_bool("/apps/revelation/file/autoload"): - self.file_open(self.gconf.get_string("/apps/revelation/file/autoload_file")) + elif self.config.get("file/autoload"): + self.file_open(self.config.get("file/autoload_file")) gtk.main()