Author: jsuchome
Date: Thu Feb 10 22:03:14 2011
New Revision: 63395
URL: http://svn.opensuse.org/viewcvs/yast?rev=63395&view=rev
Log:
show one item for snapshot pair (the POST one)
Modified:
branches/tmp/jsuchome/snapper/src/Snapper.ycp
branches/tmp/jsuchome/snapper/src/dialogs.ycp
Modified: branches/tmp/jsuchome/snapper/src/Snapper.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/jsuchome/snapper/src/Snapper.ycp?rev=63395&r1=63394&r2=63395&view=diff
==============================================================================
--- branches/tmp/jsuchome/snapper/src/Snapper.ycp (original)
+++ branches/tmp/jsuchome/snapper/src/Snapper.ycp Thu Feb 10 22:03:14 2011
@@ -38,12 +38,16 @@
import "Progress";
+// global list of all snapshot
global list<map> snapshots = [];
global string snapshots_path = "/snapshots"; // FIXME
global map selected_snapshot = $[];
+// mapping of snapshot number to index in snapshots list
+global map id2index = $[];
+
// index to snapshots list
global integer selected_snapshot_index = 0;
@@ -106,13 +110,16 @@
list<map> snapshot_maps = (list<map>) SCR::Read (.snapper.snapshots);
-
+ if (snapshot_maps == nil) snapshot_maps = [];
+ integer i = 0;
foreach (map snapshot, snapshot_maps, {
integer id = snapshot["num"]:0;
if (id == 0) return; // ignore the 'current system'
snapshot["name"] = tostring (id);
y2internal ("snapshot data: %1", snapshot);
snapshots = add (snapshots, snapshot);
+ id2index[id] = i;
+ i = i + 1;
});
Modified: branches/tmp/jsuchome/snapper/src/dialogs.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/jsuchome/snapper/src/dialogs.ycp?rev=63395&r1=63394&r2=63395&view=diff
==============================================================================
--- branches/tmp/jsuchome/snapper/src/dialogs.ycp (original)
+++ branches/tmp/jsuchome/snapper/src/dialogs.ycp Thu Feb 10 22:03:14 2011
@@ -82,20 +82,36 @@
list single_snapshot_items = [];
list coupled_snapshot_items = [];
- foreach (map s, snapshots, ``{
+ foreach (map s, snapshots, {
i = i + 1;
- string date = "";
- if (s["num"]:0 != 0)
- date = timestring("%c", s["date"]:0, false);
+
+ integer num = s["num"]:0;
+ string date = "";
+ if (num != 0)
+ date = timestring ("%c", s["date"]:0, false);
if (s["type"]:`none == `SINGLE)
+ {
single_snapshot_items = add (single_snapshot_items,
- `item (`id (i), date, s["name"]:"", s["description"]:""));
- else
+ `item (`id (i), date, num, s["description"]:""));
+ }
+ else if (s["type"]:`none == `POST)
{
- string pre = s["pre_num"]:0 != 0 ? tostring (s["pre_num"]:0) : "";
+ integer pre = s["pre_num"]:0; // pre canot be 0
+ integer index = Snapper::id2index[pre]:-1;
+ if (pre == 0 || index == -1)
+ {
+ y2warning ("something wrong - pre:%1, index:%2", pre, index);
+ continue;
+ }
+ string desc = Snapper::snapshots[index,"description"]:"";
+ string pre_date = timestring ("%c", Snapper::snapshots[index,"date"]:0, false);
coupled_snapshot_items = add (coupled_snapshot_items,
- `item (`id (i), date, s["name"]:"", pre, s["description"]:""));
+ `item (`id (i), pre, pre_date, num, date, desc));
+ }
+ else
+ {
+ y2milestone ("skipping pre snapshot: %1", num);
}
});
@@ -116,12 +132,11 @@
`Left (`Label (_("Coupled Snapshots"))),
`Table (`id (`coupled_snapshots_table), `opt(`notify, `keepSorting), `header (
// table header
- _("Date"), _("Number"), _("Previous"), _("Description")),
+ _("Pre ID"), _("Start Date"), _("Post ID"), _("End Date"), _("Description")),
coupled_snapshot_items
),
`HBox (
`PushButton (`id (`show_c), `opt (`default), _("Show Changes")),
-// `PushButton (`id (`edit), _("Edit Snapshot")),
`HStretch ()
)
);
@@ -160,6 +175,7 @@
else continue;
}
else if (ret == `show) {
+ // `POST snapshot is selected from the couple
Snapper::selected_snapshot = snapshots[selected]:$[];
Snapper::selected_snapshot_index = selected;
break;
@@ -187,7 +203,7 @@
map display_info = UI::GetDisplayInfo ();
boolean textmode = display_info["TextMode"]:false;
- string current = "";
+ string current_file = "";
// map of already read files
map files = $[];
@@ -318,7 +334,7 @@
// create the term for selected file
void set_entry_term () {
- if (current != "" && files_index[current]:$[] != $[])
+ if (current_file != "" && files_index[current_file]:$[] != $[])
{
UI::ReplaceWidget (`id (`diff_chooser), `VBox (
@@ -333,7 +349,7 @@
)))),
`VSpacing ()
));
- show_file_modification (current, previous_num, snapshot_num);
+ show_file_modification (current_file, previous_num, snapshot_num);
}
else
{
@@ -394,15 +410,14 @@
if (size (tree_items) > 0)
{
- UI::ReplaceWidget (`id (`reptree), textmode ?
- `Tree (`id(`tree), `opt (`multiSelection), snapshot_name, tree_items) :
- `Tree (`id(`tree), `opt(`notify, `multiSelection), snapshot_name, tree_items));
+ UI::ReplaceWidget (`id (`reptree),
+ `Tree (`id(`tree), `opt (`notify, `multiSelection), snapshot_name, tree_items)
+ );
// no item is selected
UI::ChangeWidget (`tree, `CurrentItem, nil);
}
- current = (string) UI::QueryWidget (`id(`tree), `CurrentItem);
- if (current == nil) current = "";
+ current_file = "";
set_entry_term ();
@@ -413,11 +428,11 @@
while(true) {
map event = UI::WaitForEvent ();
+y2internal ("event: %1", event); // FIXME look at ncurses
ret = (symbol) event["ID"]:nil;
- current = (string) UI::QueryWidget (`id(`tree),`CurrentItem);
- if (current == nil)
- current = "";
+ current_file = (string) UI::QueryWidget (`id(`tree),`CurrentItem);
+ if (current_file == nil) current_file = "";
// events in tree
if (ret == `tree)
@@ -429,21 +444,21 @@
}
else if (ret == `diff_snapshot)
{
- show_file_modification (current, previous_num, snapshot_num);
+ show_file_modification (current_file, previous_num, snapshot_num);
}
else if (ret == `diff_current)
{
- show_file_modification (current, snapshot_num, 0);
+ show_file_modification (current_file, snapshot_num, 0);
}
else if (ret == `abort || ret == `cancel || ret == `back) {
break;
}
else if (ret == `restore) {
- if (Popup::YesNo (sformat ("Do you want to restore the file '%1' from snapshot '%2'?
+ if (Popup::YesNo (sformat ("Do you want to copy the file '%1' from snapshot '%2' to current system?
-This will probably break your system. Are you sure?", current, snapshot_name)))
+This will probably break your system. Are you sure?", current_file, snapshot_name)))
{
- y2milestone ("restoring file %1...", current);
+ y2milestone ("restoring file %1...", current_file);
}
continue;
}
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org