[tepl/wip/tab: 1/3] Tab: add view property
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tepl/wip/tab: 1/3] Tab: add view property
- Date: Sat, 17 Jun 2017 17:57:32 +0000 (UTC)
commit 91f664c34dbd774a03cead5415724adcad97b475
Author: Sébastien Wilmet <swilmet gnome org>
Date: Sat Jun 17 19:50:15 2017 +0200
Tab: add view property
docs/reference/tepl-3.0-sections.txt | 1 +
tepl/tepl-tab.c | 98 ++++++++++++++++++++++++++++++++++
tepl/tepl-tab.h | 2 +
3 files changed, 101 insertions(+), 0 deletions(-)
---
diff --git a/docs/reference/tepl-3.0-sections.txt b/docs/reference/tepl-3.0-sections.txt
index b2800b8..91723ba 100644
--- a/docs/reference/tepl-3.0-sections.txt
+++ b/docs/reference/tepl-3.0-sections.txt
@@ -345,6 +345,7 @@ tepl_metadata_manager_shutdown
<FILE>tab</FILE>
TeplTab
tepl_tab_new
+tepl_tab_get_view
tepl_tab_add_info_bar
<SUBSECTION Standard>
TEPL_TYPE_TAB
diff --git a/tepl/tepl-tab.c b/tepl/tepl-tab.c
index 7aa4a02..d1e54cd 100644
--- a/tepl/tepl-tab.c
+++ b/tepl/tepl-tab.c
@@ -18,6 +18,7 @@
*/
#include "tepl-tab.h"
+#include "tepl-view.h"
/**
* SECTION:tab
@@ -27,12 +28,74 @@
struct _TeplTabPrivate
{
+ TeplView *view;
GtkWidget *main_widget;
};
+enum
+{
+ PROP_0,
+ PROP_VIEW,
+ N_PROPERTIES
+};
+
+static GParamSpec *properties[N_PROPERTIES];
+
G_DEFINE_TYPE_WITH_PRIVATE (TeplTab, tepl_tab, GTK_TYPE_GRID)
static void
+set_view (TeplTab *tab,
+ TeplView *view)
+{
+ g_return_if_fail (TEPL_IS_VIEW (view));
+
+ g_assert (tab->priv->view == NULL);
+ tab->priv->view = g_object_ref_sink (view);
+
+ g_object_notify_by_pspec (G_OBJECT (tab), properties[PROP_VIEW]);
+}
+
+static void
+tepl_tab_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ TeplTab *tab = TEPL_TAB (object);
+
+ switch (prop_id)
+ {
+ case PROP_VIEW:
+ g_value_set_object (value, tepl_tab_get_view (tab));
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+tepl_tab_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ TeplTab *tab = TEPL_TAB (object);
+
+ switch (prop_id)
+ {
+ case PROP_VIEW:
+ set_view (tab, g_value_get_object (value));
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
tepl_tab_dispose (GObject *object)
{
TeplTab *tab = TEPL_TAB (object);
@@ -47,7 +110,27 @@ tepl_tab_class_init (TeplTabClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ object_class->get_property = tepl_tab_get_property;
+ object_class->set_property = tepl_tab_set_property;
object_class->dispose = tepl_tab_dispose;
+
+ /**
+ * TeplTab:view:
+ *
+ * The #TeplView contained in the tab.
+ *
+ * Since: 3.0
+ */
+ properties[PROP_VIEW] =
+ g_param_spec_object ("view",
+ "View",
+ "",
+ TEPL_TYPE_VIEW,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS);
+
+ g_object_class_install_properties (object_class, N_PROPERTIES, properties);
}
static void
@@ -81,6 +164,21 @@ tepl_tab_new (GtkWidget *main_widget)
}
/**
+ * tepl_tab_get_view:
+ * @tab: a #TeplTab.
+ *
+ * Returns: (transfer none): the #TeplView contained in @tab.
+ * Since: 3.0
+ */
+TeplView *
+tepl_tab_get_view (TeplTab *tab)
+{
+ g_return_val_if_fail (TEPL_IS_TAB (tab), NULL);
+
+ return tab->priv->view;
+}
+
+/**
* tepl_tab_add_info_bar:
* @tab: a #TeplTab.
* @info_bar: a #GtkInfoBar.
diff --git a/tepl/tepl-tab.h b/tepl/tepl-tab.h
index 74f5c14..87956df 100644
--- a/tepl/tepl-tab.h
+++ b/tepl/tepl-tab.h
@@ -57,6 +57,8 @@ GType tepl_tab_get_type (void);
TeplTab * tepl_tab_new (GtkWidget *main_widget);
+TeplView * tepl_tab_get_view (TeplTab *tab);
+
void tepl_tab_add_info_bar (TeplTab *tab,
GtkInfoBar *info_bar);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]