]> git.street.me.uk Git - andy/viking.git/blobdiff - src/dialog.c
Add some safety checks and don't add the pixbuf into the cache if it's invalid.
[andy/viking.git] / src / dialog.c
index 1e2470b2c0ec8011ff2548806b14888a8c8b04c0..d0722662e4e72e63cfcfdc52480ee037e288d667 100644 (file)
@@ -39,6 +39,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <ctype.h>
+#include <time.h>
 
 void a_dialog_msg ( GtkWindow *parent, gint type, const gchar *info, const gchar *extra )
 {
@@ -83,6 +84,10 @@ gboolean a_dialog_goto_latlon ( GtkWindow *parent, struct LatLon *ll, const stru
   gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), lonlabel,  FALSE, FALSE, 0);
   gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), lon,  FALSE, FALSE, 0);
 
+  // 'ok' when press return in the entry
+  g_signal_connect_swapped (lat, "activate", G_CALLBACK(a_dialog_response_accept), dialog);
+  g_signal_connect_swapped (lon, "activate", G_CALLBACK(a_dialog_response_accept), dialog);
+
   gtk_dialog_set_default_response ( GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT );
 
   if ( gtk_dialog_run ( GTK_DIALOG(dialog) ) == GTK_RESPONSE_ACCEPT )
@@ -206,6 +211,8 @@ gchar *a_dialog_waypoint ( GtkWindow *parent, gchar *default_name, VikTrwLayer *
   struct LatLon ll;
   GtkWidget *latlabel, *lonlabel, *namelabel, *latentry, *lonentry, *altentry, *altlabel, *nameentry=NULL;
   GtkWidget *commentlabel, *commententry, *descriptionlabel, *descriptionentry, *imagelabel, *imageentry, *symbollabel, *symbolentry;
+  GtkWidget *timelabel = NULL;
+  GtkWidget *timevaluelabel = NULL; // No editing of time allowed ATM
   GtkListStore *store;
 
   gchar *lat, *lon, *alt;
@@ -318,11 +325,22 @@ gchar *a_dialog_waypoint ( GtkWindow *parent, gchar *default_name, VikTrwLayer *
   if ( !is_new && wp->image )
     vik_file_entry_set_filename ( VIK_FILE_ENTRY(imageentry), wp->image );
 
+  if ( !is_new && wp->has_timestamp ) {
+    gchar tmp_str[64];
+    timelabel = gtk_label_new ( _("Time:") );
+    timevaluelabel = gtk_label_new ( NULL );
+    strftime ( tmp_str, sizeof(tmp_str), "%c", localtime(&(wp->timestamp)) );
+    gtk_label_set_text ( GTK_LABEL(timevaluelabel), tmp_str );
+  }
 
   gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), latlabel, FALSE, FALSE, 0);
   gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), latentry, FALSE, FALSE, 0);
   gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), lonlabel, FALSE, FALSE, 0);
   gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), lonentry, FALSE, FALSE, 0);
+  if ( timelabel ) {
+    gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), timelabel, FALSE, FALSE, 0);
+    gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), timevaluelabel, FALSE, FALSE, 0);
+  }
   gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), altlabel, FALSE, FALSE, 0);
   gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), altentry, FALSE, FALSE, 0);
   gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), commentlabel, FALSE, FALSE, 0);
@@ -491,7 +509,7 @@ GList *a_dialog_select_from_list ( GtkWindow *parent, GList *names, gboolean mul
   return NULL;
 }
 
-gchar *a_dialog_new_track ( GtkWindow *parent, GHashTable *tracks, gchar *default_name, gboolean is_route )
+gchar *a_dialog_new_track ( GtkWindow *parent, gchar *default_name, gboolean is_route )
 {
   GtkWidget *dialog = gtk_dialog_new_with_buttons ( is_route ? _("Add Route") : _("Add Track"),
                                                   parent,
@@ -533,17 +551,17 @@ gchar *a_dialog_new_track ( GtkWindow *parent, GHashTable *tracks, gchar *defaul
 }
 
 /* creates a vbox full of labels */
-GtkWidget *a_dialog_create_label_vbox ( gchar **texts, int label_count )
+GtkWidget *a_dialog_create_label_vbox ( gchar **texts, int label_count, gint spacing, gint padding )
 {
   GtkWidget *vbox, *label;
   int i;
-  vbox = gtk_vbox_new( TRUE, 3 );
+  vbox = gtk_vbox_new( TRUE, spacing );
 
   for ( i = 0; i < label_count; i++ )
   {
     label = gtk_label_new(NULL);
     gtk_label_set_markup ( GTK_LABEL(label), _(texts[i]) );
-    gtk_box_pack_start ( GTK_BOX(vbox), label, FALSE, TRUE, 5 );
+    gtk_box_pack_start ( GTK_BOX(vbox), label, FALSE, TRUE, padding );
   }
   return vbox;
 }
@@ -696,8 +714,11 @@ gboolean a_dialog_time_threshold ( GtkWindow *parent, gchar *title_text, gchar *
 }
 
 /**
+ * a_dialog_get_positive_number:
+ * 
  * Dialog to return a positive number via a spinbox within the supplied limits
- * A return value of zero indicates the dialog was cancelled
+ * 
+ * Returns: A value of zero indicates the dialog was cancelled
  */
 guint a_dialog_get_positive_number ( GtkWindow *parent, gchar *title_text, gchar *label_text, guint default_num, guint min, guint max, guint step )
 {
@@ -781,12 +802,51 @@ void a_dialog_about ( GtkWindow *parent )
                        "along with this program; if not, write to the Free Software "
                        "Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA");
 
+  // Would be nice to use gtk_about_dialog_add_credit_section (), but that requires gtk 3.4
+  // For now shove it in the 'artists' section so at least the information is easily visible
+  // Something more advanced might have proper version information too...
+  const gchar *libs[] = {
+    "Compiled in libraries:",
+    // Default libs
+    "libglib-2.0",
+    "libgthread-2.0",
+    "libgtk+-2.0",
+    "libgio-2.0",
+    // Potentially optional libs (but probably couldn't build without them)
+#ifdef HAVE_LIBM
+    "libm",
+#endif
+#ifdef HAVE_LIBZ
+    "libz",
+#endif
+#ifdef HAVE_LIBCURL
+    "libcurl",
+#endif
+    // Actually optional libs
+#ifdef HAVE_LIBGPS
+    "libgps",
+#endif
+#ifdef HAVE_LIBEXIF
+    "libexif",
+#endif
+#ifdef HAVE_LIBX11
+    "libX11",
+#endif
+#ifdef HAVE_LIBMAGIC
+    "libmagic",
+#endif
+#ifdef HAVE_LIBBZ2
+    "libbz2",
+#endif
+    NULL
+  };
   // Newer versions of GTK 'just work', calling gtk_show_uri() on the URL or email and opens up the appropriate program
   // This is the old method:
 #if (GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION < 24)
   gtk_about_dialog_set_url_hook (about_url_hook, NULL, NULL);
   gtk_about_dialog_set_email_hook (about_email_hook, NULL, NULL);
 #endif
+
   gtk_show_about_dialog (parent,
        /* TODO do not set program-name and correctly set info for g_get_application_name */
        "program-name", program_name,
@@ -800,6 +860,7 @@ void a_dialog_about ( GtkWindow *parent )
        "authors", AUTHORS,
        "documenters", DOCUMENTERS,
        "translator-credits", _("Translation is coordinated on http://launchpad.net/viking"),
+       "artists", libs,
        NULL);
 }