st: Use G_DECLARE_*_TYPE

Cut down on boilerplate by using the (no longer that) new helper
macros. We don't care about breaking ABI in private libraries, so
use G_DECLARE_FINAL_TYPE even where the class struct used to be
exposed in the header, except for types we inherit from ourselves
(obviously) or where the class exposes any vfuncs (where changes
could affect inheritance in extensions).
This commit is contained in:
Florian Müllner 2015-09-24 16:08:13 +02:00
parent 2f88a7a1e1
commit ffe4eaf00d
36 changed files with 552 additions and 819 deletions

View File

@ -37,6 +37,8 @@
#include "st-adjustment.h"
#include "st-private.h"
typedef struct _StAdjustmentPrivate StAdjustmentPrivate;
struct _StAdjustmentPrivate
{
/* Do not sanity-check values while constructing,
@ -90,6 +92,7 @@ st_adjustment_constructed (GObject *object)
{
GObjectClass *g_class;
StAdjustment *self = ST_ADJUSTMENT (object);
StAdjustmentPrivate *priv = st_adjustment_get_instance_private (self);
g_class = G_OBJECT_CLASS (st_adjustment_parent_class);
/* The docs say we're suppose to chain up, but would crash without
@ -100,8 +103,8 @@ st_adjustment_constructed (GObject *object)
g_class->constructed (object);
}
ST_ADJUSTMENT (self)->priv->is_constructing = FALSE;
st_adjustment_clamp_page (self, self->priv->lower, self->priv->upper);
priv->is_constructing = FALSE;
st_adjustment_clamp_page (self, priv->lower, priv->upper);
}
static void
@ -110,7 +113,7 @@ st_adjustment_get_property (GObject *gobject,
GValue *value,
GParamSpec *pspec)
{
StAdjustmentPrivate *priv = ST_ADJUSTMENT (gobject)->priv;
StAdjustmentPrivate *priv = st_adjustment_get_instance_private (ST_ADJUSTMENT (gobject));
switch (prop_id)
{
@ -271,9 +274,8 @@ st_adjustment_class_init (StAdjustmentClass *klass)
static void
st_adjustment_init (StAdjustment *self)
{
self->priv = st_adjustment_get_instance_private (self);
self->priv->is_constructing = TRUE;
StAdjustmentPrivate *priv = st_adjustment_get_instance_private (self);
priv->is_constructing = TRUE;
}
StAdjustment *
@ -297,13 +299,9 @@ st_adjustment_new (gdouble value,
gdouble
st_adjustment_get_value (StAdjustment *adjustment)
{
StAdjustmentPrivate *priv;
g_return_val_if_fail (ST_IS_ADJUSTMENT (adjustment), 0);
priv = adjustment->priv;
return priv->value;
return ((StAdjustmentPrivate *)st_adjustment_get_instance_private (adjustment))->value;
}
void
@ -314,7 +312,7 @@ st_adjustment_set_value (StAdjustment *adjustment,
g_return_if_fail (ST_IS_ADJUSTMENT (adjustment));
priv = adjustment->priv;
priv = st_adjustment_get_instance_private (adjustment);
/* Defer clamp until after construction. */
if (!priv->is_constructing)
@ -342,7 +340,7 @@ st_adjustment_clamp_page (StAdjustment *adjustment,
g_return_if_fail (ST_IS_ADJUSTMENT (adjustment));
priv = adjustment->priv;
priv = st_adjustment_get_instance_private (adjustment);
lower = CLAMP (lower, priv->lower, priv->upper - priv->page_size);
upper = CLAMP (upper, priv->lower + priv->page_size, priv->upper);
@ -369,7 +367,7 @@ static gboolean
st_adjustment_set_lower (StAdjustment *adjustment,
gdouble lower)
{
StAdjustmentPrivate *priv = adjustment->priv;
StAdjustmentPrivate *priv = st_adjustment_get_instance_private (adjustment);
if (priv->lower != lower)
{
@ -393,7 +391,7 @@ static gboolean
st_adjustment_set_upper (StAdjustment *adjustment,
gdouble upper)
{
StAdjustmentPrivate *priv = adjustment->priv;
StAdjustmentPrivate *priv = st_adjustment_get_instance_private (adjustment);
if (priv->upper != upper)
{
@ -417,7 +415,7 @@ static gboolean
st_adjustment_set_step_increment (StAdjustment *adjustment,
gdouble step)
{
StAdjustmentPrivate *priv = adjustment->priv;
StAdjustmentPrivate *priv = st_adjustment_get_instance_private (adjustment);
if (priv->step_increment != step)
{
@ -437,7 +435,7 @@ static gboolean
st_adjustment_set_page_increment (StAdjustment *adjustment,
gdouble page)
{
StAdjustmentPrivate *priv = adjustment->priv;
StAdjustmentPrivate *priv = st_adjustment_get_instance_private (adjustment);
if (priv->page_increment != page)
{
@ -457,7 +455,7 @@ static gboolean
st_adjustment_set_page_size (StAdjustment *adjustment,
gdouble size)
{
StAdjustmentPrivate *priv = adjustment->priv;
StAdjustmentPrivate *priv = st_adjustment_get_instance_private (adjustment);
if (priv->page_size != size)
{
@ -494,7 +492,7 @@ st_adjustment_set_values (StAdjustment *adjustment,
g_return_if_fail (step_increment >= 0 && step_increment <= G_MAXDOUBLE);
g_return_if_fail (page_increment >= 0 && page_increment <= G_MAXDOUBLE);
priv = adjustment->priv;
priv = st_adjustment_get_instance_private (adjustment);
emit_changed = FALSE;
@ -543,7 +541,7 @@ st_adjustment_get_values (StAdjustment *adjustment,
g_return_if_fail (ST_IS_ADJUSTMENT (adjustment));
priv = adjustment->priv;
priv = st_adjustment_get_instance_private (adjustment);
if (lower)
*lower = priv->lower;
@ -585,7 +583,7 @@ st_adjustment_adjust_for_scroll_event (StAdjustment *adjustment,
g_return_if_fail (ST_IS_ADJUSTMENT (adjustment));
priv = adjustment->priv;
priv = st_adjustment_get_instance_private (adjustment);
scroll_unit = pow (priv->page_size, 2.0 / 3.0);

View File

@ -31,30 +31,7 @@
G_BEGIN_DECLS
#define ST_TYPE_ADJUSTMENT (st_adjustment_get_type())
#define ST_ADJUSTMENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ST_TYPE_ADJUSTMENT, StAdjustment))
#define ST_IS_ADJUSTMENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ST_TYPE_ADJUSTMENT))
#define ST_ADJUSTMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ST_TYPE_ADJUSTMENT, StAdjustmentClass))
#define ST_IS_ADJUSTMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ST_TYPE_ADJUSTMENT))
#define ST_ADJUSTMENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ST_TYPE_ADJUSTMENT, StAdjustmentClass))
typedef struct _StAdjustment StAdjustment;
typedef struct _StAdjustmentPrivate StAdjustmentPrivate;
typedef struct _StAdjustmentClass StAdjustmentClass;
/**
* StAdjustment:
*
* Class for handling an interval between to values. The contents of
* the #StAdjustment are private and should be accessed using the
* public API.
*/
struct _StAdjustment
{
/*< private >*/
GObject parent_instance;
StAdjustmentPrivate *priv;
};
G_DECLARE_DERIVABLE_TYPE (StAdjustment, st_adjustment, ST, ADJUSTMENT, GObject)
/**
* StAdjustmentClass:
@ -71,8 +48,6 @@ struct _StAdjustmentClass
void (* changed) (StAdjustment *adjustment);
};
GType st_adjustment_get_type (void) G_GNUC_CONST;
StAdjustment *st_adjustment_new (gdouble value,
gdouble lower,
gdouble upper,

View File

@ -38,6 +38,7 @@
#include "st-enum-types.h"
#include "st-private.h"
typedef struct _StBinPrivate StBinPrivate;
struct _StBinPrivate
{
ClutterActor *child;
@ -78,10 +79,11 @@ static void
st_bin_remove (ClutterContainer *container,
ClutterActor *actor)
{
StBinPrivate *priv = ST_BIN (container)->priv;
StBin *bin = ST_BIN (container);
StBinPrivate *priv = st_bin_get_instance_private (bin);
if (priv->child == actor)
st_bin_set_child (ST_BIN (container), NULL);
st_bin_set_child (bin, NULL);
}
static void
@ -96,7 +98,7 @@ st_bin_allocate (ClutterActor *self,
const ClutterActorBox *box,
ClutterAllocationFlags flags)
{
StBinPrivate *priv = ST_BIN (self)->priv;
StBinPrivate *priv = st_bin_get_instance_private (ST_BIN (self));
clutter_actor_set_allocation (self, box, flags);
@ -122,7 +124,7 @@ st_bin_get_preferred_width (ClutterActor *self,
gfloat *min_width_p,
gfloat *natural_width_p)
{
StBinPrivate *priv = ST_BIN (self)->priv;
StBinPrivate *priv = st_bin_get_instance_private (ST_BIN (self));
StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (self));
st_theme_node_adjust_for_height (theme_node, &for_height);
@ -151,7 +153,7 @@ st_bin_get_preferred_height (ClutterActor *self,
gfloat *min_height_p,
gfloat *natural_height_p)
{
StBinPrivate *priv = ST_BIN (self)->priv;
StBinPrivate *priv = st_bin_get_instance_private (ST_BIN (self));
StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (self));
st_theme_node_adjust_for_width (theme_node, &for_width);
@ -177,7 +179,7 @@ st_bin_get_preferred_height (ClutterActor *self,
static void
st_bin_dispose (GObject *gobject)
{
StBinPrivate *priv = ST_BIN (gobject)->priv;
StBinPrivate *priv = st_bin_get_instance_private (ST_BIN (gobject));
if (priv->child)
clutter_actor_destroy (priv->child);
@ -189,7 +191,7 @@ st_bin_dispose (GObject *gobject)
static void
st_bin_popup_menu (StWidget *widget)
{
StBinPrivate *priv = ST_BIN (widget)->priv;
StBinPrivate *priv = st_bin_get_instance_private (ST_BIN (widget));
if (priv->child && ST_IS_WIDGET (priv->child))
st_widget_popup_menu (ST_WIDGET (priv->child));
@ -200,7 +202,7 @@ st_bin_navigate_focus (StWidget *widget,
ClutterActor *from,
GtkDirectionType direction)
{
StBinPrivate *priv = ST_BIN (widget)->priv;
StBinPrivate *priv = st_bin_get_instance_private (ST_BIN (widget));
ClutterActor *bin_actor = CLUTTER_ACTOR (widget);
if (st_widget_get_can_focus (widget))
@ -231,6 +233,7 @@ st_bin_set_property (GObject *gobject,
GParamSpec *pspec)
{
StBin *bin = ST_BIN (gobject);
StBinPrivate *priv = st_bin_get_instance_private (bin);
switch (prop_id)
{
@ -241,24 +244,24 @@ st_bin_set_property (GObject *gobject,
case PROP_X_ALIGN:
st_bin_set_alignment (bin,
g_value_get_enum (value),
bin->priv->y_align);
priv->y_align);
break;
case PROP_Y_ALIGN:
st_bin_set_alignment (bin,
bin->priv->x_align,
priv->x_align,
g_value_get_enum (value));
break;
case PROP_X_FILL:
st_bin_set_fill (bin,
g_value_get_boolean (value),
bin->priv->y_fill);
priv->y_fill);
break;
case PROP_Y_FILL:
st_bin_set_fill (bin,
bin->priv->x_fill,
priv->x_fill,
g_value_get_boolean (value));
break;
@ -273,7 +276,7 @@ st_bin_get_property (GObject *gobject,
GValue *value,
GParamSpec *pspec)
{
StBinPrivate *priv = ST_BIN (gobject)->priv;
StBinPrivate *priv = st_bin_get_instance_private (ST_BIN (gobject));
switch (prop_id)
{
@ -389,10 +392,10 @@ st_bin_class_init (StBinClass *klass)
static void
st_bin_init (StBin *bin)
{
bin->priv = st_bin_get_instance_private (bin);
StBinPrivate *priv = st_bin_get_instance_private (bin);
bin->priv->x_align = ST_ALIGN_MIDDLE;
bin->priv->y_align = ST_ALIGN_MIDDLE;
priv->x_align = ST_ALIGN_MIDDLE;
priv->y_align = ST_ALIGN_MIDDLE;
}
/**
@ -426,7 +429,7 @@ st_bin_set_child (StBin *bin,
g_return_if_fail (ST_IS_BIN (bin));
g_return_if_fail (child == NULL || CLUTTER_IS_ACTOR (child));
priv = bin->priv;
priv = st_bin_get_instance_private (bin);
if (priv->child == child)
return;
@ -460,7 +463,7 @@ st_bin_get_child (StBin *bin)
{
g_return_val_if_fail (ST_IS_BIN (bin), NULL);
return bin->priv->child;
return ((StBinPrivate *)st_bin_get_instance_private (bin))->child;
}
/**
@ -482,7 +485,7 @@ st_bin_set_alignment (StBin *bin,
g_return_if_fail (ST_IS_BIN (bin));
priv = bin->priv;
priv = st_bin_get_instance_private (bin);
g_object_freeze_notify (G_OBJECT (bin));
@ -524,7 +527,7 @@ st_bin_get_alignment (StBin *bin,
g_return_if_fail (ST_IS_BIN (bin));
priv = bin->priv;
priv = st_bin_get_instance_private (bin);
if (x_align)
*x_align = priv->x_align;
@ -552,7 +555,7 @@ st_bin_set_fill (StBin *bin,
g_return_if_fail (ST_IS_BIN (bin));
priv = bin->priv;
priv = st_bin_get_instance_private (bin);
g_object_freeze_notify (G_OBJECT (bin));
@ -591,11 +594,15 @@ st_bin_get_fill (StBin *bin,
gboolean *x_fill,
gboolean *y_fill)
{
StBinPrivate *priv;
g_return_if_fail (ST_IS_BIN (bin));
priv = st_bin_get_instance_private (bin);
if (x_fill)
*x_fill = bin->priv->x_fill;
*x_fill = priv->x_fill;
if (y_fill)
*y_fill = bin->priv->y_fill;
*y_fill = priv->y_fill;
}

View File

@ -30,28 +30,7 @@
G_BEGIN_DECLS
#define ST_TYPE_BIN (st_bin_get_type ())
#define ST_BIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ST_TYPE_BIN, StBin))
#define ST_IS_BIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ST_TYPE_BIN))
#define ST_BIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ST_TYPE_BIN, StBinClass))
#define ST_IS_BIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ST_TYPE_BIN))
#define ST_BIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ST_TYPE_BIN, StBinClass))
typedef struct _StBin StBin;
typedef struct _StBinPrivate StBinPrivate;
typedef struct _StBinClass StBinClass;
/**
* StBin:
*
* The #StBin struct contains only private data
*/
struct _StBin
{
/*< private >*/
StWidget parent_instance;
StBinPrivate *priv;
};
G_DECLARE_DERIVABLE_TYPE (StBin, st_bin, ST, BIN, StWidget)
/**
* StBinClass:
@ -64,8 +43,6 @@ struct _StBinClass
StWidgetClass parent_class;
};
GType st_bin_get_type (void) G_GNUC_CONST;
StWidget * st_bin_new (void);
void st_bin_set_child (StBin *bin,
ClutterActor *child);

View File

@ -28,17 +28,9 @@ G_BEGIN_DECLS
/* A StBorderImage encapsulates an image with specified unscaled borders on each edge.
*/
typedef struct _StBorderImage StBorderImage;
typedef struct _StBorderImageClass StBorderImageClass;
#define ST_TYPE_BORDER_IMAGE (st_border_image_get_type ())
#define ST_BORDER_IMAGE(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), ST_TYPE_BORDER_IMAGE, StBorderImage))
#define ST_BORDER_IMAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ST_TYPE_BORDER_IMAGE, StBorderImageClass))
#define ST_IS_BORDER_IMAGE(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), ST_TYPE_BORDER_IMAGE))
#define ST_IS_BORDER_IMAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ST_TYPE_BORDER_IMAGE))
#define ST_BORDER_IMAGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ST_TYPE_BORDER_IMAGE, StBorderImageClass))
GType st_border_image_get_type (void) G_GNUC_CONST;
G_DECLARE_FINAL_TYPE (StBorderImage, st_border_image, ST, BORDER_IMAGE, GObject)
StBorderImage *st_border_image_new (GFile *file,
int border_top,

View File

@ -27,29 +27,9 @@
G_BEGIN_DECLS
#define ST_TYPE_BOX_LAYOUT_CHILD st_box_layout_child_get_type()
#define ST_BOX_LAYOUT_CHILD(obj) \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), \
ST_TYPE_BOX_LAYOUT_CHILD, StBoxLayoutChild))
#define ST_BOX_LAYOUT_CHILD_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST ((klass), \
ST_TYPE_BOX_LAYOUT_CHILD, StBoxLayoutChildClass))
#define ST_IS_BOX_LAYOUT_CHILD(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
ST_TYPE_BOX_LAYOUT_CHILD))
#define ST_IS_BOX_LAYOUT_CHILD_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), \
ST_TYPE_BOX_LAYOUT_CHILD))
#define ST_BOX_LAYOUT_CHILD_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), \
ST_TYPE_BOX_LAYOUT_CHILD, StBoxLayoutChildClass))
G_DECLARE_FINAL_TYPE (StBoxLayoutChild, st_box_layout_child, ST, BOX_LAYOUT_CHILD, ClutterChildMeta)
typedef struct _StBoxLayoutChild StBoxLayoutChild;
typedef struct _StBoxLayoutChildClass StBoxLayoutChildClass;
typedef struct _StBoxLayoutChildPrivate StBoxLayoutChildPrivate;
/**
@ -67,13 +47,6 @@ struct _StBoxLayoutChild
gboolean y_fill_set;
};
struct _StBoxLayoutChildClass
{
ClutterChildMetaClass parent_class;
};
GType st_box_layout_child_get_type (void);
G_END_DECLS
#endif /* _ST_BOX_LAYOUT_CHILD_H */

View File

@ -30,29 +30,9 @@
G_BEGIN_DECLS
#define ST_TYPE_BOX_LAYOUT st_box_layout_get_type()
#define ST_BOX_LAYOUT(obj) \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), \
ST_TYPE_BOX_LAYOUT, StBoxLayout))
#define ST_BOX_LAYOUT_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST ((klass), \
ST_TYPE_BOX_LAYOUT, StBoxLayoutClass))
#define ST_IS_BOX_LAYOUT(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
ST_TYPE_BOX_LAYOUT))
#define ST_IS_BOX_LAYOUT_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), \
ST_TYPE_BOX_LAYOUT))
#define ST_BOX_LAYOUT_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), \
ST_TYPE_BOX_LAYOUT, StBoxLayoutClass))
G_DECLARE_FINAL_TYPE (StBoxLayout, st_box_layout, ST, BOX_LAYOUT, StWidget)
typedef struct _StBoxLayout StBoxLayout;
typedef struct _StBoxLayoutClass StBoxLayoutClass;
typedef struct _StBoxLayoutPrivate StBoxLayoutPrivate;
/**
@ -69,13 +49,6 @@ struct _StBoxLayout
StBoxLayoutPrivate *priv;
};
struct _StBoxLayoutClass
{
StWidgetClass parent_class;
};
GType st_box_layout_get_type (void);
StWidget *st_box_layout_new (void);
void st_box_layout_set_vertical (StBoxLayout *box,

View File

@ -64,6 +64,8 @@ enum
LAST_SIGNAL
};
typedef struct _StButtonPrivate StButtonPrivate;
struct _StButtonPrivate
{
gchar *text;
@ -105,7 +107,7 @@ static void
st_button_style_changed (StWidget *widget)
{
StButton *button = ST_BUTTON (widget);
StButtonPrivate *priv = button->priv;
StButtonPrivate *priv = st_button_get_instance_private (button);
StButtonClass *button_class = ST_BUTTON_GET_CLASS (button);
StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (button));
double spacing;
@ -132,12 +134,14 @@ st_button_press (StButton *button,
StButtonMask mask,
ClutterEventSequence *sequence)
{
if (button->priv->pressed == 0 || sequence)
StButtonPrivate *priv = st_button_get_instance_private (button);
if (priv->pressed == 0 || sequence)
st_widget_add_style_pseudo_class (ST_WIDGET (button), "active");
button->priv->pressed |= mask;
button->priv->press_sequence = sequence;
button->priv->device = device;
priv->pressed |= mask;
priv->press_sequence = sequence;
priv->device = device;
}
static void
@ -147,25 +151,27 @@ st_button_release (StButton *button,
int clicked_button,
ClutterEventSequence *sequence)
{
if ((device && button->priv->device != device) ||
(sequence && button->priv->press_sequence != sequence))
StButtonPrivate *priv = st_button_get_instance_private (button);
if ((device && priv->device != device) ||
(sequence && priv->press_sequence != sequence))
return;
else if (!sequence)
{
button->priv->pressed &= ~mask;
priv->pressed &= ~mask;
if (button->priv->pressed != 0)
if (priv->pressed != 0)
return;
}
button->priv->press_sequence = NULL;
button->priv->device = NULL;
priv->press_sequence = NULL;
priv->device = NULL;
st_widget_remove_style_pseudo_class (ST_WIDGET (button), "active");
if (clicked_button || sequence)
{
if (button->priv->is_toggle)
st_button_set_checked (button, !button->priv->is_checked);
if (priv->is_toggle)
st_button_set_checked (button, !priv->is_checked);
g_signal_emit (button, button_signals[CLICKED], 0, clicked_button);
}
@ -176,18 +182,19 @@ st_button_button_press (ClutterActor *actor,
ClutterButtonEvent *event)
{
StButton *button = ST_BUTTON (actor);
StButtonPrivate *priv = st_button_get_instance_private (button);
StButtonMask mask = ST_BUTTON_MASK_FROM_BUTTON (event->button);
ClutterInputDevice *device = clutter_event_get_device ((ClutterEvent*) event);
if (button->priv->press_sequence)
if (priv->press_sequence)
return CLUTTER_EVENT_PROPAGATE;
if (button->priv->button_mask & mask)
if (priv->button_mask & mask)
{
if (button->priv->grabbed == 0)
if (priv->grabbed == 0)
clutter_grab_pointer (actor);
button->priv->grabbed |= mask;
priv->grabbed |= mask;
st_button_press (button, device, mask, NULL);
return TRUE;
@ -201,18 +208,19 @@ st_button_button_release (ClutterActor *actor,
ClutterButtonEvent *event)
{
StButton *button = ST_BUTTON (actor);
StButtonPrivate *priv = st_button_get_instance_private (button);
StButtonMask mask = ST_BUTTON_MASK_FROM_BUTTON (event->button);
ClutterInputDevice *device = clutter_event_get_device ((ClutterEvent*) event);
if (button->priv->button_mask & mask)
if (priv->button_mask & mask)
{
gboolean is_click;
is_click = button->priv->grabbed && clutter_actor_contains (actor, event->source);
is_click = priv->grabbed && clutter_actor_contains (actor, event->source);
st_button_release (button, device, mask, is_click ? event->button : 0, NULL);
button->priv->grabbed &= ~mask;
if (button->priv->grabbed == 0)
priv->grabbed &= ~mask;
if (priv->grabbed == 0)
clutter_ungrab_pointer ();
return TRUE;
@ -226,25 +234,26 @@ st_button_touch_event (ClutterActor *actor,
ClutterTouchEvent *event)
{
StButton *button = ST_BUTTON (actor);
StButtonPrivate *priv = st_button_get_instance_private (button);
StButtonMask mask = ST_BUTTON_MASK_FROM_BUTTON (1);
ClutterEventSequence *sequence;
ClutterInputDevice *device;
if (button->priv->pressed != 0)
if (priv->pressed != 0)
return CLUTTER_EVENT_PROPAGATE;
device = clutter_event_get_device ((ClutterEvent*) event);
sequence = clutter_event_get_event_sequence ((ClutterEvent*) event);
if (event->type == CLUTTER_TOUCH_BEGIN && !button->priv->press_sequence)
if (event->type == CLUTTER_TOUCH_BEGIN && !priv->press_sequence)
{
clutter_input_device_sequence_grab (device, sequence, actor);
st_button_press (button, device, 0, sequence);
return CLUTTER_EVENT_STOP;
}
else if (event->type == CLUTTER_TOUCH_END &&
button->priv->device == device &&
button->priv->press_sequence == sequence)
priv->device == device &&
priv->press_sequence == sequence)
{
st_button_release (button, device, mask, 0, sequence);
clutter_input_device_sequence_ungrab (device, sequence);
@ -259,8 +268,9 @@ st_button_key_press (ClutterActor *actor,
ClutterKeyEvent *event)
{
StButton *button = ST_BUTTON (actor);
StButtonPrivate *priv = st_button_get_instance_private (button);
if (button->priv->button_mask & ST_BUTTON_ONE)
if (priv->button_mask & ST_BUTTON_ONE)
{
if (event->keyval == CLUTTER_KEY_space ||
event->keyval == CLUTTER_KEY_Return ||
@ -280,8 +290,9 @@ st_button_key_release (ClutterActor *actor,
ClutterKeyEvent *event)
{
StButton *button = ST_BUTTON (actor);
StButtonPrivate *priv = st_button_get_instance_private (button);
if (button->priv->button_mask & ST_BUTTON_ONE)
if (priv->button_mask & ST_BUTTON_ONE)
{
if (event->keyval == CLUTTER_KEY_space ||
event->keyval == CLUTTER_KEY_Return ||
@ -290,7 +301,7 @@ st_button_key_release (ClutterActor *actor,
{
gboolean is_click;
is_click = (button->priv->pressed & ST_BUTTON_ONE);
is_click = (priv->pressed & ST_BUTTON_ONE);
st_button_release (button, NULL, ST_BUTTON_ONE, is_click ? 1 : 0, NULL);
return TRUE;
}
@ -303,10 +314,11 @@ static void
st_button_key_focus_out (ClutterActor *actor)
{
StButton *button = ST_BUTTON (actor);
StButtonPrivate *priv = st_button_get_instance_private (button);
/* If we lose focus between a key press and release, undo the press */
if ((button->priv->pressed & ST_BUTTON_ONE) &&
!(button->priv->grabbed & ST_BUTTON_ONE))
if ((priv->pressed & ST_BUTTON_ONE) &&
!(priv->grabbed & ST_BUTTON_ONE))
st_button_release (button, NULL, ST_BUTTON_ONE, 0, NULL);
CLUTTER_ACTOR_CLASS (st_button_parent_class)->key_focus_out (actor);
@ -317,18 +329,19 @@ st_button_enter (ClutterActor *actor,
ClutterCrossingEvent *event)
{
StButton *button = ST_BUTTON (actor);
StButtonPrivate *priv = st_button_get_instance_private (button);
gboolean ret;
ret = CLUTTER_ACTOR_CLASS (st_button_parent_class)->enter_event (actor, event);
if (button->priv->grabbed)
if (priv->grabbed)
{
if (st_widget_get_hover (ST_WIDGET (button)))
st_button_press (button, button->priv->device,
button->priv->grabbed, NULL);
st_button_press (button, priv->device,
priv->grabbed, NULL);
else
st_button_release (button, button->priv->device,
button->priv->grabbed, 0, NULL);
st_button_release (button, priv->device,
priv->grabbed, 0, NULL);
}
return ret;
@ -339,18 +352,19 @@ st_button_leave (ClutterActor *actor,
ClutterCrossingEvent *event)
{
StButton *button = ST_BUTTON (actor);
StButtonPrivate *priv = st_button_get_instance_private (button);
gboolean ret;
ret = CLUTTER_ACTOR_CLASS (st_button_parent_class)->leave_event (actor, event);
if (button->priv->grabbed)
if (priv->grabbed)
{
if (st_widget_get_hover (ST_WIDGET (button)))
st_button_press (button, button->priv->device,
button->priv->grabbed, NULL);
st_button_press (button, priv->device,
priv->grabbed, NULL);
else
st_button_release (button, button->priv->device,
button->priv->grabbed, 0, NULL);
st_button_release (button, priv->device,
priv->grabbed, 0, NULL);
}
return ret;
@ -392,7 +406,7 @@ st_button_get_property (GObject *gobject,
GValue *value,
GParamSpec *pspec)
{
StButtonPrivate *priv = ST_BUTTON (gobject)->priv;
StButtonPrivate *priv = st_button_get_instance_private (ST_BUTTON (gobject));
switch (prop_id)
{
@ -422,7 +436,7 @@ st_button_get_property (GObject *gobject,
static void
st_button_finalize (GObject *gobject)
{
StButtonPrivate *priv = ST_BUTTON (gobject)->priv;
StButtonPrivate *priv = st_button_get_instance_private (ST_BUTTON (gobject));
g_free (priv->text);
@ -507,9 +521,10 @@ st_button_class_init (StButtonClass *klass)
static void
st_button_init (StButton *button)
{
button->priv = st_button_get_instance_private (button);
button->priv->spacing = 6;
button->priv->button_mask = ST_BUTTON_ONE;
StButtonPrivate *priv = st_button_get_instance_private (button);
priv->spacing = 6;
priv->button_mask = ST_BUTTON_ONE;
clutter_actor_set_reactive (CLUTTER_ACTOR (button), TRUE);
st_widget_set_track_hover (ST_WIDGET (button), TRUE);
@ -555,7 +570,7 @@ st_button_get_label (StButton *button)
{
g_return_val_if_fail (ST_IS_BUTTON (button), NULL);
return button->priv->text;
return ((StButtonPrivate *)st_button_get_instance_private (button))->text;
}
/**
@ -574,7 +589,7 @@ st_button_set_label (StButton *button,
g_return_if_fail (ST_IS_BUTTON (button));
priv = button->priv;
priv = st_button_get_instance_private (button);
g_free (priv->text);
@ -621,7 +636,7 @@ st_button_get_button_mask (StButton *button)
{
g_return_val_if_fail (ST_IS_BUTTON (button), 0);
return button->priv->button_mask;
return ((StButtonPrivate *)st_button_get_instance_private (button))->button_mask;
}
/**
@ -635,9 +650,12 @@ void
st_button_set_button_mask (StButton *button,
StButtonMask mask)
{
StButtonPrivate *priv;
g_return_if_fail (ST_IS_BUTTON (button));
button->priv->button_mask = mask;
priv = st_button_get_instance_private (button);
priv->button_mask = mask;
g_object_notify (G_OBJECT (button), "button-mask");
}
@ -655,7 +673,7 @@ st_button_get_toggle_mode (StButton *button)
{
g_return_val_if_fail (ST_IS_BUTTON (button), FALSE);
return button->priv->is_toggle;
return ((StButtonPrivate *)st_button_get_instance_private (button))->is_toggle;
}
/**
@ -670,9 +688,12 @@ void
st_button_set_toggle_mode (StButton *button,
gboolean toggle)
{
StButtonPrivate *priv;
g_return_if_fail (ST_IS_BUTTON (button));
button->priv->is_toggle = toggle;
priv = st_button_get_instance_private (button);
priv->is_toggle = toggle;
g_object_notify (G_OBJECT (button), "toggle-mode");
}
@ -690,7 +711,7 @@ st_button_get_checked (StButton *button)
{
g_return_val_if_fail (ST_IS_BUTTON (button), FALSE);
return button->priv->is_checked;
return ((StButtonPrivate *)st_button_get_instance_private (button))->is_checked;
}
/**
@ -705,11 +726,14 @@ void
st_button_set_checked (StButton *button,
gboolean checked)
{
StButtonPrivate *priv;
g_return_if_fail (ST_IS_BUTTON (button));
if (button->priv->is_checked != checked)
priv = st_button_get_instance_private (button);
if (priv->is_checked != checked)
{
button->priv->is_checked = checked;
priv->is_checked = checked;
if (checked)
st_widget_add_style_pseudo_class (ST_WIDGET (button), "checked");
@ -736,25 +760,30 @@ st_button_set_checked (StButton *button,
void
st_button_fake_release (StButton *button)
{
if (button->priv->pressed)
st_button_release (button, button->priv->device,
button->priv->pressed, 0, NULL);
StButtonPrivate *priv;
if (button->priv->grabbed)
g_return_if_fail (ST_IS_BUTTON (button));
priv = st_button_get_instance_private (button);
if (priv->pressed)
st_button_release (button, priv->device,
priv->pressed, 0, NULL);
if (priv->grabbed)
{
button->priv->grabbed = 0;
priv->grabbed = 0;
clutter_ungrab_pointer ();
}
if (button->priv->device &&
button->priv->press_sequence)
if (priv->device &&
priv->press_sequence)
{
clutter_input_device_sequence_ungrab (button->priv->device,
button->priv->press_sequence);
button->priv->press_sequence = NULL;
clutter_input_device_sequence_ungrab (priv->device,
priv->press_sequence);
priv->press_sequence = NULL;
}
button->priv->device = NULL;
priv->device = NULL;
}
/******************************************************************************/
@ -817,7 +846,7 @@ st_button_accessible_get_name (AtkObject *obj)
if (name != NULL)
return name;
return button->priv->text;
return st_button_get_label (button);
}
static void
@ -847,7 +876,7 @@ static void
st_button_accessible_compute_role (AtkObject *accessible,
StButton *button)
{
atk_object_set_role (accessible, button->priv->is_toggle
atk_object_set_role (accessible, st_button_get_toggle_mode (button)
? ATK_ROLE_TOGGLE_BUTTON : ATK_ROLE_PUSH_BUTTON);
}

View File

@ -30,30 +30,7 @@ G_BEGIN_DECLS
#include <st/st-bin.h>
#define ST_TYPE_BUTTON (st_button_get_type ())
#define ST_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ST_TYPE_BUTTON, StButton))
#define ST_IS_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ST_TYPE_BUTTON))
#define ST_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ST_TYPE_BUTTON, StButtonClass))
#define ST_IS_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ST_TYPE_BUTTON))
#define ST_BUTTON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ST_TYPE_BUTTON, StButtonClass))
typedef struct _StButton StButton;
typedef struct _StButtonPrivate StButtonPrivate;
typedef struct _StButtonClass StButtonClass;
/**
* StButton:
*
* The contents of this structure is private and should only be accessed using
* the provided API.
*/
struct _StButton
{
/*< private >*/
StBin parent_instance;
StButtonPrivate *priv;
};
G_DECLARE_DERIVABLE_TYPE (StButton, st_button, ST, BUTTON, StBin)
struct _StButtonClass
{
@ -66,8 +43,6 @@ struct _StButtonClass
void (* clicked) (StButton *button);
};
GType st_button_get_type (void) G_GNUC_CONST;
StWidget *st_button_new (void);
StWidget *st_button_new_with_label (const gchar *text);
const gchar *st_button_get_label (StButton *button);

View File

@ -29,29 +29,9 @@
G_BEGIN_DECLS
#define ST_TYPE_CLIPBOARD st_clipboard_get_type()
#define ST_CLIPBOARD(obj) \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), \
ST_TYPE_CLIPBOARD, StClipboard))
#define ST_CLIPBOARD_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST ((klass), \
ST_TYPE_CLIPBOARD, StClipboardClass))
#define ST_IS_CLIPBOARD(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
ST_TYPE_CLIPBOARD))
#define ST_IS_CLIPBOARD_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), \
ST_TYPE_CLIPBOARD))
#define ST_CLIPBOARD_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), \
ST_TYPE_CLIPBOARD, StClipboardClass))
G_DECLARE_FINAL_TYPE (StClipboard, st_clipboard, ST, CLIPBOARD, GObject)
typedef struct _StClipboard StClipboard;
typedef struct _StClipboardClass StClipboardClass;
typedef struct _StClipboardPrivate StClipboardPrivate;
/**
@ -67,11 +47,6 @@ struct _StClipboard
StClipboardPrivate *priv;
};
struct _StClipboardClass
{
GObjectClass parent_class;
};
typedef enum {
ST_CLIPBOARD_TYPE_PRIMARY,
ST_CLIPBOARD_TYPE_CLIPBOARD
@ -89,8 +64,6 @@ typedef void (*StClipboardCallbackFunc) (StClipboard *clipboard,
const gchar *text,
gpointer user_data);
GType st_clipboard_get_type (void);
StClipboard* st_clipboard_get_default (void);
void st_clipboard_get_text (StClipboard *clipboard,

View File

@ -36,6 +36,7 @@
#include <cairo.h>
typedef struct _StDrawingAreaPrivate StDrawingAreaPrivate;
struct _StDrawingAreaPrivate {
CoglTexture *texture;
CoglPipeline *pipeline;
@ -59,7 +60,7 @@ static void
st_drawing_area_dispose (GObject *object)
{
StDrawingArea *area = ST_DRAWING_AREA (object);
StDrawingAreaPrivate *priv = area->priv;
StDrawingAreaPrivate *priv = st_drawing_area_get_instance_private (area);
g_clear_pointer (&priv->pipeline, cogl_object_unref);
g_clear_pointer (&priv->texture, cogl_object_unref);
@ -71,7 +72,7 @@ static void
st_drawing_area_paint (ClutterActor *self)
{
StDrawingArea *area = ST_DRAWING_AREA (self);
StDrawingAreaPrivate *priv = area->priv;
StDrawingAreaPrivate *priv = st_drawing_area_get_instance_private (area);
StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (self));
ClutterActorBox allocation_box;
ClutterActorBox content_box;
@ -157,7 +158,7 @@ static void
st_drawing_area_style_changed (StWidget *self)
{
StDrawingArea *area = ST_DRAWING_AREA (self);
StDrawingAreaPrivate *priv = area->priv;
StDrawingAreaPrivate *priv = st_drawing_area_get_instance_private (area);
(ST_WIDGET_CLASS (st_drawing_area_parent_class))->style_changed (self);
@ -187,8 +188,8 @@ st_drawing_area_class_init (StDrawingAreaClass *klass)
static void
st_drawing_area_init (StDrawingArea *area)
{
area->priv = st_drawing_area_get_instance_private (area);
area->priv->texture = NULL;
StDrawingAreaPrivate *priv = st_drawing_area_get_instance_private (area);
priv->texture = NULL;
}
/**
@ -208,7 +209,7 @@ st_drawing_area_queue_repaint (StDrawingArea *area)
g_return_if_fail (ST_IS_DRAWING_AREA (area));
priv = area->priv;
priv = st_drawing_area_get_instance_private (area);
priv->needs_repaint = TRUE;
clutter_actor_queue_redraw (CLUTTER_ACTOR (area));
@ -226,10 +227,14 @@ st_drawing_area_queue_repaint (StDrawingArea *area)
cairo_t *
st_drawing_area_get_context (StDrawingArea *area)
{
g_return_val_if_fail (ST_IS_DRAWING_AREA (area), NULL);
g_return_val_if_fail (area->priv->in_repaint, NULL);
StDrawingAreaPrivate *priv;
return area->priv->context;
g_return_val_if_fail (ST_IS_DRAWING_AREA (area), NULL);
priv = st_drawing_area_get_instance_private (area);
g_return_val_if_fail (priv->in_repaint, NULL);
return priv->context;
}
/**
@ -250,9 +255,9 @@ st_drawing_area_get_surface_size (StDrawingArea *area,
StDrawingAreaPrivate *priv;
g_return_if_fail (ST_IS_DRAWING_AREA (area));
g_return_if_fail (area->priv->in_repaint);
priv = area->priv;
priv = st_drawing_area_get_instance_private (area);
g_return_if_fail (priv->in_repaint);
if (width)
*width = cogl_texture_get_width (priv->texture);

View File

@ -25,23 +25,8 @@
#include <cairo.h>
#define ST_TYPE_DRAWING_AREA (st_drawing_area_get_type ())
#define ST_DRAWING_AREA(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ST_TYPE_DRAWING_AREA, StDrawingArea))
#define ST_DRAWING_AREA_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ST_TYPE_DRAWING_AREA, StDrawingAreaClass))
#define ST_IS_DRAWING_AREA(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ST_TYPE_DRAWING_AREA))
#define ST_IS_DRAWING_AREA_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ST_TYPE_DRAWING_AREA))
#define ST_DRAWING_AREA_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ST_TYPE_DRAWING_AREA, StDrawingAreaClass))
typedef struct _StDrawingArea StDrawingArea;
typedef struct _StDrawingAreaClass StDrawingAreaClass;
typedef struct _StDrawingAreaPrivate StDrawingAreaPrivate;
struct _StDrawingArea
{
StWidget parent;
StDrawingAreaPrivate *priv;
};
G_DECLARE_DERIVABLE_TYPE (StDrawingArea, st_drawing_area,
ST, DRAWING_AREA, StWidget)
struct _StDrawingAreaClass
{
@ -50,8 +35,6 @@ struct _StDrawingAreaClass
void (*repaint) (StDrawingArea *area);
};
GType st_drawing_area_get_type (void) G_GNUC_CONST;
void st_drawing_area_queue_repaint (StDrawingArea *area);
cairo_t *st_drawing_area_get_context (StDrawingArea *area);
void st_drawing_area_get_surface_size (StDrawingArea *area,

View File

@ -87,9 +87,10 @@ enum
LAST_SIGNAL
};
#define ST_ENTRY_PRIV(x) ((StEntry *) x)->priv
#define ST_ENTRY_PRIV(x) st_entry_get_instance_private ((StEntry *) x)
typedef struct _StEntryPrivate StEntryPrivate;
struct _StEntryPrivate
{
ClutterActor *entry;
@ -182,7 +183,8 @@ st_entry_get_property (GObject *gobject,
static void
show_capslock_feedback (StEntry *entry)
{
if (entry->priv->secondary_icon == NULL)
StEntryPrivate *priv = ST_ENTRY_PRIV (entry);
if (priv->secondary_icon == NULL)
{
ClutterActor *icon = g_object_new (ST_TYPE_ICON,
"style-class", "capslock-warning",
@ -190,17 +192,18 @@ show_capslock_feedback (StEntry *entry)
NULL);
st_entry_set_secondary_icon (entry, icon);
entry->priv->capslock_warning_shown = TRUE;
priv->capslock_warning_shown = TRUE;
}
}
static void
remove_capslock_feedback (StEntry *entry)
{
if (entry->priv->capslock_warning_shown)
StEntryPrivate *priv = ST_ENTRY_PRIV (entry);
if (priv->capslock_warning_shown)
{
st_entry_set_secondary_icon (entry, NULL);
entry->priv->capslock_warning_shown = FALSE;
priv->capslock_warning_shown = FALSE;
}
}
@ -209,8 +212,9 @@ keymap_state_changed (GdkKeymap *keymap,
gpointer user_data)
{
StEntry *entry = ST_ENTRY (user_data);
StEntryPrivate *priv = ST_ENTRY_PRIV (entry);
if (clutter_text_get_password_char (CLUTTER_TEXT (entry->priv->entry)) != 0)
if (clutter_text_get_password_char (CLUTTER_TEXT (priv->entry)) != 0)
{
if (gdk_keymap_get_caps_lock_state (keymap))
show_capslock_feedback (entry);
@ -223,7 +227,7 @@ static void
st_entry_dispose (GObject *object)
{
StEntry *entry = ST_ENTRY (object);
StEntryPrivate *priv = entry->priv;
StEntryPrivate *priv = ST_ENTRY_PRIV (entry);
GdkKeymap *keymap;
if (priv->entry)
@ -479,7 +483,7 @@ clutter_text_focus_in_cb (ClutterText *text,
ClutterActor *actor)
{
StEntry *entry = ST_ENTRY (actor);
StEntryPrivate *priv = entry->priv;
StEntryPrivate *priv = ST_ENTRY_PRIV (entry);
GdkKeymap *keymap;
/* remove the hint if visible */
@ -505,7 +509,7 @@ clutter_text_focus_out_cb (ClutterText *text,
ClutterActor *actor)
{
StEntry *entry = ST_ENTRY (actor);
StEntryPrivate *priv = entry->priv;
StEntryPrivate *priv = ST_ENTRY_PRIV (entry);
GdkKeymap *keymap;
st_widget_remove_style_pseudo_class (ST_WIDGET (actor), "focus");
@ -531,8 +535,9 @@ clutter_text_password_char_cb (GObject *object,
gpointer user_data)
{
StEntry *entry = ST_ENTRY (user_data);
StEntryPrivate *priv = ST_ENTRY_PRIV (entry);
if (clutter_text_get_password_char (CLUTTER_TEXT (entry->priv->entry)) == 0)
if (clutter_text_get_password_char (CLUTTER_TEXT (priv->entry)) == 0)
remove_capslock_feedback (entry);
}
@ -541,7 +546,8 @@ st_entry_clipboard_callback (StClipboard *clipboard,
const gchar *text,
gpointer data)
{
ClutterText *ctext = (ClutterText*)((StEntry *) data)->priv->entry;
StEntryPrivate *priv = ST_ENTRY_PRIV (data);
ClutterText *ctext = (ClutterText*)priv->entry;
gint cursor_pos;
if (!text)
@ -720,14 +726,15 @@ st_entry_set_cursor (StEntry *entry,
{
cursor_func (entry, use_ibeam, cursor_func_data);
entry->priv->has_ibeam = use_ibeam;
((StEntryPrivate *)ST_ENTRY_PRIV (entry))->has_ibeam = use_ibeam;
}
static gboolean
st_entry_enter_event (ClutterActor *actor,
ClutterCrossingEvent *event)
{
if (event->source == ST_ENTRY (actor)->priv->entry && event->related != NULL)
StEntryPrivate *priv = ST_ENTRY_PRIV (actor);
if (event->source == priv->entry && event->related != NULL)
st_entry_set_cursor (ST_ENTRY (actor), TRUE);
return CLUTTER_ACTOR_CLASS (st_entry_parent_class)->enter_event (actor, event);
@ -737,7 +744,8 @@ static gboolean
st_entry_leave_event (ClutterActor *actor,
ClutterCrossingEvent *event)
{
if (event->source == ST_ENTRY (actor)->priv->entry && event->related != NULL)
StEntryPrivate *priv = ST_ENTRY_PRIV (actor);
if (event->source == priv->entry && event->related != NULL)
st_entry_set_cursor (ST_ENTRY (actor), FALSE);
return CLUTTER_ACTOR_CLASS (st_entry_parent_class)->leave_event (actor, event);
@ -746,7 +754,8 @@ st_entry_leave_event (ClutterActor *actor,
static void
st_entry_unmap (ClutterActor *actor)
{
if (ST_ENTRY (actor)->priv->has_ibeam)
StEntryPrivate *priv = ST_ENTRY_PRIV (actor);
if (priv->has_ibeam)
st_entry_set_cursor (ST_ENTRY (actor), FALSE);
CLUTTER_ACTOR_CLASS (st_entry_parent_class)->unmap (actor);
@ -855,7 +864,7 @@ st_entry_init (StEntry *entry)
{
StEntryPrivate *priv;
priv = entry->priv = st_entry_get_instance_private (entry);
priv = st_entry_get_instance_private (entry);
priv->entry = g_object_new (ST_TYPE_IM_TEXT,
"line-alignment", PANGO_ALIGN_LEFT,
@ -917,12 +926,15 @@ st_entry_new (const gchar *text)
const gchar *
st_entry_get_text (StEntry *entry)
{
StEntryPrivate *priv;
g_return_val_if_fail (ST_IS_ENTRY (entry), NULL);
if (entry->priv->hint_visible)
priv = st_entry_get_instance_private (entry);
if (priv->hint_visible)
return "";
else
return clutter_text_get_text (CLUTTER_TEXT (entry->priv->entry));
return clutter_text_get_text (CLUTTER_TEXT (priv->entry));
}
/**
@ -940,7 +952,7 @@ st_entry_set_text (StEntry *entry,
g_return_if_fail (ST_IS_ENTRY (entry));
priv = entry->priv;
priv = st_entry_get_instance_private (entry);
/* set a hint if we are blanking the entry */
if (priv->hint
@ -977,7 +989,7 @@ st_entry_get_clutter_text (StEntry *entry)
{
g_return_val_if_fail (ST_ENTRY (entry), NULL);
return entry->priv->entry;
return ((StEntryPrivate *)ST_ENTRY_PRIV (entry))->entry;
}
/**
@ -997,7 +1009,7 @@ st_entry_set_hint_text (StEntry *entry,
g_return_if_fail (ST_IS_ENTRY (entry));
priv = entry->priv;
priv = st_entry_get_instance_private (entry);
g_free (priv->hint);
@ -1027,7 +1039,7 @@ st_entry_get_hint_text (StEntry *entry)
{
g_return_val_if_fail (ST_IS_ENTRY (entry), NULL);
return entry->priv->hint;
return ((StEntryPrivate *)ST_ENTRY_PRIV (entry))->hint;
}
/**
@ -1043,11 +1055,13 @@ void
st_entry_set_input_purpose (StEntry *entry,
GtkInputPurpose purpose)
{
StEntryPrivate *priv;
StIMText *imtext;
g_return_if_fail (ST_IS_ENTRY (entry));
imtext = ST_IM_TEXT (entry->priv->entry);
priv = st_entry_get_instance_private (entry);
imtext = ST_IM_TEXT (priv->entry);
if (st_im_text_get_input_purpose (imtext) != purpose)
{
@ -1066,9 +1080,12 @@ st_entry_set_input_purpose (StEntry *entry,
GtkInputPurpose
st_entry_get_input_purpose (StEntry *entry)
{
StEntryPrivate *priv;
g_return_val_if_fail (ST_IS_ENTRY (entry), GTK_INPUT_PURPOSE_FREE_FORM);
return st_im_text_get_input_purpose (ST_IM_TEXT (entry->priv->entry));
priv = st_entry_get_instance_private (entry);
return st_im_text_get_input_purpose (ST_IM_TEXT (priv->entry));
}
/**
@ -1083,11 +1100,13 @@ void
st_entry_set_input_hints (StEntry *entry,
GtkInputHints hints)
{
StEntryPrivate *priv;
StIMText *imtext;
g_return_if_fail (ST_IS_ENTRY (entry));
imtext = ST_IM_TEXT (entry->priv->entry);
priv = st_entry_get_instance_private (entry);
imtext = ST_IM_TEXT (priv->entry);
if (st_im_text_get_input_hints (imtext) != hints)
{
@ -1106,9 +1125,12 @@ st_entry_set_input_hints (StEntry *entry,
GtkInputHints
st_entry_get_input_hints (StEntry *entry)
{
StEntryPrivate *priv;
g_return_val_if_fail (ST_IS_ENTRY (entry), GTK_INPUT_HINT_NONE);
return st_im_text_get_input_hints (ST_IM_TEXT (entry->priv->entry));
priv = st_entry_get_instance_private (entry);
return st_im_text_get_input_hints (ST_IM_TEXT (priv->entry));
}
static gboolean
@ -1116,7 +1138,7 @@ _st_entry_icon_press_cb (ClutterActor *actor,
ClutterButtonEvent *event,
StEntry *entry)
{
StEntryPrivate *priv = entry->priv;
StEntryPrivate *priv = ST_ENTRY_PRIV (actor);
if (actor == priv->primary_icon)
g_signal_emit (entry, entry_signals[PRIMARY_ICON_CLICKED], 0);
@ -1168,7 +1190,7 @@ st_entry_set_primary_icon (StEntry *entry,
g_return_if_fail (ST_IS_ENTRY (entry));
priv = entry->priv;
priv = st_entry_get_instance_private (entry);
_st_entry_set_icon (entry, &priv->primary_icon, icon);
}
@ -1188,7 +1210,7 @@ st_entry_set_secondary_icon (StEntry *entry,
g_return_if_fail (ST_IS_ENTRY (entry));
priv = entry->priv;
priv = st_entry_get_instance_private (entry);
_st_entry_set_icon (entry, &priv->secondary_icon, icon);
}
@ -1239,6 +1261,7 @@ static gint
st_entry_accessible_get_n_children (AtkObject *obj)
{
StEntry *entry = NULL;
StEntryPrivate *priv;
g_return_val_if_fail (ST_IS_ENTRY_ACCESSIBLE (obj), 0);
@ -1247,7 +1270,8 @@ st_entry_accessible_get_n_children (AtkObject *obj)
if (entry == NULL)
return 0;
if (entry->priv->entry == NULL)
priv = st_entry_get_instance_private (entry);
if (priv->entry == NULL)
return 0;
else
return 1;
@ -1258,6 +1282,7 @@ st_entry_accessible_ref_child (AtkObject *obj,
gint i)
{
StEntry *entry = NULL;
StEntryPrivate *priv;
AtkObject *result = NULL;
g_return_val_if_fail (ST_IS_ENTRY_ACCESSIBLE (obj), NULL);
@ -1268,10 +1293,11 @@ st_entry_accessible_ref_child (AtkObject *obj,
if (entry == NULL)
return NULL;
if (entry->priv->entry == NULL)
priv = st_entry_get_instance_private (entry);
if (priv->entry == NULL)
return NULL;
result = clutter_actor_get_accessible (entry->priv->entry);
result = clutter_actor_get_accessible (priv->entry);
g_object_ref (result);
return result;

View File

@ -29,29 +29,7 @@ G_BEGIN_DECLS
#include <st/st-widget.h>
#define ST_TYPE_ENTRY (st_entry_get_type ())
#define ST_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ST_TYPE_ENTRY, StEntry))
#define ST_IS_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ST_TYPE_ENTRY))
#define ST_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ST_TYPE_ENTRY, StEntryClass))
#define ST_IS_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ST_TYPE_ENTRY))
#define ST_ENTRY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ST_TYPE_ENTRY, StEntryClass))
typedef struct _StEntry StEntry;
typedef struct _StEntryPrivate StEntryPrivate;
typedef struct _StEntryClass StEntryClass;
/**
* StEntry:
*
* The contents of this structure is private and should only be accessed using
* the provided API.
*/
struct _StEntry
{
/*< private >*/
StWidget parent_instance;
StEntryPrivate *priv;
};
G_DECLARE_DERIVABLE_TYPE (StEntry, st_entry, ST, ENTRY, StWidget)
struct _StEntryClass
{
@ -62,8 +40,6 @@ struct _StEntryClass
void (*secondary_icon_clicked) (StEntry *entry);
};
GType st_entry_get_type (void) G_GNUC_CONST;
StWidget *st_entry_new (const gchar *text);
const gchar *st_entry_get_text (StEntry *entry);
void st_entry_set_text (StEntry *entry,

View File

@ -31,15 +31,10 @@
G_BEGIN_DECLS
#define ST_TYPE_FOCUS_MANAGER (st_focus_manager_get_type ())
#define ST_FOCUS_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ST_TYPE_FOCUS_MANAGER, StFocusManager))
#define ST_IS_FOCUS_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ST_TYPE_FOCUS_MANAGER))
#define ST_FOCUS_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ST_TYPE_FOCUS_MANAGER, StFocusManagerClass))
#define ST_IS_FOCUS_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ST_TYPE_FOCUS_MANAGER))
#define ST_FOCUS_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ST_TYPE_FOCUS_MANAGER, StFocusManagerClass))
G_DECLARE_FINAL_TYPE (StFocusManager, st_focus_manager, ST, FOCUS_MANAGER, GObject)
typedef struct _StFocusManager StFocusManager;
typedef struct _StFocusManagerPrivate StFocusManagerPrivate;
typedef struct _StFocusManagerClass StFocusManagerClass;
/**
* StFocusManager:
@ -54,19 +49,6 @@ struct _StFocusManager
StFocusManagerPrivate *priv;
};
/**
* StFocusManagerClass:
*
* The #StFocusManagerClass struct contains only private data
*/
struct _StFocusManagerClass
{
/*< private >*/
GObjectClass parent_class;
};
GType st_focus_manager_get_type (void) G_GNUC_CONST;
StFocusManager *st_focus_manager_get_for_stage (ClutterStage *stage);
void st_focus_manager_add_group (StFocusManager *manager,

View File

@ -37,21 +37,7 @@
G_BEGIN_DECLS
#define ST_TYPE_ICON st_icon_get_type()
#define ST_ICON(obj) \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), ST_TYPE_ICON, StIcon))
#define ST_ICON_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST ((klass), ST_TYPE_ICON, StIconClass))
#define ST_IS_ICON(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), ST_TYPE_ICON))
#define ST_IS_ICON_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), ST_TYPE_ICON))
#define ST_ICON_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), ST_TYPE_ICON, StIconClass))
G_DECLARE_FINAL_TYPE (StIcon, st_icon, ST, ICON, StWidget)
typedef struct _StIconPrivate StIconPrivate;
@ -61,25 +47,12 @@ typedef struct _StIconPrivate StIconPrivate;
* The contents of this structure are private and should only be accessed
* through the public API.
*/
typedef struct {
struct _StIcon {
/*< private >*/
StWidget parent;
StIconPrivate *priv;
} StIcon;
typedef struct {
StWidgetClass parent_class;
/* padding for future expansion */
void (*_padding_0) (void);
void (*_padding_1) (void);
void (*_padding_2) (void);
void (*_padding_3) (void);
void (*_padding_4) (void);
} StIconClass;
GType st_icon_get_type (void);
};
ClutterActor* st_icon_new (void);

View File

@ -36,15 +36,10 @@ G_BEGIN_DECLS
#include <clutter/clutter.h>
#define ST_TYPE_IM_TEXT (st_im_text_get_type ())
#define ST_IM_TEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ST_TYPE_IM_TEXT, StIMText))
#define ST_IS_IM_TEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ST_TYPE_IM_TEXT))
#define ST_IM_TEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ST_TYPE_IM_TEXT, StIMTextClass))
#define ST_IS_IM_TEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ST_TYPE_IM_TEXT))
#define ST_IM_TEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ST_TYPE_IM_TEXT, StIMTextClass))
G_DECLARE_FINAL_TYPE (StIMText, st_im_text, ST, IM_TEXT, ClutterText)
typedef struct _StIMText StIMText;
typedef struct _StIMTextPrivate StIMTextPrivate;
typedef struct _StIMTextClass StIMTextClass;
struct _StIMText
{
@ -53,13 +48,6 @@ struct _StIMText
StIMTextPrivate *priv;
};
struct _StIMTextClass
{
ClutterTextClass parent_class;
};
GType st_im_text_get_type (void) G_GNUC_CONST;
ClutterActor *st_im_text_new (const gchar *text);
void st_im_text_set_input_purpose (StIMText *imtext,
GtkInputPurpose purpose);

View File

@ -29,15 +29,9 @@ G_BEGIN_DECLS
#include <st/st-widget.h>
#define ST_TYPE_LABEL (st_label_get_type ())
#define ST_LABEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ST_TYPE_LABEL, StLabel))
#define ST_IS_LABEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ST_TYPE_LABEL))
#define ST_LABEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ST_TYPE_LABEL, StLabelClass))
#define ST_IS_LABEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ST_TYPE_LABEL))
#define ST_LABEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ST_TYPE_LABEL, StLabelClass))
G_DECLARE_FINAL_TYPE (StLabel, st_label, ST, LABEL, StWidget)
typedef struct _StLabel StLabel;
typedef struct _StLabelPrivate StLabelPrivate;
typedef struct _StLabelClass StLabelClass;
/**
* StLabel:
@ -53,13 +47,6 @@ struct _StLabel
StLabelPrivate *priv;
};
struct _StLabelClass
{
StWidgetClass parent_class;
};
GType st_label_get_type (void) G_GNUC_CONST;
StWidget * st_label_new (const gchar *text);
const gchar * st_label_get_text (StLabel *label);
void st_label_set_text (StLabel *label,

View File

@ -44,6 +44,7 @@
#define PAGING_INITIAL_REPEAT_TIMEOUT 500
#define PAGING_SUBSEQUENT_REPEAT_TIMEOUT 200
typedef struct _StScrollBarPrivate StScrollBarPrivate;
struct _StScrollBarPrivate
{
StAdjustment *adjustment;
@ -70,6 +71,8 @@ struct _StScrollBarPrivate
G_DEFINE_TYPE_WITH_PRIVATE (StScrollBar, st_scroll_bar, ST_TYPE_WIDGET)
#define ST_SCROLL_BAR_PRIVATE(sb) st_scroll_bar_get_instance_private (ST_SCROLL_BAR (sb))
enum
{
PROP_0,
@ -103,7 +106,7 @@ st_scroll_bar_get_property (GObject *gobject,
GValue *value,
GParamSpec *pspec)
{
StScrollBarPrivate *priv = ST_SCROLL_BAR (gobject)->priv;
StScrollBarPrivate *priv = ST_SCROLL_BAR_PRIVATE (gobject);
switch (prop_id)
{
@ -128,6 +131,7 @@ st_scroll_bar_set_property (GObject *gobject,
GParamSpec *pspec)
{
StScrollBar *bar = ST_SCROLL_BAR (gobject);
StScrollBarPrivate *priv = st_scroll_bar_get_instance_private (bar);
switch (prop_id)
{
@ -136,12 +140,12 @@ st_scroll_bar_set_property (GObject *gobject,
break;
case PROP_VERTICAL:
bar->priv->vertical = g_value_get_boolean (value);
if (bar->priv->vertical)
clutter_actor_set_name (CLUTTER_ACTOR (bar->priv->handle),
priv->vertical = g_value_get_boolean (value);
if (priv->vertical)
clutter_actor_set_name (CLUTTER_ACTOR (priv->handle),
"vhandle");
else
clutter_actor_set_name (CLUTTER_ACTOR (bar->priv->handle),
clutter_actor_set_name (CLUTTER_ACTOR (priv->handle),
"hhandle");
clutter_actor_queue_relayout ((ClutterActor*) gobject);
break;
@ -156,7 +160,7 @@ static void
st_scroll_bar_dispose (GObject *gobject)
{
StScrollBar *bar = ST_SCROLL_BAR (gobject);
StScrollBarPrivate *priv = bar->priv;
StScrollBarPrivate *priv = st_scroll_bar_get_instance_private (bar);
if (priv->adjustment)
st_scroll_bar_set_adjustment (bar, NULL);
@ -189,7 +193,7 @@ scroll_bar_allocate_children (StScrollBar *bar,
const ClutterActorBox *box,
ClutterAllocationFlags flags)
{
StScrollBarPrivate *priv = bar->priv;
StScrollBarPrivate *priv = st_scroll_bar_get_instance_private (bar);
StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (bar));
ClutterActorBox content_box, trough_box;
@ -281,7 +285,7 @@ st_scroll_bar_get_preferred_width (ClutterActor *self,
gfloat *natural_width_p)
{
StScrollBar *bar = ST_SCROLL_BAR (self);
StScrollBarPrivate *priv = bar->priv;
StScrollBarPrivate *priv = st_scroll_bar_get_instance_private (bar);
StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (self));
gfloat trough_min_width, trough_natural_width;
gfloat handle_min_width, handle_natural_width;
@ -321,7 +325,7 @@ st_scroll_bar_get_preferred_height (ClutterActor *self,
gfloat *natural_height_p)
{
StScrollBar *bar = ST_SCROLL_BAR (self);
StScrollBarPrivate *priv = bar->priv;
StScrollBarPrivate *priv = st_scroll_bar_get_instance_private (bar);
StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (self));
gfloat trough_min_height, trough_natural_height;
gfloat handle_min_height, handle_natural_height;
@ -392,7 +396,7 @@ scroll_bar_update_positions (StScrollBar *bar)
static void
st_scroll_bar_style_changed (StWidget *widget)
{
StScrollBarPrivate *priv = ST_SCROLL_BAR (widget)->priv;
StScrollBarPrivate *priv = ST_SCROLL_BAR_PRIVATE (widget);
st_widget_style_changed (ST_WIDGET (priv->trough));
st_widget_style_changed (ST_WIDGET (priv->handle));
@ -406,8 +410,9 @@ bar_reactive_notify_cb (GObject *gobject,
gpointer user_data)
{
StScrollBar *bar = ST_SCROLL_BAR (gobject);
StScrollBarPrivate *priv = st_scroll_bar_get_instance_private (bar);
clutter_actor_set_reactive (bar->priv->handle,
clutter_actor_set_reactive (priv->handle,
clutter_actor_get_reactive (CLUTTER_ACTOR (bar)));
}
@ -460,7 +465,7 @@ static gboolean
st_scroll_bar_scroll_event (ClutterActor *actor,
ClutterScrollEvent *event)
{
StScrollBarPrivate *priv = ST_SCROLL_BAR (actor)->priv;
StScrollBarPrivate *priv = ST_SCROLL_BAR_PRIVATE (actor);
if (clutter_event_is_pointer_emulated ((ClutterEvent *) event))
return TRUE;
@ -551,7 +556,7 @@ move_slider (StScrollBar *bar,
gfloat x,
gfloat y)
{
StScrollBarPrivate *priv = bar->priv;
StScrollBarPrivate *priv = st_scroll_bar_get_instance_private (bar);
gdouble position, lower, upper, page_size;
gfloat ux, uy, pos, size;
@ -595,13 +600,14 @@ move_slider (StScrollBar *bar,
static void
stop_scrolling (StScrollBar *bar)
{
if (!bar->priv->grabbed)
StScrollBarPrivate *priv = st_scroll_bar_get_instance_private (bar);
if (!priv->grabbed)
return;
st_widget_remove_style_pseudo_class (ST_WIDGET (bar->priv->handle), "active");
st_widget_remove_style_pseudo_class (ST_WIDGET (priv->handle), "active");
clutter_ungrab_pointer ();
bar->priv->grabbed = FALSE;
priv->grabbed = FALSE;
g_signal_emit (bar, signals[SCROLL_STOP], 0);
}
@ -610,7 +616,8 @@ handle_motion_event_cb (ClutterActor *trough,
ClutterMotionEvent *event,
StScrollBar *bar)
{
if (!bar->priv->grabbed)
StScrollBarPrivate *priv = st_scroll_bar_get_instance_private (bar);
if (!priv->grabbed)
return FALSE;
move_slider (bar, event->x, event->y);
@ -634,7 +641,7 @@ handle_button_press_event_cb (ClutterActor *actor,
ClutterButtonEvent *event,
StScrollBar *bar)
{
StScrollBarPrivate *priv = bar->priv;
StScrollBarPrivate *priv = st_scroll_bar_get_instance_private (bar);
if (event->button != 1)
return FALSE;
@ -672,6 +679,7 @@ animation_completed_cb (ClutterAnimation *animation,
static gboolean
trough_paging_cb (StScrollBar *self)
{
StScrollBarPrivate *priv = st_scroll_bar_get_instance_private (self);
gfloat handle_pos, event_pos, tx, ty;
gdouble value;
gdouble page_increment;
@ -682,66 +690,66 @@ trough_paging_cb (StScrollBar *self)
GValue v = { 0, };
ClutterTimeline *t;
if (self->priv->paging_event_no == 0)
if (priv->paging_event_no == 0)
{
/* Scroll on after initial timeout. */
mode = CLUTTER_EASE_OUT_CUBIC;
ret = FALSE;
self->priv->paging_event_no = 1;
self->priv->paging_source_id = g_timeout_add (
priv->paging_event_no = 1;
priv->paging_source_id = g_timeout_add (
PAGING_INITIAL_REPEAT_TIMEOUT,
(GSourceFunc) trough_paging_cb,
self);
g_source_set_name_by_id (self->priv->paging_source_id, "[gnome-shell] trough_paging_cb");
g_source_set_name_by_id (priv->paging_source_id, "[gnome-shell] trough_paging_cb");
}
else if (self->priv->paging_event_no == 1)
else if (priv->paging_event_no == 1)
{
/* Scroll on after subsequent timeout. */
ret = FALSE;
mode = CLUTTER_EASE_IN_CUBIC;
self->priv->paging_event_no = 2;
self->priv->paging_source_id = g_timeout_add (
priv->paging_event_no = 2;
priv->paging_source_id = g_timeout_add (
PAGING_SUBSEQUENT_REPEAT_TIMEOUT,
(GSourceFunc) trough_paging_cb,
self);
g_source_set_name_by_id (self->priv->paging_source_id, "[gnome-shell] trough_paging_cb");
g_source_set_name_by_id (priv->paging_source_id, "[gnome-shell] trough_paging_cb");
}
else
{
/* Keep scrolling. */
ret = TRUE;
mode = CLUTTER_LINEAR;
self->priv->paging_event_no++;
priv->paging_event_no++;
}
/* Do the scrolling */
st_adjustment_get_values (self->priv->adjustment,
st_adjustment_get_values (priv->adjustment,
&value, NULL, NULL,
NULL, &page_increment, NULL);
if (self->priv->vertical)
handle_pos = clutter_actor_get_y (self->priv->handle);
if (priv->vertical)
handle_pos = clutter_actor_get_y (priv->handle);
else
handle_pos = clutter_actor_get_x (self->priv->handle);
handle_pos = clutter_actor_get_x (priv->handle);
clutter_actor_transform_stage_point (CLUTTER_ACTOR (self->priv->trough),
self->priv->move_x,
self->priv->move_y,
clutter_actor_transform_stage_point (CLUTTER_ACTOR (priv->trough),
priv->move_x,
priv->move_y,
&tx, &ty);
if (self->priv->vertical)
if (priv->vertical)
event_pos = ty;
else
event_pos = tx;
if (event_pos > handle_pos)
{
if (self->priv->paging_direction == NONE)
if (priv->paging_direction == NONE)
{
/* Remember direction. */
self->priv->paging_direction = DOWN;
priv->paging_direction = DOWN;
}
if (self->priv->paging_direction == UP)
if (priv->paging_direction == UP)
{
/* Scrolled far enough. */
return FALSE;
@ -750,12 +758,12 @@ trough_paging_cb (StScrollBar *self)
}
else
{
if (self->priv->paging_direction == NONE)
if (priv->paging_direction == NONE)
{
/* Remember direction. */
self->priv->paging_direction = UP;
priv->paging_direction = UP;
}
if (self->priv->paging_direction == DOWN)
if (priv->paging_direction == DOWN)
{
/* Scrolled far enough. */
return FALSE;
@ -763,24 +771,23 @@ trough_paging_cb (StScrollBar *self)
value -= page_increment;
}
if (self->priv->paging_animation)
if (priv->paging_animation)
{
clutter_animation_completed (self->priv->paging_animation);
clutter_animation_completed (priv->paging_animation);
}
/* FIXME: Creating a new animation for each scroll is probably not the best
* idea, but it's a lot less involved than extenind the current animation */
a = self->priv->paging_animation = g_object_new (CLUTTER_TYPE_ANIMATION,
"object", self->priv->adjustment,
a = priv->paging_animation = g_object_new (CLUTTER_TYPE_ANIMATION,
"object", priv->adjustment,
"duration", (guint)(PAGING_SUBSEQUENT_REPEAT_TIMEOUT * st_slow_down_factor),
"mode", mode,
NULL);
g_value_init (&v, G_TYPE_DOUBLE);
g_value_set_double (&v, value);
clutter_animation_bind (self->priv->paging_animation, "value", &v);
t = clutter_animation_get_timeline (self->priv->paging_animation);
g_signal_connect (a, "completed", G_CALLBACK (animation_completed_cb),
self->priv);
clutter_animation_bind (priv->paging_animation, "value", &v);
t = clutter_animation_get_timeline (priv->paging_animation);
g_signal_connect (a, "completed", G_CALLBACK (animation_completed_cb), priv);
clutter_timeline_start (t);
return ret;
@ -791,18 +798,21 @@ trough_button_press_event_cb (ClutterActor *actor,
ClutterButtonEvent *event,
StScrollBar *self)
{
StScrollBarPrivate *priv;
g_return_val_if_fail (self, FALSE);
if (event->button != 1)
return FALSE;
if (self->priv->adjustment == NULL)
priv = st_scroll_bar_get_instance_private (self);
if (priv->adjustment == NULL)
return FALSE;
self->priv->move_x = event->x;
self->priv->move_y = event->y;
self->priv->paging_direction = NONE;
self->priv->paging_event_no = 0;
priv->move_x = event->x;
priv->move_y = event->y;
priv->paging_direction = NONE;
priv->paging_event_no = 0;
trough_paging_cb (self);
return TRUE;
@ -813,13 +823,15 @@ trough_button_release_event_cb (ClutterActor *actor,
ClutterButtonEvent *event,
StScrollBar *self)
{
StScrollBarPrivate *priv = st_scroll_bar_get_instance_private (self);
if (event->button != 1)
return FALSE;
if (self->priv->paging_source_id)
if (priv->paging_source_id)
{
g_source_remove (self->priv->paging_source_id);
self->priv->paging_source_id = 0;
g_source_remove (priv->paging_source_id);
priv->paging_source_id = 0;
}
return TRUE;
@ -830,10 +842,12 @@ trough_leave_event_cb (ClutterActor *actor,
ClutterEvent *event,
StScrollBar *self)
{
if (self->priv->paging_source_id)
StScrollBarPrivate *priv = st_scroll_bar_get_instance_private (self);
if (priv->paging_source_id)
{
g_source_remove (self->priv->paging_source_id);
self->priv->paging_source_id = 0;
g_source_remove (priv->paging_source_id);
priv->paging_source_id = 0;
return TRUE;
}
@ -843,7 +857,7 @@ trough_leave_event_cb (ClutterActor *actor,
static void
st_scroll_bar_notify_reactive (StScrollBar *self)
{
StScrollBarPrivate *priv = self->priv;
StScrollBarPrivate *priv = st_scroll_bar_get_instance_private (self);
gboolean reactive = clutter_actor_get_reactive (CLUTTER_ACTOR (self));
@ -854,29 +868,29 @@ st_scroll_bar_notify_reactive (StScrollBar *self)
static void
st_scroll_bar_init (StScrollBar *self)
{
self->priv = st_scroll_bar_get_instance_private (self);
StScrollBarPrivate *priv = st_scroll_bar_get_instance_private (self);
self->priv->trough = (ClutterActor *) st_bin_new ();
clutter_actor_set_reactive ((ClutterActor *) self->priv->trough, TRUE);
clutter_actor_set_name (CLUTTER_ACTOR (self->priv->trough), "trough");
priv->trough = (ClutterActor *) st_bin_new ();
clutter_actor_set_reactive ((ClutterActor *) priv->trough, TRUE);
clutter_actor_set_name (CLUTTER_ACTOR (priv->trough), "trough");
clutter_actor_add_child (CLUTTER_ACTOR (self),
CLUTTER_ACTOR (self->priv->trough));
g_signal_connect (self->priv->trough, "button-press-event",
CLUTTER_ACTOR (priv->trough));
g_signal_connect (priv->trough, "button-press-event",
G_CALLBACK (trough_button_press_event_cb), self);
g_signal_connect (self->priv->trough, "button-release-event",
g_signal_connect (priv->trough, "button-release-event",
G_CALLBACK (trough_button_release_event_cb), self);
g_signal_connect (self->priv->trough, "leave-event",
g_signal_connect (priv->trough, "leave-event",
G_CALLBACK (trough_leave_event_cb), self);
self->priv->handle = (ClutterActor *) st_button_new ();
clutter_actor_set_name (CLUTTER_ACTOR (self->priv->handle), "hhandle");
priv->handle = (ClutterActor *) st_button_new ();
clutter_actor_set_name (CLUTTER_ACTOR (priv->handle), "hhandle");
clutter_actor_add_child (CLUTTER_ACTOR (self),
CLUTTER_ACTOR (self->priv->handle));
g_signal_connect (self->priv->handle, "button-press-event",
CLUTTER_ACTOR (priv->handle));
g_signal_connect (priv->handle, "button-press-event",
G_CALLBACK (handle_button_press_event_cb), self);
g_signal_connect (self->priv->handle, "button-release-event",
g_signal_connect (priv->handle, "button-release-event",
G_CALLBACK (handle_button_release_event_cb), self);
g_signal_connect (self->priv->handle, "motion-event",
g_signal_connect (priv->handle, "motion-event",
G_CALLBACK (handle_motion_event_cb), self);
clutter_actor_set_reactive (CLUTTER_ACTOR (self), TRUE);
@ -916,7 +930,7 @@ st_scroll_bar_set_adjustment (StScrollBar *bar,
g_return_if_fail (ST_IS_SCROLL_BAR (bar));
priv = bar->priv;
priv = st_scroll_bar_get_instance_private (bar);
if (adjustment == priv->adjustment)
return;
@ -964,6 +978,6 @@ st_scroll_bar_get_adjustment (StScrollBar *bar)
{
g_return_val_if_fail (ST_IS_SCROLL_BAR (bar), NULL);
return bar->priv->adjustment;
return ((StScrollBarPrivate *)ST_SCROLL_BAR_PRIVATE (bar))->adjustment;
}

View File

@ -31,29 +31,7 @@
G_BEGIN_DECLS
#define ST_TYPE_SCROLL_BAR (st_scroll_bar_get_type())
#define ST_SCROLL_BAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ST_TYPE_SCROLL_BAR, StScrollBar))
#define ST_IS_SCROLL_BAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ST_TYPE_SCROLL_BAR))
#define ST_SCROLL_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ST_TYPE_SCROLL_BAR, StScrollBarClass))
#define ST_IS_SCROLL_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ST_TYPE_SCROLL_BAR))
#define ST_SCROLL_BAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ST_TYPE_SCROLL_BAR, StScrollBarClass))
typedef struct _StScrollBar StScrollBar;
typedef struct _StScrollBarPrivate StScrollBarPrivate;
typedef struct _StScrollBarClass StScrollBarClass;
/**
* StScrollBar:
*
* The contents of this structure are private and should only be accessed
* through the public API.
*/
struct _StScrollBar
{
/*< private >*/
StWidget parent_instance;
StScrollBarPrivate *priv;
};
G_DECLARE_DERIVABLE_TYPE (StScrollBar, st_scroll_bar, ST, SCROLL_BAR, StWidget)
struct _StScrollBarClass
{
@ -64,8 +42,6 @@ struct _StScrollBarClass
void (*scroll_stop) (StScrollBar *bar);
};
GType st_scroll_bar_get_type (void) G_GNUC_CONST;
StWidget *st_scroll_bar_new (StAdjustment *adjustment);
void st_scroll_bar_set_adjustment (StScrollBar *bar,

View File

@ -19,10 +19,6 @@
*/
#define ST_SCROLL_VIEW_FADE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ST_TYPE_SCROLL_VIEW_FADE, StScrollViewFadeClass))
#define ST_IS_SCROLL_VIEW_FADE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ST_TYPE_SCROLL_VIEW_FADE))
#define ST_SCROLL_VIEW_FADE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ST_TYPE_SCROLL_VIEW_FADE, StScrollViewFadeClass))
#include "st-scroll-view-fade.h"
#include "st-scroll-view.h"
#include "st-widget.h"
@ -33,8 +29,6 @@
#include <clutter/clutter.h>
#include <cogl/cogl.h>
typedef struct _StScrollViewFadeClass StScrollViewFadeClass;
#define DEFAULT_FADE_OFFSET 68.0f
#include "st-scroll-view-fade-generated.c"
@ -55,11 +49,6 @@ struct _StScrollViewFade
float hfade_offset;
};
struct _StScrollViewFadeClass
{
ClutterShaderEffectClass parent_class;
};
G_DEFINE_TYPE (StScrollViewFade,
st_scroll_view_fade,
CLUTTER_TYPE_SHADER_EFFECT);

View File

@ -26,12 +26,8 @@
G_BEGIN_DECLS
#define ST_TYPE_SCROLL_VIEW_FADE (st_scroll_view_fade_get_type ())
#define ST_SCROLL_VIEW_FADE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ST_TYPE_SCROLL_VIEW_FADE, StScrollViewFade))
#define ST_IS_SCROLL_VIEW_FADE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ST_TYPE_SCROLL_VIEW_FADE))
typedef struct _StScrollViewFade StScrollViewFade;
GType st_scroll_view_fade_get_type (void) G_GNUC_CONST;
G_DECLARE_FINAL_TYPE (StScrollViewFade, st_scroll_view_fade,
ST, SCROLL_VIEW_FADE, ClutterShaderEffect)
ClutterEffect *st_scroll_view_fade_new (void);

View File

@ -32,15 +32,9 @@
G_BEGIN_DECLS
#define ST_TYPE_SCROLL_VIEW (st_scroll_view_get_type())
#define ST_SCROLL_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ST_TYPE_SCROLL_VIEW, StScrollView))
#define ST_IS_SCROLL_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ST_TYPE_SCROLL_VIEW))
#define ST_SCROLL_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ST_TYPE_SCROLL_VIEW, StScrollViewClass))
#define ST_IS_SCROLL_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ST_TYPE_SCROLL_VIEW))
#define ST_SCROLL_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ST_TYPE_SCROLL_VIEW, StScrollViewClass))
G_DECLARE_FINAL_TYPE (StScrollView, st_scroll_view, ST, SCROLL_VIEW, StBin)
typedef struct _StScrollView StScrollView;
typedef struct _StScrollViewPrivate StScrollViewPrivate;
typedef struct _StScrollViewClass StScrollViewClass;
/**
* StScrollView:
@ -56,13 +50,6 @@ struct _StScrollView
StScrollViewPrivate *priv;
};
struct _StScrollViewClass
{
StBinClass parent_class;
};
GType st_scroll_view_get_type (void) G_GNUC_CONST;
StWidget *st_scroll_view_new (void);
ClutterActor *st_scroll_view_get_hscroll_bar (StScrollView *scroll);

View File

@ -21,6 +21,8 @@
#include "st-scrollable.h"
G_DEFINE_INTERFACE (StScrollable, st_scrollable, G_TYPE_OBJECT)
/**
* SECTION:st-scrollable
* @short_description: A #ClutterActor that can be scrolled
@ -77,7 +79,7 @@
* page_increment: page_size - step_increment
*/
static void
st_scrollable_base_init (gpointer g_iface)
st_scrollable_default_init (StScrollableInterface *g_iface)
{
static gboolean initialized = FALSE;
@ -101,30 +103,12 @@ st_scrollable_base_init (gpointer g_iface)
}
}
GType
st_scrollable_get_type (void)
{
static GType type = 0;
if (type == 0)
{
static const GTypeInfo info =
{
sizeof (StScrollableInterface),
st_scrollable_base_init, /* base_init */
NULL,
};
type = g_type_register_static (G_TYPE_INTERFACE,
"StScrollable", &info, 0);
}
return type;
}
void
st_scrollable_set_adjustments (StScrollable *scrollable,
StAdjustment *hadjustment,
StAdjustment *vadjustment)
{
ST_SCROLLABLE_GET_INTERFACE (scrollable)->set_adjustments (scrollable,
ST_SCROLLABLE_GET_IFACE (scrollable)->set_adjustments (scrollable,
hadjustment,
vadjustment);
}
@ -142,7 +126,7 @@ st_scrollable_get_adjustments (StScrollable *scrollable,
StAdjustment **hadjustment,
StAdjustment **vadjustment)
{
ST_SCROLLABLE_GET_INTERFACE (scrollable)->get_adjustments (scrollable,
ST_SCROLLABLE_GET_IFACE (scrollable)->get_adjustments (scrollable,
hadjustment,
vadjustment);
}

View File

@ -31,11 +31,8 @@
G_BEGIN_DECLS
#define ST_TYPE_SCROLLABLE (st_scrollable_get_type ())
#define ST_SCROLLABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ST_TYPE_SCROLLABLE, StScrollable))
#define ST_IS_SCROLLABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ST_TYPE_SCROLLABLE))
#define ST_SCROLLABLE_GET_INTERFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), ST_TYPE_SCROLLABLE, StScrollableInterface))
G_DECLARE_INTERFACE (StScrollable, st_scrollable, ST, SCROLLABLE, GObject)
typedef struct _StScrollable StScrollable; /* Dummy object */
typedef struct _StScrollableInterface StScrollableInterface;
struct _StScrollableInterface
@ -50,8 +47,6 @@ struct _StScrollableInterface
StAdjustment **vadjustment);
};
GType st_scrollable_get_type (void) G_GNUC_CONST;
void st_scrollable_set_adjustments (StScrollable *scrollable,
StAdjustment *hadjustment,
StAdjustment *vadjustment);

View File

@ -34,14 +34,8 @@
#include <st/st-theme-node.h>
#define ST_TYPE_TEXTURE_CACHE (st_texture_cache_get_type ())
#define ST_TEXTURE_CACHE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ST_TYPE_TEXTURE_CACHE, StTextureCache))
#define ST_TEXTURE_CACHE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ST_TYPE_TEXTURE_CACHE, StTextureCacheClass))
#define ST_IS_TEXTURE_CACHE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ST_TYPE_TEXTURE_CACHE))
#define ST_IS_TEXTURE_CACHE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ST_TYPE_TEXTURE_CACHE))
#define ST_TEXTURE_CACHE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ST_TYPE_TEXTURE_CACHE, StTextureCacheClass))
typedef struct _StTextureCache StTextureCache;
typedef struct _StTextureCacheClass StTextureCacheClass;
G_DECLARE_FINAL_TYPE (StTextureCache, st_texture_cache,
ST, TEXTURE_CACHE, GObject)
typedef struct _StTextureCachePrivate StTextureCachePrivate;
@ -52,19 +46,11 @@ struct _StTextureCache
StTextureCachePrivate *priv;
};
struct _StTextureCacheClass
{
GObjectClass parent_class;
};
typedef enum {
ST_TEXTURE_CACHE_POLICY_NONE,
ST_TEXTURE_CACHE_POLICY_FOREVER
} StTextureCachePolicy;
GType st_texture_cache_get_type (void) G_GNUC_CONST;
StTextureCache* st_texture_cache_get_default (void);
ClutterActor *

View File

@ -38,10 +38,6 @@ struct _StThemeContext {
int scale_factor;
};
struct _StThemeContextClass {
GObjectClass parent_class;
};
#define DEFAULT_FONT "sans-serif 10"
enum

View File

@ -38,16 +38,9 @@ G_BEGIN_DECLS
* by using st_theme_context_get_for_stage().
*/
typedef struct _StThemeContextClass StThemeContextClass;
#define ST_TYPE_THEME_CONTEXT (st_theme_context_get_type ())
#define ST_THEME_CONTEXT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), ST_TYPE_THEME_CONTEXT, StThemeContext))
#define ST_THEME_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ST_TYPE_THEME_CONTEXT, StThemeContextClass))
#define ST_IS_THEME_CONTEXT(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), ST_TYPE_THEME_CONTEXT))
#define ST_IS_THEME_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ST_TYPE_THEME_CONTEXT))
#define ST_THEME_CONTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ST_TYPE_THEME_CONTEXT, StThemeContextClass))
GType st_theme_context_get_type (void) G_GNUC_CONST;
G_DECLARE_FINAL_TYPE (StThemeContext, st_theme_context,
ST, THEME_CONTEXT, GObject)
StThemeContext *st_theme_context_new (void);
StThemeContext *st_theme_context_get_for_stage (ClutterStage *stage);

View File

@ -116,11 +116,6 @@ struct _StThemeNode {
StThemeNodePaintState cached_state;
};
struct _StThemeNodeClass {
GObjectClass parent_class;
};
void _st_theme_node_ensure_background (StThemeNode *node);
void _st_theme_node_ensure_geometry (StThemeNode *node);
void _st_theme_node_apply_margins (StThemeNode *node,

View File

@ -27,6 +27,14 @@ enum {
LAST_SIGNAL
};
typedef struct _StThemeNodeTransitionPrivate StThemeNodeTransitionPrivate;
struct _StThemeNodeTransition {
GObject parent;
StThemeNodeTransitionPrivate *priv;
};
struct _StThemeNodeTransitionPrivate {
StThemeNode *old_theme_node;
StThemeNode *new_theme_node;
@ -80,14 +88,12 @@ st_theme_node_transition_new (StThemeNode *from_node,
guint duration)
{
StThemeNodeTransition *transition;
g_return_val_if_fail (ST_IS_THEME_NODE (from_node), NULL);
g_return_val_if_fail (ST_IS_THEME_NODE (to_node), NULL);
duration = st_theme_node_get_transition_duration (to_node);
transition = g_object_new (ST_TYPE_THEME_NODE_TRANSITION,
NULL);
transition = g_object_new (ST_TYPE_THEME_NODE_TRANSITION, NULL);
transition->priv->old_theme_node = g_object_ref (from_node);
transition->priv->new_theme_node = g_object_ref (to_node);
@ -121,13 +127,14 @@ void
st_theme_node_transition_update (StThemeNodeTransition *transition,
StThemeNode *new_node)
{
StThemeNodeTransitionPrivate *priv = transition->priv;
StThemeNodeTransitionPrivate *priv;
StThemeNode *old_node;
ClutterTimelineDirection direction;
g_return_if_fail (ST_IS_THEME_NODE_TRANSITION (transition));
g_return_if_fail (ST_IS_THEME_NODE (new_node));
priv = transition->priv;
direction = clutter_timeline_get_direction (priv->timeline);
old_node = (direction == CLUTTER_TIMELINE_FORWARD) ? priv->old_theme_node
: priv->new_theme_node;

View File

@ -29,27 +29,8 @@
G_BEGIN_DECLS
#define ST_TYPE_THEME_NODE_TRANSITION (st_theme_node_transition_get_type ())
#define ST_THEME_NODE_TRANSITION(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), ST_TYPE_THEME_NODE_TRANSITION, StThemeNodeTransition))
#define ST_IS_THEME_NODE_TRANSITION(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), ST_TYPE_THEME_NODE_TRANSITION))
#define ST_THEME_NODE_TRANSITION_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), ST_TYPE_THEME_NODE_TRANSITION, StThemeNodeTransitionClass))
#define ST_IS_THEME_NODE_TRANSITION_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), ST_TYPE_THEME_NODE_TRANSITION))
#define ST_THEME_NODE_TRANSITION_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), ST_THEME_NODE_TRANSITION, StThemeNodeTransitionClass))
typedef struct _StThemeNodeTransition StThemeNodeTransition;
typedef struct _StThemeNodeTransitionClass StThemeNodeTransitionClass;
typedef struct _StThemeNodeTransitionPrivate StThemeNodeTransitionPrivate;
struct _StThemeNodeTransition {
GObject parent;
StThemeNodeTransitionPrivate *priv;
};
struct _StThemeNodeTransitionClass {
GObjectClass parent_class;
};
GType st_theme_node_transition_get_type (void) G_GNUC_CONST;
G_DECLARE_FINAL_TYPE (StThemeNodeTransition, st_theme_node_transition,
ST, THEME_NODE_TRANSITION, GObject)
StThemeNodeTransition *st_theme_node_transition_new (StThemeNode *from_node,
StThemeNode *to_node,

View File

@ -48,15 +48,8 @@ G_BEGIN_DECLS
typedef struct _StTheme StTheme;
typedef struct _StThemeContext StThemeContext;
typedef struct _StThemeNode StThemeNode;
typedef struct _StThemeNodeClass StThemeNodeClass;
#define ST_TYPE_THEME_NODE (st_theme_node_get_type ())
#define ST_THEME_NODE(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), ST_TYPE_THEME_NODE, StThemeNode))
#define ST_THEME_NODE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ST_TYPE_THEME_NODE, StThemeNodeClass))
#define ST_IS_THEME_NODE(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), ST_TYPE_THEME_NODE))
#define ST_IS_THEME_NODE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ST_TYPE_THEME_NODE))
#define ST_THEME_NODE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ST_TYPE_THEME_NODE, StThemeNodeClass))
G_DECLARE_FINAL_TYPE (StThemeNode, st_theme_node, ST, THEME_NODE, GObject)
typedef enum {
ST_SIDE_TOP,
@ -117,8 +110,6 @@ struct _StThemeNodePaintState {
CoglHandle corner_material[4];
};
GType st_theme_node_get_type (void) G_GNUC_CONST;
StThemeNode *st_theme_node_new (StThemeContext *context,
StThemeNode *parent_node, /* can be null */
StTheme *theme, /* can be null */

View File

@ -71,11 +71,6 @@ struct _StTheme
CRCascade *cascade;
};
struct _StThemeClass
{
GObjectClass parent_class;
};
enum
{
PROP_0,

View File

@ -36,16 +36,8 @@ G_BEGIN_DECLS
* of actors using st_widget_set_theme().
*/
typedef struct _StThemeClass StThemeClass;
#define ST_TYPE_THEME (st_theme_get_type ())
#define ST_THEME(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), ST_TYPE_THEME, StTheme))
#define ST_THEME_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ST_TYPE_THEME, StThemeClass))
#define ST_IS_THEME(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), ST_TYPE_THEME))
#define ST_IS_THEME_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ST_TYPE_THEME))
#define ST_THEME_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ST_TYPE_THEME, StThemeClass))
GType st_theme_get_type (void) G_GNUC_CONST;
G_DECLARE_FINAL_TYPE (StTheme, st_theme, ST, THEME, GObject)
StTheme *st_theme_new (GFile *application_stylesheet,
GFile *theme_stylesheet,

View File

@ -53,6 +53,7 @@
/*
* Forward declaration for sake of StWidgetChild
*/
typedef struct _StWidgetPrivate StWidgetPrivate;
struct _StWidgetPrivate
{
StTheme *theme;
@ -129,6 +130,7 @@ static guint signals[LAST_SIGNAL] = { 0, };
gfloat st_slow_down_factor = 1.0;
G_DEFINE_TYPE_WITH_PRIVATE (StWidget, st_widget, CLUTTER_TYPE_ACTOR);
#define ST_WIDGET_PRIVATE(w) ((StWidgetPrivate *)st_widget_get_instance_private (w))
static void st_widget_recompute_style (StWidget *widget,
StThemeNode *old_theme_node);
@ -201,7 +203,7 @@ st_widget_get_property (GObject *gobject,
GParamSpec *pspec)
{
StWidget *actor = ST_WIDGET (gobject);
StWidgetPrivate *priv = actor->priv;
StWidgetPrivate *priv = st_widget_get_instance_private (ST_WIDGET (gobject));
switch (prop_id)
{
@ -254,24 +256,30 @@ st_widget_get_property (GObject *gobject,
static void
st_widget_remove_transition (StWidget *widget)
{
if (widget->priv->transition_animation)
StWidgetPrivate *priv = st_widget_get_instance_private (widget);
if (priv->transition_animation)
{
g_object_run_dispose (G_OBJECT (widget->priv->transition_animation));
g_object_unref (widget->priv->transition_animation);
widget->priv->transition_animation = NULL;
g_object_run_dispose (G_OBJECT (priv->transition_animation));
g_object_unref (priv->transition_animation);
priv->transition_animation = NULL;
}
}
static void
next_paint_state (StWidget *widget)
{
widget->priv->current_paint_state = (widget->priv->current_paint_state + 1) % G_N_ELEMENTS (widget->priv->paint_states);
StWidgetPrivate *priv = st_widget_get_instance_private (widget);
priv->current_paint_state = (priv->current_paint_state + 1) % G_N_ELEMENTS (priv->paint_states);
}
static StThemeNodePaintState *
current_paint_state (StWidget *widget)
{
return &widget->priv->paint_states[widget->priv->current_paint_state];
StWidgetPrivate *priv = st_widget_get_instance_private (widget);
return &priv->paint_states[priv->current_paint_state];
}
static void
@ -280,7 +288,8 @@ st_widget_texture_cache_changed (StTextureCache *cache,
gpointer user_data)
{
StWidget *actor = ST_WIDGET (user_data);
StThemeNode *node = actor->priv->theme_node;
StWidgetPrivate *priv = st_widget_get_instance_private (actor);
StThemeNode *node = priv->theme_node;
gboolean changed = FALSE;
GFile *theme_file;
@ -322,7 +331,7 @@ static void
st_widget_dispose (GObject *gobject)
{
StWidget *actor = ST_WIDGET (gobject);
StWidgetPrivate *priv = ST_WIDGET (actor)->priv;
StWidgetPrivate *priv = st_widget_get_instance_private (actor);
g_clear_pointer (&priv->theme, g_object_unref);
g_clear_pointer (&priv->theme_node, g_object_unref);
@ -346,7 +355,7 @@ st_widget_dispose (GObject *gobject)
static void
st_widget_finalize (GObject *gobject)
{
StWidgetPrivate *priv = ST_WIDGET (gobject)->priv;
StWidgetPrivate *priv = st_widget_get_instance_private (ST_WIDGET (gobject));
guint i;
g_free (priv->style_class);
@ -429,6 +438,7 @@ st_widget_allocate (ClutterActor *actor,
void
st_widget_paint_background (StWidget *widget)
{
StWidgetPrivate *priv = st_widget_get_instance_private (widget);
StThemeNode *theme_node;
ClutterActorBox allocation;
guint8 opacity;
@ -439,8 +449,8 @@ st_widget_paint_background (StWidget *widget)
opacity = clutter_actor_get_paint_opacity (CLUTTER_ACTOR (widget));
if (widget->priv->transition_animation)
st_theme_node_transition_paint (widget->priv->transition_animation,
if (priv->transition_animation)
st_theme_node_transition_paint (priv->transition_animation,
&allocation,
opacity);
else
@ -491,7 +501,7 @@ static void
st_widget_unmap (ClutterActor *actor)
{
StWidget *self = ST_WIDGET (actor);
StWidgetPrivate *priv = self->priv;
StWidgetPrivate *priv = st_widget_get_instance_private (self);
CLUTTER_ACTOR_CLASS (st_widget_parent_class)->unmap (actor);
@ -525,13 +535,14 @@ st_widget_real_style_changed (StWidget *self)
void
st_widget_style_changed (StWidget *widget)
{
StWidgetPrivate *priv = st_widget_get_instance_private (widget);
StThemeNode *old_theme_node = NULL;
widget->priv->is_style_dirty = TRUE;
if (widget->priv->theme_node)
priv->is_style_dirty = TRUE;
if (priv->theme_node)
{
old_theme_node = widget->priv->theme_node;
widget->priv->theme_node = NULL;
old_theme_node = priv->theme_node;
priv->theme_node = NULL;
}
/* update the style only if we are mapped */
@ -584,7 +595,7 @@ get_root_theme_node (ClutterStage *stage)
StThemeNode *
st_widget_get_theme_node (StWidget *widget)
{
StWidgetPrivate *priv = widget->priv;
StWidgetPrivate *priv = st_widget_get_instance_private (widget);
if (priv->theme_node == NULL)
{
@ -668,16 +679,16 @@ st_widget_get_theme_node (StWidget *widget)
StThemeNode *
st_widget_peek_theme_node (StWidget *widget)
{
StWidgetPrivate *priv = widget->priv;
g_return_val_if_fail (ST_IS_WIDGET (widget), NULL);
return priv->theme_node;
return ST_WIDGET_PRIVATE (widget)->theme_node;
}
static gboolean
st_widget_enter (ClutterActor *actor,
ClutterCrossingEvent *event)
{
StWidgetPrivate *priv = ST_WIDGET (actor)->priv;
StWidgetPrivate *priv = st_widget_get_instance_private (ST_WIDGET (actor));
if (priv->track_hover)
{
@ -703,7 +714,7 @@ static gboolean
st_widget_leave (ClutterActor *actor,
ClutterCrossingEvent *event)
{
StWidgetPrivate *priv = ST_WIDGET (actor)->priv;
StWidgetPrivate *priv = st_widget_get_instance_private (ST_WIDGET (actor));
if (priv->track_hover)
{
@ -761,7 +772,7 @@ st_widget_get_paint_volume (ClutterActor *self,
if (!clutter_actor_has_allocation (self))
return FALSE;
priv = ST_WIDGET (self)->priv;
priv = st_widget_get_instance_private (ST_WIDGET (self));
theme_node = st_widget_get_theme_node (ST_WIDGET (self));
clutter_actor_get_allocation_box (self, &alloc_box);
@ -1036,7 +1047,7 @@ st_widget_set_theme (StWidget *actor,
g_return_if_fail (ST_IS_WIDGET (actor));
priv = actor->priv;
priv = st_widget_get_instance_private (actor);
if (theme != priv->theme)
{
@ -1063,7 +1074,7 @@ st_widget_get_theme (StWidget *actor)
{
g_return_val_if_fail (ST_IS_WIDGET (actor), NULL);
return actor->priv->theme;
return ST_WIDGET_PRIVATE (actor)->theme;
}
static const gchar *
@ -1173,9 +1184,13 @@ void
st_widget_set_style_class_name (StWidget *actor,
const gchar *style_class_list)
{
StWidgetPrivate *priv;
g_return_if_fail (ST_IS_WIDGET (actor));
if (set_class_list (&actor->priv->style_class, style_class_list))
priv = st_widget_get_instance_private (actor);
if (set_class_list (&priv->style_class, style_class_list))
{
st_widget_style_changed (actor);
g_object_notify (G_OBJECT (actor), "style-class");
@ -1194,10 +1209,14 @@ void
st_widget_add_style_class_name (StWidget *actor,
const gchar *style_class)
{
StWidgetPrivate *priv;
g_return_if_fail (ST_IS_WIDGET (actor));
g_return_if_fail (style_class != NULL);
if (add_class_name (&actor->priv->style_class, style_class))
priv = st_widget_get_instance_private (actor);
if (add_class_name (&priv->style_class, style_class))
{
st_widget_style_changed (actor);
g_object_notify (G_OBJECT (actor), "style-class");
@ -1216,10 +1235,14 @@ void
st_widget_remove_style_class_name (StWidget *actor,
const gchar *style_class)
{
StWidgetPrivate *priv;
g_return_if_fail (ST_IS_WIDGET (actor));
g_return_if_fail (style_class != NULL);
if (remove_class_name (&actor->priv->style_class, style_class))
priv = st_widget_get_instance_private (actor);
if (remove_class_name (&priv->style_class, style_class))
{
st_widget_style_changed (actor);
g_object_notify (G_OBJECT (actor), "style-class");
@ -1240,7 +1263,7 @@ st_widget_get_style_class_name (StWidget *actor)
{
g_return_val_if_fail (ST_IS_WIDGET (actor), NULL);
return actor->priv->style_class;
return ST_WIDGET_PRIVATE (actor)->style_class;
}
/**
@ -1257,9 +1280,13 @@ gboolean
st_widget_has_style_class_name (StWidget *actor,
const gchar *style_class)
{
StWidgetPrivate *priv;
g_return_val_if_fail (ST_IS_WIDGET (actor), FALSE);
return find_class_name (actor->priv->style_class, style_class) != NULL;
priv = st_widget_get_instance_private (actor);
return find_class_name (priv->style_class, style_class) != NULL;
}
/**
@ -1280,7 +1307,7 @@ st_widget_get_style_pseudo_class (StWidget *actor)
{
g_return_val_if_fail (ST_IS_WIDGET (actor), NULL);
return actor->priv->pseudo_class;
return ST_WIDGET_PRIVATE (actor)->pseudo_class;
}
/**
@ -1297,9 +1324,13 @@ gboolean
st_widget_has_style_pseudo_class (StWidget *actor,
const gchar *pseudo_class)
{
StWidgetPrivate *priv;
g_return_val_if_fail (ST_IS_WIDGET (actor), FALSE);
return find_class_name (actor->priv->pseudo_class, pseudo_class) != NULL;
priv = st_widget_get_instance_private (actor);
return find_class_name (priv->pseudo_class, pseudo_class) != NULL;
}
/**
@ -1316,9 +1347,13 @@ void
st_widget_set_style_pseudo_class (StWidget *actor,
const gchar *pseudo_class_list)
{
StWidgetPrivate *priv;
g_return_if_fail (ST_IS_WIDGET (actor));
if (set_class_list (&actor->priv->pseudo_class, pseudo_class_list))
priv = st_widget_get_instance_private (actor);
if (set_class_list (&priv->pseudo_class, pseudo_class_list))
{
st_widget_style_changed (actor);
g_object_notify (G_OBJECT (actor), "pseudo-class");
@ -1337,10 +1372,14 @@ void
st_widget_add_style_pseudo_class (StWidget *actor,
const gchar *pseudo_class)
{
StWidgetPrivate *priv;
g_return_if_fail (ST_IS_WIDGET (actor));
g_return_if_fail (pseudo_class != NULL);
if (add_class_name (&actor->priv->pseudo_class, pseudo_class))
priv = st_widget_get_instance_private (actor);
if (add_class_name (&priv->pseudo_class, pseudo_class))
{
st_widget_style_changed (actor);
g_object_notify (G_OBJECT (actor), "pseudo-class");
@ -1358,10 +1397,14 @@ void
st_widget_remove_style_pseudo_class (StWidget *actor,
const gchar *pseudo_class)
{
StWidgetPrivate *priv;
g_return_if_fail (ST_IS_WIDGET (actor));
g_return_if_fail (pseudo_class != NULL);
if (remove_class_name (&actor->priv->pseudo_class, pseudo_class))
priv = st_widget_get_instance_private (actor);
if (remove_class_name (&priv->pseudo_class, pseudo_class))
{
st_widget_style_changed (actor);
g_object_notify (G_OBJECT (actor), "pseudo-class");
@ -1385,7 +1428,7 @@ st_widget_set_style (StWidget *actor,
g_return_if_fail (ST_IS_WIDGET (actor));
priv = actor->priv;
priv = st_widget_get_instance_private (actor);
if (g_strcmp0 (style, priv->inline_style))
{
@ -1412,7 +1455,7 @@ st_widget_get_style (StWidget *actor)
{
g_return_val_if_fail (ST_IS_WIDGET (actor), NULL);
return actor->priv->inline_style;
return ST_WIDGET_PRIVATE (actor)->inline_style;
}
static void
@ -1428,12 +1471,14 @@ st_widget_reactive_notify (StWidget *widget,
GParamSpec *pspec,
gpointer data)
{
StWidgetPrivate *priv = st_widget_get_instance_private (widget);
if (clutter_actor_get_reactive (CLUTTER_ACTOR (widget)))
st_widget_remove_style_pseudo_class (widget, "insensitive");
else
st_widget_add_style_pseudo_class (widget, "insensitive");
if (widget->priv->track_hover)
if (priv->track_hover)
st_widget_sync_hover(widget);
}
@ -1442,12 +1487,13 @@ st_widget_first_child_notify (StWidget *widget,
GParamSpec *pspec,
gpointer data)
{
StWidgetPrivate *priv = st_widget_get_instance_private (widget);
ClutterActor *first_child;
if (widget->priv->prev_first_child != NULL)
if (priv->prev_first_child != NULL)
{
st_widget_remove_style_pseudo_class (widget->priv->prev_first_child, "first-child");
g_clear_object (&widget->priv->prev_first_child);
st_widget_remove_style_pseudo_class (priv->prev_first_child, "first-child");
g_clear_object (&priv->prev_first_child);
}
first_child = clutter_actor_get_first_child (CLUTTER_ACTOR (widget));
@ -1458,7 +1504,7 @@ st_widget_first_child_notify (StWidget *widget,
if (ST_IS_WIDGET (first_child))
{
st_widget_add_style_pseudo_class (ST_WIDGET (first_child), "first-child");
widget->priv->prev_first_child = g_object_ref (ST_WIDGET (first_child));
priv->prev_first_child = g_object_ref (ST_WIDGET (first_child));
}
}
@ -1467,12 +1513,13 @@ st_widget_last_child_notify (StWidget *widget,
GParamSpec *pspec,
gpointer data)
{
StWidgetPrivate *priv = st_widget_get_instance_private (widget);
ClutterActor *last_child;
if (widget->priv->prev_last_child != NULL)
if (priv->prev_last_child != NULL)
{
st_widget_remove_style_pseudo_class (widget->priv->prev_last_child, "last-child");
g_clear_object (&widget->priv->prev_last_child);
st_widget_remove_style_pseudo_class (priv->prev_last_child, "last-child");
g_clear_object (&priv->prev_last_child);
}
last_child = clutter_actor_get_last_child (CLUTTER_ACTOR (widget));
@ -1483,7 +1530,7 @@ st_widget_last_child_notify (StWidget *widget,
if (ST_IS_WIDGET (last_child))
{
st_widget_add_style_pseudo_class (ST_WIDGET (last_child), "last-child");
widget->priv->prev_last_child = g_object_ref (ST_WIDGET (last_child));
priv->prev_last_child = g_object_ref (ST_WIDGET (last_child));
}
}
@ -1493,7 +1540,7 @@ st_widget_init (StWidget *actor)
StWidgetPrivate *priv;
guint i;
actor->priv = priv = st_widget_get_instance_private (actor);
priv = st_widget_get_instance_private (actor);
priv->transition_animation = NULL;
priv->local_state_set = atk_state_set_new ();
@ -1526,6 +1573,7 @@ static void
st_widget_recompute_style (StWidget *widget,
StThemeNode *old_theme_node)
{
StWidgetPrivate *priv = st_widget_get_instance_private (widget);
StThemeNode *new_theme_node = st_widget_get_theme_node (widget);
int transition_duration;
gboolean paint_equal;
@ -1533,7 +1581,7 @@ st_widget_recompute_style (StWidget *widget,
if (new_theme_node == old_theme_node)
{
widget->priv->is_style_dirty = FALSE;
priv->is_style_dirty = FALSE;
return;
}
@ -1553,9 +1601,9 @@ st_widget_recompute_style (StWidget *widget,
if (animations_enabled && transition_duration > 0)
{
if (widget->priv->transition_animation != NULL)
if (priv->transition_animation != NULL)
{
st_theme_node_transition_update (widget->priv->transition_animation,
st_theme_node_transition_update (priv->transition_animation,
new_theme_node);
}
else if (old_theme_node && !paint_equal)
@ -1566,21 +1614,21 @@ st_widget_recompute_style (StWidget *widget,
* we can't animate that anyways.
*/
widget->priv->transition_animation =
priv->transition_animation =
st_theme_node_transition_new (old_theme_node,
new_theme_node,
current_paint_state (widget),
transition_duration);
g_signal_connect (widget->priv->transition_animation, "completed",
g_signal_connect (priv->transition_animation, "completed",
G_CALLBACK (on_transition_completed), widget);
g_signal_connect_swapped (widget->priv->transition_animation,
g_signal_connect_swapped (priv->transition_animation,
"new-frame",
G_CALLBACK (clutter_actor_queue_redraw),
widget);
}
}
else if (widget->priv->transition_animation)
else if (priv->transition_animation)
{
st_widget_remove_transition (widget);
}
@ -1594,7 +1642,7 @@ st_widget_recompute_style (StWidget *widget,
}
g_signal_emit (widget, signals[STYLE_CHANGED], 0);
widget->priv->is_style_dirty = FALSE;
priv->is_style_dirty = FALSE;
}
/**
@ -1607,9 +1655,13 @@ st_widget_recompute_style (StWidget *widget,
void
st_widget_ensure_style (StWidget *widget)
{
StWidgetPrivate *priv;
g_return_if_fail (ST_IS_WIDGET (widget));
if (widget->priv->is_style_dirty)
priv = st_widget_get_instance_private (widget);
if (priv->is_style_dirty)
st_widget_recompute_style (widget, NULL);
}
@ -1639,7 +1691,7 @@ st_widget_set_track_hover (StWidget *widget,
g_return_if_fail (ST_IS_WIDGET (widget));
priv = widget->priv;
priv = st_widget_get_instance_private (widget);
if (priv->track_hover != track_hover)
{
@ -1667,7 +1719,7 @@ st_widget_get_track_hover (StWidget *widget)
{
g_return_val_if_fail (ST_IS_WIDGET (widget), FALSE);
return widget->priv->track_hover;
return ST_WIDGET_PRIVATE (widget)->track_hover;
}
/**
@ -1690,7 +1742,7 @@ st_widget_set_hover (StWidget *widget,
g_return_if_fail (ST_IS_WIDGET (widget));
priv = widget->priv;
priv = st_widget_get_instance_private (widget);
if (priv->hover != hover)
{
@ -1741,7 +1793,7 @@ st_widget_get_hover (StWidget *widget)
{
g_return_val_if_fail (ST_IS_WIDGET (widget), FALSE);
return widget->priv->hover;
return ST_WIDGET_PRIVATE (widget)->hover;
}
/**
@ -1761,7 +1813,7 @@ st_widget_set_can_focus (StWidget *widget,
g_return_if_fail (ST_IS_WIDGET (widget));
priv = widget->priv;
priv = st_widget_get_instance_private (widget);
if (priv->can_focus != can_focus)
{
@ -1784,7 +1836,7 @@ st_widget_get_can_focus (StWidget *widget)
{
g_return_val_if_fail (ST_IS_WIDGET (widget), FALSE);
return widget->priv->can_focus;
return ST_WIDGET_PRIVATE (widget)->can_focus;
}
/**
@ -1905,6 +1957,7 @@ st_widget_real_navigate_focus (StWidget *widget,
ClutterActor *from,
GtkDirectionType direction)
{
StWidgetPrivate *priv = st_widget_get_instance_private (widget);
ClutterActor *widget_actor, *focus_child;
GList *children, *l;
@ -1920,7 +1973,7 @@ st_widget_real_navigate_focus (StWidget *widget,
while (focus_child && clutter_actor_get_parent (focus_child) != widget_actor)
focus_child = clutter_actor_get_parent (focus_child);
if (widget->priv->can_focus)
if (priv->can_focus)
{
if (!focus_child)
{
@ -2229,7 +2282,7 @@ st_widget_get_label_actor (StWidget *widget)
{
g_return_val_if_fail (ST_IS_WIDGET (widget), NULL);
return widget->priv->label_actor;
return ST_WIDGET_PRIVATE (widget)->label_actor;
}
/**
@ -2246,17 +2299,21 @@ void
st_widget_set_label_actor (StWidget *widget,
ClutterActor *label)
{
StWidgetPrivate *priv;
g_return_if_fail (ST_IS_WIDGET (widget));
if (widget->priv->label_actor != label)
priv = st_widget_get_instance_private (widget);
if (priv->label_actor != label)
{
if (widget->priv->label_actor)
g_object_unref (widget->priv->label_actor);
if (priv->label_actor)
g_object_unref (priv->label_actor);
if (label != NULL)
widget->priv->label_actor = g_object_ref (label);
priv->label_actor = g_object_ref (label);
else
widget->priv->label_actor = NULL;
priv->label_actor = NULL;
g_object_notify (G_OBJECT (widget), "label-actor");
}
@ -2281,12 +2338,16 @@ void
st_widget_set_accessible_name (StWidget *widget,
const gchar *name)
{
StWidgetPrivate *priv;
g_return_if_fail (ST_IS_WIDGET (widget));
if (widget->priv->accessible_name != NULL)
g_free (widget->priv->accessible_name);
priv = st_widget_get_instance_private (widget);
widget->priv->accessible_name = g_strdup (name);
if (priv->accessible_name != NULL)
g_free (priv->accessible_name);
priv->accessible_name = g_strdup (name);
g_object_notify (G_OBJECT (widget), "accessible-name");
}
@ -2305,7 +2366,7 @@ st_widget_get_accessible_name (StWidget *widget)
{
g_return_val_if_fail (ST_IS_WIDGET (widget), NULL);
return widget->priv->accessible_name;
return ST_WIDGET_PRIVATE (widget)->accessible_name;
}
/**
@ -2334,9 +2395,12 @@ void
st_widget_set_accessible_role (StWidget *widget,
AtkRole role)
{
StWidgetPrivate *priv;
g_return_if_fail (ST_IS_WIDGET (widget));
widget->priv->accessible_role = role;
priv = st_widget_get_instance_private (widget);
priv->accessible_role = role;
g_object_notify (G_OBJECT (widget), "accessible-role");
}
@ -2354,14 +2418,17 @@ st_widget_set_accessible_role (StWidget *widget,
AtkRole
st_widget_get_accessible_role (StWidget *widget)
{
StWidgetPrivate *priv;
AtkObject *accessible = NULL;
AtkRole role = ATK_ROLE_INVALID;
g_return_val_if_fail (ST_IS_WIDGET (widget), ATK_ROLE_INVALID);
if (widget->priv->accessible_role != ATK_ROLE_INVALID)
role = widget->priv->accessible_role;
else if (widget->priv->accessible != NULL)
priv = st_widget_get_instance_private (widget);
if (priv->accessible_role != ATK_ROLE_INVALID)
role = priv->accessible_role;
else if (priv->accessible != NULL)
role = atk_object_get_role (accessible);
return role;
@ -2372,8 +2439,10 @@ notify_accessible_state_change (StWidget *widget,
AtkStateType state,
gboolean value)
{
if (widget->priv->accessible != NULL)
atk_object_notify_state_change (widget->priv->accessible, state, value);
StWidgetPrivate *priv = st_widget_get_instance_private (widget);
if (priv->accessible != NULL)
atk_object_notify_state_change (priv->accessible, state, value);
}
/**
@ -2399,9 +2468,13 @@ void
st_widget_add_accessible_state (StWidget *widget,
AtkStateType state)
{
StWidgetPrivate *priv;
g_return_if_fail (ST_IS_WIDGET (widget));
if (atk_state_set_add_state (widget->priv->local_state_set, state))
priv = st_widget_get_instance_private (widget);
if (atk_state_set_add_state (priv->local_state_set, state))
notify_accessible_state_change (widget, state, TRUE);
}
@ -2418,9 +2491,13 @@ void
st_widget_remove_accessible_state (StWidget *widget,
AtkStateType state)
{
StWidgetPrivate *priv;
g_return_if_fail (ST_IS_WIDGET (widget));
if (atk_state_set_remove_state (widget->priv->local_state_set, state))
priv = st_widget_get_instance_private (widget);
if (atk_state_set_remove_state (priv->local_state_set, state))
notify_accessible_state_change (widget, state, FALSE);
}
@ -2471,18 +2548,20 @@ static AtkObject *
st_widget_get_accessible (ClutterActor *actor)
{
StWidget *widget = NULL;
StWidgetPrivate *priv;
g_return_val_if_fail (ST_IS_WIDGET (actor), NULL);
widget = ST_WIDGET (actor);
priv = st_widget_get_instance_private (widget);
if (widget->priv->accessible == NULL)
if (priv->accessible == NULL)
{
widget->priv->accessible =
priv->accessible =
g_object_new (ST_WIDGET_GET_CLASS (widget)->get_accessible_type (),
NULL);
atk_object_initialize (widget->priv->accessible, actor);
atk_object_initialize (priv->accessible, actor);
/* AtkGObjectAccessible, which StWidgetAccessible derives from, clears
* the back reference to the object in a weak notify for the object;
@ -2493,10 +2572,10 @@ st_widget_get_accessible (ClutterActor *actor)
* will result in a new accessible object being created.
*/
g_object_add_weak_pointer (G_OBJECT (actor),
(gpointer *)&widget->priv->accessible);
(gpointer *)&priv->accessible);
}
return widget->priv->accessible;
return priv->accessible;
}
/**
@ -2522,28 +2601,32 @@ void
st_widget_set_accessible (StWidget *widget,
AtkObject *accessible)
{
StWidgetPrivate *priv;
g_return_if_fail (ST_IS_WIDGET (widget));
g_return_if_fail (accessible == NULL || ATK_IS_GOBJECT_ACCESSIBLE (accessible));
if (widget->priv->accessible != accessible)
priv = st_widget_get_instance_private (widget);
if (priv->accessible != accessible)
{
if (widget->priv->accessible)
if (priv->accessible)
{
g_object_remove_weak_pointer (G_OBJECT (widget),
(gpointer *)&widget->priv->accessible);
g_object_unref (widget->priv->accessible);
widget->priv->accessible = NULL;
(gpointer *)&priv->accessible);
g_object_unref (priv->accessible);
priv->accessible = NULL;
}
if (accessible)
{
widget->priv->accessible = g_object_ref (accessible);
priv->accessible = g_object_ref (accessible);
/* See note in st_widget_get_accessible() */
g_object_add_weak_pointer (G_OBJECT (widget),
(gpointer *)&widget->priv->accessible);
(gpointer *)&priv->accessible);
}
else
widget->priv->accessible = NULL;
priv->accessible = NULL;
}
}
@ -2564,7 +2647,7 @@ st_widget_accessible_get_name (AtkObject *obj)
if (widget == NULL)
name = NULL;
else
name = widget->priv->accessible_name;
name = st_widget_get_accessible_name (widget);
}
return name;
@ -2651,6 +2734,7 @@ st_widget_accessible_ref_state_set (AtkObject *obj)
AtkStateSet *aux_set = NULL;
ClutterActor *actor = NULL;
StWidget *widget = NULL;
StWidgetPrivate *widget_priv;
StWidgetAccessible *self = NULL;
result = ATK_OBJECT_CLASS (st_widget_accessible_parent_class)->ref_state_set (obj);
@ -2662,6 +2746,7 @@ st_widget_accessible_ref_state_set (AtkObject *obj)
widget = ST_WIDGET (actor);
self = ST_WIDGET_ACCESSIBLE (obj);
widget_priv = st_widget_get_instance_private (widget);
/* priv->selected should be properly updated on the
* ATK_STATE_SELECTED notification callbacks
@ -2684,9 +2769,9 @@ st_widget_accessible_ref_state_set (AtkObject *obj)
atk_state_set_remove_state (result, ATK_STATE_FOCUSABLE);
/* We add the states added externally if required */
if (!atk_state_set_is_empty (widget->priv->local_state_set))
if (!atk_state_set_is_empty (widget_priv->local_state_set))
{
aux_set = atk_state_set_or_sets (result, widget->priv->local_state_set);
aux_set = atk_state_set_or_sets (result, widget_priv->local_state_set);
g_object_unref (result); /* previous result will not be used */
result = aux_set;
@ -2699,6 +2784,7 @@ static AtkRole
st_widget_accessible_get_role (AtkObject *obj)
{
StWidget *widget = NULL;
AtkRole role;
g_return_val_if_fail (ST_IS_WIDGET_ACCESSIBLE (obj), ATK_ROLE_INVALID);
@ -2707,8 +2793,9 @@ st_widget_accessible_get_role (AtkObject *obj)
if (widget == NULL)
return ATK_ROLE_INVALID;
if (widget->priv->accessible_role != ATK_ROLE_INVALID)
return widget->priv->accessible_role;
role = st_widget_get_accessible_role (widget);
if (role != ATK_ROLE_INVALID)
return role;
return ATK_OBJECT_CLASS (st_widget_accessible_parent_class)->get_role (obj);
}

View File

@ -36,31 +36,10 @@
G_BEGIN_DECLS
#define ST_TYPE_WIDGET (st_widget_get_type ())
#define ST_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ST_TYPE_WIDGET, StWidget))
#define ST_IS_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ST_TYPE_WIDGET))
#define ST_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ST_TYPE_WIDGET, StWidgetClass))
#define ST_IS_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ST_TYPE_WIDGET))
#define ST_WIDGET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ST_TYPE_WIDGET, StWidgetClass))
G_DECLARE_DERIVABLE_TYPE (StWidget, st_widget, ST, WIDGET, ClutterActor)
typedef struct _StWidget StWidget;
typedef struct _StWidgetPrivate StWidgetPrivate;
typedef struct _StWidgetClass StWidgetClass;
/**
* StWidget:
*
* Base class for stylable actors. The contents of the #StWidget
* structure are private and should only be accessed through the
* public API.
*/
struct _StWidget
{
/*< private >*/
ClutterActor parent_instance;
StWidgetPrivate *priv;
};
/**
* StWidgetClass:
*
@ -91,8 +70,6 @@ struct _StWidgetClass
GList * (* get_focus_chain) (StWidget *widget);
};
GType st_widget_get_type (void) G_GNUC_CONST;
void st_widget_set_style_pseudo_class (StWidget *actor,
const gchar *pseudo_class_list);
void st_widget_add_style_pseudo_class (StWidget *actor,