summaryrefslogtreecommitdiff
path: root/endless
diff options
context:
space:
mode:
authormatt <mattdangerw@gmail.com>2013-05-15 00:45:06 -0700
committerMatt Watson <mattdangerw@gmail.com>2013-06-03 14:51:26 -0700
commit0a66aeb3b11841f8e4a83ffd3577a91829353983 (patch)
treef6611afb9bb6a979d1ce4715d50943ce69a51dba /endless
parent8394ee40026b12f53ca7e44458c42aadd17a1de0 (diff)
Added basic splash page manager functionality.
Splash page and main page widget properties with getters and setters. Ability to switch between the splash and main page. Added splash- page.js smoke test. [endlessm/eos-sdk#62]
Diffstat (limited to 'endless')
-rw-r--r--endless/Makefile.am2
-rw-r--r--endless/endless.h1
-rw-r--r--endless/eossplashpagemanager.c287
-rw-r--r--endless/eossplashpagemanager.h92
4 files changed, 382 insertions, 0 deletions
diff --git a/endless/Makefile.am b/endless/Makefile.am
index 48712dd..4dc9042 100644
--- a/endless/Makefile.am
+++ b/endless/Makefile.am
@@ -8,6 +8,7 @@ endless_private_installed_headers = \
endless/eosenums.h \
endless/eosmacros.h \
endless/eospagemanager.h \
+ endless/eossplashpagemanager.h \
endless/eostypes.h \
endless/eoswindow.h \
endless/eosactionbutton-private.h
@@ -18,6 +19,7 @@ endless_library_sources = \
endless/eosinit.c endless/eosinit-private.h \
endless/eospagemanager.c \
endless/eosmainarea.c endless/eosmainarea-private.h \
+ endless/eossplashpagemanager.c \
endless/eostopbar.c endless/eostopbar-private.h \
endless/eosactionbutton.c \
endless/eoswindow.c
diff --git a/endless/endless.h b/endless/endless.h
index 48778b0..6e9d46e 100644
--- a/endless/endless.h
+++ b/endless/endless.h
@@ -14,6 +14,7 @@ G_BEGIN_DECLS
#include "eostypes.h"
#include "eosapplication.h"
#include "eospagemanager.h"
+#include "eossplashpagemanager.h"
#include "eoswindow.h"
#undef _EOS_SDK_INSIDE_ENDLESS_H
diff --git a/endless/eossplashpagemanager.c b/endless/eossplashpagemanager.c
new file mode 100644
index 0000000..27057a9
--- /dev/null
+++ b/endless/eossplashpagemanager.c
@@ -0,0 +1,287 @@
+/* Copyright 2013 Endless Mobile, Inc. */
+
+#include "config.h"
+#include "eossplashpagemanager.h"
+
+#include <gtk/gtk.h>
+
+#include <string.h>
+
+/**
+ * SECTION:splash-page-manager
+ * @short_description: Add splash screen to application
+ * @title: Splash Page Manager
+ *
+ * Builds on the #EosSplashPageManager to provide an application with two pages. The
+ * first page is called the splash screen and provides a simple welcome screen
+ * with minimal user interface. Once the user complete any action needed on
+ * the splash screen page (e.g. select a file to open), they will be taken to
+ * the main screen where the main work of the application will be done.
+ *
+ * The splash screen and main page can contain any widget. Call
+ * show_main_page() and show_splash_page() to toggle between the two views.
+ * The splash screen will be shown by default until a call to show_main_page()
+ * is made.
+ */
+
+G_DEFINE_TYPE (EosSplashPageManager, eos_splash_page_manager, EOS_TYPE_PAGE_MANAGER)
+
+#define SPLASH_PAGE_MANAGER_PRIVATE(o) \
+ (G_TYPE_INSTANCE_GET_PRIVATE ((o), EOS_TYPE_SPLASH_PAGE_MANAGER, EosSplashPageManagerPrivate))
+
+struct _EosSplashPageManagerPrivate
+{
+ GtkWidget *splash_page;
+ GtkWidget *main_page;
+ gboolean main_page_shown;
+};
+
+enum
+{
+ PROP_0,
+ PROP_SPLASH_PAGE,
+ PROP_MAIN_PAGE,
+ NPROPS
+};
+
+static GParamSpec *eos_splash_page_manager_props[NPROPS] = { NULL, };
+
+static void
+eos_splash_page_manager_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ EosSplashPageManager *self = EOS_SPLASH_PAGE_MANAGER (object);
+
+ switch (property_id)
+ {
+ case PROP_SPLASH_PAGE:
+ g_value_set_object (value, eos_splash_page_manager_get_splash_page (self));
+ break;
+
+ case PROP_MAIN_PAGE:
+ g_value_set_object (value, eos_splash_page_manager_get_main_page (self));
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ }
+}
+
+static void
+eos_splash_page_manager_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ EosSplashPageManager *self = EOS_SPLASH_PAGE_MANAGER (object);
+
+ switch (property_id)
+ {
+ case PROP_SPLASH_PAGE:
+ eos_splash_page_manager_set_splash_page (self, g_value_get_object (value));
+ break;
+
+ case PROP_MAIN_PAGE:
+ eos_splash_page_manager_set_main_page (self, g_value_get_object (value));
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ }
+}
+
+static void
+eos_splash_page_manager_class_init (EosSplashPageManagerClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ g_type_class_add_private (klass, sizeof (EosSplashPageManagerPrivate));
+
+ object_class->get_property = eos_splash_page_manager_get_property;
+ object_class->set_property = eos_splash_page_manager_set_property;
+
+ /**
+ * EosSplashPageManager:splash-page:
+ *
+ * A reference to the splash page widget of the splash page manager. If no
+ * page has been set, points to null.
+ */
+ eos_splash_page_manager_props[PROP_SPLASH_PAGE] =
+ g_param_spec_object ("splash-page", "Splash page",
+ "Splash page of the splash page manager",
+ GTK_TYPE_WIDGET,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+
+ /**
+ * EosPageManager:main-page:
+ *
+ * A reference to the main page widget of the splash page manager. If no
+ * page has been set, points to null.
+ */
+ eos_splash_page_manager_props[PROP_MAIN_PAGE] =
+ g_param_spec_object ("main-page", "Main page",
+ "Main page of the splash page manager",
+ GTK_TYPE_WIDGET,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+
+ g_object_class_install_properties (object_class, NPROPS,
+ eos_splash_page_manager_props);
+}
+
+static void
+eos_splash_page_manager_init (EosSplashPageManager *self)
+{
+ self->priv = SPLASH_PAGE_MANAGER_PRIVATE (self);
+}
+
+/* Public API */
+
+/**
+ * eos_splash_page_manager_new:
+ *
+ * Creates a new default splash page manager.
+ *
+ * Returns: the new page manager.
+ */
+GtkWidget *
+eos_splash_page_manager_new (void)
+{
+ return g_object_new (EOS_TYPE_SPLASH_PAGE_MANAGER, NULL);
+}
+
+/**
+ * eos_splash_page_manager_get_splash_page:
+ * @self: the splash page manager
+ *
+ * Gets a pointer to the splash page widget. See #EosSplashPageManager:splash-
+ * page for more information.
+ *
+ * Returns: (transfer none): the page #GtkWidget, or %NULL if the splash page
+ * has not been set.
+ */
+GtkWidget *
+eos_splash_page_manager_get_splash_page (EosSplashPageManager *self)
+{
+ g_return_val_if_fail (EOS_IS_SPLASH_PAGE_MANAGER (self), NULL);
+
+ return self->priv->splash_page;
+}
+
+/**
+ * eos_splash_page_manager_set_splash_page:
+ * @self: the splash page manager
+ * @page: the splash page widget
+ *
+ * Sets the widget for the splash page. See #EosSplashPageManager:splash-page
+ * for more information.
+ */
+void
+eos_splash_page_manager_set_splash_page (EosSplashPageManager *self,
+ GtkWidget *page)
+{
+ g_return_if_fail (EOS_IS_SPLASH_PAGE_MANAGER (self));
+ g_return_if_fail (page == NULL || GTK_IS_WIDGET (page));
+ g_return_if_fail (page == NULL || gtk_widget_get_parent (page) == NULL);
+
+
+ if (self->priv->splash_page != page)
+ {
+ if (self->priv->splash_page != NULL)
+ gtk_container_remove (GTK_CONTAINER (self), self->priv->splash_page);
+ if (page != NULL)
+ {
+ gtk_container_add (GTK_CONTAINER (self), page);
+ if (!self->priv->main_page_shown)
+ eos_page_manager_set_visible_page (EOS_PAGE_MANAGER (self), page);
+ }
+ self->priv->splash_page = page;
+ g_object_notify( G_OBJECT (self), "splash-page");
+ }
+}
+
+
+/**
+ * eos_splash_page_manager_get_main_page:
+ * @self: the splash page manager
+ *
+ * Gets a pointer to the main page widget. See #EosSplashPageManager:main-page
+ * for more information.
+ *
+ * Returns: (transfer none): the page #GtkWidget, or %NULL if the main page
+ * has not been set.
+ */
+GtkWidget *
+eos_splash_page_manager_get_main_page (EosSplashPageManager *self)
+{
+ g_return_val_if_fail (EOS_IS_SPLASH_PAGE_MANAGER (self), NULL);
+
+ return self->priv->main_page;
+}
+
+/**
+ * eos_splash_page_manager_set_main_page:
+ * @self: the splash page manager
+ * @page: the main page widget
+ *
+ * Sets the widget for the main page. See #EosSplashPageManager:main-page for
+ * more information.
+ */
+void
+eos_splash_page_manager_set_main_page (EosSplashPageManager *self,
+ GtkWidget *page)
+{
+ g_return_if_fail (EOS_IS_SPLASH_PAGE_MANAGER (self));
+ g_return_if_fail (page == NULL || GTK_IS_WIDGET (page));
+ g_return_if_fail (page == NULL || gtk_widget_get_parent (page) == NULL);
+
+ if (self->priv->main_page != page)
+ {
+ if (self->priv->main_page != NULL)
+ gtk_container_remove (GTK_CONTAINER (self), self->priv->main_page);
+ if (page != NULL)
+ gtk_container_add (GTK_CONTAINER (self), page);
+ self->priv->main_page = page;
+ g_object_notify( G_OBJECT (self), "main-page");
+ }
+}
+
+/**
+ * eos_splash_page_manager_show_splash_page:
+ * @self: the splash page manager
+ *
+ * Shows the main page of the splash page manager.
+ */
+void
+eos_splash_page_manager_show_main_page (EosSplashPageManager *self)
+{
+ g_return_if_fail (EOS_IS_SPLASH_PAGE_MANAGER (self));
+ if (self->priv->main_page == NULL)
+ {
+ g_critical ("Main page is null, have you set it?");
+ return;
+ }
+ self->priv->main_page_shown = TRUE;
+ eos_page_manager_set_visible_page (EOS_PAGE_MANAGER (self), self->priv->main_page);
+}
+
+/**
+ * eos_splash_page_manager_show_splash_page:
+ * @self: the splash page manager
+ *
+ * Shows the splash page. This page is shown first by default, so this only
+ * has effect if you want to "reshow" the page after calling show_main_page.
+ */
+void
+eos_splash_page_manager_show_splash_page (EosSplashPageManager *self)
+{
+ g_return_if_fail (EOS_IS_SPLASH_PAGE_MANAGER (self));
+ if (self->priv->splash_page == NULL)
+ {
+ g_critical ("Splash page is null, have you set it?");
+ return;
+ }
+ self->priv->main_page_shown = FALSE;
+ eos_page_manager_set_visible_page (EOS_PAGE_MANAGER (self), self->priv->splash_page);
+}
diff --git a/endless/eossplashpagemanager.h b/endless/eossplashpagemanager.h
new file mode 100644
index 0000000..4e88d7d
--- /dev/null
+++ b/endless/eossplashpagemanager.h
@@ -0,0 +1,92 @@
+/* Copyright 2013 Endless Mobile, Inc. */
+
+#ifndef EOS_SPLASH_PAGE_MANAGER_H
+#define EOS_SPLASH_PAGE_MANAGER_H
+
+#if !(defined(_EOS_SDK_INSIDE_ENDLESS_H) || defined(COMPILING_EOS_SDK))
+#error "Please do not include this header file directly."
+#endif
+
+#include "eostypes.h"
+
+#include "eospagemanager.h"
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define EOS_TYPE_SPLASH_PAGE_MANAGER eos_splash_page_manager_get_type()
+
+#define EOS_SPLASH_PAGE_MANAGER(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+ EOS_TYPE_SPLASH_PAGE_MANAGER, EosSplashPageManager))
+
+#define EOS_SPLASH_PAGE_MANAGER_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST ((klass), \
+ EOS_TYPE_SPLASH_PAGE_MANAGER, EosSplashPageManagerClass))
+
+#define EOS_IS_SPLASH_PAGE_MANAGER(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+ EOS_TYPE_SPLASH_PAGE_MANAGER))
+
+#define EOS_IS_SPLASH_PAGE_MANAGER_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE ((klass), \
+ EOS_TYPE_SPLASH_PAGE_MANAGER))
+
+#define EOS_SPLASH_PAGE_MANAGER_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS ((obj), \
+ EOS_TYPE_SPLASH_PAGE_MANAGER, EosSplashPageManagerClass))
+
+typedef struct _EosSplashPageManager EosSplashPageManager;
+typedef struct _EosSplashPageManagerClass EosSplashPageManagerClass;
+typedef struct _EosSplashPageManagerPrivate EosSplashPageManagerPrivate;
+
+/**
+ * EosSplashPageManager:
+ *
+ * This structure contains no public members.
+ */
+struct _EosSplashPageManager
+{
+ EosPageManager parent;
+
+ EosSplashPageManagerPrivate *priv;
+};
+
+struct _EosSplashPageManagerClass
+{
+ EosPageManagerClass parent_class;
+
+ /* For further expansion */
+ gpointer _padding[8];
+};
+
+EOS_SDK_ALL_API_VERSIONS
+GType eos_splash_page_manager_get_type (void) G_GNUC_CONST;
+
+EOS_SDK_ALL_API_VERSIONS
+GtkWidget *eos_splash_page_manager_new (void);
+
+EOS_SDK_ALL_API_VERSIONS
+GtkWidget *eos_splash_page_manager_get_splash_page (EosSplashPageManager *self);
+
+EOS_SDK_ALL_API_VERSIONS
+void eos_splash_page_manager_set_splash_page (EosSplashPageManager *self,
+ GtkWidget *page);
+
+EOS_SDK_ALL_API_VERSIONS
+GtkWidget *eos_splash_page_manager_get_main_page (EosSplashPageManager *self);
+
+EOS_SDK_ALL_API_VERSIONS
+void eos_splash_page_manager_set_main_page (EosSplashPageManager *self,
+ GtkWidget *page);
+
+EOS_SDK_ALL_API_VERSIONS
+void eos_splash_page_manager_show_main_page (EosSplashPageManager *self);
+
+EOS_SDK_ALL_API_VERSIONS
+void eos_splash_page_manager_show_splash_page (EosSplashPageManager *self);
+
+G_END_DECLS
+
+#endif /* EOS_SPLASH_PAGE_MANAGER_H */