gimprc.in app/gimprc.[ch] new gimprc variable "help-browser" which can be

1999-12-19  Michael Natterer  <mitch@gimp.org>

	* gimprc.in
	* app/gimprc.[ch]
	* app/preferences_dialog.c: new gimprc variable "help-browser"
	which can be either "gimp", or "netscape".

	* app/gimphelp.[ch]: depending on the value of help_browser, show
	the help page with the webbrowser plugin.
This commit is contained in:
Michael Natterer 1999-12-19 17:15:11 +00:00 committed by Michael Natterer
parent 6d1d305f95
commit 65e424f36b
10 changed files with 342 additions and 70 deletions

View file

@ -1,3 +1,13 @@
1999-12-19 Michael Natterer <mitch@gimp.org>
* gimprc.in
* app/gimprc.[ch]
* app/preferences_dialog.c: new gimprc variable "help-browser"
which can be either "gimp", or "netscape".
* app/gimphelp.[ch]: depending on the value of help_browser, show
the help page with the webbrowser plugin.
1999-12-19 Michael Natterer <mitch@gimp.org>
* plug-ins/helpbrowser/helpbrowser.c: immediately return from

View file

@ -110,6 +110,7 @@ static int old_trust_dirty_flag;
static int old_use_help;
static int old_nav_window_per_display;
static int old_info_window_follows_mouse;
static int old_help_browser;
/* variables which can't be changed on the fly */
static int edit_stingy_memory_use;
@ -560,6 +561,8 @@ file_prefs_save_callback (GtkWidget *widget,
info_window_follows_mouse = edit_info_window_follows_mouse;
restart_notification = TRUE;
}
if (help_browser != old_help_browser)
update = g_list_append (update, "help-browser");
save_gimprc (&update, &remove);
@ -631,6 +634,7 @@ file_prefs_cancel_callback (GtkWidget *widget,
use_help = old_use_help;
nav_window_per_display = old_nav_window_per_display;
info_window_follows_mouse = old_info_window_follows_mouse;
help_browser = old_help_browser;
if (preview_size != old_preview_size)
{
@ -733,8 +737,10 @@ file_prefs_toggle_callback (GtkWidget *widget,
context_manager_set_global_paint_options (GTK_TOGGLE_BUTTON (widget)->active);
else if (data == &show_indicators)
show_indicators = GTK_TOGGLE_BUTTON (widget)->active;
else if (data == &thumbnail_mode || data == &interpolation_type ||
data == &trust_dirty_flag)
else if (data == &thumbnail_mode ||
data == &interpolation_type ||
data == &trust_dirty_flag ||
data == &help_browser)
{
val = data;
*val = (long) gtk_object_get_user_data (GTK_OBJECT (widget));
@ -1232,6 +1238,7 @@ file_pref_cmd_callback (GtkWidget *widget,
old_use_help = use_help;
old_nav_window_per_display = nav_window_per_display;
old_info_window_follows_mouse = info_window_follows_mouse;
old_help_browser = help_browser;
file_prefs_strset (&old_image_title_format, image_title_format);
file_prefs_strset (&old_temp_path, edit_temp_path);
@ -1645,6 +1652,26 @@ file_pref_cmd_callback (GtkWidget *widget,
&use_help);
gtk_widget_show (button);
vbox2 = file_prefs_frame_new (_("Help Browser"), GTK_BOX (vbox));
table = gtk_table_new (1, 2, FALSE);
gtk_container_set_border_width (GTK_CONTAINER (table), 2);
gtk_table_set_col_spacings (GTK_TABLE (table), 4);
gtk_box_pack_start (GTK_BOX (vbox2), table, FALSE, FALSE, 0);
gtk_widget_show (table);
optionmenu =
gimp_option_menu_new (file_prefs_toggle_callback,
(gpointer) help_browser,
_("Internal"), &help_browser,
(gpointer) HELP_BROWSER_GIMP,
_("Netscape"), &help_browser,
(gpointer) HELP_BROWSER_NETSCAPE,
NULL);
gimp_table_attach_aligned (GTK_TABLE (table), 0,
_("Help Browser to Use:"), 1.0, 0.5,
optionmenu, TRUE);
/* Interface / Image Windows */
vbox = file_prefs_notebook_append_page (GTK_NOTEBOOK (notebook),
_("Image Windows Settings"),

View file

@ -18,6 +18,12 @@
* 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"
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <gdk/gdkkeysyms.h>
#include <gtk/gtk.h>
@ -26,11 +32,16 @@
#include "plug_in.h"
#include "procedural_db.h"
#include "libgimp/gimpenv.h"
#include "libgimp/gimpintl.h"
#define DEBUG_HELP
/* local function prototypes */
static void gimp_help_internal (gchar *current_locale,
gchar *help_data);
static void gimp_help_netscape (gchar *current_locale,
gchar *help_data);
static void gimp_help_callback (GtkWidget *widget,
gpointer data);
static gint gimp_help_tips_query_idle_show_help (gpointer data);
@ -180,14 +191,47 @@ gimp_help_set_help_data (GtkWidget *widget,
void
gimp_help (gchar *help_data)
{
ProcRecord *proc_rec;
static gchar *current_locale = "C";
if (help_data == NULL && help_browser != HELP_BROWSER_GIMP)
help_data = "welcome.html";
#ifdef DEBUG_HELP
g_print ("Help Page: %s\n", help_data);
#endif /* DEBUG_HELP */
switch (help_browser)
{
case HELP_BROWSER_GIMP:
gimp_help_internal (current_locale, help_data);
break;
case HELP_BROWSER_NETSCAPE:
gimp_help_netscape (current_locale, help_data);
break;
default:
break;
}
}
void
gimp_context_help (void)
{
if (tips_query)
gimp_help_tips_query_start (NULL, tips_query);
}
/*********************/
/* local functions */
/*********************/
void
gimp_help_internal (gchar *current_locale,
gchar *help_data)
{
ProcRecord *proc_rec;
/* Check if a help browser is already running */
proc_rec = procedural_db_lookup ("extension_gimp_help_browser_temp");
@ -234,15 +278,32 @@ gimp_help (gchar *help_data)
}
void
gimp_context_help (void)
gimp_help_netscape (gchar *current_locale,
gchar *help_data)
{
if (tips_query)
gimp_help_tips_query_start (NULL, tips_query);
}
Argument *return_vals;
gint nreturn_vals;
gchar *url;
/*********************/
/* local functions */
/*********************/
url = g_strconcat ("file:",
gimp_data_directory (),
"/help/",
current_locale, "/",
help_data,
NULL);
return_vals =
procedural_db_run_proc ("extension_web_browser",
&nreturn_vals,
PDB_INT32, RUN_NONINTERACTIVE,
PDB_STRING, url,
PDB_INT32, FALSE,
PDB_END);
procedural_db_destroy_args (return_vals, nreturn_vals);
g_free (url);
}
static void
gimp_help_callback (GtkWidget *widget,

View file

@ -38,13 +38,14 @@
#include "errors.h"
#include "fileops.h"
#include "general.h"
#include "gimpparasite.h"
#include "gimphelp.h"
#include "gimprc.h"
#include "menus.h"
#include "plug_in.h"
#include "gimage.h"
#include "session.h"
#include "tools.h"
#include "gimpparasite.h"
#include "libgimp/parasite.h"
#include "libgimp/gimpintl.h"
@ -75,7 +76,8 @@ typedef enum {
TT_XSESSIONINFO,
TT_XUNITINFO,
TT_XPARASITE,
TT_XNAVPREVSIZE
TT_XNAVPREVSIZE,
TT_XHELPBROWSER
} TokenType;
typedef struct _ParseFunc ParseFunc;
@ -161,6 +163,7 @@ int trust_dirty_flag = FALSE;
int use_help = TRUE;
int nav_window_per_display = FALSE;
int info_window_follows_mouse = FALSE;
int help_browser = HELP_BROWSER_GIMP;
extern char * module_db_load_inhibit;
@ -189,6 +192,7 @@ static int parse_menu_path (gpointer val1p, gpointer val2p);
static int parse_session_info (gpointer val1p, gpointer val2p);
static int parse_unit_info (gpointer val1p, gpointer val2p);
static int parse_parasite (gpointer val1p, gpointer val2p);
static int parse_help_broswer (gpointer val1p, gpointer val2p);
static int parse_proc_def (PlugInProcDef **proc_def);
static int parse_proc_arg (ProcArg *arg);
@ -211,6 +215,7 @@ static inline char* color_cube_to_str (gpointer val1p, gpointer val2p);
static inline char * preview_size_to_str (gpointer val1p, gpointer val2p);
static inline char * nav_preview_size_to_str (gpointer val1p, gpointer val2p);
static inline char * units_to_str (gpointer val1p, gpointer val2p);
static inline char * help_browser_to_str (gpointer val1p, gpointer val2p);
static char* transform_path (char *path, int destroy);
static void gimprc_set_token (char *token, char *value);
@ -317,7 +322,8 @@ static ParseFunc funcs[] =
{ "nav-window-per-display", TT_BOOLEAN, &nav_window_per_display, NULL },
{ "nav-window-follows-auto", TT_BOOLEAN, NULL, &nav_window_per_display },
{ "info-window-follows-mouse", TT_BOOLEAN, &info_window_follows_mouse, NULL },
{ "info-window-per-display", TT_BOOLEAN, NULL, &info_window_follows_mouse }
{ "info-window-per-display", TT_BOOLEAN, NULL, &info_window_follows_mouse },
{ "help-browser", TT_XHELPBROWSER, &help_browser, NULL }
};
static int nfuncs = sizeof (funcs) / sizeof (funcs[0]);
@ -844,6 +850,8 @@ parse_statement (void)
return parse_unit_info (funcs[i].val1p, funcs[i].val2p);
case TT_XPARASITE:
return parse_parasite (funcs[i].val1p, funcs[i].val2p);
case TT_XHELPBROWSER:
return parse_help_browser (funcs[i].val1p, funcs[i].val2p);
}
return parse_unknown (token_sym);
@ -2378,6 +2386,30 @@ error:
return res;
}
static int
parse_help_browser (gpointer val1p,
gpointer val2p)
{
int token;
token = peek_next_token ();
if (!token || token != TOKEN_SYMBOL)
return ERROR;
token = get_next_token ();
if (strcmp (token_sym, "gimp") == 0)
help_browser = HELP_BROWSER_GIMP;
else if (strcmp (token_sym, "netscape") == 0)
help_browser = HELP_BROWSER_NETSCAPE;
token = peek_next_token ();
if (!token || (token != TOKEN_RIGHT_PAREN))
return ERROR;
token = get_next_token ();
return OK;
}
static int
parse_unknown (char *token_sym)
{
@ -2474,6 +2506,8 @@ value_to_str (char *name)
return nav_preview_size_to_str (funcs[i].val1p, funcs[i].val2p);
case TT_XUNIT:
return units_to_str (funcs[i].val1p, funcs[i].val2p);
case TT_XHELPBROWSER:
return help_browser_to_str (funcs[i].val1p, funcs[i].val2p);
case TT_XPLUGIN:
case TT_XPLUGINDEF:
case TT_XMENUPATH:
@ -2651,6 +2685,16 @@ units_to_str (gpointer val1p,
return g_strdup (gimp_unit_get_identifier (*((GUnit*)val1p)));
}
static inline char *
help_browser_to_str (gpointer val1p,
gpointer val2p)
{
if (help_browser == HELP_BROWSER_NETSCAPE)
return g_strdup ("netscape");
else
return g_strdup ("gimp");
}
static void
add_gimp_directory_token (char *gimp_dir)
{

View file

@ -84,6 +84,7 @@ extern int trust_dirty_flag;
extern int use_help;
extern int nav_window_per_display;
extern int info_window_follows_mouse;
extern int help_browser;
/* function prototypes */
void parse_buffers_init (); /* this has to be called before any file

View file

@ -110,6 +110,7 @@ static int old_trust_dirty_flag;
static int old_use_help;
static int old_nav_window_per_display;
static int old_info_window_follows_mouse;
static int old_help_browser;
/* variables which can't be changed on the fly */
static int edit_stingy_memory_use;
@ -560,6 +561,8 @@ file_prefs_save_callback (GtkWidget *widget,
info_window_follows_mouse = edit_info_window_follows_mouse;
restart_notification = TRUE;
}
if (help_browser != old_help_browser)
update = g_list_append (update, "help-browser");
save_gimprc (&update, &remove);
@ -631,6 +634,7 @@ file_prefs_cancel_callback (GtkWidget *widget,
use_help = old_use_help;
nav_window_per_display = old_nav_window_per_display;
info_window_follows_mouse = old_info_window_follows_mouse;
help_browser = old_help_browser;
if (preview_size != old_preview_size)
{
@ -733,8 +737,10 @@ file_prefs_toggle_callback (GtkWidget *widget,
context_manager_set_global_paint_options (GTK_TOGGLE_BUTTON (widget)->active);
else if (data == &show_indicators)
show_indicators = GTK_TOGGLE_BUTTON (widget)->active;
else if (data == &thumbnail_mode || data == &interpolation_type ||
data == &trust_dirty_flag)
else if (data == &thumbnail_mode ||
data == &interpolation_type ||
data == &trust_dirty_flag ||
data == &help_browser)
{
val = data;
*val = (long) gtk_object_get_user_data (GTK_OBJECT (widget));
@ -1232,6 +1238,7 @@ file_pref_cmd_callback (GtkWidget *widget,
old_use_help = use_help;
old_nav_window_per_display = nav_window_per_display;
old_info_window_follows_mouse = info_window_follows_mouse;
old_help_browser = help_browser;
file_prefs_strset (&old_image_title_format, image_title_format);
file_prefs_strset (&old_temp_path, edit_temp_path);
@ -1645,6 +1652,26 @@ file_pref_cmd_callback (GtkWidget *widget,
&use_help);
gtk_widget_show (button);
vbox2 = file_prefs_frame_new (_("Help Browser"), GTK_BOX (vbox));
table = gtk_table_new (1, 2, FALSE);
gtk_container_set_border_width (GTK_CONTAINER (table), 2);
gtk_table_set_col_spacings (GTK_TABLE (table), 4);
gtk_box_pack_start (GTK_BOX (vbox2), table, FALSE, FALSE, 0);
gtk_widget_show (table);
optionmenu =
gimp_option_menu_new (file_prefs_toggle_callback,
(gpointer) help_browser,
_("Internal"), &help_browser,
(gpointer) HELP_BROWSER_GIMP,
_("Netscape"), &help_browser,
(gpointer) HELP_BROWSER_NETSCAPE,
NULL);
gimp_table_attach_aligned (GTK_TABLE (table), 0,
_("Help Browser to Use:"), 1.0, 0.5,
optionmenu, TRUE);
/* Interface / Image Windows */
vbox = file_prefs_notebook_append_page (GTK_NOTEBOOK (notebook),
_("Image Windows Settings"),

View file

@ -110,6 +110,7 @@ static int old_trust_dirty_flag;
static int old_use_help;
static int old_nav_window_per_display;
static int old_info_window_follows_mouse;
static int old_help_browser;
/* variables which can't be changed on the fly */
static int edit_stingy_memory_use;
@ -560,6 +561,8 @@ file_prefs_save_callback (GtkWidget *widget,
info_window_follows_mouse = edit_info_window_follows_mouse;
restart_notification = TRUE;
}
if (help_browser != old_help_browser)
update = g_list_append (update, "help-browser");
save_gimprc (&update, &remove);
@ -631,6 +634,7 @@ file_prefs_cancel_callback (GtkWidget *widget,
use_help = old_use_help;
nav_window_per_display = old_nav_window_per_display;
info_window_follows_mouse = old_info_window_follows_mouse;
help_browser = old_help_browser;
if (preview_size != old_preview_size)
{
@ -733,8 +737,10 @@ file_prefs_toggle_callback (GtkWidget *widget,
context_manager_set_global_paint_options (GTK_TOGGLE_BUTTON (widget)->active);
else if (data == &show_indicators)
show_indicators = GTK_TOGGLE_BUTTON (widget)->active;
else if (data == &thumbnail_mode || data == &interpolation_type ||
data == &trust_dirty_flag)
else if (data == &thumbnail_mode ||
data == &interpolation_type ||
data == &trust_dirty_flag ||
data == &help_browser)
{
val = data;
*val = (long) gtk_object_get_user_data (GTK_OBJECT (widget));
@ -1232,6 +1238,7 @@ file_pref_cmd_callback (GtkWidget *widget,
old_use_help = use_help;
old_nav_window_per_display = nav_window_per_display;
old_info_window_follows_mouse = info_window_follows_mouse;
old_help_browser = help_browser;
file_prefs_strset (&old_image_title_format, image_title_format);
file_prefs_strset (&old_temp_path, edit_temp_path);
@ -1645,6 +1652,26 @@ file_pref_cmd_callback (GtkWidget *widget,
&use_help);
gtk_widget_show (button);
vbox2 = file_prefs_frame_new (_("Help Browser"), GTK_BOX (vbox));
table = gtk_table_new (1, 2, FALSE);
gtk_container_set_border_width (GTK_CONTAINER (table), 2);
gtk_table_set_col_spacings (GTK_TABLE (table), 4);
gtk_box_pack_start (GTK_BOX (vbox2), table, FALSE, FALSE, 0);
gtk_widget_show (table);
optionmenu =
gimp_option_menu_new (file_prefs_toggle_callback,
(gpointer) help_browser,
_("Internal"), &help_browser,
(gpointer) HELP_BROWSER_GIMP,
_("Netscape"), &help_browser,
(gpointer) HELP_BROWSER_NETSCAPE,
NULL);
gimp_table_attach_aligned (GTK_TABLE (table), 0,
_("Help Browser to Use:"), 1.0, 0.5,
optionmenu, TRUE);
/* Interface / Image Windows */
vbox = file_prefs_notebook_append_page (GTK_NOTEBOOK (notebook),
_("Image Windows Settings"),

View file

@ -18,6 +18,12 @@
* 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"
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <gdk/gdkkeysyms.h>
#include <gtk/gtk.h>
@ -26,11 +32,16 @@
#include "plug_in.h"
#include "procedural_db.h"
#include "libgimp/gimpenv.h"
#include "libgimp/gimpintl.h"
#define DEBUG_HELP
/* local function prototypes */
static void gimp_help_internal (gchar *current_locale,
gchar *help_data);
static void gimp_help_netscape (gchar *current_locale,
gchar *help_data);
static void gimp_help_callback (GtkWidget *widget,
gpointer data);
static gint gimp_help_tips_query_idle_show_help (gpointer data);
@ -180,14 +191,47 @@ gimp_help_set_help_data (GtkWidget *widget,
void
gimp_help (gchar *help_data)
{
ProcRecord *proc_rec;
static gchar *current_locale = "C";
if (help_data == NULL && help_browser != HELP_BROWSER_GIMP)
help_data = "welcome.html";
#ifdef DEBUG_HELP
g_print ("Help Page: %s\n", help_data);
#endif /* DEBUG_HELP */
switch (help_browser)
{
case HELP_BROWSER_GIMP:
gimp_help_internal (current_locale, help_data);
break;
case HELP_BROWSER_NETSCAPE:
gimp_help_netscape (current_locale, help_data);
break;
default:
break;
}
}
void
gimp_context_help (void)
{
if (tips_query)
gimp_help_tips_query_start (NULL, tips_query);
}
/*********************/
/* local functions */
/*********************/
void
gimp_help_internal (gchar *current_locale,
gchar *help_data)
{
ProcRecord *proc_rec;
/* Check if a help browser is already running */
proc_rec = procedural_db_lookup ("extension_gimp_help_browser_temp");
@ -234,15 +278,32 @@ gimp_help (gchar *help_data)
}
void
gimp_context_help (void)
gimp_help_netscape (gchar *current_locale,
gchar *help_data)
{
if (tips_query)
gimp_help_tips_query_start (NULL, tips_query);
}
Argument *return_vals;
gint nreturn_vals;
gchar *url;
/*********************/
/* local functions */
/*********************/
url = g_strconcat ("file:",
gimp_data_directory (),
"/help/",
current_locale, "/",
help_data,
NULL);
return_vals =
procedural_db_run_proc ("extension_web_browser",
&nreturn_vals,
PDB_INT32, RUN_NONINTERACTIVE,
PDB_STRING, url,
PDB_INT32, FALSE,
PDB_END);
procedural_db_destroy_args (return_vals, nreturn_vals);
g_free (url);
}
static void
gimp_help_callback (GtkWidget *widget,

View file

@ -292,6 +292,13 @@
# Just uncomment the following line if you trust the dirty flag.
# (trust-dirty-flag)
# Help browser
# Determines which program to use as browser for the GIMP help pages.
# Possible values are "gimp" which means the built-in help browser
# which comes with GIMP as a plug-in and "netscape" which will show
# the help pages using the "netscape-remote" command.
(help-browser gimp)
# Gfig search path
# This path will be searched for Gfig figures when you use the Gfig plug-in.
(gfig-path "${gimp_dir}/gfig:${gimp_data_dir}/gfig")

View file

@ -292,6 +292,13 @@
# Just uncomment the following line if you trust the dirty flag.
# (trust-dirty-flag)
# Help browser
# Determines which program to use as browser for the GIMP help pages.
# Possible values are "gimp" which means the built-in help browser
# which comes with GIMP as a plug-in and "netscape" which will show
# the help pages using the "netscape-remote" command.
(help-browser gimp)
# Gfig search path
# This path will be searched for Gfig figures when you use the Gfig plug-in.
(gfig-path "${gimp_dir}/gfig:${gimp_data_dir}/gfig")