Author: locilka
Date: Thu Apr 24 15:23:39 2008
New Revision: 47036
URL: http://svn.opensuse.org/viewcvs/yast?rev=47036&view=rev
Log:
- New better shiny unified progress for image deployment.
- Showing also the just-handled image name (bnc #381188).
- 2.16.39
Modified:
trunk/installation/VERSION
trunk/installation/package/yast2-installation.changes
trunk/installation/src/clients/inst_deploy_image.ycp
trunk/installation/src/modules/ImageInstallation.ycp
Modified: trunk/installation/VERSION
URL: http://svn.opensuse.org/viewcvs/yast/trunk/installation/VERSION?rev=47036&r1=47035&r2=47036&view=diff
==============================================================================
--- trunk/installation/VERSION (original)
+++ trunk/installation/VERSION Thu Apr 24 15:23:39 2008
@@ -1 +1 @@
-2.16.38
+2.16.39
Modified: trunk/installation/package/yast2-installation.changes
URL: http://svn.opensuse.org/viewcvs/yast/trunk/installation/package/yast2-installation.changes?rev=47036&r1=47035&r2=47036&view=diff
==============================================================================
--- trunk/installation/package/yast2-installation.changes (original)
+++ trunk/installation/package/yast2-installation.changes Thu Apr 24 15:23:39 2008
@@ -1,4 +1,11 @@
-------------------------------------------------------------------
+Thu Apr 24 14:54:53 CEST 2008 - locilka@suse.cz
+
+- New better shiny unified progress for image deployment.
+- Showing also the just-handled image name (bnc #381188).
+- 2.16.39
+
+-------------------------------------------------------------------
Wed Apr 23 15:10:24 CEST 2008 - locilka@suse.cz
- Enabling inst_suseconfig in Automatic configuration (bnc #381751)
Modified: trunk/installation/src/clients/inst_deploy_image.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/installation/src/clients/inst_deploy_image.ycp?rev=47036&r1=47035&r2=47036&view=diff
==============================================================================
--- trunk/installation/src/clients/inst_deploy_image.ycp (original)
+++ trunk/installation/src/clients/inst_deploy_image.ycp Thu Apr 24 15:23:39 2008
@@ -5,6 +5,7 @@
import "Wizard";
import "SourceManager";
import "String";
+import "PackageCallbacks";
textdomain "installation";
@@ -14,51 +15,124 @@
return `auto;
}
-y2milestone ("Deploying image");
+y2milestone ("Deploying images");
list<string> images = ImageInstallation::ImageOrder ();
integer last_image = nil;
-/**
- * Set the progress
- * @param image integer the number of image
- * @param percent integer the percentage of the particular image
- */
-void SetProgress (integer image, integer percent) {
- if (percent >= 100)
- image = image + 1;
-
- if (image != last_image) {
- last_image = image;
- if (image < size (images)) {
- UI::ChangeWidget (
- `id ("deploying_progress"),
- `Label,
- sformat (_("Deploying Images (%1/%2)..."), (image + 1), size (images))
- );
+integer _last_download_progress = -1;
+
+integer _current_overall_progress = 0;
+integer _last_overall_progress = -1;
+
+integer _current_subprogress_start = 0;
+integer _current_subprogress_steps = 0;
+integer _current_subprogress_total = 0;
+
+integer _current_step_in_subprogress = 0;
+
+string _previous_id = nil;
+
+void SetProgress () {
+ integer percent = 100 * _current_step_in_subprogress / _current_subprogress_total;
+ UI::ChangeWidget (`id ("one_image"), `Value, percent);
+}
+
+void OverallProgressHandler (string id, integer current_step) {
+ // new set of steps
+ if (_previous_id != id) {
+ // reset steps in subprogress
+ _current_step_in_subprogress = 0;
+
+ // new settings for new step
+ _current_subprogress_start = ImageInstallation::GetProgressLayoutDetails (id, "steps_start_at");
+ _current_subprogress_steps = ImageInstallation::GetProgressLayoutDetails (id, "steps_reserved");
+ _current_subprogress_total = ImageInstallation::GetProgressLayoutDetails (id, "steps_total");
+
+ // div by zero!
+ if (_current_subprogress_total == 0) {
+ y2error ("steps_total=0");
+ _current_subprogress_total = 100;
}
+
+ y2milestone (
+ "New overall progress ID: %1 (steps_start_at: %2, steps_reserved: %3, steps_total: %4)",
+ id, _current_subprogress_start, _current_subprogress_steps, _current_subprogress_total
+ );
+
+ // when deploying images, label is handled separately
+ if (id != "deploying_images") {
+ string new_label = ImageInstallation::GetProgressLayoutLabel (id);
+ UI::ChangeWidget (`id ("one_image"), `Label, new_label);
+ }
+
+ _previous_id = id;
+ }
+
+ // incremental
+ if (current_step == nil) {
+ _current_step_in_subprogress = _current_step_in_subprogress + 1;
+ // set to exact number
+ } else {
+ _current_step_in_subprogress = current_step;
+ }
+
+ if (id == "storing_user_prefs" || id == "restoring_user_prefs") {
+ SetProgress();
}
- UI::ChangeWidget (
- `id ("deploying_progress"),
- `Value,
- image
- );
+ _current_overall_progress = _current_subprogress_start +
+ (_current_subprogress_steps * _current_step_in_subprogress / _current_subprogress_total);
+
+ // update UI only if nr% has changed
+ if (_current_overall_progress > _last_overall_progress) {
+ _last_overall_progress = _current_overall_progress;
+ UI::ChangeWidget (`id ("deploying_progress"), `Value, _current_overall_progress);
+ }
}
-integer _last_download_progress = -1;
+integer _steps_for_one_image = 100;
+boolean download_handler_hit = false;
boolean MyProgressDownloadHandler (integer percent, integer bps_avg, integer bps_current) {
- // FIXME: remove this line
- y2milestone ("PerCent: %1, AVG: %2, Spd: %3", percent, bps_avg, bps_current);
+ // changing settings on the fly
+ // ... first when download handler is hit
+ if (! download_handler_hit) {
+ y2milestone ("DownloadHandler - first hit");
+ // twice more steps
+ ImageInstallation::AdjustProgressLayout ("deploying_images", (2 * _steps_for_one_image * size (images)), _("Deploying mages..."));
+ download_handler_hit = true;
+ }
+
+ map current_image = ImageInstallation::GetCurrentImageDetails();
if (_last_download_progress < percent) {
- UI::ChangeWidget (
- `id ("one_image"), `Label,
- sformat (_("Downloading image at speed %1/s"), String::FormatSize (bps_current))
- );
+ string current_image_name = current_image["name"]:"";
+ if (current_image_name == "") {
+ UI::ChangeWidget (
+ `id ("one_image"), `Label,
+ sformat (_("Downloading image at speed %1/s"), String::FormatSize (bps_current))
+ );
+ } else {
+ UI::ChangeWidget (
+ `id ("one_image"), `Label,
+ sformat (_("Downloading image %1 at speed %2/s"), current_image_name, String::FormatSize (bps_current))
+ );
+ }
+
UI::ChangeWidget (`id ("one_image"), `Value, percent);
+
+ integer current_image_nr = current_image["image_nr"]:0;
+ integer current_steps = 0;
+
+ if (download_handler_hit) {
+ current_steps = (current_image_nr * 2 * _steps_for_one_image) + percent;
+ } else {
+ current_steps = (current_image_nr * _steps_for_one_image) + percent;
+ }
+
+ OverallProgressHandler ("deploying_images", current_steps);
}
_last_download_progress = percent;
@@ -91,7 +165,12 @@
// reset the label
if (x_progress == 0) {
- UI::ChangeWidget (`id ("one_image"), `Label, _("Deploying image..."));
+ string current_image_name = current_image["name"]:"";
+ if (current_image_name == "") {
+ UI::ChangeWidget (`id ("one_image"), `Label, _("Deploying image..."));
+ } else {
+ UI::ChangeWidget (`id ("one_image"), `Label, sformat (_("Deploying image %1..."), current_image_name));
+ }
// one image done
} else if (x_progress == 100) {
UI::ChangeWidget (`id ("one_image"), `Label, _("Image deployed"));
@@ -101,45 +180,61 @@
if (x_progress > _last_progress) {
UI::ChangeWidget (`id ("one_image"), `Value, x_progress);
_last_progress = x_progress;
+ integer current_image_nr = current_image["image_nr"]:0;
+ integer current_steps = 0;
+
+ if (download_handler_hit) {
+ current_steps = ((current_image_nr * 2 + 1) * _steps_for_one_image) + x_progress;
+ } else {
+ current_steps = (current_image_nr * _steps_for_one_image) + x_progress;
+ }
+
+ OverallProgressHandler ("deploying_images", current_steps);
}
}
ImageInstallation::SetDeployTarImageProgress (SetOneImageProgress);
ImageInstallation::SetDownloadTarImageProgress (MyProgressDownloadHandler);
+ImageInstallation::SetOverallDeployingProgress (OverallProgressHandler);
-ImageInstallation::StoreAllChanges();
-
-Pkg::TargetFinish ();
+ImageInstallation::AdjustProgressLayout ("deploying_images", (_steps_for_one_image * size (images)), _("Deploying mages..."));
Wizard::SetContents (
_("Deploying Installation Images"),
`VBox (
`ProgressBar (
`id ("one_image"),
- _("Deploying image..."),
+ _("Initializing..."),
100,
0
),
`ProgressBar (
`id ("deploying_progress"),
_("Deploying Images..."),
- size(images),
+ 100,
0
)
),
"",
false, false
);
+
+ImageInstallation::StoreAllChanges();
+
+Pkg::TargetFinish ();
+
Wizard::SetTitleIcon ("yast-inst-mode");
SourceManager::InstInitSourceMoveDownloadArea();
-ImageInstallation::DeployImages (images, Installation::destdir, SetProgress);
+ImageInstallation::DeployImages (images, Installation::destdir, nil);
y2milestone ("Target image for package selector prepared");
+PackageCallbacks::RegisterEmptyProgressCallbacks();
Pkg::TargetInitialize (Installation::destdir);
Pkg::TargetLoad ();
+PackageCallbacks::RestorePreviousProgressCallbacks();
ImageInstallation::RestoreAllChanges();
Modified: trunk/installation/src/modules/ImageInstallation.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/installation/src/modules/ImageInstallation.ycp?rev=47036&r1=47035&r2=47036&view=diff
==============================================================================
--- trunk/installation/src/modules/ImageInstallation.ycp (original)
+++ trunk/installation/src/modules/ImageInstallation.ycp Thu Apr 24 15:23:39 2008
@@ -175,6 +175,13 @@
y2milestone ("New download_image_progress: %1", download_image_progress);
}
+void (string, integer) generic_set_progress = nil;
+
+global void SetOverallDeployingProgress (void (string, integer) odp) {
+ generic_set_progress = odp;
+ y2milestone ("New generic_set_progress: %1", generic_set_progress);
+}
+
/**
* Deploy an image of the filesystem type
* @param id string the id of the image
@@ -192,6 +199,7 @@
return false;
}
+ // reset, adjust labels, etc.
if (tar_image_progress != nil)
tar_image_progress (0);
@@ -249,6 +257,7 @@
}
y2milestone ("Finished");
+ // adjust labels etc.
if (tar_image_progress != nil)
tar_image_progress (100);
@@ -334,7 +343,11 @@
// FIXME unmounting
}
+integer _current_image_from_imageset = -1;
+
void SetCurrentImageDetails (map img) {
+ _current_image_from_imageset = _current_image_from_imageset + 1;
+
if (size (images_details) == 0) {
y2warning ("Images details are empty");
}
@@ -346,6 +359,7 @@
"files" : images_details[img["file"]:"","files"]:0,
// 100% progress
"max_progress" : tointeger (images_details[img["file"]:"","size"]:0 / _record_size),
+ "image_nr" : _current_image_from_imageset,
];
}
@@ -498,12 +512,15 @@
Pkg::CallbackProgressDownload (download_image_progress);
integer num = -1;
+ _current_image_from_imageset = -1;
foreach (string img, images, {
num = num + 1;
- progress (num, 0);
+ if (progress != nil)
+ progress (num, 0);
DeployImage (img, target);
- progress (num, 100);
+ if (progress != nil)
+ progress (num, 100);
});
// unregister downloading progress
@@ -824,6 +841,40 @@
*/
map > objects_state = $[];
+ map progress_layout = $[
+ "storing_user_prefs" : $[
+ "steps_start_at" : 0,
+ "steps_reserved" : 6,
+ ],
+ "deploying_images" : $[
+ "steps_start_at" : 6,
+ "steps_reserved" : 84,
+
+ ],
+ "restoring_user_prefs" : $[
+ "steps_start_at" : 90,
+ "steps_reserved" : 10,
+ ],
+ ];
+
+ global integer GetProgressLayoutDetails (string id, string details) {
+ return progress_layout[id, details]:0;
+ }
+
+ global string GetProgressLayoutLabel (string id) {
+ return progress_layout[id, "label"]:_("Deploying...");
+ }
+
+ global void AdjustProgressLayout (string id, integer steps_total, string label) {
+ if (! haskey (progress_layout, id)) {
+ y2error ("Unknown key: %1", id);
+ return;
+ }
+
+ progress_layout[id, "label"] = label;
+ progress_layout[id, "steps_total"] = steps_total;
+ }
+
/**
* Function stores all new/requested states of all handled/supported types.
*
@@ -831,15 +882,13 @@
* @see objects_state
*/
global void StoreAllChanges () {
- Progress::Simple (
- // TRANSLATORS: Dialog caption
- _("Installation from Images"),
- // TRANSLATORS: Dialog progress
- _("Storing user preferences..."),
- 4 * size (all_supported_types),
- // TRANSLATORS: help text
- _("<p>Installation process is just storing the user-defined selection of packages</p>")
- );
+ integer nr_steps = 4 * size (all_supported_types);
+ string id = "storing_user_prefs";
+
+ AdjustProgressLayout (id, nr_steps, _("Storing user preferences..."));
+
+ if (generic_set_progress != nil)
+ generic_set_progress (id, 0);
// Query for changed state of all knwon types
// 'changed' means that they were 'installed' and 'not locked' before
@@ -856,28 +905,34 @@
return (one_object["status"]:`unknown == `removed);
});
objects_state[one_type, "remove"] = remove_resolvables;
- Progress::NextStep();
+
+ if (generic_set_progress != nil)
+ generic_set_progress (id, nil);
list