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:
Bradford Hovinen 2001-04-25 01:00:46 +00:00 committed by Bradford Hovinen (Gdict maintainer)
parent b38b466dc0
commit 9bf1996a30
18 changed files with 283 additions and 133 deletions

View file

@ -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);
}

View file

@ -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 *

View file

@ -48,7 +48,7 @@ struct _Preferences
{
GtkObject object;
gboolean frozen;
gint frozen;
gboolean auto_apply;
guint timeout_id;