From: Kaj-Michael Lang Date: Thu, 1 Nov 2007 16:23:13 +0000 (+0200) Subject: Use shared setter for search result. X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c0425ca31112ccfd5a8be57f95f0c81ab97c0fa1;p=mapper Use shared setter for search result. --- diff --git a/src/search.c b/src/search.c index 65d7afe..dd10f70 100644 --- a/src/search.c +++ b/src/search.c @@ -70,6 +70,7 @@ struct _search_dialog { GtkWidget *list; GtkWidget *search_entry; GtkWidget *btn_edit; + GtkWidget *label; GtkListStore *store; gdouble lat; gdouble lon; @@ -86,7 +87,7 @@ guint cid; GtkTreeIter iter; guint slen; search_dialog *s=(search_dialog *)data; - +gboolean sres=FALSE; slen=strlen(gtk_entry_get_text(GTK_ENTRY(s->search_entry))); if (gtk_combo_box_get_active_iter(GTK_COMBO_BOX(s->cmb_category), &iter)==TRUE) @@ -105,27 +106,25 @@ st=g_strdup(gtk_entry_get_text(GTK_ENTRY(s->search_entry))); switch (s->stype) { case SEARCH_TYPE_POI: - if (poi_search((cid==-1) ? POI_SEARCH_TEXT : POI_SEARCH_TEXT_CAT, s->lat, s->lon, st, cid, &s->store)==TRUE) { - gtk_tree_view_set_model(GTK_TREE_VIEW(s->list), GTK_TREE_MODEL(s->store)); - g_object_unref(G_OBJECT(s->store)); - } else { - s->store=NULL; - gtk_tree_view_set_model(GTK_TREE_VIEW(s->list), GTK_TREE_MODEL(s->store)); - } + sres=poi_search((cid==-1) ? POI_SEARCH_TEXT : POI_SEARCH_TEXT_CAT, s->lat, s->lon, st, cid, &s->store); break; case SEARCH_TYPE_WAY: - if (osm_way_search(s->lat, s->lon, st, &s->store)==TRUE) { - gtk_tree_view_set_model(GTK_TREE_VIEW(s->list), GTK_TREE_MODEL(s->store)); - g_object_unref(G_OBJECT(s->store)); - } else { - s->store=NULL; - gtk_tree_view_set_model(GTK_TREE_VIEW(s->list), GTK_TREE_MODEL(s->store)); - } + sres=osm_way_search(s->lat, s->lon, st, &s->store); break; case SEARCH_TYPE_PLACE: popup_error(s->dialog, "Not yet implemented"); + sres=FALSE; break; } + +if (sres==TRUE) { + gtk_tree_view_set_model(GTK_TREE_VIEW(s->list), GTK_TREE_MODEL(s->store)); + g_object_unref(G_OBJECT(s->store)); +} else { + s->store=NULL; + gtk_tree_view_set_model(GTK_TREE_VIEW(s->list), GTK_TREE_MODEL(s->store)); +} + g_free(st); return TRUE; } @@ -332,6 +331,9 @@ gtk_tree_view_append_column(GTK_TREE_VIEW(sd.list), column); gtk_tree_view_set_search_column (GTK_TREE_VIEW(sd.list), ITEM_LABEL); gtk_container_add(GTK_CONTAINER(sw), sd.list); +sd.label=gtk_label_new(""); +gtk_box_pack_start(GTK_BOX(hbox), sd.label, FALSE, FALSE, 0); + g_signal_connect(G_OBJECT(btn_search), "clicked", G_CALLBACK(search_do_cb), &sd); g_signal_connect(G_OBJECT(btn_goto), "clicked", G_CALLBACK(search_goto_cb), &sd); g_signal_connect(G_OBJECT(btn_route_to), "clicked", G_CALLBACK(search_route_to_cb), &sd);