From 724ac979c9b745c3841acf02d82f303fad540e09 Mon Sep 17 00:00:00 2001 From: Kaj-Michael Lang Date: Tue, 6 May 2008 16:52:05 +0300 Subject: [PATCH] Map widget: - Add methods to add and remove paths --- src/gtkmap.c | 33 +++++++++++++++++++++++++++++++++ src/gtkmap.h | 4 ++-- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/src/gtkmap.c b/src/gtkmap.c index 2e59188..f8db4cb 100644 --- a/src/gtkmap.c +++ b/src/gtkmap.c @@ -811,6 +811,39 @@ for (iter=priv->paths; iter!=NULL; iter=iter->next) { } } +gboolean +gtk_map_add_path(GtkWidget *widget, Path *path) +{ +GtkMap *map; +GtkMapPriv *priv; + +g_return_if_fail(GTK_IS_MAP(widget)); +g_return_if_fail(path); + +map=GTK_MAP(widget); +priv=GTK_MAP_GET_PRIVATE(map); + +/* Don't allow duplicates */ +if (g_slist_find(priv->paths, path)!=NULL) + return FALSE; +priv->paths=g_slist_append(priv->paths, path); +return TRUE; +} + +gboolean +gtk_map_remove_path(GtkWidget *widget, Path *path) +{ +GtkMap *map; +GtkMapPriv *priv; + +g_return_if_fail(GTK_IS_MAP(widget)); +g_return_if_fail(path); + +map=GTK_MAP(widget); +priv=GTK_MAP_GET_PRIVATE(map); +priv->paths=g_slist_remove(priv->paths, path); +} + static void gtk_map_mark_draw(GtkWidget *widget, GdkEventExpose *event) { diff --git a/src/gtkmap.h b/src/gtkmap.h index 958f3ff..b9729a2 100644 --- a/src/gtkmap.h +++ b/src/gtkmap.h @@ -73,9 +73,9 @@ void gtk_map_set_mark(GtkWidget *map); void gtk_map_move_mark(GtkWidget *map); /* Path functions */ -void gtk_map_set_path(GtkWidget *map, Path *path, PathType type, gint id); +gboolean gtk_map_add_path(GtkWidget *map, Path *path); gboolean gtk_map_remove_path(GtkWidget *map, Path *path); -gboolean gtk_map_remove_path_by_id(GtkWidget *map, gint id); +gboolean gtk_map_remove_path_by_id(GtkWidget *map, gint path_id); /* Get copy of map buffer */ GdkPixmap *gtk_map_pixmap_get(GtkWidget *map); -- 2.39.5