Changeset 714

Show
Ignore:
Timestamp:
07/27/07 02:18:48 (1 year ago)
Author:
Gregor
Message:

dsssps/components.d: Added "Move Up"/"Move Down" feature.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • other/dps/trunk/dsss.conf

    r704 r714  
    33[dsssps/dps.d] 
    44target=dps 
     5 
  • other/dps/trunk/dsssps/components.d

    r712 r714  
    1515import dsssps.prefs; 
    1616import dsssps.process; 
     17import dsssps.sconf; 
    1718 
    1819class Component : wxTreeItemData { 
     
    7071            "dsss distclean" ~ buildName); 
    7172        dpsApp.aui.Update(); 
     73    } 
     74} 
     75 
     76/// A template set of functions for sections 
     77template TCompSect() { 
     78    char[] sectName; 
     79 
     80    /// Menu and setup for sections 
     81    void sectMenu(char[] ssn, wxMenu topMenu) 
     82    { 
     83        sectName = ssn.dup; 
     84 
     85        topMenu.Append(++floatingIds, "Move Up"); 
     86        dpsApp.EVT_MENU(floatingIds, &OnMoveUp); 
     87 
     88        topMenu.Append(++floatingIds, "Move Down"); 
     89        dpsApp.EVT_MENU(floatingIds, &OnMoveDown); 
     90    } 
     91 
     92    /// Move this section up 
     93    void OnMoveUp(Object s, wxEvent e) 
     94    { 
     95        DSSSConfS dcs = readDSSSConfSimple("dsss.conf"); 
     96        int i; 
     97        for (i = 0; 
     98             i < dcs.sections.length && 
     99             dcs.sections[i] != sectName; 
     100             i++) {} 
     101        if (i == 0 || i == dcs.sections.length) return; 
     102 
     103        char[][] newS = 
     104            dcs.sections[0..(i-1)] ~ 
     105            [sectName] ~ 
     106            dcs.sections[(i-1)..i] ~ 
     107            dcs.sections[(i+1)..$]; 
     108        dcs.sections = newS; 
     109 
     110        writeDSSSConfSimple("dsss.conf", dcs); 
     111        dpsApp.loadTopDSSSConf(); 
     112    } 
     113 
     114    /// Move this section down 
     115    void OnMoveDown(Object s, wxEvent e) 
     116    { 
     117        DSSSConfS dcs = readDSSSConfSimple("dsss.conf"); 
     118        int i; 
     119        for (i = 0; 
     120             i < dcs.sections.length && 
     121             dcs.sections[i] != sectName; 
     122             i++) {} 
     123        if (i >= dcs.sections.length - 1) return; 
     124 
     125        char[][] newS = 
     126            dcs.sections[0..i] ~ 
     127            dcs.sections[(i+1)..(i+2)] ~ 
     128            [sectName] ~ 
     129            dcs.sections[(i+2)..$]; 
     130        dcs.sections = newS; 
     131 
     132        writeDSSSConfSimple("dsss.conf", dcs); 
     133        dpsApp.loadTopDSSSConf(); 
    72134    } 
    73135} 
     
    102164 
    103165    mixin TCompBuild; 
     166    mixin TCompSect; 
    104167 
    105168    override void popupMenu(wxTreeCtrl tree, wxEvent e) 
     
    108171        wxMenu topMenu = new wxMenu(); 
    109172 
    110         // Set up the build option
     173        // Set up the menu
    111174        buildMenu(" " ~ name, topMenu); 
     175        sectMenu(name, topMenu); 
    112176 
    113177        // And display it 
     
    124188 
    125189    mixin TCompBuild; 
     190    mixin TCompSect; 
    126191 
    127192    override void popupMenu(wxTreeCtrl tree, wxEvent e) 
     
    130195        wxMenu topMenu = new wxMenu(); 
    131196 
    132         // Set up the build option
     197        // Set up the menu
    133198        buildMenu(" " ~ name, topMenu); 
     199        sectMenu(name, topMenu); 
    134200 
    135201        // And display it 
     
    305371        char[] origdir = FileSystem.getDirectory(); 
    306372        try { 
    307             Cout("DIR: ")(name).newline; 
    308373            FileSystem.setDirectory(name); 
    309             Cout("DPS: ")(dpsBinPath).newline; 
    310374            (new Process(dpsBinPath, Environment.get())).execute(); 
    311375        } catch (Exception e) {} // ignore failures (FIXME)