[gnome-initial-setup] assistant: Split out Clutter implementation
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-initial-setup] assistant: Split out Clutter implementation
- Date: Tue, 17 Jul 2012 00:45:21 +0000 (UTC)
commit d1aee07a3e4a199317eb294ff35279c25f8fb0a5
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Mon Jul 16 19:16:48 2012 -0400
assistant: Split out Clutter implementation
gnome-initial-setup/Makefile.am | 3 +-
gnome-initial-setup/gis-assistant-clutter.c | 96 +++++++++++++++++++++++++++
gnome-initial-setup/gis-assistant-clutter.h | 41 +++++++++++
gnome-initial-setup/gis-assistant-private.h | 35 ++++++++++
gnome-initial-setup/gis-assistant.c | 45 ++++---------
gnome-initial-setup/gnome-initial-setup.c | 4 +-
gnome-initial-setup/setup.ui | 2 +-
7 files changed, 191 insertions(+), 35 deletions(-)
---
diff --git a/gnome-initial-setup/Makefile.am b/gnome-initial-setup/Makefile.am
index 945b9f4..cc40647 100644
--- a/gnome-initial-setup/Makefile.am
+++ b/gnome-initial-setup/Makefile.am
@@ -33,7 +33,8 @@ BUILT_SOURCES += setup_resources.c
gnome_initial_setup_SOURCES = \
gnome-initial-setup.c gnome-initial-setup.h \
cc-notebook.c cc-notebook.h \
- gis-assistant.c gis-assistant.h \
+ gis-assistant.c gis-assistant.h gis-assistant-private.h \
+ gis-assistant-clutter.c gis-assistant-clutter.h \
gis-utils.c gis-utils.h \
$(BUILT_SOURCES)
diff --git a/gnome-initial-setup/gis-assistant-clutter.c b/gnome-initial-setup/gis-assistant-clutter.c
new file mode 100644
index 0000000..94463a5
--- /dev/null
+++ b/gnome-initial-setup/gis-assistant-clutter.c
@@ -0,0 +1,96 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
+/*
+ * 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
+ * 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 <gtk/gtk.h>
+
+#include "gis-assistant-clutter.h"
+#include "gis-assistant-private.h"
+#include "cc-notebook.h"
+
+G_DEFINE_TYPE (GisAssistantClutter, gis_assistant_clutter, GIS_TYPE_ASSISTANT)
+
+#define GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GIS_TYPE_ASSISTANT_CLUTTER, GisAssistantClutterPrivate))
+
+struct _GisAssistantClutterPrivate
+{
+ GtkWidget *notebook;
+};
+
+static void
+current_page_changed (CcNotebook *notebook,
+ GParamSpec *pspec,
+ GisAssistant *assistant)
+{
+ GtkWidget *page = cc_notebook_get_selected_page (notebook);
+ _gis_assistant_current_page_changed (assistant, page);
+}
+
+static void
+gis_assistant_clutter_switch_to (GisAssistant *assistant, GtkWidget *widget)
+{
+ GisAssistantClutterPrivate *priv = GIS_ASSISTANT_CLUTTER (assistant)->priv;
+ cc_notebook_select_page (CC_NOTEBOOK (priv->notebook), widget, TRUE);
+}
+
+static void
+gis_assistant_clutter_add_page (GisAssistant *assistant,
+ GtkWidget *page)
+{
+ GisAssistantClutterPrivate *priv = GIS_ASSISTANT_CLUTTER (assistant)->priv;
+ cc_notebook_add_page (CC_NOTEBOOK (priv->notebook), page);
+}
+
+static void
+gis_assistant_clutter_init (GisAssistantClutter *assistant_clutter)
+{
+ GisAssistantClutterPrivate *priv = GET_PRIVATE (assistant_clutter);
+ GisAssistant *assistant = GIS_ASSISTANT (assistant_clutter);
+ GtkWidget *frame;
+
+ assistant_clutter->priv = priv;
+
+ frame = _gis_assistant_get_frame (assistant);
+ priv->notebook = cc_notebook_new ();
+ gtk_container_add (GTK_CONTAINER (frame), priv->notebook);
+
+ gtk_widget_show (priv->notebook);
+
+ g_signal_connect (priv->notebook, "notify::current-page",
+ G_CALLBACK (current_page_changed), assistant);
+}
+
+static void
+gis_assistant_clutter_class_init (GisAssistantClutterClass *klass)
+{
+ GisAssistantClass *assistant_class = GIS_ASSISTANT_CLASS (klass);
+
+ g_type_class_add_private (klass, sizeof (GisAssistantClutterPrivate));
+
+ assistant_class->add_page = gis_assistant_clutter_add_page;
+ assistant_class->switch_to = gis_assistant_clutter_switch_to;
+}
diff --git a/gnome-initial-setup/gis-assistant-clutter.h b/gnome-initial-setup/gis-assistant-clutter.h
new file mode 100644
index 0000000..99978a3
--- /dev/null
+++ b/gnome-initial-setup/gis-assistant-clutter.h
@@ -0,0 +1,41 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
+/* GIS_ASSISTANT_CLUTTER */
+/* GisAssistantClutter */
+
+#ifndef __GIS_ASSISTANT_CLUTTER_H__
+#define __GIS_ASSISTANT_CLUTTER_H__
+
+#include <glib-object.h>
+
+#include "gis-assistant.h"
+
+G_BEGIN_DECLS
+
+#define GIS_TYPE_ASSISTANT_CLUTTER (gis_assistant_clutter_get_type ())
+#define GIS_ASSISTANT_CLUTTER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIS_TYPE_ASSISTANT_CLUTTER, GisAssistantClutter))
+#define GIS_ASSISTANT_CLUTTER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIS_TYPE_ASSISTANT_CLUTTER, GisAssistantClutterClass))
+#define GIS_IS_ASSISTANT_CLUTTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIS_TYPE_ASSISTANT_CLUTTER))
+#define GIS_IS_ASSISTANT_CLUTTER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIS_TYPE_ASSISTANT_CLUTTER))
+#define GIS_ASSISTANT_CLUTTER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIS_TYPE_ASSISTANT_CLUTTER, GisAssistantClutterClass))
+
+typedef struct _GisAssistantClutter GisAssistantClutter;
+typedef struct _GisAssistantClutterClass GisAssistantClutterClass;
+typedef struct _GisAssistantClutterPrivate GisAssistantClutterPrivate;
+
+struct _GisAssistantClutter
+{
+ GisAssistant parent;
+
+ GisAssistantClutterPrivate *priv;
+};
+
+struct _GisAssistantClutterClass
+{
+ GisAssistantClass parent_class;
+};
+
+GType gis_assistant_clutter_get_type (void);
+
+G_END_DECLS
+
+#endif /* __GIS_ASSISTANT_CLUTTER_H__ */
diff --git a/gnome-initial-setup/gis-assistant-private.h b/gnome-initial-setup/gis-assistant-private.h
new file mode 100644
index 0000000..9f4c2f0
--- /dev/null
+++ b/gnome-initial-setup/gis-assistant-private.h
@@ -0,0 +1,35 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
+/*
+ * 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
+ * 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.
+ */
+
+#ifndef __GIS_ASSISTANT_PRIVATE_H__
+#define __GIS_ASSISTANT_PRIVATE_H__
+
+#include "gis-assistant.h"
+
+G_BEGIN_DECLS
+
+GtkWidget *_gis_assistant_get_frame (GisAssistant *assistant);
+
+void _gis_assistant_current_page_changed (GisAssistant *assistant,
+ GtkWidget *page);
+
+G_END_DECLS
+
+#endif /* __GIS_ASSISTANT_PRIVATE_H__ */
diff --git a/gnome-initial-setup/gis-assistant.c b/gnome-initial-setup/gis-assistant.c
index 1047f87..79efb95 100644
--- a/gnome-initial-setup/gis-assistant.c
+++ b/gnome-initial-setup/gis-assistant.c
@@ -29,7 +29,7 @@
#include <gtk/gtk.h>
#include "gis-assistant.h"
-#include "cc-notebook.h"
+#include "gis-assistant-private.h"
G_DEFINE_TYPE (GisAssistant, gis_assistant, GTK_TYPE_BOX)
@@ -46,7 +46,7 @@ typedef struct _PageData PageData;
struct _GisAssistantPrivate
{
- GtkWidget *notebook;
+ GtkWidget *frame;
GtkWidget *forward;
GtkWidget *back;
GtkWidget *main_layout;
@@ -185,13 +185,17 @@ gis_assistant_get_page_complete (GisAssistant *assistant,
return page_data->page_complete;
}
-static void
-current_page_changed (CcNotebook *notebook,
- GParamSpec *pspec,
- GisAssistant *assistant)
+GtkWidget *
+_gis_assistant_get_frame (GisAssistant *assistant)
+{
+ return assistant->priv->frame;
+}
+
+void
+_gis_assistant_current_page_changed (GisAssistant *assistant,
+ GtkWidget *page)
{
GisAssistantPrivate *priv = assistant->priv;
- GtkWidget *page = cc_notebook_get_selected_page (notebook);
PageData *page_data = get_page_data_for_page (page);
if (priv->current_page != page_data) {
@@ -209,8 +213,9 @@ gis_assistant_init (GisAssistant *assistant)
priv->main_layout = gtk_box_new (GTK_ORIENTATION_VERTICAL, 10);
gtk_box_pack_start (GTK_BOX (assistant), priv->main_layout, TRUE, TRUE, 0);
- priv->notebook = cc_notebook_new ();
- gtk_box_pack_start (GTK_BOX (priv->main_layout), priv->notebook, TRUE, TRUE, 0);
+ priv->frame = gtk_frame_new ("");
+ 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->action_area = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
gtk_box_pack_start (GTK_BOX (priv->main_layout), priv->action_area, FALSE, TRUE, 0);
@@ -228,9 +233,6 @@ gis_assistant_init (GisAssistant *assistant)
gtk_box_pack_start (GTK_BOX (priv->action_area), priv->back, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (priv->action_area), priv->forward, FALSE, FALSE, 0);
- g_signal_connect (priv->notebook, "notify::current-page",
- G_CALLBACK (current_page_changed), assistant);
-
g_signal_connect (priv->forward, "clicked",
G_CALLBACK (go_forward), assistant);
@@ -259,23 +261,6 @@ gis_assistant_finalize (GObject *gobject)
G_OBJECT_CLASS (gis_assistant_parent_class)->finalize (gobject);
}
-
-
-static void
-gis_assistant_real_switch_to (GisAssistant *assistant, GtkWidget *widget)
-{
- GisAssistantPrivate *priv = assistant->priv;
- cc_notebook_select_page (CC_NOTEBOOK (priv->notebook), widget, TRUE);
-}
-
-static void
-gis_assistant_real_add_page (GisAssistant *assistant,
- GtkWidget *page)
-{
- GisAssistantPrivate *priv = assistant->priv;
- cc_notebook_add_page (CC_NOTEBOOK (priv->notebook), page);
-}
-
static void
gis_assistant_class_init (GisAssistantClass *klass)
{
@@ -286,8 +271,6 @@ gis_assistant_class_init (GisAssistantClass *klass)
gobject_class->finalize = gis_assistant_finalize;
klass->prepare = gis_assistant_prepare;
- klass->add_page = gis_assistant_real_add_page;
- klass->switch_to = gis_assistant_real_switch_to;
/**
* GisAssistant::prepare:
diff --git a/gnome-initial-setup/gnome-initial-setup.c b/gnome-initial-setup/gnome-initial-setup.c
index 647e2ce..e96d805 100644
--- a/gnome-initial-setup/gnome-initial-setup.c
+++ b/gnome-initial-setup/gnome-initial-setup.c
@@ -12,7 +12,7 @@
#include <gtk/gtk.h>
#include <clutter-gtk/clutter-gtk.h>
-#include "gis-assistant.h"
+#include "gis-assistant-clutter.h"
#include "pages/language/gis-language-page.h"
#include "pages/eulas/gis-eula-pages.h"
@@ -159,7 +159,7 @@ main (int argc, char *argv[])
}
/* Make sure GisAssistant is initialized. */
- g_type_ensure (GIS_TYPE_ASSISTANT);
+ g_type_ensure (GIS_TYPE_ASSISTANT_CLUTTER);
setup->builder = gis_builder ("setup");
diff --git a/gnome-initial-setup/setup.ui b/gnome-initial-setup/setup.ui
index b277d3d..5b5f4c1 100644
--- a/gnome-initial-setup/setup.ui
+++ b/gnome-initial-setup/setup.ui
@@ -11,7 +11,7 @@
<property name="resizable">False</property>
<property name="window-position">center-always</property>
<child>
- <object class="GisAssistant" id="assistant">
+ <object class="GisAssistantClutter" id="assistant">
<property name="visible">True</property>
</object>
</child>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]