]> err.no Git - mapper/commitdiff
Move gps banner handling from mapper.c to their own file. Misc other cleanups.
authorKaj-Michael Lang <milang@onion.tal.org>
Fri, 3 Aug 2007 05:57:28 +0000 (08:57 +0300)
committerKaj-Michael Lang <milang@onion.tal.org>
Fri, 3 Aug 2007 05:57:28 +0000 (08:57 +0300)
src/Makefile.am
src/bt-bluez.c
src/cb.c
src/gps-conn.c [new file with mode: 0644]
src/gps-nmea-parse.c
src/gps-panels.c
src/hildon-wrappers.c
src/iap.c
src/mapper.c
src/ui-common.c
src/ui-common.h

index 61cedb2b57dcb387d94e896473f09cee89018ae6..9c1e3fb75e26d00dc43c4c07fe452ba286b315ec 100644 (file)
@@ -38,6 +38,7 @@ mapper_SOURCES = utils.c \
        gps-browse.c \
        gps-nmea-parse.c \
        gps-panels.c \
+       gps-conn.c \
        cb.c \
        iap.c \
        route.c \
index 187378fd6db4fd377eecd3c79959f77dafb43666..7c41d74ef52d20e9eacd7926e9d40efdca835ee1 100644 (file)
@@ -102,6 +102,12 @@ static gboolean rcvr_connect_bt()
                        perror("ERROR: ");
                        return TRUE;
                break;
+               case EHOSTUNREACH:
+                       g_printf("*** Bluetooth/GPS device not found.\n");
+                       rcvr_disconnect();
+                       rcvr_connect_later();
+                       return FALSE;
+               break;
                default:
                        /* Connection failed.  Disconnect and try again later. */
                        g_printf("### Connect failed, retrying... %d %d\n", e, r);
index e12efcc53cdf8b4e9f318bd74cb5364c391d021a..839a092e375074997321c3f228f947c6c1d2a817 100644 (file)
--- a/src/cb.c
+++ b/src/cb.c
 #include <glib/gstdio.h>
 #include <gtk/gtk.h>
 #include <fcntl.h>
-#include <libgnomevfs/gnome-vfs.h>
-#include <curl/multi.h>
 #include <gconf/gconf-client.h>
-#include <libxml/parser.h>
 #include <libintl.h>
 #include <locale.h>
-#include <sqlite3.h>
 
-#ifdef WITH_HILDON
+#ifdef WITH_OSSO
 #include <libosso.h>
 #include <osso-helplib.h>
+#endif
+#ifdef WITH_HILDON
 #include <hildon-widgets/hildon-program.h>
 #include <hildon-widgets/hildon-controlbar.h>
 #include <hildon-widgets/hildon-note.h>
@@ -1125,14 +1123,11 @@ void cmenu_route_add_way(guint unitx, guint unity)
 
                        g_free(desc);
 
