From 024c773b54d4f2a079983967ca69e4f11df9805d Mon Sep 17 00:00:00 2001 From: Kaj-Michael Lang Date: Tue, 19 Jun 2007 16:08:21 +0300 Subject: [PATCH] Add a progress bar to the toolbar. Use the progress bar from the hildon wrappers --- src/hildon-wrappers.c | 24 +++++++++++++++++------- src/map.c | 9 +++++---- src/ui-common.c | 5 ++++- src/ui-common.h | 1 + 4 files changed, 27 insertions(+), 12 deletions(-) diff --git a/src/hildon-wrappers.c b/src/hildon-wrappers.c index eba28fd..3d6c8fa 100644 --- a/src/hildon-wrappers.c +++ b/src/hildon-wrappers.c @@ -8,7 +8,7 @@ #include #include "ui-common.h" -static _sb_sid=0; +static gint _sb_sid=0; GtkWidget *hildon_file_chooser_dialog_new(GtkWindow * parent, GtkFileChooserAction action) @@ -51,9 +51,11 @@ void hildon_banner_show_information(GtkWidget *w, void *t, gchar *text) _sb_sid=g_timeout_add(6000, status_bar_clear, NULL); } -GtkWidget *hildon_banner_show_progress(GtkWidget * widget, GtkProgressBar * bar, +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; } @@ -66,21 +68,29 @@ GtkWidget *hildon_note_new_confirmation(GtkWidget *widget, const gchar *text) GTK_BUTTONS_OK_CANCEL, text); } -void hildon_banner_set_fraction(GtkWidget * widget, gfloat tmp) +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); + g_printf("P: %f\n", fraction); } -GtkWidget *hildon_banner_show_animation(GtkWidget * widget, - const gchar * animation_name, - const gchar * text) +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; } void gtk_widget_tap_and_hold_setup(GtkWidget * a, GtkWidget * w, void *p, gint t) { + } GtkWidget *hildon_number_editor_new(gint min, gint max) diff --git a/src/map.c b/src/map.c index 7942189..7e4d3b7 100644 --- a/src/map.c +++ b/src/map.c @@ -51,6 +51,9 @@ static guint _id = 0; static gint _zoom_timeout_sid=0; static gint _map_mode=0; +guint _num_downloads=0; +guint _curr_download=0; + void map_render_paths(); void map_force_redraw(); gboolean curl_download_timeout(); @@ -716,8 +719,7 @@ gboolean map_download_idle_refresh(ProgressUpdateInfo * pui) } else { /* No more retries left - something must be wrong. */ MACRO_BANNER_SHOW_INFO(_window, - _ - ("Error in download. Check internet connection" + _("Error in download. Check internet connection" " and/or Map Repository URL Format.")); } } @@ -731,8 +733,7 @@ gboolean map_download_idle_refresh(ProgressUpdateInfo * pui) _num_downloads = _curr_download = 0; } else hildon_banner_set_fraction(HILDON_BANNER(_download_banner), - _curr_download / - (double)_num_downloads); + _curr_download / (double)_num_downloads); vprintf("%s(): return\n", __PRETTY_FUNCTION__); return FALSE; diff --git a/src/ui-common.c b/src/ui-common.c index 30d714a..b5d8b63 100644 --- a/src/ui-common.c +++ b/src/ui-common.c @@ -765,7 +765,10 @@ item = gtk_separator_tool_item_new(); gtk_toolbar_insert (GTK_TOOLBAR (_toolbar), item, -1); #ifndef WITH_HILDON - +item = gtk_tool_item_new(); +_progress_item=gtk_progress_bar_new(); +gtk_container_add(item, _progress_item); +gtk_toolbar_insert (GTK_TOOLBAR (_toolbar), item, -1); #endif } diff --git a/src/ui-common.h b/src/ui-common.h index 99a91fa..9e1d059 100644 --- a/src/ui-common.h +++ b/src/ui-common.h @@ -128,6 +128,7 @@ GtkWidget *_menu_poi_item; /* Toolbar items */ GtkWidget *_toolbar_fullscreen_item; +GtkWidget *_progress_item; /* Menu items for the "Auto-Center" submenu. */ GtkWidget *_menu_ac_latlon_item; -- 2.39.5