return TRUE;
}
+GtkWidget *
+category_combo_new(void)
+{
+GtkWidget *cmb;
+GtkCellRenderer *renderer;
+
+/* Category ID, Label */
+cmb=gtk_combo_box_new_with_model(GTK_TREE_MODEL(gtk_list_store_new(2, G_TYPE_INT, G_TYPE_STRING)));
+
+/* Set up the view for the combo box. */
+renderer = gtk_cell_renderer_text_new();
+gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(cmb), renderer, TRUE);
+gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(cmb), renderer, "text", 1, NULL);
+
+return cmb;
+}
+
+static void
+poi_category_combo_populate(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);
+
+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
category_dialog(guint cat_id)
{
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;
GTK_RESPONSE_REJECT, NULL);
}
-gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox),
- table = gtk_table_new(6, 4, FALSE), TRUE, TRUE, 0);
+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(_("Label")),
- 0, 1, 0, 1, GTK_FILL, 0, 2, 4);
+gtk_table_attach(GTK_TABLE(table), label = gtk_label_new(_("Label")), 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),
- txt_label = gtk_entry_new(),
- 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, 0, 2, 4);
- gtk_table_attach(GTK_TABLE(table), label = gtk_label_new(_("Description")),
- 0, 1, 1, 2, GTK_FILL, 0, 2, 4);
+gtk_table_attach(GTK_TABLE(table), txt_label = gtk_entry_new(), 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, 0, 2, 4);
+gtk_table_attach(GTK_TABLE(table), label = gtk_label_new(_("Description")), 0, 1, 1, 2, GTK_FILL, 0, 2, 4);
gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
- txt_scroll = gtk_scrolled_window_new(NULL, NULL);
+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, 1, 2, GTK_EXPAND | GTK_FILL, 0, 2, 4);
+gtk_table_attach(GTK_TABLE(table), txt_scroll, 1, 2, 1, 2, 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);
desc_txt = gtk_text_view_get_buffer(GTK_TEXT_VIEW(txt_desc));
-gtk_table_attach(GTK_TABLE(table),
- chk_enabled = gtk_check_button_new_with_label(_("Enabled")), 0, 2, 2,
- 3, GTK_EXPAND | GTK_FILL, 0, 2, 4);
+gtk_table_attach(GTK_TABLE(table), chk_enabled = gtk_check_button_new_with_label(_("Enabled")), 0, 2, 2, 3, GTK_EXPAND | GTK_FILL, 0, 2, 4);
/* label */
gtk_entry_set_text(GTK_ENTRY(txt_label), c->label);
}
static void
-category_toggled(GtkCellRendererToggle * cell, gchar * path, gpointer data)
+category_toggled_cb(GtkCellRendererToggle * cell, gchar * path, gpointer data)
{
GtkTreeIter iter;
gboolean cat_enabled;
}
static gboolean
-category_add(GtkWidget * widget, GtkWidget * tree_view)
+category_add_cb(GtkWidget *widget, GtkWidget *tree_view)
{
GtkListStore *store;
}
static gboolean
-category_edit(GtkWidget * widget, GtkWidget * tree_view)
+category_edit_cb(GtkWidget *widget, GtkWidget *tree_view)
{
GtkTreeIter iter;
GtkTreeModel *store;
gtk_tree_view_column_set_max_width(column, 1);
renderer = gtk_cell_renderer_toggle_new();
-g_signal_connect(renderer, "toggled", G_CALLBACK(category_toggled), store);
+g_signal_connect(renderer, "toggled", G_CALLBACK(category_toggled_cb), store);
column = gtk_tree_view_column_new_with_attributes(_("Enabled"), renderer, "active", CAT_ENABLED, NULL);
gtk_tree_view_append_column(GTK_TREE_VIEW(tree_view), column);
gtk_tree_view_column_set_sort_column_id (column, CAT_ENABLED);
gtk_window_set_default_size(GTK_WINDOW(dialog), 500, 300);
-g_signal_connect(G_OBJECT(btn_edit), "clicked", G_CALLBACK(category_edit), tree_view);
-g_signal_connect(G_OBJECT(btn_add), "clicked", G_CALLBACK(category_add), tree_view);
+g_signal_connect(G_OBJECT(btn_edit), "clicked", G_CALLBACK(category_edit_cb), tree_view);
+g_signal_connect(G_OBJECT(btn_add), "clicked", G_CALLBACK(category_add_cb), tree_view);
gtk_widget_show_all(dialog);
while (GTK_RESPONSE_ACCEPT == gtk_dialog_run(GTK_DIALOG(dialog))) {
return TRUE;
}
+static gboolean
+poi_search_do_cb(GtkWidget *widget, gpointer data)
+{
+return TRUE;
+}
+
+static gboolean
+poi_goto_cb(GtkWidget *widget, gpointer data)
+{
+return TRUE;
+}
+
+static gboolean
+poi_route_to_cb(GtkWidget *widget, gpointer data)
+{
+return TRUE;
+}
+
gboolean
poi_search_dialog(GtkListStore *store, poi_info *poi)
{
-GtkWidget *dialog, *list, *sw;
-GtkWidget *hbox, *label, *search_entry;
+GtkWidget *dialog, *list, *sw, *cmb_category;
+GtkWidget *hbox, *label, *search_entry, *btn_search, *btn_goto, *btn_route_to;
GtkTreeViewColumn *column;
GtkCellRenderer *renderer;
GtkTreeIter iter;
GTK_STOCK_CANCEL,
GTK_RESPONSE_REJECT, NULL);
+gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->action_area),
+ btn_goto = gtk_button_new_with_label(_("Go")));
+
+gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->action_area),
+ btn_route_to = gtk_button_new_with_label(_("Route to")));
+
gtk_window_set_default_size(GTK_WINDOW(dialog), 500, 300);
hbox = gtk_hbox_new(FALSE, 4),
label=gtk_label_new(_("Search:"));
gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
+cmb_category = category_combo_new();
+gtk_box_pack_start(GTK_BOX(hbox), cmb_category, FALSE, FALSE, 0);
+poi_category_combo_populate(cmb_category, 0);
+
search_entry=gtk_entry_new();
gtk_box_pack_start(GTK_BOX(hbox), search_entry, TRUE, TRUE, 0);
+btn_search=gtk_button_new_with_label(_("Search"));
+gtk_box_pack_start(GTK_BOX(hbox), btn_search, FALSE, FALSE, 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);
gtk_tree_view_column_set_sort_column_id (column, POI_CATLAB);
gtk_tree_view_append_column(GTK_TREE_VIEW(list), column);
+g_signal_connect(G_OBJECT(btn_search), "clicked", G_CALLBACK(poi_search_do_cb), NULL);
+g_signal_connect(G_OBJECT(btn_goto), "clicked", G_CALLBACK(poi_goto_cb), NULL);
+g_signal_connect(G_OBJECT(btn_route_to), "clicked", G_CALLBACK(poi_route_to_cb), NULL);
+
gtk_widget_show_all(dialog);
while (GTK_RESPONSE_ACCEPT == gtk_dialog_run(GTK_DIALOG(dialog))) {
return poi_search_dialog(store, poi);
}
-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);
-
-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)
{
if (category_list())
- poi_populate_cat_combo(data->cmb_category, data->cat_id);
+ poi_category_combo_populate(data->cmb_category, data->cat_id);
return TRUE;
}
hbox = gtk_hbox_new(FALSE, 4),
1, 2, 3, 4, GTK_EXPAND | GTK_FILL, 0, 2, 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)));
+cmb_category = category_combo_new();
gtk_box_pack_start(GTK_BOX(hbox), cmb_category, 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_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_entry_set_text(GTK_ENTRY(txt_label), poi.label);
/* category */
-poi_populate_cat_combo(cmb_category, poi.cat_id);
+poi_category_combo_populate(cmb_category, poi.cat_id);
/* poi_desc */
gtk_text_buffer_set_text(desc_txt, poi.desc, -1);