gimp r25674 - in trunk: . plug-ins/help plug-ins/help-browser



Author: neo
Date: Fri May 16 16:56:33 2008
New Revision: 25674
URL: http://svn.gnome.org/viewvc/gimp?rev=25674&view=rev

Log:
2008-05-16  Sven Neumann  <sven gimp org>

        * plug-ins/help/Makefile.am
        * plug-ins/help/gimphelpprogress.[ch]
        * plug-ins/help/gimphelpprogress-private.h: new files providing a
        simple framework for progress indication and cancellation.

        * plug-ins/help/gimphelp.[ch]
        * plug-ins/help/gimphelpdomain.[ch]
        * plug-ins/help/gimphelpitem.[ch]
        * plug-ins/help/gimphelplocale.[ch]
        * plug-ins/help/gimphelptypes.h
        * plug-ins/help/help.c
        * plug-ins/help/locales.[ch]: changed accordingly (passing NULL
        as progress for now). Also updated copyright headers.

        * plug-ins/help-browser/help-browser.c: same here.

        * plug-ins/help/gimp-help-lookup.c: use the new API and show some
        progress indication when the --verbose command-line option is used.


Added:
   trunk/plug-ins/help/gimphelpprogress-private.h   (contents, props changed)
   trunk/plug-ins/help/gimphelpprogress.c   (contents, props changed)
   trunk/plug-ins/help/gimphelpprogress.h   (contents, props changed)
Modified:
   trunk/ChangeLog
   trunk/plug-ins/help-browser/help-browser.c
   trunk/plug-ins/help/Makefile.am
   trunk/plug-ins/help/gimp-help-lookup.c
   trunk/plug-ins/help/gimphelp.c
   trunk/plug-ins/help/gimphelp.h
   trunk/plug-ins/help/gimphelpdomain.c
   trunk/plug-ins/help/gimphelpdomain.h
   trunk/plug-ins/help/gimphelpitem.c
   trunk/plug-ins/help/gimphelpitem.h
   trunk/plug-ins/help/gimphelplocale.c
   trunk/plug-ins/help/gimphelplocale.h
   trunk/plug-ins/help/gimphelptypes.h
   trunk/plug-ins/help/help.c
   trunk/plug-ins/help/locales.c
   trunk/plug-ins/help/locales.h

Modified: trunk/plug-ins/help-browser/help-browser.c
==============================================================================
--- trunk/plug-ins/help-browser/help-browser.c	(original)
+++ trunk/plug-ins/help-browser/help-browser.c	Fri May 16 16:56:33 2008
@@ -2,11 +2,11 @@
  * Copyright (C) 1995 Spencer Kimball and Peter Mattis
  *
  * The GIMP Help Browser
- * Copyright (C) 1999-2004 Sven Neumann <sven gimp org>
+ * Copyright (C) 1999-2008 Sven Neumann <sven gimp org>
  *                         Michael Natterer <mitch gimp org>
  *                         Henrik Brix Andersen <brix gimp org>
  *
