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
|
@ -1,5 +1,5 @@
|
|||
always_built_SUBDIRS = desktop-links \
|
||||
new-background-properties \
|
||||
new-background-properties new-screensaver-properties \
|
||||
theme-switcher new-sound-properties new-bell-properties \
|
||||
new-ui-properties url-properties gnome-edit-properties \
|
||||
session-properties wm-properties new-keyboard-properties \
|
||||
|
|
|
@ -48,15 +48,21 @@ static PrefsWidget *prefs_widget;
|
|||
static guint ok_handler_id;
|
||||
static guint cancel_handler_id;
|
||||
|
||||
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, "background-properties-capplet",
|
||||
xml_doc, STORE_MASK_PREVIOUS);
|
||||
|
@ -67,8 +73,11 @@ 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);
|
||||
}
|
||||
|
||||
gtk_signal_disconnect (GTK_OBJECT (prefs_widget), ok_handler_id);
|
||||
gtk_signal_disconnect (GTK_OBJECT (prefs_widget), cancel_handler_id);
|
||||
gtk_object_destroy (GTK_OBJECT (prefs_widget));
|
||||
|
@ -78,8 +87,11 @@ ok_cb (GtkWidget *widget)
|
|||
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);
|
||||
}
|
||||
|
||||
gtk_signal_disconnect (GTK_OBJECT (prefs_widget), ok_handler_id);
|
||||
gtk_signal_disconnect (GTK_OBJECT (prefs_widget), cancel_handler_id);
|
||||
gtk_object_destroy (GTK_OBJECT (prefs_widget));
|
||||
|
@ -118,17 +130,18 @@ do_get_xml (void)
|
|||
}
|
||||
|
||||
static void
|
||||
do_set_xml (void)
|
||||
do_set_xml (gboolean apply_settings)
|
||||
{
|
||||
Preferences *prefs;
|
||||
xmlDocPtr doc;
|
||||
char *buffer = NULL;
|
||||
int len = 0;
|
||||
int bytes_read;
|
||||
|
||||
while (!feof (stdin)) {
|
||||
if (!len) buffer = g_new (char, 16384);
|
||||
else buffer = g_renew (char, buffer, len + 16384);
|
||||
fread (buffer + len, 1, 16384, stdin);
|
||||
bytes_read = fread (buffer + len, 1, 16384, stdin);
|
||||
buffer[len + bytes_read] = '\0';
|
||||
len += 16384;
|
||||
}
|
||||
|
||||
|
@ -138,7 +151,9 @@ do_set_xml (void)
|
|||
|
||||
if (prefs) {
|
||||
preferences_save (prefs);
|
||||
preferences_apply_now (prefs);
|
||||
|
||||
if (apply_settings)
|
||||
preferences_apply_now (prefs);
|
||||
} else {
|
||||
g_warning ("Error while reading the screensaver config file");
|
||||
}
|
||||
|
@ -176,7 +191,7 @@ main (int argc, char **argv)
|
|||
return 0;
|
||||
}
|
||||
else if (res == 4) {
|
||||
do_set_xml ();
|
||||
do_set_xml (TRUE);
|
||||
return 0;
|
||||
}
|
||||
else if (res == 5) {
|
||||
|
@ -212,10 +227,22 @@ main (int argc, char **argv)
|
|||
gnome_window_icon_set_default_from_file
|
||||
(GNOME_ICONDIR"/gnome-ccbackground.png");
|
||||
|
||||
prefs = PREFERENCES (preferences_new ());
|
||||
preferences_load (prefs);
|
||||
archive = ARCHIVE (archive_load (FALSE));
|
||||
|
||||
if (token || res == 1) {
|
||||
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 || res == 1)) {
|
||||
preferences_apply_now (prefs);
|
||||
}
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
|
||||
#include <gnome.h>
|
||||
#include <gdk-pixbuf/gdk-pixbuf-xlibrgb.h>
|
||||
#include <capplet-widget.h>
|
||||
|
||||
#include "preferences.h"
|
||||
#include "applier.h"
|
||||
|
@ -307,15 +308,18 @@ preferences_save (Preferences *prefs)
|
|||
void
|
||||
preferences_changed (Preferences *prefs)
|
||||
{
|
||||
if (prefs->frozen) return;
|
||||
/* FIXME: This is a really horrible kludge... */
|
||||
if (prefs->frozen > 1) return;
|
||||
|
||||
if (prefs->timeout_id)
|
||||
gtk_timeout_remove (prefs->timeout_id);
|
||||
if (prefs->frozen == 0) {
|
||||
if (prefs->timeout_id)
|
||||
gtk_timeout_remove (prefs->timeout_id);
|
||||
|
||||
if (prefs->auto_apply)
|
||||
prefs->timeout_id =
|
||||
gtk_timeout_add (2000, (GtkFunction) apply_timeout_cb,
|
||||
prefs);
|
||||
if (prefs->auto_apply)
|
||||
prefs->timeout_id =
|
||||
gtk_timeout_add
|
||||
(2000, (GtkFunction) apply_timeout_cb, prefs);
|
||||
}
|
||||
|
||||
applier_apply_prefs (applier, prefs, FALSE, TRUE);
|
||||
}
|
||||
|
@ -346,13 +350,13 @@ preferences_apply_preview (Preferences *prefs)
|
|||
void
|
||||
preferences_freeze (Preferences *prefs)
|
||||
{
|
||||
prefs->frozen = TRUE;
|
||||
prefs->frozen++;
|
||||
}
|
||||
|
||||
void
|
||||
preferences_thaw (Preferences *prefs)
|
||||
{
|
||||
prefs->frozen = FALSE;
|
||||
if (prefs->frozen > 0) prefs->frozen--;
|
||||
}
|
||||
|
||||
Preferences *
|
||||
|
|
|
@ -48,7 +48,7 @@ struct _Preferences
|
|||
{
|
||||
GtkObject object;
|
||||
|
||||
gboolean frozen;
|
||||
gint frozen;
|
||||
gboolean auto_apply;
|
||||
guint timeout_id;
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -262,12 +262,12 @@ preferences_apply_now (Preferences *prefs)
|
|||
|
||||
void preferences_freeze (Preferences *prefs)
|
||||
{
|
||||
prefs->frozen = TRUE;
|
||||
prefs->frozen++;
|
||||
}
|
||||
|
||||
void preferences_thaw (Preferences *prefs)
|
||||
{
|
||||
prefs->frozen = FALSE;
|
||||
if (prefs->frozen > 0) prefs->frozen--;
|
||||
}
|
||||
|
||||
Preferences *
|
||||
|
|
|
@ -39,7 +39,7 @@ struct _Preferences
|
|||
{
|
||||
GtkObject object;
|
||||
|
||||
gboolean frozen;
|
||||
gint frozen;
|
||||
guint timeout_id;
|
||||
|
||||
gint rate;
|
||||
|
|
|
@ -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, "mouse-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-mouse.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);
|
||||
}
|
||||
|
||||
|
|
|
@ -277,12 +277,12 @@ preferences_apply_now (Preferences *prefs)
|
|||
|
||||
void preferences_freeze (Preferences *prefs)
|
||||
{
|
||||
prefs->frozen = TRUE;
|
||||
prefs->frozen++;
|
||||
}
|
||||
|
||||
void preferences_thaw (Preferences *prefs)
|
||||
{
|
||||
prefs->frozen = FALSE;
|
||||
if (prefs->frozen > 0) prefs->frozen--;
|
||||
}
|
||||
|
||||
Preferences *
|
||||
|
|
|
@ -39,7 +39,7 @@ struct _Preferences
|
|||
{
|
||||
GtkObject object;
|
||||
|
||||
gboolean frozen;
|
||||
gint frozen;
|
||||
guint timeout_id;
|
||||
|
||||
gboolean rtol;
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include <tree.h>
|
||||
#include <parser.h>
|
||||
#include <xmlIO.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <glade/glade.h>
|
||||
|
||||
|
@ -51,15 +52,21 @@ static PrefsWidget *prefs_widget;
|
|||
|
||||
static CappletWidget *capplet;
|
||||
|
||||
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, "screensaver-properties-capplet",
|
||||
xml_doc, STORE_MASK_PREVIOUS);
|
||||
|
@ -81,9 +88,11 @@ try_cb (GtkWidget *widget)
|
|||
|
||||
old_sm = prefs->selection_mode;
|
||||
|
||||
prefs_widget_store_prefs (prefs_widget, prefs);
|
||||
preferences_save (prefs);
|
||||
setup_dpms (prefs);
|
||||
if (!outside_location) {
|
||||
prefs_widget_store_prefs (prefs_widget, prefs);
|
||||
preferences_save (prefs);
|
||||
setup_dpms (prefs);
|
||||
}
|
||||
|
||||
if (old_sm == SM_DISABLE_SCREENSAVER &&
|
||||
prefs->selection_mode != SM_DISABLE_SCREENSAVER)
|
||||
|
@ -100,14 +109,17 @@ revert_cb (GtkWidget *widget)
|
|||
|
||||
old_sm = old_prefs->selection_mode;
|
||||
|
||||
preferences_save (old_prefs);
|
||||
preferences_destroy (prefs);
|
||||
if (!outside_location) {
|
||||
preferences_save (old_prefs);
|
||||
preferences_destroy (prefs);
|
||||
}
|
||||
|
||||
prefs = preferences_new ();
|
||||
preferences_load (prefs);
|
||||
|
||||
prefs->frozen = TRUE;
|
||||
prefs->frozen++;
|
||||
prefs_widget_get_prefs (prefs_widget, prefs);
|
||||
prefs->frozen = FALSE;
|
||||
prefs->frozen--;
|
||||
|
||||
setup_dpms (old_prefs);
|
||||
|
||||
|
@ -128,16 +140,17 @@ ok_cb (GtkWidget *widget)
|
|||
|
||||
close_preview ();
|
||||
|
||||
prefs_widget_store_prefs (prefs_widget, prefs);
|
||||
preferences_save (prefs);
|
||||
setup_dpms (prefs);
|
||||
|
||||
if (old_sm == SM_DISABLE_SCREENSAVER &&
|
||||
prefs->selection_mode != SM_DISABLE_SCREENSAVER)
|
||||
start_xscreensaver ();
|
||||
else if (old_sm != SM_DISABLE_SCREENSAVER &&
|
||||
prefs->selection_mode == SM_DISABLE_SCREENSAVER)
|
||||
stop_xscreensaver ();
|
||||
if (!outside_location) {
|
||||
prefs_widget_store_prefs (prefs_widget, prefs);
|
||||
preferences_save (prefs);
|
||||
setup_dpms (prefs);
|
||||
if (old_sm == SM_DISABLE_SCREENSAVER &&
|
||||
prefs->selection_mode != SM_DISABLE_SCREENSAVER)
|
||||
start_xscreensaver ();
|
||||
else if (old_sm != SM_DISABLE_SCREENSAVER &&
|
||||
prefs->selection_mode == SM_DISABLE_SCREENSAVER)
|
||||
stop_xscreensaver ();
|
||||
}
|
||||
|
||||
store_archive_data ();
|
||||
}
|
||||
|
@ -151,15 +164,17 @@ cancel_cb (GtkWidget *widget)
|
|||
|
||||
close_preview ();
|
||||
|
||||
preferences_save (old_prefs);
|
||||
setup_dpms (old_prefs);
|
||||
if (!outside_location) {
|
||||
preferences_save (old_prefs);
|
||||
setup_dpms (old_prefs);
|
||||
|
||||
if (old_sm == SM_DISABLE_SCREENSAVER &&
|
||||
prefs->selection_mode != SM_DISABLE_SCREENSAVER)
|
||||
start_xscreensaver ();
|
||||
else if (old_sm != SM_DISABLE_SCREENSAVER &&
|
||||
prefs->selection_mode == SM_DISABLE_SCREENSAVER)
|
||||
stop_xscreensaver ();
|
||||
if (old_sm == SM_DISABLE_SCREENSAVER &&
|
||||
prefs->selection_mode != SM_DISABLE_SCREENSAVER)
|
||||
start_xscreensaver ();
|
||||
else if (old_sm != SM_DISABLE_SCREENSAVER &&
|
||||
prefs->selection_mode == SM_DISABLE_SCREENSAVER)
|
||||
stop_xscreensaver ();
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -183,7 +198,7 @@ setup_capplet_widget (void)
|
|||
gtk_signal_connect (GTK_OBJECT (capplet), "cancel",
|
||||
GTK_SIGNAL_FUNC (cancel_cb), NULL);
|
||||
|
||||
prefs->frozen = TRUE;
|
||||
prefs->frozen++;
|
||||
|
||||
prefs_widget = PREFS_WIDGET (prefs_widget_new ());
|
||||
|
||||
|
@ -200,7 +215,7 @@ setup_capplet_widget (void)
|
|||
|
||||
gtk_widget_show_all (GTK_WIDGET (capplet));
|
||||
|
||||
prefs->frozen = FALSE;
|
||||
prefs->frozen--;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -217,7 +232,7 @@ do_get_xml (void)
|
|||
}
|
||||
|
||||
static void
|
||||
do_set_xml (void)
|
||||
do_set_xml (gboolean apply_settings)
|
||||
{
|
||||
xmlDocPtr doc;
|
||||
Preferences *old_prefs, *new_prefs;
|
||||
|
@ -240,7 +255,11 @@ do_set_xml (void)
|
|||
|
||||
if (new_prefs) {
|
||||
new_prefs->config_db = old_prefs->config_db;
|
||||
preferences_save (new_prefs);
|
||||
|
||||
if (apply_settings)
|
||||
preferences_save (new_prefs);
|
||||
else
|
||||
prefs = new_prefs;
|
||||
} else {
|
||||
g_warning ("Error while reading the screensaver config file");
|
||||
}
|
||||
|
@ -269,7 +288,7 @@ main (int argc, char **argv)
|
|||
return 0;
|
||||
}
|
||||
else if (res == 4) {
|
||||
do_set_xml ();
|
||||
do_set_xml (TRUE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -302,16 +321,30 @@ main (int argc, char **argv)
|
|||
(GNOME_ICONDIR"/gnome-ccscreensaver.png");
|
||||
|
||||
init_resource_database (argc, argv);
|
||||
prefs = 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);
|
||||
prefs->frozen++;
|
||||
} else {
|
||||
outside_location = FALSE;
|
||||
prefs = preferences_new ();
|
||||
preferences_load (prefs);
|
||||
}
|
||||
|
||||
if (!outside_location && token) {
|
||||
if (prefs->selection_mode != SM_DISABLE_SCREENSAVER)
|
||||
start_xscreensaver ();
|
||||
setup_dpms (prefs);
|
||||
}
|
||||
|
||||
if (!res) {
|
||||
old_prefs = preferences_new (); preferences_load (old_prefs);
|
||||
old_prefs = preferences_new ();
|
||||
preferences_load (old_prefs);
|
||||
setup_capplet_widget ();
|
||||
|
||||
capplet_gtk_main ();
|
||||
|
|
|
@ -80,7 +80,7 @@ struct _Preferences
|
|||
|
||||
GList *screensavers;
|
||||
|
||||
gboolean frozen; /* TRUE if we shouldn't reflect
|
||||
gint frozen; /* TRUE if we shouldn't reflect
|
||||
* preference changes in capplet */
|
||||
GTree *config_db; /* key-value database of config options */
|
||||
|
||||
|
|
|
@ -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, "sound-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");
|
||||
}
|
||||
|
||||
|
@ -158,7 +168,7 @@ main (int argc, char **argv)
|
|||
return 0;
|
||||
}
|
||||
else if (res == 4) {
|
||||
do_set_xml ();
|
||||
do_set_xml (TRUE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -190,10 +200,22 @@ main (int argc, char **argv)
|
|||
gnome_window_icon_set_default_from_file
|
||||
(GNOME_ICONDIR"/~icon~");
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -298,7 +298,7 @@ preferences_freeze (Preferences *prefs)
|
|||
g_return_if_fail (prefs != NULL);
|
||||
g_return_if_fail (IS_PREFERENCES (prefs));
|
||||
|
||||
prefs->frozen = TRUE;
|
||||
prefs->frozen++;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -307,7 +307,7 @@ preferences_thaw (Preferences *prefs)
|
|||
g_return_if_fail (prefs != NULL);
|
||||
g_return_if_fail (IS_PREFERENCES (prefs));
|
||||
|
||||
prefs->frozen = FALSE;
|
||||
if (prefs->frozen > 0) prefs->frozen--;
|
||||
}
|
||||
|
||||
Preferences *
|
||||
|
|
|
@ -65,7 +65,7 @@ struct _Preferences
|
|||
{
|
||||
GtkObject object;
|
||||
|
||||
gboolean frozen;
|
||||
gint frozen;
|
||||
guint timeout_id;
|
||||
|
||||
gboolean enable_esd;
|
||||
|
|
|
@ -48,15 +48,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, "ui-properties-capplet",
|
||||
xml_doc, STORE_MASK_PREVIOUS);
|
||||
|
@ -67,14 +73,17 @@ store_archive_data (void)
|
|||
static void
|
||||
ok_cb (GtkWidget *widget)
|
||||
{
|
||||
preferences_save (prefs);
|
||||
if (!outside_location)
|
||||
preferences_save (prefs);
|
||||
|
||||
store_archive_data ();
|
||||
}
|
||||
|
||||
static void
|
||||
cancel_cb (GtkWidget *widget)
|
||||
{
|
||||
preferences_save (old_prefs);
|
||||
if (!outside_location)
|
||||
preferences_save (old_prefs);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -108,9 +117,8 @@ do_get_xml (void)
|
|||
}
|
||||
|
||||
static void
|
||||
do_set_xml (void)
|
||||
do_set_xml (gboolean apply_settings)
|
||||
{
|
||||
Preferences *prefs;
|
||||
xmlDocPtr doc;
|
||||
char *buffer = NULL;
|
||||
int len = 0;
|
||||
|
@ -126,9 +134,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");
|
||||
}
|
||||
|
||||
|
@ -156,7 +164,7 @@ main (int argc, char **argv)
|
|||
return 0;
|
||||
}
|
||||
else if (res == 4) {
|
||||
do_set_xml ();
|
||||
do_set_xml (TRUE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -187,10 +195,22 @@ main (int argc, char **argv)
|
|||
|
||||
gnome_window_icon_set_default_from_file (GNOME_ICONDIR"/gnome-applications.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);
|
||||
}
|
||||
|
||||
|
|
|
@ -188,7 +188,7 @@ preferences_freeze (Preferences *prefs)
|
|||
g_return_if_fail (prefs != NULL);
|
||||
g_return_if_fail (IS_PREFERENCES (prefs));
|
||||
|
||||
prefs->frozen = TRUE;
|
||||
prefs->frozen++;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -197,7 +197,7 @@ preferences_thaw (Preferences *prefs)
|
|||
g_return_if_fail (prefs != NULL);
|
||||
g_return_if_fail (IS_PREFERENCES (prefs));
|
||||
|
||||
prefs->frozen = FALSE;
|
||||
if (prefs->frozen > 0) prefs->frozen--;
|
||||
}
|
||||
|
||||
Preferences *
|
||||
|
|
|
@ -40,7 +40,7 @@ struct _Preferences
|
|||
{
|
||||
GtkObject object;
|
||||
|
||||
gboolean frozen;
|
||||
gint frozen;
|
||||
guint timeout_id;
|
||||
|
||||
GnomePreferences *gnome_prefs;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue