Applied a slightly modified patch from Róman Joost as attached to bug

2008-08-04  Sven Neumann  <sven@gimp.org>

	Applied a slightly modified patch from Róman Joost as attached 
to
	bug #545963. This add links to the user manual to the tips 
dialog:

	* data/tips/gimp-tips.dtd
	* data/tips/gimp-tips.xml.in: add optional help IDs to the tips.

	* app/dialogs/tips-dialog.c

	* app/dialogs/tips-parser.[ch]: parse the help IDs from the tips
	file and show a "Learn more" link in the tips dialog.


svn path=/trunk/; revision=26361
This commit is contained in:
Sven Neumann 2008-08-04 13:56:07 +00:00 committed by Sven Neumann
parent 6f8f412fd4
commit 083c48d2d2
6 changed files with 162 additions and 73 deletions

View file

@ -1,3 +1,16 @@
2008-08-04 Sven Neumann <sven@gimp.org>
Applied a slightly modified patch from Róman Joost as attached to
bug #545963. This add links to the user manual to the tips dialog:
* data/tips/gimp-tips.dtd
* data/tips/gimp-tips.xml.in: add optional help IDs to the tips.
* app/dialogs/tips-dialog.c
* app/dialogs/tips-parser.[ch]: parse the help IDs from the tips
file and show a "Learn more" link in the tips dialog.
2008-08-03 Martin Nordholts <martinn@svn.gnome.org> 2008-08-03 Martin Nordholts <martinn@svn.gnome.org>
* app/display/gimpdisplayshell.c (gimp_display_shell_new): Center * app/display/gimpdisplayshell.c (gimp_display_shell_new): Center

View file

