First try at a simple autozoomer.
gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(lst_devices), TRUE);
renderer = gtk_cell_renderer_text_new();
- column =
- gtk_tree_view_column_new_with_attributes(_("MAC"), renderer, "text",
- 0);
+ column = gtk_tree_view_column_new_with_attributes(_("MAC"), renderer, "text", 0, NULL);
gtk_tree_view_append_column(GTK_TREE_VIEW(lst_devices), column);
renderer = gtk_cell_renderer_text_new();
- column =
- gtk_tree_view_column_new_with_attributes(_("Description"), renderer,
- "text", 1);
+ column = gtk_tree_view_column_new_with_attributes(_("Description"), renderer, "text", 1, NULL);
gtk_tree_view_append_column(GTK_TREE_VIEW(lst_devices), column);
gtk_widget_show_all(dialog);
return TRUE;
}
-gboolean cb_zoom_fit(GtkAction * action)
+gboolean cb_zoom_autozoom(GtkAction * action)
{
printf("%s()\n", __PRETTY_FUNCTION__);
- map_zoom(10);
+ map_set_autozoom(TRUE);
+
+ vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
+ return TRUE;
+}
+
+gboolean cb_zoom_base(GtkAction * action)
+{
+ printf("%s()\n", __PRETTY_FUNCTION__);
+
+ map_set_autozoom(FALSE);
+ map_set_zoom(4);
vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
return TRUE;
{
printf("%s()\n", __PRETTY_FUNCTION__);
+ map_set_autozoom(FALSE);
map_zoom(-1);
vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
{
printf("%s()\n", __PRETTY_FUNCTION__);
+ map_set_autozoom(FALSE);
map_zoom(1);
vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
gboolean menu_cb_auto_download(GtkAction * action);
/* Callbacks for the "View" submenu. */
+gboolean cb_zoom_autozoom(GtkAction * action);
+gboolean cb_zoom_base(GtkAction * action);
gboolean cb_zoomin(GtkAction * action);
gboolean cb_zoomout(GtkAction * action);
gboolean cb_fullscreen(GtkAction * action);
static guint before[2] = { 0, 0 };
static guint _id = 0;
+static _zoom_timeout=0;
+
void map_render_paths();
void map_force_redraw();
gboolean curl_download_timeout();
return nzoom;
}
+static gboolean
+map_autozoomer()
+{
+static gfloat z=6.0;
+
+if (_zoom_timeout==0)
+ return FALSE;
+
+z=(z+_gps.speed+1)/2;
+if (z>7) z=7.0; else if (z<1) z=1.0;
+map_set_zoom(round(z));
+
+return TRUE;
+}
+
+void
+map_set_autozoom(gboolean az)
+{
+if ((az==TRUE) && (_zoom_timeout!=0)) {
+ _zoom_timeout=g_timeout_add(5000, (GSourceFunc) map_autozoomer, NULL);
+ return;
+}
+
+if ((az==FALSE) && (_zoom_timeout!=0)) {
+ _zoom_timeout=0;
+ return;
+}
+
+}
+
static void map_draw_track(gint x, gint y)
{
_pos.unitx = x2unit((gint) (x + 0.5));
create_sql =
sqlite3_mprintf
- ("create table poi (poi_id integer PRIMARY KEY, lat real, "
- "lon real, label text, desc text, cat_id integer);"
+ ("create table poi (poi_id integer PRIMARY KEY, "
+ "lat real, "
+ "lon real, "
+ "elev real, "
+ "label text, "
+ "desc text, "
+ "public integer, "
+ "cat_id integer);"
"create table category (cat_id integer PRIMARY KEY,"
- "label text, desc text, enabled integer);"
+ "label text, "
+ "desc text, "
+ "icon text, "
+ "color char(7), "
+ "enabled integer);"
/* Add some default categories... */
"insert into category (label, desc, enabled) "
"values ('%q', '%q', 1); "
} else
sqlite3_free_table(pszResult);
+ return TRUE;
}
gboolean
/* select from poi */
sqlite3_prepare(db,
"select p.lat, p.lon, p.poi_id, p.label, p.desc,"
- " p.cat_id, c.label, c.desc"
+ " p.cat_id, c.label, c.desc, c.icon, c.color"
" from poi p, category c "
" where p.lat between ? and ? "
" and p.lon between ? and ? "
sqlite3_prepare(db,
"select p.lat, p.lon, p.label, c.label"
" from poi p, category c "
- " where c.enabled = 1 and p.cat_id = c.cat_id"
+ " where c.enabled = 1 and p.cat_id = c.cat_id "
+ " and p.lat between $LAT-0.15 and $LAT+0.15 "
+ " and p.lon between $LON-0.15 and $LAT+0.15 "
" order by (($LAT - p.lat) * ($LAT - p.lat) "
"+ ($LON - p.lon) * ($LON - p.lon)) limit 1",
-1, &_stmt_select_nearest_poi, NULL);
/* insert poi */
sqlite3_prepare(db,
- "insert into poi (lat, lon, label, desc, cat_id)"
- " values (?, ?, ?, ?, ?)", -1, &_stmt_insert_poi, NULL);
+ "insert into poi (lat, lon, label, desc, cat_id, public)"
+ " values (?, ?, ?, ?, ?, 1)", -1, &_stmt_insert_poi, NULL);
/* update poi */
sqlite3_prepare(db,
"update poi set label = ?, desc = ?, "
poi_category_update(gint cat_id, gchar * cat_label, gchar * cat_desc,
gint cat_enabled)
{
-gboolean results;
+gboolean results=TRUE;
if (cat_id > 0) {
/* edit category */
gboolean
poi_category_delete(DeletePOI * dpoi)
{
-/* delete dpoi->poi_id */
- if (SQLITE_OK != sqlite3_bind_int(_stmt_delete_poi_by_catid, 1,
- dpoi->id)
+if (SQLITE_OK != sqlite3_bind_int(_stmt_delete_poi_by_catid, 1, dpoi->id)
|| SQLITE_DONE != sqlite3_step(_stmt_delete_poi_by_catid)) {
sqlite3_reset(_stmt_delete_poi_by_catid);
return FALSE;
- }
- sqlite3_reset(_stmt_delete_poi_by_catid);
+}
+sqlite3_reset(_stmt_delete_poi_by_catid);
- if (SQLITE_OK != sqlite3_bind_int(_stmt_delete_cat, 1, dpoi->id) ||
- SQLITE_DONE != sqlite3_step(_stmt_delete_cat)) {
- sqlite3_reset(_stmt_delete_cat);
- return FALSE;
- }
+if (SQLITE_OK != sqlite3_bind_int(_stmt_delete_cat, 1, dpoi->id) ||
+ SQLITE_DONE != sqlite3_step(_stmt_delete_cat)) {
sqlite3_reset(_stmt_delete_cat);
+ return FALSE;
+}
+sqlite3_reset(_stmt_delete_cat);
+return TRUE;
}
gboolean
poi_delete(DeletePOI * dpoi)
{
-guint i;
-
if (SQLITE_OK != sqlite3_bind_int(_stmt_delete_poi, 1, dpoi->id) ||
SQLITE_DONE != sqlite3_step(_stmt_delete_poi)) {
sqlite3_reset(_stmt_delete_poi);
gtk_toolbar_insert (GTK_TOOLBAR (_toolbar), item, -1);
g_signal_connect (item, "clicked", G_CALLBACK (cb_zoomout), NULL);
-#if 0
-item = gtk_tool_button_new_from_stock (GTK_STOCK_ZOOM_FIT);
+item = gtk_tool_button_new_from_stock (GTK_STOCK_ZOOM_100);
gtk_toolbar_insert (GTK_TOOLBAR (_toolbar), item, -1);
g_signal_connect (item, "clicked", G_CALLBACK (cb_zoom_base), NULL);
-#endif
+
+item = gtk_tool_button_new_from_stock (GTK_STOCK_ZOOM_FIT);
+gtk_toolbar_insert (GTK_TOOLBAR (_toolbar), item, -1);
+g_signal_connect (item, "clicked", G_CALLBACK (cb_zoom_autozoom), NULL);
item = gtk_separator_tool_item_new();
gtk_toolbar_insert (GTK_TOOLBAR (_toolbar), item, -1);
item = gtk_separator_tool_item_new();
gtk_toolbar_insert (GTK_TOOLBAR (_toolbar), item, -1);
+
+#ifndef WITH_HILDON
+
+#endif
}
/**
void mapper_init(gint argc, gchar ** argv)
{
GtkWidget *hbox, *label, *vbox, *vbox_main;
+ GtkWidget *notebook;
GdkColor color;
printf("%s()\n", __PRETTY_FUNCTION__);
_toolbar = gtk_toolbar_new();
toolbar_init();
+ notebook = gtk_notebook_new();
+ gtk_notebook_set_show_tabs(notebook, TRUE);
+ label = gtk_label_new("Map");
+
#ifdef WITH_HILDON
/* Create and add widgets and supporting data. */
hbox = gtk_hbox_new(FALSE, 0);
- gtk_container_add(GTK_CONTAINER(_window), hbox);
+ gtk_notebook_append_page(notebook, hbox, label);
+ gtk_container_add(GTK_CONTAINER(_window), notebook);
hildon_program_set_common_toolbar(_program, _toolbar);
#else
vbox_main = gtk_vbox_new(FALSE, 0);
_menu_bar = gtk_menu_bar_new();
gtk_box_pack_start(GTK_BOX(vbox_main), _menu_bar, FALSE, FALSE, 0);
-
gtk_box_pack_start(GTK_BOX(vbox_main), _toolbar, FALSE, FALSE, 0);
hbox = gtk_hbox_new(FALSE, 0);
- gtk_box_pack_start(GTK_BOX(vbox_main), hbox, TRUE, TRUE, 0);
+ gtk_notebook_append_page(notebook, hbox, label);
+ gtk_box_pack_start(GTK_BOX(vbox_main), notebook, TRUE, TRUE, 0);
_status_bar = gtk_statusbar_new();
gtk_box_pack_start(GTK_BOX(vbox_main), _status_bar, FALSE, FALSE, 0);