-static void symbol_entry_changed_cb(GtkWidget *combo, GtkListStore *store)
-{
- GtkTreeIter iter;
- gchar *sym;
-
- if (!gtk_combo_box_get_active_iter(GTK_COMBO_BOX(combo), &iter))
- return;
-
- gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, 0, (void *)&sym, -1 );
- /* Note: symm is NULL when "(none)" is select (first cell is empty) */
- gtk_widget_set_tooltip_text(combo, sym);
- g_free(sym);
-}
-
-/* todo: less on this side, like add track */
-gboolean a_dialog_new_waypoint ( GtkWindow *parent, gchar **dest, VikWaypoint *wp, GHashTable *waypoints, VikCoordMode coord_mode )
-{
- GtkWidget *dialog = gtk_dialog_new_with_buttons (_("Waypoint Properties"),
- parent,
- GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_STOCK_CANCEL,
- GTK_RESPONSE_REJECT,
- GTK_STOCK_OK,
- GTK_RESPONSE_ACCEPT,
- NULL);
- struct LatLon ll;
- GtkWidget *latlabel, *lonlabel, *namelabel, *latentry, *lonentry, *altentry, *altlabel, *nameentry=NULL, *commentlabel,
- *commententry, *imagelabel, *imageentry, *symbollabel, *symbolentry;
- GtkListStore *store;
-
-
-
-
- gchar *lat, *lon, *alt;
-
- vik_coord_to_latlon ( &(wp->coord), &ll );
-
- lat = g_strdup_printf ( "%f", ll.lat );
- lon = g_strdup_printf ( "%f", ll.lon );
- alt = g_strdup_printf ( "%f", wp->altitude );
-
- if ( dest != NULL )
- {
- namelabel = gtk_label_new (_("Name:"));
- nameentry = gtk_entry_new ();
- if ( *dest ) {
- gtk_entry_set_text( GTK_ENTRY(nameentry), *dest );
- g_free ( *dest );
- *dest = NULL;
- }
- g_signal_connect_swapped ( nameentry, "activate", G_CALLBACK(a_dialog_response_accept), GTK_DIALOG(dialog) );
- gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), namelabel, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), nameentry, FALSE, FALSE, 0);
- }
-
- latlabel = gtk_label_new (_("Latitude:"));
- latentry = gtk_entry_new ();
- gtk_entry_set_text ( GTK_ENTRY(latentry), lat );
- g_free ( lat );
-
- lonlabel = gtk_label_new (_("Longitude:"));
- lonentry = gtk_entry_new ();
- gtk_entry_set_text ( GTK_ENTRY(lonentry), lon );
- g_free ( lon );
-
- altlabel = gtk_label_new (_("Altitude:"));
- altentry = gtk_entry_new ();
- gtk_entry_set_text ( GTK_ENTRY(altentry), alt );
- g_free ( alt );
-
- commentlabel = gtk_label_new (_("Comment:"));
- commententry = gtk_entry_new ();
- gchar *cmt = a_googlesearch_get_search_string_for_this_place(VIK_WINDOW(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), 6);
- g_signal_connect(symbolentry, "changed",
- G_CALLBACK(symbol_entry_changed_cb), store);
- 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), lonlabel, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), lonentry, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), altlabel, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), altentry, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), commentlabel, 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 )
- {
- const gchar *constname = gtk_entry_get_text ( GTK_ENTRY(nameentry) );
- if ( strlen(constname) == 0 ) /* TODO: other checks (isalpha or whatever ) */
- a_dialog_info_msg ( parent, _("Please enter a name for the waypoint.") );
- else {
- gchar *name = g_strdup ( constname );
-
- if ( g_hash_table_lookup ( waypoints, name ) && !a_dialog_overwrite ( parent, _("The waypoint \"%s\" exists, do you want to overwrite it?"), name ) )
- g_free ( name );
- else
- {
- /* Do It */
- *dest = name;
- 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 (valid name) */
- }
- else
- {
- 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 )
- vik_waypoint_set_comment ( wp, gtk_entry_get_text ( GTK_ENTRY(commententry) ) );
- if ( (! wp->image) || strcmp ( wp->image, vik_file_entry_get_filename ( VIK_FILE_ENTRY ( imageentry ) ) ) != 0 )
- {
- 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;
- }
- }
- gtk_widget_destroy ( dialog );
- return FALSE;
-}
-