@ -36,7 +36,6 @@
#include "gimp-intl.h" #include "gimp-intl.h"
enum enum
{ {
RESPONSE_PREVIOUS = 1, RESPONSE_PREVIOUS = 1,
@ -47,11 +46,14 @@ static void tips_dialog_set_tip (GimpTip *tip);
static void tips_dialog_response (GtkWidget *dialog, static void tips_dialog_response (GtkWidget *dialog,
gint response); gint response);
static void tips_dialog_destroy (GtkWidget *widget, static void tips_dialog_destroy (GtkWidget *widget,
gpointer data); GimpGuiConfig *config);
static void more_button_clicked (GtkWidget *button,
Gimp *gimp);
static GtkWidget *tips_dialog = NULL; static GtkWidget *tips_dialog = NULL;
static GtkWidget *thetip_label = NULL; static GtkWidget *tip_label = NULL;
static GtkWidget *more_button = NULL;
static GList *tips = NULL; static GList *tips = NULL;
static GList *current_tip = NULL; static GList *current_tip = NULL;
@ -164,21 +166,38 @@ tips_dialog_create (Gimp *gimp)
gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0);
gtk_widget_show (hbox); gtk_widget_show (hbox);
thetip_label = gtk_label_new (NULL); vbox = gtk_vbox_new (FALSE, 6);
gtk_label_set_selectable (GTK_LABEL (thetip_label), TRUE); gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
gtk_label_set_justify (GTK_LABEL (thetip_label), GTK_JUSTIFY_LEFT); gtk_widget_show (vbox);
gtk_label_set_line_wrap (GTK_LABEL (thetip_label), TRUE);
gtk_misc_set_alignment (GTK_MISC (thetip_label), 0.5, 0.5);
gtk_box_pack_start (GTK_BOX (hbox), thetip_label, TRUE, TRUE, 0);
gtk_widget_show (thetip_label);
image = gtk_image_new_from_stock (GIMP_STOCK_INFO, GTK_ICON_SIZE_DIALOG); image = gtk_image_new_from_stock (GIMP_STOCK_INFO, GTK_ICON_SIZE_DIALOG);
gtk_misc_set_alignment (GTK_MISC (image), 0.5, 0.5); gtk_misc_set_alignment (GTK_MISC (image), 0.5, 0.0);
gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
gtk_widget_show (image); gtk_widget_show (image);
gtk_container_set_focus_chain (GTK_CONTAINER (hbox), NULL); gtk_container_set_focus_chain (GTK_CONTAINER (hbox), NULL);
tip_label = gtk_label_new (NULL);
gtk_label_set_selectable (GTK_LABEL (tip_label), TRUE);
gtk_label_set_justify (GTK_LABEL (tip_label), GTK_JUSTIFY_LEFT);
gtk_label_set_line_wrap (GTK_LABEL (tip_label), TRUE);
gtk_misc_set_alignment (GTK_MISC (tip_label), 0.5, 0.0);
gtk_box_pack_start (GTK_BOX (vbox), tip_label, TRUE, TRUE, 0);
gtk_widget_show (tip_label);
hbox = gtk_hbox_new (FALSE, 0);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
gtk_widget_show (hbox);
more_button = gtk_link_button_new_with_label ("http://docs.gimp.org/",
_("Learn more"));
gtk_widget_show (more_button);
gtk_box_pack_start (GTK_BOX (hbox), more_button, FALSE, FALSE, 0);
g_signal_connect (more_button, "clicked",
G_CALLBACK (more_button_clicked),
gimp);
tips_dialog_set_tip (current_tip->data); tips_dialog_set_tip (current_tip->data);
return tips_dialog; return tips_dialog;
@ -186,10 +205,8 @@ tips_dialog_create (Gimp *gimp)
static void static void
tips_dialog_destroy (GtkWidget *widget, tips_dialog_destroy (GtkWidget *widget,
gpointer data) GimpGuiConfig *config)
{ {
GimpGuiConfig *config = GIMP_GUI_CONFIG (data);
/* the last-shown-tip is saved in sessionrc */ /* the last-shown-tip is saved in sessionrc */
config->last_tip = g_list_position (tips, current_tip); config->last_tip = g_list_position (tips, current_tip);
@ -227,5 +244,21 @@ tips_dialog_set_tip (GimpTip *tip)
{ {
g_return_if_fail (tip != NULL); g_return_if_fail (tip != NULL);
gtk_label_set_markup (GTK_LABEL (thetip_label), tip->thetip); gtk_label_set_markup (GTK_LABEL (tip_label), tip->text);
/* set the URI to unset the "visited" state */
gtk_link_button_set_uri (GTK_LINK_BUTTON (more_button),
"http://docs.gimp.org/");
gtk_widget_set_sensitive (more_button, tip->help_id != NULL);
}
static void
more_button_clicked (GtkWidget *button,
Gimp *gimp)
{
GimpTip *tip = current_tip->data;
if (tip->help_id)
gimp_help (gimp, NULL, NULL, tip->help_id);
} }

View file

@ -54,6 +54,7 @@ typedef struct
TipsParserState state; TipsParserState state;
TipsParserState last_known_state; TipsParserState last_known_state;
const gchar *locale; const gchar *locale;
const gchar *help_id;
TipsParserLocaleState locale_state; TipsParserLocaleState locale_state;
gint markup_depth; gint markup_depth;
gint unknown_depth; gint unknown_depth;
@ -85,6 +86,11 @@ static void tips_parser_end_markup (TipsParser *parser,
const gchar *markup_name); const gchar *markup_name);
static void tips_parser_start_unknown (TipsParser *parser); static void tips_parser_start_unknown (TipsParser *parser);
static void tips_parser_end_unknown (TipsParser *parser); static void tips_parser_end_unknown (TipsParser *parser);
static gchar * tips_parser_parse_help_id (TipsParser *parser,
const gchar **names,
const gchar **values);
static void tips_parser_parse_locale (TipsParser *parser, static void tips_parser_parse_locale (TipsParser *parser,
const gchar **names, const gchar **names,
const gchar **values); const gchar **values);
@ -129,7 +135,7 @@ gimp_tip_new (const gchar *title,
va_end (args); va_end (args);
} }
tip->thetip = g_string_free (str, FALSE); tip->text = g_string_free (str, FALSE);
return tip; return tip;
} }
@ -140,7 +146,9 @@ gimp_tip_free (GimpTip *tip)
if (! tip) if (! tip)
return; return;
g_free (tip->thetip); g_free (tip->text);
g_free (tip->help_id);
g_slice_free (GimpTip, tip); g_slice_free (GimpTip, tip);
} }
@ -230,9 +238,13 @@ tips_parser_start_element (GMarkupParseContext *context,
{ {
case TIPS_START: case TIPS_START:
if (strcmp (element_name, "gimp-tips") == 0) if (strcmp (element_name, "gimp-tips") == 0)
{
parser->state = TIPS_IN_TIPS; parser->state = TIPS_IN_TIPS;
}
else else
{
tips_parser_start_unknown (parser); tips_parser_start_unknown (parser);
}
break; break;
case TIPS_IN_TIPS: case TIPS_IN_TIPS:
@ -240,9 +252,14 @@ tips_parser_start_element (GMarkupParseContext *context,
{ {
parser->state = TIPS_IN_TIP; parser->state = TIPS_IN_TIP;
parser->current_tip = g_slice_new0 (GimpTip); parser->current_tip = g_slice_new0 (GimpTip);
parser->current_tip->help_id = tips_parser_parse_help_id (parser,
attribute_names,
attribute_values);
} }
else else
{
tips_parser_start_unknown (parser); tips_parser_start_unknown (parser);
}
break; break;
case TIPS_IN_TIP: case TIPS_IN_TIP:
@ -252,16 +269,22 @@ tips_parser_start_element (GMarkupParseContext *context,
tips_parser_parse_locale (parser, attribute_names, attribute_values); tips_parser_parse_locale (parser, attribute_names, attribute_values);
} }
else else
{
tips_parser_start_unknown (parser); tips_parser_start_unknown (parser);
}
break; break;
case TIPS_IN_THETIP: case TIPS_IN_THETIP:
if (strcmp (element_name, "b" ) == 0 || if (strcmp (element_name, "b" ) == 0 ||
strcmp (element_name, "big") == 0 || strcmp (element_name, "big") == 0 ||
strcmp (element_name, "tt" ) == 0) strcmp (element_name, "tt" ) == 0)
{
tips_parser_start_markup (parser, element_name); tips_parser_start_markup (parser, element_name);
}
else else
{
tips_parser_start_unknown (parser); tips_parser_start_unknown (parser);
}
break; break;
case TIPS_IN_UNKNOWN: case TIPS_IN_UNKNOWN:
@ -297,7 +320,7 @@ tips_parser_end_element (GMarkupParseContext *context,
case TIPS_IN_THETIP: case TIPS_IN_THETIP:
if (parser->markup_depth == 0) if (parser->markup_depth == 0)
{ {
tips_parser_set_by_locale (parser, &parser->current_tip->thetip); tips_parser_set_by_locale (parser, &parser->current_tip->text);
g_string_truncate (parser->value, 0); g_string_truncate (parser->value, 0);
parser->state = TIPS_IN_TIP; parser->state = TIPS_IN_TIP;
} }
@ -387,6 +410,23 @@ tips_parser_end_unknown (TipsParser *parser)
parser->state = parser->last_known_state; parser->state = parser->last_known_state;
} }
static gchar *
tips_parser_parse_help_id (TipsParser *parser,
const gchar **names,
const gchar **values)
{
while (*names && *values)
{
if (strcmp (*names, "help") == 0 && **values)
return g_strdup (*values);
names++;
values++;
}
return NULL;
}
static void static void
tips_parser_parse_locale (TipsParser *parser, tips_parser_parse_locale (TipsParser *parser,
const gchar **names, const gchar **names,
@ -435,3 +475,4 @@ tips_parser_set_by_locale (TipsParser *parser,
break; break;
} }
} }

View file

@ -27,7 +27,8 @@ typedef struct _GimpTip GimpTip;
struct _GimpTip struct _GimpTip
{ {
gchar *thetip; gchar *text;
gchar *help_id;
}; };

View file

@ -4,6 +4,7 @@
<!ELEMENT tip (thetip+)> <!ELEMENT tip (thetip+)>
<!ATTLIST tip level (start|beginner|intermediate|advanced) #REQUIRED> <!ATTLIST tip level (start|beginner|intermediate|advanced) #REQUIRED>
<!ATTLIST tip help CDATA #IMPLIED>
<!ENTITY % markup "(#PCDATA|b|big|tt)*"> <!ENTITY % markup "(#PCDATA|b|big|tt)*">

View file

@ -20,20 +20,20 @@
pressing the F1 key at any time. This also works inside the menus. pressing the F1 key at any time. This also works inside the menus.
</_thetip> </_thetip>
</tip> </tip>
<tip level="beginner"> <tip level="beginner" help="gimp-layer-dialog">
<_thetip> <_thetip>
GIMP uses layers to let you organize your image. Think of them GIMP uses layers to let you organize your image. Think of them
as a stack of slides or filters, such that looking through them you as a stack of slides or filters, such that looking through them you
see a composite of their contents. see a composite of their contents.
</_thetip> </_thetip>
</tip> </tip>
<tip level="beginner"> <tip level="beginner" help="gimp-layer-menu">
<_thetip> <_thetip>
You can perform many layer operations by right-clicking on the text You can perform many layer operations by right-clicking on the text
label of a layer in the Layers dialog. label of a layer in the Layers dialog.
</_thetip> </_thetip>
</tip> </tip>
<tip level="beginner"> <tip level="beginner" help="gimp-file-save">
<_thetip> <_thetip>
When you save an image to work on it again later, try using XCF, When you save an image to work on it again later, try using XCF,
GIMP's native file format (use the file extension <tt>.xcf</tt>). GIMP's native file format (use the file extension <tt>.xcf</tt>).
@ -41,14 +41,14 @@
Once a project is completed, you can save it as JPEG, PNG, GIF, ... Once a project is completed, you can save it as JPEG, PNG, GIF, ...
</_thetip> </_thetip>
</tip> </tip>
<tip level="beginner"> <tip level="beginner" help="gimp-image-flatten">
<_thetip> <_thetip>
Most plug-ins work on the current layer of the current image. In Most plug-ins work on the current layer of the current image. In
some cases, you will have to merge all layers (Image→Flatten Image) some cases, you will have to merge all layers (Image→Flatten Image)
if you want the plug-in to work on the whole image. if you want the plug-in to work on the whole image.
</_thetip> </_thetip>
</tip> </tip>
<tip level="beginner"> <tip level="beginner" help="gimp-layer-alpha-add">
<_thetip> <_thetip>
If a layer's name in the Layers dialog is displayed in <b>bold</b>, If a layer's name in the Layers dialog is displayed in <b>bold</b>,
this layer doesn't have an alpha-channel. You can add an alpha-channel this layer doesn't have an alpha-channel. You can add an alpha-channel
@ -91,14 +91,14 @@
(or optionally hold <tt>Spacebar</tt> while you move the mouse). (or optionally hold <tt>Spacebar</tt> while you move the mouse).
</_thetip> </_thetip>
</tip> </tip>
<tip level="intermediate"> <tip level="intermediate" help="gimp-concepts-image-grid">
<_thetip> <_thetip>
Click and drag on a ruler to place a guide on an image. All Click and drag on a ruler to place a guide on an image. All
dragged selections will snap to the guides. You can remove dragged selections will snap to the guides. You can remove
guides by dragging them off the image with the Move tool. guides by dragging them off the image with the Move tool.
</_thetip> </_thetip>
</tip> </tip>
<tip level="intermediate"> <tip level="intermediate" help="gimp-file-new">
<_thetip> <_thetip>
You can drag a layer from the Layers dialog and drop it onto the You can drag a layer from the Layers dialog and drop it onto the
toolbox. This will create a new image containing only that layer. toolbox. This will create a new image containing only that layer.
@ -128,28 +128,28 @@
current one. current one.
</_thetip> </_thetip>
</tip> </tip>
<tip level="intermediate"> <tip level="intermediate" help="gimp-selection-stroke">
<_thetip> <_thetip>
You can draw simple squares or circles using Edit→Stroke Selection. You can draw simple squares or circles using Edit→Stroke Selection.
It strokes the edge of your current selection. More complex shapes It strokes the edge of your current selection. More complex shapes
can be drawn using the Path tool or with Filters→Render→Gfig. can be drawn using the Path tool or with Filters→Render→Gfig.
</_thetip> </_thetip>
</tip> </tip>
<tip level="intermediate"> <tip level="intermediate" help="gimp-path-stroke">
<_thetip> <_thetip>
If you stroke a path (Edit→Stroke Path), the paint tools can If you stroke a path (Edit→Stroke Path), the paint tools can
be used with their current settings. You can use the Paintbrush in be used with their current settings. You can use the Paintbrush in
gradient mode or even the Eraser or the Smudge tool. gradient mode or even the Eraser or the Smudge tool.
</_thetip> </_thetip>
</tip> </tip>
<tip level="intermediate"> <tip level="intermediate" help="gimp-using-paths">
<_thetip> <_thetip>
You can create and edit complex selections using the Path tool. You can create and edit complex selections using the Path tool.
The Paths dialog allows you to work on multiple paths and to convert The Paths dialog allows you to work on multiple paths and to convert
them to selections. them to selections.
</_thetip> </_thetip>
</tip> </tip>
<tip level="intermediate"> <tip level="intermediate" help="gimp-using-quickmask">
<_thetip> <_thetip>
You can use the paint tools to change the selection. Click on the You can use the paint tools to change the selection. Click on the
&quot;Quick Mask&quot; button at the bottom left of an image window. &quot;Quick Mask&quot; button at the bottom left of an image window.
@ -157,7 +157,7 @@
again to convert it back to a normal selection. again to convert it back to a normal selection.
</_thetip> </_thetip>
</tip> </tip>
<tip level="intermediate"> <tip level="intermediate" help="gimp-channel-dialog">
<_thetip> <_thetip>
You can save a selection to a channel (Select→Save to Channel) and You can save a selection to a channel (Select→Save to Channel) and
then modify this channel with any paint tools. Using the buttons in then modify this channel with any paint tools. Using the buttons in
@ -208,7 +208,7 @@
an image (if your window manager doesn't trap those keys...). an image (if your window manager doesn't trap those keys...).
</_thetip> </_thetip>
</tip> </tip>
<tip level="advanced"> <tip level="advanced" help="gimp-tool-bucket-fill">
<_thetip> <_thetip>
<tt>Ctrl</tt>-click with the Bucket Fill tool to have it use <tt>Ctrl</tt>-click with the Bucket Fill tool to have it use
the background color instead of the foreground color. the background color instead of the foreground color.
@ -216,7 +216,7 @@
sets the background color instead of the foreground color. sets the background color instead of the foreground color.
</_thetip> </_thetip>
</tip> </tip>
<tip level="advanced"> <tip level="advanced" help="gimp-tools-transform">
<_thetip> <_thetip>
<tt>Ctrl</tt>-drag with the Rotate tool will constrain the <tt>Ctrl</tt>-drag with the Rotate tool will constrain the
rotation to 15 degree angles. rotation to 15 degree angles.