summaryrefslogtreecommitdiff
path: root/gtk2_ardour/utils.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2007-11-08 01:40:25 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2007-11-08 01:40:25 +0000
commitbadc087263990ecf360792c10e4d9f2d60828d43 (patch)
tree7e4b7e0afea47be51cbad48f06bb1779f483f56f /gtk2_ardour/utils.cc
parentdf20e5935fbdaf7d27f924e4e2ea87707d8a2314 (diff)
merged with 2.0-ongoing changes 2582-2605 (not thoroughly tested but it compiles, start up, and creates a new session)
git-svn-id: svn://localhost/ardour2/trunk@2606 d708f5d6-7413-0410-9779-e7cbd77b26cf
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)
{