]> err.no Git - mapper/commitdiff
Add completion to the search entry
authorKaj-Michael Lang <milang@onion.tal.org>
Mon, 18 Feb 2008 12:48:00 +0000 (14:48 +0200)
committerKaj-Michael Lang <milang@onion.tal.org>
Mon, 18 Feb 2008 12:48:00 +0000 (14:48 +0200)
src/search.c

index a03d17a021ccf12fbdf2571a54140520a6353539..93273a0d0f649b7d09915fcfa0fd1ba1a1408849 100644 (file)
@@ -68,6 +68,7 @@ struct _search_dialog {
 };
 
 static search_dialog sd;
+static GtkListStore *search_model=NULL;
 
 static gboolean
 search_do_cb(GtkWidget *widget, gpointer data)
@@ -104,9 +105,11 @@ st=g_strdup(gtk_entry_get_text(GTK_ENTRY(s->search_entry)));
 
 switch (s->stype) {
        case SEARCH_TYPE_POI:
+               MACRO_BANNER_SHOW_INFO(s->dialog, _("Searching POIs..."));
                sres=poi_search((cid==-1 && slen>0) ? POI_SEARCH_TEXT : (cid!=-1 && slen==0) ? POI_SEARCH_CAT : POI_SEARCH_TEXT_CAT, s->lat, s->lon, st, cid, &s->store);
        break;
        case SEARCH_TYPE_WAY:
+               MACRO_BANNER_SHOW_INFO(s->dialog, _("Searching streets..."));
                sres=osm_way_search(s->lat, s->lon, st, &s->store);
        break;
        case SEARCH_TYPE_PLACE:
@@ -224,6 +227,7 @@ mapper_search_dialog(mapper_search_type stype, gdouble lat, gdouble lon)
 GtkWidget *sw, *hbox, *label, *btn_search;
 GtkTreeViewColumn *column;
 GtkCellRenderer *renderer;
+GtkEntryCompletion *search_comp;
 gint res;
 
 sd.store=NULL;
@@ -240,6 +244,9 @@ sd.dialog = gtk_dialog_new_with_buttons(_("Search"),
                        GTK_STOCK_CLOSE, GTK_RESPONSE_REJECT, 
                        NULL);
 
+if (search_model==NULL)
+       search_model=gtk_list_store_new(1, G_TYPE_STRING);
+
 gtk_window_set_default_size(GTK_WINDOW(sd.dialog), 500, 300);
 
 hbox = gtk_hbox_new(FALSE, 4),
@@ -261,6 +268,10 @@ gtk_box_pack_start(GTK_BOX(hbox), sd.cmb_category, FALSE, FALSE, 0);
 poi_category_combo_populate(sd.cmb_category, 0, TRUE);
 
 sd.search_entry=gtk_entry_new();
+search_comp=gtk_entry_completion_new();
+gtk_entry_completion_set_model(search_comp, GTK_TREE_MODEL(search_model));
+gtk_entry_completion_set_text_column(search_comp, 0);
+gtk_entry_set_completion(GTK_ENTRY(sd.search_entry), search_comp);
 gtk_box_pack_start(GTK_BOX(hbox), sd.search_entry, TRUE, TRUE, 0);
 
 btn_search=gtk_button_new_with_label(_("Search"));