[tepl] AmtkFactory: add constructors
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tepl] AmtkFactory: add constructors
- Date: Tue, 8 Aug 2017 17:38:16 +0000 (UTC)
commit 858e538a6acf92c6a342e671f79c191201500591
Author: Sébastien Wilmet <swilmet gnome org>
Date: Mon Aug 7 20:14:31 2017 +0200
AmtkFactory: add constructors
It is no longer an abstract class, there is actually no need to create
subclasses (at least to create a GtkMenu and GtkToolbar).
amtk/amtk-factory.c | 34 ++++++++++++++++++++++++++++++++++
amtk/amtk-factory.h | 24 ++++++++++++++----------
docs/reference/tepl-3.0-sections.txt | 2 ++
3 files changed, 50 insertions(+), 10 deletions(-)
---
diff --git a/amtk/amtk-factory.c b/amtk/amtk-factory.c
index cb30cb0..90576d3 100644
--- a/amtk/amtk-factory.c
+++ b/amtk/amtk-factory.c
@@ -201,6 +201,40 @@ amtk_factory_init (AmtkFactory *factory)
}
/**
+ * amtk_factory_new:
+ * @application: (nullable): a #GtkApplication, or %NULL.
+ *
+ * Creates a new #AmtkFactory object. Associating a #GtkApplication is optional.
+ *
+ * Returns: a new #AmtkFactory.
+ * Since: 3.0
+ */
+AmtkFactory *
+amtk_factory_new (GtkApplication *application)
+{
+ g_return_val_if_fail (application == NULL || GTK_IS_APPLICATION (application), NULL);
+
+ return g_object_new (AMTK_TYPE_FACTORY,
+ "application", application,
+ NULL);
+}
+
+/**
+ * amtk_factory_new_with_default_application:
+ *
+ * Calls amtk_factory_new() with g_application_get_default() (it must be a
+ * #GtkApplication).
+ *
+ * Returns: a new #AmtkFactory with the default #GtkApplication.
+ * Since: 3.0
+ */
+AmtkFactory *
+amtk_factory_new_with_default_application (void)
+{
+ return amtk_factory_new (GTK_APPLICATION (g_application_get_default ()));
+}
+
+/**
* amtk_factory_get_application:
* @factory: an #AmtkFactory.
*
diff --git a/amtk/amtk-factory.h b/amtk/amtk-factory.h
index bf7e51b..eb45b6d 100644
--- a/amtk/amtk-factory.h
+++ b/amtk/amtk-factory.h
@@ -84,21 +84,25 @@ typedef enum
AMTK_FACTORY_IGNORE_ACCELS_FOR_APP = 1 << 6,
} AmtkFactoryFlags;
-GType amtk_factory_get_type (void);
+GType amtk_factory_get_type (void);
-GtkApplication * amtk_factory_get_application (AmtkFactory *factory);
+AmtkFactory * amtk_factory_new (GtkApplication *application);
-AmtkFactoryFlags amtk_factory_get_default_flags (AmtkFactory *factory);
+AmtkFactory * amtk_factory_new_with_default_application (void);
-void amtk_factory_set_default_flags (AmtkFactory *factory,
- AmtkFactoryFlags default_flags);
+GtkApplication * amtk_factory_get_application (AmtkFactory *factory);
-GtkToolItem * amtk_factory_create_tool_button (AmtkFactory *factory,
- const gchar *action_name);
+AmtkFactoryFlags amtk_factory_get_default_flags (AmtkFactory *factory);
-GtkToolItem * amtk_factory_create_tool_button_full (AmtkFactory *factory,
- const gchar *action_name,
- AmtkFactoryFlags flags);
+void amtk_factory_set_default_flags (AmtkFactory *factory,
+ AmtkFactoryFlags default_flags);
+
+GtkToolItem * amtk_factory_create_tool_button (AmtkFactory *factory,
+ const gchar *action_name);
+
+GtkToolItem * amtk_factory_create_tool_button_full (AmtkFactory *factory,
+ const gchar *action_name,
+ AmtkFactoryFlags flags);
G_END_DECLS
diff --git a/docs/reference/tepl-3.0-sections.txt b/docs/reference/tepl-3.0-sections.txt
index a69ce76..2059383 100644
--- a/docs/reference/tepl-3.0-sections.txt
+++ b/docs/reference/tepl-3.0-sections.txt
@@ -101,6 +101,8 @@ amtk_action_map_add_action_entries_check_dups
<FILE>amtk-factory</FILE>
AmtkFactory
AmtkFactoryFlags
+amtk_factory_new
+amtk_factory_new_with_default_application
amtk_factory_get_application
amtk_factory_get_default_flags
amtk_factory_set_default_flags
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]