Use status bar for message in !hildon mode. Timeout messages in 5 seconds.
Misc other changes.
#ifdef WITH_HILDON
ossohelp_show(_osso, HELP_ID_ABOUT, OSSO_HELP_SHOW_DIALOG);
#else
- gtk_show_about_dialog(GTK_WINDOW(_window), "name", "OSM-Mapper",
- "version", "0.1", NULL);
+ gtk_show_about_dialog(GTK_WINDOW(_window), "name", "Mapper",
+ "version", VERSION, NULL);
#endif
vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
gchar buffer[80], tmp1[16], tmp2[16];
printf("%s()\n", __PRETTY_FUNCTION__);
+ g_printf("S: %d %d\n", unitx, unity);
+
unit2latlon(unitx, unity, lat, lon);
lat_format(lat, tmp1);
lon_format(lon, tmp2);
gboolean sat_panel_expose(GtkWidget * widget, GdkEventExpose * event);
gboolean sat_details_panel_expose(GtkWidget * widget, GdkEventExpose * event);
-gboolean
-channel_cb_error(GIOChannel * src, GIOCondition condition, gpointer data);
-gboolean
-channel_cb_connect(GIOChannel * src, GIOCondition condition, gpointer data);
-gboolean
-channel_cb_input(GIOChannel * src, GIOCondition condition, gpointer data);
+gboolean channel_cb_error(GIOChannel * src, GIOCondition condition, gpointer data);
+gboolean channel_cb_connect(GIOChannel * src, GIOCondition condition, gpointer data);
+gboolean channel_cb_input(GIOChannel * src, GIOCondition condition, gpointer data);
/* Callbacks for the "Route" submenu. */
gboolean menu_cb_route_download(GtkAction * action);
#include "mapper-types.h"
#include "map.h"
#include "route.h"
+#include "db.h"
#include "poi.h"
#include "gps.h"
#include "ui-common.h"
gnome_vfs_uri_make_full_from_relative(poi_base, "poi.db");
g_free(poi_base);
}
- db_connect(_db, _poi_db);
+ db_connect(&_db, _poi_db);
_poi_zoom = gconf_client_get_int(gconf_client,
GCONF_KEY_POI_ZOOM, NULL);
+#include "config.h"
+
#include <gtk/gtk.h>
#include <sqlite3.h>
#include <libintl.h>
#include <locale.h>
-static sqlite3_stmt *_stmt_select_poi = NULL;
-static sqlite3_stmt *_stmt_select_nearest_poi = NULL;
-static sqlite3_stmt *_stmt_insert_poi = NULL;
-static sqlite3_stmt *_stmt_update_poi = NULL;
-static sqlite3_stmt *_stmt_delete_poi = NULL;
-static sqlite3_stmt *_stmt_delete_poi_by_catid = NULL;
-static sqlite3_stmt *_stmt_nextlabel_poi = NULL;
-
-static sqlite3_stmt *_stmt_select_cat = NULL;
-static sqlite3_stmt *_stmt_insert_cat = NULL;
-static sqlite3_stmt *_stmt_update_cat = NULL;
-static sqlite3_stmt *_stmt_delete_cat = NULL;
-static sqlite3_stmt *_stmt_toggle_cat = NULL;
-static sqlite3_stmt *_stmt_selall_cat = NULL;
-
-gboolean db_connect(sqlite3 * db, gchar * poi_db)
+#include "utils.h"
+#include "ui-common.h"
+#include "poi.h"
+
+sqlite3_stmt *_stmt_select_poi = NULL;
+sqlite3_stmt *_stmt_select_nearest_poi = NULL;
+sqlite3_stmt *_stmt_insert_poi = NULL;
+sqlite3_stmt *_stmt_update_poi = NULL;
+sqlite3_stmt *_stmt_delete_poi = NULL;
+sqlite3_stmt *_stmt_delete_poi_by_catid = NULL;
+sqlite3_stmt *_stmt_nextlabel_poi = NULL;
+
+sqlite3_stmt *_stmt_select_cat = NULL;
+sqlite3_stmt *_stmt_insert_cat = NULL;
+sqlite3_stmt *_stmt_update_cat = NULL;
+sqlite3_stmt *_stmt_delete_cat = NULL;
+sqlite3_stmt *_stmt_toggle_cat = NULL;
+sqlite3_stmt *_stmt_selall_cat = NULL;
+
+gboolean db_prepare(sqlite3 *db)
+{
+
+return TRUE;
+}
+
+gboolean db_close(sqlite3 *db)
+{
+if (db) {
+ sqlite3_close(db);
+ db=NULL;
+}
+return TRUE;
+}
+
+gboolean db_connect(sqlite3 **ndb, const gchar *poi_db)
{
gchar buffer[100];
gchar *perror;
gchar **pszResult;
guint nRow, nColumn;
+ sqlite3 *db;
+
printf("%s()\n", __PRETTY_FUNCTION__);
+ if (ndb && *ndb)
+ db=*ndb;
+ else
+ db=NULL;
+
if (db) {
sqlite3_close(db);
db = NULL;
sqlite3_errmsg(db));
sqlite3_close(db);
db = NULL;
- /* popup_error(_window, buffer2); */
+ popup_error(_window, buffer2);
return FALSE;
}
+ *ndb=db;
+
if (SQLITE_OK != sqlite3_get_table(db, "select label from poi limit 1",
&pszResult, &nRow, &nColumn, NULL)) {
gchar *create_sql;
sqlite3_errmsg(db));
sqlite3_close(db);
db = NULL;
- /*popup_error(_window, buffer); */
+ popup_error(_window, buffer);
return FALSE;
}
} else
#include "ui-common.h"
#include "hildon-wrappers.h"
+gboolean
+file_open(gchar *dir, gchar *file, GnomeVFSHandle **vfs)
+{
+GtkWidget *dialog;
+gboolean success;
+
+#ifdef WITH_HILDON
+dialog = hildon_file_chooser_dialog_new(GTK_WINDOW(_window), GTK_FILE_CHOOSER_ACTION_OPEN);
+#else
+dialog = gtk_file_chooser_dialog_new("Open...", GTK_WINDOW(_window), GTK_FILE_CHOOSER_ACTION_OPEN,
+ GTK_STOCK_CANCEL,
+ GTK_RESPONSE_CANCEL,
+ GTK_STOCK_OPEN,
+ GTK_RESPONSE_ACCEPT, NULL);
+#endif
+
+if (dir)
+ gtk_file_chooser_set_current_folder_uri(GTK_FILE_CHOOSER(dialog), dir);
+
+if (file)
+ gtk_file_chooser_set_uri(GTK_FILE_CHOOSER(dialog), file);
+
+while (!success && gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK) {
+ gchar *file_uri_str;
+ GnomeVFSResult vfs_result;
+
+ /* Get the selected filename. */
+ file_uri_str = gtk_file_chooser_get_uri(GTK_FILE_CHOOSER(dialog));
+
+ printf("file: %s\n", file_uri_str);
+
+ g_free(file_uri_str);
+}
+
+}
+
+gboolean
+file_save(gchar *dir, gchar *file, GnomeVFSHandle **vfs)
+{
+GtkWidget *dialog;
+gboolean success;
+
+#ifdef WITH_HILDON
+dialog = hildon_file_chooser_dialog_new(GTK_WINDOW(_window), GTK_FILE_CHOOSER_ACTION_SAVE);
+#else
+dialog = gtk_file_chooser_dialog_new("Save...", GTK_WINDOW(_window), GTK_FILE_CHOOSER_ACTION_SAVE,
+ GTK_STOCK_CANCEL,
+ GTK_RESPONSE_CANCEL,
+ GTK_STOCK_SAVE,
+ GTK_RESPONSE_ACCEPT, NULL);
+gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(dialog), TRUE);
+#endif
+
+if (dir)
+ gtk_file_chooser_set_current_folder_uri(GTK_FILE_CHOOSER(dialog), dir);
+
+if (file)
+ gtk_file_chooser_set_uri(GTK_FILE_CHOOSER(dialog), file);
+
+success=FALSE;
+if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) {
+ gchar *file_uri_str;
+ GnomeVFSResult vfs_result;
+
+ file_uri_str = gtk_file_chooser_get_uri(GTK_FILE_CHOOSER(dialog));
+ vfs_result = gnome_vfs_create(vfs, file_uri_str, GNOME_VFS_OPEN_WRITE, FALSE, 0664);
+ g_free(file_uri_str);
+
+ if (vfs_result!=GNOME_VFS_OK) {
+ success=FALSE;
+ } else {
+ if (dir) {
+ g_free(dir);
+ dir = gtk_file_chooser_get_current_folder_uri(GTK_FILE_CHOOSER(dialog));
+ }
+ if (file) {
+ g_free(file);
+ file = gtk_file_chooser_get_uri(GTK_FILE_CHOOSER(dialog));
+ }
+ success=TRUE;
+ }
+}
+
+gtk_widget_destroy(dialog);
+return success;
+}
+
/**
* This is a multi-purpose function for allowing the user to select a file
* for either reading or writing. If chooser_action is
gboolean success = FALSE;
printf("%s()\n", __PRETTY_FUNCTION__);
- dialog =
- hildon_file_chooser_dialog_new(GTK_WINDOW(_window), chooser_action);
+ dialog = hildon_file_chooser_dialog_new(GTK_WINDOW(_window), chooser_action);
if (dir && *dir)
gtk_file_chooser_set_current_folder_uri(GTK_FILE_CHOOSER
return dialog;
}
-void hildon_banner_show_information(void *w, void *t, gchar * text)
+static gboolean
+status_bar_clear(void)
{
- static guint cid = 0;
-
- if (cid != 0)
- gtk_statusbar_pop(_status_bar, cid);
+ gtk_statusbar_pop(_status_bar, 0);
+ return FALSE;
+}
- cid = gtk_statusbar_get_context_id(_status_bar, text);
- gtk_statusbar_push(_status_bar, cid, text);
+void hildon_banner_show_information(GtkWidget *w, void *t, gchar *text)
+{
+ gtk_statusbar_pop(_status_bar, 0);
+ gtk_statusbar_push(_status_bar, 0, text);
+ g_timeout_add(5000, status_bar_clear, NULL);
}
GtkWidget *hildon_banner_show_progress(GtkWidget * widget, GtkProgressBar * bar,
const gchar * text)
{
- hildon_banner_show_information(NULL, NULL, text);
+ hildon_banner_show_information(_status_bar, NULL, text);
return NULL;
}
-GtkWidget *hildon_note_new_confirmation(GtkWidget * w, gchar * text)
+GtkWidget *hildon_note_new_confirmation(GtkWidget *widget, const gchar *text)
{
- GtkWidget *dialog;
- dialog = gtk_message_dialog_new(w,
+ return gtk_message_dialog_new(widget,
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_ERROR,
GTK_BUTTONS_OK_CANCEL, text);
-
- return dialog;
}
-void hildon_banner_set_fraction(GtkWidget * w, gfloat tmp)
+void hildon_banner_set_fraction(GtkWidget * widget, gfloat tmp)
{
+
}
GtkWidget *hildon_banner_show_animation(GtkWidget * widget,
const gchar * animation_name,
const gchar * text)
{
- g_print(animation_name);
- g_print(text);
+ hildon_banner_show_information(_status_bar, NULL, text);
return NULL;
}
(_menu_ac_none_item),
TRUE);
+ if (TRUE) {
+ map_draw_track(event->x, event->y);
+ }
+
map_center_unit(x2unit((gint) (event->x + 0.5)),
y2unit((gint) (event->y + 0.5)));
break;
before[1] = 0;
break;
case 3:
- /* map_draw_track(event->x, event->y); */
break;
}
if (!_connect_banner)
_connect_banner =
hildon_banner_show_animation(_window, NULL,
- _
- ("Searching for GPS receiver"));
+ _("Searching for GPS receiver"));
break;
case RCVR_UP:
if (_connect_banner) {
if (!_fix_banner)
_fix_banner =
hildon_banner_show_progress(_window, NULL,
- _
- ("Establishing GPS fix"));
+ _("Establishing GPS fix"));
break;
default:; /* to quell warning. */
}
+/*
+
+POI table definitions:
+
+-- public POIs from different sources
+-- (Fuel, pubs, museums, etc)
+--
+create table poi (
+ poi_id integer PRIMARY KEY,
+ cat_id integer,
+ source int,
+ source_id int,
+ type int,
+ lat real,
+ lon real,
+ elev real,
+ label text,
+ desc text,
+ wikipedia text,
+ url text,
+ phone varchar(64),
+ email varchar(64),
+);
+
+-- type:
+-- 0=POI
+-- 1=Landmark
+
+-- Shared categories for POIs and landmarks
+create table category (
+ cat_id integer PRIMARY KEY,
+ priority int,
+ label text,
+ desc text,
+ color char(6),
+ icon varchar(32),
+ enabled integer
+);
+
+*/
+
#ifndef _MAPPER_POI_H
#define _MAPPER_POI_H
#include <sqlite3.h>
+typedef enum {
+ POI_TYPE_POINT=0,
+ POI_TYPE_LANDMARK=1,
+} poi_types_e;
+
typedef struct _PoiDb PoiDb;
struct _PoiDb {
sqlite3 *db;
#include "settings.h"
#include "mapper-types.h"
#include "map.h"
+#include "file.h"
void route_find_nearest_point();
void cancel_autoroute(gboolean temporary);
rcvr_changed = TRUE;
}
- _center_ratio =
- hildon_controlbar_get_value(HILDON_CONTROLBAR
+ _center_ratio = hildon_controlbar_get_value(HILDON_CONTROLBAR
(num_center_ratio));
- _lead_ratio =
- hildon_controlbar_get_value(HILDON_CONTROLBAR
+ _lead_ratio = hildon_controlbar_get_value(HILDON_CONTROLBAR
(num_lead_ratio));
- _draw_width =
- hildon_controlbar_get_value(HILDON_CONTROLBAR
+ _draw_width = hildon_controlbar_get_value(HILDON_CONTROLBAR
(num_draw_width));
- _always_keep_on =
- !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
+ _always_keep_on = !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
(chk_always_keep_on));
_units = gtk_combo_box_get_active(GTK_COMBO_BOX(cmb_units));
- _degformat =
- gtk_combo_box_get_active(GTK_COMBO_BOX(cmb_degformat));
+ _degformat = gtk_combo_box_get_active(GTK_COMBO_BOX(cmb_degformat));
- _speed_limit_on =
- gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
+ _speed_limit_on = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
(chk_speed_limit_on));
- _speed_limit =
- hildon_number_editor_get_value(HILDON_NUMBER_EDITOR
+ _speed_limit = hildon_number_editor_get_value(HILDON_NUMBER_EDITOR
(num_speed));
- _speed_location =
- gtk_combo_box_get_active(GTK_COMBO_BOX(cmb_speed_location));
+ _speed_location = gtk_combo_box_get_active(GTK_COMBO_BOX(cmb_speed_location));
- _info_font_size =
- gtk_combo_box_get_active(GTK_COMBO_BOX(cmb_info_font_size));
+ _info_font_size = gtk_combo_box_get_active(GTK_COMBO_BOX(cmb_info_font_size));
- _announce_notice_ratio =
- hildon_controlbar_get_value(HILDON_CONTROLBAR
+ _announce_notice_ratio = hildon_controlbar_get_value(HILDON_CONTROLBAR
(num_announce_notice));
- _voice_speed =
- hildon_controlbar_get_value(HILDON_CONTROLBAR
+ _voice_speed = hildon_controlbar_get_value(HILDON_CONTROLBAR
(num_voice_speed)) / 3.0;
- _voice_pitch =
- hildon_controlbar_get_value(HILDON_CONTROLBAR
+ _voice_pitch = hildon_controlbar_get_value(HILDON_CONTROLBAR
(num_voice_pitch));
- _enable_voice =
- gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
+ _enable_voice = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
(chk_enable_voice));
if (_db) {
}
g_free(_poi_db);
if (strlen(gtk_entry_get_text(GTK_ENTRY(txt_poi_db)))) {
- _poi_db =
- g_strdup(gtk_entry_get_text(GTK_ENTRY(txt_poi_db)));
- db_connect(_db, _poi_db);
+ _poi_db = g_strdup(gtk_entry_get_text(GTK_ENTRY(txt_poi_db)));
+ db_connect(&_db, _poi_db);
} else
_poi_db = NULL;
gtk_widget_set_sensitive(_cmenu_poi, _db != NULL);
gtk_widget_set_sensitive(_menu_poi_item, _db != NULL);
- _poi_zoom =
- hildon_number_editor_get_value(HILDON_NUMBER_EDITOR
- (num_poi_zoom));
+ _poi_zoom = hildon_number_editor_get_value(HILDON_NUMBER_EDITOR(num_poi_zoom));
update_gcs();
#include "settings.h"
#include "mapper-types.h"
#include "ui-common.h"
+#include "file.h"
void path_resize(Path * path, guint size)
{
gint size;
gboolean r = FALSE;
- if (open_file
- (&buffer, NULL, &size, NULL, &_track_file_uri,
- GTK_FILE_CHOOSER_ACTION_OPEN)) {
+ if (open_file(&buffer, NULL, &size, NULL, &_track_file_uri, GTK_FILE_CHOOSER_ACTION_OPEN)) {
if (parse_gpx(&_track, buffer, size, -1)) {
map_force_redraw();
MACRO_BANNER_SHOW_INFO(_window, _("Track Opened"));
GnomeVFSHandle *handle;
gboolean r = FALSE;
- if (open_file(NULL, &handle, NULL, NULL, &_track_file_uri,
- GTK_FILE_CHOOSER_ACTION_SAVE)) {
+/* if (open_file(NULL, &handle, NULL, NULL, &_track_file_uri, GTK_FILE_CHOOSER_ACTION_SAVE)) { */
+
+ if (file_save(_track_file_uri, _track_file_uri, &handle)) {
if (write_gpx(&_track, handle)) {
MACRO_BANNER_SHOW_INFO(_window, _("Track Saved"));
r = TRUE;
if (*desc) {
MACRO_PATH_INCREMENT_WTAIL(_track);
_track.wtail->point = _track.tail;
- _track.wtail->desc
- = gtk_text_buffer_get_text(tbuf, &ti1, &ti2, TRUE);
+ _track.wtail->desc = gtk_text_buffer_get_text(tbuf, &ti1, &ti2, TRUE);
} else {
- popup_error(dialog,
- _
- ("Please provide a description for the mark."));
+ popup_error(dialog, _("Please provide a description for the mark."));
g_free(desc);
continue;
}
break;
}
gtk_widget_destroy(dialog);
-
}
GtkWidget *_file_item;
_file_item = gtk_menu_item_new_with_label("File");
-
-/* gtk_widget_show_all(GTK_WIDGET(_menu_bar));*/
-
#if 1
- gtk_menu_item_set_submenu(GTK_MENU_ITEM(_file_item), GTK_MENU(menu));
- gtk_menu_bar_append(GTK_MENU_BAR(_menu_bar), _file_item);
+ gtk_menu_item_set_submenu(GTK_MENU_ITEM(_file_item), GTK_WIDGET(menu));
+ gtk_menu_bar_append(GTK_MENU_BAR(_menu_bar), GTK_WIDGET(_file_item));
#else
gtk_menu_bar_append(GTK_MENU_BAR(_menu_bar), menu);
#endif
= gtk_menu_item_new_with_label(_("Show Distance to")));
gtk_menu_append(submenu, _cmenu_way_route_to_item
=
- gtk_menu_item_new_with_label(_
- ("Download Route to...")));
+ gtk_menu_item_new_with_label(_("Download Route to...")));
gtk_menu_append(submenu, _cmenu_way_delete_item =
gtk_menu_item_new_with_label(_("Delete...")));
gtk_menu_append(submenu, gtk_separator_menu_item_new());
- gtk_menu_append(submenu, _cmenu_way_add_poi
- = gtk_menu_item_new_with_label(_("Add POI...")));
+ gtk_menu_append(submenu, _cmenu_way_add_poi = gtk_menu_item_new_with_label(_("Add POI...")));
gtk_widget_set_sensitive(_cmenu_way_add_poi, _db != NULL);
gtk_menu_append(submenu, gtk_separator_menu_item_new());
- gtk_menu_append(submenu, _cmenu_way_goto_nextway
- = gtk_menu_item_new_with_label(_("Go to Next")));
+ gtk_menu_append(submenu, _cmenu_way_goto_nextway = gtk_menu_item_new_with_label(_("Go to Next")));
/* Setup the POI context menu. */
- gtk_menu_append(menu, _cmenu_poi
- = gtk_menu_item_new_with_label(_("POI")));
+ gtk_menu_append(menu, _cmenu_poi = gtk_menu_item_new_with_label(_("POI")));
gtk_widget_set_sensitive(_cmenu_poi, _db != NULL);
- gtk_menu_item_set_submenu(GTK_MENU_ITEM(_cmenu_poi),
- submenu = gtk_menu_new());
+ gtk_menu_item_set_submenu(GTK_MENU_ITEM(_cmenu_poi), submenu = gtk_menu_new());
gtk_menu_append(submenu, _cmenu_poi_edit_poi
= gtk_menu_item_new_with_label(_("View/Edit...")));
#include <libxml/parser.h>
#include "mapper-types.h"
+#include "ui-maemo.h"
+#include "hildon-wrappers.h"
/** The main GtkContainer of the application. */
GtkWidget *_window;
GtkMenu *_menu_map;
-/** CONTEXT MENU ITEMS. */
+/** Context menu click location on map */
guint _cmenu_position_x;
guint _cmenu_position_y;
gboolean window_present();
-
-#include "ui-maemo.h"
-#include "hildon-wrappers.h"
+void popup_error(GtkWidget * window, const gchar * error);
#endif
* BELOW: DEFINES ***********************************************************
****************************************************************************/
-#define DEBUG
+/* #define DEBUG */
#ifndef DEBUG
#define printf(...)
g_free(my_macro_buffer); \
}
#else
-#define MACRO_BANNER_SHOW_INFO(A, S) { g_print("INFO: %s\n", (S)); }
+#define MACRO_BANNER_SHOW_INFO(A, S) { hildon_banner_show_information(A, NULL, S); }
#endif
#define GPS_READ_BUF_SIZE 256