[gnome-initial-setup] gnome-initial-setup: Only destroy and recreate pages after the current one



commit d9c0b9e91e15c9c522386c89313e36610231a2a4
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Wed Feb 13 16:01:31 2013 -0500

    gnome-initial-setup: Only destroy and recreate pages after the current one
    
    This ensures that we don't go back to the welcome page when the locale
    is changed.

 gnome-initial-setup/gis-assistant.c       |   24 ++++++-----------
 gnome-initial-setup/gis-assistant.h       |    3 +-
 gnome-initial-setup/gnome-initial-setup.c |   39 ++++++++++++++++++++++++++--
 3 files changed, 47 insertions(+), 19 deletions(-)
---
diff --git a/gnome-initial-setup/gis-assistant.c b/gnome-initial-setup/gis-assistant.c
index 8888535..edadcf1 100644
--- a/gnome-initial-setup/gis-assistant.c
+++ b/gnome-initial-setup/gis-assistant.c
@@ -218,24 +218,18 @@ gis_assistant_add_page (GisAssistant *assistant,
     update_navigation_buttons (assistant);
 }
 
-void
-gis_assistant_destroy_all_pages (GisAssistant *assistant)
+GisPage *
+gis_assistant_get_current_page (GisAssistant *assistant)
 {
   GisAssistantPrivate *priv = assistant->priv;
-  GList *l, *next;
-
-  g_object_freeze_notify (G_OBJECT (assistant));
-
-  for (l = priv->pages; l != NULL; l = next)
-    {
-      GisPage *page = l->data;
-      next = l->next;
-      gtk_widget_destroy (GTK_WIDGET (page));
-    }
-
-  g_object_thaw_notify (G_OBJECT (assistant));
+  return priv->current_page;
+}
 
-  g_assert (priv->pages == NULL);
+GList *
+gis_assistant_get_all_pages (GisAssistant *assistant)
+{
+  GisAssistantPrivate *priv = assistant->priv;
+  return priv->pages;
 }
 
 static void
diff --git a/gnome-initial-setup/gis-assistant.h b/gnome-initial-setup/gis-assistant.h
index f5549f9..8e28d3c 100644
--- a/gnome-initial-setup/gis-assistant.h
+++ b/gnome-initial-setup/gis-assistant.h
@@ -64,7 +64,8 @@ void      gis_assistant_add_page          (GisAssistant *assistant,
 
 void      gis_assistant_next_page         (GisAssistant *assistant);
 void      gis_assistant_previous_page     (GisAssistant *assistant);
-void      gis_assistant_destroy_all_pages (GisAssistant *assistant);
+GisPage * gis_assistant_get_current_page  (GisAssistant *assistant);
+GList   * gis_assistant_get_all_pages     (GisAssistant *assistant);
 gchar *   gis_assistant_get_title         (GisAssistant *assistant);
 
 void      gis_assistant_locale_changed    (GisAssistant *assistant);
diff --git a/gnome-initial-setup/gnome-initial-setup.c b/gnome-initial-setup/gnome-initial-setup.c
index 0af5e4a..81cca3e 100644
--- a/gnome-initial-setup/gnome-initial-setup.c
+++ b/gnome-initial-setup/gnome-initial-setup.c
@@ -136,19 +136,52 @@ pages_to_skip_from_file (void)
 }
 
 static void
+destroy_pages_after (GisAssistant *assistant,
+                     GisPage      *page)
+{
+  GList *pages, *l, *next;
+
+  pages = gis_assistant_get_all_pages (assistant);
+
+  for (l = pages; l != NULL; l = l->next)
+    if (l->data == page)
+      break;
+
+  l = l->next;
+  for (; l != NULL; l = next) {
+    next = l->next;
+    gtk_widget_destroy (GTK_WIDGET (l->data));
+  }
+}
+
+static void
 rebuild_pages_cb (GisDriver *driver)
 {
   PageData *page_data;
+  GisAssistant *assistant;
+  GisPage *current_page;
   gchar **skip_pages;
 
-  gis_assistant_destroy_all_pages (gis_driver_get_assistant (driver));
+  assistant = gis_driver_get_assistant (driver);
+  current_page = gis_assistant_get_current_page (assistant);
 
   skip_pages = pages_to_skip_from_file ();
 
-  for (page_data = page_table; page_data->page_id != NULL; ++page_data) {
+  page_data = page_table;
+
+  if (current_page != NULL) {
+    destroy_pages_after (assistant, current_page);
+
+    for (page_data = page_table; page_data->page_id != NULL; ++page_data)
+      if (g_str_equal (page_data->page_id, GIS_PAGE_GET_CLASS (current_page)->page_id))
+        break;
+
+    ++page_data;
+  }
+
+  for (; page_data->page_id != NULL; ++page_data)
     if (!should_skip_page (driver, page_data->page_id, skip_pages))
       page_data->prepare_page_func (driver);
-  }
 
   g_strfreev (skip_pages);
 }


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