summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ui/draw-workspace.c11
-rw-r--r--src/ui/theme.c81
-rw-r--r--src/ui/theme.h8
3 files changed, 82 insertions, 18 deletions
diff --git a/src/ui/draw-workspace.c b/src/ui/draw-workspace.c
index a40579db..4feb25c9 100644
--- a/src/ui/draw-workspace.c
+++ b/src/ui/draw-workspace.c
@@ -26,12 +26,7 @@
*/
#include "draw-workspace.h"
-
-#if GTK_CHECK_VERSION (3, 0, 0)
-#define MATE_DESKTOP_USE_UNSTABLE_API
-#include <libmate-desktop/mate-desktop-utils.h>
-#endif
-
+#include "theme.h"
static void
get_window_rect (const WnckWindowDisplayInfo *win,
@@ -110,7 +105,7 @@ draw_window (GtkWidget *widget,
#if GTK_CHECK_VERSION (3, 0, 0)
style = gtk_widget_get_style_context (widget);
if (is_active)
- mate_desktop_gtk_style_get_light_color (style, state, &color);
+ meta_gtk_style_get_light_color (style, state, &color);
else
gtk_style_context_get_background_color (style, state, &color);
gdk_cairo_set_source_rgba (cr, &color);
@@ -268,7 +263,7 @@ wnck_draw_workspace (GtkWidget *widget,
#if GTK_CHECK_VERSION (3, 0, 0)
GdkRGBA color;
- mate_desktop_gtk_style_get_dark_color (style,state, &color);
+ meta_gtk_style_get_dark_color (style,state, &color);
gdk_cairo_set_source_rgba (cr, &color);
#else
gdk_cairo_set_source_color (cr, &gtk_widget_get_style (widget)->dark[state]);
diff --git a/src/ui/theme.c b/src/ui/theme.c
index 173c58f0..e348f62e 100644
--- a/src/ui/theme.c
+++ b/src/ui/theme.c
@@ -64,11 +64,6 @@
#include <math.h>
#if GTK_CHECK_VERSION (3, 0, 0)
-#define MATE_DESKTOP_USE_UNSTABLE_API
-#include <libmate-desktop/mate-desktop-utils.h>
-#endif
-
-#if GTK_CHECK_VERSION (3, 0, 0)
#define GDK_COLOR_RGBA(color) \
((guint32) (0xff | \
((int)((color).red * 255) << 24) | \
@@ -1487,6 +1482,72 @@ meta_color_spec_new_gtk (MetaGtkColorComponent component,
#if GTK_CHECK_VERSION (3, 0, 0)
static void
+get_background_color_real (GtkStyleContext *context,
+ GtkStateFlags state,
+ GdkRGBA *color)
+{
+ GdkRGBA *c;
+
+ g_return_if_fail (color != NULL);
+ g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
+
+ gtk_style_context_get (context,
+ state,
+ "background-color", &c,
+ NULL);
+
+ *color = *c;
+ gdk_rgba_free (c);
+}
+
+static void
+get_background_color (GtkStyleContext *context,
+ GtkStateFlags state,
+ GdkRGBA *color)
+{
+ GdkRGBA empty = { 0.0, 0.0, 0.0, 0.0 };
+ GdkRGBA rgba;
+
+ get_background_color_real (context, state, &rgba);
+
+ if (gdk_rgba_equal (&rgba, &empty))
+ {
+ GtkWidget *toplevel;
+ GtkStyleContext *tmp;
+
+ toplevel = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ tmp = gtk_widget_get_style_context (toplevel);
+
+ get_background_color_real (tmp, state, &rgba);
+
+ gtk_widget_destroy (toplevel);
+ }
+
+ *color = rgba;
+}
+
+/* Based on set_color() in gtkstyle.c */
+#define LIGHTNESS_MULT 1.3
+#define DARKNESS_MULT 0.7
+void
+meta_gtk_style_get_light_color (GtkStyleContext *style,
+ GtkStateFlags state,
+ GdkRGBA *color)
+{
+ get_background_color (style, state, color);
+ gtk_style_shade (color, color, LIGHTNESS_MULT);
+}
+
+void
+meta_gtk_style_get_dark_color (GtkStyleContext *style,
+ GtkStateFlags state,
+ GdkRGBA *color)
+{
+ get_background_color (style, state, color);
+ gtk_style_shade (color, color, DARKNESS_MULT);
+}
+
+static void
meta_set_color_from_style (GdkRGBA *color,
GtkStyleContext *context,
GtkStateFlags state,
@@ -1498,7 +1559,7 @@ meta_set_color_from_style (GdkRGBA *color,
{
case META_GTK_COLOR_BG:
case META_GTK_COLOR_BASE:
- gtk_style_context_get_background_color (context, state, color);
+ get_background_color (context, state, color);
break;
case META_GTK_COLOR_FG:
case META_GTK_COLOR_TEXT:
@@ -1513,18 +1574,18 @@ meta_set_color_from_style (GdkRGBA *color,
color->blue = (color->blue + other.blue) / 2;
break;
case META_GTK_COLOR_MID:
- mate_desktop_gtk_style_get_light_color (context, state, color);
- mate_desktop_gtk_style_get_dark_color (context, state, &other);
+ meta_gtk_style_get_light_color (context, state, color);
+ meta_gtk_style_get_dark_color (context, state, &other);
color->red = (color->red + other.red) / 2;
color->green = (color->green + other.green) / 2;
color->blue = (color->blue + other.blue) / 2;
break;
case META_GTK_COLOR_LIGHT:
- mate_desktop_gtk_style_get_light_color (context, state, color);
+ meta_gtk_style_get_light_color (context, state, color);
break;
case META_GTK_COLOR_DARK:
- mate_desktop_gtk_style_get_dark_color (context, state, color);
+ meta_gtk_style_get_dark_color (context, state, color);
break;
case META_GTK_COLOR_LAST:
g_assert_not_reached ();
diff --git a/src/ui/theme.h b/src/ui/theme.h
index 742d01fe..ea3ec196 100644
--- a/src/ui/theme.h
+++ b/src/ui/theme.h
@@ -1269,6 +1269,14 @@ GtkArrowType meta_gtk_arrow_from_string (const char *s
const char* meta_gtk_arrow_to_string (GtkArrowType arrow);
MetaImageFillType meta_image_fill_type_from_string (const char *str);
const char* meta_image_fill_type_to_string (MetaImageFillType fill_type);
+#if GTK_CHECK_VERSION (3, 0, 0)
+void meta_gtk_style_get_light_color (GtkStyleContext *style,
+ GtkStateFlags state,
+ GdkRGBA *color);
+void meta_gtk_style_get_dark_color (GtkStyleContext *style,
+ GtkStateFlags state,
+ GdkRGBA *color);
+#endif
guint meta_theme_earliest_version_with_button (MetaButtonType type);