[gtk+/wip/css: 135/163] background: Simplify background-repeat



commit 4550721d18c3ebd62a79c925c095b28b6550845f
Author: Benjamin Otte <otte redhat com>
Date:   Wed Jan 4 16:31:04 2012 +0100

    background: Simplify background-repeat
    
    It used to be a struct, now it's just an enum

 gtk/gtkcssstylefuncs.c        |   33 ---------------------------------
 gtk/gtkcssstylepropertyimpl.c |    3 +--
 gtk/gtkcsstypes.c             |    2 --
 gtk/gtkcsstypesprivate.h      |   17 +++--------------
 gtk/gtkthemingbackground.c    |    2 +-
 5 files changed, 5 insertions(+), 52 deletions(-)
---
diff --git a/gtk/gtkcssstylefuncs.c b/gtk/gtkcssstylefuncs.c
index 8595699..5f4893b 100644
--- a/gtk/gtkcssstylefuncs.c
+++ b/gtk/gtkcssstylefuncs.c
@@ -1062,35 +1062,6 @@ shadow_value_compute (GValue          *computed,
 }
 
 static gboolean
-background_repeat_value_parse (GtkCssParser *parser,
-                               GFile *file,
-                               GValue *value)
-{
-  GtkCssBackgroundRepeat repeat;
-  int style;
-
-  if (!enum_parse (parser, GTK_TYPE_CSS_BACKGROUND_REPEAT_STYLE, &style))
-    return FALSE;
-
-  repeat.repeat = style;
-
-  g_value_set_boxed (value, &repeat);
-
-  return TRUE;
-}
-
-static void
-background_repeat_value_print (const GValue *value,
-                               GString      *string)
-{
-  GtkCssBackgroundRepeat *repeat;
-
-  repeat = g_value_get_boxed (value);
-
-  enum_print (repeat->repeat, GTK_TYPE_CSS_BACKGROUND_REPEAT_STYLE, string);
-}
-
-static gboolean
 border_image_repeat_value_parse (GtkCssParser *parser,
                                  GFile *file,
                                  GValue *value)
@@ -1319,10 +1290,6 @@ gtk_css_style_funcs_init (void)
                                 flags_value_parse,
                                 flags_value_print,
                                 NULL);
