Bug 767830 - Help browser does not launch on OS X

Try harder to show help when webkit is missing or the help browser
won't start:

- offer to switch to the web browser when the help browser is
  present, but won't start for some reason
- in prefs, don't bother showing the help browser GUI when webkit
  is missing, otherwise show a warning label if the help browser
  is not installed even though webkit is there. Switch to the web
  browser in both cases (modified patch from lisanet)
- add OS X replacement for gtk_show_uri() in plug-in-web-browser
  (modified patch from lisanet)
This commit is contained in:
Michael Natterer 2016-09-06 20:51:47 +02:00
parent b7d41c83c6
commit 308efbb514
7 changed files with 155 additions and 52 deletions

View File

@ -293,6 +293,14 @@ prefs_response (GtkWidget *widget,
config_copy = g_object_get_data (G_OBJECT (dialog), "config-copy");
gimp_config_reset (config_copy);
/* don't use the default value if there is no help browser */
if (! gimp_help_browser_is_installed (gimp))
{
g_object_set (config_copy,
"help-browser", GIMP_HELP_BROWSER_WEB_BROWSER,
NULL);
}
}
gtk_widget_destroy (confirm);
@ -798,6 +806,35 @@ prefs_table_new (gint rows,
return table;
}
static GtkWidget *
prefs_hint_box_new (const gchar *icon_name,
const gchar *text)
{
GtkWidget *hbox;
GtkWidget *image;
GtkWidget *label;
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_BUTTON);
gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
gtk_widget_show (image);
label = gtk_label_new (text);
gimp_label_set_attributes (GTK_LABEL (label),
PANGO_ATTR_STYLE, PANGO_STYLE_ITALIC,
-1);
gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
gtk_widget_show (label);
gtk_widget_show (hbox);
return hbox;
}
static GtkWidget *
prefs_button_add (const gchar *icon_name,
const gchar *label,
@ -2191,59 +2228,64 @@ prefs_dialog_new (Gimp *gimp,
_("Show help _buttons"),
GTK_BOX (vbox2));
{
GtkWidget *combo;
GtkWidget *hbox;
GtkWidget *image;
GtkWidget *label;
const gchar *icon;
const gchar *text;
table = prefs_table_new (2, GTK_CONTAINER (vbox2));
button = prefs_boolean_combo_box_add (object, "user-manual-online",
_("Use the online version"),
_("Use a locally installed copy"),
_("User manual:"),
GTK_TABLE (table), 0, size_group);
gimp_help_set_help_data (button, NULL, NULL);
table = prefs_table_new (2, GTK_CONTAINER (vbox2));
combo = prefs_boolean_combo_box_add (object, "user-manual-online",
_("Use the online version"),
_("Use a locally installed copy"),
_("User manual:"),
GTK_TABLE (table), 0, size_group);
gimp_help_set_help_data (combo, NULL, NULL);
if (gimp_help_user_manual_is_installed (gimp))
{
hbox = prefs_hint_box_new (GIMP_STOCK_INFO,
_("There's a local installation "
"of the user manual."));
}
else
{
hbox = prefs_hint_box_new (GIMP_STOCK_WARNING,
_("The user manual is not installed "
"locally."));
}
if (gimp_help_user_manual_is_installed (gimp))
{
icon = GIMP_STOCK_INFO;
text = _("There's a local installation of the user manual.");
}
else
{
icon = GIMP_STOCK_WARNING;
text = _("The user manual is not installed locally.");
}
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
gtk_table_attach_defaults (GTK_TABLE (table), hbox, 1, 2, 1, 2);
gtk_widget_show (hbox);
image = gtk_image_new_from_icon_name (icon, GTK_ICON_SIZE_BUTTON);
gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
gtk_widget_show (image);
label = gtk_label_new (text);
gimp_label_set_attributes (GTK_LABEL (label),
PANGO_ATTR_STYLE, PANGO_STYLE_ITALIC,
-1);
gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
gtk_widget_show (label);
}
gtk_table_attach_defaults (GTK_TABLE (table), hbox, 1, 2, 1, 2);
gtk_widget_show (hbox);
/* Help Browser */
#ifdef HAVE_WEBKIT
/* If there is no webkit available, assume we are on a platform
* that doesn't use the help browser, so don't bother showing
* the combo.
*/
vbox2 = prefs_frame_new (_("Help Browser"), GTK_CONTAINER (vbox), FALSE);
table = prefs_table_new (1, GTK_CONTAINER (vbox2));
prefs_enum_combo_box_add (object, "help-browser", 0, 0,
_("H_elp browser to use:"),
GTK_TABLE (table), 0, size_group);
if (gimp_help_browser_is_installed (gimp))
{
table = prefs_table_new (1, GTK_CONTAINER (vbox2));
button = prefs_enum_combo_box_add (object, "help-browser", 0, 0,
_("H_elp browser to use:"),
GTK_TABLE (table), 0, size_group);
}
else
{
hbox = prefs_hint_box_new (GIMP_STOCK_WARNING,
_("The GIMP help browser doesn't seem to "
"be installed. Using the web browser "
"instead."));
gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0);
gtk_widget_show (hbox);
g_object_set (config,
"help-browser", GIMP_HELP_BROWSER_WEB_BROWSER,
NULL);
}
#else
g_object_set (config,
"help-browser", GIMP_HELP_BROWSER_WEB_BROWSER,
NULL);
#endif /* HAVE_WEBKIT */
/* Action Search */
vbox2 = prefs_frame_new (_("Action Search"), GTK_CONTAINER (vbox), FALSE);

