static GtkWidget *dialog_qp;
typedef struct _PoiCategoryEditInfo PoiCategoryEditInfo;
-static struct _PoiCategoryEditInfo {
+struct _PoiCategoryEditInfo {
GtkWidget *cmb_category;
guint cat_id;
};
return TRUE;
}
-gboolean
-menu_cb_category(GtkAction * action)
-{
-
- if (category_list())
- map_force_redraw();
-
- return TRUE;
-}
-
gboolean
poi_delete_confirm(GtkWidget * widget, delete_poi * dpoi)
{
return TRUE;
}
-gboolean
-poi_select(guint unitx, guint unity, poi_info *poi)
+gboolean
+poi_search_dialog(GtkListStore *store, poi_info *poi)
{
-GtkWidget *dialog;
-GtkWidget *list;
-GtkWidget *sw;
+GtkWidget *dialog, *list, *sw;
+GtkWidget *hbox, *label, *search_entry;
GtkTreeViewColumn *column;
GtkCellRenderer *renderer;
-GtkListStore *store;
GtkTreeIter iter;
gboolean selected = FALSE;
-guint num_cats;
-
-if (poi_get_list(unitx, unity, &store, &num_cats)==FALSE)
- return FALSE;
-
-switch (num_cats) {
-case 0:
- MACRO_BANNER_SHOW_INFO(_window, _("No POIs found."));
- g_object_unref(G_OBJECT(store));
- return FALSE;
- break;
-case 1:
- gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter);
- gtk_tree_model_get(GTK_TREE_MODEL(store),
- &iter,
- POI_POIID, &(poi->poi_id),
- POI_CATID, &(poi->cat_id),
- POI_LAT, &(poi->lat),
- POI_LON, &(poi->lon),
- POI_LABEL, &(poi->label),
- POI_DESC, &(poi->desc), -1);
- g_object_unref(G_OBJECT(store));
- return TRUE;
-break;
-}
-/* There are at least 2 matching POI's - let the user select one. */
dialog = gtk_dialog_new_with_buttons(_("Select POI"),
- GTK_WINDOW(_window),
- GTK_DIALOG_MODAL, GTK_STOCK_OK,
- GTK_RESPONSE_ACCEPT,
- GTK_STOCK_CANCEL,
- GTK_RESPONSE_REJECT, NULL);
+ GTK_WINDOW(_window),
+ GTK_DIALOG_MODAL, GTK_STOCK_OK,
+ GTK_RESPONSE_ACCEPT,
+ GTK_STOCK_CANCEL,
+ GTK_RESPONSE_REJECT, NULL);
gtk_window_set_default_size(GTK_WINDOW(dialog), 500, 300);
+hbox = gtk_hbox_new(FALSE, 4),
+gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox, FALSE, FALSE, 0);
+
+label=gtk_label_new(_("Search:"));
+gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
+
+search_entry=gtk_entry_new();
+gtk_box_pack_start(GTK_BOX(hbox), search_entry, TRUE, TRUE, 0);
+
sw = gtk_scrolled_window_new(NULL, NULL);
gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_ETCHED_IN);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
return selected;
}
+gboolean
+poi_select(guint unitx, guint unity, poi_info *poi)
+{
+GtkListStore *store;
+guint num_cats;
+GtkTreeIter iter;
+
+if (poi_get_list(unitx, unity, &store, &num_cats)==FALSE)
+ return FALSE;
+
+switch (num_cats) {
+case 0:
+ MACRO_BANNER_SHOW_INFO(_window, _("No POIs found."));
+ g_object_unref(G_OBJECT(store));
+ return FALSE;
+ break;
+case 1:
+ gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter);
+ gtk_tree_model_get(GTK_TREE_MODEL(store),
+ &iter,
+ POI_POIID, &(poi->poi_id),
+ POI_CATID, &(poi->cat_id),
+ POI_LAT, &(poi->lat),
+ POI_LON, &(poi->lon),
+ POI_LABEL, &(poi->label),
+ POI_DESC, &(poi->desc), -1);
+ g_object_unref(G_OBJECT(store));
+ return TRUE;
+break;
+}
+
+return poi_search_dialog(store, poi);
+}
+
static void
poi_populate_cat_combo(GtkWidget * cmb_category, guint cat_id)
{
GTK_DIALOG_MODAL,
GTK_STOCK_OK,
GTK_RESPONSE_ACCEPT, NULL);
- gtk_container_add(GTK_CONTAINER
- (GTK_DIALOG(dialog)->action_area),
+ gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->action_area),
btn_delete = gtk_button_new_with_label(_("Delete")));
dpoi.dialog = dialog;
dpoi.txt_label = g_strdup(poi.label);
dpoi.id = poi.poi_id;
- g_signal_connect(G_OBJECT(btn_delete), "clicked",
- G_CALLBACK(poi_delete_confirm), &dpoi);
+ g_signal_connect(G_OBJECT(btn_delete), "clicked", G_CALLBACK(poi_delete_confirm), &dpoi);
- gtk_dialog_add_button(GTK_DIALOG(dialog),
- GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT);
+ gtk_dialog_add_button(GTK_DIALOG(dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT);
} else {
- if (SQLITE_ROW == sqlite3_step(poisql.nextlabel_poi))
- poi.label = g_strdup_printf("Point%06d", sqlite3_column_int(poisql.nextlabel_poi, 0));
- sqlite3_reset(poisql.nextlabel_poi);
-
unit2latlon(unitx, unity, poi.lat, poi.lon);
poi.poi_id = 0;
poi.cat_id = 0;
poi.desc = g_strdup("");
+ poi.label = g_strdup("");
dialog = gtk_dialog_new_with_buttons(_("Add POI"),
GTK_WINDOW(_window),
gtk_table_attach(GTK_TABLE(table),
hbox = gtk_hbox_new(FALSE, 4),
1, 2, 3, 4, GTK_EXPAND | GTK_FILL, 0, 2, 4);
-gtk_box_pack_start(GTK_BOX(hbox), cmb_category = gtk_combo_box_new_with_model(GTK_TREE_MODEL(gtk_list_store_new(2, G_TYPE_INT, /* Category ID */
- G_TYPE_STRING))), /* Category Label */
- FALSE, FALSE, 4);
+
+/* Category ID, Label */
+cmb_category = gtk_combo_box_new_with_model(GTK_TREE_MODEL(gtk_list_store_new(2, G_TYPE_INT, G_TYPE_STRING)));
+gtk_box_pack_start(GTK_BOX(hbox), cmb_category, FALSE, FALSE, 4);
+
/* Set up the view for the combo box. */
{
GtkCellRenderer *renderer;
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog_qp)->vbox), table = gtk_table_new(3, 3, FALSE), TRUE, TRUE, 0);
-gtk_table_set_col_spacings(table, 6);
-gtk_table_set_row_spacings(table, 6);
-gtk_table_set_homogeneous(table, TRUE);
+gtk_table_set_col_spacings(GTK_TABLE(table), 6);
+gtk_table_set_row_spacings(GTK_TABLE(table), 6);
+gtk_table_set_homogeneous(GTK_TABLE(table), TRUE);
for (x=1;x<=3;x++) {
for (y=1;y<=3;y++) {