Author: jsuchome Date: Thu Dec 16 17:42:49 2010 New Revision: 63000 URL: http://svn.opensuse.org/viewcvs/yast?rev=63000&view=rev Log: better UI, alignment etc. 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=63000&r1=62999&r2=63000&view=diff ============================================================================== --- branches/tmp/jsuchome/snapper/src/Snapper.ycp (original) +++ branches/tmp/jsuchome/snapper/src/Snapper.ycp Thu Dec 16 17:42:49 2010 @@ -88,7 +88,27 @@ map out = (map) SCR::Execute (.target.bash_output, sformat ("/usr/bin/diff -u %1 %2", file1, file2)); - ret["diff"] = out["stdout"]:""; + if (out["stderr"]:"" != "") + { + y2warning ("out: %1", out); + ret["diff"] = out["stderr"]:""; + } + else if (out["stdout"]:nil == "") + { + ret["status"] = "no_change"; + } + else + { + ret["diff"] = out["stdout"]:""; + } + } + else if (FileUtils::Exists (file1)) + { + ret["status"] = "removed"; + } + else if (FileUtils::Exists (file2)) + { + ret["status"] = "created"; } 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=63000&r1=62999&r2=63000&view=diff ============================================================================== --- branches/tmp/jsuchome/snapper/src/dialogs.ycp (original) +++ branches/tmp/jsuchome/snapper/src/dialogs.ycp Thu Dec 16 17:42:49 2010 @@ -84,13 +84,13 @@ }); term contents = `VBox ( - `Table (`id (`snapshots_table), `opt(`notify), `header ( + `Table (`id (`snapshots_table), `opt(`notify, `keepSorting), `header ( // table header _("Date"), _("Name"), _("Description")), snapshot_items ), `HBox ( - `PushButton (`id (`show), _("Show Changes")), + `PushButton (`id (`show), `opt (`default), _("Show Changes")), `PushButton (`id (`edit), _("Edit Snapshot")), `HStretch () ) @@ -101,6 +101,8 @@ Wizard::HideBackButton (); Wizard::HideAbortButton (); + UI::SetFocus (`id (`snapshots_table)); + any ret = nil; while(true) { @@ -209,26 +211,50 @@ return ret; } - // create the term for selected file - define void set_entry_term () { - - list items = []; + // helper function: show the specific modification between snapshots + void show_file_modification (string file, string pre, string post) { - term cont = `Heading ("some general info about the snapshot"); - string diff = ""; - if (current != "" && files_index[current]:$[] != $[]) + term content = `VBox (); + map modification = Snapper::GetFileModification (file, pre, post); + if (haskey (modification, "diff")) { - string changes = files_index[current,"changes"]:""; - cont = `VBox (`VSpacing ()); - if (substring (changes, 0, 1) == "+") + string diff = modification["diff"]:""; + diff = mergestring (splitstring (diff, "\n"), "<br>"); + content = `RichText (`id (`diff), diff); + } + else + { + if (modification["status"]:"" == "created") { - cont = add (cont, `Label ("New file was created")); + content = `Left (`Heading ("New file was created")); } - else if (substring (changes, 0, 1) == "c") + else if (modification["status"]:"" == "removed") { - cont = `VBox ( - `VSpacing (), - `Label ("File was modified"), + content = `Left (`Heading ("File was removed")); + } + else if (modification["status"]:"" == "no_change") + { + content = `Left (`Heading ("File was not changed")); + } + else + { + y2warning ("not known: %1", modification); + } + } + UI::ReplaceWidget (`id (`diff_content), `VBox ( + content, + `Bottom (`Right (`PushButton (`id (`restore), _("Restore")))) + )); + } + + + // create the term for selected file + void set_entry_term () { + + if (current != "" && files_index[current]:$[] != $[]) + { + + UI::ReplaceWidget (`id (`diff_chooser), `VBox ( `VSpacing (), `RadioButtonGroup (`id(`rd), `Left (`HVSquash (`VBox ( `Left (`RadioButton (`id(`diff_snapshot), `opt (`notify), @@ -238,37 +264,22 @@ // radio button label _("Compare file from the snapshot with the current system"), false)) )))), - `VSpacing (), - `RichText (`id (`diff), "") - ); - map modification = Snapper::GetFileModification ( - current, snapshot_name + "/pre", snapshot_name + "/post"); - diff = modification["diff"]:""; - diff = mergestring (splitstring (diff, "\n"), "<br>"); - } - else if (substring (changes, 0, 1) == "-") - { - cont = add (cont, `Label ("File was removed")); - } - else - { - cont = add (cont, `Heading (changes)); - } + `VSpacing () + )); + show_file_modification (current, snapshot_name + "/pre", snapshot_name + "/post"); } - UI::ReplaceWidget (`entryContents, cont); - if (UI::WidgetExists (`id (`diff))) + else { - UI::ChangeWidget (`id (`diff), `Value, diff); + UI::ReplaceWidget (`id (`diff_chooser), `VBox (`VStretch ())); + UI::ReplaceWidget (`id (`diff_content), `HBox (`HStretch ())); } } term contents = `HBox ( `HWeight (1, `HBox (`VSpacing (20), `VBox (`HSpacing(70), - `VSpacing (0.2), `HBox ( `HSpacing (), `ReplacePoint (`id (`reptree), `Tree (`id(`tree), snapshot_name, [])), - `ReplacePoint (`id (`repbuttons), `Empty ()), `HSpacing () ), `HBox ( @@ -279,16 +290,26 @@ `PushButton (`id (`open), `opt (`key_F6),_("&Open")): `Empty (), `HSpacing (1.5) - ), - `VSpacing (0.6) + ) ))), - `HWeight (2, `ReplacePoint (`id (`entryContents), `Top (`HBox ()))) + `HWeight (2, `VBox ( + `Label (`id (`label), Snapper::selected_snapshot["description"]:""), + `Frame ("", `HBox ( + `HSpacing (0.5), `VBox ( + `VSpacing (0.5), + `ReplacePoint (`id (`diff_chooser), `VBox (`VStretch ())), + `ReplacePoint (`id (`diff_content), `HBox (`HStretch ())), + `VSpacing (0.5) + ), + `HSpacing (0.5) + )) + )) ); // show the dialog contents with empty tree, compute items later Wizard::SetContentsButtons (caption, contents, HELPS["show"]:"", // button label - Label::CancelButton(), _("Restore")); + Label::CancelButton(), _("Restore Selected")); // generate the map with directory tree structure foreach (map file, file_list, { @@ -341,23 +362,24 @@ } else if (ret == `diff_snapshot) { - map modification = Snapper::GetFileModification ( - current, snapshot_name + "/pre", snapshot_name + "/post"); - string diff = modification["diff"]:""; - diff = mergestring (splitstring (diff, "\n"), "<br>"); - UI::ChangeWidget (`id (`diff), `Value, diff); + show_file_modification (current, snapshot_name + "/pre", snapshot_name + "/post"); } else if (ret == `diff_current) { - map modification = Snapper::GetFileModification ( - current, snapshot_name + "/pre", ""); - string diff = modification["diff"]:""; - diff = mergestring (splitstring (diff, "\n"), "<br>"); - UI::ChangeWidget (`id (`diff), `Value, diff); + show_file_modification (current, snapshot_name + "/post", ""); } 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'? + +This will probably break your system. Are you sure?", current, snapshot_name))) + { + y2milestone ("restoring file %1...", current); + } + continue; + } else if (ret == `next) { if (true) { -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org