~ubuntu-branches/ubuntu/saucy/gimp/saucy

« back to all changes in this revision

Viewing changes to app/widgets/gimptextproxy.c

  • Committer: Package Import Robot
  • Author(s): Micah Gersten
  • Date: 2012-05-20 19:21:01 UTC
  • mfrom: (1.1.26) (0.4.16 sid)
  • Revision ID: package-import@ubuntu.com-20120520192101-bs7zetx8ffoq2nfv
Tags: 2.8.0-2ubuntu1
* Merge from Debian unstable (LP: #908472). Remaining Changes:
  - debian/patches/02_help-message.patch,
    debian/patches/03_gimp.desktop.in.in.patch:
    + Update some strings for Ubuntu
  - debian/control:
    + Update description
  - debian/rules:
    + Set gettext domain and update translation templates
* Drop the following patches that were applied upstream:
  - debian/patches/ghost-cursor.patch: fix Wacom tablet cursor events
  - debian/patches/embed-page-setup-dialog.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* GIMP - The GNU Image Manipulation Program
 
2
 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
 
3
 *
 
4
 * GimpTextProxy
 
5
 * Copyright (C) 2009-2010  Michael Natterer <mitch@gimp.org>
 
6
 *
 
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.
 
11
 *
 
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.
 
16
 *
 
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/>.
 
19
 */
 
20
 
 
21
#include "config.h"
 
22
 
 
23
#include <gtk/gtk.h>
 
24
#include <gdk/gdkkeysyms.h>
 
25
 
 
26
#include "widgets-types.h"
 
27
 
 
28
#include "core/gimpmarshal.h"
 
29
 
 
30
#include "gimptextproxy.h"
 
31
 
 
32
 
 
33
enum
 
34
{
 
35
  CHANGE_SIZE,
 
36
  CHANGE_BASELINE,
 
37
  CHANGE_KERNING,
 
38
  LAST_SIGNAL
 
39
};
 
40
 
 
41
 
 
42
static void   gimp_text_proxy_move_cursor        (GtkTextView     *text_view,
 
43
                                                  GtkMovementStep  step,
 
44
                                                  gint             count,
 
45
                                                  gboolean         extend_selection);
 
46
static void   gimp_text_proxy_insert_at_cursor   (GtkTextView     *text_view,
 
47
                                                  const gchar     *str);
 
48
static void   gimp_text_proxy_delete_from_cursor (GtkTextView     *text_view,
 
49
                                                  GtkDeleteType    type,
 
50
                                                  gint             count);
 
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);
 
56
 
 
57
 
 
58
G_DEFINE_TYPE (GimpTextProxy, gimp_text_proxy, GTK_TYPE_TEXT_VIEW)
 
59
 
 
60
static guint proxy_signals[LAST_SIGNAL] = { 0 };
 
61
 
 
62
 
 
63
static void
 
64
gimp_text_proxy_class_init (GimpTextProxyClass *klass)
 
65
{
 
66
  GtkTextViewClass *tv_class = GTK_TEXT_VIEW_CLASS (klass);
 
67
  GtkBindingSet    *binding_set;
 
68
 
 
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;
 
77
 
 
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),
 
83
                  NULL, NULL,
 
84
                  gimp_marshal_VOID__DOUBLE,
 
85
                  G_TYPE_NONE, 1,
 
86
                  G_TYPE_DOUBLE);
 
87
 
 
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),
 
93
                  NULL, NULL,
 
94
                  gimp_marshal_VOID__DOUBLE,
 
95
                  G_TYPE_NONE, 1,
 
96
                  G_TYPE_DOUBLE);
 
97
 
 
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),
 
103
                  NULL, NULL,
 
104
                  gimp_marshal_VOID__DOUBLE,
 
105
                  G_TYPE_NONE, 1,
 
106
                  G_TYPE_DOUBLE);
 
107
 
 
108
  binding_set = gtk_binding_set_by_class (klass);
 
109
 
 
110
  gtk_binding_entry_add_signal (binding_set, GDK_KEY_plus, GDK_MOD1_MASK,
 
111
                                "change-size", 1,
 
112
                                G_TYPE_DOUBLE, 1.0);
 
113
  gtk_binding_entry_add_signal (binding_set, GDK_KEY_minus, GDK_MOD1_MASK,
 
114
                                "change-size", 1,
 
115
                                G_TYPE_DOUBLE, -1.0);
 
116
 
 
117
  gtk_binding_entry_add_signal (binding_set, GDK_KEY_Up, GDK_MOD1_MASK,
 
118
                                "change-baseline", 1,
 
119
                                G_TYPE_DOUBLE, 1.0);
 
120
  gtk_binding_entry_add_signal (binding_set, GDK_KEY_Down, GDK_MOD1_MASK,
 
121
                                "change-baseline", 1,
 
122
                                G_TYPE_DOUBLE, -1.0);
 
123
 
 
124
  gtk_binding_entry_add_signal (binding_set, GDK_KEY_Left, GDK_MOD1_MASK,
 
125
                                "change-kerning", 1,
 
126
                                G_TYPE_DOUBLE, -1.0);
 
127
  gtk_binding_entry_add_signal (binding_set, GDK_KEY_Right, GDK_MOD1_MASK,
 
128
                                "change-kerning", 1,
 
129
                                G_TYPE_DOUBLE, 1.0);
 
130
}
 
131
 
 
132
static void
 
133
gimp_text_proxy_init (GimpTextProxy *text_proxy)
 
134
{
 
135
}
 
136
 
 
137
static void
 
138
gimp_text_proxy_move_cursor (GtkTextView     *text_view,
 
139
                             GtkMovementStep  step,
 
140
                             gint             count,
 
141
                             gboolean         extend_selection)
 
142
{
 
143
}
 
144
 
 
145
static void
 
146
gimp_text_proxy_insert_at_cursor (GtkTextView *text_view,
 
147
                                  const gchar *str)
 
148
{
 
149
}
 
150
 
 
151
static void
 
152
gimp_text_proxy_delete_from_cursor (GtkTextView   *text_view,
 
153
                                    GtkDeleteType  type,
 
154
                                    gint           count)
 
155
{
 
156
}
 
157
 
 
158
static void
 
159
gimp_text_proxy_backspace (GtkTextView *text_view)
 
160
{
 
161
}
 
162
 
 
163
static void
 
164
gimp_text_proxy_cut_clipboard (GtkTextView *text_view)
 
165
{
 
166
}
 
167
 
 
168
static void
 
169
gimp_text_proxy_copy_clipboard (GtkTextView *text_view)
 
170
{
 
171
}
 
172
 
 
173
static void
 
174
gimp_text_proxy_paste_clipboard (GtkTextView *text_view)
 
175
{
 
176
}
 
177
 
 
178
static void
 
179
gimp_text_proxy_toggle_overwrite (GtkTextView *text_view)
 
180
{
 
181
}
 
182
 
 
183
 
 
184
/*  public functions  */
 
185
 
 
186
GtkWidget *
 
187
gimp_text_proxy_new (void)
 
188
{
 
189
  GtkTextBuffer *buffer = gtk_text_buffer_new (NULL);
 
190
  GtkWidget     *proxy;
 
191
 
 
192
  proxy = g_object_new (GIMP_TYPE_TEXT_PROXY,
 
193
                        "buffer", buffer,
 
194
                        NULL);
 
195
 
 
196
  g_object_unref (buffer);
 
197
 
 
198
  return proxy;
 
199
}