summaryrefslogtreecommitdiff
path: root/libbackground
diff options
context:
space:
mode:
authorRachel Hestilow <hestgray@src.gnome.org>2002-02-11 04:13:39 +0000
committerRachel Hestilow <hestgray@src.gnome.org>2002-02-11 04:13:39 +0000
commit42c170078bddadd4a888c8fb91dde25d0bdec3d7 (patch)
tree687759afaae490dedb823719b5c4c31f6e15441a /libbackground
parent8062a0559330d4f8795185c4497618254e2dee84 (diff)
downloadgnome-control-center-42c170078bddadd4a888c8fb91dde25d0bdec3d7.tar.gz
Reverting changes back to hovinen's pre-seth-ui setup.
Diffstat (limited to 'libbackground')
-rw-r--r--libbackground/applier.c116
-rw-r--r--libbackground/preferences.c101
-rw-r--r--libbackground/preferences.h15
3 files changed, 103 insertions, 129 deletions
diff --git a/libbackground/applier.c b/libbackground/applier.c
index 794d33bb3..04967e955 100644
--- a/libbackground/applier.c
+++ b/libbackground/applier.c
@@ -42,10 +42,10 @@
#include "applier.h"
-#define MONITOR_CONTENTS_X 0
-#define MONITOR_CONTENTS_Y 0
-#define MONITOR_CONTENTS_WIDTH 51
-#define MONITOR_CONTENTS_HEIGHT 38
+#define MONITOR_CONTENTS_X 20
+#define MONITOR_CONTENTS_Y 10
+#define MONITOR_CONTENTS_WIDTH 157
+#define MONITOR_CONTENTS_HEIGHT 111
enum {
PROP_0,
@@ -390,27 +390,21 @@ bg_applier_apply_prefs (BGApplier *bg_applier,
bg_applier->p->wallpaper_pixbuf = NULL;
if (new_prefs->wallpaper_enabled) {
- if (new_prefs->wallpaper_filename == NULL) {
- new_prefs->wallpaper_enabled = FALSE;
- } else {
- g_return_if_fail (new_prefs->wallpaper_filename != NULL);
-
- bg_applier->p->wallpaper_pixbuf =
- gdk_pixbuf_new_from_file (new_prefs->wallpaper_filename, NULL);
-
- if (bg_applier->p->wallpaper_pixbuf == NULL) {
- g_warning (_("Could not load pixbuf \"%s\"; disabling wallpaper."),
- new_prefs->wallpaper_filename);
- new_prefs->wallpaper_enabled = FALSE;
-
- }
- else
- {
- if (bg_applier->p->timeout)
- g_source_remove (bg_applier->p->timeout);
- bg_applier->p->timeout = g_timeout_add (30000, (GSourceFunc) cleanup_cb, bg_applier);
+ g_return_if_fail (new_prefs->wallpaper_filename != NULL);
+
+ bg_applier->p->wallpaper_pixbuf =
+ gdk_pixbuf_new_from_file (new_prefs->wallpaper_filename, NULL);
- }
+ if (bg_applier->p->wallpaper_pixbuf == NULL) {
+ g_warning (_("Could not load pixbuf \"%s\"; disabling wallpaper."),
+ new_prefs->wallpaper_filename);
+ new_prefs->wallpaper_enabled = FALSE;
+ }
+ else
+ {
+ if (bg_applier->p->timeout)
+ g_source_remove (bg_applier->p->timeout);
+ bg_applier->p->timeout = g_timeout_add (30000, (GSourceFunc) cleanup_cb, bg_applier);
}
}
}
@@ -443,15 +437,68 @@ bg_applier_render_color_p (const BGApplier *bg_applier, const BGPreferences *pre
GtkWidget *
bg_applier_get_preview_widget (BGApplier *bg_applier)
{
- if (bg_applier->p->preview_widget == NULL) {
- GdkPixmap *pixmap;
+ GdkPixbuf *pixbuf;
+ GdkPixmap *pixmap;
+ GdkBitmap *mask;
+ GdkVisual *visual;
+ GdkColormap *colormap;
+ gchar *filename;
+ GdkGC *gc;
+
+ g_return_val_if_fail (bg_applier != NULL, NULL);
+ g_return_val_if_fail (IS_BG_APPLIER (bg_applier), NULL);
+
+ if (bg_applier->p->type != BG_APPLIER_PREVIEW)
+ return NULL;
+
+ if (bg_applier->p->preview_widget != NULL)
+ return bg_applier->p->preview_widget;
- /* fixme: What to do here? gdk does not export root_parent publicly (Lauris) */
- pixmap = gdk_pixmap_new (GDK_ROOT_PARENT(), 51, 38, -1);
- bg_applier->p->preview_widget = gtk_image_new_from_pixmap (pixmap, NULL);
- }
+ filename = gnome_pixmap_file ("monitor.png");
+ visual = gdk_window_get_visual (GDK_ROOT_PARENT ());
+ colormap = gdk_window_get_colormap (GDK_ROOT_PARENT ());
- return bg_applier->p->preview_widget;
+ gtk_widget_push_visual (visual);
+ gtk_widget_push_colormap (colormap);
+
+ pixbuf = gdk_pixbuf_new_from_file (filename, NULL);
+
+ if (pixbuf == NULL) return NULL;
+
+ pixmap = gdk_pixmap_new (GDK_ROOT_PARENT (),
+ gdk_pixbuf_get_width (pixbuf),
+ gdk_pixbuf_get_height (pixbuf),
+ visual->depth);
+ mask = gdk_pixmap_new (GDK_ROOT_PARENT (),
+ gdk_pixbuf_get_width (pixbuf),
+ gdk_pixbuf_get_height (pixbuf),
+ 1);
+
+ gc = gdk_gc_new (GDK_ROOT_PARENT ());
+
+ gdk_pixbuf_render_threshold_alpha (pixbuf, mask,
+ 0, 0, 0, 0,
+ gdk_pixbuf_get_width (pixbuf),
+ gdk_pixbuf_get_height (pixbuf),
+ 1);
+
+ gdk_gc_set_clip_mask (gc, mask);
+
+ gdk_pixbuf_render_to_drawable (pixbuf, pixmap, gc,
+ 0, 0, 0, 0,
+ gdk_pixbuf_get_width (pixbuf),
+ gdk_pixbuf_get_height (pixbuf),
+ GDK_RGB_DITHER_MAX, 0, 0);
+
+ bg_applier->p->preview_widget = gtk_pixmap_new (pixmap, mask);
+ gtk_widget_show (bg_applier->p->preview_widget);
+ g_object_unref (G_OBJECT (pixbuf));
+ g_free (filename);
+
+ gtk_widget_pop_visual ();
+ gtk_widget_pop_colormap ();
+
+ return bg_applier->p->preview_widget;
}
GdkPixbuf *
@@ -474,8 +521,6 @@ draw_disabled_message (GtkWidget *widget)
gint x, y, w, h;
const char *disabled_string = _("Disabled");
- printf ("disabled\n");
-
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_IMAGE (widget));
@@ -806,8 +851,7 @@ create_pixmap (BGApplier *bg_applier, const BGPreferences *prefs)
if (!GTK_WIDGET_REALIZED (bg_applier->p->preview_widget))
gtk_widget_realize (bg_applier->p->preview_widget);
- g_assert (gtk_image_get_storage_type (GTK_IMAGE(bg_applier->p->preview_widget)) == GTK_IMAGE_PIXMAP);
- gtk_image_get_pixmap (GTK_IMAGE (bg_applier->p->preview_widget), &bg_applier->p->pixmap, NULL);
+ bg_applier->p->pixmap = GTK_PIXMAP (bg_applier->p->preview_widget)->pixmap;
bg_applier->p->pixmap_is_set = TRUE;
break;
}
@@ -918,8 +962,6 @@ get_geometry (wallpaper_type_t wallpaper_type,
src_geom->width = pwidth;
src_geom->height = pheight;
break;
- case WPTYPE_EMBOSSED:
- g_warning ("Embossing is not yet supported");
default:
g_error ("Bad wallpaper type");
break;
diff --git a/libbackground/preferences.c b/libbackground/preferences.c
index 90f6f7665..ddf377bf4 100644
--- a/libbackground/preferences.c
+++ b/libbackground/preferences.c
@@ -41,8 +41,6 @@ static void bg_preferences_class_init (BGPreferencesClass *class);
static void bg_preferences_finalize (GObject *object);
static GdkColor *read_color_from_string (const gchar *string);
-static orientation_t read_orientation_from_string (gchar *string);
-static wallpaper_type_t read_wptype_from_string (gchar *string);
GType
bg_preferences_get_type (void)
@@ -175,30 +173,22 @@ bg_preferences_load (BGPreferences *prefs)
client = gconf_client_get_default ();
- prefs->enabled = gconf_client_get_bool (client, BG_PREFERENCES_DRAW_BACKGROUND, &error);
- prefs->wallpaper_filename = gconf_client_get_string (client, BG_PREFERENCES_PICTURE_FILENAME, &error);
-
- prefs->color1 = read_color_from_string (gconf_client_get_string (client, BG_PREFERENCES_PRIMARY_COLOR, &error));
- prefs->color2 = read_color_from_string (gconf_client_get_string (client, BG_PREFERENCES_SECONDARY_COLOR, &error));
-
- prefs->opacity = gconf_client_get_int (client, BG_PREFERENCES_PICTURE_OPACITY, &error);
+ prefs->enabled = gconf_client_get_bool (client, "/desktop/gnome/background/enabled", &error);
+ prefs->wallpaper_type = gconf_client_get_int (client, "/desktop/gnome/background/wallpaper-type", &error);
+ prefs->wallpaper_filename = gconf_client_get_string (client, "/desktop/gnome/background/wallpaper-filename", &error);
+ prefs->wallpaper_enabled = gconf_client_get_bool (client, "/desktop/gnome/background/wallpaper-enabled", &error);
+ prefs->color1 = read_color_from_string (gconf_client_get_string (client, "/desktop/gnome/background/color1", &error));
+ prefs->color2 = read_color_from_string (gconf_client_get_string (client, "/desktop/gnome/background/color2", &error));
+ prefs->opacity = gconf_client_get_int (client, "/desktop/gnome/background/opacity", &error);
if (prefs->opacity >= 100 || prefs->opacity < 0)
prefs->adjust_opacity = FALSE;
- prefs->orientation = read_orientation_from_string (gconf_client_get_string (client, BG_PREFERENCES_COLOR_SHADING_TYPE, &error));
+ prefs->orientation = gconf_client_get_int (client, "/desktop/gnome/background/orientation", &error);
+
if (prefs->orientation == ORIENTATION_SOLID)
prefs->gradient_enabled = FALSE;
else
prefs->gradient_enabled = TRUE;
-
- prefs->wallpaper_type = read_wptype_from_string (gconf_client_get_string (client, BG_PREFERENCES_PICTURE_OPTIONS, &error));
-
- if (prefs->wallpaper_type == -1) {
- prefs->wallpaper_enabled = FALSE;
- prefs->wallpaper_type = WPTYPE_CENTERED;
- } else {
- prefs->wallpaper_enabled = TRUE;
- }
}
/* Parse the event name given (the event being notification of a property having
@@ -215,17 +205,10 @@ bg_preferences_merge_entry (BGPreferences *prefs,
g_return_if_fail (prefs != NULL);
g_return_if_fail (IS_BG_PREFERENCES (prefs));
- if (!strcmp (entry->key, BG_PREFERENCES_PICTURE_OPTIONS)) {
- prefs->wallpaper_type = read_wptype_from_string (g_strdup (gconf_value_get_string (value)));
- if (prefs->wallpaper_type == -1) {
- prefs->wallpaper_enabled = FALSE;
- prefs->wallpaper_type = WPTYPE_CENTERED;
- } else {
- prefs->wallpaper_enabled = TRUE;
- }
-
+ if (!strcmp (entry->key, "/desktop/gnome/background/wallpaper_type")) {
+ prefs->wallpaper_type = gconf_value_get_int (value);
}
- else if (!strcmp (entry->key, BG_PREFERENCES_PICTURE_FILENAME)) {
+ else if (!strcmp (entry->key, "/desktop/gnome/background/wallpaper-filename")) {
prefs->wallpaper_filename = g_strdup (gconf_value_get_string (value));
if (prefs->wallpaper_filename != NULL &&
@@ -235,27 +218,27 @@ bg_preferences_merge_entry (BGPreferences *prefs,
else
prefs->wallpaper_enabled = FALSE;
}
- else if (!strcmp (entry->key, BG_PREFERENCES_PRIMARY_COLOR)) {
+ else if (!strcmp (entry->key, "/desktop/gnome/background/color1")) {
prefs->color1 = read_color_from_string (gconf_value_get_string (value));
}
- else if (!strcmp (entry->key, BG_PREFERENCES_SECONDARY_COLOR)) {
+ else if (!strcmp (entry->key, "/desktop/gnome/background/color2")) {
prefs->color2 = read_color_from_string (gconf_value_get_string (value));
}
- else if (!strcmp (entry->key, BG_PREFERENCES_PICTURE_OPACITY)) {
+ else if (!strcmp (entry->key, "/desktop/gnome/background/opacity")) {
prefs->opacity = gconf_value_get_int (value);
if (prefs->opacity >= 100)
prefs->adjust_opacity = FALSE;
}
- else if (!strcmp (entry->key, BG_PREFERENCES_COLOR_SHADING_TYPE)) {
- prefs->orientation = read_orientation_from_string (g_strdup (gconf_value_get_string (value)));
+ else if (!strcmp (entry->key, "/desktop/gnome/background/orientation")) {
+ prefs->orientation = gconf_value_get_int (value);
if (prefs->orientation == ORIENTATION_SOLID)
prefs->gradient_enabled = FALSE;
else
prefs->gradient_enabled = TRUE;
}
- else if (!strcmp (entry->key, BG_PREFERENCES_DRAW_BACKGROUND)) {
+ else if (!strcmp (entry->key, "/desktop/gnome/background/wallpaper-enabled")) {
if (gconf_value_get_bool (value) &&
(prefs->wallpaper_filename != NULL) &&
strcmp (prefs->wallpaper_filename, "") != 0 &&
@@ -263,49 +246,12 @@ bg_preferences_merge_entry (BGPreferences *prefs,
prefs->wallpaper_enabled = TRUE;
else
prefs->wallpaper_enabled = FALSE;
- } else {
- g_warning ("%s: Unknown property: %s", __FUNCTION__, entry->key);
- }
-}
-
-static wallpaper_type_t
-read_wptype_from_string (gchar *string)
-{
- wallpaper_type_t type = -1;
-
- if (string) {
- if (!strncmp (string, "wallpaper", sizeof ("wallpaper"))) {
- type = WPTYPE_TILED;
- } else if (!strncmp (string, "centered", sizeof ("centered"))) {
- type = WPTYPE_CENTERED;
- } else if (!strncmp (string, "scaled", sizeof ("scaled"))) {
- type = WPTYPE_SCALED;
- } else if (!strncmp (string, "stretched", sizeof ("stretched"))) {
- type = WPTYPE_STRETCHED;
- } else if (!strncmp (string, "embossed", sizeof ("embossed"))) {
- type = WPTYPE_EMBOSSED;
- }
- g_free (string);
}
-
- return type;
-}
-
-static orientation_t
-read_orientation_from_string (gchar *string)
-{
- orientation_t type = ORIENTATION_SOLID;
-
- if (string) {
- if (!strncmp (string, "vertical-gradient", sizeof ("vertical-gradient"))) {
- type = ORIENTATION_VERT;
- } else if (!strncmp (string, "horizontal-gradient", sizeof ("horizontal-gradient"))) {
- type = ORIENTATION_HORIZ;
- }
- g_free (string);
+ else if (!strcmp (entry->key, "/desktop/gnome/background/wallpaper-type")) {
+ prefs->wallpaper_type = gconf_value_get_int (value);
+ } else {
+ g_warning ("%s: Unknown property: %s", G_GNUC_FUNCTION, entry->key);
}
-
- return type;
}
static GdkColor *
@@ -321,10 +267,7 @@ read_color_from_string (const gchar *string)
rgb = ((color->red >> 8) << 16) ||
((color->green >> 8) << 8) ||
(color->blue >> 8);
-#if 0
- /* fixme: I am not sure, but this can be accomplished otherwise */
color->pixel = gdk_rgb_xpixel_from_rgb (rgb);
-#endif
}
return color;
diff --git a/libbackground/preferences.h b/libbackground/preferences.h
index 00b6a55d4..dcb73df80 100644
--- a/libbackground/preferences.h
+++ b/libbackground/preferences.h
@@ -32,26 +32,15 @@
#define BG_PREFERENCES_CLASS(klass) G_TYPE_CHECK_CLASS_CAST (klass, bg_preferences_get_type (), BGPreferencesClass)
#define IS_BG_PREFERENCES(obj) G_TYPE_CHECK_INSTANCE_TYPE (obj, bg_preferences_get_type ())
-#define BG_PREFERENCES_DRAW_BACKGROUND "/desktop/gnome/background/draw_background"
-#define BG_PREFERENCES_PRIMARY_COLOR "/desktop/gnome/background/primary_color"
-#define BG_PREFERENCES_SECONDARY_COLOR "/desktop/gnome/background/secondary_color"
-#define BG_PREFERENCES_COLOR_SHADING_TYPE "/desktop/gnome/background/color_shading_type"
-#define BG_PREFERENCES_PICTURE_OPTIONS "/desktop/gnome/background/picture_options"
-#define BG_PREFERENCES_PICTURE_OPACITY "/desktop/gnome/background/picture_opacity"
-#define BG_PREFERENCES_PICTURE_FILENAME "/desktop/gnome/background/picture_filename"
-
-
typedef struct _BGPreferences BGPreferences;
typedef struct _BGPreferencesClass BGPreferencesClass;
typedef enum _orientation_t {
- ORIENTATION_SOLID = 0,
- ORIENTATION_HORIZ,
- ORIENTATION_VERT
+ ORIENTATION_SOLID, ORIENTATION_HORIZ, ORIENTATION_VERT
} orientation_t;
typedef enum _wallpaper_type_t {
- WPTYPE_TILED = 0, WPTYPE_CENTERED, WPTYPE_SCALED,
+ WPTYPE_TILED, WPTYPE_CENTERED, WPTYPE_SCALED,
WPTYPE_STRETCHED, WPTYPE_EMBOSSED
} wallpaper_type_t;