From 97cb00daac543a7ab2547aaba129db5e71008fb2 Mon Sep 17 00:00:00 2001 From: Kaj-Michael Lang Date: Mon, 6 Aug 2007 17:21:31 +0300 Subject: [PATCH] Split out filter settings from Settings dialog and add menu item under track to bring it up. --- src/Makefile.am | 1 + src/cb.c | 6 +++ src/cb.h | 1 + src/config.c | 26 ++++++++--- src/filter-gui.c | 108 +++++++++++++++++++++++++++++++++++++++++++++ src/settings-gui.c | 54 ----------------------- src/ui-common.c | 4 ++ src/ui-common.h | 1 + 8 files changed, 140 insertions(+), 61 deletions(-) create mode 100644 src/filter-gui.c diff --git a/src/Makefile.am b/src/Makefile.am index 2298e84..3a5c42d 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -50,6 +50,7 @@ mapper_SOURCES = utils.c \ poi-gui.c \ map-poi.c \ settings-gui.c \ + filter-gui.c \ speed-display.c \ hildon-wrappers.c \ ui-common.c \ diff --git a/src/cb.c b/src/cb.c index 30b3382..3a845eb 100644 --- a/src/cb.c +++ b/src/cb.c @@ -208,6 +208,12 @@ gboolean menu_cb_track_clear(GtkAction * action) return TRUE; } +gboolean menu_cb_track_filter(GtkAction * action) +{ +filter_dialog(); +return TRUE; +} + gboolean menu_cb_show_tracks(GtkAction * action) { printf("%s()\n", __PRETTY_FUNCTION__); diff --git a/src/cb.h b/src/cb.h index c4cce18..9ec84cf 100644 --- a/src/cb.h +++ b/src/cb.h @@ -41,6 +41,7 @@ gboolean menu_cb_track_insert_mark(GtkAction * action); gboolean menu_cb_track_distlast(GtkAction * action); gboolean menu_cb_track_distfirst(GtkAction * action); gboolean menu_cb_track_clear(GtkAction * action); +gboolean menu_cb_track_filter(GtkAction * action); /* Callbacks for the "Maps" submenu. */ gboolean menu_cb_maps_select(GtkAction * action, gpointer new_repo); diff --git a/src/config.c b/src/config.c index 81428a3..cbf5446 100644 --- a/src/config.c +++ b/src/config.c @@ -188,6 +188,7 @@ if (_repo_list == NULL) { return TRUE; } +gboolean config_save_home(void) { GConfClient *gconf_client = gconf_client_get_default(); @@ -202,6 +203,24 @@ gconf_client_set_float(gconf_client, GCONF_KEY_HOME_LON, _home.lon, NULL); return TRUE; } +gboolean +config_save_filter(void) +{ +GConfClient *gconf_client = gconf_client_get_default(); + +if (!gconf_client) + return FALSE; + +/* Filtering */ +gconf_client_set_bool(gconf_client, GCONF_KEY_GPS_FILTER, _gps_filter, NULL); +gconf_client_set_float(gconf_client, GCONF_KEY_GPS_FILTER_HDOP, _filter_hdop, NULL); +gconf_client_set_float(gconf_client, GCONF_KEY_GPS_FILTER_VDOP, _filter_vdop, NULL); +gconf_client_set_float(gconf_client, GCONF_KEY_GPS_FILTER_ANGLE, _filter_angle, NULL); +gconf_client_set_float(gconf_client, GCONF_KEY_GPS_FILTER_OSM, _filter_osm, NULL); + +return TRUE; +} + /** * Save all configuration data to GCONF. */ @@ -351,13 +370,6 @@ config_save() /* Save Enable GPS flag. */ gconf_client_set_bool(gconf_client, GCONF_KEY_ENABLE_GPS, _enable_gps, NULL); - /* Filtering */ - gconf_client_set_bool(gconf_client, GCONF_KEY_GPS_FILTER, _gps_filter, NULL); - gconf_client_set_float(gconf_client, GCONF_KEY_GPS_FILTER_HDOP, _filter_hdop, NULL); - gconf_client_set_float(gconf_client, GCONF_KEY_GPS_FILTER_VDOP, _filter_vdop, NULL); - gconf_client_set_float(gconf_client, GCONF_KEY_GPS_FILTER_ANGLE, _filter_angle, NULL); - gconf_client_set_float(gconf_client, GCONF_KEY_GPS_FILTER_OSM, _filter_osm, NULL); - /* Save Route Locations. */ gconf_client_set_list(gconf_client, GCONF_KEY_ROUTE_LOCATIONS, GCONF_VALUE_STRING, _loc_list, NULL); diff --git a/src/filter-gui.c b/src/filter-gui.c new file mode 100644 index 0000000..7e398f5 --- /dev/null +++ b/src/filter-gui.c @@ -0,0 +1,108 @@ +#include "config.h" + +#define _GNU_SOURCE + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "hildon-mapper.h" + +#include "utils.h" +#include "gps.h" +#include "map.h" +#include "mapper-types.h" +#include "bt.h" +#include "ui-common.h" +#include "settings.h" + +#include "hildon-wrappers.h" + +GtkWidget *dialog; +GtkWidget *swindow; +GtkWidget *table; +GtkWidget *notebook; +GtkWidget *label; + +GtkWidget *chk_gps_filter; +GtkWidget *num_angle; +GtkWidget *num_hdop; +GtkWidget *num_vdop; +GtkWidget *num_osm_dist; + +gboolean +filter_dialog(void) +{ +dialog = gtk_dialog_new_with_buttons(_("Track Filter"), + GTK_WINDOW(_window), + GTK_DIALOG_MODAL, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, + GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, + NULL); + +gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), + notebook = gtk_notebook_new(), TRUE, TRUE, 0); + +gtk_notebook_append_page(GTK_NOTEBOOK(notebook), + table = gtk_table_new(2,4,FALSE), label = gtk_label_new(_("GPS"))); + +gtk_table_attach(GTK_TABLE(table), + chk_gps_filter = gtk_check_button_new_with_label(_("Enable track filter")), + 0, 2, 0, 1, GTK_EXPAND | GTK_FILL, 0, 2, 4); +gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(chk_gps_filter), _gps_filter); + +gtk_table_attach(GTK_TABLE(table), label = gtk_label_new(_("Horizontal")), + 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), num_hdop = gtk_hscale_new_with_range(0, 200, 0.1), + 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, 0, 2, 4); + +gtk_table_attach(GTK_TABLE(table), label = gtk_label_new(_("Vertical")), + 0, 1, 2, 3, GTK_FILL, 0, 2, 4); +gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f); +gtk_table_attach(GTK_TABLE(table), num_vdop = gtk_hscale_new_with_range(0, 200, 0.1), + 1, 2, 2, 3, GTK_EXPAND | GTK_FILL, 0, 2, 4); + +gtk_table_attach(GTK_TABLE(table), label = gtk_label_new(_("Angle")), + 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), num_angle = gtk_hscale_new_with_range(0, 45, 0.5), + 1, 2, 3, 4, GTK_EXPAND | GTK_FILL, 0, 2, 4); + +gtk_notebook_append_page(GTK_NOTEBOOK(notebook), + table = gtk_table_new(2,1,FALSE), label = gtk_label_new(_("Other"))); + +/* Distance to OSM data */ +gtk_table_attach(GTK_TABLE(table), label = gtk_label_new(_("Distance to OSM Data")), + 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), num_osm_dist = gtk_hscale_new_with_range(0, 5000, 50), + 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, 0, 2, 4); + +gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(chk_gps_filter), _gps_filter); +gtk_range_set_value(GTK_RANGE(num_hdop), _filter_hdop); +gtk_range_set_value(GTK_RANGE(num_vdop), _filter_vdop); +gtk_range_set_value(GTK_RANGE(num_angle), _filter_angle); +gtk_range_set_value(GTK_RANGE(num_osm_dist), _filter_osm); + +gtk_widget_show_all(dialog); + +if (GTK_RESPONSE_ACCEPT == gtk_dialog_run(GTK_DIALOG(dialog))) { + _filter_angle = gtk_range_get_value(GTK_RANGE(num_angle)); + _filter_hdop = gtk_range_get_value(GTK_RANGE(num_hdop)); + _filter_vdop = gtk_range_get_value(GTK_RANGE(num_vdop)); + _filter_osm = gtk_range_get_value(GTK_RANGE(num_osm_dist)); + _gps_filter = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(chk_gps_filter)); + + config_save_filter(); +} + +gtk_widget_destroy(dialog); + +return TRUE; +} diff --git a/src/settings-gui.c b/src/settings-gui.c index a8aabee..1cae3c3 100644 --- a/src/settings-gui.c +++ b/src/settings-gui.c @@ -413,13 +413,6 @@ settings_dialog(void) GtkWidget *cmb_speed_location; GtkWidget *cmb_info_font_size; - GtkWidget *_filter_window; - GtkWidget *chk_gps_filter; - GtkWidget *num_angle; - GtkWidget *num_hdop; - GtkWidget *num_vdop; - GtkWidget *num_osm_dist; - BrowseInfo browse_info = { 0, 0 }; ScanInfo scan_info = { 0 }; gboolean rcvr_changed = FALSE; @@ -478,43 +471,6 @@ settings_dialog(void) gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_CENTER); gtk_misc_set_alignment(GTK_MISC(label), 0.5f, 0.5f); - _filter_window=gtk_scrolled_window_new(NULL, NULL); - gtk_notebook_append_page(GTK_NOTEBOOK(notebook), - _filter_window, - label = gtk_label_new(_("Filter"))); - - table = gtk_table_new(2, 5, FALSE); - gtk_scrolled_window_add_with_viewport(_filter_window, table); - - gtk_table_attach(GTK_TABLE(table), - chk_gps_filter = gtk_check_button_new_with_label(_("Enable GPS track filter")), - 0, 2, 0, 1, GTK_EXPAND | GTK_FILL, 0, 2, 4); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(chk_gps_filter), _gps_filter); - - gtk_table_attach(GTK_TABLE(table), label = gtk_label_new(_("Horizontal")), - 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), num_hdop = gtk_hscale_new_with_range(0, 200, 0.1), - 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, 0, 2, 4); - - gtk_table_attach(GTK_TABLE(table), label = gtk_label_new(_("Vertical")), - 0, 1, 2, 3, GTK_FILL, 0, 2, 4); - gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f); - gtk_table_attach(GTK_TABLE(table), num_vdop = gtk_hscale_new_with_range(0, 200, 0.1), - 1, 2, 2, 3, GTK_EXPAND | GTK_FILL, 0, 2, 4); - - gtk_table_attach(GTK_TABLE(table), label = gtk_label_new(_("Angle")), - 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), num_angle = gtk_hscale_new_with_range(0, 45, 0.5), - 1, 2, 3, 4, GTK_EXPAND | GTK_FILL, 0, 2, 4); - - /* Distance to OSM data */ - gtk_table_attach(GTK_TABLE(table), label = gtk_label_new(_("Distance to OSM Data")), - 0, 1, 4, 5, GTK_FILL, 0, 2, 4); - gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f); - gtk_table_attach(GTK_TABLE(table), num_osm_dist = gtk_hscale_new_with_range(0, 5000, 50), - 1, 2, 4, 5, GTK_EXPAND | GTK_FILL, 0, 2, 4); /* Auto-Center page. */ gtk_notebook_append_page(GTK_NOTEBOOK(notebook), @@ -760,11 +716,6 @@ settings_dialog(void) gtk_combo_box_set_active(GTK_COMBO_BOX(cmb_speed_location), _speed_location); gtk_combo_box_set_active(GTK_COMBO_BOX(cmb_info_font_size), _info_font_size); - gtk_range_set_value(num_hdop, _filter_hdop); - gtk_range_set_value(num_vdop, _filter_vdop); - gtk_range_set_value(num_angle, _filter_angle); - gtk_range_set_value(num_osm_dist, _filter_osm); - gtk_widget_show_all(dialog); /* TODO: Uncomment the following hide function calls if moimart ever @@ -822,11 +773,6 @@ settings_dialog(void) _voice_pitch = hildon_controlbar_get_value(HILDON_CONTROLBAR(num_voice_pitch)); _enable_voice = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(chk_enable_voice)); - _filter_angle = gtk_range_get_value(GTK_RANGE(num_angle)); - _filter_hdop = gtk_range_get_value(GTK_RANGE(num_hdop)); - _filter_vdop = gtk_range_get_value(GTK_RANGE(num_vdop)); - _filter_osm = gtk_range_get_value(GTK_RANGE(num_osm_dist)); - _gps_filter = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(chk_gps_filter)); if (_db) { mapper_db_disconnect(&_db); diff --git a/src/ui-common.c b/src/ui-common.c index 40dd079..69dbc70 100644 --- a/src/ui-common.c +++ b/src/ui-common.c @@ -306,6 +306,8 @@ static void menu_init() gtk_menu_append(submenu, _menu_track_distlast_item = gtk_menu_item_new_with_label(_("Show Distance from Last Mark"))); gtk_menu_append(submenu, _menu_track_distfirst_item = gtk_menu_item_new_with_label(_("Show Distance from Beginning"))); gtk_menu_append(submenu, _menu_track_clear_item = gtk_menu_item_new_with_label(_("Clear"))); + gtk_menu_append(submenu, gtk_separator_menu_item_new()); + gtk_menu_append(submenu, _menu_track_filter = gtk_menu_item_new_with_label(_("Filter..."))); /* The "Maps" submenu. */ menu_item = gtk_menu_item_new_with_label(_("Maps")); @@ -432,6 +434,8 @@ static void menu_init() G_CALLBACK(menu_cb_track_distfirst), NULL); g_signal_connect(G_OBJECT(_menu_track_clear_item), "activate", G_CALLBACK(menu_cb_track_clear), NULL); + g_signal_connect(G_OBJECT(_menu_track_filter), "activate", + G_CALLBACK(menu_cb_track_filter), NULL); /* Connect the "Maps" signals. */ g_signal_connect(G_OBJECT(_menu_maps_repoman_item), "activate", diff --git a/src/ui-common.h b/src/ui-common.h index 09e2281..e8a0b6d 100644 --- a/src/ui-common.h +++ b/src/ui-common.h @@ -110,6 +110,7 @@ GtkWidget *_menu_track_insert_mark_item; GtkWidget *_menu_track_distlast_item; GtkWidget *_menu_track_distfirst_item; GtkWidget *_menu_track_clear_item; +GtkWidget *_menu_track_filter; /* Menu items for the "Maps" submenu. */ GtkWidget *_menu_maps_submenu; -- 2.39.5