#include "viking.h"
#include "thumbnails.h"
+#include "garminsymbols.h"
+#include "degrees_converters.h"
+#include "authors.h"
+#include "googlesearch.h"
#include <stdlib.h>
#include <string.h>
if ( gtk_dialog_run ( GTK_DIALOG(dialog) ) == GTK_RESPONSE_ACCEPT )
{
- ll->lat = atof ( gtk_entry_get_text ( GTK_ENTRY(lat) ) );
- ll->lon = atof ( gtk_entry_get_text ( GTK_ENTRY(lon) ) );
+ ll->lat = convert_dms_to_dec ( gtk_entry_get_text ( GTK_ENTRY(lat) ) );
+ ll->lon = convert_dms_to_dec ( gtk_entry_get_text ( GTK_ENTRY(lon) ) );
gtk_widget_destroy ( dialog );
return TRUE;
}
GTK_RESPONSE_ACCEPT,
NULL);
struct LatLon ll;
- GtkWidget *latlabel, *lonlabel, *namelabel, *latentry, *lonentry, *altentry, *altlabel, *nameentry, *commentlabel, *commententry, *imagelabel, *imageentry;
+ GtkWidget *latlabel, *lonlabel, *namelabel, *latentry, *lonentry, *altentry, *altlabel, *nameentry, *commentlabel,
+ *commententry, *imagelabel, *imageentry, *symbollabel, *symbolentry;
+ GtkListStore *store;
+
+
+
gchar *lat, *lon, *alt;
commentlabel = gtk_label_new ("Comment:");
commententry = gtk_entry_new ();
+ gchar *cmt = a_googlesearch_get_search_string_for_this_place(parent);
+ if (cmt)
+ gtk_entry_set_text(GTK_ENTRY(commententry), cmt);
imagelabel = gtk_label_new ("Image:");
imageentry = vik_file_entry_new ();
+ {
+ GtkCellRenderer *r;
+ symbollabel = gtk_label_new ("Symbol:");
+ GtkTreeIter iter;
+
+ store = gtk_list_store_new(3, G_TYPE_STRING, GDK_TYPE_PIXBUF, G_TYPE_STRING);
+ symbolentry = gtk_combo_box_new_with_model(GTK_TREE_MODEL(store));
+ gtk_combo_box_set_wrap_width(GTK_COMBO_BOX(symbolentry), 3);
+ gtk_list_store_append (store, &iter);
+ gtk_list_store_set (store, &iter, 0, NULL, 1, NULL, 2, "(none)", -1);
+ a_populate_sym_list(store);
+
+ r = gtk_cell_renderer_pixbuf_new ();
+ gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (symbolentry), r, FALSE);
+ gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (symbolentry), r, "pixbuf", 1, NULL);
+
+ r = gtk_cell_renderer_text_new ();
+ gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (symbolentry), r, FALSE);
+ gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (symbolentry), r, "text", 2, NULL);
+
+ if ( dest == NULL && wp->symbol ) {
+ gboolean ok;
+ gchar *sym;
+ for (ok = gtk_tree_model_get_iter_first ( GTK_TREE_MODEL(store), &iter ); ok; ok = gtk_tree_model_iter_next ( GTK_TREE_MODEL(store), &iter)) {
+ gtk_tree_model_get ( GTK_TREE_MODEL(store), &iter, 0, (void *)&sym, -1 );
+ if (sym && !strcmp(sym, wp->symbol)) {
+ g_free(sym);
+ break;
+ } else {
+ g_free(sym);
+ }
+ }
+ gtk_combo_box_set_active_iter(GTK_COMBO_BOX(symbolentry), &iter);
+ }
+ }
+
if ( dest == NULL && wp->comment )
gtk_entry_set_text ( GTK_ENTRY(commententry), wp->comment );
if ( dest == NULL && wp->image )
vik_file_entry_set_filename ( VIK_FILE_ENTRY(imageentry), wp->image );
-
gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), latlabel, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), latentry, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), commententry, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), imagelabel, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), imageentry, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), symbollabel, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), GTK_WIDGET(symbolentry), FALSE, FALSE, 0);
gtk_widget_show_all ( GTK_DIALOG(dialog)->vbox );
-
+
while ( gtk_dialog_run ( GTK_DIALOG(dialog) ) == GTK_RESPONSE_ACCEPT )
{
if ( dest )
{
/* Do It */
*dest = name;
- ll.lat = atof ( gtk_entry_get_text ( GTK_ENTRY(latentry) ) );
- ll.lon = atof ( gtk_entry_get_text ( GTK_ENTRY(lonentry) ) );
+ 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 );
wp->altitude = atof ( gtk_entry_get_text ( GTK_ENTRY(altentry) ) );
vik_waypoint_set_comment ( wp, gtk_entry_get_text ( GTK_ENTRY(commententry) ) );
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);
+ }
+ }
+
gtk_widget_destroy ( dialog );
return TRUE;
}
}
else
{
- ll.lat = atof ( gtk_entry_get_text ( GTK_ENTRY(latentry) ) );
- ll.lon = atof ( gtk_entry_get_text ( GTK_ENTRY(lonentry) ) );
+ 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 );
wp->altitude = atof ( gtk_entry_get_text ( GTK_ENTRY(altentry) ) );
if ( (! wp->comment) || strcmp ( wp->comment, gtk_entry_get_text ( GTK_ENTRY(commententry) ) ) != 0 )
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);
+ }
+ }
+
gtk_widget_destroy ( dialog );
return TRUE;
gtk_widget_destroy ( dialog );
return FALSE;
}
+
+
+void a_dialog_about ( GtkWindow *parent )
+{
+ int re;
+ char *msg = g_markup_printf_escaped (
+ "<span font_desc='20' weight='bold'>Viking %s</span>\n\n"
+ "GPS Data and Topo Analyzer, Explorer, and Manager.\n\n"
+ "<small>(C) 2003-2007, Evan Battaglia</small>\n\n"
+ "<small>Web site: %s</small>",
+ VIKING_VERSION, VIKING_URL);
+ GtkWidget *msgbox = gtk_message_dialog_new_with_markup ( parent,
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_INFO,
+ GTK_BUTTONS_NONE,
+ msg);
+
+ gtk_dialog_add_buttons (GTK_DIALOG(msgbox), "Credits", 1, "License", 2, "Close", 3, NULL, NULL);
+
+ while ((re = gtk_dialog_run ( GTK_DIALOG(msgbox))) != 3) {
+ if (re==1) {
+ /* creds */
+ a_dialog_info_msg(parent, AUTHORS);
+ }
+ if (re==2) {
+ a_dialog_info_msg(parent, "\n\n"
+ "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."
+ "\n\n"
+ "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."
+ "\n\n"
+ "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");
+ }
+ }
+ gtk_widget_destroy ( msgbox );
+}
+
+gboolean a_dialog_map_n_zoom(GtkWindow *parent, gchar *mapnames[], gint default_map, gchar *zoom_list[], gint default_zoom, gint *selected_map, gint *selected_zoom)
+{
+ gchar **s;
+
+ GtkWidget *dialog = gtk_dialog_new_with_buttons ( "Download along track", parent, 0, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, NULL );
+
+ GtkWidget *map_label = gtk_label_new("Map type:");
+ GtkWidget *map_combo = GTK_COMBO_BOX(gtk_combo_box_new_text());
+ for (s = mapnames; *s; s++)
+ gtk_combo_box_append_text(map_combo, *s);
+ gtk_combo_box_set_active (map_combo, default_map);
+ GtkWidget *zoom_label = gtk_label_new("Zoom level:");
+ GtkWidget *zoom_combo = GTK_COMBO_BOX(gtk_combo_box_new_text());
+ for (s = zoom_list; *s; s++)
+ gtk_combo_box_append_text(zoom_combo, *s);
+ gtk_combo_box_set_active (zoom_combo, default_zoom);
+
+ GtkTable *box = GTK_TABLE(gtk_table_new(2, 2, FALSE));
+ gtk_table_attach_defaults(box, GTK_WIDGET(map_label), 0, 1, 0, 1);
+ gtk_table_attach_defaults(box, GTK_WIDGET(map_combo), 1, 2, 0, 1);
+ gtk_table_attach_defaults(box, GTK_WIDGET(zoom_label), 0, 1, 1, 2);
+ gtk_table_attach_defaults(box, GTK_WIDGET(zoom_combo), 1, 2, 1, 2);
+
+ gtk_box_pack_start ( GTK_BOX(GTK_DIALOG(dialog)->vbox), GTK_WIDGET(box), FALSE, FALSE, 5 );
+
+ gtk_widget_show_all ( dialog );
+ if ( gtk_dialog_run ( GTK_DIALOG(dialog) ) != GTK_RESPONSE_ACCEPT ) {
+ gtk_widget_destroy(dialog);
+ return FALSE;
+ }
+
+ *selected_map = gtk_combo_box_get_active(map_combo);
+ *selected_zoom = gtk_combo_box_get_active(zoom_combo);
+
+ gtk_widget_destroy(dialog);
+ return TRUE;
+}