Commit 6fb797ca authored by Bradford Hovinen's avatar Bradford Hovinen Committed by Bradford Hovinen (Gdict maintainer)
Browse files

Implement. Create a copy of a preferences structure (clone_cb): Implement

2001-05-06  Bradford Hovinen  <hovinen@ximian.com>

	* preferences.c (preferences_clone): Implement. Create a copy of a
	preferences structure
	(clone_cb): Implement
	(read_prefs_from_db): Parse screensavers from a copy of the string
	so that we don't overwrite the original

	* main.c (main): Call preferences_clone instead of reloading old
	preferences
parent 7bfddd30
2001-05-06 Bradford Hovinen <hovinen@ximian.com>
* preferences.c (preferences_clone): Implement. Create a copy of a
preferences structure
(clone_cb): Implement
(read_prefs_from_db): Parse screensavers from a copy of the string
so that we don't overwrite the original
* main.c (main): Call preferences_clone instead of reloading old
preferences
2001-05-05 Bradford Hovinen <hovinen@ximian.com>
* prefs-widget.c (one_screensaver_cb): Fix segv
......
......@@ -400,8 +400,7 @@ main (int argc, char **argv)
#endif /* HAVE_XIMIAN_ARCHIVER */
if (!res) {
old_prefs = preferences_new ();
preferences_load (old_prefs);
old_prefs = preferences_clone (prefs);
setup_capplet_widget ();
capplet_gtk_main ();
......
......@@ -59,7 +59,7 @@ remove_entry (GTree *config_db, gchar *entry)
static void
read_prefs_from_db (Preferences *prefs)
{
gchar *value;
gchar *value, *tmp;
value = g_tree_lookup (prefs->config_db, "verbose");
if (value) prefs->verbose = parse_boolean_resource (value);
......@@ -95,7 +95,12 @@ read_prefs_from_db (Preferences *prefs)
if (value) prefs->cycle = parse_minutes_resource (value);
value = g_tree_lookup (prefs->config_db, "programs");
if (value) prefs->screensavers = parse_screensaver_list (value);
if (value) {
tmp = g_strdup (value);
prefs->screensavers = parse_screensaver_list (tmp);
g_free (tmp);
}
}
static void
......@@ -169,6 +174,38 @@ preferences_new (void)
return prefs;
}
static gint
clone_cb (gchar *key, gchar *value, Preferences *new_prefs)
{
if (!strcmp (key, "programs"))
g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "Programs value is:\n%s", value);
g_tree_insert (new_prefs->config_db, key, g_strdup (value));
return 0;
}
Preferences *
preferences_clone (Preferences *prefs)
{
Preferences *new_prefs;
new_prefs = g_new0 (Preferences, 1);
new_prefs->config_db = g_tree_new ((GCompareFunc) strcmp);
new_prefs->selection_mode = prefs->selection_mode;
new_prefs->power_management = prefs->power_management;
new_prefs->standby_time = prefs->standby_time;
new_prefs->suspend_time = prefs->suspend_time;
new_prefs->power_down_time = prefs->power_down_time;
g_tree_traverse (prefs->config_db, (GTraverseFunc) clone_cb,
G_IN_ORDER, new_prefs);
read_prefs_from_db (new_prefs);
return new_prefs;
}
void
preferences_destroy (Preferences *prefs)
{
......
......@@ -95,6 +95,7 @@ struct _Preferences
typedef struct _Preferences Preferences;
Preferences *preferences_new (void);
Preferences *preferences_clone (Preferences *prefs);
void preferences_destroy (Preferences *prefs);
void preferences_load (Preferences *prefs);
......
/*
* Translatable strings file generated by extract-labels
* Add this file to your project's POTFILES.in.
* DO NOT compile it as part of your application.
*/
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment