[gtk+/win32-theme] Push G_OS_WIN32 ifdefs into gtkwin32theme.c



commit 359f05f34b70fa2021c399a61b1b2e1f3ed2cc43
Author: Alexander Larsson <alexl redhat com>
Date:   Wed Nov 16 10:20:25 2011 +0100

    Push G_OS_WIN32 ifdefs into gtkwin32theme.c
    
    This means all the parsing etc works on non-win32, so that
    all themes parse the same on all arches.
    
    Of course, you don't get the actual theme bits, just pink.

 gtk/Makefile.am          |    5 +++--
 gtk/gtkstyleproperties.c |    9 ++-------
 gtk/gtkstyleproperty.c   |   10 ----------
 gtk/gtkwin32theme.c      |   30 ++++++++++++++++++++++++++++--
 4 files changed, 33 insertions(+), 21 deletions(-)
---
diff --git a/gtk/Makefile.am b/gtk/Makefile.am
index c6daa95..8909611 100644
--- a/gtk/Makefile.am
+++ b/gtk/Makefile.am
@@ -465,6 +465,7 @@ gtk_private_h_sources =		\
 	gtktreedatalist.h	\
 	gtktreeprivate.h	\
 	gtkwidgetprivate.h	\
+	gtkwin32themeprivate.h	\
 	gtkwindowprivate.h	\
 	gtktreemenu.h		\
 	$(gtk_clipboard_dnd_h_sources) \
@@ -724,6 +725,7 @@ gtk_base_c_sources = 		\
 	gtkwidget.c		\
 	gtkwidgetpath.c		\
 	gtkwindow.c		\
+	gtkwin32theme.c		\
 	$(gtk_clipboard_dnd_c_sources) \
 	$(gtk_appchooser_impl_c_sources)
 
@@ -758,13 +760,12 @@ gtk_c_sources += $(gtk_os_unix_c_sources)
 endif
 
 gtk_os_win32_c_sources = \
-	gtkwin32theme.c			\
 	gtkprint-win32.c		\
 	gtkprintoperation-win32.c	\
 	gtkwin32.c
 gtk_all_c_sources += $(gtk_os_win32_c_sources)
 if OS_WIN32
-gtk_private_h_sources += gtkprint-win32.h gtkwin32themeprivate.h
+gtk_private_h_sources += gtkprint-win32.h
 gtk_c_sources += $(gtk_os_win32_c_sources)
 endif
 
diff --git a/gtk/gtkstyleproperties.c b/gtk/gtkstyleproperties.c
index 4e12a09..8b931ad 100644
--- a/gtk/gtkstyleproperties.c
+++ b/gtk/gtkstyleproperties.c
@@ -37,9 +37,7 @@
 #include "gtkstylepropertyprivate.h"
 #include "gtkintl.h"
 
-#ifdef G_OS_WIN32
 #include "gtkwin32themeprivate.h"
