[gnome-initial-setup] Revert "Remove the old gd-based assistant and use GtkStack"



commit 0c27fbaaae4fce035cc9fe4fb1dc75f9cdf70414
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Fri Apr 26 12:43:51 2013 -0400

    Revert "Remove the old gd-based assistant and use GtkStack"
    
    This reverts commit b638eb2d32cf925663c52dca3b1c8bdd826f4a8f.
    
    We want to use GIS on systems with GTK+ 3.8, so just use libgd
    for now.

 configure.ac                            |    2 +-
 gnome-initial-setup/Makefile.am         |    1 +
 gnome-initial-setup/gis-assistant-gd.c  |  116 +++++++++++++++++++++++++++++++
 gnome-initial-setup/gis-assistant-gd.h  |   60 ++++++++++++++++
 gnome-initial-setup/gis-assistant-gtk.c |   54 +++++---------
 gnome-initial-setup/gis-driver.c        |   17 ++++-
 6 files changed, 213 insertions(+), 37 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index fe4520f..43b5ebb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -94,7 +94,7 @@ PKG_CHECK_MODULES(ISOCODES, iso-codes)
 AC_DEFINE_UNQUOTED([ISO_CODES_PREFIX],["`$PKG_CONFIG --variable=prefix iso-codes`"],[ISO codes prefix])
 ISO_CODES=iso-codes
 
-LIBGD_INIT([notification static])
+LIBGD_INIT([stack notification static])
 
 GLIB_VERSION_DEFINES="-DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_30 
'-DGLIB_VERSION_MAX_ALLOWED=G_ENCODE_VERSION(2,34)'"
 
diff --git a/gnome-initial-setup/Makefile.am b/gnome-initial-setup/Makefile.am
index 7668859..a38ed54 100644
--- a/gnome-initial-setup/Makefile.am
+++ b/gnome-initial-setup/Makefile.am
@@ -17,6 +17,7 @@ gnome_initial_setup_SOURCES = \
        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-gd.c gis-assistant-gd.h \
        gis-page.c gis-page.h \
        gis-driver.c gis-driver.h
 
