#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 )
{
/* Specify if a new waypoint or not */
/* If a new waypoint then it uses the default_name for the suggested name allowing the user to change it.
The name to use is returned
- When an existing waypoint the default name is shown but is not allowed to be changed and NULL is returned
*/
/* todo: less on this side, like add track */
gchar *a_dialog_waypoint ( GtkWindow *parent, gchar *default_name, VikTrwLayer *vtl, VikWaypoint *wp, VikCoordMode coord_mode, gboolean is_new, gboolean *updated )
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;
namelabel = gtk_label_new (_("Name:"));
gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), namelabel, FALSE, FALSE, 0);
- if ( is_new )
- {
- // New waypoint, so name is still changeable
- nameentry = gtk_entry_new ();
- if ( default_name )
- gtk_entry_set_text( GTK_ENTRY(nameentry), default_name );
- g_signal_connect_swapped ( nameentry, "activate", G_CALLBACK(a_dialog_response_accept), GTK_DIALOG(dialog) );
- }
- else {
- // Existing waypoint - so can not change the name this way - but at least can see it
- if ( default_name )
- nameentry = gtk_label_new ( default_name );
- }
- if ( nameentry )
- gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), nameentry, FALSE, FALSE, 0);
+ // Name is now always changeable
+ nameentry = gtk_entry_new ();
+ if ( default_name )
+ gtk_entry_set_text( GTK_ENTRY(nameentry), default_name );
+ g_signal_connect_swapped ( nameentry, "activate", G_CALLBACK(a_dialog_response_accept), GTK_DIALOG(dialog) );
+ gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), nameentry, FALSE, FALSE, 0);
latlabel = gtk_label_new (_("Latitude:"));
latentry = gtk_entry_new ();
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);
while ( gtk_dialog_run ( GTK_DIALOG(dialog) ) == GTK_RESPONSE_ACCEPT )
{
- if ( is_new )
- {
- if ( strlen((gchar*)gtk_entry_get_text ( GTK_ENTRY(nameentry) )) == 0 ) /* TODO: other checks (isalpha or whatever ) */
- a_dialog_info_msg ( parent, _("Please enter a name for the waypoint.") );
- else {
- // NB: No check for unique names - this allows generation of same named entries.
- gchar *entered_name = g_strdup ( (gchar*)gtk_entry_get_text ( GTK_ENTRY(nameentry) ) );
-
- /* Do It */
- ll.lat = convert_dms_to_dec ( gtk_entry_get_text ( GTK_ENTRY(latentry) ) );
- ll.lon = convert_dms_to_dec ( gtk_entry_get_text ( GTK_ENTRY(lonentry) ) );
- vik_coord_load_from_latlon ( &(wp->coord), coord_mode, &ll );
- // Always store in metres
- switch (height_units) {
- case VIK_UNITS_HEIGHT_METRES:
- wp->altitude = atof ( gtk_entry_get_text ( GTK_ENTRY(altentry) ) );
- break;
- case VIK_UNITS_HEIGHT_FEET:
- wp->altitude = VIK_FEET_TO_METERS(atof ( gtk_entry_get_text ( GTK_ENTRY(altentry) ) ));
- break;
- default:
- wp->altitude = atof ( gtk_entry_get_text ( GTK_ENTRY(altentry) ) );
- g_critical("Houston, we've had a problem. height=%d", height_units);
- }
- vik_waypoint_set_comment ( wp, gtk_entry_get_text ( GTK_ENTRY(commententry) ) );
- vik_waypoint_set_description ( wp, gtk_entry_get_text ( GTK_ENTRY(descriptionentry) ) );
- vik_waypoint_set_image ( wp, vik_file_entry_get_filename ( VIK_FILE_ENTRY(imageentry) ) );
- if ( wp->image && *(wp->image) && (!a_thumbnails_exists(wp->image)) )
- a_thumbnails_create ( wp->image );
-
- GtkTreeIter iter, first;
- gtk_tree_model_get_iter_first ( GTK_TREE_MODEL(store), &first );
- if ( !gtk_combo_box_get_active_iter ( GTK_COMBO_BOX(symbolentry), &iter ) || !memcmp(&iter, &first, sizeof(GtkTreeIter)) ) {
- vik_waypoint_set_symbol ( wp, NULL );
- } else {
- gchar *sym;
- gtk_tree_model_get ( GTK_TREE_MODEL(store), &iter, 0, (void *)&sym, -1 );
- vik_waypoint_set_symbol ( wp, sym );
- g_free(sym);
- }
+ if ( strlen((gchar*)gtk_entry_get_text ( GTK_ENTRY(nameentry) )) == 0 ) /* TODO: other checks (isalpha or whatever ) */
+ a_dialog_info_msg ( parent, _("Please enter a name for the waypoint.") );
+ else {
+ // NB: No check for unique names - this allows generation of same named entries.
+ gchar *entered_name = g_strdup ( (gchar*)gtk_entry_get_text ( GTK_ENTRY(nameentry) ) );
- gtk_widget_destroy ( dialog );
- return entered_name;
- }
- }
- else
- {
+ /* Do It */
ll.lat = convert_dms_to_dec ( gtk_entry_get_text ( GTK_ENTRY(latentry) ) );
ll.lon = convert_dms_to_dec ( gtk_entry_get_text ( GTK_ENTRY(lonentry) ) );
vik_coord_load_from_latlon ( &(wp->coord), coord_mode, &ll );
+ // Always store in metres
switch (height_units) {
case VIK_UNITS_HEIGHT_METRES:
- wp->altitude = atof ( gtk_entry_get_text ( GTK_ENTRY(altentry) ) );
- break;
+ wp->altitude = atof ( gtk_entry_get_text ( GTK_ENTRY(altentry) ) );
+ break;
case VIK_UNITS_HEIGHT_FEET:
- wp->altitude = VIK_FEET_TO_METERS(atof ( gtk_entry_get_text ( GTK_ENTRY(altentry) ) ));
- break;
+ wp->altitude = VIK_FEET_TO_METERS(atof ( gtk_entry_get_text ( GTK_ENTRY(altentry) ) ));
+ break;
default:
- wp->altitude = atof ( gtk_entry_get_text ( GTK_ENTRY(altentry) ) );
- g_critical("Houston, we've had a problem. height=%d", height_units);
+ wp->altitude = atof ( gtk_entry_get_text ( GTK_ENTRY(altentry) ) );
+ g_critical("Houston, we've had a problem. height=%d", height_units);
}
- if ( (! wp->comment) || strcmp ( wp->comment, gtk_entry_get_text ( GTK_ENTRY(commententry) ) ) != 0 )
+ if ( g_strcmp0 ( wp->comment, gtk_entry_get_text ( GTK_ENTRY(commententry) ) ) )
vik_waypoint_set_comment ( wp, gtk_entry_get_text ( GTK_ENTRY(commententry) ) );
- if ( (! wp->description) || strcmp ( wp->description, gtk_entry_get_text ( GTK_ENTRY(descriptionentry) ) ) != 0 )
+ if ( g_strcmp0 ( wp->description, gtk_entry_get_text ( GTK_ENTRY(descriptionentry) ) ) )
vik_waypoint_set_description ( wp, gtk_entry_get_text ( GTK_ENTRY(descriptionentry) ) );
- if ( (! wp->image) || strcmp ( wp->image, vik_file_entry_get_filename ( VIK_FILE_ENTRY ( imageentry ) ) ) != 0 )
- {
+ if ( g_strcmp0 ( wp->image, vik_file_entry_get_filename ( VIK_FILE_ENTRY(imageentry) ) ) )
vik_waypoint_set_image ( wp, vik_file_entry_get_filename ( VIK_FILE_ENTRY(imageentry) ) );
- if ( wp->image && *(wp->image) && (!a_thumbnails_exists(wp->image)) )
- a_thumbnails_create ( wp->image );
+ if ( wp->image && *(wp->image) && (!a_thumbnails_exists(wp->image)) )
+ a_thumbnails_create ( wp->image );
+
+ GtkTreeIter iter, first;
+ gtk_tree_model_get_iter_first ( GTK_TREE_MODEL(store), &first );
+ if ( !gtk_combo_box_get_active_iter ( GTK_COMBO_BOX(symbolentry), &iter ) || !memcmp(&iter, &first, sizeof(GtkTreeIter)) ) {
+ vik_waypoint_set_symbol ( wp, NULL );
+ } else {
+ gchar *sym;
+ gtk_tree_model_get ( GTK_TREE_MODEL(store), &iter, 0, (void *)&sym, -1 );
+ vik_waypoint_set_symbol ( wp, sym );
+ g_free(sym);
}
- {
- GtkTreeIter iter, first;
- gtk_tree_model_get_iter_first ( GTK_TREE_MODEL(store), &first );
- if ( !gtk_combo_box_get_active_iter ( GTK_COMBO_BOX(symbolentry), &iter ) || !memcmp(&iter, &first, sizeof(GtkTreeIter)) ) {
- vik_waypoint_set_symbol ( wp, NULL );
- } else {
- gchar *sym;
- gtk_tree_model_get ( GTK_TREE_MODEL(store), &iter, 0, (void *)&sym, -1 );
- vik_waypoint_set_symbol ( wp, sym );
- g_free(sym);
- }
- }
-
gtk_widget_destroy ( dialog );
-
- *updated = TRUE;
- return NULL;
+ if ( is_new )
+ return entered_name;
+ else {
+ *updated = TRUE;
+ // See if name has been changed
+ if ( g_strcmp0 (default_name, entered_name ) )
+ return entered_name;
+ else
+ return NULL;
+ }
}
}
gtk_widget_destroy ( dialog );
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,
}
/* 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;
}
}
/**
+ * 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 )
{
"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
+ 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,
"authors", AUTHORS,
"documenters", DOCUMENTERS,
"translator-credits", _("Translation is coordinated on http://launchpad.net/viking"),
+ "artists", libs,
NULL);
}