1/* Part of XPCE --- The SWI-Prolog GUI toolkit 2 3 Author: Jan Wielemaker and Anjo Anjewierden 4 E-mail: J.Wielemaker@cs.vu.nl 5 WWW: http://www.swi-prolog.nl/projects/xpce/ 6 Copyright (c) 2011-2013, University of Amsterdam 7 VU University Amsterdam 8 All rights reserved. 9 10 Redistribution and use in source and binary forms, with or without 11 modification, are permitted provided that the following conditions 12 are met: 13 14 1. Redistributions of source code must retain the above copyright 15 notice, this list of conditions and the following disclaimer. 16 17 2. Redistributions in binary form must reproduce the above copyright 18 notice, this list of conditions and the following disclaimer in 19 the documentation and/or other materials provided with the 20 distribution. 21 22 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 25 FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 26 COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 27 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 28 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 30 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 32 ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 POSSIBILITY OF SUCH DAMAGE. 34*/ 35 36:- module(link_xpce, []). 37:- set_prolog_flag(generate_debug_info, true). 38 39/** <module> Associate XPCE with SWI-Prolog 40 41This file initialises XPCE, the SWI-Prolog native GUI. XPCE is 42initialised only if it is detected. 43 44The source-location of this file is packages/xpce/swipl/swipl-rc. It is 45installed as <plbase>/<exe-base>.rc, where <exe-base> is =|swipl-win|= 46to associate with the SWI-Prolog gui application on Windows and =swipl= 47on Unix/X11 platforms. 48*/ 49 50:- op(200, fy, user:(@)). 51:- op(250, yfx, user:(?)). 52:- op(990, xfx, user:(:=)). 53 54:- multifile 55 user:file_search_path/2. 56 57:- dynamic 58 pcehomestore_/1. 59:- volatile 60 pcehomestore_/1. 61 62pcehome_(Home) :- 63 pcehomestore_(Home), !. 64pcehome_(Home) :- 65 ( getenv('XPCEHOME', RawHome) 66 ; current_prolog_flag(home, PlHome), 67 ( current_prolog_flag(xpce_version, Version), 68 atom_concat('/xpce-', Version, Suffix) 69 ; Suffix = '/xpce' 70 ), 71 atom_concat(PlHome, Suffix, RawHome) 72 ), 73 exists_directory(RawHome), !, 74 absolute_file_name(RawHome, Home), 75 asserta(pcehomestore_(Home)). 76 77user:file_search_path(pce, PceHome) :- 78 pcehome_(PceHome). 79user:file_search_path(library, pce('prolog/lib')). 80user:file_search_path(foreign, pce(ArchLib)) :- 81 current_prolog_flag(arch, Arch), 82 atom_concat('lib/', Arch, ArchLib). 83 84% We added a directory to the autoload directories: force reloading the 85% index 86:- reload_library_index. 87 88gui_setup_ :- 89 current_prolog_flag(gui, true), !. 90gui_setup_ :- 91 ( getenv('DISPLAY', D), D \== '' 92 ; current_prolog_flag(windows, true) 93 ), !, 94 create_prolog_flag(gui, true, []), 95 menu_setup_, 96 editor_setup, 97 load_files(user:library(swi_hooks), [silent(true)]). % help, etc. 98 :- % plwin.exe menus 100 current_prolog_flag(console_menu, true), 101 load_files(user:library(win_menu), [silent(true)]). 102menu_setup_. 103 104editor_setup :- 105 current_prolog_flag(editor, default), !, 106 set_prolog_flag(editor, pce_emacs). 107editor_setup. 108 109pce_setup_ :- 110 current_prolog_flag(xpce, true), !. 111pce_setup_ :- 112 current_prolog_flag(argv, Argv), 113 \+ memberchk('--nopce', Argv), % explicitely no XPCE 114 pcehome_(PceHome), 115 exists_directory(PceHome), 116 gui_setup_, 117 ( memberchk('--pce', Argv) 118 ; current_prolog_flag(executable, Executable), 119 file_base_name(Executable, Base), 120 sub_atom_icasechk(Base, _, pce) 121 ), !, 122 load_files(user:library(pce), [silent(true)]). 123pce_setup_. 124 125:- initialization pce_setup_.