[tepl] Stack: create add_component() function



commit 258b732e917697cd1e8462a3b6709fb5bae0f233
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Mon Apr 20 15:22:31 2020 +0200

    Stack: create add_component() function
    
    This is just the beginning to have a side panel container.

 docs/reference/tepl-docs.xml     |  5 ++++
 docs/reference/tepl-sections.txt |  5 ++++
 po/POTFILES.in                   |  1 +
 tepl/meson.build                 |  2 ++
 tepl/tepl-stack.c                | 58 ++++++++++++++++++++++++++++++++++++++++
 tepl/tepl-stack.h                | 39 +++++++++++++++++++++++++++
 tepl/tepl.h                      |  1 +
 7 files changed, 111 insertions(+)
---
diff --git a/docs/reference/tepl-docs.xml b/docs/reference/tepl-docs.xml
index 9903a03..8c08fe8 100644
--- a/docs/reference/tepl-docs.xml
+++ b/docs/reference/tepl-docs.xml
@@ -40,6 +40,11 @@
       <xi:include href="xml/menu-shell.xml"/>
     </chapter>
 
+    <chapter id="panels">
+      <title>Side and Bottom Panels</title>
+      <xi:include href="xml/stack.xml"/>
+    </chapter>
+
     <chapter id="file-loading-and-saving">
       <title>File Loading and Saving</title>
       <xi:include href="xml/encoding.xml"/>
diff --git a/docs/reference/tepl-sections.txt b/docs/reference/tepl-sections.txt
index dcf0498..b094fa2 100644
--- a/docs/reference/tepl-sections.txt
+++ b/docs/reference/tepl-sections.txt
@@ -318,6 +318,11 @@ TeplMetadataManagerPrivate
 tepl_metadata_manager_get_type
 </SECTION>
 
+<SECTION>
+<FILE>stack</FILE>
+tepl_stack_add_component
+</SECTION>
+
 <SECTION>
 <FILE>statusbar</FILE>
 TeplStatusbar
diff --git a/po/POTFILES.in b/po/POTFILES.in
index db4eb68..f852939 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -23,6 +23,7 @@ tepl/tepl-metadata-manager.c
 tepl/tepl-metadata-parser.c
 tepl/tepl-notebook.c
 tepl/tepl-signal-group.c
+tepl/tepl-stack.c
 tepl/tepl-statusbar.c
 tepl/tepl-tab.c
 tepl/tepl-tab-group.c
diff --git a/tepl/meson.build b/tepl/meson.build
index 7aea597..dc4395e 100644
--- a/tepl/meson.build
+++ b/tepl/meson.build
@@ -18,6 +18,7 @@ tepl_public_headers = [
   'tepl-metadata.h',
   'tepl-metadata-manager.h',
   'tepl-notebook.h',
+  'tepl-stack.h',
   'tepl-statusbar.h',
   'tepl-tab.h',
   'tepl-tab-group.h',
@@ -45,6 +46,7 @@ tepl_public_c_files = [
   'tepl-metadata.c',
   'tepl-metadata-manager.c',
   'tepl-notebook.c',
+  'tepl-stack.c',
   'tepl-statusbar.c',
   'tepl-tab.c',
   'tepl-tab-group.c',
diff --git a/tepl/tepl-stack.c b/tepl/tepl-stack.c
new file mode 100644
index 0000000..729c529
--- /dev/null
+++ b/tepl/tepl-stack.c
@@ -0,0 +1,58 @@
+/*
+ * This file is part of Tepl, a text editor library.
+ *
+ * Copyright 2020 - 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-stack.h"
+
+/**
+ * SECTION:stack
+ * @Title: TeplStack
+ * @Short_description: #GtkStack functions
+ *
+ * #GtkStack functions.
+ */
+
+/**
+ * tepl_stack_add_component:
+ * @stack: a #GtkStack.
+ * @child: the #GtkWidget to add to the @stack.
+ * @name: the name for @child.
+ * @title: a human-readable title for @child.
+ * @icon_name: the icon name for @child.
+ *
+ * The same as gtk_stack_add_titled(), but sets in addition the “icon-name”
+ * child property.
+ *
+ * Since: 5.0
+ */
+void
+tepl_stack_add_component (GtkStack    *stack,
+                         GtkWidget   *child,
+                         const gchar *name,
+                         const gchar *title,
+                         const gchar *icon_name)
+{
+       g_return_if_fail (icon_name != NULL);
+
+       gtk_stack_add_titled (stack, child, name, title);
+
+       gtk_container_child_set (GTK_CONTAINER (stack),
+                                child,
+                                "icon-name", icon_name,
+                                NULL);
+}
diff --git a/tepl/tepl-stack.h b/tepl/tepl-stack.h
new file mode 100644
index 0000000..74e82b7
--- /dev/null
+++ b/tepl/tepl-stack.h
@@ -0,0 +1,39 @@
+/*
+ * This file is part of Tepl, a text editor library.
+ *
+ * Copyright 2020 - 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_STACK_H
+#define TEPL_STACK_H
+
+#if !defined (TEPL_H_INSIDE) && !defined (TEPL_COMPILATION)
+#error "Only <tepl/tepl.h> can be included directly."
+#endif
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+void   tepl_stack_add_component        (GtkStack    *stack,
+                                        GtkWidget   *child,
+                                        const gchar *name,
+                                        const gchar *title,
+                                        const gchar *icon_name);
+
+G_END_DECLS
+
+#endif /* TEPL_STACK_H */
diff --git a/tepl/tepl.h b/tepl/tepl.h
index d54d0f1..987ef25 100644
--- a/tepl/tepl.h
+++ b/tepl/tepl.h
@@ -44,6 +44,7 @@
 #include <tepl/tepl-metadata.h>
 #include <tepl/tepl-metadata-manager.h>
 #include <tepl/tepl-notebook.h>
+#include <tepl/tepl-stack.h>
 #include <tepl/tepl-statusbar.h>
 #include <tepl/tepl-tab.h>
 #include <tepl/tepl-tab-group.h>


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