~ghugesss/xpad/debug_support

« back to all changes in this revision

Viewing changes to src/xpad-text-view.c

  • Committer: Arthur Borsboom
  • Date: 2014-06-19 13:15:30 UTC
  • mfrom: (665.1.59 xpad-4.3)
  • Revision ID: arthurborsboom@gmail.com-20140619131530-ecsvweog8592zqie
Fix: prevented color updating conflict between preferences and pad colors
Fix: Technical - reduced code by removing double code
Fix: Technical - ensured that all the menus of each pad are updated when changing options in the View menu
Fix: renamed Xpad_periodic functions to lowercase in line with other function namings
Fix: repaired showing all the notes in the menu: pad->menu->notes
Fix: Technical - removed unnecessary initialization and unnecessary function
Fix: Resolved a disposing error of the clipboard contents after erasing a pad
Fix: Pad properties - switched foreground and background order in GUI.
Fix: Technical - got rid of the global variable: xpad_global_settings
New: added shortcuts keys for New pad (CTRL-N) and Delete (SHIFT-DEL)
Fix: Technical - changed comment style
Fix: replaced get user home dir with specific glib function
Fix: Default values are set correctly on first startup (no configuration file) by reintroducing a double default value administration.
Fix: Improved performance by reducing the amount of GTK_ casts, as suggested in the GTK best practices
Fix: Applied GTK best practices for inclusion of 1st config.h and 2nd its header file in each c-file

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 
20
20
*/
21
21
 
 
22
#include "../config.h"
 
23
#include "xpad-text-view.h"
22
24
#include <gtk/gtk.h>
23
 
#include "xpad-text-view.h"
24
25
#include "xpad-text-buffer.h"
25
 
#include "xpad-app.h"
 
26
#include "xpad-pad.h"
 
27
#include "xpad-toolbar.h"
26
28
 
27
29
struct XpadTextViewPrivate 
28
30
{
32
34
        gulong notify_back_handler;
33
35
        gulong notify_font_handler;
34
36
        XpadTextBuffer *buffer;
 
37
        XpadSettings *settings;
 
38
        XpadPad *pad;
35
39
};
36
40
 
37
 
G_DEFINE_TYPE_WITH_PRIVATE(XpadTextView, xpad_text_view, GTK_TYPE_TEXT_VIEW)
 
41
G_DEFINE_TYPE_WITH_PRIVATE (XpadTextView, xpad_text_view, GTK_TYPE_TEXT_VIEW)
38
42
 
39
43
static void xpad_text_view_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
40
44
static void xpad_text_view_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
 
45
static void xpad_text_view_constructed (GObject *object);
41
46
static void xpad_text_view_dispose (GObject *object);
42
47
static void xpad_text_view_finalize (GObject *object);
43
48
static void xpad_text_view_realize (XpadTextView *widget);
44
 
static gboolean xpad_text_view_button_press_event (GtkWidget *widget, GdkEventButton *event);
45
 
static gboolean xpad_text_view_focus_out_event (GtkWidget *widget, GdkEventFocus *event);
 
49
static gboolean xpad_text_view_button_press_event (GtkWidget *widget, GdkEventButton *event, XpadSettings *settings);
 
50
static gboolean xpad_text_view_focus_out_event (GtkWidget *widget, GdkEventFocus *event, XpadSettings *settings);
46
51
static void xpad_text_view_notify_edit_lock (XpadTextView *view);
47
52
static void xpad_text_view_notify_editable (XpadTextView *view);
48
53
static void xpad_text_view_notify_fontname (XpadTextView *view);
50
55
 
51
56
enum
52
57
{
53
 
  PROP_0,
54
 
  PROP_FOLLOW_FONT_STYLE,
55
 
  PROP_FOLLOW_COLOR_STYLE,
56
 
  LAST_PROP
 
58
        PROP_0,
 
59
        PROP_SETTINGS,
 
60
        PROP_PAD,
 
61
        PROP_FOLLOW_FONT_STYLE,
 
62
        PROP_FOLLOW_COLOR_STYLE,
 
63
        N_PROPERTIES
57
64
};
58
65
 
 
66
static GParamSpec *obj_prop[N_PROPERTIES] = { NULL, };
 
