[libdazzle: 1/2] app: Add constructor for DzlApplication
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libdazzle: 1/2] app: Add constructor for DzlApplication
- Date: Wed, 24 Apr 2019 21:58:12 +0000 (UTC)
commit 198c097926a73c79024dd00c2e37ce3728878d02
Author: Christopher Davis <brainblasted disroot org>
Date: Wed Apr 24 17:49:51 2019 -0400
app: Add constructor for DzlApplication
DzlApplication was built for subclassing,
but not all language bindings support subclassing yet.
In order for users of those languages to get the benefits
of DzlApplication, there needs to be a constructor.
src/app/dzl-application.c | 12 ++++++++++++
src/app/dzl-application.h | 3 +++
tests/test-application.c | 4 +---
3 files changed, 16 insertions(+), 3 deletions(-)
---
diff --git a/src/app/dzl-application.c b/src/app/dzl-application.c
index 6b2e16a..5ba4ecb 100644
--- a/src/app/dzl-application.c
+++ b/src/app/dzl-application.c
@@ -89,6 +89,18 @@ static GParamSpec *properties [N_PROPS];
G_DEFINE_TYPE_WITH_PRIVATE (DzlApplication, dzl_application, GTK_TYPE_APPLICATION)
+DzlApplication *
+dzl_application_new (const gchar *application_id,
+ GApplicationFlags flags)
+{
+ g_return_val_if_fail (application_id == NULL || g_application_id_is_valid (application_id), NULL);
+
+ return g_object_new (DZL_TYPE_APPLICATION,
+ "application-id", application_id,
+ "flags", flags,
+ NULL);
+}
+
static void
dzl_application_real_add_resources (DzlApplication *self,
const gchar *resource_path)
diff --git a/src/app/dzl-application.h b/src/app/dzl-application.h
index cd26976..944f510 100644
--- a/src/app/dzl-application.h
+++ b/src/app/dzl-application.h
@@ -58,6 +58,9 @@ struct _DzlApplicationClass
gpointer _reserved8;
};
+DZL_AVAILABLE_IN_3_34
+DzlApplication *dzl_application_new (const gchar *application_id,
+ GApplicationFlags flags);
DZL_AVAILABLE_IN_ALL
DzlMenuManager *dzl_application_get_menu_manager (DzlApplication *self);
DZL_AVAILABLE_IN_ALL
diff --git a/tests/test-application.c b/tests/test-application.c
index dda2efd..ff61909 100644
--- a/tests/test-application.c
+++ b/tests/test-application.c
@@ -25,9 +25,7 @@ test_app_basic (void)
g_autoptr(DzlApplication) app = NULL;
int ret;
- app = g_object_new (DZL_TYPE_APPLICATION,
- "application-id", "org.gnome.FooTest",
- NULL);
+ app = dzl_application_new ("org.gnome.FooTest", G_APPLICATION_FLAGS_NONE);
g_signal_connect (app, "activate", G_CALLBACK (on_activate), NULL);
ret = g_application_run (G_APPLICATION (app), g_argc, g_argv);
g_assert_cmpint (ret, ==, EXIT_SUCCESS);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]