diff --git a/gnome-initial-setup/gis-assistant-gd.c b/gnome-initial-setup/gis-assistant-gd.c
new file mode 100644
index 0000000..368605b
--- /dev/null
+++ b/gnome-initial-setup/gis-assistant-gd.c
@@ -0,0 +1,116 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
+/*
+ * Copyright (C) 2013 Red Hat
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ *
+ * Written by:
+ *     Jasper St. Pierre <jstpierre mecheye net>
+ */
+
+#include "config.h"
+
+#include <glib-object.h>
+#include <glib/gi18n.h>
+#include <libgd/gd.h>
+
+#include "gis-assistant-gd.h"
+#include "gis-assistant-private.h"
+
+G_DEFINE_TYPE (GisAssistantGd, gis_assistant_gd, GIS_TYPE_ASSISTANT)
+
+#define GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GIS_TYPE_ASSISTANT_GD, GisAssistantGdPrivate))
+
+struct _GisAssistantGdPrivate
+{
+  GtkWidget *stack;
+};
+
+static void
+current_page_changed (GObject    *gobject,
+                      GParamSpec *pspec,
+                      gpointer    user_data)
+{
+  GdStack *stack = GD_STACK (gobject);
+  GisAssistant *assistant = GIS_ASSISTANT (user_data);
+  GtkWidget *new_page = gd_stack_get_visible_child (stack);
+  _gis_assistant_current_page_changed (assistant, GIS_PAGE (new_page));
+}
+
+static void
+gis_assistant_gd_switch_to (GisAssistant          *assistant,
+                            GisAssistantDirection  direction,
+                            GisPage               *page)
+{
+  GisAssistantGdPrivate *priv = GIS_ASSISTANT_GD (assistant)->priv;
+  GdStackTransitionType transition_type;
+
+  switch (direction) {
+  case GIS_ASSISTANT_NEXT:
+    transition_type = GD_STACK_TRANSITION_TYPE_SLIDE_LEFT;
+    break;
+  case GIS_ASSISTANT_PREV:
+    transition_type = GD_STACK_TRANSITION_TYPE_SLIDE_RIGHT;
+    break;
+  default:
+    g_assert_not_reached ();
+  }
+
+  gd_stack_set_transition_type (GD_STACK (priv->stack), transition_type);
+
+  gd_stack_set_visible_child (GD_STACK (priv->stack),
+                              GTK_WIDGET (page));
+}
+
+static void
+gis_assistant_gd_add_page (GisAssistant *assistant,
+                           GisPage      *page)
+{
+  GisAssistantGdPrivate *priv = GIS_ASSISTANT_GD (assistant)->priv;
+  gtk_container_add (GTK_CONTAINER (priv->stack), GTK_WIDGET (page));
+}
+
+static void
+gis_assistant_gd_init (GisAssistantGd *assistant_gd)
+{
+  GisAssistantGdPrivate *priv = GET_PRIVATE (assistant_gd);
+  GisAssistant *assistant = GIS_ASSISTANT (assistant_gd);
+  GtkWidget *frame;
+
+  assistant_gd->priv = priv;
+
+  frame = _gis_assistant_get_frame (assistant);
+  priv->stack = gd_stack_new ();
+  gd_stack_set_transition_type (GD_STACK (priv->stack),
+                                GD_STACK_TRANSITION_TYPE_CROSSFADE);
+  gtk_container_add (GTK_CONTAINER (frame), priv->stack);
+
+  gtk_widget_show (priv->stack);
+
+  g_signal_connect (priv->stack, "notify::visible-child",
+                    G_CALLBACK (current_page_changed), assistant);
+}
+
+static void
+gis_assistant_gd_class_init (GisAssistantGdClass *klass)
+{
+  GisAssistantClass *assistant_class = GIS_ASSISTANT_CLASS (klass);
+
+  g_type_class_add_private (klass, sizeof (GisAssistantGdPrivate));
+
+  assistant_class->add_page = gis_assistant_gd_add_page;
+  assistant_class->switch_to = gis_assistant_gd_switch_to;
+}
diff --git a/gnome-initial-setup/gis-assistant-gd.h b/gnome-initial-setup/gis-assistant-gd.h
new file mode 100644
index 0000000..07f2dfd
--- /dev/null
+++ b/gnome-initial-setup/gis-assistant-gd.h
@@ -0,0 +1,60 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
+/*
+ * Copyright (C) 2013 Red Hat
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ *
+ * Written by:
+ *     Jasper St. Pierre <jstpierre mecheye net>
+ */
+
+#ifndef __GIS_ASSISTANT_GD_H__
+#define __GIS_ASSISTANT_GD_H__
+
+#include <glib-object.h>
+
+#include "gis-assistant.h"
+
+G_BEGIN_DECLS
+
+#define GIS_TYPE_ASSISTANT_GD             (gis_assistant_gd_get_type ())
+#define GIS_ASSISTANT_GD(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIS_TYPE_ASSISTANT_GD, 
GisAssistantGd))
+#define GIS_ASSISTANT_GD_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST ((klass),  GIS_TYPE_ASSISTANT_GD, 
GisAssistantGdClass))
+#define GIS_IS_ASSISTANT_GD(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIS_TYPE_ASSISTANT_GD))
+#define GIS_IS_ASSISTANT_GD_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass),   GIS_TYPE_ASSISTANT_GD))
+#define GIS_ASSISTANT_GD_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj),  GIS_TYPE_ASSISTANT_GD, 
GisAssistantGdClass))
+
+typedef struct _GisAssistantGd        GisAssistantGd;
+typedef struct _GisAssistantGdClass   GisAssistantGdClass;
+typedef struct _GisAssistantGdPrivate GisAssistantGdPrivate;
+
+struct _GisAssistantGd
+{
+  GisAssistant parent;
+
+  GisAssistantGdPrivate *priv;
+};
+
+struct _GisAssistantGdClass
+{
+  GisAssistantClass parent_class;
+};
+
+GType gis_assistant_gd_get_type (void);
+
+G_END_DECLS
+
+#endif /* __GIS_ASSISTANT_GD_H__ */
diff --git a/gnome-initial-setup/gis-assistant-gtk.c b/gnome-initial-setup/gis-assistant-gtk.c
index 33be664..aac3f99 100644
--- a/gnome-initial-setup/gis-assistant-gtk.c
+++ b/gnome-initial-setup/gis-assistant-gtk.c
@@ -1,6 +1,6 @@
 /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
 /*
- * Copyright (C) 2013 Red Hat
+ * Copyright (C) 2012 Red Hat
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as
@@ -36,51 +36,36 @@ G_DEFINE_TYPE (GisAssistantGtk, gis_assistant_gtk, GIS_TYPE_ASSISTANT)
 
 struct _GisAssistantGtkPrivate
 {
-  GtkWidget *stack;
+  GtkWidget *notebook;
 };
 
 static void
-current_page_changed (GObject    *gobject,
-                      GParamSpec *pspec,
-                      gpointer    user_data)
+current_page_changed (GtkNotebook  *notebook,
+                      GtkWidget    *new_page,
+                      gint          new_page_num,
+                      GisAssistant *assistant)
 {
-  GtkStack *stack = GTK_STACK (gobject);
-  GisAssistant *assistant = GIS_ASSISTANT (user_data);
-  GtkWidget *new_page = gtk_stack_get_visible_child (stack);
   _gis_assistant_current_page_changed (assistant, GIS_PAGE (new_page));
 }
 
 static void
 gis_assistant_gtk_switch_to (GisAssistant          *assistant,
-                            GisAssistantDirection  direction,
-                            GisPage               *page)
+                             GisAssistantDirection  direction,
+                             GisPage               *page)
 {
   GisAssistantGtkPrivate *priv = GIS_ASSISTANT_GTK (assistant)->priv;
-  GtkStackTransitionType transition_type;
-
-  switch (direction) {
-  case GIS_ASSISTANT_NEXT:
-    transition_type = GTK_STACK_TRANSITION_TYPE_SLIDE_LEFT;
-    break;
-  case GIS_ASSISTANT_PREV:
-    transition_type = GTK_STACK_TRANSITION_TYPE_SLIDE_RIGHT;
-    break;
-  default:
-    g_assert_not_reached ();
-  }
-
-  gtk_stack_set_transition_type (GTK_STACK (priv->stack), transition_type);
-
-  gtk_stack_set_visible_child (GTK_STACK (priv->stack),
-                              GTK_WIDGET (page));
+  gint page_num = gtk_notebook_page_num (GTK_NOTEBOOK (priv->notebook),
+                                         GTK_WIDGET (page));
+  gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook), page_num);
 }
 
 static void
 gis_assistant_gtk_add_page (GisAssistant *assistant,
-                           GisPage      *page)
+                            GisPage      *page)
 {
   GisAssistantGtkPrivate *priv = GIS_ASSISTANT_GTK (assistant)->priv;
-  gtk_container_add (GTK_CONTAINER (priv->stack), GTK_WIDGET (page));
+  gtk_notebook_append_page (GTK_NOTEBOOK (priv->notebook),
+                            GTK_WIDGET (page), NULL);
 }
 
 static void
@@ -93,14 +78,13 @@ gis_assistant_gtk_init (GisAssistantGtk *assistant_gtk)
   assistant_gtk->priv = priv;
 
   frame = _gis_assistant_get_frame (assistant);
-  priv->stack = gtk_stack_new ();
-  gtk_stack_set_transition_type (GTK_STACK (priv->stack),
-                                GTK_STACK_TRANSITION_TYPE_CROSSFADE);
-  gtk_container_add (GTK_CONTAINER (frame), priv->stack);
+  priv->notebook = gtk_notebook_new ();
+  gtk_notebook_set_show_tabs (GTK_NOTEBOOK (priv->notebook), FALSE);
+  gtk_container_add (GTK_CONTAINER (frame), priv->notebook);
 
-  gtk_widget_show (priv->stack);
+  gtk_widget_show (priv->notebook);
 
-  g_signal_connect (priv->stack, "notify::visible-child",
+  g_signal_connect (priv->notebook, "switch-page",
                     G_CALLBACK (current_page_changed), assistant);
 }
 
diff --git a/gnome-initial-setup/gis-driver.c b/gnome-initial-setup/gis-driver.c
index 49ca273..39886a0 100644
--- a/gnome-initial-setup/gis-driver.c
+++ b/gnome-initial-setup/gis-driver.c
@@ -28,6 +28,7 @@
 #include <stdlib.h>
 
 #include "gis-assistant-gtk.h"
+#include "gis-assistant-gd.h"
 
 #define GIS_TYPE_DRIVER_MODE (gis_driver_mode_get_type ())
 
@@ -184,6 +185,20 @@ gis_driver_get_mode (GisDriver *driver)
   return priv->mode;
 }
 
+static GType
+get_assistant_type (void)
+{
+  gboolean enable_animations;
+  g_object_get (gtk_settings_get_default (),
+                "gtk-enable-animations", &enable_animations,
+                NULL);
+
+  if (enable_animations && g_getenv ("GIS_DISABLE_GD") == NULL)
+    return GIS_TYPE_ASSISTANT_GD;
+  else
+    return GIS_TYPE_ASSISTANT_GTK;
+}
+
 static void
 gis_driver_get_property (GObject      *object,
                          guint         prop_id,
@@ -263,7 +278,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 (get_assistant_type (), 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]