Handle --get-defaults (do_restore_from_defaults): Implement

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

	* capplets/*/main.c (main): Handle --get-defaults
	(do_restore_from_defaults): Implement

	* capplets/*/preferences.c (preferences_init): Load default values
This commit is contained in:
Bradford Hovinen 2001-05-04 00:05:14 +00:00 committed by Bradford Hovinen (Gdict maintainer)
parent fc7487ef4f
commit a7fa858b61
13 changed files with 171 additions and 14 deletions

View file

@ -1,3 +1,10 @@
2001-05-03 Bradford Hovinen <hovinen@ximian.com>
* capplets/*/main.c (main): Handle --get-defaults
(do_restore_from_defaults): Implement
* capplets/*/preferences.c (preferences_init): Load default values
2001-04-27 Bradford Hovinen <hovinen@ximian.com>
* capplets/wm-properties/wm-list.c (wm_read_from_xml): Make

View file

@ -78,12 +78,22 @@ preferences_get_type (void)
static void
preferences_init (Preferences *prefs)
{
prefs->frozen = FALSE;
prefs->frozen = FALSE;
prefs->color1 = NULL;
prefs->color2 = NULL;
/* Load default values */
prefs->color1 = read_color_from_string ("#39374b");
prefs->color2 = read_color_from_string ("#42528f");
prefs->enabled = TRUE;
prefs->wallpaper_enabled = FALSE;
prefs->gradient_enabled = TRUE;
prefs->orientation = ORIENTATION_VERT;
prefs->wallpaper_type = WPTYPE_TILED;
prefs->wallpaper_filename = NULL;
prefs->wallpaper_sel_path = NULL;
prefs->wallpaper_sel_path = g_get_home_dir ();
prefs->auto_apply = TRUE;
prefs->wallpapers = NULL;
prefs->adjust_opacity = TRUE;
prefs->opacity = 255;
}
static void
@ -222,7 +232,7 @@ preferences_load (Preferences *prefs)
gnome_config_get_bool ("/Background/Default/autoApply=true");
if (!g_strcasecmp (prefs->wallpaper_filename, "(None)")) {
g_free(prefs->wallpaper_filename);
g_free (prefs->wallpaper_filename);
prefs->wallpaper_filename = NULL;
prefs->wallpaper_enabled = FALSE;
} else {
@ -245,7 +255,7 @@ preferences_load (Preferences *prefs)
prefs->adjust_opacity =
gnome_config_get_bool
("/Background/Default/adjustOpacity=true");
("/Background/Default/adjustOpacity=false");
prefs->opacity =
gnome_config_get_int ("/Background/Default/opacity=255");
@ -379,12 +389,12 @@ preferences_read_xml (xmlDocPtr xml_doc)
prefs->orientation = ORIENTATION_VERT;
if (prefs->color1) {
gdk_color_free (prefs->color1);
g_free (prefs->color1);
prefs->color1 = NULL;
}
if (prefs->color2) {
gdk_color_free (prefs->color2);
g_free (prefs->color2);
prefs->color2 = NULL;
}
@ -524,7 +534,7 @@ xml_read_bool (xmlNodePtr node)
text = xmlNodeGetContent (node);
if (!g_strcasecmp (text, "true"))
if (text != NULL && !g_strcasecmp (text, "true"))
return TRUE;
else
return FALSE;

View file

@ -151,6 +151,14 @@ do_set_xml (gboolean apply_settings)
return;
}
static void
do_restore_from_defaults (void)
{
prefs = PREFERENCES (preferences_new ());
preferences_save (prefs);
preferences_apply_now (prefs);
}
int
main (int argc, char **argv)
{
@ -178,6 +186,10 @@ main (int argc, char **argv)
do_set_xml (TRUE);
return 0;
}
else if (res == 5) {
do_restore_from_defaults ();
return 0;
}
client = gnome_master_client ();
flags = gnome_client_get_flags (client);

View file

@ -85,9 +85,33 @@ preferences_get_type (void)
static void
preferences_init (Preferences *prefs)
{
XKeyboardState kbdstate;
gint event_base_return, error_base_return;
XGetKeyboardControl (GDK_DISPLAY (), &kbdstate);
prefs->frozen = FALSE;
/* Code to initialize preferences object to defaults */
prefs->repeat = kbdstate.global_auto_repeat;
#ifdef HAVE_X11_EXTENSIONS_XF86MISC_H
if (XF86MiscQueryExtension (GDK_DISPLAY (),
&event_base_return,
&error_base_return) == True)
{
XF86MiscGetKbdSettings (GDK_DISPLAY (), &kbdsettings);
prefs->rate = kbdsettings.rate;
prefs->delay = kbdsettings.delay;
} else {
prefs->rate = 5;
prefs->delay = 500;
}
#else
/* FIXME: how to get the keyboard speed on non-xf86? */
prefs->rate = 5;
prefs->delay = 500;
#endif
}
static void

View file

