From 7e9ffb6b095fff756dec717f337e6a6aa42dd208 Mon Sep 17 00:00:00 2001 From: "P. F. Chimento" Date: Mon, 22 Apr 2013 13:43:11 +0200 Subject: Rename C source and header files For consistency with GTK, blah.[ch] should be named eosblah.[ch]. [#23] --- docs/reference/endless/Makefile.am | 2 +- endless/Makefile.am | 20 ++--- endless/apiversion.h | 12 --- endless/application.c | 165 ------------------------------------- endless/application.h | 70 ---------------- endless/endless.h | 6 +- endless/enums.h | 12 --- endless/eosapplication.c | 165 +++++++++++++++++++++++++++++++++++++ endless/eosapplication.h | 70 ++++++++++++++++ endless/eosenums.h | 12 +++ endless/eoshello.c | 70 ++++++++++++++++ endless/eosinit-private.h | 14 ++++ endless/eosinit.c | 53 ++++++++++++ endless/eosmacros.h | 12 +++ endless/eostypes.h | 18 ++++ endless/eosversion.h | 12 +++ endless/eoswindow.c | 121 +++++++++++++++++++++++++++ endless/eoswindow.h | 71 ++++++++++++++++ endless/hello.c | 70 ---------------- endless/init-private.h | 14 ---- endless/init.c | 53 ------------ endless/macros.h | 12 --- endless/types.h | 18 ---- endless/window.c | 121 --------------------------- endless/window.h | 71 ---------------- test/test-init.c | 2 +- 26 files changed, 633 insertions(+), 633 deletions(-) delete mode 100644 endless/apiversion.h delete mode 100644 endless/application.c delete mode 100644 endless/application.h delete mode 100644 endless/enums.h create mode 100644 endless/eosapplication.c create mode 100644 endless/eosapplication.h create mode 100644 endless/eosenums.h create mode 100644 endless/eoshello.c create mode 100644 endless/eosinit-private.h create mode 100644 endless/eosinit.c create mode 100644 endless/eosmacros.h create mode 100644 endless/eostypes.h create mode 100644 endless/eosversion.h create mode 100644 endless/eoswindow.c create mode 100644 endless/eoswindow.h delete mode 100644 endless/hello.c delete mode 100644 endless/init-private.h delete mode 100644 endless/init.c delete mode 100644 endless/macros.h delete mode 100644 endless/types.h delete mode 100644 endless/window.c delete mode 100644 endless/window.h diff --git a/docs/reference/endless/Makefile.am b/docs/reference/endless/Makefile.am index a207921..5ac1019 100644 --- a/docs/reference/endless/Makefile.am +++ b/docs/reference/endless/Makefile.am @@ -48,7 +48,7 @@ EXTRA_HFILES= # Header files or dirs to ignore when scanning. Use base file/dir names # e.g. IGNORE_HFILES=gtkdebug.h gtkintl.h private_code -IGNORE_HFILES=$(top_srcdir)/endless/init-private.h +IGNORE_HFILES=$(top_srcdir)/endless/eosinit-private.h # Images to copy into HTML directory. # e.g. HTML_IMAGES=$(top_srcdir)/gtk/stock-icons/stock_about_24.png diff --git a/endless/Makefile.am b/endless/Makefile.am index 583ca74..cb5a259 100644 --- a/endless/Makefile.am +++ b/endless/Makefile.am @@ -3,18 +3,18 @@ endless_public_installed_headers = endless/endless.h endless_private_installed_headers = \ - endless/apiversion.h \ - endless/application.h \ - endless/enums.h \ - endless/macros.h \ - endless/types.h \ - endless/window.h + endless/eosversion.h \ + endless/eosapplication.h \ + endless/eosenums.h \ + endless/eosmacros.h \ + endless/eostypes.h \ + endless/eoswindow.h endless_library_sources = \ - endless/application.c \ - endless/hello.c \ - endless/init.c endless/init-private.h \ - endless/window.c + endless/eosapplication.c \ + endless/eoshello.c \ + endless/eosinit.c endless/eosinit-private.h \ + endless/eoswindow.c # Endless GUI library lib_LTLIBRARIES = libendless-@EOS_SDK_API_VERSION@.la diff --git a/endless/apiversion.h b/endless/apiversion.h deleted file mode 100644 index 5b9b292..0000000 --- a/endless/apiversion.h +++ /dev/null @@ -1,12 +0,0 @@ -/* Copyright 2013 Endless Mobile, Inc. */ - -#if !(defined(_EOS_SDK_INSIDE_ENDLESS_H) || defined(COMPILING_EOS_SDK)) -#error "Please do not include this header file directly." -#endif - -#ifndef API_VERSION_H -#define API_VERSION_H - -#define EOS_SDK_ALL_API_VERSIONS - -#endif /* API_VERSION_H */ diff --git a/endless/application.c b/endless/application.c deleted file mode 100644 index ef93e13..0000000 --- a/endless/application.c +++ /dev/null @@ -1,165 +0,0 @@ -/* Copyright 2013 Endless Mobile, Inc. */ - -#include "config.h" -#include "application.h" - -#include - -#include "window.h" - -/** - * SECTION:application - * @short_description: Start here with your application - * @title: Applications - * - * The #EosApplication class is where you start when programming your - * application. - * You should create a class that extends #EosApplication. - * - * You also need to think up an application ID. - * This takes the form of a reverse domain name, and it should be unique. - * This ID is used to make sure that only one copy of your application is - * running at any time; if a user tries to start a second copy, then the first - * copy is brought to the front. - * - * To set up your application's data and window, override the - * #GApplication::startup function, like this example do-nothing application, - * Smoke Grinder: - * |[ - * const Lang = imports.lang; - * const Endless = imports.gi.Endless; - * - * const SmokeGrinder = new Lang.Class ({ - * Name: 'SmokeGrinder', - * Extends: Endless.Application, - * - * vfunc_startup: function() { - * this.parent(); - * this._window = new Endless.Window({application: this}); - * this._window.show_all(); - * }, - * }); - * - * let app = new SmokeGrinder({ application_id: "com.example.smokegrinder", - * flags: 0 }); - * app.run(ARGV); - * ]| - */ - -G_DEFINE_TYPE (EosApplication, eos_application, GTK_TYPE_APPLICATION) - -#define APPLICATION_PRIVATE(o) \ - (G_TYPE_INSTANCE_GET_PRIVATE ((o), EOS_TYPE_APPLICATION, EosApplicationPrivate)) - -struct _EosApplicationPrivate -{ - EosWindow *main_application_window; -}; - -static void -eos_application_activate (GApplication *application) -{ - EosApplication *self = EOS_APPLICATION (application); - - G_APPLICATION_CLASS (eos_application_parent_class)->activate (application); - - /* Raise the main application window if it is iconified. This behavior will - be default in GTK at some future point, in which case the following - paragraph can be removed. */ - if (self->priv->main_application_window) - { - gtk_window_present (GTK_WINDOW (self->priv->main_application_window)); - } - - /* TODO: Should it be required to override activate() as in GApplication? */ -} - -static void -eos_application_window_added (GtkApplication *application, - GtkWindow *window) -{ - EosApplication *self = EOS_APPLICATION (application); - - GTK_APPLICATION_CLASS (eos_application_parent_class)->window_added ( - application, window); - - /* If the new window is an EosWindow, then it is our main application window; - it should be raised when the application is activated */ - if (EOS_IS_WINDOW (window)) - { - if (self->priv->main_application_window != NULL) - { - g_error ("You should not add more than one application window."); - } - g_object_ref (window); - self->priv->main_application_window = EOS_WINDOW (window); - } -} - -static void -eos_application_window_removed (GtkApplication *application, - GtkWindow *window) -{ - EosApplication *self = EOS_APPLICATION (application); - - GTK_APPLICATION_CLASS (eos_application_parent_class)->window_removed ( - application, window); - - if (EOS_IS_WINDOW (window)) - { - if (self->priv->main_application_window == NULL) - { - g_warning ("EosWindow is being removed from EosApplication, although " - "none was added."); - return; - } - if (self->priv->main_application_window != EOS_WINDOW (window)) - g_warning ("A different EosWindow is being removed from EosApplication " - "than the one that was added."); - g_object_unref (window); - self->priv->main_application_window = NULL; - } -} - -static void -eos_application_class_init (EosApplicationClass *klass) -{ - GApplicationClass *g_application_class = G_APPLICATION_CLASS (klass); - GtkApplicationClass *gtk_application_class = GTK_APPLICATION_CLASS (klass); - - g_type_class_add_private (klass, sizeof (EosApplicationPrivate)); - - g_application_class->activate = eos_application_activate; - gtk_application_class->window_added = eos_application_window_added; - gtk_application_class->window_removed = eos_application_window_removed; -} - -static void -eos_application_init (EosApplication *self) -{ - self->priv = APPLICATION_PRIVATE (self); -} - -/* Public API */ - -/** - * eos_application_new: - * @application_id: a unique identifier for the application, for example a - * reverse domain name. - * @flags: flags to apply to the application; see #GApplicationFlags. - * - * Create a new application. For the application ID, use a reverse domain name, - * such as com.endlessm.weather. See g_application_id_is_valid() - * for the full rules for application IDs. - * - * Returns: a pointer to the application. - */ -EosApplication * -eos_application_new (const gchar *application_id, - GApplicationFlags flags) -{ - return g_object_new (EOS_TYPE_APPLICATION, - "application-id", application_id, - "flags", flags, - NULL); -} diff --git a/endless/application.h b/endless/application.h deleted file mode 100644 index 5089c12..0000000 --- a/endless/application.h +++ /dev/null @@ -1,70 +0,0 @@ -/* Copyright 2013 Endless Mobile, Inc. */ - -#if !(defined(_EOS_SDK_INSIDE_ENDLESS_H) || defined(COMPILING_EOS_SDK)) -#error "Please do not include this header file directly." -#endif - -#ifndef EOS_APPLICATION_H -#define EOS_APPLICATION_H - -#include "types.h" - -#include - -#define EOS_TYPE_APPLICATION eos_application_get_type() - -#define EOS_APPLICATION(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ - EOS_TYPE_APPLICATION, EosApplication)) - -#define EOS_APPLICATION_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST ((klass), \ - EOS_TYPE_APPLICATION, EosApplicationClass)) - -#define EOS_IS_APPLICATION(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \ - EOS_TYPE_APPLICATION)) - -#define EOS_IS_APPLICATION_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE ((klass), \ - EOS_TYPE_APPLICATION)) - -#define EOS_APPLICATION_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS ((obj), \ - EOS_TYPE_APPLICATION, EosApplicationClass)) - -typedef struct _EosApplication EosApplication; -typedef struct _EosApplicationClass EosApplicationClass; -typedef struct _EosApplicationPrivate EosApplicationPrivate; - -/** - * EosApplication: - * - * This class structure contains no public members. - */ -struct _EosApplication -{ - /*< private >*/ - GtkApplication parent; - - EosApplicationPrivate *priv; -}; - -struct _EosApplicationClass -{ - GtkApplicationClass parent_class; - - /* For further expansion */ - gpointer _padding[8]; -}; - -EOS_SDK_ALL_API_VERSIONS -GType eos_application_get_type (void) G_GNUC_CONST; - -EOS_SDK_ALL_API_VERSIONS -EosApplication *eos_application_new (const gchar *application_id, - GApplicationFlags flags); - -G_END_DECLS - -#endif /* EOS_APPLICATION_H */ diff --git a/endless/endless.h b/endless/endless.h index b452247..6bf4f29 100644 --- a/endless/endless.h +++ b/endless/endless.h @@ -11,9 +11,9 @@ G_BEGIN_DECLS #define _EOS_SDK_INSIDE_ENDLESS_H /* Pull in other header files */ -#include "types.h" -#include "application.h" -#include "window.h" +#include "eostypes.h" +#include "eosapplication.h" +#include "eoswindow.h" #undef _EOS_SDK_INSIDE_ENDLESS_H diff --git a/endless/enums.h b/endless/enums.h deleted file mode 100644 index b85cde3..0000000 --- a/endless/enums.h +++ /dev/null @@ -1,12 +0,0 @@ -/* Copyright 2013 Endless Mobile, Inc. */ - -#if !(defined(_EOS_SDK_INSIDE_ENDLESS_H) || defined(COMPILING_EOS_SDK)) -#error "Please do not include this header file directly." -#endif - -#ifndef EOS_ENUMS_H -#define EOS_ENUMS_H - -/* Shared typedefs for enumerations */ - -#endif /* EOS_ENUMS_H */ diff --git a/endless/eosapplication.c b/endless/eosapplication.c new file mode 100644 index 0000000..df7a15e --- /dev/null +++ b/endless/eosapplication.c @@ -0,0 +1,165 @@ +/* Copyright 2013 Endless Mobile, Inc. */ + +#include "config.h" +#include "eosapplication.h" + +#include + +#include "eoswindow.h" + +/** + * SECTION:application + * @short_description: Start here with your application + * @title: Applications + * + * The #EosApplication class is where you start when programming your + * application. + * You should create a class that extends #EosApplication. + * + * You also need to think up an application ID. + * This takes the form of a reverse domain name, and it should be unique. + * This ID is used to make sure that only one copy of your application is + * running at any time; if a user tries to start a second copy, then the first + * copy is brought to the front. + * + * To set up your application's data and window, override the + * #GApplication::startup function, like this example do-nothing application, + * Smoke Grinder: + * |[ + * const Lang = imports.lang; + * const Endless = imports.gi.Endless; + * + * const SmokeGrinder = new Lang.Class ({ + * Name: 'SmokeGrinder', + * Extends: Endless.Application, + * + * vfunc_startup: function() { + * this.parent(); + * this._window = new Endless.Window({application: this}); + * this._window.show_all(); + * }, + * }); + * + * let app = new SmokeGrinder({ application_id: "com.example.smokegrinder", + * flags: 0 }); + * app.run(ARGV); + * ]| + */ + +G_DEFINE_TYPE (EosApplication, eos_application, GTK_TYPE_APPLICATION) + +#define APPLICATION_PRIVATE(o) \ + (G_TYPE_INSTANCE_GET_PRIVATE ((o), EOS_TYPE_APPLICATION, EosApplicationPrivate)) + +struct _EosApplicationPrivate +{ + EosWindow *main_application_window; +}; + +static void +eos_application_activate (GApplication *application) +{ + EosApplication *self = EOS_APPLICATION (application); + + G_APPLICATION_CLASS (eos_application_parent_class)->activate (application); + + /* Raise the main application window if it is iconified. This behavior will + be default in GTK at some future point, in which case the following + paragraph can be removed. */ + if (self->priv->main_application_window) + { + gtk_window_present (GTK_WINDOW (self->priv->main_application_window)); + } + + /* TODO: Should it be required to override activate() as in GApplication? */ +} + +static void +eos_application_window_added (GtkApplication *application, + GtkWindow *window) +{ + EosApplication *self = EOS_APPLICATION (application); + + GTK_APPLICATION_CLASS (eos_application_parent_class)->window_added ( + application, window); + + /* If the new window is an EosWindow, then it is our main application window; + it should be raised when the application is activated */ + if (EOS_IS_WINDOW (window)) + { + if (self->priv->main_application_window != NULL) + { + g_error ("You should not add more than one application window."); + } + g_object_ref (window); + self->priv->main_application_window = EOS_WINDOW (window); + } +} + +static void +eos_application_window_removed (GtkApplication *application, + GtkWindow *window) +{ + EosApplication *self = EOS_APPLICATION (application); + + GTK_APPLICATION_CLASS (eos_application_parent_class)->window_removed ( + application, window); + + if (EOS_IS_WINDOW (window)) + { + if (self->priv->main_application_window == NULL) + { + g_warning ("EosWindow is being removed from EosApplication, although " + "none was added."); + return; + } + if (self->priv->main_application_window != EOS_WINDOW (window)) + g_warning ("A different EosWindow is being removed from EosApplication " + "than the one that was added."); + g_object_unref (window); + self->priv->main_application_window = NULL; + } +} + +static void +eos_application_class_init (EosApplicationClass *klass) +{ + GApplicationClass *g_application_class = G_APPLICATION_CLASS (klass); + GtkApplicationClass *gtk_application_class = GTK_APPLICATION_CLASS (klass); + + g_type_class_add_private (klass, sizeof (EosApplicationPrivate)); + + g_application_class->activate = eos_application_activate; + gtk_application_class->window_added = eos_application_window_added; + gtk_application_class->window_removed = eos_application_window_removed; +} + +static void +eos_application_init (EosApplication *self) +{ + self->priv = APPLICATION_PRIVATE (self); +} + +/* Public API */ + +/** + * eos_application_new: + * @application_id: a unique identifier for the application, for example a + * reverse domain name. + * @flags: flags to apply to the application; see #GApplicationFlags. + * + * Create a new application. For the application ID, use a reverse domain name, + * such as com.endlessm.weather. See g_application_id_is_valid() + * for the full rules for application IDs. + * + * Returns: a pointer to the application. + */ +EosApplication * +eos_application_new (const gchar *application_id, + GApplicationFlags flags) +{ + return g_object_new (EOS_TYPE_APPLICATION, + "application-id", application_id, + "flags", flags, + NULL); +} diff --git a/endless/eosapplication.h b/endless/eosapplication.h new file mode 100644 index 0000000..8720f9e --- /dev/null +++ b/endless/eosapplication.h @@ -0,0 +1,70 @@ +/* Copyright 2013 Endless Mobile, Inc. */ + +#if !(defined(_EOS_SDK_INSIDE_ENDLESS_H) || defined(COMPILING_EOS_SDK)) +#error "Please do not include this header file directly." +#endif + +#ifndef EOS_APPLICATION_H +#define EOS_APPLICATION_H + +#include "eostypes.h" + +#include + +#define EOS_TYPE_APPLICATION eos_application_get_type() + +#define EOS_APPLICATION(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ + EOS_TYPE_APPLICATION, EosApplication)) + +#define EOS_APPLICATION_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST ((klass), \ + EOS_TYPE_APPLICATION, EosApplicationClass)) + +#define EOS_IS_APPLICATION(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \ + EOS_TYPE_APPLICATION)) + +#define EOS_IS_APPLICATION_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE ((klass), \ + EOS_TYPE_APPLICATION)) + +#define EOS_APPLICATION_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS ((obj), \ + EOS_TYPE_APPLICATION, EosApplicationClass)) + +typedef struct _EosApplication EosApplication; +typedef struct _EosApplicationClass EosApplicationClass; +typedef struct _EosApplicationPrivate EosApplicationPrivate; + +/** + * EosApplication: + * + * This class structure contains no public members. + */ +struct _EosApplication +{ + /*< private >*/ + GtkApplication parent; + + EosApplicationPrivate *priv; +}; + +struct _EosApplicationClass +{ + GtkApplicationClass parent_class; + + /* For further expansion */ + gpointer _padding[8]; +}; + +EOS_SDK_ALL_API_VERSIONS +GType eos_application_get_type (void) G_GNUC_CONST; + +EOS_SDK_ALL_API_VERSIONS +EosApplication *eos_application_new (const gchar *application_id, + GApplicationFlags flags); + +G_END_DECLS + +#endif /* EOS_APPLICATION_H */ diff --git a/endless/eosenums.h b/endless/eosenums.h new file mode 100644 index 0000000..b85cde3 --- /dev/null +++ b/endless/eosenums.h @@ -0,0 +1,12 @@ +/* Copyright 2013 Endless Mobile, Inc. */ + +#if !(defined(_EOS_SDK_INSIDE_ENDLESS_H) || defined(COMPILING_EOS_SDK)) +#error "Please do not include this header file directly." +#endif + +#ifndef EOS_ENUMS_H +#define EOS_ENUMS_H + +/* Shared typedefs for enumerations */ + +#endif /* EOS_ENUMS_H */ diff --git a/endless/eoshello.c b/endless/eoshello.c new file mode 100644 index 0000000..83be05a --- /dev/null +++ b/endless/eoshello.c @@ -0,0 +1,70 @@ +/* Copyright 2013 Endless Mobile, Inc. */ + +#include +#include +#include +#include +#include + +#include + +/** + * SECTION:hello + * @short_description: Sample skeleton function + * @title: Hello + * + * This is a sample skeleton function that says hello either to the terminal or + * a file. + */ + +/** + * eos_hello_sample_function: + * @file: (allow-none): #GFile to write to, or %NULL + * @error: (allow-none): Return location for a #GError, or %NULL to ignore. + * + * A sample API function to say hello with. Prints on the terminal if @file is + * %NULL, or else appends it to @file. + * + * Returns: %TRUE on success, %FALSE on error. + */ +gboolean +eos_hello_sample_function(GFile *file, + GError **error) +{ + char *hello_string = _("Hello, world!\n"); + GFileOutputStream *stream; + ssize_t write_count; + gboolean success; + + g_return_val_if_fail (G_IS_FILE (file) || file == NULL, FALSE); + g_return_val_if_fail (error == NULL || *error == NULL, FALSE); + + /* Print to terminal */ + if (file == NULL) + { + g_print ("%s", hello_string); + return TRUE; + } + + stream = g_file_append_to (file, + G_FILE_CREATE_NONE, + NULL, /* cancellable */ + error); + if(!stream) + return FALSE; + + write_count = g_output_stream_write (G_OUTPUT_STREAM (stream), + hello_string, + strlen (hello_string), + NULL, /* cancellable */ + error); + success = g_output_stream_close (G_OUTPUT_STREAM (stream), + NULL, /* cancellable */ + error); + g_object_unref (stream); + + if (write_count == -1 || !success) + return FALSE; + + return TRUE; +} diff --git a/endless/eosinit-private.h b/endless/eosinit-private.h new file mode 100644 index 0000000..d242d5e --- /dev/null +++ b/endless/eosinit-private.h @@ -0,0 +1,14 @@ +/* Copyright 2013 Endless Mobile, Inc. */ + +#ifndef EOS_INIT_PRIVATE_H +#define EOS_INIT_PRIVATE_H + +#include + +G_BEGIN_DECLS + +gboolean eos_is_inited (void); + +G_END_DECLS + +#endif /* EOS_INIT_PRIVATE_H */ diff --git a/endless/eosinit.c b/endless/eosinit.c new file mode 100644 index 0000000..fadc9b4 --- /dev/null +++ b/endless/eosinit.c @@ -0,0 +1,53 @@ +/* Copyright 2013 Endless Mobile, Inc. */ + +#include +#include +#include + +#include "eosinit-private.h" + +/* Constructors supported since GCC 2.7; I have this on GLib's authority. This +should also work on Clang. */ +#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7) + +#define _EOS_CONSTRUCTOR(func) static void __attribute__((constructor)) func (void); +#define _EOS_DESTRUCTOR(func) static void __atrribute__((destructor)) func (void); + +#else + +#error "We do not currently support constructors for your compiler." + +#endif /* compiler version */ + +static gboolean _eos_initialized = FALSE; + +/* + * _eos_init: + * + * This function initializes the library. It is called automatically when the + * library is loaded. + */ +_EOS_CONSTRUCTOR(_eos_init); +static void +_eos_init (void) +{ + if (G_UNLIKELY (!_eos_initialized)) + { + /* Initialize Gettext */ + bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); + bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); + + _eos_initialized = TRUE; + } +} + +/* + * eos_is_inited: + * + * For testing purposes. + */ +gboolean +eos_is_inited (void) +{ + return _eos_initialized; +} diff --git a/endless/eosmacros.h b/endless/eosmacros.h new file mode 100644 index 0000000..1a3fc44 --- /dev/null +++ b/endless/eosmacros.h @@ -0,0 +1,12 @@ +/* Copyright 2013 Endless Mobile, Inc. */ + +#if !(defined(_EOS_SDK_INSIDE_ENDLESS_H) || defined(COMPILING_EOS_SDK)) +#error "Please do not include this header file directly." +#endif + +#ifndef EOS_MACROS_H +#define EOS_MACROS_H + +/* Shared preprocessor macros */ + +#endif /* EOS_MACROS_H */ diff --git a/endless/eostypes.h b/endless/eostypes.h new file mode 100644 index 0000000..68bd6d3 --- /dev/null +++ b/endless/eostypes.h @@ -0,0 +1,18 @@ +/* Copyright 2013 Endless Mobile, Inc. */ + +#if !(defined(_EOS_SDK_INSIDE_ENDLESS_H) || defined(COMPILING_EOS_SDK)) +#error "Please do not include this header file directly." +#endif + +#ifndef EOS_TYPES_H +#define EOS_TYPES_H + +#include "eosenums.h" +#include "eosmacros.h" +#include "eosversion.h" + +#include + +/* Shared typedefs for structures */ + +#endif /* EOS_TYPES_H */ diff --git a/endless/eosversion.h b/endless/eosversion.h new file mode 100644 index 0000000..5b9b292 --- /dev/null +++ b/endless/eosversion.h @@ -0,0 +1,12 @@ +/* Copyright 2013 Endless Mobile, Inc. */ + +#if !(defined(_EOS_SDK_INSIDE_ENDLESS_H) || defined(COMPILING_EOS_SDK)) +#error "Please do not include this header file directly." +#endif + +#ifndef API_VERSION_H +#define API_VERSION_H + +#define EOS_SDK_ALL_API_VERSIONS + +#endif /* API_VERSION_H */ diff --git a/endless/eoswindow.c b/endless/eoswindow.c new file mode 100644 index 0000000..29032a6 --- /dev/null +++ b/endless/eoswindow.c @@ -0,0 +1,121 @@ +/* Copyright 2013 Endless Mobile, Inc. */ + +#include "config.h" +#include "eoswindow.h" + +#include "eosapplication.h" + +#include + +/** + * SECTION:window + * @short_description: A window for your application + * @title: Window + * + * Stub + */ + +G_DEFINE_TYPE (EosWindow, eos_window, GTK_TYPE_APPLICATION_WINDOW) + +#define WINDOW_PRIVATE(o) \ + (G_TYPE_INSTANCE_GET_PRIVATE ((o), EOS_TYPE_WINDOW, EosWindowPrivate)) + +struct _EosWindowPrivate +{ + EosApplication *application; +}; + +enum +{ + PROP_0, + PROP_APPLICATION, + NPROPS +}; + +static GParamSpec *eos_window_props[NPROPS] = { NULL, }; + +static void +eos_window_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + EosWindow *self = EOS_WINDOW (object); + + switch (property_id) + { + case PROP_APPLICATION: + g_value_set_object (value, self->priv->application); + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + } +} + +static void +eos_window_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) +{ + EosWindow *self = EOS_WINDOW (object); + + switch (property_id) + { + case PROP_APPLICATION: + self->priv->application = g_value_get_object (value); + gtk_window_set_application (GTK_WINDOW (self), + GTK_APPLICATION (self->priv->application)); + if (self->priv->application == NULL) + g_critical ("In order to create a window, you must have an application " + "for it to connect to."); + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + } +} + +static void +eos_window_class_init (EosWindowClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + g_type_class_add_private (klass, sizeof (EosWindowPrivate)); + + object_class->get_property = eos_window_get_property; + object_class->set_property = eos_window_set_property; + + eos_window_props[PROP_APPLICATION] = + g_param_spec_object ("application", "Application", + "Application associated with this window", + EOS_TYPE_APPLICATION, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); + + g_object_class_install_properties (object_class, NPROPS, eos_window_props); +} + +static void +eos_window_init (EosWindow *self) +{ + self->priv = WINDOW_PRIVATE (self); +} + +/* Public API */ + +/** + * eos_window_new: + * @application: the #EosApplication that the window belongs to. + * + * Create a window. It is invisible by default. + * + * Returns: a pointer to the window. + */ +GtkWidget * +eos_window_new (EosApplication *application) +{ + return GTK_WIDGET (g_object_new (EOS_TYPE_WINDOW, + "application", application, + NULL)); +} diff --git a/endless/eoswindow.h b/endless/eoswindow.h new file mode 100644 index 0000000..7fe6bfd --- /dev/null +++ b/endless/eoswindow.h @@ -0,0 +1,71 @@ +/* Copyright 2013 Endless Mobile, Inc. */ + +#if !(defined(_EOS_SDK_INSIDE_ENDLESS_H) || defined(COMPILING_EOS_SDK)) +#error "Please do not include this header file directly." +#endif + +#ifndef EOS_WINDOW_H +#define EOS_WINDOW_H + +#include "eostypes.h" + +#include "eosapplication.h" + +G_BEGIN_DECLS + +#define EOS_TYPE_WINDOW eos_window_get_type() + +#define EOS_WINDOW(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ + EOS_TYPE_WINDOW, EosWindow)) + +#define EOS_WINDOW_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST ((klass), \ + EOS_TYPE_WINDOW, EosWindowClass)) + +#define EOS_IS_WINDOW(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \ + EOS_TYPE_WINDOW)) + +#define EOS_IS_WINDOW_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE ((klass), \ + EOS_TYPE_WINDOW)) + +#define EOS_WINDOW_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS ((obj), \ + EOS_TYPE_WINDOW, EosWindowClass)) + +typedef struct _EosWindow EosWindow; +typedef struct _EosWindowClass EosWindowClass; +typedef struct _EosWindowPrivate EosWindowPrivate; + +/** + * EosWindow: + * + * This class structure contains no public members. + */ +struct _EosWindow +{ + /*< private >*/ + GtkApplicationWindow parent; + + EosWindowPrivate *priv; +}; + +struct _EosWindowClass +{ + GtkApplicationWindowClass parent_class; + + /* For further expansion */ + gpointer _padding[8]; +}; + +EOS_SDK_ALL_API_VERSIONS +GType eos_window_get_type (void) G_GNUC_CONST; + +EOS_SDK_ALL_API_VERSIONS +GtkWidget *eos_window_new (EosApplication *application); + +G_END_DECLS + +#endif /* EOS_WINDOW_H */ diff --git a/endless/hello.c b/endless/hello.c deleted file mode 100644 index 83be05a..0000000 --- a/endless/hello.c +++ /dev/null @@ -1,70 +0,0 @@ -/* Copyright 2013 Endless Mobile, Inc. */ - -#include -#include -#include -#include -#include - -#include - -/** - * SECTION:hello - * @short_description: Sample skeleton function - * @title: Hello - * - * This is a sample skeleton function that says hello either to the terminal or - * a file. - */ - -/** - * eos_hello_sample_function: - * @file: (allow-none): #GFile to write to, or %NULL - * @error: (allow-none): Return location for a #GError, or %NULL to ignore. - * - * A sample API function to say hello with. Prints on the terminal if @file is - * %NULL, or else appends it to @file. - * - * Returns: %TRUE on success, %FALSE on error. - */ -gboolean -eos_hello_sample_function(GFile *file, - GError **error) -{ - char *hello_string = _("Hello, world!\n"); - GFileOutputStream *stream; - ssize_t write_count; - gboolean success; - - g_return_val_if_fail (G_IS_FILE (file) || file == NULL, FALSE); - g_return_val_if_fail (error == NULL || *error == NULL, FALSE); - - /* Print to terminal */ - if (file == NULL) - { - g_print ("%s", hello_string); - return TRUE; - } - - stream = g_file_append_to (file, - G_FILE_CREATE_NONE, - NULL, /* cancellable */ - error); - if(!stream) - return FALSE; - - write_count = g_output_stream_write (G_OUTPUT_STREAM (stream), - hello_string, - strlen (hello_string), - NULL, /* cancellable */ - error); - success = g_output_stream_close (G_OUTPUT_STREAM (stream), - NULL, /* cancellable */ - error); - g_object_unref (stream); - - if (write_count == -1 || !success) - return FALSE; - - return TRUE; -} diff --git a/endless/init-private.h b/endless/init-private.h deleted file mode 100644 index d242d5e..0000000 --- a/endless/init-private.h +++ /dev/null @@ -1,14 +0,0 @@ -/* Copyright 2013 Endless Mobile, Inc. */ - -#ifndef EOS_INIT_PRIVATE_H -#define EOS_INIT_PRIVATE_H - -#include - -G_BEGIN_DECLS - -gboolean eos_is_inited (void); - -G_END_DECLS - -#endif /* EOS_INIT_PRIVATE_H */ diff --git a/endless/init.c b/endless/init.c deleted file mode 100644 index cf1cdeb..0000000 --- a/endless/init.c +++ /dev/null @@ -1,53 +0,0 @@ -/* Copyright 2013 Endless Mobile, Inc. */ - -#include -#include -#include - -#include "init-private.h" - -/* Constructors supported since GCC 2.7; I have this on GLib's authority. This -should also work on Clang. */ -#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7) - -#define _EOS_CONSTRUCTOR(func) static void __attribute__((constructor)) func (void); -#define _EOS_DESTRUCTOR(func) static void __atrribute__((destructor)) func (void); - -#else - -#error "We do not currently support constructors for your compiler." - -#endif /* compiler version */ - -static gboolean _eos_initialized = FALSE; - -/* - * _eos_init: - * - * This function initializes the library. It is called automatically when the - * library is loaded. - */ -_EOS_CONSTRUCTOR(_eos_init); -static void -_eos_init (void) -{ - if (G_UNLIKELY (!_eos_initialized)) - { - /* Initialize Gettext */ - bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); - bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); - - _eos_initialized = TRUE; - } -} - -/* - * eos_is_inited: - * - * For testing purposes. - */ -gboolean -eos_is_inited (void) -{ - return _eos_initialized; -} diff --git a/endless/macros.h b/endless/macros.h deleted file mode 100644 index 1a3fc44..0000000 --- a/endless/macros.h +++ /dev/null @@ -1,12 +0,0 @@ -/* Copyright 2013 Endless Mobile, Inc. */ - -#if !(defined(_EOS_SDK_INSIDE_ENDLESS_H) || defined(COMPILING_EOS_SDK)) -#error "Please do not include this header file directly." -#endif - -#ifndef EOS_MACROS_H -#define EOS_MACROS_H - -/* Shared preprocessor macros */ - -#endif /* EOS_MACROS_H */ diff --git a/endless/types.h b/endless/types.h deleted file mode 100644 index bfa5c1b..0000000 --- a/endless/types.h +++ /dev/null @@ -1,18 +0,0 @@ -/* Copyright 2013 Endless Mobile, Inc. */ - -#if !(defined(_EOS_SDK_INSIDE_ENDLESS_H) || defined(COMPILING_EOS_SDK)) -#error "Please do not include this header file directly." -#endif - -#ifndef EOS_TYPES_H -#define EOS_TYPES_H - -#include "enums.h" -#include "macros.h" -#include "apiversion.h" - -#include - -/* Shared typedefs for structures */ - -#endif /* EOS_TYPES_H */ diff --git a/endless/window.c b/endless/window.c deleted file mode 100644 index 86c95fa..0000000 --- a/endless/window.c +++ /dev/null @@ -1,121 +0,0 @@ -/* Copyright 2013 Endless Mobile, Inc. */ - -#include "config.h" -#include "window.h" - -#include "application.h" - -#include - -/** - * SECTION:window - * @short_description: A window for your application - * @title: Window - * - * Stub - */ - -G_DEFINE_TYPE (EosWindow, eos_window, GTK_TYPE_APPLICATION_WINDOW) - -#define WINDOW_PRIVATE(o) \ - (G_TYPE_INSTANCE_GET_PRIVATE ((o), EOS_TYPE_WINDOW, EosWindowPrivate)) - -struct _EosWindowPrivate -{ - EosApplication *application; -}; - -enum -{ - PROP_0, - PROP_APPLICATION, - NPROPS -}; - -static GParamSpec *eos_window_props[NPROPS] = { NULL, }; - -static void -eos_window_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) -{ - EosWindow *self = EOS_WINDOW (object); - - switch (property_id) - { - case PROP_APPLICATION: - g_value_set_object (value, self->priv->application); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - } -} - -static void -eos_window_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec) -{ - EosWindow *self = EOS_WINDOW (object); - - switch (property_id) - { - case PROP_APPLICATION: - self->priv->application = g_value_get_object (value); - gtk_window_set_application (GTK_WINDOW (self), - GTK_APPLICATION (self->priv->application)); - if (self->priv->application == NULL) - g_critical ("In order to create a window, you must have an application " - "for it to connect to."); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - } -} - -static void -eos_window_class_init (EosWindowClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - g_type_class_add_private (klass, sizeof (EosWindowPrivate)); - - object_class->get_property = eos_window_get_property; - object_class->set_property = eos_window_set_property; - - eos_window_props[PROP_APPLICATION] = - g_param_spec_object ("application", "Application", - "Application associated with this window", - EOS_TYPE_APPLICATION, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); - - g_object_class_install_properties (object_class, NPROPS, eos_window_props); -} - -static void -eos_window_init (EosWindow *self) -{ - self->priv = WINDOW_PRIVATE (self); -} - -/* Public API */ - -/** - * eos_window_new: - * @application: the #EosApplication that the window belongs to. - * - * Create a window. It is invisible by default. - * - * Returns: a pointer to the window. - */ -GtkWidget * -eos_window_new (EosApplication *application) -{ - return GTK_WIDGET (g_object_new (EOS_TYPE_WINDOW, - "application", application, - NULL)); -} diff --git a/endless/window.h b/endless/window.h deleted file mode 100644 index b92b4eb..0000000 --- a/endless/window.h +++ /dev/null @@ -1,71 +0,0 @@ -/* Copyright 2013 Endless Mobile, Inc. */ - -#if !(defined(_EOS_SDK_INSIDE_ENDLESS_H) || defined(COMPILING_EOS_SDK)) -#error "Please do not include this header file directly." -#endif - -#ifndef EOS_WINDOW_H -#define EOS_WINDOW_H - -#include "types.h" - -#include "application.h" - -G_BEGIN_DECLS - -#define EOS_TYPE_WINDOW eos_window_get_type() - -#define EOS_WINDOW(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ - EOS_TYPE_WINDOW, EosWindow)) - -#define EOS_WINDOW_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST ((klass), \ - EOS_TYPE_WINDOW, EosWindowClass)) - -#define EOS_IS_WINDOW(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \ - EOS_TYPE_WINDOW)) - -#define EOS_IS_WINDOW_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE ((klass), \ - EOS_TYPE_WINDOW)) - -#define EOS_WINDOW_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS ((obj), \ - EOS_TYPE_WINDOW, EosWindowClass)) - -typedef struct _EosWindow EosWindow; -typedef struct _EosWindowClass EosWindowClass; -typedef struct _EosWindowPrivate EosWindowPrivate; - -/** - * EosWindow: - * - * This class structure contains no public members. - */ -struct _EosWindow -{ - /*< private >*/ - GtkApplicationWindow parent; - - EosWindowPrivate *priv; -}; - -struct _EosWindowClass -{ - GtkApplicationWindowClass parent_class; - - /* For further expansion */ - gpointer _padding[8]; -}; - -EOS_SDK_ALL_API_VERSIONS -GType eos_window_get_type (void) G_GNUC_CONST; - -EOS_SDK_ALL_API_VERSIONS -GtkWidget *eos_window_new (EosApplication *application); - -G_END_DECLS - -#endif /* EOS_WINDOW_H */ diff --git a/test/test-init.c b/test/test-init.c index 1fd856e..482c079 100644 --- a/test/test-init.c +++ b/test/test-init.c @@ -2,7 +2,7 @@ #include #include -#include "endless/init-private.h" +#include "endless/eosinit-private.h" #include "run-tests.h" -- cgit v1.2.3