1 /*
2 * pluma-commands-edit.c
3 * This file is part of pluma
4 *
5 * Copyright (C) 1998, 1999 Alex Roberts, Evan Lawrence
6 * Copyright (C) 2000, 2001 Chema Celorio, Paolo Maggi
7 * Copyright (C) 2002-2005 Paolo Maggi
8 * Copyright (C) 2012-2021 MATE Developers
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin St, Fifth Floor,
23 * Boston, MA 02110-1301, USA.
24 */
25
26 /*
27 * Modified by the pluma Team, 1998-2005. See the AUTHORS file for a
28 * list of people on the pluma Team.
29 * See the ChangeLog files for a list of changes.
30 *
31 * $Id$
32 */
33
34 #ifdef HAVE_CONFIG_H
35 #include <config.h>
36 #endif
37
38 #include <gtk/gtk.h>
39
40 #include "pluma-commands.h"
41 #include "pluma-window.h"
42 #include "pluma-debug.h"
43 #include "pluma-view.h"
44 #include "dialogs/pluma-preferences-dialog.h"
45
46 void
_pluma_cmd_edit_undo(GtkAction * action,PlumaWindow * window)47 _pluma_cmd_edit_undo (GtkAction *action,
48 PlumaWindow *window)
49 {
50 PlumaView *active_view;
51 GtkSourceBuffer *active_document;
52
53 pluma_debug (DEBUG_COMMANDS);
54
55 active_view = pluma_window_get_active_view (window);
56 g_return_if_fail (active_view);
57
58 active_document = GTK_SOURCE_BUFFER (gtk_text_view_get_buffer (GTK_TEXT_VIEW (active_view)));
59
60 gtk_source_buffer_undo (active_document);
61
62 pluma_view_scroll_to_cursor (active_view);
63
64 gtk_widget_grab_focus (GTK_WIDGET (active_view));
65 }
66
67 void
_pluma_cmd_edit_redo(GtkAction * action,PlumaWindow * window)68 _pluma_cmd_edit_redo (GtkAction *action,
69 PlumaWindow *window)
70 {
71 PlumaView *active_view;
72 GtkSourceBuffer *active_document;
73
74 pluma_debug (DEBUG_COMMANDS);
75
76 active_view = pluma_window_get_active_view (window);
77 g_return_if_fail (active_view);
78
79 active_document = GTK_SOURCE_BUFFER (gtk_text_view_get_buffer (GTK_TEXT_VIEW (active_view)));
80
81 gtk_source_buffer_redo (active_document);
82
83 pluma_view_scroll_to_cursor (active_view);
84
85 gtk_widget_grab_focus (GTK_WIDGET (active_view));
86 }
87
88 void
_pluma_cmd_edit_cut(GtkAction * action,PlumaWindow * window)89 _pluma_cmd_edit_cut (GtkAction *action,
90 PlumaWindow *window)
91 {
92 PlumaView *active_view;
93
94 pluma_debug (DEBUG_COMMANDS);
95
96 active_view = pluma_window_get_active_view (window);
97 g_return_if_fail (active_view);
98
99 pluma_view_cut_clipboard (active_view);
100
101 gtk_widget_grab_focus (GTK_WIDGET (active_view));
102 }
103
104 void
_pluma_cmd_edit_copy(GtkAction * action,PlumaWindow * window)105 _pluma_cmd_edit_copy (GtkAction *action,
106 PlumaWindow *window)
107 {
108 PlumaView *active_view;
109
110 pluma_debug (DEBUG_COMMANDS);
111
112 active_view = pluma_window_get_active_view (window);
113 g_return_if_fail (active_view);
114
115 pluma_view_copy_clipboard (active_view);
116
117 gtk_widget_grab_focus (GTK_WIDGET (active_view));
118 }
119
120 void
_pluma_cmd_edit_paste(GtkAction * action,PlumaWindow * window)121 _pluma_cmd_edit_paste (GtkAction *action,
122 PlumaWindow *window)
123 {
124 PlumaView *active_view;
125
126 pluma_debug (DEBUG_COMMANDS);
127
128 active_view = pluma_window_get_active_view (window);
129 g_return_if_fail (active_view);
130
131 pluma_view_paste_clipboard (active_view);
132
133 gtk_widget_grab_focus (GTK_WIDGET (active_view));
134 }
135
136 void
_pluma_cmd_edit_delete(GtkAction * action,PlumaWindow * window)137 _pluma_cmd_edit_delete (GtkAction *action,
138 PlumaWindow *window)
139 {
140 PlumaView *active_view;
141
142 pluma_debug (DEBUG_COMMANDS);
143
144 active_view = pluma_window_get_active_view (window);
145 g_return_if_fail (active_view);
146
147 pluma_view_delete_selection (active_view);
148
149 gtk_widget_grab_focus (GTK_WIDGET (active_view));
150 }
151
152 void
_pluma_cmd_edit_select_all(GtkAction * action,PlumaWindow * window)153 _pluma_cmd_edit_select_all (GtkAction *action,
154 PlumaWindow *window)
155 {
156 PlumaView *active_view;
157
158 pluma_debug (DEBUG_COMMANDS);
159
160 active_view = pluma_window_get_active_view (window);
161 g_return_if_fail (active_view);
162
163 pluma_view_select_all (active_view);
164
165 gtk_widget_grab_focus (GTK_WIDGET (active_view));
166 }
167
168 void
_pluma_cmd_edit_upper_case(GtkAction * action,PlumaWindow * window)169 _pluma_cmd_edit_upper_case (GtkAction *action,
170 PlumaWindow *window)
171 {
172 PlumaView *active_view;
173
174 pluma_debug (DEBUG_COMMANDS);
175
176 active_view = pluma_window_get_active_view (window);
177 g_return_if_fail (active_view);
178
179 pluma_view_upper_case_selection (active_view);
180
181 gtk_widget_grab_focus (GTK_WIDGET (active_view));
182 }
183
184 void
_pluma_cmd_edit_lower_case(GtkAction * action,PlumaWindow * window)185 _pluma_cmd_edit_lower_case (GtkAction *action,
186 PlumaWindow *window)
187 {
188 PlumaView *active_view;
189
190 pluma_debug (DEBUG_COMMANDS);
191
192 active_view = pluma_window_get_active_view (window);
193 g_return_if_fail (active_view);
194
195 pluma_view_lower_case_selection (active_view);
196
197 gtk_widget_grab_focus (GTK_WIDGET (active_view));
198 }
199
200 void
_pluma_cmd_edit_invert_case(GtkAction * action,PlumaWindow * window)201 _pluma_cmd_edit_invert_case (GtkAction *action,
202 PlumaWindow *window)
203 {
204 PlumaView *active_view;
205
206 pluma_debug (DEBUG_COMMANDS);
207
208 active_view = pluma_window_get_active_view (window);
209 g_return_if_fail (active_view);
210
211 pluma_view_invert_case_selection (active_view);
212
213 gtk_widget_grab_focus (GTK_WIDGET (active_view));
214 }
215
216 void
_pluma_cmd_edit_title_case(GtkAction * action,PlumaWindow * window)217 _pluma_cmd_edit_title_case (GtkAction *action,
218 PlumaWindow *window)
219 {
220 PlumaView *active_view;
221
222 pluma_debug (DEBUG_COMMANDS);
223
224 active_view = pluma_window_get_active_view (window);
225 g_return_if_fail (active_view);
226
227 pluma_view_title_case_selection (active_view);
228
229 gtk_widget_grab_focus (GTK_WIDGET (active_view));
230 }
231
232 void
_pluma_cmd_edit_preferences(GtkAction * action,PlumaWindow * window)233 _pluma_cmd_edit_preferences (GtkAction *action,
234 PlumaWindow *window)
235 {
236 pluma_debug (DEBUG_COMMANDS);
237
238 pluma_show_preferences_dialog (window);
239 }
240