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