*/
#include <config.h>
-#include "gtkalias.h"
#include "gtkcellrenderer.h"
#include "gtkintl.h"
#include "gtkmarshalers.h"
+#include "gtkprivate.h"
#include "gtktreeprivate.h"
+#include "gtkalias.h"
-static void gtk_cell_renderer_init (GtkCellRenderer *cell);
-static void gtk_cell_renderer_class_init (GtkCellRendererClass *class);
static void gtk_cell_renderer_get_property (GObject *object,
guint param_id,
GValue *value,
static guint cell_renderer_signals[LAST_SIGNAL] = { 0 };
-
-GType
-gtk_cell_renderer_get_type (void)
-{
- static GType cell_type = 0;
-
- if (!cell_type)
- {
- static const GTypeInfo cell_info =
- {
- sizeof (GtkCellRendererClass),
- NULL, /* base_init */
- NULL, /* base_finalize */
- (GClassInitFunc) gtk_cell_renderer_class_init,
- NULL, /* class_finalize */
- NULL, /* class_data */
- sizeof (GtkCellRenderer),
- 0, /* n_preallocs */
- (GInstanceInitFunc) gtk_cell_renderer_init,
- NULL, /* value_table */
- };
-
- cell_type = g_type_register_static (GTK_TYPE_OBJECT, "GtkCellRenderer",
- &cell_info, G_TYPE_FLAG_ABSTRACT);
- }
-
- return cell_type;
-}
+G_DEFINE_ABSTRACT_TYPE (GtkCellRenderer, gtk_cell_renderer, GTK_TYPE_OBJECT)
static void
gtk_cell_renderer_init (GtkCellRenderer *cell)
* cell. For example, an editable cell renderer could be written to cancel
* editing when the user presses Escape.
*
- * See also: gtk_cell_renderer_editing_canceled()
+ * See also: gtk_cell_renderer_stop_editing().
*
* Since: 2.4
*/
cell_renderer_signals[EDITING_CANCELED] =
- g_signal_new ("editing-canceled",
+ g_signal_new (I_("editing-canceled"),
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GtkCellRendererClass, editing_canceled),
* Since: 2.6
*/
cell_renderer_signals[EDITING_STARTED] =
- g_signal_new ("editing-started",
+ g_signal_new (I_("editing-started"),
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GtkCellRendererClass, editing_started),
P_("Editable mode of the CellRenderer"),
GTK_TYPE_CELL_RENDERER_MODE,
GTK_CELL_RENDERER_MODE_INERT,
- G_PARAM_READABLE |
- G_PARAM_WRITABLE));
+ GTK_PARAM_READWRITE));
g_object_class_install_property (object_class,
PROP_VISIBLE,
P_("visible"),
P_("Display the cell"),
TRUE,
- G_PARAM_READWRITE));
+ GTK_PARAM_READWRITE));
g_object_class_install_property (object_class,
PROP_SENSITIVE,
g_param_spec_boolean ("sensitive",
P_("Sensitive"),
P_("Display the cell sensitive"),
TRUE,
- G_PARAM_READWRITE));
+ GTK_PARAM_READWRITE));
g_object_class_install_property (object_class,
PROP_XALIGN,
0.0,
1.0,
0.5,
- G_PARAM_READABLE |
- G_PARAM_WRITABLE));
+ GTK_PARAM_READWRITE));
g_object_class_install_property (object_class,
PROP_YALIGN,
0.0,
1.0,
0.5,
- G_PARAM_READABLE |
- G_PARAM_WRITABLE));
+ GTK_PARAM_READWRITE));
g_object_class_install_property (object_class,
PROP_XPAD,
0,
G_MAXUINT,
0,
- G_PARAM_READABLE |
- G_PARAM_WRITABLE));
+ GTK_PARAM_READWRITE));
g_object_class_install_property (object_class,
PROP_YPAD,
0,
G_MAXUINT,
0,
- G_PARAM_READABLE |
- G_PARAM_WRITABLE));
+ GTK_PARAM_READWRITE));
g_object_class_install_property (object_class,
PROP_WIDTH,
-1,
G_MAXINT,
-1,
- G_PARAM_READABLE |
- G_PARAM_WRITABLE));
+ GTK_PARAM_READWRITE));
g_object_class_install_property (object_class,
PROP_HEIGHT,
-1,
G_MAXINT,
-1,
- G_PARAM_READABLE |
- G_PARAM_WRITABLE));
+ GTK_PARAM_READWRITE));
g_object_class_install_property (object_class,
PROP_IS_EXPANDER,
P_("Is Expander"),
P_("Row has children"),
FALSE,
- G_PARAM_READABLE |
- G_PARAM_WRITABLE));
+ GTK_PARAM_READWRITE));
g_object_class_install_property (object_class,
P_("Is Expanded"),
P_("Row is an expander row, and is expanded"),
FALSE,
- G_PARAM_READABLE |
- G_PARAM_WRITABLE));
+ GTK_PARAM_READWRITE));
g_object_class_install_property (object_class,
PROP_CELL_BACKGROUND,
P_("Cell background color name"),
P_("Cell background color as a string"),
NULL,
- G_PARAM_WRITABLE));
+ GTK_PARAM_WRITABLE));
g_object_class_install_property (object_class,
PROP_CELL_BACKGROUND_GDK,
P_("Cell background color"),
P_("Cell background color as a GdkColor"),
GDK_TYPE_COLOR,
- G_PARAM_READABLE | G_PARAM_WRITABLE));
+ GTK_PARAM_READWRITE));
-#define ADD_SET_PROP(propname, propval, nick, blurb) g_object_class_install_property (object_class, propval, g_param_spec_boolean (propname, nick, blurb, FALSE, G_PARAM_READABLE | G_PARAM_WRITABLE))
+#define ADD_SET_PROP(propname, propval, nick, blurb) g_object_class_install_property (object_class, propval, g_param_spec_boolean (propname, nick, blurb, FALSE, GTK_PARAM_READWRITE))
ADD_SET_PROP ("cell-background-set", PROP_CELL_BACKGROUND_SET,
P_("Cell background set"),
else
g_warning ("Don't know color `%s'", g_value_get_string (value));
- g_object_notify (object, "cell_background_gdk");
+ g_object_notify (object, "cell-background-gdk");
}
break;
case PROP_CELL_BACKGROUND_GDK:
if (!cell->cell_background_set)
{
cell->cell_background_set = TRUE;
- g_object_notify (G_OBJECT (cell), "cell_background_set");
+ g_object_notify (G_OBJECT (cell), "cell-background-set");
}
priv->cell_background.red = color->red;
if (cell->cell_background_set)
{
cell->cell_background_set = FALSE;
- g_object_notify (G_OBJECT (cell), "cell_background_set");
+ g_object_notify (G_OBJECT (cell), "cell-background-set");
}
}
}
* @width: location to return width needed to render a cell, or %NULL
* @height: location to return height needed to render a cell, or %NULL
*
- * Obtains the width and height needed to render the cell. Used by view widgets
- * to determine the appropriate size for the cell_area passed to
- * gtk_cell_renderer_render(). If @cell_area is not %NULL, fills in the x and y
- * offsets (if set) of the cell relative to this location. Please note that the
- * values set in @width and @height, as well as those in @x_offset and @y_offset
- * are inclusive of the xpad and ypad properties.
+ * Obtains the width and height needed to render the cell. Used by view
+ * widgets to determine the appropriate size for the cell_area passed to
+ * gtk_cell_renderer_render(). If @cell_area is not %NULL, fills in the
+ * x and y offsets (if set) of the cell relative to this location.
+ *
+ * Please note that the values set in @width and @height, as well as those
+ * in @x_offset and @y_offset are inclusive of the xpad and ypad properties.
**/
void
gtk_cell_renderer_get_size (GtkCellRenderer *cell,
* @cell: a #GtkCellRenderer
* @window: a #GdkDrawable to draw to
* @widget: the widget owning @window
- * @background_area: entire cell area (including tree expanders and maybe padding on the sides)
+ * @background_area: entire cell area (including tree expanders and maybe
+ * padding on the sides)
* @cell_area: area normally rendered by a cell renderer
* @expose_area: area that actually needs updating
* @flags: flags that affect rendering
* blank space around the cell, and also the area containing the tree expander;
* so the @background_area rectangles for all cells tile to cover the entire
* @window. @expose_area is a clip rectangle.
- *
**/
void
gtk_cell_renderer_render (GtkCellRenderer *cell,
if (cell->cell_background_set && !selected)
{
- GdkColor color;
- GdkGC *gc;
-
- color.red = priv->cell_background.red;
- color.green = priv->cell_background.green;
- color.blue = priv->cell_background.blue;
-
- gc = gdk_gc_new (window);
- gdk_gc_set_rgb_fg_color (gc, &color);
- gdk_draw_rectangle (window, gc, TRUE,
- background_area->x, background_area->y,
- background_area->width, background_area->height);
- g_object_unref (gc);
+ cairo_t *cr = gdk_cairo_create (window);
+
+ gdk_cairo_rectangle (cr, background_area);
+ gdk_cairo_set_source_color (cr, &priv->cell_background);
+ cairo_fill (cr);
+
+ cairo_destroy (cr);
}
GTK_CELL_RENDERER_GET_CLASS (cell)->render (cell,
* @cell: a #GtkCellRenderer
* @event: a #GdkEvent
* @widget: widget that received the event
- * @path: widget-dependent string representation of the event location; e.g. for #GtkTreeView, a string representation of #GtkTreePath
- * @background_area: background area as passed to @gtk_cell_renderer_render
- * @cell_area: cell area as passed to @gtk_cell_renderer_render
+ * @path: widget-dependent string representation of the event location;
+ * e.g. for #GtkTreeView, a string representation of #GtkTreePath
+ * @background_area: background area as passed to gtk_cell_renderer_render()
+ * @cell_area: cell area as passed to gtk_cell_renderer_render()
* @flags: render flags
*
- * Passes an activate event to the cell renderer for possible processing. Some
- * cell renderers may use events; for example, #GtkCellRendererToggle toggles
- * when it gets a mouse click.
+ * Passes an activate event to the cell renderer for possible processing.
+ * Some cell renderers may use events; for example, #GtkCellRendererToggle
+ * toggles when it gets a mouse click.
*
* Return value: %TRUE if the event was consumed/handled
**/
* @cell: a #GtkCellRenderer
* @event: a #GdkEvent
* @widget: widget that received the event
- * @path: widget-dependent string representation of the event location; e.g. for #GtkTreeView, a string representation of #GtkTreePath
- * @background_area: background area as passed to @gtk_cell_renderer_render
- * @cell_area: cell area as passed to @gtk_cell_renderer_render
+ * @path: widget-dependent string representation of the event location;
+ * e.g. for #GtkTreeView, a string representation of #GtkTreePath
+ * @background_area: background area as passed to gtk_cell_renderer_render()
+ * @cell_area: cell area as passed to gtk_cell_renderer_render()
* @flags: render flags
*
* Passes an activate event to the cell renderer for possible processing.
* gtk_cell_renderer_editing_canceled:
* @cell: A #GtkCellRenderer
*
- * Causes the cell renderer to emit the "editing-canceled" signal. This
- * function is for use only by implementations of cell renderers that need to
- * notify the client program that an editing process was canceled and the
- * changes were not committed.
+ * Causes the cell renderer to emit the #GtkCellRenderer::editing-canceled
+ * signal.
+ *
+ * This function is for use only by implementations of cell renderers that
+ * need to notify the client program that an editing process was canceled
+ * and the changes were not committed.
*
* Since: 2.4
- * Deprecated: Use gtk_cell_renderer_stop_editing() instead
+ * Deprecated: 2.6: Use gtk_cell_renderer_stop_editing() instead
**/
void
gtk_cell_renderer_editing_canceled (GtkCellRenderer *cell)
* @canceled: %TRUE if the editing has been canceled
*
* Informs the cell renderer that the editing is stopped.
- * If @canceled is %TRUE, the cell renderer will emit the "editing-canceled"
- * signal. This function should be called by cell renderer implementations
- * in response to the "editing-done" signal of #GtkCellEditable.
+ * If @canceled is %TRUE, the cell renderer will emit the
+ * #GtkCellRenderer::editing-canceled signal.
+ *
+ * This function should be called by cell renderer implementations
+ * in response to the #GtkCellEditable::editing-done signal of
+ * #GtkCellEditable.
*
* Since: 2.6
**/
}
}
+#define __GTK_CELL_RENDERER_C__
+#include "gtkaliasdef.c"