[nautilus-actions] BaseWindow::on_all_widgets_showed_class_handler() successively invoke each derived class



commit 1bae870400847ecf6187c592d86cec5b89a31a2a
Author: Pierre Wieser <pwieser trychlos org>
Date:   Sat Jan 22 15:33:05 2011 +0100

    BaseWindow::on_all_widgets_showed_class_handler() successively invoke each derived class

 ChangeLog              |    7 ++++---
 src/nact/base-window.c |   37 ++++++++++++-------------------------
 src/nact/base-window.h |   30 +++++++++++++++++++-----------
 3 files changed, 35 insertions(+), 39 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 3275d7e..886112f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,11 +1,12 @@
 2011-01-22 Pierre Wieser <pwieser trychlos org>
 
 	* src/nact/base-window.c (on_initialize_gtk_toplevel_class_handler,
-	on_initialize_base_window_class_handler):
+	on_initialize_base_window_class_handler,
+	on_all_widgets_showed_class_handler):
 	Succssively invoke all derived class methods.
 
-	* src/nact/base-window.h (initial_load_toplevel, runtime_init_toplevel):
-	Update comments.
+	* src/nact/base-window.h (initial_load_toplevel, runtime_init_toplevel,
+	@all_widgets_showed): Update comments.
 
 	* src/nact/base-application.c (appli_initialize_manage_options):
 	Successively invoke all derived class methods.
diff --git a/src/nact/base-window.c b/src/nact/base-window.c
index 13e65d0..6c6e6df 100644
--- a/src/nact/base-window.c
+++ b/src/nact/base-window.c
@@ -127,13 +127,12 @@ static void             on_initialize_gtk_toplevel_class_handler( BaseWindow *wi
 static void             do_initialize_gtk_toplevel( BaseWindow *window, gpointer user_data );
 static void             on_initialize_base_window_class_handler( BaseWindow *window, gpointer user_data );
 static void             do_initialize_base_window( BaseWindow *window, gpointer user_data );
+static void             on_all_widgets_showed_class_handler( BaseWindow *window, gpointer user_data );
 
-static void             v_all_widgets_showed( BaseWindow *window, gpointer user_data );
 static gboolean         v_dialog_response( GtkDialog *dialog, gint code, BaseWindow *window );
 static gchar           *v_get_toplevel_name( const BaseWindow *window );
 static gchar           *v_get_iprefs_window_id( const BaseWindow *window );
 
-static void             window_do_all_widgets_showed( BaseWindow *window, gpointer user_data );
 static gboolean         window_do_dialog_response( GtkDialog *dialog, gint code, BaseWindow *window );
 static gboolean         window_do_delete_event( BaseWindow *window, GtkWindow *toplevel, GdkEvent *event );
 static gboolean         window_do_is_willing_to_quit( const BaseWindow *window );
@@ -246,7 +245,7 @@ class_init( BaseWindowClass *klass )
 
 	klass->initial_load_toplevel = do_initialize_gtk_toplevel;
 	klass->runtime_init_toplevel = do_initialize_base_window;
-	klass->all_widgets_showed = window_do_all_widgets_showed;
+	klass->all_widgets_showed = NULL;
 	klass->dialog_response = window_do_dialog_response;
 	klass->delete_event = window_do_delete_event;
 	klass->get_toplevel_name = NULL;
@@ -308,7 +307,7 @@ class_init( BaseWindowClass *klass )
 				BASE_SIGNAL_ALL_WIDGETS_SHOWED,
 				G_TYPE_FROM_CLASS( klass ),
 				G_SIGNAL_RUN_LAST,
-				G_CALLBACK( v_all_widgets_showed ),
+				G_CALLBACK( on_all_widgets_showed_class_handler ),
 				NULL,
 				NULL,
 				g_cclosure_marshal_VOID__POINTER,
@@ -1025,20 +1024,21 @@ do_initialize_base_window( BaseWindow *window, gpointer user_data )
 }
 
 static void
