[libegg/spread-table-dnd: 3/78] Make EggSpreadTable cooperate better with subclasses.
- From: Tristan Van Berkom <tvb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libegg/spread-table-dnd: 3/78] Make EggSpreadTable cooperate better with subclasses.
- Date: Sun, 10 Apr 2011 06:59:51 +0000 (UTC)
commit e38f47172944ac09837317e665d3c6588aab247f
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date: Fri Mar 11 00:09:16 2011 +0900
Make EggSpreadTable cooperate better with subclasses.
o Chain up in ->size_allocate() in case a subclass uses a GdkWindow
o Create ->insert_child() vfunc so that subclasses can play a role
both when adding and removing children
libegg/spreadtable/eggspreadtable.c | 46 ++++++++++++++++++++++++----------
libegg/spreadtable/eggspreadtable.h | 4 +++
2 files changed, 36 insertions(+), 14 deletions(-)
---
diff --git a/libegg/spreadtable/eggspreadtable.c b/libegg/spreadtable/eggspreadtable.c
index c5dbbd1..6f191c8 100644
--- a/libegg/spreadtable/eggspreadtable.c
+++ b/libegg/spreadtable/eggspreadtable.c
@@ -1,5 +1,5 @@
/* gtkspreadtable.c
- * Copyright (C) 2007-2010 Openismus GmbH
+ * Copyright (C) 2010 Openismus GmbH
*
* Authors:
* Tristan Van Berkom <tristanvb openismus com>
@@ -71,7 +71,6 @@ static void egg_spread_table_set_property (GObject *object,
GParamSpec *pspec);
/* GtkWidgetClass */
-
static GtkSizeRequestMode egg_spread_table_get_request_mode (GtkWidget *widget);
static void egg_spread_table_get_width (GtkWidget *widget,
gint *minimum_size,
@@ -104,6 +103,11 @@ static void egg_spread_table_forall (GtkContainer *containe
static GType egg_spread_table_child_type (GtkContainer *container);
+/* EggSpreadTableClass */
+static void egg_spread_table_real_insert_child (EggSpreadTable *table,
+ GtkWidget *child,
+ gint index);
+
G_DEFINE_TYPE_WITH_CODE (EggSpreadTable, egg_spread_table, GTK_TYPE_CONTAINER,
G_IMPLEMENT_INTERFACE (GTK_TYPE_ORIENTABLE, NULL))
@@ -143,6 +147,8 @@ egg_spread_table_class_init (EggSpreadTableClass *class)
container_class->forall = egg_spread_table_forall;
container_class->child_type = egg_spread_table_child_type;
+ class->insert_child = egg_spread_table_real_insert_child;
+
gtk_container_class_handle_border_width (container_class);
/* GObjectClass properties */
@@ -781,7 +787,7 @@ egg_spread_table_size_allocate (GtkWidget *widget,
gint item_spacing;
GtkOrientation opposite_orientation;
- gtk_widget_set_allocation (widget, allocation);
+ GTK_WIDGET_CLASS (egg_spread_table_parent_class)->size_allocate (widget, allocation);
if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
full_thickness = allocation->height;
@@ -884,6 +890,28 @@ egg_spread_table_child_type (G_GNUC_UNUSED GtkContainer *container)
return GTK_TYPE_WIDGET;
}
+
+/*****************************************************
+ * EggSpreadTableClass *
+ *****************************************************/
+static void
+egg_spread_table_real_insert_child (EggSpreadTable *table,
+ GtkWidget *child,
+ gint index)
+{
+ EggSpreadTablePrivate *priv;
+ GList *list;
+
+ priv = table->priv;
+
+ list = g_list_find (priv->children, child);
+ g_return_if_fail (list == NULL);
+
+ priv->children = g_list_insert (priv->children, child, index);
+
+ gtk_widget_set_parent (child, GTK_WIDGET (table));
+}
+
/*****************************************************
* API *
*****************************************************/
@@ -920,20 +948,10 @@ egg_spread_table_insert_child (EggSpreadTable *table,
GtkWidget *child,
gint index)
{
- EggSpreadTablePrivate *priv;
- GList *list;
-
g_return_if_fail (EGG_IS_SPREAD_TABLE (table));
g_return_if_fail (GTK_IS_WIDGET (child));
- priv = table->priv;
-
- list = g_list_find (priv->children, child);
- g_return_if_fail (list == NULL);
-
- priv->children = g_list_insert (priv->children, child, index);
-
- gtk_widget_set_parent (child, GTK_WIDGET (table));
+ EGG_SPREAD_TABLE_GET_CLASS (table)->insert_child (table, child, index);
}
diff --git a/libegg/spreadtable/eggspreadtable.h b/libegg/spreadtable/eggspreadtable.h
index 7531a80..50fa8fd 100644
--- a/libegg/spreadtable/eggspreadtable.h
+++ b/libegg/spreadtable/eggspreadtable.h
@@ -51,6 +51,10 @@ struct _EggSpreadTable
struct _EggSpreadTableClass
{
GtkContainerClass parent_class;
+
+ void ( *insert_child) (EggSpreadTable *table,
+ GtkWidget *child,
+ gint index);
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]