summaryrefslogtreecommitdiff
path: root/src/utilities/color.vala
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2015-05-03 07:25:38 +0200
committerJörg Frings-Fürst <debian@jff-webhosting.net>2015-05-03 07:25:38 +0200
commitdaab38595df60c0ef3e142c195382cb35d448203 (patch)
tree4186938621912272570b4187a4d8ef8e3ca87b47 /src/utilities/color.vala
parentfbd5a9eb0d29bdfd9f5f0892190452e17871afd9 (diff)
parenta1c05d93bbb3c1bdb0c0fed9d7110804037cfd55 (diff)
Merge tag 'upstream/0.6.2'
Upstream version 0.6.2
Diffstat (limited to 'src/utilities/color.vala')
-rw-r--r--src/utilities/color.vala21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/utilities/color.vala b/src/utilities/color.vala
index 6bb9d06..a681e02 100644
--- a/src/utilities/color.vala
+++ b/src/utilities/color.vala
@@ -77,6 +77,19 @@ public class Color: GLib.Object {
}
/////////////////////////////////////////////////////////////////////
+ /// Creates a color from a given widget style
+ /////////////////////////////////////////////////////////////////////
+
+ public Color.from_widget_style(Gtk.Widget widget, string style_name) {
+ var ctx = widget.get_style_context();
+ Gdk.RGBA color;
+ if (!ctx.lookup_color(style_name, out color)) {
+ warning("Failed to get style color for widget style \"" + style_name + "\"!");
+ }
+ Color.from_gdk(color);
+ }
+
+ /////////////////////////////////////////////////////////////////////
/// Creates a color, parsed from a string, such as #22EE33
/////////////////////////////////////////////////////////////////////
@@ -129,6 +142,14 @@ public class Color: GLib.Object {
}
/////////////////////////////////////////////////////////////////////
+ /// Returns this color as its hex representation.
+ /////////////////////////////////////////////////////////////////////
+
+ public string to_hex_string() {
+ return "#%02X%02X%02X".printf((int)(_r*255), (int)(_g*255), (int)(_b*255));
+ }
+
+ /////////////////////////////////////////////////////////////////////
/// The reddish part of the color.
/////////////////////////////////////////////////////////////////////