]> err.no Git - mapper/commitdiff
Use shared setter for search result.
authorKaj-Michael Lang <milang@onion.tal.org>
Thu, 1 Nov 2007 16:23:13 +0000 (18:23 +0200)
committerKaj-Michael Lang <milang@onion.tal.org>
Thu, 1 Nov 2007 16:23:13 +0000 (18:23 +0200)
src/search.c

index 65d7afe066928b68b77bd88abba31b1b787ab8d7..dd10f704fcbef29380b830aa12e5e62f035c8738 100644 (file)
@@ -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);