Commits

stacklet  committed 3bd238d

Set the app string and copyright based on application.ini

  • Participants
  • Parent commits 0335643
  • Tags alpha_release_20100312

Comments (0)

Files changed (1)

File src/stacklet/stackbundler/chrome/content/about.xul

 <?xml version="1.0"?>
 <?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
 
-<window id="main" title="About Stacklet Bundler" width="600" height="400" onclose="quit();"
+<window id="main" title="About Stacklet Bundler" width="600" height="400" onclose="quit();" onload="initAbout();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
 <script>
 
+function initAbout(){
+  try {
+    var name = '';
+    var version = '';
+    var build = '';
+    var copyright = '';
+    var DIR_SERVICE = new Components.Constructor("@mozilla.org/file/directory_service;1", "nsIProperties");
+    var path = (new DIR_SERVICE()).get('resource:app', Components.interfaces.nsIFile).path + '/application.ini';
+    var file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);  
+    file.initWithPath(path);
+
+    var istream = Components.classes["@mozilla.org/network/file-input-stream;1"].createInstance(Components.interfaces.nsIFileInputStream);  
+    istream.init(file, 0x01, 0444, 0);  
+    istream.QueryInterface(Components.interfaces.nsILineInputStream);  
+   
+    var line = {}, lines = [], hasmore;  
+    do {  
+      hasmore = istream.readLine(line);
+      if (line.value.indexOf('BuildID=') == 0) {
+        build = line.value.substring(10);        
+      } else if (line.value.indexOf('Name=') == 0) {
+        name = line.value.substring(5);        
+      } else if (line.value.indexOf('Version=') == 0) {
+        version = line.value.substring(8);        
+      } else if (line.value.indexOf('Copyright=') == 0) {
+        copyright = line.value.substring(10);        
+      }      
+    } while(hasmore);  
+    
+    document.getElementById('appString').value = name + ' ' + version + '; Build ' + build;
+    document.getElementById('copyright').value = copyright;
+    
+  } catch (err) {
+    alert(err);
+  }
+}
+
 function quit(){
   try {
     var appStartup = Components.classes['@mozilla.org/toolkit/app-startup;1'].getService(Components.interfaces.nsIAppStartup);
 }
 </script>  
   <groupbox orient='vertical' align='center' style="font-weight : bold;" >
-    <label value='Stacklet Bundler 1.0 Beta'/>
+    <label id='appString' value=''/>
+    <label id='copyright' value=''/>
     <textbox width='250' readonly="true" multiline="false" class="plain" value="http://stacklet.com/stackbundler"/>
     <label value='GNU GPL Version 2'/>
   </groupbox>