-#endif
 
 /**
  * SECTION:gtkstyleproperties
@@ -471,11 +469,8 @@ _gtk_style_properties_set_property_by_property (GtkStyleProperties     *props,
     {
       /* Allow GtkGradient and theme part as a substitute */
       g_return_if_fail (value_type == CAIRO_GOBJECT_TYPE_PATTERN ||
-                        value_type == GTK_TYPE_GRADIENT
-#ifdef G_OS_WIN32
-			|| value_type == GTK_TYPE_WIN32_THEME_PART
-#endif
-			);
+                        value_type == GTK_TYPE_GRADIENT	||
+			value_type == GTK_TYPE_WIN32_THEME_PART);
     }
   else if (style_prop->pspec->value_type == G_TYPE_INT)
     {
diff --git a/gtk/gtkstyleproperty.c b/gtk/gtkstyleproperty.c
index 4cb50fe..7c302ad 100644
--- a/gtk/gtkstyleproperty.c
+++ b/gtk/gtkstyleproperty.c
@@ -41,11 +41,7 @@
 #include "gtkshadowprivate.h"
 #include "gtkthemingengine.h"
 #include "gtktypebuiltins.h"
-
-#ifdef G_OS_WIN32
 #include "gtkwin32themeprivate.h"
-#endif
-
 
 /* this is in case round() is not provided by the compiler, 
  * such as in the case of C89 compilers, like MSVC
@@ -913,13 +909,11 @@ pattern_value_parse (GtkCssParser *parser,
 {
   if (_gtk_css_parser_begins_with (parser, '-'))
     {
-#ifdef G_OS_WIN32
       int res;
       res = _gtk_win32_theme_part_parse (parser, base, value);
       if (res >= 0)
 	return res > 0;
       /* < 0 => continue */
-#endif
       g_value_unset (value);
       g_value_init (value, GTK_TYPE_GRADIENT);
       return gradient_value_parse (parser, base, value);
@@ -2486,7 +2480,6 @@ resolve_color_rgb (GtkStyleProperties *props,
   return TRUE;
 }
 
-#ifdef G_OS_WIN32
 static gboolean
 resolve_win32_theme_part (GtkStyleProperties *props,
 			  GValue             *value,
@@ -2506,7 +2499,6 @@ resolve_win32_theme_part (GtkStyleProperties *props,
 
   return TRUE;
 }
-#endif
 
 
 static gboolean
@@ -2595,14 +2587,12 @@ _gtk_style_property_resolve (const GtkStyleProperty *property,
       if (!resolve_shadow (props, val))
         _gtk_style_property_default_value (property, props, state, val);
     }
-#ifdef G_OS_WIN32
   else if (G_VALUE_TYPE (val) == GTK_TYPE_WIN32_THEME_PART)
     {
       if (resolve_win32_theme_part (props, val, val_out, context))
 	return; /* Don't copy val, this sets val_out */
       _gtk_style_property_default_value (property, props, state, val);
     }
-#endif
 
  out:
   g_value_copy (val, val_out);
diff --git a/gtk/gtkwin32theme.c b/gtk/gtkwin32theme.c
index ec10367..43c19da 100644
--- a/gtk/gtkwin32theme.c
+++ b/gtk/gtkwin32theme.c
@@ -23,9 +23,11 @@
 
 #include <config.h>
 
-#include <windows.h>
-
 #include "gtkwin32themeprivate.h"
+
+#ifdef G_OS_WIN32
+
+#include <windows.h>
 #include <cairo-win32.h>
 
 typedef HANDLE HTHEME;
@@ -161,6 +163,22 @@ lookup_htheme_by_classname (const char *class)
   return theme;
 }
 
+#else
+
+typedef void * HTHEME;
+
+static void
+_gtk_win32_theme_init (void)
+{
+}
+
+static HTHEME
+lookup_htheme_by_classname (const char *class)
+{
+  return NULL;
+}
+
+#endif /* G_OS_WIN32 */
 
 G_DEFINE_BOXED_TYPE_WITH_CODE (GtkWin32ThemePart, _gtk_win32_theme_part,
 			       _gtk_win32_theme_part_ref, _gtk_win32_theme_part_unref, 
@@ -290,6 +308,7 @@ _gtk_win32_theme_part_render  (GtkWin32ThemePart  *part,
 			       int                 width,
 			       int                 height)
 {
+#ifdef G_OS_WIN32
   cairo_surface_t *surface, *image;
   cairo_pattern_t *pattern;
   cairo_matrix_t matrix;
@@ -325,4 +344,11 @@ _gtk_win32_theme_part_render  (GtkWin32ThemePart  *part,
 			       surface, (cairo_destroy_func_t) cairo_surface_destroy);
 
   return pattern;
+#else
+  GdkRGBA color;
+  
+  gdk_rgba_parse (&color, "pink");
+
+  return cairo_pattern_create_rgb (color.red, color.green, color.blue);
+#endif
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]