[tepl] Tab: use old GObject style
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tepl] Tab: use old GObject style
- Date: Sat, 17 Jun 2017 16:41:54 +0000 (UTC)
commit d11817cb858f85f343a5bf19923c64615a743940
Author: Sébastien Wilmet <swilmet gnome org>
Date: Sat Jun 17 18:38:01 2017 +0200
Tab: use old GObject style
tepl/tepl-tab.c | 22 ++++++++--------------
tepl/tepl-tab.h | 25 ++++++++++++++++++++-----
2 files changed, 28 insertions(+), 19 deletions(-)
---
diff --git a/tepl/tepl-tab.c b/tepl/tepl-tab.c
index 44d3a3b..7aa4a02 100644
--- a/tepl/tepl-tab.c
+++ b/tepl/tepl-tab.c
@@ -1,7 +1,7 @@
/*
* This file is part of Tepl, a text editor library.
*
- * Copyright 2016 - Sébastien Wilmet <swilmet gnome org>
+ * Copyright 2016, 2017 - Sébastien Wilmet <swilmet gnome org>
*
* Tepl is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the
@@ -25,8 +25,6 @@
* @Title: TeplTab
*/
-typedef struct _TeplTabPrivate TeplTabPrivate;
-
struct _TeplTabPrivate
{
GtkWidget *main_widget;
@@ -37,9 +35,9 @@ G_DEFINE_TYPE_WITH_PRIVATE (TeplTab, tepl_tab, GTK_TYPE_GRID)
static void
tepl_tab_dispose (GObject *object)
{
- TeplTabPrivate *priv = tepl_tab_get_instance_private (TEPL_TAB (object));
+ TeplTab *tab = TEPL_TAB (object);
- g_clear_object (&priv->main_widget);
+ g_clear_object (&tab->priv->main_widget);
G_OBJECT_CLASS (tepl_tab_parent_class)->dispose (object);
}
@@ -55,6 +53,8 @@ tepl_tab_class_init (TeplTabClass *klass)
static void
tepl_tab_init (TeplTab *tab)
{
+ tab->priv = tepl_tab_get_instance_private (tab);
+
gtk_orientable_set_orientation (GTK_ORIENTABLE (tab), GTK_ORIENTATION_VERTICAL);
}
@@ -69,15 +69,13 @@ TeplTab *
tepl_tab_new (GtkWidget *main_widget)
{
TeplTab *tab;
- TeplTabPrivate *priv;
g_return_val_if_fail (GTK_IS_WIDGET (main_widget), NULL);
tab = g_object_new (TEPL_TYPE_TAB, NULL);
- priv = tepl_tab_get_instance_private (tab);
gtk_container_add (GTK_CONTAINER (tab), main_widget);
- priv->main_widget = g_object_ref_sink (main_widget);
+ tab->priv->main_widget = g_object_ref_sink (main_widget);
return tab;
}
@@ -99,20 +97,16 @@ void
tepl_tab_add_info_bar (TeplTab *tab,
GtkInfoBar *info_bar)
{
- TeplTabPrivate *priv;
-
g_return_if_fail (TEPL_IS_TAB (tab));
g_return_if_fail (GTK_IS_INFO_BAR (info_bar));
- priv = tepl_tab_get_instance_private (tab);
-
gtk_grid_insert_next_to (GTK_GRID (tab),
- priv->main_widget,
+ tab->priv->main_widget,
GTK_POS_TOP);
gtk_grid_attach_next_to (GTK_GRID (tab),
GTK_WIDGET (info_bar),
- priv->main_widget,
+ tab->priv->main_widget,
GTK_POS_TOP,
1, 1);
}
diff --git a/tepl/tepl-tab.h b/tepl/tepl-tab.h
index 9ddb02c..74f5c14 100644
--- a/tepl/tepl-tab.h
+++ b/tepl/tepl-tab.h
@@ -1,7 +1,7 @@
/*
* This file is part of Tepl, a text editor library.
*
- * Copyright 2016 - Sébastien Wilmet <swilmet gnome org>
+ * Copyright 2016, 2017 - Sébastien Wilmet <swilmet gnome org>
*
* Tepl is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the
@@ -25,13 +25,26 @@
#endif
#include <gtk/gtk.h>
+#include <tepl/tepl-types.h>
G_BEGIN_DECLS
-#define TEPL_TYPE_TAB (tepl_tab_get_type ())
-G_DECLARE_DERIVABLE_TYPE (TeplTab, tepl_tab,
- TEPL, TAB,
- GtkGrid)
+#define TEPL_TYPE_TAB (tepl_tab_get_type ())
+#define TEPL_TAB(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TEPL_TYPE_TAB, TeplTab))
+#define TEPL_TAB_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TEPL_TYPE_TAB, TeplTabClass))
+#define TEPL_IS_TAB(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TEPL_TYPE_TAB))
+#define TEPL_IS_TAB_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TEPL_TYPE_TAB))
+#define TEPL_TAB_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TEPL_TYPE_TAB, TeplTabClass))
+
+typedef struct _TeplTabClass TeplTabClass;
+typedef struct _TeplTabPrivate TeplTabPrivate;
+
+struct _TeplTab
+{
+ GtkGrid parent;
+
+ TeplTabPrivate *priv;
+};
struct _TeplTabClass
{
@@ -40,6 +53,8 @@ struct _TeplTabClass
gpointer padding[12];
};
+GType tepl_tab_get_type (void);
+
TeplTab * tepl_tab_new (GtkWidget *main_widget);
void tepl_tab_add_info_bar (TeplTab *tab,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]