From d17be1067804a6a64136c43146dcb3ad6f1ddc29 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Sun, 6 Apr 2014 10:27:59 +0100 Subject: [PATCH] Convert some console warnings to get reported to the GUI in the statusbar. --- src/datasource_geotag.c | 4 +++- src/datasource_osm_my_traces.c | 9 ++++++--- src/vikmapslayer.c | 17 ++++++++++++++--- src/vikwindow.c | 17 ++++++++++++----- 4 files changed, 35 insertions(+), 12 deletions(-) diff --git a/src/datasource_geotag.c b/src/datasource_geotag.c index eb75c599..9ec5d35b 100644 --- a/src/datasource_geotag.c +++ b/src/datasource_geotag.c @@ -165,7 +165,9 @@ static gboolean datasource_geotag_process ( VikTrwLayer *vtl, const gchar *cmd, g_free ( name ); } else { - g_warning ( _("Unable to create waypoint from %s"), filename ); + gchar* msg = g_strdup_printf ( _("Unable to create waypoint from %s"), filename ); + vik_window_statusbar_update ( adw->vw, msg, VIK_STATUSBAR_INFO ); + g_free (msg); } g_free ( filename ); cur_file = g_slist_next ( cur_file ); diff --git a/src/datasource_osm_my_traces.c b/src/datasource_osm_my_traces.c index f496206c..78b544bb 100644 --- a/src/datasource_osm_my_traces.c +++ b/src/datasource_osm_my_traces.c @@ -644,9 +644,12 @@ static gboolean datasource_osm_my_traces_process ( VikTrwLayer *vtl, const gchar // http://developer.gnome.org/gtk/2.24/GtkProgressBar.html got_something = got_something || result; - // TODO feedback to UI to inform which traces failed - if ( !result ) - g_warning ( _("Unable to get trace: %s"), url ); + if ( !result ) { + // Report errors to the status bar + gchar* msg = g_strdup_printf ( _("Unable to get trace: %s"), url ); + vik_window_statusbar_update ( adw->vw, msg, VIK_STATUSBAR_INFO ); + g_free (msg); + } g_free ( url ); } diff --git a/src/vikmapslayer.c b/src/vikmapslayer.c index 2718a11e..42bcbdd9 100644 --- a/src/vikmapslayer.c +++ b/src/vikmapslayer.c @@ -991,8 +991,14 @@ static GdkPixbuf *get_pixbuf( VikMapsLayer *vml, gint mode, MapCoord *mapcoord, /* free the pixbuf on error */ if (gx) { - if ( gx->domain != GDK_PIXBUF_ERROR || gx->code != GDK_PIXBUF_ERROR_CORRUPT_IMAGE ) - g_warning ( _("Couldn't open image file: %s"), gx->message ); + if ( gx->domain != GDK_PIXBUF_ERROR || gx->code != GDK_PIXBUF_ERROR_CORRUPT_IMAGE ) { + // Report a warning + if ( IS_VIK_WINDOW ((VikWindow*)VIK_GTK_WINDOW_FROM_LAYER(vml)) ) { + gchar* msg = g_strdup_printf ( _("Couldn't open image file: %s"), gx->message ); + vik_window_statusbar_update ( (VikWindow*)VIK_GTK_WINDOW_FROM_LAYER(vml), msg, VIK_STATUSBAR_INFO ); + g_free (msg); + } + } g_error_free ( gx ); if ( pixbuf ) @@ -1063,7 +1069,12 @@ static void maps_layer_draw_section ( VikMapsLayer *vml, VikViewport *vvp, VikCo existence_only = TRUE; } else { - g_warning ( _("Cowardly refusing to draw tiles or existence of tiles beyond %d zoom out factor"), (int)( 1.0/REAL_MIN_SHRINKFACTOR)); + // Report the reason for not drawing + if ( IS_VIK_WINDOW ((VikWindow*)VIK_GTK_WINDOW_FROM_LAYER(vml)) ) { + gchar* msg = g_strdup_printf ( _("Cowardly refusing to draw tiles or existence of tiles beyond %d zoom out factor"), (int)( 1.0/REAL_MIN_SHRINKFACTOR)); + vik_window_statusbar_update ( (VikWindow*)VIK_GTK_WINDOW_FROM_LAYER(vml), msg, VIK_STATUSBAR_INFO ); + g_free (msg); + } return; } } diff --git a/src/vikwindow.c b/src/vikwindow.c index 798983b2..6a9bfdd5 100644 --- a/src/vikwindow.c +++ b/src/vikwindow.c @@ -2652,7 +2652,10 @@ static void setup_recent_files (VikWindow *self) G_CALLBACK (on_activate_recent_item), (gpointer) self); } -static void update_recently_used_document(const gchar *filename) +/* + * + */ +static void update_recently_used_document (VikWindow *vw, const gchar *filename) { /* Update Recently Used Document framework */ GtkRecentManager *manager = gtk_recent_manager_get_default(); @@ -2673,7 +2676,9 @@ static void update_recently_used_document(const gchar *filename) recent_data->is_private = FALSE; if (!gtk_recent_manager_add_full (manager, uri, recent_data)) { - g_warning (_("Unable to add '%s' to the list of recently used documents"), uri); + gchar *msg = g_strdup_printf (_("Unable to add '%s' to the list of recently used documents"), uri); + vik_statusbar_set_message ( vw->viking_vs, VIK_STATUSBAR_INFO, msg ); + g_free ( msg ); } g_free (uri); @@ -2770,7 +2775,7 @@ void vik_window_open_file ( VikWindow *vw, const gchar *filename, gboolean chang success = TRUE; // When LOAD_TYPE_OTHER_SUCCESS *only*, this will maintain the existing Viking project restore_original_filename = ! restore_original_filename; - update_recently_used_document(filename); + update_recently_used_document (vw, filename); draw_update ( vw ); break; } @@ -2967,7 +2972,7 @@ static gboolean window_save ( VikWindow *vw ) if ( a_file_save ( vik_layers_panel_get_top_layer ( vw->viking_vlp ), vw->viking_vvp, vw->filename ) ) { - update_recently_used_document ( vw->filename ); + update_recently_used_document ( vw, vw->filename ); } else { @@ -3480,7 +3485,9 @@ static void save_image_dir ( VikWindow *vw, const gchar *fn, guint w, guint h, g gdk_pixbuf_save ( pixbuf_to_save, name_of_file, save_as_png ? "png" : "jpeg", &error, NULL ); if (error) { - g_warning("Unable to write to file %s: %s", name_of_file, error->message ); + gchar *msg = g_strdup_printf (_("Unable to write to file %s: %s"), name_of_file, error->message ); + vik_statusbar_set_message ( vw->viking_vs, VIK_STATUSBAR_INFO, msg ); + g_free ( msg ); g_error_free (error); } -- 2.39.5