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.
This commit is contained in:
@ -54,12 +54,23 @@ gtk_cell_layout_pack_start (GtkCellLayout *cell_layout,
|
|||||||
GtkCellRenderer *cell,
|
GtkCellRenderer *cell,
|
||||||
gboolean expand)
|
gboolean expand)
|
||||||
{
|
{
|
||||||
|
GtkCellLayoutIface *iface;
|
||||||
|
GtkCellArea *area;
|
||||||
|
|
||||||
g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout));
|
g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout));
|
||||||
g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
|
g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
|
||||||
|
|
||||||
(* GTK_CELL_LAYOUT_GET_IFACE (cell_layout)->pack_start) (cell_layout,
|
iface = GTK_CELL_LAYOUT_GET_IFACE (cell_layout);
|
||||||
cell,
|
|
||||||
expand);
|
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,
|
GtkCellRenderer *cell,
|
||||||
gboolean expand)
|
gboolean expand)
|
||||||
{
|
{
|
||||||
|
GtkCellLayoutIface *iface;
|
||||||
|
GtkCellArea *area;
|
||||||
|
|
||||||
g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout));
|
g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout));
|
||||||
g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
|
g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
|
||||||
|
|
||||||
(* GTK_CELL_LAYOUT_GET_IFACE (cell_layout)->pack_end) (cell_layout,
|
iface = GTK_CELL_LAYOUT_GET_IFACE (cell_layout);
|
||||||
cell,
|
|
||||||
expand);
|
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
|
void
|
||||||
gtk_cell_layout_clear (GtkCellLayout *cell_layout)
|
gtk_cell_layout_clear (GtkCellLayout *cell_layout)
|
||||||
{
|
{
|
||||||
|
GtkCellLayoutIface *iface;
|
||||||
|
GtkCellArea *area;
|
||||||
|
|
||||||
g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout));
|
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
|
static void
|
||||||
@ -114,17 +149,28 @@ gtk_cell_layout_set_attributesv (GtkCellLayout *cell_layout,
|
|||||||
gchar *attribute;
|
gchar *attribute;
|
||||||
gint column;
|
gint column;
|
||||||
GtkCellLayoutIface *iface;
|
GtkCellLayoutIface *iface;
|
||||||
|
GtkCellArea *area;
|
||||||
|
|
||||||
attribute = va_arg (args, gchar *);
|
attribute = va_arg (args, gchar *);
|
||||||
|
|
||||||
iface = GTK_CELL_LAYOUT_GET_IFACE (cell_layout);
|
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)
|
while (attribute != NULL)
|
||||||
{
|
{
|
||||||
column = va_arg (args, gint);
|
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 *);
|
attribute = va_arg (args, gchar *);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -178,15 +224,28 @@ gtk_cell_layout_add_attribute (GtkCellLayout *cell_layout,
|
|||||||
const gchar *attribute,
|
const gchar *attribute,
|
||||||
gint column)
|
gint column)
|
||||||
{
|
{
|
||||||
|
GtkCellLayoutIface *iface;
|
||||||
|
GtkCellArea *area;
|
||||||
|
|
||||||
g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout));
|
g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout));
|
||||||
g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
|
g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
|
||||||
g_return_if_fail (attribute != NULL);
|
g_return_if_fail (attribute != NULL);
|
||||||
g_return_if_fail (column >= 0);
|
g_return_if_fail (column >= 0);
|
||||||
|
|
||||||
(* GTK_CELL_LAYOUT_GET_IFACE (cell_layout)->add_attribute) (cell_layout,
|
iface = GTK_CELL_LAYOUT_GET_IFACE (cell_layout);
|
||||||
cell,
|
|
||||||
attribute,
|
if (iface->add_attribute)
|
||||||
column);
|
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,
|
gpointer func_data,
|
||||||
GDestroyNotify destroy)
|
GDestroyNotify destroy)
|
||||||
{
|
{
|
||||||
|
GtkCellLayoutIface *iface;
|
||||||
|
GtkCellArea *area;
|
||||||
|
|
||||||
g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout));
|
g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout));
|
||||||
g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
|
g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
|
||||||
|
|
||||||
(* GTK_CELL_LAYOUT_GET_IFACE (cell_layout)->set_cell_data_func) (cell_layout,
|
iface = GTK_CELL_LAYOUT_GET_IFACE (cell_layout);
|
||||||
cell,
|
|
||||||
func,
|
if (iface->set_cell_data_func)
|
||||||
func_data,
|
iface->set_cell_data_func (cell_layout,
|
||||||
destroy);
|
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,
|
gtk_cell_layout_clear_attributes (GtkCellLayout *cell_layout,
|
||||||
GtkCellRenderer *cell)
|
GtkCellRenderer *cell)
|
||||||
{
|
{
|
||||||
|
GtkCellLayoutIface *iface;
|
||||||
|
GtkCellArea *area;
|
||||||
|
|
||||||
g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout));
|
g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout));
|
||||||
g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
|
g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
|
||||||
|
|
||||||
(* GTK_CELL_LAYOUT_GET_IFACE (cell_layout)->clear_attributes) (cell_layout,
|
iface = GTK_CELL_LAYOUT_GET_IFACE (cell_layout);
|
||||||
cell);
|
|
||||||
|
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,
|
GtkCellRenderer *cell,
|
||||||
gint position)
|
gint position)
|
||||||
{
|
{
|
||||||
|
GtkCellLayoutIface *iface;
|
||||||
|
GtkCellArea *area;
|
||||||
|
|
||||||
g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout));
|
g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout));
|
||||||
g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
|
g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
|
||||||
|
|
||||||
(* GTK_CELL_LAYOUT_GET_IFACE (cell_layout)->reorder) (cell_layout,
|
iface = GTK_CELL_LAYOUT_GET_IFACE (cell_layout);
|
||||||
cell,
|
|
||||||
position);
|
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)
|
gtk_cell_layout_get_cells (GtkCellLayout *cell_layout)
|
||||||
{
|
{
|
||||||
GtkCellLayoutIface *iface;
|
GtkCellLayoutIface *iface;
|
||||||
|
GtkCellArea *area;
|
||||||
|
|
||||||
g_return_val_if_fail (GTK_IS_CELL_LAYOUT (cell_layout), NULL);
|
g_return_val_if_fail (GTK_IS_CELL_LAYOUT (cell_layout), NULL);
|
||||||
|
|
||||||
iface = GTK_CELL_LAYOUT_GET_IFACE (cell_layout);
|
iface = GTK_CELL_LAYOUT_GET_IFACE (cell_layout);
|
||||||
if (iface->get_cells)
|
if (iface->get_cells)
|
||||||
return iface->get_cells (cell_layout);
|
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;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user