inspector: Show surface and renderer

This commit is contained in:
Matthias Clasen 2019-05-28 19:43:01 +00:00
parent 84739dde99
commit 908632138c

View File

@ -55,6 +55,12 @@ struct _GtkInspectorMiscInfoPrivate {
GtkWidget *allocated_size;
GtkWidget *baseline_row;
GtkWidget *baseline;
GtkWidget *surface_row;
GtkWidget *surface;
GtkWidget *surface_button;
GtkWidget *renderer_row;
GtkWidget *renderer;
GtkWidget *renderer_button;
GtkWidget *frame_clock_row;
GtkWidget *frame_clock;
GtkWidget *frame_clock_button;
@ -193,6 +199,26 @@ show_mnemonic_label (GtkWidget *button, GtkInspectorMiscInfo *sl)
show_object (sl, G_OBJECT (widget), "properties");
}
static void
show_surface (GtkWidget *button, GtkInspectorMiscInfo *sl)
{
GObject *surface;
surface = (GObject *)gtk_native_get_surface (GTK_NATIVE (sl->priv->object));
if (surface)
show_object (sl, G_OBJECT (surface), "properties");
}
static void
show_renderer (GtkWidget *button, GtkInspectorMiscInfo *sl)
{
GObject *renderer;
renderer = (GObject *)gtk_native_get_renderer (GTK_NATIVE (sl->priv->object));
if (renderer)
show_object (sl, G_OBJECT (renderer), "properties");
}
static void
show_frame_clock (GtkWidget *button, GtkInspectorMiscInfo *sl)
{
@ -204,23 +230,74 @@ show_frame_clock (GtkWidget *button, GtkInspectorMiscInfo *sl)
}
static void
update_frame_clock (GtkInspectorMiscInfo *sl)
update_surface (GtkInspectorMiscInfo *sl)
{
GObject *clock;
clock = (GObject *)gtk_widget_get_frame_clock (GTK_WIDGET (sl->priv->object));
if (clock)
if (GTK_IS_NATIVE (sl->priv->object))
{
gchar *tmp;
tmp = g_strdup_printf ("%p", clock);
gtk_label_set_label (GTK_LABEL (sl->priv->frame_clock), tmp);
GObject *obj;
char *tmp;
gtk_widget_show (sl->priv->surface_row);
obj = (GObject *)gtk_native_get_surface (GTK_NATIVE (sl->priv->object));
tmp = g_strdup_printf ("%p", obj);
gtk_label_set_label (GTK_LABEL (sl->priv->surface), tmp);
g_free (tmp);
gtk_widget_set_sensitive (sl->priv->frame_clock_button, TRUE);
}
else
{
gtk_label_set_label (GTK_LABEL (sl->priv->frame_clock), "NULL");
gtk_widget_set_sensitive (sl->priv->frame_clock_button, FALSE);
gtk_widget_hide (sl->priv->surface_row);
}
}
static void
update_renderer (GtkInspectorMiscInfo *sl)
{
if (GTK_IS_NATIVE (sl->priv->object))
{
GObject *obj;
char *tmp;
gtk_widget_show (sl->priv->renderer_row);
obj = (GObject *)gtk_native_get_surface (GTK_NATIVE (sl->priv->object));
tmp = g_strdup_printf ("%p", obj);
gtk_label_set_label (GTK_LABEL (sl->priv->renderer), tmp);
g_free (tmp);
}
else
{
gtk_widget_hide (sl->priv->renderer_row);
}
}
static void
update_frame_clock (GtkInspectorMiscInfo *sl)
{
if (GTK_IS_ROOT (sl->priv->object))
{
GObject *clock;
gtk_widget_show (sl->priv->frame_clock_row);
clock = (GObject *)gtk_widget_get_frame_clock (GTK_WIDGET (sl->priv->object));
if (clock)
{
gchar *tmp;
tmp = g_strdup_printf ("%p", clock);
gtk_label_set_label (GTK_LABEL (sl->priv->frame_clock), tmp);
g_free (tmp);
gtk_widget_set_sensitive (sl->priv->frame_clock_button, TRUE);
}
else
{
gtk_label_set_label (GTK_LABEL (sl->priv->frame_clock), "NULL");
gtk_widget_set_sensitive (sl->priv->frame_clock_button, FALSE);
}
}
else
{
gtk_widget_hide (sl->priv->frame_clock_row);
}
}
@ -281,10 +358,12 @@ update_info (gpointer data)
gtk_widget_set_visible (sl->priv->realized, gtk_widget_get_realized (GTK_WIDGET (sl->priv->object)));
gtk_widget_set_visible (sl->priv->is_toplevel, GTK_IS_ROOT (sl->priv->object));
gtk_widget_set_visible (sl->priv->child_visible, gtk_widget_get_child_visible (GTK_WIDGET (sl->priv->object)));
update_frame_clock (sl);
}
update_surface (sl);
update_renderer (sl);
update_frame_clock (sl);
if (GTK_IS_BUILDABLE (sl->priv->object))
{
gtk_label_set_text (GTK_LABEL (sl->priv->buildable_id),
@ -522,6 +601,12 @@ gtk_inspector_misc_info_class_init (GtkInspectorMiscInfoClass *klass)
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, allocated_size);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, baseline_row);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, baseline);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, surface_row);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, surface);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, surface_button);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, renderer_row);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, renderer);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, renderer_button);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, frame_clock_row);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, frame_clock);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, frame_clock_button);
@ -546,6 +631,8 @@ gtk_inspector_misc_info_class_init (GtkInspectorMiscInfoClass *klass)
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, child_visible_row);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, child_visible);
gtk_widget_class_bind_template_callback (widget_class, show_surface);
gtk_widget_class_bind_template_callback (widget_class, show_renderer);
gtk_widget_class_bind_template_callback (widget_class, show_frame_clock);
}