[gnome-initial-setup] assistant: Remove assistant subclasses



commit bc6267e12bb43730dca969cca55f8e70992cfa04
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Tue Sep 24 16:42:58 2013 -0400

    assistant: Remove assistant subclasses
    
    We used to have GTK+ and Clutter-based assistants, but now that
    GtkStack is out, we can simply only have one.

 gnome-initial-setup/Makefile.am             |    3 +-
 gnome-initial-setup/gis-assistant-gtk.c     |   95 ---------------------------
 gnome-initial-setup/gis-assistant-gtk.h     |   57 ----------------
 gnome-initial-setup/gis-assistant-private.h |   38 -----------
 gnome-initial-setup/gis-assistant.c         |   41 ++++++++----
 gnome-initial-setup/gis-assistant.h         |    3 -
 gnome-initial-setup/gis-driver.c            |    4 +-
 7 files changed, 31 insertions(+), 210 deletions(-)
---
diff --git a/gnome-initial-setup/Makefile.am b/gnome-initial-setup/Makefile.am
index 6111bb8..b727563 100644
--- a/gnome-initial-setup/Makefile.am
+++ b/gnome-initial-setup/Makefile.am
@@ -14,8 +14,7 @@ libexec_PROGRAMS = gnome-initial-setup gnome-initial-setup-copy-worker
 gnome_initial_setup_SOURCES =  \
        gnome-initial-setup.c gnome-initial-setup.h \
        gis-center-container.c gis-center-container.h \
-       gis-assistant.c gis-assistant.h gis-assistant-private.h \
-       gis-assistant-gtk.c gis-assistant-gtk.h \
+       gis-assistant.c gis-assistant.h \
        gis-page.c gis-page.h \
        gis-driver.c gis-driver.h
 
diff --git a/gnome-initial-setup/gis-assistant.c b/gnome-initial-setup/gis-assistant.c
index fe20571..a9a920f 100644
--- a/gnome-initial-setup/gis-assistant.c
+++ b/gnome-initial-setup/gis-assistant.c
@@ -29,7 +29,6 @@
 #include <gtk/gtk.h>
 
 #include "gis-assistant.h"
-#include "gis-assistant-private.h"
 #include "gis-center-container.h"
 
 enum {
@@ -59,6 +58,7 @@ struct _GisAssistantPrivate
   GtkWidget *page_action_widget_area;
   GtkWidget *spinner;
   GtkWidget *titlebar;
+  GtkWidget *stack;
 
   GList *pages;
   GisPage *current_page;
@@ -92,7 +92,9 @@ gis_assistant_switch_to (GisAssistant          *assistant,
                          GisAssistantDirection  direction,
                          GisPage               *page)
 {
-  GIS_ASSISTANT_GET_CLASS (assistant)->switch_to (assistant, direction, page);
+  GisAssistantPrivate *priv = gis_assistant_get_instance_private (assistant);
+
+  gtk_stack_set_visible_child (GTK_STACK (priv->stack), GTK_WIDGET (page));
 }
 
 static void
@@ -320,7 +322,7 @@ gis_assistant_add_page (GisAssistant *assistant,
   g_signal_connect (page, "destroy", G_CALLBACK (widget_destroyed), assistant);
   g_signal_connect (page, "notify", G_CALLBACK (page_notify), assistant);
 
-  GIS_ASSISTANT_GET_CLASS (assistant)->add_page (assistant, page);
+  gtk_container_add (GTK_CONTAINER (priv->stack), GTK_WIDGET (page));
 
   if (priv->current_page->assistant_priv->link == link->prev)
     update_navigation_buttons (assistant);
@@ -382,16 +384,9 @@ gis_assistant_get_titlebar (GisAssistant *assistant)
   return priv->titlebar;
 }
 
-GtkWidget *
-_gis_assistant_get_frame (GisAssistant *assistant)
-{
-  GisAssistantPrivate *priv = gis_assistant_get_instance_private (assistant);
-  return priv->frame;
-}
-
-void
-_gis_assistant_current_page_changed (GisAssistant *assistant,
-                                     GisPage      *page)
+static void
+update_current_page (GisAssistant *assistant,
+                     GisPage      *page)
 {
   GisAssistantPrivate *priv = gis_assistant_get_instance_private (assistant);
 
@@ -409,6 +404,18 @@ _gis_assistant_current_page_changed (GisAssistant *assistant,
   gis_page_shown (page);
 }
 
+static void
+current_page_changed (GObject    *gobject,
+                      GParamSpec *pspec,
+                      gpointer    user_data)
+{
+  GisAssistant *assistant = GIS_ASSISTANT (user_data);
+  GtkStack *stack = GTK_STACK (gobject);
+  GtkWidget *new_page = gtk_stack_get_visible_child (stack);
+
+  update_current_page (assistant, GIS_PAGE (new_page));
+}
+
 void
 gis_assistant_locale_changed (GisAssistant *assistant)
 {
@@ -449,6 +456,14 @@ gis_assistant_init (GisAssistant *assistant)
   gtk_frame_set_shadow_type (GTK_FRAME (priv->frame), GTK_SHADOW_NONE);
   gtk_box_pack_start (GTK_BOX (priv->main_layout), priv->frame, TRUE, TRUE, 0);
 
+  priv->stack = gtk_stack_new ();
+  gtk_stack_set_transition_type (GTK_STACK (priv->stack),
+                                 GTK_STACK_TRANSITION_TYPE_SLIDE_LEFT_RIGHT);
+  gtk_container_add (GTK_CONTAINER (priv->frame), priv->stack);
+
+  g_signal_connect (priv->stack, "notify::visible-child",
+                    G_CALLBACK (current_page_changed), assistant);
+
   priv->page_action_widget_area = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
 
   priv->forward = gtk_button_new ();
diff --git a/gnome-initial-setup/gis-assistant.h b/gnome-initial-setup/gis-assistant.h
index ba4bdf3..625988d 100644
--- a/gnome-initial-setup/gis-assistant.h
+++ b/gnome-initial-setup/gis-assistant.h
@@ -53,9 +53,6 @@ struct _GisAssistantClass
   GtkBoxClass parent_class;
 
   void (* next_page) (GisAssistant *assistant, GisPage *page);
-
-  void (* switch_to) (GisAssistant *assistant, GisAssistantDirection direction, GisPage *page);
-  void (* add_page) (GisAssistant *assistant, GisPage *page);
 };
 
 GType gis_assistant_get_type (void);
diff --git a/gnome-initial-setup/gis-driver.c b/gnome-initial-setup/gis-driver.c
index dd1758f..0dea62b 100644
--- a/gnome-initial-setup/gis-driver.c
+++ b/gnome-initial-setup/gis-driver.c
@@ -28,7 +28,7 @@
 #include <stdlib.h>
 #include <locale.h>
 
-#include "gis-assistant-gtk.h"
+#include "gis-assistant.h"
 
 #define GIS_TYPE_DRIVER_MODE (gis_driver_mode_get_type ())
 
@@ -271,7 +271,7 @@ gis_driver_startup (GApplication *app)
                     G_CALLBACK (window_realize_cb),
                     (gpointer)app);
 
-  priv->assistant = g_object_new (GIS_TYPE_ASSISTANT_GTK, NULL);
+  priv->assistant = g_object_new (GIS_TYPE_ASSISTANT, NULL);
   gtk_container_add (GTK_CONTAINER (priv->main_window), GTK_WIDGET (priv->assistant));
 
   gtk_widget_show (GTK_WIDGET (priv->assistant));


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