[nautilus-actions] BaseApplication::manage_options() method is successively invoked for all derived classes



commit b989dc75cea2689ee2ed07686b62b3a427cd3e35
Author: Pierre Wieser <pwieser trychlos org>
Date:   Sat Jan 22 14:54:57 2011 +0100

    BaseApplication::manage_options() method is successively invoked for all derived classes
    
    Rationale: invoking the parent class method from the derived class, hoping that this will successively
    invoke all class hierarchy, does not work if one of the intermediate class does not actually implement
    this virtual method.

 ChangeLog                   |    7 +++++++
 src/nact/base-application.c |    8 ++++++--
 src/nact/base-application.h |   11 ++++++++---
 src/nact/nact-application.c |    5 -----
 4 files changed, 21 insertions(+), 10 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 14236c0..5cdf3d0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2011-01-22 Pierre Wieser <pwieser trychlos org>
 
+	* src/nact/base-application.c (appli_initialize_manage_options):
+	Successively invoke all derived class methods.
+
+	* src/nact/base-application.h (manage_options): Update comment.
+
+	* src/nact/nact-application.c (appli_manage_options): Updated accordingly.
+
 	* src/nact/base-builder.c:
 	* src/nact/base-builder.h (base_builder_get_toplevel_by_name):
 	Use a const BaseBuilder as argument;
diff --git a/src/nact/base-application.c b/src/nact/base-application.c
index fcc6b52..accdfdd 100644
--- a/src/nact/base-application.c
+++ b/src/nact/base-application.c
@@ -399,6 +399,7 @@ instance_finalize( GObject *application )
 	self = BASE_APPLICATION( application );
 
 	g_free( self->private->application_name );
+	g_free( self->private->description );
 	g_free( self->private->icon_name );
 	g_free( self->private->unique_app_name );
 
@@ -546,13 +547,16 @@ appli_initialize_manage_options( const BaseApplication *application, int *code )
 {
 	static const gchar *thisfn = "base_application_appli_initialize_manage_options";
 	gboolean ret;
+	GObjectClass *class;
 
 	g_debug( "%s: application=%p, code=%p (%d)", thisfn, ( void * ) application, ( void * ) code, *code );
 
 	ret = TRUE;
 
-	if( BASE_APPLICATION_GET_CLASS( application )->manage_options ){
-		ret = BASE_APPLICATION_GET_CLASS( application )->manage_options( application, code );
+	for( class = G_OBJECT_GET_CLASS( application ) ; ret && BASE_IS_APPLICATION_CLASS( class ) ; class = g_type_class_peek_parent( class )){
+		if( BASE_APPLICATION_CLASS( class )->manage_options ){
+			ret = BASE_APPLICATION_CLASS( class )->manage_options( application, code );
+		}
 	}
 
 	return( ret );
diff --git a/src/nact/base-application.h b/src/nact/base-application.h
index 387b749..ab806c4 100644
--- a/src/nact/base-application.h
+++ b/src/nact/base-application.h
@@ -115,8 +115,12 @@ typedef struct {
 	 * This let the derived class an opportunity to manage command-line
 	 * arguments.
 	 *
-	 * If it does not dected an error, the derived class should call the
-	 * parent method, to give it a chance to manage its own options.
+	 * The BaseApplication base class takes care of successively invoking
+	 * all manage_options() methods of derived classes, from the topmost
+	 * derived class up to the BaseApplication base class, while each methods
+	 * returns %TRUE.
+	 *
+	 * In other words, it stops this loop as soon as a method returns %FALSE.
 	 *
 	 * Returns: %TRUE to continue execution, %FALSE to stop it.
 	 */
@@ -129,7 +133,8 @@ typedef struct {
 	 * This is invoked by the BaseApplication base class to let the derived
 	 * class do its own initializations and create its main window.
 	 *
-	 * This is a pure virtual method.
+	 * This is a pure virtual method. Only the most derived class
+	 * main_window_new() method is invoked.
 	 *
 	 * Returns: the main window of the application, as a #BaseWindow
 	 * -derived object. It may or may not have already been initialized.
diff --git a/src/nact/nact-application.c b/src/nact/nact-application.c
index d7c4d54..db6eb0e 100644
--- a/src/nact/nact-application.c
+++ b/src/nact/nact-application.c
@@ -323,11 +323,6 @@ appli_manage_options( const BaseApplication *application, int *code )
 		g_object_set( G_OBJECT( application ), BASE_PROP_UNIQUE_APP_NAME, "", NULL );
 	}
 
-	/* call parent class */
-	if( ret && BASE_APPLICATION_CLASS( st_parent_class )->manage_options ){
-		ret = BASE_APPLICATION_CLASS( st_parent_class )->manage_options( application, code );
-	}
-
 	return( ret );
 }
 



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