-v_all_widgets_showed( BaseWindow *window, gpointer user_data )
+on_all_widgets_showed_class_handler( BaseWindow *window, gpointer user_data )
 {
-	static const gchar *thisfn = "base_window_v_all_widgets_showed";
+	static const gchar *thisfn = "base_window_on_all_widgets_showed_class_handler";
+	GObjectClass *class;
 
-	g_debug( "%s: window=%p, user_data=%p", thisfn, ( void * ) window, ( void * ) user_data );
 	g_return_if_fail( BASE_IS_WINDOW( window ));
 
-	if( !window->private->dispose_has_run ){
+	g_debug( "%s: window=%p, user_data=%p", thisfn, ( void * ) window, ( void * ) user_data );
 
-		if( BASE_WINDOW_GET_CLASS( window )->all_widgets_showed ){
-			BASE_WINDOW_GET_CLASS( window )->all_widgets_showed( window, user_data );
+	if( !window->private->dispose_has_run ){
 
-		} else {
-			window_do_all_widgets_showed( window, user_data );
+		for( class = G_OBJECT_GET_CLASS( window ) ; BASE_IS_WINDOW_CLASS( class ) ; class = g_type_class_peek_parent( class )){
+			if( BASE_WINDOW_CLASS( class )->all_widgets_showed ){
+				BASE_WINDOW_CLASS( class )->all_widgets_showed( window, user_data );
+			}
 		}
 	}
 }
@@ -1103,19 +1103,6 @@ v_get_iprefs_window_id( const BaseWindow *window )
 	return( id );
 }
 
-static void
-window_do_all_widgets_showed( BaseWindow *window, gpointer user_data )
-{
-	static const gchar *thisfn = "base_window_do_all_widgets_showed";
-
-	g_debug( "%s: window=%p, user_data=%p", thisfn, ( void * ) window, ( void * ) user_data );
-	g_return_if_fail( BASE_IS_WINDOW( window ));
-
-	if( !window->private->dispose_has_run ){
-		/* nothing to do here */
-	}
-}
-
 /*
  * return TRUE to quit the dialog loop
  */
diff --git a/src/nact/base-window.h b/src/nact/base-window.h
index 509edc5..fae3a96 100644
--- a/src/nact/base-window.h
+++ b/src/nact/base-window.h
@@ -95,8 +95,8 @@ typedef struct _BaseWindowClassPrivate  BaseWindowClassPrivate;
 /**
  * BaseWindowClass:
  * @initial_load_toplevel: initialize the toplevel GtkWindow
- * @runtime_init_toplevel:
- * @all_widgets_showed:
+ * @runtime_init_toplevel: initialize the BaseWindow
+ * @all_widgets_showed:    all widgets have been showed
  * @dialog_response:
  * @delete_event:
  * @get_toplevel_name:
@@ -128,7 +128,7 @@ typedef struct {
 	 * so called last, set this GtkWindow toplevel window transient for
 	 * its parent window.
 	 */
-	void              ( *initial_load_toplevel )( BaseWindow *window, gpointer user_data );
+	void     ( *initial_load_toplevel )( BaseWindow *window, gpointer user_data );
 
 	/**
 	 * runtime_init_toplevel:
@@ -146,19 +146,27 @@ typedef struct {
 	 * The BaseWindow base class implementation of this method, which is
 	 * so called last, reset last size and position of the window.
 	 */
-	void              ( *runtime_init_toplevel )( BaseWindow *window, gpointer user_data );
+	void     ( *runtime_init_toplevel )( BaseWindow *window, gpointer user_data );
 
 	/**
 	 * all_widgets_showed:
 	 * @window: this #BaseWindow instance.
+	 * @user_data: not used
+	 *
+	 * Invoked at the end of initialization process, after all connected
+	 * handlers have themselves run.
+	 *
+	 * The BaseWindow class takes care of successively invoking the
+	 * all_widgets_showed() method of each derived class, starting from
+	 * the topmost derived class, up to the BaseWindow itself.
 	 */
-	void              ( *all_widgets_showed )   ( BaseWindow *window, gpointer user_data );
+	void     ( *all_widgets_showed )   ( BaseWindow *window, gpointer user_data );
 
 	/**
 	 * dialog_response:
 	 * @window: this #BaseWindow instance.
 	 */
-	gboolean          ( *dialog_response )      ( GtkDialog *dialog, gint code, BaseWindow *window );
+	gboolean ( *dialog_response )      ( GtkDialog *dialog, gint code, BaseWindow *window );
 
 	/**
 	 * delete_event:
@@ -169,7 +177,7 @@ typedef struct {
 	 * can so implement the virtual function, without having to take
 	 * care of the signal itself.
 	 */
-	gboolean          ( *delete_event )         ( BaseWindow *window, GtkWindow *toplevel, GdkEvent *event );
+	gboolean ( *delete_event )         ( BaseWindow *window, GtkWindow *toplevel, GdkEvent *event );
 
 	/**
 	 * window_get_toplevel_name:
@@ -177,7 +185,7 @@ typedef struct {
 	 *
 	 * Pure virtual function.
 	 */
-	gchar *           ( *get_toplevel_name )    ( const BaseWindow *window );
+	gchar *  ( *get_toplevel_name )    ( const BaseWindow *window );
 
 	/**
 	 * get_iprefs_window_id:
@@ -189,7 +197,7 @@ typedef struct {
 	 * This delegates to #BaseWindow-derived classes the NactIPrefs
 	 * interface virtual function.
 	 */
-	gchar *           ( *get_iprefs_window_id ) ( const BaseWindow *window );
+	gchar *  ( *get_iprefs_window_id ) ( const BaseWindow *window );
 
 	/**
 	 * get_ui_filename:
@@ -204,7 +212,7 @@ typedef struct {
 	 * Returns: the filename of the XML definition, to be g_free() by
 	 * the caller.
 	 */
-	gchar *           ( *get_ui_filename )      ( const BaseWindow *window );
+	gchar *  ( *get_ui_filename )      ( const BaseWindow *window );
 
 	/**
 	 * is_willing_to_quit:
@@ -219,7 +227,7 @@ typedef struct {
 	 * Returns: the filename of the XML definition, to be g_free() by
 	 * the caller.
 	 */
-	gboolean          ( *is_willing_to_quit )   ( const BaseWindow *window );
+	gboolean ( *is_willing_to_quit )   ( const BaseWindow *window );
 }
 	BaseWindowClass;
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]