[f-spot: 22/41] drop the TransparentColor stuffs, replaced by secial CheckPattern
- From: Stephane Delcroix <sdelcroix src gnome org>
- To: svn-commits-list gnome org
- Subject: [f-spot: 22/41] drop the TransparentColor stuffs, replaced by secial CheckPattern
- Date: Mon, 15 Jun 2009 08:41:42 -0400 (EDT)
commit 824e195593c21085d03aba9d93ea9a041378bb72
Author: Stephane Delcroix <stephane delcroix org>
Date: Wed Jun 10 10:40:12 2009 +0200
drop the TransparentColor stuffs, replaced by secial CheckPattern
src/PhotoImageView.cs | 2 +-
src/SingleView.cs | 8 ++++----
src/Widgets/CheckPattern.cs | 37 +++++++++++++++++++++++++++++++++++++
src/Widgets/ImageView.cs | 35 ++++-------------------------------
4 files changed, 46 insertions(+), 36 deletions(-)
---
diff --git a/src/PhotoImageView.cs b/src/PhotoImageView.cs
index 3ef67fb..2458121 100644
--- a/src/PhotoImageView.cs
+++ b/src/PhotoImageView.cs
@@ -50,7 +50,7 @@ namespace FSpot.Widgets {
protected override void OnStyleSet (Gtk.Style previous)
{
- this.SetTransparentColor (this.Style.Backgrounds [(int)Gtk.StateType.Normal]);
+ CheckPattern = new CheckPattern (this.Style.Backgrounds [(int)Gtk.StateType.Normal]);
}
new public BrowsablePointer Item {
diff --git a/src/SingleView.cs b/src/SingleView.cs
index 7cbb45e..9ba6eef 100644
--- a/src/SingleView.cs
+++ b/src/SingleView.cs
@@ -581,16 +581,16 @@ namespace FSpot {
case Preferences.VIEWER_TRANSPARENCY:
if (Preferences.Get<string> (key) == "CHECK_PATTERN")
- image_view.SetCheckSize (2);
+ image_view.CheckPattern = CheckPattern.Dark;
else if (Preferences.Get<string> (key) == "COLOR")
- image_view.SetTransparentColor (Preferences.Get<string> (Preferences.VIEWER_TRANS_COLOR));
+ image_view.CheckPattern = new CheckPattern (Preferences.Get<string> (Preferences.VIEWER_TRANS_COLOR));
else // NONE
- image_view.SetTransparentColor (image_view.Style.BaseColors [(int)Gtk.StateType.Normal]);
+ image_view.CheckPattern = new CheckPattern (image_view.Style.BaseColors [(int)Gtk.StateType.Normal]);
break;
case Preferences.VIEWER_TRANS_COLOR:
if (Preferences.Get<string> (Preferences.VIEWER_TRANSPARENCY) == "COLOR")
- image_view.SetTransparentColor (Preferences.Get<string> (key));
+ image_view.CheckPattern = new CheckPattern (Preferences.Get<string> (key));
break;
}
}
diff --git a/src/Widgets/CheckPattern.cs b/src/Widgets/CheckPattern.cs
index 40b3dc7..33e3321 100644
--- a/src/Widgets/CheckPattern.cs
+++ b/src/Widgets/CheckPattern.cs
@@ -7,6 +7,9 @@
// This is free software. See COPYING for details.
//
+using System;
+using Gdk;
+
namespace FSpot.Widgets
{
public struct CheckPattern
@@ -21,6 +24,25 @@ namespace FSpot.Widgets
this.check_size = check_size;
}
+ public CheckPattern (string color1, string color2, int check_size) : this (s_to_h (color1), s_to_h (color2), check_size)
+ {
+ }
+
+ public CheckPattern (uint transparent_color)
+ {
+ color1 = color2 = transparent_color;
+ check_size = 32;
+ }
+
+ //format "#000000"
+ public CheckPattern (string transparent_color) : this (s_to_h (transparent_color))
+ {
+ }
+
+ public CheckPattern (Color transparent_color) : this (c_to_h (transparent_color))
+ {
+ }
+
public uint Color1
{
get { return color1; }
@@ -42,5 +64,20 @@ namespace FSpot.Widgets
public static CheckPattern Black = new CheckPattern (0x00000000, 0x00000000, 8);
public static CheckPattern Gray = new CheckPattern (0x00808080, 0x00808080, 8);
public static CheckPattern White = new CheckPattern (0x00ffffff, 0x00ffffff, 8);
+
+ static uint s_to_h (string color)
+ {
+ return (uint)(Byte.Parse (color.Substring (1,2), System.Globalization.NumberStyles.AllowHexSpecifier) << 16) +
+ (uint)(Byte.Parse (color.Substring (3,2), System.Globalization.NumberStyles.AllowHexSpecifier) << 8) +
+ (uint)(Byte.Parse (color.Substring (5,2), System.Globalization.NumberStyles.AllowHexSpecifier));
+ }
+
+ static uint c_to_h (Color color)
+ {
+ return (((uint)color.Red) << 16) +
+ (((uint)color.Green) << 8) +
+ (((uint)color.Blue));
+ }
+
}
}
diff --git a/src/Widgets/ImageView.cs b/src/Widgets/ImageView.cs
index c2a4326..ea939a5 100644
--- a/src/Widgets/ImageView.cs
+++ b/src/Widgets/ImageView.cs
@@ -30,7 +30,6 @@ namespace FSpot.Widgets
public ImageView () : base (null, null)
{
- transparent_color = this.Style.BaseColors [(int)Gtk.StateType.Normal];
}
Pixbuf pixbuf;
@@ -53,9 +52,10 @@ namespace FSpot.Widgets
}
}
- public int CheckSize {
- get { throw new NotImplementedException ();}
- set { throw new NotImplementedException ();}
+ CheckPattern check_pattern = CheckPattern.Dark;
+ public CheckPattern CheckPattern {
+ get { return check_pattern; }
+ set { check_pattern = value; }
}
public PointerMode PointerMode {
@@ -147,33 +147,6 @@ namespace FSpot.Widgets
DoZoom (zoom * zoom_increment, true, x, y);
}
- Gdk.Color transparent_color;
- public Gdk.Color TransparentColor {
- get { return transparent_color; }
- set { transparent_color = value; }
- }
-
- [Obsolete ("Use the TransparentColor property")]
- public void SetTransparentColor (Gdk.Color color)
- {
- TransparentColor = color;
- }
-
- public void SetTransparentColor (string color) //format "#000000"
- {
- TransparentColor = new Gdk.Color (
- Byte.Parse (color.Substring (1,2), System.Globalization.NumberStyles.AllowHexSpecifier),
- Byte.Parse (color.Substring (3,2), System.Globalization.NumberStyles.AllowHexSpecifier),
- Byte.Parse (color.Substring (5,2), System.Globalization.NumberStyles.AllowHexSpecifier)
- );
- }
-
- [Obsolete ("use the CheckSize Property instead")]
- public void SetCheckSize (int size)
- {
- CheckSize = size;
- }
-
public Gdk.Point WindowCoordsToImage (Point win)
{
throw new NotImplementedException ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]