[frogr] Fixed weird bug making progress bar dialogs dissapear when changing across different desktops after



commit 92cb3ccd593c8ae490f94e7a67896c14af63ae09
Author: Mario Sanchez Prada <msanchez igalia com>
Date:   Thu Jan 20 20:34:27 2011 +0100

    Fixed weird bug making progress bar dialogs dissapear when changing
    across different desktops after the first upload.

 src/frogr-controller.c       |   41 ++++++++++++++++++++++++-----------------
 src/frogr-main-view.c        |   20 +++++++++++++++-----
 src/frogr-main-view.h        |    2 ++
 src/frogr-picture-uploader.c |   16 ++++++++--------
 4 files changed, 49 insertions(+), 30 deletions(-)
---
diff --git a/src/frogr-controller.c b/src/frogr-controller.c
index afbeab7..1655730 100644
--- a/src/frogr-controller.c
+++ b/src/frogr-controller.c
@@ -871,8 +871,7 @@ _notify_creating_set (FrogrController *self,
   gchar *progress_text = NULL;
 
   priv = FROGR_CONTROLLER_GET_PRIVATE (self);
-  frogr_main_view_show_progress (priv->mainview,
-                                 _("Creating new photosetâ?¦"));
+  frogr_main_view_set_progress_description (priv->mainview, _("Creating new photosetâ?¦"));
 
   picture_title = frogr_picture_get_title (picture);
   set_title = frogr_photoset_get_title (set);
@@ -896,8 +895,7 @@ _notify_adding_to_set (FrogrController *self,
   gchar *progress_text = NULL;
 
   priv = FROGR_CONTROLLER_GET_PRIVATE (self);
-  frogr_main_view_show_progress (priv->mainview,
-                                 _("Adding picture to photosetsâ?¦"));
+  frogr_main_view_set_progress_description(priv->mainview, _("Adding picture to photosetsâ?¦"));
 
   picture_title = frogr_picture_get_title (picture);
   set_title = frogr_photoset_get_title (set);
@@ -919,8 +917,7 @@ _notify_adding_to_group (FrogrController *self,
   gchar *progress_text = NULL;
 
   priv = FROGR_CONTROLLER_GET_PRIVATE (self);
-  frogr_main_view_show_progress (priv->mainview,
-                                 _("Adding picture to groupsâ?¦"));
+  frogr_main_view_set_progress_description(priv->mainview, _("Adding picture to groupsâ?¦"));
 
   picture_title = frogr_picture_get_title (picture);
   group_name = frogr_group_get_name (group);
@@ -1389,7 +1386,6 @@ _show_details_dialog_on_idle (GSList *pictures)
   /* Keep the source while internally busy */
   if (priv->fetching_tags)
     {
-      frogr_main_view_show_progress (mainview, _("Retrieving list of tagsâ?¦"));
       frogr_main_view_pulse_progress (mainview);
       return TRUE;
     }
@@ -1422,7 +1418,6 @@ _show_add_tags_dialog_on_idle (GSList *pictures)
   /* Keep the source while internally busy */
   if (priv->fetching_tags)
     {
-      frogr_main_view_show_progress (mainview, _("Retrieving list of tagsâ?¦"));
       frogr_main_view_pulse_progress (mainview);
       return TRUE;
     }
@@ -1455,7 +1450,6 @@ _show_create_new_set_dialog_on_idle (GSList *pictures)
   /* Keep the source while internally busy */
   if (priv->fetching_sets)
     {
-      frogr_main_view_show_progress (mainview, _("Retrieving list of setsâ?¦"));
       frogr_main_view_pulse_progress (mainview);
       return TRUE;
     }
@@ -1487,7 +1481,6 @@ _show_add_to_set_dialog_on_idle (GSList *pictures)
   /* Keep the source while internally busy */
   if (priv->fetching_sets)
     {
-      frogr_main_view_show_progress (mainview, _("Retrieving list of setsâ?¦"));
       frogr_main_view_pulse_progress (mainview);
       return TRUE;
     }
@@ -1522,7 +1515,6 @@ _show_add_to_group_dialog_on_idle (GSList *pictures)
   /* Keep the source while internally busy */
   if (priv->fetching_groups)
     {
-      frogr_main_view_show_progress (mainview, _("Retrieving list of groupsâ?¦"));
       frogr_main_view_pulse_progress (mainview);
       return TRUE;
     }
@@ -1759,7 +1751,7 @@ frogr_controller_run_app (FrogrController *self)
   priv->app_running = TRUE;
 
   /* Try to pre-fetch some data from the server right after launch */
-  _fetch_everything (self);
+  /* _fetch_everything (self); */
 
   /* Start on idle state */
   _set_state (self, FROGR_STATE_IDLE);
@@ -1968,7 +1960,10 @@ frogr_controller_show_details_dialog (FrogrController *self,
 
   /* Fetch the tags list first if needed */
   if (frogr_main_view_model_n_tags (mainview_model) == 0 && !priv->tags_fetched)
-    _fetch_tags (self);
+    {
+      frogr_main_view_show_progress (priv->mainview, _("Retrieving list of tagsâ?¦"));
+      _fetch_tags (self);
+    }
 
   /* Show the dialog when possible */
   gdk_threads_add_timeout (DEFAULT_TIMEOUT, (GSourceFunc) _show_details_dialog_on_idle, pictures);
@@ -1988,7 +1983,10 @@ frogr_controller_show_add_tags_dialog (FrogrController *self,
 
   /* Fetch the tags list first if needed */
   if (frogr_main_view_model_n_tags (mainview_model) == 0 && !priv->tags_fetched)
-    _fetch_tags (self);
+    {
+      frogr_main_view_show_progress (priv->mainview, _("Retrieving list of tagsâ?¦"));
+      _fetch_tags (self);
+    }
 
   /* Show the dialog when possible */
   gdk_threads_add_timeout (DEFAULT_TIMEOUT, (GSourceFunc) _show_add_tags_dialog_on_idle, pictures);
@@ -2008,7 +2006,10 @@ frogr_controller_show_create_new_set_dialog (FrogrController *self,
 
   /* Fetch the sets first if needed */
   if (frogr_main_view_model_n_sets (mainview_model) == 0 && !priv->sets_fetched)
-    _fetch_sets (self);
+    {
+      frogr_main_view_show_progress (priv->mainview, _("Retrieving list of setsâ?¦"));
+      _fetch_sets (self);
+    }
 
   /* Show the dialog when possible */
   gdk_threads_add_timeout (DEFAULT_TIMEOUT, (GSourceFunc) _show_create_new_set_dialog_on_idle, pictures);
@@ -2028,7 +2029,10 @@ frogr_controller_show_add_to_set_dialog (FrogrController *self,
 
   /* Fetch the sets first if needed */
   if (frogr_main_view_model_n_sets (mainview_model) == 0 && !priv->sets_fetched)
-    _fetch_sets (self);
+    {
+      frogr_main_view_show_progress (priv->mainview, _("Retrieving list of setsâ?¦"));
+      _fetch_sets (self);
+    }
 
   /* Show the dialog when possible */
   gdk_threads_add_timeout (DEFAULT_TIMEOUT, (GSourceFunc) _show_add_to_set_dialog_on_idle, pictures);
@@ -2048,7 +2052,10 @@ frogr_controller_show_add_to_group_dialog (FrogrController *self,
 
   /* Fetch the groups first if needed */
   if (frogr_main_view_model_n_groups (mainview_model) == 0 && !priv->groups_fetched)
-    _fetch_groups (self);
+    {
+      frogr_main_view_show_progress (priv->mainview, _("Retrieving list of groupsâ?¦"));
+      _fetch_groups (self);
+    }
 
   /* Show the dialog when possible */
   gdk_threads_add_timeout (DEFAULT_TIMEOUT, (GSourceFunc) _show_add_to_group_dialog_on_idle, pictures);
diff --git a/src/frogr-main-view.c b/src/frogr-main-view.c
index ac618c0..68903dd 100644
--- a/src/frogr-main-view.c
+++ b/src/frogr-main-view.c
@@ -1559,9 +1559,23 @@ frogr_main_view_show_progress (FrogrMainView *self, const gchar *text)
   g_return_if_fail(FROGR_IS_MAIN_VIEW (self));
 
   FrogrMainViewPrivate *priv = FROGR_MAIN_VIEW_GET_PRIVATE (self);
-  gtk_label_set_text (GTK_LABEL (priv->progress_label), text);
+
+  /* Reset values */
+  gtk_label_set_text (GTK_LABEL (priv->progress_label), text ? text : "");
+  gtk_progress_bar_set_text (GTK_PROGRESS_BAR (priv->progress_bar), "");
+  gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (priv->progress_bar), 0.0);
 
   gtk_widget_show_all (GTK_WIDGET (priv->progress_dialog));
+  /* gtk_window_present (GTK_WINDOW (priv->progress_dialog)); */
+}
+
+void
+frogr_main_view_set_progress_description (FrogrMainView *self, const gchar *text)
+{
+  g_return_if_fail(FROGR_IS_MAIN_VIEW (self));
+
+  FrogrMainViewPrivate *priv = FROGR_MAIN_VIEW_GET_PRIVATE (self);
+  gtk_label_set_text (GTK_LABEL (priv->progress_label), text);
 }
 
 void
@@ -1574,8 +1588,6 @@ frogr_main_view_set_progress_status_text (FrogrMainView *self, const gchar *text
   /* 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
@@ -1592,8 +1604,6 @@ frogr_main_view_set_progress_status_fraction (FrogrMainView *self, double fracti
     fraction = 1.0;
 
   gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (priv->progress_bar), fraction);
-
-  gtk_widget_show_all (GTK_WIDGET (priv->progress_dialog));
 }
 
 void
diff --git a/src/frogr-main-view.h b/src/frogr-main-view.h
index 7669457..75a28cf 100644
--- a/src/frogr-main-view.h
+++ b/src/frogr-main-view.h
@@ -59,6 +59,8 @@ void frogr_main_view_set_status_text (FrogrMainView *self, const gchar *text);
 
 void frogr_main_view_show_progress (FrogrMainView *self, const gchar *text);
 
+void frogr_main_view_set_progress_description (FrogrMainView *self, 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);
diff --git a/src/frogr-picture-uploader.c b/src/frogr-picture-uploader.c
index e35dec4..59993de 100644
--- a/src/frogr-picture-uploader.c
+++ b/src/frogr-picture-uploader.c
@@ -73,8 +73,8 @@ _update_status_and_progress (FrogrPictureUploader *self)
   FrogrPictureUploaderPrivate *priv =
     FROGR_PICTURE_UPLOADER_GET_PRIVATE (self);
 
+  gchar *description = NULL;
   gchar *status_text = NULL;
-  gchar *progress_bar_text = NULL;
 
   if (priv->current)
     {
@@ -82,19 +82,18 @@ _update_status_and_progress (FrogrPictureUploader *self)
       gchar *title = g_strdup (frogr_picture_get_title (picture));
 
       /* Update progress */
-      status_text = g_strdup_printf (_("Uploading '%s'â?¦"), title);
-      progress_bar_text = g_strdup_printf ("%d / %d",
+      description = g_strdup_printf (_("Uploading '%s'â?¦"), title);
+      status_text = g_strdup_printf ("%d / %d",
                                            priv->index + 1,
                                            priv->n_pictures);
       g_free (title);
     }
-
-  frogr_main_view_show_progress (priv->mainview, status_text);
-  frogr_main_view_set_progress_status_text (priv->mainview, progress_bar_text);
+  frogr_main_view_set_progress_description(priv->mainview, description);
+  frogr_main_view_set_progress_status_text (priv->mainview, status_text);
 
   /* Free */
+  g_free (description);
   g_free (status_text);
-  g_free (progress_bar_text);
 }
 
 static void
@@ -256,7 +255,8 @@ frogr_picture_uploader_upload (FrogrPictureUploader *self)
   if (priv->pictures == NULL)
     return;
 
-  /* Update status and progress bars */
+  /* Update status and show progress bars */
+  frogr_main_view_show_progress (priv->mainview, NULL);
   _update_status_and_progress (self);
 
   /* Trigger the asynchronous process */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]