Changeset 700

Show
Ignore:
Timestamp:
07/25/07 02:37:45 (1 year ago)
Author:
Gregor
Message:

Lots of new features.

Files:

Legend:

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

    r699 r700  
    33[dsssps/dps.d] 
    44target=dps 
     5 
     6[foo] 
  • other/dps/trunk/dsssps/components.d

    r699 r700  
    11module dsssps.components; 
     2 
     3import tango.io.Console; 
    24 
    35import tango.sys.Environment; 
     
    68import wx.wx; 
    79 
     10import dsssps.dps; 
     11import dsssps.prefs; 
     12import dsssps.process; 
     13 
    814class Component : wxTreeItemData { 
    9     void activate() { assert(0, "Bad component."); } 
     15    void activate(wxTreeCtrl tree, wxEvent e) {} 
     16    void popupMenu(wxTreeCtrl tree, wxEvent e) {} 
    1017} 
    1118 
     
    2431 
    2532    /// Edit the file 
    26     override void activate(
     33    override void activate(wxTreeCtrl tree, wxEvent e
    2734    { 
    28         (new Process("gvim " ~ name, Environment.get())).execute(); 
     35        (new DPSProcessRun(editor ~ " " ~ name, &(dpsApp.loadTopDSSSConf))).Show(false); 
    2936    } 
    3037 
     
    3239    char[] name; 
    3340} 
     41 
     42class CompFileBuild : CompFile { 
     43    this(char[] name) { super(name); } 
     44 
     45    override void popupMenu(wxTreeCtrl tree, wxEvent e) 
     46    { 
     47        // Create the menu 
     48        wxMenu topMenu = new wxMenu(); 
     49 
     50        topMenu.Append(++floatingIds, "Build"); 
     51        dpsApp.EVT_MENU(floatingIds, &OnBuild); 
     52 
     53        topMenu.Append(++floatingIds, "Build Verbose"); 
     54        dpsApp.EVT_MENU(floatingIds, &OnBuildVerbose); 
     55 
     56        // And display it 
     57        tree.PopupMenu(topMenu, (cast(wxTreeEvent) e).point); 
     58    } 
     59 
     60    /// Callback for building 
     61    void OnBuild(Object s, wxEvent e) 
     62    { 
     63        // FIXME 
     64        (new DPSProcessWindow("dsss build " ~ fname)).Show(true); 
     65    } 
     66 
     67    /// Callback for building verbose 
     68    void OnBuildVerbose(Object s, wxEvent e) 
     69    { 
     70        // FIXME 
     71        (new DPSProcessWindow("dsss build " ~ fname ~ " -v")).Show(true); 
     72    } 
     73} 
     74 
     75class CompTop : Component { 
     76    override void popupMenu(wxTreeCtrl tree, wxEvent e) 
     77    { 
     78        // Create a menu on-the-fly with "build" and "edit dsss.conf" 
     79        wxMenu topMenu = new wxMenu(); 
     80         
     81        topMenu.Append(++floatingIds, "Build"); 
     82        dpsApp.EVT_MENU(floatingIds, &OnBuild); 
     83 
     84        topMenu.Append(++floatingIds, "Build Verbose"); 
     85        dpsApp.EVT_MENU(floatingIds, &OnBuildVerbose); 
     86 
     87        topMenu.Append(++floatingIds, "Clean"); 
     88        dpsApp.EVT_MENU(floatingIds, &OnClean); 
     89 
     90        topMenu.Append(++floatingIds, "Edit dsss.conf"); 
     91        dpsApp.EVT_MENU(floatingIds, &OnEditDSSSConf); 
     92 
     93        // Then display it 
     94        tree.PopupMenu(topMenu, (cast(wxTreeEvent) e).point); 
     95    } 
     96 
     97    /// Callback for building 
     98    void OnBuild(Object s, wxEvent e) 
     99    { 
     100        // FIXME 
     101        (new DPSProcessWindow("dsss build")).Show(true); 
     102    } 
     103 
     104    /// Callback for building verbose 
     105    void OnBuildVerbose(Object s, wxEvent e) 
     106    { 
     107        // FIXME 
     108        (new DPSProcessWindow("dsss build -v")).Show(true); 
     109    } 
     110 
     111    /// Callback for cleaning 
     112    void OnClean(Object s, wxEvent e) 
     113    { 
     114        // FIXME 
     115        (new DPSProcessWindow("dsss distclean")).Show(true); 
     116    } 
     117 
     118    /// Callback for editing 
     119    void OnEditDSSSConf(Object s, wxEvent e) 
     120    { 
     121        // FIXME 
     122        (new DPSProcessRun(editor ~ " dsss.conf", &(dpsApp.loadTopDSSSConf))).Show(false); 
     123    } 
     124} 
  • other/dps/trunk/dsssps/dps.d

    r699 r700  
    2424 
    2525import dsssps.components; 
     26import dsssps.prefs; 
    2627 
    2728char[] binPath; 
     
    3334{ 
    3435    wxTreeCtrl components; /// The components tree 
    35  
     36     
     37    // IDs for important elements 
     38    enum Elem { Tree, MenuBar, MenuPreferences, MenuQuit }; 
     39     
    3640    /// Load the top dsss.conf file into the components tree 
    3741    void loadTopDSSSConf() 
     
    4448        DSSSConf conf = readConfig([]); 
    4549 
     50        // set up the head 
     51        wxTreeItemId top = components.AddRoot(conf.settings[""]["name"], 0, -1, new CompTop()); 
     52 
    4653        // then call loadDSSSConf to load it in 
    47         wxTreeItemId top = components.AddRoot(conf.settings[""]["name"]); 
    4854        loadDSSSConf(components, top, conf); 
    4955    } 
     
    8591                comp = tree.AppendItem(top, 
    8692                    sect ~ " [binary]", 1, -1, 
    87                     new CompFile(sect)); 
     93                    new CompFileBuild(sect)); 
    8894 
    8995                // now use rebuild to get the list 
     
    108114                } 
    109115 
     116                // then use rebuild to get the list of non-existing files 
     117                p = new Process("rebuild -notfound " ~ sect, Environment.get()); 
     118                p.execute(); 
     119                flist = null; 
     120                foreach (line; new LineIterator!(char)(p.stdout)) { 
     121                    flist ~= line.dup; 
     122                } 
     123                p.wait(); 
     124 
     125                // sort it 
     126                flist.sort; 
     127                if (flist.length != 0) { 
     128                    // OK, need to add a not-found section 
     129                    wxTreeItemId notfound = 
     130                        tree.AppendItem(comp, 
     131                            "Non-existent files", 0, -1); 
     132 
     133                    foreach (file; flist) { 
     134                        tree.AppendItem(notfound, 
     135                            file, 1, -1, 
     136                            new CompFile(file)); 
     137                    } 
     138                } 
     139 
    110140            } else { 
    111141                // otherwise, just the top 
     
    118148    } 
    119149 
    120     // IDs for important elements 
    121     enum Elem { Tree }; 
    122  
    123150    public override bool OnInit() 
    124151    { 
    125152        wxFrame frame = new wxFrame(null, wxID_ANY, "DSSS Project Studio"); 
     153 
     154        // set up the menus 
     155        wxMenu fileMenu = new wxMenu(); 
     156 
     157        fileMenu.Append(Elem.MenuPreferences, "Preferences"); 
     158        EVT_MENU(Elem.MenuPreferences, &OnPreferences); 
     159 
     160        fileMenu.Append(Elem.MenuQuit, "Quit"); 
     161        EVT_MENU(Elem.MenuQuit, &OnQuit); 
     162 
     163        wxMenuBar menuBar = new wxMenuBar(); 
     164        menuBar.Append(fileMenu, "File"); 
     165        frame.menuBar(menuBar); 
    126166         
    127167        // get some images for the tree 
     
    134174        components.AssignImageList(il); 
    135175        EVT_TREE_ITEM_ACTIVATED(Elem.Tree, &activatedFile); 
     176        EVT_TREE_ITEM_RIGHT_CLICK(Elem.Tree, &treeMenu); 
    136177 
    137178        // load in the dsss.conf file 
     
    148189    { 
    149190        // s should be a wxTreeItemId 
    150         s = e.EventObject(); 
    151         if (cast(wxTreeCtrl) s is null) { 
    152             return; 
    153         } 
    154         wxTreeCtrl wtc = cast(wxTreeCtrl) s; 
    155  
     191        wxTreeCtrl wtc = cast(wxTreeCtrl) e.EventObject(); 
    156192        wxTreeItemId i = wtc.Selection(); 
    157193        wxTreeItemData d = wtc.GetItemData(i); 
     
    160196            if (c !is null) { 
    161197                // activate it 
    162                 c.activate(); 
     198                c.activate(wtc, e); 
    163199            } 
    164200        } 
    165201    } 
     202 
     203    /// Pop up the menu for the tree 
     204    void treeMenu(Object s, wxEvent e) 
     205    { 
     206        wxTreeCtrl wtc = cast(wxTreeCtrl) e.EventObject(); 
     207        wxTreeItemId i = wtc.Selection(); 
     208        wxTreeItemData d = wtc.GetItemData(i); 
     209        if (d !is null) { 
     210            Component c = cast(Component) d; 
     211            if (c !is null) { 
     212                c.popupMenu(wtc, e); 
     213            } 
     214        } 
     215    } 
     216 
     217    /// Pressed "preferences" 
     218    void OnPreferences(Object s, wxEvent e) 
     219    { 
     220        Cout("Preferences.").newline; 
     221    } 
     222 
     223    /// Pressed "Quit" 
     224    void OnQuit(Object s, wxEvent e) 
     225    { 
     226        exit(0); 
     227    } 
    166228} 
     229 
     230DPSApp dpsApp; 
     231 
     232/// Use this int for "floating" wx IDs: ++floatingIds to get a new one 
     233int floatingIds = 99; 
    167234 
    168235int main(char[][] args) 
    169236{ 
    170237    binPath = Environment.exePath(args[0]).path(); 
    171     DPSApp app = new DPSApp(); 
    172     app.Run(); 
     238    loadPrefs(args[0]); 
     239    dpsApp = new DPSApp(); 
     240    dpsApp.Run(); 
    173241    return 0; 
    174242} 
  • other/dps/trunk/sss/conf.d

    r699 r700  
    432432    char[] confFile; 
    433433     
    434     if ((new FilePath(configFName)).exists()) { 
     434    if ((new FilePath(configF)).exists()) { 
    435435        if (genconfig) { 
    436436            // this makes no sense 
     
    439439        } 
    440440         
    441         // before reading the config, distclean if it's changed 
    442         if (configF == configFName) { 
    443             if ((new FilePath(configLBName)).exists()) { 
    444                 if (fileNewer(configFName, configLBName)) { 
    445                     // our config has changed 
    446                     distclean(readConfig(null, false, configLBName)); 
    447                 } 
    448             } 
    449          
    450             // copy in our new dsss.lastbuild 
    451             (new FilePath(configLBName)).copy(configFName); 
    452         } 
    453          
    454441        // Read the config file 
    455         confFile = cast(char[]) (new File(configFName)).read(); 
     442        confFile = cast(char[]) (new File(configF)).read(); 
    456443    } else { 
    457444        // Generate the config file 
     
    479466        if (genconfig) { 
    480467            // write it 
    481             (new File(configFName)).write(confFile); 
     468            (new File(configF)).write(confFile); 
    482469        } 
    483470         
     
    916903                proc = new Process(cmd); 
    917904            } 
     905            proc.execute(); 
    918906             
    919907            // now catch its output