A
download panel-gconf.c
Language: C
LOC: 228
Project Info
gnome-core
Server: Gnome
Type: cvs
...nome‑core\gnome‑core\panel\
   .cvsignore
   aligned-widget.c
   aligned-widget.h
   applet.c
   applet.h
   basep-widget.c
   basep-widget.h
   border-widget.c
   border-widget.h
   button-widget.c
   button-widget.h
   distribution.c
   distribution.h
   drawer-widget.c
   drawer-widget.h
   drawer.c
   drawer.h
   edge-widget.c
   edge-widget.h
   floating-widget.c
   floating-widget.h
   foobar-widget.c
   foobar-widget.h
   global-keys.c
   global-keys.h
   gnome-panel-add-launcher.c
   gnome-panel-properties.c
   ...l-properties.desktop.in
   ...-panel-properties.glade
   gnome-panel-screenshot.c
   ...-panel-screenshot.glade
   gnome-run.c
   gnome-run.h
   GNOME_Panel.server.in
   launcher.c
   launcher.h
   logout.c
   logout.h
   main.c
   Makefile.am
   menu-fentry.c
   menu-fentry.h
   menu-properties.c
   menu-properties.h
   menu-util.c
   menu-util.h
   menu.c
   menu.h
   multiscreen-stuff.c
   multiscreen-stuff.h
   nothing.cP
   nothing.h
   panel-applet-frame.c
   panel-applet-frame.h
   panel-config-global.h
   panel-config.c
   panel-config.h
   panel-gconf.c
   panel-gconf.h
   ...l-global-config.schemas
   panel-main.h
   panel-marshal.list
   ...er-panel-config.schemas
   panel-shell.c
   panel-shell.h
   panel-types.h
   panel-util.c
   panel-util.h
   panel-widget.c
   panel-widget.h
   panel.c
   panel.h
   panel.hints
   quick-desktop-reader.c
   quick-desktop-reader.h
   rgb-stuff.c
   rgb-stuff.h
   session.c
   session.h
   sliding-widget.c
   sliding-widget.h
   status-docklet.c
   status-docklet.h
   status.c
   status.h
   swallow.c
   swallow.h
   TODO.old
   xstuff.c
   xstuff.h

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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
#include <config.h>
#include <string.h>

#include <glib.h>
#include <gconf/gconf-client.h>
#include <libgnomeui/gnome-client.h>

#include "panel-gconf.h"

#undef PANEL_GCONF_DEBUG

gchar * 
panel_gconf_global_config_get_full_key (const gchar *key) {
	return g_strdup_printf ("/apps/panel/global/%s", key);
}

gchar *
panel_gconf_general_profile_get_full_key (const gchar *profile, const gchar *key) {
	return g_strdup_printf ("/apps/panel/profiles/%s/general/%s", profile, key);
}

gchar *
panel_gconf_panel_profile_get_full_key (const gchar *profile, const gchar *panel_id, const gchar *key) {
	return g_strdup_printf ("/apps/panel/profiles/%s/panels/%s/%s", profile, panel_id, key);
}

gchar *
panel_gconf_applets_profile_get_full_key (const gchar *profile, const gchar *applet_id, const gchar *key) {
	return g_strdup_printf ("/apps/panel/profiles/%s/applets/%s/%s", profile, applet_id, key);
}

gchar *
panel_gconf_objects_profile_get_full_key (const gchar *profile, const gchar *object_id, const gchar *key) {
	return g_strdup_printf ("/apps/panel/profiles/%s/objects/%s/%s", profile, object_id, key);
}

gchar *
panel_gconf_general_default_profile_get_full_key (const gchar *profile, const gchar *key) {
	return g_strdup_printf ("/apps/panel/default-profiles/%s/general/%s", profile, key);
}

gchar *
panel_gconf_panel_default_profile_get_full_key (const gchar *profile, const gchar *panel_id, const gchar *key) {
	return g_strdup_printf ("/apps/panel/default-profiles/%s/panels/%s/%s", profile, panel_id, key);
}

gchar *
panel_gconf_applets_default_profile_get_full_key (const gchar *profile, const gchar *applet_id, const gchar *key) {
	return g_strdup_printf ("/apps/panel/default-profiles/%s/applets/%s/%s", profile, applet_id, key);
}

gchar *
panel_gconf_objects_default_profile_get_full_key (const gchar *profile, const gchar *object_id, const gchar *key) {
	return g_strdup_printf ("/apps/panel/default-profiles/%s/objects/%s/%s", profile, object_id, key);
}

GConfClient * 
panel_gconf_get_client (void) {
	static GConfClient *client = NULL;

        if (!client)
                client = gconf_client_get_default ();

        return client;
}

GSList *
panel_gconf_all_global_entries (void)
{
	GSList *list;

	list = gconf_client_all_entries (panel_gconf_get_client (),
					 "/apps/panel/global",
					 NULL);

	return list;
}

gint 
panel_gconf_get_int (const gchar *key, gint default_val) {
	GConfValue *value;
	GError *error = NULL;

	value =  gconf_client_get (panel_gconf_get_client (), key, &error);

	if (value != NULL) {
		gint retval; 
	
		g_assert (error == NULL);

		if (value->type == GCONF_VALUE_INT)  {
			retval = gconf_value_get_int (value);
		} else {
			/* FIXME : We still need to handle errors better than this */
			retval = default_val;
		}
		gconf_value_free (value);

		return retval;
	} else {
		return default_val;
	}
}

