URL: http://svn.opensuse.org/viewcvs/yast?rev=62737&view=rev Log: support for ordering in bonding slaves (bnc#640611)
Modified: trunk/network/src/lan/address.ycp
Aaargh, sloppy indentation all over! But it's fine if you want your eyes to hurt when doing maintenance, and be cursed by colleagues who inherit your code.
@@ -182,8 +203,72 @@ }); });
- UI::ChangeWidget(`id(key), `Items, items); -y2internal("slaves %1", settings["SLAVES"]:[]); + // reorder the items + list l2=[]; + list l1=[]; + foreach(term t, (list<term>) items, { + if (contains(settings["SLAVES"]:[], t[0,0]:"")){ + l1=add(l1, t); + } else { + l2=add(l2, t); + } + }); + + items=[]; + foreach(string s, settings["SLAVES"]:[],{ + foreach(term t, (list<term>) l1,{ + if (t[0,0]:""==s) items=add(items, t); + }); + }); + + items=union(items,l2); + UI::ChangeWidget(`msbox_items, `Items, items); + enableSlaveButtons(); +} + +symbol HandleSlave(string key, map event) +{ + if (event["EventReason"]:"" =="SelectionChanged"){ + enableSlaveButtons(); + } else if (event["EventReason"]:""=="Activated" && event["WidgetClass"]:nil==`PushButton){ + list<term> items = (list<term>)UI::QueryWidget(`msbox_items, `Items); + string current = tostring(UI::QueryWidget(`msbox_items, `CurrentItem)); + integer index = getISlaveIndex(current); + list<term> new_items=[]; + integer pos=0; + switch(event["ID"]:`nil){ + case `up: + while(index>pos+1){ + new_items=add(new_items, items[pos]:nil); + pos=pos+1; + } + new_items=add(new_items, items[index]:nil); + new_items=add(new_items, items[index-1]:nil); + new_items=(list<term>)union(new_items, (list<term>)sublist(items, index)); + break; + case `down: + while(index>pos){ + new_items=add(new_items, items[pos]:nil); + pos=pos+1; + } + new_items=add(new_items, items[index+1]:nil); + new_items=add(new_items, items[index]:nil); + new_items=(list<term>)union(new_items, (list<term>)sublist(items, index+1)); + break; + default: + y2warning("unknown action"); + return nil; + } + items = new_items; + UI::ChangeWidget(`msbox_items, `Items, items); + enableSlaveButtons(); + + } else + { + y2debug("event:%1", event); + } + + return nil; }
/** -- Martin Vidner, YaST developer http://en.opensuse.org/User:Mvidner
Kuracke oddeleni v restauraci je jako fekalni oddeleni v bazenu