summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--endless/eoswindow.c24
-rw-r--r--test/run-tests.h1
-rw-r--r--test/test-window.c24
3 files changed, 48 insertions, 1 deletions
diff --git a/endless/eoswindow.c b/endless/eoswindow.c
index 62345b2..7cd7f28 100644
--- a/endless/eoswindow.c
+++ b/endless/eoswindow.c
@@ -12,7 +12,22 @@
* @short_description: A window for your application
* @title: Window
*
- * Stub
+ * The #EosWindow class is where you put your application's user interface.
+ * You should create a class that extends #EosWindow.
+ *
+ * Create the interface in your window class's _init() function, like this:
+ * |[
+ * const SmokeGrinderWindow = new Lang.Class({
+ * Name: 'SmokeGrinderWindow',
+ * Extends: Endless.Window,
+ *
+ * _init(): function (props) {
+ * this.parent(props);
+ * this._button = Gtk.Button({label: 'Push me'});
+ * this.add(this._button);
+ * },
+ * });
+ * ]|
*/
G_DEFINE_TYPE (EosWindow, eos_window, GTK_TYPE_APPLICATION_WINDOW)
@@ -87,6 +102,13 @@ eos_window_class_init (EosWindowClass *klass)
object_class->get_property = eos_window_get_property;
object_class->set_property = eos_window_set_property;
+ /**
+ * EosWindow:application:
+ *
+ * The #EosApplication that this window is associated with. See also
+ * #GtkWindow:application; the difference is that #EosWindow:application
+ * cannot be %NULL and must be an #EosApplication.
+ */
eos_window_props[PROP_APPLICATION] =
g_param_spec_object ("application", "Application",
"Application associated with this window",
diff --git a/test/run-tests.h b/test/run-tests.h
index e60000f..8d18015 100644
--- a/test/run-tests.h
+++ b/test/run-tests.h
@@ -3,6 +3,7 @@
#ifndef RUN_TESTS_H
#define RUN_TESTS_H
+#define TEST_LOG_DOMAIN "EndlessSDK"
#define TEST_APPLICATION_ID "com.endlessm.example.test"
#define ADD_APP_WINDOW_TEST(path, test_func) \
diff --git a/test/test-window.c b/test/test-window.c
index b08727d..9127120 100644
--- a/test/test-window.c
+++ b/test/test-window.c
@@ -6,6 +6,10 @@
#include "run-tests.h"
+#define EXPECTED_NULL_APPLICATION_ERRMSG \
+ "In order to create a window, you must have an application for it to " \
+ "connect to."
+
static void
test_assign_application (GApplication *app)
{
@@ -17,6 +21,24 @@ test_assign_application (GApplication *app)
gtk_widget_destroy (win);
}
+static void
+test_application_not_null (GApplication *app)
+{
+ GtkWidget *win;
+
+ g_test_expect_message (TEST_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
+ EXPECTED_NULL_APPLICATION_ERRMSG);
+
+ win = eos_window_new (NULL);
+
+ g_test_assert_expected_messages ();
+
+ gtk_widget_destroy (win);
+ g_application_release (app);
+ g_application_quit (app); /* Doesn't quit when win is destroyed */
+}
+
+static void
test_screen_size (GApplication *app)
{
GtkWidget *win = eos_window_new (EOS_APPLICATION (app));
@@ -54,5 +76,7 @@ void
add_window_tests (void)
{
ADD_APP_WINDOW_TEST ("/window/assign-application", test_assign_application);
+ ADD_APP_WINDOW_TEST ("/window/application-not-null",
+ test_application_not_null);
ADD_APP_WINDOW_TEST ("/window/screen-size", test_screen_size);
}