gboolean
panel_gconf_get_bool (const gchar *key, gboolean default_val) {
	GConfValue *value;
	GError *error = NULL;

	value = gconf_client_get (panel_gconf_get_client (), key, &error);
	
	if (value != NULL) {
		gboolean retval;

		g_assert (error == NULL);

		if (value->type == GCONF_VALUE_BOOL) {
			retval = gconf_value_get_bool (value);
		} else {
			/* FIXME : We still need to handle errors better than this */
			retval = default_val;
		}

		gconf_value_free (value);

		return retval;
	} else {
		return default_val;
	}
}

gchar * 
panel_gconf_get_string (const gchar *key, const gchar *default_val) {
	GConfValue *value;
	GError *error = NULL;

	value = gconf_client_get (panel_gconf_get_client (), key, &error);

	if (value != NULL) {
		gchar *retval;
	
		g_assert (error == NULL);

		if (value->type == GCONF_VALUE_STRING) {	
			retval = g_strdup (gconf_value_get_string (value));
		} else {
			/* FIXME : We still need to handle errors better than this */
			retval = g_strdup (default_val);
		}

		gconf_value_free (value);

		return retval;
	} else {
		return g_strdup (default_val);
	}
}

void 
panel_gconf_set_int (const gchar *key, gint value) {

	gconf_client_set_int (panel_gconf_get_client (), key, value, NULL);
			      
	return;
}

void 
panel_gconf_set_bool (const gchar *key, gboolean value) {

	gconf_client_set_bool (panel_gconf_get_client (), key, value, NULL);

	return;
}

void 
panel_gconf_set_string (const gchar *key, const gchar *value) {

	gconf_client_set_string (panel_gconf_get_client (), key, value, NULL);

	return;
}

guint 
panel_gconf_notify_add (const gchar *key, GConfClientNotifyFunc notify_func, gpointer user_data) {
	guint notify_id;
	notify_id = gconf_client_notify_add (panel_gconf_get_client (), 
					     key, 
					     notify_func, 
					     user_data, 
					     NULL, NULL);
	return notify_id;
}

static void
panel_notify_object_dead (guint notify_id)
{
	gconf_client_notify_remove (panel_gconf_get_client (),
				    notify_id);
}

guint
panel_gconf_notify_add_while_alive (const gchar *key, 
				    GConfClientNotifyFunc notify_func, 
				    GObject *alive_object)
{
	guint notify_id;

	g_return_val_if_fail (G_IS_OBJECT (alive_object), 0);

	notify_id = panel_gconf_notify_add (key, notify_func, alive_object);
	if (notify_id > 0) {
		/* Add a weak reference to the object so that we can
		 * remove the notification when the object's gone. */
		g_object_weak_ref (alive_object,
				   (GWeakNotify)panel_notify_object_dead,
				   GUINT_TO_POINTER (notify_id));
	}
	return notify_id;
}

void
panel_gconf_add_dir (const gchar *key) {
	gconf_client_add_dir (panel_gconf_get_client (),
			      key,
			      GCONF_CLIENT_PRELOAD_NONE,
			      NULL);
	return;
}

gboolean
panel_gconf_dir_exists (const gchar *key) {
	GError   *error = NULL;
	gboolean  retval = FALSE;

	g_return_val_if_fail (key != NULL, FALSE);
	
	retval = gconf_client_dir_exists (panel_gconf_get_client (), key, &error);
	if (error) {
		g_warning (G_STRLOC ": gconf error from dir_exists(): %s", error->message);
		g_error_free (error);
	}

	return retval;
}

char *
panel_gconf_objects_get_full_key (const gchar *profile,
				  const gchar *object_id,
				  const gchar *key,
				  gboolean     use_default)
{
	char *retval = NULL;

   	retval = use_default ? panel_gconf_objects_default_profile_get_full_key (profile, object_id, key) :
		panel_gconf_objects_profile_get_full_key (profile, object_id, key);

	return retval;
}

/* FIXME: cut and paste code from gconf - hopefully this will be public API for future releases */

void
panel_gconf_directory_recursive_clean (GConfClient *client, const gchar *dir) {
	GSList *subdirs;
	GSList *entries;
	GSList *tmp;

	subdirs = gconf_client_all_dirs (client, dir, NULL);

#ifdef PANEL_GCONF_DEBUG
	printf ("Recursive Clean for %s\n", dir);
#endif 

	if (subdirs != NULL) {
    		tmp = subdirs;

    		while (tmp != NULL) {
      			gchar *s = tmp->data;
      			panel_gconf_directory_recursive_clean (client, s);
      			g_free (s);
      			tmp = g_slist_next (tmp);
    		}

	    	g_slist_free (subdirs);
  	}
 
  	entries = gconf_client_all_entries (client, dir, NULL);

  	if (entries != NULL) {
    		tmp = entries;

    		while (tmp != NULL) {
 			GConfEntry *entry = tmp->data;

#ifdef PANEL_GCONF_DEBUG
			printf ("Unsetting %s\n", gconf_entry_get_key (entry));
#endif 
      			gconf_client_unset (client, gconf_entry_get_key (entry), NULL);
      			gconf_entry_free (entry);
      			tmp = g_slist_next (tmp);
    		}
    		
		g_slist_free (entries);
  	}

	gconf_client_unset (client, dir, NULL);
}

About Koders | Resources | Downloads | Support | Black Duck | Terms of Service | DMCA | Privacy Policy | Contact Us