Support --location
2001-04-24 Bradford Hovinen <hovinen@ximian.com> * capplets/*/main.c: * capplets/*/preferences.c: Support --location * capplets/Makefile.am: Compile in screensaver properties
This commit is contained in:
parent
b38b466dc0
commit
9bf1996a30
18 changed files with 283 additions and 133 deletions
|
@ -45,15 +45,21 @@ static Preferences *prefs;
|
|||
static Preferences *old_prefs;
|
||||
static PrefsWidget *prefs_widget;
|
||||
|
||||
static Archive *archive;
|
||||
static gboolean outside_location;
|
||||
|
||||
static void
|
||||
store_archive_data (void)
|
||||
{
|
||||
Archive *archive;
|
||||
Location *location;
|
||||
xmlDocPtr xml_doc;
|
||||
|
||||
archive = ARCHIVE (archive_load (FALSE));
|
||||
location = archive_get_current_location (archive);
|
||||
if (capplet_get_location () == NULL)
|
||||
location = archive_get_current_location (archive);
|
||||
else
|
||||
location = archive_get_location (archive,
|
||||
capplet_get_location ());
|
||||
|
||||
xml_doc = preferences_write_xml (prefs);
|
||||
location_store_xml (location, "keyboard-properties-capplet",
|
||||
xml_doc, STORE_MASK_PREVIOUS);
|
||||
|
@ -64,16 +70,21 @@ store_archive_data (void)
|
|||
static void
|
||||
ok_cb (GtkWidget *widget)
|
||||
{
|
||||
preferences_save (prefs);
|
||||
preferences_apply_now (prefs);
|
||||
if (!outside_location) {
|
||||
preferences_save (prefs);
|
||||
preferences_apply_now (prefs);
|
||||
}
|
||||
|
||||
store_archive_data ();
|
||||
}
|
||||
|
||||
static void
|
||||
cancel_cb (GtkWidget *widget)
|
||||
{
|
||||
preferences_save (old_prefs);
|
||||
preferences_apply_now (old_prefs);
|
||||
if (!outside_location) {
|
||||
preferences_save (old_prefs);
|
||||
preferences_apply_now (old_prefs);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -107,9 +118,8 @@ do_get_xml (void)
|
|||
}
|
||||
|
||||
static void
|
||||
do_set_xml (void)
|
||||
do_set_xml (gboolean apply_settings)
|
||||
{
|
||||
Preferences *prefs;
|
||||
xmlDocPtr doc;
|
||||
char *buffer;
|
||||
int len = 0;
|
||||
|
@ -125,9 +135,9 @@ do_set_xml (void)
|
|||
|
||||
prefs = preferences_read_xml (doc);
|
||||
|
||||
if (prefs)
|
||||
if (prefs && apply_settings)
|
||||
preferences_save (prefs);
|
||||
else
|
||||
else if (prefs == NULL)
|
||||
g_warning ("Error while reading the screensaver config file");
|
||||
}
|
||||
|
||||
|
@ -155,7 +165,7 @@ main (int argc, char **argv)
|
|||
return 0;
|
||||
}
|
||||
else if (res == 4) {
|
||||
do_set_xml ();
|
||||
do_set_xml (TRUE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -187,10 +197,22 @@ main (int argc, char **argv)
|
|||
gnome_window_icon_set_default_from_file
|
||||
(GNOME_ICONDIR"/gnome-cckeyboard.png");
|
||||
|
||||
prefs = PREFERENCES (preferences_new ());
|
||||
preferences_load (prefs);
|
||||
archive = ARCHIVE (archive_load (FALSE));
|
||||
|
||||
if (token) {
|
||||
if (capplet_get_location () != NULL &&
|
||||
strcmp (capplet_get_location (),
|
||||
archive_get_current_location_id (archive)))
|
||||
{
|
||||
outside_location = TRUE;
|
||||
do_set_xml (FALSE);
|
||||
preferences_freeze (prefs);
|
||||
} else {
|
||||
outside_location = FALSE;
|
||||
prefs = PREFERENCES (preferences_new ());
|
||||
preferences_load (prefs);
|
||||
}
|
||||
|
||||
if (!outside_location && token) {
|
||||
preferences_apply_now (prefs);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue