From 29b0f549b2206e0b6e30c3027c943058a1817479 Mon Sep 17 00:00:00 2001 From: Kaj-Michael Lang Date: Wed, 31 Oct 2007 10:34:23 +0200 Subject: [PATCH] A bit more search dialog work --- src/search.c | 77 ++++++++++++++++++++++++++++++++++------------------ 1 file changed, 50 insertions(+), 27 deletions(-) diff --git a/src/search.c b/src/search.c index ad2e7b9..abc9d3d 100644 --- a/src/search.c +++ b/src/search.c @@ -53,6 +53,25 @@ #include "help.h" +typedef enum { + SEARCH_TYPE_POI=0, + SEARCH_TYPE_WAY=1, + SEARCH_TYPE_PLACE=2, +} search_type; + +typedef enum { + ITEM_ID, + ITEM_CATID, + ITEM_LAT, + ITEM_LON, + ITEM_LATLON, + ITEM_LABEL, + ITEM_DESC, + ITEM_CATLAB, + ITEM_DIST, + ITEM_NUM_COLUMNS +} item_list_id; + typedef struct _search_query poi_search_query; struct _search_query { gdouble lat; @@ -64,8 +83,9 @@ struct _search_query { typedef struct _search_dialog search_dialog; struct _search_dialog { GtkWidget *dialog; - GtkWidget *list; + GtkWidget *cmb_type; GtkWidget *cmb_category; + GtkWidget *list; GtkWidget *search_entry; GtkListStore *store; gdouble lat; @@ -167,22 +187,28 @@ map_update_location_from_center(); return TRUE; } +static gboolean +search_edit_cb(GtkWidget *widget, gpointer data) +{ + +return TRUE; +} + gboolean mapper_search_dialog(gdouble lat, gdouble lon) { -GtkWidget *sw, *hbox, *label, *btn_search, *btn_goto, *btn_route_to; +GtkWidget *sw, *hbox, *label, *btn_search, *btn_goto, *btn_route_to, *btn_edit; GtkTreeViewColumn *column; GtkCellRenderer *renderer; GtkTreeIter iter; -gboolean selected = FALSE; sd.dialog = gtk_dialog_new_with_buttons(_("Search"), GTK_WINDOW(_window), GTK_DIALOG_MODAL, - GTK_STOCK_OK, - GTK_RESPONSE_ACCEPT, GTK_STOCK_CANCEL, - GTK_RESPONSE_REJECT, NULL); + GTK_RESPONSE_REJECT, + NULL); + sd.lat=lat; sd.lon=lon; @@ -192,6 +218,9 @@ gtk_container_add(GTK_CONTAINER(GTK_DIALOG(sd.dialog)->action_area), gtk_container_add(GTK_CONTAINER(GTK_DIALOG(sd.dialog)->action_area), btn_route_to = gtk_button_new_with_label(_("Route to"))); +gtk_container_add(GTK_CONTAINER(GTK_DIALOG(sd.dialog)->action_area), + btn_edit = gtk_button_new_with_label(_("Edit"))); + gtk_window_set_default_size(GTK_WINDOW(sd.dialog), 500, 300); hbox = gtk_hbox_new(FALSE, 4), @@ -200,6 +229,12 @@ gtk_box_pack_start(GTK_BOX(GTK_DIALOG(sd.dialog)->vbox), hbox, FALSE, FALSE, 0); label=gtk_label_new(_("Search:")); gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); +sd.cmb_type=gtk_combo_box_new(); +gtk_combo_box_append_text(GTK_COMBO_BOX(sd.cmb_type), "POI"); +gtk_combo_box_append_text(GTK_COMBO_BOX(sd.cmb_type), "Street"); +/* gtk_combo_box_append_text(GTK_COMBO_BOX(sd.cmb_type), "Place"); */ +gtk_box_pack_start(GTK_BOX(hbox), sd.cmb_type, FALSE, FALSE, 0); + sd.cmb_category = category_combo_new(); gtk_box_pack_start(GTK_BOX(hbox), sd.cmb_category, FALSE, FALSE, 0); poi_category_combo_populate(sd.cmb_category, 0, TRUE); @@ -228,44 +263,32 @@ gtk_container_add(GTK_CONTAINER(sw), sd.list); gtk_tree_selection_set_mode(gtk_tree_view_get_selection (GTK_TREE_VIEW(sd.list)), GTK_SELECTION_SINGLE); gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(sd.list), TRUE); gtk_tree_view_set_rules_hint (GTK_TREE_VIEW(sd.list), TRUE); -gtk_tree_view_set_search_column (GTK_TREE_VIEW(sd.list), POI_LABEL); +gtk_tree_view_set_search_column (GTK_TREE_VIEW(sd.list), ITEM_LABEL); renderer = gtk_cell_renderer_text_new(); -column = gtk_tree_view_column_new_with_attributes(_("Location"), renderer, "text", POI_LATLON, NULL); +column = gtk_tree_view_column_new_with_attributes(_("Location"), renderer, "text", ITEM_LATLON, NULL); gtk_tree_view_append_column(GTK_TREE_VIEW(sd.list), column); renderer = gtk_cell_renderer_text_new(); -column = gtk_tree_view_column_new_with_attributes(_("Label"), renderer, "text", POI_LABEL, NULL); -gtk_tree_view_column_set_sort_column_id (column, POI_LABEL); +column = gtk_tree_view_column_new_with_attributes(_("Label"), renderer, "text", ITEM_LABEL, NULL); +gtk_tree_view_column_set_sort_column_id (column, ITEM_LABEL); gtk_tree_view_append_column(GTK_TREE_VIEW(sd.list), column); renderer = gtk_cell_renderer_text_new(); -column = gtk_tree_view_column_new_with_attributes(_("Category"), renderer, "text", POI_CATLAB, NULL); -gtk_tree_view_column_set_sort_column_id (column, POI_CATLAB); +column = gtk_tree_view_column_new_with_attributes(_("Category"), renderer, "text", ITEM_CATLAB, NULL); +gtk_tree_view_column_set_sort_column_id (column, ITEM_CATLAB); gtk_tree_view_append_column(GTK_TREE_VIEW(sd.list), column); 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); +g_signal_connect(G_OBJECT(btn_edit), "clicked", G_CALLBACK(search_edit_cb), &sd); gtk_widget_show_all(sd.dialog); -while (GTK_RESPONSE_ACCEPT == gtk_dialog_run(GTK_DIALOG(sd.dialog))) { - if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(sd.list)), NULL, &iter)) { - gtk_tree_model_get(GTK_TREE_MODEL(sd.store), &iter, POI_POIID, &(poi->poi_id), -1); - gtk_tree_model_get(GTK_TREE_MODEL(sd.store), &iter, POI_CATID, &(poi->cat_id), -1); - gtk_tree_model_get(GTK_TREE_MODEL(sd.store), &iter, POI_LAT, &(poi->lat), -1); - gtk_tree_model_get(GTK_TREE_MODEL(sd.store), &iter, POI_LON, &(poi->lon), -1); - gtk_tree_model_get(GTK_TREE_MODEL(sd.store), &iter, POI_LABEL, &(poi->label), -1); - gtk_tree_model_get(GTK_TREE_MODEL(sd.store), &iter, POI_DESC, &(poi->desc), -1); - selected = TRUE; - break; - } else { - popup_error(sd.dialog, _("Select one POI from the list.")); - } -} +gtk_dialog_run(GTK_DIALOG(sd.dialog); gtk_widget_destroy(sd.dialog); -return selected; +return TRUE; } -- 2.39.5