[sapwood] start to extract the ThemeImage into its own source files



commit d05c79e9e8700ac73d77178e981286136537acd3
Author: Sven Herzberg <herzi gnome-de org>
Date:   Fri Jul 30 23:25:28 2010 +0200

    start to extract the ThemeImage into its own source files
    
    * engine/Makefile.am: updated
    * engine/sapwood-rc-style.c,
    * engine/sapwood-style.c,
    * engine/theme-pixbuf.h: stripped off the first part of the ThemeImage
      API
    * engine/theme-image.c,
    * engine/theme-image.h: initial version of the newly merged stuff

 engine/Makefile.am        |   10 ++--
 engine/sapwood-rc-style.c |   30 ++----------
 engine/sapwood-style.c    |   70 +--------------------------
 engine/theme-image.c      |  119 +++++++++++++++++++++++++++++++++++++++++++++
 engine/theme-image.h      |   86 ++++++++++++++++++++++++++++++++
 engine/theme-pixbuf.h     |   58 ++++------------------
 6 files changed, 227 insertions(+), 146 deletions(-)
---
diff --git a/engine/Makefile.am b/engine/Makefile.am
index a95deee..e1ad754 100644
--- a/engine/Makefile.am
+++ b/engine/Makefile.am
@@ -10,10 +10,12 @@ libsapwood_la_SOURCES=\
 	sapwood-main.c \
 	sapwood-rc-style.c	\
 	sapwood-rc-style.h	\
-	sapwood-style.c		\
-	sapwood-style.h		\
-	theme-pixbuf.c		\
-	theme-pixbuf.h		\
+	sapwood-style.c \
+	sapwood-style.h \
+	theme-image.c \
+	theme-image.h \
+	theme-pixbuf.c \
+	theme-pixbuf.h \
 	sapwood-pixmap.c \
 	sapwood-pixmap.h \
 	sapwood-pixmap-priv.h \
diff --git a/engine/sapwood-rc-style.c b/engine/sapwood-rc-style.c
index 7818417..fc5a462 100644
--- a/engine/sapwood-rc-style.c
+++ b/engine/sapwood-rc-style.c
@@ -1,6 +1,7 @@
 /* GTK+ Sapwood Engine
- * Copyright (C) 1998-2000 Red Hat, Inc.
- * Copyright (C) 2005 Nokia Corporation
+ * Copyright (C) 1998-2000  Red Hat, Inc.
+ * Copyright (C) 2005  Nokia Corporation
+ * Copyright (C) 2010  Sven Herzberg
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -23,6 +24,7 @@
  */
 #include <config.h>
 
+#include "theme-image.h"
 #include "theme-pixbuf.h"
 #include "sapwood-style.h"
 #include "sapwood-rc-style.h"
@@ -35,8 +37,6 @@ static void      sapwood_rc_style_merge        (GtkRcStyle         *dest,
 						GtkRcStyle         *src);
 static GtkStyle *sapwood_rc_style_create_style (GtkRcStyle         *rc_style);
 
-static void theme_image_unref (ThemeImage *data);
-
 static struct
   {
     gchar *name;
@@ -570,28 +570,6 @@ theme_image_ref (ThemeImage *data)
 }
 
 static void
-theme_image_unref (ThemeImage *data)
-{
-  data->refcount--;
-  if (data->refcount == 0)
-    {
-      if (data->match_data.detail)
-	g_free (data->match_data.detail);
-      if (data->background)
-	theme_pixbuf_unref (data->background);
-      if (data->overlay)
-	theme_pixbuf_unref (data->overlay);
-      if (data->gap_start)
-	theme_pixbuf_unref (data->gap_start);
-      if (data->gap)
-	theme_pixbuf_unref (data->gap);
-      if (data->gap_end)
-	theme_pixbuf_unref (data->gap_end);
-      g_free (data);
-    }
-}
-
-static void
 validate_pixbuf (GScanner     *scanner,
                  ThemePixbuf **theme_pb,
                  const char   *name)
diff --git a/engine/sapwood-style.c b/engine/sapwood-style.c
index 1cf2ee3..fe255a1 100644
--- a/engine/sapwood-style.c
+++ b/engine/sapwood-style.c
@@ -26,6 +26,7 @@
 #include <math.h>
 #include <string.h>
 
