data/tips/gimp-tips.dtd data/tips/gimp-tips.xml.in reverted some of the

2008-03-28  Sven Neumann  <sven@gimp.org>

	* data/tips/gimp-tips.dtd
	* data/tips/gimp-tips.xml.in
	* app/dialogs/tips-parser.[ch]: reverted some of the changes 
from
	yesterday. The simplification went too far and we inadvertently
	lost an important feature.


svn path=/trunk/; revision=25269
This commit is contained in:
Sven Neumann 2008-03-28 07:34:38 +00:00 committed by Sven Neumann
parent cdb1dd1709
commit 848a3e197f
4 changed files with 321 additions and 251 deletions

View File

@ -1,7 +1,7 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* tips-parser.c -- Parse the gimp-tips.xml file.
* tips-parser.c - Parse the gimp-tips.xml file.
* Copyright (C) 2002, 2008 Sven Neumann <sven@gimp.org>
*
* This program is free software; you can redistribute it and/or modify
@ -38,15 +38,23 @@ typedef enum
TIPS_START,
TIPS_IN_TIPS,
TIPS_IN_TIP,
TIPS_IN_THETIP,
TIPS_IN_UNKNOWN
} TipsParserState;
typedef enum
{
TIPS_LOCALE_NONE,
TIPS_LOCALE_MATCH,
TIPS_LOCALE_MISMATCH
} TipsParserLocaleState;
typedef struct
{
TipsParserState state;
TipsParserState last_known_state;
const gchar *locale;
gboolean locale_match;
TipsParserLocaleState locale_state;
gint markup_depth;
gint unknown_depth;
GString *value;
@ -80,7 +88,7 @@ static void tips_parser_end_unknown (TipsParser *parser);
static void tips_parser_parse_locale (TipsParser *parser,
const gchar **names,
const gchar **values);
static gboolean tips_parser_set_by_locale (TipsParser *parser,
static void tips_parser_set_by_locale (TipsParser *parser,
gchar **dest);
@ -208,13 +216,9 @@ tips_parser_start_element (GMarkupParseContext *context,
{
case TIPS_START:
if (strcmp (element_name, "gimp-tips") == 0)
{
parser->state = TIPS_IN_TIPS;
}
else
{
tips_parser_start_unknown (parser);
}
break;
case TIPS_IN_TIPS:
@ -222,26 +226,29 @@ tips_parser_start_element (GMarkupParseContext *context,
{
parser->state = TIPS_IN_TIP;
parser->current_tip = g_slice_new0 (GimpTip);
tips_parser_parse_locale (parser, attribute_names, attribute_values);
}
else
{
tips_parser_start_unknown (parser);
}
break;
case TIPS_IN_TIP:
if (strcmp (element_name, "thetip") == 0)
{
parser->state = TIPS_IN_THETIP;
tips_parser_parse_locale (parser, attribute_names, attribute_values);
}
else
tips_parser_start_unknown (parser);
break;
case TIPS_IN_THETIP:
if (strcmp (element_name, "b" ) == 0 ||
strcmp (element_name, "big") == 0 ||
strcmp (element_name, "tt" ) == 0)
{
tips_parser_start_markup (parser, element_name);
}
else
{
tips_parser_start_unknown (parser);
}
break;
case TIPS_IN_UNKNOWN:
tips_parser_start_unknown (parser);
@ -268,21 +275,20 @@ tips_parser_end_element (GMarkupParseContext *context,
break;
case TIPS_IN_TIP:
if (parser->markup_depth == 0)
{
if (tips_parser_set_by_locale (parser, &parser->current_tip->thetip))
{
parser->tips = g_list_prepend (parser->tips, parser->current_tip);
parser->current_tip = NULL;
}
g_string_truncate (parser->value, 0);
parser->state = TIPS_IN_TIPS;
break;
case TIPS_IN_THETIP:
if (parser->markup_depth == 0)
{
tips_parser_set_by_locale (parser, &parser->current_tip->thetip);
g_string_truncate (parser->value, 0);
parser->state = TIPS_IN_TIP;
}
else
{
tips_parser_end_markup (parser, element_name);
}
break;
case TIPS_IN_UNKNOWN:
@ -302,8 +308,8 @@ tips_parser_characters (GMarkupParseContext *context,
switch (parser->state)
{
case TIPS_IN_TIP:
if (parser->locale_match)
case TIPS_IN_THETIP:
if (parser->locale_state != TIPS_LOCALE_MISMATCH)
{
gint i;
@ -323,7 +329,6 @@ tips_parser_characters (GMarkupParseContext *context,
}
}
break;
default:
break;
}
@ -373,16 +378,15 @@ tips_parser_parse_locale (TipsParser *parser,
const gchar **names,
const gchar **values)
{
parser->locale_match = (parser->locale == NULL);
parser->locale_state = TIPS_LOCALE_NONE;
while (*names && *values)
{
if (strcmp (*names, "xml:lang") == 0 && **values)
{
if (parser->locale)
parser->locale_match = (strcmp (*values, parser->locale) == 0);
else
parser->locale_match = FALSE;
parser->locale_state = (parser->locale &&
strcmp (*values, parser->locale) == 0 ?
TIPS_LOCALE_MATCH : TIPS_LOCALE_MISMATCH);
}
names++;
@ -390,16 +394,30 @@ tips_parser_parse_locale (TipsParser *parser,
}
}
static gboolean
static void
tips_parser_set_by_locale (TipsParser *parser,
gchar **dest)
{
if (parser->locale_match)
switch (parser->locale_state)
{
case TIPS_LOCALE_NONE:
if (!parser->locale)
{
g_free (*dest);
*dest = g_strdup (parser->value->str);
return TRUE;
}
else if (*dest == NULL)
{
*dest = g_strdup (parser->value->str);
}
break;
return FALSE;
case TIPS_LOCALE_MATCH:
g_free (*dest);
*dest = g_strdup (parser->value->str);
break;
case TIPS_LOCALE_MISMATCH:
break;
}
}

View File

@ -1,7 +1,7 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* tips-parser.h -- Parse the gimp-tips.xml file.
* tips-parser.h - Parse the gimp-tips.xml file.
* Copyright (C) 2002, 2008 Sven Neumann <sven@gimp.org>
*
* This program is free software; you can redistribute it and/or modify
@ -33,9 +33,6 @@ struct _GimpTip
GimpTip * gimp_tip_new (const gchar *format,
...) G_GNUC_PRINTF(1, 2);
void gimp_tip_set (GimpTip *tip,
const gchar *format,
...) G_GNUC_PRINTF(2, 3);
void gimp_tip_free (GimpTip *tip);
GList * gimp_tips_from_file (const gchar *filename,

View File

@ -1,13 +1,15 @@
<!-- Simple DTD for GIMP tips -->
<!ENTITY % markup "(#PCDATA|b|big|tt)*" >
<!ELEMENT gimp-tips (tip+)>
<!ELEMENT gimp-tips (tip+) >
<!ELEMENT tip (thetip+)>
<!ATTLIST tip level (start|beginner|intermediate|advanced) #REQUIRED>
<!ELEMENT tip %markup; >
<!ATTLIST tip level (start|beginner|intermediate|advanced) #REQUIRED
xml:lang CDATA #IMPLIED >
<!ENTITY % markup "(#PCDATA|b|big|tt)*">
<!ELEMENT b %markup; >
<!ELEMENT big %markup; >
<!ELEMENT tt %markup; >
<!ELEMENT b %markup;>
<!ELEMENT big %markup;>
<!ELEMENT tt %markup;>
<!ELEMENT thetip %markup;>
<!ATTLIST thetip xml:lang CDATA #IMPLIED>

View File

@ -1,138 +1,178 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE gimp-tips SYSTEM "gimp-tips.dtd">
<gimp-tips>
<!-- This is a list of tips for GIMP. -->
<!-- -->
<!-- The tips parser supports a very basic markup language. You may use -->
<!-- the tag b to specify bold text, big to increase the font size and -->
<!-- tt to switch to a monospace font. -->
<gimp-tips>
<!-- -->
<!-- Tips for beginners start here -->
<!-- (for people who are not familiar yet with layers and image formats) -->
<!-- -->
<_tip level="beginner">
<tip level="beginner">
<_thetip>
You can get context-sensitive help for most of GIMP's features by
pressing the F1 key at any time. This also works inside the menus.
</_tip>
<_tip level="beginner">
</_thetip>
</tip>
<tip level="beginner">
<_thetip>
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
see a composite of their contents.
</_tip>
<_tip level="beginner">
</_thetip>
</tip>
<tip level="beginner">
<_thetip>
You can perform many layer operations by right-clicking on the text
label of a layer in the Layers dialog.
</_tip>
<_tip level="beginner">
</_thetip>
</tip>
<tip level="beginner">
<_thetip>
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>).
This preserves the layers and every aspect of your work-in-progress.
Once a project is completed, you can save it as JPEG, PNG, GIF, ...
</_tip>
<_tip level="beginner">
</_thetip>
</tip>
<tip level="beginner">
<_thetip>
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)
if you want the plug-in to work on the whole image.
</_tip>
<_tip level="beginner">
</_thetip>
</tip>
<tip level="beginner">
<_thetip>
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
using Layer→Transparency→Add Alpha Channel.
</_tip>
<_tip level="beginner">
</_thetip>
</tip>
<tip level="beginner">
<_thetip>
Not all effects can be applied to all kinds of images. This is
indicated by a grayed-out menu-entry. You may need to change
the image mode to RGB (Image→Mode→RGB), add an alpha-channel
(Layer→Transparency→Add Alpha Channel) or flatten it
(Image→Flatten Image).
</_tip>
<_tip level="beginner">
</_thetip>
</tip>
<tip level="beginner">
<_thetip>
You can adjust or move a selection by using <tt>Alt</tt>-drag.
If this makes the window move, your window manager uses the
<tt>Alt</tt> key already. Most window managers can be
configured to ignore the <tt>Alt</tt> key or to use
the <tt>Super</tt> key (or "Windows logo") instead.
</_tip>
</_thetip>
</tip>
<!-- -->
<!-- Tips for intermediate users start here -->
<!-- -->
<_tip level="intermediate">
<tip level="intermediate">
<_thetip>
You can drag and drop many things in GIMP. For example, dragging
a color from the toolbox or from a color palette and dropping it into
an image will fill the current selection with that color.
</_tip>
<_tip level="intermediate">
</_thetip>
</tip>
<tip level="intermediate">
<_thetip>
You can use the middle mouse button to pan around the image
(or optionally hold <tt>Spacebar</tt> while you move the mouse).
</_tip>
<_tip level="intermediate">
</_thetip>
</tip>
<tip level="intermediate">
<_thetip>
Click and drag on a ruler to place a guide on an image. All
dragged selections will snap to the guides. You can remove
guides by dragging them off the image with the Move tool.
</_tip>
<_tip level="intermediate">
</_thetip>
</tip>
<tip level="intermediate">
<_thetip>
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.
</_tip>
<_tip level="intermediate">
</_thetip>
</tip>
<tip level="intermediate">
<_thetip>
A floating selection must be anchored to a new layer or to the last
active layer before doing other operations on the image. Click on the
&quot;New Layer&quot; or the &quot;Anchor Layer&quot; button in the
Layers dialog, or use the menus to do the same.
</_tip>
<_tip level="intermediate">
</_thetip>
</tip>
<tip level="intermediate">
<_thetip>
GIMP supports gzip compression on the fly. Just add <tt>.gz</tt>
(or <tt>.bz2</tt>, if you have bzip2 installed) to the filename and
your image will be saved compressed. Of course loading compressed
images works too.
</_tip>
<_tip level="intermediate">
</_thetip>
</tip>
<tip level="intermediate">
<_thetip>
Pressing and holding the <tt>Shift</tt> key before making a selection
allows you to add to the current selection instead of replacing it.
Using <tt>Ctrl</tt> before making a selection subtracts from the
current one.
</_tip>
<_tip level="intermediate">
</_thetip>
</tip>
<tip level="intermediate">
<_thetip>
You can draw simple squares or circles using Edit→Stroke Selection.
It strokes the edge of your current selection. More complex shapes
can be drawn using the Path tool or with Filters→Render→Gfig.
</_tip>
<_tip level="intermediate">
</_thetip>
</tip>
<tip level="intermediate">
<_thetip>
If you stroke a path (Edit→Stroke Path), the paint tools can
be used with their current settings. You can use the Paintbrush in
gradient mode or even the Eraser or the Smudge tool.
</_tip>
<_tip level="intermediate">
</_thetip>
</tip>
<tip level="intermediate">
<_thetip>
You can create and edit complex selections using the Path tool.
The Paths dialog allows you to work on multiple paths and to convert
them to selections.
</_tip>
<_tip level="intermediate">
</_thetip>
</tip>
<tip level="intermediate">
<_thetip>
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.
Change your selection by painting in the image and click on the button
again to convert it back to a normal selection.
</_tip>
<_tip level="intermediate">
</_thetip>
</tip>
<tip level="intermediate">
<_thetip>
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
the Channels dialog, you can toggle the visibility of this new channel
or convert it to a selection.
</_tip>
</_thetip>
</tip>
<!-- -->
<!-- Tips for advanced users start here -->
<!-- (this is mostly for learning shortcut keys) -->
<!-- -->
<_tip level="advanced">
<tip level="advanced">
<_thetip>
After you enabled &quot;Dynamic Keyboard Shortcuts&quot; in the
Preferences dialog, you can reassign shortcut keys. Do so by bringing
up the menu, selecting a menu item, and pressing the desired key
@ -140,52 +180,65 @@
key bindings are saved when you exit GIMP.
You should probably disable &quot;Dynamic Keyboard Shortcuts&quot;
afterwards, to prevent accidentally assigning/reassigning shortcuts.
</_tip>
<_tip level="advanced">
</_thetip>
</tip>
<tip level="advanced">
<_thetip>
If your screen is too cluttered, you can press <tt>Tab</tt>
in an image window to toggle the visibility of the toolbox
and other dialogs.
</_tip>
<_tip level="advanced">
</_thetip>
</tip>
<tip level="advanced">
<_thetip>
<tt>Shift</tt>-click on the eye icon in the Layers dialog to hide all
layers but that one. <tt>Shift</tt>-click again to show all layers.
</_tip>
<_tip level="advanced">
</_thetip>
</tip>
<tip level="advanced">
<_thetip>
<tt>Ctrl</tt>-clicking on the layer mask's preview in the Layers dialog
toggles the effect of the layer mask. <tt>Alt</tt>-clicking on the layer
mask's preview in the Layers dialog toggles viewing the mask directly.
</_tip>
<_tip level="advanced">
</_thetip>
</tip>
<tip level="advanced">
<_thetip>
You can use <tt>Ctrl</tt>-<tt>Tab</tt> to cycle through all layers in
an image (if your window manager doesn't trap those keys...).
</_tip>
<_tip level="advanced">
</_thetip>
</tip>
<tip level="advanced">
<_thetip>
<tt>Ctrl</tt>-click with the Bucket Fill tool to have it use
the background color instead of the foreground color.
Similarly, <tt>Ctrl</tt>-clicking with the eyedropper tool
sets the background color instead of the foreground color.
</_tip>
<_tip level="advanced">
</_thetip>
</tip>
<tip level="advanced">
<_thetip>
<tt>Ctrl</tt>-drag with the Rotate tool will constrain the
rotation to 15 degree angles.
</_tip>
<_tip level="advanced">
</_thetip>
</tip>
<tip level="advanced">
<_thetip>
To create a circle-shaped selection, hold <tt>Shift</tt> while
doing an ellipse select. To place a circle precisely, drag
horizontal and vertical guides tangent to the circle you want to
select, place your cursor at the intersection of the guides, and
the resulting selection will just touch the guides.
</_tip>
<_tip level="advanced">
</_thetip>
</tip>
<tip level="advanced">
<_thetip>
If some of your scanned photos do not look colorful enough, you
can easily improve their tonal range with the &quot;Auto&quot;
button in the Levels tool (Colors→Levels). If there are any
color casts, you can correct them with the Curves tool
(Colors→Curves).
</_tip>
<!-- -->
<!-- (end of tips) -->
<!-- -->
</_thetip>
</tip>
</gimp-tips>