]> err.no Git - mapper/commitdiff
Split out filter settings from Settings dialog and add menu item under track to bring...
authorKaj-Michael Lang <milang@onion.tal.org>
Mon, 6 Aug 2007 14:21:31 +0000 (17:21 +0300)
committerKaj-Michael Lang <milang@onion.tal.org>
Mon, 6 Aug 2007 14:21:31 +0000 (17:21 +0300)
src/Makefile.am
src/cb.c
src/cb.h
src/config.c
src/filter-gui.c [new file with mode: 0644]
src/settings-gui.c
src/ui-common.c
src/ui-common.h

index 2298e8485cd17823a9237952e05bea1cc971d562..3a5c42dfa2a903da9cd9faaf655829ee8f599118 100644 (file)
@@ -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 \
index 30b338239c6eed137b789925f89afb87a8c64ae6..3a845eb012dce266a0b5f0de4625d31d702aca35 100644 (file)
--- 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__);
index c4cce18b86ed6f88aa0ed9324950560fa9dbc90b..9ec84cf35f5f89d56f61c5d987c2b8b023f44505 100644 (file)
--- 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);
index 81428a33e38edef19bdcd9a726700428f331729c..cbf5446c5069efffa5a9ff8cbb0a86595e7ab4a8 100644 (file)
@@ -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 (file)
index 0000000..7e398f5
--- /dev/null
@@ -0,0 +1,108 @@
+#include "config.h"
+
+#define _GNU_SOURCE
+
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+#include <strings.h>
+#include <stddef.h>
+#include <glib/gstdio.h>
+#include <gtk/gtk.h>
+#include <libintl.h>
+#include <locale.h>
+
+#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;
+}
index a8aabeed63063510e46fe0740efbfd26e980ff0c..1cae3c36673910ffe3bd3323557fae31ccc7c59e 100644 (file)
@@ -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);
index 40dd079d4058df116fa3ec6d44e0574b4fb2c329..69dbc70b9f8c5f0ca1d4ef32ff4d2182bbf62dba 100644 (file)
@@ -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",
index 09e228147e92c34e478f1d6953990081ff724267..e8a0b6dab41fbf8d55a96777ef0e57fa84517647 100644 (file)
@@ -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;