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
=== modified file 'configure.ac'
--- configure.ac 2013-10-21 18:52:10 +0000
+++ configure.ac 2013-11-01 20:03:38 +0000
@@ -1,7 +1,7 @@
1# Process this file with autoconf to produce a configure script.1# Process this file with autoconf to produce a configure script.
22
3# Sets up autoconf.3# Sets up autoconf.
4AC_INIT([Xpad],[4.2],[xpad-hackers@lists.launchpad.net])4AC_INIT([Xpad],[4.3],[xpad-hackers@lists.launchpad.net])
5AC_CONFIG_SRCDIR(src/xpad-app.c)5AC_CONFIG_SRCDIR(src/xpad-app.c)
6AC_CONFIG_HEADERS([config.h:config.h.in])6AC_CONFIG_HEADERS([config.h:config.h.in])
77
@@ -15,9 +15,18 @@
15AC_PROG_MAKE_SET15AC_PROG_MAKE_SET
16AC_PROG_INTLTOOL([0.31], [no-xml])16AC_PROG_INTLTOOL([0.31], [no-xml])
1717
18# Checks for libraries.
19AC_PATH_XTRA18AC_PATH_XTRA
20PKG_CHECK_MODULES(GTK, gtk+-2.0 >= 2.12 gio-2.0)19
20# Checks for GTK+ 3.0
21PKG_CHECK_MODULES(GTK, gtk+-3.0 gio-2.0)
22AM_CONDITIONAL(GTK, test -n "$GTK_LIBS")
23# ensure that only allowed headers are included
24GTK_CFLAGS+="-DGTK_DISABLE_SINGLE_INCLUDES "
25# ensure that no gtk deprecated symbols are used
26GTK_CFLAGS+="-DGDK_DISABLE_DEPRECATED "
27GTK_CFLAGS+="-DGTK_DISABLE_DEPRECATED "
28# ensure use of accessors
29GTK_CFLAGS+="-DGSEAL_ENABLE "
21AC_SUBST(GTK_CFLAGS)30AC_SUBST(GTK_CFLAGS)
22AC_SUBST(GTK_LIBS)31AC_SUBST(GTK_LIBS)
2332
@@ -25,6 +34,18 @@
25AC_SUBST(GLIB_CFLAGS)34AC_SUBST(GLIB_CFLAGS)
26AC_SUBST(GLIB_LIBS)35AC_SUBST(GLIB_LIBS)
2736
37PKG_CHECK_MODULES(PANGO, pango >= 1.32)
38AC_SUBST(PANGO_LIBS)
39AC_SUBST(PANGO_CFLAGS)
40
41PKG_CHECK_MODULES(PIXBUF, gdk-pixbuf-2.0 >= 2.28)
42AC_SUBST(PIXBUF_LIBS)
43AC_SUBST(PIXBUF_CFLAGS)
44
45PKG_CHECK_MODULES(ATK, atk >= 2.8 atk-bridge-2.0)
46AC_SUBST(ATK_LIBS)
47AC_SUBST(ATK_CFLAGS)
48
28# Checks for typedefs, structures, and compiler characteristics.49# Checks for typedefs, structures, and compiler characteristics.
29AC_C_CONST50AC_C_CONST
30AC_TYPE_SIZE_T51AC_TYPE_SIZE_T
3152
=== modified file 'src/fio.c'
--- src/fio.c 2011-11-14 17:10:03 +0000
+++ src/fio.c 2013-11-01 20:03:38 +0000
@@ -57,14 +57,14 @@
57gchar *str_replace_tokens (gchar **string, gchar obj, gchar *replacement)57gchar *str_replace_tokens (gchar **string, gchar obj, gchar *replacement)
58{58{
59 gchar *p;59 gchar *p;
60 gint rsize = strlen (replacement);60 gsize rsize = strlen (replacement);
61 gint osize = 1;61 gsize osize = 1;
62 gint diff = rsize - osize;62 gsize diff = rsize - osize;
63 63
64 p = *string;64 p = *string;
65 while ((p = strchr (p, obj)))65 while ((p = strchr (p, obj)))
66 {66 {
67 gint offset = p - *string;67 long offset = p - *string;
68 *string = g_realloc (*string, strlen (*string) + diff + 1);68 *string = g_realloc (*string, strlen (*string) + diff + 1);
69 p = *string + offset;69 p = *string + offset;
70 g_memmove (p + rsize, p + osize, strlen (p + osize) + 1);70 g_memmove (p + rsize, p + osize, strlen (p + osize) + 1);
@@ -188,7 +188,7 @@
188 gchar *fullitem;188 gchar *fullitem;
189 gint *value;189 gint *value;
190 gchar *where;190 gchar *where;
191 gint size;191 gsize size;
192 gchar type;192 gchar type;
193 193
194 type = item[0];194 type = item[0];
@@ -316,4 +316,3 @@
316 g_file_delete (file, NULL, NULL);316 g_file_delete (file, NULL, NULL);
317 g_object_unref (file);317 g_object_unref (file);
318}318}
319
320319
=== modified file 'src/help.c'
--- src/help.c 2013-10-18 18:31:20 +0000
+++ src/help.c 2013-11-01 20:03:38 +0000
@@ -40,27 +40,30 @@
40 gchar *helptextbuf;40 gchar *helptextbuf;
41 41
42 /* Create the widgets */42 /* Create the widgets */
43
44 dialog = gtk_dialog_new ();43 dialog = gtk_dialog_new ();
45 helptext = gtk_label_new ("");44 helptext = gtk_label_new ("");
46 45
47 /* we use g_strdup_printf because C89 has size limits on static strings */46 if (page == 0) {
48 helptextbuf = g_strdup_printf ("%s\n\n%s\n\n%s\n\n%s\n\n%s\n\n%s",47 /* we use g_strdup_printf because C89 has size limits on static strings */
49_("Each xpad session consists of one or more open pads. "48 helptextbuf = g_strdup_printf ("%s\n\n%s\n\n%s\n\n%s\n\n%s\n\n%s",
50"These pads are basically sticky notes on your desktop in which "49 _("Each xpad session consists of one or more open pads. "
51"you can write memos."),50 "These pads are basically sticky notes on your desktop in which "
52_("<b>To move a pad</b>, left drag on the toolbar, right drag "51 "you can write memos."),
53"on the resizer in the bottom right, or hold down CTRL "52 _("<b>To move a pad</b>, left drag on the toolbar, right drag "
54"while left dragging anywhere on the pad."),53 "on the resizer in the bottom right, or hold down CTRL "
55_("<b>To resize a pad</b>, left drag on the resizer or hold down "54 "while left dragging anywhere on the pad."),
56"CTRL while right dragging anywhere on the pad."),55 _("<b>To resize a pad</b>, left drag on the resizer or hold down "
57_("<b>To change color settings</b>, right click on a pad "56 "CTRL while right dragging anywhere on the pad."),
58"and choose Edit->Preferences."),57 _("<b>To change color settings</b>, right click on a pad "
59_("Most actions are available throught the popup menu "58 "and choose Edit->Preferences."),
60"that appears when you right click on a pad. Try it out and "59 _("Most actions are available throught the popup menu "
61"enjoy."),60 "that appears when you right click on a pad. Try it out and "
62_("Please send ideas or bug reports to\n"61 "enjoy."),
63"https://bugs.launchpad.net/xpad/+filebug"));62 _("Please send ideas or bug reports to\n"
63 "https://bugs.launchpad.net/xpad/+filebug"));
64 }
65 else
66 helptextbuf = g_strdup_printf("Unknown help page requested");
64 67
65 gtk_label_set_markup (GTK_LABEL (helptext), helptextbuf);68 gtk_label_set_markup (GTK_LABEL (helptext), helptextbuf);
66 69
@@ -73,14 +76,14 @@
73 gtk_window_set_title (GTK_WINDOW (dialog), _("Help"));76 gtk_window_set_title (GTK_WINDOW (dialog), _("Help"));
74 77
75 /* Add the label, and show everything we've added to the dialog. */78 /* Add the label, and show everything we've added to the dialog. */
76 gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->vbox), helptext);79 gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), helptext);
77 button = gtk_dialog_add_button (GTK_DIALOG(dialog), "gtk-close", 1);80 button = gtk_dialog_add_button (GTK_DIALOG(dialog), "gtk-close", 1);
78 81
79 gtk_window_set_position (GTK_WINDOW(dialog), GTK_WIN_POS_CENTER);82 gtk_window_set_position (GTK_WINDOW(dialog), GTK_WIN_POS_CENTER);
80 83
81 g_signal_connect (GTK_OBJECT (dialog), "destroy", 84 g_signal_connect (GTK_WINDOW (dialog), "destroy",
82 G_CALLBACK (help_close), NULL);85 G_CALLBACK (help_close), NULL);
83 g_signal_connect_swapped (GTK_OBJECT (button), "clicked", 86 g_signal_connect_swapped (GTK_BUTTON (button), "clicked",
84 G_CALLBACK (gtk_widget_destroy), dialog);87 G_CALLBACK (gtk_widget_destroy), dialog);
85 88
86 gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);89 gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
8790
=== modified file 'src/prefix.c'
--- src/prefix.c 2008-09-21 00:03:40 +0000
+++ src/prefix.c 2013-11-01 20:03:38 +0000
@@ -397,7 +397,7 @@
397397
398 while (end > path && *end == '/')398 while (end > path && *end == '/')
399 end--;399 end--;
400 result = br_strndup ((char *) path, end - path + 1);400 result = br_strndup ((char *) path, ((size_t) (end - path + 1)));
401 if (!*result)401 if (!*result)
402 {402 {
403 free (result);403 free (result);
@@ -431,7 +431,7 @@
431 end = strrchr (path, '/');431 end = strrchr (path, '/');
432 if (!end) return strdup (path);432 if (!end) return strdup (path);
433433
434 tmp = br_strndup ((char *) path, end - path);434 tmp = br_strndup ((char *) path, ((size_t) (end - path)));
435 if (!*tmp)435 if (!*tmp)
436 {436 {
437 free (tmp);437 free (tmp);
@@ -440,7 +440,7 @@
440 end = strrchr (tmp, '/');440 end = strrchr (tmp, '/');
441 if (!end) return tmp;441 if (!end) return tmp;
442442
443 result = br_strndup (tmp, end - tmp);443 result = br_strndup (tmp, ((size_t) (end - tmp)));
444 free (tmp);444 free (tmp);
445445
446 if (!*result)446 if (!*result)
447447
=== modified file 'src/xpad-app.c'
--- src/xpad-app.c 2013-10-18 18:31:20 +0000
+++ src/xpad-app.c 2013-11-01 20:03:38 +0000
@@ -1,6 +1,7 @@
1/**1/**
2 * Copyright (c) 2004-2007 Michael Terry2 * Copyright (c) 2004-2007 Michael Terry
3 * Copyright (c) 2009 Paul Ivanov3 * Copyright (c) 2009 Paul Ivanov
4 * Copyright (c) 2013 Arthur Borsboom
4 * 5 *
5 * This program is free software; you can redistribute it and/or modify6 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by7 * it under the terms of the GNU General Public License as published by
@@ -21,16 +22,17 @@
21/* define _GNU_SOURCE here because that makes our sockets work nice22/* define _GNU_SOURCE here because that makes our sockets work nice
22 Unfortunately, we lose portability... */23 Unfortunately, we lose portability... */
23#define _GNU_SOURCE 124#define _GNU_SOURCE 1
25#include "../config.h"
24#include <stdio.h>26#include <stdio.h>
25#include <unistd.h>27#include <unistd.h>
26#include <sys/un.h>28#include <sys/un.h>
27#include <sys/socket.h>29#include <sys/socket.h>
28#include <sys/select.h>30#include <sys/select.h>
31#include <errno.h>
2932
30#include <string.h>33#include <string.h>
31#include <stdlib.h> /* for exit */34#include <stdlib.h> /* for exit */
3235
33#include "../config.h"
34#include <glib/gi18n.h>36#include <glib/gi18n.h>
35#include <glib/gstdio.h>37#include <glib/gstdio.h>
3638
@@ -77,21 +79,21 @@
77static gchar *server_filename;79static gchar *server_filename;
78static gint server_fd;80static gint server_fd;
79static FILE *output;81static FILE *output;
80static gboolean xpad_translucent = FALSE;
81static XpadPadGroup *pad_group;82static XpadPadGroup *pad_group;
82static gint pads_loaded_on_start = 0;83static gint pads_loaded_on_start = 0;
8384XpadSettings *xpad_global_settings;
84static gboolean process_local_args (gint *argc, gchar **argv[]);85
85static gboolean process_remote_args (gint *argc, gchar **argv[], gboolean have_gtk);86static gboolean process_local_args (gint *argc, gchar **argv[]);
8687static gboolean process_remote_args (gint *argc, gchar **argv[], gboolean have_gtk);
87static gboolean config_dir_exists (void);88
88static gchar *make_config_dir (void);89static gboolean config_dir_exists (void);
89static void register_stock_icons (void);90static gchar *make_config_dir (void);
90static gint xpad_app_load_pads (void);91static void register_stock_icons (void);
91static gboolean xpad_app_quit_if_no_pads (XpadPadGroup *group);92static gint xpad_app_load_pads (void);
92static gboolean xpad_app_first_idle_check (XpadPadGroup *group);93static gboolean xpad_app_quit_if_no_pads (XpadPadGroup *group);
93static gboolean xpad_app_pass_args (void);94static gboolean xpad_app_first_idle_check (XpadPadGroup *group);
94static gboolean xpad_app_open_proc_file (void);95static gboolean xpad_app_pass_args (void);
96static gboolean xpad_app_open_proc_file (void);
9597
9698
97static void99static void
@@ -99,17 +101,15 @@
99{101{
100 gboolean first_time;102 gboolean first_time;
101 gboolean have_gtk;103 gboolean have_gtk;
102 // GdkVisual *visual;
103104
104 /* Set up i18n */105 /* Set up support different languages */
105#ifdef ENABLE_NLS106#ifdef ENABLE_NLS
106 gtk_set_locale ();
107 bindtextdomain (GETTEXT_PACKAGE, LOCALE_DIR);107 bindtextdomain (GETTEXT_PACKAGE, LOCALE_DIR);
108 bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");108 bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
109 textdomain (GETTEXT_PACKAGE);109 textdomain (GETTEXT_PACKAGE);
110#endif110#endif
111111
112 have_gtk = gtk_init_check (&argc, &argv);112 have_gtk = gtk_init_check (&argc, &argv); // Leaves 135 referenced objects behind. No idea how to unref. Total up to here 135.
113 xpad_argc = argc;113 xpad_argc = argc;
114 xpad_argv = argv;114 xpad_argv = argv;
115 output = stdout;115 output = stdout;
@@ -137,18 +137,9 @@
137 137
138 g_set_application_name (_("Xpad"));138 g_set_application_name (_("Xpad"));
139 gdk_set_program_class (PACKAGE);139 gdk_set_program_class (PACKAGE);
140 140
141 /* Set up translucency. */
142/* visual = gdk_visual_get_best_with_depth (32);
143 if (visual)
144 {
145 GdkColormap *colormap;
146 colormap = gdk_colormap_new (visual, TRUE);
147 gtk_widget_set_default_colormap (colormap);
148 xpad_translucent = TRUE;
149 }*/
150
151 /* Set up program path. */141 /* Set up program path. */
142
152 if (xpad_argc > 0)143 if (xpad_argc > 0)
153 program_path = g_find_program_in_path (xpad_argv[0]);144 program_path = g_find_program_in_path (xpad_argv[0]);
154 else145 else
@@ -158,26 +149,28 @@
158 149
159 if (xpad_app_pass_args ())150 if (xpad_app_pass_args ())
160 exit (0);151 exit (0);
161 152
162 /* Race condition here, between calls */153 /* Race condition here, between calls */
163 xpad_app_open_proc_file ();154 xpad_app_open_proc_file ();
164 155
165 register_stock_icons ();156 register_stock_icons (); // Leaves 1039 referenced objects behind. No idea how to unref, except 1. Total up to here 1173.
166 gtk_window_set_default_icon_name (PACKAGE);157 gtk_window_set_default_icon_name (PACKAGE);
167 158
168 pad_group = xpad_pad_group_new();159 pad_group = xpad_pad_group_new(); // Creates 1 referenced object; but does get unrefferenced. Total 1173.
169 process_remote_args (&xpad_argc, &xpad_argv, TRUE);160 process_remote_args (&xpad_argc, &xpad_argv, TRUE);
170 161
171 xpad_tray_open ();162 xpad_tray_open (); // Creates 34 referenced objects; but only 14 get unrefferenced. Total 1193.
172 xpad_session_manager_init ();163 xpad_session_manager_init ();
173164
165 xpad_global_settings = xpad_settings_new (); // Creates 1 reference, 1 reference gets cleaned up. Total 1193
166
174 /* Initialize Xpad-periodic module */167 /* Initialize Xpad-periodic module */
175 Xpad_periodic_init();168 Xpad_periodic_init();
176 Xpad_periodic_set_callback("save-content", (XpadPeriodicFunc) xpad_pad_save_content);169 Xpad_periodic_set_callback("save-content", (XpadPeriodicFunc) xpad_pad_save_content);
177 Xpad_periodic_set_callback("save-info", (XpadPeriodicFunc) xpad_pad_save_info);170 Xpad_periodic_set_callback("save-info", (XpadPeriodicFunc) xpad_pad_save_info);
178 171
179 /* load all pads */172 /* load all pads */
180 pads_loaded_on_start = xpad_app_load_pads ();173 pads_loaded_on_start = xpad_app_load_pads (); // each pad creates 333 references and leaves about 100 references behind. Total 1268.
181 if (pads_loaded_on_start == 0 && !option_new) {174 if (pads_loaded_on_start == 0 && !option_new) {
182 if (!option_nonew) {175 if (!option_nonew) {
183 GtkWidget *pad = xpad_pad_new (pad_group);176 GtkWidget *pad = xpad_pad_new (pad_group);
@@ -194,19 +187,15 @@
194 server_filename = NULL;187 server_filename = NULL;
195}188}
196189
197
198gint main (gint argc, gchar **argv)190gint main (gint argc, gchar **argv)
199{191{
200 xpad_app_init (argc, argv);192 xpad_app_init (argc, argv);
201 193
202 gtk_main ();194 gtk_main ();
203 195
204 return 0;196 return 0;
205}197}
206198
207
208
209
210/* parent and secondary may be NULL.199/* parent and secondary may be NULL.
211 * Returns when user dismisses error.200 * Returns when user dismisses error.
212 */201 */
@@ -228,15 +217,12 @@
228 xpad_session_manager_stop_interact (FALSE);217 xpad_session_manager_stop_interact (FALSE);
229}218}
230219
231
232
233G_CONST_RETURN gchar *220G_CONST_RETURN gchar *
234xpad_app_get_config_dir (void)221xpad_app_get_config_dir (void)
235{222{
236 return config_dir;223 return config_dir;
237}224}
238225
239
240/* Returns absolute path to our own executable. May be NULL. */226/* Returns absolute path to our own executable. May be NULL. */
241G_CONST_RETURN gchar *227G_CONST_RETURN gchar *
242xpad_app_get_program_path (void)228xpad_app_get_program_path (void)
@@ -244,7 +230,6 @@
244 return program_path;230 return program_path;
245}231}
246232
247
248XpadPadGroup *233XpadPadGroup *
249xpad_app_get_pad_group (void)234xpad_app_get_pad_group (void)
250{235{
@@ -255,25 +240,23 @@
255xpad_app_quit (void)240xpad_app_quit (void)
256{241{
257 // Free the memory used by the pads belonging to this group242 // Free the memory used by the pads belonging to this group
258 xpad_pad_group_destroy_pads(xpad_app_get_pad_group());243 xpad_pad_group_destroy_pads (xpad_app_get_pad_group());
259244
260 // Free the memory used by group.245 // Free the memory used by group.
261 g_object_unref(xpad_app_get_pad_group());246 g_object_unref (xpad_app_get_pad_group());
262247
263 // Free the memory used by the settings menu.248 // Free the memory used by the settings menu.
264 g_object_unref(XPAD_SETTINGS(xpad_settings()));249 g_object_unref (xpad_global_settings);
250 xpad_global_settings = NULL; // This is needed due to the asynchronous finalizing process.
265251
266 // Free the memory used by the tray icon and its menu.252 // Free the memory used by the tray icon and its menu.
267 xpad_tray_close();253 xpad_tray_close ();
254
255 // Free the theme reference. Unfortunately GTK3 leaves about 1000 objects behind.
256 g_object_unref (gtk_icon_theme_get_default ());
268257
269 // Give GTK the signal to clean the rest and quit the application.258 // Give GTK the signal to clean the rest and quit the application.
270 gtk_main_quit();259 gtk_main_quit ();
271}
272
273gboolean
274xpad_app_get_translucent (void)
275{
276 return xpad_translucent;
277}260}
278261
279static gboolean262static gboolean
@@ -361,19 +344,17 @@
361 * secondary text of 'secondary'. No buttons are added.344 * secondary text of 'secondary'. No buttons are added.
362 */345 */
363GtkWidget *346GtkWidget *
364xpad_app_alert_new (GtkWindow *parent, const gchar *stock,347xpad_app_alert_new (GtkWindow *parent, const gchar *stock, const gchar *primary, const gchar *secondary)
365 const gchar *primary, const gchar *secondary)
366{348{
367 GtkWidget *dialog, *hbox, *image, *label;349 GtkWidget *dialog, *hbox, *image, *label;
368 gchar *buf;350 gchar *buf;
369 351
370 dialog = gtk_dialog_new_with_buttons (352 dialog = gtk_dialog_new();
371 "",353 gtk_window_set_transient_for (GTK_WINDOW (dialog), parent);
372 parent,354 gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog), TRUE);
373 GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR,355 gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
374 NULL);356
375 357 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 12);
376 hbox = gtk_hbox_new (FALSE, 12);
377 image = gtk_image_new_from_stock (stock, GTK_ICON_SIZE_DIALOG);358 image = gtk_image_new_from_stock (stock, GTK_ICON_SIZE_DIALOG);
378 label = gtk_label_new (NULL);359 label = gtk_label_new (NULL);
379 360
@@ -385,14 +366,14 @@
385 gtk_label_set_markup (GTK_LABEL (label), buf);366 gtk_label_set_markup (GTK_LABEL (label), buf);
386 g_free (buf);367 g_free (buf);
387 368
388 gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), hbox);369 gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), 12);
370 gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), hbox);
389 gtk_container_add (GTK_CONTAINER (hbox), image);371 gtk_container_add (GTK_CONTAINER (hbox), image);
390 gtk_container_add (GTK_CONTAINER (hbox), label);372 gtk_container_add (GTK_CONTAINER (hbox), label);
391 373
392 gtk_misc_set_alignment (GTK_MISC (image), 0.5, 0);374 gtk_misc_set_alignment (GTK_MISC (image), 0.5, 0);
393 gtk_misc_set_alignment (GTK_MISC (label), 0.5, 0);375 gtk_misc_set_alignment (GTK_MISC (label), 0.5, 0);
394 gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);376 gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
395 gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 12);
396 gtk_container_set_border_width (GTK_CONTAINER (hbox), 6);377 gtk_container_set_border_width (GTK_CONTAINER (hbox), 6);
397 gtk_container_set_border_width (GTK_CONTAINER (dialog), 6);378 gtk_container_set_border_width (GTK_CONTAINER (dialog), 6);
398 gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);379 gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
@@ -529,16 +510,27 @@
529converts main program arguments into one long string.510converts main program arguments into one long string.
530puts allocated string in dest, and returns size511puts allocated string in dest, and returns size
531*/512*/
532static gint513static guint
533args_to_string (int argc, char **argv, char **dest)514args_to_string (int argc, char **argv, char **dest)
534{515{
535 gint i;516 gint i = 0;
536 gint size = 0;517 guint size = 0;
537 gchar *p;518 gchar *p = NULL;
538 519 size_t string_length = 0;
539 for (i = 0; i < argc; i++)520
540 size += strlen (argv[i]) + 1;521
541 522 for (i = 0; i < argc; i++) {
523 string_length = strlen (argv[i]) + 1;
524
525 // safe cast
526 if( string_length <= UINT_MAX ) {
527 size += (guint) string_length;
528 }
529 else {
530 g_warning("casting the size of the arguments failed");
531 }
532 }
533
542 *dest = g_malloc (size);534 *dest = g_malloc (size);
543 535
544 p = *dest;536 p = *dest;
@@ -561,10 +553,10 @@
561/*553/*
562returns number of strings in newly allocated argv554returns number of strings in newly allocated argv
563*/555*/
564static gint556static guint
565string_to_args (const char *string, char ***argv)557string_to_args (const char *string, char ***argv)
566{558{
567 gint num, i;559 guint num, i;
568 const gchar *tmp;560 const gchar *tmp;
569 char **list;561 char **list;
570 562
@@ -582,8 +574,18 @@
582 /* string points to beginning of current arg */574 /* string points to beginning of current arg */
583 tmp = strchr (string, ' '); /* NULL or end of this arg */575 tmp = strchr (string, ' '); /* NULL or end of this arg */
584 576
585 if (tmp) len = tmp - string;577 if (tmp) {
586 else len = strlen (string);578 long int difference = tmp - string;
579 // safe cast from long int to size_t
580 if (difference >= 0)
581 len = (size_t) difference;
582 else {
583 g_warning("Error casting argument length. Arguments might not be processed correctly.");
584 len = 0;
585 }
586 }
587 else
588 len = strlen (string);
587 589
588 list[i] = g_malloc (len + 1);590 list[i] = g_malloc (len + 1);
589 strncpy (list[i], string, len);591 strncpy (list[i], string, len);
@@ -600,18 +602,18 @@
600 return num;602 return num;
601}603}
602604
603#include <errno.h>
604/* This reads a line from the proc file. This line will contain arguments to process. */605/* This reads a line from the proc file. This line will contain arguments to process. */
605static void606static void
606xpad_app_read_from_proc_file (void)607xpad_app_read_from_proc_file (void)
607{608{
608 gint client_fd, size;609 gint client_fd;
610 guint size = 0;
609 gint argc;611 gint argc;
610 gchar **argv;612 gchar **argv;
611 gchar *args;613 gchar *args;
612 struct sockaddr_un client;614 struct sockaddr_un client;
613 socklen_t client_len;615 socklen_t client_len;
614 size_t bytes;616 ssize_t bytes = -1;
615 617
616 /* accept waiting connection */618 /* accept waiting connection */
617 client_len = sizeof (client);619 client_len = sizeof (client);
@@ -619,10 +621,12 @@
619 if (client_fd == -1)621 if (client_fd == -1)
620 return;622 return;
621 623
622 /* get size of args */624 /* get size of args and verify for errors */
623 bytes = read (client_fd, &size, sizeof (size));625 bytes = read (client_fd, &size, sizeof (size));
624 if (bytes != sizeof(size))626 if (bytes == -1 || bytes != sizeof(size)) {
627 g_warning("Cannot read proc file correctly");
625 goto close_client_fd;628 goto close_client_fd;
629 }
626 630
627 /* alloc memory */631 /* alloc memory */
628 args = (gchar *) g_malloc (size);632 args = (gchar *) g_malloc (size);
@@ -634,7 +638,7 @@
634 if (bytes < size)638 if (bytes < size)
635 goto close_client_fd;639 goto close_client_fd;
636 640
637 argc = string_to_args (args, &argv);641 argc = (gint) string_to_args (args, &argv);
638 642
639 g_free (args);643 g_free (args);
640 644
@@ -645,7 +649,11 @@
645 {649 {
646 /* if there were no non-local arguments, insert --new as argument */650 /* if there were no non-local arguments, insert --new as argument */
647 gint c = 2;651 gint c = 2;
648 gchar **v = g_malloc (sizeof (gchar *) * c);652 gchar **v = NULL;
653 unsigned long int my_size = 0;
654 // safe cast
655 my_size = sizeof (gchar *) * (long unsigned) c;
656 v = g_malloc (my_size);
649 v[0] = PACKAGE;657 v[0] = PACKAGE;
650 v[1] = "--new";658 v[1] = "--new";
651 659
@@ -665,10 +673,15 @@
665 close (client_fd);673 close (client_fd);
666}674}
667675
668
669static gboolean676static gboolean
670can_read_from_server_fd (GIOChannel *source, GIOCondition condition, gpointer data)677can_read_from_server_fd (GIOChannel *source, GIOCondition condition, gpointer data)
671{678{
679 // A dirty way to silence the compiler for these unused variables.
680 // Feel free to implement these variables in the way they are ment to be used.
681 (void) source;
682 (void) condition;
683 (void) data;
684
672 xpad_app_read_from_proc_file ();685 xpad_app_read_from_proc_file ();
673 686
674 return TRUE;687 return TRUE;
@@ -712,8 +725,8 @@
712 fd_set fdset;725 fd_set fdset;
713 gchar buf [129];726 gchar buf [129];
714 gchar *args = NULL;727 gchar *args = NULL;
715 gint size;728 guint size;
716 gint bytesRead;729 ssize_t bytesRead;
717 gboolean connected = FALSE;730 gboolean connected = FALSE;
718 ssize_t error = NULL;731 ssize_t error = NULL;
719 732
720733
=== modified file 'src/xpad-app.h'
--- src/xpad-app.h 2013-10-09 14:46:10 +0000
+++ src/xpad-app.h 2013-11-01 20:03:38 +0000
@@ -21,6 +21,7 @@
2121
22#include <gtk/gtk.h>22#include <gtk/gtk.h>
23#include "xpad-pad-group.h"23#include "xpad-pad-group.h"
24#include "xpad-settings.h"
2425
25G_BEGIN_DECLS26G_BEGIN_DECLS
2627
@@ -30,6 +31,7 @@
30G_CONST_RETURN gchar *xpad_app_get_config_dir (void);31G_CONST_RETURN gchar *xpad_app_get_config_dir (void);
31G_CONST_RETURN gchar *xpad_app_get_program_path (void);32G_CONST_RETURN gchar *xpad_app_get_program_path (void);
32XpadPadGroup *xpad_app_get_pad_group (void);33XpadPadGroup *xpad_app_get_pad_group (void);
34XpadSettings *xpad_global_settings;
33gboolean xpad_app_get_translucent (void);35gboolean xpad_app_get_translucent (void);
34void xpad_app_quit (void);36void xpad_app_quit (void);
3537
3638
=== modified file 'src/xpad-grip-tool-item.c'
--- src/xpad-grip-tool-item.c 2013-10-18 18:31:20 +0000
+++ src/xpad-grip-tool-item.c 2013-11-01 20:03:38 +0000
@@ -16,6 +16,7 @@
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */17 */
1818
19#include "../config.h"
19#include "xpad-grip-tool-item.h"20#include "xpad-grip-tool-item.h"
2021
21struct XpadGripToolItemPrivate22struct XpadGripToolItemPrivate
@@ -28,7 +29,7 @@
28static void xpad_grip_tool_item_dispose (GObject *object);29static void xpad_grip_tool_item_dispose (GObject *object);
29static void xpad_grip_tool_item_finalize (GObject *object);30static void xpad_grip_tool_item_finalize (GObject *object);
3031
31static gboolean xpad_grip_tool_item_event_box_expose (GtkWidget *widget, GdkEventExpose *event);32static gboolean xpad_grip_tool_item_event_box_draw (GtkWidget *widget, cairo_t *cr);
32static void xpad_grip_tool_item_event_box_realize (GtkWidget *widget);33static void xpad_grip_tool_item_event_box_realize (GtkWidget *widget);
33static gboolean xpad_grip_tool_item_button_pressed_event (GtkWidget *widget, GdkEventButton *event);34static gboolean xpad_grip_tool_item_button_pressed_event (GtkWidget *widget, GdkEventButton *event);
3435
@@ -59,7 +60,7 @@
59 gtk_widget_add_events (grip->priv->drawbox, GDK_BUTTON_PRESS_MASK | GDK_EXPOSURE_MASK);60 gtk_widget_add_events (grip->priv->drawbox, GDK_BUTTON_PRESS_MASK | GDK_EXPOSURE_MASK);
60 g_signal_connect (grip->priv->drawbox, "button-press-event", G_CALLBACK (xpad_grip_tool_item_button_pressed_event), NULL);61 g_signal_connect (grip->priv->drawbox, "button-press-event", G_CALLBACK (xpad_grip_tool_item_button_pressed_event), NULL);
61 g_signal_connect (grip->priv->drawbox, "realize", G_CALLBACK (xpad_grip_tool_item_event_box_realize), NULL);62 g_signal_connect (grip->priv->drawbox, "realize", G_CALLBACK (xpad_grip_tool_item_event_box_realize), NULL);
62 g_signal_connect (grip->priv->drawbox, "expose-event", G_CALLBACK (xpad_grip_tool_item_event_box_expose), NULL);63 g_signal_connect (grip->priv->drawbox, "draw", G_CALLBACK (xpad_grip_tool_item_event_box_draw), NULL);
63 gtk_widget_set_size_request (grip->priv->drawbox, 18, 18);64 gtk_widget_set_size_request (grip->priv->drawbox, 18, 18);
64 65
65 right = gtk_widget_get_direction (grip->priv->drawbox) == GTK_TEXT_DIR_LTR;66 right = gtk_widget_get_direction (grip->priv->drawbox) == GTK_TEXT_DIR_LTR;
@@ -95,7 +96,7 @@
95 edge = GDK_WINDOW_EDGE_SOUTH_WEST;96 edge = GDK_WINDOW_EDGE_SOUTH_WEST;
96 97
97 gtk_window_begin_resize_drag (GTK_WINDOW (gtk_widget_get_toplevel (widget)),98 gtk_window_begin_resize_drag (GTK_WINDOW (gtk_widget_get_toplevel (widget)),
98 edge, event->button, event->x_root, event->y_root, event->time);99 edge, (gint) event->button, (gint) event->x_root, (gint) event->y_root, event->time);
99 100
100 return TRUE;101 return TRUE;
101 }102 }
@@ -116,30 +117,18 @@
116 cursor_type = GDK_BOTTOM_LEFT_CORNER;117 cursor_type = GDK_BOTTOM_LEFT_CORNER;
117 118
118 cursor = gdk_cursor_new_for_display (display, cursor_type);119 cursor = gdk_cursor_new_for_display (display, cursor_type);
119 gdk_window_set_cursor (widget->window, cursor);120 gdk_window_set_cursor (gtk_widget_get_window(widget), cursor);
120 gdk_cursor_unref (cursor);121 g_object_unref (cursor);
121}122}
122123
123static gboolean124static gboolean
124xpad_grip_tool_item_event_box_expose (GtkWidget *widget, GdkEventExpose *event)125xpad_grip_tool_item_event_box_draw (GtkWidget *widget, cairo_t *cr)
125{126{
126 GdkWindowEdge edge;127 gtk_render_handle(gtk_widget_get_style_context(widget),
127 128 cr,
128 if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR)129 0, 0,
129 edge = GDK_WINDOW_EDGE_SOUTH_EAST;130 gtk_widget_get_allocated_width(widget),
130 else131 gtk_widget_get_allocated_width(widget));
131 edge = GDK_WINDOW_EDGE_SOUTH_WEST;
132
133 gtk_paint_resize_grip (
134 widget->style,
135 widget->window,
136 GTK_WIDGET_STATE (widget),
137 NULL,
138 widget,
139 "xpad-grip-tool-item",
140 edge,
141 0, 0,
142 widget->allocation.width, widget->allocation.height);
143 132
144 return FALSE;133 return FALSE;
145}134}
146135
=== modified file 'src/xpad-pad-group.c'
--- src/xpad-pad-group.c 2013-10-18 18:31:20 +0000
+++ src/xpad-pad-group.c 2013-11-01 20:03:38 +0000
@@ -17,6 +17,7 @@
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */18 */
1919
20#include "../config.h"
20#include "xpad-pad-group.h"21#include "xpad-pad-group.h"
21#include "xpad-settings.h"22#include "xpad-settings.h"
22#include "xpad-pad.h"23#include "xpad-pad.h"
@@ -165,7 +166,7 @@
165 GSList *i;166 GSList *i;
166 for (i = group->priv->pads; i; i = i->next)167 for (i = group->priv->pads; i; i = i->next)
167 {168 {
168 if (GTK_WIDGET_VISIBLE(GTK_WIDGET(i->data)))169 if (gtk_widget_get_visible(GTK_WIDGET(i->data)))
169 num ++;170 num ++;
170 }171 }
171 g_slist_free(i);172 g_slist_free(i);
172173
=== modified file 'src/xpad-pad-properties.c'
--- src/xpad-pad-properties.c 2013-10-21 02:51:19 +0000
+++ src/xpad-pad-properties.c 2013-11-01 20:03:38 +0000
@@ -29,10 +29,10 @@
29 GtkWidget *colorbox;29 GtkWidget *colorbox;
30 30
31 GtkWidget *textbutton;31 GtkWidget *textbutton;
32 GdkColor texttmp;32 GdkRGBA texttmp;
33 33
34 GtkWidget *backbutton;34 GtkWidget *backbutton;
35 GdkColor backtmp;35 GdkRGBA backtmp;
36 36
37 GtkWidget *fontbutton;37 GtkWidget *fontbutton;
38};38};
@@ -100,7 +100,7 @@
100 g_param_spec_boxed ("text-color",100 g_param_spec_boxed ("text-color",
101 "Text Color",101 "Text Color",
102 "The color of text in the pad",102 "The color of text in the pad",
103 GDK_TYPE_COLOR,103 GDK_TYPE_RGBA,
104 G_PARAM_READWRITE));104 G_PARAM_READWRITE));
105 105
106 g_object_class_install_property (gobject_class,106 g_object_class_install_property (gobject_class,
@@ -108,7 +108,7 @@
108 g_param_spec_boxed ("back-color",108 g_param_spec_boxed ("back-color",
109 "Back Color",109 "Back Color",
110 "The color of the background in the pad",110 "The color of the background in the pad",
111 GDK_TYPE_COLOR,111 GDK_TYPE_RGBA,
112 G_PARAM_READWRITE));112 G_PARAM_READWRITE));
113 113
114 g_object_class_install_property (gobject_class,114 g_object_class_install_property (gobject_class,
@@ -123,7 +123,7 @@
123static void123static void
124xpad_pad_properties_init (XpadPadProperties *prop)124xpad_pad_properties_init (XpadPadProperties *prop)
125{125{
126 GtkWidget *font_radio, *color_radio, *hbox, *font_hbox, *vbox;126 GtkWidget *font_radio, *color_radio, *hbox, *font_hbox, *vbox = NULL;
127 GtkWidget *label, *appearance_frame, *alignment, *appearance_vbox;127 GtkWidget *label, *appearance_frame, *alignment, *appearance_vbox;
128 gchar *text;128 gchar *text;
129 GtkSizeGroup *size_group_labels = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);129 GtkSizeGroup *size_group_labels = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
@@ -137,10 +137,10 @@
137 "xalign", 0.0,137 "xalign", 0.0,
138 NULL));138 NULL));
139 g_free (text);139 g_free (text);
140 appearance_vbox = GTK_WIDGET (g_object_new (GTK_TYPE_VBOX,140
141 "homogeneous", FALSE,141 appearance_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 18);
142 "spacing", 18,142 gtk_box_set_homogeneous (GTK_BOX (appearance_vbox), FALSE);
143 NULL));143
144 alignment = gtk_alignment_new (1, 1, 1, 1);144 alignment = gtk_alignment_new (1, 1, 1, 1);
145 g_object_set (G_OBJECT (alignment),145 g_object_set (G_OBJECT (alignment),
146 "left-padding", 12,146 "left-padding", 12,
@@ -163,12 +163,14 @@
163 color_radio = gtk_radio_button_new_with_mnemonic (NULL, _("Use colors from xpad preferences"));163 color_radio = gtk_radio_button_new_with_mnemonic (NULL, _("Use colors from xpad preferences"));
164 prop->priv->colorcheck = gtk_radio_button_new_with_mnemonic_from_widget (GTK_RADIO_BUTTON (color_radio), _("Use these colors:"));164 prop->priv->colorcheck = gtk_radio_button_new_with_mnemonic_from_widget (GTK_RADIO_BUTTON (color_radio), _("Use these colors:"));
165 165
166 font_hbox = gtk_hbox_new (FALSE, 6);166 font_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
167
167 gtk_box_pack_start (GTK_BOX (font_hbox), prop->priv->fontcheck, FALSE, FALSE, 0);168 gtk_box_pack_start (GTK_BOX (font_hbox), prop->priv->fontcheck, FALSE, FALSE, 0);
168 gtk_box_pack_start (GTK_BOX (font_hbox), prop->priv->fontbutton, TRUE, TRUE, 0);169 gtk_box_pack_start (GTK_BOX (font_hbox), prop->priv->fontbutton, TRUE, TRUE, 0);
169 170
170 prop->priv->colorbox = gtk_vbox_new (FALSE, 6);171 prop->priv->colorbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
171 hbox = gtk_hbox_new (FALSE, 12);172 hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
173
172 label = gtk_label_new_with_mnemonic (_("Background:"));174 label = gtk_label_new_with_mnemonic (_("Background:"));
173 gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);175 gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
174 gtk_size_group_add_widget (size_group_labels, label);176 gtk_size_group_add_widget (size_group_labels, label);
@@ -176,7 +178,7 @@
176 gtk_box_pack_start (GTK_BOX (hbox), prop->priv->backbutton, TRUE, TRUE, 0);178 gtk_box_pack_start (GTK_BOX (hbox), prop->priv->backbutton, TRUE, TRUE, 0);
177 g_object_set (G_OBJECT (prop->priv->colorbox), "child", hbox, NULL);179 g_object_set (G_OBJECT (prop->priv->colorbox), "child", hbox, NULL);
178 180
179 hbox = gtk_hbox_new (FALSE, 12);181 hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
180 label = gtk_label_new_with_mnemonic (_("Foreground:"));182 label = gtk_label_new_with_mnemonic (_("Foreground:"));
181 gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);183 gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
182 gtk_size_group_add_widget (size_group_labels, label);184 gtk_size_group_add_widget (size_group_labels, label);
@@ -188,25 +190,26 @@
188 gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 0, 0, 12, 0);190 gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 0, 0, 12, 0);
189 gtk_container_add (GTK_CONTAINER (alignment), prop->priv->colorbox);191 gtk_container_add (GTK_CONTAINER (alignment), prop->priv->colorbox);
190 192
191
192 gtk_dialog_add_button (GTK_DIALOG (prop), "gtk-close", GTK_RESPONSE_CLOSE);193 gtk_dialog_add_button (GTK_DIALOG (prop), "gtk-close", GTK_RESPONSE_CLOSE);
193 gtk_dialog_set_default_response (GTK_DIALOG (prop), GTK_RESPONSE_CLOSE);194 gtk_dialog_set_default_response (GTK_DIALOG (prop), GTK_RESPONSE_CLOSE);
194 gtk_dialog_set_has_separator (GTK_DIALOG (prop), FALSE);
195 g_signal_connect (prop, "response", G_CALLBACK (xpad_pad_properties_response), NULL);195 g_signal_connect (prop, "response", G_CALLBACK (xpad_pad_properties_response), NULL);
196 196
197 gtk_color_button_set_use_alpha (GTK_COLOR_BUTTON (prop->priv->textbutton), FALSE);197 gtk_color_chooser_set_use_alpha (GTK_COLOR_CHOOSER (prop->priv->textbutton), FALSE);
198 gtk_color_button_set_use_alpha (GTK_COLOR_BUTTON (prop->priv->backbutton), FALSE);198 gtk_color_chooser_set_use_alpha (GTK_COLOR_CHOOSER (prop->priv->backbutton), TRUE);
199 199
200 gtk_color_button_set_title (GTK_COLOR_BUTTON (prop->priv->textbutton), _("Set Foreground Color"));200 gtk_color_button_set_title (GTK_COLOR_BUTTON (prop->priv->textbutton), _("Set Foreground Color"));
201 gtk_color_button_set_title (GTK_COLOR_BUTTON (prop->priv->backbutton), _("Set Background Color"));201 gtk_color_button_set_title (GTK_COLOR_BUTTON (prop->priv->backbutton), _("Set Background Color"));
202 gtk_font_button_set_title (GTK_FONT_BUTTON (prop->priv->fontbutton), _("Set Font"));202 gtk_font_button_set_title (GTK_FONT_BUTTON (prop->priv->fontbutton), _("Set Font"));
203 203
204 vbox = gtk_vbox_new (FALSE, 6);204 vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
205 hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
206
205 gtk_box_pack_start (GTK_BOX (vbox), font_radio, FALSE, FALSE, 0);207 gtk_box_pack_start (GTK_BOX (vbox), font_radio, FALSE, FALSE, 0);
206 gtk_box_pack_start (GTK_BOX (vbox), font_hbox, FALSE, FALSE, 0);208 gtk_box_pack_start (GTK_BOX (vbox), font_hbox, FALSE, FALSE, 0);
207 gtk_box_pack_start (GTK_BOX (appearance_vbox), vbox, FALSE, FALSE, 0);209 gtk_box_pack_start (GTK_BOX (appearance_vbox), vbox, FALSE, FALSE, 0);
208 210
209 vbox = gtk_vbox_new (FALSE, 6);211 vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
212
210 gtk_box_pack_start (GTK_BOX (vbox), color_radio, FALSE, FALSE, 0);213 gtk_box_pack_start (GTK_BOX (vbox), color_radio, FALSE, FALSE, 0);
211 gtk_box_pack_start (GTK_BOX (vbox), prop->priv->colorcheck, FALSE, FALSE, 0);214 gtk_box_pack_start (GTK_BOX (vbox), prop->priv->colorcheck, FALSE, FALSE, 0);
212 gtk_box_pack_start (GTK_BOX (vbox), alignment, FALSE, FALSE, 0);215 gtk_box_pack_start (GTK_BOX (vbox), alignment, FALSE, FALSE, 0);
@@ -227,10 +230,9 @@
227 230
228 g_object_unref (size_group_labels);231 g_object_unref (size_group_labels);
229 232
230 g_object_set (G_OBJECT (GTK_DIALOG (prop)->vbox),233 gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (prop))), appearance_frame);
231 "child", appearance_frame,234
232 NULL);235 gtk_widget_show_all (gtk_dialog_get_content_area (GTK_DIALOG (prop)));
233 gtk_widget_show_all (GTK_DIALOG (prop)->vbox);
234}236}
235237
236static void238static void
@@ -271,18 +273,30 @@
271static void273static void
272change_text_color (GtkColorButton *button, XpadPadProperties *prop)274change_text_color (GtkColorButton *button, XpadPadProperties *prop)
273{275{
276 // A dirty way to silence the compiler for these unused variables.
277 // Feel free to implement these variables in the way they are ment to be used.
278 (void) button;
279
274 g_object_notify (G_OBJECT (prop), "text-color");280 g_object_notify (G_OBJECT (prop), "text-color");
275}281}
276282
277static void283static void
278change_back_color (GtkColorButton *button, XpadPadProperties *prop)284change_back_color (GtkColorButton *button, XpadPadProperties *prop)
279{285{
286 // A dirty way to silence the compiler for these unused variables.
287 // Feel free to implement these variables in the way they are ment to be used.
288 (void) button;
289
280 g_object_notify (G_OBJECT (prop), "back-color");290 g_object_notify (G_OBJECT (prop), "back-color");
281}291}
282292
283static void293static void
284change_font_face (GtkFontButton *button, XpadPadProperties *prop)294change_font_face (GtkFontButton *button, XpadPadProperties *prop)
285{295{
296 // A dirty way to silence the compiler for these unused variables.
297 // Feel free to implement these variables in the way they are ment to be used.
298 (void) button;
299
286 g_object_notify (G_OBJECT (prop), "fontname");300 g_object_notify (G_OBJECT (prop), "fontname");
287}301}
288302
@@ -290,7 +304,6 @@
290xpad_pad_properties_set_follow_font_style (XpadPadProperties *prop, gboolean follow)304xpad_pad_properties_set_follow_font_style (XpadPadProperties *prop, gboolean follow)
291{305{
292 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (prop->priv->fontcheck), !follow);306 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (prop->priv->fontcheck), !follow);
293
294 g_object_notify (G_OBJECT (prop), "follow_font_style");307 g_object_notify (G_OBJECT (prop), "follow_font_style");
295}308}
296309
@@ -304,7 +317,6 @@
304xpad_pad_properties_set_follow_color_style (XpadPadProperties *prop, gboolean follow)317xpad_pad_properties_set_follow_color_style (XpadPadProperties *prop, gboolean follow)
305{318{
306 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (prop->priv->colorcheck), !follow);319 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (prop->priv->colorcheck), !follow);
307
308 g_object_notify (G_OBJECT (prop), "follow_color_style");320 g_object_notify (G_OBJECT (prop), "follow_color_style");
309}321}
310322
@@ -315,32 +327,30 @@
315}327}
316328
317void329void
318xpad_pad_properties_set_back_color (XpadPadProperties *prop, const GdkColor *back)330xpad_pad_properties_set_back_color (XpadPadProperties *prop, const GdkRGBA *back)
319{331{
320 gtk_color_button_set_color (GTK_COLOR_BUTTON (prop->priv->backbutton), back);332 gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (prop->priv->backbutton), back);
321
322 g_object_notify (G_OBJECT (prop), "back_color");333 g_object_notify (G_OBJECT (prop), "back_color");
323}334}
324335
325G_CONST_RETURN GdkColor *336G_CONST_RETURN GdkRGBA *
326xpad_pad_properties_get_back_color (XpadPadProperties *prop)337xpad_pad_properties_get_back_color (XpadPadProperties *prop)
327{338{
328 gtk_color_button_get_color (GTK_COLOR_BUTTON (prop->priv->backbutton), &prop->priv->backtmp);339 gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (prop->priv->backbutton), &prop->priv->backtmp);
329 return &prop->priv->backtmp;340 return &prop->priv->backtmp;
330}341}
331342
332void343void
333xpad_pad_properties_set_text_color (XpadPadProperties *prop, const GdkColor *text)344xpad_pad_properties_set_text_color (XpadPadProperties *prop, const GdkRGBA *text)
334{345{
335 gtk_color_button_set_color (GTK_COLOR_BUTTON (prop->priv->textbutton), text);346 gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (prop->priv->textbutton), text);
336
337 g_object_notify (G_OBJECT (prop), "text_color");347 g_object_notify (G_OBJECT (prop), "text_color");
338}348}
339349
340G_CONST_RETURN GdkColor *350G_CONST_RETURN GdkRGBA *
341xpad_pad_properties_get_text_color (XpadPadProperties *prop)351xpad_pad_properties_get_text_color (XpadPadProperties *prop)
342{352{
343 gtk_color_button_get_color (GTK_COLOR_BUTTON (prop->priv->textbutton), &prop->priv->texttmp);353 gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (prop->priv->textbutton), &prop->priv->texttmp);
344 return &prop->priv->texttmp;354 return &prop->priv->texttmp;
345}355}
346356
@@ -348,7 +358,6 @@
348xpad_pad_properties_set_fontname (XpadPadProperties *prop, const gchar *fontname)358xpad_pad_properties_set_fontname (XpadPadProperties *prop, const gchar *fontname)
349{359{
350 gtk_font_button_set_font_name (GTK_FONT_BUTTON (prop->priv->fontbutton), fontname);360 gtk_font_button_set_font_name (GTK_FONT_BUTTON (prop->priv->fontbutton), fontname);
351
352 g_object_notify (G_OBJECT (prop), "fontname");361 g_object_notify (G_OBJECT (prop), "fontname");
353}362}
354363
355364
=== modified file 'src/xpad-pad-properties.h'
--- src/xpad-pad-properties.h 2008-09-21 00:03:40 +0000
+++ src/xpad-pad-properties.h 2013-11-01 20:03:38 +0000
@@ -58,11 +58,11 @@
58void xpad_pad_properties_set_follow_color_style (XpadPadProperties *pad_properties, gboolean follow);58void xpad_pad_properties_set_follow_color_style (XpadPadProperties *pad_properties, gboolean follow);
59gboolean xpad_pad_properties_get_follow_color_style (XpadPadProperties *pad_properties);59gboolean xpad_pad_properties_get_follow_color_style (XpadPadProperties *pad_properties);
6060
61void xpad_pad_properties_set_back_color (XpadPadProperties *pad_properties, const GdkColor *back);61void xpad_pad_properties_set_back_color (XpadPadProperties *pad_properties, const GdkRGBA *back);
62G_CONST_RETURN GdkColor *xpad_pad_properties_get_back_color (XpadPadProperties *pad_properties);62G_CONST_RETURN GdkRGBA *xpad_pad_properties_get_back_color (XpadPadProperties *pad_properties);
6363
64void xpad_pad_properties_set_text_color (XpadPadProperties *pad_properties, const GdkColor *text);64void xpad_pad_properties_set_text_color (XpadPadProperties *pad_properties, const GdkRGBA *text);
65G_CONST_RETURN GdkColor *xpad_pad_properties_get_text_color (XpadPadProperties *pad_properties);65G_CONST_RETURN GdkRGBA *xpad_pad_properties_get_text_color (XpadPadProperties *pad_properties);
6666
67void xpad_pad_properties_set_fontname (XpadPadProperties *pad_properties, const gchar *fontname);67void xpad_pad_properties_set_fontname (XpadPadProperties *pad_properties, const gchar *fontname);
68G_CONST_RETURN gchar *xpad_pad_properties_get_fontname (XpadPadProperties *pad_properties);68G_CONST_RETURN gchar *xpad_pad_properties_get_fontname (XpadPadProperties *pad_properties);
6969
=== modified file 'src/xpad-pad.c'
--- src/xpad-pad.c 2013-10-23 18:30:54 +0000
+++ src/xpad-pad.c 2013-11-01 20:03:38 +0000
@@ -123,8 +123,8 @@
123static void xpad_pad_paste (XpadPad *pad);123static void xpad_pad_paste (XpadPad *pad);
124static void xpad_pad_delete (XpadPad *pad);124static void xpad_pad_delete (XpadPad *pad);
125static void xpad_pad_open_properties (XpadPad *pad);125static void xpad_pad_open_properties (XpadPad *pad);
126static void xpad_pad_open_preferences (XpadPad *pad);126static void xpad_pad_open_preferences ();
127static void xpad_pad_quit (XpadPad *pad);127static void xpad_pad_quit ();
128static void xpad_pad_close_all (XpadPad *pad);128static void xpad_pad_close_all (XpadPad *pad);
129static void xpad_pad_sync_title (XpadPad *pad);129static void xpad_pad_sync_title (XpadPad *pad);
130static void xpad_pad_set_group (XpadPad *pad, XpadPadGroup *group);130static void xpad_pad_set_group (XpadPad *pad, XpadPadGroup *group);
@@ -237,11 +237,11 @@
237 pad->priv->x = 0;237 pad->priv->x = 0;
238 pad->priv->y = 0;238 pad->priv->y = 0;
239 pad->priv->location_valid = FALSE;239 pad->priv->location_valid = FALSE;
240 pad->priv->width = xpad_settings_get_width (xpad_settings ());240 pad->priv->width = xpad_settings_get_width (xpad_global_settings);
241 pad->priv->height = xpad_settings_get_height (xpad_settings ());241 pad->priv->height = xpad_settings_get_height (xpad_global_settings);
242 pad->priv->infoname = NULL;242 pad->priv->infoname = NULL;
243 pad->priv->contentname = NULL;243 pad->priv->contentname = NULL;
244 pad->priv->sticky = xpad_settings_get_sticky (xpad_settings ());244 pad->priv->sticky = xpad_settings_get_sticky (xpad_global_settings);
245 pad->priv->textview = NULL;245 pad->priv->textview = NULL;
246 pad->priv->scrollbar = NULL;246 pad->priv->scrollbar = NULL;
247 pad->priv->toolbar = NULL;247 pad->priv->toolbar = NULL;
@@ -254,11 +254,7 @@
254 pad->priv->unsaved_info = FALSE;254 pad->priv->unsaved_info = FALSE;
255 pad->priv->group = NULL;255 pad->priv->group = NULL;
256256
257 XpadTextView *text_view = g_object_new (XPAD_TYPE_TEXT_VIEW,257 XpadTextView *text_view = XPAD_TEXT_VIEW (xpad_text_view_new ());
258 "follow-font-style", TRUE,
259 "follow-color-style", TRUE,
260 NULL);
261
262 xpad_text_view_set_pad (text_view, pad);258 xpad_text_view_set_pad (text_view, pad);
263259
264 pad->priv->textview = GTK_WIDGET (text_view);260 pad->priv->textview = GTK_WIDGET (text_view);
@@ -276,25 +272,26 @@
276272
277 accel_group = gtk_accel_group_new ();273 accel_group = gtk_accel_group_new ();
278 gtk_window_add_accel_group (GTK_WINDOW (pad), accel_group);274 gtk_window_add_accel_group (GTK_WINDOW (pad), accel_group);
275
279 pad->priv->menu = menu_get_popup_no_highlight (pad, accel_group);276 pad->priv->menu = menu_get_popup_no_highlight (pad, accel_group);
280 pad->priv->highlight_menu = menu_get_popup_highlight (pad, accel_group);277 pad->priv->highlight_menu = menu_get_popup_highlight (pad, accel_group);
281 gtk_accel_group_connect (accel_group, GDK_Q, GDK_CONTROL_MASK, 0,278
282 g_cclosure_new_swap (G_CALLBACK (xpad_pad_quit), pad, NULL));279 gtk_accel_group_connect (accel_group, GDK_KEY_Q, GDK_CONTROL_MASK, 0,
280 g_cclosure_new_swap (G_CALLBACK (xpad_app_quit), pad, NULL));
283 g_object_unref (G_OBJECT (accel_group));281 g_object_unref (G_OBJECT (accel_group));
284282
285 vbox = GTK_WIDGET (g_object_new (GTK_TYPE_VBOX,283 vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
286 "homogeneous", FALSE,284 gtk_box_set_homogeneous (GTK_BOX(vbox), FALSE);
287 "spacing", 0,285 gtk_box_pack_start (GTK_BOX(vbox), pad->priv->scrollbar, TRUE, TRUE, 0);
288 "child", pad->priv->scrollbar,286 gtk_box_pack_start (GTK_BOX(vbox), pad->priv->toolbar, FALSE, FALSE, 0);
289 "child", pad->priv->toolbar,287
290 NULL));
291 gtk_container_child_set (GTK_CONTAINER (vbox), pad->priv->toolbar, "expand", FALSE, NULL);288 gtk_container_child_set (GTK_CONTAINER (vbox), pad->priv->toolbar, "expand", FALSE, NULL);
292289
293 gtk_window_set_decorated (GTK_WINDOW(pad), xpad_settings_get_has_decorations (xpad_settings ()));290 gtk_window_set_decorated (GTK_WINDOW(pad), xpad_settings_get_has_decorations (xpad_global_settings));
294 gtk_window_set_default_size (GTK_WINDOW(pad), (gint) xpad_settings_get_width (xpad_settings ()), (gint) xpad_settings_get_height (xpad_settings ()));291 gtk_window_set_default_size (GTK_WINDOW(pad), (gint) xpad_settings_get_width (xpad_global_settings), (gint) xpad_settings_get_height (xpad_global_settings));
295 gtk_window_set_gravity (GTK_WINDOW(pad), GDK_GRAVITY_STATIC); /* static gravity makes saving pad x,y work */292 gtk_window_set_gravity (GTK_WINDOW(pad), GDK_GRAVITY_STATIC); // static gravity makes saving pad x,y work
296 gtk_window_set_skip_pager_hint (GTK_WINDOW(pad),xpad_settings_get_has_decorations (xpad_settings ()));293 gtk_window_set_skip_pager_hint (GTK_WINDOW(pad),xpad_settings_get_has_decorations (xpad_global_settings));
297 gtk_window_set_skip_taskbar_hint (GTK_WINDOW(pad), !xpad_settings_get_has_decorations (xpad_settings ()));294 gtk_window_set_skip_taskbar_hint (GTK_WINDOW(pad), !xpad_settings_get_has_decorations (xpad_global_settings));
298 gtk_window_set_type_hint (GTK_WINDOW(pad), GDK_WINDOW_TYPE_HINT_NORMAL);295 gtk_window_set_type_hint (GTK_WINDOW(pad), GDK_WINDOW_TYPE_HINT_NORMAL);
299 gtk_window_set_position (GTK_WINDOW(pad), GTK_WIN_POS_MOUSE);296 gtk_window_set_position (GTK_WINDOW(pad), GTK_WIN_POS_MOUSE);
300297
@@ -321,7 +318,7 @@
321 gtk_widget_hide (pad->priv->toolbar);318 gtk_widget_hide (pad->priv->toolbar);
322 xpad_pad_notify_has_toolbar (pad);319 xpad_pad_notify_has_toolbar (pad);
323320
324 /* Set up signals */321 // Set up signals
325 gtk_widget_add_events (GTK_WIDGET (pad), GDK_BUTTON_PRESS_MASK | GDK_PROPERTY_CHANGE_MASK);322 gtk_widget_add_events (GTK_WIDGET (pad), GDK_BUTTON_PRESS_MASK | GDK_PROPERTY_CHANGE_MASK);
326 gtk_widget_add_events (pad->priv->toolbar, GDK_ALL_EVENTS_MASK);323 gtk_widget_add_events (pad->priv->toolbar, GDK_ALL_EVENTS_MASK);
327 g_signal_connect (pad->priv->textview, "button-press-event", G_CALLBACK (xpad_pad_text_view_button_press_event), pad);324 g_signal_connect (pad->priv->textview, "button-press-event", G_CALLBACK (xpad_pad_text_view_button_press_event), pad);
@@ -337,10 +334,10 @@
337 g_signal_connect (pad, "enter-notify-event", G_CALLBACK (xpad_pad_enter_notify_event), NULL);334 g_signal_connect (pad, "enter-notify-event", G_CALLBACK (xpad_pad_enter_notify_event), NULL);
338 g_signal_connect (pad, "leave-notify-event", G_CALLBACK (xpad_pad_leave_notify_event), NULL);335 g_signal_connect (pad, "leave-notify-event", G_CALLBACK (xpad_pad_leave_notify_event), NULL);
339336
340 g_signal_connect_swapped (xpad_settings (), "notify::has-decorations", G_CALLBACK (xpad_pad_notify_has_decorations), pad);337 g_signal_connect_swapped (xpad_global_settings, "notify::has-decorations", G_CALLBACK (xpad_pad_notify_has_decorations), pad);
341 g_signal_connect_swapped (xpad_settings (), "notify::has-toolbar", G_CALLBACK (xpad_pad_notify_has_toolbar), pad);338 g_signal_connect_swapped (xpad_global_settings, "notify::has-toolbar", G_CALLBACK (xpad_pad_notify_has_toolbar), pad);
342 g_signal_connect_swapped (xpad_settings (), "notify::autohide-toolbar", G_CALLBACK (xpad_pad_notify_autohide_toolbar), pad);339 g_signal_connect_swapped (xpad_global_settings, "notify::autohide-toolbar", G_CALLBACK (xpad_pad_notify_autohide_toolbar), pad);
343 g_signal_connect_swapped (xpad_settings (), "notify::has-scrollbar", G_CALLBACK (xpad_pad_notify_has_scrollbar), pad);340 g_signal_connect_swapped (xpad_global_settings, "notify::has-scrollbar", G_CALLBACK (xpad_pad_notify_has_scrollbar), pad);
344 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);341 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);
345 g_signal_connect_swapped (pad->priv->clipboard, "owner-change", G_CALLBACK (xpad_pad_notify_clipboard_owner_changed), pad);342 g_signal_connect_swapped (pad->priv->clipboard, "owner-change", G_CALLBACK (xpad_pad_notify_clipboard_owner_changed), pad);
346343
@@ -365,25 +362,6 @@
365}362}
366363
367static void364static void
368xpad_pad_show (XpadPad *pad)
369{
370 /* Some wm's might not acknowledge our request for a specific
371 location before we are shown. What we do here is a little gimpy
372 and not very respectful of wms' sovereignty, but it has the effect
373 of making pads' locations very dependable. We just move the pad
374 again here after being shown. This may create a visual effect if
375 the wm did ignore us, but is better than being in the wrong
376 place, I guess. */
377 if (pad->priv->location_valid)
378 gtk_window_move (GTK_WINDOW (pad), pad->priv->x, pad->priv->y);
379
380 if (pad->priv->sticky)
381 gtk_window_stick (GTK_WINDOW (pad));
382 else
383 gtk_window_unstick (GTK_WINDOW (pad));
384}
385
386static void
387xpad_pad_dispose (GObject *object)365xpad_pad_dispose (GObject *object)
388{366{
389 XpadPad *pad = XPAD_PAD (object);367 XpadPad *pad = XPAD_PAD (object);
@@ -403,13 +381,18 @@
403 pad->priv->highlight_menu = NULL;381 pad->priv->highlight_menu = NULL;
404 }382 }
405383
384 // 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.
406 if (GTK_IS_CLIPBOARD(pad->priv->clipboard)) {385 if (GTK_IS_CLIPBOARD(pad->priv->clipboard)) {
407 // 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.
408 g_signal_handlers_disconnect_matched (pad->priv->clipboard, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, pad);386 g_signal_handlers_disconnect_matched (pad->priv->clipboard, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, pad);
409 }387 }
410388
389<<<<<<< TREE
411 if (XPAD_IS_TOOLBAR(pad->priv->toolbar)) {390 if (XPAD_IS_TOOLBAR(pad->priv->toolbar)) {
412 // 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.391 // 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.
392=======
393 // 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.
394 if (XPAD_IS_TOOLBAR(pad->priv->toolbar)) {
395>>>>>>> MERGE-SOURCE
413 g_signal_handlers_disconnect_matched (pad->priv->toolbar, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, pad);396 g_signal_handlers_disconnect_matched (pad->priv->toolbar, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, pad);
414 gtk_widget_destroy(pad->priv->toolbar);397 gtk_widget_destroy(pad->priv->toolbar);
415 pad->priv->toolbar = NULL;398 pad->priv->toolbar = NULL;
@@ -423,7 +406,8 @@
423{406{
424 XpadPad *pad = XPAD_PAD (object);407 XpadPad *pad = XPAD_PAD (object);
425408
426 g_signal_handlers_disconnect_matched (xpad_settings (), G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, pad);409 if (xpad_global_settings != NULL)
410 g_signal_handlers_disconnect_matched (xpad_global_settings, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, pad);
427411
428 g_free (pad->priv->infoname);412 g_free (pad->priv->infoname);
429 g_free (pad->priv->contentname);413 g_free (pad->priv->contentname);
@@ -432,9 +416,28 @@
432}416}
433417
434static void418static void
419xpad_pad_show (XpadPad *pad)
420{
421 /* Some wm's might not acknowledge our request for a specific
422 location before we are shown. What we do here is a little gimpy
423 and not very respectful of wms' sovereignty, but it has the effect
424 of making pads' locations very dependable. We just move the pad
425 again here after being shown. This may create a visual effect if
426 the wm did ignore us, but is better than being in the wrong
427 place, I guess. */
428 if (pad->priv->location_valid)
429 gtk_window_move (GTK_WINDOW (pad), pad->priv->x, pad->priv->y);
430
431 if (pad->priv->sticky)
432 gtk_window_stick (GTK_WINDOW (pad));
433 else
434 gtk_window_unstick (GTK_WINDOW (pad));
435}
436
437static void
435xpad_pad_notify_has_scrollbar (XpadPad *pad)438xpad_pad_notify_has_scrollbar (XpadPad *pad)
436{439{
437 if (xpad_settings_get_has_scrollbar (xpad_settings ()))440 if (xpad_settings_get_has_scrollbar (xpad_global_settings))
438 {441 {
439 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (pad->priv->scrollbar), 442 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (pad->priv->scrollbar),
440 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);443 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
@@ -458,7 +461,7 @@
458static void461static void
459xpad_pad_notify_has_decorations (XpadPad *pad)462xpad_pad_notify_has_decorations (XpadPad *pad)
460{463{
461 gboolean decorations = xpad_settings_get_has_decorations (xpad_settings ());464 gboolean decorations = xpad_settings_get_has_decorations (xpad_global_settings);
462 465
463 /**466 /**
464 * There are two modes of operation: a normal mode and a 'stealth' mode.467 * There are two modes of operation: a normal mode and a 'stealth' mode.
@@ -478,7 +481,7 @@
478static guint481static guint
479xpad_pad_text_and_toolbar_height (XpadPad *pad)482xpad_pad_text_and_toolbar_height (XpadPad *pad)
480{483{
481 GdkRectangle rec;484 cairo_rectangle_int_t rec;
482 gint textx, texty, x, y;485 gint textx, texty, x, y;
483 GtkTextIter iter;486 GtkTextIter iter;
484 487
@@ -503,22 +506,22 @@
503static void506static void
504xpad_pad_show_toolbar (XpadPad *pad)507xpad_pad_show_toolbar (XpadPad *pad)
505{508{
506 if (!GTK_WIDGET_VISIBLE (pad->priv->toolbar))509 if (!gtk_widget_get_visible (pad->priv->toolbar))
507 {510 {
508 GtkRequisition req;511 GtkRequisition req;
509 512
510 if (GTK_WIDGET (pad)->window)513 if (gtk_widget_get_window(GTK_WIDGET(pad)))
511 gdk_window_freeze_updates (GTK_WIDGET (pad)->window);514 gdk_window_freeze_updates (gtk_widget_get_window(GTK_WIDGET(pad)));
512 gtk_widget_show (pad->priv->toolbar);515 gtk_widget_show (pad->priv->toolbar);
513 if (!pad->priv->toolbar_height)516 if (!pad->priv->toolbar_height)
514 {517 {
515 gtk_widget_size_request (pad->priv->toolbar, &req);518 gtk_widget_get_preferred_size (pad->priv->toolbar, &req, NULL);
516 // safe cast from gint to guint519 // safe cast from gint to guint
517 if (req.height >= 0) {520 if (req.height >= 0) {
518 pad->priv->toolbar_height = (guint) req.height;521 pad->priv->toolbar_height = (guint) req.height;
519 }522 }
520 else {523 else {
521 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.");524 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.");
522 pad->priv->toolbar_height = 0;525 pad->priv->toolbar_height = 0;
523 }526 }
524 }527 }
@@ -535,18 +538,18 @@
535 538
536 pad->priv->toolbar_pad_resized = FALSE;539 pad->priv->toolbar_pad_resized = FALSE;
537 540
538 if (GTK_WIDGET (pad)->window)541 if (gtk_widget_get_window(GTK_WIDGET(pad)))
539 gdk_window_thaw_updates (GTK_WIDGET (pad)->window);542 gdk_window_thaw_updates (gtk_widget_get_window(GTK_WIDGET(pad)));
540 }543 }
541}544}
542545
543static void546static void
544xpad_pad_hide_toolbar (XpadPad *pad)547xpad_pad_hide_toolbar (XpadPad *pad)
545{548{
546 if (GTK_WIDGET_VISIBLE (pad->priv->toolbar))549 if (gtk_widget_get_visible (pad->priv->toolbar))
547 {550 {
548 if (GTK_WIDGET (pad)->window)551 if (gtk_widget_get_window(GTK_WIDGET(pad)))
549 gdk_window_freeze_updates (GTK_WIDGET (pad)->window);552 gdk_window_freeze_updates (gtk_widget_get_window(GTK_WIDGET(pad)));
550 gtk_widget_hide (pad->priv->toolbar);553 gtk_widget_hide (pad->priv->toolbar);
551 554
552 if (pad->priv->toolbar_expanded ||555 if (pad->priv->toolbar_expanded ||
@@ -556,17 +559,17 @@
556 gtk_window_resize (GTK_WINDOW (pad), (gint) pad->priv->width, (gint) pad->priv->height);559 gtk_window_resize (GTK_WINDOW (pad), (gint) pad->priv->width, (gint) pad->priv->height);
557 pad->priv->toolbar_expanded = FALSE;560 pad->priv->toolbar_expanded = FALSE;
558 }561 }
559 if (GTK_WIDGET (pad)->window)562 if (gtk_widget_get_window(GTK_WIDGET(pad)))
560 gdk_window_thaw_updates (GTK_WIDGET (pad)->window);563 gdk_window_thaw_updates (gtk_widget_get_window(GTK_WIDGET(pad)));
561 }564 }
562}565}
563566
564static void567static void
565xpad_pad_notify_has_toolbar (XpadPad *pad)568xpad_pad_notify_has_toolbar (XpadPad *pad)
566{569{
567 if (xpad_settings_get_has_toolbar (xpad_settings ()))570 if (xpad_settings_get_has_toolbar (xpad_global_settings))
568 {571 {
569 if (!xpad_settings_get_autohide_toolbar (xpad_settings ()))572 if (!xpad_settings_get_autohide_toolbar (xpad_global_settings))
570 xpad_pad_show_toolbar (pad);573 xpad_pad_show_toolbar (pad);
571 }574 }
572 else575 else
@@ -580,8 +583,8 @@
580 return FALSE;583 return FALSE;
581584
582 if (pad->priv->toolbar_timeout &&585 if (pad->priv->toolbar_timeout &&
583 xpad_settings_get_autohide_toolbar (xpad_settings ()) &&586 xpad_settings_get_autohide_toolbar (xpad_global_settings) &&
584 xpad_settings_get_has_toolbar (xpad_settings ()))587 xpad_settings_get_has_toolbar (xpad_global_settings))
585 xpad_pad_hide_toolbar (pad);588 xpad_pad_hide_toolbar (pad);
586 589
587 pad->priv->toolbar_timeout = 0;590 pad->priv->toolbar_timeout = 0;
@@ -592,7 +595,7 @@
592static void595static void
593xpad_pad_notify_autohide_toolbar (XpadPad *pad)596xpad_pad_notify_autohide_toolbar (XpadPad *pad)
594{597{
595 if (xpad_settings_get_autohide_toolbar (xpad_settings ()))598 if (xpad_settings_get_autohide_toolbar (xpad_global_settings))
596 {599 {
597 /* Likely not to be in pad when turning setting on */600 /* Likely not to be in pad when turning setting on */
598 if (!pad->priv->toolbar_timeout)601 if (!pad->priv->toolbar_timeout)
@@ -600,7 +603,7 @@
600 }603 }
601 else604 else
602 {605 {
603 if (xpad_settings_get_has_toolbar (xpad_settings ()))606 if (xpad_settings_get_has_toolbar (xpad_global_settings))
604 xpad_pad_show_toolbar(pad);607 xpad_pad_show_toolbar(pad);
605 }608 }
606}609}
@@ -613,9 +616,9 @@
613 GtkTextBuffer *buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (pad->priv->textview));616 GtkTextBuffer *buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (pad->priv->textview));
614 gboolean has_selection = gtk_text_buffer_get_has_selection (buffer);617 gboolean has_selection = gtk_text_buffer_get_has_selection (buffer);
615618
616 XpadToolbar *toolbar = NULL;619 XpadToolbar *toolbar = XPAD_TOOLBAR (pad->priv->toolbar);
617 toolbar = XPAD_TOOLBAR (pad->priv->toolbar);620 if (toolbar == NULL)
618 g_return_if_fail (toolbar);621 return;
619622
620 xpad_toolbar_enable_cut_button (toolbar, has_selection);623 xpad_toolbar_enable_cut_button (toolbar, has_selection);
621 xpad_toolbar_enable_copy_button (toolbar, has_selection);624 xpad_toolbar_enable_copy_button (toolbar, has_selection);
@@ -628,7 +631,7 @@
628631
629 XpadToolbar *toolbar = NULL;632 XpadToolbar *toolbar = NULL;
630 // safe cast to toolbar633 // safe cast to toolbar
631 if (XPAD_IS_TOOLBAR(pad->priv->toolbar)) {634 if (XPAD_IS_TOOLBAR (pad->priv->toolbar)) {
632 toolbar = XPAD_TOOLBAR (pad->priv->toolbar);635 toolbar = XPAD_TOOLBAR (pad->priv->toolbar);
633 g_return_if_fail (toolbar);636 g_return_if_fail (toolbar);
634637
@@ -660,8 +663,8 @@
660static gboolean663static gboolean
661xpad_pad_enter_notify_event (GtkWidget *pad, GdkEventCrossing *event)664xpad_pad_enter_notify_event (GtkWidget *pad, GdkEventCrossing *event)
662{665{
663 if (xpad_settings_get_has_toolbar (xpad_settings ()) &&666 if (xpad_settings_get_has_toolbar (xpad_global_settings) &&
664 xpad_settings_get_autohide_toolbar (xpad_settings ()) &&667 xpad_settings_get_autohide_toolbar (xpad_global_settings) &&
665 event->detail != GDK_NOTIFY_INFERIOR &&668 event->detail != GDK_NOTIFY_INFERIOR &&
666 event->mode == GDK_CROSSING_NORMAL)669 event->mode == GDK_CROSSING_NORMAL)
667 {670 {
@@ -675,8 +678,8 @@
675static gboolean678static gboolean
676xpad_pad_leave_notify_event (GtkWidget *pad, GdkEventCrossing *event)679xpad_pad_leave_notify_event (GtkWidget *pad, GdkEventCrossing *event)
677{680{
678 if (xpad_settings_get_has_toolbar (xpad_settings ()) &&681 if (xpad_settings_get_has_toolbar (xpad_global_settings) &&
679 xpad_settings_get_autohide_toolbar (xpad_settings ()) &&682 xpad_settings_get_autohide_toolbar (xpad_global_settings) &&
680 event->detail != GDK_NOTIFY_INFERIOR &&683 event->detail != GDK_NOTIFY_INFERIOR &&
681 event->mode == GDK_CROSSING_NORMAL)684 event->mode == GDK_CROSSING_NORMAL)
682 {685 {
@@ -727,7 +730,7 @@
727void730void
728xpad_pad_toggle(XpadPad *pad)731xpad_pad_toggle(XpadPad *pad)
729{732{
730 if (GTK_WIDGET_VISIBLE (pad)) 733 if (gtk_widget_get_visible (GTK_WIDGET(pad)))
731 xpad_pad_close (pad);734 xpad_pad_close (pad);
732 else735 else
733 gtk_widget_show (GTK_WIDGET (pad));736 gtk_widget_show (GTK_WIDGET (pad));
@@ -741,7 +744,7 @@
741 gchar *content;744 gchar *content;
742 gboolean confirm;745 gboolean confirm;
743 746
744 if (!xpad_settings_get_confirm_destroy (xpad_settings ()))747 if (!xpad_settings_get_confirm_destroy (xpad_global_settings))
745 return FALSE;748 return FALSE;
746 749
747 buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (pad->priv->textview));750 buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (pad->priv->textview));
@@ -832,7 +835,7 @@
832 PangoFontDescription *fontdesc;835 PangoFontDescription *fontdesc;
833 836
834 fontdesc = font ? pango_font_description_from_string (font) : NULL;837 fontdesc = font ? pango_font_description_from_string (font) : NULL;
835 gtk_widget_modify_font (pad->priv->textview, fontdesc);838 gtk_widget_override_font (pad->priv->textview, fontdesc);
836 if (fontdesc)839 if (fontdesc)
837 pango_font_description_free (fontdesc);840 pango_font_description_free (fontdesc);
838 }841 }
@@ -841,38 +844,41 @@
841}844}
842845
843static void846static void
844prop_notify_follow_color (XpadPad *pad)847prop_notify_colors (XpadPad *pad)
845{848{
846 XpadPadProperties *prop = XPAD_PAD_PROPERTIES (pad->priv->properties);849 XpadPadProperties *prop = XPAD_PAD_PROPERTIES (pad->priv->properties);
847 850
848 xpad_text_view_set_follow_color_style (XPAD_TEXT_VIEW (pad->priv->textview), xpad_pad_properties_get_follow_color_style (prop));851 xpad_text_view_set_follow_color_style (XPAD_TEXT_VIEW (pad->priv->textview), xpad_pad_properties_get_follow_color_style (prop));
849 852
850 if (!xpad_pad_properties_get_follow_color_style (prop))853 if (xpad_pad_properties_get_follow_color_style (prop))
851 {854 {
852 gtk_widget_modify_base (pad->priv->textview, GTK_STATE_NORMAL, xpad_pad_properties_get_back_color (prop));855 // Set the colors to the global preferences colors
853 gtk_widget_modify_text (pad->priv->textview, GTK_STATE_NORMAL, xpad_pad_properties_get_text_color (prop));856 const GdkRGBA *text_color = xpad_settings_get_text_color (xpad_global_settings);
854 }857 const GdkRGBA *back_color = xpad_settings_get_back_color (xpad_global_settings);
855 858
856 xpad_pad_save_info_delayed (pad);859 gtk_widget_override_cursor (pad->priv->textview, text_color, text_color);
857}860 gtk_widget_override_color (pad->priv->textview, GTK_STATE_FLAG_NORMAL, text_color);
858861 gtk_widget_override_background_color (pad->priv->textview, GTK_STATE_FLAG_NORMAL, back_color);
859static void862
860prop_notify_text (XpadPad *pad)863 // Inverse the text and background colors for selected text, so it is likely to be visible by any choice of the colors.
861{864 gtk_widget_override_color (pad->priv->textview, GTK_STATE_FLAG_SELECTED, back_color);
862 XpadPadProperties *prop = XPAD_PAD_PROPERTIES (pad->priv->properties);865 gtk_widget_override_background_color (pad->priv->textview, GTK_STATE_FLAG_SELECTED, text_color);
863 866 }
864 gtk_widget_modify_text (pad->priv->textview, GTK_STATE_NORMAL, xpad_pad_properties_get_text_color (prop));867 else
865 868 {
866 xpad_pad_save_info_delayed (pad);869 // Set the color to the individual pad properties colors
867}870 const GdkRGBA *text_color = xpad_pad_properties_get_text_color (prop);
868871 const GdkRGBA *back_color = xpad_pad_properties_get_back_color (prop);
869static void872
870prop_notify_back (XpadPad *pad)873 gtk_widget_override_cursor (pad->priv->textview, text_color, text_color);
871{874 gtk_widget_override_color (pad->priv->textview, GTK_STATE_FLAG_NORMAL, text_color);
872 XpadPadProperties *prop = XPAD_PAD_PROPERTIES (pad->priv->properties);875 gtk_widget_override_background_color (pad->priv->textview, GTK_STATE_FLAG_NORMAL, back_color);
873 876
874 gtk_widget_modify_base (pad->priv->textview, GTK_STATE_NORMAL, xpad_pad_properties_get_back_color (prop));877 // Inverse the text and background colors for selected text, so it is likely to be visible by any choice of the colors.
875 878 gtk_widget_override_color (pad->priv->textview, GTK_STATE_FLAG_SELECTED, back_color);
879 gtk_widget_override_background_color (pad->priv->textview, GTK_STATE_FLAG_SELECTED, text_color);
880 }
881
876 xpad_pad_save_info_delayed (pad);882 xpad_pad_save_info_delayed (pad);
877}883}
878884
@@ -885,7 +891,7 @@
885 PangoFontDescription *fontdesc;891 PangoFontDescription *fontdesc;
886 892
887 fontdesc = font ? pango_font_description_from_string (font) : NULL;893 fontdesc = font ? pango_font_description_from_string (font) : NULL;
888 gtk_widget_modify_font (pad->priv->textview, fontdesc);894 gtk_widget_override_font (pad->priv->textview, fontdesc);
889 if (fontdesc)895 if (fontdesc)
890 pango_font_description_free (fontdesc);896 pango_font_description_free (fontdesc);
891 897
@@ -895,8 +901,10 @@
895static void901static void
896xpad_pad_open_properties (XpadPad *pad)902xpad_pad_open_properties (XpadPad *pad)
897{903{
898 GtkStyle *style;904 GtkStyleContext *style = NULL;
899 gchar *fontname;905 PangoFontDescription *font;
906 GdkRGBA widget_text_color = {0, 0, 0, 0};
907 GdkRGBA widget_background_color = {0, 0, 0, 0};
900 908
901 if (pad->priv->properties)909 if (pad->priv->properties)
902 {910 {
@@ -911,22 +919,25 @@
911 919
912 g_signal_connect_swapped (pad->priv->properties, "destroy", G_CALLBACK (pad_properties_destroyed), pad);920 g_signal_connect_swapped (pad->priv->properties, "destroy", G_CALLBACK (pad_properties_destroyed), pad);
913 g_signal_connect (pad, "notify::title", G_CALLBACK (pad_properties_sync_title), NULL);921 g_signal_connect (pad, "notify::title", G_CALLBACK (pad_properties_sync_title), NULL);
914 922
915 style = gtk_widget_get_style (pad->priv->textview);923 style = gtk_widget_get_style_context (pad->priv->textview);
916 fontname = style->font_desc ? pango_font_description_to_string (style->font_desc) : NULL;924 gtk_style_context_get(style, GTK_STATE_FLAG_NORMAL, GTK_STYLE_PROPERTY_FONT, &font, NULL);
925 gtk_style_context_get_color (style, GTK_STATE_FLAG_NORMAL, &widget_text_color);
926 gtk_style_context_get_background_color (style, GTK_STATE_FLAG_NORMAL, &widget_background_color);
927
917 g_object_set (G_OBJECT (pad->priv->properties),928 g_object_set (G_OBJECT (pad->priv->properties),
918 "follow-font-style", xpad_text_view_get_follow_font_style (XPAD_TEXT_VIEW (pad->priv->textview)),929 "follow-font-style", xpad_text_view_get_follow_font_style (XPAD_TEXT_VIEW (pad->priv->textview)),
919 "follow-color-style", xpad_text_view_get_follow_color_style (XPAD_TEXT_VIEW (pad->priv->textview)),930 "follow-color-style", xpad_text_view_get_follow_color_style (XPAD_TEXT_VIEW (pad->priv->textview)),
920 "back-color", &style->base[GTK_STATE_NORMAL],931 "back-color", &widget_background_color,
921 "text-color", &style->text[GTK_STATE_NORMAL],932 "text-color", &widget_text_color,
922 "fontname", fontname,933 "fontname", pango_font_description_to_string(font),
923 NULL);934 NULL);
924 g_free (fontname);935 pango_font_description_free (font);
925 936
926 g_signal_connect_swapped (pad->priv->properties, "notify::follow-font-style", G_CALLBACK (prop_notify_follow_font), pad);937 g_signal_connect_swapped (pad->priv->properties, "notify::follow-font-style", G_CALLBACK (prop_notify_follow_font), pad);
927 g_signal_connect_swapped (pad->priv->properties, "notify::follow-color-style", G_CALLBACK (prop_notify_follow_color), pad);938 g_signal_connect_swapped (pad->priv->properties, "notify::follow-color-style", G_CALLBACK (prop_notify_colors), pad);
928 g_signal_connect_swapped (pad->priv->properties, "notify::text-color", G_CALLBACK (prop_notify_text), pad);939 g_signal_connect_swapped (pad->priv->properties, "notify::text-color", G_CALLBACK (prop_notify_colors), pad);
929 g_signal_connect_swapped (pad->priv->properties, "notify::back-color", G_CALLBACK (prop_notify_back), pad);940 g_signal_connect_swapped (pad->priv->properties, "notify::back-color", G_CALLBACK (prop_notify_colors), pad);
930 g_signal_connect_swapped (pad->priv->properties, "notify::fontname", G_CALLBACK (prop_notify_font), pad);941 g_signal_connect_swapped (pad->priv->properties, "notify::fontname", G_CALLBACK (prop_notify_font), pad);
931 942
932 pad_properties_sync_title (pad);943 pad_properties_sync_title (pad);
@@ -935,13 +946,13 @@
935}946}
936947
937static void948static void
938xpad_pad_open_preferences (XpadPad *pad)949xpad_pad_open_preferences ()
939{950{
940 xpad_preferences_open ();951 xpad_preferences_open ();
941}952}
942953
943static void954static void
944xpad_pad_quit (XpadPad *pad)955xpad_pad_quit ()
945{956{
946 xpad_app_quit ();957 xpad_app_quit ();
947}958}
@@ -949,6 +960,10 @@
949static void960static void
950xpad_pad_text_changed (XpadPad *pad, GtkTextBuffer *buffer)961xpad_pad_text_changed (XpadPad *pad, GtkTextBuffer *buffer)
951{962{
963 // A dirty way to silence the compiler for these unused variables.
964 // Feel free to implement these variables in the way they are ment to be used.
965 (void) buffer;
966
952 /* set title */967 /* set title */
953 xpad_pad_sync_title (pad);968 xpad_pad_sync_title (pad);
954 969
@@ -973,7 +988,7 @@
973static gboolean988static gboolean
974xpad_pad_configure_event (XpadPad *pad, GdkEventConfigure *event)989xpad_pad_configure_event (XpadPad *pad, GdkEventConfigure *event)
975{990{
976 if (!GTK_WIDGET_VISIBLE (pad))991 if (!gtk_widget_get_visible (GTK_WIDGET(pad)))
977 return FALSE;992 return FALSE;
978993
979 int eWidth = event->width;994 int eWidth = event->width;
@@ -1012,6 +1027,10 @@
1012static gboolean1027static gboolean
1013xpad_pad_delete_event (XpadPad *pad, GdkEvent *event)1028xpad_pad_delete_event (XpadPad *pad, GdkEvent *event)
1014{1029{
1030 // A dirty way to silence the compiler for these unused variables.
1031 // Feel free to implement these variables in the way they are ment to be used.
1032 (void) event;
1033
1015 xpad_pad_close (pad);1034 xpad_pad_close (pad);
1016 1035
1017 return TRUE;1036 return TRUE;
@@ -1028,6 +1047,10 @@
1028static gboolean1047static gboolean
1029xpad_pad_text_view_button_press_event (GtkWidget *text_view, GdkEventButton *event, XpadPad *pad)1048xpad_pad_text_view_button_press_event (GtkWidget *text_view, GdkEventButton *event, XpadPad *pad)
1030{1049{
1050 // A dirty way to silence the compiler for these unused variables.
1051 // Feel free to implement these variables in the way they are ment to be used.
1052 (void) text_view;
1053
1031 if (event->type == GDK_BUTTON_PRESS)1054 if (event->type == GDK_BUTTON_PRESS)
1032 {1055 {
1033 switch (event->button)1056 switch (event->button)
@@ -1236,7 +1259,10 @@
1236{1259{
1237 gboolean locked = FALSE, follow_font = TRUE, follow_color = TRUE;1260 gboolean locked = FALSE, follow_font = TRUE, follow_color = TRUE;
1238 gboolean hidden = FALSE;1261 gboolean hidden = FALSE;
1239 GdkColor text = {0}, back = {0};1262 gchar *text_color_string = NULL;
1263 gchar *background_color_string = NULL;
1264 GdkRGBA text = {0, 0, 0, 0};
1265 GdkRGBA back = {0, 0, 0, 0};
1240 gchar *fontname = NULL;1266 gchar *fontname = NULL;
12411267
1242 if (!pad->priv->infoname)1268 if (!pad->priv->infoname)
@@ -1252,12 +1278,8 @@
1252 "b|follow_color", &follow_color,1278 "b|follow_color", &follow_color,
1253 "b|sticky", &pad->priv->sticky,1279 "b|sticky", &pad->priv->sticky,
1254 "b|hidden", &hidden,1280 "b|hidden", &hidden,
1255 "h|back_red", &back.red,1281 "s|back", &background_color_string,
1256 "h|back_green", &back.green,1282 "s|text", &text_color_string,
1257 "h|back_blue", &back.blue,
1258 "h|text_red", &text.red,
1259 "h|text_green", &text.green,
1260 "h|text_blue", &text.blue,
1261 "s|fontname", &fontname,1283 "s|fontname", &fontname,
1262 "s|content", &pad->priv->contentname,1284 "s|content", &pad->priv->contentname,
1263 NULL))1285 NULL))
@@ -1266,8 +1288,8 @@
1266 pad->priv->unsaved_info = FALSE;1288 pad->priv->unsaved_info = FALSE;
1267 1289
1268 pad->priv->location_valid = TRUE;1290 pad->priv->location_valid = TRUE;
1269 if (xpad_settings_get_has_toolbar (xpad_settings ()) &&1291 if (xpad_settings_get_has_toolbar (xpad_global_settings) &&
1270 !xpad_settings_get_autohide_toolbar (xpad_settings ()))1292 !xpad_settings_get_autohide_toolbar (xpad_global_settings))
1271 {1293 {
1272 pad->priv->toolbar_height = 0;1294 pad->priv->toolbar_height = 0;
1273 xpad_pad_hide_toolbar (pad);1295 xpad_pad_hide_toolbar (pad);
@@ -1280,26 +1302,45 @@
1280 xpad_text_view_set_follow_font_style (XPAD_TEXT_VIEW (pad->priv->textview), follow_font);1302 xpad_text_view_set_follow_font_style (XPAD_TEXT_VIEW (pad->priv->textview), follow_font);
1281 xpad_text_view_set_follow_color_style (XPAD_TEXT_VIEW (pad->priv->textview), follow_color);1303 xpad_text_view_set_follow_color_style (XPAD_TEXT_VIEW (pad->priv->textview), follow_color);
1282 1304
1283 /* obsolete setting, no longer written as of xpad-2.0-b2 */
1284 if (locked)1305 if (locked)
1285 {1306 {
1286 xpad_text_view_set_follow_font_style (XPAD_TEXT_VIEW (pad->priv->textview), FALSE);1307 xpad_text_view_set_follow_font_style (XPAD_TEXT_VIEW (pad->priv->textview), FALSE);
1287 xpad_text_view_set_follow_color_style (XPAD_TEXT_VIEW (pad->priv->textview), FALSE);1308 xpad_text_view_set_follow_color_style (XPAD_TEXT_VIEW (pad->priv->textview), FALSE);
1288 }1309 }
1289 1310
1290 if (!xpad_text_view_get_follow_color_style (XPAD_TEXT_VIEW (pad->priv->textview)))1311 if (!follow_font)
1291 {
1292 gtk_widget_modify_text (pad->priv->textview, GTK_STATE_NORMAL, &text);
1293 gtk_widget_modify_base (pad->priv->textview, GTK_STATE_NORMAL, &back);
1294 }
1295
1296 if (!xpad_text_view_get_follow_font_style (XPAD_TEXT_VIEW (pad->priv->textview)))
1297 {1312 {
1298 PangoFontDescription *font_desc = pango_font_description_from_string (fontname);1313 PangoFontDescription *font_desc = pango_font_description_from_string (fontname);
1299 gtk_widget_modify_font (pad->priv->textview, font_desc);1314 gtk_widget_override_font (pad->priv->textview, font_desc);
1300 pango_font_description_free (font_desc);1315 pango_font_description_free (font_desc);
1301 }1316 }
13021317
1318 if (!follow_color)
1319 {
1320 // If, for some reason, one of the colors could not be retrieved
1321 // (for example due to the migration to the new GdkRGBA colors), set the color to the default.
1322 if (text_color_string == NULL || background_color_string == NULL) {
1323 text = (GdkRGBA) {0, 0, 0, 1};
1324 back = (GdkRGBA) {1, 0.933334350586, 0.6, 1};
1325 }
1326 else {
1327 // If, for some reason, the parsing of the colors fail, set the color to the default.
1328 if (!gdk_rgba_parse (&text, text_color_string) || !gdk_rgba_parse (&back, background_color_string)) {
1329 text = (GdkRGBA) {0, 0, 0, 1};
1330 back = (GdkRGBA) {1, 0.933334350586, 0.6, 1};
1331 }
1332 }
1333
1334 // Set the text and background color for this pad, as stated in its properties file.
1335 gtk_widget_override_cursor (pad->priv->textview, &text, &text);
1336 gtk_widget_override_color (pad->priv->textview, GTK_STATE_FLAG_NORMAL, &text);
1337 gtk_widget_override_background_color (pad->priv->textview, GTK_STATE_FLAG_NORMAL, &back);
1338
1339 // Inverse the text and background colors for selected text, so it is likely to be visible by any choice of the colors.
1340 gtk_widget_override_color (pad->priv->textview, GTK_STATE_FLAG_SELECTED, &back);
1341 gtk_widget_override_background_color (pad->priv->textview, GTK_STATE_FLAG_SELECTED, &text);
1342 }
1343
1303 /* Find the sticky notes menu setting for this pad (which is on the global default),1344 /* Find the sticky notes menu setting for this pad (which is on the global default),
1304 * and change its setting to the setting from the info file (pad specific default).1345 * and change its setting to the setting from the info file (pad specific default).
1305 */1346 */
@@ -1346,8 +1387,10 @@
1346xpad_pad_save_info (XpadPad *pad)1387xpad_pad_save_info (XpadPad *pad)
1347{1388{
1348 guint height = NULL;1389 guint height = NULL;
1349 GtkStyle *style = NULL;1390 GtkStyleContext *style = NULL;
1350 gchar *fontname = NULL;1391 PangoFontDescription *font = NULL;
1392 GdkRGBA widget_text_color = {0, 0, 0, 0};
1393 GdkRGBA widget_background_color = {0, 0, 0, 0};
13511394
1352 g_return_if_fail (pad);1395 g_return_if_fail (pad);
13531396
@@ -1371,12 +1414,14 @@
1371 }1414 }
1372 1415
1373 height = pad->priv->height;1416 height = pad->priv->height;
1374 if (GTK_WIDGET_VISIBLE (pad->priv->toolbar) && pad->priv->toolbar_expanded)1417 if (gtk_widget_get_visible (pad->priv->toolbar) && pad->priv->toolbar_expanded)
1375 height -= pad->priv->toolbar_height;1418 height -= pad->priv->toolbar_height;
1376 1419
1377 style = gtk_widget_get_style (pad->priv->textview);1420 style = gtk_widget_get_style_context (pad->priv->textview);
1378 fontname = pango_font_description_to_string (style->font_desc);1421 gtk_style_context_get (style, GTK_STATE_FLAG_NORMAL, GTK_STYLE_PROPERTY_FONT, &font, NULL);
1379 1422 gtk_style_context_get_color (style, GTK_STATE_FLAG_NORMAL, &widget_text_color);
1423 gtk_style_context_get_background_color (style, GTK_STATE_FLAG_NORMAL, &widget_background_color);
1424
1380 fio_set_values_to_file (pad->priv->infoname,1425 fio_set_values_to_file (pad->priv->infoname,
1381 "i|width", pad->priv->width,1426 "i|width", pad->priv->width,
1382 "i|height", height,1427 "i|height", height,
@@ -1385,19 +1430,15 @@
1385 "b|follow_font", xpad_text_view_get_follow_font_style (XPAD_TEXT_VIEW (pad->priv->textview)),1430 "b|follow_font", xpad_text_view_get_follow_font_style (XPAD_TEXT_VIEW (pad->priv->textview)),
1386 "b|follow_color", xpad_text_view_get_follow_color_style (XPAD_TEXT_VIEW (pad->priv->textview)),1431 "b|follow_color", xpad_text_view_get_follow_color_style (XPAD_TEXT_VIEW (pad->priv->textview)),
1387 "b|sticky", pad->priv->sticky,1432 "b|sticky", pad->priv->sticky,
1388 "b|hidden", !GTK_WIDGET_VISIBLE (pad),1433 "b|hidden", !gtk_widget_get_visible (GTK_WIDGET(pad)),
1389 "h|back_red", style->base[GTK_STATE_NORMAL].red,1434 "s|back", gdk_rgba_to_string (&widget_background_color),
1390 "h|back_green", style->base[GTK_STATE_NORMAL].green,1435 "s|text", gdk_rgba_to_string (&widget_text_color),
1391 "h|back_blue", style->base[GTK_STATE_NORMAL].blue,1436 "s|fontname", pango_font_description_to_string (font),
1392 "h|text_red", style->text[GTK_STATE_NORMAL].red,
1393 "h|text_green", style->text[GTK_STATE_NORMAL].green,
1394 "h|text_blue", style->text[GTK_STATE_NORMAL].blue,
1395 "s|fontname", fontname,
1396 "s|content", pad->priv->contentname,1437 "s|content", pad->priv->contentname,
1397 NULL);1438 NULL);
13981439
1440 pango_font_description_free (font);
1399 pad->priv->unsaved_info = FALSE;1441 pad->priv->unsaved_info = FALSE;
1400 g_free (fontname);
1401}1442}
14021443
1403static void1444static void
@@ -1407,21 +1448,6 @@
1407 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};1448 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};
1408 const gchar *comments = _("Sticky notes");1449 const gchar *comments = _("Sticky notes");
1409 const gchar *copyright = "© 2001-2013 Michael Terry";1450 const gchar *copyright = "© 2001-2013 Michael Terry";
1410 /* we use g_strdup_printf because C89 has size limits on static strings */
1411 gchar *license = g_strdup_printf ("%s\n%s\n%s",
1412"This program is free software; you can redistribute it and/or\n"
1413"modify it under the terms of the GNU General Public License\n"
1414"as published by the Free Software Foundation; either version 3\n"
1415"of the License, or (at your option) any later version.\n"
1416,
1417"This program is distributed in the hope that it will be useful,\n"
1418"but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
1419"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
1420"GNU General Public License for more details.\n"
1421,
1422"You should have received a copy of the GNU General Public License\n"
1423"along with this program; if not, write to the Free Software\n"
1424"Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.");
1425 /* Translators: please translate this as your own name and optionally email1451 /* Translators: please translate this as your own name and optionally email
1426 like so: "Your Name <your@email.com>" */1452 like so: "Your Name <your@email.com>" */
1427 const gchar *translator_credits = _("translator-credits");1453 const gchar *translator_credits = _("translator-credits");
@@ -1432,14 +1458,12 @@
1432 "authors", authors,1458 "authors", authors,
1433 "comments", comments,1459 "comments", comments,
1434 "copyright", copyright,1460 "copyright", copyright,
1435 "license", license,1461 "license-type", GTK_LICENSE_GPL_3_0,
1436 "logo-icon-name", PACKAGE,1462 "logo-icon-name", PACKAGE,
1437 "translator-credits", translator_credits,1463 "translator-credits", translator_credits,
1438 "version", VERSION,1464 "version", VERSION,
1439 "website", website,1465 "website", website,
1440 NULL);1466 NULL);
1441
1442 g_free (license);
1443}1467}
14441468
1445void1469void
@@ -1616,25 +1640,41 @@
1616static void1640static void
1617menu_toolbar (XpadPad *pad, GtkCheckMenuItem *check)1641menu_toolbar (XpadPad *pad, GtkCheckMenuItem *check)
1618{1642{
1619 xpad_settings_set_has_toolbar (xpad_settings (), gtk_check_menu_item_get_active (check));1643 // A dirty way to silence the compiler for these unused variables.
1644 // Feel free to implement these variables in the way they are ment to be used.
1645 (void) pad;
1646
1647 xpad_settings_set_has_toolbar (xpad_global_settings, gtk_check_menu_item_get_active (check));
1620}1648}
16211649
1622static void1650static void
1623menu_scrollbar (XpadPad *pad, GtkCheckMenuItem *check)1651menu_scrollbar (XpadPad *pad, GtkCheckMenuItem *check)
1624{1652{
1625 xpad_settings_set_has_scrollbar (xpad_settings (), gtk_check_menu_item_get_active (check));1653 // A dirty way to silence the compiler for these unused variables.
1654 // Feel free to implement these variables in the way they are ment to be used.
1655 (void) pad;
1656
1657 xpad_settings_set_has_scrollbar (xpad_global_settings, gtk_check_menu_item_get_active (check));
1626}1658}
16271659
1628static void1660static void
1629menu_autohide (XpadPad *pad, GtkCheckMenuItem *check)1661menu_autohide (XpadPad *pad, GtkCheckMenuItem *check)
1630{1662{
1631 xpad_settings_set_autohide_toolbar (xpad_settings (), gtk_check_menu_item_get_active (check));1663 // A dirty way to silence the compiler for these unused variables.
1664 // Feel free to implement these variables in the way they are ment to be used.
1665 (void) pad;
1666
1667 xpad_settings_set_autohide_toolbar (xpad_global_settings, gtk_check_menu_item_get_active (check));
1632}1668}
16331669
1634static void1670static void
1635menu_decorated (XpadPad *pad, GtkCheckMenuItem *check)1671menu_decorated (XpadPad *pad, GtkCheckMenuItem *check)
1636{1672{
1637 xpad_settings_set_has_decorations (xpad_settings (), gtk_check_menu_item_get_active (check));1673 // A dirty way to silence the compiler for these unused variables.
1674 // Feel free to implement these variables in the way they are ment to be used.
1675 (void) pad;
1676
1677 xpad_settings_set_has_decorations (xpad_global_settings, gtk_check_menu_item_get_active (check));
1638}1678}
16391679
1640static gint1680static gint
@@ -1718,7 +1758,6 @@
1718 MENU_ADD_STOCK (GTK_STOCK_CLOSE, xpad_pad_close);1758 MENU_ADD_STOCK (GTK_STOCK_CLOSE, xpad_pad_close);
1719 MENU_ADD_STOCK (GTK_STOCK_DELETE, xpad_pad_delete);1759 MENU_ADD_STOCK (GTK_STOCK_DELETE, xpad_pad_delete);
1720 1760
1721
1722 item = gtk_menu_item_new_with_mnemonic (_("_Edit"));1761 item = gtk_menu_item_new_with_mnemonic (_("_Edit"));
1723 gtk_container_add (GTK_CONTAINER (uppermenu), item);1762 gtk_container_add (GTK_CONTAINER (uppermenu), item);
1724 gtk_widget_show (item);1763 gtk_widget_show (item);
@@ -1726,10 +1765,10 @@
1726 menu = gtk_menu_new ();1765 menu = gtk_menu_new ();
1727 gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), menu);1766 gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), menu);
1728 1767
1729 MENU_ADD_STOCK_WITH_ACCEL (GTK_STOCK_UNDO, menu_undo, GDK_Z, GDK_CONTROL_MASK);1768 MENU_ADD_STOCK_WITH_ACCEL (GTK_STOCK_UNDO, menu_undo, GDK_KEY_Z, GDK_CONTROL_MASK);
1730 g_object_set_data (G_OBJECT (uppermenu), "undo", item);1769 g_object_set_data (G_OBJECT (uppermenu), "undo", item);
1731 1770
1732 MENU_ADD_STOCK_WITH_ACCEL (GTK_STOCK_REDO, menu_redo, GDK_R, GDK_CONTROL_MASK);1771 MENU_ADD_STOCK_WITH_ACCEL (GTK_STOCK_REDO, menu_redo, GDK_KEY_R, GDK_CONTROL_MASK);
1733 g_object_set_data (G_OBJECT (uppermenu), "redo", item);1772 g_object_set_data (G_OBJECT (uppermenu), "redo", item);
17341773
1735 MENU_ADD_SEP();1774 MENU_ADD_SEP();
@@ -1749,11 +1788,11 @@
1749 menu = gtk_menu_new ();1788 menu = gtk_menu_new ();
1750 gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), menu);1789 gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), menu);
1751 1790
1752 MENU_ADD_CHECK (_("_Toolbar"), xpad_settings_get_has_toolbar (xpad_settings ()), menu_toolbar);1791 MENU_ADD_CHECK (_("_Toolbar"), xpad_settings_get_has_toolbar (xpad_global_settings), menu_toolbar);
1753 MENU_ADD_CHECK (_("_Autohide Toolbar"), xpad_settings_get_autohide_toolbar (xpad_settings ()), menu_autohide);1792 MENU_ADD_CHECK (_("_Autohide Toolbar"), xpad_settings_get_autohide_toolbar (xpad_global_settings), menu_autohide);
1754 gtk_widget_set_sensitive (item, xpad_settings_get_has_toolbar (xpad_settings ()));1793 gtk_widget_set_sensitive (item, xpad_settings_get_has_toolbar (xpad_global_settings));
1755 MENU_ADD_CHECK (_("_Scrollbar"), xpad_settings_get_has_scrollbar (xpad_settings ()), menu_scrollbar);1794 MENU_ADD_CHECK (_("_Scrollbar"), xpad_settings_get_has_scrollbar (xpad_global_settings), menu_scrollbar);
1756 MENU_ADD_CHECK (_("_Window Decorations"), xpad_settings_get_has_decorations (xpad_settings ()), menu_decorated);1795 MENU_ADD_CHECK (_("_Window Decorations"), xpad_settings_get_has_decorations (xpad_global_settings), menu_decorated);
1757 1796
1758 1797
1759 item = gtk_menu_item_new_with_mnemonic (_("_Notes"));1798 item = gtk_menu_item_new_with_mnemonic (_("_Notes"));
@@ -1776,7 +1815,7 @@
1776 menu = gtk_menu_new ();1815 menu = gtk_menu_new ();
1777 gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), menu);1816 gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), menu);
1778 1817
1779 MENU_ADD (_("_Contents"), GTK_STOCK_HELP, GDK_F1, 0, show_help);1818 MENU_ADD (_("_Contents"), GTK_STOCK_HELP, GDK_KEY_F1, 0, show_help);
1780 MENU_ADD (_("_About"), GTK_STOCK_ABOUT, 0, 0, menu_about);1819 MENU_ADD (_("_About"), GTK_STOCK_ABOUT, 0, 0, menu_about);
1781 1820
1782 return uppermenu;1821 return uppermenu;
@@ -1880,9 +1919,9 @@
1880 MENU_ADD_STOCK (GTK_STOCK_PASTE, menu_paste);1919 MENU_ADD_STOCK (GTK_STOCK_PASTE, menu_paste);
1881 g_object_set_data (G_OBJECT (menu), "paste", item);1920 g_object_set_data (G_OBJECT (menu), "paste", item);
1882 MENU_ADD_SEP ();1921 MENU_ADD_SEP ();
1883 MENU_ADD_STOCK_WITH_ACCEL (GTK_STOCK_BOLD, menu_bold, GDK_b, GDK_CONTROL_MASK);1922 MENU_ADD_STOCK_WITH_ACCEL (GTK_STOCK_BOLD, menu_bold, GDK_KEY_b, GDK_CONTROL_MASK);
1884 MENU_ADD_STOCK_WITH_ACCEL (GTK_STOCK_ITALIC, menu_italic, GDK_i, GDK_CONTROL_MASK);1923 MENU_ADD_STOCK_WITH_ACCEL (GTK_STOCK_ITALIC, menu_italic, GDK_KEY_i, GDK_CONTROL_MASK);
1885 MENU_ADD_STOCK_WITH_ACCEL (GTK_STOCK_UNDERLINE, menu_underline, GDK_u, GDK_CONTROL_MASK);1924 MENU_ADD_STOCK_WITH_ACCEL (GTK_STOCK_UNDERLINE, menu_underline, GDK_KEY_u, GDK_CONTROL_MASK);
1886 MENU_ADD_STOCK (GTK_STOCK_STRIKETHROUGH, menu_strikethrough);1925 MENU_ADD_STOCK (GTK_STOCK_STRIKETHROUGH, menu_strikethrough);
1887 1926
1888 return menu;1927 return menu;
@@ -1891,6 +1930,10 @@
1891static void1930static void
1892menu_prep_popup_highlight (XpadPad *pad, GtkWidget *menu)1931menu_prep_popup_highlight (XpadPad *pad, GtkWidget *menu)
1893{1932{
1933 // A dirty way to silence the compiler for these unused variables.
1934 // Feel free to implement these variables in the way they are ment to be used.
1935 (void) pad;
1936
1894 GtkWidget *item;1937 GtkWidget *item;
1895 GtkClipboard *clipboard;1938 GtkClipboard *clipboard;
1896 1939
@@ -1904,6 +1947,10 @@
1904static void1947static void
1905menu_popup (GtkWidget *menu, XpadPad *pad)1948menu_popup (GtkWidget *menu, XpadPad *pad)
1906{1949{
1950 // A dirty way to silence the compiler for these unused variables.
1951 // Feel free to implement these variables in the way they are ment to be used.
1952 (void) menu;
1953
1907 g_signal_handlers_block_matched (pad, G_SIGNAL_MATCH_FUNC, 0, 0, NULL, (gpointer) xpad_pad_leave_notify_event, NULL);1954 g_signal_handlers_block_matched (pad, G_SIGNAL_MATCH_FUNC, 0, 0, NULL, (gpointer) xpad_pad_leave_notify_event, NULL);
1908 pad->priv->toolbar_timeout = 0;1955 pad->priv->toolbar_timeout = 0;
1909}1956}
@@ -1911,20 +1958,33 @@
1911static void1958static void
1912menu_popdown (GtkWidget *menu, XpadPad *pad)1959menu_popdown (GtkWidget *menu, XpadPad *pad)
1913{1960{
1914 GdkRectangle rect;1961 // A dirty way to silence the compiler for these unused variables.
1915 1962 // Feel free to implement these variables in the way they are ment to be used.
1916 g_signal_handlers_unblock_matched (pad, G_SIGNAL_MATCH_FUNC, 0, 0, NULL, (gpointer) xpad_pad_leave_notify_event, NULL);1963 (void) menu;
1917 1964
1965 cairo_rectangle_int_t rect;
1966
1918 /**1967 /**
1919 * We must check if we disabled off of pad and start the timeout if so.1968 * We must check if we disabled off of pad and start the timeout if so.
1920 */1969 */
1921 gdk_window_get_pointer (GTK_WIDGET (pad)->window, &rect.x, &rect.y, NULL);1970
1971 // TODO: The replacement GTK3 function below gives a Gdk-critical error.
1972 // However when setting the rectangular to a fixed x and y position, I don't see any negative effects.
1973 // What is the reason of getting the device position for making the menu dissapear?
1974
1975 // GTK2: gdk_window_get_pointer (gtk_widget_get_window(GTK_WIDGET(pad)), &rect.x, &rect.y, NULL);
1976 // GTK3: gdk_window_get_device_position (gtk_widget_get_window (GTK_WIDGET (pad)), GDK_SOURCE_MOUSE, &rect.x, &rect.y, NULL);
1977 // Gdk-CRITICAL **: gdk_window_get_device_position: assertion 'GDK_IS_DEVICE (device)' failed
1978
1979 rect.x = 10;
1980 rect.y = 10;
1922 rect.width = 1;1981 rect.width = 1;
1923 rect.height = 1;1982 rect.height = 1;
1924 1983
1925 if (!pad->priv->toolbar_timeout &&1984 if (!pad->priv->toolbar_timeout && !gtk_widget_intersect (GTK_WIDGET (pad), &rect, NULL))
1926 !gtk_widget_intersect (GTK_WIDGET (pad), &rect, NULL))
1927 pad->priv->toolbar_timeout = g_timeout_add (1000, (GSourceFunc) toolbar_timeout, pad);1985 pad->priv->toolbar_timeout = g_timeout_add (1000, (GSourceFunc) toolbar_timeout, pad);
1986
1987 g_signal_handlers_unblock_matched (pad, G_SIGNAL_MATCH_FUNC, 0, 0, NULL, (gpointer) xpad_pad_leave_notify_event, NULL);
1928}1988}
19291989
1930static void1990static void
@@ -1936,12 +1996,20 @@
1936static void1996static void
1937xpad_pad_toolbar_popup (GtkWidget *toolbar, GtkMenu *menu, XpadPad *pad)1997xpad_pad_toolbar_popup (GtkWidget *toolbar, GtkMenu *menu, XpadPad *pad)
1938{1998{
1999 // A dirty way to silence the compiler for these unused variables.
2000 // Feel free to implement these variables in the way they are ment to be used.
2001 (void) toolbar;
2002
1939 menu_popup (GTK_WIDGET (menu), pad);2003 menu_popup (GTK_WIDGET (menu), pad);
1940}2004}
19412005
1942static void2006static void
1943xpad_pad_toolbar_popdown (GtkWidget *toolbar, GtkMenu *menu, XpadPad *pad)2007xpad_pad_toolbar_popdown (GtkWidget *toolbar, GtkMenu *menu, XpadPad *pad)
1944{2008{
2009 // A dirty way to silence the compiler for these unused variables.
2010 // Feel free to implement these variables in the way they are ment to be used.
2011 (void) toolbar;
2012
1945 menu_popdown (GTK_WIDGET (menu), pad);2013 menu_popdown (GTK_WIDGET (menu), pad);
1946}2014}
19472015
19482016
=== modified file 'src/xpad-periodic.c'
--- src/xpad-periodic.c 2013-10-09 14:46:10 +0000
+++ src/xpad-periodic.c 2013-11-01 20:03:38 +0000
@@ -1,4 +1,4 @@
11#include "../config.h"
2#include <stdlib.h>2#include <stdlib.h>
3#include <stdio.h>3#include <stdio.h>
4#include <string.h>4#include <string.h>
@@ -57,21 +57,20 @@
57gboolean Xpad_periodic_init (void)57gboolean Xpad_periodic_init (void)
58{58{
59 memset(xpptr, 0, sizeof(*xpptr));59 memset(xpptr, 0, sizeof(*xpptr));
60 xpptr->after_id =60 xpptr->after_id = (gint) g_timeout_add_seconds(TIMEOUT_SECONDS, xppd_intercept, xpptr);
61 g_timeout_add_seconds(TIMEOUT_SECONDS, xppd_intercept, xpptr);
6261
63 /* Allocate space for the signal references. */62 /* Allocate space for the signal references. */
64 int tlen = xpptr->template_len = 5;63 int tlen = xpptr->template_len = 5;
65 int slen = xpptr->sigs_len = 20;64 int slen = xpptr->sigs_len = 20;
66 xpptr->template = g_malloc0(tlen * sizeof(Xpadsigref));65 xpptr->template = g_malloc0((gsize) tlen * sizeof(Xpadsigref));
67 xpptr->sigs = g_malloc0(slen * sizeof(Xpadsigref));66 xpptr->sigs = g_malloc0((gsize) slen * sizeof(Xpadsigref));
6867
69 return TRUE;68 return TRUE;
70}69}
7170
72void Xpad_periodic_close (void)71void Xpad_periodic_close (void)
73{72{
74 if (xpptr->after_id) { g_source_remove(xpptr->after_id); }73 if (xpptr->after_id) { g_source_remove((guint) xpptr->after_id); }
75 /* Free the signal references memory. */74 /* Free the signal references memory. */
76 g_free(xpptr->template);75 g_free(xpptr->template);
77 g_free(xpptr->sigs);76 g_free(xpptr->sigs);
@@ -92,6 +91,10 @@
92************************/91************************/
93gint xppd_intercept (gpointer cdata)92gint xppd_intercept (gpointer cdata)
94{93{
94 // A dirty way to silence the compiler for these unused variables.
95 // Feel free to implement these variables in the way they are ment to be used.
96 (void) cdata;
97
95 int cnt=0;98 int cnt=0;
96 XpadPeriodicFunc fnptr=0;99 XpadPeriodicFunc fnptr=0;
97 xpptr->count++; /* increment tick count */100 xpptr->count++; /* increment tick count */
@@ -228,6 +231,10 @@
228231
229gint gprint_ignore (const char * fmt, ...)232gint gprint_ignore (const char * fmt, ...)
230{233{
234 // A dirty way to silence the compiler for these unused variables.
235 // Feel free to implement these variables in the way they are ment to be used.
236 (void) fmt;
237
231 return 0;238 return 0;
232}239}
233240
234241
=== modified file 'src/xpad-preferences.c'
--- src/xpad-preferences.c 2013-10-21 02:51:19 +0000
+++ src/xpad-preferences.c 2013-11-01 20:03:38 +0000
@@ -42,22 +42,22 @@
42 GtkWidget *backbutton;42 GtkWidget *backbutton;
43 GtkWidget *fontbutton;43 GtkWidget *fontbutton;
44 44
45 guint notify_edit_handler;45 gulong notify_edit_handler;
46 guint notify_sticky_handler;46 gulong notify_sticky_handler;
47 guint notify_confirm_handler;47 gulong notify_confirm_handler;
48 guint notify_font_handler;48 gulong notify_font_handler;
49 guint notify_back_handler;49 gulong notify_back_handler;
50 guint notify_text_handler;50 gulong notify_text_handler;
51 guint notify_tray_handler;51 gulong notify_tray_handler;
52 guint font_handler;52 gulong font_handler;
53 guint back_handler;53 gulong back_handler;
54 guint text_handler;54 gulong text_handler;
55 guint colorcheck_handler;55 gulong colorcheck_handler;
56 guint fontcheck_handler;56 gulong fontcheck_handler;
57 guint editcheck_handler;57 gulong editcheck_handler;
58 guint stickycheck_handler;58 gulong stickycheck_handler;
59 guint confirmcheck_handler;59 gulong confirmcheck_handler;
60 guint trayclick_handler;60 gulong trayclick_handler;
61};61};
6262
63G_DEFINE_TYPE_WITH_PRIVATE(XpadPreferences, xpad_preferences, GTK_TYPE_DIALOG)63G_DEFINE_TYPE_WITH_PRIVATE(XpadPreferences, xpad_preferences, GTK_TYPE_DIALOG)
@@ -67,8 +67,8 @@
67static void change_confirm_check (GtkToggleButton *button, XpadPreferences *pref);67static void change_confirm_check (GtkToggleButton *button, XpadPreferences *pref);
68static void change_color_check (GtkToggleButton *button, XpadPreferences *pref);68static void change_color_check (GtkToggleButton *button, XpadPreferences *pref);
69static void change_font_check (GtkToggleButton *button, XpadPreferences *pref);69static void change_font_check (GtkToggleButton *button, XpadPreferences *pref);
70static void change_text_color (GtkColorButton *button, XpadPreferences *pref);70static void change_text_color (GtkColorChooser *chooser, XpadPreferences *pref);
71static void change_back_color (GtkColorButton *button, XpadPreferences *pref);71static void change_back_color (GtkColorChooser *chooser, XpadPreferences *pref);
72static void change_font_face (GtkFontButton *button, XpadPreferences *pref);72static void change_font_face (GtkFontButton *button, XpadPreferences *pref);
73static void change_tray_click_configuration(GtkComboBox *box, XpadPreferences *pref);73static void change_tray_click_configuration(GtkComboBox *box, XpadPreferences *pref);
74static void notify_edit (XpadPreferences *pref);74static void notify_edit (XpadPreferences *pref);
@@ -112,14 +112,16 @@
112xpad_preferences_init (XpadPreferences *pref)112xpad_preferences_init (XpadPreferences *pref)
113{113{
114 GtkWidget *hbox, *font_hbox, *vbox;114 GtkWidget *hbox, *font_hbox, *vbox;
115 const GdkColor *color;115 const GdkRGBA *color;
116 const gchar *fontname;116 const gchar *fontname;
117 GtkStyle *style;117 GtkStyleContext *style;
118 GtkWidget *label, *appearance_frame, *alignment, *appearance_vbox;118 GtkWidget *label, *appearance_frame, *alignment, *appearance_vbox;
119 GtkWidget *options_frame, *options_vbox, *global_vbox, *tray_config_vbox;119 GtkWidget *options_frame, *options_vbox, *global_vbox, *tray_config_vbox;
120 gchar *text;120 gchar *text;
121 GtkSizeGroup *size_group_labels = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);121 GtkSizeGroup *size_group_labels = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
122 GtkRequisition req;122 GtkRequisition req;
123 GdkRGBA theme_text_color = {0, 0, 0, 0};
124 GdkRGBA theme_background_color = {0, 0, 0, 0};
123 125
124 pref->priv = xpad_preferences_get_instance_private(pref);126 pref->priv = xpad_preferences_get_instance_private(pref);
125 127
@@ -130,10 +132,9 @@
130 "xalign", 0.0,132 "xalign", 0.0,
131 NULL));133 NULL));
132 g_free (text);134 g_free (text);
133 appearance_vbox = GTK_WIDGET (g_object_new (GTK_TYPE_VBOX,135 appearance_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 18);
134 "homogeneous", FALSE,136 gtk_box_set_homogeneous (GTK_BOX (appearance_vbox), FALSE);
135 "spacing", 18,137
136 NULL));
137 alignment = gtk_alignment_new (1, 1, 1, 1);138 alignment = gtk_alignment_new (1, 1, 1, 1);
138 g_object_set (G_OBJECT (alignment),139 g_object_set (G_OBJECT (alignment),
139 "left-padding", 12,140 "left-padding", 12,
@@ -155,12 +156,14 @@
155 pref->priv->anticolorcheck = gtk_radio_button_new_with_mnemonic (NULL, _("Use colors from theme"));156 pref->priv->anticolorcheck = gtk_radio_button_new_with_mnemonic (NULL, _("Use colors from theme"));
156 pref->priv->colorcheck = gtk_radio_button_new_with_mnemonic_from_widget (GTK_RADIO_BUTTON (pref->priv->anticolorcheck), _("Use these colors:"));157 pref->priv->colorcheck = gtk_radio_button_new_with_mnemonic_from_widget (GTK_RADIO_BUTTON (pref->priv->anticolorcheck), _("Use these colors:"));
157 158
158 font_hbox = gtk_hbox_new (FALSE, 6);159 font_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
160
159 gtk_box_pack_start (GTK_BOX (font_hbox), pref->priv->fontcheck, FALSE, FALSE, 0);161 gtk_box_pack_start (GTK_BOX (font_hbox), pref->priv->fontcheck, FALSE, FALSE, 0);
160 gtk_box_pack_start (GTK_BOX (font_hbox), pref->priv->fontbutton, TRUE, TRUE, 0);162 gtk_box_pack_start (GTK_BOX (font_hbox), pref->priv->fontbutton, TRUE, TRUE, 0);
161 163
162 pref->priv->colorbox = gtk_vbox_new (FALSE, 6);164 pref->priv->colorbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
163 hbox = gtk_hbox_new (FALSE, 12);165 hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
166
164 label = gtk_label_new_with_mnemonic (_("Background:"));167 label = gtk_label_new_with_mnemonic (_("Background:"));
165 gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);168 gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
166 gtk_size_group_add_widget (size_group_labels, label);169 gtk_size_group_add_widget (size_group_labels, label);
@@ -168,7 +171,8 @@
168 gtk_box_pack_start (GTK_BOX (hbox), pref->priv->backbutton, TRUE, TRUE, 0);171 gtk_box_pack_start (GTK_BOX (hbox), pref->priv->backbutton, TRUE, TRUE, 0);
169 g_object_set (G_OBJECT (pref->priv->colorbox), "child", hbox, NULL);172 g_object_set (G_OBJECT (pref->priv->colorbox), "child", hbox, NULL);
170 173
171 hbox = gtk_hbox_new (FALSE, 12);174 hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
175
172 label = gtk_label_new_with_mnemonic (_("Foreground:"));176 label = gtk_label_new_with_mnemonic (_("Foreground:"));
173 gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);177 gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
174 gtk_size_group_add_widget (size_group_labels, label);178 gtk_size_group_add_widget (size_group_labels, label);
@@ -186,40 +190,41 @@
186 190
187 gtk_dialog_add_button (GTK_DIALOG (pref), "gtk-close", GTK_RESPONSE_CLOSE);191 gtk_dialog_add_button (GTK_DIALOG (pref), "gtk-close", GTK_RESPONSE_CLOSE);
188 gtk_dialog_set_default_response (GTK_DIALOG (pref), GTK_RESPONSE_CLOSE);192 gtk_dialog_set_default_response (GTK_DIALOG (pref), GTK_RESPONSE_CLOSE);
189 gtk_dialog_set_has_separator (GTK_DIALOG (pref), FALSE);
190 g_signal_connect (pref, "response", G_CALLBACK (xpad_preferences_response), NULL);193 g_signal_connect (pref, "response", G_CALLBACK (xpad_preferences_response), NULL);
191 gtk_window_set_title (GTK_WINDOW (pref), _("Xpad Preferences"));194 gtk_window_set_title (GTK_WINDOW (pref), _("Xpad Preferences"));
192 195
193 gtk_color_button_set_use_alpha (GTK_COLOR_BUTTON (pref->priv->textbutton), FALSE);196 gtk_color_chooser_set_use_alpha (GTK_COLOR_CHOOSER (pref->priv->textbutton), FALSE);
194 gtk_color_button_set_use_alpha (GTK_COLOR_BUTTON (pref->priv->backbutton), xpad_app_get_translucent ());197 gtk_color_chooser_set_use_alpha (GTK_COLOR_CHOOSER (pref->priv->backbutton), TRUE);
195 198
196 gtk_color_button_set_title (GTK_COLOR_BUTTON (pref->priv->textbutton), _("Set Foreground Color"));199 gtk_color_button_set_title (GTK_COLOR_BUTTON (pref->priv->textbutton), _("Set Foreground Color"));
197 gtk_color_button_set_title (GTK_COLOR_BUTTON (pref->priv->backbutton), _("Set Background Color"));200 gtk_color_button_set_title (GTK_COLOR_BUTTON (pref->priv->backbutton), _("Set Background Color"));
198 gtk_font_button_set_title (GTK_FONT_BUTTON (pref->priv->fontbutton), _("Set Font"));201 gtk_font_button_set_title (GTK_FONT_BUTTON (pref->priv->fontbutton), _("Set Font"));
199 202
200 /* Set current state */203 /* Set current state */
201 style = gtk_widget_get_default_style ();204 style = gtk_widget_get_style_context (GTK_WIDGET(pref));
205 gtk_style_context_get_color (style, GTK_STATE_FLAG_NORMAL, &theme_text_color);
206 gtk_style_context_get_background_color (style, GTK_STATE_FLAG_NORMAL, &theme_background_color);
202 207
203 color = xpad_settings_get_back_color (xpad_settings ());208 color = xpad_settings_get_back_color (xpad_global_settings);
204 if (color)209 if (color)
205 {210 {
206 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pref->priv->colorcheck), TRUE);211 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pref->priv->colorcheck), TRUE);
207 gtk_color_button_set_color (GTK_COLOR_BUTTON (pref->priv->backbutton), color);212 gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (pref->priv->backbutton), color);
208 }213 }
209 else214 else
210 {215 {
211 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pref->priv->anticolorcheck), TRUE);216 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pref->priv->anticolorcheck), TRUE);
212 gtk_widget_set_sensitive (pref->priv->colorbox, FALSE);217 gtk_widget_set_sensitive (pref->priv->colorbox, FALSE);
213 gtk_color_button_set_color (GTK_COLOR_BUTTON (pref->priv->backbutton), &style->base[GTK_STATE_NORMAL]);218 gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (pref->priv->backbutton), &theme_background_color);
214 }219 }
215 220
216 color = xpad_settings_get_text_color (xpad_settings ());221 color = xpad_settings_get_text_color (xpad_global_settings);
217 if (color)222 if (color)
218 gtk_color_button_set_color (GTK_COLOR_BUTTON (pref->priv->textbutton), color);223 gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (pref->priv->textbutton), color);
219 else224 else
220 gtk_color_button_set_color (GTK_COLOR_BUTTON (pref->priv->textbutton), &style->text[GTK_STATE_NORMAL]);225 gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (pref->priv->textbutton), &theme_text_color);
221 226
222 fontname = xpad_settings_get_fontname (xpad_settings ());227 fontname = xpad_settings_get_fontname (xpad_global_settings);
223 if (fontname)228 if (fontname)
224 {229 {
225 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pref->priv->fontcheck), TRUE);230 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pref->priv->fontcheck), TRUE);
@@ -227,32 +232,33 @@
227 }232 }
228 else233 else
229 {234 {
230 gchar *str;235 PangoFontDescription *font;
231 236
232 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pref->priv->antifontcheck), TRUE);237 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pref->priv->antifontcheck), TRUE);
233 gtk_widget_set_sensitive (pref->priv->fontbutton, FALSE);238 gtk_widget_set_sensitive (pref->priv->fontbutton, FALSE);
234 239
235 str = pango_font_description_to_string (style->font_desc);240 gtk_style_context_get (style, GTK_STATE_FLAG_NORMAL, GTK_STYLE_PROPERTY_FONT, &font, NULL);
236 gtk_font_button_set_font_name (GTK_FONT_BUTTON (pref->priv->fontbutton), str);241 gtk_font_button_set_font_name (GTK_FONT_BUTTON (pref->priv->fontbutton), pango_font_description_to_string(font));
237 g_free (str);242 pango_font_description_free (font);
238 }243 }
239 244
240 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pref->priv->editcheck), xpad_settings_get_edit_lock (xpad_settings ()));245 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pref->priv->editcheck), xpad_settings_get_edit_lock (xpad_global_settings));
241 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pref->priv->stickycheck), xpad_settings_get_sticky (xpad_settings ()));246 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pref->priv->stickycheck), xpad_settings_get_sticky (xpad_global_settings));
242 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pref->priv->confirmcheck), xpad_settings_get_confirm_destroy (xpad_settings ()));247 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pref->priv->confirmcheck), xpad_settings_get_confirm_destroy (xpad_global_settings));
243 248
244 vbox = gtk_vbox_new (FALSE, 6);249 vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
250
245 gtk_box_pack_start (GTK_BOX (vbox), pref->priv->antifontcheck, FALSE, FALSE, 0);251 gtk_box_pack_start (GTK_BOX (vbox), pref->priv->antifontcheck, FALSE, FALSE, 0);
246 gtk_box_pack_start (GTK_BOX (vbox), font_hbox, FALSE, FALSE, 0);252 gtk_box_pack_start (GTK_BOX (vbox), font_hbox, FALSE, FALSE, 0);
247 gtk_box_pack_start (GTK_BOX (appearance_vbox), vbox, FALSE, FALSE, 0);253 gtk_box_pack_start (GTK_BOX (appearance_vbox), vbox, FALSE, FALSE, 0);
248 254
249 vbox = gtk_vbox_new (FALSE, 6);255 vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
256
250 gtk_box_pack_start (GTK_BOX (vbox), pref->priv->anticolorcheck, FALSE, FALSE, 0);257 gtk_box_pack_start (GTK_BOX (vbox), pref->priv->anticolorcheck, FALSE, FALSE, 0);
251 gtk_box_pack_start (GTK_BOX (vbox), pref->priv->colorcheck, FALSE, FALSE, 0);258 gtk_box_pack_start (GTK_BOX (vbox), pref->priv->colorcheck, FALSE, FALSE, 0);
252 gtk_box_pack_start (GTK_BOX (vbox), alignment, FALSE, FALSE, 0);259 gtk_box_pack_start (GTK_BOX (vbox), alignment, FALSE, FALSE, 0);
253 gtk_box_pack_start (GTK_BOX (appearance_vbox), vbox, FALSE, FALSE, 0);260 gtk_box_pack_start (GTK_BOX (appearance_vbox), vbox, FALSE, FALSE, 0);
254 261
255
256 text = g_strconcat ("<b>", _("Options"), "</b>", NULL);262 text = g_strconcat ("<b>", _("Options"), "</b>", NULL);
257 label = GTK_WIDGET (g_object_new (GTK_TYPE_LABEL,263 label = GTK_WIDGET (g_object_new (GTK_TYPE_LABEL,
258 "label", text,264 "label", text,
@@ -260,10 +266,10 @@
260 "xalign", 0.0,266 "xalign", 0.0,
261 NULL));267 NULL));
262 g_free (text);268 g_free (text);
263 options_vbox = GTK_WIDGET (g_object_new (GTK_TYPE_VBOX,269
264 "homogeneous", FALSE,270 options_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
265 "spacing", 6,271 gtk_box_set_homogeneous (GTK_BOX (options_vbox), FALSE);
266 NULL));272
267 alignment = gtk_alignment_new (1, 1, 1, 1);273 alignment = gtk_alignment_new (1, 1, 1, 1);
268 g_object_set (G_OBJECT (alignment),274 g_object_set (G_OBJECT (alignment),
269 "left-padding", 12,275 "left-padding", 12,
@@ -275,39 +281,35 @@
275 "shadow-type", GTK_SHADOW_NONE,281 "shadow-type", GTK_SHADOW_NONE,
276 "child", alignment,282 "child", alignment,
277 NULL));283 NULL));
278 284
279 tray_config_vbox = GTK_WIDGET (g_object_new (GTK_TYPE_VBOX,285 // System tray configuration left-click behaviour
280 "homogeneous", FALSE,286 tray_config_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
281 "spacing", 6,287 gtk_box_set_homogeneous (GTK_BOX (tray_config_vbox), FALSE);
282 NULL));288 pref->priv->trayconfigbox = gtk_combo_box_text_new();
283289 gtk_combo_box_text_append_text ( GTK_COMBO_BOX_TEXT( pref->priv->trayconfigbox ), _("Do Nothing") );
284 pref->priv->trayconfigbox = gtk_combo_box_new_text();290 gtk_combo_box_text_append_text ( GTK_COMBO_BOX_TEXT( pref->priv->trayconfigbox ), _("Toggle Show All") );
285 gtk_combo_box_append_text( GTK_COMBO_BOX( pref->priv->trayconfigbox ), "Do Nothing" );291 gtk_combo_box_text_append_text ( GTK_COMBO_BOX_TEXT( pref->priv->trayconfigbox ), _("List of Pads") );
286 gtk_combo_box_append_text( GTK_COMBO_BOX( pref->priv->trayconfigbox ), "Toggle Show All" );292 gtk_combo_box_text_append_text ( GTK_COMBO_BOX_TEXT( pref->priv->trayconfigbox ), _("New Pad") );
287 gtk_combo_box_append_text( GTK_COMBO_BOX( pref->priv->trayconfigbox ), "List of Pads" );293 gtk_combo_box_set_active( GTK_COMBO_BOX( pref->priv->trayconfigbox ), (gint) xpad_settings_get_tray_click_handler(xpad_global_settings));
288 gtk_combo_box_append_text( GTK_COMBO_BOX( pref->priv->trayconfigbox ), "New Pad" );294 hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
289 gtk_combo_box_set_active( GTK_COMBO_BOX( pref->priv->trayconfigbox ), xpad_settings_get_tray_click_handler(xpad_settings()));
290
291 hbox = gtk_hbox_new(FALSE, 12);
292 label = gtk_label_new_with_mnemonic(_("Tray click behaviour"));295 label = gtk_label_new_with_mnemonic(_("Tray click behaviour"));
293 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);296 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
294 gtk_box_pack_start(GTK_BOX(hbox), pref->priv->trayconfigbox, TRUE, TRUE, 0);297 gtk_box_pack_start(GTK_BOX(hbox), pref->priv->trayconfigbox, TRUE, TRUE, 0);
295 gtk_box_pack_start(GTK_BOX(tray_config_vbox), hbox, TRUE, TRUE, 0);298 gtk_box_pack_start(GTK_BOX(tray_config_vbox), hbox, TRUE, TRUE, 0);
296299
300 // Edit, sticky and confirmation checkboxes
297 gtk_box_pack_start (GTK_BOX (options_vbox), pref->priv->editcheck, FALSE, FALSE, 0);301 gtk_box_pack_start (GTK_BOX (options_vbox), pref->priv->editcheck, FALSE, FALSE, 0);
298 gtk_box_pack_start (GTK_BOX (options_vbox), pref->priv->stickycheck, FALSE, FALSE, 0);302 gtk_box_pack_start (GTK_BOX (options_vbox), pref->priv->stickycheck, FALSE, FALSE, 0);
299 gtk_box_pack_start (GTK_BOX (options_vbox), pref->priv->confirmcheck, FALSE, FALSE, 0); 303 gtk_box_pack_start (GTK_BOX (options_vbox), pref->priv->confirmcheck, FALSE, FALSE, 0);
300 g_object_set (GTK_WIDGET(options_vbox), "child", tray_config_vbox, NULL);304 g_object_set (GTK_WIDGET(options_vbox), "child", tray_config_vbox, NULL);
301 305
302 global_vbox = g_object_new (GTK_TYPE_VBOX,306 global_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
303 "border-width", 6,307 gtk_box_set_homogeneous (GTK_BOX (global_vbox), FALSE);
304 "homogeneous", FALSE,308 gtk_box_pack_start (GTK_BOX (global_vbox), appearance_frame, FALSE, FALSE, 0);
305 "spacing", 18,309 gtk_box_pack_start (GTK_BOX (global_vbox), options_frame, FALSE, FALSE, 0);
306 "child", appearance_frame,310 gtk_container_set_border_width (GTK_CONTAINER (global_vbox), 6);
307 "child", options_frame,311
308 NULL);312 gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (pref))), global_vbox, FALSE, FALSE, 0);
309
310 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (pref)->vbox), global_vbox, FALSE, FALSE, 0);
311 313
312 pref->priv->editcheck_handler = g_signal_connect (pref->priv->editcheck, "toggled", G_CALLBACK (change_edit_check), pref);314 pref->priv->editcheck_handler = g_signal_connect (pref->priv->editcheck, "toggled", G_CALLBACK (change_edit_check), pref);
313 pref->priv->stickycheck_handler = g_signal_connect (pref->priv->stickycheck, "toggled", G_CALLBACK (change_sticky_check), pref);315 pref->priv->stickycheck_handler = g_signal_connect (pref->priv->stickycheck, "toggled", G_CALLBACK (change_sticky_check), pref);
@@ -318,20 +320,20 @@
318 pref->priv->back_handler = g_signal_connect (pref->priv->backbutton, "color-set", G_CALLBACK (change_back_color), pref);320 pref->priv->back_handler = g_signal_connect (pref->priv->backbutton, "color-set", G_CALLBACK (change_back_color), pref);
319 pref->priv->font_handler = g_signal_connect (pref->priv->fontbutton, "font-set", G_CALLBACK (change_font_face), pref);321 pref->priv->font_handler = g_signal_connect (pref->priv->fontbutton, "font-set", G_CALLBACK (change_font_face), pref);
320 pref->priv->trayclick_handler = g_signal_connect(pref->priv->trayconfigbox, "changed", G_CALLBACK(change_tray_click_configuration), pref);322 pref->priv->trayclick_handler = g_signal_connect(pref->priv->trayconfigbox, "changed", G_CALLBACK(change_tray_click_configuration), pref);
321 pref->priv->notify_font_handler = g_signal_connect_swapped (xpad_settings (), "notify::fontname", G_CALLBACK (notify_fontname), pref);323 pref->priv->notify_font_handler = g_signal_connect_swapped (xpad_global_settings, "notify::fontname", G_CALLBACK (notify_fontname), pref);
322 pref->priv->notify_text_handler = g_signal_connect_swapped (xpad_settings (), "notify::text-color", G_CALLBACK (notify_text_color), pref);324 pref->priv->notify_text_handler = g_signal_connect_swapped (xpad_global_settings, "notify::text-color", G_CALLBACK (notify_text_color), pref);
323 pref->priv->notify_back_handler = g_signal_connect_swapped (xpad_settings (), "notify::back-color", G_CALLBACK (notify_back_color), pref);325 pref->priv->notify_back_handler = g_signal_connect_swapped (xpad_global_settings, "notify::back-color", G_CALLBACK (notify_back_color), pref);
324 pref->priv->notify_sticky_handler = g_signal_connect_swapped (xpad_settings (), "notify::sticky", G_CALLBACK (notify_sticky), pref);326 pref->priv->notify_sticky_handler = g_signal_connect_swapped (xpad_global_settings, "notify::sticky", G_CALLBACK (notify_sticky), pref);
325 pref->priv->notify_edit_handler = g_signal_connect_swapped (xpad_settings (), "notify::edit-lock", G_CALLBACK (notify_edit), pref);327 pref->priv->notify_edit_handler = g_signal_connect_swapped (xpad_global_settings, "notify::edit-lock", G_CALLBACK (notify_edit), pref);
326 pref->priv->notify_confirm_handler = g_signal_connect_swapped (xpad_settings (), "notify::confirm-destroy", G_CALLBACK (notify_confirm), pref);328 pref->priv->notify_confirm_handler = g_signal_connect_swapped (xpad_global_settings, "notify::confirm-destroy", G_CALLBACK (notify_confirm), pref);
327 pref->priv->notify_tray_handler = g_signal_connect_swapped (xpad_settings (), "notify::tray_click_configuration", G_CALLBACK(notify_tray_click), pref);329 pref->priv->notify_tray_handler = g_signal_connect_swapped (xpad_global_settings, "notify::tray_click_configuration", G_CALLBACK(notify_tray_click), pref);
328 330
329 g_object_unref (size_group_labels);331 g_object_unref (size_group_labels);
330 332
331 gtk_widget_show_all (GTK_DIALOG (pref)->vbox);333 gtk_widget_show_all (gtk_dialog_get_content_area (GTK_DIALOG (pref)));
332 334
333 /* Make window not so squished */335 /* Make window not so squished */
334 gtk_widget_size_request (GTK_WIDGET (pref), &req);336 gtk_widget_get_preferred_size (GTK_WIDGET (pref), &req, NULL);
335 g_object_set (G_OBJECT (pref), "default-width", (gint) (req.height * 0.8), NULL);337 g_object_set (G_OBJECT (pref), "default-width", (gint) (req.height * 0.8), NULL);
336}338}
337339
@@ -346,7 +348,7 @@
346{348{
347 XpadPreferences *pref = XPAD_PREFERENCES (object);349 XpadPreferences *pref = XPAD_PREFERENCES (object);
348350
349 g_signal_handlers_disconnect_matched (xpad_settings (), G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, pref);351 g_signal_handlers_disconnect_matched (xpad_global_settings, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, pref);
350 352
351 G_OBJECT_CLASS (xpad_preferences_parent_class)->finalize (object);353 G_OBJECT_CLASS (xpad_preferences_parent_class)->finalize (object);
352}354}
@@ -361,108 +363,110 @@
361static void363static void
362change_color_check (GtkToggleButton *button, XpadPreferences *pref)364change_color_check (GtkToggleButton *button, XpadPreferences *pref)
363{365{
364 g_signal_handler_block (xpad_settings (), pref->priv->notify_back_handler);366 g_signal_handler_block (xpad_global_settings, pref->priv->notify_back_handler);
365 g_signal_handler_block (xpad_settings (), pref->priv->notify_text_handler);367 g_signal_handler_block (xpad_global_settings, pref->priv->notify_text_handler);
366 368
367 if (!gtk_toggle_button_get_active (button))369 if (!gtk_toggle_button_get_active (button))
368 {370 {
369 xpad_settings_set_text_color (xpad_settings (), NULL);371 xpad_settings_set_text_color (xpad_global_settings, NULL);
370 xpad_settings_set_back_color (xpad_settings (), NULL);372 xpad_settings_set_back_color (xpad_global_settings, NULL);
371 }373 }
372 else374 else
373 {375 {
374 GdkColor color;376 GdkRGBA color;
375 gtk_color_button_get_color (GTK_COLOR_BUTTON (pref->priv->textbutton), &color);377 gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (pref->priv->textbutton), &color);
376 xpad_settings_set_text_color (xpad_settings (), &color);378 xpad_settings_set_text_color (xpad_global_settings, &color);
377 gtk_color_button_get_color (GTK_COLOR_BUTTON (pref->priv->backbutton), &color);379 gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (pref->priv->backbutton), &color);
378 xpad_settings_set_back_color (xpad_settings (), &color);380 xpad_settings_set_back_color (xpad_global_settings, &color);
379 }381 }
380 382
381 gtk_widget_set_sensitive (pref->priv->colorbox, gtk_toggle_button_get_active (button));383 gtk_widget_set_sensitive (pref->priv->colorbox, gtk_toggle_button_get_active (button));
382 384
383 g_signal_handler_unblock (xpad_settings (), pref->priv->notify_back_handler);385 g_signal_handler_unblock (xpad_global_settings, pref->priv->notify_back_handler);
384 g_signal_handler_unblock (xpad_settings (), pref->priv->notify_text_handler);386 g_signal_handler_unblock (xpad_global_settings, pref->priv->notify_text_handler);
385}387}
386388
387static void389static void
388change_font_check (GtkToggleButton *button, XpadPreferences *pref)390change_font_check (GtkToggleButton *button, XpadPreferences *pref)
389{391{
390 g_signal_handler_block (xpad_settings (), pref->priv->notify_font_handler);392 g_signal_handler_block (xpad_global_settings, pref->priv->notify_font_handler);
391 393
392 if (!gtk_toggle_button_get_active (button))394 if (!gtk_toggle_button_get_active (button))
393 xpad_settings_set_fontname (xpad_settings (), NULL);395 xpad_settings_set_fontname (xpad_global_settings, NULL);
394 else396 else
395 xpad_settings_set_fontname (xpad_settings (), gtk_font_button_get_font_name (GTK_FONT_BUTTON (pref->priv->fontbutton)));397 xpad_settings_set_fontname (xpad_global_settings, gtk_font_button_get_font_name (GTK_FONT_BUTTON (pref->priv->fontbutton)));
396 398
397 gtk_widget_set_sensitive (pref->priv->fontbutton, gtk_toggle_button_get_active (button));399 gtk_widget_set_sensitive (pref->priv->fontbutton, gtk_toggle_button_get_active (button));
398 400
399 g_signal_handler_unblock (xpad_settings (), pref->priv->notify_font_handler);401 g_signal_handler_unblock (xpad_global_settings, pref->priv->notify_font_handler);
400}402}
401403
402static void404static void
403change_edit_check (GtkToggleButton *button, XpadPreferences *pref)405change_edit_check (GtkToggleButton *button, XpadPreferences *pref)
404{406{
405 g_signal_handler_block (xpad_settings (), pref->priv->notify_edit_handler);407 g_signal_handler_block (xpad_global_settings, pref->priv->notify_edit_handler);
406 xpad_settings_set_edit_lock (xpad_settings (), gtk_toggle_button_get_active (button));408 xpad_settings_set_edit_lock (xpad_global_settings, gtk_toggle_button_get_active (button));
407 g_signal_handler_unblock (xpad_settings (), pref->priv->notify_edit_handler);409 g_signal_handler_unblock (xpad_global_settings, pref->priv->notify_edit_handler);
408}410}
409411
410static void412static void
411change_sticky_check (GtkToggleButton *button, XpadPreferences *pref)413change_sticky_check (GtkToggleButton *button, XpadPreferences *pref)
412{414{
413 g_signal_handler_block (xpad_settings (), pref->priv->notify_sticky_handler);415 g_signal_handler_block (xpad_global_settings, pref->priv->notify_sticky_handler);
414 xpad_settings_set_sticky (xpad_settings (), gtk_toggle_button_get_active (button));416 xpad_settings_set_sticky (xpad_global_settings, gtk_toggle_button_get_active (button));
415 g_signal_handler_unblock (xpad_settings (), pref->priv->notify_sticky_handler);417 g_signal_handler_unblock (xpad_global_settings, pref->priv->notify_sticky_handler);
416}418}
417419
418static void420static void
419change_confirm_check (GtkToggleButton *button, XpadPreferences *pref)421change_confirm_check (GtkToggleButton *button, XpadPreferences *pref)
420{422{
421 g_signal_handler_block (xpad_settings (), pref->priv->notify_confirm_handler);423 g_signal_handler_block (xpad_global_settings, pref->priv->notify_confirm_handler);
422 xpad_settings_set_confirm_destroy (xpad_settings (), gtk_toggle_button_get_active (button));424 xpad_settings_set_confirm_destroy (xpad_global_settings, gtk_toggle_button_get_active (button));
423 g_signal_handler_unblock (xpad_settings (), pref->priv->notify_confirm_handler);425 g_signal_handler_unblock (xpad_global_settings, pref->priv->notify_confirm_handler);
424}426}
425427
426static void428static void
427change_tray_click_configuration(GtkComboBox *box, XpadPreferences *pref)429change_tray_click_configuration(GtkComboBox *box, XpadPreferences *pref)
428{430{
429 g_signal_handler_block(xpad_settings(), pref->priv->notify_tray_handler);431 g_signal_handler_block(xpad_global_settings, pref->priv->notify_tray_handler);
430 xpad_settings_set_tray_click_handler(xpad_settings(), gtk_combo_box_get_active(box));432 xpad_settings_set_tray_click_handler(xpad_global_settings, (guint) gtk_combo_box_get_active(box));
431 g_signal_handler_unblock(xpad_settings(), pref->priv->notify_tray_handler);433 g_signal_handler_unblock(xpad_global_settings, pref->priv->notify_tray_handler);
432}434}
433435
434static void436static void
435change_text_color (GtkColorButton *button, XpadPreferences *pref)437change_text_color (GtkColorChooser *chooser, XpadPreferences *pref)
436{438{
437 GdkColor color;439 GdkRGBA color = {0, 0, 0, 0};
438 gtk_color_button_get_color (button, &color);440 gtk_color_chooser_get_rgba (chooser, &color);
439 g_signal_handler_block (xpad_settings (), pref->priv->notify_text_handler);441
440 xpad_settings_set_text_color (xpad_settings (), &color);442 g_signal_handler_block (xpad_global_settings, pref->priv->notify_text_handler);
441 g_signal_handler_unblock (xpad_settings (), pref->priv->notify_text_handler);443 xpad_settings_set_text_color (xpad_global_settings, &color);
442}444 g_signal_handler_unblock (xpad_global_settings, pref->priv->notify_text_handler);
443445}
444static void446
445change_back_color (GtkColorButton *button, XpadPreferences *pref)447static void
446{448change_back_color (GtkColorChooser *chooser, XpadPreferences *pref)
447 GdkColor color;449{
448 gtk_color_button_get_color (button, &color);450 GdkRGBA color = {0, 0, 0, 0};
449 g_signal_handler_block (xpad_settings (), pref->priv->notify_back_handler);451 gtk_color_chooser_get_rgba (chooser, &color);
450 xpad_settings_set_back_color (xpad_settings (), &color);452
451 g_signal_handler_unblock (xpad_settings (), pref->priv->notify_back_handler);453 g_signal_handler_block (xpad_global_settings, pref->priv->notify_back_handler);
454 xpad_settings_set_back_color (xpad_global_settings, &color);
455 g_signal_handler_unblock (xpad_global_settings, pref->priv->notify_back_handler);
452}456}
453457
454static void458static void
455change_font_face (GtkFontButton *button, XpadPreferences *pref)459change_font_face (GtkFontButton *button, XpadPreferences *pref)
456{460{
457 g_signal_handler_block (xpad_settings (), pref->priv->notify_font_handler);461 g_signal_handler_block (xpad_global_settings, pref->priv->notify_font_handler);
458 xpad_settings_set_fontname (xpad_settings (), gtk_font_button_get_font_name (button));462 xpad_settings_set_fontname (xpad_global_settings, gtk_font_button_get_font_name (button));
459 g_signal_handler_unblock (xpad_settings (), pref->priv->notify_font_handler);463 g_signal_handler_unblock (xpad_global_settings, pref->priv->notify_font_handler);
460}464}
461465
462static void466static void
463notify_back_color (XpadPreferences *pref)467notify_back_color (XpadPreferences *pref)
464{468{
465 const GdkColor *color = xpad_settings_get_back_color (xpad_settings ());469 const GdkRGBA *color = xpad_settings_get_back_color (xpad_global_settings);
466 470
467 g_signal_handler_block (pref->priv->backbutton, pref->priv->back_handler);471 g_signal_handler_block (pref->priv->backbutton, pref->priv->back_handler);
468 g_signal_handler_block (pref->priv->colorcheck, pref->priv->colorcheck_handler);472 g_signal_handler_block (pref->priv->colorcheck, pref->priv->colorcheck_handler);
@@ -471,7 +475,7 @@
471 {475 {
472 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pref->priv->colorcheck), TRUE);476 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pref->priv->colorcheck), TRUE);
473 gtk_widget_set_sensitive (pref->priv->colorbox, TRUE);477 gtk_widget_set_sensitive (pref->priv->colorbox, TRUE);
474 gtk_color_button_set_color (GTK_COLOR_BUTTON (pref->priv->backbutton), color);478 gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (pref->priv->backbutton), color);
475 }479 }
476 else480 else
477 {481 {
@@ -486,7 +490,7 @@
486static void490static void
487notify_text_color (XpadPreferences *pref)491notify_text_color (XpadPreferences *pref)
488{492{
489 const GdkColor *color = xpad_settings_get_text_color (xpad_settings ());493 const GdkRGBA *color = xpad_settings_get_text_color (xpad_global_settings);
490 494
491 g_signal_handler_block (pref->priv->textbutton, pref->priv->text_handler);495 g_signal_handler_block (pref->priv->textbutton, pref->priv->text_handler);
492 g_signal_handler_block (pref->priv->colorcheck, pref->priv->colorcheck_handler);496 g_signal_handler_block (pref->priv->colorcheck, pref->priv->colorcheck_handler);
@@ -495,7 +499,8 @@
495 {499 {
496 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pref->priv->colorcheck), TRUE);500 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pref->priv->colorcheck), TRUE);
497 gtk_widget_set_sensitive (pref->priv->colorbox, TRUE);501 gtk_widget_set_sensitive (pref->priv->colorbox, TRUE);
498 gtk_color_button_set_color (GTK_COLOR_BUTTON (pref->priv->textbutton), color);502 gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (pref->priv->textbutton), color);
503
499 }504 }
500 else505 else
501 {506 {
@@ -510,7 +515,7 @@
510static void515static void
511notify_fontname (XpadPreferences *pref)516notify_fontname (XpadPreferences *pref)
512{517{
513 const gchar *fontname = xpad_settings_get_fontname (xpad_settings ());518 const gchar *fontname = xpad_settings_get_fontname (xpad_global_settings);
514 519
515 g_signal_handler_block (pref->priv->fontbutton, pref->priv->font_handler);520 g_signal_handler_block (pref->priv->fontbutton, pref->priv->font_handler);
516 g_signal_handler_block (pref->priv->fontcheck, pref->priv->fontcheck_handler);521 g_signal_handler_block (pref->priv->fontcheck, pref->priv->fontcheck_handler);
@@ -535,7 +540,7 @@
535notify_edit (XpadPreferences *pref)540notify_edit (XpadPreferences *pref)
536{541{
537 g_signal_handler_block (pref->priv->editcheck, pref->priv->editcheck_handler);542 g_signal_handler_block (pref->priv->editcheck, pref->priv->editcheck_handler);
538 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pref->priv->editcheck), xpad_settings_get_edit_lock (xpad_settings ()));543 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pref->priv->editcheck), xpad_settings_get_edit_lock (xpad_global_settings));
539 g_signal_handler_unblock (pref->priv->editcheck, pref->priv->editcheck_handler);544 g_signal_handler_unblock (pref->priv->editcheck, pref->priv->editcheck_handler);
540}545}
541546
@@ -543,7 +548,7 @@
543notify_sticky (XpadPreferences *pref)548notify_sticky (XpadPreferences *pref)
544{549{
545 g_signal_handler_block (pref->priv->stickycheck, pref->priv->stickycheck_handler);550 g_signal_handler_block (pref->priv->stickycheck, pref->priv->stickycheck_handler);
546 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pref->priv->stickycheck), xpad_settings_get_sticky (xpad_settings ()));551 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pref->priv->stickycheck), xpad_settings_get_sticky (xpad_global_settings));
547 g_signal_handler_unblock (pref->priv->stickycheck, pref->priv->stickycheck_handler);552 g_signal_handler_unblock (pref->priv->stickycheck, pref->priv->stickycheck_handler);
548}553}
549554
@@ -551,7 +556,7 @@
551notify_confirm (XpadPreferences *pref)556notify_confirm (XpadPreferences *pref)
552{557{
553 g_signal_handler_block (pref->priv->confirmcheck, pref->priv->confirmcheck_handler);558 g_signal_handler_block (pref->priv->confirmcheck, pref->priv->confirmcheck_handler);
554 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pref->priv->confirmcheck), xpad_settings_get_confirm_destroy (xpad_settings ()));559 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pref->priv->confirmcheck), xpad_settings_get_confirm_destroy (xpad_global_settings));
555 g_signal_handler_unblock (pref->priv->confirmcheck, pref->priv->confirmcheck_handler);560 g_signal_handler_unblock (pref->priv->confirmcheck, pref->priv->confirmcheck_handler);
556}561}
557562
@@ -559,7 +564,7 @@
559notify_tray_click(XpadPreferences *pref)564notify_tray_click(XpadPreferences *pref)
560{565{
561 g_signal_handler_block(pref->priv->trayconfigbox, pref->priv->trayclick_handler);566 g_signal_handler_block(pref->priv->trayconfigbox, pref->priv->trayclick_handler);
562 gtk_combo_box_set_active(GTK_COMBO_BOX(pref->priv->trayconfigbox), xpad_settings_get_tray_click_handler(xpad_settings()));567 gtk_combo_box_set_active(GTK_COMBO_BOX(pref->priv->trayconfigbox), (gint) xpad_settings_get_tray_click_handler(xpad_global_settings));
563 g_signal_handler_unblock(pref->priv->trayconfigbox, pref->priv->trayclick_handler);568 g_signal_handler_unblock(pref->priv->trayconfigbox, pref->priv->trayclick_handler);
564}569}
565570
566571
=== modified file 'src/xpad-session-manager.c'
--- src/xpad-session-manager.c 2008-09-21 00:03:40 +0000
+++ src/xpad-session-manager.c 2013-11-01 20:03:38 +0000
@@ -18,10 +18,12 @@
1818
19*/19*/
2020
21#include "../config.h"
21#include "xpad-session-manager.h"22#include "xpad-session-manager.h"
2223
23#ifndef X_DISPLAY_MISSING24#ifndef X_DISPLAY_MISSING
2425
26#include <gdk/gdkx.h>
25#include <X11/SM/SMlib.h>27#include <X11/SM/SMlib.h>
26#include <stdio.h> /* only for printf */28#include <stdio.h> /* only for printf */
27#include <sys/types.h> /* for getuid and getpwuid */29#include <sys/types.h> /* for getuid and getpwuid */
@@ -56,8 +58,14 @@
56static gboolean58static gboolean
57xpad_session_manager_cycle (GIOChannel *source, GIOCondition condition,59xpad_session_manager_cycle (GIOChannel *source, GIOCondition condition,
58 gpointer data)60 gpointer data)
59{ 61{
60 gboolean rv = TRUE;62 // A dirty way to silence the compiler for these unused variables.
63 // Feel free to implement these variables in the way they are ment to be used.
64 (void) source;
65 (void) condition;
66 (void) data;
67
68 gboolean rv = TRUE;
61 IceConn ice_conn;69 IceConn ice_conn;
62 70
63 ice_conn = SmcGetIceConnection (xpad_session_manager_conn);71 ice_conn = SmcGetIceConnection (xpad_session_manager_conn);
@@ -102,8 +110,13 @@
102static void110static void
103xpad_session_manager_start_interact_callback (SmcConn smc_conn, SmPointer client_data)111xpad_session_manager_start_interact_callback (SmcConn smc_conn, SmPointer client_data)
104{112{
105 if (blocking)113 // A dirty way to silence the compiler for these unused variables.
106 gtk_main_quit ();114 // Feel free to implement these variables in the way they are ment to be used.
115 (void) client_data;
116 (void) smc_conn;
117
118 if (blocking)
119 gtk_main_quit ();
107 blocking = FALSE;120 blocking = FALSE;
108}121}
109122
@@ -163,6 +176,11 @@
163xpad_session_manager_ice_connection_watch (IceConn ice_conn,176xpad_session_manager_ice_connection_watch (IceConn ice_conn,
164 IcePointer client_data, Bool opening, IcePointer *watch_data)177 IcePointer client_data, Bool opening, IcePointer *watch_data)
165{178{
179 // A dirty way to silence the compiler for these unused variables.
180 // Feel free to implement these variables in the way they are ment to be used.
181 (void) client_data;
182 (void) watch_data;
183
166 int fd = IceConnectionNumber (ice_conn);184 int fd = IceConnectionNumber (ice_conn);
167 185
168 if (opening)186 if (opening)
@@ -192,9 +210,10 @@
192 };210 };
193 SmProp *props[G_N_ELEMENTS (prop)];211 SmProp *props[G_N_ELEMENTS (prop)];
194 struct passwd *pw;212 struct passwd *pw;
195 int i;213 uint i;
196 gchar *pid_str;214 gchar *pid_str;
197 gchar *command = g_strdup (xpad_app_get_program_path ());215 gchar *command = g_strdup (xpad_app_get_program_path ());
216 size_t string_length = 0;
198 217
199 prop[0].vals = vals.clone;218 prop[0].vals = vals.clone;
200 prop[1].vals = vals.program;219 prop[1].vals = vals.program;
@@ -207,28 +226,57 @@
207 }226 }
208 227
209 pw = getpwuid (getuid ());228 pw = getpwuid (getuid ());
210 229
230 // While setting all the properties, safe casts are being used.
211 vals.user->value = pw ? pw->pw_name : "";231 vals.user->value = pw ? pw->pw_name : "";
212 vals.user->length = strlen (vals.user->value);232 string_length = strlen (vals.user->value);
233 if (string_length <= INT_MAX)
234 vals.user->length = (int) string_length;
235 else
236 g_warning("While setting the session manager properties a casting problem has occured. Xpad might not function as expected. Please send a bugreport.");
213 237
214 vals.program->value = command;238 vals.program->value = command;
215 vals.program->length = strlen (vals.program->value);239 string_length = strlen (vals.program->value);
240 if (string_length <= INT_MAX)
241 vals.program->length = (int) string_length;
242 else
243 g_warning("While setting the session manager properties a casting problem has occured. Xpad might not function as expected. Please send a bugreport.");
216 244
217 vals.clone->value = command;245 vals.clone->value = command;
218 vals.clone->length = strlen (vals.clone->value);246 string_length = strlen (vals.clone->value);
247 if (string_length <= INT_MAX)
248 vals.clone->length = (int) string_length;
249 else
250 g_warning("While setting the session manager properties a casting problem has occured. Xpad might not function as expected. Please send a bugreport.");
219 251
220 vals.restart[0].value = command;252 vals.restart[0].value = command;
221 vals.restart[0].length = strlen (vals.restart[0].value);253 string_length = strlen (vals.restart[0].value);
222 254 if (string_length <= INT_MAX)
255 vals.restart[0].length = (int) string_length;
256 else
257 g_warning("While setting the session manager properties a casting problem has occured. Xpad might not function as expected. Please send a bugreport.");
258
223 vals.restart[1].value = "--sm-client-id";259 vals.restart[1].value = "--sm-client-id";
224 vals.restart[1].length = strlen (vals.restart[1].value);260 string_length = strlen (vals.restart[1].value);
225 261 if (string_length <= INT_MAX)
262 vals.restart[1].length = (int) string_length;
263 else
264 g_warning("While setting the session manager properties a casting problem has occured. Xpad might not function as expected. Please send a bugreport.");
265
226 vals.restart[2].value = client_id;266 vals.restart[2].value = client_id;
227 vals.restart[2].length = strlen (vals.restart[2].value);267 string_length = strlen (vals.restart[2].value);
268 if (string_length <= INT_MAX)
269 vals.restart[2].length = (int) string_length;
270 else
271 g_warning("While setting the session manager properties a casting problem has occured. Xpad might not function as expected. Please send a bugreport.");
228 272
229 pid_str = g_strdup_printf ("%i", getpid ());273 pid_str = g_strdup_printf ("%i", getpid ());
230 vals.process->value = pid_str;274 vals.process->value = pid_str;
231 vals.process->length = strlen (vals.process->value);275 string_length = strlen (vals.process->value);
276 if (string_length <= INT_MAX)
277 vals.process->length = (int) string_length;
278 else
279 g_warning("While setting the session manager properties a casting problem has occured. Xpad might not function as expected. Please send a bugreport.");
232 280
233 SmcSetProperties (xpad_session_manager_conn, 4, (SmProp **) &props);281 SmcSetProperties (xpad_session_manager_conn, 4, (SmProp **) &props);
234 282
@@ -270,7 +318,7 @@
270 xpad_ice_fd = -1;318 xpad_ice_fd = -1;
271 IceAddConnectionWatch (xpad_session_manager_ice_connection_watch, NULL);319 IceAddConnectionWatch (xpad_session_manager_ice_connection_watch, NULL);
272 320
273 gdk_set_sm_client_id (client_id);321 gdk_x11_set_sm_client_id (client_id);
274}322}
275323
276void324void
@@ -306,6 +354,10 @@
306static void354static void
307xpad_session_manager_save_global (Bool fast)355xpad_session_manager_save_global (Bool fast)
308{356{
357 // A dirty way to silence the compiler for these unused variables.
358 // Feel free to implement these variables in the way they are ment to be used.
359 (void) fast;
360
309 /* No need to do anything. Currently, all xpad pads are always current with361 /* No need to do anything. Currently, all xpad pads are always current with
310 hard drive. */362 hard drive. */
311}363}
@@ -313,6 +365,10 @@
313static void365static void
314xpad_session_manager_save_local (Bool fast)366xpad_session_manager_save_local (Bool fast)
315{367{
368 // A dirty way to silence the compiler for these unused variables.
369 // Feel free to implement these variables in the way they are ment to be used.
370 (void) fast;
371
316 /* should also save cursor positions and open accessory windows */372 /* should also save cursor positions and open accessory windows */
317 373
318 if (set_props)374 if (set_props)
@@ -327,6 +383,10 @@
327 int save_type, Bool shutdown, int interact_style,383 int save_type, Bool shutdown, int interact_style,
328 Bool fast)384 Bool fast)
329{385{
386 // A dirty way to silence the compiler for these unused variables.
387 // Feel free to implement these variables in the way they are ment to be used.
388 (void) client_data;
389
330 RETURN_IF_BAD_CONN (smc_conn);390 RETURN_IF_BAD_CONN (smc_conn);
331 391
332 xpad_interact_style = interact_style;392 xpad_interact_style = interact_style;
@@ -357,6 +417,10 @@
357static void417static void
358xpad_session_manager_die (SmcConn smc_conn, SmPointer client_data)418xpad_session_manager_die (SmcConn smc_conn, SmPointer client_data)
359{419{
420 // A dirty way to silence the compiler for these unused variables.
421 // Feel free to implement these variables in the way they are ment to be used.
422 (void) client_data;
423
360 RETURN_IF_BAD_CONN (smc_conn);424 RETURN_IF_BAD_CONN (smc_conn);
361 xpad_shutdown = True;425 xpad_shutdown = True;
362 426
@@ -372,6 +436,10 @@
372static void436static void
373xpad_session_manager_shutdown_cancelled (SmcConn smc_conn, SmPointer client_data)437xpad_session_manager_shutdown_cancelled (SmcConn smc_conn, SmPointer client_data)
374{438{
439 // A dirty way to silence the compiler for these unused variables.
440 // Feel free to implement these variables in the way they are ment to be used.
441 (void) client_data;
442
375 RETURN_IF_BAD_CONN (smc_conn);443 RETURN_IF_BAD_CONN (smc_conn);
376 RETURN_IF_NOT_SAVING ();444 RETURN_IF_NOT_SAVING ();
377 xpad_shutdown = False;445 xpad_shutdown = False;
@@ -386,6 +454,10 @@
386static void454static void
387xpad_session_manager_save_complete (SmcConn smc_conn, SmPointer client_data)455xpad_session_manager_save_complete (SmcConn smc_conn, SmPointer client_data)
388{456{
457 // A dirty way to silence the compiler for these unused variables.
458 // Feel free to implement these variables in the way they are ment to be used.
459 (void) client_data;
460
389 RETURN_IF_BAD_CONN (smc_conn);461 RETURN_IF_BAD_CONN (smc_conn);
390 RETURN_IF_NOT_SAVING ();462 RETURN_IF_NOT_SAVING ();
391 463
392464
=== modified file 'src/xpad-settings.c'
--- src/xpad-settings.c 2013-10-18 20:23:43 +0000
+++ src/xpad-settings.c 2013-11-01 20:03:38 +0000
@@ -18,11 +18,12 @@
1818
19*/19*/
2020
21#include "../config.h"
21#include <string.h>22#include <string.h>
22#include "xpad-settings.h"23#include "xpad-settings.h"
23#include "fio.h"24#include "fio.h"
2425
25struct XpadSettingsPrivate 26struct XpadSettingsPrivate
26{27{
27 guint width;28 guint width;
28 guint height;29 guint height;
@@ -34,8 +35,8 @@
34 gboolean has_toolbar;35 gboolean has_toolbar;
35 gboolean autohide_toolbar;36 gboolean autohide_toolbar;
36 gboolean has_scrollbar;37 gboolean has_scrollbar;
37 GdkColor *back;38 GdkRGBA *back;
38 GdkColor *text;39 GdkRGBA *text;
39 gchar *fontname;40 gchar *fontname;
40 GSList *toolbar_buttons;41 GSList *toolbar_buttons;
41};42};
@@ -76,17 +77,12 @@
76static void xpad_settings_dispose (GObject *object);77static void xpad_settings_dispose (GObject *object);
77static void xpad_settings_finalize (GObject *object);78static void xpad_settings_finalize (GObject *object);
7879
79static XpadSettings *_xpad_settings = NULL;
80static guint signals[LAST_SIGNAL] = { 0 };80static guint signals[LAST_SIGNAL] = { 0 };
8181
82XpadSettings *82XpadSettings *
83xpad_settings (void)83xpad_settings_new (void)
84{84{
85 /* Singleton class */85 return g_object_new (XPAD_TYPE_SETTINGS, NULL);
86 if (!_xpad_settings)
87 _xpad_settings = XPAD_SETTINGS (g_object_new (XPAD_TYPE_SETTINGS, NULL));
88
89 return _xpad_settings;
90}86}
9187
92static void88static void
@@ -198,7 +194,7 @@
198 g_param_spec_boxed ("text_color",194 g_param_spec_boxed ("text_color",
199 "Text Color",195 "Text Color",
200 "Default color of pad text",196 "Default color of pad text",
201 GDK_TYPE_COLOR,197 GDK_TYPE_RGBA,
202 G_PARAM_READWRITE));198 G_PARAM_READWRITE));
203 199
204 g_object_class_install_property (gobject_class,200 g_object_class_install_property (gobject_class,
@@ -206,7 +202,7 @@
206 g_param_spec_boxed ("back_color",202 g_param_spec_boxed ("back_color",
207 "Back Color",203 "Back Color",
208 "Default color of pad background",204 "Default color of pad background",
209 GDK_TYPE_COLOR,205 GDK_TYPE_RGBA,
210 G_PARAM_READWRITE));206 G_PARAM_READWRITE));
211 207
212 /* Signals */208 /* Signals */
@@ -223,25 +219,12 @@
223static void219static void
224xpad_settings_init (XpadSettings *settings)220xpad_settings_init (XpadSettings *settings)
225{221{
226 GdkColor back, text;
227
228 settings->priv = xpad_settings_get_instance_private(settings);222 settings->priv = xpad_settings_get_instance_private(settings);
229 223
230 /* A pleasant light yellow color, similar to 224 /* A pleasant light yellow background color, similar to commercial sticky notes, with black text. */
231 commercial sticky notes. */225 settings->priv->text = gdk_rgba_copy(&(GdkRGBA) {0, 0, 0, 1});
232 back.pixel = 0;226 settings->priv->back = gdk_rgba_copy(&(GdkRGBA) {1, 0.933334350586, 0.6, 1});
233 back.red = 65535;227
234 back.green = 61166;
235 back.blue = 39321;
236 settings->priv->back = gdk_color_copy (&back);
237
238 /* Black */
239 text.pixel = 0;
240 text.red = 0;
241 text.green = 0;
242 text.blue = 0;
243 settings->priv->text = gdk_color_copy (&text);
244
245 settings->priv->width = 200;228 settings->priv->width = 200;
246 settings->priv->height = 200;229 settings->priv->height = 200;
247 settings->priv->has_decorations = TRUE;230 settings->priv->has_decorations = TRUE;
@@ -276,9 +259,9 @@
276 g_slist_free (settings->priv->toolbar_buttons);259 g_slist_free (settings->priv->toolbar_buttons);
277260
278 if (settings->priv->text)261 if (settings->priv->text)
279 gdk_color_free (settings->priv->text);262 gdk_rgba_free (settings->priv->text);
280 if (settings->priv->back)263 if (settings->priv->back)
281 gdk_color_free (settings->priv->back);264 gdk_rgba_free (settings->priv->back);
282265
283 g_free (settings->priv->fontname);266 g_free (settings->priv->fontname);
284 267
@@ -575,13 +558,13 @@
575 return settings->priv->toolbar_buttons;558 return settings->priv->toolbar_buttons;
576}559}
577560
578void xpad_settings_set_back_color (XpadSettings *settings, const GdkColor *back)561void xpad_settings_set_back_color (XpadSettings *settings, const GdkRGBA *back)
579{562{
580 if (settings->priv->back)563 if (settings->priv->back)
581 gdk_color_free (settings->priv->back);564 gdk_rgba_free (settings->priv->back);
582 565
583 if (back)566 if (back)
584 settings->priv->back = gdk_color_copy (back);567 settings->priv->back = gdk_rgba_copy (back);
585 else568 else
586 settings->priv->back = NULL;569 settings->priv->back = NULL;
587 570
@@ -590,18 +573,18 @@
590 g_object_notify (G_OBJECT (settings), "back_color");573 g_object_notify (G_OBJECT (settings), "back_color");
591}574}
592575
593G_CONST_RETURN GdkColor *xpad_settings_get_back_color (XpadSettings *settings)576G_CONST_RETURN GdkRGBA *xpad_settings_get_back_color (XpadSettings *settings)
594{577{
595 return settings->priv->back;578 return settings->priv->back;
596}579}
597580
598void xpad_settings_set_text_color (XpadSettings *settings, const GdkColor *text)581void xpad_settings_set_text_color (XpadSettings *settings, const GdkRGBA *text)
599{582{
600 if (settings->priv->text)583 if (settings->priv->text)
601 gdk_color_free (settings->priv->text);584 gdk_rgba_free (settings->priv->text);
602 585
603 if (text)586 if (text)
604 settings->priv->text = gdk_color_copy (text);587 settings->priv->text = gdk_rgba_copy (text);
605 else588 else
606 settings->priv->text = NULL;589 settings->priv->text = NULL;
607 590
@@ -610,7 +593,7 @@
610 g_object_notify (G_OBJECT (settings), "text_color");593 g_object_notify (G_OBJECT (settings), "text_color");
611}594}
612595
613G_CONST_RETURN GdkColor *xpad_settings_get_text_color (XpadSettings *settings)596G_CONST_RETURN GdkRGBA *xpad_settings_get_text_color (XpadSettings *settings)
614{597{
615 return settings->priv->text;598 return settings->priv->text;
616}599}
@@ -767,18 +750,23 @@
767 * We need to set up int values for all these to take the value from the file.750 * We need to set up int values for all these to take the value from the file.
768 * These will be assigned back to the appropriate values after load.751 * These will be assigned back to the appropriate values after load.
769 */752 */
753
770 gchar *buttons = NULL;754 gchar *buttons = NULL;
771 GdkColor text = {0}, back = {0};755 gchar *text_color_string = NULL;
756 gchar *background_color_string = NULL;
757 GdkRGBA text = {0, 0, 0, 0};
758 GdkRGBA back = {0, 0, 0, 0};
772 gboolean use_text, use_back;759 gboolean use_text, use_back;
773 760
774 use_text = settings->priv->text ? TRUE : FALSE;761 use_text = settings->priv->text ? TRUE : FALSE;
775 if (settings->priv->text)762 if (settings->priv->text)
776 text = *settings->priv->text;763 text = *settings->priv->text;
777 764
778 use_back = settings->priv->back ? TRUE : FALSE;765 use_back = settings->priv->back ? TRUE : FALSE;
779 if (settings->priv->back)766 if (settings->priv->back)
780 back = *settings->priv->back;767 back = *settings->priv->back;
781 768
769 // get all the values from the default-style text file in the forms of booleans, ints or strings.
782 if (fio_get_values_from_file (filename, 770 if (fio_get_values_from_file (filename,
783 "b|decorations", &settings->priv->has_decorations,771 "b|decorations", &settings->priv->has_decorations,
784 "u|height", &settings->priv->height,772 "u|height", &settings->priv->height,
@@ -787,13 +775,9 @@
787 "b|edit_lock", &settings->priv->edit_lock,775 "b|edit_lock", &settings->priv->edit_lock,
788 "b|sticky_on_start", &settings->priv->sticky,776 "b|sticky_on_start", &settings->priv->sticky,
789 "u|tray_click_configuration", &settings->priv->tray_click_configuration,777 "u|tray_click_configuration", &settings->priv->tray_click_configuration,
790 "h|back_red", &back.red,778 "s|back", &background_color_string,
791 "h|back_green", &back.green,
792 "h|back_blue", &back.blue,
793 "b|use_back", &use_back,779 "b|use_back", &use_back,
794 "h|text_red", &text.red,780 "s|text", &text_color_string,
795 "h|text_green", &text.green,
796 "h|text_blue", &text.blue,
797 "b|use_text", &use_text,781 "b|use_text", &use_text,
798 "s|fontname", &settings->priv->fontname,782 "s|fontname", &settings->priv->fontname,
799 "b|toolbar", &settings->priv->has_toolbar,783 "b|toolbar", &settings->priv->has_toolbar,
@@ -802,21 +786,46 @@
802 "s|buttons", &buttons,786 "s|buttons", &buttons,
803 NULL))787 NULL))
804 return;788 return;
805 789
806 if (use_text)790 if (use_text)
807 {791 {
808 gdk_color_free (settings->priv->text);792 gdk_rgba_free (settings->priv->text);
809 settings->priv->text = gdk_color_copy (&text);793
810 }794 // If, for some reason, one of the colors could not be retrieved
811795 // (for example due to the migration to the new GdkRGBA colors), set the color to the default.
812 gdk_color_free (settings->priv->back);796 if (text_color_string == NULL) {
813 if (use_back)797 text = (GdkRGBA) {0, 0, 0, 1};
814 settings->priv->back = gdk_color_copy (&back);798 }
799 else {
800 // If, for some reason, the parsing of the colors fail, set the color to the default.
801 if (!gdk_rgba_parse (&text, text_color_string)) {
802 text = (GdkRGBA) {0, 0, 0, 1};
803 }
804 }
805
806 settings->priv->text = gdk_rgba_copy (&text);
807 }
808
809 gdk_rgba_free (settings->priv->back);
810 if (use_back) {
811 // If, for some reason, one of the colors could not be retrieved
812 // (for example due to the migration to the new GdkRGBA colors), set the color to the default.
813 if (background_color_string == NULL) {
814 back = (GdkRGBA) {1, 0.933334350586, 0.6, 1};
815 }
816 else {
817 // If, for some reason, the parsing of the colors fail, set the color to the default.
818 if (!gdk_rgba_parse (&back, background_color_string)) {
819 back = (GdkRGBA) {1, 0.933334350586, 0.6, 1};
820 }
821 }
822
823 settings->priv->back = gdk_rgba_copy (&back);
824 }
815 else825 else
816 settings->priv->back = NULL;826 settings->priv->back = NULL;
817827
818 if (settings->priv->fontname &&828 if (settings->priv->fontname && strcmp (settings->priv->fontname, "NULL") == 0)
819 strcmp (settings->priv->fontname, "NULL") == 0)
820 {829 {
821 g_free (settings->priv->fontname);830 g_free (settings->priv->fontname);
822 settings->priv->fontname = NULL;831 settings->priv->fontname = NULL;
@@ -841,7 +850,7 @@
841 {850 {
842 settings->priv->toolbar_buttons = 851 settings->priv->toolbar_buttons =
843 g_slist_append (settings->priv->toolbar_buttons,852 g_slist_append (settings->priv->toolbar_buttons,
844 g_strstrip (button_names[i])); /* takes ownership of string */853 g_strstrip (button_names[i])); // takes ownership of string
845 }854 }
846 855
847 g_free (button_names);856 g_free (button_names);
@@ -879,13 +888,9 @@
879 "b|edit_lock", settings->priv->edit_lock,888 "b|edit_lock", settings->priv->edit_lock,
880 "b|sticky_on_start", settings->priv->sticky,889 "b|sticky_on_start", settings->priv->sticky,
881 "u|tray_click_configuration", settings->priv->tray_click_configuration,890 "u|tray_click_configuration", settings->priv->tray_click_configuration,
882 "h|back_red", settings->priv->back ? settings->priv->back->red : 0,891 "s|back", settings->priv->back ? gdk_rgba_to_string (settings->priv->back) : "NULL",
883 "h|back_green", settings->priv->back ? settings->priv->back->green : 0,
884 "h|back_blue", settings->priv->back ? settings->priv->back->blue : 0,
885 "b|use_back", settings->priv->back ? TRUE : FALSE,892 "b|use_back", settings->priv->back ? TRUE : FALSE,
886 "h|text_red", settings->priv->text ? settings->priv->text->red : 0,893 "s|text", settings->priv->text ? gdk_rgba_to_string (settings->priv->text) : "NULL",
887 "h|text_green", settings->priv->text ? settings->priv->text->green : 0,
888 "h|text_blue", settings->priv->text ? settings->priv->text->blue : 0,
889 "b|use_text", settings->priv->text ? TRUE : FALSE,894 "b|use_text", settings->priv->text ? TRUE : FALSE,
890 "s|fontname", settings->priv->fontname ? settings->priv->fontname : "NULL",895 "s|fontname", settings->priv->fontname ? settings->priv->fontname : "NULL",
891 "b|toolbar", settings->priv->has_toolbar,896 "b|toolbar", settings->priv->has_toolbar,
892897
=== modified file 'src/xpad-settings.h'
--- src/xpad-settings.h 2013-10-18 20:23:43 +0000
+++ src/xpad-settings.h 2013-11-01 20:03:38 +0000
@@ -52,7 +52,7 @@
5252
53GType xpad_settings_get_type (void);53GType xpad_settings_get_type (void);
5454
55XpadSettings *xpad_settings (void);55XpadSettings *xpad_settings_new (void);
5656
57void xpad_settings_set_width (XpadSettings *settings, guint width);57void xpad_settings_set_width (XpadSettings *settings, guint width);
58guint xpad_settings_get_width (XpadSettings *settings);58guint xpad_settings_get_width (XpadSettings *settings);
@@ -88,15 +88,16 @@
88gboolean xpad_settings_remove_last_toolbar_button (XpadSettings *settings);88gboolean xpad_settings_remove_last_toolbar_button (XpadSettings *settings);
89G_CONST_RETURN GSList *xpad_settings_get_toolbar_buttons (XpadSettings *settings);89G_CONST_RETURN GSList *xpad_settings_get_toolbar_buttons (XpadSettings *settings);
9090
91void xpad_settings_set_back_color (XpadSettings *settings, const GdkColor *back);91void xpad_settings_set_back_color (XpadSettings *settings, const GdkRGBA *back);
92G_CONST_RETURN GdkColor *xpad_settings_get_back_color (XpadSettings *settings);92G_CONST_RETURN GdkRGBA *xpad_settings_get_back_color (XpadSettings *settings);
9393
94void xpad_settings_set_text_color (XpadSettings *settings, const GdkColor *text);94void xpad_settings_set_text_color (XpadSettings *settings, const GdkRGBA *text);
95G_CONST_RETURN GdkColor *xpad_settings_get_text_color (XpadSettings *settings);95G_CONST_RETURN GdkRGBA *xpad_settings_get_text_color (XpadSettings *settings);
9696
97void xpad_settings_set_fontname (XpadSettings *settings, const gchar *fontname);97void xpad_settings_set_fontname (XpadSettings *settings, const gchar *fontname);
98G_CONST_RETURN gchar *xpad_settings_get_fontname (XpadSettings *settings);98G_CONST_RETURN gchar *xpad_settings_get_fontname (XpadSettings *settings);
9999
100void xpad_settings_set_tray_click_handler (XpadSettings *settings, guint conf);
100guint xpad_settings_get_tray_click_handler(XpadSettings *settings);101guint xpad_settings_get_tray_click_handler(XpadSettings *settings);
101102
102G_END_DECLS103G_END_DECLS
103104
=== modified file 'src/xpad-text-buffer.c'
--- src/xpad-text-buffer.c 2013-10-23 18:30:54 +0000
+++ src/xpad-text-buffer.c 2013-11-01 20:03:38 +0000
@@ -17,6 +17,7 @@
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */18 */
1919
20#include "../config.h"
20#include "xpad-text-buffer.h"21#include "xpad-text-buffer.h"
21#include "xpad-undo.h"22#include "xpad-undo.h"
22#include "xpad-pad.h"23#include "xpad-pad.h"
2324
=== modified file 'src/xpad-text-view.c'
--- src/xpad-text-view.c 2013-10-18 18:31:20 +0000
+++ src/xpad-text-view.c 2013-11-01 20:03:38 +0000
@@ -16,9 +16,11 @@
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */17 */
1818
19#include "../config.h"
19#include "xpad-text-view.h"20#include "xpad-text-view.h"
20#include "xpad-text-buffer.h"21#include "xpad-text-buffer.h"
21#include "xpad-settings.h"22#include "xpad-settings.h"
23#include "xpad-app.h"
2224
23struct XpadTextViewPrivate 25struct XpadTextViewPrivate
24{26{
@@ -42,9 +44,7 @@
42static void xpad_text_view_notify_edit_lock (XpadTextView *view);44static void xpad_text_view_notify_edit_lock (XpadTextView *view);
43static void xpad_text_view_notify_editable (XpadTextView *view);45static void xpad_text_view_notify_editable (XpadTextView *view);
44static void xpad_text_view_notify_fontname (XpadTextView *view);46static void xpad_text_view_notify_fontname (XpadTextView *view);
45static void xpad_text_view_notify_text_color (XpadTextView *view);47static void xpad_text_view_notify_colors (XpadTextView *view);
46static void xpad_text_view_notify_back_color (XpadTextView *view);
47static void xpad_text_view_style_set (GtkWidget *widget, GtkStyle *previous_style);
4848
49enum49enum
50{50{
@@ -57,7 +57,7 @@
57GtkWidget *57GtkWidget *
58xpad_text_view_new (void)58xpad_text_view_new (void)
59{59{
60 return GTK_WIDGET (g_object_new (XPAD_TYPE_TEXT_VIEW, NULL));60 return GTK_WIDGET (g_object_new (XPAD_TYPE_TEXT_VIEW, "follow-font-style", TRUE, "follow-color-style", TRUE, NULL));
61}61}
6262
63static void63static void
@@ -113,14 +113,12 @@
113 g_signal_connect_after (view, "focus-out-event", G_CALLBACK (xpad_text_view_focus_out_event), NULL);113 g_signal_connect_after (view, "focus-out-event", G_CALLBACK (xpad_text_view_focus_out_event), NULL);
114 g_signal_connect (view, "realize", G_CALLBACK (xpad_text_view_realize), NULL);114 g_signal_connect (view, "realize", G_CALLBACK (xpad_text_view_realize), NULL);
115 g_signal_connect (view, "notify::editable", G_CALLBACK (xpad_text_view_notify_editable), NULL);115 g_signal_connect (view, "notify::editable", G_CALLBACK (xpad_text_view_notify_editable), NULL);
116 g_signal_connect (view, "style-set", G_CALLBACK (xpad_text_view_style_set), NULL);116 g_signal_connect_swapped (xpad_global_settings, "notify::edit-lock", G_CALLBACK (xpad_text_view_notify_edit_lock), view);
117 g_signal_connect_swapped (xpad_settings (), "notify::edit-lock", G_CALLBACK (xpad_text_view_notify_edit_lock), view);117 view->priv->notify_font_handler = g_signal_connect_swapped (xpad_global_settings, "notify::fontname", G_CALLBACK (xpad_text_view_notify_fontname), view);
118 view->priv->notify_font_handler = g_signal_connect_swapped (xpad_settings (), "notify::fontname", G_CALLBACK (xpad_text_view_notify_fontname), view);118 view->priv->notify_text_handler = g_signal_connect_swapped (xpad_global_settings, "notify::text-color", G_CALLBACK (xpad_text_view_notify_colors), view);
119 view->priv->notify_text_handler = g_signal_connect_swapped (xpad_settings (), "notify::text-color", G_CALLBACK (xpad_text_view_notify_text_color), view);119 view->priv->notify_back_handler = g_signal_connect_swapped (xpad_global_settings, "notify::back-color", G_CALLBACK (xpad_text_view_notify_colors), view);
120 view->priv->notify_back_handler = g_signal_connect_swapped (xpad_settings (), "notify::back-color", G_CALLBACK (xpad_text_view_notify_back_color), view);
121 120
122 xpad_text_view_notify_text_color (view);121 xpad_text_view_notify_colors (view);
123 xpad_text_view_notify_back_color (view);
124 xpad_text_view_notify_fontname (view);122 xpad_text_view_notify_fontname (view);
125}123}
126124
@@ -139,19 +137,27 @@
139static void137static void
140xpad_text_view_finalize (GObject *object)138xpad_text_view_finalize (GObject *object)
141{139{
140 XpadTextView *view = XPAD_TEXT_VIEW (object);
141
142 g_signal_handlers_disconnect_matched (xpad_global_settings, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, view);
143
142 G_OBJECT_CLASS (xpad_text_view_parent_class)->finalize (object);144 G_OBJECT_CLASS (xpad_text_view_parent_class)->finalize (object);
143}145}
144146
145static void147static void
146xpad_text_view_realize (XpadTextView *view)148xpad_text_view_realize (XpadTextView *view)
147{149{
148 gtk_text_view_set_editable (GTK_TEXT_VIEW (view), !xpad_settings_get_edit_lock (xpad_settings ()));150 gtk_text_view_set_editable (GTK_TEXT_VIEW (view), !xpad_settings_get_edit_lock (xpad_global_settings));
149}151}
150152
151static gboolean153static gboolean
152xpad_text_view_focus_out_event (GtkWidget *widget, GdkEventFocus *event)154xpad_text_view_focus_out_event (GtkWidget *widget, GdkEventFocus *event)
153{155{
154 if (xpad_settings_get_edit_lock (xpad_settings ()))156 // A dirty way to silence the compiler for these unused variables.
157 // Feel free to implement these variables in the way they are ment to be used.
158 (void) event;
159
160 if (xpad_settings_get_edit_lock (xpad_global_settings))
155 {161 {
156 gtk_text_view_set_editable (GTK_TEXT_VIEW (widget), FALSE);162 gtk_text_view_set_editable (GTK_TEXT_VIEW (widget), FALSE);
157 return TRUE;163 return TRUE;
@@ -164,7 +170,7 @@
164xpad_text_view_button_press_event (GtkWidget *widget, GdkEventButton *event)170xpad_text_view_button_press_event (GtkWidget *widget, GdkEventButton *event)
165{171{
166 if (event->button == 1 &&172 if (event->button == 1 &&
167 xpad_settings_get_edit_lock (xpad_settings ()) &&173 xpad_settings_get_edit_lock (xpad_global_settings) &&
168 !gtk_text_view_get_editable (GTK_TEXT_VIEW (widget)))174 !gtk_text_view_get_editable (GTK_TEXT_VIEW (widget)))
169 {175 {
170 if (event->type == GDK_2BUTTON_PRESS)176 if (event->type == GDK_2BUTTON_PRESS)
@@ -174,7 +180,7 @@
174 }180 }
175 else if (event->type == GDK_BUTTON_PRESS)181 else if (event->type == GDK_BUTTON_PRESS)
176 {182 {
177 gtk_window_begin_move_drag (GTK_WINDOW (gtk_widget_get_toplevel (widget)), event->button, event->x_root, event->y_root, event->time);183 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);
178 return TRUE;184 return TRUE;
179 }185 }
180 }186 }
@@ -186,7 +192,7 @@
186xpad_text_view_notify_edit_lock (XpadTextView *view)192xpad_text_view_notify_edit_lock (XpadTextView *view)
187{193{
188 /* chances are good that they don't have the text view focused while it changed, so make non-editable if edit lock turned on */194 /* chances are good that they don't have the text view focused while it changed, so make non-editable if edit lock turned on */
189 gtk_text_view_set_editable (GTK_TEXT_VIEW (view), !xpad_settings_get_edit_lock (xpad_settings ()));195 gtk_text_view_set_editable (GTK_TEXT_VIEW (view), !xpad_settings_get_edit_lock (xpad_global_settings));
190}196}
191197
192static void198static void
@@ -203,71 +209,53 @@
203 gdk_window_set_cursor (gtk_text_view_get_window (GTK_TEXT_VIEW (view), GTK_TEXT_WINDOW_TEXT), cursor);209 gdk_window_set_cursor (gtk_text_view_get_window (GTK_TEXT_VIEW (view), GTK_TEXT_WINDOW_TEXT), cursor);
204 210
205 if (cursor)211 if (cursor)
206 gdk_cursor_unref (cursor);212 g_object_unref (cursor);
207}
208
209/* Adjust the cursor to match the text color */
210static void
211xpad_text_view_style_set (GtkWidget *widget, GtkStyle *previous_style)
212{
213 GdkColor c;
214
215 /* text color changes */
216 c = gtk_widget_get_style (widget)->text[GTK_STATE_NORMAL];
217 if (!previous_style || !gdk_color_equal (&c, &previous_style->text[GTK_STATE_NORMAL]))
218 {
219 const gchar *name = gtk_widget_get_name (widget);
220 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);
221 gtk_rc_parse_string (style_string);
222 g_free (style_string);
223 gtk_widget_reset_rc_styles (widget);
224 }
225
226 /* base color changes */
227 c = gtk_widget_get_style (widget)->base[GTK_STATE_NORMAL];
228 if (!previous_style || !gdk_color_equal (&c, &previous_style->base[GTK_STATE_NORMAL]))
229 {
230 gtk_widget_modify_bg (widget, GTK_STATE_NORMAL, &c);
231 }
232}213}
233214
234static void215static void
235xpad_text_view_notify_fontname (XpadTextView *view)216xpad_text_view_notify_fontname (XpadTextView *view)
236{217{
237 const gchar *font = xpad_settings_get_fontname (xpad_settings ());218 const gchar *font = xpad_settings_get_fontname (xpad_global_settings);
238 PangoFontDescription *fontdesc;219 PangoFontDescription *fontdesc;
239 220
240 fontdesc = font ? pango_font_description_from_string (font) : NULL;221 fontdesc = font ? pango_font_description_from_string (font) : NULL;
241 gtk_widget_modify_font (GTK_WIDGET (view), fontdesc);222 gtk_widget_override_font (GTK_WIDGET (view), fontdesc);
242 if (fontdesc)223 if (fontdesc)
243 pango_font_description_free (fontdesc);224 pango_font_description_free (fontdesc);
244}225}
245226
246static void227// Update the colors of the textview
247xpad_text_view_notify_text_color (XpadTextView *view)228static void
248{229xpad_text_view_notify_colors (XpadTextView *view)
249 gtk_widget_modify_text (GTK_WIDGET (view), GTK_STATE_NORMAL, xpad_settings_get_text_color (xpad_settings ()));230{
250}231 // Set the colors of this individual pad to the global setting preference.
251232 const GdkRGBA *text_color = xpad_settings_get_text_color (xpad_global_settings);
252static void233 const GdkRGBA *back_color = xpad_settings_get_back_color (xpad_global_settings);
253xpad_text_view_notify_back_color (XpadTextView *view)234
254{235 gtk_widget_override_cursor (GTK_WIDGET (view), text_color, text_color);
255 gtk_widget_modify_base (GTK_WIDGET (view), GTK_STATE_NORMAL, xpad_settings_get_back_color (xpad_settings ()));236 gtk_widget_override_color (GTK_WIDGET (view), GTK_STATE_FLAG_NORMAL, text_color);
237 gtk_widget_override_background_color (GTK_WIDGET (view), GTK_STATE_FLAG_NORMAL, back_color);
238
239 // Inverse the text and background colors for selected text, so it is likely to be visible by any choice of the colors.
240 gtk_widget_override_color (GTK_WIDGET (view), GTK_STATE_FLAG_SELECTED, back_color);
241 gtk_widget_override_background_color (GTK_WIDGET (view), GTK_STATE_FLAG_SELECTED, text_color);
256}242}
257243
258void244void
259xpad_text_view_set_follow_font_style (XpadTextView *view, gboolean follow)245xpad_text_view_set_follow_font_style (XpadTextView *view, gboolean follow)
260{246{
247 g_return_if_fail (view);
248
261 if (follow != view->priv->follow_font_style)249 if (follow != view->priv->follow_font_style)
262 {250 {
263 if (follow)251 if (follow)
264 {252 {
265 g_signal_handler_unblock (xpad_settings (), view->priv->notify_font_handler);253 g_signal_handler_unblock (xpad_global_settings, view->priv->notify_font_handler);
266 xpad_text_view_notify_fontname (view);254 xpad_text_view_notify_fontname (view);
267 }255 }
268 else256 else
269 {257 {
270 g_signal_handler_block (xpad_settings (), view->priv->notify_font_handler);258 g_signal_handler_block (xpad_global_settings, view->priv->notify_font_handler);
271 }259 }
272 }260 }
273 261
@@ -279,37 +267,44 @@
279gboolean267gboolean
280xpad_text_view_get_follow_font_style (XpadTextView *view)268xpad_text_view_get_follow_font_style (XpadTextView *view)
281{269{
282 return view->priv->follow_font_style;270 if (view == NULL)
271 return TRUE;
272 else
273 return view->priv->follow_font_style;
283}274}
284275
285void276void
286xpad_text_view_set_follow_color_style (XpadTextView *view, gboolean follow)277xpad_text_view_set_follow_color_style (XpadTextView *view, gboolean follow)
287{278{
279 g_return_if_fail (view);
280
288 if (follow != view->priv->follow_color_style)281 if (follow != view->priv->follow_color_style)
289 {282 {
290 if (follow)283 if (follow)
291 {284 {
292 g_signal_handler_unblock (xpad_settings (), view->priv->notify_text_handler);285 xpad_text_view_notify_colors (view);
293 g_signal_handler_unblock (xpad_settings (), view->priv->notify_back_handler);286 g_signal_handler_unblock (xpad_global_settings, view->priv->notify_text_handler);
294 xpad_text_view_notify_text_color (view);287 g_signal_handler_unblock (xpad_global_settings, view->priv->notify_back_handler);
295 xpad_text_view_notify_back_color (view);
296 }288 }
297 else289 else
298 {290 {
299 g_signal_handler_block (xpad_settings (), view->priv->notify_text_handler);291 g_signal_handler_block (xpad_global_settings, view->priv->notify_text_handler);
300 g_signal_handler_block (xpad_settings (), view->priv->notify_back_handler);292 g_signal_handler_block (xpad_global_settings, view->priv->notify_back_handler);
301 }293 }
294
295 view->priv->follow_color_style = follow;
302 }296 }
303 297
304 view->priv->follow_color_style = follow;
305
306 g_object_notify (G_OBJECT (view), "follow_color_style");298 g_object_notify (G_OBJECT (view), "follow_color_style");
307}299}
308300
309gboolean301gboolean
310xpad_text_view_get_follow_color_style (XpadTextView *view)302xpad_text_view_get_follow_color_style (XpadTextView *view)
311{303{
312 return view->priv->follow_color_style;304 if (view == NULL)
305 return TRUE;
306 else
307 return view->priv->follow_color_style;
313}308}
314309
315static void310static void
316311
=== modified file 'src/xpad-toolbar.c'
--- src/xpad-toolbar.c 2013-10-18 18:31:20 +0000
+++ src/xpad-toolbar.c 2013-11-01 20:03:38 +0000
@@ -25,6 +25,7 @@
25#include "xpad-toolbar.h"25#include "xpad-toolbar.h"
26#include "xpad-settings.h"26#include "xpad-settings.h"
27#include "xpad-grip-tool-item.h"27#include "xpad-grip-tool-item.h"
28#include "xpad-app.h"
2829
29struct XpadToolbarPrivate30struct XpadToolbarPrivate
30{31{
@@ -279,7 +280,7 @@
279 "toolbar-style", GTK_TOOLBAR_ICONS,280 "toolbar-style", GTK_TOOLBAR_ICONS,
280 NULL);281 NULL);
281 282
282 g_signal_connect_swapped (xpad_settings (), "change-buttons", G_CALLBACK (xpad_toolbar_change_buttons), toolbar);283 g_signal_connect_swapped (xpad_global_settings, "change-buttons", G_CALLBACK (xpad_toolbar_change_buttons), toolbar);
283 284
284 xpad_toolbar_change_buttons (toolbar);285 xpad_toolbar_change_buttons (toolbar);
285}286}
@@ -288,7 +289,7 @@
288xpad_toolbar_dispose (GObject *object)289xpad_toolbar_dispose (GObject *object)
289{290{
290 XpadToolbar *toolbar = XPAD_TOOLBAR (object);291 XpadToolbar *toolbar = XPAD_TOOLBAR (object);
291 292
292 if (toolbar->priv->pad) {293 if (toolbar->priv->pad) {
293 g_object_unref (toolbar->priv->pad);294 g_object_unref (toolbar->priv->pad);
294 toolbar->priv->pad = NULL;295 toolbar->priv->pad = NULL;
@@ -346,6 +347,10 @@
346static G_CONST_RETURN XpadToolbarButton *347static G_CONST_RETURN XpadToolbarButton *
347xpad_toolbar_button_lookup (XpadToolbar *toolbar, const gchar *name)348xpad_toolbar_button_lookup (XpadToolbar *toolbar, const gchar *name)
348{349{
350 // A dirty way to silence the compiler for these unused variables.
351 // Feel free to implement these variables in the way they are ment to be used.
352 (void) toolbar;
353
349 guint i;354 guint i;
350 for (i = 0; i < G_N_ELEMENTS (buttons); i++)355 for (i = 0; i < G_N_ELEMENTS (buttons); i++)
351 if (!g_ascii_strcasecmp (name, buttons[i].name))356 if (!g_ascii_strcasecmp (name, buttons[i].name))
@@ -424,7 +429,7 @@
424 for (j = 0; j < G_N_ELEMENTS (buttons); j++)429 for (j = 0; j < G_N_ELEMENTS (buttons); j++)
425 g_object_set_data (G_OBJECT (toolbar), buttons[j].name, NULL);430 g_object_set_data (G_OBJECT (toolbar), buttons[j].name, NULL);
426 431
427 slist = xpad_settings_get_toolbar_buttons (xpad_settings ());432 slist = xpad_settings_get_toolbar_buttons (xpad_global_settings);
428 for (stemp = slist; stemp; stemp = stemp->next)433 for (stemp = slist; stemp; stemp = stemp->next)
429 {434 {
430 const XpadToolbarButton *button;435 const XpadToolbarButton *button;
@@ -468,19 +473,19 @@
468static void473static void
469xpad_toolbar_remove_all_buttons ()474xpad_toolbar_remove_all_buttons ()
470{475{
471 xpad_settings_remove_all_toolbar_buttons (xpad_settings ());476 xpad_settings_remove_all_toolbar_buttons (xpad_global_settings);
472}477}
473478
474static void479static void
475xpad_toolbar_remove_last_button ()480xpad_toolbar_remove_last_button ()
476{481{
477 xpad_settings_remove_last_toolbar_button (xpad_settings ());482 xpad_settings_remove_last_toolbar_button (xpad_global_settings);
478}483}
479484
480static void485static void
481xpad_toolbar_add_button (const gchar *name)486xpad_toolbar_add_button (const gchar *name)
482{487{
483 xpad_settings_add_toolbar_button (xpad_settings (), name);488 xpad_settings_add_toolbar_button (xpad_global_settings, name);
484}489}
485490
486static void491static void
@@ -492,13 +497,18 @@
492static gboolean497static gboolean
493xpad_toolbar_popup_context_menu (GtkToolbar *toolbar, gint x, gint y, gint button)498xpad_toolbar_popup_context_menu (GtkToolbar *toolbar, gint x, gint y, gint button)
494{499{
500 // A dirty way to silence the compiler for these unused variables.
501 // Feel free to implement these variables in the way they are ment to be used.
502 (void) x;
503 (void) y;
504
495 GtkWidget *menu;505 GtkWidget *menu;
496 const GSList *current_buttons;506 const GSList *current_buttons;
497 guint i;507 guint i;
498 508
499 menu = gtk_menu_new ();509 menu = gtk_menu_new ();
500 510
501 current_buttons = xpad_settings_get_toolbar_buttons (xpad_settings ());511 current_buttons = xpad_settings_get_toolbar_buttons (xpad_global_settings);
502512
503 gboolean is_button = FALSE;513 gboolean is_button = FALSE;
504 514
@@ -679,7 +689,7 @@
679689
680 button_num = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (button), "xpad-button-num"));690 button_num = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (button), "xpad-button-num"));
681691
682 xpad_settings_remove_toolbar_button (xpad_settings (), button_num);692 xpad_settings_remove_toolbar_button (xpad_global_settings, button_num);
683}693}
684694
685static void695static void
@@ -731,7 +741,7 @@
731static gboolean741static gboolean
732xpad_toolbar_move_button_move_keyboard (XpadToolbar *toolbar, GdkEventKey *event)742xpad_toolbar_move_button_move_keyboard (XpadToolbar *toolbar, GdkEventKey *event)
733{743{
734 if (event->keyval == GDK_Left || event->keyval == GDK_KP_Left)744 if (event->keyval == GDK_KEY_Left || event->keyval == GDK_KEY_KP_Left)
735 {745 {
736 if (!toolbar->priv->move_removed)746 if (!toolbar->priv->move_removed)
737 {747 {
@@ -744,7 +754,7 @@
744754
745 gtk_toolbar_set_drop_highlight_item (GTK_TOOLBAR (toolbar), toolbar->priv->move_button, toolbar->priv->move_index);755 gtk_toolbar_set_drop_highlight_item (GTK_TOOLBAR (toolbar), toolbar->priv->move_button, toolbar->priv->move_index);
746 }756 }
747 else if (event->keyval == GDK_Right || event->keyval == GDK_KP_Right)757 else if (event->keyval == GDK_KEY_Right || event->keyval == GDK_KEY_KP_Right)
748 {758 {
749 gint max;759 gint max;
750760
@@ -761,7 +771,7 @@
761771
762 gtk_toolbar_set_drop_highlight_item (GTK_TOOLBAR (toolbar), toolbar->priv->move_button, toolbar->priv->move_index);772 gtk_toolbar_set_drop_highlight_item (GTK_TOOLBAR (toolbar), toolbar->priv->move_button, toolbar->priv->move_index);
763 }773 }
764 else if (event->keyval == GDK_space || event->keyval == GDK_KP_Space || event->keyval == GDK_Return || event->keyval == GDK_KP_Enter)774 else if (event->keyval == GDK_KEY_space || event->keyval == GDK_KEY_KP_Space || event->keyval == GDK_KEY_Return || event->keyval == GDK_KEY_KP_Enter)
765 {775 {
766 xpad_toolbar_move_button_end (toolbar);776 xpad_toolbar_move_button_end (toolbar);
767 return TRUE;777 return TRUE;
@@ -813,7 +823,7 @@
813 max = gtk_toolbar_get_n_items (GTK_TOOLBAR (toolbar)) - 2;823 max = gtk_toolbar_get_n_items (GTK_TOOLBAR (toolbar)) - 2;
814 toolbar->priv->move_index = MIN (toolbar->priv->move_index, max);824 toolbar->priv->move_index = MIN (toolbar->priv->move_index, max);
815825
816 if (!xpad_settings_move_toolbar_button (xpad_settings (), old_spot, toolbar->priv->move_index) &&826 if (!xpad_settings_move_toolbar_button (xpad_global_settings, old_spot, toolbar->priv->move_index) &&
817 toolbar->priv->move_removed)827 toolbar->priv->move_removed)
818 {828 {
819 gtk_toolbar_insert (GTK_TOOLBAR (toolbar), toolbar->priv->move_button, toolbar->priv->move_index);829 gtk_toolbar_insert (GTK_TOOLBAR (toolbar), toolbar->priv->move_button, toolbar->priv->move_index);
820830
=== modified file 'src/xpad-tray.c'
--- src/xpad-tray.c 2013-10-21 02:51:19 +0000
+++ src/xpad-tray.c 2013-11-01 20:03:38 +0000
@@ -2,6 +2,7 @@
22
3Copyright (c) 2002 Jamis Buck3Copyright (c) 2002 Jamis Buck
4Copyright (c) 2003-2007 Michael Terry4Copyright (c) 2003-2007 Michael Terry
5Copyright (c) 2013 Arthur Borsboom
56
6This program is free software; you can redistribute it and/or modify7This program is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by8it under the terms of the GNU General Public License as published by
@@ -52,26 +53,25 @@
52static GtkWidget *menu = NULL;53static GtkWidget *menu = NULL;
5354
54void55void
55xpad_tray_open (void)56xpad_tray_open ()
56{57{
57 GtkIconTheme *theme;58 GtkIconTheme *theme;
5859
59 // xpad_tray_close ();
60
61 theme = gtk_icon_theme_get_default ();60 theme = gtk_icon_theme_get_default ();
61
62 if (!gtk_icon_theme_has_icon (theme, PACKAGE)) {62 if (!gtk_icon_theme_has_icon (theme, PACKAGE)) {
63 return;63 return;
64 }64 }
65 65
66 if (gtk_icon_theme_has_icon (theme, "xpad-panel"))66 if (gtk_icon_theme_has_icon (theme, "xpad-panel"))
67 {67 {
68 docklet = gtk_status_icon_new_from_icon_name ("xpad-panel");68 docklet = gtk_status_icon_new_from_icon_name ("xpad-panel");
69 }69 }
70 else70 else
71 {71 {
72 docklet = gtk_status_icon_new_from_icon_name (PACKAGE);72 docklet = gtk_status_icon_new_from_icon_name (PACKAGE);
73 }73 }
74 74
75 if (docklet)75 if (docklet)
76 {76 {
77 g_signal_connect (docklet, "activate", G_CALLBACK (xpad_tray_activate_cb), NULL);77 g_signal_connect (docklet, "activate", G_CALLBACK (xpad_tray_activate_cb), NULL);
@@ -117,7 +117,7 @@
117static void117static void
118menu_show_all (XpadPadGroup *group)118menu_show_all (XpadPadGroup *group)
119{119{
120 GSList *pads = xpad_pad_group_get_pads (xpad_app_get_pad_group ());120 GSList *pads = xpad_pad_group_get_pads (group);
121 g_slist_foreach (pads, (GFunc) gtk_window_present, NULL);121 g_slist_foreach (pads, (GFunc) gtk_window_present, NULL);
122 g_slist_free (pads);122 g_slist_free (pads);
123}123}
@@ -153,7 +153,6 @@
153{153{
154 GtkWidget *item;154 GtkWidget *item;
155 GSList *pads;155 GSList *pads;
156 gint n;
157 gboolean no_any_pad = FALSE;156 gboolean no_any_pad = FALSE;
158 157
159 menu = gtk_menu_new ();158 menu = gtk_menu_new ();
@@ -208,7 +207,7 @@
208static void207static void
209xpad_tray_activate_cb (GtkStatusIcon *icon)208xpad_tray_activate_cb (GtkStatusIcon *icon)
210{209{
211 switch (xpad_settings_get_tray_click_handler(xpad_settings()))210 switch (xpad_settings_get_tray_click_handler(xpad_global_settings))
212 {211 {
213 case TOGGLE_SHOW_ALL:212 case TOGGLE_SHOW_ALL:
214 xpad_tray_show_hide_all();213 xpad_tray_show_hide_all();
215214
=== modified file 'src/xpad-undo.c'
--- src/xpad-undo.c 2013-10-18 18:31:20 +0000
+++ src/xpad-undo.c 2013-11-01 20:03:38 +0000
@@ -223,12 +223,20 @@
223static void223static void
224xpad_undo_begin_user_action (GtkTextBuffer *buffer, XpadUndo *undo)224xpad_undo_begin_user_action (GtkTextBuffer *buffer, XpadUndo *undo)
225{225{
226 // A dirty way to silence the compiler for these unused variables.
227 // Feel free to implement these variables in the way they are ment to be used.
228 (void) buffer;
229
226 undo->priv->user_action++;230 undo->priv->user_action++;
227}231}
228232
229static void233static void
230xpad_undo_end_user_action (GtkTextBuffer *buffer, XpadUndo *undo)234xpad_undo_end_user_action (GtkTextBuffer *buffer, XpadUndo *undo)
231{235{
236 // A dirty way to silence the compiler for these unused variables.
237 // Feel free to implement these variables in the way they are ment to be used.
238 (void) buffer;
239
232 if (undo->priv->user_action > 0)240 if (undo->priv->user_action > 0)
233 undo->priv->user_action--;241 undo->priv->user_action--;
234}242}
@@ -275,15 +283,28 @@
275static void283static void
276xpad_undo_insert_text (GtkTextBuffer *buffer, GtkTextIter *location, gchar *text, gint len, XpadUndo *undo)284xpad_undo_insert_text (GtkTextBuffer *buffer, GtkTextIter *location, gchar *text, gint len, XpadUndo *undo)
277{285{
286 // A dirty way to silence the compiler for these unused variables.
287 // Feel free to implement these variables in the way they are ment to be used.
288 (void) buffer;
289
278 if (undo->priv->frozen)290 if (undo->priv->frozen)
279 return;291 return;
280292
281 if (undo->priv->user_action)293 if (undo->priv->user_action)
282 {294 {
295 gint n_utf8_chars = 0;
296 glong string_length = 0;
297
283 xpad_undo_clear_redo_history (undo);298 xpad_undo_clear_redo_history (undo);
284299
285 gint pos = gtk_text_iter_get_offset (location);300 gint pos = gtk_text_iter_get_offset (location);
286 gint n_utf8_chars = g_utf8_strlen (text, len);301
302 // safe cast
303 string_length = g_utf8_strlen (text, len);
304 if (string_length <= UINT_MAX)
305 n_utf8_chars = (gint) string_length;
306 else
307 g_warning("Casting problem in undo insert text function. Please send a bugreport.");
287308
288 /* Merge similar actions. This is how Undo works in most editors, if there is a series of309 /* Merge similar actions. This is how Undo works in most editors, if there is a series of
289 1-letter insertions - they are merge for Undo */310 1-letter insertions - they are merge for Undo */
@@ -299,8 +320,8 @@
299 && (prev_action->n_utf8_chars == 1 || prev_action->merged)) // with which we should merge320 && (prev_action->n_utf8_chars == 1 || prev_action->merged)) // with which we should merge
300 {321 {
301 /* if there was a space stop merging unless that was a series of spaces */322 /* if there was a space stop merging unless that was a series of spaces */
302 if ((!g_unichar_isspace (prev_action->text[0]) && !g_ascii_isspace (text[0])) ||323 if ((!g_unichar_isspace ((gunichar) prev_action->text[0]) && !g_ascii_isspace ((gunichar) text[0])) ||
303 (g_unichar_isspace (prev_action->text[0]) && g_unichar_isspace (text[0])))324 (g_unichar_isspace ((gunichar) prev_action->text[0]) && g_unichar_isspace ((gunichar) text[0])))
304 {325 {
305 gchar *joined_str = g_strjoin (NULL, prev_action->text, text, NULL);326 gchar *joined_str = g_strjoin (NULL, prev_action->text, text, NULL);
306 g_free (prev_action->text);327 g_free (prev_action->text);
@@ -328,7 +349,11 @@
328 is nothing after history_curr at this point so we349 is nothing after history_curr at this point so we
329 insert right after it. history_start won't change350 insert right after it. history_start won't change
330 since it is a left guard - not NULL */351 since it is a left guard - not NULL */
331 GList *dummy_start = g_list_append (undo->priv->history_curr, action); // supress warning, we have left guard for start352 GList *dummy_start = g_list_append (undo->priv->history_curr, action);
353 // A dirty way to silence the compiler for these unused variables.
354 // Feel free to implement these variables in the way they are ment to be used.
355 (void) dummy_start;
356
332 undo->priv->history_curr = g_list_next (undo->priv->history_curr);357 undo->priv->history_curr = g_list_next (undo->priv->history_curr);
333358
334 xpad_pad_notify_undo_redo_changed (xpad_text_buffer_get_pad (undo->priv->buffer));359 xpad_pad_notify_undo_redo_changed (xpad_text_buffer_get_pad (undo->priv->buffer));
@@ -338,18 +363,31 @@
338static void363static void
339xpad_undo_delete_range (GtkTextBuffer *buffer, GtkTextIter *start, GtkTextIter *end, XpadUndo *undo)364xpad_undo_delete_range (GtkTextBuffer *buffer, GtkTextIter *start, GtkTextIter *end, XpadUndo *undo)
340{365{
366 // A dirty way to silence the compiler for these unused variables.
367 // Feel free to implement these variables in the way they are ment to be used.
368 (void) buffer;
369
341 if (undo->priv->frozen)370 if (undo->priv->frozen)
342 return;371 return;
343372
344 if (undo->priv->user_action)373 if (undo->priv->user_action)
345 {374 {
375 gint n_utf8_chars = 0;
376 glong string_length = 0;
377
346 xpad_undo_clear_redo_history (undo);378 xpad_undo_clear_redo_history (undo);
347379
348 gchar *text = gtk_text_iter_get_text (start, end);380 gchar *text = gtk_text_iter_get_text (start, end);
349 gint start_offset = gtk_text_iter_get_offset (start);381 gint start_offset = gtk_text_iter_get_offset (start);
350 gint end_offset = gtk_text_iter_get_offset (end);382 gint end_offset = gtk_text_iter_get_offset (end);
351 gint len = abs (end_offset - start_offset);383 gint len = abs (end_offset - start_offset);
352 gint n_utf8_chars = g_utf8_strlen (text, len);384
385 // safe cast
386 string_length = g_utf8_strlen (text, len);
387 if (string_length <= UINT_MAX)
388 n_utf8_chars = (gint) string_length;
389 else
390 g_warning("Casting problem in undo delete range function. Please send a bugreport.");
353391
354 UserAction *action = g_new (UserAction, 1);392 UserAction *action = g_new (UserAction, 1);
355 action->action_type = USER_ACTION_DELETE_RANGE;393 action->action_type = USER_ACTION_DELETE_RANGE;
@@ -360,7 +398,11 @@
360 action->n_utf8_chars = n_utf8_chars;398 action->n_utf8_chars = n_utf8_chars;
361 action->merged = FALSE;399 action->merged = FALSE;
362400
363 GList *dummy_start = g_list_append (undo->priv->history_curr, action); // supress warning, we have left guard for start401 GList *dummy_start = g_list_append (undo->priv->history_curr, action);
402 // A dirty way to silence the compiler for these unused variables.
403 // Feel free to implement these variables in the way they are ment to be used.
404 (void) dummy_start;
405
364 undo->priv->history_curr = g_list_next (undo->priv->history_curr);406 undo->priv->history_curr = g_list_next (undo->priv->history_curr);
365407
366 xpad_pad_notify_undo_redo_changed (xpad_text_buffer_get_pad (undo->priv->buffer));408 xpad_pad_notify_undo_redo_changed (xpad_text_buffer_get_pad (undo->priv->buffer));
@@ -385,7 +427,11 @@
385 action->end = end_offset; 427 action->end = end_offset;
386 action->merged = FALSE;428 action->merged = FALSE;
387429
388 GList *dummy_start = g_list_append (undo->priv->history_curr, action); // supress warning, we have left guard for start430 GList *dummy_start = g_list_append (undo->priv->history_curr, action);
431 // A dirty way to silence the compiler for these unused variables.
432 // Feel free to implement these variables in the way they are ment to be used.
433 (void) dummy_start;
434
389 undo->priv->history_curr = g_list_next (undo->priv->history_curr);435 undo->priv->history_curr = g_list_next (undo->priv->history_curr);
390436
391 xpad_pad_notify_undo_redo_changed (xpad_text_buffer_get_pad (undo->priv->buffer));437 xpad_pad_notify_undo_redo_changed (xpad_text_buffer_get_pad (undo->priv->buffer));
@@ -409,7 +455,11 @@
409 action->end = end_offset;455 action->end = end_offset;
410 action->merged = FALSE;456 action->merged = FALSE;
411457
412 GList *dummy_start = g_list_append (undo->priv->history_curr, action); // supress warning, we have left guard for start458 GList *dummy_start = g_list_append (undo->priv->history_curr, action);
459 // A dirty way to silence the compiler for these unused variables.
460 // Feel free to implement these variables in the way they are ment to be used.
461 (void) dummy_start;
462
413 undo->priv->history_curr = g_list_next (undo->priv->history_curr);463 undo->priv->history_curr = g_list_next (undo->priv->history_curr);
414464
415 xpad_pad_notify_undo_redo_changed (xpad_text_buffer_get_pad (undo->priv->buffer));465 xpad_pad_notify_undo_redo_changed (xpad_text_buffer_get_pad (undo->priv->buffer));

Subscribers

People subscribed via source and target branches