inspector: Add a way to highlight widgets

In contrast to the flashing, where we blink the widget a
few times, this is explicitly turned on and off.

It will be used for indicating widgets that are part of
a size group, in the next commit.
This commit is contained in:
Matthias Clasen 2014-05-20 21:43:00 -04:00
parent 65c9e2a651
commit 538b987bc5
2 changed files with 20 additions and 2 deletions

View File

@ -299,7 +299,7 @@ draw_flash (GtkWidget *widget,
{
GtkAllocation alloc;
if (iw->flash_count % 2 == 0)
if (iw && iw->flash_count % 2 == 0)
return FALSE;
if (GTK_IS_WINDOW (widget))
@ -359,4 +359,18 @@ gtk_inspector_flash_widget (GtkInspectorWindow *iw,
iw->flash_cnx = g_timeout_add (150, (GSourceFunc) on_flash_timeout, iw);
}
void
gtk_inspector_start_highlight (GtkWidget *widget)
{
g_signal_connect_after (widget, "draw", G_CALLBACK (draw_flash), NULL);
gtk_widget_queue_draw (widget);
}
void
gtk_inspector_stop_highlight (GtkWidget *widget)
{
g_signal_handlers_disconnect_by_func (widget, draw_flash, NULL);
gtk_widget_queue_draw (widget);
}
/* vim: set et sw=2 ts=2: */

View File

@ -50,6 +50,7 @@ typedef struct
GtkWidget *classes_list;
GtkWidget *widget_css_editor;
GtkWidget *object_hierarchy;
GtkWidget *size_groups;
GtkWidget *data_list;
GtkWidget *actions;
@ -75,7 +76,10 @@ GType gtk_inspector_window_get_type (void);
GtkWidget *gtk_inspector_window_new (void);
void gtk_inspector_flash_widget (GtkInspectorWindow *iw,
GtkWidget *widget);
GtkWidget *widget);
void gtk_inspector_start_highlight (GtkWidget *widget);
void gtk_inspector_stop_highlight (GtkWidget *widget);
G_END_DECLS