source: trunk/third/GConf2/examples/simple-controller.c @ 18253

Revision 18253, 2.2 KB checked in by ghudson, 22 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r18252, which included commits to RCS files with non-trunk default branches.
Line 
1/* -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2/* GConf
3 * Copyright (C) 1999, 2000 Red Hat Inc.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library 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 GNU
13 * Library General Public License for more details.
14 *
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
19 */
20
21/* A very simple program that sets a single key value when you type
22   it in an entry and press return */
23
24#include <gconf/gconf-client.h>
25#include <gtk/gtk.h>
26
27void
28entry_activated_callback(GtkWidget* entry, gpointer user_data)
29{
30  GConfClient* client;
31  gchar* str;
32 
33  client = GCONF_CLIENT(user_data);
34
35  str = gtk_editable_get_chars(GTK_EDITABLE(entry), 0, -1);
36
37  gconf_client_set_string(client, "/extra/test/directory/key",
38                          str, NULL);
39
40  g_free(str);
41}
42
43int
44main(int argc, char** argv)
45{
46  GtkWidget* window;
47  GtkWidget* entry;
48  GConfClient* client;
49
50  gtk_init(&argc, &argv);
51  gconf_init(argc, argv, NULL);
52 
53  window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
54  entry = gtk_entry_new();
55
56  gtk_container_add(GTK_CONTAINER(window), entry); 
57
58  client = gconf_client_get_default();
59
60  gconf_client_add_dir(client,
61                       "/extra/test/directory",
62                       GCONF_CLIENT_PRELOAD_NONE,
63                       NULL);
64
65
66  g_signal_connect (G_OBJECT (entry), "activate",
67                    G_CALLBACK (entry_activated_callback),
68                    client);
69
70  /* If key isn't writable, then set insensitive */
71  gtk_widget_set_sensitive (entry,
72                            gconf_client_key_is_writable (client,
73                                                          "/extra/test/directory/key", NULL));
74 
75  gtk_widget_show_all(window);
76
77  gtk_main();
78
79  return 0;
80}
81
82
Note: See TracBrowser for help on using the repository browser.