~ubuntu-branches/debian/lenny/fpc/lenny

« back to all changes in this revision

Viewing changes to fpcsrc/packages/extra/gnome1/gconf/examples/gconfexample.pp

  • Committer: Bazaar Package Importer
  • Author(s): Mazen Neifer, Torsten Werner, Mazen Neifer
  • Date: 2008-05-17 17:12:11 UTC
  • mfrom: (3.1.9 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080517171211-9qi33xhd9evfa0kg
Tags: 2.2.0-dfsg1-9
[ Torsten Werner ]
* Add Mazen Neifer to Uploaders field.

[ Mazen Neifer ]
* Moved FPC sources into a version dependent directory from /usr/share/fpcsrc
  to /usr/share/fpcsrc/${FPCVERSION}. This allow installing more than on FPC
  release.
* Fixed far call issue in compiler preventing building huge binearies.
  (closes: #477743)
* Updated building dependencies, recomennded and suggested packages.
* Moved fppkg to fp-utils as it is just a helper tool and is not required by
  compiler.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Program gconfexample;
 
2
 
 
3
Uses glib, gtk, gconf, gconfclient;
 
4
 
 
5
Const
 
6
  PATH : PChar = '/apps/GNOMEnclature/gconf_example';
 
7
  KEY : PChar= '/apps/GNOMEnclature/gconf_example/my_option';
 
8
 
 
9
{ Update the GConf key when the user toggles the check button. }
 
10
Procedure button_toggled_cb (button : PGtkWidget; data : gpointer); cdecl;
 
11
var
 
12
  client : PGConfClient;
 
13
  thevalue : gboolean;
 
14
begin
 
15
  client := gconf_client_get_default ();
 
16
 
 
17
  thevalue := gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button));
 
18
 
 
19
  gconf_client_set_bool (client, KEY, thevalue, nil);
 
20
end;
 
21
 
 
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;
 
25
var
 
26
  check_button : PGtkWidget;
 
27
  thevalue : PGConfValue;
 
28
  checked : gboolean;
 
29
begin
 
30
  check_button := GTK_WIDGET (user_data);
 
31
 
 
32
  thevalue := gconf_entry_get_value (entry);
 
33
 
 
34
  checked := gconf_value_get_bool (thevalue);
 
35
 
 
36
  { Update the check button accordingly. }
 
37
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_button),
 
38
                                checked);
 
39
end;
 
40
 
 
41
var
 
42
  window : PGtkWidget;
 
43
  check_button : PGTKWidget;
 
44
  client : PGConfClient;
 
45
  thevalue : gboolean;
 
46
 
 
47
begin
 
48
  gtk_init (@argc, @argv);
 
49
  gconf_init(argc, argv, nil);
 
50
 
 
51
  client := gconf_client_get_default ();
 
52
 
 
53
  window := gtk_window_new (GTK_WINDOW_TOPLEVEL);
 
54
  gtk_signal_connect(GTK_OBJECT (window), 'destroy',
 
55
                   @gtk_main_quit, nil);
 
56
 
 
57
  { Get the initial value from GConf. }
 
58
  thevalue := gconf_client_get_bool (client, KEY, nil);
 
59
 
 
60
  check_button := gtk_check_button_new_with_label ('My option');
 
61
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_button),
 
62
                                      thevalue);
 
63
 
 
64
  gtk_signal_connect (GTK_OBJECT (check_button), 'toggled',
 
65
                          gtk_SIGNAL_FUNC(@button_toggled_cb), nil);
 
66
 
 
67
  gtk_container_add (GTK_CONTAINER (window), check_button);
 
68
 
 
69
  gtk_widget_show_all (window);
 
70
 
 
71
  (* Add our directory to the list of directories the GConfClient will
 
72
   * watch.
 
73
   *)
 
74
 
 
75
  gconf_client_add_dir (client, PATH, GCONF_CLIENT_PRELOAD_NONE, nil);
 
76
 
 
77
  { Listen to changes to our key. }
 
78
 
 
79
  gconf_client_notify_add (client, KEY, @gconf_notify_func, check_button, nil, nil);
 
80
 
 
81
  gtk_main ();
 
82
 
 
83
end.