[tepl/wip/tab-list] Implement TeplTabList interface



commit 8ad80ca07aa57d9c01597c5dac25c0ee9a5fccbf
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Sat Jun 24 07:06:03 2017 +0200

    Implement TeplTabList interface

 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-tab-list.c                 |  117 ++++++++++++++++++++++++++++++++++
 tepl/tepl-tab-list.h                 |   72 +++++++++++++++++++++
 tepl/tepl-types.h                    |    1 +
 tepl/tepl.h                          |    1 +
 8 files changed, 211 insertions(+), 0 deletions(-)
---
diff --git a/docs/reference/tepl-3.0-sections.txt b/docs/reference/tepl-3.0-sections.txt
index ea63224..ee28e14 100644
--- a/docs/reference/tepl-3.0-sections.txt
+++ b/docs/reference/tepl-3.0-sections.txt
@@ -362,6 +362,22 @@ tepl_tab_get_type
 </SECTION>
 
 <SECTION>
+<FILE>tab-list</FILE>
+TeplTabList
+TeplTabListInterface
+tepl_tab_list_get_tabs
+tepl_tab_list_get_active_tab
+tepl_tab_list_get_active_view
+tepl_tab_list_get_active_buffer
+<SUBSECTION Standard>
+TEPL_IS_TAB_LIST
+TEPL_TAB_LIST
+TEPL_TAB_LIST_GET_INTERFACE
+TEPL_TYPE_TAB_LIST
+tepl_tab_list_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 e37d0e8..58f2896 100644
--- a/docs/reference/tepl-docs.xml.in
+++ b/docs/reference/tepl-docs.xml.in
@@ -21,6 +21,7 @@
       <title>Framework</title>
       <xi:include href="xml/application.xml"/>
       <xi:include href="xml/application-window.xml"/>
+      <xi:include href="xml/tab-list.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 88ab969..de15d83 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -21,5 +21,6 @@ tepl/tepl-menu-item.c
 tepl/tepl-menu-shell.c
 tepl/tepl-metadata-manager.c
 tepl/tepl-tab.c
+tepl/tepl-tab-list.c
 tepl/tepl-utils.c
 tepl/tepl-view.c
diff --git a/tepl/Makefile.am b/tepl/Makefile.am
index a292039..a8d5e85 100644
--- a/tepl/Makefile.am
+++ b/tepl/Makefile.am
@@ -33,6 +33,7 @@ tepl_public_headers =                         \
        tepl-metadata-manager.h                 \
        tepl-types.h                            \
        tepl-tab.h                              \
+       tepl-tab-list.h                         \
        tepl-utils.h                            \
        tepl-view.h
 
@@ -57,6 +58,7 @@ tepl_public_c_files =                         \
        tepl-menu-shell.c                       \
        tepl-metadata-manager.c                 \
        tepl-tab.c                              \
+       tepl-tab-list.c                         \
        tepl-utils.c                            \
        tepl-view.c
 
