[tepl] Implement tepl_menu_shell_append_edit_actions()



commit d94ca3b58161f938fef90a409b2ae25b1d45fe34
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Thu Jul 20 15:33:45 2017 +0200

    Implement tepl_menu_shell_append_edit_actions()

 docs/reference/tepl-3.0-sections.txt |    5 +++
 docs/reference/tepl-docs.xml.in      |    5 +++
 po/POTFILES.in                       |    1 +
 tepl/Makefile.am                     |    2 +
 tepl/tepl-application-window.c       |    2 +
 tepl/tepl-menu-shell.c               |   66 ++++++++++++++++++++++++++++++++++
 tepl/tepl-menu-shell.h               |   35 ++++++++++++++++++
 tepl/tepl.h                          |    1 +
 8 files changed, 117 insertions(+), 0 deletions(-)
---
diff --git a/docs/reference/tepl-3.0-sections.txt b/docs/reference/tepl-3.0-sections.txt
index 159ddac..87ea96a 100644
--- a/docs/reference/tepl-3.0-sections.txt
+++ b/docs/reference/tepl-3.0-sections.txt
@@ -400,6 +400,11 @@ tepl_iter_get_line_indentation
 </SECTION>
 
 <SECTION>
+<FILE>menu-shell</FILE>
+tepl_menu_shell_append_edit_actions
+</SECTION>
+
+<SECTION>
 <FILE>metadata-manager</FILE>
 tepl_metadata_manager_init
 tepl_metadata_manager_shutdown
diff --git a/docs/reference/tepl-docs.xml.in b/docs/reference/tepl-docs.xml.in
index 958d883..ef9cd4e 100644
--- a/docs/reference/tepl-docs.xml.in
+++ b/docs/reference/tepl-docs.xml.in
@@ -47,6 +47,11 @@
       <xi:include href="xml/buffer.xml"/>
     </chapter>
 
+    <chapter id="menus-and-toolbars">
+      <title>Menus</title>
+      <xi:include href="xml/menu-shell.xml"/>
+    </chapter>
+
     <chapter id="file-loading-and-saving">
       <title>File Loading and Saving</title>
       <xi:include href="xml/encoding.xml"/>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 213322b..f9b92f0 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -24,6 +24,7 @@ tepl/tepl-file-saver.c
 tepl/tepl-info-bar.c
 tepl/tepl-init.c
 tepl/tepl-iter.c
+tepl/tepl-menu-shell.c
 tepl/tepl-metadata-manager.c
 tepl/tepl-notebook.c
 tepl/tepl-tab.c
diff --git a/tepl/Makefile.am b/tepl/Makefile.am
index ed1a2dd..86084f7 100644
--- a/tepl/Makefile.am
+++ b/tepl/Makefile.am
@@ -24,6 +24,7 @@ tepl_public_headers =                         \
        tepl-gutter-renderer-folds.h            \
        tepl-info-bar.h                         \
        tepl-iter.h                             \
+       tepl-menu-shell.h                       \
        tepl-metadata-manager.h                 \
        tepl-notebook.h                         \
        tepl-types.h                            \
@@ -45,6 +46,7 @@ tepl_public_c_files =                         \
        tepl-gutter-renderer-folds.c            \
        tepl-info-bar.c                         \
        tepl-iter.c                             \
+       tepl-menu-shell.c                       \
        tepl-metadata-manager.c                 \
        tepl-notebook.c                         \
        tepl-tab.c                              \
diff --git a/tepl/tepl-application-window.c b/tepl/tepl-application-window.c
index 8074ac7..36e9d44 100644
--- a/tepl/tepl-application-window.c
+++ b/tepl/tepl-application-window.c
@@ -52,6 +52,8 @@
  * - `"win.tepl-paste"`: calls tepl_view_paste_clipboard() on the active view.
  * - `"win.tepl-delete"`: calls tepl_view_delete_selection() on the active view.
  * - `"win.tepl-select-all"`: calls tepl_view_select_all() on the active view.
+ *
+ * See the tepl_menu_shell_append_edit_actions() convenience function.
  */
 
 struct _TeplApplicationWindowPrivate
diff --git a/tepl/tepl-menu-shell.c b/tepl/tepl-menu-shell.c
new file mode 100644
index 0000000..96b5a76
--- /dev/null
+++ b/tepl/tepl-menu-shell.c
@@ -0,0 +1,66 @@
+/*
+ * 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-menu-shell.h"
+#include <amtk/amtk.h>
+
+/**
+ * SECTION:menu-shell
+ * @Short_description: #GtkMenuShell functions
+ * @Title: TeplMenuShell
+ *
+ * #GtkMenuShell functions.
+ */
+
+/**
+ * tepl_menu_shell_append_edit_actions:
+ * @menu_shell: a #GtkMenuShell.
+ *
+ * Appends #GtkMenuItem's to @menu_shell for the following #GAction's:
+ * - `"win.tepl-cut"`
+ * - `"win.tepl-copy"`
+ * - `"win.tepl-paste"`
+ * - `"win.tepl-delete"`
+ * - `"win.tepl-select-all"`
+ *
+ * See the [list of GActions implemented in
+ * TeplApplicationWindow][tepl-application-window-gactions]. This function
+ * correctly uses the %AMTK_FACTORY_IGNORE_ACCELS_FOR_APP flag to create the
+ * #GtkMenuItem's.
+ *
+ * Since: 3.0
+ */
+void
+tepl_menu_shell_append_edit_actions (GtkMenuShell *menu_shell)
+{
+       AmtkFactoryMenu *factory;
+
+       g_return_if_fail (GTK_IS_MENU_SHELL (menu_shell));
+
+       factory = amtk_factory_menu_new (NULL);
+       amtk_factory_set_default_flags (AMTK_FACTORY (factory), AMTK_FACTORY_IGNORE_ACCELS_FOR_APP);
+
+       gtk_menu_shell_append (menu_shell, amtk_factory_menu_create_menu_item (factory, "win.tepl-cut"));
+       gtk_menu_shell_append (menu_shell, amtk_factory_menu_create_menu_item (factory, "win.tepl-copy"));
+       gtk_menu_shell_append (menu_shell, amtk_factory_menu_create_menu_item (factory, "win.tepl-paste"));
+       gtk_menu_shell_append (menu_shell, amtk_factory_menu_create_menu_item (factory, "win.tepl-delete"));
+       gtk_menu_shell_append (menu_shell, amtk_factory_menu_create_menu_item (factory, 
"win.tepl-select-all"));
+
+       g_object_unref (factory);
+}
diff --git a/tepl/tepl-menu-shell.h b/tepl/tepl-menu-shell.h
new file mode 100644
index 0000000..db9eec5
--- /dev/null
+++ b/tepl/tepl-menu-shell.h
@@ -0,0 +1,35 @@
+/*
+ * 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_MENU_SHELL_H
+#define TEPL_MENU_SHELL_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_menu_shell_append_edit_actions     (GtkMenuShell *menu_shell);
+
+G_END_DECLS
+
+#endif /* TEPL_MENU_SHELL_H */
diff --git a/tepl/tepl.h b/tepl/tepl.h
index 980f465..c59f330 100644
--- a/tepl/tepl.h
+++ b/tepl/tepl.h
@@ -39,6 +39,7 @@
 #include <tepl/tepl-gutter-renderer-folds.h>
 #include <tepl/tepl-info-bar.h>
 #include <tepl/tepl-iter.h>
+#include <tepl/tepl-menu-shell.h>
 #include <tepl/tepl-metadata-manager.h>
 #include <tepl/tepl-notebook.h>
 #include <tepl/tepl-tab.h>


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