From 848a3e197ff7691b4065d9ef68766002e720e210 Mon Sep 17 00:00:00 2001 From: Sven Neumann Date: Fri, 28 Mar 2008 07:34:38 +0000 Subject: [PATCH] data/tips/gimp-tips.dtd data/tips/gimp-tips.xml.in reverted some of the 2008-03-28 Sven Neumann * 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 --- app/dialogs/tips-parser.c | 170 +++++++++-------- app/dialogs/tips-parser.h | 5 +- data/tips/gimp-tips.dtd | 18 +- data/tips/gimp-tips.xml.in | 379 +++++++++++++++++++++---------------- 4 files changed, 321 insertions(+), 251 deletions(-) diff --git a/app/dialogs/tips-parser.c b/app/dialogs/tips-parser.c index 30bd92357a..1bc0d81b91 100644 --- a/app/dialogs/tips-parser.c +++ b/app/dialogs/tips-parser.c @@ -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 * * This program is free software; you can redistribute it and/or modify @@ -38,50 +38,58 @@ 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; - gint markup_depth; - gint unknown_depth; - GString *value; - GimpTip *current_tip; - GList *tips; + TipsParserState state; + TipsParserState last_known_state; + const gchar *locale; + TipsParserLocaleState locale_state; + gint markup_depth; + gint unknown_depth; + GString *value; + GimpTip *current_tip; + GList *tips; } TipsParser; -static void tips_parser_start_element (GMarkupParseContext *context, - const gchar *element_name, - const gchar **attribute_names, - const gchar **attribute_values, - gpointer user_data, - GError **error); -static void tips_parser_end_element (GMarkupParseContext *context, - const gchar *element_name, - gpointer user_data, - GError **error); -static void tips_parser_characters (GMarkupParseContext *context, - const gchar *text, - gsize text_len, - gpointer user_data, - GError **error); +static void tips_parser_start_element (GMarkupParseContext *context, + const gchar *element_name, + const gchar **attribute_names, + const gchar **attribute_values, + gpointer user_data, + GError **error); +static void tips_parser_end_element (GMarkupParseContext *context, + const gchar *element_name, + gpointer user_data, + GError **error); +static void tips_parser_characters (GMarkupParseContext *context, + const gchar *text, + gsize text_len, + gpointer user_data, + GError **error); -static void tips_parser_start_markup (TipsParser *parser, - const gchar *markup_name); -static void tips_parser_end_markup (TipsParser *parser, - const gchar *markup_name); -static void tips_parser_start_unknown (TipsParser *parser); -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, - gchar **dest); +static void tips_parser_start_markup (TipsParser *parser, + const gchar *markup_name); +static void tips_parser_end_markup (TipsParser *parser, + const gchar *markup_name); +static void tips_parser_start_unknown (TipsParser *parser); +static void tips_parser_end_unknown (TipsParser *parser); +static void tips_parser_parse_locale (TipsParser *parser, + const gchar **names, + const gchar **values); +static void tips_parser_set_by_locale (TipsParser *parser, + gchar **dest); static const GMarkupParser markup_parser = @@ -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; - } + parser->state = TIPS_IN_TIPS; else - { - tips_parser_start_unknown (parser); - } + 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); - } + 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); - } + tips_parser_start_markup (parser, element_name); else - { - tips_parser_start_unknown (parser); - } + 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: + parser->tips = g_list_prepend (parser->tips, parser->current_tip); + parser->current_tip = NULL; + parser->state = TIPS_IN_TIPS; + break; + + case TIPS_IN_THETIP: 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; - } + tips_parser_set_by_locale (parser, &parser->current_tip->thetip); g_string_truncate (parser->value, 0); - - parser->state = TIPS_IN_TIPS; + parser->state = TIPS_IN_TIP; } else - { - tips_parser_end_markup (parser, element_name); - } + 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); + } + else if (*dest == NULL) + { + *dest = g_strdup (parser->value->str); + } + break; + + case TIPS_LOCALE_MATCH: g_free (*dest); *dest = g_strdup (parser->value->str); - return TRUE; - } + break; - return FALSE; + case TIPS_LOCALE_MISMATCH: + break; + } } diff --git a/app/dialogs/tips-parser.h b/app/dialogs/tips-parser.h index 115e6db57d..5af10c0cc6 100644 --- a/app/dialogs/tips-parser.h +++ b/app/dialogs/tips-parser.h @@ -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 * * 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, diff --git a/data/tips/gimp-tips.dtd b/data/tips/gimp-tips.dtd index 1be89c020b..700f8b7714 100644 --- a/data/tips/gimp-tips.dtd +++ b/data/tips/gimp-tips.dtd @@ -1,13 +1,15 @@ - + - + + - - + - - - + + + + + + diff --git a/data/tips/gimp-tips.xml.in b/data/tips/gimp-tips.xml.in index f8df9ef4da..ee5387a45f 100644 --- a/data/tips/gimp-tips.xml.in +++ b/data/tips/gimp-tips.xml.in @@ -1,191 +1,244 @@ - - + - <_tip level="beginner"> - 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 level="beginner"> - 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 level="beginner"> - You can perform many layer operations by right-clicking on the text - label of a layer in the Layers dialog. - - <_tip level="beginner"> - When you save an image to work on it again later, try using XCF, - GIMP's native file format (use the file extension .xcf). - 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 level="beginner"> - 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 level="beginner"> - If a layer's name in the Layers dialog is displayed in bold, - this layer doesn't have an alpha-channel. You can add an alpha-channel - using Layer→Transparency→Add Alpha Channel. - - <_tip level="beginner"> - 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 level="beginner"> - You can adjust or move a selection by using Alt-drag. - If this makes the window move, your window manager uses the - Alt key already. Most window managers can be - configured to ignore the Alt key or to use - the Super key (or "Windows logo") instead. - + + <_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. + + + + <_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. + + + + <_thetip> + You can perform many layer operations by right-clicking on the text + label of a layer in the Layers dialog. + + + + <_thetip> + When you save an image to work on it again later, try using XCF, + GIMP's native file format (use the file extension .xcf). + 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, ... + + + + <_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. + + + + <_thetip> + If a layer's name in the Layers dialog is displayed in bold, + this layer doesn't have an alpha-channel. You can add an alpha-channel + using Layer→Transparency→Add Alpha Channel. + + + + <_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). + + + + <_thetip> + You can adjust or move a selection by using Alt-drag. + If this makes the window move, your window manager uses the + Alt key already. Most window managers can be + configured to ignore the Alt key or to use + the Super key (or "Windows logo") instead. + + - <_tip level="intermediate"> - 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 level="intermediate"> - You can use the middle mouse button to pan around the image - (or optionally hold Spacebar while you move the mouse). - - <_tip level="intermediate"> - 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 level="intermediate"> - 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 level="intermediate"> - 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 - "New Layer" or the "Anchor Layer" button in the - Layers dialog, or use the menus to do the same. - - <_tip level="intermediate"> - GIMP supports gzip compression on the fly. Just add .gz - (or .bz2, if you have bzip2 installed) to the filename and - your image will be saved compressed. Of course loading compressed - images works too. - - <_tip level="intermediate"> - Pressing and holding the Shift key before making a selection - allows you to add to the current selection instead of replacing it. - Using Ctrl before making a selection subtracts from the - current one. - - <_tip level="intermediate"> - 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 level="intermediate"> - 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 level="intermediate"> - 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 level="intermediate"> - You can use the paint tools to change the selection. Click on the - "Quick Mask" 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 level="intermediate"> - 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. - + + <_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. + + + + <_thetip> + You can use the middle mouse button to pan around the image + (or optionally hold Spacebar while you move the mouse). + + + + <_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. + + + + <_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. + + + + <_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 + "New Layer" or the "Anchor Layer" button in the + Layers dialog, or use the menus to do the same. + + + + <_thetip> + GIMP supports gzip compression on the fly. Just add .gz + (or .bz2, if you have bzip2 installed) to the filename and + your image will be saved compressed. Of course loading compressed + images works too. + + + + <_thetip> + Pressing and holding the Shift key before making a selection + allows you to add to the current selection instead of replacing it. + Using Ctrl before making a selection subtracts from the + current one. + + + + <_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. + + + + <_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. + + + + <_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. + + + + <_thetip> + You can use the paint tools to change the selection. Click on the + "Quick Mask" 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. + + + + <_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 level="advanced"> - After you enabled "Dynamic Keyboard Shortcuts" 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 - combination. If "Save Keyboard Shortcuts" is enabled, the - key bindings are saved when you exit GIMP. - You should probably disable "Dynamic Keyboard Shortcuts" - afterwards, to prevent accidentally assigning/reassigning shortcuts. - - <_tip level="advanced"> - If your screen is too cluttered, you can press Tab - in an image window to toggle the visibility of the toolbox - and other dialogs. - - <_tip level="advanced"> - Shift-click on the eye icon in the Layers dialog to hide all - layers but that one. Shift-click again to show all layers. - - <_tip level="advanced"> - Ctrl-clicking on the layer mask's preview in the Layers dialog - toggles the effect of the layer mask. Alt-clicking on the layer - mask's preview in the Layers dialog toggles viewing the mask directly. - - <_tip level="advanced"> - You can use Ctrl-Tab to cycle through all layers in - an image (if your window manager doesn't trap those keys...). - - <_tip level="advanced"> - Ctrl-click with the Bucket Fill tool to have it use - the background color instead of the foreground color. - Similarly, Ctrl-clicking with the eyedropper tool - sets the background color instead of the foreground color. - - <_tip level="advanced"> - Ctrl-drag with the Rotate tool will constrain the - rotation to 15 degree angles. - - <_tip level="advanced"> - To create a circle-shaped selection, hold Shift 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 level="advanced"> - If some of your scanned photos do not look colorful enough, you - can easily improve their tonal range with the "Auto" - button in the Levels tool (Colors→Levels). If there are any - color casts, you can correct them with the Curves tool - (Colors→Curves). - - - - - + + <_thetip> + After you enabled "Dynamic Keyboard Shortcuts" 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 + combination. If "Save Keyboard Shortcuts" is enabled, the + key bindings are saved when you exit GIMP. + You should probably disable "Dynamic Keyboard Shortcuts" + afterwards, to prevent accidentally assigning/reassigning shortcuts. + + + + <_thetip> + If your screen is too cluttered, you can press Tab + in an image window to toggle the visibility of the toolbox + and other dialogs. + + + + <_thetip> + Shift-click on the eye icon in the Layers dialog to hide all + layers but that one. Shift-click again to show all layers. + + + + <_thetip> + Ctrl-clicking on the layer mask's preview in the Layers dialog + toggles the effect of the layer mask. Alt-clicking on the layer + mask's preview in the Layers dialog toggles viewing the mask directly. + + + + <_thetip> + You can use Ctrl-Tab to cycle through all layers in + an image (if your window manager doesn't trap those keys...). + + + + <_thetip> + Ctrl-click with the Bucket Fill tool to have it use + the background color instead of the foreground color. + Similarly, Ctrl-clicking with the eyedropper tool + sets the background color instead of the foreground color. + + + + <_thetip> + Ctrl-drag with the Rotate tool will constrain the + rotation to 15 degree angles. + + + + <_thetip> + To create a circle-shaped selection, hold Shift 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. + + + + <_thetip> + If some of your scanned photos do not look colorful enough, you + can easily improve their tonal range with the "Auto" + button in the Levels tool (Colors→Levels). If there are any + color casts, you can correct them with the Curves tool + (Colors→Curves). + +