From 3400efd0a06dc9cbda13061806eb28046736708c Mon Sep 17 00:00:00 2001 From: Kaj-Michael Lang Date: Thu, 18 Oct 2007 12:21:18 +0300 Subject: [PATCH] Misc --- src/poi-gui.c | 613 +++++++++++++++++++++++++------------------------- 1 file changed, 304 insertions(+), 309 deletions(-) diff --git a/src/poi-gui.c b/src/poi-gui.c index d333ecf..40a8a47 100644 --- a/src/poi-gui.c +++ b/src/poi-gui.c @@ -30,6 +30,12 @@ static GtkWidget *dialog_qp; +typedef struct _PoiCategoryEditInfo PoiCategoryEditInfo; +static struct _PoiCategoryEditInfo { + GtkWidget *cmb_category; + guint cat_id; +}; + static gboolean category_delete(GtkWidget *widget, delete_poi *dpoi) { @@ -46,7 +52,7 @@ category_delete(GtkWidget *widget, delete_poi *dpoi) if (i == GTK_RESPONSE_OK) { if (poi_category_delete(dpoi)==FALSE) - MACRO_BANNER_SHOW_INFO(_window, _("Problem deleting category or POI")); + popup_error(_window, _("Problem deleting category or POI")); gtk_widget_hide_all(dpoi->dialog); map_force_redraw(); } @@ -174,7 +180,7 @@ category_dialog(guint cat_id) results=poi_category_update(cat_id, c); if (results==FALSE) - MACRO_BANNER_SHOW_INFO(_window, _("Problem updating category")); + popup_error(_window, _("Problem updating category")); poi_category_free(c); } @@ -202,7 +208,7 @@ category_toggled(GtkCellRendererToggle * cell, gchar * path, gpointer data) cat_enabled ^= 1; if (poi_category_toggle(cat_id, cat_enabled)==FALSE) { - MACRO_BANNER_SHOW_INFO(_window, _("Problem updating Category")); + popup_error(_window, _("Problem updating Category")); } else { gtk_list_store_set(GTK_LIST_STORE(model), &iter, CAT_ENABLED, cat_enabled, -1); } @@ -345,158 +351,150 @@ menu_cb_category(GtkAction * action) gboolean poi_delete_confirm(GtkWidget * widget, delete_poi * dpoi) { - GtkWidget *dialog; - guint i; - gchar *buffer; - - buffer = g_strdup_printf("%s\n%s", _("Delete POI?"), dpoi->txt_label); - dialog = hildon_note_new_confirmation(GTK_WINDOW(_window), buffer); - g_free(buffer); - i = gtk_dialog_run(GTK_DIALOG(dialog)); - gtk_widget_destroy(GTK_WIDGET(dialog)); - - if (i == GTK_RESPONSE_OK) { - if (poi_delete(dpoi)==FALSE) { - MACRO_BANNER_SHOW_INFO(_window, _("Problem deleting POI")); - } else { - gtk_widget_hide_all(dpoi->dialog); - map_force_redraw(); - } +GtkWidget *dialog; +guint i; +gchar *buffer; + +buffer = g_strdup_printf("%s\n%s", _("Delete POI?"), dpoi->txt_label); +dialog = hildon_note_new_confirmation(GTK_WINDOW(_window), buffer); +g_free(buffer); +i = gtk_dialog_run(GTK_DIALOG(dialog)); +gtk_widget_destroy(GTK_WIDGET(dialog)); + +if (i == GTK_RESPONSE_OK) { + if (poi_delete(dpoi)==FALSE) { + popup_error(_window, _("Problem deleting POI")); + } else { + gtk_widget_hide_all(dpoi->dialog); + map_force_redraw(); } - - return TRUE; +} +return TRUE; } gboolean select_poi(guint unitx, guint unity, poi_info *poi) { - GtkWidget *dialog; - GtkWidget *list; - GtkWidget *sw; - 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; +GtkWidget *dialog; +GtkWidget *list; +GtkWidget *sw; +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; - } - - /* 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_set_default_size(GTK_WINDOW(dialog), 500, 300); - - 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); - gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), sw, TRUE, TRUE, 0); - - list = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store)); - gtk_container_add(GTK_CONTAINER(sw), list); +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; +} - gtk_tree_selection_set_mode(gtk_tree_view_get_selection (GTK_TREE_VIEW(list)), GTK_SELECTION_SINGLE); - gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(list), TRUE); - gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (list), TRUE); - gtk_tree_view_set_search_column (GTK_TREE_VIEW (list), POI_LABEL); - - renderer = gtk_cell_renderer_text_new(); - column = gtk_tree_view_column_new_with_attributes(_("Location"), renderer, "text", POI_LATLON, NULL); - gtk_tree_view_append_column(GTK_TREE_VIEW(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); - gtk_tree_view_append_column(GTK_TREE_VIEW(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); - gtk_tree_view_append_column(GTK_TREE_VIEW(list), column); - - gtk_widget_show_all(dialog); - - while (GTK_RESPONSE_ACCEPT == gtk_dialog_run(GTK_DIALOG(dialog))) { - if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(list)), NULL, &iter)) { - gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, POI_POIID, &(poi->poi_id), -1); - gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, POI_CATID, &(poi->cat_id), -1); - gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, POI_LAT, &(poi->lat), -1); - gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, POI_LON, &(poi->lon), -1); - gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, POI_LABEL, &(poi->label), -1); - gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, POI_DESC, &(poi->desc), -1); - selected = TRUE; - break; - } else { - popup_error(dialog, _("Select one POI from the list.")); - } +/* 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_set_default_size(GTK_WINDOW(dialog), 500, 300); + +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); +gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), sw, TRUE, TRUE, 0); + +list = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store)); +gtk_container_add(GTK_CONTAINER(sw), list); +g_object_unref(G_OBJECT(store)); + +gtk_tree_selection_set_mode(gtk_tree_view_get_selection (GTK_TREE_VIEW(list)), GTK_SELECTION_SINGLE); +gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(list), TRUE); +gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (list), TRUE); +gtk_tree_view_set_search_column (GTK_TREE_VIEW (list), POI_LABEL); + +renderer = gtk_cell_renderer_text_new(); +column = gtk_tree_view_column_new_with_attributes(_("Location"), renderer, "text", POI_LATLON, NULL); +gtk_tree_view_append_column(GTK_TREE_VIEW(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); +gtk_tree_view_append_column(GTK_TREE_VIEW(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); +gtk_tree_view_append_column(GTK_TREE_VIEW(list), column); + +gtk_widget_show_all(dialog); + +while (GTK_RESPONSE_ACCEPT == gtk_dialog_run(GTK_DIALOG(dialog))) { + if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(list)), NULL, &iter)) { + gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, POI_POIID, &(poi->poi_id), -1); + gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, POI_CATID, &(poi->cat_id), -1); + gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, POI_LAT, &(poi->lat), -1); + gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, POI_LON, &(poi->lon), -1); + gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, POI_LABEL, &(poi->label), -1); + gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, POI_DESC, &(poi->desc), -1); + selected = TRUE; + break; + } else { + popup_error(dialog, _("Select one POI from the list.")); } +} - gtk_widget_destroy(dialog); - - return selected; +gtk_widget_destroy(dialog); +return selected; } static void poi_populate_cat_combo(GtkWidget * cmb_category, guint cat_id) { - GtkTreeIter active; - GtkListStore *store; - gboolean has_active = FALSE; - - store = GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(cmb_category))); - gtk_list_store_clear(store); - - while (SQLITE_ROW == sqlite3_step(poisql.selall_cat)) { - GtkTreeIter iter; - guint cid = sqlite3_column_int(poisql.selall_cat, 0); - gtk_list_store_append(store, &iter); - gtk_list_store_set(store, &iter, 0, cid, 1, sqlite3_column_text(poisql.selall_cat, 1), -1); - if (cid == cat_id) { - active = iter; - has_active = TRUE; - } - } - sqlite3_reset(poisql.selall_cat); +GtkTreeIter active; +GtkListStore *store; +gboolean has_active = FALSE; - if (!has_active) - gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &active); +store = GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(cmb_category))); +gtk_list_store_clear(store); - gtk_combo_box_set_active_iter(GTK_COMBO_BOX(cmb_category), &active); +while (SQLITE_ROW == sqlite3_step(poisql.selall_cat)) { + GtkTreeIter iter; + guint cid = sqlite3_column_int(poisql.selall_cat, 0); + gtk_list_store_append(store, &iter); + gtk_list_store_set(store, &iter, 0, cid, 1, sqlite3_column_text(poisql.selall_cat, 1), -1); + if (cid == cat_id) { + active = iter; + has_active = TRUE; + } } +sqlite3_reset(poisql.selall_cat); -typedef struct _PoiCategoryEditInfo PoiCategoryEditInfo; -struct _PoiCategoryEditInfo { - GtkWidget *cmb_category; - guint cat_id; -}; +if (!has_active) + gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &active); + +gtk_combo_box_set_active_iter(GTK_COMBO_BOX(cmb_category), &active); +} gboolean poi_edit_cat(GtkWidget * widget, PoiCategoryEditInfo * data) @@ -509,207 +507,204 @@ return TRUE; gboolean poi_dialog(POIAction action, guint unitx, guint unity) { - poi_info poi; - gchar slat1[10], slon1[10]; - gchar *p_latlon; - GtkWidget *dialog; - GtkWidget *table; - GtkWidget *label; - GtkWidget *txt_label; - GtkWidget *cmb_category; - GtkWidget *txt_desc; - GtkWidget *btn_delete = NULL; - GtkWidget *btn_catedit; - GtkWidget *hbox; - GtkWidget *txt_scroll; - GtkTextBuffer *desc_txt; - GtkTextIter begin, end; - delete_poi dpoi = { NULL, NULL, 0 }; - PoiCategoryEditInfo pcedit; - - if (action == ACTION_EDIT_POI) { - if (!select_poi(unitx, unity, &poi)) { - return FALSE; - } - - dialog = gtk_dialog_new_with_buttons(_("Edit POI"), - GTK_WINDOW(_window), - GTK_DIALOG_MODAL, - GTK_STOCK_OK, - GTK_RESPONSE_ACCEPT, NULL); - - 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); - - 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(""); - - dialog = gtk_dialog_new_with_buttons(_("Add POI"), - GTK_WINDOW(_window), - GTK_DIALOG_MODAL, - GTK_STOCK_OK, - GTK_RESPONSE_ACCEPT, - GTK_STOCK_CANCEL, - GTK_RESPONSE_REJECT, NULL); - } - - /* Set the p_latlon string. */ - { - gchar tmp1[16], tmp2[16]; - lat_format(poi.lat, tmp1); - lon_format(poi.lon, tmp2); - p_latlon = g_strdup_printf("%s, %s", tmp1, tmp2); +poi_info poi; +gchar slat1[10], slon1[10]; +gchar *p_latlon; +GtkWidget *dialog; +GtkWidget *table; +GtkWidget *label; +GtkWidget *txt_label; +GtkWidget *cmb_category; +GtkWidget *txt_desc; +GtkWidget *btn_delete = NULL; +GtkWidget *btn_catedit; +GtkWidget *hbox; +GtkWidget *txt_scroll; +GtkTextBuffer *desc_txt; +GtkTextIter begin, end; +delete_poi dpoi = { NULL, NULL, 0 }; +PoiCategoryEditInfo pcedit; + +if (action == ACTION_EDIT_POI) { + if (!select_poi(unitx, unity, &poi)) { + return FALSE; } - gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), - table = gtk_table_new(6, 4, FALSE), TRUE, TRUE, 0); - - gtk_table_attach(GTK_TABLE(table), - label = gtk_label_new(_("Lat, Lon")), - 0, 1, 0, 1, GTK_FILL, 0, 2, 4); - gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f); + dialog = gtk_dialog_new_with_buttons(_("Edit POI"), + GTK_WINDOW(_window), + GTK_DIALOG_MODAL, + GTK_STOCK_OK, + GTK_RESPONSE_ACCEPT, NULL); + 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); + + 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(""); + + dialog = gtk_dialog_new_with_buttons(_("Add POI"), + GTK_WINDOW(_window), + GTK_DIALOG_MODAL, + GTK_STOCK_OK, + GTK_RESPONSE_ACCEPT, + GTK_STOCK_CANCEL, + GTK_RESPONSE_REJECT, NULL); +} - gtk_table_attach(GTK_TABLE(table), - label = gtk_label_new(p_latlon), - 1, 3, 0, 1, GTK_FILL, 0, 2, 4); - gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.5f); +/* Set the p_latlon string. */ +{ + gchar tmp1[16], tmp2[16]; + lat_format(poi.lat, tmp1); + lon_format(poi.lon, tmp2); + p_latlon = g_strdup_printf("%s, %s", tmp1, tmp2); +} - gtk_table_attach(GTK_TABLE(table), - label = gtk_label_new(_("Label")), - 0, 1, 1, 2, GTK_FILL, 0, 2, 4); - gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f); - gtk_table_attach(GTK_TABLE(table), - txt_label = gtk_entry_new(), - 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, 0, 2, 4); +gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), + table = gtk_table_new(6, 4, FALSE), TRUE, TRUE, 0); + +gtk_table_attach(GTK_TABLE(table), + label = gtk_label_new(_("Lat, Lon")), + 0, 1, 0, 1, GTK_FILL, 0, 2, 4); +gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f); + +gtk_table_attach(GTK_TABLE(table), + label = gtk_label_new(p_latlon), + 1, 3, 0, 1, GTK_FILL, 0, 2, 4); +gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.5f); + +gtk_table_attach(GTK_TABLE(table), + label = gtk_label_new(_("Label")), + 0, 1, 1, 2, GTK_FILL, 0, 2, 4); +gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f); +gtk_table_attach(GTK_TABLE(table), + txt_label = gtk_entry_new(), + 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, 0, 2, 4); + +gtk_table_attach(GTK_TABLE(table), + label = gtk_label_new(_("Category")), + 0, 1, 3, 4, GTK_FILL, 0, 2, 4); +gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f); +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); +/* Set up the view for the combo box. */ +{ + GtkCellRenderer *renderer; + renderer = gtk_cell_renderer_text_new(); + gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(cmb_category), renderer, TRUE); + gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(cmb_category), renderer, "text", 1, NULL); +} - gtk_table_attach(GTK_TABLE(table), - label = gtk_label_new(_("Category")), - 0, 1, 3, 4, GTK_FILL, 0, 2, 4); - gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f); - 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); - /* Set up the view for the combo box. */ - { - GtkCellRenderer *renderer; - renderer = gtk_cell_renderer_text_new(); - gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(cmb_category), - renderer, TRUE); - gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(cmb_category), - renderer, "text", 1, NULL); - } +gtk_box_pack_start(GTK_BOX(hbox), + btn_catedit = gtk_button_new_with_label(_("Edit Categories...")), + FALSE, FALSE, 4); - gtk_box_pack_start(GTK_BOX(hbox), - btn_catedit = gtk_button_new_with_label(_("Edit Categories...")), - FALSE, FALSE, 4); +gtk_table_attach(GTK_TABLE(table), + label = gtk_label_new(_("Description")), + 0, 1, 5, 6, GTK_FILL, 0, 2, 4); +gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f); - gtk_table_attach(GTK_TABLE(table), - label = gtk_label_new(_("Description")), - 0, 1, 5, 6, GTK_FILL, 0, 2, 4); - gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f); +txt_scroll = gtk_scrolled_window_new(NULL, NULL); +gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(txt_scroll), GTK_SHADOW_IN); +gtk_table_attach(GTK_TABLE(table), txt_scroll, 1, 2, 5, 6, GTK_EXPAND | GTK_FILL, 0, 2, 4); - txt_scroll = gtk_scrolled_window_new(NULL, NULL); - gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(txt_scroll), GTK_SHADOW_IN); - gtk_table_attach(GTK_TABLE(table), txt_scroll, 1, 2, 5, 6, GTK_EXPAND | GTK_FILL, 0, 2, 4); +gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(txt_scroll), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(txt_scroll), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); +txt_desc = gtk_text_view_new(); +gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(txt_desc), GTK_WRAP_WORD); - txt_desc = gtk_text_view_new(); - gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(txt_desc), GTK_WRAP_WORD); +gtk_container_add(GTK_CONTAINER(txt_scroll), txt_desc); +gtk_widget_set_size_request(GTK_WIDGET(txt_scroll), 400, 60); - gtk_container_add(GTK_CONTAINER(txt_scroll), txt_desc); - gtk_widget_set_size_request(GTK_WIDGET(txt_scroll), 400, 60); +desc_txt = gtk_text_view_get_buffer(GTK_TEXT_VIEW(txt_desc)); - desc_txt = gtk_text_view_get_buffer(GTK_TEXT_VIEW(txt_desc)); +/* label */ +gtk_entry_set_text(GTK_ENTRY(txt_label), poi.label); - /* label */ - gtk_entry_set_text(GTK_ENTRY(txt_label), poi.label); +/* category */ +poi_populate_cat_combo(cmb_category, poi.cat_id); - /* category */ - poi_populate_cat_combo(cmb_category, poi.cat_id); +/* poi_desc */ +gtk_text_buffer_set_text(desc_txt, poi.desc, -1); - /* poi_desc */ - gtk_text_buffer_set_text(desc_txt, poi.desc, -1); +/* Connect Signals */ +pcedit.cmb_category = cmb_category; +pcedit.cat_id = poi.cat_id; +g_signal_connect(G_OBJECT(btn_catedit), "clicked", G_CALLBACK(poi_edit_cat), &pcedit); +gtk_widget_show_all(dialog); - /* Connect Signals */ - pcedit.cmb_category = cmb_category; - pcedit.cat_id = poi.cat_id; - g_signal_connect(G_OBJECT(btn_catedit), "clicked", G_CALLBACK(poi_edit_cat), &pcedit); - gtk_widget_show_all(dialog); +while (GTK_RESPONSE_ACCEPT == gtk_dialog_run(GTK_DIALOG(dialog))) { + gchar *poi_label = NULL; + gchar *poi_desc = NULL; + GtkTreeIter iter; - while (GTK_RESPONSE_ACCEPT == gtk_dialog_run(GTK_DIALOG(dialog))) { - gchar *poi_label = NULL; - gchar *poi_desc = NULL; - GtkTreeIter iter; - - if (strlen(gtk_entry_get_text(GTK_ENTRY(txt_label)))) - poi_label = gtk_entry_get_text(GTK_ENTRY(txt_label)); - else { - popup_error(dialog, _("Please specify a name for the POI.")); - continue; - } + if (strlen(gtk_entry_get_text(GTK_ENTRY(txt_label)))) + poi_label = gtk_entry_get_text(GTK_ENTRY(txt_label)); + else { + popup_error(dialog, _("Please specify a name for the POI.")); + continue; + } - if (!gtk_combo_box_get_active_iter - (GTK_COMBO_BOX(cmb_category), &iter)) { - popup_error(dialog, _("Please specify a category for the POI.")); - continue; - } + if (!gtk_combo_box_get_active_iter + (GTK_COMBO_BOX(cmb_category), &iter)) { + popup_error(dialog, _("Please specify a category for the POI.")); + continue; + } - gtk_text_buffer_get_iter_at_offset(desc_txt, &begin, 0); - gtk_text_buffer_get_end_iter(desc_txt, &end); - poi_desc = gtk_text_buffer_get_text(desc_txt, &begin, &end, TRUE); + gtk_text_buffer_get_iter_at_offset(desc_txt, &begin, 0); + gtk_text_buffer_get_end_iter(desc_txt, &end); + poi_desc = gtk_text_buffer_get_text(desc_txt, &begin, &end, TRUE); - gtk_tree_model_get(gtk_combo_box_get_model(GTK_COMBO_BOX(cmb_category)), &iter, 0, &poi.cat_id, -1); + gtk_tree_model_get(gtk_combo_box_get_model(GTK_COMBO_BOX(cmb_category)), &iter, 0, &poi.cat_id, -1); - if (action == ACTION_EDIT_POI) { - /* edit poi */ - if (poi_update(poi.poi_id, poi.cat_id, poi_label, poi_desc)==FALSE) { - MACRO_BANNER_SHOW_INFO(_window, _("Problem updating POI")); - } else { - map_render_data(); - } + if (action == ACTION_EDIT_POI) { + /* edit poi */ + if (poi_update(poi.poi_id, poi.cat_id, poi_label, poi_desc)==FALSE) { + popup_error(_window, _("Problem updating POI")); } else { - /* add poi */ - g_ascii_dtostr(slat1, sizeof(slat1), poi.lat); - g_ascii_dtostr(slon1, sizeof(slon1), poi.lon); - if (poi_add(poi.lat, poi.lon, poi.cat_id, poi_label, poi_desc)==FALSE) { - MACRO_BANNER_SHOW_INFO(_window, _("Problem adding POI")); - } else { - map_render_data(); - } + map_render_data(); + } + } else { + /* add poi */ + g_ascii_dtostr(slat1, sizeof(slat1), poi.lat); + g_ascii_dtostr(slon1, sizeof(slon1), poi.lon); + if (poi_add(poi.lat, poi.lon, poi.cat_id, poi_label, poi_desc)==FALSE) { + popup_error(_window, _("Problem adding POI")); + } else { + map_render_data(); } - break; } - g_free(dpoi.txt_label); + break; +} +g_free(dpoi.txt_label); - g_free(poi.label); - g_free(poi.desc); - g_free(p_latlon); +g_free(poi.label); +g_free(poi.desc); +g_free(p_latlon); - gtk_widget_hide_all(dialog); +gtk_widget_hide_all(dialog); - return TRUE; +return TRUE; } static gboolean -- 2.39.5