summaryrefslogtreecommitdiff
path: root/plugins/gtkui/gdkdrawing.c
diff options
context:
space:
mode:
authorGravatar Alexey Yakovenko <wakeroid@gmail.com>2010-03-10 19:36:10 +0100
committerGravatar Alexey Yakovenko <wakeroid@gmail.com>2010-03-10 19:36:10 +0100
commitaa30e6b53816629d2fd4cb4dbd1f9a35b1473563 (patch)
treeb8486438045e3022a8178e9d8c535481bd7a7441 /plugins/gtkui/gdkdrawing.c
parent18b350cc0ee0c53d5ae93384576146a064bb5372 (diff)
custom widget colors WIP
Diffstat (limited to 'plugins/gtkui/gdkdrawing.c')
-rw-r--r--plugins/gtkui/gdkdrawing.c81
1 files changed, 74 insertions, 7 deletions
diff --git a/plugins/gtkui/gdkdrawing.c b/plugins/gtkui/gdkdrawing.c
index c78f5d54..3a992627 100644
--- a/plugins/gtkui/gdkdrawing.c
+++ b/plugins/gtkui/gdkdrawing.c
@@ -21,9 +21,11 @@
#endif
#include <gtk/gtk.h>
-#include <gdk/gdkkeysyms.h>
+//#include <gdk/gdkkeysyms.h>
+#include <string.h>
#include "drawing.h"
#include "support.h"
+#include "gtkui.h"
static GdkDrawable *drawable;
static GdkGC *gc;
@@ -58,11 +60,6 @@ draw_copy (uintptr_t dest_canvas, uintptr_t src_canvas, int dx, int dy, int sx,
gdk_draw_drawable (GDK_DRAWABLE (dest_canvas), gc, GDK_DRAWABLE (src_canvas), dx, dy, sx, sy, w, h);
}
-uintptr_t
-draw_load_pixbuf (const char *fname) {
- return (uintptr_t)create_pixbuf (fname);
-}
-
void
draw_pixbuf (uintptr_t dest_canvas, uintptr_t pixbuf, int dx, int dy, int sx, int sy, int w, int h) {
gdk_pixbuf_render_to_drawable (GDK_PIXBUF (pixbuf), GDK_DRAWABLE (dest_canvas), gc, sx, sy, dx, dy, w, h, GDK_RGB_DITHER_NONE, 0, 0);
@@ -118,7 +115,7 @@ draw_get_font_size (void) {
float dpi = gdk_screen_get_resolution (screen);
GtkStyle *style = gtk_widget_get_default_style ();
PangoFontDescription *desc = style->font_desc;
- return (float)pango_font_description_get_size (desc) / PANGO_SCALE * dpi / 72;
+ return (float)(pango_font_description_get_size (desc) / PANGO_SCALE * dpi / 72);
}
void
@@ -151,3 +148,73 @@ draw_get_text_extents (const char *text, int len, int *w, int *h) {
*w = ink.width;
*h = ink.height;
}
+
+static GdkColor gtkui_back_color;
+static GdkColor gtkui_selection_color;
+static GdkColor gtkui_dark_color;
+static GdkColor gtkui_mid_color;
+static GdkColor gtkui_light_color;
+
+void
+gtkui_init_theme_colors (void) {
+ int override = deadbeef->conf_get_int ("gtkui.override_theme_colors", 0);
+
+ extern GtkWidget *mainwin;
+ GtkStyle *style = mainwin->style;
+ char color_text[100];
+ const char *clr;
+
+ if (!override) {
+ memcpy (&gtkui_selection_color, &style->base[GTK_STATE_SELECTED], sizeof (GdkColor));
+ memcpy (&gtkui_back_color, &style->fg[GTK_STATE_NORMAL], sizeof (GdkColor));
+ memcpy (&gtkui_dark_color, &style->dark[GTK_STATE_NORMAL], sizeof (GdkColor));
+ memcpy (&gtkui_mid_color, &style->mid[GTK_STATE_NORMAL], sizeof (GdkColor));
+ memcpy (&gtkui_light_color, &style->light[GTK_STATE_NORMAL], sizeof (GdkColor));
+ }
+ else {
+ snprintf (color_text, sizeof (color_text), "%d %d %d", style->base[GTK_STATE_SELECTED].red, style->base[GTK_STATE_SELECTED].green, style->base[GTK_STATE_SELECTED].blue);
+ clr = deadbeef->conf_get_str ("gtkui.color.selection", color_text);
+ sscanf (clr, "%d %d %d", &gtkui_selection_color.red, &gtkui_selection_color.green, &gtkui_selection_color.blue);
+
+ snprintf (color_text, sizeof (color_text), "%d %d %d", style->fg[GTK_STATE_NORMAL].red, style->fg[GTK_STATE_NORMAL].green, style->fg[GTK_STATE_NORMAL].blue);
+ clr = deadbeef->conf_get_str ("gtkui.color.back", color_text);
+ sscanf (clr, "%d %d %d", &gtkui_back_color.red, &gtkui_back_color.green, &gtkui_back_color.blue);
+
+ snprintf (color_text, sizeof (color_text), "%d %d %d", style->dark[GTK_STATE_NORMAL].red, style->dark[GTK_STATE_NORMAL].green, style->dark[GTK_STATE_NORMAL].blue);
+ clr = deadbeef->conf_get_str ("gtkui.color.dark", color_text);
+ sscanf (clr, "%d %d %d", &gtkui_dark_color.red, &gtkui_dark_color.green, &gtkui_dark_color.blue);
+
+ snprintf (color_text, sizeof (color_text), "%d %d %d", style->mid[GTK_STATE_NORMAL].red, style->mid[GTK_STATE_NORMAL].green, style->mid[GTK_STATE_NORMAL].blue);
+ clr = deadbeef->conf_get_str ("gtkui.color.mid", color_text);
+ sscanf (clr, "%d %d %d", &gtkui_mid_color.red, &gtkui_mid_color.green, &gtkui_mid_color.blue);
+
+ snprintf (color_text, sizeof (color_text), "%d %d %d", style->light[GTK_STATE_NORMAL].red, style->light[GTK_STATE_NORMAL].green, style->light[GTK_STATE_NORMAL].blue);
+ clr = deadbeef->conf_get_str ("gtkui.color.light", color_text);
+ sscanf (clr, "%d %d %d", &gtkui_light_color.red, &gtkui_light_color.green, &gtkui_light_color.blue);
+ }
+}
+
+GdkColor *
+gtkui_get_back_color (void) {
+ return &gtkui_back_color;
+}
+
+GdkColor *
+gtkui_get_selection_color (void) {
+ return &gtkui_selection_color;
+}
+
+GdkColor *
+gtkui_get_dark_color (void) {
+ return &gtkui_dark_color;
+}
+
+GdkColor *
+gtkui_get_mid_color (void) {
+ return &gtkui_mid_color;
+}
+
+GdkColor *
+gtkui_get_light_color (void) {
+ return &gtkui_light_color;
+}