@ -152,6 +152,14 @@ do_set_xml (gboolean apply_settings)
return;
}
static void
do_restore_from_defaults (void)
{
prefs = PREFERENCES (preferences_new ());
preferences_save (prefs);
preferences_apply_now (prefs);
}
int
main (int argc, char **argv)
{
@ -179,6 +187,10 @@ main (int argc, char **argv)
do_set_xml (TRUE);
return 0;
}
else if (res == 5) {
do_restore_from_defaults ();
return 0;
}
client = gnome_master_client ();
flags = gnome_client_get_flags (client);

View file

@ -86,9 +86,39 @@ preferences_get_type (void)
static void
preferences_init (Preferences *prefs)
{
unsigned char buttons[MAX_BUTTONS];
int acc_num, acc_den, thresh;
prefs->frozen = FALSE;
/* Code to initialize preferences object to defaults */
/* Load default values */
prefs->nbuttons = XGetPointerMapping (GDK_DISPLAY (), buttons,
MAX_BUTTONS);
g_assert (prefs->nbuttons <= MAX_BUTTONS);
XGetPointerControl (GDK_DISPLAY (), &acc_num, &acc_den, &thresh);
prefs->threshold = thresh;
if (acc_num != 1 && acc_den != 1) {
if (acc_num > acc_den) {
acc_num = (int) ((double) acc_num / acc_den);
acc_den = 1;
} else {
acc_den = (int) ((double) acc_den / acc_num);
acc_num = 1;
}
}
if (acc_num > MAX_ACCEL)
acc_num = MAX_ACCEL;
if (acc_den > MAX_ACCEL)
acc_den = MAX_ACCEL;
if (acc_den == 1)
prefs->acceleration = acc_num + MAX_ACCEL - 1;
else
prefs->acceleration = MAX_ACCEL - acc_den;
}
static void

View file

@ -1,3 +1,7 @@
2001-05-03 Bradford Hovinen <hovinen@ximian.com>
* preferences.c (preferences_new): Load default values
2001-04-27 Bradford Hovinen <hovinen@ximian.com>
* preferences.c (screensaver_read_xml): Make label an attribute of

View file

@ -264,6 +264,13 @@ do_set_xml (gboolean apply_settings)
return;
}
static void
do_restore_from_defaults (void)
{
prefs = preferences_new ();
preferences_save (prefs);
}
int
main (int argc, char **argv)
{
@ -290,6 +297,10 @@ main (int argc, char **argv)
do_set_xml (TRUE);
return 0;
}
else if (res == 5) {
do_restore_from_defaults ();
return 0;
}
client = gnome_master_client ();
flags = gnome_client_get_flags (client);

View file

@ -157,6 +157,15 @@ preferences_new (void)
prefs = g_new0 (Preferences, 1);
/* Load default values */
preferences_load_from_xrdb (prefs);
prefs->selection_mode = 3;
prefs->power_management = FALSE;
prefs->standby_time = 0;
prefs->suspend_time = 0;
prefs->power_down_time = 20;
return prefs;
}

View file

@ -150,6 +150,14 @@ do_set_xml (gboolean apply_settings)
return;
}
static void
do_restore_from_defaults (void)
{
prefs = PREFERENCES (preferences_new ());
preferences_save (prefs);
preferences_apply_now (prefs);
}
int
main (int argc, char **argv)
{
@ -180,6 +188,10 @@ main (int argc, char **argv)
do_set_xml (TRUE);
return 0;
}
else if (res == 5) {
do_restore_from_defaults ();
return 0;
}
client = gnome_master_client ();
flags = gnome_client_get_flags (client);

View file

@ -106,9 +106,21 @@ preferences_get_type (void)
static void
preferences_init (Preferences *prefs)
{
prefs->frozen = FALSE;
prefs->categories = g_tree_new ((GCompareFunc) strcmp);
prefs->cat_byfile = g_tree_new ((GCompareFunc) strcmp);
gchar *ctmp;
prefs->frozen = FALSE;
prefs->categories = g_tree_new ((GCompareFunc) strcmp);
prefs->cat_byfile = g_tree_new ((GCompareFunc) strcmp);
/* Load default values */
prefs->enable_esd = FALSE;
prefs->enable_sound_events = FALSE;
ctmp = gnome_config_file ("/sound/events");
if (ctmp != NULL) {
read_path (prefs, ctmp);
g_free (ctmp);
}
}
static void

View file

@ -149,6 +149,14 @@ do_set_xml (gboolean apply_settings)
return;
}
static void
do_restore_from_defaults (void)
{
prefs = PREFERENCES (preferences_new ());
preferences_save (prefs);
preferences_apply_now (prefs);
}
int
main (int argc, char **argv)
{
@ -176,6 +184,10 @@ main (int argc, char **argv)
do_set_xml (TRUE);
return 0;
}
else if (res == 5) {
do_restore_from_defaults ();
return 0;
}
client = gnome_master_client ();
flags = gnome_client_get_flags (client);

View file

@ -74,6 +74,8 @@ preferences_init (Preferences *prefs)
{
prefs->frozen = FALSE;
prefs->gnome_prefs = g_new0 (GnomePreferences, 1);
/* FIXME: Code to set default values */
}
static void