[nautilus-actions] New function base_window_dump_children()
- From: Pierre Wieser <pwieser src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus-actions] New function base_window_dump_children()
- Date: Mon, 21 Nov 2011 20:30:42 +0000 (UTC)
commit ab5e67fb1f4c0ee29d1610781d183e85cf925722
Author: Pierre Wieser <pwieser trychlos org>
Date: Wed Nov 16 23:52:07 2011 +0100
New function base_window_dump_children()
To be used in maintainer mode to dump the widgets's hierarchy of a container.
ChangeLog | 6 +++++
src/core/na-gtk-utils.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++-
src/core/na-gtk-utils.h | 4 +++
src/nact/base-window.c | 23 +++++++++++++++++++
src/nact/base-window.h | 4 +++
5 files changed, 92 insertions(+), 1 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index c62084e..856b171 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
2011-11-16 Pierre Wieser <pwieser trychlos org>
+ * src/nact/base-window.c:
+ * src/nact/base-window.h (base_window_dump_children): New function.
+
+ * src/core/na-gtk-utils.c:
+ * src/core/na-gtk-utils.h (na_gtk_utils_dump_children): New function.
+
* docs/nact/C/nact-conditions.xml:
* docs/nact/C/nact-edit.xml:
* docs/nact/C/nact-execution.xml:
diff --git a/src/core/na-gtk-utils.c b/src/core/na-gtk-utils.c
index 3e5e5f4..aaf9aa5 100644
--- a/src/core/na-gtk-utils.c
+++ b/src/core/na-gtk-utils.c
@@ -56,8 +56,11 @@ na_gtk_utils_search_for_child_widget( GtkContainer *container, const gchar *name
if( GTK_IS_WIDGET( ic->data )){
child = GTK_WIDGET( ic->data );
+#if GTK_CHECK_VERSION( 2, 20, 0 )
child_name = gtk_buildable_get_name( GTK_BUILDABLE( child ));
-
+#else
+ child_name = gtk_widget_get_name( child );
+#endif
if( child_name && strlen( child_name )){
/*g_debug( "%s: child=%s", thisfn, child_name );*/
@@ -75,3 +78,54 @@ na_gtk_utils_search_for_child_widget( GtkContainer *container, const gchar *name
g_list_free( children );
return( found );
}
+
+#ifdef NA_MAINTAINER_MODE
+static void
+dump_children( GtkContainer *container, int level )
+{
+ static const gchar *thisfn = "na_gtk_utils_dump_children";
+ GList *children = gtk_container_get_children( container );
+ GList *ic;
+ GtkWidget *child;
+ const gchar *child_name;
+ GString *prefix;
+ int i;
+
+ prefix = g_string_new( "" );
+ for( i = 0 ; i < level ; ++i ){
+ g_string_append_printf( prefix, "%s", "| " );
+ }
+
+ for( ic = children ; ic ; ic = ic->next ){
+
+ if( GTK_IS_WIDGET( ic->data )){
+ child = GTK_WIDGET( ic->data );
+#if GTK_CHECK_VERSION( 2, 20, 0 )
+ child_name = gtk_buildable_get_name( GTK_BUILDABLE( child ));
+#else
+ child_name = gtk_widget_get_name( child );
+#endif
+ if( child_name && strlen( child_name )){
+ g_debug( "%s: %s%s\t%s", thisfn, prefix->str, G_OBJECT_TYPE_NAME( child ), child_name );
+
+ if( GTK_IS_CONTAINER( child )){
+ dump_children( GTK_CONTAINER( child ), level+1 );
+ }
+ }
+ }
+ }
+
+ g_list_free( children );
+ g_string_free( prefix, TRUE );
+}
+
+void
+na_gtk_utils_dump_children( GtkContainer *container )
+{
+ static const gchar *thisfn = "na_gtk_utils_dump_children";
+
+ g_debug( "%s: container=%p", thisfn, container );
+
+ dump_children( container, 0 );
+}
+#endif
diff --git a/src/core/na-gtk-utils.h b/src/core/na-gtk-utils.h
index b291867..d279e5d 100644
--- a/src/core/na-gtk-utils.h
+++ b/src/core/na-gtk-utils.h
@@ -42,6 +42,10 @@ G_BEGIN_DECLS
GtkWidget *na_gtk_utils_search_for_child_widget( GtkContainer *container, const gchar *name );
+#ifdef NA_MAINTAINER_MODE
+void na_gtk_utils_dump_children ( GtkContainer *container );
+#endif
+
G_END_DECLS
#endif /* __CORE_API_NA_GTK_UTILS_H__ */
diff --git a/src/nact/base-window.c b/src/nact/base-window.c
index 301582a..00ee3ef 100644
--- a/src/nact/base-window.c
+++ b/src/nact/base-window.c
@@ -879,6 +879,10 @@ on_all_widgets_showed_class_handler( BaseWindow *window )
if( BASE_WINDOW_GET_CLASS( window )->all_widgets_showed ){
BASE_WINDOW_GET_CLASS( window )->all_widgets_showed( window );
}
+
+#ifdef NA_MAINTAINER_MODE
+ base_window_dump_children( BASE_WINDOW( window ));
+#endif
}
}
@@ -949,6 +953,25 @@ on_delete_event( GtkWidget *toplevel, GdkEvent *event, BaseWindow *window )
return( stop );
}
+#ifdef NA_MAINTAINER_MODE
+/*
+ * base_window_dump_children:
+ * @window: this #BaseWindow instance.
+ *
+ * Displays the known children of this window.
+ */
+void
+base_window_dump_children( const BaseWindow *window )
+{
+ g_return_if_fail( BASE_IS_WINDOW( window ));
+
+ if( !window->private->dispose_has_run ){
+
+ na_gtk_utils_dump_children( GTK_CONTAINER( window->private->gtk_toplevel ));
+ }
+}
+#endif
+
/**
* base_window_get_application:
* @window: this #BaseWindow object.
diff --git a/src/nact/base-window.h b/src/nact/base-window.h
index 7384399..5697e64 100644
--- a/src/nact/base-window.h
+++ b/src/nact/base-window.h
@@ -226,6 +226,10 @@ GType base_window_get_type( void );
gboolean base_window_init( BaseWindow *window );
int base_window_run ( BaseWindow *window );
+#ifdef NA_MAINTAINER_MODE
+void base_window_dump_children ( const BaseWindow *window );
+#endif
+
BaseApplication *base_window_get_application ( const BaseWindow *window );
BaseWindow *base_window_get_parent ( const BaseWindow *window );
GtkWindow *base_window_get_gtk_toplevel ( const BaseWindow *window );
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]