diff options
author | Tristan Van Berkom <tristan.van.berkom@gmail.com> | 2010-11-22 16:27:52 +0900 |
---|---|---|
committer | Tristan Van Berkom <tristan.van.berkom@gmail.com> | 2010-11-29 13:03:41 +0900 |
commit | cad41833a257b2fb6b6681479650e5a20b331fdc (patch) | |
tree | 3c352f3e4796e3eb72333705066da2ab9f86ac79 /gtk/gtkcelllayout.c | |
parent | d3aed12b65dab6365c664104477280be74117287 (diff) | |
download | gtk+-cad41833a257b2fb6b6681479650e5a20b331fdc.tar.gz |
Allow minimal implementation of GtkCellLayout
Since GtkCellArea delegate does all the work, cell layout widgets
who use a GtkCellArea internally only have to implement the _get_area()
method, this just reduces code to forward the calls over the the internal
cell area.
Diffstat (limited to 'gtk/gtkcelllayout.c')
-rw-r--r-- | gtk/gtkcelllayout.c | 149 |
1 files changed, 126 insertions, 23 deletions
diff --git a/gtk/gtkcelllayout.c b/gtk/gtkcelllayout.c index b13f0902a6..f25864bad6 100644 --- a/gtk/gtkcelllayout.c +++ b/gtk/gtkcelllayout.c @@ -54,12 +54,23 @@ gtk_cell_layout_pack_start (GtkCellLayout *cell_layout, GtkCellRenderer *cell, gboolean expand) { + GtkCellLayoutIface *iface; + GtkCellArea *area; + g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout)); g_return_if_fail (GTK_IS_CELL_RENDERER (cell)); - (* GTK_CELL_LAYOUT_GET_IFACE (cell_layout)->pack_start) (cell_layout, - cell, - expand); + iface = GTK_CELL_LAYOUT_GET_IFACE (cell_layout); + + if (iface->pack_start) + iface->pack_start (cell_layout, cell, expand); + else + { + area = iface->get_area (cell_layout); + + if (area) + gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (area), cell, expand); + } } /** @@ -81,12 +92,23 @@ gtk_cell_layout_pack_end (GtkCellLayout *cell_layout, GtkCellRenderer *cell, gboolean expand) { + GtkCellLayoutIface *iface; + GtkCellArea *area; + g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout)); g_return_if_fail (GTK_IS_CELL_RENDERER (cell)); - (* GTK_CELL_LAYOUT_GET_IFACE (cell_layout)->pack_end) (cell_layout, - cell, - expand); + iface = GTK_CELL_LAYOUT_GET_IFACE (cell_layout); + + if (iface->pack_end) + iface->pack_end (cell_layout, cell, expand); + else + { + area = iface->get_area (cell_layout); + + if (area) + gtk_cell_layout_pack_end (GTK_CELL_LAYOUT (area), cell, expand); + } } /** @@ -101,9 +123,22 @@ gtk_cell_layout_pack_end (GtkCellLayout *cell_layout, void gtk_cell_layout_clear (GtkCellLayout *cell_layout) { + GtkCellLayoutIface *iface; + GtkCellArea *area; + g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout)); - (* GTK_CELL_LAYOUT_GET_IFACE (cell_layout)->clear) (cell_layout); + iface = GTK_CELL_LAYOUT_GET_IFACE (cell_layout); + + if (iface->clear) + iface->clear (cell_layout); + else + { + area = iface->get_area (cell_layout); + + if (area) + gtk_cell_layout_clear (GTK_CELL_LAYOUT (area)); + } } static void @@ -114,17 +149,28 @@ gtk_cell_layout_set_attributesv (GtkCellLayout *cell_layout, gchar *attribute; gint column; GtkCellLayoutIface *iface; + GtkCellArea *area; attribute = va_arg (args, gchar *); iface = GTK_CELL_LAYOUT_GET_IFACE (cell_layout); - (* iface->clear_attributes) (cell_layout, cell); + if (iface->get_area) + area = iface->get_area (cell_layout); + + if (iface->clear_attributes) + iface->clear_attributes (cell_layout, cell); + else if (area) + gtk_cell_layout_clear_attributes (GTK_CELL_LAYOUT (area), cell); while (attribute != NULL) { column = va_arg (args, gint); - (* iface->add_attribute) (cell_layout, cell, attribute, column); + if (iface->add_attribute) + iface->add_attribute (cell_layout, cell, attribute, column); + else if (area) + gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (area), cell, attribute, column); + attribute = va_arg (args, gchar *); } } @@ -178,15 +224,28 @@ gtk_cell_layout_add_attribute (GtkCellLayout *cell_layout, const gchar *attribute, gint column) { + GtkCellLayoutIface *iface; + GtkCellArea *area; + g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout)); g_return_if_fail (GTK_IS_CELL_RENDERER (cell)); g_return_if_fail (attribute != NULL); g_return_if_fail (column >= 0); - (* GTK_CELL_LAYOUT_GET_IFACE (cell_layout)->add_attribute) (cell_layout, - cell, - attribute, - column); + iface = GTK_CELL_LAYOUT_GET_IFACE (cell_layout); + + if (iface->add_attribute) + iface->add_attribute (cell_layout, + cell, + attribute, + column); + else + { + area = iface->get_area (cell_layout); + + if (area) + gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (area), cell, attribute, column); + } } /** @@ -211,14 +270,27 @@ gtk_cell_layout_set_cell_data_func (GtkCellLayout *cell_layout, gpointer func_data, GDestroyNotify destroy) { + GtkCellLayoutIface *iface; + GtkCellArea *area; + g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout)); g_return_if_fail (GTK_IS_CELL_RENDERER (cell)); - (* GTK_CELL_LAYOUT_GET_IFACE (cell_layout)->set_cell_data_func) (cell_layout, - cell, - func, - func_data, - destroy); + iface = GTK_CELL_LAYOUT_GET_IFACE (cell_layout); + + if (iface->set_cell_data_func) + iface->set_cell_data_func (cell_layout, + cell, + func, + func_data, + destroy); + else + { + area = iface->get_area (cell_layout); + + if (area) + gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (area), cell, func, func_data, destroy); + } } /** @@ -235,11 +307,23 @@ void gtk_cell_layout_clear_attributes (GtkCellLayout *cell_layout, GtkCellRenderer *cell) { + GtkCellLayoutIface *iface; + GtkCellArea *area; + g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout)); g_return_if_fail (GTK_IS_CELL_RENDERER (cell)); - (* GTK_CELL_LAYOUT_GET_IFACE (cell_layout)->clear_attributes) (cell_layout, - cell); + iface = GTK_CELL_LAYOUT_GET_IFACE (cell_layout); + + if (iface->clear_attributes) + iface->clear_attributes (cell_layout, cell); + else + { + area = iface->get_area (cell_layout); + + if (area) + gtk_cell_layout_clear_attributes (GTK_CELL_LAYOUT (area), cell); + } } /** @@ -258,12 +342,23 @@ gtk_cell_layout_reorder (GtkCellLayout *cell_layout, GtkCellRenderer *cell, gint position) { + GtkCellLayoutIface *iface; + GtkCellArea *area; + g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout)); g_return_if_fail (GTK_IS_CELL_RENDERER (cell)); - (* GTK_CELL_LAYOUT_GET_IFACE (cell_layout)->reorder) (cell_layout, - cell, - position); + iface = GTK_CELL_LAYOUT_GET_IFACE (cell_layout); + + if (iface->reorder) + iface->reorder (cell_layout, cell, position); + else + { + area = iface->get_area (cell_layout); + + if (area) + gtk_cell_layout_reorder (GTK_CELL_LAYOUT (area), cell, position); + } } /** @@ -282,12 +377,20 @@ GList * gtk_cell_layout_get_cells (GtkCellLayout *cell_layout) { GtkCellLayoutIface *iface; + GtkCellArea *area; g_return_val_if_fail (GTK_IS_CELL_LAYOUT (cell_layout), NULL); iface = GTK_CELL_LAYOUT_GET_IFACE (cell_layout); if (iface->get_cells) return iface->get_cells (cell_layout); + else + { + area = iface->get_area (cell_layout); + + if (area) + return gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (area)); + } return NULL; } |