Commit b989dc75 authored by Pierre Wieser's avatar Pierre Wieser

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.
parent 5e5fc6a3
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;
......
......@@ -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 );
......
......@@ -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.
......
......@@ -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 );
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment