~ubuntu-branches/ubuntu/trusty/gnome-python/trusty

« back to all changes in this revision

Viewing changes to examples/gconf/simple-view.py

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2005-12-02 12:30:09 UTC
  • Revision ID: james.westby@ubuntu.com-20051202123009-z00n5h4uuwfo64ev
Tags: upstream-2.12.2
ImportĀ upstreamĀ versionĀ 2.12.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
#
 
3
# A very simple program that monitors a single key for changes.
 
4
#
 
5
 
 
6
import gtk
 
7
import gconf
 
8
 
 
9
def key_changed_callback (client, cnxn_id, entry, label):
 
10
    if not entry.value:
 
11
        label.set ('<unset>')
 
12
    else:
 
13
        if entry.value.type == gconf.VALUE_STRING:
 
14
            label.set_text (entry.value.to_string ())
 
15
        else:
 
16
            label.set ('<wrong type>')
 
17
 
 
18
client = gconf.client_get_default ()
 
19
 
 
20
window = gtk.Window ()
 
21
window.set_default_size (120, 80)
 
22
window.connect ('destroy', lambda w: gtk.mainquit ())
 
23
 
 
24
s = client.get_string ("/testing/directory/key")
 
25
 
 
26
label = gtk.Label (s or '<unset>')
 
27
window.add (label)
 
28
 
 
29
client.add_dir ('/testing/directory',
 
30
                gconf.CLIENT_PRELOAD_NONE)
 
31
 
 
32
client.notify_add ("/testing/directory/key",
 
33
                   key_changed_callback, label)
 
34
 
 
35
window.show_all ()
 
36
gtk.main ()