[tepl/wip/notebook] Implement TeplNotebook
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tepl/wip/notebook] Implement TeplNotebook
- Date: Sat, 24 Jun 2017 13:19:25 +0000 (UTC)
commit a98c108c85ad89afa34012116f3dce598a7c09c2
Author: Sébastien Wilmet <swilmet gnome org>
Date: Sat Jun 24 14:53:33 2017 +0200
Implement TeplNotebook
docs/reference/tepl-3.0-sections.txt | 16 ++++
docs/reference/tepl-docs.xml.in | 1 +
po/POTFILES.in | 1 +
tepl/Makefile.am | 2 +
tepl/tepl-notebook.c | 130 ++++++++++++++++++++++++++++++++++
tepl/tepl-notebook.h | 60 ++++++++++++++++
tepl/tepl-types.h | 1 +
tepl/tepl.h | 1 +
8 files changed, 212 insertions(+), 0 deletions(-)
---
diff --git a/docs/reference/tepl-3.0-sections.txt b/docs/reference/tepl-3.0-sections.txt
index 2c7d182..fd276ca 100644
--- a/docs/reference/tepl-3.0-sections.txt
+++ b/docs/reference/tepl-3.0-sections.txt
@@ -381,6 +381,22 @@ tepl_tab_list_get_type
</SECTION>
<SECTION>
+<FILE>notebook</FILE>
+TeplNotebook
+tepl_notebook_new
+<SUBSECTION Standard>
+TEPL_IS_NOTEBOOK
+TEPL_IS_NOTEBOOK_CLASS
+TEPL_NOTEBOOK
+TEPL_NOTEBOOK_CLASS
+TEPL_NOTEBOOK_GET_CLASS
+TEPL_TYPE_NOTEBOOK
+TeplNotebookClass
+TeplNotebookPrivate
+tepl_notebook_get_type
+</SECTION>
+
+<SECTION>
<FILE>utils</FILE>
tepl_utils_recent_chooser_menu_get_item_uri
</SECTION>
diff --git a/docs/reference/tepl-docs.xml.in b/docs/reference/tepl-docs.xml.in
index 58f2896..5271944 100644
--- a/docs/reference/tepl-docs.xml.in
+++ b/docs/reference/tepl-docs.xml.in
@@ -22,6 +22,7 @@
<xi:include href="xml/application.xml"/>
<xi:include href="xml/application-window.xml"/>
<xi:include href="xml/tab-list.xml"/>
+ <xi:include href="xml/notebook.xml"/>
<xi:include href="xml/tab.xml"/>
<xi:include href="xml/view.xml"/>
<xi:include href="xml/buffer.xml"/>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index de15d83..5b230b0 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -20,6 +20,7 @@ tepl/tepl-iter.c
tepl/tepl-menu-item.c
tepl/tepl-menu-shell.c
tepl/tepl-metadata-manager.c
+tepl/tepl-notebook.c
tepl/tepl-tab.c
tepl/tepl-tab-list.c
tepl/tepl-utils.c
diff --git a/tepl/Makefile.am b/tepl/Makefile.am
index a8d5e85..8062f5b 100644
--- a/tepl/Makefile.am
+++ b/tepl/Makefile.am
@@ -31,6 +31,7 @@ tepl_public_headers = \
tepl-menu-item.h \
tepl-menu-shell.h \
tepl-metadata-manager.h \
+ tepl-notebook.h \
tepl-types.h \
tepl-tab.h \
tepl-tab-list.h \
@@ -57,6 +58,7 @@ tepl_public_c_files = \
tepl-menu-item.c \
tepl-menu-shell.c \
tepl-metadata-manager.c \
+ tepl-notebook.c \
tepl-tab.c \
tepl-tab-list.c \
tepl-utils.c \
diff --git a/tepl/tepl-notebook.c b/tepl/tepl-notebook.c
new file mode 100644
index 0000000..86aaff4
--- /dev/null
+++ b/tepl/tepl-notebook.c
@@ -0,0 +1,130 @@
+/*
+ * This file is part of Tepl, a text editor library.
+ *
+ * Copyright 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
+ * Free Software Foundation; either version 2.1 of the License, or (at your
+ * option) any later version.
+ *
+ * Tepl is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "tepl-notebook.h"
+#include "tepl-tab-list.h"
+#include "tepl-tab.h"
+
+/**
+ * SECTION:notebook
+ * @Short_description: #GtkNotebook subclass implementing the #TeplTabList
+ * interface
+ * @Title: TeplNotebook
+ *
+ * #TeplNotebook is a subclass of #GtkNotebook that implements the #TeplTabList
+ * interface.
+ */
+
+struct _TeplNotebookPrivate
+{
+ gint something;
+};
+
+static void tepl_tab_list_interface_init (gpointer g_iface,
+ gpointer iface_data);
+
+G_DEFINE_TYPE_WITH_CODE (TeplNotebook,
+ tepl_notebook,
+ GTK_TYPE_NOTEBOOK,
+ G_ADD_PRIVATE (TeplNotebook)
+ G_IMPLEMENT_INTERFACE (TEPL_TYPE_TAB_LIST,
+ tepl_tab_list_interface_init))
+
+static void
+tepl_notebook_finalize (GObject *object)
+{
+
+ G_OBJECT_CLASS (tepl_notebook_parent_class)->finalize (object);
+}
+
+static void
+tepl_notebook_class_init (TeplNotebookClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->finalize = tepl_notebook_finalize;
+}
+
+static GList *
+tepl_notebook_get_tabs (TeplTabList *tab_list)
+{
+ GtkNotebook *notebook = GTK_NOTEBOOK (tab_list);
+ GList *tabs = NULL;
+ gint n_pages;
+ gint page_num;
+
+ n_pages = gtk_notebook_get_n_pages (notebook);
+ for (page_num = n_pages - 1; page_num >= 0; page_num--)
+ {
+ GtkWidget *page_widget;
+
+ page_widget = gtk_notebook_get_nth_page (notebook, page_num);
+ if (TEPL_IS_TAB (page_widget))
+ {
+ tabs = g_list_prepend (tabs, TEPL_TAB (page_widget));
+ }
+ }
+
+ return tabs;
+}
+
+static TeplTab *
+tepl_notebook_get_active_tab (TeplTabList *tab_list)
+{
+ GtkNotebook *notebook = GTK_NOTEBOOK (tab_list);
+ gint cur_page_num;
+ GtkWidget *cur_page_widget;
+
+ cur_page_num = gtk_notebook_get_current_page (notebook);
+ if (cur_page_num == -1)
+ {
+ return NULL;
+ }
+
+ cur_page_widget = gtk_notebook_get_nth_page (notebook, cur_page_num);
+ return TEPL_IS_TAB (cur_page_widget) ? TEPL_TAB (cur_page_widget) : NULL;
+}
+
+static void
+tepl_tab_list_interface_init (gpointer g_iface,
+ gpointer iface_data)
+{
+ TeplTabListInterface *interface = g_iface;
+
+ interface->get_tabs = tepl_notebook_get_tabs;
+ interface->get_active_tab = tepl_notebook_get_active_tab;
+}
+
+static void
+tepl_notebook_init (TeplNotebook *notebook)
+{
+ notebook->priv = tepl_notebook_get_instance_private (notebook);
+}
+
+/**
+ * tepl_notebook_new:
+ *
+ * Returns: (transfer floating): a new #TeplNotebook.
+ * Since: 3.0
+ */
+GtkWidget *
+tepl_notebook_new (void)
+{
+ return g_object_new (TEPL_TYPE_NOTEBOOK, NULL);
+}
diff --git a/tepl/tepl-notebook.h b/tepl/tepl-notebook.h
new file mode 100644
index 0000000..7c6c17d
--- /dev/null
+++ b/tepl/tepl-notebook.h
@@ -0,0 +1,60 @@
+/*
+ * This file is part of Tepl, a text editor library.
+ *
+ * Copyright 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
+ * Free Software Foundation; either version 2.1 of the License, or (at your
+ * option) any later version.
+ *
+ * Tepl is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef TEPL_NOTEBOOK_H
+#define TEPL_NOTEBOOK_H
+
+#if !defined (TEPL_H_INSIDE) && !defined (TEPL_COMPILATION)
+#error "Only <tepl/tepl.h> can be included directly."
+#endif
+
+#include <gtk/gtk.h>
+#include <tepl/tepl-types.h>
+
+G_BEGIN_DECLS
+
+#define TEPL_TYPE_NOTEBOOK (tepl_notebook_get_type ())
+#define TEPL_NOTEBOOK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TEPL_TYPE_NOTEBOOK, TeplNotebook))
+#define TEPL_NOTEBOOK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TEPL_TYPE_NOTEBOOK,
TeplNotebookClass))
+#define TEPL_IS_NOTEBOOK(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TEPL_TYPE_NOTEBOOK))
+#define TEPL_IS_NOTEBOOK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TEPL_TYPE_NOTEBOOK))
+#define TEPL_NOTEBOOK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TEPL_TYPE_NOTEBOOK,
TeplNotebookClass))
+
+typedef struct _TeplNotebookClass TeplNotebookClass;
+typedef struct _TeplNotebookPrivate TeplNotebookPrivate;
+
+struct _TeplNotebook
+{
+ GtkNotebook parent;
+
+ TeplNotebookPrivate *priv;
+};
+
+struct _TeplNotebookClass
+{
+ GtkNotebookClass parent_class;
+};
+
+GType tepl_notebook_get_type (void);
+
+GtkWidget * tepl_notebook_new (void);
+
+G_END_DECLS
+
+#endif /* TEPL_NOTEBOOK_H */
diff --git a/tepl/tepl-types.h b/tepl/tepl-types.h
index b988e49..389e945 100644
--- a/tepl/tepl-types.h
+++ b/tepl/tepl-types.h
@@ -44,6 +44,7 @@ typedef struct _TeplFoldRegion TeplFoldRegion;
typedef struct _TeplGutterRendererFolds TeplGutterRendererFolds;
typedef struct _TeplInfoBar TeplInfoBar;
typedef struct _TeplMenuShell TeplMenuShell;
+typedef struct _TeplNotebook TeplNotebook;
typedef struct _TeplTab TeplTab;
typedef struct _TeplTabList TeplTabList;
typedef struct _TeplView TeplView;
diff --git a/tepl/tepl.h b/tepl/tepl.h
index d9d75fa..81d351a 100644
--- a/tepl/tepl.h
+++ b/tepl/tepl.h
@@ -44,6 +44,7 @@
#include <tepl/tepl-menu-item.h>
#include <tepl/tepl-menu-shell.h>
#include <tepl/tepl-metadata-manager.h>
+#include <tepl/tepl-notebook.h>
#include <tepl/tepl-tab.h>
#include <tepl/tepl-tab-list.h>
#include <tepl/tepl-utils.h>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]