diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2015-05-03 07:25:37 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2015-05-03 07:25:37 +0200 |
commit | a1c05d93bbb3c1bdb0c0fed9d7110804037cfd55 (patch) | |
tree | cb97ed3768912934cfc0e817beca620200d91993 /src/utilities/color.vala | |
parent | 5478fe2ceb86715f4ab9a51eb97c517465febfa6 (diff) |
Imported Upstream version 0.6.2upstream/0.6.2
Diffstat (limited to 'src/utilities/color.vala')
-rw-r--r-- | src/utilities/color.vala | 21 |
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. ///////////////////////////////////////////////////////////////////// |