credits dialogue
authorThomas Thurman <tthurman@gnome.org>
Sun, 30 Aug 2009 16:07:47 +0000 (12:07 -0400)
committerThomas Thurman <tthurman@gnome.org>
Sun, 30 Aug 2009 16:07:47 +0000 (12:07 -0400)
belltower.c
static.ini

index 5e02e95..e73934d 100644 (file)
@@ -19,8 +19,8 @@
 #define MAX_FIELDS 50
 
 GtkWidget *window;
-
 LocationGPSDevice *device;
+GKeyFile *static_content;
 
 typedef enum {
   /** stop scanning the database */
@@ -854,6 +854,91 @@ recent_towers (void)
   show_message ("This is not yet implemented.");
 }
 
+/**
+ * Loads the content of the static data file.  Possibly puts
+ * up a warning if we can't load it.
+ */
+static void
+load_static_content (void)
+{
+  static_content = g_key_file_new ();
+
+  if (!g_key_file_load_from_file (static_content,
+                                 "/usr/share/belltower/static.ini",
+                                 G_KEY_FILE_NONE,
+                                 NULL))
+    {
+      show_message ("Could not load static content.  Attempting to continue.");
+    }
+}
+
+/**
+ * Displays a web page.
+ * (Perhaps this should be merged with show_browser().)
+ *
+ * \param url  The URL.
+ */
+static void
+show_web_page (GtkButton *dummy,
+              gpointer url)
+{
+  show_browser (url);
+}
+
+/**
+ * Shows the credits.
+ *
+ * \param source If non-null, we were called from a button press,
+ *               so always show the credits.  If null, we were called
+ *               automatically on startup, so show the credits if
+ *               they haven't already been seen.
+ */
+static void
+show_credits (GtkButton *source,
+             gpointer dummy)
+{
+  gboolean from_button = (source!=NULL);
+  GtkWidget *dialog, *label, *button;
+
+  dialog = gtk_dialog_new_with_buttons ("Credits",
+                                       GTK_WINDOW (window),
+                                       GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
+                                       NULL
+                                       );
+
+  button = hildon_button_new_with_text (HILDON_SIZE_AUTO_WIDTH | HILDON_SIZE_FINGER_HEIGHT,
+                                       HILDON_BUTTON_ARRANGEMENT_VERTICAL,
+                                       "View the GNU General Public Licence",
+                                       "This program is provided under the GPL, with no warranty.");
+  g_signal_connect (button, "clicked", G_CALLBACK (show_web_page),
+                   "www.gnu.org/copyleft/gpl.html");
+  gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox),
+                   button,
+                   TRUE, TRUE, 0);
+
+  button = hildon_button_new_with_text (HILDON_SIZE_AUTO_WIDTH | HILDON_SIZE_FINGER_HEIGHT,
+                                       HILDON_BUTTON_ARRANGEMENT_VERTICAL,
+                                       "View Dove's Guide for Church Bell Ringers",
+                                       "The source of this program's data.");
+  g_signal_connect (button, "clicked", G_CALLBACK (show_web_page),
+                   "http://dove.cccbr.org.uk");
+  gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox),
+                   button,
+                   TRUE, TRUE, 0);
+
+  button = hildon_button_new_with_text (HILDON_SIZE_AUTO_WIDTH | HILDON_SIZE_FINGER_HEIGHT,
+                                       HILDON_BUTTON_ARRANGEMENT_VERTICAL,
+                                       "View belfry photograph",
+                                       "Image \xc2\xa9 Amanda Slater, cc-by-sa.");
+  g_signal_connect (button, "clicked", G_CALLBACK (show_web_page),
+                   "http://www.flickr.com/photos/pikerslanefarm/3398769335/");
+  gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox),
+                   button,
+                   TRUE, TRUE, 0);
+  
+  gtk_widget_show_all (GTK_WIDGET (dialog));
+}
+
 int
 main(int argc, char **argv)
 {
@@ -882,7 +967,7 @@ main(int argc, char **argv)
 
   /* extra buttons for the app menu */
   button = gtk_button_new_with_label ("Credits");
-  hildon_app_menu_append (menu, GTK_BUTTON (button));
+  g_signal_connect (button, "clicked", G_CALLBACK (show_credits), NULL);
   hildon_app_menu_append (menu, GTK_BUTTON (button));
 
   gtk_widget_show_all (GTK_WIDGET (menu));
@@ -897,6 +982,9 @@ main(int argc, char **argv)
   gtk_container_add (GTK_CONTAINER (window), hbox);
   gtk_widget_show_all (GTK_WIDGET (window));
 
+  load_static_content ();
+  show_credits (NULL, NULL);
+
   gtk_main ();
 
   return EXIT_SUCCESS;
index 6d9dd48..e8bfb39 100644 (file)
@@ -1,6 +1,3 @@
-[General]
-credits="This application is released under the GNU General Public Licence.  It is provided in the hope that it will be useful, but with NO WARRANTY.<br/><br/>The database is taken from the public data of <a href='http://dove.cccbr.org.uk'>Dove's Guide for Church Bell Ringers</a>.<br/><br/><a href='http://www.flickr.com/photos/pikerslanefarm/3398769335/'>The image of a belfry on the front screen</a> is &copy; Amanda Slater, cc-by-sa.<br/><br/>"
-
 #
 # Mappings:
 #