1/* Part of XPCE --- The SWI-Prolog GUI toolkit 2 3 Author: Jan Wielemaker and Anjo Anjewierden 4 E-mail: jan@swi-prolog.org 5 WWW: http://www.swi-prolog.nl/projects/xpce/ 6 Copyright (c) 2011-2025, University of Amsterdam 7 VU University Amsterdam 8 SWI-Prolog Solutions b.v. 9 All rights reserved. 10 11 Redistribution and use in source and binary forms, with or without 12 modification, are permitted provided that the following conditions 13 are met: 14 15 1. Redistributions of source code must retain the above copyright 16 notice, this list of conditions and the following disclaimer. 17 18 2. Redistributions in binary form must reproduce the above copyright 19 notice, this list of conditions and the following disclaimer in 20 the documentation and/or other materials provided with the 21 distribution. 22 23 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 28 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 29 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 30 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 31 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 33 ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 34 POSSIBILITY OF SUCH DAMAGE. 35*/ 36 37:- module(link_xpce, []). 38:- if(\+current_prolog_flag(xpce,false)). 39:- set_prolog_flag(generate_debug_info, true).
57:- multifile 58 user:file_search_path/2. 59:- dynamic 60 pce_setup_done/1. 61 62has_xpce_library :- 63 pce_setup_done(How), 64 How \== false. 65 66user:file_search_path(pce, swi(xpce)) :- 67 has_xpce_library. 68user:file_search_path(library, pce('prolog/lib')) :- 69 has_xpce_library. 70user:file_search_path(foreign, pce(ArchLib)) :- 71 has_xpce_library, 72 current_prolog_flag(arch, Arch), 73 atom_concat('lib/', Arch, ArchLib).
default.80gui_setup_ :- 81 current_prolog_flag(gui, true), 82 !. 83gui_setup_ :- 84 create_prolog_flag(gui, true, []), 85 editor_setup, 86 use_module(user:library(swi_hooks)). 87 88editor_setup :- 89 current_prolog_flag(editor, default), 90 !, 91 set_prolog_flag(editor, pce_emacs). 92editor_setup.
DISPLAY (X11) or WAYLAND_DISPLAY (Wayland). We also
assume we can run graphics if the SDL_VIDEO_DRIVER is set to
dummy, implying we try to run headless.103has_display :- current_prolog_flag(windows, true), !. 104has_display :- current_prolog_flag(apple, true), !. 105has_display :- getenv('WAYLAND_DISPLAY', D), D \== '', !. 106has_display :- getenv('DISPLAY', D), D \== '', !. 107has_display :- getenv('SDL_VIDEODRIVER', dummy). 108has_display :- current_prolog_flag('SDL_VIDEODRIVER', dummy).
xpce is false: do not setup xpce.xpce is true: load xpce and set it up.xpce is not present. Now
120pce_setup_ :- 121 pce_setup_done(_), 122 !. 123pce_setup_ :- 124 ( current_prolog_flag(xpce, true) 125 -> Preload = true, 126 How = true 127 ; has_display, % no explicit xpce flag 128 Preload = false, 129 How = lazy 130 ), 131 !, 132 set_prolog_flag(xpce, true), 133 asserta(pce_setup_done(How)), 134 reload_library_index, 135 gui_setup_, 136 ( Preload == true 137 -> ensure_loaded(user:library(pce)) 138 ; true 139 ). 140pce_setup_ :- % Implicit and no display 141 asserta(pce_setup_done(false)). 142 143:- initialization pce_setup_. 144:- endif. % \+ current_prolog_flag(xpce,false)
Associate XPCE with SWI-Prolog
This file initialises XPCE, the SWI-Prolog native GUI. XPCE is initialised if one of these conditions is true.
xpceistruexpceistrue. Otherwise it is setup to be loaded lazily if one of the GUI IDE tools is invoked.The source-location of this file is packages/xpce/swipl/swipl-rc. It is installed as <plbase>/<exe-base>.rc, where <exe-base> is
swipl-winto associate with the SWI-Prolog gui application on Windows andswiplon Unix/X11 platforms. */