summaryrefslogtreecommitdiff
path: root/gtk2_ardour/utils.cc
diff options
context:
space:
mode:
Diffstat (limited to 'gtk2_ardour/utils.cc')
-rw-r--r--gtk2_ardour/utils.cc56
1 files changed, 56 insertions, 0 deletions
diff --git a/gtk2_ardour/utils.cc b/gtk2_ardour/utils.cc
index 570a481c11..941132396a 100644
--- a/gtk2_ardour/utils.cc
+++ b/gtk2_ardour/utils.cc
@@ -22,6 +22,7 @@
#include <fstream>
#include <sys/stat.h>
#include <libart_lgpl/art_misc.h>
+#include <gtkmm/rc.h>
#include <gtkmm/window.h>
#include <gtkmm/combo.h>
#include <gtkmm/label.h>
@@ -325,6 +326,61 @@ rgba_from_style (string style, uint32_t r, uint32_t g, uint32_t b, uint32_t a, s
}
}
+
+Gdk::Color
+color_from_style (string widget_style_name, int state, string attr)
+{
+ GtkStyle* style;
+
+ style = gtk_rc_get_style_by_paths (gtk_settings_get_default(),
+ widget_style_name.c_str(),
+ 0, G_TYPE_NONE);
+
+ if (!style) {
+ error << string_compose (_("no style found for %1, using red"), style) << endmsg;
+ return Gdk::Color ("red");
+ }
+
+ cerr << "got style for " << widget_style_name << endl;
+
+ if (attr == "fg") {
+ return Gdk::Color (&style->fg[state]);
+ }
+
+ if (attr == "bg") {
+ cerr << "returning color from bg\n";
+ return Gdk::Color (&style->bg[state]);
+ }
+
+ if (attr == "light") {
+ return Gdk::Color (&style->light[state]);
+ }
+
+ if (attr == "dark") {
+ return Gdk::Color (&style->dark[state]);
+ }
+
+ if (attr == "mid") {
+ return Gdk::Color (&style->mid[state]);
+ }
+
+ if (attr == "text") {
+ return Gdk::Color (&style->text[state]);
+ }
+
+ if (attr == "base") {
+ return Gdk::Color (&style->base[state]);
+ }
+
+ if (attr == "text_aa") {
+ return Gdk::Color (&style->text_aa[state]);
+ }
+
+ error << string_compose (_("unknown style attribute %1 requested for color; using \"red\""), attr) << endmsg;
+ return Gdk::Color ("red");
+}
+
+
bool
canvas_item_visible (ArdourCanvas::Item* item)
{