[frogr] Properly report progress to the user (no more discreet progress bars)
- From: Mario Sanchez Prada <msanchez src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [frogr] Properly report progress to the user (no more discreet progress bars)
- Date: Thu, 20 Jan 2011 16:40:25 +0000 (UTC)
commit 27ed2295b418b08097297d54f56e768185526f85
Author: Mario Sanchez Prada <msanchez igalia com>
Date: Thu Jan 20 17:25:13 2011 +0100
Properly report progress to the user (no more discreet progress bars)
src/frogr-controller.c | 48 ++++++++++++++++++++++++++++++-----------
src/frogr-main-view.c | 29 +++++++++++++++---------
src/frogr-main-view.h | 8 +++---
src/frogr-picture-uploader.c | 7 ++---
4 files changed, 60 insertions(+), 32 deletions(-)
---
diff --git a/src/frogr-controller.c b/src/frogr-controller.c
index 89be02a..27728f1 100644
--- a/src/frogr-controller.c
+++ b/src/frogr-controller.c
@@ -126,6 +126,8 @@ static void _notify_error_to_user (FrogrController *self,
static void _show_auth_failed_dialog (GtkWindow *parent, const gchar *message);
+static void _data_fraction_sent_cb (FspSession *session, gdouble fraction, gpointer data);
+
static void _auth_failed_dialog_response_cb (GtkDialog *dialog, gint response, gpointer data);
static void _get_auth_url_cb (GObject *obj, GAsyncResult *res, gpointer data);
@@ -362,6 +364,18 @@ _show_auth_failed_dialog (GtkWindow *parent, const gchar *message)
}
static void
+_data_fraction_sent_cb (FspSession *session, gdouble fraction, gpointer data)
+{
+ FrogrController *self = NULL;
+ FrogrControllerPrivate *priv = NULL;
+
+ self = FROGR_CONTROLLER(data);
+ priv = FROGR_CONTROLLER_GET_PRIVATE (self);
+
+ frogr_main_view_set_progress_status_fraction (priv->mainview, fraction);
+}
+
+static void
_auth_failed_dialog_response_cb (GtkDialog *dialog, gint response, gpointer data)
{
if (response == GTK_RESPONSE_OK)
@@ -811,7 +825,10 @@ _complete_picture_upload_on_idle (gpointer data)
/* Keep the source while busy */
if (priv->adding_to_set || priv->adding_to_group)
- return TRUE;
+ {
+ frogr_main_view_pulse_progress (priv->mainview);
+ return TRUE;
+ }
picture = up_st->picture;
callback = up_st->callback;
@@ -848,8 +865,8 @@ _notify_creating_set (FrogrController *self,
gchar *progress_text = NULL;
priv = FROGR_CONTROLLER_GET_PRIVATE (self);
- frogr_main_view_set_progress_text (priv->mainview,
- _("Creating new photosetâ?¦"));
+ frogr_main_view_show_progress (priv->mainview,
+ _("Creating new photosetâ?¦"));
picture_title = frogr_picture_get_title (picture);
set_title = frogr_photoset_get_title (set);
@@ -873,8 +890,8 @@ _notify_adding_to_set (FrogrController *self,
gchar *progress_text = NULL;
priv = FROGR_CONTROLLER_GET_PRIVATE (self);
- frogr_main_view_set_progress_text (priv->mainview,
- _("Adding picture to photosetâ?¦"));
+ frogr_main_view_show_progress (priv->mainview,
+ _("Adding picture to photosetâ?¦"));
picture_title = frogr_picture_get_title (picture);
set_title = frogr_photoset_get_title (set);
@@ -896,8 +913,8 @@ _notify_adding_to_group (FrogrController *self,
gchar *progress_text = NULL;
priv = FROGR_CONTROLLER_GET_PRIVATE (self);
- frogr_main_view_set_progress_text (priv->mainview,
- _("Adding picture to groupâ?¦"));
+ frogr_main_view_show_progress (priv->mainview,
+ _("Adding picture to groupâ?¦"));
picture_title = frogr_picture_get_title (picture);
group_name = frogr_group_get_name (group);
@@ -1096,7 +1113,7 @@ _fetch_sets_cb (GObject *object, GAsyncResult *res, gpointer data)
{
current_data_set = FSP_DATA_PHOTO_SET (item->data);
current_set = frogr_photoset_new (current_data_set->title,
- current_data_set->description);
+ current_data_set->description);
frogr_photoset_set_id (current_set, current_data_set->id);
frogr_photoset_set_primary_photo_id (current_set, current_data_set->primary_photo_id);
frogr_photoset_set_n_photos (current_set, current_data_set->n_photos);
@@ -1415,7 +1432,7 @@ _show_details_dialog_on_idle (GSList *pictures)
/* Keep the source while internally busy */
if (priv->fetching_tags)
{
- frogr_main_view_set_progress_text (mainview, _("Retrieving list of tagsâ?¦"));
+ frogr_main_view_show_progress (mainview, _("Retrieving list of tagsâ?¦"));
frogr_main_view_pulse_progress (mainview);
return TRUE;
}
@@ -1448,7 +1465,7 @@ _show_add_tags_dialog_on_idle (GSList *pictures)
/* Keep the source while internally busy */
if (priv->fetching_tags)
{
- frogr_main_view_set_progress_text (mainview, _("Retrieving list of tagsâ?¦"));
+ frogr_main_view_show_progress (mainview, _("Retrieving list of tagsâ?¦"));
frogr_main_view_pulse_progress (mainview);
return TRUE;
}
@@ -1481,7 +1498,7 @@ _show_create_new_set_dialog_on_idle (GSList *pictures)
/* Keep the source while internally busy */
if (priv->fetching_sets)
{
- frogr_main_view_set_progress_text (mainview, _("Retrieving list of setsâ?¦"));
+ frogr_main_view_show_progress (mainview, _("Retrieving list of setsâ?¦"));
frogr_main_view_pulse_progress (mainview);
return TRUE;
}
@@ -1513,7 +1530,7 @@ _show_add_to_set_dialog_on_idle (GSList *pictures)
/* Keep the source while internally busy */
if (priv->fetching_sets)
{
- frogr_main_view_set_progress_text (mainview, _("Retrieving list of setsâ?¦"));
+ frogr_main_view_show_progress (mainview, _("Retrieving list of setsâ?¦"));
frogr_main_view_pulse_progress (mainview);
return TRUE;
}
@@ -1548,7 +1565,7 @@ _show_add_to_group_dialog_on_idle (GSList *pictures)
/* Keep the source while internally busy */
if (priv->fetching_groups)
{
- frogr_main_view_set_progress_text (mainview, _("Retrieving list of groupsâ?¦"));
+ frogr_main_view_show_progress (mainview, _("Retrieving list of groupsâ?¦"));
frogr_main_view_pulse_progress (mainview);
return TRUE;
}
@@ -1740,6 +1757,11 @@ frogr_controller_init (FrogrController *self)
const gchar *password = frogr_config_get_proxy_password (priv->config);
frogr_controller_set_proxy (self, host, port, username, password);
}
+
+ /* Connect to this signal to report progress to the user */
+ g_signal_connect (G_OBJECT (priv->session), "data-fraction-sent",
+ G_CALLBACK (_data_fraction_sent_cb),
+ self);
}
diff --git a/src/frogr-main-view.c b/src/frogr-main-view.c
index 19aab96..396c507 100644
--- a/src/frogr-main-view.c
+++ b/src/frogr-main-view.c
@@ -1556,8 +1556,7 @@ frogr_main_view_set_status_text (FrogrMainView *self,
}
void
-frogr_main_view_set_progress_text (FrogrMainView *self,
- const gchar *text)
+frogr_main_view_show_progress (FrogrMainView *self, const gchar *text)
{
g_return_if_fail(FROGR_IS_MAIN_VIEW (self));
@@ -1568,23 +1567,31 @@ frogr_main_view_set_progress_text (FrogrMainView *self,
}
void
-frogr_main_view_set_progress_status (FrogrMainView *self,
- double fraction,
- const gchar *text)
+frogr_main_view_set_progress_status_text (FrogrMainView *self, const gchar *text)
{
g_return_if_fail(FROGR_IS_MAIN_VIEW (self));
FrogrMainViewPrivate *priv = FROGR_MAIN_VIEW_GET_PRIVATE (self);
- /* Show the widget and set fraction */
- gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (priv->progress_bar),
- fraction);
-
/* Set superimposed text, if specified */
if (text != NULL)
gtk_progress_bar_set_text (GTK_PROGRESS_BAR (priv->progress_bar), text);
+}
- gtk_widget_show_all (GTK_WIDGET (priv->progress_dialog));
+void
+frogr_main_view_set_progress_status_fraction (FrogrMainView *self, double fraction)
+{
+ g_return_if_fail(FROGR_IS_MAIN_VIEW (self));
+
+ FrogrMainViewPrivate *priv = FROGR_MAIN_VIEW_GET_PRIVATE (self);
+
+ /* Check limits */
+ if (fraction < 0.0)
+ fraction = 0.0;
+ if (fraction > 1.0)
+ fraction = 1.0;
+
+ gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (priv->progress_bar), fraction);
}
void
@@ -1594,7 +1601,7 @@ frogr_main_view_pulse_progress (FrogrMainView *self)
FrogrMainViewPrivate *priv = FROGR_MAIN_VIEW_GET_PRIVATE (self);
- /* Show the widget and set fraction */
+ /* Show the widget and pulse */
gtk_progress_bar_pulse (GTK_PROGRESS_BAR (priv->progress_bar));
/* Empty text for this */
diff --git a/src/frogr-main-view.h b/src/frogr-main-view.h
index 7189e8a..7669457 100644
--- a/src/frogr-main-view.h
+++ b/src/frogr-main-view.h
@@ -57,11 +57,11 @@ GtkWindow *frogr_main_view_get_window (FrogrMainView *self);
void frogr_main_view_set_status_text (FrogrMainView *self, const gchar *text);
-void frogr_main_view_set_progress_text (FrogrMainView *self, const gchar *text);
+void frogr_main_view_show_progress (FrogrMainView *self, const gchar *text);
-void frogr_main_view_set_progress_status (FrogrMainView *self,
- double fraction,
- const gchar *text);
+void frogr_main_view_set_progress_status_text (FrogrMainView *self, const gchar *text);
+
+void frogr_main_view_set_progress_status_fraction (FrogrMainView *self, double fraction);
void frogr_main_view_pulse_progress (FrogrMainView *self);
diff --git a/src/frogr-picture-uploader.c b/src/frogr-picture-uploader.c
index c6ec5d5..5a22c65 100644
--- a/src/frogr-picture-uploader.c
+++ b/src/frogr-picture-uploader.c
@@ -89,10 +89,9 @@ _update_status_and_progress (FrogrPictureUploader *self)
g_free (title);
}
- frogr_main_view_set_progress_text (priv->mainview, status_text);
- frogr_main_view_set_progress_status (priv->mainview,
- (double) priv->index / priv->n_pictures,
- progress_bar_text);
+ frogr_main_view_show_progress (priv->mainview, status_text);
+ frogr_main_view_set_progress_status_text (priv->mainview, progress_bar_text);
+
/* Free */
g_free (status_text);
g_free (progress_bar_text);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]