[yast-commit] r63449 - in /branches/tmp/jsuchome/snapper/src: Snapper.ycp dialogs.ycp snapper.ycp wizards.ycp
Author: jsuchome
Date: Mon Feb 21 16:16:53 2011
New Revision: 63449
URL: http://svn.opensuse.org/viewcvs/yast?rev=63449&view=rev
Log:
added restore function
Modified:
branches/tmp/jsuchome/snapper/src/Snapper.ycp
branches/tmp/jsuchome/snapper/src/dialogs.ycp
branches/tmp/jsuchome/snapper/src/snapper.ycp
branches/tmp/jsuchome/snapper/src/wizards.ycp
Modified: branches/tmp/jsuchome/snapper/src/Snapper.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/jsuchome/snapper/src/Snapper.ycp?rev=63449&r1=63448&r2=63449&view=diff
==============================================================================
--- branches/tmp/jsuchome/snapper/src/Snapper.ycp (original)
+++ branches/tmp/jsuchome/snapper/src/Snapper.ycp Mon Feb 21 16:16:53 2011
@@ -35,6 +35,7 @@
textdomain "snapper";
import "FileUtils";
+import "Label";
import "Progress";
@@ -68,8 +69,8 @@
map ret = $[];
- string file1 = sformat ("%1/%2/snapshot/%3", snapshots_path, old, file);
- string file2 = sformat ("%1/%2/snapshot/%3", snapshots_path, new, file);
+ string file1 = sformat ("%1/%2/snapshot%3", snapshots_path, old, file);
+ string file2 = sformat ("%1/%2/snapshot%3", snapshots_path, new, file);
if (new == 0)
file2 = file;
@@ -160,36 +161,52 @@
}
/**
- * Write all snapper settings
- * @return true on success
+ * Copy given files from selected snapshot to current filesystem
*/
-global boolean Write() {
+global boolean RestoreFiles (integer snapshot_num, list<string> files) {
- /* Snapper read dialog caption */
- string caption = _("Saving snapper Configuration");
+ boolean ret = true;
+ y2milestone ("going to restore files %1", files);
- integer steps = 2;
+ UI::OpenDialog (`opt (`decorated), `HBox (`HSpacing(1.5), `VBox (
+ `HSpacing (60),
+ // label for log window
+ `LogView (`id (`log), _("Restoring Files..."), 8, 0),
+ `ProgressBar (`id (`progress), "", size (files), 0),
+ `PushButton (`id (`ok), Label::OKButton ())
+ ), `HSpacing (1.5)));
+
+ UI::ChangeWidget (`id (`ok), `Enabled, false);
+ integer progress = 0;
+ foreach (string file, files, {
+
+ UI::ChangeWidget (`id (`progress ), `Value, progress);
+
+ string orig = sformat ("%1/%2/snapshot%3", snapshots_path, snapshot_num, file);
+
+ string dir = substring (file, 0, findlastof (file, "/"));
+ y2internal ("copying file %1 to %2 (dir: %3)", orig, file, dir);
+ if (FileUtils::CheckAndCreatePath (dir))
+ {
+ SCR::Execute (.target.bash, sformat ("/bin/cp %1 %2", orig, file));
+ UI::ChangeWidget (`id (`log), `LastLine, file + "\n");
+ }
+ else
+ {
+ // log entry (%1 is file name)
+ UI::ChangeWidget (`id (`log), `LastLine, sformat (_("%1 skipped\n"), file));
+ }
+ sleep (100);
+ progress = progress + 1;
+ });
- Progress::New(caption, " ", steps, [
- /* Progress stage 1/2 */
- _("Write the settings"),
- /* Progress stage 2/2 */
- _("Run SuSEconfig")
- ], [
- /* Progress step 1/2 */
- _("Writing the settings..."),
- /* Progress step 2/2 */
- _("Running SuSEconfig..."),
- /* Progress finished */
- _("Finished")
- ],
- ""
- );
+ UI::ChangeWidget (`id (`progress ), `Value, progress);
+ UI::ChangeWidget (`id (`ok), `Enabled, true);
- Progress::NextStage();
- Progress::NextStage ();
- Progress::NextStage();
- return true;
+ UI::UserInput ();
+ UI::CloseDialog ();
+
+ return ret;
}
Modified: branches/tmp/jsuchome/snapper/src/dialogs.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/jsuchome/snapper/src/dialogs.ycp?rev=63449&r1=63448&r2=63449&view=diff
==============================================================================
--- branches/tmp/jsuchome/snapper/src/dialogs.ycp (original)
+++ branches/tmp/jsuchome/snapper/src/dialogs.ycp Mon Feb 21 16:16:53 2011
@@ -58,16 +58,6 @@
}
/**
- * Write settings dialog
- * @return `abort if aborted and `next otherwise
- */
-symbol WriteDialog() {
- Wizard::RestoreHelp(HELPS["write"]:"");
- boolean ret = Snapper::Write();
- return ret ? `next : `abort;
-}
-
-/**
* Summary dialog
* @return dialog result
*/
@@ -255,6 +245,7 @@
// helper function: update the global map with directory tree structure
map
participants (1)
-
jsuchome@svn2.opensuse.org