diff -ur /tmp/xfdesktop-4.4.2.old/po/en_GB.po /tmp/xfdesktop-4.4.2/po/en_GB.po --- /tmp/xfdesktop-4.4.2.old/po/en_GB.po 2007-11-17 20:31:46.000000000 +0100 +++ /tmp/xfdesktop-4.4.2/po/en_GB.po 2007-12-17 16:05:02.000000000 +0100 @@ -633,9 +633,22 @@ msgid "Scaled" msgstr "Scaled" -#: ../settings/appearance-settings.c:796 -msgid "A_djust Brightness:" -msgstr "A_djust Brightness:" +#: ../settings/appearance-settings.c:741 +msgid "Maxpect" +msgstr "Maxpect" + + +#: ../settings/appearance-settings.c:845 +msgid "Adjust _Brightness:" +msgstr "Adjust _Brightness:" + +#: ../settings/appearance-settings.c:873 +msgid "Adjust _Saturation:" +msgstr "Adjust _Saturation:" + +#: ../settings/appearance-settings.c:901 +msgid "Adjust _Hue:" +msgstr "Adjust _Hue:" #: ../settings/appearance-settings.c:854 #, c-format diff -ur /tmp/xfdesktop-4.4.2.old/settings/appearance-settings.c /tmp/xfdesktop-4.4.2/settings/appearance-settings.c --- /tmp/xfdesktop-4.4.2.old/settings/appearance-settings.c 2007-11-17 20:31:41.000000000 +0100 +++ /tmp/xfdesktop-4.4.2/settings/appearance-settings.c 2007-12-17 16:05:02.000000000 +0100 @@ -235,6 +235,30 @@ BACKDROP_CHANNEL, bp->brightness); } + /* saturation */ + g_snprintf(setting_name, 128, "saturation_%d_%d", i, j); + setting = mcs_manager_setting_lookup(mcs_plugin->manager, setting_name, + BACKDROP_CHANNEL); + if(setting) + bp->saturation = setting->data.v_int; + else { + bp->saturation = 0; + mcs_manager_set_int(mcs_plugin->manager, setting_name, + BACKDROP_CHANNEL, bp->saturation); + } + + /* hue */ + g_snprintf(setting_name, 128, "hue_%d_%d", i, j); + setting = mcs_manager_setting_lookup(mcs_plugin->manager, setting_name, + BACKDROP_CHANNEL); + if(setting) + bp->hue = setting->data.v_int; + else { + bp->hue = 0; + mcs_manager_set_int(mcs_plugin->manager, setting_name, + BACKDROP_CHANNEL, bp->hue); + } + /* color 1 */ g_snprintf(setting_name, 128, "color1_%d_%d", i, j); setting = mcs_manager_setting_lookup(mcs_plugin->manager, setting_name, @@ -738,6 +762,7 @@ gtk_combo_box_append_text(GTK_COMBO_BOX(combo), _("Tiled")); gtk_combo_box_append_text(GTK_COMBO_BOX(combo), _("Stretched")); gtk_combo_box_append_text(GTK_COMBO_BOX(combo), _("Scaled")); + gtk_combo_box_append_text(GTK_COMBO_BOX(combo), _("Maxpect")); gtk_combo_box_set_active(GTK_COMBO_BOX(combo), bp->style); gtk_label_set_mnemonic_widget(GTK_LABEL(label), combo); gtk_widget_show(combo); @@ -768,7 +793,7 @@ update_brightness(GtkRange *w, BackdropPanel *bp) { gchar setting_name[128]; - + bp->brightness = gtk_range_get_value(w); g_snprintf(setting_name, 128, "brightness_%d_%d", bp->xscreen, bp->monitor); mcs_manager_set_int(bp->bd->plugin->manager, setting_name, BACKDROP_CHANNEL, @@ -776,6 +801,30 @@ mcs_manager_notify(bp->bd->plugin->manager, BACKDROP_CHANNEL); } +static void +update_saturation(GtkRange *w, BackdropPanel *bp) +{ + gchar setting_name[128]; + + bp->saturation = gtk_range_get_value(w); + g_snprintf(setting_name, 128, "saturation_%d_%d", bp->xscreen, bp->monitor); + mcs_manager_set_int(bp->bd->plugin->manager, setting_name, BACKDROP_CHANNEL, + bp->saturation); + mcs_manager_notify(bp->bd->plugin->manager, BACKDROP_CHANNEL); +} + +static void +update_hue(GtkRange *w, BackdropPanel *bp) +{ + gchar setting_name[128]; + + bp->hue = gtk_range_get_value(w); + g_snprintf(setting_name, 128, "hue_%d_%d", bp->xscreen, bp->monitor); + mcs_manager_set_int(bp->bd->plugin->manager, setting_name, BACKDROP_CHANNEL, + bp->hue); + mcs_manager_notify(bp->bd->plugin->manager, BACKDROP_CHANNEL); +} + /* this is a workaround for a gtk bug. it seems that if you move the slider * around a bit, and try to go back to zero, you often get "-0" displayed */ static gchar * @@ -793,7 +842,7 @@ gtk_widget_show(hbox); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); - label = gtk_label_new_with_mnemonic(_("A_djust Brightness:")); + label = gtk_label_new_with_mnemonic(_("Adjust _Brightness:")); gtk_widget_show(label); gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 4); @@ -812,6 +861,62 @@ G_CALLBACK(hscale_format), NULL); } +static void +add_saturation_slider(GtkWidget *vbox, BackdropPanel *bp) +{ + GtkWidget *label, *hbox, *hscale; + + hbox = gtk_hbox_new(FALSE, BORDER); + gtk_widget_show(hbox); + gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); + + label = gtk_label_new_with_mnemonic(_("Adjust _Saturation:")); + gtk_widget_show(label); + gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 4); + + hscale = gtk_hscale_new_with_range(-128, 127, 1); + gtk_label_set_mnemonic_widget(GTK_LABEL(label), hscale); + gtk_scale_set_draw_value(GTK_SCALE(hscale), TRUE); + gtk_scale_set_value_pos(GTK_SCALE(hscale), GTK_POS_RIGHT); + gtk_range_set_increments(GTK_RANGE(hscale), 1, 5); + gtk_range_set_value(GTK_RANGE(hscale), bp->saturation); + gtk_range_set_update_policy(GTK_RANGE(hscale), GTK_UPDATE_DISCONTINUOUS); + gtk_widget_show(hscale); + gtk_box_pack_start(GTK_BOX(hbox), hscale, TRUE, TRUE, 4); + g_signal_connect(G_OBJECT(hscale), "value-changed", + G_CALLBACK(update_saturation), bp); + g_signal_connect(G_OBJECT(hscale), "format-value", + G_CALLBACK(hscale_format), NULL); +} + +static void +add_hue_slider(GtkWidget *vbox, BackdropPanel *bp) +{ + GtkWidget *label, *hbox, *hscale; + + hbox = gtk_hbox_new(FALSE, BORDER); + gtk_widget_show(hbox); + gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); + + label = gtk_label_new_with_mnemonic(_("Adjust _Hue:")); + gtk_widget_show(label); + gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 4); + + hscale = gtk_hscale_new_with_range(0, 359, 1); + gtk_label_set_mnemonic_widget(GTK_LABEL(label), hscale); + gtk_scale_set_draw_value(GTK_SCALE(hscale), TRUE); + gtk_scale_set_value_pos(GTK_SCALE(hscale), GTK_POS_RIGHT); + gtk_range_set_increments(GTK_RANGE(hscale), 1, 5); + gtk_range_set_value(GTK_RANGE(hscale), bp->hue); + gtk_range_set_update_policy(GTK_RANGE(hscale), GTK_UPDATE_DISCONTINUOUS); + gtk_widget_show(hscale); + gtk_box_pack_start(GTK_BOX(hbox), hscale, TRUE, TRUE, 4); + g_signal_connect(G_OBJECT(hscale), "value-changed", + G_CALLBACK(update_hue), bp); + g_signal_connect(G_OBJECT(hscale), "format-value", + G_CALLBACK(hscale_format), NULL); +} + #if 0 void toggle_set_background(GtkToggleButton *tb, BackdropPanel *bp) @@ -1218,6 +1323,12 @@ /* image brightness */ add_brightness_slider(page, bp); + + /* image saturation */ + add_saturation_slider(page, bp); + + /* image hue */ + add_hue_slider(page, bp); add_spacer(GTK_BOX(page)); diff -ur /tmp/xfdesktop-4.4.2.old/settings/settings-common.h /tmp/xfdesktop-4.4.2/settings/settings-common.h --- /tmp/xfdesktop-4.4.2.old/settings/settings-common.h 2007-11-17 20:31:41.000000000 +0100 +++ /tmp/xfdesktop-4.4.2/settings/settings-common.h 2007-12-17 16:05:02.000000000 +0100 @@ -61,6 +61,8 @@ gchar *image_path; XfceBackdropImageStyle style; gint brightness; + gint saturation; + gint hue; /* the notebook page */ GtkWidget *page; diff -ur /tmp/xfdesktop-4.4.2.old/src/xfce-backdrop.c /tmp/xfdesktop-4.4.2/src/xfce-backdrop.c --- /tmp/xfdesktop-4.4.2.old/src/xfce-backdrop.c 2007-11-17 20:31:41.000000000 +0100 +++ /tmp/xfdesktop-4.4.2/src/xfce-backdrop.c 2007-12-17 16:45:36.000000000 +0100 @@ -45,16 +45,18 @@ { gint width, height; gint bpp; - + XfceBackdropColorStyle color_style; GdkColor color1; GdkColor color2; - + gboolean show_image; XfceBackdropImageStyle image_style; gchar *image_path; - + gint brightness; + gint saturation; + gint hue; }; enum { @@ -74,24 +76,24 @@ gboolean has_alpha = FALSE; gint i, len; GError *err = NULL; - + g_return_val_if_fail(src != NULL, NULL); if(amount == 0) return src; - + gdk_pixdata_from_pixbuf(&pdata, src, FALSE); has_alpha = (pdata.pixdata_type & GDK_PIXDATA_COLOR_TYPE_RGBA); if(pdata.length < 1) len = pdata.width * pdata.height * (has_alpha?4:3); else len = pdata.length - GDK_PIXDATA_HEADER_LENGTH; - + for(i = 0; i < len; i++) { gshort scaled; - + if(has_alpha && (i+1)%4) continue; - + scaled = pdata.pixel_data[i] + amount; if(scaled > 255) scaled = 255; @@ -99,7 +101,7 @@ scaled = 0; pdata.pixel_data[i] = scaled; } - + newpix = gdk_pixbuf_from_pixdata(&pdata, TRUE, &err); if(!newpix) { g_warning("%s: Unable to modify image brightness: %s", PACKAGE, @@ -108,7 +110,136 @@ return src; } g_object_unref(G_OBJECT(src)); - + + return newpix; +} + +static GdkPixbuf * +adjust_saturation(GdkPixbuf *src, gint amount) +{ + g_return_val_if_fail(src != NULL, NULL); + if(amount == 0) + return src; + GdkPixbuf *newpix = gdk_pixbuf_copy(src); + gdk_pixbuf_saturate_and_pixelate(src, newpix, ((gdouble)(amount+128))/127.5f, FALSE); + g_object_unref(G_OBJECT(src)); + return newpix; +} + +static GdkPixbuf * +adjust_hue(GdkPixbuf *src, gint amount) +{ + g_return_val_if_fail(src != NULL, NULL); + if(amount == 0) + return src; + GdkPixbuf *newpix; + GdkPixdata pdata; + gboolean has_alpha = FALSE; + gint i, len; + GError *err = NULL; + + g_return_val_if_fail(src != NULL, NULL); + if(amount == 0) + return src; + + gdk_pixdata_from_pixbuf(&pdata, src, FALSE); + has_alpha = (pdata.pixdata_type & GDK_PIXDATA_COLOR_TYPE_RGBA); + if(pdata.length < 1) + len = pdata.width * pdata.height * (has_alpha?4:3); + else + len = pdata.length - GDK_PIXDATA_HEADER_LENGTH; + + gint iInc=(has_alpha?4:3); + for(i = 0; i < len; i+=iInc) { + /* Get RGB pixel */ + gint r,g,b; + r = pdata.pixel_data[i+0]; + g = pdata.pixel_data[i+1]; + b = pdata.pixel_data[i+2]; + + /* Convert into HSV colorspace */ + gint min, max; + min = MIN( r, MIN(g, b)); + max = MAX( r, MAX(g, b)); + + gdouble h,s,v; + if(min == max) + h = 0; else + if(max == r && g >= b ) + h = 60.0f * ((gdouble)(g - b))/((gdouble)(max - min)) + 0.0f; else + if(max == r && g < b ) + h = 60.0f * ((gdouble)(g - b))/((gdouble)(max - min)) + 360.0f; else + if(max == g) + h = 60.0f * ((gdouble)(b - r))/((gdouble)(max - min)) + 120.0f; else + if(max == b) + h = 60.0f * ((gdouble)(r - g))/((gdouble)(max - min)) + 240.0f; + + s = max == 0 ? 0.0f : 1.0f - (((gdouble)min)/((gdouble)max)); + v = ((gdouble)max)/255.0f; + + /* Shift h by amount */ + h += amount; + while(h>=360.0f) h -= 360.0f; + + /* convert HSV back to RGB */ + gdouble f, p, q, t; + gint hi; + hi = ((int)(h/60.0f))%6; + f = (h/60.0f) - ((gdouble)hi); + p = v * (1.0f - s); + q = v * (1.0f - (f * s)); + t = v * (1.0f - ((1.0f - f) * s)); + + switch( hi ) { + case 0: + r = v * 255.0f; + g = t * 255.0f; + b = p * 255.0f; + break; + case 1: + r = q * 255.0f; + g = v * 255.0f; + b = p * 255.0f; + break; + case 2: + r = p * 255.0f; + g = v * 255.0f; + b = t * 255.0f; + break; + case 3: + r = p * 255.0f; + g = q * 255.0f; + b = v * 255.0f; + break; + case 4: + r = t * 255.0f; + g = p * 255.0f; + b = v * 255.0f; + break; + case 5: + r = v * 255.0f; + g = p * 255.0f; + b = q * 255.0f; + break; + default: + g_return_val_if_fail( (hi >= 0) && (hi < 6), NULL); + } + + /* update pixel data */ + pdata.pixel_data[i + 0] = r; + pdata.pixel_data[i + 1] = g; + pdata.pixel_data[i + 2] = b; + } + + newpix = gdk_pixbuf_from_pixdata(&pdata, TRUE, &err); + if(!newpix) { + g_warning("%s: Unable to modify image brightness: %s", PACKAGE, + err->message); + g_error_free(err); + return src; + } + g_object_unref(G_OBJECT(src)); + return newpix; } @@ -117,14 +248,14 @@ { GdkPixbuf *pix; guint32 rgba; - + pix = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, 8, width, height); - + rgba = (((color->red & 0xff00) << 8) | ((color->green & 0xff00)) | ((color->blue & 0xff00) >> 8)) << 8; - + gdk_pixbuf_fill(pix, rgba); - + return pix; } @@ -137,12 +268,12 @@ GdkPixdata pixdata; guint8 rgb[3]; GError *err = NULL; - + g_return_val_if_fail(color1 != NULL && color2 != NULL, NULL); g_return_val_if_fail(width > 0 && height > 0, NULL); g_return_val_if_fail(style == XFCE_BACKDROP_COLOR_HORIZ_GRADIENT || style == XFCE_BACKDROP_COLOR_VERT_GRADIENT, NULL); - + pixdata.magic = GDK_PIXBUF_MAGIC_NUMBER; pixdata.length = GDK_PIXDATA_HEADER_LENGTH + (width * height * 3); pixdata.pixdata_type = GDK_PIXDATA_COLOR_TYPE_RGB @@ -159,7 +290,7 @@ rgb[2] = (color1->blue + (i * (color2->blue - color1->blue) / width)) >> 8; memcpy(pixdata.pixel_data+(i*3), rgb, 3); } - + for(i = 1; i < height; i++) { memcpy(pixdata.pixel_data+(i*pixdata.rowstride), pixdata.pixel_data, pixdata.rowstride); @@ -173,16 +304,16 @@ memcpy(pixdata.pixel_data+(i*pixdata.rowstride)+(j*3), rgb, 3); } } - + pix = gdk_pixbuf_from_pixdata(&pixdata, TRUE, &err); if(!pix) { g_warning("%s: Unable to create color gradient: %s\n", PACKAGE, err->message); g_error_free(err); } - + g_free(pixdata.pixel_data); - + return pix; } @@ -196,11 +327,11 @@ xfce_backdrop_class_init(XfceBackdropClass *klass) { GObjectClass *gobject_class = (GObjectClass *)klass; - + g_type_class_add_private(klass, sizeof(XfceBackdropPriv)); - + gobject_class->finalize = xfce_backdrop_finalize; - + backdrop_signals[BACKDROP_CHANGED] = g_signal_new("changed", G_OBJECT_CLASS_TYPE(gobject_class), G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET(XfceBackdropClass, changed), NULL, NULL, @@ -219,12 +350,12 @@ xfce_backdrop_finalize(GObject *object) { XfceBackdrop *backdrop = XFCE_BACKDROP(object); - + g_return_if_fail(backdrop != NULL); - + if(backdrop->priv->image_path) g_free(backdrop->priv->image_path); - + G_OBJECT_CLASS(xfce_backdrop_parent_class)->finalize(object); } @@ -244,12 +375,12 @@ xfce_backdrop_new(GdkVisual *visual) { XfceBackdrop *backdrop; - + g_return_val_if_fail(GDK_IS_VISUAL(visual), NULL); - + backdrop = g_object_new(XFCE_TYPE_BACKDROP, NULL); backdrop->priv->bpp = visual->depth; - + return backdrop; } @@ -266,15 +397,15 @@ xfce_backdrop_new_with_size(GdkVisual *visual, gint width, gint height) { XfceBackdrop *backdrop; - + g_return_val_if_fail(GDK_IS_VISUAL(visual), NULL); - + backdrop = g_object_new(XFCE_TYPE_BACKDROP, NULL); - + backdrop->priv->bpp = visual->depth; backdrop->priv->width = width; backdrop->priv->height = height; - + return backdrop; } @@ -292,7 +423,7 @@ xfce_backdrop_set_size(XfceBackdrop *backdrop, gint width, gint height) { g_return_if_fail(XFCE_IS_BACKDROP(backdrop)); - + backdrop->priv->width = width; backdrop->priv->height = height; } @@ -309,7 +440,7 @@ XfceBackdropColorStyle style) { g_return_if_fail(XFCE_IS_BACKDROP(backdrop)); - + if(style != backdrop->priv->color_style) { backdrop->priv->color_style = style; g_signal_emit(G_OBJECT(backdrop), backdrop_signals[BACKDROP_CHANGED], 0); @@ -340,7 +471,7 @@ const GdkColor *color) { g_return_if_fail(XFCE_IS_BACKDROP(backdrop) && color != NULL); - + if(color->red != backdrop->priv->color1.red || color->green != backdrop->priv->color1.green || color->blue != backdrop->priv->color1.blue) @@ -357,7 +488,7 @@ GdkColor *color) { g_return_if_fail(XFCE_IS_BACKDROP(backdrop) && color); - + memcpy(color, &backdrop->priv->color1, sizeof(GdkColor)); } @@ -376,7 +507,7 @@ const GdkColor *color) { g_return_if_fail(XFCE_IS_BACKDROP(backdrop) && color != NULL); - + if(color->red != backdrop->priv->color2.red || color->green != backdrop->priv->color2.green || color->blue != backdrop->priv->color2.blue) @@ -394,7 +525,7 @@ GdkColor *color) { g_return_if_fail(XFCE_IS_BACKDROP(backdrop) && color); - + memcpy(color, &backdrop->priv->color2, sizeof(GdkColor)); } @@ -410,7 +541,7 @@ xfce_backdrop_set_show_image(XfceBackdrop *backdrop, gboolean show_image) { g_return_if_fail(XFCE_IS_BACKDROP(backdrop)); - + if(backdrop->priv->show_image != show_image) { backdrop->priv->show_image = show_image; g_signal_emit(G_OBJECT(backdrop), backdrop_signals[BACKDROP_CHANGED], 0); @@ -440,7 +571,7 @@ XfceBackdropImageStyle style) { g_return_if_fail(XFCE_IS_BACKDROP(backdrop)); - + if(style != backdrop->priv->image_style) { backdrop->priv->image_style = style; g_signal_emit(G_OBJECT(backdrop), backdrop_signals[BACKDROP_CHANGED], 0); @@ -468,12 +599,12 @@ xfce_backdrop_set_image_filename(XfceBackdrop *backdrop, const gchar *filename) { g_return_if_fail(XFCE_IS_BACKDROP(backdrop)); - + if(backdrop->priv->image_path) g_free(backdrop->priv->image_path); - + backdrop->priv->image_path = g_strdup(filename); - + g_signal_emit(G_OBJECT(backdrop), backdrop_signals[BACKDROP_CHANGED], 0); } @@ -497,7 +628,7 @@ xfce_backdrop_set_brightness(XfceBackdrop *backdrop, gint brightness) { g_return_if_fail(XFCE_IS_BACKDROP(backdrop)); - + if(brightness != backdrop->priv->brightness) { backdrop->priv->brightness = brightness; g_signal_emit(G_OBJECT(backdrop), backdrop_signals[BACKDROP_CHANGED], 0); @@ -512,6 +643,53 @@ } /** + * xfce_backdrop_set_saturation: + * @backdrop: An #XfceBackdrop. + * @saturation: A saturation value. + * + * Modifies the saturation of the backdrop using a value between -128 and 127. + * A value of 0 indicates that the saturation should not be changed. This value + * is applied to the entire image, after compositing. + **/ +void +xfce_backdrop_set_saturation(XfceBackdrop *backdrop, gint saturation) +{ + g_return_if_fail(XFCE_IS_BACKDROP(backdrop)); + + if(saturation != backdrop->priv->saturation) { + backdrop->priv->saturation = saturation; + g_signal_emit(G_OBJECT(backdrop), backdrop_signals[BACKDROP_CHANGED], 0); + } +} + +/** + * xfce_backdrop_set_hue: + * @backdrop: An #XfceBackdrop. + * @hue: A hue value. + * + * Shifts the hue of the backdrop using a value between 0 and 359 degrees. + * A value of 0 indicates that the hue should not be changed. This value + * is applied to the entire image, after compositing. + **/ +void +xfce_backdrop_set_hue(XfceBackdrop *backdrop, gint hue) +{ + g_return_if_fail(XFCE_IS_BACKDROP(backdrop)); + + if(hue != backdrop->priv->hue) { + backdrop->priv->hue = hue; + g_signal_emit(G_OBJECT(backdrop), backdrop_signals[BACKDROP_CHANGED], 0); + } +} + +gint +xfce_backdrop_get_hue(XfceBackdrop *backdrop) +{ + g_return_val_if_fail(XFCE_IS_BACKDROP(backdrop), 0); + return backdrop->priv->hue; +} + +/** * xfce_backdrop_get_pixbuf: * @backdrop: An #XfceBackdrop. * @@ -530,9 +708,9 @@ gint dx, dy, xo, yo; gdouble xscale, yscale; GdkInterpType interp; - + g_return_val_if_fail(XFCE_IS_BACKDROP(backdrop), NULL); - + if(backdrop->priv->show_image && backdrop->priv->image_path) { image = gdk_pixbuf_new_from_file(backdrop->priv->image_path, NULL); if(image) { @@ -540,7 +718,7 @@ ih = gdk_pixbuf_get_height(image); } } - + if(backdrop->priv->width == 0 || backdrop->priv->height == 0) { if(!image) return NULL; @@ -550,7 +728,7 @@ w = backdrop->priv->width; h = backdrop->priv->height; } - + if(backdrop->priv->color_style == XFCE_BACKDROP_COLOR_SOLID) final_image = create_solid(&backdrop->priv->color1, w, h); else { @@ -559,27 +737,31 @@ if(!final_image) final_image = create_solid(&backdrop->priv->color1, w, h); } - + if(!image) { if(backdrop->priv->brightness != 0) final_image = adjust_brightness(final_image, backdrop->priv->brightness); - + if(backdrop->priv->saturation != 0) + final_image = adjust_saturation(final_image, backdrop->priv->saturation); + if(backdrop->priv->hue != 0) + final_image = adjust_hue(final_image, backdrop->priv->hue); + return final_image; } - + if(backdrop->priv->image_style == XFCE_BACKDROP_IMAGE_AUTO) { if(ih <= h / 2 && iw <= w / 2) istyle = XFCE_BACKDROP_IMAGE_TILED; else - istyle = XFCE_BACKDROP_IMAGE_SCALED; + istyle = XFCE_BACKDROP_IMAGE_MAXPECT; } else istyle = backdrop->priv->image_style; - + /* if the image is the same as the screen size, there's no reason to do * any scaling at all */ if(w == iw && h == ih) istyle = XFCE_BACKDROP_IMAGE_CENTERED; - + /* if we don't need to do any scaling, don't do any interpolation. this * fixes a problem where hyper/bilinear filtering causes blurriness in * some images. http://bugzilla.xfce.org/show_bug.cgi?id=2939 */ @@ -595,7 +777,7 @@ else interp = GDK_INTERP_BILINEAR; } - + switch(istyle) { case XFCE_BACKDROP_IMAGE_CENTERED: dx = MAX((w - iw) / 2, 0); @@ -606,36 +788,52 @@ MIN(w, iw), MIN(h, ih), xo, yo, 1.0, 1.0, interp, 255); break; - + case XFCE_BACKDROP_IMAGE_TILED: tmp = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, w, h); for(i = 0; (i * iw) < w; i++) { for(j = 0; (j * ih) < h; j++) { gint newx = iw * i, newy = ih * j; gint neww = iw, newh = ih; - + if((newx + neww) > w) neww = w - newx; if((newy + newh) > h) newh = h - newy; - + gdk_pixbuf_copy_area(image, 0, 0, neww, newh, tmp, newx, newy); } } - + gdk_pixbuf_composite(tmp, final_image, 0, 0, w, h, 0, 0, 1.0, 1.0, interp, 255); g_object_unref(G_OBJECT(tmp)); break; - + case XFCE_BACKDROP_IMAGE_STRETCHED: xscale = (gdouble)w / iw; yscale = (gdouble)h / ih; gdk_pixbuf_composite(image, final_image, 0, 0, w, h, 0, 0, xscale, yscale, interp, 255); break; - + + case XFCE_BACKDROP_IMAGE_MAXPECT: + xscale = (gdouble)w / iw; + yscale = (gdouble)h / ih; + if( xscale < yscale ) { + xscale = yscale; + dx = (w - (iw * yscale)) / 2; + dy = 0; + } else { + yscale = xscale; + dy = (h - (ih * xscale)) / 2; + dx = 0; + } + gdk_pixbuf_composite( image, final_image, 0, 0, + w, h, dx, dy, + xscale, yscale, interp, 255); + break; case XFCE_BACKDROP_IMAGE_SCALED: xscale = (gdouble)w / iw; yscale = (gdouble)h / ih; @@ -650,21 +848,24 @@ } dx = xo; dy = yo; - + gdk_pixbuf_composite(image, final_image, dx, dy, iw * xscale, ih * yscale, xo, yo, xscale, yscale, interp, 255); break; - default: g_critical("Invalid image style: %d\n", (gint)istyle); } - + if(image) g_object_unref(G_OBJECT(image)); - + if(backdrop->priv->brightness != 0) final_image = adjust_brightness(final_image, backdrop->priv->brightness); - + if(backdrop->priv->saturation != 0) + final_image = adjust_saturation(final_image, backdrop->priv->saturation); + if(backdrop->priv->hue != 0) + final_image = adjust_hue(final_image, backdrop->priv->hue); + return final_image; } Only in /tmp/xfdesktop-4.4.2/src: xfce-backdrop.c~ diff -ur /tmp/xfdesktop-4.4.2.old/src/xfce-backdrop.h /tmp/xfdesktop-4.4.2/src/xfce-backdrop.h --- /tmp/xfdesktop-4.4.2.old/src/xfce-backdrop.h 2007-11-17 20:31:41.000000000 +0100 +++ /tmp/xfdesktop-4.4.2/src/xfce-backdrop.h 2007-12-17 16:05:02.000000000 +0100 @@ -48,7 +48,8 @@ XFCE_BACKDROP_IMAGE_CENTERED, XFCE_BACKDROP_IMAGE_TILED, XFCE_BACKDROP_IMAGE_STRETCHED, - XFCE_BACKDROP_IMAGE_SCALED + XFCE_BACKDROP_IMAGE_SCALED, + XFCE_BACKDROP_IMAGE_MAXPECT } XfceBackdropImageStyle; typedef enum @@ -119,6 +120,10 @@ gint brightness); gint xfce_backdrop_get_brightness (XfceBackdrop *backdrop); +void xfce_backdrop_set_saturation (XfceBackdrop *backdrop, + gint saturation); +gint xfce_backdrop_get_saturation (XfceBackdrop *backdrop); + GdkPixbuf *xfce_backdrop_get_pixbuf (XfceBackdrop *backdrop); G_END_DECLS diff -ur /tmp/xfdesktop-4.4.2.old/src/xfce-desktop-settings.c /tmp/xfdesktop-4.4.2/src/xfce-desktop-settings.c --- /tmp/xfdesktop-4.4.2.old/src/xfce-desktop-settings.c 2007-11-17 20:31:41.000000000 +0100 +++ /tmp/xfdesktop-4.4.2/src/xfce-desktop-settings.c 2007-12-17 16:05:02.000000000 +0100 @@ -364,6 +364,24 @@ setting = NULL; } else xfce_backdrop_set_brightness(backdrop, 0); + g_snprintf(setting_name, 64, "saturation_%d_%d", screen, i); + if(MCS_SUCCESS == mcs_client_get_setting(mcs_client, setting_name, + BACKDROP_CHANNEL, &setting)) + { + xfce_backdrop_set_saturation(backdrop, setting->data.v_int); + mcs_setting_free(setting); + setting = NULL; + } else + xfce_backdrop_set_saturation(backdrop, 0); + g_snprintf(setting_name, 64, "hue_%d_%d", screen, i); + if(MCS_SUCCESS == mcs_client_get_setting(mcs_client, setting_name, + BACKDROP_CHANNEL, &setting)) + { + xfce_backdrop_set_hue(backdrop, setting->data.v_int); + mcs_setting_free(setting); + setting = NULL; + } else + xfce_backdrop_set_hue(backdrop, 0); } xfce_desktop_thaw_updates(desktop); @@ -481,6 +499,12 @@ } else if(strstr(setting->name, "brightness") == setting->name) { xfce_backdrop_set_brightness(backdrop, setting->data.v_int); handled = TRUE; + } else if(strstr(setting->name, "saturation") == setting->name) { + xfce_backdrop_set_saturation(backdrop, setting->data.v_int); + handled = TRUE; + } else if(strstr(setting->name, "hue") == setting->name) { + xfce_backdrop_set_hue(backdrop, setting->data.v_int); + handled = TRUE; } break;