[gtk+] border-image: move private types to gtkcsstypes.c
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] border-image: move private types to gtkcsstypes.c
- Date: Thu, 9 Jun 2011 04:24:32 +0000 (UTC)
commit 4e95e6ae21d8105453a49e1eac072917a9cf996e
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Sun Jun 5 16:49:54 2011 -0400
border-image: move private types to gtkcsstypes.c
gtk/gtkborderimage.c | 50 +++++++++++++------------------------------
gtk/gtkborderimageprivate.h | 23 ++++++-------------
gtk/gtkcsstypes.c | 1 +
gtk/gtkcsstypesprivate.h | 15 +++++++++++++
gtk/gtkenums.h | 7 ------
gtk/gtkstyleproperty.c | 34 ++++++++++++++--------------
6 files changed, 55 insertions(+), 75 deletions(-)
---
diff --git a/gtk/gtkborderimage.c b/gtk/gtkborderimage.c
index 075889b..f38b4f9 100644
--- a/gtk/gtkborderimage.c
+++ b/gtk/gtkborderimage.c
@@ -28,26 +28,6 @@
#include "gtkborderimageprivate.h"
-static GtkBorderImageRepeat *
-_gtk_border_image_repeat_copy (const GtkBorderImageRepeat *repeat)
-{
- GtkBorderImageRepeat *retval;
-
- retval = g_slice_new0 (GtkBorderImageRepeat);
- *retval = *repeat;
-
- return retval;
-}
-
-static void
-_gtk_border_image_repeat_free (GtkBorderImageRepeat *repeat)
-{
- g_slice_free (GtkBorderImageRepeat, repeat);
-}
-
-G_DEFINE_BOXED_TYPE (GtkBorderImageRepeat, _gtk_border_image_repeat,
- _gtk_border_image_repeat_copy, _gtk_border_image_repeat_free)
-
G_DEFINE_BOXED_TYPE (GtkBorderImage, _gtk_border_image,
_gtk_border_image_ref, _gtk_border_image_unref)
@@ -72,7 +52,7 @@ struct _GtkBorderImage {
GtkGradient *source_gradient;
GtkBorder slice;
- GtkBorderImageRepeat repeat;
+ GtkCssBorderImageRepeat repeat;
gint ref_count;
gboolean resolved;
@@ -81,7 +61,7 @@ struct _GtkBorderImage {
GtkBorderImage *
_gtk_border_image_new (cairo_pattern_t *pattern,
GtkBorder *slice,
- GtkBorderImageRepeat *repeat)
+ GtkCssBorderImageRepeat *repeat)
{
GtkBorderImage *image;
@@ -105,7 +85,7 @@ _gtk_border_image_new (cairo_pattern_t *pattern,
GtkBorderImage *
_gtk_border_image_new_for_gradient (GtkGradient *gradient,
GtkBorder *slice,
- GtkBorderImageRepeat *repeat)
+ GtkCssBorderImageRepeat *repeat)
{
GtkBorderImage *image;
@@ -198,7 +178,7 @@ _gtk_border_image_unpack (const GValue *value,
g_value_set_boxed (¶meter[1].value, &image->slice);
parameter[2].name = "border-image-repeat";
- g_value_init (¶meter[2].value, GTK_TYPE_BORDER_IMAGE_REPEAT);
+ g_value_init (¶meter[2].value, GTK_TYPE_CSS_BORDER_IMAGE_REPEAT);
g_value_set_boxed (¶meter[2].value, &image->repeat);
*n_params = 3;
@@ -213,7 +193,7 @@ _gtk_border_image_pack (GValue *value,
GtkBorderImage *image;
cairo_pattern_t *source;
GtkBorder *slice;
- GtkBorderImageRepeat *repeat;
+ GtkCssBorderImageRepeat *repeat;
gtk_style_properties_get (props, state,
"border-image-source", &source,
@@ -237,7 +217,7 @@ _gtk_border_image_pack (GValue *value,
gtk_border_free (slice);
if (repeat != NULL)
- _gtk_border_image_repeat_free (repeat);
+ g_free (repeat);
}
static void
@@ -327,7 +307,7 @@ render_border (cairo_t *cr,
gdouble surface_height,
guint side,
GtkBorder *border_area,
- GtkBorderImageRepeat *repeat)
+ GtkCssBorderImageRepeat *repeat)
{
gdouble target_x, target_y;
gdouble target_width, target_height;
@@ -362,18 +342,18 @@ render_border (cairo_t *cr,
target_x = border_area->left;
target_y = (side == SIDE_TOP) ? 0 : (total_height - border_area->bottom);
- if (repeat->vrepeat == GTK_REPEAT_STYLE_NONE)
+ if (repeat->vrepeat == GTK_CSS_REPEAT_STYLE_NONE)
{
target_width = image_area.width;
}
- else if (repeat->vrepeat == GTK_REPEAT_STYLE_REPEAT)
+ else if (repeat->vrepeat == GTK_CSS_REPEAT_STYLE_REPEAT)
{
repeat_pattern = TRUE;
target_x = border_area->left + (total_width - border_area->left - border_area->right) / 2;
target_y = ((side == SIDE_TOP) ? 0 : (total_height - border_area->bottom)) / 2;
}
- else if (repeat->vrepeat == GTK_REPEAT_STYLE_ROUND)
+ else if (repeat->vrepeat == GTK_CSS_REPEAT_STYLE_ROUND)
{
gint n_repeats;
@@ -382,7 +362,7 @@ render_border (cairo_t *cr,
n_repeats = (gint) floor (image_area.width / surface_width);
target_width = image_area.width / n_repeats;
}
- else if (repeat->vrepeat == GTK_REPEAT_STYLE_SPACE)
+ else if (repeat->vrepeat == GTK_CSS_REPEAT_STYLE_SPACE)
{
cairo_surface_t *spaced_surface;
@@ -407,11 +387,11 @@ render_border (cairo_t *cr,
target_x = (side == SIDE_LEFT) ? 0 : (total_width - border_area->right);
target_y = border_area->top;
- if (repeat->hrepeat == GTK_REPEAT_STYLE_NONE)
+ if (repeat->hrepeat == GTK_CSS_REPEAT_STYLE_NONE)
{
target_height = total_height - border_area->top - border_area->bottom;
}
- else if (repeat->hrepeat == GTK_REPEAT_STYLE_REPEAT)
+ else if (repeat->hrepeat == GTK_CSS_REPEAT_STYLE_REPEAT)
{
repeat_pattern = TRUE;
@@ -419,7 +399,7 @@ render_border (cairo_t *cr,
target_x = (side == SIDE_LEFT) ? 0 : (total_width - border_area->right) / 2;
target_y = border_area->top + (total_height - border_area->top - border_area->bottom) / 2;
}
- else if (repeat->hrepeat == GTK_REPEAT_STYLE_ROUND)
+ else if (repeat->hrepeat == GTK_CSS_REPEAT_STYLE_ROUND)
{
gint n_repeats;
@@ -428,7 +408,7 @@ render_border (cairo_t *cr,
n_repeats = (gint) floor (image_area.height / surface_height);
target_height = image_area.height / n_repeats;
}
- else if (repeat->hrepeat == GTK_REPEAT_STYLE_SPACE)
+ else if (repeat->hrepeat == GTK_CSS_REPEAT_STYLE_SPACE)
{
cairo_surface_t *spaced_surface;
diff --git a/gtk/gtkborderimageprivate.h b/gtk/gtkborderimageprivate.h
index 2eddd93..5068c51 100644
--- a/gtk/gtkborderimageprivate.h
+++ b/gtk/gtkborderimageprivate.h
@@ -24,23 +24,14 @@
#ifndef __GTK_BORDER_IMAGE_H__
#define __GTK_BORDER_IMAGE_H__
-#include <gtk/gtkborder.h>
-#include <gtk/gtkenums.h>
-#include <gtk/gtkgradient.h>
-#include <gtk/gtkstyleproperties.h>
-#include <gtk/gtkthemingengine.h>
+#include "gtkborder.h"
+#include "gtkgradient.h"
+#include "gtkstyleproperties.h"
+#include "gtkthemingengine.h"
+#include "gtkcsstypesprivate.h"
G_BEGIN_DECLS
-#define GTK_TYPE_BORDER_IMAGE_REPEAT (_gtk_border_image_repeat_get_type ())
-
-GType _gtk_border_image_repeat_get_type (void) G_GNUC_CONST;
-
-typedef struct {
- GtkRepeatStyle vrepeat;
- GtkRepeatStyle hrepeat;
-} GtkBorderImageRepeat;
-
typedef struct _GtkBorderImage GtkBorderImage;
#define GTK_TYPE_BORDER_IMAGE (_gtk_border_image_get_type ())
@@ -49,10 +40,10 @@ GType _gtk_border_image_get_type (void) G_GNUC_CONST;
GtkBorderImage * _gtk_border_image_new (cairo_pattern_t *source,
GtkBorder *slice,
- GtkBorderImageRepeat *repeat);
+ GtkCssBorderImageRepeat *repeat);
GtkBorderImage * _gtk_border_image_new_for_gradient (GtkGradient *gradient,
GtkBorder *slice,
- GtkBorderImageRepeat *repeat);
+ GtkCssBorderImageRepeat *repeat);
GtkBorderImage * _gtk_border_image_resolve (GtkBorderImage *image,
GtkStyleProperties *props);
diff --git a/gtk/gtkcsstypes.c b/gtk/gtkcsstypes.c
index 44b0d28..e84bd2c 100644
--- a/gtk/gtkcsstypes.c
+++ b/gtk/gtkcsstypes.c
@@ -33,3 +33,4 @@ G_DEFINE_BOXED_TYPE (TypeName, type_name, type_name ## _copy, g_free)
DEFINE_BOXED_TYPE_WITH_COPY_FUNC (GtkCssBorderCornerRadius, _gtk_css_border_corner_radius)
DEFINE_BOXED_TYPE_WITH_COPY_FUNC (GtkCssBorderRadius, _gtk_css_border_radius)
+DEFINE_BOXED_TYPE_WITH_COPY_FUNC (GtkCssBorderImageRepeat, _gtk_css_border_image_repeat)
diff --git a/gtk/gtkcsstypesprivate.h b/gtk/gtkcsstypesprivate.h
index db3e274..e6f9b34 100644
--- a/gtk/gtkcsstypesprivate.h
+++ b/gtk/gtkcsstypesprivate.h
@@ -24,8 +24,16 @@
G_BEGIN_DECLS
+typedef enum {
+ GTK_CSS_REPEAT_STYLE_NONE,
+ GTK_CSS_REPEAT_STYLE_REPEAT,
+ GTK_CSS_REPEAT_STYLE_ROUND,
+ GTK_CSS_REPEAT_STYLE_SPACE
+} GtkCssRepeatStyle;
+
typedef struct _GtkCssBorderCornerRadius GtkCssBorderCornerRadius;
typedef struct _GtkCssBorderRadius GtkCssBorderRadius;
+typedef struct _GtkCssBorderImageRepeat GtkCssBorderImageRepeat;
struct _GtkCssBorderCornerRadius {
double horizontal;
@@ -39,11 +47,18 @@ struct _GtkCssBorderRadius {
GtkCssBorderCornerRadius bottom_left;
};
+struct _GtkCssBorderImageRepeat {
+ GtkCssRepeatStyle vrepeat;
+ GtkCssRepeatStyle hrepeat;
+};
+
#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_border_corner_radius_get_type (void);
GType _gtk_css_border_radius_get_type (void);
+GType _gtk_css_border_image_repeat_get_type (void);
G_END_DECLS
diff --git a/gtk/gtkenums.h b/gtk/gtkenums.h
index 2a4c700..33e3aea 100644
--- a/gtk/gtkenums.h
+++ b/gtk/gtkenums.h
@@ -916,13 +916,6 @@ typedef enum {
GTK_BORDER_STYLE_OUTSET
} GtkBorderStyle;
-typedef enum {
- GTK_REPEAT_STYLE_NONE,
- GTK_REPEAT_STYLE_REPEAT,
- GTK_REPEAT_STYLE_ROUND,
- GTK_REPEAT_STYLE_SPACE
-} GtkRepeatStyle;
-
G_END_DECLS
diff --git a/gtk/gtkstyleproperty.c b/gtk/gtkstyleproperty.c
index f825db3..5ad1a01 100644
--- a/gtk/gtkstyleproperty.c
+++ b/gtk/gtkstyleproperty.c
@@ -953,23 +953,23 @@ border_image_repeat_value_parse (GtkCssParser *parser,
GFile *file,
GValue *value)
{
- GtkBorderImageRepeat image_repeat;
- GtkRepeatStyle styles[2];
+ GtkCssBorderImageRepeat image_repeat;
+ GtkCssRepeatStyle styles[2];
gint i;
for (i = 0; i < 2; i++)
{
if (_gtk_css_parser_try (parser, "stretch", TRUE))
- styles[i] = GTK_REPEAT_STYLE_NONE;
+ styles[i] = GTK_CSS_REPEAT_STYLE_NONE;
else if (_gtk_css_parser_try (parser, "repeat", TRUE))
- styles[i] = GTK_REPEAT_STYLE_REPEAT;
+ styles[i] = GTK_CSS_REPEAT_STYLE_REPEAT;
else if (_gtk_css_parser_try (parser, "round", TRUE))
- styles[i] = GTK_REPEAT_STYLE_ROUND;
+ styles[i] = GTK_CSS_REPEAT_STYLE_ROUND;
else if (_gtk_css_parser_try (parser, "space", TRUE))
- styles[i] = GTK_REPEAT_STYLE_SPACE;
+ styles[i] = GTK_CSS_REPEAT_STYLE_SPACE;
else if (i == 0)
{
- styles[1] = styles[0] = GTK_REPEAT_STYLE_NONE;
+ styles[1] = styles[0] = GTK_CSS_REPEAT_STYLE_NONE;
break;
}
else
@@ -985,17 +985,17 @@ border_image_repeat_value_parse (GtkCssParser *parser,
}
static const gchar *
-border_image_repeat_style_to_string (GtkRepeatStyle repeat)
+border_image_repeat_style_to_string (GtkCssRepeatStyle repeat)
{
switch (repeat)
{
- case GTK_REPEAT_STYLE_NONE:
+ case GTK_CSS_REPEAT_STYLE_NONE:
return "stretch";
- case GTK_REPEAT_STYLE_REPEAT:
+ case GTK_CSS_REPEAT_STYLE_REPEAT:
return "repeat";
- case GTK_REPEAT_STYLE_ROUND:
+ case GTK_CSS_REPEAT_STYLE_ROUND:
return "round";
- case GTK_REPEAT_STYLE_SPACE:
+ case GTK_CSS_REPEAT_STYLE_SPACE:
return "space";
default:
return NULL;
@@ -1006,7 +1006,7 @@ static void
border_image_repeat_value_print (const GValue *value,
GString *string)
{
- GtkBorderImageRepeat *image_repeat;
+ GtkCssBorderImageRepeat *image_repeat;
image_repeat = g_value_get_boxed (value);
@@ -1024,7 +1024,7 @@ border_image_value_parse (GtkCssParser *parser,
cairo_pattern_t *pattern = NULL;
GtkGradient *gradient = NULL;
GtkBorder border, *parsed_border;
- GtkBorderImageRepeat repeat, *parsed_repeat;
+ GtkCssBorderImageRepeat repeat, *parsed_repeat;
gboolean retval = FALSE;
GtkBorderImage *image = NULL;
@@ -1048,7 +1048,7 @@ border_image_value_parse (GtkCssParser *parser,
border = *parsed_border;
g_value_unset (&temp);
- g_value_init (&temp, GTK_TYPE_BORDER_IMAGE_REPEAT);
+ g_value_init (&temp, GTK_TYPE_CSS_BORDER_IMAGE_REPEAT);
if (!border_image_repeat_value_parse (parser, base, &temp))
goto out;
@@ -1694,7 +1694,7 @@ css_string_funcs_init (void)
register_conversion_function (GTK_TYPE_BORDER_IMAGE,
border_image_value_parse,
NULL);
- register_conversion_function (GTK_TYPE_BORDER_IMAGE_REPEAT,
+ register_conversion_function (GTK_TYPE_CSS_BORDER_IMAGE_REPEAT,
border_image_repeat_value_parse,
border_image_repeat_value_print);
register_conversion_function (GTK_TYPE_SHADOW,
@@ -2241,7 +2241,7 @@ gtk_style_property_init (void)
g_param_spec_boxed ("border-image-repeat",
"Border image repeat",
"Border image repeat",
- GTK_TYPE_BORDER_IMAGE_REPEAT, 0));
+ GTK_TYPE_CSS_BORDER_IMAGE_REPEAT, 0));
gtk_style_properties_register_property (NULL,
g_param_spec_boxed ("border-image-slice",
"Border image slice",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]