[frogr] Ensure progress dialog is shown only when actually fetching data
- From: Mario Sanchez Prada <msanchez src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [frogr] Ensure progress dialog is shown only when actually fetching data
- Date: Sat, 7 May 2011 15:06:33 +0000 (UTC)
commit 5fea09846c397ebbff4ed16d5c4d6c8fbd65eb4a
Author: Mario Sanchez Prada <msanchez igalia com>
Date: Sat May 7 17:02:40 2011 +0200
Ensure progress dialog is shown only when actually fetching data
src/frogr-controller.c | 51 ++++++++++++++++++++++++++++++++++++++++-------
1 files changed, 43 insertions(+), 8 deletions(-)
---
diff --git a/src/frogr-controller.c b/src/frogr-controller.c
index 575ea9e..930a456 100644
--- a/src/frogr-controller.c
+++ b/src/frogr-controller.c
@@ -114,6 +114,14 @@ typedef struct {
GError *error;
} upload_picture_st;
+typedef enum {
+ FETCHING_NOTHING,
+ FETCHING_ACCOUNT_INFO,
+ FETCHING_ACCOUNT_EXTRA_INFO,
+ FETCHING_SETS,
+ FETCHING_GROUPS,
+ FETCHING_TAGS,
+} FetchingActivity;
/* Prototypes */
@@ -197,7 +205,7 @@ static void _fetch_tags (FrogrController *self);
static void _fetch_tags_cb (GObject *object, GAsyncResult *res, gpointer data);
-static gboolean _show_progress_on_idle (const gchar *text);
+static gboolean _show_progress_on_idle (gpointer data);
static gboolean _show_details_dialog_on_idle (GSList *pictures);
@@ -1416,15 +1424,42 @@ _fetch_tags_cb (GObject *object, GAsyncResult *res, gpointer data)
}
static gboolean
-_show_progress_on_idle (const gchar *text)
+_show_progress_on_idle (gpointer data)
{
FrogrController *controller = NULL;
FrogrControllerPrivate *priv = NULL;
+ FetchingActivity activity = FETCHING_NOTHING;
+ const gchar *text = NULL;
+ gboolean show_dialog = FALSE;
controller = frogr_controller_get_instance ();
priv = FROGR_CONTROLLER_GET_PRIVATE (controller);
- frogr_main_view_show_progress (priv->mainview, text);
+ activity = GPOINTER_TO_INT (data);
+ switch (activity)
+ {
+ case FETCHING_SETS:
+ text = _("Retrieving list of setsâ?¦");
+ show_dialog = priv->fetching_tags;
+ break;
+
+ case FETCHING_GROUPS:
+ text = _("Retrieving list of groupsâ?¦");
+ show_dialog = priv->fetching_groups;
+ break;
+
+ case FETCHING_TAGS:
+ text = _("Retrieving list of tagsâ?¦");
+ show_dialog = priv->fetching_tags;
+ break;
+
+ default:
+ text = NULL;
+ }
+
+ /* Actually show the dialog, if needed */
+ if (show_dialog)
+ frogr_main_view_show_progress (priv->mainview, text);
return FALSE;
}
@@ -2028,7 +2063,7 @@ frogr_controller_show_details_dialog (FrogrController *self,
/* Fetch the tags list first if needed */
if (frogr_config_get_tags_autocompletion (priv->config) && !priv->tags_fetched)
{
- gdk_threads_add_timeout (DEFAULT_TIMEOUT, (GSourceFunc) _show_progress_on_idle, _("Retrieving list of tagsâ?¦"));
+ gdk_threads_add_timeout (DEFAULT_TIMEOUT, (GSourceFunc) _show_progress_on_idle, GINT_TO_POINTER (FETCHING_TAGS));
if (!priv->fetching_tags)
_fetch_tags (self);
}
@@ -2050,7 +2085,7 @@ frogr_controller_show_add_tags_dialog (FrogrController *self,
/* Fetch the tags list first if needed */
if (frogr_config_get_tags_autocompletion (priv->config) && !priv->tags_fetched)
{
- gdk_threads_add_timeout (DEFAULT_TIMEOUT, (GSourceFunc) _show_progress_on_idle, _("Retrieving list of tagsâ?¦"));
+ gdk_threads_add_timeout (DEFAULT_TIMEOUT, (GSourceFunc) _show_progress_on_idle, GINT_TO_POINTER (FETCHING_TAGS));
if (!priv->fetching_tags)
_fetch_tags (self);
}
@@ -2072,7 +2107,7 @@ frogr_controller_show_create_new_set_dialog (FrogrController *self,
/* Fetch the sets first if needed */
if (!priv->sets_fetched)
{
- gdk_threads_add_timeout (DEFAULT_TIMEOUT, (GSourceFunc) _show_progress_on_idle, _("Retrieving list of setsâ?¦"));
+ gdk_threads_add_timeout (DEFAULT_TIMEOUT, (GSourceFunc) _show_progress_on_idle, GINT_TO_POINTER (FETCHING_SETS));
if (!priv->fetching_sets)
_fetch_sets (self);
}
@@ -2094,7 +2129,7 @@ frogr_controller_show_add_to_set_dialog (FrogrController *self,
/* Fetch the sets first if needed */
if (!priv->sets_fetched)
{
- gdk_threads_add_timeout (DEFAULT_TIMEOUT, (GSourceFunc) _show_progress_on_idle, _("Retrieving list of setsâ?¦"));
+ gdk_threads_add_timeout (DEFAULT_TIMEOUT, (GSourceFunc) _show_progress_on_idle, GINT_TO_POINTER (FETCHING_SETS));
if (!priv->fetching_sets)
_fetch_sets (self);
}
@@ -2116,7 +2151,7 @@ frogr_controller_show_add_to_group_dialog (FrogrController *self,
/* Fetch the groups first if needed */
if (!priv->groups_fetched)
{
- gdk_threads_add_timeout (DEFAULT_TIMEOUT, (GSourceFunc) _show_progress_on_idle, _("Retrieving list of groupsâ?¦"));
+ gdk_threads_add_timeout (DEFAULT_TIMEOUT, (GSourceFunc) _show_progress_on_idle, GINT_TO_POINTER (FETCHING_GROUPS));
if (!priv->fetching_groups)
_fetch_groups (self);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]