};
/* --- prototypes --- */
-static void gtk_style_init (GtkStyle *style);
-static void gtk_style_class_init (GtkStyleClass *klass);
static void gtk_style_finalize (GObject *object);
static void gtk_style_realize (GtkStyle *style,
GdkColormap *colormap);
static const GdkColor gtk_default_selected_base = { 0, GTK_BLUE };
static const GdkColor gtk_default_active_base = { 0, GTK_VERY_DARK_GRAY };
-static gpointer parent_class = NULL;
-
/* --- signals --- */
static guint realize_signal = 0;
static guint unrealize_signal = 0;
+G_DEFINE_TYPE (GtkStyle, gtk_style, G_TYPE_OBJECT)
+
/* --- functions --- */
-GType
-gtk_style_get_type (void)
-{
- static GType style_type = 0;
-
- if (!style_type)
- {
- static const GTypeInfo style_info =
- {
- sizeof (GtkStyleClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) gtk_style_class_init,
- NULL, /* class_finalize */
- NULL, /* class_data */
- sizeof (GtkStyle),
- 0, /* n_preallocs */
- (GInstanceInitFunc) gtk_style_init,
- };
-
- style_type = g_type_register_static (G_TYPE_OBJECT, I_("GtkStyle"),
- &style_info, 0);
- }
-
- return style_type;
-}
/**
* _gtk_style_init_for_settings:
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- parent_class = g_type_class_peek_parent (klass);
-
object_class->finalize = gtk_style_finalize;
klass->clone = gtk_style_real_clone;
if (style->rc_style)
gtk_rc_style_unref (style->rc_style);
- G_OBJECT_CLASS (parent_class)->finalize (object);
+ G_OBJECT_CLASS (gtk_style_parent_class)->finalize (object);
}
gtk_style_realize (GtkStyle *style,
GdkColormap *colormap)
{
- g_return_if_fail (GTK_IS_STYLE (style));
- g_return_if_fail (GDK_IS_COLORMAP (colormap));
-
style->colormap = g_object_ref (colormap);
style->depth = gdk_colormap_get_visual (colormap)->depth;
style->ythickness = src->ythickness;
if (style->rc_style)
- gtk_rc_style_unref (style->rc_style);
+ g_object_unref (style->rc_style);
style->rc_style = src->rc_style;
if (src->rc_style)
- gtk_rc_style_ref (src->rc_style);
+ g_object_ref (src->rc_style);
/* don't copy, just clear cache */
clear_property_cache (style);
gchar *contents = g_strdup_value_contents (&rcprop->value);
g_message ("%s: failed to retrieve property `%s::%s' of type `%s' from rc file value \"%s\" of type `%s'",
- rcprop->origin,
+ rcprop->origin ? rcprop->origin : "(for origin information, set GTK_DEBUG)",
g_type_name (pspec->owner_type), pspec->name,
g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)),
contents,
gint thickness_dark;
gint i;
- g_return_if_fail (GTK_IS_STYLE (style));
- g_return_if_fail (window != NULL);
-
thickness_light = style->ythickness / 2;
thickness_dark = style->ythickness - thickness_light;
gint thickness_dark;
gint i;
- g_return_if_fail (GTK_IS_STYLE (style));
- g_return_if_fail (window != NULL);
-
thickness_light = style->xthickness / 2;
thickness_dark = style->xthickness - thickness_light;
gint thickness_dark;
gint i;
- g_return_if_fail (GTK_IS_STYLE (style));
- g_return_if_fail (window != NULL);
-
if (shadow_type == GTK_SHADOW_IN)
{
- if (detail && (strcmp (detail, "buttondefault") == 0))
+ if (detail && strcmp (detail, "buttondefault") == 0)
{
sanitize_size (window, &width, &height);
x, y, width, height);
return;
}
- if (widget && GTK_IS_SPIN_BUTTON (widget) &&
+ if (GTK_IS_SPIN_BUTTON (widget) &&
detail && strcmp (detail, "spinbutton") == 0)
{
draw_spinbutton_shadow (style, window, state_type,
}
if (shadow_type == GTK_SHADOW_IN &&
- widget && GTK_IS_SPIN_BUTTON (widget) &&
+ GTK_IS_SPIN_BUTTON (widget) &&
detail && strcmp (detail, "entry") == 0)
{
if (get_direction (widget) == GTK_TEXT_DIR_LTR)
gint yadjust;
gint i;
- g_return_if_fail (GTK_IS_STYLE (style));
- g_return_if_fail (window != NULL);
- g_return_if_fail (points != NULL);
-
switch (shadow_type)
{
case GTK_SHADOW_IN:
GdkGC *inner_sw = NULL;
GdkGC *inner_se = NULL;
- g_return_if_fail (GTK_IS_STYLE (style));
- g_return_if_fail (window != NULL);
-
sanitize_size (window, &width, &height);
half_width = width / 2;
gint y,
const gchar *string)
{
- g_return_if_fail (GTK_IS_STYLE (style));
- g_return_if_fail (window != NULL);
-
if (area)
{
gdk_gc_set_clip_rectangle (style->white_gc, area);
{
gboolean is_spinbutton_box = FALSE;
- g_return_if_fail (GTK_IS_STYLE (style));
- g_return_if_fail (window != NULL);
-
sanitize_size (window, &width, &height);
- if (widget && GTK_IS_SPIN_BUTTON (widget) && detail)
+ if (GTK_IS_SPIN_BUTTON (widget) && detail)
{
if (strcmp (detail, "spinbutton_up") == 0)
{
GdkGC *gc1;
GdkGC *freeme = NULL;
- g_return_if_fail (GTK_IS_STYLE (style));
- g_return_if_fail (window != NULL);
-
sanitize_size (window, &width, &height);
if (detail)
gc1 = style->bg_gc[GTK_STATE_SELECTED];
else if (!strcmp ("cell_even", detail) ||
!strcmp ("cell_odd", detail) ||
- !strcmp ("cell_even_ruled", detail))
+ !strcmp ("cell_even_ruled", detail) ||
+ !strcmp ("cell_even_ruled_sorted", detail))
{
/* This has to be really broken; alex made me do it. -jrb */
if (GTK_WIDGET_HAS_FOCUS (widget))
else
gc1 = style->base_gc[GTK_STATE_ACTIVE];
}
- else if (!strcmp ("cell_odd_ruled", detail))
+ else if (!strcmp ("cell_odd_ruled", detail) ||
+ !strcmp ("cell_odd_ruled_sorted", detail))
{
if (GTK_WIDGET_HAS_FOCUS (widget))
freeme = get_darkened_gc (window, &style->base[state_type], 1);
GdkGC *gc3 = NULL;
GdkGC *gc4 = NULL;
- g_return_if_fail (GTK_IS_STYLE (style));
- g_return_if_fail (window != NULL);
-
sanitize_size (window, &width, &height);
switch (shadow_type)
GdkGC *gc3 = NULL;
GdkGC *gc4 = NULL;
- g_return_if_fail (GTK_IS_STYLE (style));
- g_return_if_fail (window != NULL);
-
gtk_style_apply_default_background (style, window,
widget && !GTK_WIDGET_NO_WINDOW (widget),
state_type, area, x, y, width, height);
gdk_draw_line (window, gc2,
x, y + gap_x, x, y + gap_x);
}
- if ((width - (gap_x + gap_width)) > 0)
+ if ((height - (gap_x + gap_width)) > 0)
{
gdk_draw_line (window, gc1,
x, y + gap_x + gap_width, x, y + height - 2);
gdk_draw_line (window, gc3,
x + width - 1, y + gap_x, x + width - 1, y + gap_x);
}
- if ((width - (gap_x + gap_width)) > 0)
+ if ((height - (gap_x + gap_width)) > 0)
{
gdk_draw_line (window, gc4,
x + width - 1, y + gap_x + gap_width, x + width - 1, y + height - 2);
GdkGC *gc3 = NULL;
GdkGC *gc4 = NULL;
- g_return_if_fail (GTK_IS_STYLE (style));
- g_return_if_fail (window != NULL);
-
gtk_style_apply_default_background (style, window,
widget && !GTK_WIDGET_NO_WINDOW (widget),
GTK_STATE_NORMAL, area, x, y, width, height);
gint height,
GtkOrientation orientation)
{
- g_return_if_fail (GTK_IS_STYLE (style));
- g_return_if_fail (window != NULL);
-
sanitize_size (window, &width, &height);
gtk_paint_box (style, window, state_type, shadow_type,
gint y,
gushort size)
{
-
size = CLAMP (size, 2, 3);
if (size == 2)
GdkRectangle dest;
gint intersect;
- g_return_if_fail (GTK_IS_STYLE (style));
- g_return_if_fail (window != NULL);
-
sanitize_size (window, &width, &height);
gtk_paint_box (style, window, state_type, shadow_type, area, widget,
PangoLayout *layout)
{
GdkGC *gc;
-
- g_return_if_fail (GTK_IS_STYLE (style));
- g_return_if_fail (window != NULL);
gc = use_text ? style->text_gc[state_type] : style->fg_gc[state_type];
GdkPoint points[4];
gint i, j, skip;
- g_return_if_fail (GTK_IS_STYLE (style));
- g_return_if_fail (window != NULL);
-
if (area)
{
gdk_gc_set_clip_rectangle (style->light_gc[state_type], area);
GTK_STYLE_GET_CLASS (style)->draw_focus (style, window, state_type, area, widget, detail, x, y, width, height);
}
+/**
+ * gtk_paint_slider:
+ * @style: a #GtkStyle
+ * @window: a #GdkWindow
+ * @state_type: a state
+ * @shadow_type: a shadow
+ * @area: clip rectangle, or %NULL if the
+ * output should not be clipped
+ * @widget: the widget (may be %NULL)
+ * @detail: a style detail (may be %NULL)
+ * @x: the x origin of the rectangle in which to draw a slider
+ * @y: the y origin of the rectangle in which to draw a slider
+ * @width: the width of the rectangle in which to draw a slider
+ * @height: the height of the rectangle in which to draw a slider
+ * @orientation: the orientation to be used
+ *
+ * Draws a slider in the given rectangle on @window using the
+ * given style and orientation.
+ **/
void
gtk_paint_slider (GtkStyle *style,
GdkWindow *window,
widget, detail, x, y, expander_style);
}
+/**
+ * gtk_paint_layout:
+ * @style: a #GtkStyle
+ * @window: a #GdkWindow
+ * @state_type: a state
+ * @use_text: whether to use the text or foreground
+ * graphics context of @style
+ * @area: clip rectangle, or %NULL if the
+ * output should not be clipped
+ * @widget: the widget (may be %NULL)
+ * @detail: a style detail (may be %NULL)
+ * @x: x origin
+ * @y: y origin
+ * @layout: the layout to draw
+ *
+ * Draws a layout on @window using the given parameters.
+ **/
void
gtk_paint_layout (GtkStyle *style,
GdkWindow *window,
GtkStateType state_type,
- gboolean use_text,
+ gboolean use_text,
GdkRectangle *area,
GtkWidget *widget,
const gchar *detail,
gfloat cursor_aspect_ratio;
gint offset;
- g_return_if_fail (direction != GTK_TEXT_DIR_NONE);
-
/* When changing the shape or size of the cursor here,
* propagate the changes to gtktextview.c:text_window_invalidate_cursors().
*/