[gnome-games] aisleriot: Better error messages when showing help fails



commit c287c72cb4afb2e47d8cc3c8f72b16e0ebdcabf6
Author: Christian Persch <chpe gnome org>
Date:   Fri Jul 3 20:35:13 2009 +0200

    aisleriot: Better error messages when showing help fails
    
    Use games_help_display_full() and games_show_error() using the display
    name of the help section instead of the file name.

 aisleriot/util.c   |   31 +++++++++++++++++++++++++++++--
 aisleriot/util.h   |    3 ++-
 aisleriot/window.c |    4 ++--
 3 files changed, 33 insertions(+), 5 deletions(-)
---
diff --git a/aisleriot/util.c b/aisleriot/util.c
index 2bc8b36..3a06198 100644
--- a/aisleriot/util.c
+++ b/aisleriot/util.c
@@ -27,6 +27,8 @@
 #include <gtk/gtk.h>
 
 #include <libgames-support/games-help.h>
+#include <libgames-support/games-show.h>
+#include <libgames-support/games-string-utils.h>
 
 #include "util.h"
 
@@ -57,16 +59,41 @@ game_file_to_help_section (const char *game_file)
   return buf;
 }
 
+/**
+ * aisleriot_show_help:
+ * @window: a parent window to use for error messages
+ * @game_file: the game to show help for, or %NULL to show
+ *   general help
+ *
+ * Shows help for @game_file, or the main help if @game_file is %NULL.
+ */
 void
-aisleriot_display_help (GtkWindow *parent,
+aisleriot_show_help (GtkWidget *window,
                         const char *game_file)
 {
   char *help_section = NULL;
+  GError *error = NULL;
 
   if (game_file != NULL) {
     help_section = game_file_to_help_section (game_file);
   }
 
-  games_help_display (GTK_WIDGET (parent), DOC_MODULE, help_section);
+  if (!games_help_display_full (GTK_WIDGET (window), DOC_MODULE, help_section, &error)) {
+    if (game_file != NULL) {
+      char *help_section_display;
+
+      help_section_display = games_filename_to_display_name (game_file);
+
+      games_show_error (window, error,
+                        _("Could not show help for â??%sâ??"),
+                        help_section_display);
+    } else {
+      games_show_error (window, error,
+                        _("Could not show Aisleriot help"));
+    }
+
+    g_error_free (error);
+  }
+
   g_free (help_section);
 }
diff --git a/aisleriot/util.h b/aisleriot/util.h
index 8dacf3e..d9dd980 100644
--- a/aisleriot/util.h
+++ b/aisleriot/util.h
@@ -24,7 +24,8 @@
 
 G_BEGIN_DECLS
 
-void aisleriot_display_help (GtkWindow * parent, const char *game_file);
+void aisleriot_show_help (GtkWidget *window,
+                          const char *game_file);
 
 G_END_DECLS
 
diff --git a/aisleriot/window.c b/aisleriot/window.c
index a1c01f1..2a7f4ba 100644
--- a/aisleriot/window.c
+++ b/aisleriot/window.c
@@ -666,7 +666,7 @@ static void
 help_general_cb (GtkAction *action,
                  AisleriotWindow *window)
 {
-  aisleriot_display_help (GTK_WINDOW (window), NULL);
+  aisleriot_show_help (GTK_WIDGET (window), NULL);
 }
 
 static void
@@ -677,7 +677,7 @@ help_on_game_cb (GtkAction *action,
   const char *game_file;
   
   game_file = aisleriot_game_get_game_file (priv->game);
-  aisleriot_display_help (GTK_WINDOW (window), game_file);
+  aisleriot_show_help (GTK_WIDGET (window), game_file);
 }
 
 static void



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