Merge lp:~arthurborsboom/xpad/xpad-4.3 into lp:xpad

Proposed by Arthur Borsboom
Status: Merged
Merged at revision: 670
Proposed branch: lp:~arthurborsboom/xpad/xpad-4.3
Merge into: lp:xpad
Diff against target: 3723 lines (+973/-723) (has conflicts)
21 files modified
configure.ac (+24/-3)
src/fio.c (+5/-6)
src/help.c (+24/-21)
src/prefix.c (+3/-3)
src/xpad-app.c (+100/-87)
src/xpad-app.h (+2/-0)
src/xpad-grip-tool-item.c (+12/-23)
src/xpad-pad-group.c (+2/-1)
src/xpad-pad-properties.c (+46/-37)
src/xpad-pad-properties.h (+4/-4)
src/xpad-pad.c (+267/-199)
src/xpad-periodic.c (+13/-6)
src/xpad-preferences.c (+150/-145)
src/xpad-session-manager.c (+88/-16)
src/xpad-settings.c (+71/-66)
src/xpad-settings.h (+6/-5)
src/xpad-text-buffer.c (+1/-0)
src/xpad-text-view.c (+62/-67)
src/xpad-toolbar.c (+22/-12)
src/xpad-tray.c (+13/-14)
src/xpad-undo.c (+58/-8)
Text conflict in src/xpad-pad.c
To merge this branch: bzr merge lp:~arthurborsboom/xpad/xpad-4.3
Reviewer Review Type Date Requested Status
Arthur Borsboom Approve
Review via email: mp+193655@code.launchpad.net

Description of the change

- Migration from GTK2 to GTK3
- Resolving compiler warnings

