[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

gEDA-cvs: gaf.git: branch: master updated (1.7.1-20110619-222-g1c00bf5)



The branch, master has been updated
       via  1c00bf53cb8b49eb29e84a63e5c49253fc479f21 (commit)
       via  ae070b080856b6eef1059ee50dede82cc4f0afe8 (commit)
       via  ba0651db94d86a2407f16027213ce3068670cc36 (commit)
       via  30fa50eb42e33e4c8ff616eef7c4ba10eb65d228 (commit)
       via  c0d2ef0cd57cd566c457979b67a017503591d7aa (commit)
       via  3c2f5abf382a78b2ad5e1af2b08c9b5bec9d21b7 (commit)
       via  eb1e773f3f95f99fcd6ac6d0d0ebc947102e60ab (commit)
       via  c41a838b680ed158ddd8e2acb880de21caf0a352 (commit)
       via  ec03489e1057f10a35a0877c52034dee99f50bc6 (commit)
      from  0f3a44ec39dfb562ccfd9d3d458ba5e9062d2259 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


=========
 Summary
=========

 NEWS                                   |    6 +
 README                                 |    2 +-
 configure.ac                           |   18 +-
 docs/scheme-api/geda-scheme.texi       |   91 +++++++++
 gschem/include/prototype.h             |    7 +-
 gschem/lib/system-gschemrc.scm         |    8 -
 gschem/po/POTFILES.in                  |    2 +
 gschem/scheme/Makefile.am              |    4 +-
 gschem/scheme/gschem.scm               |   46 +++++-
 gschem/scheme/gschem/gschemdoc.scm     |  224 ++++++++++++++++++++++
 gschem/scheme/gschem/util.scm          |   27 +++
 gschem/scripts/Makefile.am             |   13 +-
 gschem/scripts/gschemdoc.sh            |  327 --------------------------------
 gschem/src/Makefile.am                 |    3 +
 gschem/src/g_funcs.c                   |   60 ------
 gschem/src/g_keys.c                    |    1 -
 gschem/src/g_register.c                |    3 -
 gschem/src/g_util.c                    |   90 +++++++++
 gschem/src/g_window.c                  |   11 +-
 gschem/src/gschem.c                    |    1 +
 gschem/src/i_callbacks.c               |  100 ----------
 gschem/src/x_misc.c                    |  162 ++++++++++++++++
 libgeda/include/libgedaguile_priv.h    |    1 +
 libgeda/scheme/Makefile.am             |    4 +-
 libgeda/scheme/geda/os.scm             |   57 ++++++
 libgeda/scheme/unit-tests/t0400-os.scm |   26 +++
 libgeda/src/Makefile.am                |    2 +
 libgeda/src/f_basic.c                  |   18 ++-
 libgeda/src/libgeda.c                  |    3 +
 libgeda/src/scheme_init.c              |    1 +
 libgeda/src/scheme_os.c                |  104 ++++++++++
 m4/geda-host.m4                        |   79 ++++++++
 m4/geda-uri-viewer.m4                  |   75 ++++++++
 m4/geda-windows.m4                     |   36 +---
 34 files changed, 1054 insertions(+), 558 deletions(-)
 create mode 100644 gschem/scheme/gschem/gschemdoc.scm
 create mode 100644 gschem/scheme/gschem/util.scm
 delete mode 100644 gschem/scripts/gschemdoc.sh
 create mode 100644 gschem/src/g_util.c
 create mode 100644 gschem/src/x_misc.c
 create mode 100644 libgeda/scheme/geda/os.scm
 create mode 100644 libgeda/scheme/unit-tests/t0400-os.scm
 create mode 100644 libgeda/src/scheme_os.c
 create mode 100644 m4/geda-host.m4
 create mode 100644 m4/geda-uri-viewer.m4


=================
 Commit Messages
=================

commit 1c00bf53cb8b49eb29e84a63e5c49253fc479f21
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>

    gschem: Rewrite gschemdoc in Scheme.
    
    This completely removes the "gschemdoc" helper tool, and reimplements
    almost all its functionality in Scheme, using the "show-uri" function
    added in commit b4452ce0b1d4.  This permits gschem's documentation and
    component documentation to be found and shown in an appropriate viewer
    on all platforms, including Windows.  I have verified that this works
    correctly on Linux, Cygwin and Windows XP.
    
    There is a drawback, however, in that "locate" is no longer used to
    search for candidate files -- only the gEDA documentation directory
    and the working directory are checked.  In future, this functionality
    should probably be restored using desktop search.  There may also be
    problems displaying documentation if gEDA data or documentation were
    installed to non-standard directories, due to the slightly inelegant
    methods used to detect the gEDA documentation directory relocatably.
    
    The component documentation search behaviour can be altered by
    redefining the 'hierarchy-documentation' function in a gschemrc file.

:100644 100644 560f9a0... fdd42b0... M	NEWS
:100644 100644 c0eebc7... 4795ef3... M	gschem/include/prototype.h
:100644 100644 6008dc5... 59a7ec9... M	gschem/lib/system-gschemrc.scm
:100644 100644 8d1d0c3... 54d5a52... M	gschem/scheme/Makefile.am
:100644 100644 db19279... 508511f... M	gschem/scheme/gschem.scm
:000000 100644 0000000... e441dc3... A	gschem/scheme/gschem/gschemdoc.scm
:100644 100644 8c2c7a1... a6e3533... M	gschem/scripts/Makefile.am
:100644 000000 c24cde8... 0000000... D	gschem/scripts/gschemdoc.sh
:100644 100644 1e3a0c4... 8d8f44b... M	gschem/src/g_funcs.c
:100644 100644 45bd971... d48f701... M	gschem/src/g_keys.c
:100644 100644 a053a0f... fb01771... M	gschem/src/g_register.c
:100644 100644 6a1e216... f37e68e... M	gschem/src/i_callbacks.c

commit ae070b080856b6eef1059ee50dede82cc4f0afe8
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>

    scheme-api: Add (geda os) module.
    
    Add the (geda os) module, which provides operating system information
    and services, including:
    
    - host operating system classification
    - gEDA standard paths
    - directory and search path separators

:100644 100644 70fc3d7... f383000... M	docs/scheme-api/geda-scheme.texi
:100644 100644 49916ab... 229119b... M	libgeda/include/libgedaguile_priv.h
:100644 100644 e35bb47... 6c221f4... M	libgeda/scheme/Makefile.am
:000000 100644 0000000... 8430e6e... A	libgeda/scheme/geda/os.scm
:000000 100644 0000000... aa58206... A	libgeda/scheme/unit-tests/t0400-os.scm
:100644 100644 07a80d3... c65c979... M	libgeda/src/Makefile.am
:100644 100644 7dd2321... a9da63e... M	libgeda/src/scheme_init.c
:000000 100644 0000000... 72e1b9a... A	libgeda/src/scheme_os.c

commit ba0651db94d86a2407f16027213ce3068670cc36
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>

    build-sys: More extensive host tests.
    
    Adds explicit checks for Cygwin and OS X.

:000000 100644 0000000... 5e06541... A	m4/geda-host.m4
:100644 100644 4658d3c... 2e26d94... M	m4/geda-windows.m4

commit 30fa50eb42e33e4c8ff616eef7c4ba10eb65d228
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>

    scheme-api: Add show-uri and show-file functions to (gschem util).

:100644 100644 0ee90ae... 70fc3d7... M	docs/scheme-api/geda-scheme.texi
:100644 100644 4332459... c0eebc7... M	gschem/include/prototype.h
:100644 100644 c596672... f24e2e3... M	gschem/po/POTFILES.in
:100644 100644 6c60a63... 8d1d0c3... M	gschem/scheme/Makefile.am
:000000 100644 0000000... 72ab874... A	gschem/scheme/gschem/util.scm
:100644 100644 dcc4be3... 12d22d6... M	gschem/src/Makefile.am
:000000 100644 0000000... f96ada3... A	gschem/src/g_util.c
:100644 100644 f2776a0... d33d35d... M	gschem/src/gschem.c

commit c0d2ef0cd57cd566c457979b67a017503591d7aa
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>

    gschem: Add x_show_uri().
    
    This function launches a URI in the appropriate application for
    handling it, as determined by the platform's filetype association
    settings.
    
    GTK+ 2.16.0 and later provide a the gtk_show_uri() function, which
    attempts to use GIO to launch the default application for a URI.
    Unfortunately, it doesn't work properly on Windows with HTTP and FTP
    URLs, does evil things with FUSE when passed some URIs, and insists on
    GNOME applications even when you're not running GNOME.  Unfortunately,
    it is also currently considered the Right Way of doing things, and has
    the advantage of providing detailed error messages when things go
    wrong.
    
    With this patch, x_show_url() defaults to using gtk_show_url() on
    Linux, but not on other host platforms.  The --enable-gio and
    --disable-gio arguments to configure can be used to override this
    behaviour.
    
    If GIO is not enabled, the default behaviour differs depending on the
    platform:
    
    - On native Windows, the ShellExecute() API call is used by default.
    
    - On other platforms, a helper command is used.  If the URI_VIEWER
      variable was not set during configure, the command used is:
    
      * `cygstart' on Cygwin
      * `open' on Mac OS X
      * `xdg-open' otherwise.
    
    Using a helper command can be forced on Windows by setting URI_VIEWER.
    
    For example, to disable GIO and select an alternative URI launcher
    command:
    
      ./configure URI_VIEWER=my-open --disable-gio

:100644 100644 8d65cb9... 595d832... M	configure.ac
:100644 100644 b55c4c8... 4332459... M	gschem/include/prototype.h
:100644 100644 bfe0b68... c596672... M	gschem/po/POTFILES.in
:100644 100644 44e7cd1... dcc4be3... M	gschem/src/Makefile.am
:000000 100644 0000000... 52211d1... A	gschem/src/x_misc.c
:000000 100644 0000000... a0bfeb2... A	m4/geda-uri-viewer.m4

commit 3c2f5abf382a78b2ad5e1af2b08c9b5bec9d21b7
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>

    build-sys: Require at least GTK+ 2.16.0.

:100644 100644 c03e9af... 560f9a0... M	NEWS
:100644 100644 2af142d... f595b74... M	README
:100644 100644 c98281f... 8d65cb9... M	configure.ac

commit eb1e773f3f95f99fcd6ac6d0d0ebc947102e60ab
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>

    libgeda: Make sure paths are set up during initialisation.
    
    Until the s_path_*() functions are called, the GEDADATA and GEDADATARC
    environment variables may not be set.  Make sure the environment
    variables are set up during library startup.

:100644 100644 bd08412... 5bb3eb4... M	libgeda/src/libgeda.c

commit c41a838b680ed158ddd8e2acb880de21caf0a352
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>

    scheme-api: Fix duplicate function name close_page_x.
    
    This was causing build failures on Cygwin.

:100644 100644 ca1023d... 2996ce6... M	gschem/src/g_window.c

commit ec03489e1057f10a35a0877c52034dee99f50bc6
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>

    libgeda: Make f_normalize_pathname() behave correctly on Windows.
    
    On POSIX systems, f_normalize_pathname() emits a G_FILE_ERROR_NOENT
    error if the file is missing.  This patch makes it behave in the same
    way on Windows.
    
    This fixes some spurious "something went wrong in Scheme" error
    messages on Windows.
    
    Reported-by: DJ Delorie <dj@xxxxxxxxxxx>

:100644 100644 5438530... 5ee61c2... M	libgeda/src/f_basic.c

=========
 Changes
=========

commit 1c00bf53cb8b49eb29e84a63e5c49253fc479f21
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>

    gschem: Rewrite gschemdoc in Scheme.
    
    This completely removes the "gschemdoc" helper tool, and reimplements
    almost all its functionality in Scheme, using the "show-uri" function
    added in commit b4452ce0b1d4.  This permits gschem's documentation and
    component documentation to be found and shown in an appropriate viewer
    on all platforms, including Windows.  I have verified that this works
    correctly on Linux, Cygwin and Windows XP.
    
    There is a drawback, however, in that "locate" is no longer used to
    search for candidate files -- only the gEDA documentation directory
    and the working directory are checked.  In future, this functionality
    should probably be restored using desktop search.  There may also be
    problems displaying documentation if gEDA data or documentation were
    installed to non-standard directories, due to the slightly inelegant
    methods used to detect the gEDA documentation directory relocatably.
    
    The component documentation search behaviour can be altered by
    redefining the 'hierarchy-documentation' function in a gschemrc file.

diff --git a/NEWS b/NEWS
index 560f9a0..fdd42b0 100644
--- a/NEWS
+++ b/NEWS
@@ -30,6 +30,10 @@ Notable changes in gEDA/gaf 1.7.2
     the `global-set-key' function.  See notes in `system-gschemrc' for
     examples.
 
+* `gschem' now displays help files and component documentation on all
+  platforms, including Windows.  The `locate' tool is no longer used
+  to search for component documentation files.
+
 * The `bom' and `bom2' backends to `gnetlist' now give error messages
   if no attribute file can be found.  The `-O attrib_file=FILE' and
   `-O attribs=ATTRIB,ATTRIB...' options have also been added.
diff --git a/gschem/include/prototype.h b/gschem/include/prototype.h
index c0eebc7..4795ef3 100644
--- a/gschem/include/prototype.h
+++ b/gschem/include/prototype.h
@@ -29,7 +29,6 @@ SCM g_funcs_log(SCM msg);
 SCM g_funcs_msg(SCM msg);
 SCM g_funcs_confirm(SCM msg);
 SCM g_funcs_filesel(SCM msg, SCM templ, SCM flags);
-SCM g_funcs_browse_wiki(SCM wikiname);
 SCM g_funcs_use_rc_values(void);
 SCM get_selected_component_attributes(GSCHEM_TOPLEVEL *w_current);
 /* g_hook.c */
@@ -159,7 +158,6 @@ SCM g_keys_add_pin_hotkey(SCM rest);
 SCM g_keys_hierarchy_down_schematic(SCM rest);
 SCM g_keys_hierarchy_down_symbol(SCM rest);
 SCM g_keys_hierarchy_up(SCM rest);
-SCM g_keys_hierarchy_documentation(SCM rest);
 SCM g_keys_attributes_attach(SCM rest);
 SCM g_keys_attributes_detach(SCM rest);
 SCM g_keys_attributes_show_name(SCM rest);
@@ -430,7 +428,6 @@ void i_callback_add_pin_hotkey(gpointer data, guint callback_action, GtkWidget *
 void i_callback_hierarchy_down_schematic(gpointer data, guint callback_action, GtkWidget *widget);
 void i_callback_hierarchy_down_symbol(gpointer data, guint callback_action, GtkWidget *widget);
 void i_callback_hierarchy_up(gpointer data, guint callback_action, GtkWidget *widget);
-void i_callback_hierarchy_documentation(gpointer data, guint callback_action, GtkWidget *widget);
 void i_callback_attributes_attach(gpointer data, guint callback_action, GtkWidget *widget);
 void i_callback_attributes_detach(gpointer data, guint callback_action, GtkWidget *widget);
 void i_callback_attributes_show_name(gpointer data, guint callback_action, GtkWidget *widget);
diff --git a/gschem/lib/system-gschemrc.scm b/gschem/lib/system-gschemrc.scm
index 6008dc5..59a7ec9 100644
--- a/gschem/lib/system-gschemrc.scm
+++ b/gschem/lib/system-gschemrc.scm
@@ -1531,14 +1531,6 @@
 	   (,(N_ "Show _Coord Window...")   options-show-coord-window   
 				     options-show-coord-window)))
 
