inspector: Add a description vfunc for render operations
This commit is contained in:
@@ -37,6 +37,12 @@ gtk_render_operation_real_get_matrix (GtkRenderOperation *operation,
|
||||
cairo_matrix_init_identity (matrix);
|
||||
}
|
||||
|
||||
static char *
|
||||
gtk_render_operation_real_describe (GtkRenderOperation *operation)
|
||||
{
|
||||
return g_strdup (G_OBJECT_TYPE_NAME (operation));
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_render_operation_real_draw (GtkRenderOperation *operation,
|
||||
cairo_t *cr)
|
||||
@@ -48,6 +54,7 @@ gtk_render_operation_class_init (GtkRenderOperationClass *klass)
|
||||
{
|
||||
klass->get_clip = gtk_render_operation_real_get_clip;
|
||||
klass->get_matrix = gtk_render_operation_real_get_matrix;
|
||||
klass->describe = gtk_render_operation_real_describe;
|
||||
klass->draw = gtk_render_operation_real_draw;
|
||||
}
|
||||
|
||||
@@ -76,6 +83,14 @@ gtk_render_operation_get_matrix (GtkRenderOperation *operation,
|
||||
GTK_RENDER_OPERATION_GET_CLASS (operation)->get_matrix (operation, matrix);
|
||||
}
|
||||
|
||||
char *
|
||||
gtk_render_operation_describe (GtkRenderOperation *operation)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_RENDER_OPERATION (operation), NULL);
|
||||
|
||||
return GTK_RENDER_OPERATION_GET_CLASS (operation)->describe (operation);
|
||||
}
|
||||
|
||||
void
|
||||
gtk_render_operation_draw (GtkRenderOperation *operation,
|
||||
cairo_t *cr)
|
||||
|
||||
@@ -50,6 +50,7 @@ struct _GtkRenderOperationClass
|
||||
void (* get_matrix) (GtkRenderOperation *operation,
|
||||
cairo_matrix_t *matrix);
|
||||
|
||||
char * (* describe) (GtkRenderOperation *operation);
|
||||
void (* draw) (GtkRenderOperation *operation,
|
||||
cairo_t *cr);
|
||||
};
|
||||
@@ -61,6 +62,7 @@ void gtk_render_operation_get_clip (GtkRenderOperation
|
||||
void gtk_render_operation_get_matrix (GtkRenderOperation *operation,
|
||||
cairo_matrix_t *matrix);
|
||||
|
||||
char * gtk_render_operation_describe (GtkRenderOperation *operation);
|
||||
void gtk_render_operation_draw (GtkRenderOperation *operation,
|
||||
cairo_t *cr);
|
||||
|
||||
|
||||
@@ -45,6 +45,12 @@ gtk_render_operation_cairo_get_clip (GtkRenderOperation *operation,
|
||||
clip->height = ceil (extents.y + extents.height) - clip->y;
|
||||
}
|
||||
|
||||
static char *
|
||||
gtk_render_operation_cairo_describe (GtkRenderOperation *operation)
|
||||
{
|
||||
return g_strdup ("custom rendering");
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_render_operation_cairo_draw (GtkRenderOperation *operation,
|
||||
cairo_t *cr)
|
||||
@@ -74,6 +80,7 @@ gtk_render_operation_cairo_class_init (GtkRenderOperationCairoClass *klass)
|
||||
object_class->finalize = gtk_render_operation_cairo_finalize;
|
||||
|
||||
operation_class->get_clip = gtk_render_operation_cairo_get_clip;
|
||||
operation_class->describe = gtk_render_operation_cairo_describe;
|
||||
operation_class->draw = gtk_render_operation_cairo_draw;
|
||||
}
|
||||
|
||||
|
||||
@@ -41,6 +41,14 @@ gtk_render_operation_widget_get_matrix (GtkRenderOperation *operation,
|
||||
*matrix = oper->matrix;
|
||||
}
|
||||
|
||||
static char *
|
||||
gtk_render_operation_widget_describe (GtkRenderOperation *operation)
|
||||
{
|
||||
GtkRenderOperationWidget *oper = GTK_RENDER_OPERATION_WIDGET (operation);
|
||||
|
||||
return g_strdup (g_type_name (oper->widget_type));
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_render_operation_widget_draw (GtkRenderOperation *operation,
|
||||
cairo_t *cr)
|
||||
@@ -81,6 +89,7 @@ gtk_render_operation_widget_class_init (GtkRenderOperationWidgetClass *klass)
|
||||
|
||||
operation_class->get_clip = gtk_render_operation_widget_get_clip;
|
||||
operation_class->get_matrix = gtk_render_operation_widget_get_matrix;
|
||||
operation_class->describe = gtk_render_operation_widget_describe;
|
||||
operation_class->draw = gtk_render_operation_widget_draw;
|
||||
}
|
||||
|
||||
@@ -100,6 +109,7 @@ gtk_render_operation_widget_new (GtkWidget *widget,
|
||||
|
||||
result = g_object_new (GTK_TYPE_RENDER_OPERATION_WIDGET, NULL);
|
||||
|
||||
result->widget_type = G_OBJECT_TYPE (widget);
|
||||
gtk_widget_get_allocation (widget, &result->widget_allocation);
|
||||
gtk_widget_get_clip (widget, &result->widget_clip);
|
||||
result->widget_clip.x -= result->widget_allocation.x;
|
||||
|
||||
@@ -40,6 +40,7 @@ struct _GtkRenderOperationWidget
|
||||
{
|
||||
GtkRenderOperation parent;
|
||||
|
||||
GType widget_type;
|
||||
GtkAllocation widget_allocation;
|
||||
GtkAllocation widget_clip;
|
||||
cairo_matrix_t matrix;
|
||||
|
||||
@@ -161,13 +161,15 @@ gtk_inspector_snapshot_fill_listbox (GtkInspectorSnapshot *snapshot,
|
||||
guint depth)
|
||||
{
|
||||
GtkWidget *label, *row;
|
||||
char *text;
|
||||
char *text, *description;
|
||||
|
||||
text = g_strdup_printf ("%*s %s", 2 * depth, "", G_OBJECT_TYPE_NAME (oper));
|
||||
description = gtk_render_operation_describe (oper);
|
||||
text = g_strdup_printf ("%*s %s", 2 * depth, "", description);
|
||||
label = gtk_label_new (text);
|
||||
gtk_label_set_xalign (GTK_LABEL (label), 0.0);
|
||||
gtk_widget_show (label);
|
||||
g_free (text);
|
||||
g_free (description);
|
||||
|
||||
row = gtk_list_box_row_new ();
|
||||
gtk_container_add (GTK_CONTAINER (row), label);
|
||||
|
||||
Reference in New Issue
Block a user