Mailinglist Archive: yast-devel (101 mails)

< Previous Next >
[yast-devel] Progress::New() can be called recursively now
  • From: Ladislav Slezak <lslezak@xxxxxxx>
  • Date: Wed, 23 Jan 2008 09:17:35 +0100
  • Message-id: <4796F81F.50001@xxxxxxx>

Hi all,

I changed the internals of Progress:: module to support multiple (nested)
invocations of Progress::New() function. The change has been submitted in
yast2-2.16.22. Here are some details about my change.


Introduction
------------

So what's the change is about? Imagine two yast modules which use Progress:: in
their Write() function. Now you would like to use these two modules in your
client and display a progress in your Write() function.

The problem is that the there will be displayed two independent progresses (from
0% to 100%), one for each Write() call and that's not what user expects -
progress 100% doesn't mean that the work is finished! So the usual solution is
to disable Progress:: before calling another Write(), but the details about the
nested progress are lost.

The new functionality allows you to create a "parent progress" which has two
stages. The progress values will be recalculated so that the first Write() call
will display progress from 0% to 50% the second one from 50% to 100%.

The level is "unlimited", the first Write() can call another nested two Write()
functions which will be recalculated to 0%-25% and to 25%-50%, and so on...


Why it was changed?
-------------------

I wanted to fix bug #352007. The package callbacks now use Progress:: module and
many yast clients already use Progress:: at start and starting the package
manager is usually one step in their progress (e.g. online_update, sw_single).
Now the progress bar displays correct (recalculated) values for the package
manager steps.

This allows us to build new modules on top of others without loosing details in
Read() and Write() functions. If you do not want to display some details you can
still hide them using Progress::set(false).


Internals of Progress::
-----------------------

Progress:: has now an internal stack with progress state, Progress::New() checks
if there is already a progress running, if there is no progress it behaves as it
did in the past.

When there is already a progress running then Progress::New() pushes the current
state to the stack and all progress values are recalculated according to the
previous states. (In this case the stages are not displayed, they are part of
the parent stage.)

Progress::Finish() pops the state from the stack so the previous internal state
is set back.


Examples
--------

There are some examples in SVN, see
yast2/library/wizard/doc/examples/progress_*.ycp files, I think this is the best
way to learn how it works and how to use the new feature...



--

Best Regards

Ladislav Slez√°k
Yast Developer
------------------------------------------------------------------------
SUSE LINUX, s.r.o. e-mail: lslezak@xxxxxxx
Lihovarsk√° 1060/12 tel: +420 284 028 960
190 00 Prague 9 fax: +420 284 028 951
Czech Republic http://www.suse.cz/
--
To unsubscribe, e-mail: yast-devel+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: yast-devel+help@xxxxxxxxxxxx

< Previous Next >
Follow Ups