[tepl] AstractFactory: add create_tab_label()
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tepl] AstractFactory: add create_tab_label()
- Date: Sat, 29 Jul 2017 17:52:26 +0000 (UTC)
commit 0ae97bdc1a468373117d3e5267617dd001dca13e
Author: Sébastien Wilmet <swilmet gnome org>
Date: Sat Jul 29 19:49:09 2017 +0200
AstractFactory: add create_tab_label()
docs/reference/tepl-3.0-sections.txt | 1 +
tepl/tepl-abstract-factory.c | 30 ++++++++++++++++++++++++++++++
tepl/tepl-abstract-factory.h | 8 ++++++++
tepl/tepl-notebook.c | 9 +++++++--
4 files changed, 46 insertions(+), 2 deletions(-)
---
diff --git a/docs/reference/tepl-3.0-sections.txt b/docs/reference/tepl-3.0-sections.txt
index 9e4d97e..93a9375 100644
--- a/docs/reference/tepl-3.0-sections.txt
+++ b/docs/reference/tepl-3.0-sections.txt
@@ -182,6 +182,7 @@ TeplAbstractFactoryClass
tepl_abstract_factory_set_singleton
tepl_abstract_factory_get_singleton
tepl_abstract_factory_create_tab
+tepl_abstract_factory_create_tab_label
<SUBSECTION Standard>
TEPL_ABSTRACT_FACTORY
TEPL_ABSTRACT_FACTORY_CLASS
diff --git a/tepl/tepl-abstract-factory.c b/tepl/tepl-abstract-factory.c
index 0015ab5..7000bd8 100644
--- a/tepl/tepl-abstract-factory.c
+++ b/tepl/tepl-abstract-factory.c
@@ -61,6 +61,14 @@ tepl_abstract_factory_create_tab_default (TeplAbstractFactory *factory)
return tepl_tab_new ();
}
+static GtkWidget *
+tepl_abstract_factory_create_tab_label_default (TeplAbstractFactory *factory,
+ TeplTab *tab)
+{
+ /* TODO implement a default TeplTabLabel widget. */
+ return NULL;
+}
+
static void
tepl_abstract_factory_class_init (TeplAbstractFactoryClass *klass)
{
@@ -69,6 +77,7 @@ tepl_abstract_factory_class_init (TeplAbstractFactoryClass *klass)
object_class->finalize = tepl_abstract_factory_finalize;
klass->create_tab = tepl_abstract_factory_create_tab_default;
+ klass->create_tab_label = tepl_abstract_factory_create_tab_label_default;
}
static void
@@ -155,3 +164,24 @@ tepl_abstract_factory_create_tab (TeplAbstractFactory *factory)
return TEPL_ABSTRACT_FACTORY_GET_CLASS (factory)->create_tab (factory);
}
+
+/**
+ * tepl_abstract_factory_create_tab_label:
+ * @factory: the #TeplAbstractFactory.
+ * @tab: a #TeplTab.
+ *
+ * Creates a new tab label for @tab, suitable for gtk_notebook_set_tab_label().
+ *
+ * Returns: (transfer floating) (nullable): a new #GtkWidget, or %NULL for the
+ * default tab label (“page N” with #GtkNotebook).
+ * Since: 3.0
+ */
+GtkWidget *
+tepl_abstract_factory_create_tab_label (TeplAbstractFactory *factory,
+ TeplTab *tab)
+{
+ g_return_val_if_fail (TEPL_IS_ABSTRACT_FACTORY (factory), NULL);
+ g_return_val_if_fail (TEPL_IS_TAB (tab), NULL);
+
+ return TEPL_ABSTRACT_FACTORY_GET_CLASS (factory)->create_tab_label (factory, tab);
+}
diff --git a/tepl/tepl-abstract-factory.h b/tepl/tepl-abstract-factory.h
index d232d19..697d820 100644
--- a/tepl/tepl-abstract-factory.h
+++ b/tepl/tepl-abstract-factory.h
@@ -48,6 +48,8 @@ struct _TeplAbstractFactory
* @parent_class: The parent class.
* @create_tab: Virtual function pointer for tepl_abstract_factory_create_tab().
* By default the #TeplTab is created with tepl_tab_new().
+ * @create_tab_label: Virtual function pointer for
+ * tepl_abstract_factory_create_tab_label(). By default %NULL is returned.
*/
struct _TeplAbstractFactoryClass
{
@@ -55,6 +57,9 @@ struct _TeplAbstractFactoryClass
TeplTab * (* create_tab) (TeplAbstractFactory *factory);
+ GtkWidget * (* create_tab_label) (TeplAbstractFactory *factory,
+ TeplTab *tab);
+
/*< private >*/
gpointer padding[12];
};
@@ -67,6 +72,9 @@ TeplAbstractFactory * tepl_abstract_factory_get_singleton (void);
TeplTab * tepl_abstract_factory_create_tab (TeplAbstractFactory *factory);
+GtkWidget * tepl_abstract_factory_create_tab_label (TeplAbstractFactory *factory,
+ TeplTab *tab);
+
G_GNUC_INTERNAL
void _tepl_abstract_factory_unref_singleton (void);
diff --git a/tepl/tepl-notebook.c b/tepl/tepl-notebook.c
index 8832a11..0955e9d 100644
--- a/tepl/tepl-notebook.c
+++ b/tepl/tepl-notebook.c
@@ -18,6 +18,7 @@
*/
#include "tepl-notebook.h"
+#include "tepl-abstract-factory.h"
#include "tepl-tab-group.h"
#include "tepl-tab.h"
#include "tepl-signal-group.h"
@@ -274,9 +275,13 @@ tepl_notebook_append_tab_vfunc (TeplTabGroup *tab_group,
TeplTab *tab)
{
GtkNotebook *notebook = GTK_NOTEBOOK (tab_group);
+ TeplAbstractFactory *factory;
+ GtkWidget *tab_label;
- /* TODO implement a TeplTabLabel widget. */
- gtk_notebook_append_page (notebook, GTK_WIDGET (tab), NULL);
+ factory = tepl_abstract_factory_get_singleton ();
+ tab_label = tepl_abstract_factory_create_tab_label (factory, tab);
+
+ gtk_notebook_append_page (notebook, GTK_WIDGET (tab), tab_label);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]