Import NbtkBoxLayout, NbtkBoxLayoutChild

https://bugzilla.gnome.org/show_bug.cgi?id=591245
This commit is contained in:
Colin Walters 2009-09-10 01:42:25 -04:00 committed by Owen W. Taylor
parent 60819b3a79
commit 6687054474
5 changed files with 1378 additions and 0 deletions

View File

@ -66,6 +66,8 @@ nbtk-enum-types.c: stamp-nbtk-enum-types.h nbtk/nbtk-enum-types.c.in
nbtk_source_h = \
nbtk/nbtk-adjustment.h \
nbtk/nbtk-bin.h \
nbtk/nbtk-box-layout.h \
nbtk/nbtk-box-layout-child.h \
nbtk/nbtk-button.h \
nbtk/nbtk-private.h \
nbtk/nbtk-scrollable.h \
@ -86,6 +88,8 @@ nbtk_source_h = \
nbtk_source_c = \
nbtk/nbtk-adjustment.c \
nbtk/nbtk-bin.c \
nbtk/nbtk-box-layout.c \
nbtk/nbtk-box-layout-child.c \
nbtk/nbtk-button.c \
nbtk/nbtk-private.c \
nbtk/nbtk-scrollable.c \

View File

@ -0,0 +1,176 @@
/*
* nbtk-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>
*/
#include "nbtk-box-layout-child.h"
#include "nbtk-private.h"
G_DEFINE_TYPE (NbtkBoxLayoutChild, nbtk_box_layout_child, CLUTTER_TYPE_CHILD_META)
#define BOX_LAYOUT_CHILD_PRIVATE(o) \
(G_TYPE_INSTANCE_GET_PRIVATE ((o), NBTK_TYPE_BOX_LAYOUT_CHILD, NbtkBoxLayoutChildPrivate))
enum
{
PROP_0,
PROP_EXPAND,
PROP_X_FILL,
PROP_Y_FILL,
PROP_X_ALIGN,
PROP_Y_ALIGN
};
static void
nbtk_box_layout_child_get_property (GObject *object, guint property_id,
GValue *value, GParamSpec *pspec)
{
NbtkBoxLayoutChild *child = NBTK_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
nbtk_box_layout_child_set_property (GObject *object, guint property_id,
const GValue *value, GParamSpec *pspec)
{
NbtkBoxLayoutChild *child = NBTK_BOX_LAYOUT_CHILD (object);
NbtkBoxLayout *box = NBTK_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
nbtk_box_layout_child_dispose (GObject *object)
{
G_OBJECT_CLASS (nbtk_box_layout_child_parent_class)->dispose (object);
}
static void
nbtk_box_layout_child_finalize (GObject *object)
{
G_OBJECT_CLASS (nbtk_box_layout_child_parent_class)->finalize (object);
}
static void
nbtk_box_layout_child_class_init (NbtkBoxLayoutChildClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GParamSpec *pspec;
object_class->get_property = nbtk_box_layout_child_get_property;
object_class->set_property = nbtk_box_layout_child_set_property;
object_class->dispose = nbtk_box_layout_child_dispose;
object_class->finalize = nbtk_box_layout_child_finalize;
pspec = g_param_spec_boolean ("expand", "Expand",
"Allocate the child extra space",
FALSE,
NBTK_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,
NBTK_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,
NBTK_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",
NBTK_TYPE_ALIGN,
NBTK_ALIGN_MIDDLE,
NBTK_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",
NBTK_TYPE_ALIGN,
NBTK_ALIGN_MIDDLE,
NBTK_PARAM_READWRITE);
g_object_class_install_property (object_class, PROP_Y_ALIGN, pspec);
}
static void
nbtk_box_layout_child_init (NbtkBoxLayoutChild *self)
{
self->expand = FALSE;
self->x_fill = TRUE;
self->y_fill = TRUE;
self->x_align = NBTK_ALIGN_CENTER;
self->y_align = NBTK_ALIGN_CENTER;
}

View File

@ -0,0 +1,84 @@
/*
* nbtk-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 _NBTK_BOX_LAYOUT_CHILD_H
#define _NBTK_BOX_LAYOUT_CHILD_H
#include <clutter/clutter.h>
#include "nbtk-enum-types.h"
#include "nbtk-box-layout.h"
G_BEGIN_DECLS
#define NBTK_TYPE_BOX_LAYOUT_CHILD nbtk_box_layout_child_get_type()
#define NBTK_BOX_LAYOUT_CHILD(obj) \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), \
NBTK_TYPE_BOX_LAYOUT_CHILD, NbtkBoxLayoutChild))
#define NBTK_BOX_LAYOUT_CHILD_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST ((klass), \
NBTK_TYPE_BOX_LAYOUT_CHILD, NbtkBoxLayoutChildClass))
#define NBTK_IS_BOX_LAYOUT_CHILD(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
NBTK_TYPE_BOX_LAYOUT_CHILD))
#define NBTK_IS_BOX_LAYOUT_CHILD_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), \
NBTK_TYPE_BOX_LAYOUT_CHILD))
#define NBTK_BOX_LAYOUT_CHILD_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), \
NBTK_TYPE_BOX_LAYOUT_CHILD, NbtkBoxLayoutChildClass))
typedef struct _NbtkBoxLayoutChild NbtkBoxLayoutChild;
typedef struct _NbtkBoxLayoutChildClass NbtkBoxLayoutChildClass;
typedef struct _NbtkBoxLayoutChildPrivate NbtkBoxLayoutChildPrivate;
/**
* NbtkBoxLayoutChild:
*
* The contents of this structure are private and should only be accessed
* through the public API.
*/
struct _NbtkBoxLayoutChild
{
/*< private >*/
ClutterChildMeta parent;
gboolean expand;
gboolean x_fill : 1;
gboolean y_fill : 1;
NbtkAlign x_align;
NbtkAlign y_align;
};
struct _NbtkBoxLayoutChildClass
{
ClutterChildMetaClass parent_class;
};
GType nbtk_box_layout_child_get_type (void);
G_END_DECLS
#endif /* _NBTK_BOX_LAYOUT_CHILD_H */

1023
src/nbtk/nbtk-box-layout.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,91 @@
/*
* nbtk-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>
*
*/
#ifndef _NBTK_BOX_LAYOUT_H
#define _NBTK_BOX_LAYOUT_H
#include <nbtk/nbtk-widget.h>
G_BEGIN_DECLS
#define NBTK_TYPE_BOX_LAYOUT nbtk_box_layout_get_type()
#define NBTK_BOX_LAYOUT(obj) \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), \
NBTK_TYPE_BOX_LAYOUT, NbtkBoxLayout))
#define NBTK_BOX_LAYOUT_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST ((klass), \
NBTK_TYPE_BOX_LAYOUT, NbtkBoxLayoutClass))
#define NBTK_IS_BOX_LAYOUT(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
NBTK_TYPE_BOX_LAYOUT))
#define NBTK_IS_BOX_LAYOUT_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), \
NBTK_TYPE_BOX_LAYOUT))
#define NBTK_BOX_LAYOUT_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), \
NBTK_TYPE_BOX_LAYOUT, NbtkBoxLayoutClass))
typedef struct _NbtkBoxLayout NbtkBoxLayout;
typedef struct _NbtkBoxLayoutClass NbtkBoxLayoutClass;
typedef struct _NbtkBoxLayoutPrivate NbtkBoxLayoutPrivate;
/**
* NbtkBoxLayout:
*
* The contents of this structure are private and should only be accessed
* through the public API.
*/
struct _NbtkBoxLayout
{
/*< private >*/
NbtkWidget parent;
NbtkBoxLayoutPrivate *priv;
};
struct _NbtkBoxLayoutClass
{
NbtkWidgetClass parent_class;
};
GType nbtk_box_layout_get_type (void);
NbtkWidget *nbtk_box_layout_new (void);
void nbtk_box_layout_set_vertical (NbtkBoxLayout *box, gboolean vertical);
gboolean nbtk_box_layout_get_vertical (NbtkBoxLayout *box);
void nbtk_box_layout_set_pack_start (NbtkBoxLayout *box, gboolean pack_start);
gboolean nbtk_box_layout_get_pack_start (NbtkBoxLayout *box);
void nbtk_box_layout_set_spacing (NbtkBoxLayout *box, guint spacing);
guint nbtk_box_layout_get_spacing (NbtkBoxLayout *box);
G_END_DECLS
#endif /* _NBTK_BOX_LAYOUT_H */