X-Git-Url: https://git.street.me.uk/andy/viking.git/blobdiff_plain/4c77d5e0aec3c7aab32965ca4e02abb17bb6108f..80471a6a905e00bf80ad04fa2061f88ea81f15cb:/src/vikgpslayer.c diff --git a/src/vikgpslayer.c b/src/vikgpslayer.c index 55ab911a..83e56148 100644 --- a/src/vikgpslayer.c +++ b/src/vikgpslayer.c @@ -26,7 +26,7 @@ #include #include #include "viking.h" -#include "vikgpslayer_pixmap.h" +#include "icons/icons.h" #include "babel.h" #include @@ -67,7 +67,11 @@ typedef enum {GARMIN_P = 0, MAGELLAN_P, NUM_PROTOCOLS} vik_gps_proto; static gchar * params_protocols[] = {"Garmin", "Magellan", NULL}; static gchar * protocols_args[] = {"garmin", "magellan"}; /*#define NUM_PROTOCOLS (sizeof(params_protocols)/sizeof(params_protocols[0]) - 1) */ +#ifdef WINDOWS +static gchar * params_ports[] = {"com1", "usb:", NULL}; +#else static gchar * params_ports[] = {"/dev/ttyS0", "/dev/ttyS1", "/dev/ttyUSB0", "/dev/ttyUSB1", "usb:", NULL}; +#endif #define NUM_PORTS (sizeof(params_ports)/sizeof(params_ports[0]) - 1) typedef enum {GPS_DOWN=0, GPS_UP} gps_dir; @@ -122,7 +126,7 @@ enum { VikLayerInterface vik_gps_layer_interface = { "GPS", - &gpslayer_pixbuf, + &vikgpslayer_pixbuf, NULL, 0, @@ -667,9 +671,23 @@ static void set_total_count(gint cnt, GpsSession *sess) gdk_threads_enter(); g_mutex_lock(sess->mutex); if (sess->ok) { - g_sprintf(s, "%s %d %s...", - (sess->direction == GPS_DOWN) ? _("Downloading") : _("Uploading"), cnt, - (sess->progress_label == sess->wp_label) ? _("waypoints") : _("trackpoints")); + const gchar *tmp_str; + if (sess->direction == GPS_DOWN) + { + if (sess->progress_label == sess->wp_label) + tmp_str = ngettext("Downloading %d waypoint...", "Downloading %d waypoints...", cnt); + else + tmp_str = ngettext("Downloading %d trackpoint...", "Downloading %d trackpoints...", cnt); + } + else + { + if (sess->progress_label == sess->wp_label) + tmp_str = ngettext("Uploading %d waypoint...", "Uploading %d waypoints...", cnt); + else + tmp_str = ngettext("Uploading %d trackpoint...", "Uploading %d trackpoints...", cnt); + } + + g_snprintf(s, 128, tmp_str, cnt); gtk_label_set_text ( GTK_LABEL(sess->progress_label), s ); gtk_widget_show ( sess->progress_label ); sess->total_count = cnt; @@ -681,15 +699,41 @@ static void set_total_count(gint cnt, GpsSession *sess) static void set_current_count(gint cnt, GpsSession *sess) { gchar s[128]; - const gchar *dir_str = (sess->direction == GPS_DOWN) ? _("Downloaded") : _("Uploaded"); + const gchar *tmp_str; gdk_threads_enter(); g_mutex_lock(sess->mutex); if (sess->ok) { if (cnt < sess->total_count) { - g_sprintf(s, _("%s %d out of %d %s..."), dir_str, cnt, sess->total_count, (sess->progress_label == sess->wp_label) ? _("waypoints") : _("trackpoints")); + if (sess->direction == GPS_DOWN) + { + if (sess->progress_label == sess->wp_label) + tmp_str = ngettext("Downloaded %d out of %d waypoint...", "Downloaded %d out of %d waypoints...", sess->total_count); + else + tmp_str = ngettext("Downloaded %d out of %d trackpoint...", "Downloaded %d out of %d trackpoints...", sess->total_count); + } + else { + if (sess->progress_label == sess->wp_label) + tmp_str = ngettext("Uploaded %d out of %d waypoint...", "Uploaded %d out of %d waypoints...", sess->total_count); + else + tmp_str = ngettext("Uploaded %d out of %d trackpoint...", "Uploaded %d out of %d trackpoints...", sess->total_count); + } + g_snprintf(s, 128, tmp_str, cnt, sess->total_count); } else { - g_sprintf(s, "%s %d %s.", dir_str, cnt, (sess->progress_label == sess->wp_label) ? _("waypoints") : _("trackpoints")); + if (sess->direction == GPS_DOWN) + { + if (sess->progress_label == sess->wp_label) + tmp_str = ngettext("Downloaded %d waypoint", "Downloaded %d waypoints", cnt); + else + tmp_str = ngettext("Downloaded %d trackpoint", "Downloaded %d trackpoints", cnt); + } + else { + if (sess->progress_label == sess->wp_label) + tmp_str = ngettext("Uploaded %d waypoint", "Uploaded %d waypoints", cnt); + else + tmp_str = ngettext("Uploaded %d trackpoint", "Uploaded %d trackpoints", cnt); + } + g_snprintf(s, 128, tmp_str, cnt); } gtk_label_set_text ( GTK_LABEL(sess->progress_label), s ); } @@ -703,7 +747,7 @@ static void set_gps_info(const gchar *info, GpsSession *sess) gdk_threads_enter(); g_mutex_lock(sess->mutex); if (sess->ok) { - g_sprintf(s, _("GPS Device: %s"), info); + g_snprintf(s, 256, _("GPS Device: %s"), info); gtk_label_set_text ( GTK_LABEL(sess->gps_label), s ); } g_mutex_unlock(sess->mutex);