forked from AuroraMiddleware/gtk
inspector: Show child widgets of widgets
This commit is contained in:
parent
d77b288e65
commit
42f1ff0123
@ -47,6 +47,7 @@ find_widget (GtkWidget *widget,
|
||||
GtkAllocation new_allocation;
|
||||
gint x_offset = 0;
|
||||
gint y_offset = 0;
|
||||
GtkWidget *child;
|
||||
|
||||
gtk_widget_get_allocation (widget, &new_allocation);
|
||||
|
||||
@ -121,9 +122,12 @@ find_widget (GtkWidget *widget,
|
||||
new_data.found = FALSE;
|
||||
new_data.first = FALSE;
|
||||
|
||||
gtk_container_forall (GTK_CONTAINER (widget),
|
||||
(GtkCallback)find_widget,
|
||||
&new_data);
|
||||
for (child = gtk_widget_get_first_child (widget);
|
||||
child != NULL;
|
||||
child = gtk_widget_get_next_sibling (child))
|
||||
{
|
||||
find_widget (child, &new_data);
|
||||
}
|
||||
|
||||
data->found = new_data.found;
|
||||
if (data->found)
|
||||
|
@ -125,6 +125,17 @@ object_tree_widget_get_parent (GObject *object)
|
||||
return G_OBJECT (gtk_widget_get_parent (GTK_WIDGET (object)));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
object_tree_widget_get_sensitive (GObject *object)
|
||||
{
|
||||
return gtk_widget_get_mapped (GTK_WIDGET (object));
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
ObjectTreeForallFunc forall_func;
|
||||
gpointer forall_data;
|
||||
} ForallData;
|
||||
|
||||
static void
|
||||
object_tree_widget_forall (GObject *object,
|
||||
ObjectTreeForallFunc forall_func,
|
||||
@ -140,6 +151,7 @@ object_tree_widget_forall (GObject *object,
|
||||
{ GTK_PHASE_NONE, "" }
|
||||
};
|
||||
gint i;
|
||||
GtkWidget *child;
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (phases); i++)
|
||||
{
|
||||
@ -162,41 +174,13 @@ object_tree_widget_forall (GObject *object,
|
||||
if (clock)
|
||||
forall_func (clock, "frame-clock", forall_data);
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
object_tree_widget_get_sensitive (GObject *object)
|
||||
{
|
||||
return gtk_widget_get_mapped (GTK_WIDGET (object));
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
ObjectTreeForallFunc forall_func;
|
||||
gpointer forall_data;
|
||||
} ForallData;
|
||||
|
||||
static void
|
||||
container_children_callback (GtkWidget *widget,
|
||||
gpointer client_data)
|
||||
{
|
||||
ForallData *forall_data = client_data;
|
||||
|
||||
forall_data->forall_func (G_OBJECT (widget), NULL, forall_data->forall_data);
|
||||
}
|
||||
|
||||
static void
|
||||
object_tree_container_forall (GObject *object,
|
||||
ObjectTreeForallFunc forall_func,
|
||||
gpointer forall_data)
|
||||
{
|
||||
ForallData data = {
|
||||
forall_func,
|
||||
forall_data
|
||||
};
|
||||
|
||||
gtk_container_forall (GTK_CONTAINER (object),
|
||||
container_children_callback,
|
||||
&data);
|
||||
for (child = gtk_widget_get_first_child (GTK_WIDGET (object));
|
||||
child != NULL;
|
||||
child = gtk_widget_get_next_sibling (child))
|
||||
{
|
||||
forall_func (G_OBJECT (child), NULL, forall_data);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
@ -456,12 +440,6 @@ static const ObjectTreeClassFuncs object_tree_class_funcs[] = {
|
||||
object_tree_menu_item_forall,
|
||||
object_tree_widget_get_sensitive
|
||||
},
|
||||
{
|
||||
gtk_container_get_type,
|
||||
object_tree_widget_get_parent,
|
||||
object_tree_container_forall,
|
||||
object_tree_widget_get_sensitive
|
||||
},
|
||||
{
|
||||
gtk_widget_get_type,
|
||||
object_tree_widget_get_parent,
|
||||
|
@ -87,12 +87,17 @@ fix_direction_recurse (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
GtkTextDirection dir = GPOINTER_TO_INT (data);
|
||||
GtkWidget *child;
|
||||
|
||||
g_object_ref (widget);
|
||||
|
||||
gtk_widget_set_direction (widget, dir);
|
||||
if (GTK_IS_CONTAINER (widget))
|
||||
gtk_container_forall (GTK_CONTAINER (widget), fix_direction_recurse, data);
|
||||
for (child = gtk_widget_get_first_child (widget);
|
||||
child != NULL;
|
||||
child = gtk_widget_get_next_sibling (child))
|
||||
{
|
||||
fix_direction_recurse (child, data);
|
||||
}
|
||||
|
||||
g_object_unref (widget);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user