Import MxBoxLayout, MxBoxLayoutChild

https://bugzilla.gnome.org/show_bug.cgi?id=591245
This commit is contained in:
Owen W. Taylor 2009-09-10 01:42:25 -04:00
parent c1f91def74
commit 8b6962f3bf
5 changed files with 1412 additions and 0 deletions

View File

@ -67,6 +67,8 @@ st-enum-types.c: stamp-st-enum-types.h st/st-enum-types.c.in
st_source_h = \
st/st-adjustment.h \
st/st-bin.h \
st/st-box-layout.h \
st/st-box-layout-child.h \
st/st-button.h \
st/st-private.h \
st/st-stylable.h \
@ -86,6 +88,8 @@ st_source_h = \
st_source_c = \
st/st-adjustment.c \
st/st-bin.c \
st/st-box-layout.c \
st/st-box-layout-child.c \
st/st-button.c \
st/st-private.c \
st/st-scrollable.c \

View File

@ -0,0 +1,189 @@
/*
* st-box-layout-child.c: box layout child actor
*
* Copyright 2009 Intel Corporation
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU Lesser General Public License,
* version 2.1, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
* more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
*
* Written by: Thomas Wood <thomas.wood@intel.com>
*/
/**
* SECTION:st-box-layout-child
* @short_description: meta data associated with a #StBoxLayout child.
*
* #StBoxLayoutChild is a #ClutterChildMeta implementation that stores the
* child properties for children inside a #StBoxLayout.
*/
#include "st-box-layout-child.h"
#include "st-private.h"
G_DEFINE_TYPE (StBoxLayoutChild, st_box_layout_child, CLUTTER_TYPE_CHILD_META)
#define BOX_LAYOUT_CHILD_PRIVATE(o) \
(G_TYPE_INSTANCE_GET_PRIVATE ((o), ST_TYPE_BOX_LAYOUT_CHILD, StBoxLayoutChildPrivate))
enum
{
PROP_0,
PROP_EXPAND,
PROP_X_FILL,
PROP_Y_FILL,
PROP_X_ALIGN,
PROP_Y_ALIGN
};
static void
st_box_layout_child_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
StBoxLayoutChild *child = ST_BOX_LAYOUT_CHILD (object);
switch (property_id)
{
case PROP_EXPAND:
g_value_set_boolean (value, child->expand);
break;
case PROP_X_FILL:
g_value_set_boolean (value, child->x_fill);
break;
case PROP_Y_FILL:
g_value_set_boolean (value, child->y_fill);
break;
case PROP_X_ALIGN:
g_value_set_enum (value, child->x_align);
break;
case PROP_Y_ALIGN:
g_value_set_enum (value, child->y_align);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
}
static void
st_box_layout_child_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
StBoxLayoutChild *child = ST_BOX_LAYOUT_CHILD (object);
StBoxLayout *box = ST_BOX_LAYOUT (CLUTTER_CHILD_META (object)->container);
switch (property_id)
{
case PROP_EXPAND:
child->expand = g_value_get_boolean (value);
break;
case PROP_X_FILL:
child->x_fill = g_value_get_boolean (value);
break;
case PROP_Y_FILL:
child->y_fill = g_value_get_boolean (value);
break;
case PROP_X_ALIGN:
child->x_align = g_value_get_enum (value);
break;
case PROP_Y_ALIGN:
child->y_align = g_value_get_enum (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
clutter_actor_queue_relayout ((ClutterActor*) box);
}
static void
st_box_layout_child_dispose (GObject *object)
{
G_OBJECT_CLASS (st_box_layout_child_parent_class)->dispose (object);
}
static void
st_box_layout_child_finalize (GObject *object)
{
G_OBJECT_CLASS (st_box_layout_child_parent_class)->finalize (object);
}
static void
st_box_layout_child_class_init (StBoxLayoutChildClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GParamSpec *pspec;
object_class->get_property = st_box_layout_child_get_property;
object_class->set_property = st_box_layout_child_set_property;
object_class->dispose = st_box_layout_child_dispose;
object_class->finalize = st_box_layout_child_finalize;
pspec = g_param_spec_boolean ("expand", "Expand",
"Allocate the child extra space",
FALSE,
ST_PARAM_READWRITE);
g_object_class_install_property (object_class, PROP_EXPAND, pspec);
pspec = g_param_spec_boolean ("x-fill", "x-fill",
"Whether the child should receive priority "
"when the container is allocating spare space "
"on the horizontal axis",
TRUE,
ST_PARAM_READWRITE);
g_object_class_install_property (object_class, PROP_X_FILL, pspec);
pspec = g_param_spec_boolean ("y-fill", "y-fill",
"Whether the child should receive priority "
"when the container is allocating spare space "
"on the vertical axis",
TRUE,
ST_PARAM_READWRITE);
g_object_class_install_property (object_class, PROP_Y_FILL, pspec);
pspec = g_param_spec_enum ("x-align",
"X Alignment",
"X alignment of the widget within the cell",
ST_TYPE_ALIGN,
ST_ALIGN_MIDDLE,
ST_PARAM_READWRITE);
g_object_class_install_property (object_class, PROP_X_ALIGN, pspec);
pspec = g_param_spec_enum ("y-align",
"Y Alignment",
"Y alignment of the widget within the cell",
ST_TYPE_ALIGN,
ST_ALIGN_MIDDLE,
ST_PARAM_READWRITE);
g_object_class_install_property (object_class, PROP_Y_ALIGN, pspec);
}
static void
st_box_layout_child_init (StBoxLayoutChild *self)
{
self->expand = FALSE;
self->x_fill = TRUE;
self->y_fill = TRUE;
self->x_align = ST_ALIGN_MIDDLE;
self->y_align = ST_ALIGN_MIDDLE;
}

View File

@ -0,0 +1,84 @@
/*
* st-box-layout-child.h: box layout child actor
*
* Copyright 2009 Intel Corporation
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU Lesser General Public License,
* version 2.1, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
* more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
*
* Written by: Thomas Wood <thomas.wood@intel.com>
*/
#ifndef _ST_BOX_LAYOUT_CHILD_H
#define _ST_BOX_LAYOUT_CHILD_H
#include <clutter/clutter.h>
#include "st-enum-types.h"
#include "st-box-layout.h"
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))
typedef struct _StBoxLayoutChild StBoxLayoutChild;
typedef struct _StBoxLayoutChildClass StBoxLayoutChildClass;
typedef struct _StBoxLayoutChildPrivate StBoxLayoutChildPrivate;
/**
* StBoxLayoutChild:
*
* The contents of this structure are private and should only be accessed
* through the public API.
*/
struct _StBoxLayoutChild
{
/*< private >*/
ClutterChildMeta parent;
gboolean expand;
gboolean x_fill : 1;
gboolean y_fill : 1;
StAlign x_align;
StAlign y_align;
};
struct _StBoxLayoutChildClass
{
ClutterChildMetaClass parent_class;
};
GType st_box_layout_child_get_type (void);
G_END_DECLS
#endif /* _ST_BOX_LAYOUT_CHILD_H */