diff --git a/tepl/tepl-tab-list.c b/tepl/tepl-tab-list.c
new file mode 100644
index 0000000..605a7d2
--- /dev/null
+++ b/tepl/tepl-tab-list.c
@@ -0,0 +1,117 @@
+/*
+ * 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-tab-list.h"
+#include "tepl-tab.h"
+
+/**
+ * SECTION:tab-list
+ * @Short_description: Interface for a list of #TeplTab's
+ * @Title: TeplTabList
+ */
+
+G_DEFINE_INTERFACE (TeplTabList, tepl_tab_list, G_TYPE_OBJECT)
+
+static GList *
+tepl_tab_list_get_tabs_default (TeplTabList *tab_list)
+{
+       return NULL;
+}
+
+static TeplTab *
+tepl_tab_list_get_active_tab_default (TeplTabList *tab_list)
+{
+       return NULL;
+}
+
+static void
+tepl_tab_list_default_init (TeplTabListInterface *interface)
+{
+       interface->get_tabs = tepl_tab_list_get_tabs_default;
+       interface->get_active_tab = tepl_tab_list_get_active_tab_default;
+}
+
+/**
+ * tepl_tab_list_get_tabs:
+ * @tab_list: a #TeplTabList.
+ *
+ * Returns: (transfer container) (element-type TeplTab): the list of all the
+ * #TeplTab's contained in @tab_list.
+ * Since: 3.0
+ */
+GList *
+tepl_tab_list_get_tabs (TeplTabList *tab_list)
+{
+       g_return_val_if_fail (TEPL_IS_TAB_LIST (tab_list), NULL);
+
+       return TEPL_TAB_LIST_GET_INTERFACE (tab_list)->get_tabs (tab_list);
+}
+
+/**
+ * tepl_tab_list_get_active_tab:
+ * @tab_list: a #TeplTabList.
+ *
+ * Returns: (transfer none): the #TeplTab currently shown in @tab_list.
+ * Since: 3.0
+ */
+TeplTab *
+tepl_tab_list_get_active_tab (TeplTabList *tab_list)
+{
+       g_return_val_if_fail (TEPL_IS_TAB_LIST (tab_list), NULL);
+
+       return TEPL_TAB_LIST_GET_INTERFACE (tab_list)->get_active_tab (tab_list);
+}
+
+/**
+ * tepl_tab_list_get_active_view:
+ * @tab_list: a #TeplTabList.
+ *
+ * Returns: (transfer none): the #TeplView of the active tab.
+ * Since: 3.0
+ */
+TeplView *
+tepl_tab_list_get_active_view (TeplTabList *tab_list)
+{
+       TeplTab *active_tab;
+
+       g_return_val_if_fail (TEPL_IS_TAB_LIST (tab_list), NULL);
+
+       active_tab = tepl_tab_list_get_active_tab (tab_list);
+
+       return active_tab != NULL ? tepl_tab_get_view (active_tab) : NULL;
+}
+
+/**
+ * tepl_tab_list_get_active_buffer:
+ * @tab_list: a #TeplTabList.
+ *
+ * Returns: (transfer none): the #TeplBuffer of the active tab.
+ * Since: 3.0
+ */
+TeplBuffer *
+tepl_tab_list_get_active_buffer (TeplTabList *tab_list)
+{
+       TeplTab *active_tab;
+
+       g_return_val_if_fail (TEPL_IS_TAB_LIST (tab_list), NULL);
+
+       active_tab = tepl_tab_list_get_active_tab (tab_list);
+
+       return active_tab != NULL ? tepl_tab_get_buffer (active_tab) : NULL;
+}
diff --git a/tepl/tepl-tab-list.h b/tepl/tepl-tab-list.h
new file mode 100644
index 0000000..e94b711
--- /dev/null
+++ b/tepl/tepl-tab-list.h
@@ -0,0 +1,72 @@
+/*
+ * 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_TAB_LIST_H
+#define TEPL_TAB_LIST_H
+
+#if !defined (TEPL_H_INSIDE) && !defined (TEPL_COMPILATION)
+#error "Only <tepl/tepl.h> can be included directly."
+#endif
+
+#include <glib-object.h>
+#include <tepl/tepl-types.h>
+
+G_BEGIN_DECLS
+
+#define TEPL_TYPE_TAB_LIST               (tepl_tab_list_get_type ())
+#define TEPL_TAB_LIST(obj)               (G_TYPE_CHECK_INSTANCE_CAST ((obj), TEPL_TYPE_TAB_LIST, 
TeplTabList))
+#define TEPL_IS_TAB_LIST(obj)            (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TEPL_TYPE_TAB_LIST))
+#define TEPL_TAB_LIST_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), TEPL_TYPE_TAB_LIST, 
TeplTabListInterface))
+
+typedef struct _TeplTabListInterface TeplTabListInterface;
+
+/**
+ * TeplTabListInterface:
+ * @parent_interface: The parent interface.
+ * @get_tabs: Virtual function pointer for tepl_tab_list_get_tabs(). By default,
+ *   %NULL is returned.
+ * @get_active_tab: Virtual function pointer for tepl_tab_list_get_active_tab().
+ *   By default, %NULL is returned.
+ *
+ * The virtual function table for #TeplTabList.
+ *
+ * Since: 3.0
+ */
+struct _TeplTabListInterface
+{
+       GTypeInterface parent_interface;
+
+       GList *         (*get_tabs)             (TeplTabList *tab_list);
+
+       TeplTab *       (*get_active_tab)       (TeplTabList *tab_list);
+};
+
+GType          tepl_tab_list_get_type          (void);
+
+GList *                tepl_tab_list_get_tabs          (TeplTabList *tab_list);
+
+TeplTab *      tepl_tab_list_get_active_tab    (TeplTabList *tab_list);
+
+TeplView *     tepl_tab_list_get_active_view   (TeplTabList *tab_list);
+
+TeplBuffer *   tepl_tab_list_get_active_buffer (TeplTabList *tab_list);
+
+G_END_DECLS
+
+#endif /* TEPL_TAB_LIST_H */
diff --git a/tepl/tepl-types.h b/tepl/tepl-types.h
index 0d4d3db..b988e49 100644
--- a/tepl/tepl-types.h
+++ b/tepl/tepl-types.h
@@ -45,6 +45,7 @@ typedef struct _TeplGutterRendererFolds               TeplGutterRendererFolds;
 typedef struct _TeplInfoBar                    TeplInfoBar;
 typedef struct _TeplMenuShell                  TeplMenuShell;
 typedef struct _TeplTab                                TeplTab;
+typedef struct _TeplTabList                    TeplTabList;
 typedef struct _TeplView                       TeplView;
 
 G_END_DECLS
diff --git a/tepl/tepl.h b/tepl/tepl.h
index 5729971..d9d75fa 100644
--- a/tepl/tepl.h
+++ b/tepl/tepl.h
@@ -45,6 +45,7 @@
 #include <tepl/tepl-menu-shell.h>
 #include <tepl/tepl-metadata-manager.h>
 #include <tepl/tepl-tab.h>
+#include <tepl/tepl-tab-list.h>
 #include <tepl/tepl-utils.h>
 #include <tepl/tepl-view.h>
 


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