Author: sh-sh-sh
Date: Fri Apr 11 17:13:50 2008
New Revision: 46431
URL: http://svn.opensuse.org/viewcvs/yast?rev=46431&view=rev
Log:
consistency
Modified:
trunk/ycp-ui-bindings/src/YCPWizardCommandParser.cc
trunk/ycp-ui-bindings/src/YCPWizardCommandParser.h
Modified: trunk/ycp-ui-bindings/src/YCPWizardCommandParser.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/ycp-ui-bindings/src/YCPWizardCommandParser.cc?rev=46431&r1=46430&r2=46431&view=diff
==============================================================================
--- trunk/ycp-ui-bindings/src/YCPWizardCommandParser.cc (original)
+++ trunk/ycp-ui-bindings/src/YCPWizardCommandParser.cc Fri Apr 11 17:13:50 2008
@@ -97,11 +97,12 @@
if ( isCommand( "Ping()" , cmd ) ) { wizard->ping() ; return true; }
if ( isCommand( "DockSubWizard( any, string, any, string, any, string )", cmd ) )
{
- return dockSubWizard( anyArg( cmd, 0 ), stringArg( cmd, 1 ),
+ return dockSubWizard( wizard,
+ anyArg( cmd, 0 ), stringArg( cmd, 1 ),
anyArg( cmd, 2 ), stringArg( cmd, 3 ),
- anyArg( cmd, 4 ), stringArg( cmd, 5 ) ) != 0;
+ anyArg( cmd, 4 ), stringArg( cmd, 5 ) );
}
- if ( isCommand( "DeleteSubWizard()" , cmd ) ) { wizard->deleteSubWizard(); return true; }
+ if ( isCommand( "DeleteSubWizard()" , cmd ) ) { return deleteSubWizard( wizard ); }
y2error( "Undefined wizard command: %s", cmd->toString().c_str() );
return false;
}
@@ -345,49 +346,63 @@
}
-YWizard *
-YCPWizardCommandParser::dockSubWizard( const YCPValue & backButtonId, const string & backButtonLabel,
+bool
+YCPWizardCommandParser::dockSubWizard( YWizard * parentWizard,
+ const YCPValue & backButtonId, const string & backButtonLabel,
const YCPValue & abortButtonId, const string & abortButtonLabel,
const YCPValue & nextButtonId, const string & nextButtonLabel )
{
try
{
- YWizard * subWizard = 0;
- YWidget * w = YDialog::topmostDialog()->firstChild();
-
- if ( ! w )
- return 0;
-
- YWizard * parentWizard = dynamic_cast (w);
-
if ( parentWizard && parentWizard->wizardMode() == YWizardMode_Steps )
{
- y2milestone( "Docking subwizard" );
- subWizard = YUI::optionalWidgetFactory()->createWizard( parentWizard,
- backButtonLabel,
- abortButtonLabel,
- nextButtonLabel,
- YWizardMode_Standard );
+ YWizard * subWizard = YUI::optionalWidgetFactory()->createWizard( parentWizard,
+ backButtonLabel,
+ abortButtonLabel,
+ nextButtonLabel,
+ YWizardMode_Standard );
YUI_CHECK_NEW( subWizard );
-
- parentWizard->setInternalIdsEnabled( false ); // avoid duplicate IDs
- // All wizard widgets have a fixed ID `wizard
- subWizard->setId( new YCPValueWidgetID( YCPSymbol( YWizardID ) ) );
+ if ( parentWizard->dockSubWizard( subWizard ) )
+ {
+ y2milestone( "Docking subwizard" );
- // The wizard internal contents ReplacePoint has a fixed ID `contents
- subWizard->contentsReplacePoint()->setId( new YCPValueWidgetID( YCPSymbol( YWizardContentsReplacePointID ) ) );
+ // All wizard widgets have a fixed ID `wizard
+ subWizard->setId( new YCPValueWidgetID( YCPSymbol( YWizardID ) ) );
+
+ // The wizard internal contents ReplacePoint has a fixed ID `contents
+ subWizard->contentsReplacePoint()->setId( new YCPValueWidgetID( YCPSymbol( YWizardContentsReplacePointID ) ) );
+
+ if ( subWizard->backButton() ) subWizard->backButton()->setId ( new YCPValueWidgetID( backButtonId ) );
+ if ( subWizard->abortButton() ) subWizard->abortButton()->setId( new YCPValueWidgetID( abortButtonId ) );
+ if ( subWizard->nextButton() ) subWizard->nextButton()->setId ( new YCPValueWidgetID( nextButtonId ) );
+ }
+ else // Docking failed
+ {
+ y2warning( "Docking subwizard failed" );
- if ( subWizard->backButton() ) subWizard->backButton()->setId ( new YCPValueWidgetID( backButtonId ) );
- if ( subWizard->abortButton() ) subWizard->abortButton()->setId( new YCPValueWidgetID( abortButtonId ) );
- if ( subWizard->nextButton() ) subWizard->nextButton()->setId ( new YCPValueWidgetID( nextButtonId ) );
+ delete subWizard;
+ return false; // failure
+ }
}
- return subWizard;
+ return true; // success
}
catch ( YUIException & exception )
{
YUI_CAUGHT( exception );
- return 0;
+ return false; // failure
}
}
+
+
+bool
+YCPWizardCommandParser::deleteSubWizard( YWizard * subWizard )
+{
+ YWizard * parentWizard = subWizard->wizardParent();
+
+ if ( parentWizard )
+ return parentWizard->deleteSubWizard( subWizard );
+ else
+ return false; // failure
+}
Modified: trunk/ycp-ui-bindings/src/YCPWizardCommandParser.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/ycp-ui-bindings/src/YCPWizardCommandParser.h?rev=46431&r1=46430&r2=46431&view=diff
==============================================================================
--- trunk/ycp-ui-bindings/src/YCPWizardCommandParser.h (original)
+++ trunk/ycp-ui-bindings/src/YCPWizardCommandParser.h Fri Apr 11 17:13:50 2008
@@ -44,15 +44,6 @@
static bool parseAndExecute( YWizard * wizard,
const YCPTerm & command );
- /**
- * Try to create a new wizard as a sub-wizard as the existing wizard, if
- * the current dialog has a wizard in "steps" mode.
- * Return the new wizard on success and 0 if failed.
- **/
- static YWizard * dockSubWizard( const YCPValue & backButtonId, const string & backButtonLabel,
- const YCPValue & abortButtonId, const string & abortButtonLabel,
- const YCPValue & nextButtonId, const string & nextButtonLabel );
-
private:
/**
@@ -73,7 +64,7 @@
* Remove all whitespace (leading, trailing, and internal) from a string.
**/
static string stripWhitespace( const string & orig );
-
+
/**
* Return argument number 'argNo' from 'term' as string.
**/
@@ -97,7 +88,7 @@
/**
* Enable or disable a widget if it is non-null.
* Disabling the wizard's "Next" button is ignored if it is currently
- * proteced with YWizard::ProtectNextButton().
+ * proteced with YWizard::ProtectNextButton().
**/
static void enable( YWizard * wizard, YWidget * widget, bool enabled );
@@ -107,6 +98,24 @@
static void setFocus( YWidget * widget );
/**
+ * Try to create a new wizard as a sub-wizard as the existing wizard, if
+ * the current dialog has a wizard in "steps" mode.
+ *
+ * Returns 'true' on success, 'false' on failure.
+ **/
+ static bool dockSubWizard( YWizard * parentWizard,
+ const YCPValue & backButtonId, const string & backButtonLabel,
+ const YCPValue & abortButtonId, const string & abortButtonLabel,
+ const YCPValue & nextButtonId, const string & nextButtonLabel );
+
+ /**
+ * Try to delete a sub-wizard.
+ *
+ * Returns 'true' on success, 'false' on failure.
+ **/
+ static bool deleteSubWizard( YWizard * subWizard );
+
+ /**
* Constructor (disabled).
**/
YCPWizardCommandParser() {}
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org