1
/* GIMP - The GNU Image Manipulation Program
2
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
5
* Copyright (C) 2009-2010 Michael Natterer <mitch@gimp.org>
7
* This program is free software: you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation; either version 3 of the License, or
10
* (at your option) any later version.
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
17
* You should have received a copy of the GNU General Public License
18
* along with this program. If not, see <http://www.gnu.org/licenses/>.
24
#include <gdk/gdkkeysyms.h>
26
#include "widgets-types.h"
28
#include "core/gimpmarshal.h"
30
#include "gimptextproxy.h"
42
static void gimp_text_proxy_move_cursor (GtkTextView *text_view,
45
gboolean extend_selection);
46
static void gimp_text_proxy_insert_at_cursor (GtkTextView *text_view,
48
static void gimp_text_proxy_delete_from_cursor (GtkTextView *text_view,
51
static void gimp_text_proxy_backspace (GtkTextView *text_view);
52
static void gimp_text_proxy_cut_clipboard (GtkTextView *text_view);
53
static void gimp_text_proxy_copy_clipboard (GtkTextView *text_view);
54
static void gimp_text_proxy_paste_clipboard (GtkTextView *text_view);
55
static void gimp_text_proxy_toggle_overwrite (GtkTextView *text_view);
58
G_DEFINE_TYPE (GimpTextProxy, gimp_text_proxy, GTK_TYPE_TEXT_VIEW)
60
static guint proxy_signals[LAST_SIGNAL] = { 0 };
64
gimp_text_proxy_class_init (GimpTextProxyClass *klass)
66
GtkTextViewClass *tv_class = GTK_TEXT_VIEW_CLASS (klass);
67
GtkBindingSet *binding_set;
69
tv_class->move_cursor = gimp_text_proxy_move_cursor;
70
tv_class->insert_at_cursor = gimp_text_proxy_insert_at_cursor;
71
tv_class->delete_from_cursor = gimp_text_proxy_delete_from_cursor;
72
tv_class->backspace = gimp_text_proxy_backspace;
73
tv_class->cut_clipboard = gimp_text_proxy_cut_clipboard;
74
tv_class->copy_clipboard = gimp_text_proxy_copy_clipboard;
75
tv_class->paste_clipboard = gimp_text_proxy_paste_clipboard;
76
tv_class->toggle_overwrite = gimp_text_proxy_toggle_overwrite;
78
proxy_signals[CHANGE_SIZE] =
79
g_signal_new ("change-size",
80
G_TYPE_FROM_CLASS (klass),
81
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
82
G_STRUCT_OFFSET (GimpTextProxyClass, change_size),
84
gimp_marshal_VOID__DOUBLE,
88
proxy_signals[CHANGE_BASELINE] =
89
g_signal_new ("change-baseline",
90
G_TYPE_FROM_CLASS (klass),
91
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
92
G_STRUCT_OFFSET (GimpTextProxyClass, change_baseline),
94
gimp_marshal_VOID__DOUBLE,
98
proxy_signals[CHANGE_KERNING] =
99
g_signal_new ("change-kerning",
100
G_TYPE_FROM_CLASS (klass),
101
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
102
G_STRUCT_OFFSET (GimpTextProxyClass, change_kerning),
104
gimp_marshal_VOID__DOUBLE,
108
binding_set = gtk_binding_set_by_class (klass);
110
gtk_binding_entry_add_signal (binding_set, GDK_KEY_plus, GDK_MOD1_MASK,
113
gtk_binding_entry_add_signal (binding_set, GDK_KEY_minus, GDK_MOD1_MASK,
115
G_TYPE_DOUBLE, -1.0);
117
gtk_binding_entry_add_signal (binding_set, GDK_KEY_Up, GDK_MOD1_MASK,
118
"change-baseline", 1,
120
gtk_binding_entry_add_signal (binding_set, GDK_KEY_Down, GDK_MOD1_MASK,
121
"change-baseline", 1,
122
G_TYPE_DOUBLE, -1.0);
124
gtk_binding_entry_add_signal (binding_set, GDK_KEY_Left, GDK_MOD1_MASK,
126
G_TYPE_DOUBLE, -1.0);
127
gtk_binding_entry_add_signal (binding_set, GDK_KEY_Right, GDK_MOD1_MASK,
133
gimp_text_proxy_init (GimpTextProxy *text_proxy)
138
gimp_text_proxy_move_cursor (GtkTextView *text_view,
139
GtkMovementStep step,
141
gboolean extend_selection)
146
gimp_text_proxy_insert_at_cursor (GtkTextView *text_view,
152
gimp_text_proxy_delete_from_cursor (GtkTextView *text_view,
159
gimp_text_proxy_backspace (GtkTextView *text_view)
164
gimp_text_proxy_cut_clipboard (GtkTextView *text_view)
169
gimp_text_proxy_copy_clipboard (GtkTextView *text_view)
174
gimp_text_proxy_paste_clipboard (GtkTextView *text_view)
179
gimp_text_proxy_toggle_overwrite (GtkTextView *text_view)
184
/* public functions */
187
gimp_text_proxy_new (void)
189
GtkTextBuffer *buffer = gtk_text_buffer_new (NULL);
192
proxy = g_object_new (GIMP_TYPE_TEXT_PROXY,
196
g_object_unref (buffer);