1 # Copyright (C) 2006 Ulrik Sverdrup
3 # dragbox -- Commandline drag-and-drop tool for GNOME
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
21 Preference database handlers
24 from version
import pref_id
26 from gconf
import client_get_default
27 shared_client
= client_get_default()
29 def get_gconf_client():
31 Returns a gconf client object
35 def get_bool(key
, if_none
=None):
39 @param key: key in the application domain to get
40 @type key: a string object.
42 @param if_none: Placeholder if no value is set
43 @type if_none: a bool object.
45 client
= shared_client
46 gcvalue
= client
.get_without_default(pref_id
+ key
)
49 value
= gcvalue
.get_bool()
55 def set_bool(key
, value
):
57 Sets a key in the application domain
60 @type key: a string object.
63 @type value: a bool object.
65 client
= shared_client
66 client
.set_bool(pref_id
+ key
, value
)
68 def notify_add(key
, callback
, user_info
=None):
70 Registers a delegate for callbacks when a key is changed
73 callback(client, connection, entry, user_info):
75 @param key: The prefs key that changes
76 @type key: a string object.
79 @type callback: a function object.
81 @param user_info: optional user info
82 @type user_info: an object.
84 from utils
import print_debug
85 #print_debug("notify-add: %s" % (dragbox_pref_id + key,))
86 shared_client
.notify_add(pref_id
+ key
, callback
, user_info
)