-  register_conversion_function (GTK_TYPE_CSS_BACKGROUND_REPEAT,
-                                background_repeat_value_parse,
-                                background_repeat_value_print,
-                                NULL);
 }
 
 /**
diff --git a/gtk/gtkcssstylepropertyimpl.c b/gtk/gtkcssstylepropertyimpl.c
index 62dffe3..3038eb0 100644
--- a/gtk/gtkcssstylepropertyimpl.c
+++ b/gtk/gtkcssstylepropertyimpl.c
@@ -448,7 +448,6 @@ _gtk_css_style_property_init_properties (void)
   GdkRGBA rgba;
   GtkCssBorderCornerRadius no_corner_radius = { 0, };
   GtkBorder border_of_ones = { 1, 1, 1, 1 };
-  GtkCssBackgroundRepeat background_repeat = { GTK_CSS_BACKGROUND_REPEAT_STYLE_REPEAT };
   GtkCssBorderImageRepeat border_image_repeat = { GTK_CSS_REPEAT_STYLE_STRETCH, GTK_CSS_REPEAT_STYLE_STRETCH };
 
   /* Initialize "color" and "font-size" first,
@@ -711,7 +710,7 @@ _gtk_css_style_property_init_properties (void)
                                           NULL,
                                           NULL,
                                           NULL,
-                                          &background_repeat);
+                                          GTK_CSS_BACKGROUND_REPEAT);
   g_value_init (&value, GTK_TYPE_CSS_IMAGE);
   _gtk_style_property_register           ("background-image",
                                           CAIRO_GOBJECT_TYPE_PATTERN,
diff --git a/gtk/gtkcsstypes.c b/gtk/gtkcsstypes.c
index b9e01c3..674fd02 100644
--- a/gtk/gtkcsstypes.c
+++ b/gtk/gtkcsstypes.c
@@ -31,7 +31,5 @@ type_name ## _copy (const TypeName *foo) \
 \
 G_DEFINE_BOXED_TYPE (TypeName, type_name, type_name ## _copy, g_free)
 
-DEFINE_BOXED_TYPE_WITH_COPY_FUNC (GtkCssBackgroundRepeat, _gtk_css_background_repeat)
-
 DEFINE_BOXED_TYPE_WITH_COPY_FUNC (GtkCssBorderCornerRadius, _gtk_css_border_corner_radius)
 DEFINE_BOXED_TYPE_WITH_COPY_FUNC (GtkCssBorderImageRepeat, _gtk_css_border_image_repeat)
diff --git a/gtk/gtkcsstypesprivate.h b/gtk/gtkcsstypesprivate.h
index 09e60a1..a2492df 100644
--- a/gtk/gtkcsstypesprivate.h
+++ b/gtk/gtkcsstypesprivate.h
@@ -31,9 +31,9 @@ typedef enum {
 } GtkCssSpecialValue;
 
 typedef enum {
-  GTK_CSS_BACKGROUND_REPEAT_STYLE_REPEAT,
-  GTK_CSS_BACKGROUND_REPEAT_STYLE_NO_REPEAT,
-} GtkCssBackgroundRepeatStyle;
+  GTK_CSS_BACKGROUND_REPEAT,
+  GTK_CSS_BACKGROUND_NO_REPEAT,
+} GtkCssBackgroundRepeat;
 
 typedef enum {
   GTK_CSS_REPEAT_STYLE_STRETCH,
@@ -48,16 +48,9 @@ typedef enum {
   GTK_CSS_AREA_CONTENT_BOX
 } GtkCssArea;
 
-typedef struct _GtkCssBackgroundRepeat GtkCssBackgroundRepeat;
-
 typedef struct _GtkCssBorderCornerRadius GtkCssBorderCornerRadius;
 typedef struct _GtkCssBorderImageRepeat GtkCssBorderImageRepeat;
 
-struct _GtkCssBackgroundRepeat {
-  /* FIXME: will have vrepeat and hrepeat instead */
-  GtkCssBackgroundRepeatStyle repeat;
-};
-
 struct _GtkCssBorderCornerRadius {
   double horizontal;
   double vertical;
@@ -68,14 +61,10 @@ struct _GtkCssBorderImageRepeat {
   GtkCssBorderRepeatStyle hrepeat;
 };
 
-#define GTK_TYPE_CSS_BACKGROUND_REPEAT _gtk_css_background_repeat_get_type ()
-
 #define GTK_TYPE_CSS_BORDER_CORNER_RADIUS _gtk_css_border_corner_radius_get_type ()
 #define GTK_TYPE_CSS_BORDER_RADIUS _gtk_css_border_radius_get_type ()
 #define GTK_TYPE_CSS_BORDER_IMAGE_REPEAT _gtk_css_border_image_repeat_get_type ()
 
-GType           _gtk_css_background_repeat_get_type             (void);
-
 GType           _gtk_css_border_corner_radius_get_type          (void);
 GType           _gtk_css_border_radius_get_type                 (void);
 GType           _gtk_css_border_image_repeat_get_type           (void);
diff --git a/gtk/gtkthemingbackground.c b/gtk/gtkthemingbackground.c
index 972c47c..b786db6 100644
--- a/gtk/gtkthemingbackground.c
+++ b/gtk/gtkthemingbackground.c
@@ -116,7 +116,7 @@ _gtk_theming_background_paint (GtkThemingBackground *bg,
 
   if (bg->image)
     {
-      GtkCssBackgroundRepeat *repeat;
+      GtkCssBackgroundRepeat repeat;
       double image_width, image_height;
 
       gtk_theming_engine_get (bg->engine, bg->flags,



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