-                       confirm =
-                           hildon_note_new_confirmation(GTK_WINDOW(dialog),
-                                                        _
-                                                        ("Creating a \"waypoint\" with no description actually "
+                       confirm = hildon_note_new_confirmation(GTK_WINDOW(dialog),
+                                                        _("Creating a \"waypoint\" with no description actually "
                                                          "adds a break point.  Is that what you want?"));
 
-                       if (GTK_RESPONSE_OK ==
-                           gtk_dialog_run(GTK_DIALOG(confirm))) {
+                       if (GTK_RESPONSE_OK == gtk_dialog_run(GTK_DIALOG(confirm))) {
                                /* There's no description.  Add a break by adding a (0, 0)
                                 * point (if necessary), and then the ordinary route point. */
                                if (_route.tail->unity) {
@@ -1436,8 +1431,7 @@ gboolean cmenu_cb_poi_route_to(GtkAction * action)
        PoiInfo poi;
        printf("%s()\n", __PRETTY_FUNCTION__);
 
-       if (select_poi
-           (x2unit(_cmenu_position_x), y2unit(_cmenu_position_y), &poi)) {
+       if (select_poi(x2unit(_cmenu_position_x), y2unit(_cmenu_position_y), &poi)) {
                guint unitx, unity;
                latlon2unit(poi.lat, poi.lon, unitx, unity);
                cmenu_route_to(unitx, unity);
diff --git a/src/gps-conn.c b/src/gps-conn.c
new file mode 100644 (file)
index 0000000..ad27bf6
--- /dev/null
@@ -0,0 +1,80 @@
+#define _GNU_SOURCE
+
+#define _(String) gettext(String)
+
+#include <config.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <stddef.h>
+#include <errno.h>
+#include <sys/wait.h>
+#include <glib/gstdio.h>
+#include <gtk/gtk.h>
+#include <fcntl.h>
+#include <dbus/dbus-glib.h>
+
+#ifdef WITH_HILDON
+#include <hildon-widgets/hildon-banner.h>
+#endif
+
+static GtkWidget *connect_banner = NULL;
+static GtkWidget *fix_banner = NULL;
+
+#include <libintl.h>
+#include <locale.h>
+
+#include "utils.h"
+#include "settings.h"
+#include "gps.h"
+#include "map.h"
+#include "bt.h"
+#include "ui-common.h"
+
+/**
+ * Set the connection state.  This function controls all connection-related
+ * banners.
+ */
+void 
+set_conn_state(ConnState new_conn_state)
+{
+switch (_conn_state = new_conn_state) {
+       case RCVR_OFF:
+       case RCVR_FIXED:
+               if (connect_banner) {
+                       gtk_widget_destroy(connect_banner);
+                       connect_banner = NULL;
+               }
+               if (fix_banner) {
+                       gtk_widget_destroy(fix_banner);
+                       fix_banner = NULL;
+               }
+               break;
+       case RCVR_DOWN:
+               if (fix_banner) {
+                       gtk_widget_destroy(fix_banner);
+                       fix_banner = NULL;
+               }
+               if (!connect_banner)
+                       connect_banner = hildon_banner_show_animation(_window, NULL, _("Searching for GPS receiver"));
+               break;
+       case RCVR_UP:
+               if (connect_banner) {
+                       gtk_widget_destroy(connect_banner);
+                       connect_banner = NULL;
+               }
+               if (!fix_banner)
+                       fix_banner = hildon_banner_show_progress(_window, NULL, _("Establishing GPS fix"));
+               break;
+       default:;               /* to quell warning. */
+}
+}
+
+void
+set_fix_progress(gdouble fix)
+{
+#ifdef WITH_HILDON
+hildon_banner_set_fraction(fix_banner, fix);
+#else
+gtk_progress_bar_set_fraction(_progress_item, fix);
+#endif
+}
index d9a39d2308373ca4cf4d94a6fb7416b8606b6b04..56a8a2c3688c37e59d615574bd0b1ac9193578b3 100644 (file)
 #include <fcntl.h>
 #include <libxml/parser.h>
 
-#ifdef WITH_HILDON
-#include <hildon-widgets/hildon-banner.h>
-#endif
-
 #include "utils.h"
 #include "bt.h"
 #include "gps.h"
@@ -378,11 +374,9 @@ void channel_parse_gsv(gchar * sentence)
                /*  This is the last message. Calculate signal strength. */
                if (num_sats_used) {
                        if (_conn_state == RCVR_UP) {
-                               gdouble fraction =
-                                   running_total * sqrt(num_sats_used)
-                                   / num_sats_used / 100.0;
+                               gdouble fraction = running_total * sqrt(num_sats_used) / num_sats_used / 100.0;
                                BOUND(fraction, 0.0, 1.0);
-                               hildon_banner_set_fraction(HILDON_BANNER(_fix_banner), fraction);
+                               set_fix_progress(fraction);
                        }
                        running_total = 0;
                        num_sats_used = 0;
index f0bd8469924117cd98b48fc873858fe468b28d40..af5335d8128bfc3bf47996abe93c0d4d87be786a 100644 (file)
@@ -21,7 +21,8 @@
 #include "mapper-types.h"
 #include "ui-common.h"
 
-void gps_display_data(void)
+void 
+gps_display_data(void)
 {
 gchar *buffer, litbuf[16];
 printf("%s()\n", __PRETTY_FUNCTION__);
@@ -112,7 +113,8 @@ if (_gps_info)
 vprintf("%s(): return\n", __PRETTY_FUNCTION__);
 }
 
-void gps_show_info(void)
+void 
+gps_show_info(void)
 {
 printf("%s()\n", __PRETTY_FUNCTION__);
 
@@ -252,7 +254,8 @@ vprintf("%s(): return\n", __PRETTY_FUNCTION__);
 return TRUE;
 }
 
-gboolean heading_panel_expose(GtkWidget * widget, GdkEventExpose * event)
+gboolean 
+heading_panel_expose(GtkWidget * widget, GdkEventExpose * event)
 {
 guint size, xoffset, yoffset, i, x, y;
 gint dir;
@@ -737,7 +740,8 @@ gps_display_details(void)
        return TRUE;
 }
 
-void gps_details_dialog(void)
+void 
+gps_details_dialog(void)
 {
 GtkWidget *dialog;
 
index e62174afa6f4b225e5291882b8c91b6342490169..607cca3cc8dcec55dbf9e5b890a7479dc330086a 100644 (file)
@@ -15,123 +15,120 @@ static gint _sb_sid=0;
 GtkWidget *hildon_file_chooser_dialog_new(GtkWindow * parent,
                                          GtkFileChooserAction action)
 {
-       GtkWidget *dialog;
-
-       if (action == GTK_FILE_CHOOSER_ACTION_SAVE) {
-               dialog = gtk_file_chooser_dialog_new("Save", parent, action,
-                                                    GTK_STOCK_CANCEL,
-                                                    GTK_RESPONSE_CANCEL,
-                                                    GTK_STOCK_SAVE,
-                                                    GTK_RESPONSE_ACCEPT, NULL);
-               gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER
-                                                              (dialog), TRUE);
-       } else {
-               dialog = gtk_file_chooser_dialog_new("Open", parent, action,
-                                                    GTK_STOCK_CANCEL,
-                                                    GTK_RESPONSE_CANCEL,
-                                                    GTK_STOCK_OPEN,
-                                                    GTK_RESPONSE_ACCEPT, NULL);
-       }
-
-       return dialog;
+GtkWidget *dialog;
+
+if (action == GTK_FILE_CHOOSER_ACTION_SAVE) {
+       dialog = gtk_file_chooser_dialog_new("Save", parent, action,
+                                            GTK_STOCK_CANCEL,
+                                            GTK_RESPONSE_CANCEL,
+                                            GTK_STOCK_SAVE,
+                                            GTK_RESPONSE_ACCEPT, NULL);
+       gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(dialog), TRUE);
+} else {
+       dialog = gtk_file_chooser_dialog_new("Open", parent, action,
+                                            GTK_STOCK_CANCEL,
+                                            GTK_RESPONSE_CANCEL,
+                                            GTK_STOCK_OPEN,
+                                            GTK_RESPONSE_ACCEPT, NULL);
+}
+return dialog;
 }
 
 static gboolean
 status_bar_clear(void)
 {
-       gtk_statusbar_pop(_status_bar, 0);
-       _sb_sid=0;
-       return FALSE;
+gtk_statusbar_pop(_status_bar, 0);
+_sb_sid=0;
+return FALSE;
 }
 
 void hildon_banner_show_information(GtkWidget *w, void *t, gchar *text)
 {
-       gtk_statusbar_pop(GTK_STATUSBAR(_status_bar), 0);
-       gtk_statusbar_push(GTK_STATUSBAR(_status_bar), 0, text);
-       if (_sb_sid!=0)
-               g_source_remove(_sb_sid);
-       _sb_sid=g_timeout_add(6000, status_bar_clear, NULL);
+gtk_statusbar_pop(GTK_STATUSBAR(_status_bar), 0);
+gtk_statusbar_push(GTK_STATUSBAR(_status_bar), 0, text);
+if (_sb_sid!=0)
+       g_source_remove(_sb_sid);
+_sb_sid=g_timeout_add(6000, status_bar_clear, NULL);
 }
 
 GtkWidget *hildon_banner_show_progress(GtkWidget * widget, GtkProgressBar *bar,
                                       const gchar * text)
 {
-       gtk_widget_show(_progress_item);
-       gtk_progress_bar_set_text(_progress_item, text);
-       hildon_banner_show_information(_status_bar, NULL, text);
-       return NULL;
+gtk_widget_show(_progress_item);
+gtk_progress_bar_set_text(_progress_item, text);
+hildon_banner_show_information(_status_bar, NULL, text);
+return NULL;
 }
 
 GtkWidget *hildon_note_new_confirmation(GtkWidget *widget, const gchar *text)
 {
-       return gtk_message_dialog_new(widget,
-                                       GTK_DIALOG_DESTROY_WITH_PARENT,
-                                       GTK_MESSAGE_ERROR,
-                                       GTK_BUTTONS_OK_CANCEL, text);
+return gtk_message_dialog_new(widget,
+                       GTK_DIALOG_DESTROY_WITH_PARENT,
+                       GTK_MESSAGE_ERROR,
+                       GTK_BUTTONS_OK_CANCEL, text);
 }
 
 void hildon_banner_set_fraction(GtkWidget * widget, gdouble fraction)
 {
-       gtk_progress_bar_set_fraction(_progress_item, fraction);
-       if (fraction==1.0)
-               gtk_widget_hide(_progress_item);
-       else
-               gtk_widget_show(_progress_item);
+gtk_progress_bar_set_fraction(_progress_item, fraction);
+if (fraction==1.0)
+       gtk_widget_hide(_progress_item);
+else
+       gtk_widget_show(_progress_item);
 }
 
 GtkWidget *hildon_banner_show_animation(GtkWidget *widget,
                                        const gchar *animation_name,
                                        const gchar *text)
 {
-       hildon_banner_show_information(_status_bar, NULL, text);
-       gtk_widget_show(_progress_item);
-       gtk_progress_bar_pulse(_progress_item);
-       return NULL;
+hildon_banner_show_information(_status_bar, NULL, text);
+gtk_widget_show(_progress_item);
+gtk_progress_bar_pulse(_progress_item);
+return NULL;
 }
 
 void gtk_widget_tap_and_hold_setup(GtkWidget * a, GtkWidget * w, void *p, gint t)
 {
-
 }
 
 GtkWidget *hildon_number_editor_new(gint min, gint max)
 {
-       return gtk_spin_button_new_with_range(min, max, 1);
+return gtk_spin_button_new_with_range(min, max, 1);
 }
 
 gint hildon_number_editor_get_value(GtkWidget * w)
 {
-       return gtk_spin_button_get_value_as_int(GTK_WIDGET(w));
+return gtk_spin_button_get_value_as_int(GTK_WIDGET(w));
 }
 
 void hildon_number_editor_set_value(GtkWidget * w, gint v)
 {
-       gtk_spin_button_set_value(w, v);
+gtk_spin_button_set_value(w, v);
 }
 
 void hildon_number_editor_set_range(GtkWidget * w, gint min, gint max)
 {
-       gtk_spin_button_set_range(w, min, max);
+gtk_spin_button_set_range(w, min, max);
 }
 
 GtkWidget *hildon_controlbar_new()
 {
-       return gtk_hscale_new_with_range(1, 10, 1);
+return gtk_hscale_new_with_range(1, 10, 1);
 }
 
 gint hildon_controlbar_get_value(GtkWidget * w)
 {
-       return gtk_range_get_value(w);
+return gtk_range_get_value(w);
 }
 
 void hildon_controlbar_set_value(GtkWidget * w, gint v)
 {
-       gtk_range_set_value(w, (gdouble)v);
+gtk_range_set_value(w, (gdouble)v);
 }
 
 void hildon_controlbar_set_range(GtkWidget * w, gint min, gint max)
 {
-       gtk_range_set_range(w, (gdouble)min, (gdouble)max);
+gtk_range_set_range(w, (gdouble)min, (gdouble)max);
 }
 
 #else
index 1125aa49fe21f30e51beae0ec3a34a15248bb36c..e2d2ead9d6605258b7ba2596e0bc38d1084176e5 100644 (file)
--- a/src/iap.c
+++ b/src/iap.c
@@ -1,6 +1,6 @@
 #include <config.h>
 
-#ifdef WITH_HILDON
+#ifdef WITH_OSSO
 
 #include <libosso.h>
 #include <osso-helplib.h>
index 258bea0d861baa99408cf0fdfdc49d684e7af523..17d46d6dfc0317542257f796d9644491ea3167a8 100644 (file)
 #include <hildon-widgets/hildon-program.h>
 #include <hildon-widgets/hildon-controlbar.h>
 #include <hildon-widgets/hildon-note.h>
-#include <hildon-widgets/hildon-color-button.h>
-#include <hildon-widgets/hildon-file-chooser-dialog.h>
-#include <hildon-widgets/hildon-number-editor.h>
-#include <hildon-widgets/hildon-banner.h>
-#include <hildon-widgets/hildon-system-sound.h>
 #include <hildon-widgets/hildon-input-mode-hint.h>
 #include <device_symbols.h>
 #endif
@@ -105,61 +100,6 @@ GdkColor COLORABLE_DEFAULT[COLORABLE_ENUM_COUNT] = {
        {0, 0xa000, 0x0000, 0xa000}     /* COLORABLE_POI */
 };
 
-/**
- * Set the connection state.  This function controls all connection-related
- * banners.
- */
-void set_conn_state(ConnState new_conn_state)
-{
-       printf("%s(%d)\n", __PRETTY_FUNCTION__, new_conn_state);
-
-       switch (_conn_state = new_conn_state) {
-       case RCVR_OFF:
-       case RCVR_FIXED:
-#ifdef WITH_HILDON
-               if (_connect_banner) {
-                       gtk_widget_destroy(_connect_banner);
-                       _connect_banner = NULL;
-               }
-               if (_fix_banner) {
-                       gtk_widget_destroy(_fix_banner);
-                       _fix_banner = NULL;
-               }
-#else
-
-#endif
-               break;
-       case RCVR_DOWN:
-#ifdef WITH_HILDON
-               if (_fix_banner) {
-                       gtk_widget_destroy(_fix_banner);
-                       _fix_banner = NULL;
-               }
-               if (!_connect_banner)
-                       _connect_banner = hildon_banner_show_animation(_window, NULL,           
-                                        _("Searching for GPS receiver"));
-#else
-
-#endif
-               break;
-       case RCVR_UP:
-#ifdef WITH_HILDON
-               if (_connect_banner) {
-                       gtk_widget_destroy(_connect_banner);
-                       _connect_banner = NULL;
-               }
-               if (!_fix_banner)
-                       _fix_banner = hildon_banner_show_progress(_window, NULL,
-                                                       _("Establishing GPS fix"));
-#else
-
-#endif
-               break;
-       default:;               /* to quell warning. */
-       }
-
-       vprintf("%s(): return\n", __PRETTY_FUNCTION__);
-}
 
 /**
  * Save state and destroy all non-UI elements created by this program in
index a27335492d26427ca69a681899a75510d6bfb07e..f4491f36e031180c9351c3af072dcd22f0bf04b2 100644 (file)
@@ -546,9 +546,7 @@ static void menu_init()
        gtk_menu_append(submenu, _cmenu_loc_distance_to_item
                        = gtk_menu_item_new_with_label(_("Show Distance to")));
        gtk_menu_append(submenu, _cmenu_loc_route_to_item
-                       =
-                       gtk_menu_item_new_with_label(_
-                                                    ("Download Route to...")));
+                       = gtk_menu_item_new_with_label(_("Download Route to...")));
        gtk_menu_append(submenu, gtk_separator_menu_item_new());
        gtk_menu_append(submenu, _cmenu_loc_add_route
                        = gtk_menu_item_new_with_label(_("Add Route Point")));
index 5236461ac6f0143cdc2be0e4c566f99f1d149532..16c7a0959287f4a8dc905aca2c45216276e4d565 100644 (file)
@@ -187,9 +187,7 @@ GtkWidget *_cmenu_poi_add_route;
 GtkWidget *_cmenu_poi_add_way;
 GtkWidget *_cmenu_poi_goto_nearpoi;
 
-/** BANNERS. */
-GtkWidget *_connect_banner;
-GtkWidget *_fix_banner;
+/* Banners/Progress bars */
 GtkWidget *_download_banner;
 
 GtkWidget *_status_bar;