-; Set up some functions used to open help files for the help menu
-(define (help-manual)
-  (gschem-browse-wiki "geda:documentation"))
-(define (help-faq)
-  (gschem-browse-wiki "geda:faq-gschem"))
-(define (help-wiki)
-  (gschem-browse-wiki))
-
 (define help-menu-items 
 ;;
 ;;          menu item name                menu action               menu hotkey action        menu stock icon
diff --git a/gschem/scheme/Makefile.am b/gschem/scheme/Makefile.am
index 8d1d0c3..54d5a52 100644
--- a/gschem/scheme/Makefile.am
+++ b/gschem/scheme/Makefile.am
@@ -10,6 +10,7 @@ nobase_dist_scmdata_DATA = \
 	auto-place-attribs.scm \
 	pcb.scm \
 	default-attrib-positions.scm \
+	gschem/gschemdoc.scm \
 	gschem/window.scm \
 	gschem/selection.scm \
 	gschem/deprecated.scm \
diff --git a/gschem/scheme/gschem.scm b/gschem/scheme/gschem.scm
index db19279..508511f 100644
--- a/gschem/scheme/gschem.scm
+++ b/gschem/scheme/gschem.scm
@@ -17,7 +17,12 @@
 ;;; along with this program; if not, write to the Free Software
 ;;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
-(use-modules (gschem keymap))
+(use-modules (gschem keymap)
+             (gschem selection)
+             (gschem window)
+             (gschem gschemdoc)
+             (geda object)
+             (srfi srfi-1))
 
 ;; Define an eval-in-currentmodule procedure
 (define (eval-cm expr) (eval expr (current-module)))
@@ -140,3 +145,42 @@
 
   (build-dump! keymap '())
   lst)
+
+;;;; Documentation-related actions
+
+(define (hierarchy-documentation)
+  "hierarchy-documentation
+
+If a component is selected, search for and display corresponding
+documentation in a browser or PDF viewer. If no documentation can be
+found, shows a dialog with an error message."
+  (catch
+   'misc-error
+   (lambda ()
+     (let ((component
+            (any (lambda (obj) (and (component? obj) obj))
+                 (page-selection (active-page)))))
+       (and component (show-component-documentation component))))
+   (lambda (key subr msg args . rest)
+     (gschem-msg (string-append
+                  "Could not show documentation for selected component:\n\n"
+                  (apply format #f msg args))))))
+
+
+(define (help-manual)
+  "help-manual
+
+Display the front page of the gEDA manuals in a browser."
+  (show-wiki "geda:documentation"))
+
+(define (help-faq)
+  "help-faq
+
+Display the gschem Frequently Asked Questions in a browser."
+  (show-wiki "geda:faq-gschem"))
+
+(define (help-wiki)
+  "help-faq
+
+Display the gEDA wiki in a browser."
+  (show-wiki))
diff --git a/gschem/scheme/gschem/gschemdoc.scm b/gschem/scheme/gschem/gschemdoc.scm
new file mode 100644
index 0000000..e441dc3
--- /dev/null
+++ b/gschem/scheme/gschem/gschemdoc.scm
@@ -0,0 +1,224 @@
+;; gEDA - GPL Electronic Design Automation
+;; libgeda - gEDA's library - Scheme API
+;; Copyright (C) 2011 Peter Brett <peter@xxxxxxxxxxxxx>
+;;
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 2 of the License, or
+;; (at your option) any later version.
+;;
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+;;
+;; You should have received a copy of the GNU General Public License
+;; along with this program; if not, write to the Free Software
+;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA
+;;
+
+(define-module (gschem gschemdoc)
+  #:use-module (geda os)
+  #:use-module (geda object)
+  #:use-module (geda attrib)
+  #:use-module (gschem util)
+  #:use-module (ice-9 optargs)
+  #:use-module (ice-9 regex)
+  #:use-module (srfi srfi-1))
+
+;; FIXME this should probably be set via configure
+(define %configured-sys-doc-dir #f)
+
+(define-public (sys-doc-dir)
+  "sys-doc-dir
+
+Get the directory where gEDA documentation is stored."
+
+  ;; Given a gEDA data directory path, guess the installation prefix.
+  (define (guess-prefix dir)
+    (let ((ofs (string-contains
+                dir (string-append separator "share"))))
+      (and ofs (substring dir 0 ofs))))
+
+  ;; Guess the gEDA documentation directory, using the gEDA data
+  ;; search path.  Guaranteed to only return paths that correspond to
+  ;; actual directories.
+  (define (guess-docdir)
+    (any
+
+     (lambda (dir)
+       (let ((docdir
+              (string-join (list (guess-prefix dir)
+                                 "share" "doc" "geda-gaf")
+                           separator)))
+         (and (false-if-exception
+               (eq? 'directory (stat:type (stat docdir))))
+              docdir)))
+
+     (sys-data-dirs)))
+
+  (or (guess-docdir)
+      (if (platform? 'win32-native)
+          #f
+          %configured-sys-doc-dir)))
+
+;; Munge a wiki page name so that it can be used in a filename
+(define (wiki-munge name)
+  (string-map
+   (lambda (c)
+     (case c
+       ((#\? #\\ #\! #\*) #\_)
+       ((#\:) #\-)
+       (else c)))
+   name))
+
+(define*-public (show-wiki #:optional (page "index"))
+  "show-wiki PAGE
+
+Launch a browser to display a page from the offline version of the
+gEDA wiki shipped with gEDA/gaf.  The specified PAGE should be a
+string containing the page name as used on the live version of the
+wiki."
+
+  (show-uri
+   (string-append "file://"
+                  (string-join (list (sys-doc-dir) "wiki")
+                               separator 'suffix)
+                  (wiki-munge page)
+                  ".html")))
+
+(define %pdf-search-template "http://www.google.com/search?q=~S%20filetype:pdf";)
+
+;; Get the value of a named attribute.  Attached attributes are
+;; searched first, followed by inherited attributes.  The first
+;; non-empty result found is returned.
+(define (attribute-value-by-name obj name)
+  (define (any-proc attrib)
+    (and (equal? name (attrib-name attrib))
+         (let ((v (attrib-value attrib)))
+           (and (> (string-length v) 0) v))))
+  (or (any any-proc (object-attribs obj))
+      (any any-proc (inherited-attribs obj))))
+
+;; For each entry in DIRNAME, PROC is called.  If PROC returns a
+;; true value, the iteration stops and the result returned by PROC
+;; is returned to the caller.
+(define (directory-any dirname proc)
+  (call/cc
+   (lambda (return)
+     (let ((dir #f))
+       (dynamic-wind
+           (lambda () (set! dir (opendir dirname)))
+           (lambda ()
+             (do ((entry (readdir dir) (readdir dir)))
+                 ((eof-object? entry))
+               (case entry
+                 ((".." ".") #f)
+                 (else (let ((result (proc entry)))
+                         (if result (return result) #f))))))
+           (lambda () (closedir dir))))
+     #f)))
+
+;; Searches for and displays documentation in DIRNAME.  A
+;; documentation file is expected to start with BASENAME and
+;; (optionally) end with EXT.  Comparisons are carried out
+;; case-insensitively.  If no file was found, returns #f.
+(define* (directory-doc-search dirname basename #:optional (ext ""))
+  (define (test-dir-entry entry)
+    (let ((filename (string-append dirname separator entry)))
+      (and (string-prefix-ci? basename entry)
+           (string-suffix-ci? ext entry)
+           (file-exists? filename)
+           filename)))
+  (let ((filename (false-if-exception (directory-any dirname test-dir-entry))))
+    (and filename (begin (show-file filename) #t))))
+
+;; Searches for documentation STRING on the Internet, using
+;; %pdf-search-template.
+;;
+;; FIXME string should be URL-encoded.
+(define (internet-doc-search string)
+  (show-uri (format #f %pdf-search-template string)) #t)
+
+;; Munges a component basename to look more like a device name
+(define (munge-basename basename)
+  (let* ((rx (make-regexp "(-[0-9]+)?.sym$" regexp/icase))
+         (match (regexp-exec rx basename)))
+    (if match
+        (regexp-substitute #f match 'pre)
+        basename)))
+
+(define-public (show-component-documentation obj)
+  "show-component-documentation COMPONENT
+
+Find the documentation for COMPONENT, by inspecting (in order) its
+\"documentation\", \"device\" and \"value\" attributes, and its
+component basename, and searching in the current directory, the system
+gEDA documentation directory, and Google.  In most cases, results are
+restricted to \".pdf\" files.  The documentation is displayed in the
+system associated viewer application."
+
+
+  (let ((documentation (attribute-value-by-name obj "documentation"))
+        (device (attribute-value-by-name obj "device"))
+        (value (attribute-value-by-name obj "value"))
+        (basename (component-basename obj)))
+
+    ;; Try several different ways of finding documentation
+    (or
+
+     ;; 1) Checks based on "documentation=" attribute
+     (and
+      documentation
+
+      (or
+       ;; a) First check the obvious -- does the documentation
+       ;;    attribute match a file in the current directory?
+       (directory-doc-search (getcwd) documentation)
+       ;; b) What about in the documentation directory?
+       (directory-doc-search (sys-doc-dir) documentation)
+       ;; c) Does the documentation attribute look like a URL?
+       (and (any (lambda (prefix) (string-prefix? prefix documentation))
+                 '("http://"; "ftp://"; "file://"))
+            (show-uri documentation))
+
+       ;; d) If a documentation attribute was specified at all, search
+       ;;    for it with Google.
+       (internet-doc-search documentation)))
+
+     ;; 2) Checks based on "device=" and "value=" attributes
+     (and
+      device value
+      (or
+       ;; a) Look for a DEVICE-VALUE*.PDF file in the current directory
+       (directory-doc-search (getcwd) (string-append device "-" value) ".pdf")
+       ;; b) Look for a DEVICE-VALUE*.PDF file in the documentation directory
+       (directory-doc-search (sys-doc-dir) (string-append device "-" value) ".pdf")))
+     (and
+      device
+      (or
+       ;; c) Look for a DEVICE*.PDF file in the current directory
+       (directory-doc-search (getcwd) device ".pdf")
+       ;; d) Look for a DEVICE*.PDF file in the documentation directory
+       (directory-doc-search (sys-doc-dir) device ".pdf")
+       ;; d) If there's a device attribute, search for it with Google.
+       (internet-doc-search device)))
+     (and
+      value
+      ;; e) If there's a value attribute, search for it with Google.
+      (internet-pdf-search value))
+
+     ;; 3) Checks based on component basename
+     (and
+      basename (string-length basename) ; Check basename is non-empty
+
+      ;; Munge basename to look more like a device name
+      (let ((name (munge-basename basename)))
+        (or
+         ;; a) Look for BASENAME*.PDF file in current directory
+         (directory-doc-search (getcwd) name ".pdf")
+         ;; b) Look for BASENAME*.PDF file in documentation directory
+         (directory-doc-search (sys-doc-dir) name ".pdf"))))
+
+     ;; 4) Fail miserably
+     (error "No documentation found"))))
diff --git a/gschem/scripts/Makefile.am b/gschem/scripts/Makefile.am
index 8c2c7a1..a6e3533 100644
--- a/gschem/scripts/Makefile.am
+++ b/gschem/scripts/Makefile.am
@@ -1,16 +1,9 @@
 scmdatadir = $(GEDADATADIR)/scheme
 scmdata_DATA = image.scm print.scm
 
-bin_SCRIPTS = gschemdoc
-EXTRA_DIST = ChangeLog-1.0 makeallimages \
-             gschemdoc.sh makeimages print.scm image.scm
-
-gschemdoc: gschemdoc.sh
-	sed -e 's:[@]DOCDIR@:$(docdir):' < $(srcdir)/gschemdoc.sh > tmp_gschemdoc
-	chmod a+x tmp_gschemdoc
-	mv -f tmp_gschemdoc gschemdoc
+EXTRA_DIST = ChangeLog-1.0 makeallimages makeimages print.scm image.scm
 
 MOSTLYCLEANFILES =	*.log *~
 CLEANFILES = 		*.log *~
-DISTCLEANFILES = 	*.log core FILE *~ gschemdoc
-MAINTAINERCLEANFILES = 	*.log *~ Makefile.in ChangeLog gschemdoc
+DISTCLEANFILES = 	*.log core FILE *~
+MAINTAINERCLEANFILES = 	*.log *~ Makefile.in ChangeLog
diff --git a/gschem/scripts/gschemdoc.sh b/gschem/scripts/gschemdoc.sh
deleted file mode 100644
index c24cde8..0000000
--- a/gschem/scripts/gschemdoc.sh
+++ /dev/null
@@ -1,327 +0,0 @@
-#!/bin/sh
-# $Id$
-#
-# NOTE: built from gschemdoc.sh
-#
-# Present as relevant documentation as possible wrt a component
-# The strategy is built into separate cases so that may be re-arranged easily
-#
-# arguments are:
-#    1: "documentation" attribute, which can be a filename or an URL
-#    2: "device" attribute
-#    3: "value" attribute
-#    4: symbol basename
-#    5: symbol directory (currently not used)
-#
-# alternative action:
-# present gschem user's manual, or a specific wiki page
-#
-# options:
-#    "-m"              display user's manual instead
-#    "-w <path>"       display a wiki page
-#
-# deBUG:
-# echo "gschemdoc args are: <$0> <$1> <$2> <$3> <$4> <$5>"
-
-#
-# these may be changed to suit local preferences
-#
-CANDIDATE_BROWSER="xdg-open galeon mozilla phoenix netscape netscape-navigator opera firefox konqueror iexplore"
-CANDIDATE_PDFREADER="xdg-open xpdf acroread ggv gv"
-CANDIDATE_LOCATE="slocate locate"
-
-#
-# Information about the gEDA installation
-#
-DOCDIR="@DOCDIR@"
-
-# For OS X, since Linux has 'open' with different semantics
-if [ "`uname -s`" = "Darwin" ]; then
-	CANDIDATE_BROWSER="open $CANDIDATE_BROWSER"
-	CANDIDATE_PDFREADER="open $CANDIDATE_PDFREADER"
-fi
-
-#
-#  make symbol filename into something more akin to a device name
-#
-symbolbase=`echo "$4" | sed s/-[0-9]\\.sym//`
-
-#
-#  display file vith PDF viewer if file exists, it is a pdf file and we have a reader
-#
-view_file_if_pdf()
-{
-	# If we are on Cygwin, translate the path
-	# so native applications can find the file
-	if test "${cygpath}" != "no" ; then
-		file=`cygpath -w $1`
-	else
-		file=$1
-	fi
-
-	if test -f "$1" && (file "$1" | grep -q "PDF") ; then
-		if test "${pdfreader}" != "no"; then
-			echo "Found ${pdfreader}"
-			echo "Using PDF viewer and file: $file"
-			# NOTE: Acrobat Reader on Windows does not seem to support
-			#       -- on the command line
-			${pdfreader} "$file"
-			exit
-		else
-			echo "Did not find a PDF viewer application."
-			exit
-		fi
-	fi
-}
-
-#
-#  display file vith browser if available
-#
-view_file_browser()
-{
-	# If we are on Cygwin, translate the path
-	# so native applications can find the file
-	if test "${cygpath}" != "no" ; then
-		file=`cygpath -w $1`
-	else
-		file=$1
-	fi
-	
-	if test "${browser}" != "no" ; then
-		echo "Found ${browser}"
-		echo "Using browser and file: $file"
-		# NOTE: Mozilla and Netscape does not seem to support
-		#       -- on the command line
-		"${browser}" "file://$file"
-		exit
-	else
-		echo "Did not find a browser application."
-		exit
-	fi
-}
-
-#
-#  go look for things globally
-#
-go_look_for()
-{
-	if test "${browser}" != "no" ; then
-		echo "Go look for: $1"
-		"${browser}" "http://www.google.com/search?q=$1%20filetype:pdf";
-		exit
-	else
-		echo "Did not find a browser application."
-		exit
-	fi
-}
-
-#
-#  display a manual of some kind
-#
-lookup_manual()
-{
-	if test -f "${DOCDIR}/$1" ; then
-		view_file_browser "${DOCDIR}/$1"
-	fi
-	if test "${locate}" != "no"; then
-		b=`${locate} -- "/$1"`
-		if test `echo "$b" | wc -w` -ge 1; then
-			view_file_browser "`echo "$b" | head -n1`"
-		fi
-	fi
-	echo "Sorry, cannot show manual $1"
-	exit 1
-}
-
-#
-#  Display a wiki page
-#
-#  Tries a local page first; if it doesn't exist, falls back to wiki on gEDA 
-#  website.
-lookup_wiki()
-{
-    LOCALWIKIROOT="${DOCDIR}/wiki/"
-    LIVEWIKIROOT="http://geda.seul.org/wiki/";
-
-    # Munge wiki path to remove bad chars
-    LOCALNAME=$(echo "$1" | tr "?\!*:" "___-")
-    if test -z "$LOCALNAME"; then
-	LOCALNAME="index"
-    fi
-    LOCALPATH="$LOCALWIKIROOT$LOCALNAME.html"
-
-    LIVEURL="$LIVEWIKIROOT$1"
-
-    if test -f "$LOCALPATH" ; then
-	view_file_browser $LOCALPATH
-	exit
-    fi
-
-    if test "${browser}" != "no" ; then
-	
-#       # Commented out, since the online wiki and the user version
-#       # may not be the same.
-#  
-# 	echo "Found ${browser}"
-# 	echo "Using browser and URL: $LIVEURL"
-# 	# NOTE: Mozilla and Netscape does not seem to support
-# 	#       -- on the command line
-# 	${browser} "$LIVEURL"
-	echo "Did not find the page in the local path."
-	exit
-    else
-	echo "Did not find a browser application."
-	exit
-    fi
-}
-
-
-#
-#  establish what software we have
-#
-browser="no"
-for a in ${CANDIDATE_BROWSER}; do
-	b=`which $a 2>/dev/null` && browser=$b && break
-done
-
-pdfreader="no"
-for a in ${CANDIDATE_PDFREADER}; do
-	b=`which $a 2>/dev/null` && pdfreader=$b && break
-done
-
-locate="no"
-for a in ${CANDIDATE_LOCATE}; do
-	b=`which $a 2>/dev/null` && locate=$b && break
-done
-
-cygpath="no"
-b=`which cygpath 2>/dev/null` && cygpath=$b
-
-#
-#  documentation case first
-#  NOTE: this is too crude..
-#
-if test "$1" = "-m"; then
-	lookup_manual "gedadocs.html"
-fi
-
-#
-#  try to load a specific wiki path
-#
-if test "$1" = "-w"; then
-        lookup_wiki "$2"
-fi
-
-#
-#  i.
-#  if there is a file in the documentation directory, we
-#  will of course use that first and foremost
-#
-if test "$1" != "" && test -f "${DOCDIR}/$1" ; then
-	view_file_if_pdf "${DOCDIR}/$1"
-	view_file_browser "${DOCDIR}/$1"
-fi
-
-#
-#  ii.
-#  if doc is an URL, we'll invoke the brower with that URL
-#
-if test "${browser}" != "no"; then
-	for s in http ftp file; do
-		if echo "$1" | grep -q "^$s:"; then
-			echo "Found ${browser}"
-			echo "Using browser and URL: $1"
-			"${browser}" "$1"
-			exit
-		fi
-	done
-fi
-
-#
-#  iii.
-#  if documentation is a filename, we'll invoke locate to see if we can
-#  find it locally
-#
-if test "$1" != "" && test "${locate}" != "no"; then
-	b=`${locate} -- "/$1"`
-	if test `echo "$b" | wc -w` -ge 1; then
-		n="`echo "$b" | head -n1`"
-		view_file_if_pdf "$n"
-		view_file_browser "$n"
-	fi
-fi
-
-#
-#  iv.
-#  if there is a documentation at all, go look for it on the web
-#
-if test "$1" != ""; then
-	go_look_for "$1"
-fi
-
-#
-#  v.
-#  if there is a device and a value, add .pdf or .PDF and look for local files
-#
-if test "$2" != "" && test "$3" != ""; then
-	for s in .pdf .PDF; do
-		view_file_if_pdf "${DOCDIR}/$2-$3$s"
-	done
-fi
-
-#
-#  vi.
-#  if there is a device, add .pdf or .PDF and look for local files
-#
-if test "$2" != ""; then
-	for s in .pdf .PDF; do
-		view_file_if_pdf "${DOCDIR}/$2$s"
-	done
-fi
-
-#
-#  vii.
-#  if there is a device and a value, go look for both on the web
-#
-if test "$2" != "" && test "$3" != ""; then
-	go_look_for "$2%20$3"
-fi
-
-#
-#  viii.
-#  if there is a device only, go look for it on the web
-#
-if test "$2" != ""; then
-	go_look_for "$2"
-fi
-
-#
-#  ix.
-#  if there is a value only, go look for it on the web
-#
-if test "$3" != "" && test "${browser}" != "no" ; then
-	go_look_for "$3"
-fi
-
-#
-#  x.
-#  there is just a symbol filename - try to find a pdf locally
-#
-if test "${symbolbase}" != "" && test "${pdfreader}" != "no"; then
-	for s in .pdf .PDF; do
-		view_file_if_pdf "${DOCDIR}/${symbolbase}$s"
-	done
-fi
-
-#
-#  xi.
-#  there is a device, go look for it on the web
-#
-if test "${symbolbase}" != ""; then
-	go_look_for "${symbolbase}"
-fi
-
-#
-#  none of the above
-#
-echo "Sorry, cannot help you"
diff --git a/gschem/src/g_funcs.c b/gschem/src/g_funcs.c
index 1e3a0c4..8d8f44b 100644
--- a/gschem/src/g_funcs.c
+++ b/gschem/src/g_funcs.c
@@ -272,63 +272,3 @@ SCM g_funcs_use_rc_values(void)
   i_vars_set(g_current_window ());
   return SCM_BOOL_T;
 }
-
-/*! \brief Use gschemdoc to open a browser to a specific wiki page
- *
- * \param [in] wikiname the name of the wiki page
- *
- * \par Function Description
- * Invokes gschemdoc with its -w switch to open a browser to the wiki
- * page specified by wikiname.  If wikiname is empty or not a string, 
- * will browse to the main wiki page.
- */
-SCM g_funcs_browse_wiki(SCM wikiname)
-{
-  char *wikistr;
-  int pid;
-
-  /* Extract wiki name string from Scheme value structure.
-   * If not a string, use the empty string */
-  if (scm_is_string (wikiname)) {
-    wikistr = scm_to_utf8_string(wikiname);
-  } else {
-    wikistr = "";
-  }
-
-  #ifndef __MINGW32__
-
-  pid = fork();
-
-  if (pid < 0) {
-    /* Fork failed. Still in parent process, so can use the log
-     * window */
-    if (scm_is_string (wikiname))
-      free(wikistr);
-    s_log_message(_("Could not fork\n"));
-    return SCM_BOOL_F;
-  } else if (pid > 0) {
-    /* Parent process, we're finished here */
-    if (scm_is_string (wikiname))
-      free(wikistr);
-    return SCM_BOOL_T;
-  }
-  
-  /* begin daughter process stuff */
-  
-  /* assume gschemdoc is part of path */
-  char *gschemdoc = "gschemdoc";
-  char *wikiarg = "-w";
-  
-  execlp(gschemdoc, gschemdoc, wikiarg, wikistr, NULL);
-
-  /* if we return, then nothing happened */
-  fprintf(stderr, _("Could not invoke %s\n"), gschemdoc);
-  _exit(0);
-
-  /* end daughter process stuff */
-
-#else /* __MINGW32__ */
-  s_log_message(_("Documentation commands not supported under MinGW.\n"));
-  return SCM_BOOL_F;
-#endif /* __MINGW32__ */
-}
diff --git a/gschem/src/g_keys.c b/gschem/src/g_keys.c
index 45bd971..d48f701 100644
--- a/gschem/src/g_keys.c
+++ b/gschem/src/g_keys.c
@@ -223,7 +223,6 @@ DEFINE_G_KEYS(add_pin_hotkey)
 DEFINE_G_KEYS(hierarchy_down_schematic)
 DEFINE_G_KEYS(hierarchy_down_symbol)
 DEFINE_G_KEYS(hierarchy_up)
-DEFINE_G_KEYS(hierarchy_documentation)
 DEFINE_G_KEYS(attributes_attach)
 DEFINE_G_KEYS(attributes_detach)
 DEFINE_G_KEYS(attributes_show_name)
diff --git a/gschem/src/g_register.c b/gschem/src/g_register.c
index a053a0f..fb01771 100644
--- a/gschem/src/g_register.c
+++ b/gschem/src/g_register.c
@@ -146,7 +146,6 @@ static struct gsubr_t gschem_funcs[] = {
   { "gschem-msg",                1, 0, 0, g_funcs_msg },
   { "gschem-confirm",            1, 0, 0, g_funcs_confirm },
   { "gschem-filesel",            2, 0, 1, g_funcs_filesel },
-  { "gschem-browse-wiki",        0, 1, 0, g_funcs_browse_wiki },
 
   /* keymapping callbacks */
   { "file-new-window",           0, 0, 0, g_keys_file_new_window },
@@ -270,7 +269,6 @@ static struct gsubr_t gschem_funcs[] = {
   { "hierarchy-down-schematic",  0, 0, 0, g_keys_hierarchy_down_schematic },
   { "hierarchy-down-symbol",     0, 0, 0, g_keys_hierarchy_down_symbol },
   { "hierarchy-up",              0, 0, 0, g_keys_hierarchy_up },
-  { "hierarchy-documentation",   0, 0, 0, g_keys_hierarchy_documentation },
   { "attributes-attach",         0, 0, 0, g_keys_attributes_attach },
   { "attributes-detach",         0, 0, 0, g_keys_attributes_detach },
   { "attributes-show-name",      0, 0, 0, g_keys_attributes_show_name },
@@ -290,7 +288,6 @@ static struct gsubr_t gschem_funcs[] = {
   { "options-show-coord-window", 0, 0, 0, g_keys_options_show_coord_window },
   { "help-about",                0, 0, 0, g_keys_help_about },
   { "help-hotkeys",              0, 0, 0, g_keys_help_hotkeys },
-  { "help-component",            0, 0, 0, g_keys_hierarchy_documentation },
   { "misc-misc",                 0, 0, 0, g_keys_misc },
   { "misc-misc2",                0, 0, 0, g_keys_misc2 },
   { "misc-misc3",                0, 0, 0, g_keys_misc3 },
diff --git a/gschem/src/i_callbacks.c b/gschem/src/i_callbacks.c
index 6a1e216..f37e68e 100644
--- a/gschem/src/i_callbacks.c
+++ b/gschem/src/i_callbacks.c
@@ -41,53 +41,6 @@
  *  \par Function Description
  *
  */
-/* Egil Kvaleberg <egil@xxxxxxxxxxxx> on October 7, 2002 - 
- * Initiate the gschemdoc utility to provide the used with as much
- * documentation on the symbol (i.e. component) as we can manage.
- */
-static void initiate_gschemdoc(const char* documentation,const char *device,
-			       const char *value,
-			       const char* symfile, const char *sympath)
-{
-
-#ifndef __MINGW32__
-
-  int pid;
-
-  if (!documentation) documentation="";
-  if (!device) device="";
-  if (!value) value="";
-  if (!symfile) symfile="";
-  if (!sympath) sympath="";
-
-  s_log_message( _("Documentation for [%s,%s,%s,%s]\n"),
-		    documentation,device,value,symfile);
-
-
-  if ((pid = fork()) < 0) {
-    fprintf(stderr, _("Could not fork\n"));
-  } else if (pid == 0) {
-    /* daughter process */
-
-    /* assume gschemdoc is part of path */
-    char *gschemdoc = "gschemdoc";
-
-    execlp(gschemdoc, gschemdoc, documentation, device, value, symfile, sympath, NULL);
-
-    /* if we return, then nothing happened */
-    fprintf(stderr, _("Could not invoke %s\n"), gschemdoc);
-    _exit(0);
-  }
-#else
-  s_log_message(_("Documentation commands not supported under MinGW.\n"));
-#endif
-}
-
-/*! \todo Finish function documentation!!!
- *  \brief
- *  \par Function Description
- *
- */
 /* every i_callback functions have the same footprint */
 #define DEFINE_I_CALLBACK(name)				\
 	void i_callback_ ## name(gpointer data,		\
@@ -3005,59 +2958,6 @@ DEFINE_I_CALLBACK(hierarchy_up)
   }
 }
 
-/*! \todo Finish function documentation!!!
- *  \brief
- *  \par Function Description
- *
- *  \note
- *  Egil Kvaleberg <egil@xxxxxxxxxxxx> on October 7, 2002 - 
- *  Provide documentation for symbol (i.e. component)
- */
-DEFINE_I_CALLBACK(hierarchy_documentation)
-{
-  GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
-  char *attrib_doc = NULL;
-  char *attrib_device = NULL;
-  char *attrib_value = NULL;
-  OBJECT *object = NULL;
-  const gchar *sourcename = NULL;
-  const CLibSymbol *sym = NULL;
-
-  exit_if_null(w_current);
-
-  object = o_select_return_first_object(w_current);
-  if (object != NULL) {
-    /* only allow going into symbols */
-    if (object->type == OBJ_COMPLEX) {
-
-      /* look for "documentation" */
-      attrib_doc = o_attrib_search_object_attribs_by_name (object, "documentation", 0);
-      /* look for "device" */
-      attrib_device = o_attrib_search_object_attribs_by_name (object, "device", 0);
-      /* look for "value" */
-      attrib_value = o_attrib_search_object_attribs_by_name (object, "value", 0);
-
-      sym = s_clib_get_symbol_by_name (object->complex_basename);
-      if (sym != NULL) {
-        sourcename = s_clib_source_get_name (s_clib_symbol_get_source(sym));
-      }
-
-      initiate_gschemdoc(attrib_doc,
-                         attrib_device,
-                         attrib_value,
-                         object->complex_basename,
-                         sourcename);
-
-      g_free(attrib_doc);
-      g_free(attrib_device);
-      g_free(attrib_value);
-    }
-  } else {
-    generic_msg_dialog(_("This command retrieves the component documentation from the web, but there is no component selected"));
-
-  }
-}
-
 /*! \section attributes-menu Attributes Menu Callback Functions */
 /*! \todo Finish function documentation!!!
  *  \brief

commit ae070b080856b6eef1059ee50dede82cc4f0afe8
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>

    scheme-api: Add (geda os) module.
    
    Add the (geda os) module, which provides operating system information
    and services, including:
    
    - host operating system classification
    - gEDA standard paths
    - directory and search path separators

diff --git a/docs/scheme-api/geda-scheme.texi b/docs/scheme-api/geda-scheme.texi
index 70fc3d7..f383000 100644
--- a/docs/scheme-api/geda-scheme.texi
+++ b/docs/scheme-api/geda-scheme.texi
@@ -343,6 +343,7 @@ available to be used in all gEDA applications.
 * Core page functions::
 * Core object functions::
 * Core attribute functions::
+* System information::
 @end menu
 
 @node Core page functions
@@ -1503,6 +1504,78 @@ The promoted attributes are returned.  If @var{component} is not in
 fact a component @code{object}, does nothing and returns the empty list.
 @end defun
 
+@node System information
+@section System information
+
+To use the functions described in this section, you will need to load
+the @code{(geda os)} module.
+
+This section describes some functions and variables that are useful
+for Scheme code that needs to behave differently depending on which
+operating system gEDA is running on.
+
+@defvar separator-char
+The directory separator character that should be used on the host
+platform.
+@end defvar
+
+@defvar separator
+A string containing @code{separator-char}.
+@end defvar
+
+@defvar path-separator-char
+The character used for separating the elements in @samp{PATH}-like
+environment variables on the host platform.
+@end defvar
+
+@defvar path-separator
+A string containing @code{path-separator-char}.
+@end defvar
+
+@defun platform
+Returns a list of symbols describing the host platform.  The returned
+symbols may include:
+
+@itemize
+@item
+@samp{carbon}
+@item
+@samp{cygwin}
+@item
+@samp{linux}
+@item
+@samp{win32}
+@item
+@samp{win32-native}
+@end itemize
+@end defun
+
+@defun platform? type
+Returns @samp{#t} if the platform description list returned by
+@code{platform} contains the symbol @var{type}, and @samp{#f}
+otherwise.
+@end defun
+
+@defun sys-data-dirs
+Returns an ordered list of directories in which to access system-wide
+gEDA data.
+@end defun
+
+@defun sys-config-dirs
+Returns an ordered list of directories in which to access system-wide
+gEDA configuration information.
+@end defun
+
+@defun user-data-dir
+Returns an ordered list of directories in which to store user-specific
+gEDA data.
+@end defun
+
+@defun user-config-dir
+Returns the directory in which to store user-specific gEDA
+configuration information.
+@end defun
+
 @node gschem API Reference
 @chapter gschem API Reference
 
diff --git a/libgeda/include/libgedaguile_priv.h b/libgeda/include/libgedaguile_priv.h
index 49916ab..229119b 100644
--- a/libgeda/include/libgedaguile_priv.h
+++ b/libgeda/include/libgedaguile_priv.h
@@ -33,6 +33,7 @@ void edascm_init_object ();
 void edascm_init_complex ();
 void edascm_init_page ();
 void edascm_init_attrib ();
+void edascm_init_os ();
 void edascm_init_deprecated ();
 
 /* ---------------------------------------- */
diff --git a/libgeda/scheme/Makefile.am b/libgeda/scheme/Makefile.am
index e35bb47..6c221f4 100644
--- a/libgeda/scheme/Makefile.am
+++ b/libgeda/scheme/Makefile.am
@@ -1,7 +1,8 @@
 
 scmdatadir = $(GEDADATADIR)/scheme
 nobase_dist_scmdata_DATA = geda.scm color-map.scm \
-	geda/object.scm geda/page.scm geda/attrib.scm geda/deprecated.scm
+	geda/object.scm geda/page.scm geda/attrib.scm geda/deprecated.scm \
+	geda/os.scm
 
 # Unit test support.  The unit tests are run using the geda-batch
 # program, with config loading disabled (-q) so that user config
@@ -28,6 +29,7 @@ TESTS = unit-tests/t0001-geda-conf-lib.scm \
 	unit-tests/t0203-page-string-syntax.scm \
 	unit-tests/t0300-attribute.scm \
 	unit-tests/t0301-promotable-attributes.scm \
+	unit-tests/t0400-os.scm \
 	unit-tests/t1000-deprecated.scm
 
 XFAIL_TESTS = \
diff --git a/libgeda/scheme/geda/os.scm b/libgeda/scheme/geda/os.scm
new file mode 100644
index 0000000..8430e6e
--- /dev/null
+++ b/libgeda/scheme/geda/os.scm
@@ -0,0 +1,57 @@
+;; gEDA - GPL Electronic Design Automation
+;; libgeda - gEDA's library - Scheme API
+;; Copyright (C) 2011 Peter Brett <peter@xxxxxxxxxxxxx>
+;;
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 2 of the License, or
+;; (at your option) any later version.
+;;
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+;;
+;; You should have received a copy of the GNU General Public License
+;; along with this program; if not, write to the Free Software
+;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA
+;;
+
+(define-module (geda os)
+
+  ; Import C procedures and variables
+  #:use-module (geda core os)
+
+  #:use-module (srfi srfi-1))
+
+(define-public platform %platform)
+
+(define-public (platform? x)
+  (member x (platform)))
+
+(define-public separator-char
+  (if (platform? 'win32-native) #\\ #\/))
+
+(define-public separator (string separator-char))
+
+(define-public path-separator-char
+  (if (platform? 'win32-native) #\; #\:))
+
+(define-public path-separator (string path-separator-char))
+
+(define-public separator-char?
+  (if (platform? 'win32-native)
+      (let ((cls (char-set #\\ #\/)))
+        (lambda (x) (char-set-contains? cls x)))
+      (lambda (x) (eq? separator-char x))))
+
+(define-public (sys-data-dirs)
+  (list (getenv "GEDADATA")))
+
+(define-public (sys-config-dirs)
+  (list (getenv "GEDADATARC")))
+
+(define-public (user-data-dir)
+  (string-join (list (getenv "HOME") ".gEDA") separator))
+
+(define-public user-config-dir user-data-dir)
diff --git a/libgeda/scheme/unit-tests/t0400-os.scm b/libgeda/scheme/unit-tests/t0400-os.scm
new file mode 100644
index 0000000..aa58206
--- /dev/null
+++ b/libgeda/scheme/unit-tests/t0400-os.scm
@@ -0,0 +1,26 @@
+; Test Scheme procedures for accessing host operating system
+; information.
+
+(use-modules (unit-test)
+             (geda os)
+             (srfi srfi-1))
+
+(begin-test 'platform
+  (assert-true (every symbol? (platform))))
+
+(begin-test 'separators
+  (assert-true (char? separator-char))
+  (assert-true (string? separator))
+  (assert-equal 1 (string-length separator))
+
+  (assert-true (char? path-separator-char))
+  (assert-true (string? path-separator))
+  (assert-equal 1 (string-length path-separator))
+
+  (assert-true (separator-char? separator-char)))
+
+(begin-test 'directories
+  (assert-true (every string? (sys-data-dirs)))
+  (assert-true (every string? (sys-config-dirs)))
+  (assert-true (string? (user-data-dir)))
+  (assert-true (string? (user-config-dir))))
diff --git a/libgeda/src/Makefile.am b/libgeda/src/Makefile.am
index 07a80d3..c65c979 100644
--- a/libgeda/src/Makefile.am
+++ b/libgeda/src/Makefile.am
@@ -10,6 +10,7 @@ BUILT_SOURCES = \
 	scheme_complex.x \
 	scheme_page.x \
 	scheme_attrib.x \
+	scheme_os.x \
 	scheme_deprecated.x
 
 scheme_api_sources = \
@@ -18,6 +19,7 @@ scheme_api_sources = \
 	scheme_toplevel.c \
 	scheme_object.c \
 	scheme_complex.c \
+	scheme_os.c \
 	scheme_page.c \
 	scheme_attrib.c \
 	scheme_deprecated.c
diff --git a/libgeda/src/scheme_init.c b/libgeda/src/scheme_init.c
index 7dd2321..a9da63e 100644
--- a/libgeda/src/scheme_init.c
+++ b/libgeda/src/scheme_init.c
@@ -50,5 +50,6 @@ edascm_init ()
   edascm_init_complex ();
   edascm_init_page ();
   edascm_init_attrib ();
+  edascm_init_os ();
   edascm_init_deprecated ();
 }
diff --git a/libgeda/src/scheme_os.c b/libgeda/src/scheme_os.c
new file mode 100644
index 0000000..72e1b9a
--- /dev/null
+++ b/libgeda/src/scheme_os.c
@@ -0,0 +1,104 @@
+/* gEDA - GPL Electronic Design Automation
+ * libgeda - gEDA's library
+ * Copyright (C) 1998-2010 gEDA Contributors (see ChangeLog for details)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA
+ */
+
+/*!
+ * \file scheme_os.c
+ * \brief Scheme API functions for misc. OS-related stuff.
+ */
+
+#include <config.h>
+
+#include <libgeda_priv.h>
+#include <libgedaguile_priv.h>
+
+SCM_SYMBOL (carbon_sym , "carbon");
+SCM_SYMBOL (cygwin_sym , "cygwin");
+SCM_SYMBOL (linux_sym , "linux");
+SCM_SYMBOL (win32_sym , "win32");
+SCM_SYMBOL (win32_native_sym , "win32-native");
+
+/*! \brief Get host operating system information.
+ * \par Function Description
+ * Returns a list of symbols describing the operating system. The
+ * symbols may include:
+ *
+ * - win32 -- Windows
+ * - win32-native -- Windows, not via Cygwin
+ * - cygwin -- Cygwin
+ * - carbon -- Mac OS X Carbon
+ * - linux -- Linux
+ *
+ * \return a list of symbols.
+ */
+SCM_DEFINE (platform, "%platform", 0, 0, 0, (),
+            "Return a list of symbols describing the host platform.")
+{
+  SCM result = SCM_EOL;
+
+# if defined (OS_CARBON)
+  result = scm_cons (carbon_sym, result);
+# endif
+# if defined (OS_CYGWIN)
+  result = scm_cons (cygwin_sym, result);
+# endif
+# if defined (OS_LINUX)
+  result = scm_cons (linux_sym, result);
+# endif
+# if defined (OS_WIN32)
+  result = scm_cons (win32_sym, result);
+# endif
+# if defined (OS_WIN32_NATIVE)
+  result = scm_cons (win32_native_sym, result);
+# endif
+
+  return result;
+}
+
+/*!
+ * \brief Create the (geda core os) Scheme module.
+ * \par Function Description
+ * Defines procedures in the (geda core os) module. The module can
+ * be accessed using (use-modules (geda core os)).
+ */
+static void
+init_module_geda_core_os ()
+{
+  /* Register the functions and symbols */
+  #include "scheme_os.x"
+
+  /* Add them to the module's public definitions. */
+  scm_c_export (s_platform,
+                NULL);
+}
+
+/*!
+ * \brief Initialise the host platform support procedures.
+ * \par Function Description
+
+ * Registers some Scheme procedures that provide cross-platform
+ * support. Should only be called by scheme_api_init().
+ */
+void
+edascm_init_os ()
+{
+  /* Define the (geda core os) module */
+  scm_c_define_module ("geda core os",
+                       init_module_geda_core_os,
+                       NULL);
+}

commit ba0651db94d86a2407f16027213ce3068670cc36
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>

    build-sys: More extensive host tests.
    
    Adds explicit checks for Cygwin and OS X.

diff --git a/m4/geda-host.m4 b/m4/geda-host.m4
new file mode 100644
index 0000000..5e06541
--- /dev/null
+++ b/m4/geda-host.m4
@@ -0,0 +1,79 @@
+# geda-host.m4                                          -*-Autoconf-*-
+# serial 1
+
+dnl Checks for host platform and features
+dnl Copyright (C) 2011  Peter TB Brett <peter@xxxxxxxxxxxxx>
+dnl
+dnl This program is free software; you can redistribute it and/or modify
+dnl it under the terms of the GNU General Public License as published by
+dnl the Free Software Foundation; either version 2 of the License, or
+dnl (at your option) any later version.
+dnl
+dnl This program is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+dnl GNU General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program; if not, write to the Free Software
+dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+AC_DEFUN([AX_HOST],
+[
+  AC_PREREQ([2.60])dnl
+  AC_REQUIRE([AC_CANONICAL_HOST])dnl
+
+  # Need to distinguish between native Windows (via MinGW) and Unix
+  # compat. layer on Windows (Cygwin).
+  OS_WIN32_NATIVE=no
+  OS_CYGWIN=no
+  OS_LINUX=no
+  case "$host" in
+    *-*-linux*)
+      OS_LINUX=yes
+      AC_DEFINE([OS_LINUX], [1],
+                [Define to 1 if on Linux.])
+      ;;
+    *-*-mingw*)
+      OS_WIN32_NATIVE=yes
+      AC_DEFINE([OS_WIN32_NATIVE], [1],
+                [Define to 1 if on native Windows.])
+      ;;
+    *-*-cygwin*)
+      OS_CYGWIN=yes
+      AC_DEFINE([OS_CYGWIN], [1],
+                [Define to 1 if on Cygwin.])
+      ;;
+    *)
+      ;;
+  esac
+
+  AC_MSG_CHECKING([for Linux host])
+  AC_MSG_RESULT([$OS_LINUX])
+
+  AC_MSG_CHECKING([for Windows host])
+  OS_WIN32=no
+  if test "$OS_WIN32_NATIVE" = "yes" ||
+     test "$OS_CYGWIN" = "yes" ; then
+    OS_WIN32=yes
+    AC_DEFINE([OS_WIN32], [1],
+              [Define to 1 if on Windows.])
+  fi
+  AC_MSG_RESULT([$OS_WIN32])
+
+  AC_MSG_CHECKING([for Cygwin host])
+  AC_MSG_RESULT([$OS_CYGWIN])
+
+  # Carbon is the best way to check for OSX.  There are some non-OSX
+  # Darwin platforms out there!
+  AC_MSG_CHECKING([for Mac OS X Carbon host])
+  OS_CARBON=no
+  AC_TRY_CPP([
+  #include <Carbon/Carbon.h>
+  #include <CoreServices/CoreServices.h>
+  ],[
+    OS_CARBON=yes
+    AC_DEFINE([OS_CARBON], [1],
+              [Define to 1 if on Mac OS X Carbon.])])
+  AC_MSG_RESULT([$OS_CARBON])
+])
diff --git a/m4/geda-windows.m4 b/m4/geda-windows.m4
index 4658d3c..2e26d94 100644
--- a/m4/geda-windows.m4
+++ b/m4/geda-windows.m4
@@ -36,36 +36,18 @@ dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 AC_DEFUN([AX_WINDOWS_FLAGS],
 [
   AC_PREREQ([2.60])dnl
-  AC_REQUIRE([AC_CANONICAL_HOST])dnl
+  AC_REQUIRE([AX_HOST])dnl
 
-  AC_MSG_CHECKING([for Windows platform])
-  case "$host" in
-    *-*-mingw*|*-*-cygwin*)
-      windows_platform=yes
-      WINDOWS_LIBTOOL_FLAGS=-no-undefined
-      ;;
-    *)
-      windows_platform=no
-      ;;
-  esac
-  AC_MSG_RESULT([$windows_platform])
+  if test "$PLATFORM_WIN32" = "yes"; then
+    WINDOWS_LIBTOOL_FLAGS=-no-undefined
+  fi
 
-  AC_MSG_CHECKING([for native Windows])
-  case "$host" in
-    *-*-mingw*)
-      native_windows=yes
-      MINGW_GUI_LDFLAGS=-mwindows
-      MINGW_CFLAGS="-mms-bitfields"
-      ;;
-    *)
-      native_windows=no
-      ;;
-  esac
-  AC_MSG_RESULT([$native_windows])
+  if test "$PLATFORM_WIN32_NATIVE" = "yes"; then
+    MINGW_GUI_LDFLAGS=-mwindows
+    MINGW_CFLAGS="-mms-bitfields"
+  fi
 
   AC_SUBST(WINDOWS_LIBTOOL_FLAGS)
   AC_SUBST(MINGW_GUI_LDFLAGS)
   AC_SUBST(MINGW_CFLAGS)
-
-]
-)
+])

commit 30fa50eb42e33e4c8ff616eef7c4ba10eb65d228
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>

    scheme-api: Add show-uri and show-file functions to (gschem util).

diff --git a/docs/scheme-api/geda-scheme.texi b/docs/scheme-api/geda-scheme.texi
index 0ee90ae..70fc3d7 100644
--- a/docs/scheme-api/geda-scheme.texi
+++ b/docs/scheme-api/geda-scheme.texi
@@ -1839,6 +1839,24 @@ use the same attribute placement heuristics as gschem's built-in
 @xref{Text}, @ref{Attributes} and @ref{Windows and views}.
 @end defun
 
+@subsection Miscellaneous utility functions
+
+To use the functions described in this section, you will need to load
+the @code{(gschem util)} module.
+
+@defun show-uri uri
+Open @var{uri} in the registered default application associated for
+that type of file or protocol.  URI should be fully-qualified URI;
+which URIs can be handled by @code{show-uri} will depend on the system
+configuration.
+@end defun
+
+@defun show-file filename
+Displays a file in the registered default application for files of
+that type. @var{filename} should be the absolute path and filename of
+a local file.
+@end defun
+
 @node Concept Index
 @unnumbered Concept Index
 
diff --git a/gschem/include/prototype.h b/gschem/include/prototype.h
index 4332459..c0eebc7 100644
--- a/gschem/include/prototype.h
+++ b/gschem/include/prototype.h
@@ -269,6 +269,8 @@ SCM g_rc_display_outline_color_map (SCM scm_map);
 void g_register_funcs(void);
 /* g_select.c */
 void g_init_select ();
+/* g_util.c */
+void g_init_util ();
 /* g_window.c */
 GSCHEM_TOPLEVEL *g_current_window ();
 void g_dynwind_window (GSCHEM_TOPLEVEL *w_current);
diff --git a/gschem/po/POTFILES.in b/gschem/po/POTFILES.in
index c596672..f24e2e3 100644
--- a/gschem/po/POTFILES.in
+++ b/gschem/po/POTFILES.in
@@ -5,6 +5,7 @@ gschem/src/g_hook.c
 gschem/src/g_keys.c
 gschem/src/g_rc.c
 gschem/src/g_register.c
+gschem/src/g_util.c
 gschem/src/g_window.c
 gschem/src/globals.c
 gschem/src/gschem.c
diff --git a/gschem/scheme/Makefile.am b/gschem/scheme/Makefile.am
index 6c60a63..8d1d0c3 100644
--- a/gschem/scheme/Makefile.am
+++ b/gschem/scheme/Makefile.am
@@ -15,7 +15,8 @@ nobase_dist_scmdata_DATA = \
 	gschem/deprecated.scm \
 	gschem/hook.scm \
 	gschem/attrib.scm \
-	gschem/keymap.scm
+	gschem/keymap.scm \
+	gschem/util.scm
 
 MOSTLYCLEANFILES = *.log *~
 CLEANFILES = *.log *~
diff --git a/gschem/scheme/gschem/util.scm b/gschem/scheme/gschem/util.scm
new file mode 100644
index 0000000..72ab874
--- /dev/null
+++ b/gschem/scheme/gschem/util.scm
@@ -0,0 +1,27 @@
+;; gEDA - GPL Electronic Design Automation
+;; gschem - gEDA Schematic Capture - Scheme API
+;; Copyright (C) 2011 Peter Brett <peter@xxxxxxxxxxxxx>
+;;
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 2 of the License, or
+;; (at your option) any later version.
+;;
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+;;
+;; You should have received a copy of the GNU General Public License
+;; along with this program; if not, write to the Free Software
+;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA
+;;
+(define-module (gschem util)
+
+  ; Import C procedures
+  #:use-module (gschem core util))
+
+(define-public show-uri %show-uri)
+
+(define-public (show-file filename)
+  (show-uri (string-append "file://" filename)))
diff --git a/gschem/src/Makefile.am b/gschem/src/Makefile.am
index dcc4be3..12d22d6 100644
--- a/gschem/src/Makefile.am
+++ b/gschem/src/Makefile.am
@@ -4,6 +4,7 @@ BUILT_SOURCES = \
 	g_attrib.x \
 	g_hook.x \
 	g_keys.x \
+	g_util.x \
 	g_window.x \
 	g_select.x
 
@@ -17,6 +18,7 @@ gschem_SOURCES = \
 	g_rc.c \
 	g_register.c \
 	g_select.c \
+	g_util.c \
 	g_window.c \
 	globals.c \
 	gschem.c \
diff --git a/gschem/src/g_util.c b/gschem/src/g_util.c
new file mode 100644
index 0000000..f96ada3
--- /dev/null
+++ b/gschem/src/g_util.c
@@ -0,0 +1,90 @@
+/* gEDA - GPL Electronic Design Automation
+ * gschem - gEDA Schematic Capture
+ * Copyright (C) 2011 Peter Brett <peter@xxxxxxxxxxxxx>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA
+ */
+
+/*! \file g_util.c
+ * \brief Scheme utility functions
+ */
+
+#include <config.h>
+#include <missing.h>
+
+#include "gschem.h"
+
+/*! \brief Launch default application for a URI.
+ * \par Function Description
+ * Launches the default application associated with \a uri_s on the
+ * host platform.  Raises an error on failure.
+ *
+ * \note Scheme API: Implements the %show-uri procedure in the (gschem
+ * core util) module.
+ *
+ * \sa x_show_uri().
+ *
+ * \param uri_s  URI to launch viewer for.
+ * \return undefined value.
+ */
+SCM_DEFINE (show_uri, "%show-uri", 1, 0, 0, (SCM uri_s),
+            "Show a URI in the associated default application")
+{
+  /* Check that we were passed a string. */
+  SCM_ASSERT (scm_is_string (uri_s), uri_s, SCM_ARG1, s_show_uri);
+
+  GSCHEM_TOPLEVEL *w_current = g_current_window ();
+  const gchar *uri = scm_to_utf8_string (uri_s);
+  GError *err = NULL;
+
+  if (!x_show_uri (w_current, uri, &err)) {
+    scm_misc_error (s_show_uri, _("Could not launch URI ~S: ~A"),
+                    scm_list_2 (uri_s,
+                                scm_from_utf8_string (err->message)));
+  }
+  return SCM_UNDEFINED;
+}
+
+/*! \brief Create the (gschem core util) Scheme module.
+ * \par Function Description
+ * Defines procedures in the (gschem core util) module. The module can
+ * be accessed using (use-modules (gschem core util)).
+ */
+static void
+init_module_gschem_core_util ()
+{
+  /* Register the functions */
+  #include "g_util.x"
+
+  /* Add them to the module's public definitions. */
+  scm_c_export (s_show_uri,
+                NULL);
+}
+
+/*!
+ * \brief Initialise miscellaneous gschem utility procedures.
+ * \par Function Description
+ * Registers some Scheme utility procedures for e.g. accessing
+ * miscellaneous system services.  Should only be called by
+ * main_prog().
+ */
+void
+g_init_util ()
+{
+  /* Define the (gschem core util) module */
+  scm_c_define_module ("gschem core util",
+                       init_module_gschem_core_util,
+                       NULL);
+}
diff --git a/gschem/src/gschem.c b/gschem/src/gschem.c
index f2776a0..d33d35d 100644
--- a/gschem/src/gschem.c
+++ b/gschem/src/gschem.c
@@ -199,6 +199,7 @@ void main_prog(void *closure, int argc, char *argv[])
   g_init_hook ();
   g_init_attrib ();
   g_init_keys ();
+  g_init_util ();
 
   /* initialise color map (need to do this before reading rc files */
   x_color_init ();

commit c0d2ef0cd57cd566c457979b67a017503591d7aa
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>

    gschem: Add x_show_uri().
    
    This function launches a URI in the appropriate application for
    handling it, as determined by the platform's filetype association
    settings.
    
    GTK+ 2.16.0 and later provide a the gtk_show_uri() function, which
    attempts to use GIO to launch the default application for a URI.
    Unfortunately, it doesn't work properly on Windows with HTTP and FTP
    URLs, does evil things with FUSE when passed some URIs, and insists on
    GNOME applications even when you're not running GNOME.  Unfortunately,
    it is also currently considered the Right Way of doing things, and has
    the advantage of providing detailed error messages when things go
    wrong.
    
    With this patch, x_show_url() defaults to using gtk_show_url() on
    Linux, but not on other host platforms.  The --enable-gio and
    --disable-gio arguments to configure can be used to override this
    behaviour.
    
    If GIO is not enabled, the default behaviour differs depending on the
    platform:
    
    - On native Windows, the ShellExecute() API call is used by default.
    
    - On other platforms, a helper command is used.  If the URI_VIEWER
      variable was not set during configure, the command used is:
    
      * `cygstart' on Cygwin
      * `open' on Mac OS X
      * `xdg-open' otherwise.
    
    Using a helper command can be forced on Windows by setting URI_VIEWER.
    
    For example, to disable GIO and select an alternative URI launcher
    command:
    
      ./configure URI_VIEWER=my-open --disable-gio

diff --git a/configure.ac b/configure.ac
index 8d65cb9..595d832 100644
--- a/configure.ac
+++ b/configure.ac
@@ -138,6 +138,8 @@ AX_AWK_FEATURES
 
 # Assertions
 AX_OPTION_ASSERT
+# Viewing documentation
+AX_OPTION_URI_VIEWER
 # API documentation
 AX_OPTION_DOXYGEN
 # XDG desktop files
diff --git a/gschem/include/prototype.h b/gschem/include/prototype.h
index b55c4c8..4332459 100644
--- a/gschem/include/prototype.h
+++ b/gschem/include/prototype.h
@@ -806,6 +806,8 @@ void x_log_close ();
 void x_log_message (const gchar *log_domain,
                     GLogLevelFlags log_level,
                     const gchar *message);
+/* x_misc.c */
+gboolean x_show_uri (GSCHEM_TOPLEVEL *w_current, const gchar *buf, GError **err);
 /* x_menus.c */
 GtkWidget *get_main_menu(GSCHEM_TOPLEVEL *w_current);
 GtkWidget *get_main_popup(GSCHEM_TOPLEVEL *w_current);
diff --git a/gschem/po/POTFILES.in b/gschem/po/POTFILES.in
index bfe0b68..c596672 100644
--- a/gschem/po/POTFILES.in
+++ b/gschem/po/POTFILES.in
@@ -50,6 +50,7 @@ gschem/src/x_grid.c
 gschem/src/x_image.c
 gschem/src/x_log.c
 gschem/src/x_menus.c
+gschem/src/x_misc.c
 gschem/src/x_multiattrib.c
 gschem/src/x_pagesel.c
 gschem/src/x_preview.c
diff --git a/gschem/src/Makefile.am b/gschem/src/Makefile.am
index 44e7cd1..dcc4be3 100644
--- a/gschem/src/Makefile.am
+++ b/gschem/src/Makefile.am
@@ -70,6 +70,7 @@ gschem_SOURCES = \
 	x_image.c \
 	x_log.c \
 	x_menus.c \
+	x_misc.c \
 	x_multiattrib.c \
 	x_pagesel.c \
 	x_preview.c \
diff --git a/gschem/src/x_misc.c b/gschem/src/x_misc.c
new file mode 100644
index 0000000..52211d1
--- /dev/null
+++ b/gschem/src/x_misc.c
@@ -0,0 +1,162 @@
+/* gEDA - GPL Electronic Design Automation
+ * gschem - gEDA Schematic Capture
+ * Copyright (C) 2011 gEDA Contributors (see ChangeLog for details)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+#include <config.h>
+
+#ifdef OS_WIN32
+# define STRICT
+# include <windows.h>
+# undef STRICT
+#endif
+
+#include "gschem.h"
+
+#ifdef HAVE_LIBDMALLOC
+#include <dmalloc.h>
+#endif
+
+#ifdef HAVE_SYS_WAIT_H
+#include <sys/wait.h>
+#endif
+
+#if defined (OS_WIN32)
+
+/*! \brief Launch application to show URI on Windows.
+ * \par Function Description
+ * On native Windows, the ShellExecute Windows API function provides a
+ * reliable way to open a URI in a default application.
+ *
+ * This function is called by x_show_uri().
+ *
+ * \param uri    URI to launch viewer for.
+ * \param error  Location to return error information.
+ * \return TRUE on success, FALSE on failure.
+ */
+static gboolean
+show_uri__win32 (const gchar *uri, GError **error)
+{
+
+  /* On Windows, we need to use ShellExecute because allegedly GIO
+   * doesn't cope very well with Windows. :-( */
+
+  int status;
+  gchar *msg = NULL;
+
+  g_assert (uri);
+
+  status =
+    (int) ShellExecute (NULL, /* window handle */
+                        "open",
+                        uri,
+                        NULL, /* No parameters (not launching application) */
+                        NULL, /* Inherit working directory */
+                        SW_SHOWNORMAL); /* Default application display mode */
+  if (status > 32) {
+    return TRUE;
+  }
+
+  if (status == 0) {
+    msg = g_strdup (_("The operating system is out of memory or resources."));
+  } else {
+    LPVOID buf;
+    FormatMessage ((FORMAT_MESSAGE_ALLOCATE_BUFFER |
+                    FORMAT_MESSAGE_FROM_SYSTEM |
+                    FORMAT_MESSAGE_IGNORE_INSERTS),
+                   NULL,
+                   status,
+                   MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+                   (LPTSTR) &buf,
+                   0,
+                   NULL);
+    msg = g_strdup ((gchar *) buf);
+    LocalFree (buf);
+  }
+  /* \bug We should specify a domain and error code. */
+  g_set_error (error, 0, 0, "%s", msg);
+  g_free (msg);
+  return FALSE;
+}
+#endif /* OS_WIN32 */
+
+/*! \brief Launch default application for a URI.
+ * \par Function Description
+ * Launches the default application associated with \a uri on the host
+ * platform.
+ *
+ * Depending on the way gEDA was configured, this may occur by one of
+ * the following three methods:
+ *
+ * -# Calling gtk_show_uri() to use the GIO library (default on Linux)
+ * -# Calling the ShellExecute() Windows API call (default on Windows)
+ * -# Running an appropriate external tool.
+ *
+ * \param w_current  Current #GSCHEM_TOPLEVEL structure.
+ * \param uri        URI to launch viewer for.
+ * \param error      Location to return error information.
+ * \return TRUE on success, FALSE on failure.
+ */
+gboolean
+x_show_uri (GSCHEM_TOPLEVEL *w_current, const gchar *uri,
+            GError **error)
+{
+# if defined (SHOW_URI_GIO)
+  GdkScreen *screen;
+
+  g_assert (w_current);
+  g_assert (uri);
+
+  screen = gtk_window_get_screen (GTK_WINDOW (w_current->main_window));
+  return gtk_show_uri (screen, uri, GDK_CURRENT_TIME, error);
+
+# elif defined (OS_WIN32) && !defined (OS_CYGWIN)
+  return show_uri__win32 (uri, error);
+
+# else
+  gboolean spawn_status;
+  gint exit_status;
+  gchar *argv[3];
+
+  g_assert (uri);
+
+  argv[0] = SHOW_URI_COMMAND;
+  argv[1] = (gchar *) uri;
+  argv[2] = NULL; /* Null-terminated */
+
+  spawn_status = g_spawn_sync (NULL, /* Inherit working directory */
+                               argv,
+                               NULL, /* Inherit environment */
+                               G_SPAWN_SEARCH_PATH, /* Flags */
+                               NULL, /* No child setup function */
+                               NULL, /* No child setup function data */
+                               NULL, /* Don't need stdout */
+                               NULL, /* Don't need stderr */
+                               &exit_status,
+                               error);
+
+  if (!spawn_status) return FALSE;
+
+  if (exit_status != 0) {
+    g_set_error (error, G_SPAWN_ERROR, G_SPAWN_ERROR_FAILED,
+                 _("%s failed to launch URI"), argv[0]);
+    return FALSE;
+  }
+
+  return TRUE;
+
+# endif
+}
diff --git a/m4/geda-uri-viewer.m4 b/m4/geda-uri-viewer.m4
new file mode 100644
index 0000000..a0bfeb2
--- /dev/null
+++ b/m4/geda-uri-viewer.m4
@@ -0,0 +1,75 @@
+# geda-uri-viewer.m4                                    -*-Autoconf-*-
+# serial 1
+
+dnl Checks for default URI launcher method
+dnl Copyright (C) 2011  Peter TB Brett <peter@xxxxxxxxxxxxx>
+dnl
+dnl This program is free software; you can redistribute it and/or modify
+dnl it under the terms of the GNU General Public License as published by
+dnl the Free Software Foundation; either version 2 of the License, or
+dnl (at your option) any later version.
+dnl
+dnl This program is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+dnl GNU General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program; if not, write to the Free Software
+dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+AC_DEFUN([AX_OPTION_URI_VIEWER],
+[
+  AC_PREREQ([2.60])dnl
+  AC_REQUIRE([AX_HOST])dnl
+
+  AC_ARG_VAR([URI_VIEWER], [Path to URI launcher executable])
+
+  AC_MSG_CHECKING([whether to use GIO to launch URIs])
+  AC_ARG_ENABLE([gio],
+    [AS_HELP_STRING([--enable-gio],
+      [use GIO to launch URIs [default=auto]])],
+    [], [enable_gio=auto])
+
+  if test "X$enable_gio" = "Xauto" && test "X$OS_LINUX" = "Xyes"; then
+    enable_gio=yes
+  else
+    enable_gio=no
+  fi
+  if test "X$enable_gio" = "Xyes"; then
+    AC_DEFINE([SHOW_URI_GIO], [1],
+     [Define to 1 if GIO should be used to launch a default application for
+      a URI.])
+  fi
+  AC_MSG_RESULT([$enable_gio])
+
+
+  AC_MSG_CHECKING([platform URI viewer])
+
+  if test "X$enable_gio" = "Xyes" || test "X$OS_WIN32_NATIVE" = "Xyes"; then
+    # We use an API function, so we don't need a URI viewer application
+    AC_MSG_RESULT([none required])
+
+  else
+    # If the user specified a viewer command, just use that.
+    if test "X$URI_VIEWER" = "X"; then
+
+      # On Cygwin, we use cygstart, because it takes care of any required
+      # translation between cygwin filenames and native filenames.
+      if test "X$OS_CYGWIN" = "Xyes"; then
+        URI_VIEWER=cygstart
+
+      # On Mac OS X, we can use open(1) to launch URIs.
+      elif test "X$OS_CARBON" = "Xyes"; then
+        URI_VIEWER=open
+
+      # Default to xdg-open(1) on other platforms.
+      else
+        URI_VIEWER=xdg-open
+      fi
+    fi
+    AC_DEFINE_UNQUOTED([SHOW_URI_COMMAND], ["$URI_VIEWER"],
+                       [Command to launch default application for a URI.])
+    AC_MSG_RESULT([$URI_VIEWER])
+  fi
+])

commit 3c2f5abf382a78b2ad5e1af2b08c9b5bec9d21b7
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>

    build-sys: Require at least GTK+ 2.16.0.

diff --git a/NEWS b/NEWS
index c03e9af..560f9a0 100644
--- a/NEWS
+++ b/NEWS
@@ -10,6 +10,8 @@ more information, please consult the `ChangeLog' file.
 Notable changes in gEDA/gaf 1.7.2
 =================================
 
+* `geda-gaf' now requires GTK+ 2.16.0 or later.
+
 * A greatly expanded Scheme API has been added to gEDA/gaf for use by
   extension authors.  See the `geda-scheme' Info manual for more
   details.  Existing extensions may need to be modified to load the
diff --git a/README b/README
index 2af142d..f595b74 100644
--- a/README
+++ b/README
@@ -46,7 +46,7 @@ In order to compile gEDA from the distributed source archives, you
  - Guile ("GNU's Ubiquitous Intelligent Language for Extensions"),
    version 1.8.0 or later.  <http://www.gnu.org/software/guile/>
 
- - GTK+ (the Gimp Toolkit), version 2.10.0 or later.
+ - GTK+ (the Gimp Toolkit), version 2.16.0 or later.
    <http://www.gtk.org/>
 
  - The `lex' tool for generating lexical scanners.  The `flex'
diff --git a/configure.ac b/configure.ac
index c98281f..8d65cb9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -72,17 +72,17 @@ PKG_PROG_PKG_CONFIG
 
 AX_CHECK_GUILE([1.8.0])
 
-PKG_CHECK_MODULES(GLIB, [glib-2.0 >= 2.12.0], ,
-  AC_MSG_ERROR([GLib 2.12.0 or later is required.]))
+PKG_CHECK_MODULES(GLIB, [glib-2.0 >= 2.20.0], ,
+  AC_MSG_ERROR([GLib 2.20.0 or later is required.]))
 
-PKG_CHECK_MODULES(GTK, [gtk+-2.0 >= 2.10.0], ,
-  AC_MSG_ERROR([GTK+ 2.10.0 or later is required.]))
+PKG_CHECK_MODULES(GTK, [gtk+-2.0 >= 2.16.0], ,
+  AC_MSG_ERROR([GTK+ 2.16.0 or later is required.]))
 
-PKG_CHECK_MODULES(GDK_PIXBUF, [gdk-pixbuf-2.0 >= 0.15.0], ,
-  AC_MSG_ERROR([GDK_PIXBUF 0.15.0 or later is required.]))
+PKG_CHECK_MODULES(GDK_PIXBUF, [gdk-pixbuf-2.0 >= 2.16.0], ,
+  AC_MSG_ERROR([GDK_PIXBUF 2.16.0 or later is required.]))
 
-PKG_CHECK_MODULES(CAIRO, [cairo >= 1.2.0], ,
-  AC_MSG_ERROR([CAIRO 1.2.0 or later is required.]))
+PKG_CHECK_MODULES(CAIRO, [cairo >= 1.8.0], ,
+  AC_MSG_ERROR([CAIRO 1.8.0 or later is required.]))
 
 #####################################################################
 # Header files & particular functions

commit eb1e773f3f95f99fcd6ac6d0d0ebc947102e60ab
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>

    libgeda: Make sure paths are set up during initialisation.
    
    Until the s_path_*() functions are called, the GEDADATA and GEDADATARC
    environment variables may not be set.  Make sure the environment
    variables are set up during library startup.

diff --git a/libgeda/src/libgeda.c b/libgeda/src/libgeda.c
index bd08412..5bb3eb4 100644
--- a/libgeda/src/libgeda.c
+++ b/libgeda/src/libgeda.c
@@ -56,6 +56,9 @@ void libgeda_init(void)
   /* Initialise gobject */
   g_type_init ();
 
+  s_path_sys_data ();
+  s_path_sys_config ();
+
   s_clib_init();
   s_slib_init();
   s_menu_init();

commit c41a838b680ed158ddd8e2acb880de21caf0a352
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>

    scheme-api: Fix duplicate function name close_page_x.
    
    This was causing build failures on Cygwin.

diff --git a/gschem/src/g_window.c b/gschem/src/g_window.c
index ca1023d..2996ce6 100644
--- a/gschem/src/g_window.c
+++ b/gschem/src/g_window.c
@@ -197,12 +197,12 @@ SCM_DEFINE (set_active_page_x, "%set-active-page!", 1, 0, 0,
  * \param page_s Page to close.
  * \return SCM_UNDEFINED
  */
-SCM_DEFINE (close_page_x, "%close-page!", 1, 0, 0,
+SCM_DEFINE (override_close_page_x, "%close-page!", 1, 0, 0,
             (SCM page_s), "Close a page.")
 {
   /* Ensure that the argument is a page smob */
   SCM_ASSERT (edascm_is_page (page_s), page_s,
-              SCM_ARG1, s_close_page_x);
+              SCM_ARG1, s_override_close_page_x);
 
   GSCHEM_TOPLEVEL *w_current = g_current_window ();
   TOPLEVEL *toplevel = w_current->toplevel;
@@ -261,13 +261,14 @@ init_module_gschem_core_window ()
 
   /* Add them to the module's public definitions. */
   scm_c_export (s_current_window, s_active_page, s_set_active_page_x,
-                s_close_page_x, s_pointer_position, NULL);
+                s_override_close_page_x, s_pointer_position, NULL);
 
   /* Override procedures in the (geda core page) module */
   {
     SCM geda_page_module = scm_c_resolve_module ("geda core page");
-    SCM close_page_proc = scm_variable_ref (scm_c_lookup (s_close_page_x));
-    scm_c_module_define (geda_page_module, s_close_page_x, close_page_proc);
+    SCM close_page_proc =
+      scm_variable_ref (scm_c_lookup (s_override_close_page_x));
+    scm_c_module_define (geda_page_module, "close-page!", close_page_proc);
   }
 }
 

commit ec03489e1057f10a35a0877c52034dee99f50bc6
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>

    libgeda: Make f_normalize_pathname() behave correctly on Windows.
    
    On POSIX systems, f_normalize_pathname() emits a G_FILE_ERROR_NOENT
    error if the file is missing.  This patch makes it behave in the same
    way on Windows.
    
    This fixes some spurious "something went wrong in Scheme" error
    messages on Windows.
    
    Reported-by: DJ Delorie <dj@xxxxxxxxxxx>

diff --git a/libgeda/src/f_basic.c b/libgeda/src/f_basic.c
index 5438530..5ee61c2 100644
--- a/libgeda/src/f_basic.c
+++ b/libgeda/src/f_basic.c
@@ -538,15 +538,29 @@ gchar *f_normalize_filename (const gchar *name, GError **error)
    * back slashes.
    */
   DWORD len = GetFullPathName (name, MAX_PATH, buf, NULL);
+  gchar *result;
+
   if (len == 0 || len > MAX_PATH - 1) {
-    return g_strdup (name);
+    result = g_strdup (name);
   } else {
     /* The file system is case-preserving but case-insensitive,
      * canonicalize to lowercase, using the codepage associated
      * with the process locale.  */
     CharLowerBuff (buf, len);
-    return g_strdup (buf);
+    result = g_strdup (buf);
+  }
+
+  /* Test that the file actually exists, and fail if it doesn't.  We
+   * do this to be consistent with the behaviour on POSIX
+   * platforms. */
+  if (!g_file_test (result, G_FILE_TEST_EXISTS)) {
+    g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_NOENT,
+                 "%s", g_strerror (ENOENT));
+    g_free (result);
+    return NULL;
   }
+  return result;
+
 #else
 #define ROOT_MARKER_LEN 1
 




_______________________________________________
geda-cvs mailing list
geda-cvs@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-cvs