[Zope-CVS] CVS: Packages/Moztop/moztop/content - global.js:1.2 moztop.js:1.13 moztop.xul:1.9
Paul Everitt
paul@zope.com
Sat, 25 Jan 2003 12:44:32 -0500
Update of /cvs-repository/Packages/Moztop/moztop/content
In directory cvs.zope.org:/tmp/cvs-serv32357
Modified Files:
global.js moztop.js moztop.xul
Log Message:
Made the move to using rdf files in the profile dir, courtesy of
the snippet from ScottR. This means:
o A new dir "Explorer" to replace Inspector, since we
don't have tabs in the left side now
o No connection made on startup yet (more repair later)
o For now, you have to manually copy Data/moztop*rdf to
your profile dir, because 5 hours of fighting jslib
ended in defeat.
Since the URN structure has changed and the id of the
element with the datasources has changed, more work
has to be done to get it operational.
=== Packages/Moztop/moztop/content/global.js 1.1 => 1.2 ===
--- Packages/Moztop/moztop/content/global.js:1.1 Wed Jan 15 23:11:20 2003
+++ Packages/Moztop/moztop/content/global.js Sat Jan 25 12:43:58 2003
@@ -1,45 +1,77 @@
-/*****************************************************************************
-*
-* Copyright (c) 2002, 2003 Zope Corporation and Contributors.
-* All Rights Reserved.
-*
-* This software is subject to the provisions of the Zope Public License,
-* Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
-* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-* WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-* WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-* FOR A PARTICULAR PURPOSE.
-*
-******************************************************************************
-Global Javascript library that collects some of the most important constants,
-variables and functions that are not sensible to reloading. Note that this is
-*not* the right file to define global RDF datasources!
-
-$Id$
-
-******************************************************************************/
-
-/* We really need to grab the RDF Service only once. */
-var RDF =
- Components
- .classes["@mozilla.org/rdf/rdf-service;1"]
- .getService(Components.interfaces.nsIRDFService);
-
-
-/* This function gets the document of a Window having the correct id. This is
- * exremly important when dealing with dialogs and other secondary windows. */
-function getDocumentOfWindowWithId(id) {
- var win = null;
- var wmediator =
- Components.classes['@mozilla.org/appshell/window-mediator;1'].
- getService(Components.interfaces.nsIWindowMediator);
- var openwindows = wmediator.getEnumerator(null);
-
- while (openwindows.hasMoreElements()) {
- win = openwindows.getNext();
- if (win.document.getElementById(id) != null) {
- return win.document;
- }
- }
- return null;
-}
+/*****************************************************************************
+*
+* Copyright (c) 2002, 2003 Zope Corporation and Contributors.
+* All Rights Reserved.
+*
+* This software is subject to the provisions of the Zope Public License,
+* Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
+* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+* WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+* WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+* FOR A PARTICULAR PURPOSE.
+*
+******************************************************************************
+Global Javascript library that collects some of the most important constants,
+variables and functions that are not sensible to reloading. Note that this is
+*not* the right file to define global RDF datasources!
+
+$Id$
+
+******************************************************************************/
+
+/* We really need to grab the RDF Service only once. */
+var RDF =
+ Components
+ .classes["@mozilla.org/rdf/rdf-service;1"]
+ .getService(Components.interfaces.nsIRDFService);
+
+
+/* This function gets the document of a Window having the correct id. This is
+ * exremly important when dealing with dialogs and other secondary windows. */
+function getDocumentOfWindowWithId(id) {
+ var win = null;
+ var wmediator =
+ Components.classes['@mozilla.org/appshell/window-mediator;1'].
+ getService(Components.interfaces.nsIWindowMediator);
+ var openwindows = wmediator.getEnumerator(null);
+
+ while (openwindows.hasMoreElements()) {
+ win = openwindows.getNext();
+ if (win.document.getElementById(id) != null) {
+ return win.document;
+ }
+ }
+ return null;
+}
+
+
+// Return a string with a cross-platform
+// file:/// pointer to the profile directory
+function getProfileURL () {
+ // First get the directory service and query interface it to
+ // nsIProperties
+ var dirService = Components.
+ classes['@mozilla.org/file/directory_service;1'].
+ getService(Components.interfaces.nsIProperties);
+
+ // Next get the "ProfD" property of type nsIFile from the directory
+ // service, FYI this constant is defined in
+ // mozilla/xpcom/io/nsAppDirectoryServiceDefs.h
+
+ const NS_APP_USER_PROFILE_50_DIR = "ProfD";
+ profileDir = dirService.get(NS_APP_USER_PROFILE_50_DIR,
+ Components.interfaces.nsIFile);
+
+ // Now that we have it we can show it's path. See nsIFile for the
+ // other things you that can be done with profileDir
+
+ var io_service =
+ Components.classes["@mozilla.org/network/io-service;1"].
+ getService(Components.interfaces.nsIIOService);
+
+ var url = io_service.newFileURI(profileDir)
+ .QueryInterface(Components.interfaces.nsIFileURL);
+
+ return url.spec;
+}
+
=== Packages/Moztop/moztop/content/moztop.js 1.12 => 1.13 ===
--- Packages/Moztop/moztop/content/moztop.js:1.12 Thu Jan 16 10:54:39 2003
+++ Packages/Moztop/moztop/content/moztop.js Sat Jan 25 12:43:58 2003
@@ -19,6 +19,10 @@
******************************************************************************/
+// Setup the two client-side RDF datasources
+var sitesds = null;
+var typesds = null;
+
/* Function that is executed when Moztop is started. */
function startProgram() {
initTaskList();
@@ -46,10 +50,19 @@
/* Initialize the Explorer datasource */
function initExplorer() {
- var ds = RDF.GetDataSource(RDF_BASE + '@@contents.rdf');
- var tree = document.getElementById('navigationtree');
- tree.database.AddDataSource(ds);
- tree.setAttribute("ref", "urn:explorer:data");
+ // var ds = RDF.GetDataSource(RDF_BASE + '@@contents.rdf');
+ // var tree = document.getElementById('navigationtree');
+ // tree.database.AddDataSource(ds);
+ // tree.setAttribute("ref", "urn:explorer:data");
+
+ var prefsdir = getProfileURL();
+ var sitesds = new RDFDataSource(prefsdir + "/moztop_sites.rdf");
+ var typesds = new RDFDataSource(prefsdir + "/moztop_types.rdf");
+
+ var explorer=document.getElementById("navigationtree");
+ explorer.database.AddDataSource(sitesds.getRawDataSource());
+ explorer.database.AddDataSource(typesds.getRawDataSource());
+ explorer.builder.rebuild();
}
/* Reload Explorer datasource */
@@ -69,3 +82,4 @@
alert('Done reloading Content Tree.');
tree.builder.rebuild();
}
+
=== Packages/Moztop/moztop/content/moztop.xul 1.8 => 1.9 ===
--- Packages/Moztop/moztop/content/moztop.xul:1.8 Thu Jan 16 11:20:57 2003
+++ Packages/Moztop/moztop/content/moztop.xul Sat Jan 25 12:43:58 2003
@@ -7,7 +7,7 @@
<?xul-overlay href="chrome://moztop/content/Menu/MenuOverlay.xul"?>
<?xul-overlay href="chrome://moztop/content/Menu/ToolBarOverlay.xul"?>
-<?xul-overlay href="chrome://moztop/content/Inspector/InspectorOverlay.xul"?>
+<?xul-overlay href="chrome://moztop/content/Explorer/ExplorerOverlay.xul"?>
<?xul-overlay href="chrome://moztop/content/Main/MainOverlay.xul"?>
<?xul-overlay href="chrome://moztop/content/StatusBar/StatusBarOverlay.xul"?>
@@ -29,6 +29,7 @@
onclose = "return closeProgram();">
<script type="application/x-javascript" src="setup.js"/>
+ <script type="application/x-javascript" src="rdfds.js"/>
<script type="application/x-javascript" src="global.js"/>
<script type="application/x-javascript" src="moztop.js"/>
<script type="application/x-javascript" src="StatusBar/TaskManager.js"/>
@@ -52,7 +53,7 @@
</box>
<box orient="horizontal" flex="10">
- <tabbox id="inspector-tabbox" flex="3"/>
+ <vbox id="explorer" flex="3"/>
<splitter collapse="before">
<spacer flex="1"/><grippy/><spacer flex="1"/>
</splitter>