1038
src/st/st-box-layout.c Normal file

File diff suppressed because it is too large Load Diff

97
src/st/st-box-layout.h Normal file
View File

@ -0,0 +1,97 @@
/*
* st-box-layout.h: box layout actor
*
* Copyright 2009 Intel Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU Lesser General Public License,
* version 2.1, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
* more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
*
* Written by: Thomas Wood <thomas.wood@intel.com>
*
*/
#if !defined(ST_H_INSIDE) && !defined(ST_COMPILATION)
#error "Only <st/st.h> can be included directly.h"
#endif
#ifndef _ST_BOX_LAYOUT_H
#define _ST_BOX_LAYOUT_H
#include <st/st-widget.h>
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))
typedef struct _StBoxLayout StBoxLayout;
typedef struct _StBoxLayoutClass StBoxLayoutClass;
typedef struct _StBoxLayoutPrivate StBoxLayoutPrivate;
/**
* StBoxLayout:
*
* The contents of this structure are private and should only be accessed
* through the public API.
*/
struct _StBoxLayout
{
/*< private >*/
StWidget parent;
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,
gboolean vertical);
gboolean st_box_layout_get_vertical (StBoxLayout *box);
void st_box_layout_set_pack_start (StBoxLayout *box,
gboolean pack_start);
gboolean st_box_layout_get_pack_start (StBoxLayout *box);
void st_box_layout_set_spacing (StBoxLayout *box,
guint spacing);
guint st_box_layout_get_spacing (StBoxLayout *box);
G_END_DECLS
#endif /* _ST_BOX_LAYOUT_H */