From ea3933fc79e41697fd1cddbda74c34b839770c9a Mon Sep 17 00:00:00 2001 From: Evan Battaglia Date: Sat, 1 Oct 2005 08:28:57 +0000 Subject: [PATCH] Alex's optional symbols patch; Fix geocaching .loc symbols --- AUTHORS | 2 +- ChangeLog | 3 ++- src/dialog.c | 10 +++++++--- src/file.c | 2 +- src/garminsymbols.c | 22 +--------------------- src/gpx.c | 7 +++++-- src/viktrwlayer.c | 12 +++++++++--- 7 files changed, 26 insertions(+), 32 deletions(-) diff --git a/AUTHORS b/AUTHORS index 019f1e7a..09b88fa4 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1 +1 @@ -Evan Battaglia \ No newline at end of file +Evan Battaglia diff --git a/ChangeLog b/ChangeLog index a88c29bf..8d32c74d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -9,7 +9,8 @@ Alex Foobarian : * Updated DND to insert layers at the point of the drop, instead of front of list * Added wp symbol support to gpx * Fixed name collisions during track/wp DND - + * Layer-wide option as to whether to show waypoint symbols + 2005-09-29 Alex Foobarian : * Added support for waypoint symbols (changing, loading, saving), and a small number of icons. diff --git a/src/dialog.c b/src/dialog.c index e6111395..602c5c64 100644 --- a/src/dialog.c +++ b/src/dialog.c @@ -219,23 +219,27 @@ gboolean a_dialog_new_waypoint ( GtkWindow *parent, gchar **dest, VikWaypoint *w symbollabel = gtk_label_new ("Symbol:"); GtkTreeIter iter; - store = gtk_list_store_new(2, G_TYPE_STRING, GDK_TYPE_PIXBUF); + store = gtk_list_store_new(3, G_TYPE_STRING, GDK_TYPE_PIXBUF, G_TYPE_STRING); symbolentry = gtk_combo_box_new_with_model(GTK_TREE_MODEL(store)); gtk_combo_box_set_wrap_width(GTK_COMBO_BOX(symbolentry), 3); gtk_list_store_append (store, &iter); - gtk_list_store_set (store, &iter, 0, "(none)", 1, NULL, -1); + 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 (!strcmp(sym, wp->symbol)) { + if (sym && !strcmp(sym, wp->symbol)) { g_free(sym); break; } else { diff --git a/src/file.c b/src/file.c index 0d72bf6f..a3fbcc97 100644 --- a/src/file.c +++ b/src/file.c @@ -379,7 +379,7 @@ static void file_read ( VikAggregateLayer *top, FILE *f, gpointer vp ) break; } if ( ! found_match ) - g_warning ( "Line %ld: Unknown parameter", line_num ); + g_warning ( "Line %ld: Unknown parameter. Line:\n%s", line_num, line ); } else g_warning ( "Line %ld: Invalid parameter or parameter outside of layer.", line_num ); diff --git a/src/garminsymbols.c b/src/garminsymbols.c index 78d3c892..73a0fd4e 100644 --- a/src/garminsymbols.c +++ b/src/garminsymbols.c @@ -304,28 +304,8 @@ struct { GHashTable *icons = NULL; -/* found via Google, from Sylpheed/GPL and/or gstring.c in Glib */ -static gint g_str_case_equal(gconstpointer v, gconstpointer v2) -{ - return strcasecmp((const gchar *)v, (const gchar *)v2) == 0; -} - -static guint g_str_case_hash(gconstpointer key) -{ - const gchar *p = key; - guint h = *p; - - if (h) { - h = tolower(h); - for (p += 1; *p != '\0'; p++) - h = (h << 5) - h + tolower(*p); - } - - return h; -} - static void init_icons() { - icons = g_hash_table_new_full ( g_str_case_hash, g_str_case_equal, NULL, NULL); + icons = g_hash_table_new_full ( g_str_hash, g_str_equal, NULL, NULL); gint i; for (i=0; istr ); + case tt_wpt_sym: { + gchar *tmp_lower = g_utf8_strdown(c_cdata->str, -1); /* for things like Geocache */ + vik_waypoint_set_symbol ( c_wp, tmp_lower ); + g_free ( tmp_lower ); g_string_erase ( c_cdata, 0, -1 ); break; + } case tt_trk_desc: vik_track_set_comment ( c_tr, c_cdata->str ); diff --git a/src/viktrwlayer.c b/src/viktrwlayer.c index c494465b..5c8bc9ed 100644 --- a/src/viktrwlayer.c +++ b/src/viktrwlayer.c @@ -87,6 +87,7 @@ struct _VikTrwLayer { guint8 wp_symbol; guint8 wp_size; + gboolean wp_draw_symbols; gdouble velocity_min, velocity_max; GArray *track_gc; @@ -273,8 +274,9 @@ VikLayerParam trw_layer_params[] = { { "wptextcolor", VIK_LAYER_PARAM_COLOR, GROUP_WAYPOINTS, "Waypoint Text:", VIK_LAYER_WIDGET_COLOR, 0 }, { "wpbgcolor", VIK_LAYER_PARAM_COLOR, GROUP_WAYPOINTS, "Background:", VIK_LAYER_WIDGET_COLOR, 0 }, { "wpbgand", VIK_LAYER_PARAM_BOOLEAN, GROUP_WAYPOINTS, "Fake BG Color Translucency:", VIK_LAYER_WIDGET_CHECKBUTTON, 0 }, - { "wpsymbol", VIK_LAYER_PARAM_UINT, GROUP_WAYPOINTS, "Waypoint symbol:", VIK_LAYER_WIDGET_RADIOGROUP, params_wpsymbols }, + { "wpsymbol", VIK_LAYER_PARAM_UINT, GROUP_WAYPOINTS, "Waypoint marker:", VIK_LAYER_WIDGET_RADIOGROUP, params_wpsymbols }, { "wpsize", VIK_LAYER_PARAM_UINT, GROUP_WAYPOINTS, "Waypoint size:", VIK_LAYER_WIDGET_SPINBUTTON, params_scales + 7 }, + { "wpsyms", VIK_LAYER_PARAM_BOOLEAN, GROUP_WAYPOINTS, "Draw Waypoint Symbols:", VIK_LAYER_WIDGET_CHECKBUTTON }, { "drawimages", VIK_LAYER_PARAM_BOOLEAN, GROUP_IMAGES, "Draw Waypoint Images", VIK_LAYER_WIDGET_CHECKBUTTON }, { "image_size", VIK_LAYER_PARAM_UINT, GROUP_IMAGES, "Image Size (pixels):", VIK_LAYER_WIDGET_HSCALE, params_scales + 3 }, @@ -282,7 +284,7 @@ VikLayerParam trw_layer_params[] = { { "image_cache_size", VIK_LAYER_PARAM_UINT, GROUP_IMAGES, "Image Memory Cache Size:", VIK_LAYER_WIDGET_HSCALE, params_scales + 5 }, }; -enum { PARAM_TV, PARAM_WV, PARAM_DM, PARAM_DL, PARAM_DP, PARAM_DE, PARAM_EF, PARAM_DS, PARAM_SL, PARAM_LT, PARAM_BLT, PARAM_TBGC, PARAM_VMIN, PARAM_VMAX, PARAM_DLA, PARAM_WPC, PARAM_WPTC, PARAM_WPBC, PARAM_WPBA, PARAM_WPSYM, PARAM_WPSIZE, PARAM_DI, PARAM_IS, PARAM_IA, PARAM_ICS, NUM_PARAMS }; +enum { PARAM_TV, PARAM_WV, PARAM_DM, PARAM_DL, PARAM_DP, PARAM_DE, PARAM_EF, PARAM_DS, PARAM_SL, PARAM_LT, PARAM_BLT, PARAM_TBGC, PARAM_VMIN, PARAM_VMAX, PARAM_DLA, PARAM_WPC, PARAM_WPTC, PARAM_WPBC, PARAM_WPBA, PARAM_WPSYM, PARAM_WPSIZE, PARAM_WPSYMS, PARAM_DI, PARAM_IS, PARAM_IA, PARAM_ICS, NUM_PARAMS }; /****** END PARAMETERS ******/ @@ -477,6 +479,7 @@ static gboolean trw_layer_set_param ( VikTrwLayer *vtl, guint16 id, VikLayerPara case PARAM_WPBA: gdk_gc_set_function(vtl->waypoint_bg_gc, data.b ? GDK_AND : GDK_COPY ); break; case PARAM_WPSYM: if ( data.u < WP_NUM_SYMBOLS ) vtl->wp_symbol = data.u; break; case PARAM_WPSIZE: if ( data.u > 0 && data.u <= 64 ) vtl->wp_size = data.u; break; + case PARAM_WPSYMS: vtl->wp_draw_symbols = data.b; break; } return TRUE; } @@ -511,6 +514,7 @@ static VikLayerParamData trw_layer_get_param ( VikTrwLayer *vtl, guint16 id ) case PARAM_WPBA: rv.b = (vik_gc_get_function(vtl->waypoint_bg_gc)==GDK_AND); break; case PARAM_WPSYM: rv.u = vtl->wp_symbol; break; case PARAM_WPSIZE: rv.u = vtl->wp_size; break; + case PARAM_WPSYMS: rv.b = vtl->wp_draw_symbols; break; } return rv; } @@ -551,6 +555,7 @@ static VikTrwLayer *trw_layer_copy ( VikTrwLayer *vtl, gpointer vp ) rv->coord_mode = vtl->coord_mode; rv->wp_symbol = vtl->wp_symbol; rv->wp_size = vtl->wp_size; + rv->wp_draw_symbols = vtl->wp_draw_symbols; trw_layer_new_track_gcs ( rv, VIK_VIEWPORT(vp) ); @@ -983,7 +988,7 @@ static void trw_layer_draw_waypoint ( const gchar *name, VikWaypoint *wp, struct } /* DRAW ACTUAL DOT */ - if ( wp->symbol && (sym = a_get_wp_sym(wp->symbol)) ) { + if ( dp->vtl->wp_draw_symbols && wp->symbol && (sym = a_get_wp_sym(wp->symbol)) ) { vik_viewport_draw_pixbuf ( dp->vp, sym, 0, 0, x - gdk_pixbuf_get_width(sym)/2, y - gdk_pixbuf_get_height(sym)/2, -1, -1 ); } else if ( wp == dp->vtl->current_wp ) { @@ -1107,6 +1112,7 @@ VikTrwLayer *vik_trw_layer_create ( VikViewport *vp ) rv->has_verified_thumbnails = FALSE; rv->wp_symbol = WP_SYMBOL_FILLED_SQUARE; rv->wp_size = 4; + rv->wp_draw_symbols = TRUE; rv->coord_mode = vik_viewport_get_coord_mode ( vp ); -- 2.39.5