- diff -ur xfdesktop-4.4.1.orig/po/en_GB.po xfdesktop-4.4.1/po/en_GB.po
- --- xfdesktop-4.4.1.orig/po/en_GB.po 2007-04-09 16:35:35.000000000 +0200
- +++ xfdesktop-4.4.1/po/en_GB.po 2007-10-29 22:01:05.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 xfdesktop-4.4.1.orig/settings/appearance-settings.c xfdesktop-4.4.1/settings/appearance-settings.c
- --- xfdesktop-4.4.1.orig/settings/appearance-settings.c 2007-03-11 14:43:58.000000000 +0100
- +++ xfdesktop-4.4.1/settings/appearance-settings.c 2007-10-29 20:48:44.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 xfdesktop-4.4.1.orig/settings/settings-common.h xfdesktop-4.4.1/settings/settings-common.h
- --- xfdesktop-4.4.1.orig/settings/settings-common.h 2007-01-25 21:53:23.000000000 +0100
- +++ xfdesktop-4.4.1/settings/settings-common.h 2007-10-29 20:39:51.000000000 +0100
- -61,6 +61,8 @@
- gchar *image_path;
- XfceBackdropImageStyle style;
- gint brightness;
- + gint saturation;
- + gint hue;
- /* the notebook page */
- GtkWidget *page;
- diff -ur xfdesktop-4.4.1.orig/src/xfce-backdrop.c xfdesktop-4.4.1/src/xfce-backdrop.c
- --- xfdesktop-4.4.1.orig/src/xfce-backdrop.c 2007-03-11 14:43:58.000000000 +0100
- +++ xfdesktop-4.4.1/src/xfce-backdrop.c 2007-10-29 21:49:40.000000000 +0100
- -55,6 +55,8 @@
- gchar *image_path;
- gint brightness;
- + gint saturation;
- + gint hue;
- };
- enum {
- -113,6 +115,135 @@
- }
- 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;
- +}
- +
- +static GdkPixbuf *
- create_solid(GdkColor *color, gint width, gint height)
- {
- GdkPixbuf *pix;
- -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.
- *
- -563,6 +741,10 @@
- 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;
- }
- -571,7 +753,7 @@
- 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;
- -636,6 +818,41 @@
- 0, 0, xscale, yscale, interp, 255);
- break;
- + case XFCE_BACKDROP_IMAGE_MAXPECT:
- + /* We cut off that which we don't need, and let XFCE_BACKDROP_IMAGE_SCALED do the scaling.
- + * Scaling is always neccesary, the no-scaling case is taken care of earlier in this code.
- + * If aspect is a perfect match already, we immediately fall-through into regular scaling
- + * Note that is maxpect is always centered!
- + */
- + xscale = (((gdouble)iw)/((gdouble)ih)); // Image aspect
- + yscale = (((gdouble)w) / ((gdouble)h)); // Display aspect
- + if( xscale > yscale ) { // Image too wide, calcute how much we need to take off iw to achieve dy
- + tmp = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, ((gdouble)ih)*yscale, ih);
- + yscale = ((gdouble)ih)*yscale; // new width
- + xscale = 0.5f*(((gdouble)iw)-yscale); // amount to cut off, halved
- + gdk_pixbuf_copy_area(image, \
- + xscale, 0, \
- + yscale, ih, \
- + tmp, \
- + 0, 0);
- + g_object_unref(G_OBJECT(image));
- + image = tmp;
- + iw = gdk_pixbuf_get_width(image);
- + } else
- + if( xscale < yscale ) { // Image too narrow, calcute how much we need to take off ih to achieve dy
- + tmp = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, iw, ((gdouble)iw)/yscale);
- + yscale = ((gdouble)iw)/yscale; // new height
- + xscale = 0.5f*(((gdouble)ih)-yscale); // amount to cut off, halved
- + gdk_pixbuf_copy_area(image, \
- + 0, xscale, \
- + iw, yscale, \
- + tmp, \
- + 0, 0);
- + g_object_unref(G_OBJECT(image));
- + image = tmp;
- + ih = gdk_pixbuf_get_height(image);
- + }
- +
- case XFCE_BACKDROP_IMAGE_SCALED:
- xscale = (gdouble)w / iw;
- yscale = (gdouble)h / ih;
- -655,16 +872,19 @@
- 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;
- }
- diff -ur xfdesktop-4.4.1.orig/src/xfce-backdrop.h xfdesktop-4.4.1/src/xfce-backdrop.h
- --- xfdesktop-4.4.1.orig/src/xfce-backdrop.h 2007-01-25 21:53:23.000000000 +0100
- +++ xfdesktop-4.4.1/src/xfce-backdrop.h 2007-10-29 20:27:56.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 xfdesktop-4.4.1.orig/src/xfce-desktop-settings.c xfdesktop-4.4.1/src/xfce-desktop-settings.c
- --- xfdesktop-4.4.1.orig/src/xfce-desktop-settings.c 2007-01-25 21:53:23.000000000 +0100
- +++ xfdesktop-4.4.1/src/xfce-desktop-settings.c 2007-10-29 20:39:43.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;