Author: tgoettlicher
Date: Thu Jan 10 17:07:46 2008
New Revision: 43537
URL: http://svn.opensuse.org/viewcvs/yast?rev=43537&view=rev
Log:
added BusyIndicator widget (fate #302559)
Added:
trunk/core/libyui/doc/examples/BusyIndicator.ycp
trunk/core/libyui/src/YBusyIndicator.cc
trunk/core/libyui/src/YBusyIndicator.h
Modified:
trunk/core/VERSION
trunk/core/libyui/src/Makefile.am
trunk/core/libyui/src/YCPDialogParser.cc
trunk/core/libyui/src/YCPDialogParser.h
trunk/core/libyui/src/YUISymbols.h
trunk/core/libyui/src/YWidgetFactory.h
trunk/core/package/yast2-core.changes
Modified: trunk/core/VERSION
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/VERSION?rev=43537&r1=43536&r2=43537&view=diff
==============================================================================
--- trunk/core/VERSION (original)
+++ trunk/core/VERSION Thu Jan 10 17:07:46 2008
@@ -1 +1 @@
-2.16.19
+2.16.20
Added: trunk/core/libyui/doc/examples/BusyIndicator.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libyui/doc/examples/BusyIndicator.ycp?rev=43537&view=auto
==============================================================================
--- trunk/core/libyui/doc/examples/BusyIndicator.ycp (added)
+++ trunk/core/libyui/doc/examples/BusyIndicator.ycp Thu Jan 10 17:07:46 2008
@@ -0,0 +1,33 @@
+// Simple ProgressBar example
+{
+ integer timeout = 1001;
+
+ UI::OpenDialog(
+ `VBox(
+ `BusyIndicator(`id(`busy), "Sample busy indicator", timeout ),
+ `PushButton(`id(`alive), "send &tick"),
+ `PushButton(`id(`query), "&query"),
+ `Right(`PushButton(`id(`close), "&Close" ) )
+ )
+ );
+
+
+ while ( true )
+ {
+ symbol button = (symbol) UI::UserInput();
+
+ if ( button == `alive )
+ {
+ UI::ChangeWidget(`id(`busy), `Alive, true);
+ UI::ChangeWidget(`id(`busy), `Timeout, 999);
+ }
+ else if ( button == `query )
+ {
+ UI::ChangeWidget(`id(`busy), `Label, sformat("timeout: %1, alive: %2",UI::QueryWidget(`id(`busy), `Timeout), UI::QueryWidget(`id(`busy), `Alive)));
+ }
+ else if ( button == `close )
+ break;
+ }
+
+ UI::CloseDialog();
+}
Modified: trunk/core/libyui/src/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libyui/src/Makefile.am?rev=43537&r1=43536&r2=43537&view=diff
==============================================================================
--- trunk/core/libyui/src/Makefile.am (original)
+++ trunk/core/libyui/src/Makefile.am Thu Jan 10 17:07:46 2008
@@ -42,6 +42,7 @@
YWidgetFactory.cc \
YOptionalWidgetFactory.cc \
YWidgetID.cc \
+ YBusyIndicator.cc \
\
YAlignment.cc \
YBarGraph.cc \
@@ -191,6 +192,7 @@
YTimezoneSelector.h \
YTree.h \
YWizard.h \
+ YBusyIndicator.h \
\
YRpmGroupsTree.h \
YStringTree.h \
Added: trunk/core/libyui/src/YBusyIndicator.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libyui/src/YBusyIndicator.cc?rev=43537&view=auto
==============================================================================
--- trunk/core/libyui/src/YBusyIndicator.cc (added)
+++ trunk/core/libyui/src/YBusyIndicator.cc Thu Jan 10 17:07:46 2008
@@ -0,0 +1,154 @@
+/*---------------------------------------------------------------------\
+| |
+| __ __ ____ _____ ____ |
+| \ \ / /_ _/ ___|_ _|___ \ |
+| \ V / _` \___ \ | | __) | |
+| | | (_| |___) || | / __/ |
+| |_|\__,_|____/ |_| |_____| |
+| |
+| core system |
+| (C) SuSE GmbH |
+\----------------------------------------------------------------------/
+
+ File: YBusyIndicator.cc
+
+ Author: Thomas Goettlicher
+
+/-*/
+
+
+#define y2log_component "ui"
+#include
+
+#include "YUISymbols.h"
+#include "YBusyIndicator.h"
+
+struct YBusyIndicatorPrivate
+{
+ YBusyIndicatorPrivate( const string & label,
+ int timeout ,
+ bool alive )
+ : label( label )
+ , timeout( timeout )
+ , alive (true)
+ {
+ }
+
+ string label;
+ int timeout;
+ bool alive;
+};
+
+
+
+
+YBusyIndicator::YBusyIndicator( YWidget * parent,
+ const string & label,
+ int timeout,
+ bool alive )
+ : YWidget( parent )
+ , priv( new YBusyIndicatorPrivate( label, timeout, alive ) )
+{
+ YUI_CHECK_NEW( priv );
+
+ setDefaultStretchable( YD_HORIZ, true );
+ setStretchable( YD_VERT, false );
+}
+
+
+YBusyIndicator::~YBusyIndicator()
+{
+ // NOP
+}
+
+
+string YBusyIndicator::label()
+{
+ return priv->label;
+}
+
+
+void YBusyIndicator::setLabel( const string & label )
+{
+ priv->label = label;
+}
+
+
+int YBusyIndicator::timeout() const
+{
+ return priv->timeout;
+}
+
+
+void YBusyIndicator::setTimeout( int newTimeout )
+{
+ if ( newTimeout < 1 )
+ newTimeout = 1;
+
+ priv->timeout = newTimeout;
+}
+
+
+void YBusyIndicator::setAlive( bool alive )
+{
+ priv->alive = alive;
+}
+
+bool YBusyIndicator::alive() const
+{
+ return priv->alive;
+}
+
+const YPropertySet &
+YBusyIndicator::propertySet()
+{
+ static YPropertySet propSet;
+
+ if ( propSet.isEmpty() )
+ {
+ /*
+ * @property integer Timeout timeout until busy indicator changes to stalled state
+ * @property bool Alive busy indicator is in alive or stalled state
+ * @property string Label caption above the busy indicator
+ */
+ propSet.add( YProperty( YUIProperty_Timeout, YIntegerProperty ) );
+ propSet.add( YProperty( YUIProperty_Alive, YBoolProperty ) );
+ propSet.add( YProperty( YUIProperty_Label, YStringProperty ) );
+ propSet.add( YWidget::propertySet() );
+ }
+
+ return propSet;
+}
+
+
+bool
+YBusyIndicator::setProperty( const string & propertyName, const YPropertyValue & val )
+{
+ propertySet().check( propertyName, val.type() ); // throws exceptions if not found or type mismatch
+
+ if ( propertyName == YUIProperty_Timeout ) setTimeout( val.integerVal() );
+ else if ( propertyName == YUIProperty_Alive ) setAlive( val.boolVal() );
+ else if ( propertyName == YUIProperty_Label ) setLabel( val.stringVal() );
+ else
+ {
+ return YWidget::setProperty( propertyName, val );
+ }
+
+ return true; // success -- no special processing necessary
+}
+
+
+YPropertyValue
+YBusyIndicator::getProperty( const string & propertyName )
+{
+ propertySet().check( propertyName ); // throws exceptions if not found
+
+ if ( propertyName == YUIProperty_Timeout ) return YPropertyValue( timeout() );
+ else if ( propertyName == YUIProperty_Label ) return YPropertyValue( label() );
+ else if ( propertyName == YUIProperty_Alive ) return YPropertyValue( alive() );
+ else
+ {
+ return YWidget::getProperty( propertyName );
+ }
+}
+
Added: trunk/core/libyui/src/YBusyIndicator.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libyui/src/YBusyIndicator.h?rev=43537&view=auto
==============================================================================
--- trunk/core/libyui/src/YBusyIndicator.h (added)
+++ trunk/core/libyui/src/YBusyIndicator.h Thu Jan 10 17:07:46 2008
@@ -0,0 +1,129 @@
+/*---------------------------------------------------------------------\
+| |
+| __ __ ____ _____ ____ |
+| \ \ / /_ _/ ___|_ _|___ \ |
+| \ V / _` \___ \ | | __) | |
+| | | (_| |___) || | / __/ |
+| |_|\__,_|____/ |_| |_____| |
+| |
+| core system |
+| (C) SuSE GmbH |
+\----------------------------------------------------------------------/
+
+ File: YBusyIndicator.h
+
+ Author: Thomas Goettlicher
+
+/-*/
+
+#ifndef YBusyIndicator_h
+#define YBusyIndicator_h
+
+#include "YWidget.h"
+
+class YBusyIndicatorPrivate;
+
+
+class YBusyIndicator : public YWidget
+{
+protected:
+ /**
+ * Constructor.
+ **/
+ YBusyIndicator( YWidget * parent,
+ const string & label,
+ int timeout = 1000,
+ bool alive = true );
+
+public:
+ /**
+ * Destructor.
+ **/
+ virtual ~YBusyIndicator();
+
+ /**
+ * Returns a descriptive name of this widget class for logging,
+ * debugging etc.
+ **/
+ virtual const char * widgetClass() const { return "YBusyIndicator"; }
+
+ /**
+ * Get the label (the caption above the progress bar).
+ **/
+ string label();
+
+ /**
+ * Set the label (the caption above the progress bar).
+ *
+ * Derived classes are free to reimplement this, but they should call this
+ * base class method at the end of the overloaded function.
+ **/
+ virtual void setLabel( const string & label );
+
+ /**
+ * Return the current timout value.
+ **/
+ int timeout() const;
+
+ /**
+ * Set the timeout is ms after that the widget shows 'stalled' when no
+ * new tick is received.
+ *
+ * Derived classes should reimplement this, but they should call this
+ * base class method at the end of the overloaded function.
+ **/
+ virtual void setTimeout( int newTimeout );
+
+ /**
+ * Return whether busy indicator is alive or in stalled stated.
+ **/
+ bool alive() const;
+
+
+ /**
+ * Send a keep alive message to prevent BusyIndicator from changing
+ * to 'stalled' state.
+ *
+ * Derived classes should reimplement this, but they should call this
+ * base class method at the end of the overloaded function.
+ **/
+ virtual void setAlive( bool newAlive );
+
+
+ /**
+ * Set a property.
+ * Reimplemented from YWidget.
+ *
+ * This function may throw YUIPropertyExceptions.
+ *
+ * This function returns 'true' if the value was successfully set and
+ * 'false' if that value requires special handling (not in error cases:
+ * those are covered by exceptions).
+ **/
+ virtual bool setProperty( const string & propertyName,
+ const YPropertyValue & val );
+
+ /**
+ * Get a property.
+ * Reimplemented from YWidget.
+ *
+ * This method may throw YUIPropertyExceptions.
+ **/
+ virtual YPropertyValue getProperty( const string & propertyName );
+
+ /**
+ * Return this class's property set.
+ * This also initializes the property upon the first call.
+ *
+ * Reimplemented from YWidget.
+ **/
+ virtual const YPropertySet & propertySet();
+
+
+private:
+
+ ImplPtr<YBusyIndicatorPrivate> priv;
+};
+
+
+#endif // YBusyIndicator_h
Modified: trunk/core/libyui/src/YCPDialogParser.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libyui/src/YCPDialogParser.cc?rev=43537&r1=43536&r2=43537&view=diff
==============================================================================
--- trunk/core/libyui/src/YCPDialogParser.cc (original)
+++ trunk/core/libyui/src/YCPDialogParser.cc Thu Jan 10 17:07:46 2008
@@ -80,6 +80,7 @@
#include "YTree.h"
#include "YWizard.h"
#include "YTimezoneSelector.h"
+#include "YBusyIndicator.h"
using std::string;
@@ -262,6 +263,7 @@
else if ( s == YUIWidget_VSquash ) w = parseSquash ( p, opt, term, ol, n, false, true );
else if ( s == YUIWidget_VStretch ) w = parseSpacing ( p, opt, term, ol, n, YD_VERT, true );
else if ( s == YUIWidget_VWeight ) w = parseWeight ( p, opt, term, ol, n, YD_VERT );
+ else if ( s == YUIWidget_BusyIndicator ) w = parseBusyIndicator ( p, opt, term, ol, n );
// Special widgets - may or may not be supported by the specific UI.
// The YCP application should ask for presence of such a widget with Has???Widget() prior to creating one.
@@ -2198,6 +2200,9 @@
* value will be 100. If you omit the optional parameter <tt>progress</tt>, the
* progress bar will set to 0 initially.
*
+ * If you don't know the number of total steps you might want to use the
+ * BusyIndicator widget instead of ProgressBar.
+ *
**/
YWidget *
@@ -3307,6 +3312,54 @@
return selector;
}
+/**
+ * @widget Busy Indicator
+ * @short Graphical busy indicator
+ * @class YBusyIndicator
+ * @arg string label the label describing the bar
+ * @optarg integer timeout the timout until busy indicator changes to stalled state
+ * @usage `BusyIndicator(`id(`busy), "background action", 2000 ),
+ * @example BusyIndicator.ycp
+ *
+ * @description
+ *
+ * A busy indicator is a bar with a label that gives feedback to the user that
+ * a task is in progress and the user has to wait. It is similar to a progress bar.
+ * The difference is that a busy indicator can be used when the total number of
+ * steps is not known before the action starts. You have to send keep alive messages
+ * by setting alive to true every now and then, otherwise the busy indicator will
+ * change to stalled state.
+ *
+ **/
+
+YWidget *
+YCPDialogParser::parseBusyIndicator( YWidget * parent, YWidgetOpt & opt,
+ const YCPTerm & term, const YCPList & optList, int argnr )
+{
+ int s = term->size() - argnr;
+ if ( s < 1
+ || s > 2
+ || (s >= 1 && !term->value(argnr)->isString())
+ || (s >= 2 && !term->value(argnr+1)->isInteger()) )
+ {
+ y2error( "Invalid arguments for the BusyIndicator widget: %s",
+ term->toString().c_str() );
+ return 0;
+ }
+
+ rejectAllOptions( term,optList );
+
+ string label = term->value( argnr )->asString()->value();
+ int timeout = 1000;
+
+ if ( s >= 2 ) timeout = term->value( argnr+1 )->asInteger()->value();
+
+ YBusyIndicator * busyIndicator = YUI::widgetFactory()->createBusyIndicator( parent, label, timeout );
+
+ return busyIndicator;
+}
+
+
// =============================================================================
Modified: trunk/core/libyui/src/YCPDialogParser.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libyui/src/YCPDialogParser.h?rev=43537&r1=43536&r2=43537&view=diff
==============================================================================
--- trunk/core/libyui/src/YCPDialogParser.h (original)
+++ trunk/core/libyui/src/YCPDialogParser.h Thu Jan 10 17:07:46 2008
@@ -268,6 +268,8 @@
static YWidget * parseTimezoneSelector ( YWidget *parent, YWidgetOpt & opt, const YCPTerm & term,
const YCPList & optList, int argnr );
+ static YWidget * parseBusyIndicator( YWidget *parent, YWidgetOpt & opt,
+ const YCPTerm & term, const YCPList & optList, int argnr );
/**
* Look for a widget id in a widget term. If it finds one, returns
* it and sets argnr to 1, otherwise it creates a new unique widget
Modified: trunk/core/libyui/src/YUISymbols.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libyui/src/YUISymbols.h?rev=43537&r1=43536&r2=43537&view=diff
==============================================================================
--- trunk/core/libyui/src/YUISymbols.h (original)
+++ trunk/core/libyui/src/YUISymbols.h Thu Jan 10 17:07:46 2008
@@ -124,6 +124,7 @@
#define YUIWidget_VStretch "VStretch"
#define YUIWidget_VWeight "VWeight"
#define YUIWidget_PkgSpecial "PkgSpecial"
+#define YUIWidget_BusyIndicator "BusyIndicator"
// Special (optional) widgets
@@ -177,6 +178,8 @@
#define YUIProperty_Values "Values"
#define YUIProperty_VisibleLines "VisibleLines"
#define YUIProperty_WidgetClass "WidgetClass"
+#define YUIProperty_Timeout "Timeout"
+#define YUIProperty_Alive "Alive"
// Widget and dialog options
Modified: trunk/core/libyui/src/YWidgetFactory.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libyui/src/YWidgetFactory.h?rev=43537&r1=43536&r2=43537&view=diff
==============================================================================
--- trunk/core/libyui/src/YWidgetFactory.h (original)
+++ trunk/core/libyui/src/YWidgetFactory.h Thu Jan 10 17:07:46 2008
@@ -56,6 +56,7 @@
class YTableHeader;
class YTimeField;
class YTree;
+class YBusyIndicator;
@@ -102,6 +103,7 @@
virtual YTable * createTable ( YWidget * parent, YTableHeader * header ) = 0;
virtual YProgressBar * createProgressBar ( YWidget * parent, const string & label, int maxValue = 100 ) = 0;
virtual YRichText * createRichText ( YWidget * parent, const string & text = string(), bool plainTextMode = false ) = 0;
+ virtual YBusyIndicator * createBusyIndicator ( YWidget * parent, const string & label, int timeout = 1000 ) = 0;
//
// Less Common Leaf Widgets
Modified: trunk/core/package/yast2-core.changes
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/package/yast2-core.changes?rev=43537&r1=43536&r2=43537&view=diff
==============================================================================
--- trunk/core/package/yast2-core.changes (original)
+++ trunk/core/package/yast2-core.changes Thu Jan 10 17:07:46 2008
@@ -1,4 +1,10 @@
-------------------------------------------------------------------
+Thu Jan 10 17:10:00 CET 2008 - tgoettlicher@suse.de
+
+- added BusyIndicator widget (fate #302559)
+- V 2.16.20
+
+-------------------------------------------------------------------
Thu Jan 10 09:48:14 CET 2008 - lslezak@suse.cz
- added .modprobe_blacklist agent for parsing
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org