From d85c0aa6ec87e91901e393f701873085e5eeddb0 Mon Sep 17 00:00:00 2001 From: mbkma <39454100+mbkma@users.noreply.github.com> Date: Wed, 5 Aug 2020 11:19:36 +0200 Subject: Remove changecase plugin. Functionality is provided by GtkSourceView. (#565) --- pluma/pluma-commands-edit.c | 64 ++++++++++++++++++++++++++++++ pluma/pluma-commands.h | 8 ++++ pluma/pluma-ui.h | 9 +++++ pluma/pluma-ui.xml | 26 +++++++----- pluma/pluma-view.c | 97 +++++++++++++++++++++++++++++++++++++++++++++ pluma/pluma-view.h | 6 +++ 6 files changed, 200 insertions(+), 10 deletions(-) (limited to 'pluma') 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 @@ -164,6 +164,70 @@ _pluma_cmd_edit_select_all (GtkAction *action, gtk_widget_grab_focus (GTK_WIDGET (active_view)); } +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"), "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 @@ - + - + @@ -71,6 +71,12 @@ + + + + + + @@ -103,12 +109,12 @@ - + - + @@ -136,7 +142,7 @@ - + @@ -195,7 +201,7 @@ - + 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); -- cgit v1.2.1