[gnome-initial-setup] assistant: Add the beginnings of a GTK+ assistant
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-initial-setup] assistant: Add the beginnings of a GTK+ assistant
- Date: Tue, 17 Jul 2012 00:45:31 +0000 (UTC)
commit 55b398d69216ac384df335317d531134f593d026
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Mon Jul 16 20:15:10 2012 -0400
assistant: Add the beginnings of a GTK+ assistant
Currently, it does not size its children correctly. That will
need to be addressed.
gnome-initial-setup/Makefile.am | 1 +
gnome-initial-setup/gis-assistant-gtk.c | 99 +++++++++++++++++++++++++++++
gnome-initial-setup/gis-assistant-gtk.h | 41 ++++++++++++
gnome-initial-setup/gnome-initial-setup.c | 1 +
4 files changed, 142 insertions(+), 0 deletions(-)
---
diff --git a/gnome-initial-setup/Makefile.am b/gnome-initial-setup/Makefile.am
index 80e0981..923a10c 100644
--- a/gnome-initial-setup/Makefile.am
+++ b/gnome-initial-setup/Makefile.am
@@ -34,6 +34,7 @@ gnome_initial_setup_SOURCES = \
cc-notebook.c cc-notebook.h \
gis-assistant.c gis-assistant.h gis-assistant-private.h \
gis-assistant-clutter.c gis-assistant-clutter.h \
+ gis-assistant-gtk.c gis-assistant-gtk.h \
gis-utils.c gis-utils.h \
$(BUILT_SOURCES)
diff --git a/gnome-initial-setup/gis-assistant-gtk.c b/gnome-initial-setup/gis-assistant-gtk.c
new file mode 100644
index 0000000..ce08163
--- /dev/null
+++ b/gnome-initial-setup/gis-assistant-gtk.c
@@ -0,0 +1,99 @@
+/* -*- 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-gtk.h"
+#include "gis-assistant-private.h"
+
+G_DEFINE_TYPE (GisAssistantGtk, gis_assistant_gtk, GIS_TYPE_ASSISTANT)
+
+#define GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GIS_TYPE_ASSISTANT_GTK, GisAssistantGtkPrivate))
+
+struct _GisAssistantGtkPrivate
+{
+ GtkWidget *frame;
+};
+
+static void
+set_current_page (GisAssistant *assistant,
+ GtkWidget *new_page)
+{
+ GisAssistantGtkPrivate *priv = GIS_ASSISTANT_GTK (assistant)->priv;
+ GtkBin *bin = GTK_BIN (priv->frame);
+
+ GtkWidget *old_page = gtk_bin_get_child (bin);
+
+ if (old_page != NULL)
+ gtk_container_remove (GTK_CONTAINER (bin), old_page);
+
+ if (new_page != NULL)
+ gtk_container_add (GTK_CONTAINER (bin), new_page);
+
+ _gis_assistant_current_page_changed (assistant, new_page);
+}
+
+static void
+gis_assistant_gtk_switch_to (GisAssistant *assistant,
+ GtkWidget *widget)
+{
+ set_current_page (assistant, widget);
+}
+
+static void
+gis_assistant_gtk_add_page (GisAssistant *assistant,
+ GtkWidget *widget)
+{
+ GisAssistantGtkPrivate *priv = GIS_ASSISTANT_GTK (assistant)->priv;
+ GtkWidget *old_child = gtk_bin_get_child (GTK_BIN (priv->frame));
+
+ if (old_child == NULL)
+ set_current_page (assistant, widget);
+}
+
+static void
+gis_assistant_gtk_init (GisAssistantGtk *assistant_gtk)
+{
+ GisAssistantGtkPrivate *priv = GET_PRIVATE (assistant_gtk);
+ GisAssistant *assistant = GIS_ASSISTANT (assistant_gtk);
+
+ assistant_gtk->priv = priv;
+
+ priv->frame = _gis_assistant_get_frame (assistant);
+}
+
+static void
+gis_assistant_gtk_class_init (GisAssistantGtkClass *klass)
+{
+ GisAssistantClass *assistant_class = GIS_ASSISTANT_CLASS (klass);
+
+ g_type_class_add_private (klass, sizeof (GisAssistantGtkPrivate));
+
+ assistant_class->switch_to = gis_assistant_gtk_switch_to;
+ assistant_class->add_page = gis_assistant_gtk_add_page;
+}
diff --git a/gnome-initial-setup/gis-assistant-gtk.h b/gnome-initial-setup/gis-assistant-gtk.h
new file mode 100644
index 0000000..b9c5c06
--- /dev/null
+++ b/gnome-initial-setup/gis-assistant-gtk.h
@@ -0,0 +1,41 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
+/* GIS_ASSISTANT_GTK */
+/* GisAssistantGtk */
+
+#ifndef __GIS_ASSISTANT_GTK_H__
+#define __GIS_ASSISTANT_GTK_H__
+
+#include <glib-object.h>
+
+#include "gis-assistant.h"
+
+G_BEGIN_DECLS
+
+#define GIS_TYPE_ASSISTANT_GTK (gis_assistant_gtk_get_type ())
+#define GIS_ASSISTANT_GTK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIS_TYPE_ASSISTANT_GTK, GisAssistantGtk))
+#define GIS_ASSISTANT_GTK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIS_TYPE_ASSISTANT_GTK, GisAssistantGtkClass))
+#define GIS_IS_ASSISTANT_GTK(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIS_TYPE_ASSISTANT_GTK))
+#define GIS_IS_ASSISTANT_GTK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIS_TYPE_ASSISTANT_GTK))
+#define GIS_ASSISTANT_GTK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIS_TYPE_ASSISTANT_GTK, GisAssistantGtkClass))
+
+typedef struct _GisAssistantGtk GisAssistantGtk;
+typedef struct _GisAssistantGtkClass GisAssistantGtkClass;
+typedef struct _GisAssistantGtkPrivate GisAssistantGtkPrivate;
+
+struct _GisAssistantGtk
+{
+ GisAssistant parent;
+
+ GisAssistantGtkPrivate *priv;
+};
+
+struct _GisAssistantGtkClass
+{
+ GisAssistantClass parent_class;
+};
+
+GType gis_assistant_gtk_get_type (void);
+
+G_END_DECLS
+
+#endif /* __GIS_ASSISTANT_GTK_H__ */
diff --git a/gnome-initial-setup/gnome-initial-setup.c b/gnome-initial-setup/gnome-initial-setup.c
index 44f07ef..7e8ffb5 100644
--- a/gnome-initial-setup/gnome-initial-setup.c
+++ b/gnome-initial-setup/gnome-initial-setup.c
@@ -12,6 +12,7 @@
#include <gtk/gtk.h>
#include <clutter-gtk/clutter-gtk.h>
+#include "gis-assistant-gtk.h"
#include "gis-assistant-clutter.h"
#include "pages/language/gis-language-page.h"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]