Author: lslezak Date: Fri Mar 14 09:35:56 2008 New Revision: 45448 URL: http://svn.opensuse.org/viewcvs/yast?rev=45448&view=rev Log: - support for ejecting specified CD/DVD device, handle multiple devices (fate#120298) - 2.16.25 Modified: trunk/packager/VERSION trunk/packager/package/yast2-packager.changes trunk/packager/src/modules/PackageCallbacks.ycp trunk/packager/src/modules/Packages.ycp trunk/packager/yast2-packager.spec.in Modified: trunk/packager/VERSION URL: http://svn.opensuse.org/viewcvs/yast/trunk/packager/VERSION?rev=45448&r1=45447&r2=45448&view=diff ============================================================================== --- trunk/packager/VERSION (original) +++ trunk/packager/VERSION Fri Mar 14 09:35:56 2008 @@ -1 +1 @@ -2.16.24 +2.16.25 Modified: trunk/packager/package/yast2-packager.changes URL: http://svn.opensuse.org/viewcvs/yast/trunk/packager/package/yast2-packager.changes?rev=45448&r1=45447&r2=45448&view=diff ============================================================================== --- trunk/packager/package/yast2-packager.changes (original) +++ trunk/packager/package/yast2-packager.changes Fri Mar 14 09:35:56 2008 @@ -1,4 +1,11 @@ ------------------------------------------------------------------- +Fri Mar 14 09:33:47 CET 2008 - lslezak@suse.cz + +- support for ejecting specified CD/DVD device, handle multiple + devices (fate#120298) +- 2.16.25 + +------------------------------------------------------------------- Tue Mar 11 13:28:00 CET 2008 - lslezak@suse.cz - display download rate in callbacks (#168935) Modified: trunk/packager/src/modules/PackageCallbacks.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/packager/src/modules/PackageCallbacks.ycp?rev=45448&r1=45447&r2=45448&view=diff ============================================================================== --- trunk/packager/src/modules/PackageCallbacks.ycp (original) +++ trunk/packager/src/modules/PackageCallbacks.ycp Fri Mar 14 09:35:56 2008 @@ -550,6 +550,29 @@ // MEDIA CHANGE //============================================================================= +global define list<term> CDdevices(string preferred) { + list<map> cds = (list<map>)SCR::Read(.probe.cdrom); + list<term> ret = []; + + if (cds != nil) + { + foreach(map cd, cds, { + string dev = cd["dev_name"]:""; + string model = cd["model"]:""; + boolean deflt = (preferred == dev); + + if (dev != nil && dev != "" && model != nil) + { + ret = add(ret, `item(`id(dev), (deflt ? "⤠" : "") + model + sformat(" (%1)", dev))); + } + } + ); + } + + y2milestone("Detected CD devices: %1", ret); + + return ret; +} //------------------------------------------------------------------------- // @@ -567,7 +590,7 @@ global string MediaChange (string error, string url, string product, integer current, string current_label, integer wanted, string wanted_label, - boolean double_sided) + boolean double_sided, list<string> devices, integer current_device) { if (autorefreshing && autorefreshing_aborted) { @@ -583,8 +606,8 @@ SlideShow::StopTimer(); } - y2milestone ("MediaChange err'%1', url'%2', prd'%3', cur'%4'/'%5', wan'%6'/'%7'", - error, url, product, current, current_label, wanted, wanted_label); + y2milestone ("MediaChange error: err'%1', url'%2', prd'%3', cur'%4'/'%5', wan'%6'/'%7', devs: %8, curr_dev: %9", + error, url, product, current, current_label, wanted, wanted_label, devices, current_device); map url_tokens = URL::Parse (url); string url_scheme = url_tokens["scheme"]:""; @@ -676,8 +699,20 @@ if (offer_eject_button) { - // push button label during media change popup, user can eject the CD/DVD - button_box = add (button_box, `PushButton (`id(`eject), _("&Eject"))); + // detect the CD/DVD devices + list<term> cds = CDdevices(devices[current_device]:""); + + // display a menu button if there are more CD devices + if (size(cds) > 1) + { + // menu button label - used for more then one device + button_box = add (button_box, `MenuButton(_("&Eject"), cds)); + } + else + { + // push button label - in the media change popup, user can eject the CD/DVD + button_box = add (button_box, `PushButton (`id(`eject), _("&Eject"))); + } } if (Mode::commandline()) @@ -719,7 +754,7 @@ { UI::OpenDialog( `opt(`decorated), LayoutPopup (message, button_box, 10, true) ); /* TextEntry label */ - UI::ReplaceWidget(`id(`info), `VBox (`TextEntry (`id(`url), _("&URL")), `RichText(`opt(`plainText), error)) ); + UI::ReplaceWidget(`id(`info), `VBox (`InputField(`id(`url), `opt(`hstretch), _("&URL")), `RichText(`opt(`plainText), error)) ); UI::ChangeWidget(`id(`url), `Value, url); } else @@ -733,6 +768,8 @@ any r = nil; + string eject_device = ""; + repeat { r = UI::UserInput(); if ( r == `show ) @@ -749,7 +786,7 @@ UI::ReplaceWidget(`id(`info), `Empty() ); } } - if (r == `retry || r == `url) + else if (r == `retry || r == `url) { if (showLongInfo) // id(`url) must exist { @@ -761,6 +798,12 @@ } } } + else if (is(r, string) && regexpmatch((string)r, "^/dev/")) + { + y2milestone("Eject request for %1", r); + eject_device = (string)r; + r = `eject; + } } until (r == `cancel || r == `retry || r == `eject || r == `skip || r == `ignore || r == `url); y2milestone ("MediaChange %1", r); @@ -786,7 +829,30 @@ if (r == `skip) return "S"; if (r == `eject) - return "E"; + { + if (eject_device == "") + { + return "E"; + } + else + { + // get the index in the list + integer dindex = -1; + + string found = find(string d, devices, {dindex = dindex + 1; return d == eject_device;}); + + if (found != nil) + { + y2milestone("Device %1 has index %2", eject_device, dindex); + return "E" + tostring(dindex); + } + else + { + y2warning("Device %1 not found in the list, using default", eject_device); + return "E"; + } + } + } if (!Mode::normal ()) { Modified: trunk/packager/src/modules/Packages.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/packager/src/modules/Packages.ycp?rev=45448&r1=45447&r2=45448&view=diff ============================================================================== --- trunk/packager/src/modules/Packages.ycp (original) +++ trunk/packager/src/modules/Packages.ycp Fri Mar 14 09:35:56 2008 @@ -1258,7 +1258,7 @@ // FIXME somewhere get correct current_label and wanted_label string result = PackageCallbacks::MediaChange (errortext, base_url, "", - 0, "", 1, "", false); + 0, "", 1, "", false, [], 0); } } Modified: trunk/packager/yast2-packager.spec.in URL: http://svn.opensuse.org/viewcvs/yast/trunk/packager/yast2-packager.spec.in?rev=45448&r1=45447&r2=45448&view=diff ============================================================================== --- trunk/packager/yast2-packager.spec.in (original) +++ trunk/packager/yast2-packager.spec.in Fri Mar 14 09:35:56 2008 @@ -7,8 +7,8 @@ # enhanced String::FormatRateMessage() BuildRequires: yast2 >= 2.16.34 -# changed signature of ProgressProvide calback -BuildRequires: yast2-pkg-bindings >= 2.16.17 +# changed signature of MediaChange calback +BuildRequires: yast2-pkg-bindings >= 2.16.19 # Module: OneClickInstallStandard Requires: perl-XML-Bare yast2-perl-bindings @@ -17,8 +17,8 @@ Requires: yast2-country-data >= 2.16.3 Requires: yast2-installation >= 2.15.12 -# changed signature of ProgressProvide calback -Requires: yast2-pkg-bindings >= 2.16.17 +# changed signature of MediaChange calback +Requires: yast2-pkg-bindings >= 2.16.19 # URL::MakeParamsFromMap and URL::MakeMapFromParams Requires: yast2 >= 2.16.25 -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org