mirror of
https://gitlab.gnome.org/GNOME/gimp.git
synced 2025-07-03 17:33:25 +00:00
Merge branch 'wip/megakite/paste-unformatted-text' into 'master'
Issue #4352: Text copy & paste without format Closes #4352 See merge request GNOME/gimp!1386
This commit is contained in:
commit
a2b84f3893
7 changed files with 72 additions and 8 deletions
|
@ -61,6 +61,12 @@ static const GimpActionEntry text_tool_actions[] =
|
|||
text_tool_paste_cmd_callback,
|
||||
GIMP_HELP_TEXT_TOOL_PASTE },
|
||||
|
||||
{ "text-tool-paste-unformatted", NULL,
|
||||
NC_("text-tool-action", "Paste _Unformatted Text"), NULL,
|
||||
{ "<primary><shift>V", NULL }, NULL,
|
||||
text_tool_paste_unformatted_cmd_callback,
|
||||
NULL },
|
||||
|
||||
{ "text-tool-delete", GIMP_ICON_EDIT_DELETE,
|
||||
NC_("text-tool-action", "_Delete"), NULL, { NULL }, NULL,
|
||||
text_tool_delete_cmd_callback,
|
||||
|
@ -192,6 +198,7 @@ text_tool_actions_update (GimpActionGroup *group,
|
|||
SET_SENSITIVE ("text-tool-cut", text_sel);
|
||||
SET_SENSITIVE ("text-tool-copy", text_sel);
|
||||
SET_SENSITIVE ("text-tool-paste", clip);
|
||||
SET_SENSITIVE ("text-tool-paste-unformatted", clip);
|
||||
SET_SENSITIVE ("text-tool-delete", text_sel);
|
||||
SET_SENSITIVE ("text-tool-clear", text_layer);
|
||||
SET_SENSITIVE ("text-tool-load", image);
|
||||
|
|
|
@ -84,6 +84,16 @@ text_tool_paste_cmd_callback (GimpAction *action,
|
|||
gimp_text_tool_paste_clipboard (text_tool);
|
||||
}
|
||||
|
||||
void
|
||||
text_tool_paste_unformatted_cmd_callback (GimpAction *action,
|
||||
GVariant *value,
|
||||
gpointer data)
|
||||
{
|
||||
GimpTextTool *text_tool = GIMP_TEXT_TOOL (data);
|
||||
|
||||
gimp_text_tool_paste_clipboard_unformatted (text_tool);
|
||||
}
|
||||
|
||||
void
|
||||
text_tool_delete_cmd_callback (GimpAction *action,
|
||||
GVariant *value,
|
||||
|
|
|
@ -28,6 +28,10 @@ void text_tool_copy_cmd_callback (GimpAction *action,
|
|||
void text_tool_paste_cmd_callback (GimpAction *action,
|
||||
GVariant *value,
|
||||
gpointer data);
|
||||
void text_tool_paste_unformatted_cmd_callback
|
||||
(GimpAction *action,
|
||||
GVariant *value,
|
||||
gpointer data);
|
||||
void text_tool_delete_cmd_callback (GimpAction *action,
|
||||
GVariant *value,
|
||||
gpointer data);
|
||||
|
|
|
@ -520,6 +520,16 @@ gimp_text_tool_editor_key_press (GimpTextTool *text_tool,
|
|||
GIMP_TOOL (text_tool)->display);
|
||||
break;
|
||||
|
||||
/* this key binding (Ctrl-Shift-V) is dedicated for action `text-tool-
|
||||
* paste-unformatted`, which could not be connected to signal source since
|
||||
* GTKTextView did not provide us a built-in one.
|
||||
*/
|
||||
case GDK_KEY_v:
|
||||
case GDK_KEY_V:
|
||||
if ((kevent->state & gimp_get_all_modifiers_mask()) == (GDK_CONTROL_MASK | GDK_SHIFT_MASK))
|
||||
gimp_text_tool_paste_clipboard_unformatted (text_tool);
|
||||
break;
|
||||
|
||||
default:
|
||||
retval = FALSE;
|
||||
}
|
||||
|
|
|
@ -2309,6 +2309,36 @@ gimp_text_tool_paste_clipboard (GimpTextTool *text_tool)
|
|||
clipboard, NULL, TRUE);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_text_tool_paste_clipboard_unformatted (GimpTextTool *text_tool)
|
||||
{
|
||||
GimpDisplayShell *shell;
|
||||
GtkClipboard *clipboard;
|
||||
gchar *unformatted_text;
|
||||
|
||||
g_return_if_fail (GIMP_IS_TEXT_TOOL (text_tool));
|
||||
|
||||
shell = gimp_display_get_shell (GIMP_TOOL (text_tool)->display);
|
||||
|
||||
clipboard = gtk_widget_get_clipboard (GTK_WIDGET (shell),
|
||||
GDK_SELECTION_CLIPBOARD);
|
||||
|
||||
unformatted_text = gtk_clipboard_wait_for_text (clipboard);
|
||||
|
||||
if (unformatted_text)
|
||||
{
|
||||
/* First delete texts in current selection (possibly empty), in order to
|
||||
* allow overwriting.
|
||||
*/
|
||||
gtk_text_buffer_delete_selection (GTK_TEXT_BUFFER (text_tool->buffer),
|
||||
TRUE, TRUE);
|
||||
|
||||
gimp_text_buffer_insert (text_tool->buffer, unformatted_text);
|
||||
}
|
||||
|
||||
g_free (unformatted_text);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_text_tool_create_vectors (GimpTextTool *text_tool)
|
||||
{
|
||||
|
|
|
@ -114,6 +114,8 @@ void gimp_text_tool_delete_selection (GimpTextTool *text_tool);
|
|||
void gimp_text_tool_cut_clipboard (GimpTextTool *text_tool);
|
||||
void gimp_text_tool_copy_clipboard (GimpTextTool *text_tool);
|
||||
void gimp_text_tool_paste_clipboard (GimpTextTool *text_tool);
|
||||
void gimp_text_tool_paste_clipboard_unformatted
|
||||
(GimpTextTool *text_tool);
|
||||
|
||||
void gimp_text_tool_create_vectors (GimpTextTool *text_tool);
|
||||
gboolean gimp_text_tool_create_vectors_warped (GimpTextTool *text_tool,
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
<item><attribute name="action">text-tool.text-tool-cut</attribute></item>
|
||||
<item><attribute name="action">text-tool.text-tool-copy</attribute></item>
|
||||
<item><attribute name="action">text-tool.text-tool-paste</attribute></item>
|
||||
<item><attribute name="action">text-tool.text-tool-paste-unformatted</attribute></item>
|
||||
<item><attribute name="action">text-tool.text-tool-delete</attribute></item>
|
||||
<section>
|
||||
<item><attribute name="action">text-tool.text-tool-load</attribute></item>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue