Merge branch 'matthiasc/for-master' into 'master'

Matthiasc/for master

See merge request GNOME/gtk!2602
This commit is contained in:
Matthias Clasen 2020-09-19 21:22:30 +00:00
commit 874b9ef8b0
9 changed files with 319 additions and 442 deletions

12
NEWS
View File

@ -12,6 +12,9 @@ Overview of Changes in GTK 3.99.2
* GtkSearchEntry: * GtkSearchEntry:
- Don't handle forwarded events twice - Don't handle forwarded events twice
* GtkPasswordEntry:
- Add an ::activate signal
* GtkTextView: * GtkTextView:
- Fix dnd - Fix dnd
- Improve undo state tracking - Improve undo state tracking
@ -33,6 +36,9 @@ Overview of Changes in GTK 3.99.2
- Determine sample text based on font coverage - Determine sample text based on font coverage
- Allow filtering by language - Allow filtering by language
* GtkStack:
- Add gtk_stack_add_child
* GtkVideo: * GtkVideo:
- Make autoplay work - Make autoplay work
@ -44,6 +50,9 @@ Overview of Changes in GTK 3.99.2
- Tweak DND highlight color - Tweak DND highlight color
- Add spacing to .navigation-sidebar - Add spacing to .navigation-sidebar
* GDK:
- Add gdk_frame_clock_get_fps
* GSK: * GSK:
- Add radial gradient nodes - Add radial gradient nodes
@ -66,8 +75,7 @@ Overview of Changes in GTK 3.99.2
- Make filter and sorter constructors return exact types - Make filter and sorter constructors return exact types
- Rename GdkSurfaceState to GdkToplevelState - Rename GdkSurfaceState to GdkToplevelState
- Remove GdkWaylandSurface::committed - Remove GdkWaylandSurface::committed
- Add gdk_frame_clock_get_fps - Make Wayland backend api take GdkToplevel
- Add gtk_stack_add_child
* Demos: * Demos:
- Bug and crash fixes - Bug and crash fixes

View File

@ -63,7 +63,6 @@
* GtkColorChooserWidget has a single CSS node with name colorchooser. * GtkColorChooserWidget has a single CSS node with name colorchooser.
*/ */
typedef struct _GtkColorChooserWidgetPrivate GtkColorChooserWidgetPrivate;
typedef struct _GtkColorChooserWidgetClass GtkColorChooserWidgetClass; typedef struct _GtkColorChooserWidgetClass GtkColorChooserWidgetClass;
struct _GtkColorChooserWidget struct _GtkColorChooserWidget

View File

