* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
+#include "config.h"
#include "gtkaspectframe.h"
+#include "gtkprivate.h"
#include "gtkintl.h"
+#include "gtkalias.h"
enum {
PROP_0,
PROP_OBEY_CHILD
};
-static void gtk_aspect_frame_class_init (GtkAspectFrameClass *klass);
-static void gtk_aspect_frame_init (GtkAspectFrame *aspect_frame);
static void gtk_aspect_frame_set_property (GObject *object,
guint prop_id,
const GValue *value,
- GParamSpec *pspec,
- const gchar *trailer);
+ GParamSpec *pspec);
static void gtk_aspect_frame_get_property (GObject *object,
guint prop_id,
GValue *value,
- GParamSpec *pspec,
- const gchar *trailer);
+ GParamSpec *pspec);
static void gtk_aspect_frame_compute_child_allocation (GtkFrame *frame,
GtkAllocation *child_allocation);
#define MAX_RATIO 10000.0
#define MIN_RATIO 0.0001
-static GtkFrameClass *parent_class = NULL;
-
-GtkType
-gtk_aspect_frame_get_type (void)
-{
- static GtkType aspect_frame_type = 0;
-
- if (!aspect_frame_type)
- {
- static const GtkTypeInfo aspect_frame_info =
- {
- "GtkAspectFrame",
- sizeof (GtkAspectFrame),
- sizeof (GtkAspectFrameClass),
- (GtkClassInitFunc) gtk_aspect_frame_class_init,
- (GtkObjectInitFunc) gtk_aspect_frame_init,
- /* reserved_1 */ NULL,
- /* reserved_2 */ NULL,
- (GtkClassInitFunc) NULL,
- };
-
- aspect_frame_type = gtk_type_unique (GTK_TYPE_FRAME, &aspect_frame_info);
- }
-
- return aspect_frame_type;
-}
+G_DEFINE_TYPE (GtkAspectFrame, gtk_aspect_frame, GTK_TYPE_FRAME)
static void
gtk_aspect_frame_class_init (GtkAspectFrameClass *class)
{
GObjectClass *gobject_class;
- GtkObjectClass *object_class;
GtkFrameClass *frame_class;
- parent_class = gtk_type_class (GTK_TYPE_FRAME);
-
gobject_class = (GObjectClass*) class;
- object_class = (GtkObjectClass*) class;
frame_class = (GtkFrameClass*) class;
gobject_class->set_property = gtk_aspect_frame_set_property;
g_object_class_install_property (gobject_class,
PROP_XALIGN,
g_param_spec_float ("xalign",
- _("Horizontal Alignment"),
- _("X alignment of the child"),
+ P_("Horizontal Alignment"),
+ P_("X alignment of the child"),
0.0, 1.0, 0.5,
- G_PARAM_READABLE | G_PARAM_WRITABLE ));
+ GTK_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
PROP_YALIGN,
g_param_spec_float ("yalign",
- _("Vertical Alignment"),
- _("Y alignment of the child"),
+ P_("Vertical Alignment"),
+ P_("Y alignment of the child"),
0.0, 1.0, 0.5,
- G_PARAM_READABLE | G_PARAM_WRITABLE ));
+ GTK_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
PROP_RATIO,
g_param_spec_float ("ratio",
- _("Ratio"),
- _("Aspect ratio if obey_child is FALSE"),
- 0.0, 1.0, 0.5,
- G_PARAM_READABLE | G_PARAM_WRITABLE ));
+ P_("Ratio"),
+ P_("Aspect ratio if obey_child is FALSE"),
+ MIN_RATIO, MAX_RATIO, 1.0,
+ GTK_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
PROP_OBEY_CHILD,
- g_param_spec_boolean ("obey_child",
- _("Obey child"),
- _("Force aspect ratio to match that of the frame's child"),
+ g_param_spec_boolean ("obey-child",
+ P_("Obey child"),
+ P_("Force aspect ratio to match that of the frame's child"),
TRUE,
- G_PARAM_READABLE | G_PARAM_WRITABLE));
+ GTK_PARAM_READWRITE));
}
static void
aspect_frame->obey_child = TRUE;
}
-static void gtk_aspect_frame_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec,
- const gchar *trailer)
+static void
+gtk_aspect_frame_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
GtkAspectFrame *aspect_frame = GTK_ASPECT_FRAME (object);
}
}
-static void gtk_aspect_frame_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec,
- const gchar *trailer)
+static void
+gtk_aspect_frame_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
{
GtkAspectFrame *aspect_frame = GTK_ASPECT_FRAME (object);
{
GtkAspectFrame *aspect_frame;
- aspect_frame = gtk_type_new (gtk_aspect_frame_get_type ());
+ aspect_frame = g_object_new (GTK_TYPE_ASPECT_FRAME, NULL);
aspect_frame->xalign = CLAMP (xalign, 0.0, 1.0);
aspect_frame->yalign = CLAMP (yalign, 0.0, 1.0);
gfloat ratio,
gboolean obey_child)
{
- gboolean needs_resize = FALSE;
-
- g_return_if_fail (aspect_frame != NULL);
g_return_if_fail (GTK_IS_ASPECT_FRAME (aspect_frame));
xalign = CLAMP (xalign, 0.0, 1.0);
ratio = CLAMP (ratio, MIN_RATIO, MAX_RATIO);
obey_child = obey_child != FALSE;
- if (aspect_frame->xalign != xalign)
+ if ( (aspect_frame->xalign != xalign)
+ || (aspect_frame->yalign != yalign)
+ || (aspect_frame->ratio != ratio)
+ || (aspect_frame->obey_child != obey_child))
{
- aspect_frame->xalign = xalign;
- g_object_notify (G_OBJECT (aspect_frame), "xalign");
- needs_resize = TRUE;
- }
- if (aspect_frame->yalign != yalign)
- {
- aspect_frame->yalign = yalign;
- g_object_notify (G_OBJECT (aspect_frame), "yalign");
- needs_resize = TRUE;
- }
- if (aspect_frame->ratio != ratio)
- {
- aspect_frame->ratio = ratio;
- g_object_notify (G_OBJECT (aspect_frame), "ratio");
- needs_resize = TRUE;
- }
- if (aspect_frame->obey_child != obey_child)
- {
- aspect_frame->obey_child = obey_child;
- g_object_notify (G_OBJECT (aspect_frame), "obey_child");
- needs_resize = TRUE;
+ g_object_freeze_notify (G_OBJECT (aspect_frame));
+
+ if (aspect_frame->xalign != xalign)
+ {
+ aspect_frame->xalign = xalign;
+ g_object_notify (G_OBJECT (aspect_frame), "xalign");
+ }
+ if (aspect_frame->yalign != yalign)
+ {
+ aspect_frame->yalign = yalign;
+ g_object_notify (G_OBJECT (aspect_frame), "yalign");
+ }
+ if (aspect_frame->ratio != ratio)
+ {
+ aspect_frame->ratio = ratio;
+ g_object_notify (G_OBJECT (aspect_frame), "ratio");
+ }
+ if (aspect_frame->obey_child != obey_child)
+ {
+ aspect_frame->obey_child = obey_child;
+ g_object_notify (G_OBJECT (aspect_frame), "obey-child");
+ }
+ g_object_thaw_notify (G_OBJECT (aspect_frame));
+
+ gtk_widget_queue_resize (GTK_WIDGET (aspect_frame));
}
-
- if (needs_resize == TRUE)
- gtk_widget_queue_resize (GTK_WIDGET(aspect_frame));
}
static void
else
ratio = aspect_frame->ratio;
- parent_class->compute_child_allocation (frame, &full_allocation);
+ GTK_FRAME_CLASS (gtk_aspect_frame_parent_class)->compute_child_allocation (frame, &full_allocation);
if (ratio * full_allocation.height > full_allocation.width)
{
child_allocation->y = full_allocation.y + aspect_frame->yalign * (full_allocation.height - child_allocation->height);
}
else
- parent_class->compute_child_allocation (frame, child_allocation);
+ GTK_FRAME_CLASS (gtk_aspect_frame_parent_class)->compute_child_allocation (frame, child_allocation);
}
+
+#define __GTK_ASPECT_FRAME_C__
+#include "gtkaliasdef.c"