From 4e7f466078531072c0e9646ae6bbfe80d7d4c207 Mon Sep 17 00:00:00 2001 From: Kaj-Michael Lang Date: Mon, 4 Jun 2007 11:55:24 +0300 Subject: [PATCH] misc --- autom4te.cache/requests | 36 +- src/Makefile.am | 3 +- src/Makefile.in | 115 +++-- src/cb.c | 16 +- src/cb.h | 6 +- src/config.c | 2 +- src/db.c | 192 +------ src/gpx.c | 2 +- src/map.c | 83 ++- src/mapper.c | 8 +- src/poi-gui.c | 13 +- src/poi.c | 1053 ++++++++------------------------------- src/settings-gui.c | 2 +- src/ui-common.c | 46 +- 14 files changed, 421 insertions(+), 1156 deletions(-) diff --git a/autom4te.cache/requests b/autom4te.cache/requests index 5e5245f..196ea82 100644 --- a/autom4te.cache/requests +++ b/autom4te.cache/requests @@ -17,19 +17,19 @@ { 'm4_pattern_forbid' => 1, 'AC_CONFIG_LIBOBJ_DIR' => 1, - 'AC_C_VOLATILE' => 1, 'AC_TYPE_OFF_T' => 1, + 'AC_C_VOLATILE' => 1, 'AC_FUNC_CLOSEDIR_VOID' => 1, 'AC_REPLACE_FNMATCH' => 1, 'AC_PROG_LIBTOOL' => 1, 'AC_FUNC_STAT' => 1, - 'AC_FUNC_WAIT3' => 1, 'AC_HEADER_TIME' => 1, - 'AC_FUNC_LSTAT' => 1, - 'AC_STRUCT_TM' => 1, + 'AC_FUNC_WAIT3' => 1, 'AM_AUTOMAKE_VERSION' => 1, - 'AC_FUNC_GETMNTENT' => 1, + 'AC_STRUCT_TM' => 1, + 'AC_FUNC_LSTAT' => 1, 'AC_TYPE_MODE_T' => 1, + 'AC_FUNC_GETMNTENT' => 1, 'AC_FUNC_STRTOD' => 1, 'AC_CHECK_HEADERS' => 1, 'AC_FUNC_STRNLEN' => 1, @@ -48,17 +48,17 @@ 'AC_STRUCT_ST_BLOCKS' => 1, 'AC_TYPE_SIGNAL' => 1, 'AC_TYPE_UID_T' => 1, - 'AC_PROG_MAKE_SET' => 1, 'AC_CONFIG_AUX_DIR' => 1, - 'm4_pattern_allow' => 1, + 'AC_PROG_MAKE_SET' => 1, 'sinclude' => 1, + 'm4_pattern_allow' => 1, 'AC_DEFINE_TRACE_LITERAL' => 1, 'AC_FUNC_STRERROR_R' => 1, 'AC_PROG_CC' => 1, - 'AC_DECL_SYS_SIGLIST' => 1, 'AC_FUNC_FORK' => 1, - 'AC_FUNC_STRCOLL' => 1, + 'AC_DECL_SYS_SIGLIST' => 1, 'AC_FUNC_VPRINTF' => 1, + 'AC_FUNC_STRCOLL' => 1, 'AC_PROG_YACC' => 1, 'AC_INIT' => 1, 'AC_STRUCT_TIMEZONE' => 1, @@ -80,34 +80,34 @@ 'AM_MAINTAINER_MODE' => 1, 'AC_FUNC_UTIME_NULL' => 1, 'AC_FUNC_SELECT_ARGTYPES' => 1, - 'AC_HEADER_STAT' => 1, 'AC_FUNC_STRFTIME' => 1, - 'AC_PROG_CPP' => 1, + 'AC_HEADER_STAT' => 1, 'AC_C_INLINE' => 1, - 'AC_PROG_LEX' => 1, - 'AC_C_CONST' => 1, - 'AC_TYPE_PID_T' => 1, + 'AC_PROG_CPP' => 1, 'AM_ENABLE_MULTILIB' => 1, + 'AC_TYPE_PID_T' => 1, + 'AC_C_CONST' => 1, + 'AC_PROG_LEX' => 1, 'AC_CONFIG_FILES' => 1, 'include' => 1, 'AC_FUNC_SETVBUF_REVERSED' => 1, 'AC_PROG_INSTALL' => 1, 'AM_GNU_GETTEXT' => 1, - 'AC_CHECK_LIB' => 1, 'AC_FUNC_OBSTACK' => 1, + 'AC_CHECK_LIB' => 1, 'AC_FUNC_MALLOC' => 1, 'AC_FUNC_GETGROUPS' => 1, 'AC_FUNC_GETLOADAVG' => 1, 'AH_OUTPUT' => 1, 'AC_FUNC_FSEEKO' => 1, 'AM_PROG_CC_C_O' => 1, - 'AC_FUNC_MKTIME' => 1, - 'AC_CANONICAL_SYSTEM' => 1, 'AM_CONDITIONAL' => 1, + 'AC_CANONICAL_SYSTEM' => 1, + 'AC_FUNC_MKTIME' => 1, 'AC_CONFIG_HEADERS' => 1, 'AC_HEADER_SYS_WAIT' => 1, - 'AC_PROG_LN_S' => 1, 'AC_FUNC_MEMCMP' => 1, + 'AC_PROG_LN_S' => 1, 'm4_include' => 1, 'AC_HEADER_DIRENT' => 1, 'AC_CHECK_FUNCS' => 1 diff --git a/src/Makefile.am b/src/Makefile.am index 5bc314d..284b433 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -41,10 +41,11 @@ mapper_SOURCES = utils.c \ route.c \ track.c \ maemo-osso.c \ - map-poi.c \ map-repo.c \ map.c \ + poi.c \ poi-gui.c \ + map-poi.c \ settings-gui.c \ speed-display.c \ hildon-wrappers.c \ diff --git a/src/Makefile.in b/src/Makefile.in index 1de42f0..e49a9e0 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -256,10 +256,11 @@ mapper_SOURCES = utils.c \ route.c \ track.c \ maemo-osso.c \ - map-poi.c \ map-repo.c \ map.c \ + poi.c \ poi-gui.c \ + map-poi.c \ settings-gui.c \ speed-display.c \ hildon-wrappers.c \ @@ -282,11 +283,12 @@ am_mapper_OBJECTS = mapper-utils.$(OBJEXT) mapper-db.$(OBJEXT) \ mapper-gps-panels.$(OBJEXT) mapper-cb.$(OBJEXT) \ mapper-iap.$(OBJEXT) mapper-route.$(OBJEXT) \ mapper-track.$(OBJEXT) mapper-maemo-osso.$(OBJEXT) \ - mapper-map-poi.$(OBJEXT) mapper-map-repo.$(OBJEXT) \ - mapper-map.$(OBJEXT) mapper-poi-gui.$(OBJEXT) \ - mapper-settings-gui.$(OBJEXT) mapper-speed-display.$(OBJEXT) \ - mapper-hildon-wrappers.$(OBJEXT) mapper-ui-common.$(OBJEXT) \ - mapper-config.$(OBJEXT) mapper-mapper.$(OBJEXT) + mapper-map-repo.$(OBJEXT) mapper-map.$(OBJEXT) \ + mapper-poi.$(OBJEXT) mapper-poi-gui.$(OBJEXT) \ + mapper-map-poi.$(OBJEXT) mapper-settings-gui.$(OBJEXT) \ + mapper-speed-display.$(OBJEXT) mapper-hildon-wrappers.$(OBJEXT) \ + mapper-ui-common.$(OBJEXT) mapper-config.$(OBJEXT) \ + mapper-mapper.$(OBJEXT) mapper_OBJECTS = $(am_mapper_OBJECTS) mapper_DEPENDENCIES = mapper_LDFLAGS = @@ -311,6 +313,7 @@ am__depfiles_maybe = depfiles @AMDEP_TRUE@ ./$(DEPDIR)/mapper-map.Po \ @AMDEP_TRUE@ ./$(DEPDIR)/mapper-mapper.Po \ @AMDEP_TRUE@ ./$(DEPDIR)/mapper-poi-gui.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/mapper-poi.Po \ @AMDEP_TRUE@ ./$(DEPDIR)/mapper-route.Po \ @AMDEP_TRUE@ ./$(DEPDIR)/mapper-settings-gui.Po \ @AMDEP_TRUE@ ./$(DEPDIR)/mapper-speed-display.Po \ @@ -412,6 +415,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mapper-map.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mapper-mapper.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mapper-poi-gui.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mapper-poi.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mapper-route.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mapper-settings-gui.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mapper-speed-display.Po@am__quote@ @@ -914,39 +918,6 @@ mapper-maemo-osso.lo: maemo-osso.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(mapper_CFLAGS) $(CFLAGS) -c -o mapper-maemo-osso.lo `test -f 'maemo-osso.c' || echo '$(srcdir)/'`maemo-osso.c -mapper-map-poi.o: map-poi.c -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(mapper_CFLAGS) $(CFLAGS) -MT mapper-map-poi.o -MD -MP -MF "$(DEPDIR)/mapper-map-poi.Tpo" \ -@am__fastdepCC_TRUE@ -c -o mapper-map-poi.o `test -f 'map-poi.c' || echo '$(srcdir)/'`map-poi.c; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/mapper-map-poi.Tpo" "$(DEPDIR)/mapper-map-poi.Po"; \ -@am__fastdepCC_TRUE@ else rm -f "$(DEPDIR)/mapper-map-poi.Tpo"; exit 1; \ -@am__fastdepCC_TRUE@ fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='map-poi.c' object='mapper-map-poi.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/mapper-map-poi.Po' tmpdepfile='$(DEPDIR)/mapper-map-poi.TPo' @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(mapper_CFLAGS) $(CFLAGS) -c -o mapper-map-poi.o `test -f 'map-poi.c' || echo '$(srcdir)/'`map-poi.c - -mapper-map-poi.obj: map-poi.c -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(mapper_CFLAGS) $(CFLAGS) -MT mapper-map-poi.obj -MD -MP -MF "$(DEPDIR)/mapper-map-poi.Tpo" \ -@am__fastdepCC_TRUE@ -c -o mapper-map-poi.obj `if test -f 'map-poi.c'; then $(CYGPATH_W) 'map-poi.c'; else $(CYGPATH_W) '$(srcdir)/map-poi.c'; fi`; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/mapper-map-poi.Tpo" "$(DEPDIR)/mapper-map-poi.Po"; \ -@am__fastdepCC_TRUE@ else rm -f "$(DEPDIR)/mapper-map-poi.Tpo"; exit 1; \ -@am__fastdepCC_TRUE@ fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='map-poi.c' object='mapper-map-poi.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/mapper-map-poi.Po' tmpdepfile='$(DEPDIR)/mapper-map-poi.TPo' @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(mapper_CFLAGS) $(CFLAGS) -c -o mapper-map-poi.obj `if test -f 'map-poi.c'; then $(CYGPATH_W) 'map-poi.c'; else $(CYGPATH_W) '$(srcdir)/map-poi.c'; fi` - -mapper-map-poi.lo: map-poi.c -@am__fastdepCC_TRUE@ if $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(mapper_CFLAGS) $(CFLAGS) -MT mapper-map-poi.lo -MD -MP -MF "$(DEPDIR)/mapper-map-poi.Tpo" \ -@am__fastdepCC_TRUE@ -c -o mapper-map-poi.lo `test -f 'map-poi.c' || echo '$(srcdir)/'`map-poi.c; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/mapper-map-poi.Tpo" "$(DEPDIR)/mapper-map-poi.Plo"; \ -@am__fastdepCC_TRUE@ else rm -f "$(DEPDIR)/mapper-map-poi.Tpo"; exit 1; \ -@am__fastdepCC_TRUE@ fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='map-poi.c' object='mapper-map-poi.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/mapper-map-poi.Plo' tmpdepfile='$(DEPDIR)/mapper-map-poi.TPlo' @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(mapper_CFLAGS) $(CFLAGS) -c -o mapper-map-poi.lo `test -f 'map-poi.c' || echo '$(srcdir)/'`map-poi.c - mapper-map-repo.o: map-repo.c @am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(mapper_CFLAGS) $(CFLAGS) -MT mapper-map-repo.o -MD -MP -MF "$(DEPDIR)/mapper-map-repo.Tpo" \ @am__fastdepCC_TRUE@ -c -o mapper-map-repo.o `test -f 'map-repo.c' || echo '$(srcdir)/'`map-repo.c; \ @@ -1013,6 +984,39 @@ mapper-map.lo: map.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(mapper_CFLAGS) $(CFLAGS) -c -o mapper-map.lo `test -f 'map.c' || echo '$(srcdir)/'`map.c +mapper-poi.o: poi.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(mapper_CFLAGS) $(CFLAGS) -MT mapper-poi.o -MD -MP -MF "$(DEPDIR)/mapper-poi.Tpo" \ +@am__fastdepCC_TRUE@ -c -o mapper-poi.o `test -f 'poi.c' || echo '$(srcdir)/'`poi.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/mapper-poi.Tpo" "$(DEPDIR)/mapper-poi.Po"; \ +@am__fastdepCC_TRUE@ else rm -f "$(DEPDIR)/mapper-poi.Tpo"; exit 1; \ +@am__fastdepCC_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='poi.c' object='mapper-poi.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/mapper-poi.Po' tmpdepfile='$(DEPDIR)/mapper-poi.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(mapper_CFLAGS) $(CFLAGS) -c -o mapper-poi.o `test -f 'poi.c' || echo '$(srcdir)/'`poi.c + +mapper-poi.obj: poi.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(mapper_CFLAGS) $(CFLAGS) -MT mapper-poi.obj -MD -MP -MF "$(DEPDIR)/mapper-poi.Tpo" \ +@am__fastdepCC_TRUE@ -c -o mapper-poi.obj `if test -f 'poi.c'; then $(CYGPATH_W) 'poi.c'; else $(CYGPATH_W) '$(srcdir)/poi.c'; fi`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/mapper-poi.Tpo" "$(DEPDIR)/mapper-poi.Po"; \ +@am__fastdepCC_TRUE@ else rm -f "$(DEPDIR)/mapper-poi.Tpo"; exit 1; \ +@am__fastdepCC_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='poi.c' object='mapper-poi.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/mapper-poi.Po' tmpdepfile='$(DEPDIR)/mapper-poi.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(mapper_CFLAGS) $(CFLAGS) -c -o mapper-poi.obj `if test -f 'poi.c'; then $(CYGPATH_W) 'poi.c'; else $(CYGPATH_W) '$(srcdir)/poi.c'; fi` + +mapper-poi.lo: poi.c +@am__fastdepCC_TRUE@ if $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(mapper_CFLAGS) $(CFLAGS) -MT mapper-poi.lo -MD -MP -MF "$(DEPDIR)/mapper-poi.Tpo" \ +@am__fastdepCC_TRUE@ -c -o mapper-poi.lo `test -f 'poi.c' || echo '$(srcdir)/'`poi.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/mapper-poi.Tpo" "$(DEPDIR)/mapper-poi.Plo"; \ +@am__fastdepCC_TRUE@ else rm -f "$(DEPDIR)/mapper-poi.Tpo"; exit 1; \ +@am__fastdepCC_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='poi.c' object='mapper-poi.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/mapper-poi.Plo' tmpdepfile='$(DEPDIR)/mapper-poi.TPlo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(mapper_CFLAGS) $(CFLAGS) -c -o mapper-poi.lo `test -f 'poi.c' || echo '$(srcdir)/'`poi.c + mapper-poi-gui.o: poi-gui.c @am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(mapper_CFLAGS) $(CFLAGS) -MT mapper-poi-gui.o -MD -MP -MF "$(DEPDIR)/mapper-poi-gui.Tpo" \ @am__fastdepCC_TRUE@ -c -o mapper-poi-gui.o `test -f 'poi-gui.c' || echo '$(srcdir)/'`poi-gui.c; \ @@ -1046,6 +1050,39 @@ mapper-poi-gui.lo: poi-gui.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(mapper_CFLAGS) $(CFLAGS) -c -o mapper-poi-gui.lo `test -f 'poi-gui.c' || echo '$(srcdir)/'`poi-gui.c +mapper-map-poi.o: map-poi.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(mapper_CFLAGS) $(CFLAGS) -MT mapper-map-poi.o -MD -MP -MF "$(DEPDIR)/mapper-map-poi.Tpo" \ +@am__fastdepCC_TRUE@ -c -o mapper-map-poi.o `test -f 'map-poi.c' || echo '$(srcdir)/'`map-poi.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/mapper-map-poi.Tpo" "$(DEPDIR)/mapper-map-poi.Po"; \ +@am__fastdepCC_TRUE@ else rm -f "$(DEPDIR)/mapper-map-poi.Tpo"; exit 1; \ +@am__fastdepCC_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='map-poi.c' object='mapper-map-poi.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/mapper-map-poi.Po' tmpdepfile='$(DEPDIR)/mapper-map-poi.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(mapper_CFLAGS) $(CFLAGS) -c -o mapper-map-poi.o `test -f 'map-poi.c' || echo '$(srcdir)/'`map-poi.c + +mapper-map-poi.obj: map-poi.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(mapper_CFLAGS) $(CFLAGS) -MT mapper-map-poi.obj -MD -MP -MF "$(DEPDIR)/mapper-map-poi.Tpo" \ +@am__fastdepCC_TRUE@ -c -o mapper-map-poi.obj `if test -f 'map-poi.c'; then $(CYGPATH_W) 'map-poi.c'; else $(CYGPATH_W) '$(srcdir)/map-poi.c'; fi`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/mapper-map-poi.Tpo" "$(DEPDIR)/mapper-map-poi.Po"; \ +@am__fastdepCC_TRUE@ else rm -f "$(DEPDIR)/mapper-map-poi.Tpo"; exit 1; \ +@am__fastdepCC_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='map-poi.c' object='mapper-map-poi.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/mapper-map-poi.Po' tmpdepfile='$(DEPDIR)/mapper-map-poi.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(mapper_CFLAGS) $(CFLAGS) -c -o mapper-map-poi.obj `if test -f 'map-poi.c'; then $(CYGPATH_W) 'map-poi.c'; else $(CYGPATH_W) '$(srcdir)/map-poi.c'; fi` + +mapper-map-poi.lo: map-poi.c +@am__fastdepCC_TRUE@ if $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(mapper_CFLAGS) $(CFLAGS) -MT mapper-map-poi.lo -MD -MP -MF "$(DEPDIR)/mapper-map-poi.Tpo" \ +@am__fastdepCC_TRUE@ -c -o mapper-map-poi.lo `test -f 'map-poi.c' || echo '$(srcdir)/'`map-poi.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/mapper-map-poi.Tpo" "$(DEPDIR)/mapper-map-poi.Plo"; \ +@am__fastdepCC_TRUE@ else rm -f "$(DEPDIR)/mapper-map-poi.Tpo"; exit 1; \ +@am__fastdepCC_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='map-poi.c' object='mapper-map-poi.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/mapper-map-poi.Plo' tmpdepfile='$(DEPDIR)/mapper-map-poi.TPlo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(mapper_CFLAGS) $(CFLAGS) -c -o mapper-map-poi.lo `test -f 'map-poi.c' || echo '$(srcdir)/'`map-poi.c + mapper-settings-gui.o: settings-gui.c @am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(mapper_CFLAGS) $(CFLAGS) -MT mapper-settings-gui.o -MD -MP -MF "$(DEPDIR)/mapper-settings-gui.Tpo" \ @am__fastdepCC_TRUE@ -c -o mapper-settings-gui.o `test -f 'settings-gui.c' || echo '$(srcdir)/'`settings-gui.c; \ diff --git a/src/cb.c b/src/cb.c index 8b617bd..84c201c 100644 --- a/src/cb.c +++ b/src/cb.c @@ -551,7 +551,17 @@ gboolean menu_cb_maps_select(GtkAction * action, gpointer new_repo) return TRUE; } -gboolean menu_cb_zoomin(GtkAction * action) +gboolean cb_zoom_fit(GtkAction * action) +{ + printf("%s()\n", __PRETTY_FUNCTION__); + + map_zoom(10); + + vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__); + return TRUE; +} + +gboolean cb_zoomin(GtkAction * action) { printf("%s()\n", __PRETTY_FUNCTION__); @@ -561,7 +571,7 @@ gboolean menu_cb_zoomin(GtkAction * action) return TRUE; } -gboolean menu_cb_zoomout(GtkAction * action) +gboolean cb_zoomout(GtkAction * action) { printf("%s()\n", __PRETTY_FUNCTION__); @@ -571,7 +581,7 @@ gboolean menu_cb_zoomout(GtkAction * action) return TRUE; } -gboolean menu_cb_fullscreen(GtkAction * action) +gboolean cb_fullscreen(GtkAction * action) { printf("%s()\n", __PRETTY_FUNCTION__); diff --git a/src/cb.h b/src/cb.h index 92c680d..1c26d69 100644 --- a/src/cb.h +++ b/src/cb.h @@ -50,9 +50,9 @@ gboolean menu_cb_maps_repoman(GtkAction * action); gboolean menu_cb_auto_download(GtkAction * action); /* Callbacks for the "View" submenu. */ -gboolean menu_cb_zoomin(GtkAction * action); -gboolean menu_cb_zoomout(GtkAction * action); -gboolean menu_cb_fullscreen(GtkAction * action); +gboolean cb_zoomin(GtkAction * action); +gboolean cb_zoomout(GtkAction * action); +gboolean cb_fullscreen(GtkAction * action); gboolean menu_cb_show_scale(GtkAction * action); gboolean menu_cb_show_routes(GtkAction * action); gboolean menu_cb_show_tracks(GtkAction * action); diff --git a/src/config.c b/src/config.c index d13ee6a..dcf429e 100644 --- a/src/config.c +++ b/src/config.c @@ -745,7 +745,7 @@ void config_init() gnome_vfs_uri_make_full_from_relative(poi_base, "poi.db"); g_free(poi_base); } - db_connect(&_db, _poi_db); + poi_db_connect(&_db, _poi_db); _poi_zoom = gconf_client_get_int(gconf_client, GCONF_KEY_POI_ZOOM, NULL); diff --git a/src/db.c b/src/db.c index 9fc62d1..bf72ef2 100644 --- a/src/db.c +++ b/src/db.c @@ -12,37 +12,32 @@ #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) +gboolean db_check(sqlite3 *db, const gchar *table) { +gchar **pszResult; +guint nRow, nColumn; +gchar sql[64]; +snprintf(sql, sizeof(sql),"select count(*) from %s", table); + +if (SQLITE_OK != sqlite3_get_table(db, sql, + &pszResult, &nRow, &nColumn, NULL)) + return FALSE; + +sqlite3_free_table(pszResult); return TRUE; } -gboolean db_close(sqlite3 *db) +gboolean db_close(sqlite3 **db) { -if (db) { - sqlite3_close(db); - db=NULL; +if (db && *db) { + sqlite3_close(*db); + *db=NULL; } return TRUE; } -gboolean db_connect(sqlite3 **ndb, const gchar *poi_db) +gboolean db_connect(sqlite3 **ndb, const gchar *db_file) { gchar buffer[100]; gchar *perror; @@ -62,170 +57,23 @@ gboolean db_connect(sqlite3 **ndb, const gchar *poi_db) db = NULL; } - if (!poi_db) + if (!db_file) return FALSE; - if (SQLITE_OK != (sqlite3_open(poi_db, &db))) { + if (SQLITE_OK != (sqlite3_open(db_file, &db))) { gchar buffer2[200]; snprintf(buffer2, sizeof(buffer2), - "%s: %s", _("Problem with POI database"), - sqlite3_errmsg(db)); + "%s: %s", _("Problem with database"), sqlite3_errmsg(db)); sqlite3_close(db); db = NULL; + *ndb=db; 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; - - g_printf("Creating initial tables\n"); - - 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 category (cat_id integer PRIMARY KEY," - "label text, desc text, enabled integer);" - /* Add some default categories... */ - "insert into category (label, desc, enabled) " - "values ('%q', '%q', 1); " - "insert into category (label, desc, enabled) " - "values ('%q', '%q', 1); " - "insert into category (label, desc, enabled) " - "values ('%q', '%q', 1); " - "insert into category (label, desc, enabled) " - "values ('%q', '%q', 1); " - "insert into category (label, desc, enabled) " - "values ('%q', '%q', 1); " - "insert into category (label, desc, enabled) " - "values ('%q', '%q', 1); " - "insert into category (label, desc, enabled) " - "values ('%q', '%q', 1); " - "insert into category (label, desc, enabled) " - "values ('%q', '%q', 1); " - "insert into category (label, desc, enabled) " - "values ('%q', '%q', 1); " - "insert into category (label, desc, enabled) " - "values ('%q', '%q', 1); " - "insert into category (label, desc, enabled) " - "values ('%q', '%q', 1); ", - _("Fuel"), - _("Stations for purchasing fuel for vehicles."), - _("Residence"), - _("Houses, apartments, or other residences of import."), - _("Dining"), - _("Places to eat or drink."), - _("Shopping/Services"), - _("Places to shop or acquire services."), - _("Recreation"), - _("Indoor or Outdoor places to have fun."), - _("Transportation"), - _("Bus stops, airports, train stations, etc."), - _("Lodging"), - _("Places to stay temporarily or for the night."), - _("School"), - _("Elementary schools, college campuses, etc."), - _("Business"), - _("General places of business."), - _("Landmark"), - _("General landmarks."), - _("Other"), - _("Miscellaneous category for everything else.")); - - if (SQLITE_OK != - sqlite3_exec(db, create_sql, NULL, NULL, &perror) - && (SQLITE_OK != - sqlite3_get_table(db, "select label from poi limit 1", - &pszResult, &nRow, &nColumn, NULL))) { - snprintf(buffer, sizeof(buffer), "%s:\n%s", - _("Failed to open or create database"), - sqlite3_errmsg(db)); - sqlite3_close(db); - db = NULL; - popup_error(_window, buffer); - return FALSE; - } - } else - sqlite3_free_table(pszResult); - - /* Prepare our SQL statements. */ - /* 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" - " from poi p, category c " - " where p.lat between ? and ? " - " and p.lon between ? and ? " - " and c.enabled = 1 and p.cat_id = c.cat_id", - -1, &_stmt_select_poi, NULL); - - /* select nearest pois */ - 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" - " 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); - /* update poi */ - sqlite3_prepare(db, - "update poi set label = ?, desc = ?, " - "cat_id = ? where poi_id = ?", - -1, &_stmt_update_poi, NULL); - /* delete from poi */ - sqlite3_prepare(db, - " delete from poi where poi_id = ?", - -1, &_stmt_delete_poi, NULL); - /* delete from poi by cat_id */ - sqlite3_prepare(db, - "delete from poi where cat_id = ?", - -1, &_stmt_delete_poi_by_catid, NULL); - /* get next poilabel */ - sqlite3_prepare(db, - "select ifnull(max(poi_id) + 1,1) from poi", - -1, &_stmt_nextlabel_poi, NULL); - - /* select from category */ - sqlite3_prepare(db, - "select c.label, c.desc, c.enabled" - " from category c where c.cat_id = ?", - -1, &_stmt_select_cat, NULL); - /* insert into category */ - sqlite3_prepare(db, - "insert into category (label, desc, enabled)" - " values (?, ?, ?)", -1, &_stmt_insert_cat, NULL); - /* update category */ - sqlite3_prepare(db, - "update category set label = ?, desc = ?," - " enabled = ? where poi_id = ?", - -1, &_stmt_update_cat, NULL); - /* delete from category */ - sqlite3_prepare(db, - "delete from category where cat_id = ?", - -1, &_stmt_delete_cat, NULL); - /* enable category */ - sqlite3_prepare(db, - "update category set enabled = ?" - " where cat_id = ?", -1, &_stmt_toggle_cat, NULL); - /* select all category */ - sqlite3_prepare(db, - "select c.cat_id, c.label, c.desc, c.enabled," - " count(p.poi_id)" - " from category c" - " left outer join poi p on c.cat_id = p.cat_id" - " group by c.cat_id, c.label, c.desc, c.enabled " - " order by c.label", -1, &_stmt_selall_cat, NULL); - printf("%s(): return\n", __PRETTY_FUNCTION__); return TRUE; } diff --git a/src/gpx.c b/src/gpx.c index 31588b5..9d49cde 100644 --- a/src/gpx.c +++ b/src/gpx.c @@ -86,7 +86,7 @@ gboolean write_gpx(Path * path, GnomeVFSHandle * handle) /* Write the header. */ WRITE_STRING("\n" - "\n" " \n" " \n"); diff --git a/src/map.c b/src/map.c index c2c9188..b097f38 100644 --- a/src/map.c +++ b/src/map.c @@ -1284,49 +1284,6 @@ gboolean map_cb_expose(GtkWidget * widget, GdkEventExpose * event) return TRUE; } -gboolean map_cb_button_press(GtkWidget * widget, GdkEventButton * event) -{ - printf("%s()\n", __PRETTY_FUNCTION__); - - g_print("Pbutton %d\n", event->button); - - switch (event->button) { - case 1: - if (event->type == GDK_2BUTTON_PRESS) { - map_set_zoom(_zoom - 1); - return FALSE; - } - - if (event->type == GDK_3BUTTON_PRESS) { - return FALSE; - } - break; - case 2: - press[0] = event->x; - press[1] = event->y; - before[0] = press[0]; - before[1] = press[1]; - - _id = - g_signal_connect(G_OBJECT(_map_widget), - "motion_notify_event", - G_CALLBACK(map_follow_move), NULL); - break; - case 3: - _cmenu_position_x = event->x + 0.5; - _cmenu_position_y = event->y + 0.5; -#ifndef WITH_HILDON - gtk_menu_popup(GTK_MENU(_menu_map), NULL, NULL, NULL, NULL, - event->button, gtk_get_current_event_time()); -#endif - break; - } - - /* Return FALSE to allow context menu to work. */ - vprintf("%s(): return FALSE\n", __PRETTY_FUNCTION__); - return FALSE; -} - int map_zoom(gint zdir) { gchar buffer[80]; @@ -1366,11 +1323,47 @@ gboolean map_cb_scroll_event(GtkWidget * widget, GdkEventScroll * event) return FALSE; } -gboolean map_cb_button_release(GtkWidget * widget, GdkEventButton * event) +gboolean map_cb_button_press(GtkWidget * widget, GdkEventButton * event) { printf("%s()\n", __PRETTY_FUNCTION__); - g_print("Rbutton %d\n", event->button); + switch (event->button) { + case 1: + if (event->type == GDK_2BUTTON_PRESS) { + map_set_zoom(_zoom - 1); + return FALSE; + } + if (event->type == GDK_3BUTTON_PRESS) + return FALSE; + break; + case 2: + press[0] = event->x; + press[1] = event->y; + before[0] = press[0]; + before[1] = press[1]; + + _id = g_signal_connect(G_OBJECT(_map_widget), + "motion_notify_event", + G_CALLBACK(map_follow_move), NULL); + break; + case 3: + _cmenu_position_x = event->x + 0.5; + _cmenu_position_y = event->y + 0.5; +#ifndef WITH_HILDON + gtk_menu_popup(GTK_MENU(_menu_map), NULL, NULL, NULL, NULL, + event->button, gtk_get_current_event_time()); +#endif + break; + } + + /* Return FALSE to allow context menu to work. */ + vprintf("%s(): return FALSE\n", __PRETTY_FUNCTION__); + return FALSE; +} + +gboolean map_cb_button_release(GtkWidget * widget, GdkEventButton * event) +{ + printf("%s()\n", __PRETTY_FUNCTION__); switch (event->button) { case 1: diff --git a/src/mapper.c b/src/mapper.c index 475ea74..9a4b7ac 100644 --- a/src/mapper.c +++ b/src/mapper.c @@ -160,7 +160,7 @@ void set_conn_state(ConnState new_conn_state) * Save state and destroy all non-UI elements created by this program in * preparation for exiting. */ -void maemo_mapper_destroy(void) +void mapper_destroy(void) { printf("%s()\n", __PRETTY_FUNCTION__); @@ -245,7 +245,7 @@ gint main(gint argc, gchar * argv[]) #ifdef WITH_HILDON /* Initialize _osso. */ - _osso = osso_initialize("com.gnuite.maemo_mapper", VERSION, TRUE, NULL); + _osso = osso_initialize("org.tal.mapper", VERSION, TRUE, NULL); if (!_osso) { g_printerr("osso_initialize failed.\n"); return 1; @@ -266,7 +266,7 @@ gint main(gint argc, gchar * argv[]) /* Init libcurl. */ curl_global_init(CURL_GLOBAL_NOTHING); - maemo_mapper_init(argc, argv); + mapper_init(argc, argv); #ifdef WITH_HILDON if (OSSO_OK != osso_rpc_set_default_cb_f(_osso, dbus_cb_default, NULL)) { @@ -277,7 +277,7 @@ gint main(gint argc, gchar * argv[]) gtk_main(); - maemo_mapper_destroy(); + mapper_destroy(); #ifdef WITH_HILDON osso_deinitialize(_osso); diff --git a/src/poi-gui.c b/src/poi-gui.c index b5a34bb..5119c2e 100644 --- a/src/poi-gui.c +++ b/src/poi-gui.c @@ -33,8 +33,6 @@ #include "settings.h" guint _poi_zoom = 6; -sqlite3 *_db = NULL; -gchar *_poi_db = NULL; gboolean category_delete(GtkWidget * widget, DeletePOI * dpoi) { @@ -489,7 +487,7 @@ gboolean menu_cb_category(GtkAction * action) return TRUE; } -gboolean poi_delete(GtkWidget * widget, DeletePOI * dpoi) +gboolean poi_delete_confirm(GtkWidget * widget, DeletePOI * dpoi) { GtkWidget *dialog; guint i; @@ -503,15 +501,12 @@ gboolean poi_delete(GtkWidget * widget, DeletePOI * dpoi) gtk_widget_destroy(GTK_WIDGET(dialog)); if (i == GTK_RESPONSE_OK) { - if (SQLITE_OK != sqlite3_bind_int(_stmt_delete_poi, 1, dpoi->id) - || SQLITE_DONE != sqlite3_step(_stmt_delete_poi)) { - MACRO_BANNER_SHOW_INFO(_window, - _("Problem deleting POI")); + if (poi_delete(dpoi)==FALSE) { + MACRO_BANNER_SHOW_INFO(_window, _("Problem deleting POI")); } else { gtk_widget_hide_all(dpoi->dialog); map_force_redraw(); } - sqlite3_reset(_stmt_delete_poi); } vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__); @@ -778,7 +773,7 @@ gboolean poi_dialog(POIAction action, guint unitx, guint unity) dpoi.id = poi.poi_id; g_signal_connect(G_OBJECT(btn_delete), "clicked", - G_CALLBACK(poi_delete), &dpoi); + G_CALLBACK(poi_delete_confirm), &dpoi); gtk_dialog_add_button(GTK_DIALOG(dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT); diff --git a/src/poi.c b/src/poi.c index 01470e6..adc2356 100644 --- a/src/poi.c +++ b/src/poi.c @@ -10,12 +10,9 @@ #include #include #include -#include #include #include #include -#include -#include #include #include @@ -30,16 +27,200 @@ #include "map.h" #include "mapper-types.h" #include "settings.h" +#include "db.h" -guint _poi_zoom = 6; sqlite3 *_db = NULL; gchar *_poi_db = NULL; +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 +poi_db_create(sqlite3 *db) +{ + gchar **pszResult; + guint nRow, nColumn; + if (SQLITE_OK != sqlite3_get_table(db, "select label from poi limit 1", + &pszResult, &nRow, &nColumn, NULL)) { + gchar *create_sql; + + g_printf("Creating initial tables\n"); + + 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 category (cat_id integer PRIMARY KEY," + "label text, desc text, enabled integer);" + /* Add some default categories... */ + "insert into category (label, desc, enabled) " + "values ('%q', '%q', 1); " + "insert into category (label, desc, enabled) " + "values ('%q', '%q', 1); " + "insert into category (label, desc, enabled) " + "values ('%q', '%q', 1); " + "insert into category (label, desc, enabled) " + "values ('%q', '%q', 1); " + "insert into category (label, desc, enabled) " + "values ('%q', '%q', 1); " + "insert into category (label, desc, enabled) " + "values ('%q', '%q', 1); " + "insert into category (label, desc, enabled) " + "values ('%q', '%q', 1); " + "insert into category (label, desc, enabled) " + "values ('%q', '%q', 1); " + "insert into category (label, desc, enabled) " + "values ('%q', '%q', 1); " + "insert into category (label, desc, enabled) " + "values ('%q', '%q', 1); " + "insert into category (label, desc, enabled) " + "values ('%q', '%q', 1); ", + _("Fuel"), + _("Stations for purchasing fuel for vehicles."), + _("Residence"), + _("Houses, apartments, or other residences of import."), + _("Dining"), + _("Places to eat or drink."), + _("Shopping/Services"), + _("Places to shop or acquire services."), + _("Recreation"), + _("Indoor or Outdoor places to have fun."), + _("Transportation"), + _("Bus stops, airports, train stations, etc."), + _("Lodging"), + _("Places to stay temporarily or for the night."), + _("School"), + _("Elementary schools, college campuses, etc."), + _("Business"), + _("General places of business."), + _("Landmark"), + _("General landmarks."), + _("Other"), + _("Miscellaneous category for everything else.")); + + if (SQLITE_OK != + sqlite3_exec(&db, create_sql, NULL, NULL, &perror) + && (SQLITE_OK != + sqlite3_get_table(db, "select label from poi limit 1", + &pszResult, &nRow, &nColumn, NULL))) { + g_printf("%s:\n%s",_("Failed to open or create database"),sqlite3_errmsg(db)); + sqlite3_close(db); + db = NULL; + return FALSE; + } + } else + sqlite3_free_table(pszResult); + +} + +gboolean +poi_db_prepare(sqlite3 *db) +{ + /* 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" + " from poi p, category c " + " where p.lat between ? and ? " + " and p.lon between ? and ? " + " and c.enabled = 1 and p.cat_id = c.cat_id", + -1, &_stmt_select_poi, NULL); + + /* select nearest pois */ + 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" + " 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); + /* update poi */ + sqlite3_prepare(db, + "update poi set label = ?, desc = ?, " + "cat_id = ? where poi_id = ?", + -1, &_stmt_update_poi, NULL); + /* delete from poi */ + sqlite3_prepare(db, + " delete from poi where poi_id = ?", + -1, &_stmt_delete_poi, NULL); + /* delete from poi by cat_id */ + sqlite3_prepare(db, + "delete from poi where cat_id = ?", + -1, &_stmt_delete_poi_by_catid, NULL); + /* get next poilabel */ + sqlite3_prepare(db, + "select ifnull(max(poi_id) + 1,1) from poi", + -1, &_stmt_nextlabel_poi, NULL); + + /* select from category */ + sqlite3_prepare(db, + "select c.label, c.desc, c.enabled" + " from category c where c.cat_id = ?", + -1, &_stmt_select_cat, NULL); + /* insert into category */ + sqlite3_prepare(db, + "insert into category (label, desc, enabled)" + " values (?, ?, ?)", -1, &_stmt_insert_cat, NULL); + /* update category */ + sqlite3_prepare(db, + "update category set label = ?, desc = ?," + " enabled = ? where poi_id = ?", + -1, &_stmt_update_cat, NULL); + /* delete from category */ + sqlite3_prepare(db, + "delete from category where cat_id = ?", + -1, &_stmt_delete_cat, NULL); + /* enable category */ + sqlite3_prepare(db, + "update category set enabled = ?" + " where cat_id = ?", -1, &_stmt_toggle_cat, NULL); + /* select all category */ + sqlite3_prepare(db, + "select c.cat_id, c.label, c.desc, c.enabled," + " count(p.poi_id)" + " from category c" + " left outer join poi p on c.cat_id = p.cat_id" + " group by c.cat_id, c.label, c.desc, c.enabled " + " order by c.label", -1, &_stmt_selall_cat, NULL); + + return TRUE; +} + +gboolean +poi_db_connect(sqlite3 **db, const gchar *poi_db) +{ +if (db_connect(db, poi_db)) { + poi_db_create(*db); + poi_db_prepare(*db); + return TRUE; +} +return FALSE; +} + gboolean poi_category_update(gint cat_id, gchar * cat_label, gchar * cat_desc, gint cat_enabled) { - if (cat_id > 0) { +gboolean results; + +if (cat_id > 0) { /* edit category */ if (SQLITE_OK != sqlite3_bind_text(_stmt_update_cat, 1, cat_label, -1, @@ -68,9 +249,11 @@ poi_category_update(gint cat_id, gchar * cat_label, gchar * cat_desc, } sqlite3_reset(_stmt_insert_cat); } +return results; } -gboolean poi_category_delete(DeletePOI * dpoi) +gboolean +poi_category_delete(DeletePOI * dpoi) { /* delete dpoi->poi_id */ if (SQLITE_OK != sqlite3_bind_int(_stmt_delete_poi_by_catid, 1, @@ -89,857 +272,19 @@ gboolean poi_category_delete(DeletePOI * dpoi) sqlite3_reset(_stmt_delete_cat); } -gboolean category_dialog(guint cat_id) -{ - gchar *cat_label = NULL, *cat_desc = NULL; - guint cat_enabled; - GtkWidget *dialog; - GtkWidget *table; - GtkWidget *label; - GtkWidget *txt_label; - GtkWidget *txt_desc; - GtkWidget *btn_delete = NULL; - GtkWidget *txt_scroll; - GtkWidget *chk_enabled; - GtkTextBuffer *desc_txt; - GtkTextIter begin, end; - gboolean results = TRUE; - DeletePOI dpoi = { NULL, NULL, 0 }; - printf("%s()\n", __PRETTY_FUNCTION__); - - if (cat_id > 0) { - if (SQLITE_OK != - sqlite3_bind_double(_stmt_select_cat, 1, cat_id) - || SQLITE_ROW != sqlite3_step(_stmt_select_cat)) { - vprintf("%s(): return FALSE\n", __PRETTY_FUNCTION__); - sqlite3_reset(_stmt_select_cat); - return FALSE; - } - - cat_label = g_strdup(sqlite3_column_text(_stmt_select_cat, 0)); - cat_desc = g_strdup(sqlite3_column_text(_stmt_select_cat, 1)); - cat_enabled = sqlite3_column_int(_stmt_select_cat, 2); - - sqlite3_reset(_stmt_select_cat); - - dialog = gtk_dialog_new_with_buttons(_("Edit Category"), - GTK_WINDOW(_window), - GTK_DIALOG_MODAL, - GTK_STOCK_OK, - GTK_RESPONSE_ACCEPT, NULL); - - gtk_container_add(GTK_CONTAINER - (GTK_DIALOG(dialog)->action_area), - btn_delete = - gtk_button_new_with_label(_("Delete"))); - - dpoi.dialog = dialog; - dpoi.txt_label = g_strdup(cat_label); - dpoi.id = cat_id; - - g_signal_connect(G_OBJECT(btn_delete), "clicked", - G_CALLBACK(category_delete), &dpoi); - - gtk_dialog_add_button(GTK_DIALOG(dialog), - GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT); - } else { - cat_enabled = 1; - cat_label = g_strdup(""); - cat_id = 0; - cat_desc = g_strdup(""); - - dialog = gtk_dialog_new_with_buttons(_("Add Category"), - GTK_WINDOW(_window), - GTK_DIALOG_MODAL, - GTK_STOCK_OK, - GTK_RESPONSE_ACCEPT, - GTK_STOCK_CANCEL, - GTK_RESPONSE_REJECT, NULL); - } - - gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), - table = gtk_table_new(6, 4, FALSE), TRUE, TRUE, 0); - - gtk_table_attach(GTK_TABLE(table), - label = gtk_label_new(_("Label")), - 0, 1, 0, 1, GTK_FILL, 0, 2, 4); - gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f); - gtk_table_attach(GTK_TABLE(table), - txt_label = gtk_entry_new(), - 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, 0, 2, 4); - - gtk_table_attach(GTK_TABLE(table), - label = gtk_label_new(_("Description")), - 0, 1, 1, 2, GTK_FILL, 0, 2, 4); - gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f); - - txt_scroll = gtk_scrolled_window_new(NULL, NULL); - gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(txt_scroll), - GTK_SHADOW_IN); - gtk_table_attach(GTK_TABLE(table), - txt_scroll, - 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, 0, 2, 4); - - gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(txt_scroll), - GTK_POLICY_AUTOMATIC, - GTK_POLICY_AUTOMATIC); - - txt_desc = gtk_text_view_new(); - gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(txt_desc), GTK_WRAP_WORD); - - gtk_container_add(GTK_CONTAINER(txt_scroll), txt_desc); - gtk_widget_set_size_request(GTK_WIDGET(txt_scroll), 400, 60); - - desc_txt = gtk_text_view_get_buffer(GTK_TEXT_VIEW(txt_desc)); - - gtk_table_attach(GTK_TABLE(table), - chk_enabled = - gtk_check_button_new_with_label(_("Enabled")), 0, 2, 2, - 3, GTK_EXPAND | GTK_FILL, 0, 2, 4); - - /* label */ - gtk_entry_set_text(GTK_ENTRY(txt_label), cat_label); - - /* desc */ - gtk_text_buffer_set_text(desc_txt, cat_desc, -1); - - /* enabled */ - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(chk_enabled), - (cat_enabled == 1 ? TRUE : FALSE)); - - g_free(cat_label); - cat_label = NULL; - g_free(cat_desc); - cat_desc = NULL; - - gtk_widget_show_all(dialog); - - while (GTK_RESPONSE_ACCEPT == gtk_dialog_run(GTK_DIALOG(dialog))) { - if (strlen(gtk_entry_get_text(GTK_ENTRY(txt_label)))) - cat_label = - g_strdup(gtk_entry_get_text(GTK_ENTRY(txt_label))); - else { - popup_error(dialog, - _ - ("Please specify a name for the category.")); - continue; - } - - gtk_text_buffer_get_iter_at_offset(desc_txt, &begin, 0); - gtk_text_buffer_get_end_iter(desc_txt, &end); - cat_desc = - gtk_text_buffer_get_text(desc_txt, &begin, &end, TRUE); - cat_enabled = - (gtk_toggle_button_get_active - (GTK_TOGGLE_BUTTON(chk_enabled)) ? 1 : 0); - - break; - } - - g_free(dpoi.txt_label); - - g_object_unref(desc_txt); - - gtk_widget_hide_all(dialog); - - vprintf("%s(): return\n", __PRETTY_FUNCTION__); - return results; -} - -void category_toggled(GtkCellRendererToggle * cell, gchar * path, gpointer data) -{ - GtkTreeIter iter; - gboolean cat_enabled; - guint cat_id; - printf("%s()\n", __PRETTY_FUNCTION__); - - GtkTreeModel *model = GTK_TREE_MODEL(data); - if (!gtk_tree_model_get_iter_from_string(model, &iter, path)) - return; - - gtk_tree_model_get(model, &iter, CAT_ENABLED, &cat_enabled, -1); - gtk_tree_model_get(model, &iter, CAT_ID, &cat_id, -1); - - cat_enabled ^= 1; - - if (SQLITE_OK != sqlite3_bind_int(_stmt_toggle_cat, 1, cat_enabled) || - SQLITE_OK != sqlite3_bind_int(_stmt_toggle_cat, 2, cat_id) || - SQLITE_DONE != sqlite3_step(_stmt_toggle_cat)) { - MACRO_BANNER_SHOW_INFO(_window, _("Problem updating Category")); - } else - gtk_list_store_set(GTK_LIST_STORE(model), &iter, - CAT_ENABLED, cat_enabled, -1); - - sqlite3_reset(_stmt_toggle_cat); - - vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__); -} - -GtkListStore *generate_store() -{ - GtkTreeIter iter; - GtkListStore *store; - printf("%s()\n", __PRETTY_FUNCTION__); - - store = gtk_list_store_new(CAT_NUM_COLUMNS, - G_TYPE_UINT, - G_TYPE_BOOLEAN, - G_TYPE_STRING, G_TYPE_STRING, G_TYPE_UINT); - - while (SQLITE_ROW == sqlite3_step(_stmt_selall_cat)) { - gtk_list_store_append(store, &iter); - gtk_list_store_set(store, &iter, - CAT_ID, sqlite3_column_int(_stmt_selall_cat, - 0), CAT_ENABLED, - sqlite3_column_int(_stmt_selall_cat, 3), - CAT_LABEL, - sqlite3_column_text(_stmt_selall_cat, 1), - CAT_DESC, - sqlite3_column_text(_stmt_selall_cat, 2), - CAT_POI_CNT, - sqlite3_column_int(_stmt_selall_cat, 4), -1); - } - sqlite3_reset(_stmt_selall_cat); - - vprintf("%s(): return %p\n", __PRETTY_FUNCTION__, store); - return store; -} - -gboolean category_add(GtkWidget * widget, GtkWidget * tree_view) +gboolean +poi_delete(DeletePOI * dpoi) { - GtkListStore *store; - printf("%s()\n", __PRETTY_FUNCTION__); - - if (category_dialog(0)) { - store = generate_store(); - gtk_tree_view_set_model(GTK_TREE_VIEW(tree_view), - GTK_TREE_MODEL(store)); - g_object_unref(G_OBJECT(store)); - } - vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__); - return TRUE; +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); + return FALSE; +} else { + sqlite3_reset(_stmt_delete_poi); } - -gboolean category_edit(GtkWidget * widget, GtkWidget * tree_view) -{ - GtkTreeIter iter; - GtkTreeModel *store; - GtkTreeSelection *selection; - printf("%s()\n", __PRETTY_FUNCTION__); - - store = gtk_tree_view_get_model(GTK_TREE_VIEW(tree_view)); - selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_view)); - if (gtk_tree_selection_get_selected(selection, &store, &iter)) { - GValue val; - memset(&val, 0, sizeof(val)); - gtk_tree_model_get_value(store, &iter, 0, &val); - if (category_dialog(g_value_get_uint(&val))) { - GtkListStore *new_store = generate_store(); - gtk_tree_view_set_model(GTK_TREE_VIEW(tree_view), - GTK_TREE_MODEL(new_store)); - g_object_unref(G_OBJECT(new_store)); - } - } - vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__); - return TRUE; -} - -gboolean category_list() -{ - GtkWidget *dialog; - GtkWidget *tree_view; - GtkWidget *sw; - GtkWidget *btn_edit; - GtkWidget *btn_add; - GtkTreeViewColumn *column; - GtkCellRenderer *renderer; - GtkListStore *store; - printf("%s()\n", __PRETTY_FUNCTION__); - - dialog = gtk_dialog_new_with_buttons(_("POI Categories"), - GTK_WINDOW(_window), - GTK_DIALOG_MODAL, GTK_STOCK_OK, - GTK_RESPONSE_ACCEPT, NULL); - -#ifdef WITH_HILDON - /* Enable the help button. */ - ossohelp_dialog_help_enable(GTK_DIALOG(dialog), HELP_ID_POICAT, _osso); -#endif - - gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->action_area), - btn_edit = gtk_button_new_with_label(_("Edit"))); - - gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->action_area), - btn_add = gtk_button_new_with_label(_("Add"))); - - store = generate_store(); - - if (!store) - return TRUE; - - sw = gtk_scrolled_window_new(NULL, NULL); - gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), - GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); - gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), - sw, TRUE, TRUE, 0); - - tree_view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store)); - /* Maemo-related? */ - g_object_set(tree_view, "allow-checkbox-mode", FALSE, NULL); - gtk_container_add(GTK_CONTAINER(sw), tree_view); - - gtk_tree_selection_set_mode(gtk_tree_view_get_selection - (GTK_TREE_VIEW(tree_view)), - GTK_SELECTION_SINGLE); - gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(tree_view), TRUE); - - renderer = gtk_cell_renderer_text_new(); - column = - gtk_tree_view_column_new_with_attributes(_("ID"), renderer, "text", - CAT_ID, NULL); - gtk_tree_view_append_column(GTK_TREE_VIEW(tree_view), column); - gtk_tree_view_column_set_max_width(column, 1); - - renderer = gtk_cell_renderer_toggle_new(); - g_signal_connect(renderer, "toggled", - G_CALLBACK(category_toggled), store); - column = - gtk_tree_view_column_new_with_attributes(_("Enabled"), renderer, - "active", CAT_ENABLED, - NULL); - gtk_tree_view_append_column(GTK_TREE_VIEW(tree_view), column); - - g_object_unref(G_OBJECT(store)); - - renderer = gtk_cell_renderer_text_new(); - column = - gtk_tree_view_column_new_with_attributes(_("Label"), renderer, - "text", CAT_LABEL, NULL); - gtk_tree_view_append_column(GTK_TREE_VIEW(tree_view), column); - - renderer = gtk_cell_renderer_text_new(); - column = - gtk_tree_view_column_new_with_attributes(_("Description"), renderer, - "text", CAT_DESC, NULL); - gtk_tree_view_append_column(GTK_TREE_VIEW(tree_view), column); - - renderer = gtk_cell_renderer_text_new(); - column = - gtk_tree_view_column_new_with_attributes(_("# POIs"), renderer, - "text", CAT_POI_CNT, NULL); - gtk_tree_view_append_column(GTK_TREE_VIEW(tree_view), column); - - gtk_window_set_default_size(GTK_WINDOW(dialog), 500, 300); - gtk_widget_show_all(dialog); - - g_signal_connect(G_OBJECT(btn_edit), "clicked", - G_CALLBACK(category_edit), tree_view); - - g_signal_connect(G_OBJECT(btn_add), "clicked", - G_CALLBACK(category_add), tree_view); - - while (GTK_RESPONSE_ACCEPT == gtk_dialog_run(GTK_DIALOG(dialog))) { - break; - } - gtk_widget_destroy(dialog); - - vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__); - return TRUE; -} - -gboolean menu_cb_category(GtkAction * action) -{ - printf("%s()\n", __PRETTY_FUNCTION__); - - if (category_list()) - map_force_redraw(); - - vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__); - 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); - return FALSE; - } else { - sqlite3_reset(_stmt_delete_poi); - } -} - return TRUE; } -gboolean select_poi(guint unitx, guint unity, PoiInfo * poi) -{ - guint x, y; - gfloat lat1, lon1, lat2, lon2; - GtkWidget *dialog; - GtkWidget *list; - GtkWidget *sw; - GtkTreeViewColumn *column; - GtkCellRenderer *renderer; - GtkListStore *store; - GtkTreeIter iter; - gboolean selected = FALSE; - gchar tmp1[16], tmp2[16]; - guint num_cats = 0; - printf("%s()\n", __PRETTY_FUNCTION__); - - x = unitx - pixel2unit(3 * _draw_width); - y = unity + pixel2unit(3 * _draw_width); - unit2latlon(x, y, lat1, lon1); - - x = unitx + pixel2unit(3 * _draw_width); - y = unity - pixel2unit(3 * _draw_width); - unit2latlon(x, y, lat2, lon2); - - store = gtk_list_store_new(POI_NUM_COLUMNS, G_TYPE_INT, /* POI ID */ - G_TYPE_INT, /* Category ID */ - G_TYPE_FLOAT, /* Latitude */ - G_TYPE_FLOAT, /* Longitude */ - G_TYPE_STRING, /* Lat/Lon */ - G_TYPE_STRING, /* POI Label */ - G_TYPE_STRING, /* POI Desc. */ - G_TYPE_STRING); /* Category Label */ - - if (SQLITE_OK != sqlite3_bind_double(_stmt_select_poi, 1, lat1) || - SQLITE_OK != sqlite3_bind_double(_stmt_select_poi, 2, lat2) || - SQLITE_OK != sqlite3_bind_double(_stmt_select_poi, 3, lon1) || - SQLITE_OK != sqlite3_bind_double(_stmt_select_poi, 4, lon2)) { - g_printerr("Failed to bind values for _stmt_select_poi"); - return FALSE; - } - - while (SQLITE_ROW == sqlite3_step(_stmt_select_poi)) { - gfloat lat, lon; - lat = sqlite3_column_double(_stmt_select_poi, 0); - lon = sqlite3_column_double(_stmt_select_poi, 1); - printf("Found POI: %f, %f, %s, %s, %s\n", - lat, - lon, - sqlite3_column_text(_stmt_select_poi, 3), - sqlite3_column_text(_stmt_select_poi, 4), - sqlite3_column_text(_stmt_select_poi, 6)); - lat_format(lat, tmp1); - lon_format(lon, tmp2); - gtk_list_store_append(store, &iter); - gtk_list_store_set(store, &iter, - POI_POIID, - sqlite3_column_int(_stmt_select_poi, 2), - POI_CATID, - sqlite3_column_int(_stmt_select_poi, 5), - POI_LAT, lat, POI_LON, lon, POI_LATLON, - g_strdup_printf("%s, %s", tmp1, tmp2), - POI_LABEL, - sqlite3_column_text(_stmt_select_poi, 3), - POI_DESC, - sqlite3_column_text(_stmt_select_poi, 4), - POI_CATLAB, - sqlite3_column_text(_stmt_select_poi, 6), - -1); - num_cats++; - } - sqlite3_reset(_stmt_select_poi); - - switch (num_cats) { - case 0: - g_object_unref(G_OBJECT(store)); - MACRO_BANNER_SHOW_INFO(_window, _("No POIs found.")); - return FALSE; - break; - case 1: - /* iter is still set to the most-recently added POI. */ - gtk_tree_model_get(GTK_TREE_MODEL(store), - &iter, - POI_POIID, &(poi->poi_id), - POI_CATID, &(poi->cat_id), - POI_LAT, &(poi->lat), - POI_LON, &(poi->lon), - POI_LABEL, &(poi->label), - POI_DESC, &(poi->desc), -1); - g_object_unref(G_OBJECT(store)); - return TRUE; - break; - } - - /* There are at least 2 matching POI's - let the user select one. */ - dialog = gtk_dialog_new_with_buttons(_("Select POI"), - GTK_WINDOW(_window), - GTK_DIALOG_MODAL, GTK_STOCK_OK, - GTK_RESPONSE_ACCEPT, - GTK_STOCK_CANCEL, - GTK_RESPONSE_REJECT, NULL); - - gtk_window_set_default_size(GTK_WINDOW(dialog), 500, 300); - - sw = gtk_scrolled_window_new(NULL, NULL); - gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), - GTK_SHADOW_ETCHED_IN); - gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), - GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); - gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), - sw, TRUE, TRUE, 0); - - list = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store)); - g_object_unref(G_OBJECT(store)); - gtk_container_add(GTK_CONTAINER(sw), list); - - gtk_tree_selection_set_mode(gtk_tree_view_get_selection - (GTK_TREE_VIEW(list)), - GTK_SELECTION_SINGLE); - gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(list), TRUE); - - renderer = gtk_cell_renderer_text_new(); - column = - gtk_tree_view_column_new_with_attributes(_("Location"), renderer, - "text", POI_LATLON, NULL); - gtk_tree_view_append_column(GTK_TREE_VIEW(list), column); - - renderer = gtk_cell_renderer_text_new(); - column = - gtk_tree_view_column_new_with_attributes(_("Label"), renderer, - "text", POI_LABEL, NULL); - gtk_tree_view_append_column(GTK_TREE_VIEW(list), column); - - renderer = gtk_cell_renderer_text_new(); - column = - gtk_tree_view_column_new_with_attributes(_("Category"), renderer, - "text", POI_CATLAB, NULL); - gtk_tree_view_append_column(GTK_TREE_VIEW(list), column); - - gtk_widget_show_all(dialog); - - while (GTK_RESPONSE_ACCEPT == gtk_dialog_run(GTK_DIALOG(dialog))) { - if (gtk_tree_selection_get_selected - (gtk_tree_view_get_selection(GTK_TREE_VIEW(list)), NULL, - &iter)) { - gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, - POI_POIID, &(poi->poi_id), -1); - gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, - POI_CATID, &(poi->cat_id), -1); - gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, - POI_LATLON, &(poi->lat), -1); - gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, - POI_LATLON, &(poi->lon), -1); - gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, - POI_LABEL, &(poi->label), -1); - gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, - POI_DESC, &(poi->desc), -1); - selected = TRUE; - break; - } else - popup_error(dialog, _("Select one POI from the list.")); - } - - gtk_widget_destroy(dialog); - - vprintf("%s(): return %d\n", __PRETTY_FUNCTION__, selected); - return selected; -} - -void poi_populate_cat_combo(GtkWidget * cmb_category, guint cat_id) -{ - GtkTreeIter active; - GtkListStore *store; - gboolean has_active = FALSE; - printf("%s()\n", __PRETTY_FUNCTION__); - - store = - GTK_LIST_STORE(gtk_combo_box_get_model - (GTK_COMBO_BOX(cmb_category))); - gtk_list_store_clear(store); - - while (SQLITE_ROW == sqlite3_step(_stmt_selall_cat)) { - GtkTreeIter iter; - guint cid = sqlite3_column_int(_stmt_selall_cat, 0); - gtk_list_store_append(store, &iter); - gtk_list_store_set(store, &iter, - 0, cid, - 1, sqlite3_column_text(_stmt_selall_cat, 1), - -1); - if (cid == cat_id) { - active = iter; - has_active = TRUE; - } - } - sqlite3_reset(_stmt_selall_cat); - - if (!has_active) - gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &active); - - gtk_combo_box_set_active_iter(GTK_COMBO_BOX(cmb_category), &active); - - vprintf("%s(): return\n", __PRETTY_FUNCTION__); -} - -typedef struct _PoiCategoryEditInfo PoiCategoryEditInfo; -struct _PoiCategoryEditInfo { - GtkWidget *cmb_category; - guint cat_id; -}; - -gboolean poi_edit_cat(GtkWidget * widget, PoiCategoryEditInfo * data) -{ - printf("%s()\n", __PRETTY_FUNCTION__); - if (category_list()) - poi_populate_cat_combo(data->cmb_category, data->cat_id); - vprintf("%s(): return\n", __PRETTY_FUNCTION__); - return TRUE; -} - -gboolean poi_dialog(POIAction action, guint unitx, guint unity) -{ - PoiInfo poi; - gchar slat1[10], slon1[10]; - gchar *p_latlon; - GtkWidget *dialog; - GtkWidget *table; - GtkWidget *label; - GtkWidget *txt_label; - GtkWidget *cmb_category; - GtkWidget *txt_desc; - GtkWidget *btn_delete = NULL; - GtkWidget *btn_catedit; - GtkWidget *hbox; - GtkWidget *txt_scroll; - GtkTextBuffer *desc_txt; - GtkTextIter begin, end; - DeletePOI dpoi = { NULL, NULL, 0 }; - PoiCategoryEditInfo pcedit; - printf("%s()\n", __PRETTY_FUNCTION__); - - if (action == ACTION_EDIT_POI) { - if (!select_poi(unitx, unity, &poi)) { - return FALSE; - } - - dialog = gtk_dialog_new_with_buttons(_("Edit POI"), - GTK_WINDOW(_window), - GTK_DIALOG_MODAL, - GTK_STOCK_OK, - GTK_RESPONSE_ACCEPT, NULL); - - gtk_container_add(GTK_CONTAINER - (GTK_DIALOG(dialog)->action_area), - btn_delete = - gtk_button_new_with_label(_("Delete"))); - - dpoi.dialog = dialog; - dpoi.txt_label = g_strdup(poi.label); - dpoi.id = poi.poi_id; - - g_signal_connect(G_OBJECT(btn_delete), "clicked", - G_CALLBACK(poi_delete), &dpoi); - - gtk_dialog_add_button(GTK_DIALOG(dialog), - GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT); - } else { - if (SQLITE_ROW == sqlite3_step(_stmt_nextlabel_poi)) - poi.label = g_strdup_printf("Point%06d", - sqlite3_column_int - (_stmt_nextlabel_poi, 0)); - sqlite3_reset(_stmt_nextlabel_poi); - - unit2latlon(unitx, unity, poi.lat, poi.lon); - - poi.poi_id = 0; - poi.cat_id = 0; - poi.desc = g_strdup(""); - - dialog = gtk_dialog_new_with_buttons(_("Add POI"), - GTK_WINDOW(_window), - GTK_DIALOG_MODAL, - GTK_STOCK_OK, - GTK_RESPONSE_ACCEPT, - GTK_STOCK_CANCEL, - GTK_RESPONSE_REJECT, NULL); - } - - /* Set the p_latlon string. */ - { - gchar tmp1[16], tmp2[16]; - lat_format(poi.lat, tmp1); - lon_format(poi.lon, tmp2); - p_latlon = g_strdup_printf("%s, %s", tmp1, tmp2); - } - - gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), - table = gtk_table_new(6, 4, FALSE), TRUE, TRUE, 0); - - gtk_table_attach(GTK_TABLE(table), - label = gtk_label_new(_("Lat, Lon")), - 0, 1, 0, 1, GTK_FILL, 0, 2, 4); - gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f); - - gtk_table_attach(GTK_TABLE(table), - label = gtk_label_new(p_latlon), - 1, 3, 0, 1, GTK_FILL, 0, 2, 4); - gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.5f); - - gtk_table_attach(GTK_TABLE(table), - label = gtk_label_new(_("Label")), - 0, 1, 1, 2, GTK_FILL, 0, 2, 4); - gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f); - gtk_table_attach(GTK_TABLE(table), - txt_label = gtk_entry_new(), - 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, 0, 2, 4); - - gtk_table_attach(GTK_TABLE(table), - label = gtk_label_new(_("Category")), - 0, 1, 3, 4, GTK_FILL, 0, 2, 4); - gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f); - gtk_table_attach(GTK_TABLE(table), - hbox = gtk_hbox_new(FALSE, 4), - 1, 2, 3, 4, GTK_EXPAND | GTK_FILL, 0, 2, 4); - gtk_box_pack_start(GTK_BOX(hbox), cmb_category = gtk_combo_box_new_with_model(GTK_TREE_MODEL(gtk_list_store_new(2, G_TYPE_INT, /* Category ID */ - G_TYPE_STRING))), /* Category Label */ - FALSE, FALSE, 4); - /* Set up the view for the combo box. */ - { - GtkCellRenderer *renderer; - renderer = gtk_cell_renderer_text_new(); - gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(cmb_category), - renderer, TRUE); - gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(cmb_category), - renderer, "text", 1, NULL); - } - - gtk_box_pack_start(GTK_BOX(hbox), - btn_catedit = - gtk_button_new_with_label(_("Edit Categories...")), - FALSE, FALSE, 4); - - gtk_table_attach(GTK_TABLE(table), - label = gtk_label_new(_("Description")), - 0, 1, 5, 6, GTK_FILL, 0, 2, 4); - gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f); - - txt_scroll = gtk_scrolled_window_new(NULL, NULL); - gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(txt_scroll), - GTK_SHADOW_IN); - gtk_table_attach(GTK_TABLE(table), - txt_scroll, - 1, 2, 5, 6, GTK_EXPAND | GTK_FILL, 0, 2, 4); - - gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(txt_scroll), - GTK_POLICY_AUTOMATIC, - GTK_POLICY_AUTOMATIC); - - txt_desc = gtk_text_view_new(); - gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(txt_desc), GTK_WRAP_WORD); - - gtk_container_add(GTK_CONTAINER(txt_scroll), txt_desc); - gtk_widget_set_size_request(GTK_WIDGET(txt_scroll), 400, 60); - - desc_txt = gtk_text_view_get_buffer(GTK_TEXT_VIEW(txt_desc)); - - /* label */ - gtk_entry_set_text(GTK_ENTRY(txt_label), poi.label); - - /* category */ - poi_populate_cat_combo(cmb_category, poi.cat_id); - - /* poi_desc */ - gtk_text_buffer_set_text(desc_txt, poi.desc, -1); - - /* Connect Signals */ - pcedit.cmb_category = cmb_category; - pcedit.cat_id = poi.cat_id; - g_signal_connect(G_OBJECT(btn_catedit), "clicked", - G_CALLBACK(poi_edit_cat), &pcedit); - gtk_widget_show_all(dialog); - - while (GTK_RESPONSE_ACCEPT == gtk_dialog_run(GTK_DIALOG(dialog))) { - const gchar *poi_label = NULL; - gchar *poi_desc = NULL; - GtkTreeIter iter; - - if (strlen(gtk_entry_get_text(GTK_ENTRY(txt_label)))) - poi_label = gtk_entry_get_text(GTK_ENTRY(txt_label)); - else { - popup_error(dialog, - _("Please specify a name for the POI.")); - continue; - } - - if (!gtk_combo_box_get_active_iter - (GTK_COMBO_BOX(cmb_category), &iter)) { - popup_error(dialog, - _ - ("Please specify a category for the POI.")); - continue; - } - - gtk_text_buffer_get_iter_at_offset(desc_txt, &begin, 0); - gtk_text_buffer_get_end_iter(desc_txt, &end); - poi_desc = - gtk_text_buffer_get_text(desc_txt, &begin, &end, TRUE); - - gtk_tree_model_get(gtk_combo_box_get_model - (GTK_COMBO_BOX(cmb_category)), &iter, 0, - &poi.cat_id, -1); - - if (action == ACTION_EDIT_POI) { - /* edit poi */ - if (SQLITE_OK != - sqlite3_bind_text(_stmt_update_poi, 1, poi_label, - -1, SQLITE_STATIC) - || SQLITE_OK != sqlite3_bind_text(_stmt_update_poi, - 2, poi_desc, -1, - g_free) - || SQLITE_OK != sqlite3_bind_int(_stmt_update_poi, - 3, poi.cat_id) - || SQLITE_OK != sqlite3_bind_int(_stmt_update_poi, - 4, poi.poi_id) - || SQLITE_DONE != sqlite3_step(_stmt_update_poi)) { - MACRO_BANNER_SHOW_INFO(_window, - _ - ("Problem updating POI")); - } else { - MACRO_MAP_RENDER_DATA(); - } - sqlite3_reset(_stmt_update_poi); - } else { - /* add poi */ - g_ascii_dtostr(slat1, sizeof(slat1), poi.lat); - g_ascii_dtostr(slon1, sizeof(slon1), poi.lon); - if (SQLITE_OK != - sqlite3_bind_double(_stmt_insert_poi, 1, poi.lat) - || SQLITE_OK != - sqlite3_bind_double(_stmt_insert_poi, 2, poi.lon) - || SQLITE_OK != sqlite3_bind_text(_stmt_insert_poi, - 3, poi_label, -1, - g_free) - || SQLITE_OK != sqlite3_bind_text(_stmt_insert_poi, - 4, poi_desc, -1, - g_free) - || SQLITE_OK != sqlite3_bind_int(_stmt_insert_poi, - 5, poi.cat_id) - || SQLITE_DONE != sqlite3_step(_stmt_insert_poi)) { - MACRO_BANNER_SHOW_INFO(_window, - _("Problem adding POI")); - } else { - MACRO_MAP_RENDER_DATA(); - } - sqlite3_reset(_stmt_insert_poi); - } - break; - } - - g_free(dpoi.txt_label); - - g_free(poi.label); - g_free(poi.desc); - g_free(p_latlon); - - gtk_widget_hide_all(dialog); - - vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__); - return TRUE; -} diff --git a/src/settings-gui.c b/src/settings-gui.c index 53a22fa..9662f24 100644 --- a/src/settings-gui.c +++ b/src/settings-gui.c @@ -839,7 +839,7 @@ gboolean settings_dialog() 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_connect(&_db, _poi_db); } else _poi_db = NULL; diff --git a/src/ui-common.c b/src/ui-common.c index 13ea9d2..8633999 100644 --- a/src/ui-common.c +++ b/src/ui-common.c @@ -259,7 +259,7 @@ gboolean window_present() /** * Create the menu items needed for the drop down menu. */ -void menu_init() +static void menu_init() { /* Create needed handles. */ GtkMenu *menu; @@ -509,11 +509,11 @@ void menu_init() /* Connect the "View" signals. */ g_signal_connect(G_OBJECT(_menu_zoomin_item), "activate", - G_CALLBACK(menu_cb_zoomin), NULL); + G_CALLBACK(cb_zoomin), NULL); g_signal_connect(G_OBJECT(_menu_zoomout_item), "activate", - G_CALLBACK(menu_cb_zoomout), NULL); + G_CALLBACK(cb_zoomout), NULL); g_signal_connect(G_OBJECT(_menu_fullscreen_item), "toggled", - G_CALLBACK(menu_cb_fullscreen), NULL); + G_CALLBACK(cb_fullscreen), NULL); g_signal_connect(G_OBJECT(_menu_show_tracks_item), "toggled", G_CALLBACK(menu_cb_show_tracks), NULL); g_signal_connect(G_OBJECT(_menu_show_scale_item), "toggled", @@ -713,10 +713,45 @@ void menu_init() vprintf("%s(): return\n", __PRETTY_FUNCTION__); } +static void toolbar_init(void) +{ +GtkWidget *item; + +#if 0 +item = gtk_tool_button_new_from_stock (GTK_STOCK_REFRESH); +gtk_toolbar_insert (GTK_TOOLBAR (_toolbar), item, -1); +g_signal_connect (item, "clicked", G_CALLBACK (gtk_main_quit), NULL); +#endif + +item = gtk_tool_button_new_from_stock (GTK_STOCK_ZOOM_IN); +gtk_toolbar_insert (GTK_TOOLBAR (_toolbar), item, -1); +g_signal_connect (item, "clicked", G_CALLBACK (cb_zoomin), NULL); + +item = gtk_tool_button_new_from_stock (GTK_STOCK_ZOOM_OUT); +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); +gtk_toolbar_insert (GTK_TOOLBAR (_toolbar), item, -1); +g_signal_connect (item, "clicked", G_CALLBACK (cb_zoom_base), NULL); +#endif + +item = gtk_separator_tool_item_new(); +gtk_toolbar_insert (GTK_TOOLBAR (_toolbar), item, -1); + +item = gtk_tool_button_new_from_stock (GTK_STOCK_FULLSCREEN); +gtk_toolbar_insert (GTK_TOOLBAR (_toolbar), item, -1); +g_signal_connect (item, "clicked", G_CALLBACK (cb_fullscreen), NULL); + +item = gtk_separator_tool_item_new(); +gtk_toolbar_insert (GTK_TOOLBAR (_toolbar), item, -1); +} + /** * Initialize everything required in preparation for calling gtk_main(). */ -void maemo_mapper_init(gint argc, gchar ** argv) +void mapper_init(gint argc, gchar ** argv) { GtkWidget *hbox, *label, *vbox, *vbox_main; GdkColor color; @@ -855,6 +890,7 @@ void maemo_mapper_init(gint argc, gchar ** argv) #endif _toolbar = gtk_toolbar_new(); + toolbar_init(); #ifdef WITH_HILDON /* Create and add widgets and supporting data. */ -- 2.39.5