67
 
59
68
GtkWidget *
60
 
xpad_text_view_new (void)
 
69
xpad_text_view_new (XpadSettings *settings, XpadPad *pad)
61
70
{
62
 
        return GTK_WIDGET (g_object_new (XPAD_TYPE_TEXT_VIEW, "follow-font-style", TRUE, "follow-color-style", TRUE, NULL));
 
71
        return GTK_WIDGET (g_object_new (XPAD_TYPE_TEXT_VIEW, "settings", settings, "pad", pad, "follow-font-style", TRUE, "follow-color-style", TRUE, NULL));
63
72
}
64
73
 
65
74
static void
67
76
{
68
77
        GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
69
78
 
 
79
        gobject_class->constructed = xpad_text_view_constructed;
70
80
        gobject_class->dispose = xpad_text_view_dispose;
71
81
        gobject_class->finalize = xpad_text_view_finalize;
72
82
        gobject_class->set_property = xpad_text_view_set_property;
73
83
        gobject_class->get_property = xpad_text_view_get_property;
74
84
        
75
 
        /* Properties */
76
 
        
77
 
        g_object_class_install_property (gobject_class,
78
 
                                         PROP_FOLLOW_FONT_STYLE,
79
 
                                         g_param_spec_boolean ("follow-font-style",
80
 
                                                               "Follow Font Style",
81
 
                                                               "Whether to use the default xpad font style",
82
 
                                                               TRUE,
83
 
                                                               G_PARAM_READWRITE));
84
 
        
85
 
        g_object_class_install_property (gobject_class,
86
 
                                         PROP_FOLLOW_COLOR_STYLE,
87
 
                                         g_param_spec_boolean ("follow-color-style",
88
 
                                                               "Follow Color Style",
89
 
                                                               "Whether to use the default xpad color style",
90
 
                                                               TRUE,
91
 
                                                               G_PARAM_READWRITE));
 
85
        obj_prop[PROP_SETTINGS] = g_param_spec_pointer ("settings", "Xpad settings", "Xpad global settings", G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
 
86
        obj_prop[PROP_PAD] = g_param_spec_pointer ("pad", "Pad", "Pad connected to this textview", G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
 
87
        obj_prop[PROP_FOLLOW_FONT_STYLE] = g_param_spec_boolean ("follow-font-style", "Follow font style", "Whether to use the default xpad font style", TRUE, G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
 
88
        obj_prop[PROP_FOLLOW_COLOR_STYLE] = g_param_spec_boolean ("follow-color-style", "Follow color style", "Whether to use the default xpad color style", TRUE, G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
 
89
 
 
90
        g_object_class_install_properties (gobject_class, N_PROPERTIES, obj_prop);
92
91
}
93
92
 
94
93
static void
95
94
xpad_text_view_init (XpadTextView *view)
96
95
{
97
 
        gchar *name;
98
 
        
99
 
        view->priv = xpad_text_view_get_instance_private(view);
100
 
        
101
 
        view->priv->follow_font_style = TRUE;
102
 
        view->priv->follow_color_style = TRUE;
103
 
        
104
 
        view->priv->buffer = xpad_text_buffer_new();
 
96
        view->priv = xpad_text_view_get_instance_private (view);
 
97
}
 
98
 
 
99
static void xpad_text_view_constructed (GObject *object)
 
100
{
 
101
        XpadTextView *view = XPAD_TEXT_VIEW (object);
 
102
        
 
103
        view->priv->buffer = xpad_text_buffer_new (view->priv->pad);
 
104
 
105
105
        gtk_text_view_set_buffer (GTK_TEXT_VIEW (view), GTK_TEXT_BUFFER (view->priv->buffer));
106
 
        
107
106
        gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (view), GTK_WRAP_WORD);
108
107
        gtk_container_set_border_width (GTK_CONTAINER (view), 5);
109
 
        
110
 
        name = g_strdup_printf ("%p", (void *) view);
111
 
        gtk_widget_set_name (GTK_WIDGET (view), name);
112
 
        g_free (name);
113
 
        
114
 
        g_signal_connect (view, "button-press-event", G_CALLBACK (xpad_text_view_button_press_event), NULL);
115
 
        g_signal_connect_after (view, "focus-out-event", G_CALLBACK (xpad_text_view_focus_out_event), NULL);
 
108
        gtk_widget_set_name (GTK_WIDGET (view), g_strdup_printf ("%p", (void *) view));
 
109
        
 
110
        g_signal_connect (view, "button-press-event", G_CALLBACK (xpad_text_view_button_press_event), view->priv->settings);
 
111
        g_signal_connect_after (view, "focus-out-event", G_CALLBACK (xpad_text_view_focus_out_event), view->priv->settings);
116
112
        g_signal_connect (view, "realize", G_CALLBACK (xpad_text_view_realize), NULL);
117
113
        g_signal_connect (view, "notify::editable", G_CALLBACK (xpad_text_view_notify_editable), NULL);
118
 
        g_signal_connect_swapped (xpad_global_settings, "notify::edit-lock", G_CALLBACK (xpad_text_view_notify_edit_lock), view);
119
 
        view->priv->notify_font_handler = g_signal_connect_swapped (xpad_global_settings, "notify::fontname", G_CALLBACK (xpad_text_view_notify_fontname), view);
120
 
        view->priv->notify_text_handler = g_signal_connect_swapped (xpad_global_settings, "notify::text-color", G_CALLBACK (xpad_text_view_notify_colors), view);
121
 
        view->priv->notify_back_handler = g_signal_connect_swapped (xpad_global_settings, "notify::back-color", G_CALLBACK (xpad_text_view_notify_colors), view);
122
 
        xpad_text_view_notify_colors (view);
123
 
        xpad_text_view_notify_fontname (view);
 
114
        g_signal_connect_swapped (view->priv->settings, "notify::edit-lock", G_CALLBACK (xpad_text_view_notify_edit_lock), view);
 
115
 
 
116
        view->priv->notify_font_handler = g_signal_connect_swapped (view->priv->settings, "notify::fontname", G_CALLBACK (xpad_text_view_notify_fontname), view);
 
117
        view->priv->notify_text_handler = g_signal_connect_swapped (view->priv->settings, "notify::text-color", G_CALLBACK (xpad_text_view_notify_colors), view);
 
118
        view->priv->notify_back_handler = g_signal_connect_swapped (view->priv->settings, "notify::back-color", G_CALLBACK (xpad_text_view_notify_colors), view);
 
119
 
 
120
        g_signal_handler_block (view->priv->settings, view->priv->notify_font_handler);
124
121
}
125
122
 
126
123
static void
128
125
{
129
126
        XpadTextView *view = XPAD_TEXT_VIEW (object);
130
127
 
131
 
        if (view->priv->buffer) {
 
128
        if (view->priv->buffer)
132
129
                g_object_unref (view->priv->buffer);
133
 
        }
134
 
        
 
130
 
 
131
        if (view->priv->pad) {
 
132
                g_object_unref(view->priv->pad);
 
133
                view->priv->pad = NULL;
 
134
        }
 
135
 
 
136
        if (view->priv->settings) {
 
137
                g_object_unref(view->priv->settings);
 
138
                view->priv->settings = NULL;
 
139
        }
 
140
 
135
141
        G_OBJECT_CLASS (xpad_text_view_parent_class)->dispose (object);
136
142
}
137
143
 
140
146
{
141
147
        XpadTextView *view = XPAD_TEXT_VIEW (object);
142
148
 
143
 
        if (xpad_global_settings)
144
 
                g_signal_handlers_disconnect_matched (xpad_global_settings, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, view);
 
149
        if (view->priv->settings)
 
150
                g_signal_handlers_disconnect_matched (view->priv->settings, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, view);
145
151
 
146
152
        G_OBJECT_CLASS (xpad_text_view_parent_class)->finalize (object);
147
153
}
150
156
xpad_text_view_realize (XpadTextView *view)
151
157
{
152
158
        gboolean edit_lock;
153
 
        g_object_get (xpad_global_settings, "edit-lock", &edit_lock, NULL);
 
159
        g_object_get (view->priv->settings, "edit-lock", &edit_lock, NULL);
154
160
        gtk_text_view_set_editable (GTK_TEXT_VIEW (view), !edit_lock);
155
161
}
156
162
 
 
163
static void
 
164
xpad_text_view_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
 
165
{
 
166
        XpadTextView *view = XPAD_TEXT_VIEW (object);
 
167
 
 
168
        switch (prop_id)
 
169
        {
 
170
        case PROP_SETTINGS:
 
171
                view->priv->settings = g_value_get_pointer (value);
 
172
                g_object_ref (view->priv->settings);
 
173
                break;
 
174
 
 
175
        case PROP_PAD:
 
176
                view->priv->pad = g_value_get_pointer (value);
 
177
                g_object_ref (view->priv->pad);
 
178
                break;
 
179
 
 
180
        case PROP_FOLLOW_FONT_STYLE:
 
181
                view->priv->follow_font_style = g_value_get_boolean (value);
 
182
                if (view->priv->follow_font_style) {
 
183
                        xpad_text_view_notify_fontname (view);
 
184
                        if (view->priv->notify_font_handler != 0) {
 
185
                                g_signal_handler_unblock (view->priv->settings, view->priv->notify_font_handler);
 
186
                        }
 
187
                }
 
188
                else
 
189
                        g_signal_handler_block (view->priv->settings, view->priv->notify_font_handler);
 
190
                break;
 
191
 
 
192
        case PROP_FOLLOW_COLOR_STYLE:
 
193
                view->priv->follow_color_style = g_value_get_boolean (value);
 
194
                xpad_text_view_notify_colors (view);
 
195
                break;
 
196
 
 
197
        default:
 
198
                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
 
199
                break;
 
200
        }
 
201
}
 
202
 
 
203
static void
 
204
xpad_text_view_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
 
205
{
 
206
        XpadTextView *view = XPAD_TEXT_VIEW (object);
 
207
 
 
208
        switch (prop_id)
 
209
        {
 
210
        case PROP_SETTINGS:
 
211
                g_value_set_pointer (value, view->priv->settings);
 
212
                break;
 
213
 
 
214
        case PROP_PAD:
 
215
                g_value_set_pointer (value, view->priv->pad);
 
216
                break;
 
217
 
 
218
        case PROP_FOLLOW_FONT_STYLE:
 
219
                g_value_set_boolean (value, view->priv->follow_font_style);
 
220
                break;
 
221
 
 
222
        case PROP_FOLLOW_COLOR_STYLE:
 
223
                g_value_set_boolean (value, view->priv->follow_color_style);
 
224
                break;
 
225
 
 
226
        default:
 
227
                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
 
228
                break;
 
229
        }
 
230
}
 
231
 
157
232
static gboolean
158
 
xpad_text_view_focus_out_event (GtkWidget *widget, GdkEventFocus *event)
 
233
xpad_text_view_focus_out_event (GtkWidget *widget, GdkEventFocus *event, XpadSettings *settings)
159
234
{
160
235
        /* A dirty way to silence the compiler for these unused variables. */
161
236
        (void) event;
162
237
 
163
238
        gboolean edit_lock;
164
 
        g_object_get (xpad_global_settings, "edit-lock", &edit_lock, NULL);
 
239
        g_object_get (settings, "edit-lock", &edit_lock, NULL);
165
240
 
166
241
        if (edit_lock)
167
242
        {
173
248
}
174
249
 
175
250
static gboolean
176
 
xpad_text_view_button_press_event (GtkWidget *widget, GdkEventButton *event)
 
251
xpad_text_view_button_press_event (GtkWidget *widget, GdkEventButton *event, XpadSettings *settings)
177
252
{
178
253
        gboolean edit_lock;
179
 
        g_object_get (xpad_global_settings, "edit-lock", &edit_lock, NULL);
 
254
        g_object_get (settings, "edit-lock", &edit_lock, NULL);
180
255
 
181
256
        if (event->button == 1 &&
182
257
            edit_lock &&
202
277
{
203
278
        /* chances are good that they don't have the text view focused while it changed, so make non-editable if edit lock turned on */
204
279
        gboolean edit_lock;
205
 
        g_object_get (xpad_global_settings, "edit-lock", &edit_lock, NULL);
 
280
        g_object_get (view->priv->settings, "edit-lock", &edit_lock, NULL);
206
281
        gtk_text_view_set_editable (GTK_TEXT_VIEW (view), !edit_lock);
207
282
}
208
283
 
212
287
        GdkCursor *cursor;
213
288
        gboolean editable;
214
289
        GdkWindow *view_window;
 
290
        GtkTextView *view_tv = GTK_TEXT_VIEW (view);
215
291
        
216
 
        editable = gtk_text_view_get_editable (GTK_TEXT_VIEW (view));
217
 
        gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (view), editable);
 
292
        editable = gtk_text_view_get_editable (view_tv);
 
293
        gtk_text_view_set_cursor_visible (view_tv, editable);
218
294
        
219
295
        cursor = editable ? gdk_cursor_new (GDK_XTERM) : NULL;
220
296
        
221
297
        /* Only set for pads which are currently visible */ 
222
 
        view_window = gtk_text_view_get_window (GTK_TEXT_VIEW (view), GTK_TEXT_WINDOW_TEXT);
 
298
        view_window = gtk_text_view_get_window (view_tv, GTK_TEXT_WINDOW_TEXT);
223
299
        if (view_window != NULL)
224
300
                gdk_window_set_cursor (view_window, cursor);
225
301
        
231
307
xpad_text_view_notify_fontname (XpadTextView *view)
232
308
{
233
309
        const gchar *font;
234
 
        g_object_get (xpad_global_settings, "fontname", &font, NULL);
235
 
        PangoFontDescription *fontdesc;
236
 
        
237
 
        fontdesc = font ? pango_font_description_from_string (font) : NULL;
 
310
        g_object_get (view->priv->settings, "fontname", &font, NULL);
 
311
        PangoFontDescription *fontdesc = font ? pango_font_description_from_string (font) : NULL;
238
312
        gtk_widget_override_font (GTK_WIDGET (view), fontdesc);
239
313
        if (fontdesc)
240
314
                pango_font_description_free (fontdesc);
244
318
static void
245
319
xpad_text_view_notify_colors (XpadTextView *view)
246
320
{
 
321
        GtkWidget *view_widget = GTK_WIDGET (view);
247
322
        /* Set the colors of this individual pad to the global setting preference. */
248
323
        const GdkRGBA *text_color, *back_color;
249
 
        g_object_get (xpad_global_settings, "text-color", &text_color, "back-color", &back_color, NULL);
250
 
 
251
 
        gtk_widget_override_cursor (GTK_WIDGET (view), text_color, text_color);
252
 
        gtk_widget_override_color (GTK_WIDGET (view), GTK_STATE_FLAG_NORMAL, text_color);
253
 
        gtk_widget_override_background_color (GTK_WIDGET (view), GTK_STATE_FLAG_NORMAL, back_color);
254
 
 
255
 
        /* Inverse the text and background colors for selected text, so it is likely to be visible by any choice of the colors. */
256
 
        gtk_widget_override_color (GTK_WIDGET (view), GTK_STATE_FLAG_SELECTED, back_color);
257
 
        gtk_widget_override_background_color (GTK_WIDGET (view), GTK_STATE_FLAG_SELECTED, text_color);
258
 
}
259
 
 
260
 
void
261
 
xpad_text_view_set_follow_font_style (XpadTextView *view, gboolean follow)
262
 
{
263
 
        g_return_if_fail (view);
264
 
 
265
 
        if (follow != view->priv->follow_font_style)
266
 
        {
267
 
                if (follow)
268
 
                {
269
 
                        g_signal_handler_unblock (xpad_global_settings, view->priv->notify_font_handler);
270
 
                        xpad_text_view_notify_fontname (view);
271
 
                }
272
 
                else
273
 
                {
274
 
                        g_signal_handler_block (xpad_global_settings, view->priv->notify_font_handler);
275
 
                }
276
 
        }
277
 
        
278
 
        view->priv->follow_font_style = follow;
279
 
        
280
 
        g_object_notify (G_OBJECT (view), "follow_font_style");
281
 
}
282
 
 
283
 
gboolean
284
 
xpad_text_view_get_follow_font_style (XpadTextView *view)
285
 
{
286
 
        if (view == NULL)
287
 
                return TRUE;
288
 
        else
289
 
                return view->priv->follow_font_style;
290
 
}
291
 
 
292
 
void
293
 
xpad_text_view_set_follow_color_style (XpadTextView *view, gboolean follow)
294
 
{
295
 
        g_return_if_fail (view);
296
 
 
297
 
        if (follow != view->priv->follow_color_style)
298
 
        {
299
 
                if (follow)
300
 
                {
301
 
                        xpad_text_view_notify_colors (view);
302
 
                        g_signal_handler_unblock (xpad_global_settings, view->priv->notify_text_handler);
303
 
                        g_signal_handler_unblock (xpad_global_settings, view->priv->notify_back_handler);
304
 
                }
305
 
                else
306
 
                {
307
 
                        g_signal_handler_block (xpad_global_settings, view->priv->notify_text_handler);
308
 
                        g_signal_handler_block (xpad_global_settings, view->priv->notify_back_handler);
309
 
                }
310
 
 
311
 
                view->priv->follow_color_style = follow;
312
 
        }
313
 
 
314
 
        g_object_notify (G_OBJECT (view), "follow_color_style");
315
 
}
316
 
 
317
 
gboolean
318
 
xpad_text_view_get_follow_color_style (XpadTextView *view)
319
 
{
320
 
        if (view == NULL)
321
 
                return TRUE;
322
 
        else
323
 
                return view->priv->follow_color_style;
324
 
}
325
 
 
326
 
static void
327
 
xpad_text_view_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
328
 
{
329
 
        XpadTextView *view;
330
 
        
331
 
        view = XPAD_TEXT_VIEW (object);
332
 
        
333
 
        switch (prop_id)
334
 
        {
335
 
        case PROP_FOLLOW_FONT_STYLE:
336
 
                xpad_text_view_set_follow_font_style (view, g_value_get_boolean (value));
337
 
                break;
338
 
        
339
 
        case PROP_FOLLOW_COLOR_STYLE:
340
 
                xpad_text_view_set_follow_color_style (view, g_value_get_boolean (value));
341
 
                break;
342
 
        
343
 
        default:
344
 
                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
345
 
                break;
346
 
        }
347
 
}
348
 
 
349
 
static void
350
 
xpad_text_view_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
351
 
{
352
 
        XpadTextView *view;
353
 
        
354
 
        view = XPAD_TEXT_VIEW (object);
355
 
        
356
 
        switch (prop_id)
357
 
        {
358
 
        case PROP_FOLLOW_FONT_STYLE:
359
 
                g_value_set_boolean (value, xpad_text_view_get_follow_font_style (view));
360
 
                break;
361
 
        
362
 
        case PROP_FOLLOW_COLOR_STYLE:
363
 
                g_value_set_boolean (value, xpad_text_view_get_follow_color_style (view));
364
 
                break;
365
 
        
366
 
        default:
367
 
                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
368
 
                break;
369
 
        }
370
 
}
371
 
 
372
 
XpadPad *xpad_text_view_get_pad (XpadTextView *view)
373
 
{
374
 
        return xpad_text_buffer_get_pad (view->priv->buffer);
375
 
}
376
 
 
377
 
void xpad_text_view_set_pad (XpadTextView *view, XpadPad *pad)
378
 
{
379
 
        xpad_text_buffer_set_pad (view->priv->buffer, pad);
 
324
 
 
325
        if (view->priv->follow_color_style) {
 
326
                /* Set the colors to the global preferences colors */
 
327
                g_object_get (view->priv->settings, "text-color", &text_color, "back-color", &back_color, NULL);
 
328
 
 
329
                gtk_widget_override_cursor (view_widget, text_color, text_color);
 
330
                gtk_widget_override_color (view_widget, GTK_STATE_FLAG_NORMAL, text_color);
 
331
                gtk_widget_override_background_color (view_widget, GTK_STATE_FLAG_NORMAL, back_color);
 
332
 
 
333
                /* Inverse the text and background colors for selected text, so it is likely to be visible by any choice of the colors. */
 
334
                gtk_widget_override_color (view_widget, GTK_STATE_FLAG_SELECTED, back_color);
 
335
                gtk_widget_override_background_color (view_widget, GTK_STATE_FLAG_SELECTED, text_color);
 
336
 
 
337
        }
380
338
}