@ -35,12 +35,19 @@
#include <math.h> #include <math.h>
typedef struct struct _GtkColorScale
{ {
GtkScale parent_instance;
GdkRGBA color; GdkRGBA color;
GtkColorScaleType type; GtkColorScaleType type;
GdkTexture *hue_texture; GdkTexture *hue_texture;
} GtkColorScalePrivate; };
typedef struct
{
GtkScaleClass parent_class;
} GtkColorScaleClass;
enum enum
{ {
@ -59,7 +66,7 @@ static void click_action (GtkGestureClick *gesture,
double y, double y,
GtkWidget *scale); GtkWidget *scale);
G_DEFINE_TYPE_WITH_PRIVATE (GtkColorScale, gtk_color_scale, GTK_TYPE_SCALE) G_DEFINE_TYPE (GtkColorScale, gtk_color_scale, GTK_TYPE_SCALE)
void void
gtk_color_scale_snapshot_trough (GtkColorScale *scale, gtk_color_scale_snapshot_trough (GtkColorScale *scale,
@ -67,20 +74,19 @@ gtk_color_scale_snapshot_trough (GtkColorScale *scale,
int width, int width,
int height) int height)
{ {
GtkColorScalePrivate *priv = gtk_color_scale_get_instance_private (scale);
GtkWidget *widget = GTK_WIDGET (scale); GtkWidget *widget = GTK_WIDGET (scale);
if (width <= 1 || height <= 1) if (width <= 1 || height <= 1)
return; return;
if (priv->hue_texture && if (scale->hue_texture &&
(width != gdk_texture_get_width (priv->hue_texture) || (width != gdk_texture_get_width (scale->hue_texture) ||
height != gdk_texture_get_height (priv->hue_texture))) height != gdk_texture_get_height (scale->hue_texture)))
g_clear_object (&priv->hue_texture); g_clear_object (&scale->hue_texture);
if (priv->type == GTK_COLOR_SCALE_HUE) if (scale->type == GTK_COLOR_SCALE_HUE)
{ {
if (!priv->hue_texture) if (!scale->hue_texture)
{ {
GdkTexture *texture; GdkTexture *texture;
int stride; int stride;
@ -114,14 +120,14 @@ gtk_color_scale_snapshot_trough (GtkColorScale *scale,
bytes, bytes,
stride); stride);
g_bytes_unref (bytes); g_bytes_unref (bytes);
priv->hue_texture = texture; scale->hue_texture = texture;
} }
gtk_snapshot_append_texture (snapshot, gtk_snapshot_append_texture (snapshot,
priv->hue_texture, scale->hue_texture,
&GRAPHENE_RECT_INIT(0, 0, width, height)); &GRAPHENE_RECT_INIT(0, 0, width, height));
} }
else if (priv->type == GTK_COLOR_SCALE_ALPHA) else if (scale->type == GTK_COLOR_SCALE_ALPHA)
{ {
graphene_point_t start, end; graphene_point_t start, end;
const GdkRGBA *color; const GdkRGBA *color;
@ -140,7 +146,7 @@ gtk_color_scale_snapshot_trough (GtkColorScale *scale,
_gtk_color_chooser_snapshot_checkered_pattern (snapshot, width, height); _gtk_color_chooser_snapshot_checkered_pattern (snapshot, width, height);
color = &priv->color; color = &scale->color;
gtk_snapshot_append_linear_gradient (snapshot, gtk_snapshot_append_linear_gradient (snapshot,
&GRAPHENE_RECT_INIT(0, 0, width, height), &GRAPHENE_RECT_INIT(0, 0, width, height),
@ -179,7 +185,6 @@ static void
scale_constructed (GObject *object) scale_constructed (GObject *object)
{ {
GtkColorScale *scale = GTK_COLOR_SCALE (object); GtkColorScale *scale = GTK_COLOR_SCALE (object);
GtkColorScalePrivate *priv = gtk_color_scale_get_instance_private (scale);
GtkEventController *controller; GtkEventController *controller;
GtkShortcutTrigger *trigger; GtkShortcutTrigger *trigger;
GtkShortcutAction *action; GtkShortcutAction *action;
@ -192,7 +197,7 @@ scale_constructed (GObject *object)
shortcut = gtk_shortcut_new_with_arguments (trigger, shortcut = gtk_shortcut_new_with_arguments (trigger,
action, action,
"s", "s",
priv->type == GTK_COLOR_SCALE_ALPHA scale->type == GTK_COLOR_SCALE_ALPHA
? "a" : "h"); ? "a" : "h");
gtk_shortcut_controller_add_shortcut (GTK_SHORTCUT_CONTROLLER (controller), shortcut); gtk_shortcut_controller_add_shortcut (GTK_SHORTCUT_CONTROLLER (controller), shortcut);
gtk_widget_add_controller (GTK_WIDGET (scale), controller); gtk_widget_add_controller (GTK_WIDGET (scale), controller);
@ -205,28 +210,19 @@ scale_get_property (GObject *object,
GParamSpec *pspec) GParamSpec *pspec)
{ {
GtkColorScale *scale = GTK_COLOR_SCALE (object); GtkColorScale *scale = GTK_COLOR_SCALE (object);
GtkColorScalePrivate *priv = gtk_color_scale_get_instance_private (scale);
switch (prop_id) switch (prop_id)
{ {
case PROP_SCALE_TYPE: case PROP_SCALE_TYPE:
g_value_set_int (value, priv->type); g_value_set_int (value, scale->type);
break; break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;
} }
} }
static void
scale_set_type (GtkColorScale *scale,
GtkColorScaleType type)
{
GtkColorScalePrivate *priv = gtk_color_scale_get_instance_private (scale);
priv->type = type;
}
static void static void
scale_set_property (GObject *object, scale_set_property (GObject *object,
guint prop_id, guint prop_id,
@ -238,8 +234,9 @@ scale_set_property (GObject *object,
switch (prop_id) switch (prop_id)
{ {
case PROP_SCALE_TYPE: case PROP_SCALE_TYPE:
scale_set_type (scale, (GtkColorScaleType)g_value_get_int (value)); scale->type = (GtkColorScaleType) g_value_get_int (value);
break; break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;
@ -272,9 +269,9 @@ click_action (GtkGestureClick *gesture,
static void static void
scale_finalize (GObject *object) scale_finalize (GObject *object)
{ {
GtkColorScalePrivate *priv = gtk_color_scale_get_instance_private (GTK_COLOR_SCALE (object)); GtkColorScale *scale = GTK_COLOR_SCALE (object);
g_clear_object (&priv->hue_texture); g_clear_object (&scale->hue_texture);
G_OBJECT_CLASS (gtk_color_scale_parent_class)->finalize (object); G_OBJECT_CLASS (gtk_color_scale_parent_class)->finalize (object);
} }
@ -293,16 +290,13 @@ gtk_color_scale_class_init (GtkColorScaleClass *class)
g_param_spec_int ("scale-type", P_("Scale type"), P_("Scale type"), g_param_spec_int ("scale-type", P_("Scale type"), P_("Scale type"),
0, 1, 0, 0, 1, 0,
GTK_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); GTK_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
} }
void void
gtk_color_scale_set_rgba (GtkColorScale *scale, gtk_color_scale_set_rgba (GtkColorScale *scale,
const GdkRGBA *color) const GdkRGBA *color)
{ {
GtkColorScalePrivate *priv = gtk_color_scale_get_instance_private (scale); scale->color = *color;
priv->color = *color;
gtk_widget_queue_draw (gtk_range_get_trough_widget (GTK_RANGE (scale))); gtk_widget_queue_draw (gtk_range_get_trough_widget (GTK_RANGE (scale)));
} }

View File

@ -24,30 +24,10 @@ G_BEGIN_DECLS
#define GTK_TYPE_COLOR_SCALE (gtk_color_scale_get_type ()) #define GTK_TYPE_COLOR_SCALE (gtk_color_scale_get_type ())
#define GTK_COLOR_SCALE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_COLOR_SCALE, GtkColorScale)) #define GTK_COLOR_SCALE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_COLOR_SCALE, GtkColorScale))
#define GTK_COLOR_SCALE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_COLOR_SCALE, GtkColorScaleClass))
#define GTK_IS_COLOR_SCALE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_COLOR_SCALE)) #define GTK_IS_COLOR_SCALE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_COLOR_SCALE))
#define GTK_IS_COLOR_SCALE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_COLOR_SCALE))
#define GTK_COLOR_SCALE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_COLOR_SCALE, GtkColorScaleClass))
typedef struct _GtkColorScale GtkColorScale; typedef struct _GtkColorScale GtkColorScale;
typedef struct _GtkColorScaleClass GtkColorScaleClass;
struct _GtkColorScale
{
GtkScale parent_instance;
};
struct _GtkColorScaleClass
{
GtkScaleClass parent_class;
/* Padding for future expansion */
void (*_gtk_reserved1) (void);
void (*_gtk_reserved2) (void);
void (*_gtk_reserved3) (void);
void (*_gtk_reserved4) (void);
};
typedef enum typedef enum
{ {
@ -55,16 +35,16 @@ typedef enum
GTK_COLOR_SCALE_ALPHA GTK_COLOR_SCALE_ALPHA
} GtkColorScaleType; } GtkColorScaleType;
GType gtk_color_scale_get_type (void) G_GNUC_CONST; GType gtk_color_scale_get_type (void) G_GNUC_CONST;
GtkWidget * gtk_color_scale_new (GtkAdjustment *adjustment, GtkWidget * gtk_color_scale_new (GtkAdjustment *adjustment,
GtkColorScaleType type); GtkColorScaleType type);
void gtk_color_scale_set_rgba (GtkColorScale *scale, void gtk_color_scale_set_rgba (GtkColorScale *scale,
const GdkRGBA *color); const GdkRGBA *color);
void gtk_color_scale_snapshot_trough (GtkColorScale *scale, void gtk_color_scale_snapshot_trough (GtkColorScale *scale,
GtkSnapshot *snapshot, GtkSnapshot *snapshot,
int width, int width,
int height); int height);
G_END_DECLS G_END_DECLS

View File

@ -28,10 +28,10 @@ enum {
PROP_MAGNIFICATION PROP_MAGNIFICATION
}; };
typedef struct _GtkMagnifierPrivate GtkMagnifierPrivate; struct _GtkMagnifier
struct _GtkMagnifierPrivate
{ {
GtkWidget parent_instance;
GdkPaintable *paintable; GdkPaintable *paintable;
double magnification; double magnification;
int x; int x;
@ -39,8 +39,12 @@ struct _GtkMagnifierPrivate
gboolean resize; gboolean resize;
}; };
G_DEFINE_TYPE_WITH_PRIVATE (GtkMagnifier, gtk_magnifier, typedef struct
GTK_TYPE_WIDGET) {
GtkWidgetClass parent_class;
} GtkMagnifierClass;
G_DEFINE_TYPE (GtkMagnifier, gtk_magnifier, GTK_TYPE_WIDGET)
static void static void
_gtk_magnifier_set_property (GObject *object, _gtk_magnifier_set_property (GObject *object,
@ -48,20 +52,22 @@ _gtk_magnifier_set_property (GObject *object,
const GValue *value, const GValue *value,
GParamSpec *pspec) GParamSpec *pspec)
{ {
GtkMagnifier *magnifier = GTK_MAGNIFIER (object);
switch (param_id) switch (param_id)
{ {
case PROP_INSPECTED: case PROP_INSPECTED:
_gtk_magnifier_set_inspected (GTK_MAGNIFIER (object), _gtk_magnifier_set_inspected (magnifier, g_value_get_object (value));
g_value_get_object (value));
break; break;
case PROP_MAGNIFICATION: case PROP_MAGNIFICATION:
_gtk_magnifier_set_magnification (GTK_MAGNIFIER (object), _gtk_magnifier_set_magnification (magnifier, g_value_get_double (value));
g_value_get_double (value));
break; break;
case PROP_RESIZE: case PROP_RESIZE:
_gtk_magnifier_set_resize (GTK_MAGNIFIER (object), _gtk_magnifier_set_resize (magnifier, g_value_get_boolean (value));
g_value_get_boolean (value));
break; break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
} }
@ -73,23 +79,22 @@ _gtk_magnifier_get_property (GObject *object,
GValue *value, GValue *value,
GParamSpec *pspec) GParamSpec *pspec)
{ {
GtkMagnifier *magnifier; GtkMagnifier *magnifier = GTK_MAGNIFIER (object);
GtkMagnifierPrivate *priv;
magnifier = GTK_MAGNIFIER (object);
priv = gtk_magnifier_get_instance_private (magnifier);
switch (param_id) switch (param_id)
{ {
case PROP_INSPECTED: case PROP_INSPECTED:
g_value_set_object (value, gtk_widget_paintable_get_widget (GTK_WIDGET_PAINTABLE (priv->paintable))); g_value_set_object (value, gtk_widget_paintable_get_widget (GTK_WIDGET_PAINTABLE (magnifier->paintable)));
break; break;
case PROP_MAGNIFICATION: case PROP_MAGNIFICATION:
g_value_set_double (value, priv->magnification); g_value_set_double (value, magnifier->magnification);
break; break;
case PROP_RESIZE: case PROP_RESIZE:
g_value_set_boolean (value, priv->resize); g_value_set_boolean (value, magnifier->resize);
break; break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
} }
@ -100,28 +105,27 @@ gtk_magnifier_snapshot (GtkWidget *widget,
GtkSnapshot *snapshot) GtkSnapshot *snapshot)
{ {
GtkMagnifier *magnifier = GTK_MAGNIFIER (widget); GtkMagnifier *magnifier = GTK_MAGNIFIER (widget);
GtkMagnifierPrivate *priv = gtk_magnifier_get_instance_private (magnifier);
double width, height, paintable_width, paintable_height; double width, height, paintable_width, paintable_height;
if (gtk_widget_paintable_get_widget (GTK_WIDGET_PAINTABLE (priv->paintable)) == NULL) if (gtk_widget_paintable_get_widget (GTK_WIDGET_PAINTABLE (magnifier->paintable)) == NULL)
return; return;
width = gtk_widget_get_width (widget); width = gtk_widget_get_width (widget);
height = gtk_widget_get_height (widget); height = gtk_widget_get_height (widget);
paintable_width = gdk_paintable_get_intrinsic_width (priv->paintable); paintable_width = gdk_paintable_get_intrinsic_width (magnifier->paintable);
paintable_height = gdk_paintable_get_intrinsic_height (priv->paintable); paintable_height = gdk_paintable_get_intrinsic_height (magnifier->paintable);
if (paintable_width <= 0.0 || paintable_height <= 0.0) if (paintable_width <= 0.0 || paintable_height <= 0.0)
return; return;
gtk_snapshot_save (snapshot); gtk_snapshot_save (snapshot);
if (!priv->resize) if (!magnifier->resize)
gtk_snapshot_translate (snapshot, &GRAPHENE_POINT_INIT (width / 2, height / 2)); gtk_snapshot_translate (snapshot, &GRAPHENE_POINT_INIT (width / 2, height / 2));
gtk_snapshot_scale (snapshot, priv->magnification, priv->magnification); gtk_snapshot_scale (snapshot, magnifier->magnification, magnifier->magnification);
gtk_snapshot_translate (snapshot, &GRAPHENE_POINT_INIT ( gtk_snapshot_translate (snapshot, &GRAPHENE_POINT_INIT (
- CLAMP (priv->x, 0, paintable_width), - CLAMP (magnifier->x, 0, paintable_width),
- CLAMP (priv->y, 0, paintable_height))); - CLAMP (magnifier->y, 0, paintable_height)));
gdk_paintable_snapshot (priv->paintable, snapshot, paintable_width, paintable_height); gdk_paintable_snapshot (magnifier->paintable, snapshot, paintable_width, paintable_height);
gtk_snapshot_restore (snapshot); gtk_snapshot_restore (snapshot);
} }
@ -135,15 +139,14 @@ gtk_magnifier_measure (GtkWidget *widget,
int *natural_baseline) int *natural_baseline)
{ {
GtkMagnifier *magnifier = GTK_MAGNIFIER (widget); GtkMagnifier *magnifier = GTK_MAGNIFIER (widget);
GtkMagnifierPrivate *priv = gtk_magnifier_get_instance_private (magnifier);
int size; int size;
if (priv->resize) if (magnifier->resize)
{ {
if (orientation == GTK_ORIENTATION_HORIZONTAL) if (orientation == GTK_ORIENTATION_HORIZONTAL)
size = priv->magnification * gdk_paintable_get_intrinsic_width (priv->paintable); size = magnifier->magnification * gdk_paintable_get_intrinsic_width (magnifier->paintable);
else else
size = priv->magnification * gdk_paintable_get_intrinsic_height (priv->paintable); size = magnifier->magnification * gdk_paintable_get_intrinsic_height (magnifier->paintable);
} }
else else
size = 0; size = 0;
@ -155,13 +158,12 @@ gtk_magnifier_measure (GtkWidget *widget,
static void static void
gtk_magnifier_dispose (GObject *object) gtk_magnifier_dispose (GObject *object)
{ {
GtkMagnifier *self = GTK_MAGNIFIER (object); GtkMagnifier *magnifier = GTK_MAGNIFIER (object);
GtkMagnifierPrivate *priv = gtk_magnifier_get_instance_private (self);
if (priv->paintable) if (magnifier->paintable)
_gtk_magnifier_set_inspected (self, NULL); _gtk_magnifier_set_inspected (magnifier, NULL);
g_clear_object (&priv->paintable); g_clear_object (&magnifier->paintable);
G_OBJECT_CLASS (gtk_magnifier_parent_class)->dispose (object); G_OBJECT_CLASS (gtk_magnifier_parent_class)->dispose (object);
} }
@ -203,18 +205,17 @@ gtk_magnifier_class_init (GtkMagnifierClass *klass)
} }
static void static void
gtk_magnifier_init (GtkMagnifier *self) gtk_magnifier_init (GtkMagnifier *magnifier)
{ {
GtkMagnifierPrivate *priv = gtk_magnifier_get_instance_private (self); GtkWidget *widget = GTK_WIDGET (magnifier);
GtkWidget *widget = GTK_WIDGET (self);
gtk_widget_set_overflow (widget, GTK_OVERFLOW_HIDDEN); gtk_widget_set_overflow (widget, GTK_OVERFLOW_HIDDEN);
priv->magnification = 1; magnifier->magnification = 1;
priv->resize = FALSE; magnifier->resize = FALSE;
priv->paintable = gtk_widget_paintable_new (NULL); magnifier->paintable = gtk_widget_paintable_new (NULL);
g_signal_connect_swapped (priv->paintable, "invalidate-contents", G_CALLBACK (gtk_widget_queue_draw), self); g_signal_connect_swapped (magnifier->paintable, "invalidate-contents", G_CALLBACK (gtk_widget_queue_draw), magnifier);
g_signal_connect_swapped (priv->paintable, "invalidate-size", G_CALLBACK (gtk_widget_queue_resize), self); g_signal_connect_swapped (magnifier->paintable, "invalidate-size", G_CALLBACK (gtk_widget_queue_resize), magnifier);
} }
GtkWidget * GtkWidget *
@ -230,23 +231,19 @@ _gtk_magnifier_new (GtkWidget *inspected)
GtkWidget * GtkWidget *
_gtk_magnifier_get_inspected (GtkMagnifier *magnifier) _gtk_magnifier_get_inspected (GtkMagnifier *magnifier)
{ {
GtkMagnifierPrivate *priv = gtk_magnifier_get_instance_private (magnifier);
g_return_val_if_fail (GTK_IS_MAGNIFIER (magnifier), NULL); g_return_val_if_fail (GTK_IS_MAGNIFIER (magnifier), NULL);
return gtk_widget_paintable_get_widget (GTK_WIDGET_PAINTABLE (priv->paintable)); return gtk_widget_paintable_get_widget (GTK_WIDGET_PAINTABLE (magnifier->paintable));
} }
void void
_gtk_magnifier_set_inspected (GtkMagnifier *magnifier, _gtk_magnifier_set_inspected (GtkMagnifier *magnifier,
GtkWidget *inspected) GtkWidget *inspected)
{ {
GtkMagnifierPrivate *priv = gtk_magnifier_get_instance_private (magnifier);
g_return_if_fail (GTK_IS_MAGNIFIER (magnifier)); g_return_if_fail (GTK_IS_MAGNIFIER (magnifier));
g_return_if_fail (inspected == NULL || GTK_IS_WIDGET (inspected)); g_return_if_fail (inspected == NULL || GTK_IS_WIDGET (inspected));
gtk_widget_paintable_set_widget (GTK_WIDGET_PAINTABLE (priv->paintable), inspected); gtk_widget_paintable_set_widget (GTK_WIDGET_PAINTABLE (magnifier->paintable), inspected);
g_object_notify (G_OBJECT (magnifier), "inspected"); g_object_notify (G_OBJECT (magnifier), "inspected");
} }
@ -256,17 +253,13 @@ _gtk_magnifier_set_coords (GtkMagnifier *magnifier,
double x, double x,
double y) double y)
{ {
GtkMagnifierPrivate *priv;
g_return_if_fail (GTK_IS_MAGNIFIER (magnifier)); g_return_if_fail (GTK_IS_MAGNIFIER (magnifier));
priv = gtk_magnifier_get_instance_private (magnifier); if (magnifier->x == x && magnifier->y == y)
if (priv->x == x && priv->y == y)
return; return;
priv->x = x; magnifier->x = x;
priv->y = y; magnifier->y = y;
if (gtk_widget_is_visible (GTK_WIDGET (magnifier))) if (gtk_widget_is_visible (GTK_WIDGET (magnifier)))
gtk_widget_queue_draw (GTK_WIDGET (magnifier)); gtk_widget_queue_draw (GTK_WIDGET (magnifier));
@ -277,36 +270,28 @@ _gtk_magnifier_get_coords (GtkMagnifier *magnifier,
double *x, double *x,
double *y) double *y)
{ {
GtkMagnifierPrivate *priv;
g_return_if_fail (GTK_IS_MAGNIFIER (magnifier)); g_return_if_fail (GTK_IS_MAGNIFIER (magnifier));
priv = gtk_magnifier_get_instance_private (magnifier);
if (x) if (x)
*x = priv->x; *x = magnifier->x;
if (y) if (y)
*y = priv->y; *y = magnifier->y;
} }
void void
_gtk_magnifier_set_magnification (GtkMagnifier *magnifier, _gtk_magnifier_set_magnification (GtkMagnifier *magnifier,
double magnification) double magnification)
{ {
GtkMagnifierPrivate *priv;
g_return_if_fail (GTK_IS_MAGNIFIER (magnifier)); g_return_if_fail (GTK_IS_MAGNIFIER (magnifier));
priv = gtk_magnifier_get_instance_private (magnifier); if (magnifier->magnification == magnification)
if (priv->magnification == magnification)
return; return;
priv->magnification = magnification; magnifier->magnification = magnification;
g_object_notify (G_OBJECT (magnifier), "magnification"); g_object_notify (G_OBJECT (magnifier), "magnification");
if (priv->resize) if (magnifier->resize)
gtk_widget_queue_resize (GTK_WIDGET (magnifier)); gtk_widget_queue_resize (GTK_WIDGET (magnifier));
if (gtk_widget_is_visible (GTK_WIDGET (magnifier))) if (gtk_widget_is_visible (GTK_WIDGET (magnifier)))
@ -316,29 +301,21 @@ _gtk_magnifier_set_magnification (GtkMagnifier *magnifier,
double double
_gtk_magnifier_get_magnification (GtkMagnifier *magnifier) _gtk_magnifier_get_magnification (GtkMagnifier *magnifier)
{ {
GtkMagnifierPrivate *priv;
g_return_val_if_fail (GTK_IS_MAGNIFIER (magnifier), 1); g_return_val_if_fail (GTK_IS_MAGNIFIER (magnifier), 1);
priv = gtk_magnifier_get_instance_private (magnifier); return magnifier->magnification;
return priv->magnification;
} }
void void
_gtk_magnifier_set_resize (GtkMagnifier *magnifier, _gtk_magnifier_set_resize (GtkMagnifier *magnifier,
gboolean resize) gboolean resize)
{ {
GtkMagnifierPrivate *priv;
g_return_if_fail (GTK_IS_MAGNIFIER (magnifier)); g_return_if_fail (GTK_IS_MAGNIFIER (magnifier));
priv = gtk_magnifier_get_instance_private (magnifier); if (magnifier->resize == resize)
if (priv->resize == resize)
return; return;
priv->resize = resize; magnifier->resize = resize;
gtk_widget_queue_resize (GTK_WIDGET (magnifier)); gtk_widget_queue_resize (GTK_WIDGET (magnifier));
} }
@ -346,11 +323,7 @@ _gtk_magnifier_set_resize (GtkMagnifier *magnifier,
gboolean gboolean
_gtk_magnifier_get_resize (GtkMagnifier *magnifier) _gtk_magnifier_get_resize (GtkMagnifier *magnifier)
{ {
GtkMagnifierPrivate *priv;
g_return_val_if_fail (GTK_IS_MAGNIFIER (magnifier), FALSE); g_return_val_if_fail (GTK_IS_MAGNIFIER (magnifier), FALSE);
priv = gtk_magnifier_get_instance_private (magnifier); return magnifier->resize;
return priv->resize;
} }

View File

@ -22,23 +22,9 @@ G_BEGIN_DECLS
#define GTK_TYPE_MAGNIFIER (gtk_magnifier_get_type ()) #define GTK_TYPE_MAGNIFIER (gtk_magnifier_get_type ())
#define GTK_MAGNIFIER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GTK_TYPE_MAGNIFIER, GtkMagnifier)) #define GTK_MAGNIFIER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GTK_TYPE_MAGNIFIER, GtkMagnifier))
#define GTK_MAGNIFIER_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), GTK_TYPE_MAGNIFIER, GtkMagnifierClass))
#define GTK_IS_MAGNIFIER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTK_TYPE_MAGNIFIER)) #define GTK_IS_MAGNIFIER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTK_TYPE_MAGNIFIER))
#define GTK_IS_MAGNIFIER_CLASS(o) (G_TYPE_CHECK_CLASS_TYPE ((o), GTK_TYPE_MAGNIFIER))
#define GTK_MAGNIFIER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTK_TYPE_MAGNIFIER, GtkMagnifierClass))
typedef struct _GtkMagnifier GtkMagnifier; typedef struct _GtkMagnifier GtkMagnifier;
typedef struct _GtkMagnifierClass GtkMagnifierClass;
struct _GtkMagnifier
{
GtkWidget parent_instance;
};
struct _GtkMagnifierClass
{
GtkWidgetClass parent_class;
};
GType gtk_magnifier_get_type (void) G_GNUC_CONST; GType gtk_magnifier_get_type (void) G_GNUC_CONST;

View File

@ -72,27 +72,10 @@
* when the child of a #GtkRevealer widget is shown or hidden. * when the child of a #GtkRevealer widget is shown or hidden.
*/ */
enum { struct _GtkRevealer
PROP_0, {
PROP_TRANSITION_TYPE,
PROP_TRANSITION_DURATION,
PROP_REVEAL_CHILD,
PROP_CHILD_REVEALED,
PROP_CHILD,
LAST_PROP
};
typedef struct _GtkRevealerClass GtkRevealerClass;
struct _GtkRevealer {
GtkWidget parent_instance; GtkWidget parent_instance;
};
struct _GtkRevealerClass {
GtkWidgetClass parent_class;
};
typedef struct {
GtkWidget *child; GtkWidget *child;
GtkRevealerTransitionType transition_type; GtkRevealerTransitionType transition_type;
@ -104,7 +87,22 @@ typedef struct {
guint tick_id; guint tick_id;
GtkProgressTracker tracker; GtkProgressTracker tracker;
} GtkRevealerPrivate; };
typedef struct
{
GtkWidgetClass parent_class;
} GtkRevealerClass;
enum {
PROP_0,
PROP_TRANSITION_TYPE,
PROP_TRANSITION_DURATION,
PROP_REVEAL_CHILD,
PROP_CHILD_REVEALED,
PROP_CHILD,
LAST_PROP
};
static GParamSpec *props[LAST_PROP] = { NULL, }; static GParamSpec *props[LAST_PROP] = { NULL, };
@ -126,7 +124,6 @@ static void gtk_revealer_set_position (GtkRevealer *revealer,
static void gtk_revealer_buildable_iface_init (GtkBuildableIface *iface); static void gtk_revealer_buildable_iface_init (GtkBuildableIface *iface);
G_DEFINE_TYPE_WITH_CODE (GtkRevealer, gtk_revealer, GTK_TYPE_WIDGET, G_DEFINE_TYPE_WITH_CODE (GtkRevealer, gtk_revealer, GTK_TYPE_WIDGET,
G_ADD_PRIVATE (GtkRevealer)
G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE, G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
gtk_revealer_buildable_iface_init)) gtk_revealer_buildable_iface_init))
@ -155,12 +152,10 @@ gtk_revealer_buildable_iface_init (GtkBuildableIface *iface)
static void static void
gtk_revealer_init (GtkRevealer *revealer) gtk_revealer_init (GtkRevealer *revealer)
{ {
GtkRevealerPrivate *priv = gtk_revealer_get_instance_private (revealer); revealer->transition_type = GTK_REVEALER_TRANSITION_TYPE_SLIDE_DOWN;
revealer->transition_duration = 250;
priv->transition_type = GTK_REVEALER_TRANSITION_TYPE_SLIDE_DOWN; revealer->current_pos = 0.0;
priv->transition_duration = 250; revealer->target_pos = 0.0;
priv->current_pos = 0.0;
priv->target_pos = 0.0;
gtk_widget_set_overflow (GTK_WIDGET (revealer), GTK_OVERFLOW_HIDDEN); gtk_widget_set_overflow (GTK_WIDGET (revealer), GTK_OVERFLOW_HIDDEN);
} }
@ -169,9 +164,8 @@ static void
gtk_revealer_dispose (GObject *obj) gtk_revealer_dispose (GObject *obj)
{ {
GtkRevealer *revealer = GTK_REVEALER (obj); GtkRevealer *revealer = GTK_REVEALER (obj);
GtkRevealerPrivate *priv = gtk_revealer_get_instance_private (revealer);
g_clear_pointer (&priv->child, gtk_widget_unparent); g_clear_pointer (&revealer->child, gtk_widget_unparent);
G_OBJECT_CLASS (gtk_revealer_parent_class)->dispose (obj); G_OBJECT_CLASS (gtk_revealer_parent_class)->dispose (obj);
} }
@ -180,11 +174,10 @@ static void
gtk_revealer_finalize (GObject *obj) gtk_revealer_finalize (GObject *obj)
{ {
GtkRevealer *revealer = GTK_REVEALER (obj); GtkRevealer *revealer = GTK_REVEALER (obj);
GtkRevealerPrivate *priv = gtk_revealer_get_instance_private (revealer);
if (priv->tick_id != 0) if (revealer->tick_id != 0)
gtk_widget_remove_tick_callback (GTK_WIDGET (revealer), priv->tick_id); gtk_widget_remove_tick_callback (GTK_WIDGET (revealer), revealer->tick_id);
priv->tick_id = 0; revealer->tick_id = 0;
G_OBJECT_CLASS (gtk_revealer_parent_class)->finalize (obj); G_OBJECT_CLASS (gtk_revealer_parent_class)->finalize (obj);
} }
@ -252,18 +245,17 @@ static void
gtk_revealer_unmap (GtkWidget *widget) gtk_revealer_unmap (GtkWidget *widget)
{ {
GtkRevealer *revealer = GTK_REVEALER (widget); GtkRevealer *revealer = GTK_REVEALER (widget);
GtkRevealerPrivate *priv = gtk_revealer_get_instance_private (revealer);
GTK_WIDGET_CLASS (gtk_revealer_parent_class)->unmap (widget); GTK_WIDGET_CLASS (gtk_revealer_parent_class)->unmap (widget);
/* Finish & stop the animation */ /* Finish & stop the animation */
if (priv->current_pos != priv->target_pos) if (revealer->current_pos != revealer->target_pos)
gtk_revealer_set_position (revealer, priv->target_pos); gtk_revealer_set_position (revealer, revealer->target_pos);
if (priv->tick_id != 0) if (revealer->tick_id != 0)
{ {
gtk_widget_remove_tick_callback (GTK_WIDGET (revealer), priv->tick_id); gtk_widget_remove_tick_callback (GTK_WIDGET (revealer), revealer->tick_id);
priv->tick_id = 0; revealer->tick_id = 0;
} }
} }
@ -273,12 +265,11 @@ gtk_revealer_compute_expand (GtkWidget *widget,
gboolean *vexpand) gboolean *vexpand)
{ {
GtkRevealer *revealer = GTK_REVEALER (widget); GtkRevealer *revealer = GTK_REVEALER (widget);
GtkRevealerPrivate *priv = gtk_revealer_get_instance_private (revealer);
if (priv->child) if (revealer->child)
{ {
*hexpand = gtk_widget_compute_expand (priv->child, GTK_ORIENTATION_HORIZONTAL); *hexpand = gtk_widget_compute_expand (revealer->child, GTK_ORIENTATION_HORIZONTAL);
*vexpand = gtk_widget_compute_expand (priv->child, GTK_ORIENTATION_VERTICAL); *vexpand = gtk_widget_compute_expand (revealer->child, GTK_ORIENTATION_VERTICAL);
} }
else else
{ {
@ -291,10 +282,9 @@ static GtkSizeRequestMode
gtk_revealer_get_request_mode (GtkWidget *widget) gtk_revealer_get_request_mode (GtkWidget *widget)
{ {
GtkRevealer *revealer = GTK_REVEALER (widget); GtkRevealer *revealer = GTK_REVEALER (widget);
GtkRevealerPrivate *priv = gtk_revealer_get_instance_private (revealer);
if (priv->child) if (revealer->child)
return gtk_widget_get_request_mode (priv->child); return gtk_widget_get_request_mode (revealer->child);
else else
return GTK_SIZE_REQUEST_CONSTANT_SIZE; return GTK_SIZE_REQUEST_CONSTANT_SIZE;
} }
@ -374,56 +364,52 @@ gtk_revealer_new (void)
static GtkRevealerTransitionType static GtkRevealerTransitionType
effective_transition (GtkRevealer *revealer) effective_transition (GtkRevealer *revealer)
{ {
GtkRevealerPrivate *priv = gtk_revealer_get_instance_private (revealer);
if (gtk_widget_get_direction (GTK_WIDGET (revealer)) == GTK_TEXT_DIR_RTL) if (gtk_widget_get_direction (GTK_WIDGET (revealer)) == GTK_TEXT_DIR_RTL)
{ {
if (priv->transition_type == GTK_REVEALER_TRANSITION_TYPE_SLIDE_LEFT) if (revealer->transition_type == GTK_REVEALER_TRANSITION_TYPE_SLIDE_LEFT)
return GTK_REVEALER_TRANSITION_TYPE_SLIDE_RIGHT; return GTK_REVEALER_TRANSITION_TYPE_SLIDE_RIGHT;
else if (priv->transition_type == GTK_REVEALER_TRANSITION_TYPE_SLIDE_RIGHT) else if (revealer->transition_type == GTK_REVEALER_TRANSITION_TYPE_SLIDE_RIGHT)
return GTK_REVEALER_TRANSITION_TYPE_SLIDE_LEFT; return GTK_REVEALER_TRANSITION_TYPE_SLIDE_LEFT;
if (priv->transition_type == GTK_REVEALER_TRANSITION_TYPE_SWING_LEFT) if (revealer->transition_type == GTK_REVEALER_TRANSITION_TYPE_SWING_LEFT)
return GTK_REVEALER_TRANSITION_TYPE_SWING_RIGHT; return GTK_REVEALER_TRANSITION_TYPE_SWING_RIGHT;
else if (priv->transition_type == GTK_REVEALER_TRANSITION_TYPE_SWING_RIGHT) else if (revealer->transition_type == GTK_REVEALER_TRANSITION_TYPE_SWING_RIGHT)
return GTK_REVEALER_TRANSITION_TYPE_SWING_LEFT; return GTK_REVEALER_TRANSITION_TYPE_SWING_LEFT;
} }
return priv->transition_type; return revealer->transition_type;
} }
static double static double
get_child_size_scale (GtkRevealer *revealer, get_child_size_scale (GtkRevealer *revealer,
GtkOrientation orientation) GtkOrientation orientation)
{ {
GtkRevealerPrivate *priv = gtk_revealer_get_instance_private (revealer);
switch (effective_transition (revealer)) switch (effective_transition (revealer))
{ {
case GTK_REVEALER_TRANSITION_TYPE_SLIDE_RIGHT: case GTK_REVEALER_TRANSITION_TYPE_SLIDE_RIGHT:
case GTK_REVEALER_TRANSITION_TYPE_SLIDE_LEFT: case GTK_REVEALER_TRANSITION_TYPE_SLIDE_LEFT:
if (orientation == GTK_ORIENTATION_HORIZONTAL) if (orientation == GTK_ORIENTATION_HORIZONTAL)
return priv->current_pos; return revealer->current_pos;
else else
return 1.0; return 1.0;
case GTK_REVEALER_TRANSITION_TYPE_SLIDE_DOWN: case GTK_REVEALER_TRANSITION_TYPE_SLIDE_DOWN:
case GTK_REVEALER_TRANSITION_TYPE_SLIDE_UP: case GTK_REVEALER_TRANSITION_TYPE_SLIDE_UP:
if (orientation == GTK_ORIENTATION_VERTICAL) if (orientation == GTK_ORIENTATION_VERTICAL)
return priv->current_pos; return revealer->current_pos;
else else
return 1.0; return 1.0;
case GTK_REVEALER_TRANSITION_TYPE_SWING_RIGHT: case GTK_REVEALER_TRANSITION_TYPE_SWING_RIGHT:
case GTK_REVEALER_TRANSITION_TYPE_SWING_LEFT: case GTK_REVEALER_TRANSITION_TYPE_SWING_LEFT:
if (orientation == GTK_ORIENTATION_HORIZONTAL) if (orientation == GTK_ORIENTATION_HORIZONTAL)
return sin (G_PI * priv->current_pos / 2); return sin (G_PI * revealer->current_pos / 2);
else else
return 1.0; return 1.0;
case GTK_REVEALER_TRANSITION_TYPE_SWING_DOWN: case GTK_REVEALER_TRANSITION_TYPE_SWING_DOWN:
case GTK_REVEALER_TRANSITION_TYPE_SWING_UP: case GTK_REVEALER_TRANSITION_TYPE_SWING_UP:
if (orientation == GTK_ORIENTATION_VERTICAL) if (orientation == GTK_ORIENTATION_VERTICAL)
return sin (G_PI * priv->current_pos / 2); return sin (G_PI * revealer->current_pos / 2);
else else
return 1.0; return 1.0;
@ -441,17 +427,16 @@ gtk_revealer_size_allocate (GtkWidget *widget,
int baseline) int baseline)
{ {
GtkRevealer *revealer = GTK_REVEALER (widget); GtkRevealer *revealer = GTK_REVEALER (widget);
GtkRevealerPrivate *priv = gtk_revealer_get_instance_private (revealer);
GskTransform *transform; GskTransform *transform;
double hscale, vscale; double hscale, vscale;
int child_width, child_height; int child_width, child_height;
if (priv->child == NULL || !gtk_widget_get_visible (priv->child)) if (revealer->child == NULL || !gtk_widget_get_visible (revealer->child))
return; return;
if (priv->current_pos >= 1.0) if (revealer->current_pos >= 1.0)
{ {
gtk_widget_allocate (priv->child, width, height, baseline, NULL); gtk_widget_allocate (revealer->child, width, height, baseline, NULL);
return; return;
} }
@ -493,7 +478,7 @@ gtk_revealer_size_allocate (GtkWidget *widget,
{ {
int min, nat; int min, nat;
g_assert (vscale == 1.0); g_assert (vscale == 1.0);
gtk_widget_measure (priv->child, GTK_ORIENTATION_HORIZONTAL, height, &min, &nat, NULL, NULL); gtk_widget_measure (revealer->child, GTK_ORIENTATION_HORIZONTAL, height, &min, &nat, NULL, NULL);
if (ceil (nat * hscale) == width) if (ceil (nat * hscale) == width)
child_width = nat; child_width = nat;
else if (ceil (min * hscale) == width) else if (ceil (min * hscale) == width)
@ -506,7 +491,7 @@ gtk_revealer_size_allocate (GtkWidget *widget,
{ {
int min, nat; int min, nat;
child_width = width; child_width = width;
gtk_widget_measure (priv->child, GTK_ORIENTATION_VERTICAL, width, &min, &nat, NULL, NULL); gtk_widget_measure (revealer->child, GTK_ORIENTATION_VERTICAL, width, &min, &nat, NULL, NULL);
if (ceil (nat * vscale) == height) if (ceil (nat * vscale) == height)
child_height = nat; child_height = nat;
else if (ceil (min * vscale) == height) else if (ceil (min * vscale) == height)
@ -534,28 +519,28 @@ gtk_revealer_size_allocate (GtkWidget *widget,
case GTK_REVEALER_TRANSITION_TYPE_SWING_LEFT: case GTK_REVEALER_TRANSITION_TYPE_SWING_LEFT:
transform = gsk_transform_translate (transform, &GRAPHENE_POINT_INIT (width, height / 2)); transform = gsk_transform_translate (transform, &GRAPHENE_POINT_INIT (width, height / 2));
transform = gsk_transform_perspective (transform, 2 * MAX (width, height)); transform = gsk_transform_perspective (transform, 2 * MAX (width, height));
transform = gsk_transform_rotate_3d (transform, -90 * (1.0 - priv->current_pos), graphene_vec3_y_axis ()); transform = gsk_transform_rotate_3d (transform, -90 * (1.0 - revealer->current_pos), graphene_vec3_y_axis ());
transform = gsk_transform_translate (transform, &GRAPHENE_POINT_INIT (- child_width, - child_height / 2)); transform = gsk_transform_translate (transform, &GRAPHENE_POINT_INIT (- child_width, - child_height / 2));
break; break;
case GTK_REVEALER_TRANSITION_TYPE_SWING_RIGHT: case GTK_REVEALER_TRANSITION_TYPE_SWING_RIGHT:
transform = gsk_transform_translate (transform, &GRAPHENE_POINT_INIT (0, height / 2)); transform = gsk_transform_translate (transform, &GRAPHENE_POINT_INIT (0, height / 2));
transform = gsk_transform_perspective (transform, 2 * MAX (width, height)); transform = gsk_transform_perspective (transform, 2 * MAX (width, height));
transform = gsk_transform_rotate_3d (transform, 90 * (1.0 - priv->current_pos), graphene_vec3_y_axis ()); transform = gsk_transform_rotate_3d (transform, 90 * (1.0 - revealer->current_pos), graphene_vec3_y_axis ());
transform = gsk_transform_translate (transform, &GRAPHENE_POINT_INIT (0, - child_height / 2)); transform = gsk_transform_translate (transform, &GRAPHENE_POINT_INIT (0, - child_height / 2));
break; break;
case GTK_REVEALER_TRANSITION_TYPE_SWING_DOWN: case GTK_REVEALER_TRANSITION_TYPE_SWING_DOWN:
transform = gsk_transform_translate (transform, &GRAPHENE_POINT_INIT (width / 2, 0)); transform = gsk_transform_translate (transform, &GRAPHENE_POINT_INIT (width / 2, 0));
transform = gsk_transform_perspective (transform, 2 * MAX (width, height)); transform = gsk_transform_perspective (transform, 2 * MAX (width, height));
transform = gsk_transform_rotate_3d (transform, -90 * (1.0 - priv->current_pos), graphene_vec3_x_axis ()); transform = gsk_transform_rotate_3d (transform, -90 * (1.0 - revealer->current_pos), graphene_vec3_x_axis ());
transform = gsk_transform_translate (transform, &GRAPHENE_POINT_INIT (- child_width / 2, 0)); transform = gsk_transform_translate (transform, &GRAPHENE_POINT_INIT (- child_width / 2, 0));
break; break;
case GTK_REVEALER_TRANSITION_TYPE_SWING_UP: case GTK_REVEALER_TRANSITION_TYPE_SWING_UP:
transform = gsk_transform_translate (transform, &GRAPHENE_POINT_INIT (width / 2, height)); transform = gsk_transform_translate (transform, &GRAPHENE_POINT_INIT (width / 2, height));
transform = gsk_transform_perspective (transform, 2 * MAX (width, height)); transform = gsk_transform_perspective (transform, 2 * MAX (width, height));
transform = gsk_transform_rotate_3d (transform, 90 * (1.0 - priv->current_pos), graphene_vec3_x_axis ()); transform = gsk_transform_rotate_3d (transform, 90 * (1.0 - revealer->current_pos), graphene_vec3_x_axis ());
transform = gsk_transform_translate (transform, &GRAPHENE_POINT_INIT (- child_width / 2, - child_height)); transform = gsk_transform_translate (transform, &GRAPHENE_POINT_INIT (- child_width / 2, - child_height));
break; break;
@ -567,25 +552,24 @@ gtk_revealer_size_allocate (GtkWidget *widget,
break; break;
} }
gtk_widget_allocate (priv->child, child_width, child_height, -1, transform); gtk_widget_allocate (revealer->child, child_width, child_height, -1, transform);
} }
static void static void
gtk_revealer_set_position (GtkRevealer *revealer, gtk_revealer_set_position (GtkRevealer *revealer,
double pos) double pos)
{ {
GtkRevealerPrivate *priv = gtk_revealer_get_instance_private (revealer);
gboolean new_visible; gboolean new_visible;
GtkRevealerTransitionType transition; GtkRevealerTransitionType transition;
priv->current_pos = pos; revealer->current_pos = pos;
new_visible = priv->current_pos != 0.0; new_visible = revealer->current_pos != 0.0;
if (priv->child != NULL && if (revealer->child != NULL &&
new_visible != gtk_widget_get_child_visible (priv->child)) new_visible != gtk_widget_get_child_visible (revealer->child))
{ {
gtk_widget_set_child_visible (priv->child, new_visible); gtk_widget_set_child_visible (revealer->child, new_visible);
gtk_widget_queue_resize (GTK_WIDGET (revealer)); gtk_widget_queue_resize (GTK_WIDGET (revealer));
} }
@ -596,7 +580,7 @@ gtk_revealer_set_position (GtkRevealer *revealer,
} }
else if (transition == GTK_REVEALER_TRANSITION_TYPE_CROSSFADE) else if (transition == GTK_REVEALER_TRANSITION_TYPE_CROSSFADE)
{ {
gtk_widget_set_opacity (GTK_WIDGET (revealer), priv->current_pos); gtk_widget_set_opacity (GTK_WIDGET (revealer), revealer->current_pos);
gtk_widget_queue_draw (GTK_WIDGET (revealer)); gtk_widget_queue_draw (GTK_WIDGET (revealer));
} }
else else
@ -604,7 +588,7 @@ gtk_revealer_set_position (GtkRevealer *revealer,
gtk_widget_queue_resize (GTK_WIDGET (revealer)); gtk_widget_queue_resize (GTK_WIDGET (revealer));
} }
if (priv->current_pos == priv->target_pos) if (revealer->current_pos == revealer->target_pos)
g_object_notify_by_pspec (G_OBJECT (revealer), props[PROP_CHILD_REVEALED]); g_object_notify_by_pspec (G_OBJECT (revealer), props[PROP_CHILD_REVEALED]);
} }
@ -614,18 +598,17 @@ gtk_revealer_animate_cb (GtkWidget *widget,
gpointer user_data) gpointer user_data)
{ {
GtkRevealer *revealer = GTK_REVEALER (widget); GtkRevealer *revealer = GTK_REVEALER (widget);
GtkRevealerPrivate *priv = gtk_revealer_get_instance_private (revealer);
double ease; double ease;
gtk_progress_tracker_advance_frame (&priv->tracker, gtk_progress_tracker_advance_frame (&revealer->tracker,
gdk_frame_clock_get_frame_time (frame_clock)); gdk_frame_clock_get_frame_time (frame_clock));
ease = gtk_progress_tracker_get_ease_out_cubic (&priv->tracker, FALSE); ease = gtk_progress_tracker_get_ease_out_cubic (&revealer->tracker, FALSE);
gtk_revealer_set_position (revealer, gtk_revealer_set_position (revealer,
priv->source_pos + (ease * (priv->target_pos - priv->source_pos))); revealer->source_pos + (ease * (revealer->target_pos - revealer->source_pos)));
if (gtk_progress_tracker_get_state (&priv->tracker) == GTK_PROGRESS_STATE_AFTER) if (gtk_progress_tracker_get_state (&revealer->tracker) == GTK_PROGRESS_STATE_AFTER)
{ {
priv->tick_id = 0; revealer->tick_id = 0;
return FALSE; return FALSE;
} }
@ -636,28 +619,27 @@ static void
gtk_revealer_start_animation (GtkRevealer *revealer, gtk_revealer_start_animation (GtkRevealer *revealer,
double target) double target)
{ {
GtkRevealerPrivate *priv = gtk_revealer_get_instance_private (revealer);
GtkWidget *widget = GTK_WIDGET (revealer); GtkWidget *widget = GTK_WIDGET (revealer);
GtkRevealerTransitionType transition; GtkRevealerTransitionType transition;
if (priv->target_pos == target) if (revealer->target_pos == target)
return; return;
priv->target_pos = target; revealer->target_pos = target;
g_object_notify_by_pspec (G_OBJECT (revealer), props[PROP_REVEAL_CHILD]); g_object_notify_by_pspec (G_OBJECT (revealer), props[PROP_REVEAL_CHILD]);
transition = effective_transition (revealer); transition = effective_transition (revealer);
if (gtk_widget_get_mapped (widget) && if (gtk_widget_get_mapped (widget) &&
priv->transition_duration != 0 && revealer->transition_duration != 0 &&
transition != GTK_REVEALER_TRANSITION_TYPE_NONE && transition != GTK_REVEALER_TRANSITION_TYPE_NONE &&
gtk_settings_get_enable_animations (gtk_widget_get_settings (widget))) gtk_settings_get_enable_animations (gtk_widget_get_settings (widget)))
{ {
priv->source_pos = priv->current_pos; revealer->source_pos = revealer->current_pos;
if (priv->tick_id == 0) if (revealer->tick_id == 0)
priv->tick_id = revealer->tick_id =
gtk_widget_add_tick_callback (widget, gtk_revealer_animate_cb, revealer, NULL); gtk_widget_add_tick_callback (widget, gtk_revealer_animate_cb, revealer, NULL);
gtk_progress_tracker_start (&priv->tracker, gtk_progress_tracker_start (&revealer->tracker,
priv->transition_duration * 1000, revealer->transition_duration * 1000,
0, 0,
1.0); 1.0);
} }
@ -706,11 +688,9 @@ gtk_revealer_set_reveal_child (GtkRevealer *revealer,
gboolean gboolean
gtk_revealer_get_reveal_child (GtkRevealer *revealer) gtk_revealer_get_reveal_child (GtkRevealer *revealer)
{ {
GtkRevealerPrivate *priv = gtk_revealer_get_instance_private (revealer);
g_return_val_if_fail (GTK_IS_REVEALER (revealer), FALSE); g_return_val_if_fail (GTK_IS_REVEALER (revealer), FALSE);
return priv->target_pos != 0.0; return revealer->target_pos != 0.0;
} }
/** /**
@ -725,8 +705,7 @@ gtk_revealer_get_reveal_child (GtkRevealer *revealer)
gboolean gboolean
gtk_revealer_get_child_revealed (GtkRevealer *revealer) gtk_revealer_get_child_revealed (GtkRevealer *revealer)
{ {
GtkRevealerPrivate *priv = gtk_revealer_get_instance_private (revealer); gboolean animation_finished = (revealer->target_pos == revealer->current_pos);
gboolean animation_finished = (priv->target_pos == priv->current_pos);
gboolean reveal_child = gtk_revealer_get_reveal_child (revealer); gboolean reveal_child = gtk_revealer_get_reveal_child (revealer);
if (animation_finished) if (animation_finished)
@ -744,11 +723,10 @@ gtk_revealer_measure (GtkWidget *widget,
int *minimum_baseline, int *minimum_baseline,
int *natural_baseline) int *natural_baseline)
{ {
GtkRevealer *self = GTK_REVEALER (widget); GtkRevealer *revealer = GTK_REVEALER (widget);
GtkRevealerPrivate *priv = gtk_revealer_get_instance_private (self);
double scale; double scale;
scale = get_child_size_scale (self, OPPOSITE_ORIENTATION (orientation)); scale = get_child_size_scale (revealer, OPPOSITE_ORIENTATION (orientation));
if (for_size >= 0) if (for_size >= 0)
{ {
@ -758,9 +736,9 @@ gtk_revealer_measure (GtkWidget *widget,
for_size = MIN (G_MAXINT, ceil (for_size / scale)); for_size = MIN (G_MAXINT, ceil (for_size / scale));
} }
if (priv->child != NULL && _gtk_widget_get_visible (priv->child)) if (revealer->child != NULL && _gtk_widget_get_visible (revealer->child))
{ {
gtk_widget_measure (priv->child, gtk_widget_measure (revealer->child,
orientation, orientation,
for_size, for_size,
minimum, natural, minimum, natural,
@ -772,7 +750,7 @@ gtk_revealer_measure (GtkWidget *widget,
*natural = 0; *natural = 0;
} }
scale = get_child_size_scale (self, orientation); scale = get_child_size_scale (revealer, orientation);
*minimum = ceil (*minimum * scale); *minimum = ceil (*minimum * scale);
*natural = ceil (*natural * scale); *natural = ceil (*natural * scale);
} }
@ -789,11 +767,9 @@ gtk_revealer_measure (GtkWidget *widget,
guint guint
gtk_revealer_get_transition_duration (GtkRevealer *revealer) gtk_revealer_get_transition_duration (GtkRevealer *revealer)
{ {
GtkRevealerPrivate *priv = gtk_revealer_get_instance_private (revealer);
g_return_val_if_fail (GTK_IS_REVEALER (revealer), 0); g_return_val_if_fail (GTK_IS_REVEALER (revealer), 0);
return priv->transition_duration; return revealer->transition_duration;
} }
/** /**
@ -807,14 +783,12 @@ void
gtk_revealer_set_transition_duration (GtkRevealer *revealer, gtk_revealer_set_transition_duration (GtkRevealer *revealer,
guint value) guint value)
{ {
GtkRevealerPrivate *priv = gtk_revealer_get_instance_private (revealer);
g_return_if_fail (GTK_IS_REVEALER (revealer)); g_return_if_fail (GTK_IS_REVEALER (revealer));
if (priv->transition_duration == value) if (revealer->transition_duration == value)
return; return;
priv->transition_duration = value; revealer->transition_duration = value;
g_object_notify_by_pspec (G_OBJECT (revealer), props[PROP_TRANSITION_DURATION]); g_object_notify_by_pspec (G_OBJECT (revealer), props[PROP_TRANSITION_DURATION]);
} }
@ -830,11 +804,9 @@ gtk_revealer_set_transition_duration (GtkRevealer *revealer,
GtkRevealerTransitionType GtkRevealerTransitionType
gtk_revealer_get_transition_type (GtkRevealer *revealer) gtk_revealer_get_transition_type (GtkRevealer *revealer)
{ {
GtkRevealerPrivate *priv = gtk_revealer_get_instance_private (revealer);
g_return_val_if_fail (GTK_IS_REVEALER (revealer), GTK_REVEALER_TRANSITION_TYPE_NONE); g_return_val_if_fail (GTK_IS_REVEALER (revealer), GTK_REVEALER_TRANSITION_TYPE_NONE);
return priv->transition_type; return revealer->transition_type;
} }
/** /**
@ -850,14 +822,12 @@ void
gtk_revealer_set_transition_type (GtkRevealer *revealer, gtk_revealer_set_transition_type (GtkRevealer *revealer,
GtkRevealerTransitionType transition) GtkRevealerTransitionType transition)
{ {
GtkRevealerPrivate *priv = gtk_revealer_get_instance_private (revealer);
g_return_if_fail (GTK_IS_REVEALER (revealer)); g_return_if_fail (GTK_IS_REVEALER (revealer));
if (priv->transition_type == transition) if (revealer->transition_type == transition)
return; return;
priv->transition_type = transition; revealer->transition_type = transition;
gtk_widget_queue_resize (GTK_WIDGET (revealer)); gtk_widget_queue_resize (GTK_WIDGET (revealer));
g_object_notify_by_pspec (G_OBJECT (revealer), props[PROP_TRANSITION_TYPE]); g_object_notify_by_pspec (G_OBJECT (revealer), props[PROP_TRANSITION_TYPE]);
} }
@ -873,18 +843,16 @@ void
gtk_revealer_set_child (GtkRevealer *revealer, gtk_revealer_set_child (GtkRevealer *revealer,
GtkWidget *child) GtkWidget *child)
{ {
GtkRevealerPrivate *priv = gtk_revealer_get_instance_private (revealer);
g_return_if_fail (GTK_IS_REVEALER (revealer)); g_return_if_fail (GTK_IS_REVEALER (revealer));
g_return_if_fail (child == NULL || GTK_IS_WIDGET (child)); g_return_if_fail (child == NULL || GTK_IS_WIDGET (child));
g_clear_pointer (&priv->child, gtk_widget_unparent); g_clear_pointer (&revealer->child, gtk_widget_unparent);
if (child) if (child)
{ {
gtk_widget_set_parent (child, GTK_WIDGET (revealer)); gtk_widget_set_parent (child, GTK_WIDGET (revealer));
gtk_widget_set_child_visible (child, priv->current_pos != 0.0); gtk_widget_set_child_visible (child, revealer->current_pos != 0.0);
priv->child = child; revealer->child = child;
} }
g_object_notify_by_pspec (G_OBJECT (revealer), props[PROP_CHILD]); g_object_notify_by_pspec (G_OBJECT (revealer), props[PROP_CHILD]);
@ -901,9 +869,7 @@ gtk_revealer_set_child (GtkRevealer *revealer,
GtkWidget * GtkWidget *
gtk_revealer_get_child (GtkRevealer *revealer) gtk_revealer_get_child (GtkRevealer *revealer)
{ {
GtkRevealerPrivate *priv = gtk_revealer_get_instance_private (revealer);
g_return_val_if_fail (GTK_IS_REVEALER (revealer), NULL); g_return_val_if_fail (GTK_IS_REVEALER (revealer), NULL);
return priv->child; return revealer->child;
} }

View File

@ -91,16 +91,10 @@
* The .ui file for this example can be found [here](https://gitlab.gnome.org/GNOME/gtk/tree/master/demos/gtk-demo/shortcuts-builder.ui). * The .ui file for this example can be found [here](https://gitlab.gnome.org/GNOME/gtk/tree/master/demos/gtk-demo/shortcuts-builder.ui).
*/ */
struct _GtkShortcutsWindowClass struct _GtkShortcutsWindow
{ {
GtkWindowClass parent_class; GtkWindow parent_instance;
void (*close) (GtkShortcutsWindow *self);
void (*search) (GtkShortcutsWindow *self);
};
typedef struct
{
GHashTable *keywords; GHashTable *keywords;
char *initial_section; char *initial_section;
char *last_section_name; char *last_section_name;
@ -123,7 +117,15 @@ typedef struct
GtkWindow *window; GtkWindow *window;
gulong keys_changed_id; gulong keys_changed_id;
} GtkShortcutsWindowPrivate; };
typedef struct
{
GtkWindowClass parent_class;
void (*close) (GtkShortcutsWindow *self);
void (*search) (GtkShortcutsWindow *self);
} GtkShortcutsWindowClass;
typedef struct typedef struct
{ {
@ -138,7 +140,6 @@ static void gtk_shortcuts_window_buildable_iface_init (GtkBuildableIface *iface)
G_DEFINE_TYPE_WITH_CODE (GtkShortcutsWindow, gtk_shortcuts_window, GTK_TYPE_WINDOW, G_DEFINE_TYPE_WITH_CODE (GtkShortcutsWindow, gtk_shortcuts_window, GTK_TYPE_WINDOW,
G_ADD_PRIVATE (GtkShortcutsWindow)
G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE, G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
gtk_shortcuts_window_buildable_iface_init)) gtk_shortcuts_window_buildable_iface_init))
@ -180,30 +181,29 @@ more_than_three_children (GtkWidget *widget)
static void static void
update_title_stack (GtkShortcutsWindow *self) update_title_stack (GtkShortcutsWindow *self)
{ {
GtkShortcutsWindowPrivate *priv = gtk_shortcuts_window_get_instance_private (self);
GtkWidget *visible_child; GtkWidget *visible_child;
visible_child = gtk_stack_get_visible_child (priv->stack); visible_child = gtk_stack_get_visible_child (self->stack);
if (GTK_IS_SHORTCUTS_SECTION (visible_child)) if (GTK_IS_SHORTCUTS_SECTION (visible_child))
{ {
if (more_than_three_children (GTK_WIDGET (priv->stack))) if (more_than_three_children (GTK_WIDGET (self->stack)))
{ {
char *title; char *title;
gtk_stack_set_visible_child_name (priv->title_stack, "sections"); gtk_stack_set_visible_child_name (self->title_stack, "sections");
g_object_get (visible_child, "title", &title, NULL); g_object_get (visible_child, "title", &title, NULL);
gtk_menu_button_set_label (priv->menu_button, title); gtk_menu_button_set_label (self->menu_button, title);
g_free (title); g_free (title);
} }
else else
{ {
gtk_stack_set_visible_child_name (priv->title_stack, "title"); gtk_stack_set_visible_child_name (self->title_stack, "title");
} }
} }
else if (visible_child != NULL) else if (visible_child != NULL)
{ {
gtk_stack_set_visible_child_name (priv->title_stack, "search"); gtk_stack_set_visible_child_name (self->title_stack, "search");
} }
} }
@ -211,7 +211,6 @@ static void
gtk_shortcuts_window_add_search_item (GtkWidget *child, gpointer data) gtk_shortcuts_window_add_search_item (GtkWidget *child, gpointer data)
{ {
GtkShortcutsWindow *self = data; GtkShortcutsWindow *self = data;
GtkShortcutsWindowPrivate *priv = gtk_shortcuts_window_get_instance_private (self);
GtkWidget *item; GtkWidget *item;
char *accelerator = NULL; char *accelerator = NULL;
char *title = NULL; char *title = NULL;
@ -248,7 +247,7 @@ gtk_shortcuts_window_add_search_item (GtkWidget *child, gpointer data)
g_type_class_unref (class); g_type_class_unref (class);
if (g_hash_table_contains (priv->search_items_hash, hash_key)) if (g_hash_table_contains (self->search_items_hash, hash_key))
{ {
g_free (hash_key); g_free (hash_key);
g_free (title); g_free (title);
@ -256,15 +255,15 @@ gtk_shortcuts_window_add_search_item (GtkWidget *child, gpointer data)
return; return;
} }
g_hash_table_insert (priv->search_items_hash, hash_key, GINT_TO_POINTER (1)); g_hash_table_insert (self->search_items_hash, hash_key, GINT_TO_POINTER (1));
item = g_object_new (GTK_TYPE_SHORTCUTS_SHORTCUT, item = g_object_new (GTK_TYPE_SHORTCUTS_SHORTCUT,
"accelerator", accelerator, "accelerator", accelerator,
"title", title, "title", title,
"direction", direction, "direction", direction,
"shortcut-type", shortcut_type, "shortcut-type", shortcut_type,
"accel-size-group", priv->search_image_group, "accel-size-group", self->search_image_group,
"title-size-group", priv->search_text_group, "title-size-group", self->search_text_group,
"action-name", action_name, "action-name", action_name,
NULL); NULL);
if (icon_set) if (icon_set)
@ -282,11 +281,11 @@ gtk_shortcuts_window_add_search_item (GtkWidget *child, gpointer data)
str = g_strdup_printf ("%s %s", accelerator, title); str = g_strdup_printf ("%s %s", accelerator, title);
keywords = g_utf8_strdown (str, -1); keywords = g_utf8_strdown (str, -1);
g_hash_table_insert (priv->keywords, item, keywords); g_hash_table_insert (self->keywords, item, keywords);
if (shortcut_type == GTK_SHORTCUT_ACCELERATOR) if (shortcut_type == GTK_SHORTCUT_ACCELERATOR)
gtk_box_append (GTK_BOX (priv->search_shortcuts), item); gtk_box_append (GTK_BOX (self->search_shortcuts), item);
else else
gtk_box_append (GTK_BOX (priv->search_gestures), item); gtk_box_append (GTK_BOX (self->search_gestures), item);
g_free (title); g_free (title);
g_free (accelerator); g_free (accelerator);
@ -310,14 +309,13 @@ section_notify_cb (GObject *section,
gpointer data) gpointer data)
{ {
GtkShortcutsWindow *self = data; GtkShortcutsWindow *self = data;
GtkShortcutsWindowPrivate *priv = gtk_shortcuts_window_get_instance_private (self);
if (strcmp (pspec->name, "section-name") == 0) if (strcmp (pspec->name, "section-name") == 0)
{ {
char *name; char *name;
g_object_get (section, "section-name", &name, NULL); g_object_get (section, "section-name", &name, NULL);
g_object_set (gtk_stack_get_page (priv->stack, GTK_WIDGET (section)), "name", name, NULL); g_object_set (gtk_stack_get_page (self->stack, GTK_WIDGET (section)), "name", name, NULL);
g_free (name); g_free (name);
} }
else if (strcmp (pspec->name, "title") == 0) else if (strcmp (pspec->name, "title") == 0)
@ -336,7 +334,6 @@ static void
gtk_shortcuts_window_add_section (GtkShortcutsWindow *self, gtk_shortcuts_window_add_section (GtkShortcutsWindow *self,
GtkShortcutsSection *section) GtkShortcutsSection *section)
{ {
GtkShortcutsWindowPrivate *priv = gtk_shortcuts_window_get_instance_private (self);
GtkListBoxRow *row; GtkListBoxRow *row;
char *title; char *title;
char *name; char *name;
@ -359,12 +356,12 @@ gtk_shortcuts_window_add_section (GtkShortcutsWindow *self,
if (name == NULL) if (name == NULL)
name = g_strdup ("shortcuts"); name = g_strdup ("shortcuts");
gtk_stack_add_titled (priv->stack, GTK_WIDGET (section), name, title); gtk_stack_add_titled (self->stack, GTK_WIDGET (section), name, title);
visible_section = gtk_stack_get_visible_child_name (priv->stack); visible_section = gtk_stack_get_visible_child_name (self->stack);
if (strcmp (visible_section, "internal-search") == 0 || if (strcmp (visible_section, "internal-search") == 0 ||
(priv->initial_section && strcmp (priv->initial_section, visible_section) == 0)) (self->initial_section && strcmp (self->initial_section, visible_section) == 0))
gtk_stack_set_visible_child (priv->stack, GTK_WIDGET (section)); gtk_stack_set_visible_child (self->stack, GTK_WIDGET (section));
row = g_object_new (GTK_TYPE_LIST_BOX_ROW, row = g_object_new (GTK_TYPE_LIST_BOX_ROW,
NULL); NULL);
@ -379,7 +376,7 @@ gtk_shortcuts_window_add_section (GtkShortcutsWindow *self,
NULL); NULL);
g_object_set_data (G_OBJECT (section), "gtk-shortcuts-title", label); g_object_set_data (G_OBJECT (section), "gtk-shortcuts-title", label);
gtk_list_box_row_set_child (GTK_LIST_BOX_ROW (row), GTK_WIDGET (label)); gtk_list_box_row_set_child (GTK_LIST_BOX_ROW (row), GTK_WIDGET (label));
gtk_list_box_insert (GTK_LIST_BOX (priv->list_box), GTK_WIDGET (row), -1); gtk_list_box_insert (GTK_LIST_BOX (self->list_box), GTK_WIDGET (row), -1);
update_title_stack (self); update_title_stack (self);
@ -414,18 +411,17 @@ static void
gtk_shortcuts_window_set_view_name (GtkShortcutsWindow *self, gtk_shortcuts_window_set_view_name (GtkShortcutsWindow *self,
const char *view_name) const char *view_name)
{ {
GtkShortcutsWindowPrivate *priv = gtk_shortcuts_window_get_instance_private (self);
GtkWidget *section; GtkWidget *section;
g_free (priv->view_name); g_free (self->view_name);
priv->view_name = g_strdup (view_name); self->view_name = g_strdup (view_name);
for (section = gtk_widget_get_first_child (GTK_WIDGET (priv->stack)); for (section = gtk_widget_get_first_child (GTK_WIDGET (self->stack));
section != NULL; section != NULL;
section = gtk_widget_get_next_sibling (section)) section = gtk_widget_get_next_sibling (section))
{ {
if (GTK_IS_SHORTCUTS_SECTION (section)) if (GTK_IS_SHORTCUTS_SECTION (section))
g_object_set (section, "view-name", priv->view_name, NULL); g_object_set (section, "view-name", self->view_name, NULL);
} }
} }
@ -433,16 +429,15 @@ static void
gtk_shortcuts_window_set_section_name (GtkShortcutsWindow *self, gtk_shortcuts_window_set_section_name (GtkShortcutsWindow *self,
const char *section_name) const char *section_name)
{ {
GtkShortcutsWindowPrivate *priv = gtk_shortcuts_window_get_instance_private (self);
GtkWidget *section = NULL; GtkWidget *section = NULL;
g_free (priv->initial_section); g_free (self->initial_section);
priv->initial_section = g_strdup (section_name); self->initial_section = g_strdup (section_name);
if (section_name) if (section_name)
section = gtk_stack_get_child_by_name (priv->stack, section_name); section = gtk_stack_get_child_by_name (self->stack, section_name);
if (section) if (section)
gtk_stack_set_visible_child (priv->stack, section); gtk_stack_set_visible_child (self->stack, section);
} }
static void static void
@ -450,10 +445,9 @@ update_accels_cb (GtkWidget *widget,
gpointer data) gpointer data)
{ {
GtkShortcutsWindow *self = data; GtkShortcutsWindow *self = data;
GtkShortcutsWindowPrivate *priv = gtk_shortcuts_window_get_instance_private (self);
if (GTK_IS_SHORTCUTS_SHORTCUT (widget)) if (GTK_IS_SHORTCUTS_SHORTCUT (widget))
gtk_shortcuts_shortcut_update_accel (GTK_SHORTCUTS_SHORTCUT (widget), priv->window); gtk_shortcuts_shortcut_update_accel (GTK_SHORTCUTS_SHORTCUT (widget), self->window);
else else
{ {
GtkWidget *child; GtkWidget *child;
@ -468,9 +462,7 @@ update_accels_cb (GtkWidget *widget,
static void static void
update_accels_for_actions (GtkShortcutsWindow *self) update_accels_for_actions (GtkShortcutsWindow *self)
{ {
GtkShortcutsWindowPrivate *priv = gtk_shortcuts_window_get_instance_private (self); if (self->window)
if (priv->window)
{ {
GtkWidget *child; GtkWidget *child;
@ -492,18 +484,16 @@ void
gtk_shortcuts_window_set_window (GtkShortcutsWindow *self, gtk_shortcuts_window_set_window (GtkShortcutsWindow *self,
GtkWindow *window) GtkWindow *window)
{ {
GtkShortcutsWindowPrivate *priv = gtk_shortcuts_window_get_instance_private (self); if (self->keys_changed_id)
if (priv->keys_changed_id)
{ {
g_signal_handler_disconnect (priv->window, priv->keys_changed_id); g_signal_handler_disconnect (self->window, self->keys_changed_id);
priv->keys_changed_id = 0; self->keys_changed_id = 0;
} }
priv->window = window; self->window = window;
if (priv->window) if (self->window)
priv->keys_changed_id = g_signal_connect (window, "keys-changed", self->keys_changed_id = g_signal_connect (window, "keys-changed",
G_CALLBACK (keys_changed_handler), G_CALLBACK (keys_changed_handler),
self); self);
@ -515,12 +505,11 @@ gtk_shortcuts_window__list_box__row_activated (GtkShortcutsWindow *self,
GtkListBoxRow *row, GtkListBoxRow *row,
GtkListBox *list_box) GtkListBox *list_box)
{ {
GtkShortcutsWindowPrivate *priv = gtk_shortcuts_window_get_instance_private (self);
GtkWidget *section; GtkWidget *section;
section = g_object_get_data (G_OBJECT (row), "gtk-shortcuts-section"); section = g_object_get_data (G_OBJECT (row), "gtk-shortcuts-section");
gtk_stack_set_visible_child (priv->stack, section); gtk_stack_set_visible_child (self->stack, section);
gtk_popover_popdown (priv->popover); gtk_popover_popdown (self->popover);
} }
static gboolean static gboolean
@ -543,7 +532,6 @@ static void
gtk_shortcuts_window__entry__changed (GtkShortcutsWindow *self, gtk_shortcuts_window__entry__changed (GtkShortcutsWindow *self,
GtkSearchEntry *search_entry) GtkSearchEntry *search_entry)
{ {
GtkShortcutsWindowPrivate *priv = gtk_shortcuts_window_get_instance_private (self);
char *downcase = NULL; char *downcase = NULL;
GHashTableIter iter; GHashTableIter iter;
const char *text; const char *text;
@ -556,26 +544,26 @@ gtk_shortcuts_window__entry__changed (GtkShortcutsWindow *self,
if (!text || !*text) if (!text || !*text)
{ {
if (priv->last_section_name != NULL) if (self->last_section_name != NULL)
{ {
gtk_stack_set_visible_child_name (priv->stack, priv->last_section_name); gtk_stack_set_visible_child_name (self->stack, self->last_section_name);
return; return;
} }
} }
last_section_name = gtk_stack_get_visible_child_name (priv->stack); last_section_name = gtk_stack_get_visible_child_name (self->stack);
if (g_strcmp0 (last_section_name, "internal-search") != 0 && if (g_strcmp0 (last_section_name, "internal-search") != 0 &&
g_strcmp0 (last_section_name, "no-search-results") != 0) g_strcmp0 (last_section_name, "no-search-results") != 0)
{ {
g_free (priv->last_section_name); g_free (self->last_section_name);
priv->last_section_name = g_strdup (last_section_name); self->last_section_name = g_strdup (last_section_name);
} }
downcase = g_utf8_strdown (text, -1); downcase = g_utf8_strdown (text, -1);
g_hash_table_iter_init (&iter, priv->keywords); g_hash_table_iter_init (&iter, self->keywords);
has_result = FALSE; has_result = FALSE;
while (g_hash_table_iter_next (&iter, &key, &value)) while (g_hash_table_iter_next (&iter, &key, &value))
@ -596,20 +584,18 @@ gtk_shortcuts_window__entry__changed (GtkShortcutsWindow *self,
g_free (downcase); g_free (downcase);
if (has_result) if (has_result)
gtk_stack_set_visible_child_name (priv->stack, "internal-search"); gtk_stack_set_visible_child_name (self->stack, "internal-search");
else else
gtk_stack_set_visible_child_name (priv->stack, "no-search-results"); gtk_stack_set_visible_child_name (self->stack, "no-search-results");
} }
static void static void
gtk_shortcuts_window__search_mode__changed (GtkShortcutsWindow *self) gtk_shortcuts_window__search_mode__changed (GtkShortcutsWindow *self)
{ {
GtkShortcutsWindowPrivate *priv = gtk_shortcuts_window_get_instance_private (self); if (!gtk_search_bar_get_search_mode (self->search_bar))
if (!gtk_search_bar_get_search_mode (priv->search_bar))
{ {
if (priv->last_section_name != NULL) if (self->last_section_name != NULL)
gtk_stack_set_visible_child_name (priv->stack, priv->last_section_name); gtk_stack_set_visible_child_name (self->stack, self->last_section_name);
} }
} }
@ -622,37 +608,33 @@ gtk_shortcuts_window_close (GtkShortcutsWindow *self)
static void static void
gtk_shortcuts_window_search (GtkShortcutsWindow *self) gtk_shortcuts_window_search (GtkShortcutsWindow *self)
{ {
GtkShortcutsWindowPrivate *priv = gtk_shortcuts_window_get_instance_private (self); gtk_search_bar_set_search_mode (self->search_bar, TRUE);
gtk_search_bar_set_search_mode (priv->search_bar, TRUE);
} }
static void static void
gtk_shortcuts_window_constructed (GObject *object) gtk_shortcuts_window_constructed (GObject *object)
{ {
GtkShortcutsWindow *self = (GtkShortcutsWindow *)object; GtkShortcutsWindow *self = (GtkShortcutsWindow *)object;
GtkShortcutsWindowPrivate *priv = gtk_shortcuts_window_get_instance_private (self);
G_OBJECT_CLASS (gtk_shortcuts_window_parent_class)->constructed (object); G_OBJECT_CLASS (gtk_shortcuts_window_parent_class)->constructed (object);
if (priv->initial_section != NULL) if (self->initial_section != NULL)
gtk_stack_set_visible_child_name (priv->stack, priv->initial_section); gtk_stack_set_visible_child_name (self->stack, self->initial_section);
} }
static void static void
gtk_shortcuts_window_finalize (GObject *object) gtk_shortcuts_window_finalize (GObject *object)
{ {
GtkShortcutsWindow *self = (GtkShortcutsWindow *)object; GtkShortcutsWindow *self = (GtkShortcutsWindow *)object;
GtkShortcutsWindowPrivate *priv = gtk_shortcuts_window_get_instance_private (self);
g_clear_pointer (&priv->keywords, g_hash_table_unref); g_clear_pointer (&self->keywords, g_hash_table_unref);
g_clear_pointer (&priv->initial_section, g_free); g_clear_pointer (&self->initial_section, g_free);
g_clear_pointer (&priv->view_name, g_free); g_clear_pointer (&self->view_name, g_free);
g_clear_pointer (&priv->last_section_name, g_free); g_clear_pointer (&self->last_section_name, g_free);
g_clear_pointer (&priv->search_items_hash, g_hash_table_unref); g_clear_pointer (&self->search_items_hash, g_hash_table_unref);
g_clear_object (&priv->search_image_group); g_clear_object (&self->search_image_group);
g_clear_object (&priv->search_text_group); g_clear_object (&self->search_text_group);
G_OBJECT_CLASS (gtk_shortcuts_window_parent_class)->finalize (object); G_OBJECT_CLASS (gtk_shortcuts_window_parent_class)->finalize (object);
} }
@ -661,16 +643,15 @@ static void
gtk_shortcuts_window_dispose (GObject *object) gtk_shortcuts_window_dispose (GObject *object)
{ {
GtkShortcutsWindow *self = (GtkShortcutsWindow *)object; GtkShortcutsWindow *self = (GtkShortcutsWindow *)object;
GtkShortcutsWindowPrivate *priv = gtk_shortcuts_window_get_instance_private (self);
if (priv->stack) if (self->stack)
g_signal_handlers_disconnect_by_func (priv->stack, G_CALLBACK (update_title_stack), self); g_signal_handlers_disconnect_by_func (self->stack, G_CALLBACK (update_title_stack), self);
gtk_shortcuts_window_set_window (self, NULL); gtk_shortcuts_window_set_window (self, NULL);
priv->stack = NULL; self->stack = NULL;
priv->search_bar = NULL; self->search_bar = NULL;
priv->main_box = NULL; self->main_box = NULL;
G_OBJECT_CLASS (gtk_shortcuts_window_parent_class)->dispose (object); G_OBJECT_CLASS (gtk_shortcuts_window_parent_class)->dispose (object);
} }
@ -682,19 +663,18 @@ gtk_shortcuts_window_get_property (GObject *object,
GParamSpec *pspec) GParamSpec *pspec)
{ {
GtkShortcutsWindow *self = (GtkShortcutsWindow *)object; GtkShortcutsWindow *self = (GtkShortcutsWindow *)object;
GtkShortcutsWindowPrivate *priv = gtk_shortcuts_window_get_instance_private (self);
switch (prop_id) switch (prop_id)
{ {
case PROP_SECTION_NAME: case PROP_SECTION_NAME:
{ {
GtkWidget *child = gtk_stack_get_visible_child (priv->stack); GtkWidget *child = gtk_stack_get_visible_child (self->stack);
if (child != NULL) if (child != NULL)
{ {
char *name = NULL; char *name = NULL;
g_object_get (gtk_stack_get_page (priv->stack, child), g_object_get (gtk_stack_get_page (self->stack, child),
"name", &name, "name", &name,
NULL); NULL);
g_value_take_string (value, name); g_value_take_string (value, name);
@ -703,7 +683,7 @@ gtk_shortcuts_window_get_property (GObject *object,
break; break;
case PROP_VIEW_NAME: case PROP_VIEW_NAME:
g_value_set_string (value, priv->view_name); g_value_set_string (value, self->view_name);
break; break;
default: default:
@ -738,10 +718,9 @@ static void
gtk_shortcuts_window_unmap (GtkWidget *widget) gtk_shortcuts_window_unmap (GtkWidget *widget)
{ {
GtkShortcutsWindow *self = (GtkShortcutsWindow *)widget; GtkShortcutsWindow *self = (GtkShortcutsWindow *)widget;
GtkShortcutsWindowPrivate *priv = gtk_shortcuts_window_get_instance_private (self);
gtk_search_bar_set_search_mode (priv->search_bar, FALSE); gtk_search_bar_set_search_mode (self->search_bar, FALSE);
gtk_editable_set_text (GTK_EDITABLE (priv->search_entry), ""); gtk_editable_set_text (GTK_EDITABLE (self->search_entry), "");
GTK_WIDGET_CLASS (gtk_shortcuts_window_parent_class)->unmap (widget); GTK_WIDGET_CLASS (gtk_shortcuts_window_parent_class)->unmap (widget);
} }
@ -844,7 +823,6 @@ gtk_shortcuts_window_class_init (GtkShortcutsWindowClass *klass)
static void static void
gtk_shortcuts_window_init (GtkShortcutsWindow *self) gtk_shortcuts_window_init (GtkShortcutsWindow *self)
{ {
GtkShortcutsWindowPrivate *priv = gtk_shortcuts_window_get_instance_private (self);
GtkWidget *search_button; GtkWidget *search_button;
GtkBox *box; GtkBox *box;
GtkWidget *scroller; GtkWidget *scroller;
@ -854,91 +832,91 @@ gtk_shortcuts_window_init (GtkShortcutsWindow *self)
gtk_window_set_resizable (GTK_WINDOW (self), FALSE); gtk_window_set_resizable (GTK_WINDOW (self), FALSE);
priv->keywords = g_hash_table_new_full (NULL, NULL, NULL, g_free); self->keywords = g_hash_table_new_full (NULL, NULL, NULL, g_free);
priv->search_items_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); self->search_items_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
priv->search_text_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); self->search_text_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
priv->search_image_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); self->search_image_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
priv->header_bar = GTK_HEADER_BAR (gtk_header_bar_new ()); self->header_bar = GTK_HEADER_BAR (gtk_header_bar_new ());
gtk_window_set_titlebar (GTK_WINDOW (self), GTK_WIDGET (priv->header_bar)); gtk_window_set_titlebar (GTK_WINDOW (self), GTK_WIDGET (self->header_bar));
search_button = g_object_new (GTK_TYPE_TOGGLE_BUTTON, search_button = g_object_new (GTK_TYPE_TOGGLE_BUTTON,
"icon-name", "edit-find-symbolic", "icon-name", "edit-find-symbolic",
NULL); NULL);
gtk_header_bar_pack_start (GTK_HEADER_BAR (priv->header_bar), search_button); gtk_header_bar_pack_start (GTK_HEADER_BAR (self->header_bar), search_button);
priv->main_box = g_object_new (GTK_TYPE_BOX, self->main_box = g_object_new (GTK_TYPE_BOX,
"orientation", GTK_ORIENTATION_VERTICAL, "orientation", GTK_ORIENTATION_VERTICAL,
NULL); NULL);
gtk_window_set_child (GTK_WINDOW (self), priv->main_box); gtk_window_set_child (GTK_WINDOW (self), self->main_box);
priv->search_bar = g_object_new (GTK_TYPE_SEARCH_BAR, NULL); self->search_bar = g_object_new (GTK_TYPE_SEARCH_BAR, NULL);
g_object_bind_property (priv->search_bar, "search-mode-enabled", g_object_bind_property (self->search_bar, "search-mode-enabled",
search_button, "active", search_button, "active",
G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL); G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
gtk_box_append (GTK_BOX (priv->main_box), GTK_WIDGET (priv->search_bar)); gtk_box_append (GTK_BOX (self->main_box), GTK_WIDGET (self->search_bar));
gtk_search_bar_set_key_capture_widget (GTK_SEARCH_BAR (priv->search_bar), gtk_search_bar_set_key_capture_widget (GTK_SEARCH_BAR (self->search_bar),
GTK_WIDGET (self)); GTK_WIDGET (self));
priv->stack = g_object_new (GTK_TYPE_STACK, self->stack = g_object_new (GTK_TYPE_STACK,
"hexpand", TRUE, "hexpand", TRUE,
"vexpand", TRUE, "vexpand", TRUE,
"hhomogeneous", TRUE, "hhomogeneous", TRUE,
"vhomogeneous", TRUE, "vhomogeneous", TRUE,
"transition-type", GTK_STACK_TRANSITION_TYPE_CROSSFADE, "transition-type", GTK_STACK_TRANSITION_TYPE_CROSSFADE,
NULL); NULL);
gtk_box_append (GTK_BOX (priv->main_box), GTK_WIDGET (priv->stack)); gtk_box_append (GTK_BOX (self->main_box), GTK_WIDGET (self->stack));
priv->title_stack = g_object_new (GTK_TYPE_STACK, self->title_stack = g_object_new (GTK_TYPE_STACK,
NULL); NULL);
gtk_header_bar_set_title_widget (priv->header_bar, GTK_WIDGET (priv->title_stack)); gtk_header_bar_set_title_widget (self->header_bar, GTK_WIDGET (self->title_stack));
/* Translators: This is the window title for the shortcuts window in normal mode */ /* Translators: This is the window title for the shortcuts window in normal mode */
label = gtk_label_new (_("Shortcuts")); label = gtk_label_new (_("Shortcuts"));
gtk_widget_add_css_class (label, "title"); gtk_widget_add_css_class (label, "title");
gtk_stack_add_named (priv->title_stack, label, "title"); gtk_stack_add_named (self->title_stack, label, "title");
/* Translators: This is the window title for the shortcuts window in search mode */ /* Translators: This is the window title for the shortcuts window in search mode */
label = gtk_label_new (_("Search Results")); label = gtk_label_new (_("Search Results"));
gtk_widget_add_css_class (label, "title"); gtk_widget_add_css_class (label, "title");
gtk_stack_add_named (priv->title_stack, label, "search"); gtk_stack_add_named (self->title_stack, label, "search");
priv->menu_button = g_object_new (GTK_TYPE_MENU_BUTTON, self->menu_button = g_object_new (GTK_TYPE_MENU_BUTTON,
"focus-on-click", FALSE, "focus-on-click", FALSE,
NULL); NULL);
gtk_widget_add_css_class (GTK_WIDGET (priv->menu_button), "flat"); gtk_widget_add_css_class (GTK_WIDGET (self->menu_button), "flat");
gtk_stack_add_named (priv->title_stack, GTK_WIDGET (priv->menu_button), "sections"); gtk_stack_add_named (self->title_stack, GTK_WIDGET (self->menu_button), "sections");
priv->popover = g_object_new (GTK_TYPE_POPOVER, self->popover = g_object_new (GTK_TYPE_POPOVER,
"position", GTK_POS_BOTTOM, "position", GTK_POS_BOTTOM,
NULL); NULL);
gtk_menu_button_set_popover (priv->menu_button, GTK_WIDGET (priv->popover)); gtk_menu_button_set_popover (self->menu_button, GTK_WIDGET (self->popover));
priv->list_box = g_object_new (GTK_TYPE_LIST_BOX, self->list_box = g_object_new (GTK_TYPE_LIST_BOX,
"selection-mode", GTK_SELECTION_NONE, "selection-mode", GTK_SELECTION_NONE,
NULL); NULL);
g_signal_connect_object (priv->list_box, g_signal_connect_object (self->list_box,
"row-activated", "row-activated",
G_CALLBACK (gtk_shortcuts_window__list_box__row_activated), G_CALLBACK (gtk_shortcuts_window__list_box__row_activated),
self, self,
G_CONNECT_SWAPPED); G_CONNECT_SWAPPED);
gtk_popover_set_child (GTK_POPOVER (priv->popover), GTK_WIDGET (priv->list_box)); gtk_popover_set_child (GTK_POPOVER (self->popover), GTK_WIDGET (self->list_box));
priv->search_entry = GTK_SEARCH_ENTRY (gtk_search_entry_new ()); self->search_entry = GTK_SEARCH_ENTRY (gtk_search_entry_new ());
gtk_search_bar_set_child (GTK_SEARCH_BAR (priv->search_bar), GTK_WIDGET (priv->search_entry)); gtk_search_bar_set_child (GTK_SEARCH_BAR (self->search_bar), GTK_WIDGET (self->search_entry));
g_object_set (priv->search_entry, g_object_set (self->search_entry,
/* Translators: This is placeholder text for the search entry in the shortcuts window */ /* Translators: This is placeholder text for the search entry in the shortcuts window */
"placeholder-text", _("Search Shortcuts"), "placeholder-text", _("Search Shortcuts"),
"width-chars", 40, "width-chars", 40,
NULL); NULL);
g_signal_connect_object (priv->search_entry, g_signal_connect_object (self->search_entry,
"search-changed", "search-changed",
G_CALLBACK (gtk_shortcuts_window__entry__changed), G_CALLBACK (gtk_shortcuts_window__entry__changed),
self, self,
G_CONNECT_SWAPPED); G_CONNECT_SWAPPED);
g_signal_connect_object (priv->search_bar, g_signal_connect_object (self->search_bar,
"notify::search-mode-enabled", "notify::search-mode-enabled",
G_CALLBACK (gtk_shortcuts_window__search_mode__changed), G_CALLBACK (gtk_shortcuts_window__search_mode__changed),
self, self,
@ -951,21 +929,21 @@ gtk_shortcuts_window_init (GtkShortcutsWindow *self)
NULL); NULL);
gtk_widget_add_css_class (GTK_WIDGET (box), "shortcuts-search-results"); gtk_widget_add_css_class (GTK_WIDGET (box), "shortcuts-search-results");
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (scroller), GTK_WIDGET (box)); gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (scroller), GTK_WIDGET (box));
gtk_stack_add_named (priv->stack, scroller, "internal-search"); gtk_stack_add_named (self->stack, scroller, "internal-search");
priv->search_shortcuts = g_object_new (GTK_TYPE_BOX, self->search_shortcuts = g_object_new (GTK_TYPE_BOX,
"halign", GTK_ALIGN_CENTER, "halign", GTK_ALIGN_CENTER,
"spacing", 6, "spacing", 6,
"orientation", GTK_ORIENTATION_VERTICAL, "orientation", GTK_ORIENTATION_VERTICAL,
NULL); NULL);
gtk_box_append (GTK_BOX (box), GTK_WIDGET (priv->search_shortcuts)); gtk_box_append (GTK_BOX (box), GTK_WIDGET (self->search_shortcuts));
priv->search_gestures = g_object_new (GTK_TYPE_BOX, self->search_gestures = g_object_new (GTK_TYPE_BOX,
"halign", GTK_ALIGN_CENTER, "halign", GTK_ALIGN_CENTER,
"spacing", 6, "spacing", 6,
"orientation", GTK_ORIENTATION_VERTICAL, "orientation", GTK_ORIENTATION_VERTICAL,
NULL); NULL);
gtk_box_append (GTK_BOX (box), GTK_WIDGET (priv->search_gestures)); gtk_box_append (GTK_BOX (box), GTK_WIDGET (self->search_gestures));
empty = g_object_new (GTK_TYPE_GRID, empty = g_object_new (GTK_TYPE_GRID,
"row-spacing", 12, "row-spacing", 12,
@ -999,9 +977,9 @@ gtk_shortcuts_window_init (GtkShortcutsWindow *self)
NULL); NULL);
gtk_grid_attach (GTK_GRID (empty), label, 0, 2, 1, 1); gtk_grid_attach (GTK_GRID (empty), label, 0, 2, 1, 1);
gtk_stack_add_named (priv->stack, empty, "no-search-results"); gtk_stack_add_named (self->stack, empty, "no-search-results");
g_signal_connect_object (priv->stack, "notify::visible-child", g_signal_connect_object (self->stack, "notify::visible-child",
G_CALLBACK (update_title_stack), self, G_CONNECT_SWAPPED); G_CALLBACK (update_title_stack), self, G_CONNECT_SWAPPED);
} }

View File

@ -32,14 +32,7 @@ G_BEGIN_DECLS
#define GTK_IS_SHORTCUTS_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_SHORTCUTS_WINDOW)) #define GTK_IS_SHORTCUTS_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_SHORTCUTS_WINDOW))
typedef struct _GtkShortcutsWindow GtkShortcutsWindow; typedef struct _GtkShortcutsWindow GtkShortcutsWindow;
typedef struct _GtkShortcutsWindowClass GtkShortcutsWindowClass;
struct _GtkShortcutsWindow
{
GtkWindow window;
};
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
GType gtk_shortcuts_window_get_type (void) G_GNUC_CONST; GType gtk_shortcuts_window_get_type (void) G_GNUC_CONST;