mirror of
https://gitlab.gnome.org/GNOME/gimp.git
synced 2025-07-03 17:33:25 +00:00
Replaced the netscape-dependent web browser plug-in with a user
2003-09-22 Henrik Brix Andersen <brix@gimp.org> Replaced the netscape-dependent web browser plug-in with a user configureable plug-in. This fixes bug #119120: * app/config/gimpguiconfig.[ch]: added gchar *web_browser member * app/config/gimprc-blurbs.h: added web browser blurb * etc/gimprc * docs/gimprc-1.3.5.in: regenerated using gimpconfig-dump * app/gui/preferences-dialog.c (prefs_dialog_new): added UI for specifying external web browser * configure.in * plug-ins/Makefile.am * plug-ins/webbrowser/Makefile.am * plug-ins/webbrowser/README * plug-ins/webbrowser/web-browser.scm * plug-ins/webbrowser/webbrowser.c : removed the old netscape-dependent web browser plug-in * po-plug-ins/POTFILES.in * plug-ins/common/plugin-defs.pl * plug-ins/common/webbrowser.c: added a new web browser plug-in * plug-ins/common/.cvsignore * plug-ins/common/Makefile.am: regenerated * app/widgets/gimphelp.c * app/widgets/widget-enums.[ch] * plug-ins/helpbrowser/dialog.c * plug-ins/maze/maze_face.c: changed accordingly + whitespace clean-up * po-script-fu/POTFILES.in * plug-ins/script-fu/scripts/Makefile.am * plug-ins/script-fu/scripts/web-browser.scm: use the new web browser plug-in to add menu entries to <Toolbox>/Help/
This commit is contained in:
parent
c9ef4b23f7
commit
9b3bc08eb6
28 changed files with 482 additions and 1405 deletions
41
ChangeLog
41
ChangeLog
|
@ -1,3 +1,44 @@
|
|||
2003-09-22 Henrik Brix Andersen <brix@gimp.org>
|
||||
|
||||
Replaced the netscape-dependent web browser plug-in with a user
|
||||
configureable plug-in. This fixes bug #119120:
|
||||
|
||||
* app/config/gimpguiconfig.[ch]: added gchar *web_browser member
|
||||
|
||||
* app/config/gimprc-blurbs.h: added web browser blurb
|
||||
|
||||
* etc/gimprc
|
||||
* docs/gimprc-1.3.5.in: regenerated using gimpconfig-dump
|
||||
|
||||
* app/gui/preferences-dialog.c (prefs_dialog_new): added UI for
|
||||
specifying external web browser
|
||||
|
||||
* configure.in
|
||||
* plug-ins/Makefile.am
|
||||
* plug-ins/webbrowser/Makefile.am
|
||||
* plug-ins/webbrowser/README
|
||||
* plug-ins/webbrowser/web-browser.scm
|
||||
* plug-ins/webbrowser/webbrowser.c : removed the old netscape-dependent
|
||||
web browser plug-in
|
||||
|
||||
* po-plug-ins/POTFILES.in
|
||||
* plug-ins/common/plugin-defs.pl
|
||||
* plug-ins/common/webbrowser.c: added a new web browser plug-in
|
||||
|
||||
* plug-ins/common/.cvsignore
|
||||
* plug-ins/common/Makefile.am: regenerated
|
||||
|
||||
* app/widgets/gimphelp.c
|
||||
* app/widgets/widget-enums.[ch]
|
||||
* plug-ins/helpbrowser/dialog.c
|
||||
* plug-ins/maze/maze_face.c: changed accordingly + whitespace
|
||||
clean-up
|
||||
|
||||
* po-script-fu/POTFILES.in
|
||||
* plug-ins/script-fu/scripts/Makefile.am
|
||||
* plug-ins/script-fu/scripts/web-browser.scm: use the new web
|
||||
browser plug-in to add menu entries to <Toolbox>/Help/
|
||||
|
||||
2003-09-22 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/gui/menus.c (menus_restore) (menus_save): removed gimprc
|
||||
|
|
|
@ -51,6 +51,12 @@ static void gimp_gui_config_get_property (GObject *object,
|
|||
|
||||
#define DEFAULT_THEME "Default"
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
#define DEFAULT_WEB_BROWSER "\"C:\Program Files\Internet Explorer\iexplore.exe\" \"%s\""
|
||||
#else
|
||||
#define DEFAULT_WEB_BROWSER "mozilla \"%s\""
|
||||
#endif
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
|
@ -73,7 +79,8 @@ enum
|
|||
PROP_THEME_PATH,
|
||||
PROP_THEME,
|
||||
PROP_USE_HELP,
|
||||
PROP_HELP_BROWSER
|
||||
PROP_HELP_BROWSER,
|
||||
PROP_WEB_BROWSER
|
||||
};
|
||||
|
||||
static GObjectClass *parent_class = NULL;
|
||||
|
@ -207,6 +214,11 @@ gimp_gui_config_class_init (GimpGuiConfigClass *klass)
|
|||
GIMP_TYPE_HELP_BROWSER_TYPE,
|
||||
GIMP_HELP_BROWSER_GIMP,
|
||||
0);
|
||||
GIMP_CONFIG_INSTALL_PROP_PATH (object_class, PROP_WEB_BROWSER,
|
||||
"web-browser", WEB_BROWSER_BLURB,
|
||||
GIMP_PARAM_PATH_FILE,
|
||||
DEFAULT_WEB_BROWSER,
|
||||
0);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -218,6 +230,7 @@ gimp_gui_config_finalize (GObject *object)
|
|||
|
||||
g_free (gui_config->theme_path);
|
||||
g_free (gui_config->theme);
|
||||
g_free (gui_config->web_browser);
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
}
|
||||
|
@ -296,6 +309,10 @@ gimp_gui_config_set_property (GObject *object,
|
|||
case PROP_HELP_BROWSER:
|
||||
gui_config->help_browser = g_value_get_enum (value);
|
||||
break;
|
||||
case PROP_WEB_BROWSER:
|
||||
g_free (gui_config->web_browser);
|
||||
gui_config->web_browser = g_value_dup_string (value);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
|
@ -375,6 +392,9 @@ gimp_gui_config_get_property (GObject *object,
|
|||
case PROP_HELP_BROWSER:
|
||||
g_value_set_enum (value, gui_config->help_browser);
|
||||
break;
|
||||
case PROP_WEB_BROWSER:
|
||||
g_value_set_string (value, gui_config->web_browser);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
|
|
|
@ -60,6 +60,7 @@ struct _GimpGuiConfig
|
|||
gchar *theme;
|
||||
gboolean use_help;
|
||||
GimpHelpBrowserType help_browser;
|
||||
gchar *web_browser;
|
||||
|
||||
gint last_tip; /* saved in sessionrc */
|
||||
};
|
||||
|
|
|
@ -358,5 +358,12 @@ N_("Sets an upper limit to the memory that is used per image to keep " \
|
|||
#define USE_HELP_BLURB \
|
||||
N_("When enabled, pressing F1 will open the help browser.")
|
||||
|
||||
#define WEB_BROWSER_BLURB \
|
||||
N_("Sets the external web browser to be used. This can be an absolute " \
|
||||
"path or the name of an executable to search for in the user's PATH. " \
|
||||
"If the command contains '%s' it will be replaced with the URL, else " \
|
||||
"the URL will be appended to the command with a space separating the " \
|
||||
"two.")
|
||||
|
||||
|
||||
#endif /* __GIMP_RC_BLURBS_H__ */
|
||||
|
|
|
@ -1855,6 +1855,19 @@ prefs_dialog_new (Gimp *gimp,
|
|||
_("Size of Thumbnail Files:"),
|
||||
GTK_TABLE (table), 1);
|
||||
|
||||
/* External Browser */
|
||||
vbox2 = prefs_frame_new (_("Web Browser"), GTK_CONTAINER (vbox), FALSE);
|
||||
table = prefs_table_new (1, GTK_CONTAINER (vbox2), FALSE);
|
||||
|
||||
fileselection = gimp_prop_file_entry_new (config, "web-browser",
|
||||
_("Select Web Browser"),
|
||||
FALSE, FALSE);
|
||||
|
||||
gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
|
||||
_("Web Browser to Use:"), 1.0, 0.5,
|
||||
fileselection, 1, TRUE);
|
||||
|
||||
/* Rescan Font List */
|
||||
vbox2 = prefs_frame_new (_("Fonts"), GTK_CONTAINER (vbox), FALSE);
|
||||
|
||||
hbox = gtk_hbox_new (FALSE, 2);
|
||||
|
|
|
@ -1855,6 +1855,19 @@ prefs_dialog_new (Gimp *gimp,
|
|||
_("Size of Thumbnail Files:"),
|
||||
GTK_TABLE (table), 1);
|
||||
|
||||
/* External Browser */
|
||||
vbox2 = prefs_frame_new (_("Web Browser"), GTK_CONTAINER (vbox), FALSE);
|
||||
table = prefs_table_new (1, GTK_CONTAINER (vbox2), FALSE);
|
||||
|
||||
fileselection = gimp_prop_file_entry_new (config, "web-browser",
|
||||
_("Select Web Browser"),
|
||||
FALSE, FALSE);
|
||||
|
||||
gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
|
||||
_("Web Browser to Use:"), 1.0, 0.5,
|
||||
fileselection, 1, TRUE);
|
||||
|
||||
/* Rescan Font List */
|
||||
vbox2 = prefs_frame_new (_("Fonts"), GTK_CONTAINER (vbox), FALSE);
|
||||
|
||||
hbox = gtk_hbox_new (FALSE, 2);
|
||||
|
|
|
@ -71,7 +71,7 @@ static gboolean gimp_help_internal (Gimp *gimp,
|
|||
const gchar *help_domain,
|
||||
const gchar *help_locale,
|
||||
const gchar *help_id);
|
||||
static void gimp_help_netscape (Gimp *gimp,
|
||||
static void gimp_help_webbrowser (Gimp *gimp,
|
||||
const gchar *help_domain,
|
||||
const gchar *help_locale,
|
||||
const gchar *help_id);
|
||||
|
@ -142,8 +142,8 @@ gimp_idle_help (gpointer data)
|
|||
idle_help->help_id))
|
||||
break;
|
||||
|
||||
case GIMP_HELP_BROWSER_NETSCAPE:
|
||||
gimp_help_netscape (idle_help->gimp,
|
||||
case GIMP_HELP_BROWSER_WEBBROWSER:
|
||||
gimp_help_webbrowser (idle_help->gimp,
|
||||
idle_help->help_domain,
|
||||
idle_help->help_locale,
|
||||
idle_help->help_id);
|
||||
|
@ -163,14 +163,14 @@ gimp_idle_help (gpointer data)
|
|||
|
||||
static void
|
||||
gimp_help_internal_not_found_callback (GtkWidget *widget,
|
||||
gboolean use_netscape,
|
||||
gboolean use_webbrowser,
|
||||
gpointer data)
|
||||
{
|
||||
Gimp *gimp = GIMP (data);
|
||||
|
||||
if (use_netscape)
|
||||
if (use_webbrowser)
|
||||
g_object_set (gimp->config,
|
||||
"help-browser", GIMP_HELP_BROWSER_NETSCAPE,
|
||||
"help-browser", GIMP_HELP_BROWSER_WEBBROWSER,
|
||||
NULL);
|
||||
|
||||
gtk_main_quit ();
|
||||
|
@ -211,7 +211,7 @@ gimp_help_internal (Gimp *gimp,
|
|||
_("Could not find the GIMP Help Browser procedure.\n"
|
||||
"It probably was not compiled because\n"
|
||||
"you don't have GtkXmHTML installed."),
|
||||
_("Use Netscape instead"),
|
||||
_("Use web browser instead"),
|
||||
GTK_STOCK_CANCEL,
|
||||
NULL, NULL,
|
||||
gimp_help_internal_not_found_callback,
|
||||
|
@ -222,7 +222,7 @@ gimp_help_internal (Gimp *gimp,
|
|||
busy = FALSE;
|
||||
|
||||
return (GIMP_GUI_CONFIG (gimp->config)->help_browser
|
||||
!= GIMP_HELP_BROWSER_NETSCAPE);
|
||||
!= GIMP_HELP_BROWSER_WEBBROWSER);
|
||||
}
|
||||
|
||||
n_domains = plug_ins_help_domains (gimp, &help_domains, &help_uris);
|
||||
|
@ -253,7 +253,7 @@ gimp_help_internal (Gimp *gimp,
|
|||
gimp_query_boolean_box (_("Could not start GIMP Help Browser"),
|
||||
NULL, NULL, FALSE,
|
||||
_("Could not start the GIMP Help Browser."),
|
||||
_("Use Netscape instead"),
|
||||
_("Use web browser instead"),
|
||||
GTK_STOCK_CANCEL,
|
||||
NULL, NULL,
|
||||
gimp_help_internal_not_found_callback,
|
||||
|
@ -264,7 +264,7 @@ gimp_help_internal (Gimp *gimp,
|
|||
busy = FALSE;
|
||||
|
||||
return (GIMP_GUI_CONFIG (gimp->config)->help_browser
|
||||
!= GIMP_HELP_BROWSER_NETSCAPE);
|
||||
!= GIMP_HELP_BROWSER_WEBBROWSER);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -289,7 +289,7 @@ gimp_help_internal (Gimp *gimp,
|
|||
}
|
||||
|
||||
static void
|
||||
gimp_help_netscape (Gimp *gimp,
|
||||
gimp_help_webbrowser (Gimp *gimp,
|
||||
const gchar *help_domain,
|
||||
const gchar *help_locale,
|
||||
const gchar *help_id)
|
||||
|
@ -322,9 +322,7 @@ gimp_help_netscape (Gimp *gimp,
|
|||
procedural_db_run_proc (gimp,
|
||||
"plug_in_web_browser",
|
||||
&nreturn_vals,
|
||||
GIMP_PDB_INT32, GIMP_RUN_NONINTERACTIVE,
|
||||
GIMP_PDB_STRING, url,
|
||||
GIMP_PDB_INT32, FALSE,
|
||||
GIMP_PDB_END);
|
||||
|
||||
procedural_db_destroy_args (return_vals, nreturn_vals);
|
||||
|
|
|
@ -31,7 +31,7 @@ gimp_aspect_type_get_type (void)
|
|||
static const GEnumValue gimp_help_browser_type_enum_values[] =
|
||||
{
|
||||
{ GIMP_HELP_BROWSER_GIMP, N_("Internal"), "gimp" },
|
||||
{ GIMP_HELP_BROWSER_NETSCAPE, N_("Netscape"), "netscape" },
|
||||
{ GIMP_HELP_BROWSER_WEBBROWSER, N_("Web Browser"), "webbrowser" },
|
||||
{ 0, NULL, NULL }
|
||||
};
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ GType gimp_help_browser_type_get_type (void) G_GNUC_CONST;
|
|||
typedef enum
|
||||
{
|
||||
GIMP_HELP_BROWSER_GIMP, /*< desc="Internal" >*/
|
||||
GIMP_HELP_BROWSER_NETSCAPE /*< desc="Netscape" >*/
|
||||
GIMP_HELP_BROWSER_WEBBROWSER /*< desc="Web Browser" >*/
|
||||
} GimpHelpBrowserType;
|
||||
|
||||
|
||||
|
|
11
configure.in
11
configure.in
|
@ -683,14 +683,14 @@ if test "$gdk_target" = x11; then
|
|||
GIMP_REMOTE='gimp-remote-1.3';
|
||||
have_libxmu=yes
|
||||
LIBXMU="$X_LIBS $X_PRE_LIBS -lX11 -lXmu -lXt",
|
||||
[AC_MSG_WARN(*** webbrowser plug-in and gimp-remote will not be built (XMU header file not found) ***)])],
|
||||
[AC_MSG_WARN(*** gimp-remote will not be built (XMU header file not found) ***)])],
|
||||
[AC_CHECK_LIB(Xmu, XmuUpdateMapHints,
|
||||
[AC_CHECK_HEADER(X11/Xmu/WinUtil.h,
|
||||
GIMP_REMOTE='gimp-remote-1.3';
|
||||
have_libxmu=yes
|
||||
LIBXMU="$X_LIBS $X_PRE_LIBS -lX11 -lXmu -lXt",
|
||||
[AC_MSG_WARN(*** webbrowser plug-in and gimp-remote will not be built (XMU header file not found) ***)])],
|
||||
AC_MSG_WARN(*** webbrowser plug-in and gimp-remote will not be built (XMU library not found) ***), -lXt)], -lXt)
|
||||
[AC_MSG_WARN(*** gimp-remote will not be built (XMU header file not found) ***)])],
|
||||
AC_MSG_WARN(*** gimp-remote will not be built (XMU library not found) ***), -lXt)], -lXt)
|
||||
CFLAGS="$gimp_save_CFLAGS"
|
||||
LDFLAGS="$gimp_save_LDFLAGS"
|
||||
fi
|
||||
|
@ -703,10 +703,6 @@ AC_SUBST(LIBXMU)
|
|||
AC_SUBST(LIBSCREENSHOT)
|
||||
AC_SUBST(GIMP_REMOTE)
|
||||
|
||||
## webbrowser has ifdefs for Win32
|
||||
AM_CONDITIONAL(BUILD_WEBBROWSER,
|
||||
test x"$have_libxmu" = xyes || test x"$os_win32" = xyes)
|
||||
|
||||
|
||||
###################
|
||||
# Check for libtiff
|
||||
|
@ -1322,7 +1318,6 @@ plug-ins/libgck/gck/Makefile
|
|||
plug-ins/dbbrowser/Makefile
|
||||
plug-ins/script-fu/Makefile
|
||||
plug-ins/script-fu/scripts/Makefile
|
||||
plug-ins/webbrowser/Makefile
|
||||
plug-ins/xjt/Makefile
|
||||
plug-ins/FractalExplorer/Makefile
|
||||
plug-ins/FractalExplorer/fractalexplorer-examples/Makefile
|
||||
|
|
|
@ -672,7 +672,15 @@ and no.
|
|||
(help-browser gimp)
|
||||
|
||||
Sets the browser used by the help system. Possible values are gimp and
|
||||
netscape.
|
||||
webbrowser.
|
||||
|
||||
.TP
|
||||
(web-browser "mozilla \"%s\"")
|
||||
|
||||
Sets the external web browser to be used. This can be an absolute path or the
|
||||
name of an executable to search for in the user's PATH. If the command
|
||||
contains '%s' it will be replaced with the URL, else the URL will be appended
|
||||
to the command with a space separating the two. This is a single filename.
|
||||
|
||||
.TP
|
||||
(fractalexplorer-path "${gimp_dir}/fractalexplorer:${gimp_data_dir}/fractalexplorer")
|
||||
|
|
|
@ -672,7 +672,15 @@ and no.
|
|||
(help-browser gimp)
|
||||
|
||||
Sets the browser used by the help system. Possible values are gimp and
|
||||
netscape.
|
||||
webbrowser.
|
||||
|
||||
.TP
|
||||
(web-browser "mozilla \"%s\"")
|
||||
|
||||
Sets the external web browser to be used. This can be an absolute path or the
|
||||
name of an executable to search for in the user's PATH. If the command
|
||||
contains '%s' it will be replaced with the URL, else the URL will be appended
|
||||
to the command with a space separating the two. This is a single filename.
|
||||
|
||||
.TP
|
||||
(fractalexplorer-path "${gimp_dir}/fractalexplorer:${gimp_data_dir}/fractalexplorer")
|
||||
|
|
10
etc/gimprc
10
etc/gimprc
|
@ -524,10 +524,18 @@
|
|||
# (use-help yes)
|
||||
|
||||
# Sets the browser used by the help system. Possible values are gimp and
|
||||
# netscape.
|
||||
# webbrowser.
|
||||
#
|
||||
# (help-browser gimp)
|
||||
|
||||
# Sets the external web browser to be used. This can be an absolute path or
|
||||
# the name of an executable to search for in the user's PATH. If the command
|
||||
# contains '%s' it will be replaced with the URL, else the URL will be
|
||||
# appended to the command with a space separating the two. This is a single
|
||||
# filename.
|
||||
#
|
||||
# (web-browser "mozilla \"%s\"")
|
||||
|
||||
# Where to search for fractals used by the Fractal Explorer plug-in. This is
|
||||
# a colon-separated list of folders to search.
|
||||
#
|
||||
|
|
|
@ -15,10 +15,6 @@ if BUILD_HELPBROWSER
|
|||
helpbrowser = helpbrowser
|
||||
endif
|
||||
|
||||
if BUILD_WEBBROWSER
|
||||
webbrowser = webbrowser
|
||||
endif
|
||||
|
||||
if BUILD_XJT
|
||||
xjt = xjt
|
||||
endif
|
||||
|
@ -57,7 +53,6 @@ SUBDIRS = \
|
|||
rcm \
|
||||
sgi \
|
||||
sel2path \
|
||||
$(webbrowser) \
|
||||
$(win32dirs) \
|
||||
$(xjt) \
|
||||
common
|
||||
|
|
|
@ -127,6 +127,7 @@ vinvert
|
|||
vpropagate
|
||||
warp
|
||||
waves
|
||||
webbrowser
|
||||
whirlpinch
|
||||
winclipboard
|
||||
wind
|
||||
|
|
|
@ -146,6 +146,7 @@ libexec_PROGRAMS = \
|
|||
vpropagate \
|
||||
warp \
|
||||
waves \
|
||||
webbrowser \
|
||||
whirlpinch \
|
||||
$(WINCLIPBOARD) \
|
||||
wind \
|
||||
|
@ -1660,6 +1661,16 @@ waves_LDADD = \
|
|||
@GTK_LIBS@ \
|
||||
@INTLLIBS@
|
||||
|
||||
webbrowser_SOURCES = \
|
||||
webbrowser.c
|
||||
|
||||
webbrowser_LDADD = \
|
||||
$(top_builddir)/libgimp/libgimp-$(LT_RELEASE).la \
|
||||
$(top_builddir)/libgimpcolor/libgimpcolor-$(LT_RELEASE).la \
|
||||
$(top_builddir)/libgimpbase/libgimpbase-$(LT_RELEASE).la \
|
||||
@GLIB_LIBS@ \
|
||||
@INTLLIBS@
|
||||
|
||||
whirlpinch_SOURCES = \
|
||||
whirlpinch.c
|
||||
|
||||
|
|
|
@ -124,6 +124,7 @@
|
|||
'vpropagate' => { libdep => 'gtk', ui => 1 },
|
||||
'warp' => { libdep => 'gtk', ui => 1 },
|
||||
'waves' => { libdep => 'gtk', ui => 1 },
|
||||
'webbrowser' => { libdep => 'glib' },
|
||||
'whirlpinch' => { libdep => 'gtk', ui => 1 },
|
||||
'winclipboard' => { libdep => 'glib', ui => 1, optional => 1 },
|
||||
'wind' => { libdep => 'gtk', ui => 1 },
|
||||
|
|
186
plug-ins/common/webbrowser.c
Normal file
186
plug-ins/common/webbrowser.c
Normal file
|
@ -0,0 +1,186 @@
|
|||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* Web Browser Plug-in
|
||||
* Copyright (C) 2003 Henrik Brix Andersen <brix@gimp.org>
|
||||
*
|
||||
* 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-1307, USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <string.h> /* strlen, strstr */
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include <libgimp/gimp.h>
|
||||
|
||||
#include "libgimp/stdplugins-intl.h"
|
||||
|
||||
|
||||
#define PLUG_IN_NAME "plug_in_web_browser"
|
||||
|
||||
|
||||
static void query (void);
|
||||
static void run (const gchar *name,
|
||||
gint nparams,
|
||||
const GimpParam *param,
|
||||
gint *nreturn_vals,
|
||||
GimpParam **return_vals);
|
||||
static gboolean browser_open_url (const gchar *url);
|
||||
static gchar* strreplace (const gchar *string,
|
||||
const gchar *delimiter,
|
||||
const gchar *replacement);
|
||||
|
||||
|
||||
GimpPlugInInfo PLUG_IN_INFO =
|
||||
{
|
||||
NULL, /* init_proc */
|
||||
NULL, /* quit_proc */
|
||||
query, /* query_proc */
|
||||
run /* run_proc */
|
||||
};
|
||||
|
||||
|
||||
MAIN ()
|
||||
|
||||
static void
|
||||
query (void)
|
||||
{
|
||||
static GimpParamDef args[] =
|
||||
{
|
||||
{ GIMP_PDB_STRING, "url", "URL to open" }
|
||||
};
|
||||
|
||||
gimp_install_procedure (PLUG_IN_NAME,
|
||||
"Open an URL in the user specified web browser",
|
||||
"Opens the given URL in the user specified web browser.",
|
||||
"Henrik Brix Andersen <brix@gimp.org>",
|
||||
"2003",
|
||||
"2003/09/16",
|
||||
NULL, NULL,
|
||||
GIMP_PLUGIN,
|
||||
G_N_ELEMENTS (args), 0,
|
||||
args, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
run (const gchar *name,
|
||||
gint nparams,
|
||||
const GimpParam *param,
|
||||
gint *nreturn_vals,
|
||||
GimpParam **return_vals)
|
||||
{
|
||||
static GimpParam values[1];
|
||||
GimpRunMode run_mode;
|
||||
GimpPDBStatusType status;
|
||||
|
||||
run_mode = param[0].data.d_int32;
|
||||
status = GIMP_PDB_SUCCESS;
|
||||
|
||||
INIT_I18N ();
|
||||
|
||||
if (nparams == 1 &&
|
||||
param[0].data.d_string != NULL &&
|
||||
strlen (param[0].data.d_string))
|
||||
{
|
||||
if (! browser_open_url (param[0].data.d_string))
|
||||
status = GIMP_PDB_EXECUTION_ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
status = GIMP_PDB_CALLING_ERROR;
|
||||
}
|
||||
|
||||
*nreturn_vals = 1;
|
||||
*return_vals = values;
|
||||
|
||||
values[0].type = GIMP_PDB_STATUS;
|
||||
values[0].data.d_status = status;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
browser_open_url (const gchar *url)
|
||||
{
|
||||
GError *error = NULL;
|
||||
gchar *browser;
|
||||
gchar *cmd;
|
||||
gchar **argv;
|
||||
gboolean retval;
|
||||
|
||||
g_return_val_if_fail (url != NULL, FALSE);
|
||||
|
||||
browser = gimp_gimprc_query ("web-browser");
|
||||
|
||||
if (browser == NULL || ! strlen (browser))
|
||||
{
|
||||
g_message (_("Web browser not specified.\n"
|
||||
"Please specify a web browser using the Preferences Dialog."));
|
||||
g_free (browser);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* replace %s with URL */
|
||||
if (strstr (browser, "%s"))
|
||||
cmd = strreplace (browser, "%s", url);
|
||||
else
|
||||
cmd = g_strconcat (browser, " ", url, NULL);
|
||||
|
||||
/* parse the cmd line */
|
||||
if (! g_shell_parse_argv (cmd, NULL, &argv, &error))
|
||||
{
|
||||
g_message (_("Could not parse specified web browser command:\n%s"),
|
||||
error->message);
|
||||
g_error_free (error);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
retval = g_spawn_async (NULL, argv, NULL,
|
||||
G_SPAWN_SEARCH_PATH,
|
||||
NULL, NULL,
|
||||
NULL, &error);
|
||||
|
||||
if (! retval)
|
||||
{
|
||||
g_message (_("Could not execute specified web browser:\n%s"),
|
||||
error->message);
|
||||
g_error_free (error);
|
||||
}
|
||||
|
||||
g_free (browser);
|
||||
g_free (cmd);
|
||||
g_strfreev (argv);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
static gchar*
|
||||
strreplace (const gchar *string,
|
||||
const gchar *delimiter,
|
||||
const gchar *replacement)
|
||||
{
|
||||
gchar *ret;
|
||||
gchar **tmp;
|
||||
|
||||
g_return_val_if_fail (string != NULL, NULL);
|
||||
g_return_val_if_fail (delimiter != NULL, NULL);
|
||||
g_return_val_if_fail (replacement != NULL, NULL);
|
||||
|
||||
tmp = g_strsplit (string, delimiter, 0);
|
||||
ret = g_strjoinv (replacement, tmp);
|
||||
g_strfreev (tmp);
|
||||
|
||||
return ret;
|
||||
}
|
|
@ -619,12 +619,10 @@ load_remote_page (const gchar *ref)
|
|||
GimpParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
|
||||
/* try to call netscape through the web_browser interface */
|
||||
/* try to call the user specified web browser */
|
||||
return_vals = gimp_run_procedure ("plug_in_web_browser",
|
||||
&nreturn_vals,
|
||||
GIMP_PDB_INT32, GIMP_RUN_NONINTERACTIVE,
|
||||
GIMP_PDB_STRING, ref,
|
||||
GIMP_PDB_INT32, FALSE,
|
||||
GIMP_PDB_END);
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
}
|
||||
|
|
|
@ -605,9 +605,7 @@ maze_help (GtkWidget *widget,
|
|||
maze_msg (message);
|
||||
g_free (message);
|
||||
gimp_run_procedure ("plug_in_web_browser", &baz,
|
||||
GIMP_PDB_INT32, GIMP_RUN_NONINTERACTIVE,
|
||||
GIMP_PDB_STRING, MAZE_URL,
|
||||
GIMP_PDB_INT32, HELP_OPENS_NEW_WINDOW,
|
||||
GIMP_PDB_END);
|
||||
}
|
||||
else
|
||||
|
|
|
@ -100,6 +100,7 @@ scriptdata_DATA = \
|
|||
unsharp-mask.scm \
|
||||
waves-anim.scm \
|
||||
weave.scm \
|
||||
web-browser.scm \
|
||||
xach-effect.scm \
|
||||
\
|
||||
test-sphere.scm
|
||||
|
|
53
plug-ins/script-fu/scripts/web-browser.scm
Normal file
53
plug-ins/script-fu/scripts/web-browser.scm
Normal file
|
@ -0,0 +1,53 @@
|
|||
; The GIMP -- an image manipulation program
|
||||
; Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
;
|
||||
; gimp-online.scm
|
||||
; Copyright (C) 2003 Henrik Brix Andersen <brix@gimp.org>
|
||||
;
|
||||
; 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-1307, USA.
|
||||
|
||||
|
||||
(define (gimp-online-main-web-site)
|
||||
(plug-in-web-browser "http://www.gimp.org"))
|
||||
|
||||
(define (gimp-online-developer-web-site)
|
||||
(plug-in-web-browser "http://developer.gimp.org"))
|
||||
|
||||
(define (gimp-online-plug-in-web-site)
|
||||
(plug-in-web-browser "http://registry.gimp.org"))
|
||||
|
||||
(script-fu-register "gimp-online-main-web-site"
|
||||
_"<Toolbox>/Help/The GIMP Online/_Main Web Site"
|
||||
"Link to http://www.gimp.org"
|
||||
"Henrik Brix Andersen <brix@gimp.org>"
|
||||
"Henrik Brix Andersen <brix@gimp.org>"
|
||||
"2003"
|
||||
"")
|
||||
|
||||
(script-fu-register "gimp-online-developer-web-site"
|
||||
_"<Toolbox>/Help/The GIMP Online/_Developer Web Site"
|
||||
"Link to http://www.gimp.org"
|
||||
"Henrik Brix Andersen <brix@gimp.org>"
|
||||
"Henrik Brix Andersen <brix@gimp.org>"
|
||||
"2003"
|
||||
"")
|
||||
|
||||
(script-fu-register "gimp-online-plug-in-web-site"
|
||||
_"<Toolbox>/Help/The GIMP Online/Plug-in _Registry"
|
||||
"Link to http://www.gimp.org"
|
||||
"Henrik Brix Andersen <brix@gimp.org>"
|
||||
"Henrik Brix Andersen <brix@gimp.org>"
|
||||
"2003"
|
||||
"")
|
|
@ -1,34 +0,0 @@
|
|||
## Process this file with automake to produce Makefile.in
|
||||
|
||||
if OS_WIN32
|
||||
mwindows = -mwindows
|
||||
endif
|
||||
|
||||
AM_LDFLAGS = $(mwindows)
|
||||
|
||||
scriptdatadir = $(gimpdatadir)/scripts
|
||||
|
||||
scriptdata_DATA = web-browser.scm
|
||||
|
||||
libexecdir = $(gimpplugindir)/plug-ins
|
||||
|
||||
libexec_PROGRAMS = webbrowser
|
||||
|
||||
webbrowser_SOURCES = webbrowser.c
|
||||
|
||||
EXTRA_DIST = $(scriptdata_DATA)
|
||||
|
||||
INCLUDES = \
|
||||
-I$(top_srcdir) \
|
||||
$(GTK_CFLAGS) \
|
||||
-I$(includedir)
|
||||
|
||||
LDADD = \
|
||||
$(top_builddir)/libgimp/libgimpui-$(LT_RELEASE).la \
|
||||
$(top_builddir)/libgimpwidgets/libgimpwidgets-$(LT_RELEASE).la \
|
||||
$(top_builddir)/libgimp/libgimp-$(LT_RELEASE).la \
|
||||
$(top_builddir)/libgimpcolor/libgimpcolor-$(LT_RELEASE).la \
|
||||
$(top_builddir)/libgimpbase/libgimpbase-$(LT_RELEASE).la \
|
||||
$(GTK_LIBS) \
|
||||
$(LIBXMU) \
|
||||
$(INTLLIBS)
|
|
@ -1,129 +0,0 @@
|
|||
Web Browser GIMP Extension v0.3
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
by Misha Dynin <misha@xcf.berkeley.edu>
|
||||
|
||||
Introduction
|
||||
~~~~~~~~~~~~
|
||||
|
||||
Web Browser GIMP extension is not an HTML browser (at least, not yet ;-);
|
||||
it's just an interface to an external web browser that allows GIMP, using
|
||||
a PDB call, to instruct a browser to open a URL.
|
||||
|
||||
Currently, it works with Netscape, version 1.1 or above, using a protocol
|
||||
described in detail on http://home.netscape.com/newsref/std/x-remote.html.
|
||||
If Netscape is not running already, the extension starts it, with a URL
|
||||
as a command-line argument.
|
||||
|
||||
Possible uses of this extension:
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
* Providing a set of bookmarks, accessible from the GIMP.
|
||||
|
||||
This is implemented -- web-browser.scm, included in a distribution,
|
||||
builds a menu of frequently accessed GIMP websites. It's cool.
|
||||
|
||||
* Implementing GIMP online help.
|
||||
|
||||
This is the most promising use of the extension. GIMP plugins and
|
||||
main application can provide "Help" and "About" buttons, which,
|
||||
when pressed, cause a corresponding page to be opened in Netscape.
|
||||
|
||||
This is doable now; the only problem is to design a standard way
|
||||
to do that. It would be great to be able to access the documentation
|
||||
either from the web site or, if installed, from local disk.
|
||||
(add gimp-path to .gimprc; use as prefix in gimp-help() function?)
|
||||
I request input of experienced GIMP developers on this.
|
||||
|
||||
* Providing a preview in a web browser.
|
||||
|
||||
Large percentage of the graphics designed in GIMP ends up on the WWW.
|
||||
With this extension, you can write a script that automatically
|
||||
launches a web browser and displays the image as it will be viewed.
|
||||
Imagine: have a set of scripts defining page style, change one attribute,
|
||||
and have GIMP not only recompute all the images, but also automagically
|
||||
open the redesigned page design in a browser window!
|
||||
|
||||
How to use the extension:
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
* Interactively:
|
||||
|
||||
select Xtns -> Web Browser -> Open URL, type in the URL, press Ok;
|
||||
|
||||
* Non-interactively:
|
||||
|
||||
use procedure extension-web-browser (url, new-window), which takes
|
||||
as the first argument a URL of a page to open, and second argument
|
||||
is a boolean which specifies whether you want the browser to open
|
||||
a new window with a document (new-window == TRUE) or use current
|
||||
window (new-window == FALSE). If the browser is not already running,
|
||||
new-window value is ignored.
|
||||
|
||||
I didn't provide a more detailed API on purpose -- making it more
|
||||
detailed would make it more Netscape-specific, and I want to be able
|
||||
to add support for other browsers. If someone has a convincing argument
|
||||
for adding more functions (i.e. to check whether browser is running, etc.),
|
||||
email me.
|
||||
|
||||
Status:
|
||||
~~~~~~
|
||||
|
||||
Netscape support is stable. I haven't tested it on many platforms,
|
||||
but I don't expect any problems. What other browsers, if any, do we
|
||||
need to support?
|
||||
|
||||
Included "web-browser.scm" has links to the most popular (IMHO)
|
||||
GIMP pages. I hope that the extension will get incorporated into
|
||||
the main source tree, and I will not have to maintain the bookmarks
|
||||
list.
|
||||
|
||||
Need help system design based on the web browser extension.
|
||||
If some GIMP guru (petm? spencer?) tells me what's the right way to do it,
|
||||
I can implement the help system.
|
||||
|
||||
I didn't write a proof-of-concept implementation of the preview
|
||||
script mainly because I am lazy. If someone writes such a script --
|
||||
please email it to me.
|
||||
|
||||
Building Web Browser Extension
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Compiling it should be fairly easy. I've included Makefile diff's (for
|
||||
the Makefile in plug-ins directory). webbrowser requires libXmu;
|
||||
it should be linked with -lXmu.
|
||||
|
||||
Enclosed script, web-browser.scm, creates a bookmarks menu in
|
||||
Xnts/Web Browser/*. Note that there is a bug in script-fu
|
||||
(at least as of version 0.99.15) which prevents it from handling
|
||||
scripts with zero arguments. Enclosed patch to
|
||||
plug-ins/script-fu/script-fu-scripts.c fixes that bug. Without
|
||||
this patch, web-browser.scm won't work.
|
||||
|
||||
Where To Find This Extension
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
The extension can be downloaded from
|
||||
ftp://ftp.xcf.berkeley.edu/pub/misha/webbrowser.tar.gz
|
||||
|
||||
For the up-to-date information about this extension, check out
|
||||
http://www.xcf.berkeley.edu/~misha/gimp/
|
||||
|
||||
Author
|
||||
~~~~~~
|
||||
|
||||
This extension is written by Misha Dynin <misha@xcf.berkeley.edu>.
|
||||
|
||||
I used the code from GUMP plugin, by Adrian Likins <aklikins@eos.ncsu.edu>.
|
||||
|
||||
Netscape interface code copyright:
|
||||
|
||||
* Copyright © 1996 Netscape Communications Corporation, all rights reserved.
|
||||
* Created: Jamie Zawinski <jwz@netscape.com>, 24-Dec-94.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and its
|
||||
* documentation for any purpose is hereby granted without fee, provided that
|
||||
* the above copyright notice appear in all copies and that both that
|
||||
* copyright notice and this permission notice appear in supporting
|
||||
* documentation. No representations are made about the suitability of this
|
||||
* software for any purpose. It is provided "as is" without express or
|
||||
* implied warranty.
|
|
@ -1,154 +0,0 @@
|
|||
; web-browser.scm -- install bookmarks
|
||||
; Copyright (c) 1997 Misha Dynin <misha@xcf.berkeley.edu>
|
||||
; Note: script-fu must be able to handle zero argument procedures to
|
||||
; process this file!
|
||||
;
|
||||
; For more information see webbrowser.readme or
|
||||
; http://www.xcf.berkeley.edu/~misha/gimp/
|
||||
;
|
||||
; 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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
(set! web-browser-new-window 0)
|
||||
|
||||
(define (script-fu-bookmark url)
|
||||
(plug-in-web-browser 1 url web-browser-new-window))
|
||||
|
||||
(define (bookmark-register proc menu help)
|
||||
(script-fu-register proc menu help
|
||||
"Misha Dynin <misha@xcf.berkeley.edu>"
|
||||
"Misha Dynin"
|
||||
"1997"
|
||||
""))
|
||||
|
||||
(define (script-fu-bookmark-1)
|
||||
(script-fu-bookmark "http://www.gimp.org/the_gimp.html"))
|
||||
|
||||
(bookmark-register "script-fu-bookmark-1"
|
||||
_"<Toolbox>/Xtns/Web Browser/GIMP.ORG/The GIMP"
|
||||
"Link to http://www.gimp.org/the_gimp.html")
|
||||
|
||||
(define (script-fu-bookmark-2)
|
||||
(script-fu-bookmark "http://www.gimp.org/docs.html"))
|
||||
|
||||
(bookmark-register "script-fu-bookmark-2"
|
||||
_"<Toolbox>/Xtns/Web Browser/GIMP.ORG/Documenation"
|
||||
"Link to http://www.gimp.org/docs.html")
|
||||
|
||||
(define (script-fu-bookmark-3)
|
||||
(script-fu-bookmark "http://www.gimp.org/mailing_list.html"))
|
||||
|
||||
(bookmark-register "script-fu-bookmark-3"
|
||||
_"<Toolbox>/Xtns/Web Browser/GIMP.ORG/Mailing Lists"
|
||||
"Link to http://www.gimp.org/mailing_list.html")
|
||||
|
||||
(define (script-fu-bookmark-4)
|
||||
(script-fu-bookmark "http://www.gimp.org/data.html"))
|
||||
|
||||
(bookmark-register "script-fu-bookmark-4"
|
||||
_"<Toolbox>/Xtns/Web Browser/GIMP.ORG/Resources"
|
||||
"Link to http://www.gimp.org/data.html")
|
||||
|
||||
(define (script-fu-bookmark-5)
|
||||
(script-fu-bookmark "http://www.gimp.org/download.html"))
|
||||
|
||||
(bookmark-register "script-fu-bookmark-5"
|
||||
_"<Toolbox>/Xtns/Web Browser/GIMP.ORG/Download"
|
||||
"Link to http://www.gimp.org/download.html")
|
||||
|
||||
(define (script-fu-bookmark-6)
|
||||
(script-fu-bookmark "http://www.gimp.org/art.html"))
|
||||
|
||||
(bookmark-register "script-fu-bookmark-6"
|
||||
_"<Toolbox>/Xtns/Web Browser/GIMP.ORG/GIMP Art"
|
||||
"Link to http://www.gimp.org/art.html")
|
||||
|
||||
(define (script-fu-bookmark-7)
|
||||
(script-fu-bookmark "http://www.gimp.org/links.html"))
|
||||
|
||||
(bookmark-register "script-fu-bookmark-7"
|
||||
_"<Toolbox>/Xtns/Web Browser/GIMP.ORG/Links"
|
||||
"Link to http://www.gimp.org/links.html")
|
||||
|
||||
(define (script-fu-bookmark-8)
|
||||
(script-fu-bookmark "http://www.gtk.org/"))
|
||||
|
||||
(bookmark-register "script-fu-bookmark-8"
|
||||
_"<Toolbox>/Xtns/Web Browser/GIMP.ORG/GTK"
|
||||
"Link to http://www.gtk.org/")
|
||||
|
||||
(define (script-fu-bookmark-10)
|
||||
(script-fu-bookmark "http://news.gimp.org/"))
|
||||
|
||||
(bookmark-register "script-fu-bookmark-10"
|
||||
_"<Toolbox>/Xtns/Web Browser/GIMP News"
|
||||
"Link to http://news.gimp.org/")
|
||||
|
||||
(define (script-fu-bookmark-11)
|
||||
(script-fu-bookmark "http://registry.gimp.org/"))
|
||||
|
||||
(bookmark-register "script-fu-bookmark-11"
|
||||
_"<Toolbox>/Xtns/Web Browser/Plug-In Registry"
|
||||
"Link to http://registry.gimp.org/")
|
||||
|
||||
(define (script-fu-bookmark-12)
|
||||
(script-fu-bookmark "http://www.rru.com/~meo/gimp/faq-user.html"))
|
||||
|
||||
(bookmark-register "script-fu-bookmark-12"
|
||||
_"<Toolbox>/Xtns/Web Browser/User FAQ"
|
||||
"Link to http://www.rru.com/~meo/gimp/faq-user.html")
|
||||
|
||||
(define (script-fu-bookmark-13)
|
||||
(script-fu-bookmark "http://www.rru.com/~meo/gimp/faq-dev.html"))
|
||||
|
||||
(bookmark-register "script-fu-bookmark-13"
|
||||
_"<Toolbox>/Xtns/Web Browser/Developer FAQ"
|
||||
"Link to http://www.rru.com/~meo/gimp/faq-dev.html")
|
||||
|
||||
(define (script-fu-bookmark-14)
|
||||
(script-fu-bookmark "http://manual.gimp.org/"))
|
||||
|
||||
(bookmark-register "script-fu-bookmark-14"
|
||||
_"<Toolbox>/Xtns/Web Browser/GIMP Manual"
|
||||
"Link to http://manual.gimp.org/")
|
||||
|
||||
(define (script-fu-bookmark-15)
|
||||
(script-fu-bookmark "http://abattoir.cc.ndsu.nodak.edu/~nem/gimp/tuts/"))
|
||||
|
||||
(bookmark-register "script-fu-bookmark-15"
|
||||
_"<Toolbox>/Xtns/Web Browser/GIMP Tutorials"
|
||||
"Link to http://abattoir.cc.ndsu.nodak.edu/~nem/gimp/tuts/")
|
||||
|
||||
(define (script-fu-bookmark-16)
|
||||
(script-fu-bookmark "http://bugzilla.gnome.org/"))
|
||||
|
||||
(bookmark-register "script-fu-bookmark-16"
|
||||
_"<Toolbox>/Xtns/Web Browser/GIMP Bugs"
|
||||
"Link to http://bugzilla.gnome.org/")
|
||||
|
||||
(define (script-fu-bookmark-17)
|
||||
(script-fu-bookmark "http://gimp-savvy.com/"))
|
||||
|
||||
(bookmark-register "script-fu-bookmark-17"
|
||||
_"<Toolbox>/Xtns/Web Browser/Gimp-Savvy.com"
|
||||
"Link to http://gimp-savvy.com/")
|
||||
|
||||
(define (script-fu-bookmark-18)
|
||||
(script-fu-bookmark "http://gimp-savvy.com/BOOK/"))
|
||||
|
||||
(bookmark-register "script-fu-bookmark-18"
|
||||
_"<Toolbox>/Xtns/Web Browser/Grokking the GIMP"
|
||||
"Link to http://gimp-savvy.com/BOOK/")
|
||||
|
||||
|
|
@ -1,963 +0,0 @@
|
|||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
* Copyright (C) 1997 Misha Dynin
|
||||
*
|
||||
* 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-1307, USA.
|
||||
*/
|
||||
|
||||
/*
|
||||
Web Browser v0.3 -- opens a URL in Netscape
|
||||
|
||||
by Misha Dynin <misha@xcf.berkeley.edu>
|
||||
|
||||
For more information, see webbrowser.readme, as well as
|
||||
|
||||
http://www.xcf.berkeley.edu/~misha/gimp/
|
||||
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <errno.h>
|
||||
#ifdef __EMX__
|
||||
#include <process.h>
|
||||
#endif
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
#define STRICT
|
||||
#include <windows.h>
|
||||
#include <shellapi.h>
|
||||
#else
|
||||
#include <X11/X.h>
|
||||
#include <X11/Xatom.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xmu/WinUtil.h> /* for XmuClientWindow() */
|
||||
#endif
|
||||
|
||||
#include <libgimp/gimp.h>
|
||||
#include <libgimp/gimpui.h>
|
||||
|
||||
#include "libgimp/stdplugins-intl.h"
|
||||
|
||||
|
||||
/* Browser program name -- start in case it's not already running */
|
||||
#define BROWSER_PROGNAME "netscape"
|
||||
|
||||
/* Open a new window with request? */
|
||||
#define OPEN_URL_NEW_WINDOW 1
|
||||
#define OPEN_URL_CURRENT_WINDOW 0
|
||||
|
||||
#define URL_BUF_SIZE 255
|
||||
|
||||
|
||||
static void query (void);
|
||||
static void run (const gchar *name,
|
||||
gint nparams,
|
||||
const GimpParam *param,
|
||||
gint *nreturn_vals,
|
||||
GimpParam **return_vals);
|
||||
|
||||
static gint open_url_dialog (void);
|
||||
static void ok_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void about_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void new_window_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void url_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
#ifndef G_OS_WIN32
|
||||
static gint mozilla_remote (const gchar *command);
|
||||
#endif
|
||||
|
||||
static gint open_url (const gchar *url,
|
||||
gboolean new_window);
|
||||
|
||||
|
||||
GimpPlugInInfo PLUG_IN_INFO =
|
||||
{
|
||||
NULL, /* init_proc */
|
||||
NULL, /* quit_proc */
|
||||
query, /* query_proc */
|
||||
run, /* run_proc */
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
gchar url[URL_BUF_SIZE];
|
||||
gint new_window;
|
||||
} u_info;
|
||||
|
||||
static u_info url_info =
|
||||
{
|
||||
"http://www.gimp.org/", /* Default URL */
|
||||
OPEN_URL_NEW_WINDOW, /* Change to ...CURRENT_WINDOW if
|
||||
* you prefer that as the default
|
||||
*/
|
||||
};
|
||||
|
||||
static gboolean run_flag = FALSE;
|
||||
|
||||
MAIN ()
|
||||
|
||||
static void
|
||||
query (void)
|
||||
{
|
||||
static GimpParamDef args[] =
|
||||
{
|
||||
{ GIMP_PDB_INT32, "run_mode", "Interactive, non-interactive" },
|
||||
{ GIMP_PDB_STRING, "url", "URL of a document to open" },
|
||||
{ GIMP_PDB_INT32, "new_window", "Create a new window or use existing one?" },
|
||||
};
|
||||
|
||||
gimp_install_procedure ("plug_in_web_browser",
|
||||
"open URL in Netscape",
|
||||
"You need to have Netscape installed",
|
||||
"Misha Dynin <misha@xcf.berkeley.edu>",
|
||||
"Misha Dynin, Jamie Zawinski, Spencer Kimball & Peter Mattis",
|
||||
"1997",
|
||||
N_("<Toolbox>/Xtns/Web Browser/Open URL..."),
|
||||
NULL,
|
||||
GIMP_PLUGIN,
|
||||
G_N_ELEMENTS (args), 0,
|
||||
args, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
run (const gchar *name,
|
||||
gint nparams,
|
||||
const GimpParam *param,
|
||||
gint *nreturn_vals,
|
||||
GimpParam **return_vals)
|
||||
{
|
||||
static GimpParam values[1];
|
||||
GimpRunMode run_mode;
|
||||
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
|
||||
|
||||
run_mode = param[0].data.d_int32;
|
||||
|
||||
INIT_I18N ();
|
||||
|
||||
values[0].type = GIMP_PDB_STATUS;
|
||||
values[0].data.d_status = status;
|
||||
|
||||
*nreturn_vals = 1;
|
||||
*return_vals = values;
|
||||
|
||||
if (strcmp (name, "plug_in_web_browser") == 0)
|
||||
{
|
||||
switch (run_mode)
|
||||
{
|
||||
case GIMP_RUN_INTERACTIVE:
|
||||
/* Possibly retrieve data */
|
||||
gimp_get_data ("plug_in_web_browser", &url_info);
|
||||
|
||||
if (!open_url_dialog ())
|
||||
return;
|
||||
break;
|
||||
|
||||
case GIMP_RUN_NONINTERACTIVE:
|
||||
/* Make sure all the arguments are there! */
|
||||
if (nparams != 3)
|
||||
{
|
||||
status = GIMP_PDB_CALLING_ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
strncpy (url_info.url, param[1].data.d_string, URL_BUF_SIZE);
|
||||
url_info.new_window = param[2].data.d_int32;
|
||||
}
|
||||
break;
|
||||
|
||||
case GIMP_RUN_WITH_LAST_VALS:
|
||||
gimp_get_data ("plug_in_web_browser", &url_info);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (status == GIMP_PDB_SUCCESS)
|
||||
{
|
||||
if (!open_url (url_info.url, url_info.new_window))
|
||||
values[0].data.d_status = GIMP_PDB_EXECUTION_ERROR;
|
||||
|
||||
if (run_mode == GIMP_RUN_INTERACTIVE)
|
||||
gimp_set_data ("plug_in_web_browser", &url_info, sizeof (u_info));
|
||||
|
||||
values[0].data.d_status = GIMP_PDB_SUCCESS;
|
||||
}
|
||||
else
|
||||
values[0].data.d_status = GIMP_PDB_EXECUTION_ERROR;
|
||||
}
|
||||
else
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
static gint
|
||||
start_browser (const gchar *prog,
|
||||
const gchar *url)
|
||||
{
|
||||
#ifdef G_OS_WIN32
|
||||
|
||||
ShellExecute (HWND_DESKTOP, "open", url, NULL, "C:\\", SW_SHOWNORMAL);
|
||||
|
||||
#else
|
||||
#ifndef __EMX__
|
||||
pid_t cpid;
|
||||
|
||||
if ((cpid = fork()) == 0)
|
||||
{
|
||||
execlp (prog, prog, url, NULL);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
return (cpid > 0);
|
||||
#else
|
||||
return (spawnlp (P_NOWAIT, prog, prog, url, NULL) != -1);
|
||||
#endif
|
||||
#endif /* !G_OS_WIN32 */
|
||||
}
|
||||
|
||||
static gint
|
||||
open_url (const gchar *url,
|
||||
gboolean new_window)
|
||||
{
|
||||
gchar buf[512];
|
||||
|
||||
while (g_ascii_isspace (*url))
|
||||
++url;
|
||||
|
||||
#ifndef G_OS_WIN32
|
||||
sprintf (buf, "openURL(%s%s)", url, new_window ? ",new-window" : "");
|
||||
|
||||
if (mozilla_remote (buf))
|
||||
return (TRUE);
|
||||
#endif
|
||||
return (start_browser (BROWSER_PROGNAME, url));
|
||||
}
|
||||
|
||||
static gint
|
||||
open_url_dialog (void)
|
||||
{
|
||||
GtkWidget *dlg;
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *button;
|
||||
GtkWidget *entry;
|
||||
GtkWidget *table;
|
||||
GSList *group;
|
||||
gchar buffer[256];
|
||||
|
||||
gimp_ui_init ("webbrowser", FALSE);
|
||||
|
||||
dlg = gimp_dialog_new (_("Open URL"), "webbbrowser",
|
||||
gimp_standard_help_func, "filters/webbrowser.html",
|
||||
GTK_WIN_POS_MOUSE,
|
||||
FALSE, TRUE, FALSE,
|
||||
|
||||
_("About"), about_callback,
|
||||
NULL, NULL, NULL, FALSE, FALSE,
|
||||
|
||||
GTK_STOCK_CANCEL, gtk_widget_destroy,
|
||||
NULL, 1, NULL, FALSE, TRUE,
|
||||
|
||||
GTK_STOCK_OK, ok_callback,
|
||||
NULL, NULL, NULL, TRUE, FALSE,
|
||||
|
||||
NULL);
|
||||
|
||||
g_signal_connect (dlg, "destroy",
|
||||
G_CALLBACK (gtk_main_quit),
|
||||
NULL);
|
||||
|
||||
/* table */
|
||||
table = gtk_table_new (2, 2, FALSE);
|
||||
gtk_table_set_col_spacings (GTK_TABLE (table), 4);
|
||||
gtk_table_set_row_spacings (GTK_TABLE (table), 4);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (table), 6);
|
||||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), table, FALSE, FALSE, 0);
|
||||
gtk_widget_show (table);
|
||||
|
||||
/* URL */
|
||||
entry = gtk_entry_new ();
|
||||
gtk_widget_set_size_request (entry, 200, -1);
|
||||
g_snprintf (buffer, sizeof (buffer), "%s", url_info.url);
|
||||
gtk_entry_set_text (GTK_ENTRY (entry), buffer);
|
||||
gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
|
||||
_("URL:"), 1.0, 0.5,
|
||||
entry, 1, FALSE);
|
||||
g_signal_connect (entry, "changed",
|
||||
G_CALLBACK (url_callback),
|
||||
&url_info.url);
|
||||
gtk_widget_show (entry);
|
||||
|
||||
/* Window */
|
||||
hbox = gtk_hbox_new (FALSE, 4);
|
||||
gimp_table_attach_aligned (GTK_TABLE (table), 0, 1,
|
||||
_("Window:"), 1.0, 0.5,
|
||||
hbox, 1, FALSE);
|
||||
|
||||
button = gtk_radio_button_new_with_label (NULL, _("New"));
|
||||
group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (button));
|
||||
if (url_info.new_window == OPEN_URL_NEW_WINDOW)
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
|
||||
gtk_widget_show (button);
|
||||
|
||||
g_signal_connect (button, "toggled",
|
||||
G_CALLBACK (new_window_callback),
|
||||
(gpointer) OPEN_URL_NEW_WINDOW);
|
||||
|
||||
button = gtk_radio_button_new_with_label (group, _("Current"));
|
||||
group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (button));
|
||||
if (url_info.new_window == OPEN_URL_CURRENT_WINDOW)
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
|
||||
gtk_widget_show (button);
|
||||
|
||||
g_signal_connect (button, "toggled",
|
||||
G_CALLBACK (new_window_callback),
|
||||
(gpointer) OPEN_URL_CURRENT_WINDOW);
|
||||
|
||||
gtk_widget_show (dlg);
|
||||
|
||||
gtk_main ();
|
||||
gdk_flush ();
|
||||
|
||||
return run_flag;
|
||||
}
|
||||
|
||||
static void
|
||||
ok_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
run_flag = TRUE;
|
||||
|
||||
gtk_widget_destroy (GTK_WIDGET (data));
|
||||
}
|
||||
|
||||
static void
|
||||
about_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
open_url ("http://www.xcf.berkeley.edu/~misha/gimp/", OPEN_URL_NEW_WINDOW);
|
||||
}
|
||||
|
||||
static void
|
||||
new_window_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
if (GTK_TOGGLE_BUTTON (widget)->active)
|
||||
{
|
||||
url_info.new_window = GPOINTER_TO_INT (data);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
url_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
strncpy (url_info.url, gtk_entry_get_text (GTK_ENTRY (widget)), URL_BUF_SIZE);
|
||||
}
|
||||
|
||||
#ifndef G_OS_WIN32
|
||||
|
||||
/* -*- Mode:C; tab-width: 8 -*-
|
||||
* remote.c --- remote control of Netscape Navigator for Unix.
|
||||
* version 1.1.3, for Netscape Navigator 1.1 and newer.
|
||||
*
|
||||
* Copyright © 1996 Netscape Communications Corporation, all rights reserved.
|
||||
* Created: Jamie Zawinski <jwz@netscape.com>, 24-Dec-94.
|
||||
*
|
||||
* To compile:
|
||||
*
|
||||
* cc -o netscape-remote remote.c -DSTANDALONE -lXmu -lX11
|
||||
*
|
||||
* To use:
|
||||
*
|
||||
* netscape-remote -help
|
||||
*
|
||||
* Documentation for the protocol which this code implements may be found at:
|
||||
*
|
||||
* http://home.netscape.com/newsref/std/x-remote.html
|
||||
*
|
||||
* Bugs and commentary to x_cbug@netscape.com.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/* vroot.h is a header file which lets a client get along with `virtual root'
|
||||
window managers like swm, tvtwm, olvwm, etc. If you don't have this header
|
||||
file, you can find it at "http://home.netscape.com/newsref/std/vroot.h".
|
||||
If you don't care about supporting virtual root window managers, you can
|
||||
comment this line out.
|
||||
*/
|
||||
/* #include "vroot.h" */
|
||||
/* Begin vroot.h */
|
||||
/*****************************************************************************/
|
||||
/** Copyright 1991 by Andreas Stolcke **/
|
||||
/** Copyright 1990 by Solbourne Computer Inc. **/
|
||||
/** Longmont, Colorado **/
|
||||
/** **/
|
||||
/** All Rights Reserved **/
|
||||
/** **/
|
||||
/** Permission to use, copy, modify, and distribute this software and **/
|
||||
/** its documentation for any purpose and without fee is hereby **/
|
||||
/** granted, provided that the above copyright notice appear in all **/
|
||||
/** copies and that the name of Solbourne not be used in advertising **/
|
||||
/** in publicity pertaining to distribution of the software without **/
|
||||
/** specific, written prior permission. **/
|
||||
/** **/
|
||||
/** ANDREAS STOLCKE AND SOLBOURNE COMPUTER INC. DISCLAIMS ALL WARRANTIES **/
|
||||
/** WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF **/
|
||||
/** MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL ANDREAS STOLCKE **/
|
||||
/** OR SOLBOURNE BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL **/
|
||||
/** DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA **/
|
||||
/** OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER **/
|
||||
/** TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE **/
|
||||
/** OR PERFORMANCE OF THIS SOFTWARE. **/
|
||||
/*****************************************************************************/
|
||||
/*
|
||||
* vroot.h -- Virtual Root Window handling header file
|
||||
*
|
||||
* This header file redefines the X11 macros RootWindow and DefaultRootWindow,
|
||||
* making them look for a virtual root window as provided by certain `virtual'
|
||||
* window managers like swm and tvtwm. If none is found, the ordinary root
|
||||
* window is returned, thus retaining backward compatibility with standard
|
||||
* window managers.
|
||||
* The function implementing the virtual root lookup remembers the result of
|
||||
* its last invocation to avoid overhead in the case of repeated calls
|
||||
* on the same display and screen arguments.
|
||||
* The lookup code itself is taken from Tom LaStrange's ssetroot program.
|
||||
*
|
||||
* Most simple root window changing X programs can be converted to using
|
||||
* virtual roots by just including
|
||||
*
|
||||
* #include <X11/vroot.h>
|
||||
*
|
||||
* after all the X11 header files. It has been tested on such popular
|
||||
* X clients as xphoon, xfroot, xloadimage, and xaqua.
|
||||
* It also works with the core clients xprop, xwininfo, xwd, and editres
|
||||
* (and is necessary to get those clients working under tvtwm).
|
||||
* It does NOT work with xsetroot; get the xsetroot replacement included in
|
||||
* the tvtwm distribution instead.
|
||||
*
|
||||
* Andreas Stolcke <stolcke@ICSI.Berkeley.EDU>, 9/7/90
|
||||
* - replaced all NULL's with properly cast 0's, 5/6/91
|
||||
* - free children list (suggested by Mark Martin <mmm@cetia.fr>), 5/16/91
|
||||
* - include X11/Xlib.h and support RootWindowOfScreen, too 9/17/91
|
||||
*/
|
||||
|
||||
#ifndef _VROOT_H_
|
||||
#define _VROOT_H_
|
||||
|
||||
|
||||
static Window
|
||||
VirtualRootWindowOfScreen(screen)
|
||||
Screen *screen;
|
||||
{
|
||||
static Screen *save_screen = (Screen *)0;
|
||||
static Window root = (Window)0;
|
||||
|
||||
if (screen != save_screen) {
|
||||
Display *dpy = DisplayOfScreen(screen);
|
||||
Atom __SWM_VROOT = None;
|
||||
int i;
|
||||
Window rootReturn, parentReturn, *children;
|
||||
unsigned int numChildren;
|
||||
|
||||
root = RootWindowOfScreen(screen);
|
||||
|
||||
/* go look for a virtual root */
|
||||
__SWM_VROOT = XInternAtom(dpy, "__SWM_VROOT", False);
|
||||
if (XQueryTree(dpy, root, &rootReturn, &parentReturn,
|
||||
&children, &numChildren)) {
|
||||
for (i = 0; i < numChildren; i++) {
|
||||
Atom actual_type;
|
||||
int actual_format;
|
||||
unsigned long nitems, bytesafter;
|
||||
Window *newRoot = (Window *)0;
|
||||
|
||||
if (XGetWindowProperty(dpy, children[i],
|
||||
__SWM_VROOT, 0, 1, False, XA_WINDOW,
|
||||
&actual_type, &actual_format,
|
||||
&nitems, &bytesafter,
|
||||
(unsigned char **) &newRoot) == Success
|
||||
&& newRoot) {
|
||||
root = *newRoot;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (children)
|
||||
XFree((char *)children);
|
||||
}
|
||||
|
||||
save_screen = screen;
|
||||
}
|
||||
|
||||
return root;
|
||||
}
|
||||
|
||||
#undef RootWindowOfScreen
|
||||
#define RootWindowOfScreen(s) VirtualRootWindowOfScreen(s)
|
||||
|
||||
#undef RootWindow
|
||||
#define RootWindow(dpy,screen) VirtualRootWindowOfScreen(ScreenOfDisplay(dpy,screen))
|
||||
|
||||
#undef DefaultRootWindow
|
||||
#define DefaultRootWindow(dpy) VirtualRootWindowOfScreen(DefaultScreenOfDisplay(dpy))
|
||||
|
||||
#endif /* _VROOT_H_ */
|
||||
/* End vroot.h */
|
||||
|
||||
|
||||
#ifdef DIAGNOSTIC
|
||||
#ifdef STANDALONE
|
||||
static const char *progname = 0;
|
||||
static const char *expected_mozilla_version = "1.1";
|
||||
#else /* !STANDALONE */
|
||||
extern const char *progname;
|
||||
extern const char *expected_mozilla_version;
|
||||
#endif /* !STANDALONE */
|
||||
#endif /* DIAGNOSTIC */
|
||||
|
||||
#define MOZILLA_VERSION_PROP "_MOZILLA_VERSION"
|
||||
#define MOZILLA_LOCK_PROP "_MOZILLA_LOCK"
|
||||
#define MOZILLA_COMMAND_PROP "_MOZILLA_COMMAND"
|
||||
#define MOZILLA_RESPONSE_PROP "_MOZILLA_RESPONSE"
|
||||
static Atom XA_MOZILLA_VERSION = 0;
|
||||
static Atom XA_MOZILLA_LOCK = 0;
|
||||
static Atom XA_MOZILLA_COMMAND = 0;
|
||||
static Atom XA_MOZILLA_RESPONSE = 0;
|
||||
|
||||
static void
|
||||
mozilla_remote_init_atoms (Display *dpy)
|
||||
{
|
||||
if (! XA_MOZILLA_VERSION)
|
||||
XA_MOZILLA_VERSION = XInternAtom (dpy, MOZILLA_VERSION_PROP, False);
|
||||
if (! XA_MOZILLA_LOCK)
|
||||
XA_MOZILLA_LOCK = XInternAtom (dpy, MOZILLA_LOCK_PROP, False);
|
||||
if (! XA_MOZILLA_COMMAND)
|
||||
XA_MOZILLA_COMMAND = XInternAtom (dpy, MOZILLA_COMMAND_PROP, False);
|
||||
if (! XA_MOZILLA_RESPONSE)
|
||||
XA_MOZILLA_RESPONSE = XInternAtom (dpy, MOZILLA_RESPONSE_PROP, False);
|
||||
}
|
||||
|
||||
static Window
|
||||
mozilla_remote_find_window (Display *dpy)
|
||||
{
|
||||
int i;
|
||||
Window root = RootWindowOfScreen (DefaultScreenOfDisplay (dpy));
|
||||
Window root2, parent, *kids;
|
||||
unsigned int nkids;
|
||||
Window result = 0;
|
||||
|
||||
if (! XQueryTree (dpy, root, &root2, &parent, &kids, &nkids))
|
||||
{
|
||||
#ifdef DIAGNOSTIC
|
||||
fprintf (stderr, "%s: XQueryTree failed on display %s\n", progname,
|
||||
DisplayString (dpy));
|
||||
#endif
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* root != root2 is possible with virtual root WMs. */
|
||||
|
||||
if (! (kids && nkids))
|
||||
{
|
||||
#ifdef DIAGNOSTIC
|
||||
fprintf (stderr, "%s: root window has no children on display %s\n",
|
||||
progname, DisplayString (dpy));
|
||||
#endif
|
||||
return (0);
|
||||
}
|
||||
|
||||
for (i = nkids-1; i >= 0; i--)
|
||||
{
|
||||
Atom type;
|
||||
int format;
|
||||
unsigned long nitems, bytesafter;
|
||||
unsigned char *version = 0;
|
||||
Window w = XmuClientWindow (dpy, kids[i]);
|
||||
int status = XGetWindowProperty (dpy, w, XA_MOZILLA_VERSION,
|
||||
0, (65536 / sizeof (long)),
|
||||
False, XA_STRING,
|
||||
&type, &format, &nitems, &bytesafter,
|
||||
&version);
|
||||
if (! version)
|
||||
continue;
|
||||
|
||||
XFree (version);
|
||||
if (status == Success && type != None)
|
||||
{
|
||||
result = w;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static char *lock_data = 0;
|
||||
|
||||
static int
|
||||
mozilla_remote_obtain_lock (Display *dpy, Window window)
|
||||
{
|
||||
Bool locked = False;
|
||||
Bool waited = False;
|
||||
|
||||
if (! lock_data)
|
||||
{
|
||||
lock_data = (char *) malloc (255);
|
||||
sprintf (lock_data, "pid%d@", getpid ());
|
||||
if (gethostname (lock_data + strlen (lock_data), 100))
|
||||
{
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
int result;
|
||||
Atom actual_type;
|
||||
int actual_format;
|
||||
unsigned long nitems, bytes_after;
|
||||
unsigned char *data = 0;
|
||||
|
||||
XGrabServer (dpy); /* ################################# DANGER! */
|
||||
|
||||
result = XGetWindowProperty (dpy, window, XA_MOZILLA_LOCK,
|
||||
0, (65536 / sizeof (long)),
|
||||
False, /* don't delete */
|
||||
XA_STRING,
|
||||
&actual_type, &actual_format,
|
||||
&nitems, &bytes_after,
|
||||
&data);
|
||||
if (result != Success || actual_type == None)
|
||||
{
|
||||
/* It's not now locked - lock it. */
|
||||
#ifdef DEBUG_PROPS
|
||||
fprintf (stderr, "%s: (writing " MOZILLA_LOCK_PROP
|
||||
" \"%s\" to 0x%x)\n",
|
||||
progname, lock_data, (unsigned int) window);
|
||||
#endif
|
||||
XChangeProperty (dpy, window, XA_MOZILLA_LOCK, XA_STRING, 8,
|
||||
PropModeReplace, (unsigned char *) lock_data,
|
||||
strlen (lock_data));
|
||||
locked = True;
|
||||
}
|
||||
|
||||
XUngrabServer (dpy); /* ################################# danger over */
|
||||
XSync (dpy, False);
|
||||
|
||||
if (! locked)
|
||||
{
|
||||
/* We tried to grab the lock this time, and failed because someone
|
||||
else is holding it already. So, wait for a PropertyDelete event
|
||||
to come in, and try again. */
|
||||
|
||||
#ifdef DIAGNOSTIC
|
||||
fprintf (stderr, "%s: window 0x%x is locked by %s; waiting...\n",
|
||||
progname, (unsigned int) window, data);
|
||||
#endif
|
||||
waited = True;
|
||||
|
||||
while (1)
|
||||
{
|
||||
XEvent event;
|
||||
XNextEvent (dpy, &event);
|
||||
if (event.xany.type == DestroyNotify &&
|
||||
event.xdestroywindow.window == window)
|
||||
{
|
||||
#ifdef DIAGNOSTIC
|
||||
fprintf (stderr, "%s: window 0x%x unexpectedly destroyed.\n",
|
||||
progname, (unsigned int) window);
|
||||
#endif
|
||||
return (6);
|
||||
}
|
||||
else if (event.xany.type == PropertyNotify &&
|
||||
event.xproperty.state == PropertyDelete &&
|
||||
event.xproperty.window == window &&
|
||||
event.xproperty.atom == XA_MOZILLA_LOCK)
|
||||
{
|
||||
/* Ok! Someone deleted their lock, so now we can try
|
||||
again. */
|
||||
#ifdef DEBUG_PROPS
|
||||
fprintf (stderr, "%s: (0x%x unlocked, trying again...)\n",
|
||||
progname, (unsigned int) window);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (data)
|
||||
XFree (data);
|
||||
}
|
||||
while (! locked);
|
||||
|
||||
#ifdef DIAGNOSTIC
|
||||
if (waited)
|
||||
fprintf (stderr, "%s: obtained lock.\n", progname);
|
||||
#endif
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
mozilla_remote_free_lock (Display *dpy, Window window)
|
||||
{
|
||||
int result;
|
||||
Atom actual_type;
|
||||
int actual_format;
|
||||
unsigned long nitems, bytes_after;
|
||||
unsigned char *data = 0;
|
||||
|
||||
#ifdef DEBUG_PROPS
|
||||
fprintf (stderr, "%s: (deleting " MOZILLA_LOCK_PROP
|
||||
" \"%s\" from 0x%x)\n",
|
||||
progname, lock_data, (unsigned int) window);
|
||||
#endif
|
||||
|
||||
result = XGetWindowProperty (dpy, window, XA_MOZILLA_LOCK,
|
||||
0, (65536 / sizeof (long)),
|
||||
True, /* atomic delete after */
|
||||
XA_STRING,
|
||||
&actual_type, &actual_format,
|
||||
&nitems, &bytes_after,
|
||||
&data);
|
||||
if (result != Success)
|
||||
{
|
||||
#ifdef DIAGNOSTIC
|
||||
fprintf (stderr, "%s: unable to read and delete " MOZILLA_LOCK_PROP
|
||||
" property\n",
|
||||
progname);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
else if (!data || !*data)
|
||||
{
|
||||
#ifdef DIAGNOSTIC
|
||||
fprintf (stderr, "%s: invalid data on " MOZILLA_LOCK_PROP
|
||||
" of window 0x%x.\n",
|
||||
progname, (unsigned int) window);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
else if (strcmp ((char *) data, lock_data))
|
||||
{
|
||||
#ifdef DIAGNOSTIC
|
||||
fprintf (stderr, "%s: " MOZILLA_LOCK_PROP
|
||||
" was stolen! Expected \"%s\", saw \"%s\"!\n",
|
||||
progname, lock_data, data);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
if (data)
|
||||
XFree (data);
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
mozilla_remote_command (Display *dpy, Window window, const char *command)
|
||||
{
|
||||
int result = 0;
|
||||
Bool done = False;
|
||||
|
||||
#ifdef DEBUG_PROPS
|
||||
fprintf (stderr, "%s: (writing " MOZILLA_COMMAND_PROP " \"%s\" to 0x%x)\n",
|
||||
progname, command, (unsigned int) window);
|
||||
#endif
|
||||
|
||||
XChangeProperty (dpy, window, XA_MOZILLA_COMMAND, XA_STRING, 8,
|
||||
PropModeReplace, (unsigned char *) command,
|
||||
strlen (command));
|
||||
|
||||
while (!done)
|
||||
{
|
||||
XEvent event;
|
||||
XNextEvent (dpy, &event);
|
||||
if (event.xany.type == DestroyNotify &&
|
||||
event.xdestroywindow.window == window)
|
||||
{
|
||||
/* Print to warn user...*/
|
||||
#ifdef DIAGNOSTIC
|
||||
fprintf (stderr, "%s: window 0x%x was destroyed.\n",
|
||||
progname, (unsigned int) window);
|
||||
#endif
|
||||
result = 6;
|
||||
goto DONE;
|
||||
}
|
||||
else if (event.xany.type == PropertyNotify &&
|
||||
event.xproperty.state == PropertyNewValue &&
|
||||
event.xproperty.window == window &&
|
||||
event.xproperty.atom == XA_MOZILLA_RESPONSE)
|
||||
{
|
||||
Atom actual_type;
|
||||
int actual_format;
|
||||
unsigned long nitems, bytes_after;
|
||||
unsigned char *data = 0;
|
||||
|
||||
result = XGetWindowProperty (dpy, window, XA_MOZILLA_RESPONSE,
|
||||
0, (65536 / sizeof (long)),
|
||||
True, /* atomic delete after */
|
||||
XA_STRING,
|
||||
&actual_type, &actual_format,
|
||||
&nitems, &bytes_after,
|
||||
&data);
|
||||
#ifdef DEBUG_PROPS
|
||||
if (result == Success && data && *data)
|
||||
{
|
||||
fprintf (stderr, "%s: (server sent " MOZILLA_RESPONSE_PROP
|
||||
" \"%s\" to 0x%x.)\n",
|
||||
progname, data, (unsigned int) window);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (result != Success)
|
||||
{
|
||||
#ifdef DIAGNOSTIC
|
||||
fprintf (stderr, "%s: failed reading " MOZILLA_RESPONSE_PROP
|
||||
" from window 0x%0x.\n",
|
||||
progname, (unsigned int) window);
|
||||
#endif
|
||||
result = 6;
|
||||
done = True;
|
||||
}
|
||||
else if (!data || strlen((char *) data) < 5)
|
||||
{
|
||||
#ifdef DIAGNOSTIC
|
||||
fprintf (stderr, "%s: invalid data on " MOZILLA_RESPONSE_PROP
|
||||
" property of window 0x%0x.\n",
|
||||
progname, (unsigned int) window);
|
||||
#endif
|
||||
result = 6;
|
||||
done = True;
|
||||
}
|
||||
else if (*data == '1') /* positive preliminary reply */
|
||||
{
|
||||
#ifdef DIAGNOSTIC
|
||||
fprintf (stderr, "%s: %s\n", progname, data + 4);
|
||||
#endif
|
||||
/* keep going */
|
||||
done = False;
|
||||
}
|
||||
#if 1
|
||||
else if (!strncmp ((char *)data, "200", 3)) /* positive completion */
|
||||
{
|
||||
result = 0;
|
||||
done = True;
|
||||
}
|
||||
#endif
|
||||
else if (*data == '2') /* positive completion */
|
||||
{
|
||||
#ifdef DIAGNOSTIC
|
||||
fprintf (stderr, "%s: %s\n", progname, data + 4);
|
||||
#endif
|
||||
result = 0;
|
||||
done = True;
|
||||
}
|
||||
else if (*data == '3') /* positive intermediate reply */
|
||||
{
|
||||
#ifdef DIAGNOSTIC
|
||||
fprintf (stderr, "%s: internal error: "
|
||||
"server wants more information? (%s)\n",
|
||||
progname, data);
|
||||
#endif
|
||||
result = 3;
|
||||
done = True;
|
||||
}
|
||||
else if (*data == '4' || /* transient negative completion */
|
||||
*data == '5') /* permanent negative completion */
|
||||
{
|
||||
#ifdef DIAGNOSTIC
|
||||
fprintf (stderr, "%s: %s\n", progname, data + 4);
|
||||
#endif
|
||||
result = (*data - '0');
|
||||
done = True;
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef DIAGNOSTIC
|
||||
fprintf (stderr,
|
||||
"%s: unrecognised " MOZILLA_RESPONSE_PROP
|
||||
" from window 0x%x: %s\n",
|
||||
progname, (unsigned int) window, data);
|
||||
#endif
|
||||
result = 6;
|
||||
done = True;
|
||||
}
|
||||
|
||||
if (data)
|
||||
XFree (data);
|
||||
}
|
||||
#ifdef DEBUG_PROPS
|
||||
else if (event.xany.type == PropertyNotify &&
|
||||
event.xproperty.window == window &&
|
||||
event.xproperty.state == PropertyDelete &&
|
||||
event.xproperty.atom == XA_MOZILLA_COMMAND)
|
||||
{
|
||||
fprintf (stderr, "%s: (server 0x%x has accepted "
|
||||
MOZILLA_COMMAND_PROP ".)\n",
|
||||
progname, (unsigned int) window);
|
||||
}
|
||||
#endif /* DEBUG_PROPS */
|
||||
}
|
||||
|
||||
DONE:
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static int
|
||||
mozilla_remote (const gchar *command)
|
||||
{
|
||||
int status = 0;
|
||||
Display *dpy;
|
||||
Window window;
|
||||
|
||||
if (!(dpy = XOpenDisplay (NULL)))
|
||||
return (0);
|
||||
|
||||
mozilla_remote_init_atoms (dpy);
|
||||
|
||||
if (!(window = mozilla_remote_find_window (dpy)))
|
||||
return (0);
|
||||
|
||||
XSelectInput (dpy, window, (PropertyChangeMask|StructureNotifyMask));
|
||||
|
||||
if (mozilla_remote_obtain_lock (dpy, window))
|
||||
return (0);
|
||||
|
||||
status = mozilla_remote_command (dpy, window, command);
|
||||
|
||||
/* When status = 6, it means the window has been destroyed */
|
||||
/* It is invalid to free the lock when window is destroyed. */
|
||||
|
||||
if ( status != 6 )
|
||||
mozilla_remote_free_lock (dpy, window);
|
||||
|
||||
return (!status);
|
||||
}
|
||||
|
||||
#endif /* !G_OS_WIN32 */
|
|
@ -135,6 +135,7 @@ plug-ins/common/vinvert.c
|
|||
plug-ins/common/vpropagate.c
|
||||
plug-ins/common/warp.c
|
||||
plug-ins/common/waves.c
|
||||
plug-ins/common/webbrowser.c
|
||||
plug-ins/common/whirlpinch.c
|
||||
plug-ins/common/winclipboard.c
|
||||
plug-ins/common/wind.c
|
||||
|
|
|
@ -99,5 +99,5 @@ plug-ins/script-fu/scripts/truchet.scm
|
|||
plug-ins/script-fu/scripts/unsharp-mask.scm
|
||||
plug-ins/script-fu/scripts/waves-anim.scm
|
||||
plug-ins/script-fu/scripts/weave.scm
|
||||
plug-ins/script-fu/scripts/web-browser.scm
|
||||
plug-ins/script-fu/scripts/xach-effect.scm
|
||||
plug-ins/webbrowser/web-browser.scm
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue