File: simple-view.py

package info (click to toggle)
gnome-python 2.12.4-6
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 2,804 kB
  • ctags: 813
  • sloc: sh: 8,593; ansic: 7,747; python: 1,811; makefile: 333; xml: 54
file content (36 lines) | stat: -rwxr-xr-x 824 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env python
#
# A very simple program that monitors a single key for changes.
#

import gtk
import gconf

def key_changed_callback (client, cnxn_id, entry, label):
    if not entry.value:
	label.set ('<unset>')
    else:
	if entry.value.type == gconf.VALUE_STRING:
	    label.set_text (entry.value.to_string ())
	else:
	    label.set ('<wrong type>')

client = gconf.client_get_default ()

window = gtk.Window ()
window.set_default_size (120, 80)
window.connect ('destroy', lambda w: gtk.mainquit ())

s = client.get_string ("/testing/directory/key")

label = gtk.Label (s or '<unset>')
window.add (label)

client.add_dir ('/testing/directory',
                gconf.CLIENT_PRELOAD_NONE)

client.notify_add ("/testing/directory/key",
                   key_changed_callback, label)

window.show_all ()
gtk.main ()