[tepl/wip/file-loading: 2/4] AbstractFactory: add create_main_window()



commit 1e341075994ee8e6c23c71ff9b0ea66dc5bd7ba3
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Sun Oct 8 16:04:10 2017 +0200

    AbstractFactory: add create_main_window()

 docs/reference/tepl-3.0-sections.txt |    1 +
 tepl/tepl-abstract-factory.c         |   24 ++++++++++++++++++++++++
 tepl/tepl-abstract-factory.h         |   21 ++++++++++++++++-----
 3 files changed, 41 insertions(+), 5 deletions(-)
---
diff --git a/docs/reference/tepl-3.0-sections.txt b/docs/reference/tepl-3.0-sections.txt
index fe85a80..e3f6884 100644
--- a/docs/reference/tepl-3.0-sections.txt
+++ b/docs/reference/tepl-3.0-sections.txt
@@ -174,6 +174,7 @@ TeplAbstractFactory
 TeplAbstractFactoryClass
 tepl_abstract_factory_set_singleton
 tepl_abstract_factory_get_singleton
+tepl_abstract_factory_create_main_window
 tepl_abstract_factory_create_tab
 tepl_abstract_factory_create_tab_label
 tepl_abstract_factory_create_file
diff --git a/tepl/tepl-abstract-factory.c b/tepl/tepl-abstract-factory.c
index e5efd2f..2604992 100644
--- a/tepl/tepl-abstract-factory.c
+++ b/tepl/tepl-abstract-factory.c
@@ -165,6 +165,30 @@ _tepl_abstract_factory_unref_singleton (void)
 }
 
 /**
+ * tepl_abstract_factory_create_main_window:
+ * @factory: the #TeplAbstractFactory.
+ *
+ * Creates a main #GtkApplicationWindow in the sense of
+ * tepl_application_window_is_main_window().
+ *
+ * Returns: (transfer floating) (nullable): a new main application window, or
+ * %NULL if the vfunc is not implemented.
+ */
+GtkApplicationWindow *
+tepl_abstract_factory_create_main_window (TeplAbstractFactory *factory)
+{
+       g_return_val_if_fail (TEPL_IS_ABSTRACT_FACTORY (factory), NULL);
+
+       if (TEPL_ABSTRACT_FACTORY_GET_CLASS (factory)->create_main_window != NULL)
+       {
+               return TEPL_ABSTRACT_FACTORY_GET_CLASS (factory)->create_main_window (factory);
+       }
+
+       g_warning ("The TeplAbstractFactory::create_main_window vfunc is not implemented.");
+       return NULL;
+}
+
+/**
  * tepl_abstract_factory_create_tab:
  * @factory: the #TeplAbstractFactory.
  *
diff --git a/tepl/tepl-abstract-factory.h b/tepl/tepl-abstract-factory.h
index 6693045..28e7b77 100644
--- a/tepl/tepl-abstract-factory.h
+++ b/tepl/tepl-abstract-factory.h
@@ -54,20 +54,29 @@ struct _TeplAbstractFactory
  * @create_file: Virtual function pointer for
  *   tepl_abstract_factory_create_file(). By default the #TeplFile is created
  *   with tepl_file_new().
+ * @create_main_window: Virtual function pointer for
+ *   tepl_abstract_factory_create_main_window(). It is not implemented by
+ *   default.
+ */
+/* TODO move create_main_window on top, to have a more logical order, for next
+ * API break. Keyword: "deprecated" (to find this TODO when it needs to be
+ * done).
  */
 struct _TeplAbstractFactoryClass
 {
        GObjectClass parent_class;
 
-       TeplTab *       (* create_tab)          (TeplAbstractFactory *factory);
+       TeplTab *               (* create_tab)          (TeplAbstractFactory *factory);
+
+       GtkWidget *             (* create_tab_label)    (TeplAbstractFactory *factory,
+                                                        TeplTab             *tab);
 
-       GtkWidget *     (* create_tab_label)    (TeplAbstractFactory *factory,
-                                                TeplTab             *tab);
+       TeplFile *              (* create_file)         (TeplAbstractFactory *factory);
 
-       TeplFile *      (* create_file)         (TeplAbstractFactory *factory);
+       GtkApplicationWindow *  (* create_main_window)  (TeplAbstractFactory *factory);
 
        /*< private >*/
-       gpointer padding[11];
+       gpointer padding[10];
 };
 
 GType                  tepl_abstract_factory_get_type                  (void);
@@ -76,6 +85,8 @@ void                  tepl_abstract_factory_set_singleton             (TeplAbstractFactory 
*factory);
 
 TeplAbstractFactory *  tepl_abstract_factory_get_singleton             (void);
 
+GtkApplicationWindow * tepl_abstract_factory_create_main_window        (TeplAbstractFactory *factory);
+
 TeplTab *              tepl_abstract_factory_create_tab                (TeplAbstractFactory *factory);
 
 GtkWidget *            tepl_abstract_factory_create_tab_label          (TeplAbstractFactory *factory,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]