Changeset 86

Show
Ignore:
Timestamp:
08/17/08 09:19:50 (4 months ago)
Author:
bi..@lilyapp.org
Message:

fix bug #47.
add activity icons to the images directory and remove the gif that was there.
add a "runInBackground" method to utils.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lily/lily/chrome/content/lily.js

    r76 r86  
    289289                //win,str,width,color 
    290290                if(!this.initialized) 
    291                         LilyUtils.displayMessageDialog(content,"<img src='chrome://lily/content/images/ajax-loader-black.gif'/>",200);         
     291                        LilyUtils.displayMessageDialog(content,"<img src='chrome://lily/content/images/activity-medium.png'/>",200);   
    292292        }, 
    293293                                 
     
    873873        */ 
    874874        savePatchAsAddOn: function(pID) { 
    875                  
     875 
    876876                var patchID=pID||this.currPatch; 
    877                  
    878877                var exportParams = {id:patchID,type:"addon",platform:LilyUtils.navigatorPlatform()};     
    879                  
     878 
    880879                //show a dialog to get the export details 
    881880        Lily.getCurrentPatch().patchView.xulWin.openDialog("chrome://lily/content/exportDialog.xul", "lilyExportDialog", "chrome,titlebar,toolbar,centerscreen,modal",exportParams);             
    882                  
     881 
     882                Lily.getCurrentPatch().patchView.showWindowStatusActivity(true); 
     883                Lily.getCurrentPatch().patchView.setWindowStatusText("Saving as addon...") 
     884 
    883885                if(exportParams.saved) { 
    884                         LilyPatchExporter.savePatchAsAddOn(exportParams);        
     886                        LilyUtils.runInBackGround(function(){ 
     887                                LilyPatchExporter.savePatchAsAddOn(exportParams);        
     888                        },function(){ 
     889                                Lily.getCurrentPatch().patchView.showWindowStatusActivity(false); 
     890                                Lily.getCurrentPatch().patchView.clearWindowStatusText();                                
     891                        }) 
    885892                } 
    886893                 
     
    900907        Lily.getCurrentPatch().patchView.xulWin.openDialog("chrome://lily/content/exportDialog.xul", "lilyExportDialog", "chrome,titlebar,toolbar,centerscreen,modal",exportParams);                     
    901908                 
     909                Lily.getCurrentPatch().patchView.showWindowStatusActivity(true); 
     910                Lily.getCurrentPatch().patchView.setWindowStatusText("Saving as app...") 
     911 
    902912                if(exportParams.saved) { 
    903                         LilyPatchExporter.savePatchAsApp(exportParams); 
     913                        LilyUtils.runInBackGround(function(){ 
     914                                LilyPatchExporter.savePatchAsApp(exportParams);  
     915                        },function(){ 
     916                                Lily.getCurrentPatch().patchView.showWindowStatusActivity(false); 
     917                                Lily.getCurrentPatch().patchView.clearWindowStatusText();                                
     918                        }) 
    904919                }                
     920                 
    905921        },       
    906922 
  • trunk/lily/lily/chrome/content/patch.js

    r80 r86  
    20292029        this.chromeWin=null; //browsers chrome window 
    20302030        this.statusBar=null; //status bar 
    2031         this.statusBarIcon=null; //icon status bar       
     2031        this.statusBarIcon=null; //icon status bar 
     2032        this.statusBarActivity=null; //activity status bar 
    20322033        this.document=null; 
    20332034        this.body=null; 
     
    21662167                this.body.style.fontSize=LilyUtils.sizeFontForPlatform(size); 
    21672168        } 
     2169         
     2170        this.showWindowStatusActivity=function(state) {                          
     2171                if(state) 
     2172                        this.statusBarActivity.style.visibility="visible"; 
     2173                else 
     2174                        this.statusBarActivity.style.visibility="hidden"; 
     2175        }        
    21682176         
    21692177        this.setWindowStatusIcon=function(state) {               
     
    22352243 
    22362244                thisPtr.statusBar={setAttribute:function(){}};// 
    2237                 thisPtr.statusBarIcon={setAttribute:function(){}}; //window.status;// 
     2245                thisPtr.statusBarIcon={setAttribute:function(){}}; //window.status// 
    22382246 
    22392247                //pass the window refs to the controller 
     
    22762284                thisPtr.head=thisPtr.oWin.document.getElementById("headElement"); 
    22772285 
    2278                 thisPtr.statusBar=thisPtr.xulWin.document.getElementById("lilyStatusPanel")||{setAttribute:function(){}};; 
    2279                 thisPtr.statusBarIcon=thisPtr.xulWin.document.getElementById("lilyIconPanel")||{setAttribute:function(){}};; 
     2286                thisPtr.statusBar=thisPtr.xulWin.document.getElementById("lilyStatusPanel")||{setAttribute:function(){}}; 
     2287                thisPtr.statusBarIcon=thisPtr.xulWin.document.getElementById("lilyIconPanel")||{setAttribute:function(){}}; 
     2288                thisPtr.statusBarActivity=thisPtr.xulWin.document.getElementById("lilyStatusActivity")||{setAttribute:function(){}}; 
    22802289 
    22812290                //pass the window refs to the controller 
     
    23572366                thisPtr.statusBar=thisPtr.xulWin.document.getElementById("lilyStatusPanel"); 
    23582367                thisPtr.statusBarIcon=thisPtr.xulWin.document.getElementById("lilyIconPanel"); 
     2368                thisPtr.statusBarActivity=thisPtr.xulWin.document.getElementById("lilyStatusActivity");          
    23592369                                                                 
    23602370                //pass the window refs to the controller 
  • trunk/lily/lily/chrome/content/patch.xul

    r57 r86  
    189189                        <statusbarpanel tooltiptext="Patch is unlocked for editing. Click to lock." onclick="opener.Lily.toggleEdit()" class="statusbarpanel-iconic" src="chrome://lily/content/images/lock_open.png" id="lilyIconPanel" width="20"/> 
    190190                        <statusbarpanel style="height:24px;font-size:18px;font-family:verdana,DejaVu Sans,sans-serif;" id="lilyStatusPanel" flex="1"/> 
     191                        <image style="visibility:hidden" id="lilyStatusActivity" src="chrome://lily/content/images/activity-medium.png"/> 
    191192                </statusbar> 
    192193        </vbox> 
  • trunk/lily/lily/chrome/content/utils.js

    r79 r86  
    20762076        }, 
    20772077         
     2078        /* 
     2079                Method: runInBackGround 
     2080                        run a method in the background. 
     2081         
     2082                Arguments:  
     2083                        f - function to run in the background 
     2084                        cb - function to call with the result 
     2085        */ 
     2086        runInBackGround: function(f,cb) { 
     2087                 
     2088                var workingThread = function(threadID,func) { 
     2089                  this.threadID = threadID; 
     2090                  this.func = func; 
     2091              this.result; 
     2092                }; 
     2093 
     2094                workingThread.prototype = { 
     2095                  run: function() { 
     2096                    try { 
     2097                      // This is where the working thread does its processing work. 
     2098                          this.result = this.func(); 
     2099                      // When it's done, call back to the main thread to let it know 
     2100                      // we're finished. 
     2101                      main.dispatch(new mainThread(this.threadID, this.result), 
     2102                        background.DISPATCH_NORMAL); 
     2103                    } catch(err) { 
     2104                      Components.utils.reportError(err); 
     2105                    } 
     2106                  }, 
     2107 
     2108                  QueryInterface: function(iid) { 
     2109                    if (iid.equals(Components.interfaces.nsIRunnable) || 
     2110                        iid.equals(Components.interfaces.nsISupports)) { 
     2111                            return this; 
     2112                    } 
     2113                    throw Components.results.NS_ERROR_NO_INTERFACE; 
     2114                  } 
     2115                }; 
     2116                 
     2117                 
     2118                var mainThread = function(threadID,result) { 
     2119                  this.threadID = threadID; 
     2120                  this.result = result; 
     2121                }; 
     2122 
     2123                mainThread.prototype = { 
     2124                  run: function() { 
     2125                    try { 
     2126                      // This is where we react to the completion of the working thread. 
     2127                                cb(this.threadID,this.result); 
     2128                    } catch(err) { 
     2129                      Components.utils.reportError(err); 
     2130                    } 
     2131                  }, 
     2132 
     2133                  QueryInterface: function(iid) { 
     2134                    if (iid.equals(Components.interfaces.nsIRunnable) || 
     2135                        iid.equals(Components.interfaces.nsISupports)) { 
     2136                            return this; 
     2137                    } 
     2138                    throw Components.results.NS_ERROR_NO_INTERFACE; 
     2139                  } 
     2140                };       
     2141                 
     2142                var background = Components.classes["@mozilla.org/thread-manager;1"].getService().newThread(0); 
     2143                var main = Components.classes["@mozilla.org/thread-manager;1"].getService().mainThread; 
     2144                background.dispatch(new workingThread(1,f), background.DISPATCH_NORMAL); 
     2145                 
     2146        }, 
     2147         
    20782148        //drag code from https://addons.mozilla.org/en-US/seamonkey/addon/2190/ by Emanuele Ruffaldi- http://www.teslacore.it 
    20792149        dragDropHandler: function(cb) {