View File

@ -137,6 +137,17 @@ gimp_help_show (Gimp *gimp,
}
}
gboolean
gimp_help_browser_is_installed (Gimp *gimp)
{
g_return_val_if_fail (GIMP_IS_GIMP (gimp), FALSE);
if (gimp_pdb_lookup_procedure (gimp->pdb, "extension-gimp-help-browser"))
return TRUE;
return FALSE;
}
gboolean
gimp_help_user_manual_is_installed (Gimp *gimp)
{
@ -347,7 +358,8 @@ gimp_help_browser (Gimp *gimp,
_("Help browser doesn't start"),
_("Could not start the GIMP help browser "
"plug-in."),
NULL);
_("You may instead use the web browser "
"for reading the help pages."));
busy = FALSE;
return FALSE;

View File

@ -32,6 +32,10 @@ void gimp_help_show (Gimp *gimp,
const gchar *help_id);
/* checks if the help browser is available
*/
gboolean gimp_help_browser_is_installed (Gimp *gimp);
/* checks if the user manual is installed locally
*/
gboolean gimp_help_user_manual_is_installed (Gimp *gimp);

View File

@ -13,6 +13,11 @@ else
libm = -lm
endif
if PLATFORM_OSX
xobjective_c = "-xobjective-c"
framework_cocoa = -framework Cocoa
endif
if HAVE_WINDRES
include $(top_srcdir)/build/windows/gimprc-plug-ins.rule
include gimprc.common
@ -1762,6 +1767,10 @@ warp_LDADD = \
$(INTLLIBS) \
$(warp_RC)
web_browser_LDFLAGS = $(framework_cocoa)
web_browser_CFLAGS = $(xobjective_c)
web_browser_SOURCES = \
web-browser.c

View File

@ -64,6 +64,11 @@ else
libm = -lm
endif
if PLATFORM_OSX
xobjective_c = "-xobjective-c"
framework_cocoa = -framework Cocoa
endif
if HAVE_WINDRES
include \$(top_srcdir)/build/windows/gimprc-plug-ins.rule
include $rcfile
@ -161,6 +166,15 @@ foreach (sort keys %plugins) {
$optlib = "\n\t\$(" . $plugins{$_}->{libs} . ")\t\t\\";
}
if (exists $plugins{$_}->{ldflags}) {
my $ldflags = $plugins{$_}->{ldflags};
print MK <<EOT;
${makename}_LDFLAGS = $ldflags
EOT
}
if (exists $plugins{$_}->{cflags}) {
my $cflags = $plugins{$_}->{cflags};
my $cflagsvalue = $cflags =~ /FLAGS/ ? "\$($cflags)" : $cflags;

View File

@ -90,6 +90,6 @@
'unsharp-mask' => { ui => 1 },
'van-gogh-lic' => { ui => 1 },
'warp' => { ui => 1 },
'web-browser' => { ui => 1 },
'web-browser' => { ui => 1, ldflags => '$(framework_cocoa)', cflags => '$(xobjective_c)' },
'web-page' => { ui => 1, optional => 1, libs => 'WEBKIT_LIBS', cflags => 'WEBKIT_CFLAGS' }
);

View File

@ -24,14 +24,19 @@
#include <gtk/gtk.h>
#ifdef PLATFORM_OSX
#import <Cocoa/Cocoa.h>
#endif
#ifdef G_OS_WIN32
#include <windows.h>
#endif
#include <libgimp/gimp.h>
#include <libgimp/gimpui.h>
#include "libgimp/stdplugins-intl.h"
#ifdef G_OS_WIN32
#include <windows.h>
#endif
#define PLUG_IN_PROC "plug-in-web-browser"
#define PLUG_IN_BINARY "web-browser"
@ -122,6 +127,7 @@ browser_open_url (const gchar *url,
GError **error)
{
#ifdef G_OS_WIN32
HINSTANCE hinst = ShellExecute (GetDesktopWindow(),
"open", url, NULL, NULL, SW_SHOW);
@ -180,12 +186,28 @@ browser_open_url (const gchar *url,
}
return TRUE;
#elif defined(PLATFORM_OSX)
NSURL *ns_url;
gboolean retval;
@autoreleasepool
{
ns_url = [NSURL URLWithString: [NSString stringWithUTF8String: url]];
retval = [[NSWorkspace sharedWorkspace] openURL: ns_url];
}
return retval;
#else
gimp_ui_init (PLUG_IN_BINARY, FALSE);
return gtk_show_uri (gdk_screen_get_default (),
url,
gtk_get_current_event_time(),
error);
#endif
}