summaryrefslogtreecommitdiff
path: root/pluma
diff options
context:
space:
mode:
authormbkma <[email protected]>2020-08-05 11:19:36 +0200
committerGitHub <[email protected]>2020-08-05 11:19:36 +0200
commitd85c0aa6ec87e91901e393f701873085e5eeddb0 (patch)
tree6b7bcb1dc2ccff35cf865104e5d887306a253972 /pluma
parent3c2bf1aef96a7a94c58d9e99ac12a0d8cd788259 (diff)
downloadpluma-d85c0aa6ec87e91901e393f701873085e5eeddb0.tar.bz2
pluma-d85c0aa6ec87e91901e393f701873085e5eeddb0.tar.xz
Remove changecase plugin. Functionality is provided by GtkSourceView. (#565)
Diffstat (limited to 'pluma')
-rw-r--r--pluma/pluma-commands-edit.c64
-rw-r--r--pluma/pluma-commands.h8
-rw-r--r--pluma/pluma-ui.h9
-rw-r--r--pluma/pluma-ui.xml26
-rw-r--r--pluma/pluma-view.c97
-rw-r--r--pluma/pluma-view.h6
6 files changed, 200 insertions, 10 deletions
diff --git a/pluma/pluma-commands-edit.c b/pluma/pluma-commands-edit.c
index 3915da8f..71e953af 100644
--- a/pluma/pluma-commands-edit.c
+++ b/pluma/pluma-commands-edit.c
@@ -165,6 +165,70 @@ _pluma_cmd_edit_select_all (GtkAction *action,
}
void
+_pluma_cmd_edit_upper_case (GtkAction *action,
+ PlumaWindow *window)
+{
+ PlumaView *active_view;
+
+ pluma_debug (DEBUG_COMMANDS);
+
+ active_view = pluma_window_get_active_view (window);
+ g_return_if_fail (active_view);
+
+ pluma_view_upper_case_selection (active_view);
+
+ gtk_widget_grab_focus (GTK_WIDGET (active_view));
+}
+
+void
+_pluma_cmd_edit_lower_case (GtkAction *action,
+ PlumaWindow *window)
+{
+ PlumaView *active_view;
+
+ pluma_debug (DEBUG_COMMANDS);
+
+ active_view = pluma_window_get_active_view (window);
+ g_return_if_fail (active_view);
+
+ pluma_view_lower_case_selection (active_view);
+
+ gtk_widget_grab_focus (GTK_WIDGET (active_view));
+}
+
+void
+_pluma_cmd_edit_invert_case (GtkAction *action,
+ PlumaWindow *window)
+{
+ PlumaView *active_view;
+
+ pluma_debug (DEBUG_COMMANDS);
+
+ active_view = pluma_window_get_active_view (window);
+ g_return_if_fail (active_view);
+
+ pluma_view_invert_case_selection (active_view);
+
+ gtk_widget_grab_focus (GTK_WIDGET (active_view));
+}
+
+void
+_pluma_cmd_edit_title_case (GtkAction *action,
+ PlumaWindow *window)
+{
+ PlumaView *active_view;
+
+ pluma_debug (DEBUG_COMMANDS);
+
+ active_view = pluma_window_get_active_view (window);
+ g_return_if_fail (active_view);
+
+ pluma_view_title_case_selection (active_view);
+
+ gtk_widget_grab_focus (GTK_WIDGET (active_view));
+}
+
+void
_pluma_cmd_edit_preferences (GtkAction *action,
PlumaWindow *window)
{
diff --git a/pluma/pluma-commands.h b/pluma/pluma-commands.h
index 2fc44259..b2d5b423 100644
--- a/pluma/pluma-commands.h
+++ b/pluma/pluma-commands.h
@@ -103,6 +103,14 @@ void _pluma_cmd_edit_paste (GtkAction *action,
PlumaWindow *window);
void _pluma_cmd_edit_delete (GtkAction *action,
PlumaWindow *window);
+void _pluma_cmd_edit_upper_case (GtkAction *action,
+ PlumaWindow *window);
+void _pluma_cmd_edit_lower_case (GtkAction *action,
+ PlumaWindow *window);
+void _pluma_cmd_edit_invert_case (GtkAction *action,
+ PlumaWindow *window);
+void _pluma_cmd_edit_title_case (GtkAction *action,
+ PlumaWindow *window);
void _pluma_cmd_edit_select_all (GtkAction *action,
PlumaWindow *window);
void _pluma_cmd_edit_preferences (GtkAction *action,
diff --git a/pluma/pluma-ui.h b/pluma/pluma-ui.h
index 824e1e32..2567ebb0 100644
--- a/pluma/pluma-ui.h
+++ b/pluma/pluma-ui.h
@@ -103,6 +103,15 @@ static const GtkActionEntry pluma_menu_entries[] =
N_("Delete the selected text"), G_CALLBACK (_pluma_cmd_edit_delete) },
{ "EditSelectAll", "edit-select-all", N_("Select _All"), "<control>A",
N_("Select the entire document"), G_CALLBACK (_pluma_cmd_edit_select_all) },
+ { "ChangeCase", NULL, N_("C_hange Case"), NULL, NULL, NULL },
+ { "UpperCase", NULL, N_("All _Upper Case"), NULL,
+ N_("Change selected text to upper case"), G_CALLBACK (_pluma_cmd_edit_upper_case) },
+ { "LowerCase", NULL, N_("All _Lower Case"), NULL,
+ N_("Change selected text to lower case"), G_CALLBACK (_pluma_cmd_edit_lower_case) },
+ { "InvertCase", NULL, N_("_Invert Case"), NULL,
+ N_("Invert the case of selected text"), G_CALLBACK (_pluma_cmd_edit_invert_case) },
+ { "TitleCase", NULL, N_("_Title Case"), NULL,
+ N_("Capitalize the first letter of each selected word"), G_CALLBACK (_pluma_cmd_edit_title_case) },
/* View menu */
{ "ViewHighlightMode", NULL, N_("_Highlight Mode") },
diff --git a/pluma/pluma-ui.xml b/pluma/pluma-ui.xml
index f2c69b42..0c2c0d95 100644
--- a/pluma/pluma-ui.xml
+++ b/pluma/pluma-ui.xml
@@ -2,7 +2,7 @@
* pluma-ui.xml
* This file is part of pluma
*
- * Copyright (C) 2005 - Paolo Maggi
+ * Copyright (C) 2005 - Paolo Maggi
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -19,9 +19,9 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
- * Modified by the pluma Team, 2005. See the AUTHORS file for a
- * list of people on the pluma Team.
- * See the ChangeLog files for a list of changes.
+ * Modified by the pluma Team, 2005. See the AUTHORS file for a
+ * list of people on the pluma Team.
+ * See the ChangeLog files for a list of changes.
*
* $Id$
-->
@@ -60,9 +60,9 @@
<menuitem name="EditCopyMenu" action="EditCopy"/>
<menuitem name="EditPasteMenu" action="EditPaste"/>
<menuitem name="EditDeleteMenu" action="EditDelete"/>
- <placeholder name="EditOps_1" />
+ <placeholder name="EditOps_1" />
<separator/>
- <placeholder name="EditOps_2" />
+ <placeholder name="EditOps_2" />
<menuitem name="EditSelectAllMenu" action="EditSelectAll"/>
<placeholder name="EditOps_3" />
<separator/>
@@ -71,6 +71,12 @@
<placeholder name="EditOps_5" />
<separator/>
<placeholder name="EditOps_6" />
+ <menu name="ChangeCaseMenu" action="ChangeCase">
+ <menuitem name="UpperCaseMenu" action="UpperCase" />
+ <menuitem name="LowerCaseMenu" action="LowerCase" />
+ <menuitem name="InvertCaseMenu" action="InvertCase" />
+ <menuitem name="TitleCaseMenu" action="TitleCase" />
+ </menu>
<separator/>
<menuitem name="EditPreferencesMenu" action="EditPreferences"/>
</menu>
@@ -103,12 +109,12 @@
<separator/>
<placeholder name="SearchOps_4" />
<separator/>
- <menuitem name="SearchClearHighlight" action="SearchClearHighlight"/>
+ <menuitem name="SearchClearHighlight" action="SearchClearHighlight"/>
<placeholder name="SearchOps_5" />
<separator/>
<placeholder name="SearchOps_6" />
<separator/>
- <menuitem name="SearchGoToLineMenu" action="SearchGoToLine"/>
+ <menuitem name="SearchGoToLineMenu" action="SearchGoToLine"/>
<placeholder name="SearchOps_7" />
<separator/>
<placeholder name="SearchOps_8" />
@@ -136,7 +142,7 @@
<placeholder name="DocumentsOps_2" />
<separator/>
<placeholder name="DocumentsOps_3" />
- <menuitem action="DocumentsPreviousDocument" />
+ <menuitem action="DocumentsPreviousDocument" />
<menuitem action="DocumentsNextDocument" />
<separator/>
<menuitem action="DocumentsMoveToNewWindow"/>
@@ -195,7 +201,7 @@
<separator/>
<menuitem action="FilePrint"/>
<separator/>
- <placeholder name="NotebookPupupOps_1"/>
+ <placeholder name="NotebookPupupOps_1"/>
<separator/>
<menuitem name="FileCloseMenu" action="FileClose"/>
</popup>
diff --git a/pluma/pluma-view.c b/pluma/pluma-view.c
index 24bc0007..1c376877 100644
--- a/pluma/pluma-view.c
+++ b/pluma/pluma-view.c
@@ -323,6 +323,27 @@ pluma_view_class_init (PlumaViewClass *klass)
"delete_from_cursor", 2,
G_TYPE_ENUM, GTK_DELETE_PARAGRAPHS,
G_TYPE_INT, 1);
+
+ gtk_binding_entry_add_signal (binding_set,
+ GDK_KEY_u,
+ GDK_CONTROL_MASK,
+ "change_case", 1,
+ G_TYPE_ENUM, GTK_SOURCE_CHANGE_CASE_UPPER);
+ gtk_binding_entry_add_signal (binding_set,
+ GDK_KEY_l,
+ GDK_CONTROL_MASK,
+ "change_case", 1,
+ G_TYPE_ENUM, GTK_SOURCE_CHANGE_CASE_LOWER);
+ gtk_binding_entry_add_signal (binding_set,
+ GDK_KEY_u,
+ GDK_MOD1_MASK,
+ "change_case", 1,
+ G_TYPE_ENUM, GTK_SOURCE_CHANGE_CASE_TOGGLE);
+ gtk_binding_entry_add_signal (binding_set,
+ GDK_KEY_l,
+ GDK_MOD1_MASK,
+ "change_case", 1,
+ G_TYPE_ENUM, GTK_SOURCE_CHANGE_CASE_TITLE);
}
static void
@@ -753,6 +774,82 @@ pluma_view_delete_selection (PlumaView *view)
0.0);
}
+void
+pluma_view_upper_case_selection (PlumaView *view)
+{
+ GtkTextBuffer *buffer = NULL;
+ GtkTextIter start, end;
+
+ pluma_debug (DEBUG_VIEW);
+
+ g_return_if_fail (PLUMA_IS_VIEW (view));
+
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
+ g_return_if_fail (buffer != NULL);
+
+ if (gtk_text_buffer_get_selection_bounds (buffer, &start, &end))
+ {
+ gtk_source_buffer_change_case (GTK_SOURCE_BUFFER (buffer), GTK_SOURCE_CHANGE_CASE_UPPER, &start, &end);
+ }
+}
+
+void
+pluma_view_lower_case_selection (PlumaView *view)
+{
+ GtkTextBuffer *buffer = NULL;
+ GtkTextIter start, end;
+
+ pluma_debug (DEBUG_VIEW);
+
+ g_return_if_fail (PLUMA_IS_VIEW (view));
+
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
+ g_return_if_fail (buffer != NULL);
+
+ if (gtk_text_buffer_get_selection_bounds (buffer, &start, &end))
+ {
+ gtk_source_buffer_change_case (GTK_SOURCE_BUFFER (buffer), GTK_SOURCE_CHANGE_CASE_LOWER, &start, &end);
+ }
+}
+
+void
+pluma_view_invert_case_selection (PlumaView *view)
+{
+ GtkTextBuffer *buffer = NULL;
+ GtkTextIter start, end;
+
+ pluma_debug (DEBUG_VIEW);
+
+ g_return_if_fail (PLUMA_IS_VIEW (view));
+
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
+ g_return_if_fail (buffer != NULL);
+
+ if (gtk_text_buffer_get_selection_bounds (buffer, &start, &end))
+ {
+ gtk_source_buffer_change_case (GTK_SOURCE_BUFFER (buffer), GTK_SOURCE_CHANGE_CASE_TOGGLE, &start, &end);
+ }
+}
+
+void
+pluma_view_title_case_selection (PlumaView *view)
+{
+ GtkTextBuffer *buffer = NULL;
+ GtkTextIter start, end;
+
+ pluma_debug (DEBUG_VIEW);
+
+ g_return_if_fail (PLUMA_IS_VIEW (view));
+
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
+ g_return_if_fail (buffer != NULL);
+
+ if (gtk_text_buffer_get_selection_bounds (buffer, &start, &end))
+ {
+ gtk_source_buffer_change_case (GTK_SOURCE_BUFFER (buffer), GTK_SOURCE_CHANGE_CASE_TITLE, &start, &end);
+ }
+}
+
/**
* pluma_view_select_all:
* @view: a #PlumaView
diff --git a/pluma/pluma-view.h b/pluma/pluma-view.h
index c2f5e1df..afad9e08 100644
--- a/pluma/pluma-view.h
+++ b/pluma/pluma-view.h
@@ -95,6 +95,12 @@ void pluma_view_cut_clipboard (PlumaView *view);
void pluma_view_copy_clipboard (PlumaView *view);
void pluma_view_paste_clipboard (PlumaView *view);
void pluma_view_delete_selection (PlumaView *view);
+
+void pluma_view_upper_case_selection (PlumaView *view);
+void pluma_view_lower_case_selection (PlumaView *view);
+void pluma_view_invert_case_selection (PlumaView *view);
+void pluma_view_title_case_selection (PlumaView *view);
+
void pluma_view_select_all (PlumaView *view);
void pluma_view_scroll_to_cursor (PlumaView *view);