[tepl] ApplicationWindow: merge tepl-application-window-actions.c
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tepl] ApplicationWindow: merge tepl-application-window-actions.c
- Date: Sun, 23 Jul 2017 09:45:22 +0000 (UTC)
commit 21e75c785292a90b2a6a60fbc88a7b7f37c71d62
Author: Sébastien Wilmet <swilmet gnome org>
Date: Sun Jul 23 11:36:25 2017 +0200
ApplicationWindow: merge tepl-application-window-actions.c
To update the GAction:enabled properties, listening to some signals is
required, and storing TeplSignalGroup's to the Private struct.
So move the code of tepl-application-window-actions.c to
tepl-application-window.c. With AmtkApplicationWindow, a lot of code has
also been removed from TeplApplicationWindow.
When a lot of GActions will be implemented, maybe TeplApplicationWindow
will become messy and another solution will need to be found.
docs/reference/Makefile.am | 1 -
po/POTFILES.in | 1 -
tepl/Makefile.am | 2 -
tepl/tepl-application-window-actions.c | 136 --------------------------------
tepl/tepl-application-window-actions.h | 35 --------
tepl/tepl-application-window.c | 108 +++++++++++++++++++++++++-
6 files changed, 106 insertions(+), 177 deletions(-)
---
diff --git a/docs/reference/Makefile.am b/docs/reference/Makefile.am
index 86b4a0c..fa3e9a2 100644
--- a/docs/reference/Makefile.am
+++ b/docs/reference/Makefile.am
@@ -26,7 +26,6 @@ CFILE_GLOB = $(top_srcdir)/tepl/*.c $(top_srcdir)/amtk/*.c
IGNORE_HFILES = \
amtk.h \
tepl.h \
- tepl-application-window-actions.h \
tepl-buffer-input-stream.h \
tepl-encoding-converter.h \
tepl-encoding-private.h \
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 236ba41..d375c79 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -11,7 +11,6 @@ amtk/amtk-menu-shell.c
amtk/amtk-utils.c
tepl/tepl-application.c
tepl/tepl-application-window.c
-tepl/tepl-application-window-actions.c
tepl/tepl-buffer.c
tepl/tepl-buffer-input-stream.c
tepl/tepl-encoding.c
diff --git a/tepl/Makefile.am b/tepl/Makefile.am
index 85f9832..e979fdd 100644
--- a/tepl/Makefile.am
+++ b/tepl/Makefile.am
@@ -56,7 +56,6 @@ tepl_public_c_files = \
tepl_private_headers = \
gconstructor.h \
- tepl-application-window-actions.h \
tepl-buffer-input-stream.h \
tepl-encoding-converter.h \
tepl-encoding-private.h \
@@ -66,7 +65,6 @@ tepl_private_headers = \
tepl-signal-group.h
tepl_private_c_files = \
- tepl-application-window-actions.c \
tepl-buffer-input-stream.c \
tepl-encoding-converter.c \
tepl-file-content-loader.c \
diff --git a/tepl/tepl-application-window.c b/tepl/tepl-application-window.c
index cea6b05..255ecbd 100644
--- a/tepl/tepl-application-window.c
+++ b/tepl/tepl-application-window.c
@@ -18,8 +18,9 @@
*/
#include "tepl-application-window.h"
-#include "tepl-application-window-actions.h"
+#include <amtk/amtk.h>
#include "tepl-tab-group.h"
+#include "tepl-view.h"
/**
* SECTION:application-window
@@ -84,6 +85,109 @@ G_DEFINE_TYPE_WITH_CODE (TeplApplicationWindow,
tepl_tab_group_interface_init))
static void
+cut_cb (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
+{
+ TeplApplicationWindow *tepl_window = TEPL_APPLICATION_WINDOW (user_data);
+ TeplView *active_view;
+
+ active_view = tepl_tab_group_get_active_view (TEPL_TAB_GROUP (tepl_window));
+
+ if (active_view != NULL)
+ {
+ tepl_view_cut_clipboard (active_view);
+ }
+}
+
+static void
+copy_cb (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
+{
+ TeplApplicationWindow *tepl_window = TEPL_APPLICATION_WINDOW (user_data);
+ TeplView *active_view;
+
+ active_view = tepl_tab_group_get_active_view (TEPL_TAB_GROUP (tepl_window));
+
+ if (active_view != NULL)
+ {
+ tepl_view_copy_clipboard (active_view);
+ }
+}
+
+static void
+paste_cb (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
+{
+ TeplApplicationWindow *tepl_window = TEPL_APPLICATION_WINDOW (user_data);
+ TeplView *active_view;
+
+ active_view = tepl_tab_group_get_active_view (TEPL_TAB_GROUP (tepl_window));
+
+ if (active_view != NULL)
+ {
+ tepl_view_paste_clipboard (active_view);
+ }
+}
+
+static void
+delete_cb (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
+{
+ TeplApplicationWindow *tepl_window = TEPL_APPLICATION_WINDOW (user_data);
+ TeplView *active_view;
+
+ active_view = tepl_tab_group_get_active_view (TEPL_TAB_GROUP (tepl_window));
+
+ if (active_view != NULL)
+ {
+ tepl_view_delete_selection (active_view);
+ }
+}
+
+static void
+select_all_cb (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
+{
+ TeplApplicationWindow *tepl_window = TEPL_APPLICATION_WINDOW (user_data);
+ TeplView *active_view;
+
+ active_view = tepl_tab_group_get_active_view (TEPL_TAB_GROUP (tepl_window));
+
+ if (active_view != NULL)
+ {
+ tepl_view_select_all (active_view);
+ }
+}
+
+static void
+add_actions (TeplApplicationWindow *tepl_window)
+{
+ /* The actions need to be namespaced, to not conflict with the
+ * application or other libraries.
+ *
+ * Do not forget to document each action in the TeplApplicationWindow
+ * class description, and to add the corresponding AmtkActionInfoEntry
+ * in tepl-application.c.
+ */
+ const GActionEntry entries[] = {
+ { "tepl-cut", cut_cb },
+ { "tepl-copy", copy_cb },
+ { "tepl-paste", paste_cb },
+ { "tepl-delete", delete_cb },
+ { "tepl-select-all", select_all_cb },
+ };
+
+ amtk_action_map_add_action_entries_check_dups (G_ACTION_MAP (tepl_window->priv->gtk_window),
+ entries,
+ G_N_ELEMENTS (entries),
+ tepl_window);
+}
+static void
tepl_application_window_get_property (GObject *object,
guint prop_id,
GValue *value,
@@ -152,7 +256,7 @@ tepl_application_window_constructed (GObject *object)
G_OBJECT_CLASS (tepl_application_window_parent_class)->constructed (object);
}
- _tepl_application_window_add_actions (tepl_window);
+ add_actions (tepl_window);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]