To post a comment you must log in.
Revision history for this message
Arthur Borsboom (arthurborsboom) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'configure.ac'
2--- configure.ac 2013-10-21 18:52:10 +0000
3+++ configure.ac 2013-11-01 20:03:38 +0000
4@@ -1,7 +1,7 @@
5 # Process this file with autoconf to produce a configure script.
6
7 # Sets up autoconf.
8-AC_INIT([Xpad],[4.2],[xpad-hackers@lists.launchpad.net])
9+AC_INIT([Xpad],[4.3],[xpad-hackers@lists.launchpad.net])
10 AC_CONFIG_SRCDIR(src/xpad-app.c)
11 AC_CONFIG_HEADERS([config.h:config.h.in])
12
13@@ -15,9 +15,18 @@
14 AC_PROG_MAKE_SET
15 AC_PROG_INTLTOOL([0.31], [no-xml])
16
17-# Checks for libraries.
18 AC_PATH_XTRA
19-PKG_CHECK_MODULES(GTK, gtk+-2.0 >= 2.12 gio-2.0)
20+
21+# Checks for GTK+ 3.0
22+PKG_CHECK_MODULES(GTK, gtk+-3.0 gio-2.0)
23+AM_CONDITIONAL(GTK, test -n "$GTK_LIBS")
24+# ensure that only allowed headers are included
25+GTK_CFLAGS+="-DGTK_DISABLE_SINGLE_INCLUDES "
26+# ensure that no gtk deprecated symbols are used
27+GTK_CFLAGS+="-DGDK_DISABLE_DEPRECATED "
28+GTK_CFLAGS+="-DGTK_DISABLE_DEPRECATED "
29+# ensure use of accessors
30+GTK_CFLAGS+="-DGSEAL_ENABLE "
31 AC_SUBST(GTK_CFLAGS)
32 AC_SUBST(GTK_LIBS)
33
34@@ -25,6 +34,18 @@
35 AC_SUBST(GLIB_CFLAGS)
36 AC_SUBST(GLIB_LIBS)
37
38+PKG_CHECK_MODULES(PANGO, pango >= 1.32)
39+AC_SUBST(PANGO_LIBS)
40+AC_SUBST(PANGO_CFLAGS)
41+
42+PKG_CHECK_MODULES(PIXBUF, gdk-pixbuf-2.0 >= 2.28)
43+AC_SUBST(PIXBUF_LIBS)
44+AC_SUBST(PIXBUF_CFLAGS)
45+
46+PKG_CHECK_MODULES(ATK, atk >= 2.8 atk-bridge-2.0)
47+AC_SUBST(ATK_LIBS)
48+AC_SUBST(ATK_CFLAGS)
49+
50 # Checks for typedefs, structures, and compiler characteristics.
51 AC_C_CONST
52 AC_TYPE_SIZE_T
53
54=== modified file 'src/fio.c'
55--- src/fio.c 2011-11-14 17:10:03 +0000
56+++ src/fio.c 2013-11-01 20:03:38 +0000
57@@ -57,14 +57,14 @@
58 gchar *str_replace_tokens (gchar **string, gchar obj, gchar *replacement)
59 {
60 gchar *p;
61- gint rsize = strlen (replacement);
62- gint osize = 1;
63- gint diff = rsize - osize;
64+ gsize rsize = strlen (replacement);
65+ gsize osize = 1;
66+ gsize diff = rsize - osize;
67
68 p = *string;
69 while ((p = strchr (p, obj)))
70 {
71- gint offset = p - *string;
72+ long offset = p - *string;
73 *string = g_realloc (*string, strlen (*string) + diff + 1);
74 p = *string + offset;
75 g_memmove (p + rsize, p + osize, strlen (p + osize) + 1);
76@@ -188,7 +188,7 @@
77 gchar *fullitem;
78 gint *value;
79 gchar *where;
80- gint size;
81+ gsize size;
82 gchar type;
83
84 type = item[0];
85@@ -316,4 +316,3 @@
86 g_file_delete (file, NULL, NULL);
87 g_object_unref (file);
88 }
89-
90
91=== modified file 'src/help.c'
92--- src/help.c 2013-10-18 18:31:20 +0000
93+++ src/help.c 2013-11-01 20:03:38 +0000
94@@ -40,27 +40,30 @@
95 gchar *helptextbuf;
96
97 /* Create the widgets */
98-
99 dialog = gtk_dialog_new ();
100 helptext = gtk_label_new ("");
101
102- /* we use g_strdup_printf because C89 has size limits on static strings */
103- helptextbuf = g_strdup_printf ("%s\n\n%s\n\n%s\n\n%s\n\n%s\n\n%s",
104-_("Each xpad session consists of one or more open pads. "
105-"These pads are basically sticky notes on your desktop in which "
106-"you can write memos."),
107-_("<b>To move a pad</b>, left drag on the toolbar, right drag "
108-"on the resizer in the bottom right, or hold down CTRL "
109-"while left dragging anywhere on the pad."),
110-_("<b>To resize a pad</b>, left drag on the resizer or hold down "
111-"CTRL while right dragging anywhere on the pad."),
112-_("<b>To change color settings</b>, right click on a pad "
113-"and choose Edit->Preferences."),
114-_("Most actions are available throught the popup menu "
115-"that appears when you right click on a pad. Try it out and "
116-"enjoy."),
117-_("Please send ideas or bug reports to\n"
118-"https://bugs.launchpad.net/xpad/+filebug"));
119+ if (page == 0) {
120+ /* we use g_strdup_printf because C89 has size limits on static strings */
121+ helptextbuf = g_strdup_printf ("%s\n\n%s\n\n%s\n\n%s\n\n%s\n\n%s",
122+ _("Each xpad session consists of one or more open pads. "
123+ "These pads are basically sticky notes on your desktop in which "
124+ "you can write memos."),
125+ _("<b>To move a pad</b>, left drag on the toolbar, right drag "
126+ "on the resizer in the bottom right, or hold down CTRL "
127+ "while left dragging anywhere on the pad."),
128+ _("<b>To resize a pad</b>, left drag on the resizer or hold down "
129+ "CTRL while right dragging anywhere on the pad."),
130+ _("<b>To change color settings</b>, right click on a pad "
131+ "and choose Edit->Preferences."),
132+ _("Most actions are available throught the popup menu "
133+ "that appears when you right click on a pad. Try it out and "
134+ "enjoy."),
135+ _("Please send ideas or bug reports to\n"
136+ "https://bugs.launchpad.net/xpad/+filebug"));
137+ }
138+ else
139+ helptextbuf = g_strdup_printf("Unknown help page requested");
140
141 gtk_label_set_markup (GTK_LABEL (helptext), helptextbuf);
142
143@@ -73,14 +76,14 @@
144 gtk_window_set_title (GTK_WINDOW (dialog), _("Help"));
145
146 /* Add the label, and show everything we've added to the dialog. */
147- gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->vbox), helptext);
148+ gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), helptext);
149 button = gtk_dialog_add_button (GTK_DIALOG(dialog), "gtk-close", 1);
150
151 gtk_window_set_position (GTK_WINDOW(dialog), GTK_WIN_POS_CENTER);
152
153- g_signal_connect (GTK_OBJECT (dialog), "destroy",
154+ g_signal_connect (GTK_WINDOW (dialog), "destroy",
155 G_CALLBACK (help_close), NULL);
156- g_signal_connect_swapped (GTK_OBJECT (button), "clicked",
157+ g_signal_connect_swapped (GTK_BUTTON (button), "clicked",
158 G_CALLBACK (gtk_widget_destroy), dialog);
159
160 gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
161
162=== modified file 'src/prefix.c'
163--- src/prefix.c 2008-09-21 00:03:40 +0000
164+++ src/prefix.c 2013-11-01 20:03:38 +0000
165@@ -397,7 +397,7 @@
166
167 while (end > path && *end == '/')
168 end--;
169- result = br_strndup ((char *) path, end - path + 1);
170+ result = br_strndup ((char *) path, ((size_t) (end - path + 1)));
171 if (!*result)
172 {
173 free (result);
174@@ -431,7 +431,7 @@
175 end = strrchr (path, '/');
176 if (!end) return strdup (path);
177
178- tmp = br_strndup ((char *) path, end - path);
179+ tmp = br_strndup ((char *) path, ((size_t) (end - path)));
180 if (!*tmp)
181 {
182 free (tmp);
183@@ -440,7 +440,7 @@
184 end = strrchr (tmp, '/');
185 if (!end) return tmp;
186
187- result = br_strndup (tmp, end - tmp);
188+ result = br_strndup (tmp, ((size_t) (end - tmp)));
189 free (tmp);
190
191 if (!*result)
192
193=== modified file 'src/xpad-app.c'
194--- src/xpad-app.c 2013-10-18 18:31:20 +0000
195+++ src/xpad-app.c 2013-11-01 20:03:38 +0000
196@@ -1,6 +1,7 @@
197 /**
198 * Copyright (c) 2004-2007 Michael Terry
199 * Copyright (c) 2009 Paul Ivanov
200+ * Copyright (c) 2013 Arthur Borsboom
201 *
202 * This program is free software; you can redistribute it and/or modify
203 * it under the terms of the GNU General Public License as published by
204@@ -21,16 +22,17 @@
205 /* define _GNU_SOURCE here because that makes our sockets work nice
206 Unfortunately, we lose portability... */
207 #define _GNU_SOURCE 1
208+#include "../config.h"
209 #include <stdio.h>
210 #include <unistd.h>
211 #include <sys/un.h>
212 #include <sys/socket.h>
213 #include <sys/select.h>
214+#include <errno.h>
215
216 #include <string.h>
217 #include <stdlib.h> /* for exit */
218
219-#include "../config.h"
220 #include <glib/gi18n.h>
221 #include <glib/gstdio.h>
222
223@@ -77,21 +79,21 @@
224 static gchar *server_filename;
225 static gint server_fd;
226 static FILE *output;
227-static gboolean xpad_translucent = FALSE;
228 static XpadPadGroup *pad_group;
229 static gint pads_loaded_on_start = 0;
230-
231-static gboolean process_local_args (gint *argc, gchar **argv[]);
232-static gboolean process_remote_args (gint *argc, gchar **argv[], gboolean have_gtk);
233-
234-static gboolean config_dir_exists (void);
235-static gchar *make_config_dir (void);
236-static void register_stock_icons (void);
237-static gint xpad_app_load_pads (void);
238-static gboolean xpad_app_quit_if_no_pads (XpadPadGroup *group);
239-static gboolean xpad_app_first_idle_check (XpadPadGroup *group);
240-static gboolean xpad_app_pass_args (void);
241-static gboolean xpad_app_open_proc_file (void);
242+XpadSettings *xpad_global_settings;
243+
244+static gboolean process_local_args (gint *argc, gchar **argv[]);
245+static gboolean process_remote_args (gint *argc, gchar **argv[], gboolean have_gtk);
246+
247+static gboolean config_dir_exists (void);
248+static gchar *make_config_dir (void);
249+static void register_stock_icons (void);
250+static gint xpad_app_load_pads (void);
251+static gboolean xpad_app_quit_if_no_pads (XpadPadGroup *group);
252+static gboolean xpad_app_first_idle_check (XpadPadGroup *group);
253+static gboolean xpad_app_pass_args (void);
254+static gboolean xpad_app_open_proc_file (void);
255
256
257 static void
258@@ -99,17 +101,15 @@
259 {
260 gboolean first_time;
261 gboolean have_gtk;
262- // GdkVisual *visual;
263
264- /* Set up i18n */
265+ /* Set up support different languages */
266 #ifdef ENABLE_NLS
267- gtk_set_locale ();
268 bindtextdomain (GETTEXT_PACKAGE, LOCALE_DIR);
269 bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
270 textdomain (GETTEXT_PACKAGE);
271 #endif
272
273- have_gtk = gtk_init_check (&argc, &argv);
274+ have_gtk = gtk_init_check (&argc, &argv); // Leaves 135 referenced objects behind. No idea how to unref. Total up to here 135.
275 xpad_argc = argc;
276 xpad_argv = argv;
277 output = stdout;
278@@ -137,18 +137,9 @@
279
280 g_set_application_name (_("Xpad"));
281 gdk_set_program_class (PACKAGE);
282-
283- /* Set up translucency. */
284-/* visual = gdk_visual_get_best_with_depth (32);
285- if (visual)
286- {
287- GdkColormap *colormap;
288- colormap = gdk_colormap_new (visual, TRUE);
289- gtk_widget_set_default_colormap (colormap);
290- xpad_translucent = TRUE;
291- }*/
292-
293+
294 /* Set up program path. */
295+
296 if (xpad_argc > 0)
297 program_path = g_find_program_in_path (xpad_argv[0]);
298 else
299@@ -158,26 +149,28 @@
300
301 if (xpad_app_pass_args ())
302 exit (0);
303-
304+
305 /* Race condition here, between calls */
306 xpad_app_open_proc_file ();
307
308- register_stock_icons ();
309+ register_stock_icons (); // Leaves 1039 referenced objects behind. No idea how to unref, except 1. Total up to here 1173.
310 gtk_window_set_default_icon_name (PACKAGE);
311
312- pad_group = xpad_pad_group_new();
313+ pad_group = xpad_pad_group_new(); // Creates 1 referenced object; but does get unrefferenced. Total 1173.
314 process_remote_args (&xpad_argc, &xpad_argv, TRUE);
315
316- xpad_tray_open ();
317+ xpad_tray_open (); // Creates 34 referenced objects; but only 14 get unrefferenced. Total 1193.
318 xpad_session_manager_init ();
319
320+ xpad_global_settings = xpad_settings_new (); // Creates 1 reference, 1 reference gets cleaned up. Total 1193
321+
322 /* Initialize Xpad-periodic module */
323 Xpad_periodic_init();
324 Xpad_periodic_set_callback("save-content", (XpadPeriodicFunc) xpad_pad_save_content);
325 Xpad_periodic_set_callback("save-info", (XpadPeriodicFunc) xpad_pad_save_info);
326
327 /* load all pads */
328- pads_loaded_on_start = xpad_app_load_pads ();
329+ pads_loaded_on_start = xpad_app_load_pads (); // each pad creates 333 references and leaves about 100 references behind. Total 1268.
330 if (pads_loaded_on_start == 0 && !option_new) {
331 if (!option_nonew) {
332 GtkWidget *pad = xpad_pad_new (pad_group);
333@@ -194,19 +187,15 @@
334 server_filename = NULL;
335 }
336
337-
338 gint main (gint argc, gchar **argv)
339 {
340 xpad_app_init (argc, argv);
341-
342+
343 gtk_main ();
344
345 return 0;
346 }
347
348-
349-
350-
351 /* parent and secondary may be NULL.
352 * Returns when user dismisses error.
353 */
354@@ -228,15 +217,12 @@
355 xpad_session_manager_stop_interact (FALSE);
356 }
357
358-
359-
360 G_CONST_RETURN gchar *
361 xpad_app_get_config_dir (void)
362 {
363 return config_dir;
364 }
365
366-
367 /* Returns absolute path to our own executable. May be NULL. */
368 G_CONST_RETURN gchar *
369 xpad_app_get_program_path (void)
370@@ -244,7 +230,6 @@
371 return program_path;
372 }
373
374-
375 XpadPadGroup *
376 xpad_app_get_pad_group (void)
377 {
378@@ -255,25 +240,23 @@
379 xpad_app_quit (void)
380 {
381 // Free the memory used by the pads belonging to this group
382- xpad_pad_group_destroy_pads(xpad_app_get_pad_group());
383+ xpad_pad_group_destroy_pads (xpad_app_get_pad_group());
384
385 // Free the memory used by group.
386- g_object_unref(xpad_app_get_pad_group());
387+ g_object_unref (xpad_app_get_pad_group());
388
389 // Free the memory used by the settings menu.
390- g_object_unref(XPAD_SETTINGS(xpad_settings()));
391+ g_object_unref (xpad_global_settings);
392+ xpad_global_settings = NULL; // This is needed due to the asynchronous finalizing process.
393
394 // Free the memory used by the tray icon and its menu.
395- xpad_tray_close();
396+ xpad_tray_close ();
397+
398+ // Free the theme reference. Unfortunately GTK3 leaves about 1000 objects behind.
399+ g_object_unref (gtk_icon_theme_get_default ());
400
401 // Give GTK the signal to clean the rest and quit the application.
402- gtk_main_quit();
403-}
404-
405-gboolean
406-xpad_app_get_translucent (void)
407-{
408- return xpad_translucent;
409+ gtk_main_quit ();
410 }
411
412 static gboolean
413@@ -361,19 +344,17 @@
414 * secondary text of 'secondary'. No buttons are added.
415 */
416 GtkWidget *
417-xpad_app_alert_new (GtkWindow *parent, const gchar *stock,
418- const gchar *primary, const gchar *secondary)
419+xpad_app_alert_new (GtkWindow *parent, const gchar *stock, const gchar *primary, const gchar *secondary)
420 {
421 GtkWidget *dialog, *hbox, *image, *label;
422 gchar *buf;
423
424- dialog = gtk_dialog_new_with_buttons (
425- "",
426- parent,
427- GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR,
428- NULL);
429-
430- hbox = gtk_hbox_new (FALSE, 12);
431+ dialog = gtk_dialog_new();
432+ gtk_window_set_transient_for (GTK_WINDOW (dialog), parent);
433+ gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog), TRUE);
434+ gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
435+
436+ hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 12);
437 image = gtk_image_new_from_stock (stock, GTK_ICON_SIZE_DIALOG);
438 label = gtk_label_new (NULL);
439
440@@ -385,14 +366,14 @@
441 gtk_label_set_markup (GTK_LABEL (label), buf);
442 g_free (buf);
443
444- gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), hbox);
445+ gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), 12);
446+ gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), hbox);
447 gtk_container_add (GTK_CONTAINER (hbox), image);
448 gtk_container_add (GTK_CONTAINER (hbox), label);
449
450 gtk_misc_set_alignment (GTK_MISC (image), 0.5, 0);
451 gtk_misc_set_alignment (GTK_MISC (label), 0.5, 0);
452 gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
453- gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 12);
454 gtk_container_set_border_width (GTK_CONTAINER (hbox), 6);
455 gtk_container_set_border_width (GTK_CONTAINER (dialog), 6);
456 gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
457@@ -529,16 +510,27 @@
458 converts main program arguments into one long string.
459 puts allocated string in dest, and returns size
460 */
461-static gint
462+static guint
463 args_to_string (int argc, char **argv, char **dest)
464 {
465- gint i;
466- gint size = 0;
467- gchar *p;
468-
469- for (i = 0; i < argc; i++)
470- size += strlen (argv[i]) + 1;
471-
472+ gint i = 0;
473+ guint size = 0;
474+ gchar *p = NULL;
475+ size_t string_length = 0;
476+
477+
478+ for (i = 0; i < argc; i++) {
479+ string_length = strlen (argv[i]) + 1;
480+
481+ // safe cast
482+ if( string_length <= UINT_MAX ) {
483+ size += (guint) string_length;
484+ }
485+ else {
486+ g_warning("casting the size of the arguments failed");
487+ }
488+ }
489+
490 *dest = g_malloc (size);
491
492 p = *dest;
493@@ -561,10 +553,10 @@
494 /*
495 returns number of strings in newly allocated argv
496 */
497-static gint
498+static guint
499 string_to_args (const char *string, char ***argv)
500 {
501- gint num, i;
502+ guint num, i;
503 const gchar *tmp;
504 char **list;
505
506@@ -582,8 +574,18 @@
507 /* string points to beginning of current arg */
508 tmp = strchr (string, ' '); /* NULL or end of this arg */
509
510- if (tmp) len = tmp - string;
511- else len = strlen (string);
512+ if (tmp) {
513+ long int difference = tmp - string;
514+ // safe cast from long int to size_t
515+ if (difference >= 0)
516+ len = (size_t) difference;
517+ else {
518+ g_warning("Error casting argument length. Arguments might not be processed correctly.");
519+ len = 0;
520+ }
521+ }
522+ else
523+ len = strlen (string);
524
525 list[i] = g_malloc (len + 1);
526 strncpy (list[i], string, len);
527@@ -600,18 +602,18 @@
528 return num;
529 }
530
531-#include <errno.h>
532 /* This reads a line from the proc file. This line will contain arguments to process. */
533 static void
534 xpad_app_read_from_proc_file (void)
535 {
536- gint client_fd, size;
537+ gint client_fd;
538+ guint size = 0;
539 gint argc;
540 gchar **argv;
541 gchar *args;
542 struct sockaddr_un client;
543 socklen_t client_len;
544- size_t bytes;
545+ ssize_t bytes = -1;
546
547 /* accept waiting connection */
548 client_len = sizeof (client);
549@@ -619,10 +621,12 @@
550 if (client_fd == -1)
551 return;
552
553- /* get size of args */
554+ /* get size of args and verify for errors */
555 bytes = read (client_fd, &size, sizeof (size));
556- if (bytes != sizeof(size))
557+ if (bytes == -1 || bytes != sizeof(size)) {
558+ g_warning("Cannot read proc file correctly");
559 goto close_client_fd;
560+ }
561
562 /* alloc memory */
563 args = (gchar *) g_malloc (size);
564@@ -634,7 +638,7 @@
565 if (bytes < size)
566 goto close_client_fd;
567
568- argc = string_to_args (args, &argv);
569+ argc = (gint) string_to_args (args, &argv);
570
571 g_free (args);
572
573@@ -645,7 +649,11 @@
574 {
575 /* if there were no non-local arguments, insert --new as argument */
576 gint c = 2;
577- gchar **v = g_malloc (sizeof (gchar *) * c);
578+ gchar **v = NULL;
579+ unsigned long int my_size = 0;
580+ // safe cast
581+ my_size = sizeof (gchar *) * (long unsigned) c;
582+ v = g_malloc (my_size);
583 v[0] = PACKAGE;
584 v[1] = "--new";
585
586@@ -665,10 +673,15 @@
587 close (client_fd);
588 }
589
590-
591 static gboolean
592 can_read_from_server_fd (GIOChannel *source, GIOCondition condition, gpointer data)
593 {
594+ // A dirty way to silence the compiler for these unused variables.
595+ // Feel free to implement these variables in the way they are ment to be used.
596+ (void) source;
597+ (void) condition;
598+ (void) data;
599+
600 xpad_app_read_from_proc_file ();
601
602 return TRUE;
603@@ -712,8 +725,8 @@
604 fd_set fdset;
605 gchar buf [129];
606 gchar *args = NULL;
607- gint size;
608- gint bytesRead;
609+ guint size;
610+ ssize_t bytesRead;
611 gboolean connected = FALSE;
612 ssize_t error = NULL;
613
614
615=== modified file 'src/xpad-app.h'
616--- src/xpad-app.h 2013-10-09 14:46:10 +0000
617+++ src/xpad-app.h 2013-11-01 20:03:38 +0000
618@@ -21,6 +21,7 @@
619
620 #include <gtk/gtk.h>
621 #include "xpad-pad-group.h"
622+#include "xpad-settings.h"
623
624 G_BEGIN_DECLS
625
626@@ -30,6 +31,7 @@
627 G_CONST_RETURN gchar *xpad_app_get_config_dir (void);
628 G_CONST_RETURN gchar *xpad_app_get_program_path (void);
629 XpadPadGroup *xpad_app_get_pad_group (void);
630+XpadSettings *xpad_global_settings;
631 gboolean xpad_app_get_translucent (void);
632 void xpad_app_quit (void);
633
634
635=== modified file 'src/xpad-grip-tool-item.c'
636--- src/xpad-grip-tool-item.c 2013-10-18 18:31:20 +0000
637+++ src/xpad-grip-tool-item.c 2013-11-01 20:03:38 +0000
638@@ -16,6 +16,7 @@
639 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
640 */
641
642+#include "../config.h"
643 #include "xpad-grip-tool-item.h"
644
645 struct XpadGripToolItemPrivate
646@@ -28,7 +29,7 @@
647 static void xpad_grip_tool_item_dispose (GObject *object);
648 static void xpad_grip_tool_item_finalize (GObject *object);
649
650-static gboolean xpad_grip_tool_item_event_box_expose (GtkWidget *widget, GdkEventExpose *event);
651+static gboolean xpad_grip_tool_item_event_box_draw (GtkWidget *widget, cairo_t *cr);
652 static void xpad_grip_tool_item_event_box_realize (GtkWidget *widget);
653 static gboolean xpad_grip_tool_item_button_pressed_event (GtkWidget *widget, GdkEventButton *event);
654
655@@ -59,7 +60,7 @@
656 gtk_widget_add_events (grip->priv->drawbox, GDK_BUTTON_PRESS_MASK | GDK_EXPOSURE_MASK);
657 g_signal_connect (grip->priv->drawbox, "button-press-event", G_CALLBACK (xpad_grip_tool_item_button_pressed_event), NULL);
658 g_signal_connect (grip->priv->drawbox, "realize", G_CALLBACK (xpad_grip_tool_item_event_box_realize), NULL);
659- g_signal_connect (grip->priv->drawbox, "expose-event", G_CALLBACK (xpad_grip_tool_item_event_box_expose), NULL);
660+ g_signal_connect (grip->priv->drawbox, "draw", G_CALLBACK (xpad_grip_tool_item_event_box_draw), NULL);
661 gtk_widget_set_size_request (grip->priv->drawbox, 18, 18);
662
663 right = gtk_widget_get_direction (grip->priv->drawbox) == GTK_TEXT_DIR_LTR;
664@@ -95,7 +96,7 @@
665 edge = GDK_WINDOW_EDGE_SOUTH_WEST;
666
667 gtk_window_begin_resize_drag (GTK_WINDOW (gtk_widget_get_toplevel (widget)),
668- edge, event->button, event->x_root, event->y_root, event->time);
669+ edge, (gint) event->button, (gint) event->x_root, (gint) event->y_root, event->time);
670
671 return TRUE;
672 }
673@@ -116,30 +117,18 @@
674 cursor_type = GDK_BOTTOM_LEFT_CORNER;
675
676 cursor = gdk_cursor_new_for_display (display, cursor_type);
677- gdk_window_set_cursor (widget->window, cursor);
678- gdk_cursor_unref (cursor);
679+ gdk_window_set_cursor (gtk_widget_get_window(widget), cursor);
680+ g_object_unref (cursor);
681 }
682
683 static gboolean
684-xpad_grip_tool_item_event_box_expose (GtkWidget *widget, GdkEventExpose *event)
685+xpad_grip_tool_item_event_box_draw (GtkWidget *widget, cairo_t *cr)
686 {
687- GdkWindowEdge edge;
688-
689- if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR)
690- edge = GDK_WINDOW_EDGE_SOUTH_EAST;
691- else
692- edge = GDK_WINDOW_EDGE_SOUTH_WEST;
693-
694- gtk_paint_resize_grip (
695- widget->style,
696- widget->window,
697- GTK_WIDGET_STATE (widget),
698- NULL,
699- widget,
700- "xpad-grip-tool-item",
701- edge,
702- 0, 0,
703- widget->allocation.width, widget->allocation.height);
704+ gtk_render_handle(gtk_widget_get_style_context(widget),
705+ cr,
706+ 0, 0,
707+ gtk_widget_get_allocated_width(widget),
708+ gtk_widget_get_allocated_width(widget));
709
710 return FALSE;
711 }
712
713=== modified file 'src/xpad-pad-group.c'
714--- src/xpad-pad-group.c 2013-10-18 18:31:20 +0000
715+++ src/xpad-pad-group.c 2013-11-01 20:03:38 +0000
716@@ -17,6 +17,7 @@
717 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
718 */
719
720+#include "../config.h"
721 #include "xpad-pad-group.h"
722 #include "xpad-settings.h"
723 #include "xpad-pad.h"
724@@ -165,7 +166,7 @@
725 GSList *i;
726 for (i = group->priv->pads; i; i = i->next)
727 {
728- if (GTK_WIDGET_VISIBLE(GTK_WIDGET(i->data)))
729+ if (gtk_widget_get_visible(GTK_WIDGET(i->data)))
730 num ++;
731 }
732 g_slist_free(i);
733
734=== modified file 'src/xpad-pad-properties.c'
735--- src/xpad-pad-properties.c 2013-10-21 02:51:19 +0000
736+++ src/xpad-pad-properties.c 2013-11-01 20:03:38 +0000
737@@ -29,10 +29,10 @@
738 GtkWidget *colorbox;
739
740 GtkWidget *textbutton;
741- GdkColor texttmp;
742+ GdkRGBA texttmp;
743
744 GtkWidget *backbutton;
745- GdkColor backtmp;
746+ GdkRGBA backtmp;
747
748 GtkWidget *fontbutton;
749 };
750@@ -100,7 +100,7 @@
751 g_param_spec_boxed ("text-color",
752 "Text Color",
753 "The color of text in the pad",
754- GDK_TYPE_COLOR,
755+ GDK_TYPE_RGBA,
756 G_PARAM_READWRITE));
757
758 g_object_class_install_property (gobject_class,
759@@ -108,7 +108,7 @@
760 g_param_spec_boxed ("back-color",
761 "Back Color",
762 "The color of the background in the pad",
763- GDK_TYPE_COLOR,
764+ GDK_TYPE_RGBA,
765 G_PARAM_READWRITE));
766
767 g_object_class_install_property (gobject_class,
768@@ -123,7 +123,7 @@
769 static void
770 xpad_pad_properties_init (XpadPadProperties *prop)
771 {
772- GtkWidget *font_radio, *color_radio, *hbox, *font_hbox, *vbox;
773+ GtkWidget *font_radio, *color_radio, *hbox, *font_hbox, *vbox = NULL;
774 GtkWidget *label, *appearance_frame, *alignment, *appearance_vbox;
775 gchar *text;
776 GtkSizeGroup *size_group_labels = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
777@@ -137,10 +137,10 @@
778 "xalign", 0.0,
779 NULL));
780 g_free (text);
781- appearance_vbox = GTK_WIDGET (g_object_new (GTK_TYPE_VBOX,
782- "homogeneous", FALSE,
783- "spacing", 18,
784- NULL));
785+
786+ appearance_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 18);
787+ gtk_box_set_homogeneous (GTK_BOX (appearance_vbox), FALSE);
788+
789 alignment = gtk_alignment_new (1, 1, 1, 1);
790 g_object_set (G_OBJECT (alignment),
791 "left-padding", 12,
792@@ -163,12 +163,14 @@
793 color_radio = gtk_radio_button_new_with_mnemonic (NULL, _("Use colors from xpad preferences"));
794 prop->priv->colorcheck = gtk_radio_button_new_with_mnemonic_from_widget (GTK_RADIO_BUTTON (color_radio), _("Use these colors:"));
795
796- font_hbox = gtk_hbox_new (FALSE, 6);
797+ font_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
798+
799 gtk_box_pack_start (GTK_BOX (font_hbox), prop->priv->fontcheck, FALSE, FALSE, 0);
800 gtk_box_pack_start (GTK_BOX (font_hbox), prop->priv->fontbutton, TRUE, TRUE, 0);
801
802- prop->priv->colorbox = gtk_vbox_new (FALSE, 6);
803- hbox = gtk_hbox_new (FALSE, 12);
804+ prop->priv->colorbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
805+ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
806+
807 label = gtk_label_new_with_mnemonic (_("Background:"));
808 gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
809 gtk_size_group_add_widget (size_group_labels, label);
810@@ -176,7 +178,7 @@
811 gtk_box_pack_start (GTK_BOX (hbox), prop->priv->backbutton, TRUE, TRUE, 0);
812 g_object_set (G_OBJECT (prop->priv->colorbox), "child", hbox, NULL);
813
814- hbox = gtk_hbox_new (FALSE, 12);
815+ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
816 label = gtk_label_new_with_mnemonic (_("Foreground:"));
817 gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
818 gtk_size_group_add_widget (size_group_labels, label);
819@@ -188,25 +190,26 @@
820 gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 0, 0, 12, 0);
821 gtk_container_add (GTK_CONTAINER (alignment), prop->priv->colorbox);
822
823-
824 gtk_dialog_add_button (GTK_DIALOG (prop), "gtk-close", GTK_RESPONSE_CLOSE);
825 gtk_dialog_set_default_response (GTK_DIALOG (prop), GTK_RESPONSE_CLOSE);
826- gtk_dialog_set_has_separator (GTK_DIALOG (prop), FALSE);
827 g_signal_connect (prop, "response", G_CALLBACK (xpad_pad_properties_response), NULL);
828
829- gtk_color_button_set_use_alpha (GTK_COLOR_BUTTON (prop->priv->textbutton), FALSE);
830- gtk_color_button_set_use_alpha (GTK_COLOR_BUTTON (prop->priv->backbutton), FALSE);
831+ gtk_color_chooser_set_use_alpha (GTK_COLOR_CHOOSER (prop->priv->textbutton), FALSE);
832+ gtk_color_chooser_set_use_alpha (GTK_COLOR_CHOOSER (prop->priv->backbutton), TRUE);
833
834 gtk_color_button_set_title (GTK_COLOR_BUTTON (prop->priv->textbutton), _("Set Foreground Color"));
835 gtk_color_button_set_title (GTK_COLOR_BUTTON (prop->priv->backbutton), _("Set Background Color"));
836 gtk_font_button_set_title (GTK_FONT_BUTTON (prop->priv->fontbutton), _("Set Font"));
837
838- vbox = gtk_vbox_new (FALSE, 6);
839+ vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
840+ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
841+
842 gtk_box_pack_start (GTK_BOX (vbox), font_radio, FALSE, FALSE, 0);
843 gtk_box_pack_start (GTK_BOX (vbox), font_hbox, FALSE, FALSE, 0);
844 gtk_box_pack_start (GTK_BOX (appearance_vbox), vbox, FALSE, FALSE, 0);
845-
846- vbox = gtk_vbox_new (FALSE, 6);
847+
848+ vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
849+
850 gtk_box_pack_start (GTK_BOX (vbox), color_radio, FALSE, FALSE, 0);
851 gtk_box_pack_start (GTK_BOX (vbox), prop->priv->colorcheck, FALSE, FALSE, 0);
852 gtk_box_pack_start (GTK_BOX (vbox), alignment, FALSE, FALSE, 0);
853@@ -227,10 +230,9 @@
854
855 g_object_unref (size_group_labels);
856
857- g_object_set (G_OBJECT (GTK_DIALOG (prop)->vbox),
858- "child", appearance_frame,
859- NULL);
860- gtk_widget_show_all (GTK_DIALOG (prop)->vbox);
861+ gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (prop))), appearance_frame);
862+
863+ gtk_widget_show_all (gtk_dialog_get_content_area (GTK_DIALOG (prop)));
864 }
865
866 static void
867@@ -271,18 +273,30 @@
868 static void
869 change_text_color (GtkColorButton *button, XpadPadProperties *prop)
870 {
871+ // A dirty way to silence the compiler for these unused variables.
872+ // Feel free to implement these variables in the way they are ment to be used.
873+ (void) button;
874+
875 g_object_notify (G_OBJECT (prop), "text-color");
876 }
877
878 static void
879 change_back_color (GtkColorButton *button, XpadPadProperties *prop)
880 {
881+ // A dirty way to silence the compiler for these unused variables.
882+ // Feel free to implement these variables in the way they are ment to be used.
883+ (void) button;
884+
885 g_object_notify (G_OBJECT (prop), "back-color");
886 }
887
888 static void
889 change_font_face (GtkFontButton *button, XpadPadProperties *prop)
890 {
891+ // A dirty way to silence the compiler for these unused variables.
892+ // Feel free to implement these variables in the way they are ment to be used.
893+ (void) button;
894+
895 g_object_notify (G_OBJECT (prop), "fontname");
896 }
897
898@@ -290,7 +304,6 @@
899 xpad_pad_properties_set_follow_font_style (XpadPadProperties *prop, gboolean follow)
900 {
901 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (prop->priv->fontcheck), !follow);
902-
903 g_object_notify (G_OBJECT (prop), "follow_font_style");
904 }
905
906@@ -304,7 +317,6 @@
907 xpad_pad_properties_set_follow_color_style (XpadPadProperties *prop, gboolean follow)
908 {
909 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (prop->priv->colorcheck), !follow);
910-
911 g_object_notify (G_OBJECT (prop), "follow_color_style");
912 }
913
914@@ -315,32 +327,30 @@
915 }
916
917 void
918-xpad_pad_properties_set_back_color (XpadPadProperties *prop, const GdkColor *back)
919+xpad_pad_properties_set_back_color (XpadPadProperties *prop, const GdkRGBA *back)
920 {
921- gtk_color_button_set_color (GTK_COLOR_BUTTON (prop->priv->backbutton), back);
922-
923+ gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (prop->priv->backbutton), back);
924 g_object_notify (G_OBJECT (prop), "back_color");
925 }
926
927-G_CONST_RETURN GdkColor *
928+G_CONST_RETURN GdkRGBA *
929 xpad_pad_properties_get_back_color (XpadPadProperties *prop)
930 {
931- gtk_color_button_get_color (GTK_COLOR_BUTTON (prop->priv->backbutton), &prop->priv->backtmp);
932+ gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (prop->priv->backbutton), &prop->priv->backtmp);
933 return &prop->priv->backtmp;
934 }
935
936 void
937-xpad_pad_properties_set_text_color (XpadPadProperties *prop, const GdkColor *text)
938+xpad_pad_properties_set_text_color (XpadPadProperties *prop, const GdkRGBA *text)
939 {
940- gtk_color_button_set_color (GTK_COLOR_BUTTON (prop->priv->textbutton), text);
941-
942+ gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (prop->priv->textbutton), text);
943 g_object_notify (G_OBJECT (prop), "text_color");
944 }
945
946-G_CONST_RETURN GdkColor *
947+G_CONST_RETURN GdkRGBA *
948 xpad_pad_properties_get_text_color (XpadPadProperties *prop)
949 {
950- gtk_color_button_get_color (GTK_COLOR_BUTTON (prop->priv->textbutton), &prop->priv->texttmp);
951+ gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (prop->priv->textbutton), &prop->priv->texttmp);
952 return &prop->priv->texttmp;
953 }
954
955@@ -348,7 +358,6 @@
956 xpad_pad_properties_set_fontname (XpadPadProperties *prop, const gchar *fontname)
957 {
958 gtk_font_button_set_font_name (GTK_FONT_BUTTON (prop->priv->fontbutton), fontname);
959-
960 g_object_notify (G_OBJECT (prop), "fontname");
961 }
962
963
964=== modified file 'src/xpad-pad-properties.h'
965--- src/xpad-pad-properties.h 2008-09-21 00:03:40 +0000
966+++ src/xpad-pad-properties.h 2013-11-01 20:03:38 +0000
967@@ -58,11 +58,11 @@
968 void xpad_pad_properties_set_follow_color_style (XpadPadProperties *pad_properties, gboolean follow);
969 gboolean xpad_pad_properties_get_follow_color_style (XpadPadProperties *pad_properties);
970
971-void xpad_pad_properties_set_back_color (XpadPadProperties *pad_properties, const GdkColor *back);
972-G_CONST_RETURN GdkColor *xpad_pad_properties_get_back_color (XpadPadProperties *pad_properties);
973+void xpad_pad_properties_set_back_color (XpadPadProperties *pad_properties, const GdkRGBA *back);
974+G_CONST_RETURN GdkRGBA *xpad_pad_properties_get_back_color (XpadPadProperties *pad_properties);
975
976-void xpad_pad_properties_set_text_color (XpadPadProperties *pad_properties, const GdkColor *text);
977-G_CONST_RETURN GdkColor *xpad_pad_properties_get_text_color (XpadPadProperties *pad_properties);
978+void xpad_pad_properties_set_text_color (XpadPadProperties *pad_properties, const GdkRGBA *text);
979+G_CONST_RETURN GdkRGBA *xpad_pad_properties_get_text_color (XpadPadProperties *pad_properties);
980
981 void xpad_pad_properties_set_fontname (XpadPadProperties *pad_properties, const gchar *fontname);
982 G_CONST_RETURN gchar *xpad_pad_properties_get_fontname (XpadPadProperties *pad_properties);
983
984=== modified file 'src/xpad-pad.c'
985--- src/xpad-pad.c 2013-10-23 18:30:54 +0000
986+++ src/xpad-pad.c 2013-11-01 20:03:38 +0000
987@@ -123,8 +123,8 @@
988 static void xpad_pad_paste (XpadPad *pad);
989 static void xpad_pad_delete (XpadPad *pad);
990 static void xpad_pad_open_properties (XpadPad *pad);
991-static void xpad_pad_open_preferences (XpadPad *pad);
992-static void xpad_pad_quit (XpadPad *pad);
993+static void xpad_pad_open_preferences ();
994+static void xpad_pad_quit ();
995 static void xpad_pad_close_all (XpadPad *pad);
996 static void xpad_pad_sync_title (XpadPad *pad);
997 static void xpad_pad_set_group (XpadPad *pad, XpadPadGroup *group);
998@@ -237,11 +237,11 @@
999 pad->priv->x = 0;
1000 pad->priv->y = 0;
1001 pad->priv->location_valid = FALSE;
1002- pad->priv->width = xpad_settings_get_width (xpad_settings ());
1003- pad->priv->height = xpad_settings_get_height (xpad_settings ());
1004+ pad->priv->width = xpad_settings_get_width (xpad_global_settings);
1005+ pad->priv->height = xpad_settings_get_height (xpad_global_settings);
1006 pad->priv->infoname = NULL;
1007 pad->priv->contentname = NULL;
1008- pad->priv->sticky = xpad_settings_get_sticky (xpad_settings ());
1009+ pad->priv->sticky = xpad_settings_get_sticky (xpad_global_settings);
1010 pad->priv->textview = NULL;
1011 pad->priv->scrollbar = NULL;
1012 pad->priv->toolbar = NULL;
1013@@ -254,11 +254,7 @@
1014 pad->priv->unsaved_info = FALSE;
1015 pad->priv->group = NULL;
1016
1017- XpadTextView *text_view = g_object_new (XPAD_TYPE_TEXT_VIEW,
1018- "follow-font-style", TRUE,
1019- "follow-color-style", TRUE,
1020- NULL);
1021-
1022+ XpadTextView *text_view = XPAD_TEXT_VIEW (xpad_text_view_new ());
1023 xpad_text_view_set_pad (text_view, pad);
1024
1025 pad->priv->textview = GTK_WIDGET (text_view);
1026@@ -276,25 +272,26 @@
1027
1028 accel_group = gtk_accel_group_new ();
1029 gtk_window_add_accel_group (GTK_WINDOW (pad), accel_group);
1030+
1031 pad->priv->menu = menu_get_popup_no_highlight (pad, accel_group);
1032 pad->priv->highlight_menu = menu_get_popup_highlight (pad, accel_group);
1033- gtk_accel_group_connect (accel_group, GDK_Q, GDK_CONTROL_MASK, 0,
1034- g_cclosure_new_swap (G_CALLBACK (xpad_pad_quit), pad, NULL));
1035+
1036+ gtk_accel_group_connect (accel_group, GDK_KEY_Q, GDK_CONTROL_MASK, 0,
1037+ g_cclosure_new_swap (G_CALLBACK (xpad_app_quit), pad, NULL));
1038 g_object_unref (G_OBJECT (accel_group));
1039
1040- vbox = GTK_WIDGET (g_object_new (GTK_TYPE_VBOX,
1041- "homogeneous", FALSE,
1042- "spacing", 0,
1043- "child", pad->priv->scrollbar,
1044- "child", pad->priv->toolbar,
1045- NULL));
1046+ vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
1047+ gtk_box_set_homogeneous (GTK_BOX(vbox), FALSE);
1048+ gtk_box_pack_start (GTK_BOX(vbox), pad->priv->scrollbar, TRUE, TRUE, 0);
1049+ gtk_box_pack_start (GTK_BOX(vbox), pad->priv->toolbar, FALSE, FALSE, 0);
1050+
1051 gtk_container_child_set (GTK_CONTAINER (vbox), pad->priv->toolbar, "expand", FALSE, NULL);
1052
1053- gtk_window_set_decorated (GTK_WINDOW(pad), xpad_settings_get_has_decorations (xpad_settings ()));
1054- gtk_window_set_default_size (GTK_WINDOW(pad), (gint) xpad_settings_get_width (xpad_settings ()), (gint) xpad_settings_get_height (xpad_settings ()));
1055- gtk_window_set_gravity (GTK_WINDOW(pad), GDK_GRAVITY_STATIC); /* static gravity makes saving pad x,y work */
1056- gtk_window_set_skip_pager_hint (GTK_WINDOW(pad),xpad_settings_get_has_decorations (xpad_settings ()));
1057- gtk_window_set_skip_taskbar_hint (GTK_WINDOW(pad), !xpad_settings_get_has_decorations (xpad_settings ()));
1058+ gtk_window_set_decorated (GTK_WINDOW(pad), xpad_settings_get_has_decorations (xpad_global_settings));
1059+ gtk_window_set_default_size (GTK_WINDOW(pad), (gint) xpad_settings_get_width (xpad_global_settings), (gint) xpad_settings_get_height (xpad_global_settings));
1060+ gtk_window_set_gravity (GTK_WINDOW(pad), GDK_GRAVITY_STATIC); // static gravity makes saving pad x,y work
1061+ gtk_window_set_skip_pager_hint (GTK_WINDOW(pad),xpad_settings_get_has_decorations (xpad_global_settings));
1062+ gtk_window_set_skip_taskbar_hint (GTK_WINDOW(pad), !xpad_settings_get_has_decorations (xpad_global_settings));
1063 gtk_window_set_type_hint (GTK_WINDOW(pad), GDK_WINDOW_TYPE_HINT_NORMAL);
1064 gtk_window_set_position (GTK_WINDOW(pad), GTK_WIN_POS_MOUSE);
1065
1066@@ -321,7 +318,7 @@
1067 gtk_widget_hide (pad->priv->toolbar);
1068 xpad_pad_notify_has_toolbar (pad);
1069
1070- /* Set up signals */
1071+ // Set up signals
1072 gtk_widget_add_events (GTK_WIDGET (pad), GDK_BUTTON_PRESS_MASK | GDK_PROPERTY_CHANGE_MASK);
1073 gtk_widget_add_events (pad->priv->toolbar, GDK_ALL_EVENTS_MASK);
1074 g_signal_connect (pad->priv->textview, "button-press-event", G_CALLBACK (xpad_pad_text_view_button_press_event), pad);
1075@@ -337,10 +334,10 @@
1076 g_signal_connect (pad, "enter-notify-event", G_CALLBACK (xpad_pad_enter_notify_event), NULL);
1077 g_signal_connect (pad, "leave-notify-event", G_CALLBACK (xpad_pad_leave_notify_event), NULL);
1078
1079- g_signal_connect_swapped (xpad_settings (), "notify::has-decorations", G_CALLBACK (xpad_pad_notify_has_decorations), pad);
1080- g_signal_connect_swapped (xpad_settings (), "notify::has-toolbar", G_CALLBACK (xpad_pad_notify_has_toolbar), pad);
1081- g_signal_connect_swapped (xpad_settings (), "notify::autohide-toolbar", G_CALLBACK (xpad_pad_notify_autohide_toolbar), pad);
1082- g_signal_connect_swapped (xpad_settings (), "notify::has-scrollbar", G_CALLBACK (xpad_pad_notify_has_scrollbar), pad);
1083+ g_signal_connect_swapped (xpad_global_settings, "notify::has-decorations", G_CALLBACK (xpad_pad_notify_has_decorations), pad);
1084+ g_signal_connect_swapped (xpad_global_settings, "notify::has-toolbar", G_CALLBACK (xpad_pad_notify_has_toolbar), pad);
1085+ g_signal_connect_swapped (xpad_global_settings, "notify::autohide-toolbar", G_CALLBACK (xpad_pad_notify_autohide_toolbar), pad);
1086+ g_signal_connect_swapped (xpad_global_settings, "notify::has-scrollbar", G_CALLBACK (xpad_pad_notify_has_scrollbar), pad);
1087 g_signal_connect_swapped (gtk_text_view_get_buffer (GTK_TEXT_VIEW (pad->priv->textview)), "notify::has-selection", G_CALLBACK (xpad_pad_notify_has_selection), pad);
1088 g_signal_connect_swapped (pad->priv->clipboard, "owner-change", G_CALLBACK (xpad_pad_notify_clipboard_owner_changed), pad);
1089
1090@@ -365,25 +362,6 @@
1091 }
1092
1093 static void
1094-xpad_pad_show (XpadPad *pad)
1095-{
1096- /* Some wm's might not acknowledge our request for a specific
1097- location before we are shown. What we do here is a little gimpy
1098- and not very respectful of wms' sovereignty, but it has the effect
1099- of making pads' locations very dependable. We just move the pad
1100- again here after being shown. This may create a visual effect if
1101- the wm did ignore us, but is better than being in the wrong
1102- place, I guess. */
1103- if (pad->priv->location_valid)
1104- gtk_window_move (GTK_WINDOW (pad), pad->priv->x, pad->priv->y);
1105-
1106- if (pad->priv->sticky)
1107- gtk_window_stick (GTK_WINDOW (pad));
1108- else
1109- gtk_window_unstick (GTK_WINDOW (pad));
1110-}
1111-
1112-static void
1113 xpad_pad_dispose (GObject *object)
1114 {
1115 XpadPad *pad = XPAD_PAD (object);
1116@@ -403,13 +381,18 @@
1117 pad->priv->highlight_menu = NULL;
1118 }
1119
1120+ // For some reason the clipboard handler does not get automatically disconnected (or not at the right moment), leading to errors after deleting a pad. This manual disconnect prevents this error.
1121 if (GTK_IS_CLIPBOARD(pad->priv->clipboard)) {
1122- // For some reason the clipboard handler does not get automatically disconnected (or not at the right moment), leading to errors after deleting a pad. This manual disconnect prevents this error.
1123 g_signal_handlers_disconnect_matched (pad->priv->clipboard, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, pad);
1124 }
1125
1126+<<<<<<< TREE
1127 if (XPAD_IS_TOOLBAR(pad->priv->toolbar)) {
1128 // For some reason the toolbar handler does not get automatically disconnected (or not at the right moment), leading to errors after deleting a pad. This manual disconnect prevents this error.
1129+=======
1130+ // For some reason the toolbar handler does not get automatically disconnected (or not at the right moment), leading to errors after deleting a pad. This manual disconnect prevents this error.
1131+ if (XPAD_IS_TOOLBAR(pad->priv->toolbar)) {
1132+>>>>>>> MERGE-SOURCE
1133 g_signal_handlers_disconnect_matched (pad->priv->toolbar, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, pad);
1134 gtk_widget_destroy(pad->priv->toolbar);
1135 pad->priv->toolbar = NULL;
1136@@ -423,7 +406,8 @@
1137 {
1138 XpadPad *pad = XPAD_PAD (object);
1139
1140- g_signal_handlers_disconnect_matched (xpad_settings (), G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, pad);
1141+ if (xpad_global_settings != NULL)
1142+ g_signal_handlers_disconnect_matched (xpad_global_settings, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, pad);
1143
1144 g_free (pad->priv->infoname);
1145 g_free (pad->priv->contentname);
1146@@ -432,9 +416,28 @@
1147 }
1148
1149 static void
1150+xpad_pad_show (XpadPad *pad)
1151+{
1152+ /* Some wm's might not acknowledge our request for a specific
1153+ location before we are shown. What we do here is a little gimpy
1154+ and not very respectful of wms' sovereignty, but it has the effect
1155+ of making pads' locations very dependable. We just move the pad
1156+ again here after being shown. This may create a visual effect if
1157+ the wm did ignore us, but is better than being in the wrong
1158+ place, I guess. */
1159+ if (pad->priv->location_valid)
1160+ gtk_window_move (GTK_WINDOW (pad), pad->priv->x, pad->priv->y);
1161+
1162+ if (pad->priv->sticky)
1163+ gtk_window_stick (GTK_WINDOW (pad));
1164+ else
1165+ gtk_window_unstick (GTK_WINDOW (pad));
1166+}
1167+
1168+static void
1169 xpad_pad_notify_has_scrollbar (XpadPad *pad)
1170 {
1171- if (xpad_settings_get_has_scrollbar (xpad_settings ()))
1172+ if (xpad_settings_get_has_scrollbar (xpad_global_settings))
1173 {
1174 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (pad->priv->scrollbar),
1175 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
1176@@ -458,7 +461,7 @@
1177 static void
1178 xpad_pad_notify_has_decorations (XpadPad *pad)
1179 {
1180- gboolean decorations = xpad_settings_get_has_decorations (xpad_settings ());
1181+ gboolean decorations = xpad_settings_get_has_decorations (xpad_global_settings);
1182
1183 /**
1184 * There are two modes of operation: a normal mode and a 'stealth' mode.
1185@@ -478,7 +481,7 @@
1186 static guint
1187 xpad_pad_text_and_toolbar_height (XpadPad *pad)
1188 {
1189- GdkRectangle rec;
1190+ cairo_rectangle_int_t rec;
1191 gint textx, texty, x, y;
1192 GtkTextIter iter;
1193
1194@@ -503,22 +506,22 @@
1195 static void
1196 xpad_pad_show_toolbar (XpadPad *pad)
1197 {
1198- if (!GTK_WIDGET_VISIBLE (pad->priv->toolbar))
1199+ if (!gtk_widget_get_visible (pad->priv->toolbar))
1200 {
1201 GtkRequisition req;
1202
1203- if (GTK_WIDGET (pad)->window)
1204- gdk_window_freeze_updates (GTK_WIDGET (pad)->window);
1205+ if (gtk_widget_get_window(GTK_WIDGET(pad)))
1206+ gdk_window_freeze_updates (gtk_widget_get_window(GTK_WIDGET(pad)));
1207 gtk_widget_show (pad->priv->toolbar);
1208 if (!pad->priv->toolbar_height)
1209 {
1210- gtk_widget_size_request (pad->priv->toolbar, &req);
1211+ gtk_widget_get_preferred_size (pad->priv->toolbar, &req, NULL);
1212 // safe cast from gint to guint
1213 if (req.height >= 0) {
1214 pad->priv->toolbar_height = (guint) req.height;
1215 }
1216 else {
1217- g_warning("There is a problem in the program Xpad. In function 'xpad_pad_show_toolbar' the variable 'req.height' is not a postive number. Please send a bugreport to https://bugs.launchpad.net/xpad/+filebug to help improve Xpad.");
1218+ g_warning ("There is a problem in the program Xpad. In function 'xpad_pad_show_toolbar' the variable 'req.height' is not a postive number. Please send a bugreport to https://bugs.launchpad.net/xpad/+filebug to help improve Xpad.");
1219 pad->priv->toolbar_height = 0;
1220 }
1221 }
1222@@ -535,18 +538,18 @@
1223
1224 pad->priv->toolbar_pad_resized = FALSE;
1225
1226- if (GTK_WIDGET (pad)->window)
1227- gdk_window_thaw_updates (GTK_WIDGET (pad)->window);
1228+ if (gtk_widget_get_window(GTK_WIDGET(pad)))
1229+ gdk_window_thaw_updates (gtk_widget_get_window(GTK_WIDGET(pad)));
1230 }
1231 }
1232
1233 static void
1234 xpad_pad_hide_toolbar (XpadPad *pad)
1235 {
1236- if (GTK_WIDGET_VISIBLE (pad->priv->toolbar))
1237+ if (gtk_widget_get_visible (pad->priv->toolbar))
1238 {
1239- if (GTK_WIDGET (pad)->window)
1240- gdk_window_freeze_updates (GTK_WIDGET (pad)->window);
1241+ if (gtk_widget_get_window(GTK_WIDGET(pad)))
1242+ gdk_window_freeze_updates (gtk_widget_get_window(GTK_WIDGET(pad)));
1243 gtk_widget_hide (pad->priv->toolbar);
1244
1245 if (pad->priv->toolbar_expanded ||
1246@@ -556,17 +559,17 @@
1247 gtk_window_resize (GTK_WINDOW (pad), (gint) pad->priv->width, (gint) pad->priv->height);
1248 pad->priv->toolbar_expanded = FALSE;
1249 }
1250- if (GTK_WIDGET (pad)->window)
1251- gdk_window_thaw_updates (GTK_WIDGET (pad)->window);
1252+ if (gtk_widget_get_window(GTK_WIDGET(pad)))
1253+ gdk_window_thaw_updates (gtk_widget_get_window(GTK_WIDGET(pad)));
1254 }
1255 }
1256
1257 static void
1258 xpad_pad_notify_has_toolbar (XpadPad *pad)
1259 {
1260- if (xpad_settings_get_has_toolbar (xpad_settings ()))
1261+ if (xpad_settings_get_has_toolbar (xpad_global_settings))
1262 {
1263- if (!xpad_settings_get_autohide_toolbar (xpad_settings ()))
1264+ if (!xpad_settings_get_autohide_toolbar (xpad_global_settings))
1265 xpad_pad_show_toolbar (pad);
1266 }
1267 else
1268@@ -580,8 +583,8 @@
1269 return FALSE;
1270
1271 if (pad->priv->toolbar_timeout &&
1272- xpad_settings_get_autohide_toolbar (xpad_settings ()) &&
1273- xpad_settings_get_has_toolbar (xpad_settings ()))
1274+ xpad_settings_get_autohide_toolbar (xpad_global_settings) &&
1275+ xpad_settings_get_has_toolbar (xpad_global_settings))
1276 xpad_pad_hide_toolbar (pad);
1277
1278 pad->priv->toolbar_timeout = 0;
1279@@ -592,7 +595,7 @@
1280 static void
1281 xpad_pad_notify_autohide_toolbar (XpadPad *pad)
1282 {
1283- if (xpad_settings_get_autohide_toolbar (xpad_settings ()))
1284+ if (xpad_settings_get_autohide_toolbar (xpad_global_settings))
1285 {
1286 /* Likely not to be in pad when turning setting on */
1287 if (!pad->priv->toolbar_timeout)
1288@@ -600,7 +603,7 @@
1289 }
1290 else
1291 {
1292- if (xpad_settings_get_has_toolbar (xpad_settings ()))
1293+ if (xpad_settings_get_has_toolbar (xpad_global_settings))
1294 xpad_pad_show_toolbar(pad);
1295 }
1296 }
1297@@ -613,9 +616,9 @@
1298 GtkTextBuffer *buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (pad->priv->textview));
1299 gboolean has_selection = gtk_text_buffer_get_has_selection (buffer);
1300
1301- XpadToolbar *toolbar = NULL;
1302- toolbar = XPAD_TOOLBAR (pad->priv->toolbar);
1303- g_return_if_fail (toolbar);
1304+ XpadToolbar *toolbar = XPAD_TOOLBAR (pad->priv->toolbar);
1305+ if (toolbar == NULL)
1306+ return;
1307
1308 xpad_toolbar_enable_cut_button (toolbar, has_selection);
1309 xpad_toolbar_enable_copy_button (toolbar, has_selection);
1310@@ -628,7 +631,7 @@
1311
1312 XpadToolbar *toolbar = NULL;
1313 // safe cast to toolbar
1314- if (XPAD_IS_TOOLBAR(pad->priv->toolbar)) {
1315+ if (XPAD_IS_TOOLBAR (pad->priv->toolbar)) {
1316 toolbar = XPAD_TOOLBAR (pad->priv->toolbar);
1317 g_return_if_fail (toolbar);
1318
1319@@ -660,8 +663,8 @@
1320 static gboolean
1321 xpad_pad_enter_notify_event (GtkWidget *pad, GdkEventCrossing *event)
1322 {
1323- if (xpad_settings_get_has_toolbar (xpad_settings ()) &&
1324- xpad_settings_get_autohide_toolbar (xpad_settings ()) &&
1325+ if (xpad_settings_get_has_toolbar (xpad_global_settings) &&
1326+ xpad_settings_get_autohide_toolbar (xpad_global_settings) &&
1327 event->detail != GDK_NOTIFY_INFERIOR &&
1328 event->mode == GDK_CROSSING_NORMAL)
1329 {
1330@@ -675,8 +678,8 @@
1331 static gboolean
1332 xpad_pad_leave_notify_event (GtkWidget *pad, GdkEventCrossing *event)
1333 {
1334- if (xpad_settings_get_has_toolbar (xpad_settings ()) &&
1335- xpad_settings_get_autohide_toolbar (xpad_settings ()) &&
1336+ if (xpad_settings_get_has_toolbar (xpad_global_settings) &&
1337+ xpad_settings_get_autohide_toolbar (xpad_global_settings) &&
1338 event->detail != GDK_NOTIFY_INFERIOR &&
1339 event->mode == GDK_CROSSING_NORMAL)
1340 {
1341@@ -727,7 +730,7 @@
1342 void
1343 xpad_pad_toggle(XpadPad *pad)
1344 {
1345- if (GTK_WIDGET_VISIBLE (pad))
1346+ if (gtk_widget_get_visible (GTK_WIDGET(pad)))
1347 xpad_pad_close (pad);
1348 else
1349 gtk_widget_show (GTK_WIDGET (pad));
1350@@ -741,7 +744,7 @@
1351 gchar *content;
1352 gboolean confirm;
1353
1354- if (!xpad_settings_get_confirm_destroy (xpad_settings ()))
1355+ if (!xpad_settings_get_confirm_destroy (xpad_global_settings))
1356 return FALSE;
1357
1358 buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (pad->priv->textview));
1359@@ -832,7 +835,7 @@
1360 PangoFontDescription *fontdesc;
1361
1362 fontdesc = font ? pango_font_description_from_string (font) : NULL;
1363- gtk_widget_modify_font (pad->priv->textview, fontdesc);
1364+ gtk_widget_override_font (pad->priv->textview, fontdesc);
1365 if (fontdesc)
1366 pango_font_description_free (fontdesc);
1367 }
1368@@ -841,38 +844,41 @@
1369 }
1370
1371 static void
1372-prop_notify_follow_color (XpadPad *pad)
1373+prop_notify_colors (XpadPad *pad)
1374 {
1375 XpadPadProperties *prop = XPAD_PAD_PROPERTIES (pad->priv->properties);
1376
1377 xpad_text_view_set_follow_color_style (XPAD_TEXT_VIEW (pad->priv->textview), xpad_pad_properties_get_follow_color_style (prop));
1378-
1379- if (!xpad_pad_properties_get_follow_color_style (prop))
1380- {
1381- gtk_widget_modify_base (pad->priv->textview, GTK_STATE_NORMAL, xpad_pad_properties_get_back_color (prop));
1382- gtk_widget_modify_text (pad->priv->textview, GTK_STATE_NORMAL, xpad_pad_properties_get_text_color (prop));
1383- }
1384-
1385- xpad_pad_save_info_delayed (pad);
1386-}
1387-
1388-static void
1389-prop_notify_text (XpadPad *pad)
1390-{
1391- XpadPadProperties *prop = XPAD_PAD_PROPERTIES (pad->priv->properties);
1392-
1393- gtk_widget_modify_text (pad->priv->textview, GTK_STATE_NORMAL, xpad_pad_properties_get_text_color (prop));
1394-
1395- xpad_pad_save_info_delayed (pad);
1396-}
1397-
1398-static void
1399-prop_notify_back (XpadPad *pad)
1400-{
1401- XpadPadProperties *prop = XPAD_PAD_PROPERTIES (pad->priv->properties);
1402-
1403- gtk_widget_modify_base (pad->priv->textview, GTK_STATE_NORMAL, xpad_pad_properties_get_back_color (prop));
1404-
1405+
1406+ if (xpad_pad_properties_get_follow_color_style (prop))
1407+ {
1408+ // Set the colors to the global preferences colors
1409+ const GdkRGBA *text_color = xpad_settings_get_text_color (xpad_global_settings);
1410+ const GdkRGBA *back_color = xpad_settings_get_back_color (xpad_global_settings);
1411+
1412+ gtk_widget_override_cursor (pad->priv->textview, text_color, text_color);
1413+ gtk_widget_override_color (pad->priv->textview, GTK_STATE_FLAG_NORMAL, text_color);
1414+ gtk_widget_override_background_color (pad->priv->textview, GTK_STATE_FLAG_NORMAL, back_color);
1415+
1416+ // Inverse the text and background colors for selected text, so it is likely to be visible by any choice of the colors.
1417+ gtk_widget_override_color (pad->priv->textview, GTK_STATE_FLAG_SELECTED, back_color);
1418+ gtk_widget_override_background_color (pad->priv->textview, GTK_STATE_FLAG_SELECTED, text_color);
1419+ }
1420+ else
1421+ {
1422+ // Set the color to the individual pad properties colors
1423+ const GdkRGBA *text_color = xpad_pad_properties_get_text_color (prop);
1424+ const GdkRGBA *back_color = xpad_pad_properties_get_back_color (prop);
1425+
1426+ gtk_widget_override_cursor (pad->priv->textview, text_color, text_color);
1427+ gtk_widget_override_color (pad->priv->textview, GTK_STATE_FLAG_NORMAL, text_color);
1428+ gtk_widget_override_background_color (pad->priv->textview, GTK_STATE_FLAG_NORMAL, back_color);
1429+
1430+ // Inverse the text and background colors for selected text, so it is likely to be visible by any choice of the colors.
1431+ gtk_widget_override_color (pad->priv->textview, GTK_STATE_FLAG_SELECTED, back_color);
1432+ gtk_widget_override_background_color (pad->priv->textview, GTK_STATE_FLAG_SELECTED, text_color);
1433+ }
1434+
1435 xpad_pad_save_info_delayed (pad);
1436 }
1437
1438@@ -885,7 +891,7 @@
1439 PangoFontDescription *fontdesc;
1440
1441 fontdesc = font ? pango_font_description_from_string (font) : NULL;
1442- gtk_widget_modify_font (pad->priv->textview, fontdesc);
1443+ gtk_widget_override_font (pad->priv->textview, fontdesc);
1444 if (fontdesc)
1445 pango_font_description_free (fontdesc);
1446
1447@@ -895,8 +901,10 @@
1448 static void
1449 xpad_pad_open_properties (XpadPad *pad)
1450 {
1451- GtkStyle *style;
1452- gchar *fontname;
1453+ GtkStyleContext *style = NULL;
1454+ PangoFontDescription *font;
1455+ GdkRGBA widget_text_color = {0, 0, 0, 0};
1456+ GdkRGBA widget_background_color = {0, 0, 0, 0};
1457
1458 if (pad->priv->properties)
1459 {
1460@@ -911,22 +919,25 @@
1461
1462 g_signal_connect_swapped (pad->priv->properties, "destroy", G_CALLBACK (pad_properties_destroyed), pad);
1463 g_signal_connect (pad, "notify::title", G_CALLBACK (pad_properties_sync_title), NULL);
1464-
1465- style = gtk_widget_get_style (pad->priv->textview);
1466- fontname = style->font_desc ? pango_font_description_to_string (style->font_desc) : NULL;
1467+
1468+ style = gtk_widget_get_style_context (pad->priv->textview);
1469+ gtk_style_context_get(style, GTK_STATE_FLAG_NORMAL, GTK_STYLE_PROPERTY_FONT, &font, NULL);
1470+ gtk_style_context_get_color (style, GTK_STATE_FLAG_NORMAL, &widget_text_color);
1471+ gtk_style_context_get_background_color (style, GTK_STATE_FLAG_NORMAL, &widget_background_color);
1472+
1473 g_object_set (G_OBJECT (pad->priv->properties),
1474 "follow-font-style", xpad_text_view_get_follow_font_style (XPAD_TEXT_VIEW (pad->priv->textview)),
1475 "follow-color-style", xpad_text_view_get_follow_color_style (XPAD_TEXT_VIEW (pad->priv->textview)),
1476- "back-color", &style->base[GTK_STATE_NORMAL],
1477- "text-color", &style->text[GTK_STATE_NORMAL],
1478- "fontname", fontname,
1479+ "back-color", &widget_background_color,
1480+ "text-color", &widget_text_color,
1481+ "fontname", pango_font_description_to_string(font),
1482 NULL);
1483- g_free (fontname);
1484+ pango_font_description_free (font);
1485
1486 g_signal_connect_swapped (pad->priv->properties, "notify::follow-font-style", G_CALLBACK (prop_notify_follow_font), pad);
1487- g_signal_connect_swapped (pad->priv->properties, "notify::follow-color-style", G_CALLBACK (prop_notify_follow_color), pad);
1488- g_signal_connect_swapped (pad->priv->properties, "notify::text-color", G_CALLBACK (prop_notify_text), pad);
1489- g_signal_connect_swapped (pad->priv->properties, "notify::back-color", G_CALLBACK (prop_notify_back), pad);
1490+ g_signal_connect_swapped (pad->priv->properties, "notify::follow-color-style", G_CALLBACK (prop_notify_colors), pad);
1491+ g_signal_connect_swapped (pad->priv->properties, "notify::text-color", G_CALLBACK (prop_notify_colors), pad);
1492+ g_signal_connect_swapped (pad->priv->properties, "notify::back-color", G_CALLBACK (prop_notify_colors), pad);
1493 g_signal_connect_swapped (pad->priv->properties, "notify::fontname", G_CALLBACK (prop_notify_font), pad);
1494
1495 pad_properties_sync_title (pad);
1496@@ -935,13 +946,13 @@
1497 }
1498
1499 static void
1500-xpad_pad_open_preferences (XpadPad *pad)
1501+xpad_pad_open_preferences ()
1502 {
1503 xpad_preferences_open ();
1504 }
1505
1506 static void
1507-xpad_pad_quit (XpadPad *pad)
1508+xpad_pad_quit ()
1509 {
1510 xpad_app_quit ();
1511 }
1512@@ -949,6 +960,10 @@
1513 static void
1514 xpad_pad_text_changed (XpadPad *pad, GtkTextBuffer *buffer)
1515 {
1516+ // A dirty way to silence the compiler for these unused variables.
1517+ // Feel free to implement these variables in the way they are ment to be used.
1518+ (void) buffer;
1519+
1520 /* set title */
1521 xpad_pad_sync_title (pad);
1522
1523@@ -973,7 +988,7 @@
1524 static gboolean
1525 xpad_pad_configure_event (XpadPad *pad, GdkEventConfigure *event)
1526 {
1527- if (!GTK_WIDGET_VISIBLE (pad))
1528+ if (!gtk_widget_get_visible (GTK_WIDGET(pad)))
1529 return FALSE;
1530
1531 int eWidth = event->width;
1532@@ -1012,6 +1027,10 @@
1533 static gboolean
1534 xpad_pad_delete_event (XpadPad *pad, GdkEvent *event)
1535 {
1536+ // A dirty way to silence the compiler for these unused variables.
1537+ // Feel free to implement these variables in the way they are ment to be used.
1538+ (void) event;
1539+
1540 xpad_pad_close (pad);
1541
1542 return TRUE;
1543@@ -1028,6 +1047,10 @@
1544 static gboolean
1545 xpad_pad_text_view_button_press_event (GtkWidget *text_view, GdkEventButton *event, XpadPad *pad)
1546 {
1547+ // A dirty way to silence the compiler for these unused variables.
1548+ // Feel free to implement these variables in the way they are ment to be used.
1549+ (void) text_view;
1550+
1551 if (event->type == GDK_BUTTON_PRESS)
1552 {
1553 switch (event->button)
1554@@ -1236,7 +1259,10 @@
1555 {
1556 gboolean locked = FALSE, follow_font = TRUE, follow_color = TRUE;
1557 gboolean hidden = FALSE;
1558- GdkColor text = {0}, back = {0};
1559+ gchar *text_color_string = NULL;
1560+ gchar *background_color_string = NULL;
1561+ GdkRGBA text = {0, 0, 0, 0};
1562+ GdkRGBA back = {0, 0, 0, 0};
1563 gchar *fontname = NULL;
1564
1565 if (!pad->priv->infoname)
1566@@ -1252,12 +1278,8 @@
1567 "b|follow_color", &follow_color,
1568 "b|sticky", &pad->priv->sticky,
1569 "b|hidden", &hidden,
1570- "h|back_red", &back.red,
1571- "h|back_green", &back.green,
1572- "h|back_blue", &back.blue,
1573- "h|text_red", &text.red,
1574- "h|text_green", &text.green,
1575- "h|text_blue", &text.blue,
1576+ "s|back", &background_color_string,
1577+ "s|text", &text_color_string,
1578 "s|fontname", &fontname,
1579 "s|content", &pad->priv->contentname,
1580 NULL))
1581@@ -1266,8 +1288,8 @@
1582 pad->priv->unsaved_info = FALSE;
1583
1584 pad->priv->location_valid = TRUE;
1585- if (xpad_settings_get_has_toolbar (xpad_settings ()) &&
1586- !xpad_settings_get_autohide_toolbar (xpad_settings ()))
1587+ if (xpad_settings_get_has_toolbar (xpad_global_settings) &&
1588+ !xpad_settings_get_autohide_toolbar (xpad_global_settings))
1589 {
1590 pad->priv->toolbar_height = 0;
1591 xpad_pad_hide_toolbar (pad);
1592@@ -1280,26 +1302,45 @@
1593 xpad_text_view_set_follow_font_style (XPAD_TEXT_VIEW (pad->priv->textview), follow_font);
1594 xpad_text_view_set_follow_color_style (XPAD_TEXT_VIEW (pad->priv->textview), follow_color);
1595
1596- /* obsolete setting, no longer written as of xpad-2.0-b2 */
1597 if (locked)
1598 {
1599 xpad_text_view_set_follow_font_style (XPAD_TEXT_VIEW (pad->priv->textview), FALSE);
1600 xpad_text_view_set_follow_color_style (XPAD_TEXT_VIEW (pad->priv->textview), FALSE);
1601 }
1602
1603- if (!xpad_text_view_get_follow_color_style (XPAD_TEXT_VIEW (pad->priv->textview)))
1604- {
1605- gtk_widget_modify_text (pad->priv->textview, GTK_STATE_NORMAL, &text);
1606- gtk_widget_modify_base (pad->priv->textview, GTK_STATE_NORMAL, &back);
1607- }
1608-
1609- if (!xpad_text_view_get_follow_font_style (XPAD_TEXT_VIEW (pad->priv->textview)))
1610+ if (!follow_font)
1611 {
1612 PangoFontDescription *font_desc = pango_font_description_from_string (fontname);
1613- gtk_widget_modify_font (pad->priv->textview, font_desc);
1614+ gtk_widget_override_font (pad->priv->textview, font_desc);
1615 pango_font_description_free (font_desc);
1616 }
1617
1618+ if (!follow_color)
1619+ {
1620+ // If, for some reason, one of the colors could not be retrieved
1621+ // (for example due to the migration to the new GdkRGBA colors), set the color to the default.
1622+ if (text_color_string == NULL || background_color_string == NULL) {
1623+ text = (GdkRGBA) {0, 0, 0, 1};
1624+ back = (GdkRGBA) {1, 0.933334350586, 0.6, 1};
1625+ }
1626+ else {
1627+ // If, for some reason, the parsing of the colors fail, set the color to the default.
1628+ if (!gdk_rgba_parse (&text, text_color_string) || !gdk_rgba_parse (&back, background_color_string)) {
1629+ text = (GdkRGBA) {0, 0, 0, 1};
1630+ back = (GdkRGBA) {1, 0.933334350586, 0.6, 1};
1631+ }
1632+ }
1633+
1634+ // Set the text and background color for this pad, as stated in its properties file.
1635+ gtk_widget_override_cursor (pad->priv->textview, &text, &text);
1636+ gtk_widget_override_color (pad->priv->textview, GTK_STATE_FLAG_NORMAL, &text);
1637+ gtk_widget_override_background_color (pad->priv->textview, GTK_STATE_FLAG_NORMAL, &back);
1638+
1639+ // Inverse the text and background colors for selected text, so it is likely to be visible by any choice of the colors.
1640+ gtk_widget_override_color (pad->priv->textview, GTK_STATE_FLAG_SELECTED, &back);
1641+ gtk_widget_override_background_color (pad->priv->textview, GTK_STATE_FLAG_SELECTED, &text);
1642+ }
1643+
1644 /* Find the sticky notes menu setting for this pad (which is on the global default),
1645 * and change its setting to the setting from the info file (pad specific default).
1646 */
1647@@ -1346,8 +1387,10 @@
1648 xpad_pad_save_info (XpadPad *pad)
1649 {
1650 guint height = NULL;
1651- GtkStyle *style = NULL;
1652- gchar *fontname = NULL;
1653+ GtkStyleContext *style = NULL;
1654+ PangoFontDescription *font = NULL;
1655+ GdkRGBA widget_text_color = {0, 0, 0, 0};
1656+ GdkRGBA widget_background_color = {0, 0, 0, 0};
1657
1658 g_return_if_fail (pad);
1659
1660@@ -1371,12 +1414,14 @@
1661 }
1662
1663 height = pad->priv->height;
1664- if (GTK_WIDGET_VISIBLE (pad->priv->toolbar) && pad->priv->toolbar_expanded)
1665+ if (gtk_widget_get_visible (pad->priv->toolbar) && pad->priv->toolbar_expanded)
1666 height -= pad->priv->toolbar_height;
1667
1668- style = gtk_widget_get_style (pad->priv->textview);
1669- fontname = pango_font_description_to_string (style->font_desc);
1670-
1671+ style = gtk_widget_get_style_context (pad->priv->textview);
1672+ gtk_style_context_get (style, GTK_STATE_FLAG_NORMAL, GTK_STYLE_PROPERTY_FONT, &font, NULL);
1673+ gtk_style_context_get_color (style, GTK_STATE_FLAG_NORMAL, &widget_text_color);
1674+ gtk_style_context_get_background_color (style, GTK_STATE_FLAG_NORMAL, &widget_background_color);
1675+
1676 fio_set_values_to_file (pad->priv->infoname,
1677 "i|width", pad->priv->width,
1678 "i|height", height,
1679@@ -1385,19 +1430,15 @@
1680 "b|follow_font", xpad_text_view_get_follow_font_style (XPAD_TEXT_VIEW (pad->priv->textview)),
1681 "b|follow_color", xpad_text_view_get_follow_color_style (XPAD_TEXT_VIEW (pad->priv->textview)),
1682 "b|sticky", pad->priv->sticky,
1683- "b|hidden", !GTK_WIDGET_VISIBLE (pad),
1684- "h|back_red", style->base[GTK_STATE_NORMAL].red,
1685- "h|back_green", style->base[GTK_STATE_NORMAL].green,
1686- "h|back_blue", style->base[GTK_STATE_NORMAL].blue,
1687- "h|text_red", style->text[GTK_STATE_NORMAL].red,
1688- "h|text_green", style->text[GTK_STATE_NORMAL].green,
1689- "h|text_blue", style->text[GTK_STATE_NORMAL].blue,
1690- "s|fontname", fontname,
1691+ "b|hidden", !gtk_widget_get_visible (GTK_WIDGET(pad)),
1692+ "s|back", gdk_rgba_to_string (&widget_background_color),
1693+ "s|text", gdk_rgba_to_string (&widget_text_color),
1694+ "s|fontname", pango_font_description_to_string (font),
1695 "s|content", pad->priv->contentname,
1696 NULL);
1697
1698+ pango_font_description_free (font);
1699 pad->priv->unsaved_info = FALSE;
1700- g_free (fontname);
1701 }
1702
1703 static void
1704@@ -1407,21 +1448,6 @@
1705 const gchar *authors[] = {"Arthur Borsboom <arthurborsboom@gmail.com>", "Jeroen Vermeulen <jtv@xs4all.nl>", "Michael Terry <mike@mterry.name>", "Paul Ivanov <pivanov@berkeley.edu>", "Sachin Raut <great.sachin@gmail.com>", NULL};
1706 const gchar *comments = _("Sticky notes");
1707 const gchar *copyright = "© 2001-2013 Michael Terry";
1708- /* we use g_strdup_printf because C89 has size limits on static strings */
1709- gchar *license = g_strdup_printf ("%s\n%s\n%s",
1710-"This program is free software; you can redistribute it and/or\n"
1711-"modify it under the terms of the GNU General Public License\n"
1712-"as published by the Free Software Foundation; either version 3\n"
1713-"of the License, or (at your option) any later version.\n"
1714-,
1715-"This program is distributed in the hope that it will be useful,\n"
1716-"but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
1717-"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
1718-"GNU General Public License for more details.\n"
1719-,
1720-"You should have received a copy of the GNU General Public License\n"
1721-"along with this program; if not, write to the Free Software\n"
1722-"Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.");
1723 /* Translators: please translate this as your own name and optionally email
1724 like so: "Your Name <your@email.com>" */
1725 const gchar *translator_credits = _("translator-credits");
1726@@ -1432,14 +1458,12 @@
1727 "authors", authors,
1728 "comments", comments,
1729 "copyright", copyright,
1730- "license", license,
1731+ "license-type", GTK_LICENSE_GPL_3_0,
1732 "logo-icon-name", PACKAGE,
1733 "translator-credits", translator_credits,
1734 "version", VERSION,
1735 "website", website,
1736 NULL);
1737-
1738- g_free (license);
1739 }
1740
1741 void
1742@@ -1616,25 +1640,41 @@
1743 static void
1744 menu_toolbar (XpadPad *pad, GtkCheckMenuItem *check)
1745 {
1746- xpad_settings_set_has_toolbar (xpad_settings (), gtk_check_menu_item_get_active (check));
1747+ // A dirty way to silence the compiler for these unused variables.
1748+ // Feel free to implement these variables in the way they are ment to be used.
1749+ (void) pad;
1750+
1751+ xpad_settings_set_has_toolbar (xpad_global_settings, gtk_check_menu_item_get_active (check));
1752 }
1753
1754 static void
1755 menu_scrollbar (XpadPad *pad, GtkCheckMenuItem *check)
1756 {
1757- xpad_settings_set_has_scrollbar (xpad_settings (), gtk_check_menu_item_get_active (check));
1758+ // A dirty way to silence the compiler for these unused variables.
1759+ // Feel free to implement these variables in the way they are ment to be used.
1760+ (void) pad;
1761+
1762+ xpad_settings_set_has_scrollbar (xpad_global_settings, gtk_check_menu_item_get_active (check));
1763 }
1764
1765 static void
1766 menu_autohide (XpadPad *pad, GtkCheckMenuItem *check)
1767 {
1768- xpad_settings_set_autohide_toolbar (xpad_settings (), gtk_check_menu_item_get_active (check));
1769+ // A dirty way to silence the compiler for these unused variables.
1770+ // Feel free to implement these variables in the way they are ment to be used.
1771+ (void) pad;
1772+
1773+ xpad_settings_set_autohide_toolbar (xpad_global_settings, gtk_check_menu_item_get_active (check));
1774 }
1775
1776 static void
1777 menu_decorated (XpadPad *pad, GtkCheckMenuItem *check)
1778 {
1779- xpad_settings_set_has_decorations (xpad_settings (), gtk_check_menu_item_get_active (check));
1780+ // A dirty way to silence the compiler for these unused variables.
1781+ // Feel free to implement these variables in the way they are ment to be used.
1782+ (void) pad;
1783+
1784+ xpad_settings_set_has_decorations (xpad_global_settings, gtk_check_menu_item_get_active (check));
1785 }
1786
1787 static gint
1788@@ -1718,7 +1758,6 @@
1789 MENU_ADD_STOCK (GTK_STOCK_CLOSE, xpad_pad_close);
1790 MENU_ADD_STOCK (GTK_STOCK_DELETE, xpad_pad_delete);
1791
1792-
1793 item = gtk_menu_item_new_with_mnemonic (_("_Edit"));
1794 gtk_container_add (GTK_CONTAINER (uppermenu), item);
1795 gtk_widget_show (item);
1796@@ -1726,10 +1765,10 @@
1797 menu = gtk_menu_new ();
1798 gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), menu);
1799
1800- MENU_ADD_STOCK_WITH_ACCEL (GTK_STOCK_UNDO, menu_undo, GDK_Z, GDK_CONTROL_MASK);
1801+ MENU_ADD_STOCK_WITH_ACCEL (GTK_STOCK_UNDO, menu_undo, GDK_KEY_Z, GDK_CONTROL_MASK);
1802 g_object_set_data (G_OBJECT (uppermenu), "undo", item);
1803
1804- MENU_ADD_STOCK_WITH_ACCEL (GTK_STOCK_REDO, menu_redo, GDK_R, GDK_CONTROL_MASK);
1805+ MENU_ADD_STOCK_WITH_ACCEL (GTK_STOCK_REDO, menu_redo, GDK_KEY_R, GDK_CONTROL_MASK);
1806 g_object_set_data (G_OBJECT (uppermenu), "redo", item);
1807
1808 MENU_ADD_SEP();
1809@@ -1749,11 +1788,11 @@
1810 menu = gtk_menu_new ();
1811 gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), menu);
1812
1813- MENU_ADD_CHECK (_("_Toolbar"), xpad_settings_get_has_toolbar (xpad_settings ()), menu_toolbar);
1814- MENU_ADD_CHECK (_("_Autohide Toolbar"), xpad_settings_get_autohide_toolbar (xpad_settings ()), menu_autohide);
1815- gtk_widget_set_sensitive (item, xpad_settings_get_has_toolbar (xpad_settings ()));
1816- MENU_ADD_CHECK (_("_Scrollbar"), xpad_settings_get_has_scrollbar (xpad_settings ()), menu_scrollbar);
1817- MENU_ADD_CHECK (_("_Window Decorations"), xpad_settings_get_has_decorations (xpad_settings ()), menu_decorated);
1818+ MENU_ADD_CHECK (_("_Toolbar"), xpad_settings_get_has_toolbar (xpad_global_settings), menu_toolbar);
1819+ MENU_ADD_CHECK (_("_Autohide Toolbar"), xpad_settings_get_autohide_toolbar (xpad_global_settings), menu_autohide);
1820+ gtk_widget_set_sensitive (item, xpad_settings_get_has_toolbar (xpad_global_settings));
1821+ MENU_ADD_CHECK (_("_Scrollbar"), xpad_settings_get_has_scrollbar (xpad_global_settings), menu_scrollbar);
1822+ MENU_ADD_CHECK (_("_Window Decorations"), xpad_settings_get_has_decorations (xpad_global_settings), menu_decorated);
1823
1824
1825 item = gtk_menu_item_new_with_mnemonic (_("_Notes"));
1826@@ -1776,7 +1815,7 @@
1827 menu = gtk_menu_new ();
1828 gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), menu);
1829
1830- MENU_ADD (_("_Contents"), GTK_STOCK_HELP, GDK_F1, 0, show_help);
1831+ MENU_ADD (_("_Contents"), GTK_STOCK_HELP, GDK_KEY_F1, 0, show_help);
1832 MENU_ADD (_("_About"), GTK_STOCK_ABOUT, 0, 0, menu_about);
1833
1834 return uppermenu;
1835@@ -1880,9 +1919,9 @@
1836 MENU_ADD_STOCK (GTK_STOCK_PASTE, menu_paste);
1837 g_object_set_data (G_OBJECT (menu), "paste", item);
1838 MENU_ADD_SEP ();
1839- MENU_ADD_STOCK_WITH_ACCEL (GTK_STOCK_BOLD, menu_bold, GDK_b, GDK_CONTROL_MASK);
1840- MENU_ADD_STOCK_WITH_ACCEL (GTK_STOCK_ITALIC, menu_italic, GDK_i, GDK_CONTROL_MASK);
1841- MENU_ADD_STOCK_WITH_ACCEL (GTK_STOCK_UNDERLINE, menu_underline, GDK_u, GDK_CONTROL_MASK);
1842+ MENU_ADD_STOCK_WITH_ACCEL (GTK_STOCK_BOLD, menu_bold, GDK_KEY_b, GDK_CONTROL_MASK);
1843+ MENU_ADD_STOCK_WITH_ACCEL (GTK_STOCK_ITALIC, menu_italic, GDK_KEY_i, GDK_CONTROL_MASK);
1844+ MENU_ADD_STOCK_WITH_ACCEL (GTK_STOCK_UNDERLINE, menu_underline, GDK_KEY_u, GDK_CONTROL_MASK);
1845 MENU_ADD_STOCK (GTK_STOCK_STRIKETHROUGH, menu_strikethrough);
1846
1847 return menu;
1848@@ -1891,6 +1930,10 @@
1849 static void
1850 menu_prep_popup_highlight (XpadPad *pad, GtkWidget *menu)
1851 {
1852+ // A dirty way to silence the compiler for these unused variables.
1853+ // Feel free to implement these variables in the way they are ment to be used.
1854+ (void) pad;
1855+
1856 GtkWidget *item;
1857 GtkClipboard *clipboard;
1858
1859@@ -1904,6 +1947,10 @@
1860 static void
1861 menu_popup (GtkWidget *menu, XpadPad *pad)
1862 {
1863+ // A dirty way to silence the compiler for these unused variables.
1864+ // Feel free to implement these variables in the way they are ment to be used.
1865+ (void) menu;
1866+
1867 g_signal_handlers_block_matched (pad, G_SIGNAL_MATCH_FUNC, 0, 0, NULL, (gpointer) xpad_pad_leave_notify_event, NULL);
1868 pad->priv->toolbar_timeout = 0;
1869 }
1870@@ -1911,20 +1958,33 @@
1871 static void
1872 menu_popdown (GtkWidget *menu, XpadPad *pad)
1873 {
1874- GdkRectangle rect;
1875-
1876- g_signal_handlers_unblock_matched (pad, G_SIGNAL_MATCH_FUNC, 0, 0, NULL, (gpointer) xpad_pad_leave_notify_event, NULL);
1877-
1878+ // A dirty way to silence the compiler for these unused variables.
1879+ // Feel free to implement these variables in the way they are ment to be used.
1880+ (void) menu;
1881+
1882+ cairo_rectangle_int_t rect;
1883+
1884 /**
1885 * We must check if we disabled off of pad and start the timeout if so.
1886 */
1887- gdk_window_get_pointer (GTK_WIDGET (pad)->window, &rect.x, &rect.y, NULL);
1888+
1889+ // TODO: The replacement GTK3 function below gives a Gdk-critical error.
1890+ // However when setting the rectangular to a fixed x and y position, I don't see any negative effects.
1891+ // What is the reason of getting the device position for making the menu dissapear?
1892+
1893+ // GTK2: gdk_window_get_pointer (gtk_widget_get_window(GTK_WIDGET(pad)), &rect.x, &rect.y, NULL);
1894+ // GTK3: gdk_window_get_device_position (gtk_widget_get_window (GTK_WIDGET (pad)), GDK_SOURCE_MOUSE, &rect.x, &rect.y, NULL);
1895+ // Gdk-CRITICAL **: gdk_window_get_device_position: assertion 'GDK_IS_DEVICE (device)' failed
1896+
1897+ rect.x = 10;
1898+ rect.y = 10;
1899 rect.width = 1;
1900 rect.height = 1;
1901
1902- if (!pad->priv->toolbar_timeout &&
1903- !gtk_widget_intersect (GTK_WIDGET (pad), &rect, NULL))
1904+ if (!pad->priv->toolbar_timeout && !gtk_widget_intersect (GTK_WIDGET (pad), &rect, NULL))
1905 pad->priv->toolbar_timeout = g_timeout_add (1000, (GSourceFunc) toolbar_timeout, pad);
1906+
1907+ g_signal_handlers_unblock_matched (pad, G_SIGNAL_MATCH_FUNC, 0, 0, NULL, (gpointer) xpad_pad_leave_notify_event, NULL);
1908 }
1909
1910 static void
1911@@ -1936,12 +1996,20 @@
1912 static void
1913 xpad_pad_toolbar_popup (GtkWidget *toolbar, GtkMenu *menu, XpadPad *pad)
1914 {
1915+ // A dirty way to silence the compiler for these unused variables.
1916+ // Feel free to implement these variables in the way they are ment to be used.
1917+ (void) toolbar;
1918+
1919 menu_popup (GTK_WIDGET (menu), pad);
1920 }
1921
1922 static void
1923 xpad_pad_toolbar_popdown (GtkWidget *toolbar, GtkMenu *menu, XpadPad *pad)
1924 {
1925+ // A dirty way to silence the compiler for these unused variables.
1926+ // Feel free to implement these variables in the way they are ment to be used.
1927+ (void) toolbar;
1928+
1929 menu_popdown (GTK_WIDGET (menu), pad);
1930 }
1931
1932
1933=== modified file 'src/xpad-periodic.c'
1934--- src/xpad-periodic.c 2013-10-09 14:46:10 +0000
1935+++ src/xpad-periodic.c 2013-11-01 20:03:38 +0000
1936@@ -1,4 +1,4 @@
1937-
1938+#include "../config.h"
1939 #include <stdlib.h>
1940 #include <stdio.h>
1941 #include <string.h>
1942@@ -57,21 +57,20 @@
1943 gboolean Xpad_periodic_init (void)
1944 {
1945 memset(xpptr, 0, sizeof(*xpptr));
1946- xpptr->after_id =
1947- g_timeout_add_seconds(TIMEOUT_SECONDS, xppd_intercept, xpptr);
1948+ xpptr->after_id = (gint) g_timeout_add_seconds(TIMEOUT_SECONDS, xppd_intercept, xpptr);
1949
1950 /* Allocate space for the signal references. */
1951 int tlen = xpptr->template_len = 5;
1952 int slen = xpptr->sigs_len = 20;
1953- xpptr->template = g_malloc0(tlen * sizeof(Xpadsigref));
1954- xpptr->sigs = g_malloc0(slen * sizeof(Xpadsigref));
1955+ xpptr->template = g_malloc0((gsize) tlen * sizeof(Xpadsigref));
1956+ xpptr->sigs = g_malloc0((gsize) slen * sizeof(Xpadsigref));
1957
1958 return TRUE;
1959 }
1960
1961 void Xpad_periodic_close (void)
1962 {
1963- if (xpptr->after_id) { g_source_remove(xpptr->after_id); }
1964+ if (xpptr->after_id) { g_source_remove((guint) xpptr->after_id); }
1965 /* Free the signal references memory. */
1966 g_free(xpptr->template);
1967 g_free(xpptr->sigs);
1968@@ -92,6 +91,10 @@
1969 ************************/
1970 gint xppd_intercept (gpointer cdata)
1971 {
1972+ // A dirty way to silence the compiler for these unused variables.
1973+ // Feel free to implement these variables in the way they are ment to be used.
1974+ (void) cdata;
1975+
1976 int cnt=0;
1977 XpadPeriodicFunc fnptr=0;
1978 xpptr->count++; /* increment tick count */
1979@@ -228,6 +231,10 @@
1980
1981 gint gprint_ignore (const char * fmt, ...)
1982 {
1983+ // A dirty way to silence the compiler for these unused variables.
1984+ // Feel free to implement these variables in the way they are ment to be used.
1985+ (void) fmt;
1986+
1987 return 0;
1988 }
1989
1990
1991=== modified file 'src/xpad-preferences.c'
1992--- src/xpad-preferences.c 2013-10-21 02:51:19 +0000
1993+++ src/xpad-preferences.c 2013-11-01 20:03:38 +0000
1994@@ -42,22 +42,22 @@
1995 GtkWidget *backbutton;
1996 GtkWidget *fontbutton;
1997
1998- guint notify_edit_handler;
1999- guint notify_sticky_handler;
2000- guint notify_confirm_handler;
2001- guint notify_font_handler;
2002- guint notify_back_handler;
2003- guint notify_text_handler;
2004- guint notify_tray_handler;
2005- guint font_handler;
2006- guint back_handler;
2007- guint text_handler;
2008- guint colorcheck_handler;
2009- guint fontcheck_handler;
2010- guint editcheck_handler;
2011- guint stickycheck_handler;
2012- guint confirmcheck_handler;
2013- guint trayclick_handler;
2014+ gulong notify_edit_handler;
2015+ gulong notify_sticky_handler;
2016+ gulong notify_confirm_handler;
2017+ gulong notify_font_handler;
2018+ gulong notify_back_handler;
2019+ gulong notify_text_handler;
2020+ gulong notify_tray_handler;
2021+ gulong font_handler;
2022+ gulong back_handler;
2023+ gulong text_handler;
2024+ gulong colorcheck_handler;
2025+ gulong fontcheck_handler;
2026+ gulong editcheck_handler;
2027+ gulong stickycheck_handler;
2028+ gulong confirmcheck_handler;
2029+ gulong trayclick_handler;
2030 };
2031
2032 G_DEFINE_TYPE_WITH_PRIVATE(XpadPreferences, xpad_preferences, GTK_TYPE_DIALOG)
2033@@ -67,8 +67,8 @@
2034 static void change_confirm_check (GtkToggleButton *button, XpadPreferences *pref);
2035 static void change_color_check (GtkToggleButton *button, XpadPreferences *pref);
2036 static void change_font_check (GtkToggleButton *button, XpadPreferences *pref);
2037-static void change_text_color (GtkColorButton *button, XpadPreferences *pref);
2038-static void change_back_color (GtkColorButton *button, XpadPreferences *pref);
2039+static void change_text_color (GtkColorChooser *chooser, XpadPreferences *pref);
2040+static void change_back_color (GtkColorChooser *chooser, XpadPreferences *pref);
2041 static void change_font_face (GtkFontButton *button, XpadPreferences *pref);
2042 static void change_tray_click_configuration(GtkComboBox *box, XpadPreferences *pref);
2043 static void notify_edit (XpadPreferences *pref);
2044@@ -112,14 +112,16 @@
2045 xpad_preferences_init (XpadPreferences *pref)
2046 {
2047 GtkWidget *hbox, *font_hbox, *vbox;
2048- const GdkColor *color;
2049+ const GdkRGBA *color;
2050 const gchar *fontname;
2051- GtkStyle *style;
2052+ GtkStyleContext *style;
2053 GtkWidget *label, *appearance_frame, *alignment, *appearance_vbox;
2054 GtkWidget *options_frame, *options_vbox, *global_vbox, *tray_config_vbox;
2055 gchar *text;
2056 GtkSizeGroup *size_group_labels = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
2057 GtkRequisition req;
2058+ GdkRGBA theme_text_color = {0, 0, 0, 0};
2059+ GdkRGBA theme_background_color = {0, 0, 0, 0};
2060
2061 pref->priv = xpad_preferences_get_instance_private(pref);
2062
2063@@ -130,10 +132,9 @@
2064 "xalign", 0.0,
2065 NULL));
2066 g_free (text);
2067- appearance_vbox = GTK_WIDGET (g_object_new (GTK_TYPE_VBOX,
2068- "homogeneous", FALSE,
2069- "spacing", 18,
2070- NULL));
2071+ appearance_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 18);
2072+ gtk_box_set_homogeneous (GTK_BOX (appearance_vbox), FALSE);
2073+
2074 alignment = gtk_alignment_new (1, 1, 1, 1);
2075 g_object_set (G_OBJECT (alignment),
2076 "left-padding", 12,
2077@@ -155,12 +156,14 @@
2078 pref->priv->anticolorcheck = gtk_radio_button_new_with_mnemonic (NULL, _("Use colors from theme"));
2079 pref->priv->colorcheck = gtk_radio_button_new_with_mnemonic_from_widget (GTK_RADIO_BUTTON (pref->priv->anticolorcheck), _("Use these colors:"));
2080
2081- font_hbox = gtk_hbox_new (FALSE, 6);
2082+ font_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
2083+
2084 gtk_box_pack_start (GTK_BOX (font_hbox), pref->priv->fontcheck, FALSE, FALSE, 0);
2085 gtk_box_pack_start (GTK_BOX (font_hbox), pref->priv->fontbutton, TRUE, TRUE, 0);
2086
2087- pref->priv->colorbox = gtk_vbox_new (FALSE, 6);
2088- hbox = gtk_hbox_new (FALSE, 12);
2089+ pref->priv->colorbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
2090+ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
2091+
2092 label = gtk_label_new_with_mnemonic (_("Background:"));
2093 gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
2094 gtk_size_group_add_widget (size_group_labels, label);
2095@@ -168,7 +171,8 @@
2096 gtk_box_pack_start (GTK_BOX (hbox), pref->priv->backbutton, TRUE, TRUE, 0);
2097 g_object_set (G_OBJECT (pref->priv->colorbox), "child", hbox, NULL);
2098
2099- hbox = gtk_hbox_new (FALSE, 12);
2100+ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
2101+
2102 label = gtk_label_new_with_mnemonic (_("Foreground:"));
2103 gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
2104 gtk_size_group_add_widget (size_group_labels, label);
2105@@ -186,40 +190,41 @@
2106
2107 gtk_dialog_add_button (GTK_DIALOG (pref), "gtk-close", GTK_RESPONSE_CLOSE);
2108 gtk_dialog_set_default_response (GTK_DIALOG (pref), GTK_RESPONSE_CLOSE);
2109- gtk_dialog_set_has_separator (GTK_DIALOG (pref), FALSE);
2110 g_signal_connect (pref, "response", G_CALLBACK (xpad_preferences_response), NULL);
2111 gtk_window_set_title (GTK_WINDOW (pref), _("Xpad Preferences"));
2112
2113- gtk_color_button_set_use_alpha (GTK_COLOR_BUTTON (pref->priv->textbutton), FALSE);
2114- gtk_color_button_set_use_alpha (GTK_COLOR_BUTTON (pref->priv->backbutton), xpad_app_get_translucent ());
2115+ gtk_color_chooser_set_use_alpha (GTK_COLOR_CHOOSER (pref->priv->textbutton), FALSE);
2116+ gtk_color_chooser_set_use_alpha (GTK_COLOR_CHOOSER (pref->priv->backbutton), TRUE);
2117
2118 gtk_color_button_set_title (GTK_COLOR_BUTTON (pref->priv->textbutton), _("Set Foreground Color"));
2119 gtk_color_button_set_title (GTK_COLOR_BUTTON (pref->priv->backbutton), _("Set Background Color"));
2120 gtk_font_button_set_title (GTK_FONT_BUTTON (pref->priv->fontbutton), _("Set Font"));
2121
2122 /* Set current state */
2123- style = gtk_widget_get_default_style ();
2124+ style = gtk_widget_get_style_context (GTK_WIDGET(pref));
2125+ gtk_style_context_get_color (style, GTK_STATE_FLAG_NORMAL, &theme_text_color);
2126+ gtk_style_context_get_background_color (style, GTK_STATE_FLAG_NORMAL, &theme_background_color);
2127
2128- color = xpad_settings_get_back_color (xpad_settings ());
2129+ color = xpad_settings_get_back_color (xpad_global_settings);
2130 if (color)
2131 {
2132 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pref->priv->colorcheck), TRUE);
2133- gtk_color_button_set_color (GTK_COLOR_BUTTON (pref->priv->backbutton), color);
2134+ gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (pref->priv->backbutton), color);
2135 }
2136 else
2137 {
2138 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pref->priv->anticolorcheck), TRUE);
2139 gtk_widget_set_sensitive (pref->priv->colorbox, FALSE);
2140- gtk_color_button_set_color (GTK_COLOR_BUTTON (pref->priv->backbutton), &style->base[GTK_STATE_NORMAL]);
2141+ gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (pref->priv->backbutton), &theme_background_color);
2142 }
2143
2144- color = xpad_settings_get_text_color (xpad_settings ());
2145+ color = xpad_settings_get_text_color (xpad_global_settings);
2146 if (color)
2147- gtk_color_button_set_color (GTK_COLOR_BUTTON (pref->priv->textbutton), color);
2148+ gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (pref->priv->textbutton), color);
2149 else
2150- gtk_color_button_set_color (GTK_COLOR_BUTTON (pref->priv->textbutton), &style->text[GTK_STATE_NORMAL]);
2151+ gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (pref->priv->textbutton), &theme_text_color);
2152
2153- fontname = xpad_settings_get_fontname (xpad_settings ());
2154+ fontname = xpad_settings_get_fontname (xpad_global_settings);
2155 if (fontname)
2156 {
2157 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pref->priv->fontcheck), TRUE);
2158@@ -227,32 +232,33 @@
2159 }
2160 else
2161 {
2162- gchar *str;
2163+ PangoFontDescription *font;
2164
2165 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pref->priv->antifontcheck), TRUE);
2166 gtk_widget_set_sensitive (pref->priv->fontbutton, FALSE);
2167
2168- str = pango_font_description_to_string (style->font_desc);
2169- gtk_font_button_set_font_name (GTK_FONT_BUTTON (pref->priv->fontbutton), str);
2170- g_free (str);
2171+ gtk_style_context_get (style, GTK_STATE_FLAG_NORMAL, GTK_STYLE_PROPERTY_FONT, &font, NULL);
2172+ gtk_font_button_set_font_name (GTK_FONT_BUTTON (pref->priv->fontbutton), pango_font_description_to_string(font));
2173+ pango_font_description_free (font);
2174 }
2175
2176- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pref->priv->editcheck), xpad_settings_get_edit_lock (xpad_settings ()));
2177- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pref->priv->stickycheck), xpad_settings_get_sticky (xpad_settings ()));
2178- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pref->priv->confirmcheck), xpad_settings_get_confirm_destroy (xpad_settings ()));
2179+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pref->priv->editcheck), xpad_settings_get_edit_lock (xpad_global_settings));
2180+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pref->priv->stickycheck), xpad_settings_get_sticky (xpad_global_settings));
2181+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pref->priv->confirmcheck), xpad_settings_get_confirm_destroy (xpad_global_settings));
2182
2183- vbox = gtk_vbox_new (FALSE, 6);
2184+ vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
2185+
2186 gtk_box_pack_start (GTK_BOX (vbox), pref->priv->antifontcheck, FALSE, FALSE, 0);
2187 gtk_box_pack_start (GTK_BOX (vbox), font_hbox, FALSE, FALSE, 0);
2188 gtk_box_pack_start (GTK_BOX (appearance_vbox), vbox, FALSE, FALSE, 0);
2189
2190- vbox = gtk_vbox_new (FALSE, 6);
2191+ vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
2192+
2193 gtk_box_pack_start (GTK_BOX (vbox), pref->priv->anticolorcheck, FALSE, FALSE, 0);
2194 gtk_box_pack_start (GTK_BOX (vbox), pref->priv->colorcheck, FALSE, FALSE, 0);
2195 gtk_box_pack_start (GTK_BOX (vbox), alignment, FALSE, FALSE, 0);
2196 gtk_box_pack_start (GTK_BOX (appearance_vbox), vbox, FALSE, FALSE, 0);
2197
2198-
2199 text = g_strconcat ("<b>", _("Options"), "</b>", NULL);
2200 label = GTK_WIDGET (g_object_new (GTK_TYPE_LABEL,
2201 "label", text,
2202@@ -260,10 +266,10 @@
2203 "xalign", 0.0,
2204 NULL));
2205 g_free (text);
2206- options_vbox = GTK_WIDGET (g_object_new (GTK_TYPE_VBOX,
2207- "homogeneous", FALSE,
2208- "spacing", 6,
2209- NULL));
2210+
2211+ options_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
2212+ gtk_box_set_homogeneous (GTK_BOX (options_vbox), FALSE);
2213+
2214 alignment = gtk_alignment_new (1, 1, 1, 1);
2215 g_object_set (G_OBJECT (alignment),
2216 "left-padding", 12,
2217@@ -275,39 +281,35 @@
2218 "shadow-type", GTK_SHADOW_NONE,
2219 "child", alignment,
2220 NULL));
2221-
2222- tray_config_vbox = GTK_WIDGET (g_object_new (GTK_TYPE_VBOX,
2223- "homogeneous", FALSE,
2224- "spacing", 6,
2225- NULL));
2226-
2227- pref->priv->trayconfigbox = gtk_combo_box_new_text();
2228- gtk_combo_box_append_text( GTK_COMBO_BOX( pref->priv->trayconfigbox ), "Do Nothing" );
2229- gtk_combo_box_append_text( GTK_COMBO_BOX( pref->priv->trayconfigbox ), "Toggle Show All" );
2230- gtk_combo_box_append_text( GTK_COMBO_BOX( pref->priv->trayconfigbox ), "List of Pads" );
2231- gtk_combo_box_append_text( GTK_COMBO_BOX( pref->priv->trayconfigbox ), "New Pad" );
2232- gtk_combo_box_set_active( GTK_COMBO_BOX( pref->priv->trayconfigbox ), xpad_settings_get_tray_click_handler(xpad_settings()));
2233-
2234- hbox = gtk_hbox_new(FALSE, 12);
2235+
2236+ // System tray configuration left-click behaviour
2237+ tray_config_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
2238+ gtk_box_set_homogeneous (GTK_BOX (tray_config_vbox), FALSE);
2239+ pref->priv->trayconfigbox = gtk_combo_box_text_new();
2240+ gtk_combo_box_text_append_text ( GTK_COMBO_BOX_TEXT( pref->priv->trayconfigbox ), _("Do Nothing") );
2241+ gtk_combo_box_text_append_text ( GTK_COMBO_BOX_TEXT( pref->priv->trayconfigbox ), _("Toggle Show All") );
2242+ gtk_combo_box_text_append_text ( GTK_COMBO_BOX_TEXT( pref->priv->trayconfigbox ), _("List of Pads") );
2243+ gtk_combo_box_text_append_text ( GTK_COMBO_BOX_TEXT( pref->priv->trayconfigbox ), _("New Pad") );
2244+ gtk_combo_box_set_active( GTK_COMBO_BOX( pref->priv->trayconfigbox ), (gint) xpad_settings_get_tray_click_handler(xpad_global_settings));
2245+ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
2246 label = gtk_label_new_with_mnemonic(_("Tray click behaviour"));
2247 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
2248 gtk_box_pack_start(GTK_BOX(hbox), pref->priv->trayconfigbox, TRUE, TRUE, 0);
2249 gtk_box_pack_start(GTK_BOX(tray_config_vbox), hbox, TRUE, TRUE, 0);
2250
2251+ // Edit, sticky and confirmation checkboxes
2252 gtk_box_pack_start (GTK_BOX (options_vbox), pref->priv->editcheck, FALSE, FALSE, 0);
2253 gtk_box_pack_start (GTK_BOX (options_vbox), pref->priv->stickycheck, FALSE, FALSE, 0);
2254 gtk_box_pack_start (GTK_BOX (options_vbox), pref->priv->confirmcheck, FALSE, FALSE, 0);
2255 g_object_set (GTK_WIDGET(options_vbox), "child", tray_config_vbox, NULL);
2256
2257- global_vbox = g_object_new (GTK_TYPE_VBOX,
2258- "border-width", 6,
2259- "homogeneous", FALSE,
2260- "spacing", 18,
2261- "child", appearance_frame,
2262- "child", options_frame,
2263- NULL);
2264-
2265- gtk_box_pack_start (GTK_BOX (GTK_DIALOG (pref)->vbox), global_vbox, FALSE, FALSE, 0);
2266+ global_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
2267+ gtk_box_set_homogeneous (GTK_BOX (global_vbox), FALSE);
2268+ gtk_box_pack_start (GTK_BOX (global_vbox), appearance_frame, FALSE, FALSE, 0);
2269+ gtk_box_pack_start (GTK_BOX (global_vbox), options_frame, FALSE, FALSE, 0);
2270+ gtk_container_set_border_width (GTK_CONTAINER (global_vbox), 6);
2271+
2272+ gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (pref))), global_vbox, FALSE, FALSE, 0);
2273
2274 pref->priv->editcheck_handler = g_signal_connect (pref->priv->editcheck, "toggled", G_CALLBACK (change_edit_check), pref);
2275 pref->priv->stickycheck_handler = g_signal_connect (pref->priv->stickycheck, "toggled", G_CALLBACK (change_sticky_check), pref);
2276@@ -318,20 +320,20 @@
2277 pref->priv->back_handler = g_signal_connect (pref->priv->backbutton, "color-set", G_CALLBACK (change_back_color), pref);
2278 pref->priv->font_handler = g_signal_connect (pref->priv->fontbutton, "font-set", G_CALLBACK (change_font_face), pref);
2279 pref->priv->trayclick_handler = g_signal_connect(pref->priv->trayconfigbox, "changed", G_CALLBACK(change_tray_click_configuration), pref);
2280- pref->priv->notify_font_handler = g_signal_connect_swapped (xpad_settings (), "notify::fontname", G_CALLBACK (notify_fontname), pref);
2281- pref->priv->notify_text_handler = g_signal_connect_swapped (xpad_settings (), "notify::text-color", G_CALLBACK (notify_text_color), pref);
2282- pref->priv->notify_back_handler = g_signal_connect_swapped (xpad_settings (), "notify::back-color", G_CALLBACK (notify_back_color), pref);
2283- pref->priv->notify_sticky_handler = g_signal_connect_swapped (xpad_settings (), "notify::sticky", G_CALLBACK (notify_sticky), pref);
2284- pref->priv->notify_edit_handler = g_signal_connect_swapped (xpad_settings (), "notify::edit-lock", G_CALLBACK (notify_edit), pref);
2285- pref->priv->notify_confirm_handler = g_signal_connect_swapped (xpad_settings (), "notify::confirm-destroy", G_CALLBACK (notify_confirm), pref);
2286- pref->priv->notify_tray_handler = g_signal_connect_swapped (xpad_settings (), "notify::tray_click_configuration", G_CALLBACK(notify_tray_click), pref);
2287+ pref->priv->notify_font_handler = g_signal_connect_swapped (xpad_global_settings, "notify::fontname", G_CALLBACK (notify_fontname), pref);
2288+ pref->priv->notify_text_handler = g_signal_connect_swapped (xpad_global_settings, "notify::text-color", G_CALLBACK (notify_text_color), pref);
2289+ pref->priv->notify_back_handler = g_signal_connect_swapped (xpad_global_settings, "notify::back-color", G_CALLBACK (notify_back_color), pref);
2290+ pref->priv->notify_sticky_handler = g_signal_connect_swapped (xpad_global_settings, "notify::sticky", G_CALLBACK (notify_sticky), pref);
2291+ pref->priv->notify_edit_handler = g_signal_connect_swapped (xpad_global_settings, "notify::edit-lock", G_CALLBACK (notify_edit), pref);
2292+ pref->priv->notify_confirm_handler = g_signal_connect_swapped (xpad_global_settings, "notify::confirm-destroy", G_CALLBACK (notify_confirm), pref);
2293+ pref->priv->notify_tray_handler = g_signal_connect_swapped (xpad_global_settings, "notify::tray_click_configuration", G_CALLBACK(notify_tray_click), pref);
2294
2295 g_object_unref (size_group_labels);
2296
2297- gtk_widget_show_all (GTK_DIALOG (pref)->vbox);
2298+ gtk_widget_show_all (gtk_dialog_get_content_area (GTK_DIALOG (pref)));
2299
2300 /* Make window not so squished */
2301- gtk_widget_size_request (GTK_WIDGET (pref), &req);
2302+ gtk_widget_get_preferred_size (GTK_WIDGET (pref), &req, NULL);
2303 g_object_set (G_OBJECT (pref), "default-width", (gint) (req.height * 0.8), NULL);
2304 }
2305
2306@@ -346,7 +348,7 @@
2307 {
2308 XpadPreferences *pref = XPAD_PREFERENCES (object);
2309
2310- g_signal_handlers_disconnect_matched (xpad_settings (), G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, pref);
2311+ g_signal_handlers_disconnect_matched (xpad_global_settings, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, pref);
2312
2313 G_OBJECT_CLASS (xpad_preferences_parent_class)->finalize (object);
2314 }
2315@@ -361,108 +363,110 @@
2316 static void
2317 change_color_check (GtkToggleButton *button, XpadPreferences *pref)
2318 {
2319- g_signal_handler_block (xpad_settings (), pref->priv->notify_back_handler);
2320- g_signal_handler_block (xpad_settings (), pref->priv->notify_text_handler);
2321+ g_signal_handler_block (xpad_global_settings, pref->priv->notify_back_handler);
2322+ g_signal_handler_block (xpad_global_settings, pref->priv->notify_text_handler);
2323
2324 if (!gtk_toggle_button_get_active (button))
2325 {
2326- xpad_settings_set_text_color (xpad_settings (), NULL);
2327- xpad_settings_set_back_color (xpad_settings (), NULL);
2328+ xpad_settings_set_text_color (xpad_global_settings, NULL);
2329+ xpad_settings_set_back_color (xpad_global_settings, NULL);
2330 }
2331 else
2332 {
2333- GdkColor color;
2334- gtk_color_button_get_color (GTK_COLOR_BUTTON (pref->priv->textbutton), &color);
2335- xpad_settings_set_text_color (xpad_settings (), &color);
2336- gtk_color_button_get_color (GTK_COLOR_BUTTON (pref->priv->backbutton), &color);
2337- xpad_settings_set_back_color (xpad_settings (), &color);
2338+ GdkRGBA color;
2339+ gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (pref->priv->textbutton), &color);
2340+ xpad_settings_set_text_color (xpad_global_settings, &color);
2341+ gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (pref->priv->backbutton), &color);
2342+ xpad_settings_set_back_color (xpad_global_settings, &color);
2343 }
2344
2345 gtk_widget_set_sensitive (pref->priv->colorbox, gtk_toggle_button_get_active (button));
2346
2347- g_signal_handler_unblock (xpad_settings (), pref->priv->notify_back_handler);
2348- g_signal_handler_unblock (xpad_settings (), pref->priv->notify_text_handler);
2349+ g_signal_handler_unblock (xpad_global_settings, pref->priv->notify_back_handler);
2350+ g_signal_handler_unblock (xpad_global_settings, pref->priv->notify_text_handler);
2351 }
2352
2353 static void
2354 change_font_check (GtkToggleButton *button, XpadPreferences *pref)
2355 {
2356- g_signal_handler_block (xpad_settings (), pref->priv->notify_font_handler);
2357+ g_signal_handler_block (xpad_global_settings, pref->priv->notify_font_handler);
2358
2359 if (!gtk_toggle_button_get_active (button))
2360- xpad_settings_set_fontname (xpad_settings (), NULL);
2361+ xpad_settings_set_fontname (xpad_global_settings, NULL);
2362 else
2363- xpad_settings_set_fontname (xpad_settings (), gtk_font_button_get_font_name (GTK_FONT_BUTTON (pref->priv->fontbutton)));
2364+ xpad_settings_set_fontname (xpad_global_settings, gtk_font_button_get_font_name (GTK_FONT_BUTTON (pref->priv->fontbutton)));
2365
2366 gtk_widget_set_sensitive (pref->priv->fontbutton, gtk_toggle_button_get_active (button));
2367
2368- g_signal_handler_unblock (xpad_settings (), pref->priv->notify_font_handler);
2369+ g_signal_handler_unblock (xpad_global_settings, pref->priv->notify_font_handler);
2370 }
2371
2372 static void
2373 change_edit_check (GtkToggleButton *button, XpadPreferences *pref)
2374 {
2375- g_signal_handler_block (xpad_settings (), pref->priv->notify_edit_handler);
2376- xpad_settings_set_edit_lock (xpad_settings (), gtk_toggle_button_get_active (button));
2377- g_signal_handler_unblock (xpad_settings (), pref->priv->notify_edit_handler);
2378+ g_signal_handler_block (xpad_global_settings, pref->priv->notify_edit_handler);
2379+ xpad_settings_set_edit_lock (xpad_global_settings, gtk_toggle_button_get_active (button));
2380+ g_signal_handler_unblock (xpad_global_settings, pref->priv->notify_edit_handler);
2381 }
2382
2383 static void
2384 change_sticky_check (GtkToggleButton *button, XpadPreferences *pref)
2385 {
2386- g_signal_handler_block (xpad_settings (), pref->priv->notify_sticky_handler);
2387- xpad_settings_set_sticky (xpad_settings (), gtk_toggle_button_get_active (button));
2388- g_signal_handler_unblock (xpad_settings (), pref->priv->notify_sticky_handler);
2389+ g_signal_handler_block (xpad_global_settings, pref->priv->notify_sticky_handler);
2390+ xpad_settings_set_sticky (xpad_global_settings, gtk_toggle_button_get_active (button));
2391+ g_signal_handler_unblock (xpad_global_settings, pref->priv->notify_sticky_handler);
2392 }
2393
2394 static void
2395 change_confirm_check (GtkToggleButton *button, XpadPreferences *pref)
2396 {
2397- g_signal_handler_block (xpad_settings (), pref->priv->notify_confirm_handler);
2398- xpad_settings_set_confirm_destroy (xpad_settings (), gtk_toggle_button_get_active (button));
2399- g_signal_handler_unblock (xpad_settings (), pref->priv->notify_confirm_handler);
2400+ g_signal_handler_block (xpad_global_settings, pref->priv->notify_confirm_handler);
2401+ xpad_settings_set_confirm_destroy (xpad_global_settings, gtk_toggle_button_get_active (button));
2402+ g_signal_handler_unblock (xpad_global_settings, pref->priv->notify_confirm_handler);
2403 }
2404
2405 static void
2406 change_tray_click_configuration(GtkComboBox *box, XpadPreferences *pref)
2407 {
2408- g_signal_handler_block(xpad_settings(), pref->priv->notify_tray_handler);
2409- xpad_settings_set_tray_click_handler(xpad_settings(), gtk_combo_box_get_active(box));
2410- g_signal_handler_unblock(xpad_settings(), pref->priv->notify_tray_handler);
2411-}
2412-
2413-static void
2414-change_text_color (GtkColorButton *button, XpadPreferences *pref)
2415-{
2416- GdkColor color;
2417- gtk_color_button_get_color (button, &color);
2418- g_signal_handler_block (xpad_settings (), pref->priv->notify_text_handler);
2419- xpad_settings_set_text_color (xpad_settings (), &color);
2420- g_signal_handler_unblock (xpad_settings (), pref->priv->notify_text_handler);
2421-}
2422-
2423-static void
2424-change_back_color (GtkColorButton *button, XpadPreferences *pref)
2425-{
2426- GdkColor color;
2427- gtk_color_button_get_color (button, &color);
2428- g_signal_handler_block (xpad_settings (), pref->priv->notify_back_handler);
2429- xpad_settings_set_back_color (xpad_settings (), &color);
2430- g_signal_handler_unblock (xpad_settings (), pref->priv->notify_back_handler);
2431+ g_signal_handler_block(xpad_global_settings, pref->priv->notify_tray_handler);
2432+ xpad_settings_set_tray_click_handler(xpad_global_settings, (guint) gtk_combo_box_get_active(box));
2433+ g_signal_handler_unblock(xpad_global_settings, pref->priv->notify_tray_handler);
2434+}
2435+
2436+static void
2437+change_text_color (GtkColorChooser *chooser, XpadPreferences *pref)
2438+{
2439+ GdkRGBA color = {0, 0, 0, 0};
2440+ gtk_color_chooser_get_rgba (chooser, &color);
2441+
2442+ g_signal_handler_block (xpad_global_settings, pref->priv->notify_text_handler);
2443+ xpad_settings_set_text_color (xpad_global_settings, &color);
2444+ g_signal_handler_unblock (xpad_global_settings, pref->priv->notify_text_handler);
2445+}
2446+
2447+static void
2448+change_back_color (GtkColorChooser *chooser, XpadPreferences *pref)
2449+{
2450+ GdkRGBA color = {0, 0, 0, 0};
2451+ gtk_color_chooser_get_rgba (chooser, &color);
2452+
2453+ g_signal_handler_block (xpad_global_settings, pref->priv->notify_back_handler);
2454+ xpad_settings_set_back_color (xpad_global_settings, &color);
2455+ g_signal_handler_unblock (xpad_global_settings, pref->priv->notify_back_handler);
2456 }
2457
2458 static void
2459 change_font_face (GtkFontButton *button, XpadPreferences *pref)
2460 {
2461- g_signal_handler_block (xpad_settings (), pref->priv->notify_font_handler);
2462- xpad_settings_set_fontname (xpad_settings (), gtk_font_button_get_font_name (button));
2463- g_signal_handler_unblock (xpad_settings (), pref->priv->notify_font_handler);
2464+ g_signal_handler_block (xpad_global_settings, pref->priv->notify_font_handler);
2465+ xpad_settings_set_fontname (xpad_global_settings, gtk_font_button_get_font_name (button));
2466+ g_signal_handler_unblock (xpad_global_settings, pref->priv->notify_font_handler);
2467 }
2468
2469 static void
2470 notify_back_color (XpadPreferences *pref)
2471 {
2472- const GdkColor *color = xpad_settings_get_back_color (xpad_settings ());
2473+ const GdkRGBA *color = xpad_settings_get_back_color (xpad_global_settings);
2474
2475 g_signal_handler_block (pref->priv->backbutton, pref->priv->back_handler);
2476 g_signal_handler_block (pref->priv->colorcheck, pref->priv->colorcheck_handler);
2477@@ -471,7 +475,7 @@
2478 {
2479 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pref->priv->colorcheck), TRUE);
2480 gtk_widget_set_sensitive (pref->priv->colorbox, TRUE);
2481- gtk_color_button_set_color (GTK_COLOR_BUTTON (pref->priv->backbutton), color);
2482+ gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (pref->priv->backbutton), color);
2483 }
2484 else
2485 {
2486@@ -486,7 +490,7 @@
2487 static void
2488 notify_text_color (XpadPreferences *pref)
2489 {
2490- const GdkColor *color = xpad_settings_get_text_color (xpad_settings ());
2491+ const GdkRGBA *color = xpad_settings_get_text_color (xpad_global_settings);
2492
2493 g_signal_handler_block (pref->priv->textbutton, pref->priv->text_handler);
2494 g_signal_handler_block (pref->priv->colorcheck, pref->priv->colorcheck_handler);
2495@@ -495,7 +499,8 @@
2496 {
2497 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pref->priv->colorcheck), TRUE);
2498 gtk_widget_set_sensitive (pref->priv->colorbox, TRUE);
2499- gtk_color_button_set_color (GTK_COLOR_BUTTON (pref->priv->textbutton), color);
2500+ gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (pref->priv->textbutton), color);
2501+
2502 }
2503 else
2504 {
2505@@ -510,7 +515,7 @@
2506 static void
2507 notify_fontname (XpadPreferences *pref)
2508 {
2509- const gchar *fontname = xpad_settings_get_fontname (xpad_settings ());
2510+ const gchar *fontname = xpad_settings_get_fontname (xpad_global_settings);
2511
2512 g_signal_handler_block (pref->priv->fontbutton, pref->priv->font_handler);
2513 g_signal_handler_block (pref->priv->fontcheck, pref->priv->fontcheck_handler);
2514@@ -535,7 +540,7 @@
2515 notify_edit (XpadPreferences *pref)
2516 {
2517 g_signal_handler_block (pref->priv->editcheck, pref->priv->editcheck_handler);
2518- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pref->priv->editcheck), xpad_settings_get_edit_lock (xpad_settings ()));
2519+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pref->priv->editcheck), xpad_settings_get_edit_lock (xpad_global_settings));
2520 g_signal_handler_unblock (pref->priv->editcheck, pref->priv->editcheck_handler);
2521 }
2522
2523@@ -543,7 +548,7 @@
2524 notify_sticky (XpadPreferences *pref)
2525 {
2526 g_signal_handler_block (pref->priv->stickycheck, pref->priv->stickycheck_handler);
2527- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pref->priv->stickycheck), xpad_settings_get_sticky (xpad_settings ()));
2528+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pref->priv->stickycheck), xpad_settings_get_sticky (xpad_global_settings));
2529 g_signal_handler_unblock (pref->priv->stickycheck, pref->priv->stickycheck_handler);
2530 }
2531
2532@@ -551,7 +556,7 @@
2533 notify_confirm (XpadPreferences *pref)
2534 {
2535 g_signal_handler_block (pref->priv->confirmcheck, pref->priv->confirmcheck_handler);
2536- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pref->priv->confirmcheck), xpad_settings_get_confirm_destroy (xpad_settings ()));
2537+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pref->priv->confirmcheck), xpad_settings_get_confirm_destroy (xpad_global_settings));
2538 g_signal_handler_unblock (pref->priv->confirmcheck, pref->priv->confirmcheck_handler);
2539 }
2540
2541@@ -559,7 +564,7 @@
2542 notify_tray_click(XpadPreferences *pref)
2543 {
2544 g_signal_handler_block(pref->priv->trayconfigbox, pref->priv->trayclick_handler);
2545- gtk_combo_box_set_active(GTK_COMBO_BOX(pref->priv->trayconfigbox), xpad_settings_get_tray_click_handler(xpad_settings()));
2546+ gtk_combo_box_set_active(GTK_COMBO_BOX(pref->priv->trayconfigbox), (gint) xpad_settings_get_tray_click_handler(xpad_global_settings));
2547 g_signal_handler_unblock(pref->priv->trayconfigbox, pref->priv->trayclick_handler);
2548 }
2549
2550
2551=== modified file 'src/xpad-session-manager.c'
2552--- src/xpad-session-manager.c 2008-09-21 00:03:40 +0000
2553+++ src/xpad-session-manager.c 2013-11-01 20:03:38 +0000
2554@@ -18,10 +18,12 @@
2555
2556 */
2557
2558+#include "../config.h"
2559 #include "xpad-session-manager.h"
2560
2561 #ifndef X_DISPLAY_MISSING
2562
2563+#include <gdk/gdkx.h>
2564 #include <X11/SM/SMlib.h>
2565 #include <stdio.h> /* only for printf */
2566 #include <sys/types.h> /* for getuid and getpwuid */
2567@@ -56,8 +58,14 @@
2568 static gboolean
2569 xpad_session_manager_cycle (GIOChannel *source, GIOCondition condition,
2570 gpointer data)
2571-{
2572- gboolean rv = TRUE;
2573+{
2574+ // A dirty way to silence the compiler for these unused variables.
2575+ // Feel free to implement these variables in the way they are ment to be used.
2576+ (void) source;
2577+ (void) condition;
2578+ (void) data;
2579+
2580+ gboolean rv = TRUE;
2581 IceConn ice_conn;
2582
2583 ice_conn = SmcGetIceConnection (xpad_session_manager_conn);
2584@@ -102,8 +110,13 @@
2585 static void
2586 xpad_session_manager_start_interact_callback (SmcConn smc_conn, SmPointer client_data)
2587 {
2588- if (blocking)
2589- gtk_main_quit ();
2590+ // A dirty way to silence the compiler for these unused variables.
2591+ // Feel free to implement these variables in the way they are ment to be used.
2592+ (void) client_data;
2593+ (void) smc_conn;
2594+
2595+ if (blocking)
2596+ gtk_main_quit ();
2597 blocking = FALSE;
2598 }
2599
2600@@ -163,6 +176,11 @@
2601 xpad_session_manager_ice_connection_watch (IceConn ice_conn,
2602 IcePointer client_data, Bool opening, IcePointer *watch_data)
2603 {
2604+ // A dirty way to silence the compiler for these unused variables.
2605+ // Feel free to implement these variables in the way they are ment to be used.
2606+ (void) client_data;
2607+ (void) watch_data;
2608+
2609 int fd = IceConnectionNumber (ice_conn);
2610
2611 if (opening)
2612@@ -192,9 +210,10 @@
2613 };
2614 SmProp *props[G_N_ELEMENTS (prop)];
2615 struct passwd *pw;
2616- int i;
2617+ uint i;
2618 gchar *pid_str;
2619 gchar *command = g_strdup (xpad_app_get_program_path ());
2620+ size_t string_length = 0;
2621
2622 prop[0].vals = vals.clone;
2623 prop[1].vals = vals.program;
2624@@ -207,28 +226,57 @@
2625 }
2626
2627 pw = getpwuid (getuid ());
2628-
2629+
2630+ // While setting all the properties, safe casts are being used.
2631 vals.user->value = pw ? pw->pw_name : "";
2632- vals.user->length = strlen (vals.user->value);
2633+ string_length = strlen (vals.user->value);
2634+ if (string_length <= INT_MAX)
2635+ vals.user->length = (int) string_length;
2636+ else
2637+ g_warning("While setting the session manager properties a casting problem has occured. Xpad might not function as expected. Please send a bugreport.");
2638
2639 vals.program->value = command;
2640- vals.program->length = strlen (vals.program->value);
2641+ string_length = strlen (vals.program->value);
2642+ if (string_length <= INT_MAX)
2643+ vals.program->length = (int) string_length;
2644+ else
2645+ g_warning("While setting the session manager properties a casting problem has occured. Xpad might not function as expected. Please send a bugreport.");
2646
2647 vals.clone->value = command;
2648- vals.clone->length = strlen (vals.clone->value);
2649+ string_length = strlen (vals.clone->value);
2650+ if (string_length <= INT_MAX)
2651+ vals.clone->length = (int) string_length;
2652+ else
2653+ g_warning("While setting the session manager properties a casting problem has occured. Xpad might not function as expected. Please send a bugreport.");
2654
2655 vals.restart[0].value = command;
2656- vals.restart[0].length = strlen (vals.restart[0].value);
2657-
2658+ string_length = strlen (vals.restart[0].value);
2659+ if (string_length <= INT_MAX)
2660+ vals.restart[0].length = (int) string_length;
2661+ else
2662+ g_warning("While setting the session manager properties a casting problem has occured. Xpad might not function as expected. Please send a bugreport.");
2663+
2664 vals.restart[1].value = "--sm-client-id";
2665- vals.restart[1].length = strlen (vals.restart[1].value);
2666-
2667+ string_length = strlen (vals.restart[1].value);
2668+ if (string_length <= INT_MAX)
2669+ vals.restart[1].length = (int) string_length;
2670+ else
2671+ g_warning("While setting the session manager properties a casting problem has occured. Xpad might not function as expected. Please send a bugreport.");
2672+
2673 vals.restart[2].value = client_id;
2674- vals.restart[2].length = strlen (vals.restart[2].value);
2675+ string_length = strlen (vals.restart[2].value);
2676+ if (string_length <= INT_MAX)
2677+ vals.restart[2].length = (int) string_length;
2678+ else
2679+ g_warning("While setting the session manager properties a casting problem has occured. Xpad might not function as expected. Please send a bugreport.");
2680
2681 pid_str = g_strdup_printf ("%i", getpid ());
2682 vals.process->value = pid_str;
2683- vals.process->length = strlen (vals.process->value);
2684+ string_length = strlen (vals.process->value);
2685+ if (string_length <= INT_MAX)
2686+ vals.process->length = (int) string_length;
2687+ else
2688+ g_warning("While setting the session manager properties a casting problem has occured. Xpad might not function as expected. Please send a bugreport.");
2689
2690 SmcSetProperties (xpad_session_manager_conn, 4, (SmProp **) &props);
2691
2692@@ -270,7 +318,7 @@
2693 xpad_ice_fd = -1;
2694 IceAddConnectionWatch (xpad_session_manager_ice_connection_watch, NULL);
2695
2696- gdk_set_sm_client_id (client_id);
2697+ gdk_x11_set_sm_client_id (client_id);
2698 }
2699
2700 void
2701@@ -306,6 +354,10 @@
2702 static void
2703 xpad_session_manager_save_global (Bool fast)
2704 {
2705+ // A dirty way to silence the compiler for these unused variables.
2706+ // Feel free to implement these variables in the way they are ment to be used.
2707+ (void) fast;
2708+
2709 /* No need to do anything. Currently, all xpad pads are always current with
2710 hard drive. */
2711 }
2712@@ -313,6 +365,10 @@
2713 static void
2714 xpad_session_manager_save_local (Bool fast)
2715 {
2716+ // A dirty way to silence the compiler for these unused variables.
2717+ // Feel free to implement these variables in the way they are ment to be used.
2718+ (void) fast;
2719+
2720 /* should also save cursor positions and open accessory windows */
2721
2722 if (set_props)
2723@@ -327,6 +383,10 @@
2724 int save_type, Bool shutdown, int interact_style,
2725 Bool fast)
2726 {
2727+ // A dirty way to silence the compiler for these unused variables.
2728+ // Feel free to implement these variables in the way they are ment to be used.
2729+ (void) client_data;
2730+
2731 RETURN_IF_BAD_CONN (smc_conn);
2732
2733 xpad_interact_style = interact_style;
2734@@ -357,6 +417,10 @@
2735 static void
2736 xpad_session_manager_die (SmcConn smc_conn, SmPointer client_data)
2737 {
2738+ // A dirty way to silence the compiler for these unused variables.
2739+ // Feel free to implement these variables in the way they are ment to be used.
2740+ (void) client_data;
2741+
2742 RETURN_IF_BAD_CONN (smc_conn);
2743 xpad_shutdown = True;
2744
2745@@ -372,6 +436,10 @@
2746 static void
2747 xpad_session_manager_shutdown_cancelled (SmcConn smc_conn, SmPointer client_data)
2748 {
2749+ // A dirty way to silence the compiler for these unused variables.
2750+ // Feel free to implement these variables in the way they are ment to be used.
2751+ (void) client_data;
2752+
2753 RETURN_IF_BAD_CONN (smc_conn);
2754 RETURN_IF_NOT_SAVING ();
2755 xpad_shutdown = False;
2756@@ -386,6 +454,10 @@
2757 static void
2758 xpad_session_manager_save_complete (SmcConn smc_conn, SmPointer client_data)
2759 {
2760+ // A dirty way to silence the compiler for these unused variables.
2761+ // Feel free to implement these variables in the way they are ment to be used.
2762+ (void) client_data;
2763+
2764 RETURN_IF_BAD_CONN (smc_conn);
2765 RETURN_IF_NOT_SAVING ();
2766
2767
2768=== modified file 'src/xpad-settings.c'
2769--- src/xpad-settings.c 2013-10-18 20:23:43 +0000
2770+++ src/xpad-settings.c 2013-11-01 20:03:38 +0000
2771@@ -18,11 +18,12 @@
2772
2773 */
2774
2775+#include "../config.h"
2776 #include <string.h>
2777 #include "xpad-settings.h"
2778 #include "fio.h"
2779
2780-struct XpadSettingsPrivate
2781+struct XpadSettingsPrivate
2782 {
2783 guint width;
2784 guint height;
2785@@ -34,8 +35,8 @@
2786 gboolean has_toolbar;
2787 gboolean autohide_toolbar;
2788 gboolean has_scrollbar;
2789- GdkColor *back;
2790- GdkColor *text;
2791+ GdkRGBA *back;
2792+ GdkRGBA *text;
2793 gchar *fontname;
2794 GSList *toolbar_buttons;
2795 };
2796@@ -76,17 +77,12 @@
2797 static void xpad_settings_dispose (GObject *object);
2798 static void xpad_settings_finalize (GObject *object);
2799
2800-static XpadSettings *_xpad_settings = NULL;
2801 static guint signals[LAST_SIGNAL] = { 0 };
2802
2803 XpadSettings *
2804-xpad_settings (void)
2805+xpad_settings_new (void)
2806 {
2807- /* Singleton class */
2808- if (!_xpad_settings)
2809- _xpad_settings = XPAD_SETTINGS (g_object_new (XPAD_TYPE_SETTINGS, NULL));
2810-
2811- return _xpad_settings;
2812+ return g_object_new (XPAD_TYPE_SETTINGS, NULL);
2813 }
2814
2815 static void
2816@@ -198,7 +194,7 @@
2817 g_param_spec_boxed ("text_color",
2818 "Text Color",
2819 "Default color of pad text",
2820- GDK_TYPE_COLOR,
2821+ GDK_TYPE_RGBA,
2822 G_PARAM_READWRITE));
2823
2824 g_object_class_install_property (gobject_class,
2825@@ -206,7 +202,7 @@
2826 g_param_spec_boxed ("back_color",
2827 "Back Color",
2828 "Default color of pad background",
2829- GDK_TYPE_COLOR,
2830+ GDK_TYPE_RGBA,
2831 G_PARAM_READWRITE));
2832
2833 /* Signals */
2834@@ -223,25 +219,12 @@
2835 static void
2836 xpad_settings_init (XpadSettings *settings)
2837 {
2838- GdkColor back, text;
2839-
2840 settings->priv = xpad_settings_get_instance_private(settings);
2841-
2842- /* A pleasant light yellow color, similar to
2843- commercial sticky notes. */
2844- back.pixel = 0;
2845- back.red = 65535;
2846- back.green = 61166;
2847- back.blue = 39321;
2848- settings->priv->back = gdk_color_copy (&back);
2849-
2850- /* Black */
2851- text.pixel = 0;
2852- text.red = 0;
2853- text.green = 0;
2854- text.blue = 0;
2855- settings->priv->text = gdk_color_copy (&text);
2856-
2857+
2858+ /* A pleasant light yellow background color, similar to commercial sticky notes, with black text. */
2859+ settings->priv->text = gdk_rgba_copy(&(GdkRGBA) {0, 0, 0, 1});
2860+ settings->priv->back = gdk_rgba_copy(&(GdkRGBA) {1, 0.933334350586, 0.6, 1});
2861+
2862 settings->priv->width = 200;
2863 settings->priv->height = 200;
2864 settings->priv->has_decorations = TRUE;
2865@@ -276,9 +259,9 @@
2866 g_slist_free (settings->priv->toolbar_buttons);
2867
2868 if (settings->priv->text)
2869- gdk_color_free (settings->priv->text);
2870+ gdk_rgba_free (settings->priv->text);
2871 if (settings->priv->back)
2872- gdk_color_free (settings->priv->back);
2873+ gdk_rgba_free (settings->priv->back);
2874
2875 g_free (settings->priv->fontname);
2876
2877@@ -575,13 +558,13 @@
2878 return settings->priv->toolbar_buttons;
2879 }
2880
2881-void xpad_settings_set_back_color (XpadSettings *settings, const GdkColor *back)
2882+void xpad_settings_set_back_color (XpadSettings *settings, const GdkRGBA *back)
2883 {
2884 if (settings->priv->back)
2885- gdk_color_free (settings->priv->back);
2886+ gdk_rgba_free (settings->priv->back);
2887
2888 if (back)
2889- settings->priv->back = gdk_color_copy (back);
2890+ settings->priv->back = gdk_rgba_copy (back);
2891 else
2892 settings->priv->back = NULL;
2893
2894@@ -590,18 +573,18 @@
2895 g_object_notify (G_OBJECT (settings), "back_color");
2896 }
2897
2898-G_CONST_RETURN GdkColor *xpad_settings_get_back_color (XpadSettings *settings)
2899+G_CONST_RETURN GdkRGBA *xpad_settings_get_back_color (XpadSettings *settings)
2900 {
2901 return settings->priv->back;
2902 }
2903
2904-void xpad_settings_set_text_color (XpadSettings *settings, const GdkColor *text)
2905+void xpad_settings_set_text_color (XpadSettings *settings, const GdkRGBA *text)
2906 {
2907 if (settings->priv->text)
2908- gdk_color_free (settings->priv->text);
2909+ gdk_rgba_free (settings->priv->text);
2910
2911 if (text)
2912- settings->priv->text = gdk_color_copy (text);
2913+ settings->priv->text = gdk_rgba_copy (text);
2914 else
2915 settings->priv->text = NULL;
2916
2917@@ -610,7 +593,7 @@
2918 g_object_notify (G_OBJECT (settings), "text_color");
2919 }
2920
2921-G_CONST_RETURN GdkColor *xpad_settings_get_text_color (XpadSettings *settings)
2922+G_CONST_RETURN GdkRGBA *xpad_settings_get_text_color (XpadSettings *settings)
2923 {
2924 return settings->priv->text;
2925 }
2926@@ -767,18 +750,23 @@
2927 * We need to set up int values for all these to take the value from the file.
2928 * These will be assigned back to the appropriate values after load.
2929 */
2930+
2931 gchar *buttons = NULL;
2932- GdkColor text = {0}, back = {0};
2933+ gchar *text_color_string = NULL;
2934+ gchar *background_color_string = NULL;
2935+ GdkRGBA text = {0, 0, 0, 0};
2936+ GdkRGBA back = {0, 0, 0, 0};
2937 gboolean use_text, use_back;
2938
2939 use_text = settings->priv->text ? TRUE : FALSE;
2940 if (settings->priv->text)
2941 text = *settings->priv->text;
2942-
2943+
2944 use_back = settings->priv->back ? TRUE : FALSE;
2945 if (settings->priv->back)
2946 back = *settings->priv->back;
2947-
2948+
2949+ // get all the values from the default-style text file in the forms of booleans, ints or strings.
2950 if (fio_get_values_from_file (filename,
2951 "b|decorations", &settings->priv->has_decorations,
2952 "u|height", &settings->priv->height,
2953@@ -787,13 +775,9 @@
2954 "b|edit_lock", &settings->priv->edit_lock,
2955 "b|sticky_on_start", &settings->priv->sticky,
2956 "u|tray_click_configuration", &settings->priv->tray_click_configuration,
2957- "h|back_red", &back.red,
2958- "h|back_green", &back.green,
2959- "h|back_blue", &back.blue,
2960+ "s|back", &background_color_string,
2961 "b|use_back", &use_back,
2962- "h|text_red", &text.red,
2963- "h|text_green", &text.green,
2964- "h|text_blue", &text.blue,
2965+ "s|text", &text_color_string,
2966 "b|use_text", &use_text,
2967 "s|fontname", &settings->priv->fontname,
2968 "b|toolbar", &settings->priv->has_toolbar,
2969@@ -802,21 +786,46 @@
2970 "s|buttons", &buttons,
2971 NULL))
2972 return;
2973-
2974+
2975 if (use_text)
2976 {
2977- gdk_color_free (settings->priv->text);
2978- settings->priv->text = gdk_color_copy (&text);
2979- }
2980-
2981- gdk_color_free (settings->priv->back);
2982- if (use_back)
2983- settings->priv->back = gdk_color_copy (&back);
2984+ gdk_rgba_free (settings->priv->text);
2985+
2986+ // If, for some reason, one of the colors could not be retrieved
2987+ // (for example due to the migration to the new GdkRGBA colors), set the color to the default.
2988+ if (text_color_string == NULL) {
2989+ text = (GdkRGBA) {0, 0, 0, 1};
2990+ }
2991+ else {
2992+ // If, for some reason, the parsing of the colors fail, set the color to the default.
2993+ if (!gdk_rgba_parse (&text, text_color_string)) {
2994+ text = (GdkRGBA) {0, 0, 0, 1};
2995+ }
2996+ }
2997+
2998+ settings->priv->text = gdk_rgba_copy (&text);
2999+ }
3000+
3001+ gdk_rgba_free (settings->priv->back);
3002+ if (use_back) {
3003+ // If, for some reason, one of the colors could not be retrieved
3004+ // (for example due to the migration to the new GdkRGBA colors), set the color to the default.
3005+ if (background_color_string == NULL) {
3006+ back = (GdkRGBA) {1, 0.933334350586, 0.6, 1};
3007+ }
3008+ else {
3009+ // If, for some reason, the parsing of the colors fail, set the color to the default.
3010+ if (!gdk_rgba_parse (&back, background_color_string)) {
3011+ back = (GdkRGBA) {1, 0.933334350586, 0.6, 1};
3012+ }
3013+ }
3014+
3015+ settings->priv->back = gdk_rgba_copy (&back);
3016+ }
3017 else
3018 settings->priv->back = NULL;
3019
3020- if (settings->priv->fontname &&
3021- strcmp (settings->priv->fontname, "NULL") == 0)
3022+ if (settings->priv->fontname && strcmp (settings->priv->fontname, "NULL") == 0)
3023 {
3024 g_free (settings->priv->fontname);
3025 settings->priv->fontname = NULL;
3026@@ -841,7 +850,7 @@
3027 {
3028 settings->priv->toolbar_buttons =
3029 g_slist_append (settings->priv->toolbar_buttons,
3030- g_strstrip (button_names[i])); /* takes ownership of string */
3031+ g_strstrip (button_names[i])); // takes ownership of string
3032 }
3033
3034 g_free (button_names);
3035@@ -879,13 +888,9 @@
3036 "b|edit_lock", settings->priv->edit_lock,
3037 "b|sticky_on_start", settings->priv->sticky,
3038 "u|tray_click_configuration", settings->priv->tray_click_configuration,
3039- "h|back_red", settings->priv->back ? settings->priv->back->red : 0,
3040- "h|back_green", settings->priv->back ? settings->priv->back->green : 0,
3041- "h|back_blue", settings->priv->back ? settings->priv->back->blue : 0,
3042+ "s|back", settings->priv->back ? gdk_rgba_to_string (settings->priv->back) : "NULL",
3043 "b|use_back", settings->priv->back ? TRUE : FALSE,
3044- "h|text_red", settings->priv->text ? settings->priv->text->red : 0,
3045- "h|text_green", settings->priv->text ? settings->priv->text->green : 0,
3046- "h|text_blue", settings->priv->text ? settings->priv->text->blue : 0,
3047+ "s|text", settings->priv->text ? gdk_rgba_to_string (settings->priv->text) : "NULL",
3048 "b|use_text", settings->priv->text ? TRUE : FALSE,
3049 "s|fontname", settings->priv->fontname ? settings->priv->fontname : "NULL",
3050 "b|toolbar", settings->priv->has_toolbar,
3051
3052=== modified file 'src/xpad-settings.h'
3053--- src/xpad-settings.h 2013-10-18 20:23:43 +0000
3054+++ src/xpad-settings.h 2013-11-01 20:03:38 +0000
3055@@ -52,7 +52,7 @@
3056
3057 GType xpad_settings_get_type (void);
3058
3059-XpadSettings *xpad_settings (void);
3060+XpadSettings *xpad_settings_new (void);
3061
3062 void xpad_settings_set_width (XpadSettings *settings, guint width);
3063 guint xpad_settings_get_width (XpadSettings *settings);
3064@@ -88,15 +88,16 @@
3065 gboolean xpad_settings_remove_last_toolbar_button (XpadSettings *settings);
3066 G_CONST_RETURN GSList *xpad_settings_get_toolbar_buttons (XpadSettings *settings);
3067
3068-void xpad_settings_set_back_color (XpadSettings *settings, const GdkColor *back);
3069-G_CONST_RETURN GdkColor *xpad_settings_get_back_color (XpadSettings *settings);
3070+void xpad_settings_set_back_color (XpadSettings *settings, const GdkRGBA *back);
3071+G_CONST_RETURN GdkRGBA *xpad_settings_get_back_color (XpadSettings *settings);
3072
3073-void xpad_settings_set_text_color (XpadSettings *settings, const GdkColor *text);
3074-G_CONST_RETURN GdkColor *xpad_settings_get_text_color (XpadSettings *settings);
3075+void xpad_settings_set_text_color (XpadSettings *settings, const GdkRGBA *text);
3076+G_CONST_RETURN GdkRGBA *xpad_settings_get_text_color (XpadSettings *settings);
3077
3078 void xpad_settings_set_fontname (XpadSettings *settings, const gchar *fontname);
3079 G_CONST_RETURN gchar *xpad_settings_get_fontname (XpadSettings *settings);
3080
3081+void xpad_settings_set_tray_click_handler (XpadSettings *settings, guint conf);
3082 guint xpad_settings_get_tray_click_handler(XpadSettings *settings);
3083
3084 G_END_DECLS
3085
3086=== modified file 'src/xpad-text-buffer.c'
3087--- src/xpad-text-buffer.c 2013-10-23 18:30:54 +0000
3088+++ src/xpad-text-buffer.c 2013-11-01 20:03:38 +0000
3089@@ -17,6 +17,7 @@
3090 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
3091 */
3092
3093+#include "../config.h"
3094 #include "xpad-text-buffer.h"
3095 #include "xpad-undo.h"
3096 #include "xpad-pad.h"
3097
3098=== modified file 'src/xpad-text-view.c'
3099--- src/xpad-text-view.c 2013-10-18 18:31:20 +0000
3100+++ src/xpad-text-view.c 2013-11-01 20:03:38 +0000
3101@@ -16,9 +16,11 @@
3102 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
3103 */
3104
3105+#include "../config.h"
3106 #include "xpad-text-view.h"
3107 #include "xpad-text-buffer.h"
3108 #include "xpad-settings.h"
3109+#include "xpad-app.h"
3110
3111 struct XpadTextViewPrivate
3112 {
3113@@ -42,9 +44,7 @@
3114 static void xpad_text_view_notify_edit_lock (XpadTextView *view);
3115 static void xpad_text_view_notify_editable (XpadTextView *view);
3116 static void xpad_text_view_notify_fontname (XpadTextView *view);
3117-static void xpad_text_view_notify_text_color (XpadTextView *view);
3118-static void xpad_text_view_notify_back_color (XpadTextView *view);
3119-static void xpad_text_view_style_set (GtkWidget *widget, GtkStyle *previous_style);
3120+static void xpad_text_view_notify_colors (XpadTextView *view);
3121
3122 enum
3123 {
3124@@ -57,7 +57,7 @@
3125 GtkWidget *
3126 xpad_text_view_new (void)
3127 {
3128- return GTK_WIDGET (g_object_new (XPAD_TYPE_TEXT_VIEW, NULL));
3129+ return GTK_WIDGET (g_object_new (XPAD_TYPE_TEXT_VIEW, "follow-font-style", TRUE, "follow-color-style", TRUE, NULL));
3130 }
3131
3132 static void
3133@@ -113,14 +113,12 @@
3134 g_signal_connect_after (view, "focus-out-event", G_CALLBACK (xpad_text_view_focus_out_event), NULL);
3135 g_signal_connect (view, "realize", G_CALLBACK (xpad_text_view_realize), NULL);
3136 g_signal_connect (view, "notify::editable", G_CALLBACK (xpad_text_view_notify_editable), NULL);
3137- g_signal_connect (view, "style-set", G_CALLBACK (xpad_text_view_style_set), NULL);
3138- g_signal_connect_swapped (xpad_settings (), "notify::edit-lock", G_CALLBACK (xpad_text_view_notify_edit_lock), view);
3139- view->priv->notify_font_handler = g_signal_connect_swapped (xpad_settings (), "notify::fontname", G_CALLBACK (xpad_text_view_notify_fontname), view);
3140- view->priv->notify_text_handler = g_signal_connect_swapped (xpad_settings (), "notify::text-color", G_CALLBACK (xpad_text_view_notify_text_color), view);
3141- view->priv->notify_back_handler = g_signal_connect_swapped (xpad_settings (), "notify::back-color", G_CALLBACK (xpad_text_view_notify_back_color), view);
3142+ g_signal_connect_swapped (xpad_global_settings, "notify::edit-lock", G_CALLBACK (xpad_text_view_notify_edit_lock), view);
3143+ view->priv->notify_font_handler = g_signal_connect_swapped (xpad_global_settings, "notify::fontname", G_CALLBACK (xpad_text_view_notify_fontname), view);
3144+ view->priv->notify_text_handler = g_signal_connect_swapped (xpad_global_settings, "notify::text-color", G_CALLBACK (xpad_text_view_notify_colors), view);
3145+ view->priv->notify_back_handler = g_signal_connect_swapped (xpad_global_settings, "notify::back-color", G_CALLBACK (xpad_text_view_notify_colors), view);
3146
3147- xpad_text_view_notify_text_color (view);
3148- xpad_text_view_notify_back_color (view);
3149+ xpad_text_view_notify_colors (view);
3150 xpad_text_view_notify_fontname (view);
3151 }
3152
3153@@ -139,19 +137,27 @@
3154 static void
3155 xpad_text_view_finalize (GObject *object)
3156 {
3157+ XpadTextView *view = XPAD_TEXT_VIEW (object);
3158+
3159+ g_signal_handlers_disconnect_matched (xpad_global_settings, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, view);
3160+
3161 G_OBJECT_CLASS (xpad_text_view_parent_class)->finalize (object);
3162 }
3163
3164 static void
3165 xpad_text_view_realize (XpadTextView *view)
3166 {
3167- gtk_text_view_set_editable (GTK_TEXT_VIEW (view), !xpad_settings_get_edit_lock (xpad_settings ()));
3168+ gtk_text_view_set_editable (GTK_TEXT_VIEW (view), !xpad_settings_get_edit_lock (xpad_global_settings));
3169 }
3170
3171 static gboolean
3172 xpad_text_view_focus_out_event (GtkWidget *widget, GdkEventFocus *event)
3173 {
3174- if (xpad_settings_get_edit_lock (xpad_settings ()))
3175+ // A dirty way to silence the compiler for these unused variables.
3176+ // Feel free to implement these variables in the way they are ment to be used.
3177+ (void) event;
3178+
3179+ if (xpad_settings_get_edit_lock (xpad_global_settings))
3180 {
3181 gtk_text_view_set_editable (GTK_TEXT_VIEW (widget), FALSE);
3182 return TRUE;
3183@@ -164,7 +170,7 @@
3184 xpad_text_view_button_press_event (GtkWidget *widget, GdkEventButton *event)
3185 {
3186 if (event->button == 1 &&
3187- xpad_settings_get_edit_lock (xpad_settings ()) &&
3188+ xpad_settings_get_edit_lock (xpad_global_settings) &&
3189 !gtk_text_view_get_editable (GTK_TEXT_VIEW (widget)))
3190 {
3191 if (event->type == GDK_2BUTTON_PRESS)
3192@@ -174,7 +180,7 @@
3193 }
3194 else if (event->type == GDK_BUTTON_PRESS)
3195 {
3196- gtk_window_begin_move_drag (GTK_WINDOW (gtk_widget_get_toplevel (widget)), event->button, event->x_root, event->y_root, event->time);
3197+ gtk_window_begin_move_drag (GTK_WINDOW (gtk_widget_get_toplevel (widget)), (gint) event->button, (gint) event->x_root, (gint) event->y_root, event->time);
3198 return TRUE;
3199 }
3200 }
3201@@ -186,7 +192,7 @@
3202 xpad_text_view_notify_edit_lock (XpadTextView *view)
3203 {
3204 /* chances are good that they don't have the text view focused while it changed, so make non-editable if edit lock turned on */
3205- gtk_text_view_set_editable (GTK_TEXT_VIEW (view), !xpad_settings_get_edit_lock (xpad_settings ()));
3206+ gtk_text_view_set_editable (GTK_TEXT_VIEW (view), !xpad_settings_get_edit_lock (xpad_global_settings));
3207 }
3208
3209 static void
3210@@ -203,71 +209,53 @@
3211 gdk_window_set_cursor (gtk_text_view_get_window (GTK_TEXT_VIEW (view), GTK_TEXT_WINDOW_TEXT), cursor);
3212
3213 if (cursor)
3214- gdk_cursor_unref (cursor);
3215-}
3216-
3217-/* Adjust the cursor to match the text color */
3218-static void
3219-xpad_text_view_style_set (GtkWidget *widget, GtkStyle *previous_style)
3220-{
3221- GdkColor c;
3222-
3223- /* text color changes */
3224- c = gtk_widget_get_style (widget)->text[GTK_STATE_NORMAL];
3225- if (!previous_style || !gdk_color_equal (&c, &previous_style->text[GTK_STATE_NORMAL]))
3226- {
3227- const gchar *name = gtk_widget_get_name (widget);
3228- gchar *style_string = g_strdup_printf ("style '%s' {GtkWidget::cursor_color = {%" G_GUINT16_FORMAT ", %" G_GUINT16_FORMAT ", %" G_GUINT16_FORMAT "}} widget '*%s' style '%s'", name, c.red, c.green, c.blue, name, name);
3229- gtk_rc_parse_string (style_string);
3230- g_free (style_string);
3231- gtk_widget_reset_rc_styles (widget);
3232- }
3233-
3234- /* base color changes */
3235- c = gtk_widget_get_style (widget)->base[GTK_STATE_NORMAL];
3236- if (!previous_style || !gdk_color_equal (&c, &previous_style->base[GTK_STATE_NORMAL]))
3237- {
3238- gtk_widget_modify_bg (widget, GTK_STATE_NORMAL, &c);
3239- }
3240+ g_object_unref (cursor);
3241 }
3242
3243 static void
3244 xpad_text_view_notify_fontname (XpadTextView *view)
3245 {
3246- const gchar *font = xpad_settings_get_fontname (xpad_settings ());
3247+ const gchar *font = xpad_settings_get_fontname (xpad_global_settings);
3248 PangoFontDescription *fontdesc;
3249
3250 fontdesc = font ? pango_font_description_from_string (font) : NULL;
3251- gtk_widget_modify_font (GTK_WIDGET (view), fontdesc);
3252+ gtk_widget_override_font (GTK_WIDGET (view), fontdesc);
3253 if (fontdesc)
3254 pango_font_description_free (fontdesc);
3255 }
3256
3257-static void
3258-xpad_text_view_notify_text_color (XpadTextView *view)
3259-{
3260- gtk_widget_modify_text (GTK_WIDGET (view), GTK_STATE_NORMAL, xpad_settings_get_text_color (xpad_settings ()));
3261-}
3262-
3263-static void
3264-xpad_text_view_notify_back_color (XpadTextView *view)
3265-{
3266- gtk_widget_modify_base (GTK_WIDGET (view), GTK_STATE_NORMAL, xpad_settings_get_back_color (xpad_settings ()));
3267+// Update the colors of the textview
3268+static void
3269+xpad_text_view_notify_colors (XpadTextView *view)
3270+{
3271+ // Set the colors of this individual pad to the global setting preference.
3272+ const GdkRGBA *text_color = xpad_settings_get_text_color (xpad_global_settings);
3273+ const GdkRGBA *back_color = xpad_settings_get_back_color (xpad_global_settings);
3274+
3275+ gtk_widget_override_cursor (GTK_WIDGET (view), text_color, text_color);
3276+ gtk_widget_override_color (GTK_WIDGET (view), GTK_STATE_FLAG_NORMAL, text_color);
3277+ gtk_widget_override_background_color (GTK_WIDGET (view), GTK_STATE_FLAG_NORMAL, back_color);
3278+
3279+ // Inverse the text and background colors for selected text, so it is likely to be visible by any choice of the colors.
3280+ gtk_widget_override_color (GTK_WIDGET (view), GTK_STATE_FLAG_SELECTED, back_color);
3281+ gtk_widget_override_background_color (GTK_WIDGET (view), GTK_STATE_FLAG_SELECTED, text_color);
3282 }
3283
3284 void
3285 xpad_text_view_set_follow_font_style (XpadTextView *view, gboolean follow)
3286 {
3287+ g_return_if_fail (view);
3288+
3289 if (follow != view->priv->follow_font_style)
3290 {
3291 if (follow)
3292 {
3293- g_signal_handler_unblock (xpad_settings (), view->priv->notify_font_handler);
3294+ g_signal_handler_unblock (xpad_global_settings, view->priv->notify_font_handler);
3295 xpad_text_view_notify_fontname (view);
3296 }
3297 else
3298 {
3299- g_signal_handler_block (xpad_settings (), view->priv->notify_font_handler);
3300+ g_signal_handler_block (xpad_global_settings, view->priv->notify_font_handler);
3301 }
3302 }
3303
3304@@ -279,37 +267,44 @@
3305 gboolean
3306 xpad_text_view_get_follow_font_style (XpadTextView *view)
3307 {
3308- return view->priv->follow_font_style;
3309+ if (view == NULL)
3310+ return TRUE;
3311+ else
3312+ return view->priv->follow_font_style;
3313 }
3314
3315 void
3316 xpad_text_view_set_follow_color_style (XpadTextView *view, gboolean follow)
3317 {
3318+ g_return_if_fail (view);
3319+
3320 if (follow != view->priv->follow_color_style)
3321 {
3322 if (follow)
3323 {
3324- g_signal_handler_unblock (xpad_settings (), view->priv->notify_text_handler);
3325- g_signal_handler_unblock (xpad_settings (), view->priv->notify_back_handler);
3326- xpad_text_view_notify_text_color (view);
3327- xpad_text_view_notify_back_color (view);
3328+ xpad_text_view_notify_colors (view);
3329+ g_signal_handler_unblock (xpad_global_settings, view->priv->notify_text_handler);
3330+ g_signal_handler_unblock (xpad_global_settings, view->priv->notify_back_handler);
3331 }
3332 else
3333 {
3334- g_signal_handler_block (xpad_settings (), view->priv->notify_text_handler);
3335- g_signal_handler_block (xpad_settings (), view->priv->notify_back_handler);
3336+ g_signal_handler_block (xpad_global_settings, view->priv->notify_text_handler);
3337+ g_signal_handler_block (xpad_global_settings, view->priv->notify_back_handler);
3338 }
3339+
3340+ view->priv->follow_color_style = follow;
3341 }
3342-
3343- view->priv->follow_color_style = follow;
3344-
3345+
3346 g_object_notify (G_OBJECT (view), "follow_color_style");
3347 }
3348
3349 gboolean
3350 xpad_text_view_get_follow_color_style (XpadTextView *view)
3351 {
3352- return view->priv->follow_color_style;
3353+ if (view == NULL)
3354+ return TRUE;
3355+ else
3356+ return view->priv->follow_color_style;
3357 }
3358
3359 static void
3360
3361=== modified file 'src/xpad-toolbar.c'
3362--- src/xpad-toolbar.c 2013-10-18 18:31:20 +0000
3363+++ src/xpad-toolbar.c 2013-11-01 20:03:38 +0000
3364@@ -25,6 +25,7 @@
3365 #include "xpad-toolbar.h"
3366 #include "xpad-settings.h"
3367 #include "xpad-grip-tool-item.h"
3368+#include "xpad-app.h"
3369
3370 struct XpadToolbarPrivate
3371 {
3372@@ -279,7 +280,7 @@
3373 "toolbar-style", GTK_TOOLBAR_ICONS,
3374 NULL);
3375
3376- g_signal_connect_swapped (xpad_settings (), "change-buttons", G_CALLBACK (xpad_toolbar_change_buttons), toolbar);
3377+ g_signal_connect_swapped (xpad_global_settings, "change-buttons", G_CALLBACK (xpad_toolbar_change_buttons), toolbar);
3378
3379 xpad_toolbar_change_buttons (toolbar);
3380 }
3381@@ -288,7 +289,7 @@
3382 xpad_toolbar_dispose (GObject *object)
3383 {
3384 XpadToolbar *toolbar = XPAD_TOOLBAR (object);
3385-
3386+
3387 if (toolbar->priv->pad) {
3388 g_object_unref (toolbar->priv->pad);
3389 toolbar->priv->pad = NULL;
3390@@ -346,6 +347,10 @@
3391 static G_CONST_RETURN XpadToolbarButton *
3392 xpad_toolbar_button_lookup (XpadToolbar *toolbar, const gchar *name)
3393 {
3394+ // A dirty way to silence the compiler for these unused variables.
3395+ // Feel free to implement these variables in the way they are ment to be used.
3396+ (void) toolbar;
3397+
3398 guint i;
3399 for (i = 0; i < G_N_ELEMENTS (buttons); i++)
3400 if (!g_ascii_strcasecmp (name, buttons[i].name))
3401@@ -424,7 +429,7 @@
3402 for (j = 0; j < G_N_ELEMENTS (buttons); j++)
3403 g_object_set_data (G_OBJECT (toolbar), buttons[j].name, NULL);
3404
3405- slist = xpad_settings_get_toolbar_buttons (xpad_settings ());
3406+ slist = xpad_settings_get_toolbar_buttons (xpad_global_settings);
3407 for (stemp = slist; stemp; stemp = stemp->next)
3408 {
3409 const XpadToolbarButton *button;
3410@@ -468,19 +473,19 @@
3411 static void
3412 xpad_toolbar_remove_all_buttons ()
3413 {
3414- xpad_settings_remove_all_toolbar_buttons (xpad_settings ());
3415+ xpad_settings_remove_all_toolbar_buttons (xpad_global_settings);
3416 }
3417
3418 static void
3419 xpad_toolbar_remove_last_button ()
3420 {
3421- xpad_settings_remove_last_toolbar_button (xpad_settings ());
3422+ xpad_settings_remove_last_toolbar_button (xpad_global_settings);
3423 }
3424
3425 static void
3426 xpad_toolbar_add_button (const gchar *name)
3427 {
3428- xpad_settings_add_toolbar_button (xpad_settings (), name);
3429+ xpad_settings_add_toolbar_button (xpad_global_settings, name);
3430 }
3431
3432 static void
3433@@ -492,13 +497,18 @@
3434 static gboolean
3435 xpad_toolbar_popup_context_menu (GtkToolbar *toolbar, gint x, gint y, gint button)
3436 {
3437+ // A dirty way to silence the compiler for these unused variables.
3438+ // Feel free to implement these variables in the way they are ment to be used.
3439+ (void) x;
3440+ (void) y;
3441+
3442 GtkWidget *menu;
3443 const GSList *current_buttons;
3444 guint i;
3445
3446 menu = gtk_menu_new ();
3447
3448- current_buttons = xpad_settings_get_toolbar_buttons (xpad_settings ());
3449+ current_buttons = xpad_settings_get_toolbar_buttons (xpad_global_settings);
3450
3451 gboolean is_button = FALSE;
3452
3453@@ -679,7 +689,7 @@
3454
3455 button_num = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (button), "xpad-button-num"));
3456
3457- xpad_settings_remove_toolbar_button (xpad_settings (), button_num);
3458+ xpad_settings_remove_toolbar_button (xpad_global_settings, button_num);
3459 }
3460
3461 static void
3462@@ -731,7 +741,7 @@
3463 static gboolean
3464 xpad_toolbar_move_button_move_keyboard (XpadToolbar *toolbar, GdkEventKey *event)
3465 {
3466- if (event->keyval == GDK_Left || event->keyval == GDK_KP_Left)
3467+ if (event->keyval == GDK_KEY_Left || event->keyval == GDK_KEY_KP_Left)
3468 {
3469 if (!toolbar->priv->move_removed)
3470 {
3471@@ -744,7 +754,7 @@
3472
3473 gtk_toolbar_set_drop_highlight_item (GTK_TOOLBAR (toolbar), toolbar->priv->move_button, toolbar->priv->move_index);
3474 }
3475- else if (event->keyval == GDK_Right || event->keyval == GDK_KP_Right)
3476+ else if (event->keyval == GDK_KEY_Right || event->keyval == GDK_KEY_KP_Right)
3477 {
3478 gint max;
3479
3480@@ -761,7 +771,7 @@
3481
3482 gtk_toolbar_set_drop_highlight_item (GTK_TOOLBAR (toolbar), toolbar->priv->move_button, toolbar->priv->move_index);
3483 }
3484- else if (event->keyval == GDK_space || event->keyval == GDK_KP_Space || event->keyval == GDK_Return || event->keyval == GDK_KP_Enter)
3485+ else if (event->keyval == GDK_KEY_space || event->keyval == GDK_KEY_KP_Space || event->keyval == GDK_KEY_Return || event->keyval == GDK_KEY_KP_Enter)
3486 {
3487 xpad_toolbar_move_button_end (toolbar);
3488 return TRUE;
3489@@ -813,7 +823,7 @@
3490 max = gtk_toolbar_get_n_items (GTK_TOOLBAR (toolbar)) - 2;
3491 toolbar->priv->move_index = MIN (toolbar->priv->move_index, max);
3492
3493- if (!xpad_settings_move_toolbar_button (xpad_settings (), old_spot, toolbar->priv->move_index) &&
3494+ if (!xpad_settings_move_toolbar_button (xpad_global_settings, old_spot, toolbar->priv->move_index) &&
3495 toolbar->priv->move_removed)
3496 {
3497 gtk_toolbar_insert (GTK_TOOLBAR (toolbar), toolbar->priv->move_button, toolbar->priv->move_index);
3498
3499=== modified file 'src/xpad-tray.c'
3500--- src/xpad-tray.c 2013-10-21 02:51:19 +0000
3501+++ src/xpad-tray.c 2013-11-01 20:03:38 +0000
3502@@ -2,6 +2,7 @@
3503
3504 Copyright (c) 2002 Jamis Buck
3505 Copyright (c) 2003-2007 Michael Terry
3506+Copyright (c) 2013 Arthur Borsboom
3507
3508 This program is free software; you can redistribute it and/or modify
3509 it under the terms of the GNU General Public License as published by
3510@@ -52,26 +53,25 @@
3511 static GtkWidget *menu = NULL;
3512
3513 void
3514-xpad_tray_open (void)
3515+xpad_tray_open ()
3516 {
3517 GtkIconTheme *theme;
3518
3519- // xpad_tray_close ();
3520-
3521 theme = gtk_icon_theme_get_default ();
3522+
3523 if (!gtk_icon_theme_has_icon (theme, PACKAGE)) {
3524 return;
3525 }
3526-
3527+
3528 if (gtk_icon_theme_has_icon (theme, "xpad-panel"))
3529- {
3530- docklet = gtk_status_icon_new_from_icon_name ("xpad-panel");
3531- }
3532- else
3533- {
3534+ {
3535+ docklet = gtk_status_icon_new_from_icon_name ("xpad-panel");
3536+ }
3537+ else
3538+ {
3539 docklet = gtk_status_icon_new_from_icon_name (PACKAGE);
3540- }
3541-
3542+ }
3543+
3544 if (docklet)
3545 {
3546 g_signal_connect (docklet, "activate", G_CALLBACK (xpad_tray_activate_cb), NULL);
3547@@ -117,7 +117,7 @@
3548 static void
3549 menu_show_all (XpadPadGroup *group)
3550 {
3551- GSList *pads = xpad_pad_group_get_pads (xpad_app_get_pad_group ());
3552+ GSList *pads = xpad_pad_group_get_pads (group);
3553 g_slist_foreach (pads, (GFunc) gtk_window_present, NULL);
3554 g_slist_free (pads);
3555 }
3556@@ -153,7 +153,6 @@
3557 {
3558 GtkWidget *item;
3559 GSList *pads;
3560- gint n;
3561 gboolean no_any_pad = FALSE;
3562
3563 menu = gtk_menu_new ();
3564@@ -208,7 +207,7 @@
3565 static void
3566 xpad_tray_activate_cb (GtkStatusIcon *icon)
3567 {
3568- switch (xpad_settings_get_tray_click_handler(xpad_settings()))
3569+ switch (xpad_settings_get_tray_click_handler(xpad_global_settings))
3570 {
3571 case TOGGLE_SHOW_ALL:
3572 xpad_tray_show_hide_all();
3573
3574=== modified file 'src/xpad-undo.c'
3575--- src/xpad-undo.c 2013-10-18 18:31:20 +0000
3576+++ src/xpad-undo.c 2013-11-01 20:03:38 +0000
3577@@ -223,12 +223,20 @@
3578 static void
3579 xpad_undo_begin_user_action (GtkTextBuffer *buffer, XpadUndo *undo)
3580 {
3581+ // A dirty way to silence the compiler for these unused variables.
3582+ // Feel free to implement these variables in the way they are ment to be used.
3583+ (void) buffer;
3584+
3585 undo->priv->user_action++;
3586 }
3587
3588 static void
3589 xpad_undo_end_user_action (GtkTextBuffer *buffer, XpadUndo *undo)
3590 {
3591+ // A dirty way to silence the compiler for these unused variables.
3592+ // Feel free to implement these variables in the way they are ment to be used.
3593+ (void) buffer;
3594+
3595 if (undo->priv->user_action > 0)
3596 undo->priv->user_action--;
3597 }
3598@@ -275,15 +283,28 @@
3599 static void
3600 xpad_undo_insert_text (GtkTextBuffer *buffer, GtkTextIter *location, gchar *text, gint len, XpadUndo *undo)
3601 {
3602+ // A dirty way to silence the compiler for these unused variables.
3603+ // Feel free to implement these variables in the way they are ment to be used.
3604+ (void) buffer;
3605+
3606 if (undo->priv->frozen)
3607 return;
3608
3609 if (undo->priv->user_action)
3610 {
3611+ gint n_utf8_chars = 0;
3612+ glong string_length = 0;
3613+
3614 xpad_undo_clear_redo_history (undo);
3615
3616 gint pos = gtk_text_iter_get_offset (location);
3617- gint n_utf8_chars = g_utf8_strlen (text, len);
3618+
3619+ // safe cast
3620+ string_length = g_utf8_strlen (text, len);
3621+ if (string_length <= UINT_MAX)
3622+ n_utf8_chars = (gint) string_length;
3623+ else
3624+ g_warning("Casting problem in undo insert text function. Please send a bugreport.");
3625
3626 /* Merge similar actions. This is how Undo works in most editors, if there is a series of
3627 1-letter insertions - they are merge for Undo */
3628@@ -299,8 +320,8 @@
3629 && (prev_action->n_utf8_chars == 1 || prev_action->merged)) // with which we should merge
3630 {
3631 /* if there was a space stop merging unless that was a series of spaces */
3632- if ((!g_unichar_isspace (prev_action->text[0]) && !g_ascii_isspace (text[0])) ||
3633- (g_unichar_isspace (prev_action->text[0]) && g_unichar_isspace (text[0])))
3634+ if ((!g_unichar_isspace ((gunichar) prev_action->text[0]) && !g_ascii_isspace ((gunichar) text[0])) ||
3635+ (g_unichar_isspace ((gunichar) prev_action->text[0]) && g_unichar_isspace ((gunichar) text[0])))
3636 {
3637 gchar *joined_str = g_strjoin (NULL, prev_action->text, text, NULL);
3638 g_free (prev_action->text);
3639@@ -328,7 +349,11 @@
3640 is nothing after history_curr at this point so we
3641 insert right after it. history_start won't change
3642 since it is a left guard - not NULL */
3643- GList *dummy_start = g_list_append (undo->priv->history_curr, action); // supress warning, we have left guard for start
3644+ GList *dummy_start = g_list_append (undo->priv->history_curr, action);
3645+ // A dirty way to silence the compiler for these unused variables.
3646+ // Feel free to implement these variables in the way they are ment to be used.
3647+ (void) dummy_start;
3648+
3649 undo->priv->history_curr = g_list_next (undo->priv->history_curr);
3650
3651 xpad_pad_notify_undo_redo_changed (xpad_text_buffer_get_pad (undo->priv->buffer));
3652@@ -338,18 +363,31 @@
3653 static void
3654 xpad_undo_delete_range (GtkTextBuffer *buffer, GtkTextIter *start, GtkTextIter *end, XpadUndo *undo)
3655 {
3656+ // A dirty way to silence the compiler for these unused variables.
3657+ // Feel free to implement these variables in the way they are ment to be used.
3658+ (void) buffer;
3659+
3660 if (undo->priv->frozen)
3661 return;
3662
3663 if (undo->priv->user_action)
3664 {
3665+ gint n_utf8_chars = 0;
3666+ glong string_length = 0;
3667+
3668 xpad_undo_clear_redo_history (undo);
3669
3670 gchar *text = gtk_text_iter_get_text (start, end);
3671 gint start_offset = gtk_text_iter_get_offset (start);
3672 gint end_offset = gtk_text_iter_get_offset (end);
3673 gint len = abs (end_offset - start_offset);
3674- gint n_utf8_chars = g_utf8_strlen (text, len);
3675+
3676+ // safe cast
3677+ string_length = g_utf8_strlen (text, len);
3678+ if (string_length <= UINT_MAX)
3679+ n_utf8_chars = (gint) string_length;
3680+ else
3681+ g_warning("Casting problem in undo delete range function. Please send a bugreport.");
3682
3683 UserAction *action = g_new (UserAction, 1);
3684 action->action_type = USER_ACTION_DELETE_RANGE;
3685@@ -360,7 +398,11 @@
3686 action->n_utf8_chars = n_utf8_chars;
3687 action->merged = FALSE;
3688
3689- GList *dummy_start = g_list_append (undo->priv->history_curr, action); // supress warning, we have left guard for start
3690+ GList *dummy_start = g_list_append (undo->priv->history_curr, action);
3691+ // A dirty way to silence the compiler for these unused variables.
3692+ // Feel free to implement these variables in the way they are ment to be used.
3693+ (void) dummy_start;
3694+
3695 undo->priv->history_curr = g_list_next (undo->priv->history_curr);
3696
3697 xpad_pad_notify_undo_redo_changed (xpad_text_buffer_get_pad (undo->priv->buffer));
3698@@ -385,7 +427,11 @@
3699 action->end = end_offset;
3700 action->merged = FALSE;
3701
3702- GList *dummy_start = g_list_append (undo->priv->history_curr, action); // supress warning, we have left guard for start
3703+ GList *dummy_start = g_list_append (undo->priv->history_curr, action);
3704+ // A dirty way to silence the compiler for these unused variables.
3705+ // Feel free to implement these variables in the way they are ment to be used.
3706+ (void) dummy_start;
3707+
3708 undo->priv->history_curr = g_list_next (undo->priv->history_curr);
3709
3710 xpad_pad_notify_undo_redo_changed (xpad_text_buffer_get_pad (undo->priv->buffer));
3711@@ -409,7 +455,11 @@
3712 action->end = end_offset;
3713 action->merged = FALSE;
3714
3715- GList *dummy_start = g_list_append (undo->priv->history_curr, action); // supress warning, we have left guard for start
3716+ GList *dummy_start = g_list_append (undo->priv->history_curr, action);
3717+ // A dirty way to silence the compiler for these unused variables.
3718+ // Feel free to implement these variables in the way they are ment to be used.
3719+ (void) dummy_start;
3720+
3721 undo->priv->history_curr = g_list_next (undo->priv->history_curr);
3722
3723 xpad_pad_notify_undo_redo_changed (xpad_text_buffer_get_pad (undo->priv->buffer));

Subscribers

People subscribed via source and target branches