3
Uses glib, gtk, gconf, gconfclient;
6
PATH : PChar = '/apps/GNOMEnclature/gconf_example';
7
KEY : PChar= '/apps/GNOMEnclature/gconf_example/my_option';
9
{ Update the GConf key when the user toggles the check button. }
10
Procedure button_toggled_cb (button : PGtkWidget; data : gpointer); cdecl;
12
client : PGConfClient;
15
client := gconf_client_get_default ();
17
thevalue := gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button));
19
gconf_client_set_bool (client, KEY, thevalue, nil);
22
{ This is called when our key is changed. }
23
Procedure gconf_notify_func (client : PGConfClient; cnxn_id : guint;
24
entry : PGConfEntry; user_data : gpointer); cdecl;
26
check_button : PGtkWidget;
27
thevalue : PGConfValue;
30
check_button := GTK_WIDGET (user_data);
32
thevalue := gconf_entry_get_value (entry);
34
checked := gconf_value_get_bool (thevalue);
36
{ Update the check button accordingly. }
37
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_button),
43
check_button : PGTKWidget;
44
client : PGConfClient;
48
gtk_init (@argc, @argv);
49
gconf_init(argc, argv, nil);
51
client := gconf_client_get_default ();
53
window := gtk_window_new (GTK_WINDOW_TOPLEVEL);
54
gtk_signal_connect(GTK_OBJECT (window), 'destroy',
57
{ Get the initial value from GConf. }
58
thevalue := gconf_client_get_bool (client, KEY, nil);
60
check_button := gtk_check_button_new_with_label ('My option');
61
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_button),
64
gtk_signal_connect (GTK_OBJECT (check_button), 'toggled',
65
gtk_SIGNAL_FUNC(@button_toggled_cb), nil);
67
gtk_container_add (GTK_CONTAINER (window), check_button);
69
gtk_widget_show_all (window);
71
(* Add our directory to the list of directories the GConfClient will
75
gconf_client_add_dir (client, PATH, GCONF_CLIENT_PRELOAD_NONE, nil);
77
{ Listen to changes to our key. }
79
gconf_client_notify_add (client, KEY, @gconf_notify_func, check_button, nil, nil);