- * Some code & ideas stolen from the GNOME help browser.
+ * Some code & ideas taken from the GNOME help browser.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -87,14 +87,14 @@
   };
 
   gimp_install_procedure (GIMP_HELP_BROWSER_EXT_PROC,
-                          "Browse the GIMP help pages",
+                          "Browse the GIMP user manual",
                           "A small and simple HTML browser optimized for "
-			  "browsing the GIMP help pages.",
+			  "browsing the GIMP user manual.",
                           "Sven Neumann <sven gimp org>, "
 			  "Michael Natterer <mitch gimp org>"
                           "Henrik Brix Andersen <brix gimp org>",
 			  "Sven Neumann, Michael Natterer & Henrik Brix Andersen",
-                          "1999-2004",
+                          "1999-2008",
                           NULL,
                           "",
                           GIMP_EXTENSION,
@@ -184,7 +184,7 @@
 			  "Michael Natterer <mitch gimp org>"
                           "Henrik Brix Andersen <brix gimp org>",
 			  "Sven Neumann, Michael Natterer & Henrik Brix Andersen",
-			  "1999-2004",
+			  "1999-2008",
 			  NULL,
 			  "",
 			  GIMP_TEMPORARY,
@@ -232,7 +232,7 @@
           gchar          *full_uri;
           gboolean        fatal_error;
 
-          full_uri = gimp_help_domain_map (domain, locales, help_id,
+          full_uri = gimp_help_domain_map (domain, locales, help_id, NULL,
                                            &locale, &fatal_error);
 
           if (full_uri)

Modified: trunk/plug-ins/help/Makefile.am
==============================================================================
--- trunk/plug-ins/help/Makefile.am	(original)
+++ trunk/plug-ins/help/Makefile.am	Fri May 16 16:56:33 2008
@@ -25,7 +25,10 @@
 	gimphelpitem.c		\
 	gimphelpitem.h		\
 	gimphelplocale.c	\
-	gimphelplocale.h
+	gimphelplocale.h	\
+	gimphelpprogress.c	\
+	gimphelpprogress.h	\
+	gimphelpprogress-private.h
 
 libexecdir = $(gimpplugindir)/plug-ins
 

Modified: trunk/plug-ins/help/gimp-help-lookup.c
==============================================================================
--- trunk/plug-ins/help/gimp-help-lookup.c	(original)
+++ trunk/plug-ins/help/gimp-help-lookup.c	Fri May 16 16:56:33 2008
@@ -2,7 +2,7 @@
  * Copyright (C) 1995 Spencer Kimball and Peter Mattis
  *
  * gimp-help-lookup - a standalone gimp-help ID to filename mapper
- * Copyright (C)  2004 Sven Neumann <sven gimp org>
+ * Copyright (C)  2004-2008 Sven Neumann <sven gimp org>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -31,11 +31,13 @@
 #include "gimphelp.h"
 
 
-static void    show_version (void) G_GNUC_NORETURN;
+static void               show_version (void) G_GNUC_NORETURN;
 
-static gchar * lookup       (const gchar *help_domain,
-                             const gchar *help_locales,
-                             const gchar *help_id);
+static gchar            * lookup       (const gchar *help_domain,
+                                        const gchar *help_locales,
+                                        const gchar *help_id);
+
+static GimpHelpProgress * progress_new (void);
 
 
 static const gchar  *help_base    = NULL;
@@ -43,6 +45,8 @@
 static const gchar  *help_locales = NULL;
 static const gchar **help_ids     = NULL;
 
+static gboolean      be_verbose   = FALSE;
+
 
 static const GOptionEntry entries[] =
 {
@@ -63,6 +67,11 @@
     "Specifies help language", "LANG"
   },
   {
+    "verbose", 0, 0,
+    G_OPTION_ARG_NONE, &be_verbose,
+    "Be more verbose", NULL
+  },
+  {
     G_OPTION_REMAINING, 0, 0,
     G_OPTION_ARG_STRING_ARRAY, &help_ids,
     NULL, NULL
@@ -84,6 +93,7 @@
 
   context = g_option_context_new ("HELP-ID");
   g_option_context_add_main_entries (context, entries, NULL);
+
   if (! g_option_context_parse (context, &argc, &argv, &error))
     {
       g_print ("%s\n", error->message);
@@ -126,9 +136,15 @@
 
   if (domain)
     {
-      GList *locales  = gimp_help_parse_locales (help_locales);
-      gchar *full_uri = gimp_help_domain_map (domain, locales, help_id,
-                                              NULL, NULL);
+      GimpHelpProgress *progress = progress_new ();
+      GList            *locales;
+      gchar            *full_uri;
+
+      locales  = gimp_help_parse_locales (help_locales);
+      full_uri = gimp_help_domain_map (domain, locales, help_id, progress,
+                                       NULL, NULL);
+
+      gimp_help_progress_free (progress);
 
       g_list_foreach (locales, (GFunc) g_free, NULL);
       g_list_free (locales);
@@ -145,3 +161,41 @@
   g_print ("gimp-help-lookup version %s\n", GIMP_VERSION);
   exit (EXIT_SUCCESS);
 }
+
+
+static void
+progress_start (const gchar *message,
+                gboolean     cancelable,
+                gpointer     user_data)
+{
+  if (be_verbose)
+    g_printerr ("\n%s\n", message);
+}
+
+static void
+progress_end (gpointer user_data)
+{
+  if (be_verbose)
+    g_printerr ("done\n");
+}
+
+static void
+progress_set_value (gdouble  percentage,
+                    gpointer user_data)
+{
+  if (be_verbose)
+    g_printerr (".");
+}
+
+static GimpHelpProgress *
+progress_new (void)
+{
+  const GimpHelpProgressVTable vtable =
+    {
+      progress_start,
+      progress_end,
+      progress_set_value
+    };
+
+  return gimp_help_progress_new (&vtable, NULL);
+}

Modified: trunk/plug-ins/help/gimphelp.c
==============================================================================
--- trunk/plug-ins/help/gimphelp.c	(original)
+++ trunk/plug-ins/help/gimphelp.c	Fri May 16 16:56:33 2008
@@ -2,7 +2,7 @@
  * Copyright (C) 1995 Spencer Kimball and Peter Mattis
  *
  * The GIMP Help plug-in
- * Copyright (C) 1999-2004 Sven Neumann <sven gimp org>
+ * Copyright (C) 1999-2008 Sven Neumann <sven gimp org>
  *                         Michael Natterer <mitch gimp org>
  *                         Henrik Brix Andersen <brix gimp org>
  *

Modified: trunk/plug-ins/help/gimphelp.h
==============================================================================
--- trunk/plug-ins/help/gimphelp.h	(original)
+++ trunk/plug-ins/help/gimphelp.h	Fri May 16 16:56:33 2008
@@ -2,7 +2,7 @@
  * Copyright (C) 1995 Spencer Kimball and Peter Mattis
  *
  * The GIMP Help plug-in
- * Copyright (C) 1999-2004 Sven Neumann <sven gimp org>
+ * Copyright (C) 1999-2008 Sven Neumann <sven gimp org>
  *                         Michael Natterer <mitch gimp org>
  *                         Henrik Brix Andersen <brix gimp org>
  *
@@ -30,6 +30,7 @@
 #include "gimphelpdomain.h"
 #include "gimphelpitem.h"
 #include "gimphelplocale.h"
+#include "gimphelpprogress.h"
 
 
 #define GIMP_HELP_DEFAULT_DOMAIN  "http://www.gimp.org/help";

Modified: trunk/plug-ins/help/gimphelpdomain.c
==============================================================================
--- trunk/plug-ins/help/gimphelpdomain.c	(original)
+++ trunk/plug-ins/help/gimphelpdomain.c	Fri May 16 16:56:33 2008
@@ -2,7 +2,7 @@
  * Copyright (C) 1995 Spencer Kimball and Peter Mattis
  *
  * The GIMP Help plug-in
- * Copyright (C) 1999-2004 Sven Neumann <sven gimp org>
+ * Copyright (C) 1999-2008 Sven Neumann <sven gimp org>
  *                         Michael Natterer <mitch gimp org>
  *                         Henrik Brix Andersen <brix gimp org>
  *
@@ -30,6 +30,7 @@
 #include <string.h>
 
 #include <glib-object.h>
+#include <gio/gio.h>
 
 #include "libgimpbase/gimpbase.h"
 
@@ -44,9 +45,10 @@
 
 /*  local function prototypes  */
 
-static gboolean   domain_locale_parse (GimpHelpDomain  *domain,
-                                       GimpHelpLocale  *locale,
-                                       GError         **error);
+static gboolean   domain_locale_parse (GimpHelpDomain    *domain,
+                                       GimpHelpLocale    *locale,
+                                       GimpHelpProgress  *progress,
+                                       GError           **error);
 
 
 /*  public functions  */
@@ -85,8 +87,9 @@
 }
 
 GimpHelpLocale *
-gimp_help_domain_lookup_locale (GimpHelpDomain *domain,
-                                const gchar    *locale_id)
+gimp_help_domain_lookup_locale (GimpHelpDomain    *domain,
+                                const gchar       *locale_id,
+                                GimpHelpProgress  *progress)
 {
   GimpHelpLocale *locale = NULL;
 
@@ -104,17 +107,18 @@
   locale = gimp_help_locale_new (locale_id);
   g_hash_table_insert (domain->help_locales, g_strdup (locale_id), locale);
 
-  domain_locale_parse (domain, locale, NULL);
+  domain_locale_parse (domain, locale, progress, NULL);
 
   return locale;
 }
 
 gchar *
-gimp_help_domain_map (GimpHelpDomain  *domain,
-                      GList           *help_locales,
-                      const gchar     *help_id,
-                      GimpHelpLocale **ret_locale,
-                      gboolean        *fatal_error)
+gimp_help_domain_map (GimpHelpDomain    *domain,
+                      GList             *help_locales,
+                      const gchar       *help_id,
+                      GimpHelpProgress  *progress,
+                      GimpHelpLocale   **ret_locale,
+                      gboolean          *fatal_error)
 {
   GimpHelpLocale *locale = NULL;
   const gchar    *ref    = NULL;
@@ -131,7 +135,8 @@
   for (list = help_locales; list && !ref; list = list->next)
     {
       locale = gimp_help_domain_lookup_locale (domain,
-                                               (const gchar *) list->data);
+                                               (const gchar *) list->data,
+                                               progress);
       ref = gimp_help_locale_map (locale, help_id);
     }
 
@@ -139,7 +144,8 @@
   for (list = help_locales; list && !ref; list = list->next)
     {
       locale = gimp_help_domain_lookup_locale (domain,
-                                               (const gchar *) list->data);
+                                               (const gchar *) list->data,
+                                               progress);
       ref = locale->help_missing;
     }
 
@@ -163,23 +169,28 @@
 #endif
 
       locale = gimp_help_domain_lookup_locale (domain,
-                                               GIMP_HELP_DEFAULT_LOCALE);
+                                               GIMP_HELP_DEFAULT_LOCALE, NULL);
 
-      if (! domain_locale_parse (domain, locale, &error))
+      if (! domain_locale_parse (domain, locale, NULL, &error))
         {
-          if (error->code == G_FILE_ERROR_NOENT)
+          switch (error->code)
             {
+            case G_IO_ERROR_NOT_FOUND:
               g_message ("%s\n\n%s",
-                         _("The GIMP help files are not found."),
+                         _("The GIMP user manual is not available."),
                          _("Please install the additional help package or use "
                            "the online user manual at http://docs.gimp.org/.";));
-            }
-          else
-            {
+              break;
+
+            case G_IO_ERROR_CANCELLED:
+              break;
+
+            default:
               g_message ("%s\n\n%s\n\n%s",
-                         _("There is a problem with the GIMP help files."),
+                         _("There is a problem with the GIMP user manual."),
                          error->message,
                          _("Please check your installation."));
+              break;
             }
 
           g_error_free (error);
@@ -200,9 +211,10 @@
 /*  private functions  */
 
 static gboolean
-domain_locale_parse (GimpHelpDomain  *domain,
-                     GimpHelpLocale  *locale,
-                     GError         **error)
+domain_locale_parse (GimpHelpDomain    *domain,
+                     GimpHelpLocale    *locale,
+                     GimpHelpProgress  *progress,
+                     GError           **error)
 {
   gchar    *uri;
   gboolean  success;
@@ -214,7 +226,8 @@
   uri = g_strdup_printf ("%s/%s/gimp-help.xml",
                          domain->help_uri, locale->locale_id);
 
-  success = gimp_help_locale_parse (locale, uri, domain->help_domain, error);
+  success = gimp_help_locale_parse (locale, uri, domain->help_domain,
+                                    progress, error);
 
   g_free (uri);
 

Modified: trunk/plug-ins/help/gimphelpdomain.h
==============================================================================
--- trunk/plug-ins/help/gimphelpdomain.h	(original)
+++ trunk/plug-ins/help/gimphelpdomain.h	Fri May 16 16:56:33 2008
@@ -2,7 +2,7 @@
  * Copyright (C) 1995 Spencer Kimball and Peter Mattis
  *
  * The GIMP Help plug-in
- * Copyright (C) 1999-2004 Sven Neumann <sven gimp org>
+ * Copyright (C) 1999-2008 Sven Neumann <sven gimp org>
  *                         Michael Natterer <mitch gimp org>
  *                         Henrik Brix Andersen <brix gimp org>
  *
@@ -33,17 +33,19 @@
 };
 
 
-GimpHelpDomain * gimp_help_domain_new           (const gchar     *domain_name,
-                                                 const gchar     *domain_uri);
-void             gimp_help_domain_free          (GimpHelpDomain  *domain);
-
-GimpHelpLocale * gimp_help_domain_lookup_locale (GimpHelpDomain  *domain,
-                                                 const gchar     *locale_id);
-gchar          * gimp_help_domain_map           (GimpHelpDomain  *domain,
-                                                 GList           *help_locales,
-                                                 const gchar     *help_id,
-                                                 GimpHelpLocale **locale,
-                                                 gboolean        *fatal_error);
+GimpHelpDomain * gimp_help_domain_new           (const gchar       *domain_name,
+                                                 const gchar       *domain_uri);
+void             gimp_help_domain_free          (GimpHelpDomain    *domain);
+
+GimpHelpLocale * gimp_help_domain_lookup_locale (GimpHelpDomain    *domain,
+                                                 const gchar       *locale_id,
+                                                 GimpHelpProgress  *progress);
+gchar          * gimp_help_domain_map           (GimpHelpDomain    *domain,
+                                                 GList             *help_locales,
+                                                 const gchar       *help_id,
+                                                 GimpHelpProgress  *progress,
+                                                 GimpHelpLocale   **locale,
+                                                 gboolean          *fatal_error);
 void             gimp_help_domain_exit          (void);
 
 

Modified: trunk/plug-ins/help/gimphelpitem.c
==============================================================================
--- trunk/plug-ins/help/gimphelpitem.c	(original)
+++ trunk/plug-ins/help/gimphelpitem.c	Fri May 16 16:56:33 2008
@@ -2,7 +2,7 @@
  * Copyright (C) 1995 Spencer Kimball and Peter Mattis
  *
  * The GIMP Help plug-in
- * Copyright (C) 1999-2004 Sven Neumann <sven gimp org>
+ * Copyright (C) 1999-2008 Sven Neumann <sven gimp org>
  *                         Michael Natterer <mitch gimp org>
  *                         Henrik Brix Andersen <brix gimp org>
  *

Modified: trunk/plug-ins/help/gimphelpitem.h
==============================================================================
--- trunk/plug-ins/help/gimphelpitem.h	(original)
+++ trunk/plug-ins/help/gimphelpitem.h	Fri May 16 16:56:33 2008
@@ -2,7 +2,7 @@
  * Copyright (C) 1995 Spencer Kimball and Peter Mattis
  *
  * The GIMP Help plug-in
- * Copyright (C) 1999-2004 Sven Neumann <sven gimp org>
+ * Copyright (C) 1999-2008 Sven Neumann <sven gimp org>
  *                         Michael Natterer <mitch gimp org>
  *                         Henrik Brix Andersen <brix gimp org>
  *

Modified: trunk/plug-ins/help/gimphelplocale.c
==============================================================================
--- trunk/plug-ins/help/gimphelplocale.c	(original)
+++ trunk/plug-ins/help/gimphelplocale.c	Fri May 16 16:56:33 2008
@@ -2,7 +2,7 @@
  * Copyright (C) 1995 Spencer Kimball and Peter Mattis
  *
  * The GIMP Help plug-in
- * Copyright (C) 1999-2004 Sven Neumann <sven gimp org>
+ * Copyright (C) 1999-2008 Sven Neumann <sven gimp org>
  *                         Michael Natterer <mitch gimp org>
  *                         Henrik Brix Andersen <brix gimp org>
  *
@@ -33,6 +33,7 @@
 #include <gio/gio.h>
 
 #include "gimphelp.h"
+#include "gimphelpprogress-private.h"
 
 #ifdef DISABLE_NLS
 #define _(String)  (String)
@@ -117,7 +118,10 @@
 } LocaleParser;
 
 static gboolean  locale_parser_parse       (GMarkupParseContext  *context,
+                                            GimpHelpProgress     *progress,
                                             GInputStream         *stream,
+                                            goffset               size,
+                                            GCancellable         *cancellable,
                                             GError              **error);
 static void  locale_parser_start_element   (GMarkupParseContext  *context,
                                             const gchar          *element_name,
@@ -154,15 +158,18 @@
 };
 
 gboolean
-gimp_help_locale_parse (GimpHelpLocale  *locale,
-                        const gchar     *uri,
-                        const gchar     *help_domain,
-                        GError         **error)
+gimp_help_locale_parse (GimpHelpLocale    *locale,
+                        const gchar       *uri,
+                        const gchar       *help_domain,
+                        GimpHelpProgress  *progress,
+                        GError           **error)
 {
   GMarkupParseContext *context;
   GFile               *file;
   GFileInputStream    *stream;
-  LocaleParser         parser = { NULL, };
+  GCancellable        *cancellable = NULL;
+  LocaleParser         parser      = { NULL, };
+  goffset              size        = 0;
   gboolean             success;
 
   g_return_val_if_fail (locale != NULL, FALSE);
@@ -188,7 +195,38 @@
 
   file = g_file_new_for_uri (uri);
 
-  stream = g_file_read (file, NULL, error);
+  if (progress)
+    {
+      gchar *name = g_file_get_parse_name (file);
+
+      cancellable = g_cancellable_new ();
+      _gimp_help_progress_start (progress, cancellable,
+                                 _("Loading index from '%s'"), name);
+
+      g_object_unref (cancellable);
+      g_free (name);
+    }
+
+  if (progress)
+    {
+      GFileInfo *info = g_file_query_info (file,
+                                           G_FILE_ATTRIBUTE_STANDARD_SIZE, 0,
+                                           cancellable, error);
+      if (! info)
+        {
+          locale_set_error (error, _("Could not open '%s' for reading: %s"),
+                            file);
+          g_object_unref (file);
+
+          return FALSE;
+        }
+
+      size = g_file_info_get_size (info);
+
+      g_object_unref (info);
+    }
+
+  stream = g_file_read (file, cancellable, error);
 
   if (! stream)
     {
@@ -206,7 +244,12 @@
 
   context = g_markup_parse_context_new (&markup_parser, 0, &parser, NULL);
 
-  success = locale_parser_parse (context, G_INPUT_STREAM (stream), error);
+  success = locale_parser_parse (context, progress,
+                                 G_INPUT_STREAM (stream), size,
+                                 cancellable, error);
+
+  if (progress)
+    _gimp_help_progress_finish (progress);
 
   g_markup_parse_context_free (context);
   g_object_unref (stream);
@@ -224,14 +267,18 @@
 
 static gboolean
 locale_parser_parse (GMarkupParseContext  *context,
+                     GimpHelpProgress     *progress,
                      GInputStream         *stream,
+                     goffset               size,
+                     GCancellable         *cancellable,
                      GError              **error)
 {
-  gssize len;
-  gchar  buffer[4096];
+  gssize  len;
+  goffset done = 0;
+  gchar   buffer[4096];
 
   while ((len = g_input_stream_read (stream, buffer, sizeof (buffer),
-                                     NULL, error)) != -1)
+                                     cancellable, error)) != -1)
     {
       switch (len)
         {
@@ -239,6 +286,16 @@
           return g_markup_parse_context_end_parse (context, error);
 
         default:
+          done += len;
+
+          if (progress)
+            {
+              if (size > 0)
+                _gimp_help_progress_update (progress, (gdouble) done / size);
+              else
+                _gimp_help_progress_pulse (progress);
+            }
+
           if (! g_markup_parse_context_parse (context, buffer, len, error))
             return FALSE;
         }

Modified: trunk/plug-ins/help/gimphelplocale.h
==============================================================================
--- trunk/plug-ins/help/gimphelplocale.h	(original)
+++ trunk/plug-ins/help/gimphelplocale.h	Fri May 16 16:56:33 2008
@@ -2,7 +2,7 @@
  * Copyright (C) 1995 Spencer Kimball and Peter Mattis
  *
  * The GIMP Help plug-in
- * Copyright (C) 1999-2004 Sven Neumann <sven gimp org>
+ * Copyright (C) 1999-2008 Sven Neumann <sven gimp org>
  *                         Michael Natterer <mitch gimp org>
  *                         Henrik Brix Andersen <brix gimp org>
  *
@@ -36,16 +36,17 @@
 };
 
 
-GimpHelpLocale * gimp_help_locale_new        (const gchar     *locale_id);
-void             gimp_help_locale_free       (GimpHelpLocale  *locale);
+GimpHelpLocale * gimp_help_locale_new   (const gchar       *locale_id);
+void             gimp_help_locale_free  (GimpHelpLocale    *locale);
 
-const gchar    * gimp_help_locale_map        (GimpHelpLocale  *locale,
-                                              const gchar     *help_id);
+const gchar    * gimp_help_locale_map   (GimpHelpLocale    *locale,
+                                         const gchar       *help_id);
 
-gboolean         gimp_help_locale_parse      (GimpHelpLocale  *locale,
-                                              const gchar     *uri,
-                                              const gchar     *help_domain,
-                                              GError         **error);
+gboolean         gimp_help_locale_parse (GimpHelpLocale    *locale,
+                                         const gchar       *uri,
+                                         const gchar       *help_domain,
+                                         GimpHelpProgress  *progress,
+                                         GError           **error);
 
 
 #endif /* __GIMP_HELP_LOCALE_H__ */

Added: trunk/plug-ins/help/gimphelpprogress-private.h
==============================================================================
--- (empty file)
+++ trunk/plug-ins/help/gimphelpprogress-private.h	Fri May 16 16:56:33 2008
@@ -0,0 +1,40 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * The GIMP Help plug-in
+ * Copyright (C) 1999-2008 Sven Neumann <sven gimp org>
+ *                         Michael Natterer <mitch gimp org>
+ *                         Henrik Brix Andersen <brix gimp org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __GIMP_HELP_PROGRESS_PRIVATE_H__
+#define __GIMP_HELP_PROGRESS_PRIVATE_H__
+
+
+/*  internal API  */
+
+void  _gimp_help_progress_start  (GimpHelpProgress   *progress,
+                                  GCancellable       *cancellable,
+                                  const gchar        *format,
+                                  ...) G_GNUC_PRINTF (3, 4)       G_GNUC_INTERNAL;
+void  _gimp_help_progress_update (GimpHelpProgress   *progress,
+                                  gdouble             percentage) G_GNUC_INTERNAL;
+void  _gimp_help_progress_pulse  (GimpHelpProgress   *progress)   G_GNUC_INTERNAL;
+void  _gimp_help_progress_finish (GimpHelpProgress   *progress)   G_GNUC_INTERNAL;
+
+
+#endif /* ! __GIMP_HELP_PROGRESS_PRIVATE_H__ */

Added: trunk/plug-ins/help/gimphelpprogress.c
==============================================================================
--- (empty file)
+++ trunk/plug-ins/help/gimphelpprogress.c	Fri May 16 16:56:33 2008
@@ -0,0 +1,151 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * The GIMP Help plug-in
+ * Copyright (C) 1999-2008 Sven Neumann <sven gimp org>
+ *                         Michael Natterer <mitch gimp org>
+ *                         Henrik Brix Andersen <brix gimp org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+/*  This code is written so that it can also be compiled standalone.
+ *  It shouldn't depend on libgimp.
+ */
+
+#include "config.h"
+
+#include <string.h>
+
+#include <gio/gio.h>
+
+#include "gimphelptypes.h"
+#include "gimphelpprogress.h"
+#include "gimphelpprogress-private.h"
+
+
+struct _GimpHelpProgress
+{
+  GimpHelpProgressVTable  vtable;
+  gpointer                user_data;
+
+  GCancellable           *cancellable;
+};
+
+
+GimpHelpProgress *
+gimp_help_progress_new (const GimpHelpProgressVTable *vtable,
+                        gpointer                      user_data)
+{
+  GimpHelpProgress *progress;
+
+  g_return_val_if_fail (vtable != NULL, NULL);
+
+  progress = g_slice_new0 (GimpHelpProgress);
+
+  progress->vtable.start     = vtable->start;
+  progress->vtable.end       = vtable->end;
+  progress->vtable.set_value = vtable->set_value;
+
+  progress->user_data        = user_data;
+
+  return progress;
+}
+
+void
+gimp_help_progress_free (GimpHelpProgress *progress)
+{
+  g_return_if_fail (progress != NULL);
+
+  if (progress->cancellable)
+    {
+      g_object_unref (progress->cancellable);
+      progress->cancellable = NULL;
+    }
+
+  g_slice_free (GimpHelpProgress, progress);
+}
+
+void
+gimp_help_progress_cancel (GimpHelpProgress *progress)
+{
+  g_return_if_fail (progress != NULL);
+
+  if (progress->cancellable)
+    g_cancellable_cancel (progress->cancellable);
+}
+
+
+void
+_gimp_help_progress_start (GimpHelpProgress *progress,
+                           GCancellable     *cancellable,
+                           const gchar      *format,
+                           ...)
+{
+  gchar   *message;
+  va_list  args;
+
+  g_return_if_fail (progress != NULL);
+
+  if (cancellable)
+    g_object_ref (cancellable);
+
+  if (progress->cancellable)
+    g_object_unref (progress->cancellable);
+
+  progress->cancellable = cancellable;
+
+  va_start (args, format);
+  message = g_strdup_vprintf (format, args);
+  va_end (args);
+
+  if (progress->vtable.start)
+    progress->vtable.start (message, cancellable != NULL, progress->user_data);
+
+  g_free (message);
+}
+
+void
+_gimp_help_progress_update (GimpHelpProgress *progress,
+                            gdouble           percentage)
+{
+  g_return_if_fail (progress != NULL);
+
+  if (progress->vtable.set_value)
+    progress->vtable.set_value (percentage, progress->user_data);
+}
+
+void
+_gimp_help_progress_pulse (GimpHelpProgress *progress)
+{
+  g_return_if_fail (progress != NULL);
+
+  _gimp_help_progress_update (progress, -1.0);
+}
+
+void
+_gimp_help_progress_finish (GimpHelpProgress *progress)
+{
+  g_return_if_fail (progress != NULL);
+
+  if (progress->vtable.end)
+    progress->vtable.end (progress->user_data);
+
+  if (progress->cancellable)
+    {
+      g_object_unref (progress->cancellable);
+      progress->cancellable = NULL;
+    }
+}

Added: trunk/plug-ins/help/gimphelpprogress.h
==============================================================================
--- (empty file)
+++ trunk/plug-ins/help/gimphelpprogress.h	Fri May 16 16:56:33 2008
@@ -0,0 +1,52 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * The GIMP Help plug-in
+ * Copyright (C) 1999-2008 Sven Neumann <sven gimp org>
+ *                         Michael Natterer <mitch gimp org>
+ *                         Henrik Brix Andersen <brix gimp org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __GIMP_HELP_PROGRESS_H__
+#define __GIMP_HELP_PROGRESS_H__
+
+
+typedef struct
+{
+  void  (* start)           (const gchar *message,
+                             gboolean     cancelable,
+                             gpointer     user_data);
+  void  (* end)             (gpointer     user_data);
+  void  (* set_value)       (gdouble      percentage,
+                             gpointer     user_data);
+
+  /* Padding for future expansion. Must be initialized with NULL! */
+  void  (* _gimp_reserved1) (void);
+  void  (* _gimp_reserved2) (void);
+  void  (* _gimp_reserved3) (void);
+  void  (* _gimp_reserved4) (void);
+} GimpHelpProgressVTable;
+
+
+GimpHelpProgress * gimp_help_progress_new    (const GimpHelpProgressVTable *vtable,
+                                              gpointer                      user_data);
+void               gimp_help_progress_free   (GimpHelpProgress *progress);
+
+void               gimp_help_progress_cancel (GimpHelpProgress *progress);
+
+
+#endif /* ! __GIMP_HELP_PROGRESS_H__ */

Modified: trunk/plug-ins/help/gimphelptypes.h
==============================================================================
--- trunk/plug-ins/help/gimphelptypes.h	(original)
+++ trunk/plug-ins/help/gimphelptypes.h	Fri May 16 16:56:33 2008
@@ -2,7 +2,7 @@
  * Copyright (C) 1995 Spencer Kimball and Peter Mattis
  *
  * The GIMP Help plug-in
- * Copyright (C) 1999-2004 Sven Neumann <sven gimp org>
+ * Copyright (C) 1999-2008 Sven Neumann <sven gimp org>
  *                         Michael Natterer <mitch gimp org>
  *                         Henrik Brix Andersen <brix gimp org>
  *
@@ -25,9 +25,10 @@
 #define __GIMP_HELP_TYPES_H__
 
 
-typedef struct _GimpHelpDomain GimpHelpDomain;
-typedef struct _GimpHelpItem   GimpHelpItem;
-typedef struct _GimpHelpLocale GimpHelpLocale;
+typedef struct _GimpHelpDomain    GimpHelpDomain;
+typedef struct _GimpHelpItem      GimpHelpItem;
+typedef struct _GimpHelpLocale    GimpHelpLocale;
+typedef struct _GimpHelpProgress  GimpHelpProgress;
 
 
 #endif /* ! __GIMP_HELP_TYPES_H__ */

Modified: trunk/plug-ins/help/help.c
==============================================================================
--- trunk/plug-ins/help/help.c	(original)
+++ trunk/plug-ins/help/help.c	Fri May 16 16:56:33 2008
@@ -2,7 +2,7 @@
  * Copyright (C) 1995 Spencer Kimball and Peter Mattis
  *
  * The GIMP Help plug-in
- * Copyright (C) 1999-2004 Sven Neumann <sven gimp org>
+ * Copyright (C) 1999-2008 Sven Neumann <sven gimp org>
  *                         Michael Natterer <mitch gimp org>
  *                         Henrik Brix Andersen <brix gimp org>
  *
@@ -105,7 +105,7 @@
 			  "Michael Natterer <mitch gimp org>, "
                           "Henrik Brix Andersen <brix gimp org>",
                           "Sven Neumann, Michael Natterer & Henrik Brix Andersen",
-                          "1999-2004",
+                          "1999-2008",
                           NULL,
                           "",
                           GIMP_EXTENSION,
@@ -185,7 +185,7 @@
 			  "Michael Natterer <mitch gimp org>"
                           "Henrik Brix Andersen <brix gimp org",
 			  "Sven Neumann, Michael Natterer & Henrik Brix Andersen",
-			  "1999-2004",
+			  "1999-2008",
                           NULL,
                           "",
                           GIMP_TEMPORARY,
@@ -263,12 +263,13 @@
 
   if (domain)
     {
-      GList    *locales = gimp_help_parse_locales (idle_help->help_locales);
+      GList    *locales;
       gchar    *full_uri;
       gboolean  fatal_error;
 
+      locales  = gimp_help_parse_locales (idle_help->help_locales);
       full_uri = gimp_help_domain_map (domain, locales, idle_help->help_id,
-                                       NULL, &fatal_error);
+                                       NULL, NULL, &fatal_error);
 
       g_list_foreach (locales, (GFunc) g_free, NULL);
       g_list_free (locales);

Modified: trunk/plug-ins/help/locales.c
==============================================================================
--- trunk/plug-ins/help/locales.c	(original)
+++ trunk/plug-ins/help/locales.c	Fri May 16 16:56:33 2008
@@ -2,7 +2,7 @@
  * Copyright (C) 1995 Spencer Kimball and Peter Mattis
  *
  * The GIMP Help plug-in
- * Copyright (C) 1999-2004 Sven Neumann <sven gimp org>
+ * Copyright (C) 1999-2008 Sven Neumann <sven gimp org>
  *                         Michael Natterer <mitch gimp org>
  *                         Henrik Brix Andersen <brix gimp org>
  *

Modified: trunk/plug-ins/help/locales.h
==============================================================================
--- trunk/plug-ins/help/locales.h	(original)
+++ trunk/plug-ins/help/locales.h	Fri May 16 16:56:33 2008
@@ -2,7 +2,7 @@
  * Copyright (C) 1995 Spencer Kimball and Peter Mattis
  *
  * The GIMP Help plug-in
- * Copyright (C) 1999-2004 Sven Neumann <sven gimp org>
+ * Copyright (C) 1999-2008 Sven Neumann <sven gimp org>
  *                         Michael Natterer <mitch gimp org>
  *                         Henrik Brix Andersen <brix gimp org>
  *



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]