+#include "theme-image.h"
 #include "theme-pixbuf.h"
 #include "sapwood-rc-style.h"
 #include "sapwood-style.h"
@@ -65,75 +66,6 @@ enum_value_to_string (GType enum_type,
 }
 #endif /* ENABLE_DEBUG */
 
-static ThemeImage *
-match_theme_image (GtkStyle       *style,
-		   ThemeMatchData *match_data)
-{
-  GList *tmp_list;
-
-  tmp_list = SAPWOOD_RC_STYLE (style->rc_style)->img_list;
-
-  while (tmp_list)
-    {
-      guint flags;
-      ThemeImage *image = tmp_list->data;
-      tmp_list = tmp_list->next;
-
-      if (match_data->function != image->match_data.function)
-	continue;
-
-      flags = match_data->flags & image->match_data.flags;
-
-      if (flags != image->match_data.flags) /* Required components not present */
-	continue;
-
-      if ((flags & THEME_MATCH_STATE) &&
-	  match_data->state != image->match_data.state)
-	continue;
-
-      if ((flags & THEME_MATCH_POSITION) &&
-	  match_data->position != image->match_data.position)
-	continue;
-
-      if ((flags & THEME_MATCH_SHADOW) &&
-	  match_data->shadow != image->match_data.shadow)
-	continue;
-
-      if ((flags & THEME_MATCH_ARROW_DIRECTION) &&
-	  match_data->arrow_direction != image->match_data.arrow_direction)
-	continue;
-
-      if ((flags & THEME_MATCH_ORIENTATION) &&
-	  match_data->orientation != image->match_data.orientation)
-	continue;
-
-      if ((flags & THEME_MATCH_GAP_SIDE) &&
-	  match_data->gap_side != image->match_data.gap_side)
-	continue;
-
-      /* simple pattern matching for (treeview) details
-       * in gtkrc 'detail = "*_start"' will match all calls with detail ending
-       * with '_start' such as 'cell_even_start', 'cell_odd_start', etc.
-       */
-      if (image->match_data.detail)
-        {
-          if (!match_data->detail)
-            continue;
-          else if (image->match_data.detail[0] == '*')
-            {
-              if (!g_str_has_suffix (match_data->detail, image->match_data.detail + 1))
-                continue;
-            }
-          else if (strcmp (match_data->detail, image->match_data.detail) != 0)
-            continue;
-        }
-
-      return image;
-    }
-
-  return NULL;
-}
-
 static GdkBitmap *
 get_window_for_shape (ThemeImage *image,
                       GdkWindow  *window,
diff --git a/engine/theme-image.c b/engine/theme-image.c
new file mode 100644
index 0000000..667df7b
--- /dev/null
+++ b/engine/theme-image.c
@@ -0,0 +1,119 @@
+/* This file is part of the sapwood theming engine for GTK+
+ *
+ * Copyright (C) 1998-2000  Red Hat, Inc.
+ * Copyright (C) 2005,2007  Nokia Corporation
+ * Copyright (C) 2010  Sven Herzberg
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ * USA
+ */
+
+#include "theme-image.h"
+
+#include <string.h>
+#include "sapwood-rc-style.h"
+
+ThemeImage *
+match_theme_image (GtkStyle       *style,
+		   ThemeMatchData *match_data)
+{
+  GList *tmp_list;
+
+  tmp_list = SAPWOOD_RC_STYLE (style->rc_style)->img_list;
+
+  while (tmp_list)
+    {
+      guint flags;
+      ThemeImage *image = tmp_list->data;
+      tmp_list = tmp_list->next;
+
+      if (match_data->function != image->match_data.function)
+	continue;
+
+      flags = match_data->flags & image->match_data.flags;
+
+      if (flags != image->match_data.flags) /* Required components not present */
+	continue;
+
+      if ((flags & THEME_MATCH_STATE) &&
+	  match_data->state != image->match_data.state)
+	continue;
+
+      if ((flags & THEME_MATCH_POSITION) &&
+	  match_data->position != image->match_data.position)
+	continue;
+
+      if ((flags & THEME_MATCH_SHADOW) &&
+	  match_data->shadow != image->match_data.shadow)
+	continue;
+
+      if ((flags & THEME_MATCH_ARROW_DIRECTION) &&
+	  match_data->arrow_direction != image->match_data.arrow_direction)
+	continue;
+
+      if ((flags & THEME_MATCH_ORIENTATION) &&
+	  match_data->orientation != image->match_data.orientation)
+	continue;
+
+      if ((flags & THEME_MATCH_GAP_SIDE) &&
+	  match_data->gap_side != image->match_data.gap_side)
+	continue;
+
+      /* simple pattern matching for (treeview) details
+       * in gtkrc 'detail = "*_start"' will match all calls with detail ending
+       * with '_start' such as 'cell_even_start', 'cell_odd_start', etc.
+       */
+      if (image->match_data.detail)
+        {
+          if (!match_data->detail)
+            continue;
+          else if (image->match_data.detail[0] == '*')
+            {
+              if (!g_str_has_suffix (match_data->detail, image->match_data.detail + 1))
+                continue;
+            }
+          else if (strcmp (match_data->detail, image->match_data.detail) != 0)
+            continue;
+        }
+
+      return image;
+    }
+
+  return NULL;
+}
+
+void
+theme_image_unref (ThemeImage *data)
+{
+  data->refcount--;
+  if (data->refcount == 0)
+    {
+      if (data->match_data.detail)
+	g_free (data->match_data.detail);
+      if (data->background)
+	theme_pixbuf_unref (data->background);
+      if (data->overlay)
+	theme_pixbuf_unref (data->overlay);
+      if (data->gap_start)
+	theme_pixbuf_unref (data->gap_start);
+      if (data->gap)
+	theme_pixbuf_unref (data->gap);
+      if (data->gap_end)
+	theme_pixbuf_unref (data->gap_end);
+      g_free (data);
+    }
+}
+
+/* vim:set et sw=2 cino=t0,f0,(0,{s,>2s,n-1s,^-1s,e2s: */
diff --git a/engine/theme-image.h b/engine/theme-image.h
new file mode 100644
index 0000000..8fc54a2
--- /dev/null
+++ b/engine/theme-image.h
@@ -0,0 +1,86 @@
+/* This file is part of the sapwood theming engine for GTK+
+ *
+ * Copyright (C) 1998-2000  Red Hat, Inc.
+ * Copyright (C) 2005,2007  Nokia Corporation
+ * Copyright (C) 2010  Sven Herzberg
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ * USA
+ */
+
+#ifndef THEME_IMAGE_H
+#define THEME_IMAGE_H
+
+#include "theme-pixbuf.h"
+
+G_BEGIN_DECLS
+
+typedef struct _ThemeImage ThemeImage;
+typedef struct _ThemeMatchData ThemeMatchData;
+
+ThemeImage* match_theme_image (GtkStyle      * style,
+                               ThemeMatchData* match_data) G_GNUC_INTERNAL;
+void        theme_image_unref (ThemeImage    * self) G_GNUC_INTERNAL;
+
+
+typedef enum {
+  THEME_MATCH_GAP_SIDE        = 1 << 0,
+  THEME_MATCH_ORIENTATION     = 1 << 1,
+  THEME_MATCH_STATE           = 1 << 2,
+  THEME_MATCH_SHADOW          = 1 << 3,
+  THEME_MATCH_ARROW_DIRECTION = 1 << 4,
+  THEME_MATCH_POSITION        = 1 << 5
+} ThemeMatchFlags;
+
+typedef enum {
+  THEME_POS_LEFT   = 1 << 0, /* GTK_POS_LEFT   */
+  THEME_POS_RIGHT  = 1 << 1, /* GTK_POS_RIGHT  */
+  THEME_POS_TOP    = 1 << 2, /* GTK_POS_TOP    */
+  THEME_POS_BOTTOM = 1 << 3  /* GTK_POS_BOTTOM */
+} ThemePositionFlags;
+
+struct _ThemeMatchData
+{
+  gchar          *detail;
+  guint16         function;	/* Mandatory */
+
+  ThemeMatchFlags flags           : 6;
+  ThemePositionFlags position     : 4;
+  GtkStateType    state           : 3;
+  GtkShadowType   shadow          : 3;
+  GtkPositionType gap_side        : 2;
+  guint           arrow_direction : 2;	/* GtkArrowType, but without NONE */
+  GtkOrientation  orientation     : 1;
+};
+
+struct _ThemeImage
+{
+  ThemePixbuf    *background;
+  ThemePixbuf    *overlay;
+  ThemePixbuf    *gap_start;
+  ThemePixbuf    *gap;
+  ThemePixbuf    *gap_end;
+
+  ThemeMatchData  match_data;
+
+  guint           refcount : 31;
+  guint           background_shaped : 1;
+};
+
+G_END_DECLS
+
+#endif /* !THEME_IMAGE_H */
+
+/* vim:set et sw=2 cino=t0,f0,(0,{s,>2s,n-1s,^-1s,e2s: */
diff --git a/engine/theme-pixbuf.h b/engine/theme-pixbuf.h
index 64e0ec7..1c144c9 100644
--- a/engine/theme-pixbuf.h
+++ b/engine/theme-pixbuf.h
@@ -22,6 +22,9 @@
  * Carsten Haitzler <raster rasterman com>
  */
 
+#ifndef THEME_PIXBUF_H
+#define THEME_PIXBUF_H
+
 #include <gtk/gtk.h>
 #include <gdk-pixbuf/gdk-pixbuf.h>
 #include "sapwood-pixmap.h"
@@ -29,10 +32,10 @@
 /* internals */
 
 typedef struct _ThemeData ThemeData;
-typedef struct _ThemeImage ThemeImage;
-typedef struct _ThemeMatchData ThemeMatchData;
 typedef struct _ThemePixbuf ThemePixbuf;
 
+G_BEGIN_DECLS
+
 enum
 {
   TOKEN_SHADOWCOLOR = G_TOKEN_LAST + 1,
@@ -117,22 +120,6 @@ typedef enum
   COMPONENT_ALL        = 1 << 9
 } ThemePixbufComponent;
 
-typedef enum {
-  THEME_MATCH_GAP_SIDE        = 1 << 0,
-  THEME_MATCH_ORIENTATION     = 1 << 1,
-  THEME_MATCH_STATE           = 1 << 2,
-  THEME_MATCH_SHADOW          = 1 << 3,
-  THEME_MATCH_ARROW_DIRECTION = 1 << 4,
-  THEME_MATCH_POSITION        = 1 << 5
-} ThemeMatchFlags;
-
-typedef enum {
-  THEME_POS_LEFT   = 1 << 0, /* GTK_POS_LEFT   */
-  THEME_POS_RIGHT  = 1 << 1, /* GTK_POS_RIGHT  */
-  THEME_POS_TOP    = 1 << 2, /* GTK_POS_TOP    */
-  THEME_POS_BOTTOM = 1 << 3  /* GTK_POS_BOTTOM */
-} ThemePositionFlags;
-
 struct _ThemePixbuf
 {
   const char *dirname;
@@ -149,35 +136,6 @@ struct _ThemePixbuf
   guint       stretch : 1;
 };
 
-struct _ThemeMatchData
-{
-  gchar          *detail;
-  guint16         function;	/* Mandatory */
-
-  ThemeMatchFlags flags           : 6;
-  ThemePositionFlags position     : 4;
-  GtkStateType    state           : 3;
-  GtkShadowType   shadow          : 3;
-  GtkPositionType gap_side        : 2;
-  guint           arrow_direction : 2;	/* GtkArrowType, but without NONE */
-  GtkOrientation  orientation     : 1;
-};
-
-struct _ThemeImage
-{
-  ThemePixbuf    *background;
-  ThemePixbuf    *overlay;
-  ThemePixbuf    *gap_start;
-  ThemePixbuf    *gap;
-  ThemePixbuf    *gap_end;
-
-  ThemeMatchData  match_data;
-
-  guint           refcount : 31;
-  guint           background_shaped : 1;
-};
-
-
 ThemePixbuf *theme_pixbuf_new          (void) G_GNUC_INTERNAL;
 void         theme_pixbuf_unref        (ThemePixbuf  *theme_pb) G_GNUC_INTERNAL;
 ThemePixbuf *theme_pixbuf_canonicalize (ThemePixbuf  *theme_pb,
@@ -208,3 +166,9 @@ gboolean     theme_pixbuf_render       (ThemePixbuf * theme_pb,
 
 
 extern GtkStyleClass pixmap_default_class G_GNUC_INTERNAL;
+
+G_END_DECLS
+
+#endif /* !THEME_PIXBUF_H */
+
+/* vim:set et sw=2 cino=t0,f0,(0,{s,>2s,n-1s,^-1s,e2s: */



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