Advertisement
Guest User

dafox

a guest
Dec 17th, 2007
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 28.75 KB | None | 0 0
  1. diff -ur /tmp/xfdesktop-4.4.2.old/po/en_GB.po /tmp/xfdesktop-4.4.2/po/en_GB.po
  2. --- /tmp/xfdesktop-4.4.2.old/po/en_GB.po 2007-11-17 20:31:46.000000000 +0100
  3. +++ /tmp/xfdesktop-4.4.2/po/en_GB.po 2007-12-17 16:05:02.000000000 +0100
  4. @@ -633,9 +633,22 @@
  5. msgid "Scaled"
  6. msgstr "Scaled"
  7.  
  8. -#: ../settings/appearance-settings.c:796
  9. -msgid "A_djust Brightness:"
  10. -msgstr "A_djust Brightness:"
  11. +#: ../settings/appearance-settings.c:741
  12. +msgid "Maxpect"
  13. +msgstr "Maxpect"
  14. +
  15. +
  16. +#: ../settings/appearance-settings.c:845
  17. +msgid "Adjust _Brightness:"
  18. +msgstr "Adjust _Brightness:"
  19. +
  20. +#: ../settings/appearance-settings.c:873
  21. +msgid "Adjust _Saturation:"
  22. +msgstr "Adjust _Saturation:"
  23. +
  24. +#: ../settings/appearance-settings.c:901
  25. +msgid "Adjust _Hue:"
  26. +msgstr "Adjust _Hue:"
  27.  
  28. #: ../settings/appearance-settings.c:854
  29. #, c-format
  30. diff -ur /tmp/xfdesktop-4.4.2.old/settings/appearance-settings.c /tmp/xfdesktop-4.4.2/settings/appearance-settings.c
  31. --- /tmp/xfdesktop-4.4.2.old/settings/appearance-settings.c 2007-11-17 20:31:41.000000000 +0100
  32. +++ /tmp/xfdesktop-4.4.2/settings/appearance-settings.c 2007-12-17 16:05:02.000000000 +0100
  33. @@ -235,6 +235,30 @@
  34. BACKDROP_CHANNEL, bp->brightness);
  35. }
  36.  
  37. + /* saturation */
  38. + g_snprintf(setting_name, 128, "saturation_%d_%d", i, j);
  39. + setting = mcs_manager_setting_lookup(mcs_plugin->manager, setting_name,
  40. + BACKDROP_CHANNEL);
  41. + if(setting)
  42. + bp->saturation = setting->data.v_int;
  43. + else {
  44. + bp->saturation = 0;
  45. + mcs_manager_set_int(mcs_plugin->manager, setting_name,
  46. + BACKDROP_CHANNEL, bp->saturation);
  47. + }
  48. +
  49. + /* hue */
  50. + g_snprintf(setting_name, 128, "hue_%d_%d", i, j);
  51. + setting = mcs_manager_setting_lookup(mcs_plugin->manager, setting_name,
  52. + BACKDROP_CHANNEL);
  53. + if(setting)
  54. + bp->hue = setting->data.v_int;
  55. + else {
  56. + bp->hue = 0;
  57. + mcs_manager_set_int(mcs_plugin->manager, setting_name,
  58. + BACKDROP_CHANNEL, bp->hue);
  59. + }
  60. +
  61. /* color 1 */
  62. g_snprintf(setting_name, 128, "color1_%d_%d", i, j);
  63. setting = mcs_manager_setting_lookup(mcs_plugin->manager, setting_name,
  64. @@ -738,6 +762,7 @@
  65. gtk_combo_box_append_text(GTK_COMBO_BOX(combo), _("Tiled"));
  66. gtk_combo_box_append_text(GTK_COMBO_BOX(combo), _("Stretched"));
  67. gtk_combo_box_append_text(GTK_COMBO_BOX(combo), _("Scaled"));
  68. + gtk_combo_box_append_text(GTK_COMBO_BOX(combo), _("Maxpect"));
  69. gtk_combo_box_set_active(GTK_COMBO_BOX(combo), bp->style);
  70. gtk_label_set_mnemonic_widget(GTK_LABEL(label), combo);
  71. gtk_widget_show(combo);
  72. @@ -768,7 +793,7 @@
  73. update_brightness(GtkRange *w, BackdropPanel *bp)
  74. {
  75. gchar setting_name[128];
  76. -
  77. +
  78. bp->brightness = gtk_range_get_value(w);
  79. g_snprintf(setting_name, 128, "brightness_%d_%d", bp->xscreen, bp->monitor);
  80. mcs_manager_set_int(bp->bd->plugin->manager, setting_name, BACKDROP_CHANNEL,
  81. @@ -776,6 +801,30 @@
  82. mcs_manager_notify(bp->bd->plugin->manager, BACKDROP_CHANNEL);
  83. }
  84.  
  85. +static void
  86. +update_saturation(GtkRange *w, BackdropPanel *bp)
  87. +{
  88. + gchar setting_name[128];
  89. +
  90. + bp->saturation = gtk_range_get_value(w);
  91. + g_snprintf(setting_name, 128, "saturation_%d_%d", bp->xscreen, bp->monitor);
  92. + mcs_manager_set_int(bp->bd->plugin->manager, setting_name, BACKDROP_CHANNEL,
  93. + bp->saturation);
  94. + mcs_manager_notify(bp->bd->plugin->manager, BACKDROP_CHANNEL);
  95. +}
  96. +
  97. +static void
  98. +update_hue(GtkRange *w, BackdropPanel *bp)
  99. +{
  100. + gchar setting_name[128];
  101. +
  102. + bp->hue = gtk_range_get_value(w);
  103. + g_snprintf(setting_name, 128, "hue_%d_%d", bp->xscreen, bp->monitor);
  104. + mcs_manager_set_int(bp->bd->plugin->manager, setting_name, BACKDROP_CHANNEL,
  105. + bp->hue);
  106. + mcs_manager_notify(bp->bd->plugin->manager, BACKDROP_CHANNEL);
  107. +}
  108. +
  109. /* this is a workaround for a gtk bug. it seems that if you move the slider
  110. * around a bit, and try to go back to zero, you often get "-0" displayed */
  111. static gchar *
  112. @@ -793,7 +842,7 @@
  113. gtk_widget_show(hbox);
  114. gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
  115.  
  116. - label = gtk_label_new_with_mnemonic(_("A_djust Brightness:"));
  117. + label = gtk_label_new_with_mnemonic(_("Adjust _Brightness:"));
  118. gtk_widget_show(label);
  119. gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 4);
  120.  
  121. @@ -812,6 +861,62 @@
  122. G_CALLBACK(hscale_format), NULL);
  123. }
  124.  
  125. +static void
  126. +add_saturation_slider(GtkWidget *vbox, BackdropPanel *bp)
  127. +{
  128. + GtkWidget *label, *hbox, *hscale;
  129. +
  130. + hbox = gtk_hbox_new(FALSE, BORDER);
  131. + gtk_widget_show(hbox);
  132. + gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
  133. +
  134. + label = gtk_label_new_with_mnemonic(_("Adjust _Saturation:"));
  135. + gtk_widget_show(label);
  136. + gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 4);
  137. +
  138. + hscale = gtk_hscale_new_with_range(-128, 127, 1);
  139. + gtk_label_set_mnemonic_widget(GTK_LABEL(label), hscale);
  140. + gtk_scale_set_draw_value(GTK_SCALE(hscale), TRUE);
  141. + gtk_scale_set_value_pos(GTK_SCALE(hscale), GTK_POS_RIGHT);
  142. + gtk_range_set_increments(GTK_RANGE(hscale), 1, 5);
  143. + gtk_range_set_value(GTK_RANGE(hscale), bp->saturation);
  144. + gtk_range_set_update_policy(GTK_RANGE(hscale), GTK_UPDATE_DISCONTINUOUS);
  145. + gtk_widget_show(hscale);
  146. + gtk_box_pack_start(GTK_BOX(hbox), hscale, TRUE, TRUE, 4);
  147. + g_signal_connect(G_OBJECT(hscale), "value-changed",
  148. + G_CALLBACK(update_saturation), bp);
  149. + g_signal_connect(G_OBJECT(hscale), "format-value",
  150. + G_CALLBACK(hscale_format), NULL);
  151. +}
  152. +
  153. +static void
  154. +add_hue_slider(GtkWidget *vbox, BackdropPanel *bp)
  155. +{
  156. + GtkWidget *label, *hbox, *hscale;
  157. +
  158. + hbox = gtk_hbox_new(FALSE, BORDER);
  159. + gtk_widget_show(hbox);
  160. + gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
  161. +
  162. + label = gtk_label_new_with_mnemonic(_("Adjust _Hue:"));
  163. + gtk_widget_show(label);
  164. + gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 4);
  165. +
  166. + hscale = gtk_hscale_new_with_range(0, 359, 1);
  167. + gtk_label_set_mnemonic_widget(GTK_LABEL(label), hscale);
  168. + gtk_scale_set_draw_value(GTK_SCALE(hscale), TRUE);
  169. + gtk_scale_set_value_pos(GTK_SCALE(hscale), GTK_POS_RIGHT);
  170. + gtk_range_set_increments(GTK_RANGE(hscale), 1, 5);
  171. + gtk_range_set_value(GTK_RANGE(hscale), bp->hue);
  172. + gtk_range_set_update_policy(GTK_RANGE(hscale), GTK_UPDATE_DISCONTINUOUS);
  173. + gtk_widget_show(hscale);
  174. + gtk_box_pack_start(GTK_BOX(hbox), hscale, TRUE, TRUE, 4);
  175. + g_signal_connect(G_OBJECT(hscale), "value-changed",
  176. + G_CALLBACK(update_hue), bp);
  177. + g_signal_connect(G_OBJECT(hscale), "format-value",
  178. + G_CALLBACK(hscale_format), NULL);
  179. +}
  180. +
  181. #if 0
  182. void
  183. toggle_set_background(GtkToggleButton *tb, BackdropPanel *bp)
  184. @@ -1218,6 +1323,12 @@
  185.  
  186. /* image brightness */
  187. add_brightness_slider(page, bp);
  188. +
  189. + /* image saturation */
  190. + add_saturation_slider(page, bp);
  191. +
  192. + /* image hue */
  193. + add_hue_slider(page, bp);
  194.  
  195. add_spacer(GTK_BOX(page));
  196.  
  197. diff -ur /tmp/xfdesktop-4.4.2.old/settings/settings-common.h /tmp/xfdesktop-4.4.2/settings/settings-common.h
  198. --- /tmp/xfdesktop-4.4.2.old/settings/settings-common.h 2007-11-17 20:31:41.000000000 +0100
  199. +++ /tmp/xfdesktop-4.4.2/settings/settings-common.h 2007-12-17 16:05:02.000000000 +0100
  200. @@ -61,6 +61,8 @@
  201. gchar *image_path;
  202. XfceBackdropImageStyle style;
  203. gint brightness;
  204. + gint saturation;
  205. + gint hue;
  206.  
  207. /* the notebook page */
  208. GtkWidget *page;
  209. diff -ur /tmp/xfdesktop-4.4.2.old/src/xfce-backdrop.c /tmp/xfdesktop-4.4.2/src/xfce-backdrop.c
  210. --- /tmp/xfdesktop-4.4.2.old/src/xfce-backdrop.c 2007-11-17 20:31:41.000000000 +0100
  211. +++ /tmp/xfdesktop-4.4.2/src/xfce-backdrop.c 2007-12-17 16:45:36.000000000 +0100
  212. @@ -45,16 +45,18 @@
  213. {
  214. gint width, height;
  215. gint bpp;
  216. -
  217. +
  218. XfceBackdropColorStyle color_style;
  219. GdkColor color1;
  220. GdkColor color2;
  221. -
  222. +
  223. gboolean show_image;
  224. XfceBackdropImageStyle image_style;
  225. gchar *image_path;
  226. -
  227. +
  228. gint brightness;
  229. + gint saturation;
  230. + gint hue;
  231. };
  232.  
  233. enum {
  234. @@ -74,24 +76,24 @@
  235. gboolean has_alpha = FALSE;
  236. gint i, len;
  237. GError *err = NULL;
  238. -
  239. +
  240. g_return_val_if_fail(src != NULL, NULL);
  241. if(amount == 0)
  242. return src;
  243. -
  244. +
  245. gdk_pixdata_from_pixbuf(&pdata, src, FALSE);
  246. has_alpha = (pdata.pixdata_type & GDK_PIXDATA_COLOR_TYPE_RGBA);
  247. if(pdata.length < 1)
  248. len = pdata.width * pdata.height * (has_alpha?4:3);
  249. else
  250. len = pdata.length - GDK_PIXDATA_HEADER_LENGTH;
  251. -
  252. +
  253. for(i = 0; i < len; i++) {
  254. gshort scaled;
  255. -
  256. +
  257. if(has_alpha && (i+1)%4)
  258. continue;
  259. -
  260. +
  261. scaled = pdata.pixel_data[i] + amount;
  262. if(scaled > 255)
  263. scaled = 255;
  264. @@ -99,7 +101,7 @@
  265. scaled = 0;
  266. pdata.pixel_data[i] = scaled;
  267. }
  268. -
  269. +
  270. newpix = gdk_pixbuf_from_pixdata(&pdata, TRUE, &err);
  271. if(!newpix) {
  272. g_warning("%s: Unable to modify image brightness: %s", PACKAGE,
  273. @@ -108,7 +110,136 @@
  274. return src;
  275. }
  276. g_object_unref(G_OBJECT(src));
  277. -
  278. +
  279. + return newpix;
  280. +}
  281. +
  282. +static GdkPixbuf *
  283. +adjust_saturation(GdkPixbuf *src, gint amount)
  284. +{
  285. + g_return_val_if_fail(src != NULL, NULL);
  286. + if(amount == 0)
  287. + return src;
  288. + GdkPixbuf *newpix = gdk_pixbuf_copy(src);
  289. + gdk_pixbuf_saturate_and_pixelate(src, newpix, ((gdouble)(amount+128))/127.5f, FALSE);
  290. + g_object_unref(G_OBJECT(src));
  291. + return newpix;
  292. +}
  293. +
  294. +static GdkPixbuf *
  295. +adjust_hue(GdkPixbuf *src, gint amount)
  296. +{
  297. + g_return_val_if_fail(src != NULL, NULL);
  298. + if(amount == 0)
  299. + return src;
  300. + GdkPixbuf *newpix;
  301. + GdkPixdata pdata;
  302. + gboolean has_alpha = FALSE;
  303. + gint i, len;
  304. + GError *err = NULL;
  305. +
  306. + g_return_val_if_fail(src != NULL, NULL);
  307. + if(amount == 0)
  308. + return src;
  309. +
  310. + gdk_pixdata_from_pixbuf(&pdata, src, FALSE);
  311. + has_alpha = (pdata.pixdata_type & GDK_PIXDATA_COLOR_TYPE_RGBA);
  312. + if(pdata.length < 1)
  313. + len = pdata.width * pdata.height * (has_alpha?4:3);
  314. + else
  315. + len = pdata.length - GDK_PIXDATA_HEADER_LENGTH;
  316. +
  317. + gint iInc=(has_alpha?4:3);
  318. + for(i = 0; i < len; i+=iInc) {
  319. + /* Get RGB pixel */
  320. + gint r,g,b;
  321. + r = pdata.pixel_data[i+0];
  322. + g = pdata.pixel_data[i+1];
  323. + b = pdata.pixel_data[i+2];
  324. +
  325. + /* Convert into HSV colorspace */
  326. + gint min, max;
  327. + min = MIN( r, MIN(g, b));
  328. + max = MAX( r, MAX(g, b));
  329. +
  330. + gdouble h,s,v;
  331. + if(min == max)
  332. + h = 0; else
  333. + if(max == r && g >= b )
  334. + h = 60.0f * ((gdouble)(g - b))/((gdouble)(max - min)) + 0.0f; else
  335. + if(max == r && g < b )
  336. + h = 60.0f * ((gdouble)(g - b))/((gdouble)(max - min)) + 360.0f; else
  337. + if(max == g)
  338. + h = 60.0f * ((gdouble)(b - r))/((gdouble)(max - min)) + 120.0f; else
  339. + if(max == b)
  340. + h = 60.0f * ((gdouble)(r - g))/((gdouble)(max - min)) + 240.0f;
  341. +
  342. + s = max == 0 ? 0.0f : 1.0f - (((gdouble)min)/((gdouble)max));
  343. + v = ((gdouble)max)/255.0f;
  344. +
  345. + /* Shift h by amount */
  346. + h += amount;
  347. + while(h>=360.0f) h -= 360.0f;
  348. +
  349. + /* convert HSV back to RGB */
  350. + gdouble f, p, q, t;
  351. + gint hi;
  352. + hi = ((int)(h/60.0f))%6;
  353. + f = (h/60.0f) - ((gdouble)hi);
  354. + p = v * (1.0f - s);
  355. + q = v * (1.0f - (f * s));
  356. + t = v * (1.0f - ((1.0f - f) * s));
  357. +
  358. + switch( hi ) {
  359. + case 0:
  360. + r = v * 255.0f;
  361. + g = t * 255.0f;
  362. + b = p * 255.0f;
  363. + break;
  364. + case 1:
  365. + r = q * 255.0f;
  366. + g = v * 255.0f;
  367. + b = p * 255.0f;
  368. + break;
  369. + case 2:
  370. + r = p * 255.0f;
  371. + g = v * 255.0f;
  372. + b = t * 255.0f;
  373. + break;
  374. + case 3:
  375. + r = p * 255.0f;
  376. + g = q * 255.0f;
  377. + b = v * 255.0f;
  378. + break;
  379. + case 4:
  380. + r = t * 255.0f;
  381. + g = p * 255.0f;
  382. + b = v * 255.0f;
  383. + break;
  384. + case 5:
  385. + r = v * 255.0f;
  386. + g = p * 255.0f;
  387. + b = q * 255.0f;
  388. + break;
  389. + default:
  390. + g_return_val_if_fail( (hi >= 0) && (hi < 6), NULL);
  391. + }
  392. +
  393. + /* update pixel data */
  394. + pdata.pixel_data[i + 0] = r;
  395. + pdata.pixel_data[i + 1] = g;
  396. + pdata.pixel_data[i + 2] = b;
  397. + }
  398. +
  399. + newpix = gdk_pixbuf_from_pixdata(&pdata, TRUE, &err);
  400. + if(!newpix) {
  401. + g_warning("%s: Unable to modify image brightness: %s", PACKAGE,
  402. + err->message);
  403. + g_error_free(err);
  404. + return src;
  405. + }
  406. + g_object_unref(G_OBJECT(src));
  407. +
  408. return newpix;
  409. }
  410.  
  411. @@ -117,14 +248,14 @@
  412. {
  413. GdkPixbuf *pix;
  414. guint32 rgba;
  415. -
  416. +
  417. pix = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, 8, width, height);
  418. -
  419. +
  420. rgba = (((color->red & 0xff00) << 8) | ((color->green & 0xff00))
  421. | ((color->blue & 0xff00) >> 8)) << 8;
  422. -
  423. +
  424. gdk_pixbuf_fill(pix, rgba);
  425. -
  426. +
  427. return pix;
  428. }
  429.  
  430. @@ -137,12 +268,12 @@
  431. GdkPixdata pixdata;
  432. guint8 rgb[3];
  433. GError *err = NULL;
  434. -
  435. +
  436. g_return_val_if_fail(color1 != NULL && color2 != NULL, NULL);
  437. g_return_val_if_fail(width > 0 && height > 0, NULL);
  438. g_return_val_if_fail(style == XFCE_BACKDROP_COLOR_HORIZ_GRADIENT
  439. || style == XFCE_BACKDROP_COLOR_VERT_GRADIENT, NULL);
  440. -
  441. +
  442. pixdata.magic = GDK_PIXBUF_MAGIC_NUMBER;
  443. pixdata.length = GDK_PIXDATA_HEADER_LENGTH + (width * height * 3);
  444. pixdata.pixdata_type = GDK_PIXDATA_COLOR_TYPE_RGB
  445. @@ -159,7 +290,7 @@
  446. rgb[2] = (color1->blue + (i * (color2->blue - color1->blue) / width)) >> 8;
  447. memcpy(pixdata.pixel_data+(i*3), rgb, 3);
  448. }
  449. -
  450. +
  451. for(i = 1; i < height; i++) {
  452. memcpy(pixdata.pixel_data+(i*pixdata.rowstride),
  453. pixdata.pixel_data, pixdata.rowstride);
  454. @@ -173,16 +304,16 @@
  455. memcpy(pixdata.pixel_data+(i*pixdata.rowstride)+(j*3), rgb, 3);
  456. }
  457. }
  458. -
  459. +
  460. pix = gdk_pixbuf_from_pixdata(&pixdata, TRUE, &err);
  461. if(!pix) {
  462. g_warning("%s: Unable to create color gradient: %s\n", PACKAGE,
  463. err->message);
  464. g_error_free(err);
  465. }
  466. -
  467. +
  468. g_free(pixdata.pixel_data);
  469. -
  470. +
  471. return pix;
  472. }
  473.  
  474. @@ -196,11 +327,11 @@
  475. xfce_backdrop_class_init(XfceBackdropClass *klass)
  476. {
  477. GObjectClass *gobject_class = (GObjectClass *)klass;
  478. -
  479. +
  480. g_type_class_add_private(klass, sizeof(XfceBackdropPriv));
  481. -
  482. +
  483. gobject_class->finalize = xfce_backdrop_finalize;
  484. -
  485. +
  486. backdrop_signals[BACKDROP_CHANGED] = g_signal_new("changed",
  487. G_OBJECT_CLASS_TYPE(gobject_class), G_SIGNAL_RUN_FIRST,
  488. G_STRUCT_OFFSET(XfceBackdropClass, changed), NULL, NULL,
  489. @@ -219,12 +350,12 @@
  490. xfce_backdrop_finalize(GObject *object)
  491. {
  492. XfceBackdrop *backdrop = XFCE_BACKDROP(object);
  493. -
  494. +
  495. g_return_if_fail(backdrop != NULL);
  496. -
  497. +
  498. if(backdrop->priv->image_path)
  499. g_free(backdrop->priv->image_path);
  500. -
  501. +
  502. G_OBJECT_CLASS(xfce_backdrop_parent_class)->finalize(object);
  503. }
  504.  
  505. @@ -244,12 +375,12 @@
  506. xfce_backdrop_new(GdkVisual *visual)
  507. {
  508. XfceBackdrop *backdrop;
  509. -
  510. +
  511. g_return_val_if_fail(GDK_IS_VISUAL(visual), NULL);
  512. -
  513. +
  514. backdrop = g_object_new(XFCE_TYPE_BACKDROP, NULL);
  515. backdrop->priv->bpp = visual->depth;
  516. -
  517. +
  518. return backdrop;
  519. }
  520.  
  521. @@ -266,15 +397,15 @@
  522. xfce_backdrop_new_with_size(GdkVisual *visual, gint width, gint height)
  523. {
  524. XfceBackdrop *backdrop;
  525. -
  526. +
  527. g_return_val_if_fail(GDK_IS_VISUAL(visual), NULL);
  528. -
  529. +
  530. backdrop = g_object_new(XFCE_TYPE_BACKDROP, NULL);
  531. -
  532. +
  533. backdrop->priv->bpp = visual->depth;
  534. backdrop->priv->width = width;
  535. backdrop->priv->height = height;
  536. -
  537. +
  538. return backdrop;
  539. }
  540.  
  541. @@ -292,7 +423,7 @@
  542. xfce_backdrop_set_size(XfceBackdrop *backdrop, gint width, gint height)
  543. {
  544. g_return_if_fail(XFCE_IS_BACKDROP(backdrop));
  545. -
  546. +
  547. backdrop->priv->width = width;
  548. backdrop->priv->height = height;
  549. }
  550. @@ -309,7 +440,7 @@
  551. XfceBackdropColorStyle style)
  552. {
  553. g_return_if_fail(XFCE_IS_BACKDROP(backdrop));
  554. -
  555. +
  556. if(style != backdrop->priv->color_style) {
  557. backdrop->priv->color_style = style;
  558. g_signal_emit(G_OBJECT(backdrop), backdrop_signals[BACKDROP_CHANGED], 0);
  559. @@ -340,7 +471,7 @@
  560. const GdkColor *color)
  561. {
  562. g_return_if_fail(XFCE_IS_BACKDROP(backdrop) && color != NULL);
  563. -
  564. +
  565. if(color->red != backdrop->priv->color1.red
  566. || color->green != backdrop->priv->color1.green
  567. || color->blue != backdrop->priv->color1.blue)
  568. @@ -357,7 +488,7 @@
  569. GdkColor *color)
  570. {
  571. g_return_if_fail(XFCE_IS_BACKDROP(backdrop) && color);
  572. -
  573. +
  574. memcpy(color, &backdrop->priv->color1, sizeof(GdkColor));
  575. }
  576.  
  577. @@ -376,7 +507,7 @@
  578. const GdkColor *color)
  579. {
  580. g_return_if_fail(XFCE_IS_BACKDROP(backdrop) && color != NULL);
  581. -
  582. +
  583. if(color->red != backdrop->priv->color2.red
  584. || color->green != backdrop->priv->color2.green
  585. || color->blue != backdrop->priv->color2.blue)
  586. @@ -394,7 +525,7 @@
  587. GdkColor *color)
  588. {
  589. g_return_if_fail(XFCE_IS_BACKDROP(backdrop) && color);
  590. -
  591. +
  592. memcpy(color, &backdrop->priv->color2, sizeof(GdkColor));
  593. }
  594.  
  595. @@ -410,7 +541,7 @@
  596. xfce_backdrop_set_show_image(XfceBackdrop *backdrop, gboolean show_image)
  597. {
  598. g_return_if_fail(XFCE_IS_BACKDROP(backdrop));
  599. -
  600. +
  601. if(backdrop->priv->show_image != show_image) {
  602. backdrop->priv->show_image = show_image;
  603. g_signal_emit(G_OBJECT(backdrop), backdrop_signals[BACKDROP_CHANGED], 0);
  604. @@ -440,7 +571,7 @@
  605. XfceBackdropImageStyle style)
  606. {
  607. g_return_if_fail(XFCE_IS_BACKDROP(backdrop));
  608. -
  609. +
  610. if(style != backdrop->priv->image_style) {
  611. backdrop->priv->image_style = style;
  612. g_signal_emit(G_OBJECT(backdrop), backdrop_signals[BACKDROP_CHANGED], 0);
  613. @@ -468,12 +599,12 @@
  614. xfce_backdrop_set_image_filename(XfceBackdrop *backdrop, const gchar *filename)
  615. {
  616. g_return_if_fail(XFCE_IS_BACKDROP(backdrop));
  617. -
  618. +
  619. if(backdrop->priv->image_path)
  620. g_free(backdrop->priv->image_path);
  621. -
  622. +
  623. backdrop->priv->image_path = g_strdup(filename);
  624. -
  625. +
  626. g_signal_emit(G_OBJECT(backdrop), backdrop_signals[BACKDROP_CHANGED], 0);
  627. }
  628.  
  629. @@ -497,7 +628,7 @@
  630. xfce_backdrop_set_brightness(XfceBackdrop *backdrop, gint brightness)
  631. {
  632. g_return_if_fail(XFCE_IS_BACKDROP(backdrop));
  633. -
  634. +
  635. if(brightness != backdrop->priv->brightness) {
  636. backdrop->priv->brightness = brightness;
  637. g_signal_emit(G_OBJECT(backdrop), backdrop_signals[BACKDROP_CHANGED], 0);
  638. @@ -512,6 +643,53 @@
  639. }
  640.  
  641. /**
  642. + * xfce_backdrop_set_saturation:
  643. + * @backdrop: An #XfceBackdrop.
  644. + * @saturation: A saturation value.
  645. + *
  646. + * Modifies the saturation of the backdrop using a value between -128 and 127.
  647. + * A value of 0 indicates that the saturation should not be changed. This value
  648. + * is applied to the entire image, after compositing.
  649. + **/
  650. +void
  651. +xfce_backdrop_set_saturation(XfceBackdrop *backdrop, gint saturation)
  652. +{
  653. + g_return_if_fail(XFCE_IS_BACKDROP(backdrop));
  654. +
  655. + if(saturation != backdrop->priv->saturation) {
  656. + backdrop->priv->saturation = saturation;
  657. + g_signal_emit(G_OBJECT(backdrop), backdrop_signals[BACKDROP_CHANGED], 0);
  658. + }
  659. +}
  660. +
  661. +/**
  662. + * xfce_backdrop_set_hue:
  663. + * @backdrop: An #XfceBackdrop.
  664. + * @hue: A hue value.
  665. + *
  666. + * Shifts the hue of the backdrop using a value between 0 and 359 degrees.
  667. + * A value of 0 indicates that the hue should not be changed. This value
  668. + * is applied to the entire image, after compositing.
  669. + **/
  670. +void
  671. +xfce_backdrop_set_hue(XfceBackdrop *backdrop, gint hue)
  672. +{
  673. + g_return_if_fail(XFCE_IS_BACKDROP(backdrop));
  674. +
  675. + if(hue != backdrop->priv->hue) {
  676. + backdrop->priv->hue = hue;
  677. + g_signal_emit(G_OBJECT(backdrop), backdrop_signals[BACKDROP_CHANGED], 0);
  678. + }
  679. +}
  680. +
  681. +gint
  682. +xfce_backdrop_get_hue(XfceBackdrop *backdrop)
  683. +{
  684. + g_return_val_if_fail(XFCE_IS_BACKDROP(backdrop), 0);
  685. + return backdrop->priv->hue;
  686. +}
  687. +
  688. +/**
  689. * xfce_backdrop_get_pixbuf:
  690. * @backdrop: An #XfceBackdrop.
  691. *
  692. @@ -530,9 +708,9 @@
  693. gint dx, dy, xo, yo;
  694. gdouble xscale, yscale;
  695. GdkInterpType interp;
  696. -
  697. +
  698. g_return_val_if_fail(XFCE_IS_BACKDROP(backdrop), NULL);
  699. -
  700. +
  701. if(backdrop->priv->show_image && backdrop->priv->image_path) {
  702. image = gdk_pixbuf_new_from_file(backdrop->priv->image_path, NULL);
  703. if(image) {
  704. @@ -540,7 +718,7 @@
  705. ih = gdk_pixbuf_get_height(image);
  706. }
  707. }
  708. -
  709. +
  710. if(backdrop->priv->width == 0 || backdrop->priv->height == 0) {
  711. if(!image)
  712. return NULL;
  713. @@ -550,7 +728,7 @@
  714. w = backdrop->priv->width;
  715. h = backdrop->priv->height;
  716. }
  717. -
  718. +
  719. if(backdrop->priv->color_style == XFCE_BACKDROP_COLOR_SOLID)
  720. final_image = create_solid(&backdrop->priv->color1, w, h);
  721. else {
  722. @@ -559,27 +737,31 @@
  723. if(!final_image)
  724. final_image = create_solid(&backdrop->priv->color1, w, h);
  725. }
  726. -
  727. +
  728. if(!image) {
  729. if(backdrop->priv->brightness != 0)
  730. final_image = adjust_brightness(final_image, backdrop->priv->brightness);
  731. -
  732. + if(backdrop->priv->saturation != 0)
  733. + final_image = adjust_saturation(final_image, backdrop->priv->saturation);
  734. + if(backdrop->priv->hue != 0)
  735. + final_image = adjust_hue(final_image, backdrop->priv->hue);
  736. +
  737. return final_image;
  738. }
  739. -
  740. +
  741. if(backdrop->priv->image_style == XFCE_BACKDROP_IMAGE_AUTO) {
  742. if(ih <= h / 2 && iw <= w / 2)
  743. istyle = XFCE_BACKDROP_IMAGE_TILED;
  744. else
  745. - istyle = XFCE_BACKDROP_IMAGE_SCALED;
  746. + istyle = XFCE_BACKDROP_IMAGE_MAXPECT;
  747. } else
  748. istyle = backdrop->priv->image_style;
  749. -
  750. +
  751. /* if the image is the same as the screen size, there's no reason to do
  752. * any scaling at all */
  753. if(w == iw && h == ih)
  754. istyle = XFCE_BACKDROP_IMAGE_CENTERED;
  755. -
  756. +
  757. /* if we don't need to do any scaling, don't do any interpolation. this
  758. * fixes a problem where hyper/bilinear filtering causes blurriness in
  759. * some images. http://bugzilla.xfce.org/show_bug.cgi?id=2939 */
  760. @@ -595,7 +777,7 @@
  761. else
  762. interp = GDK_INTERP_BILINEAR;
  763. }
  764. -
  765. +
  766. switch(istyle) {
  767. case XFCE_BACKDROP_IMAGE_CENTERED:
  768. dx = MAX((w - iw) / 2, 0);
  769. @@ -606,36 +788,52 @@
  770. MIN(w, iw), MIN(h, ih), xo, yo, 1.0, 1.0,
  771. interp, 255);
  772. break;
  773. -
  774. +
  775. case XFCE_BACKDROP_IMAGE_TILED:
  776. tmp = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, w, h);
  777. for(i = 0; (i * iw) < w; i++) {
  778. for(j = 0; (j * ih) < h; j++) {
  779. gint newx = iw * i, newy = ih * j;
  780. gint neww = iw, newh = ih;
  781. -
  782. +
  783. if((newx + neww) > w)
  784. neww = w - newx;
  785. if((newy + newh) > h)
  786. newh = h - newy;
  787. -
  788. +
  789. gdk_pixbuf_copy_area(image, 0, 0,
  790. neww, newh, tmp, newx, newy);
  791. }
  792. }
  793. -
  794. +
  795. gdk_pixbuf_composite(tmp, final_image, 0, 0, w, h,
  796. 0, 0, 1.0, 1.0, interp, 255);
  797. g_object_unref(G_OBJECT(tmp));
  798. break;
  799. -
  800. +
  801. case XFCE_BACKDROP_IMAGE_STRETCHED:
  802. xscale = (gdouble)w / iw;
  803. yscale = (gdouble)h / ih;
  804. gdk_pixbuf_composite(image, final_image, 0, 0, w, h,
  805. 0, 0, xscale, yscale, interp, 255);
  806. break;
  807. -
  808. +
  809. + case XFCE_BACKDROP_IMAGE_MAXPECT:
  810. + xscale = (gdouble)w / iw;
  811. + yscale = (gdouble)h / ih;
  812. + if( xscale < yscale ) {
  813. + xscale = yscale;
  814. + dx = (w - (iw * yscale)) / 2;
  815. + dy = 0;
  816. + } else {
  817. + yscale = xscale;
  818. + dy = (h - (ih * xscale)) / 2;
  819. + dx = 0;
  820. + }
  821. + gdk_pixbuf_composite( image, final_image, 0, 0,
  822. + w, h, dx, dy,
  823. + xscale, yscale, interp, 255);
  824. + break;
  825. case XFCE_BACKDROP_IMAGE_SCALED:
  826. xscale = (gdouble)w / iw;
  827. yscale = (gdouble)h / ih;
  828. @@ -650,21 +848,24 @@
  829. }
  830. dx = xo;
  831. dy = yo;
  832. -
  833. +
  834. gdk_pixbuf_composite(image, final_image, dx, dy,
  835. iw * xscale, ih * yscale, xo, yo, xscale, yscale,
  836. interp, 255);
  837. break;
  838. -
  839. default:
  840. g_critical("Invalid image style: %d\n", (gint)istyle);
  841. }
  842. -
  843. +
  844. if(image)
  845. g_object_unref(G_OBJECT(image));
  846. -
  847. +
  848. if(backdrop->priv->brightness != 0)
  849. final_image = adjust_brightness(final_image, backdrop->priv->brightness);
  850. -
  851. + if(backdrop->priv->saturation != 0)
  852. + final_image = adjust_saturation(final_image, backdrop->priv->saturation);
  853. + if(backdrop->priv->hue != 0)
  854. + final_image = adjust_hue(final_image, backdrop->priv->hue);
  855. +
  856. return final_image;
  857. }
  858. Only in /tmp/xfdesktop-4.4.2/src: xfce-backdrop.c~
  859. diff -ur /tmp/xfdesktop-4.4.2.old/src/xfce-backdrop.h /tmp/xfdesktop-4.4.2/src/xfce-backdrop.h
  860. --- /tmp/xfdesktop-4.4.2.old/src/xfce-backdrop.h 2007-11-17 20:31:41.000000000 +0100
  861. +++ /tmp/xfdesktop-4.4.2/src/xfce-backdrop.h 2007-12-17 16:05:02.000000000 +0100
  862. @@ -48,7 +48,8 @@
  863. XFCE_BACKDROP_IMAGE_CENTERED,
  864. XFCE_BACKDROP_IMAGE_TILED,
  865. XFCE_BACKDROP_IMAGE_STRETCHED,
  866. - XFCE_BACKDROP_IMAGE_SCALED
  867. + XFCE_BACKDROP_IMAGE_SCALED,
  868. + XFCE_BACKDROP_IMAGE_MAXPECT
  869. } XfceBackdropImageStyle;
  870.  
  871. typedef enum
  872. @@ -119,6 +120,10 @@
  873. gint brightness);
  874. gint xfce_backdrop_get_brightness (XfceBackdrop *backdrop);
  875.  
  876. +void xfce_backdrop_set_saturation (XfceBackdrop *backdrop,
  877. + gint saturation);
  878. +gint xfce_backdrop_get_saturation (XfceBackdrop *backdrop);
  879. +
  880. GdkPixbuf *xfce_backdrop_get_pixbuf (XfceBackdrop *backdrop);
  881.  
  882. G_END_DECLS
  883. diff -ur /tmp/xfdesktop-4.4.2.old/src/xfce-desktop-settings.c /tmp/xfdesktop-4.4.2/src/xfce-desktop-settings.c
  884. --- /tmp/xfdesktop-4.4.2.old/src/xfce-desktop-settings.c 2007-11-17 20:31:41.000000000 +0100
  885. +++ /tmp/xfdesktop-4.4.2/src/xfce-desktop-settings.c 2007-12-17 16:05:02.000000000 +0100
  886. @@ -364,6 +364,24 @@
  887. setting = NULL;
  888. } else
  889. xfce_backdrop_set_brightness(backdrop, 0);
  890. + g_snprintf(setting_name, 64, "saturation_%d_%d", screen, i);
  891. + if(MCS_SUCCESS == mcs_client_get_setting(mcs_client, setting_name,
  892. + BACKDROP_CHANNEL, &setting))
  893. + {
  894. + xfce_backdrop_set_saturation(backdrop, setting->data.v_int);
  895. + mcs_setting_free(setting);
  896. + setting = NULL;
  897. + } else
  898. + xfce_backdrop_set_saturation(backdrop, 0);
  899. + g_snprintf(setting_name, 64, "hue_%d_%d", screen, i);
  900. + if(MCS_SUCCESS == mcs_client_get_setting(mcs_client, setting_name,
  901. + BACKDROP_CHANNEL, &setting))
  902. + {
  903. + xfce_backdrop_set_hue(backdrop, setting->data.v_int);
  904. + mcs_setting_free(setting);
  905. + setting = NULL;
  906. + } else
  907. + xfce_backdrop_set_hue(backdrop, 0);
  908. }
  909.  
  910. xfce_desktop_thaw_updates(desktop);
  911. @@ -481,6 +499,12 @@
  912. } else if(strstr(setting->name, "brightness") == setting->name) {
  913. xfce_backdrop_set_brightness(backdrop, setting->data.v_int);
  914. handled = TRUE;
  915. + } else if(strstr(setting->name, "saturation") == setting->name) {
  916. + xfce_backdrop_set_saturation(backdrop, setting->data.v_int);
  917. + handled = TRUE;
  918. + } else if(strstr(setting->name, "hue") == setting->name) {
  919. + xfce_backdrop_set_hue(backdrop, setting->data.v_int);
  920. + handled = TRUE;
  921. }
  922.  
  923. break;
  924.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement