Merge lp:~arthurborsboom/xpad/xpad-4.2 into lp:xpad
- xpad-4.2
- Merge into trunk
Proposed by
Arthur Borsboom
| Status: | Merged | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Merged at revision: | 657 | ||||||||||||||||||||
| Proposed branch: | lp:~arthurborsboom/xpad/xpad-4.2 | ||||||||||||||||||||
| Merge into: | lp:xpad | ||||||||||||||||||||
| Diff against target: |
3440 lines (+1176/-1007) 18 files modified
ChangeLog (+445/-13) NEWS (+0/-430) src/help.c (+2/-2) src/xpad-app.c (+33/-12) src/xpad-grip-tool-item.c (+23/-14) src/xpad-pad-group.c (+37/-27) src/xpad-pad-group.h (+1/-0) src/xpad-pad-properties.c (+26/-6) src/xpad-pad.c (+154/-77) src/xpad-preferences.c (+12/-9) src/xpad-settings.c (+46/-17) src/xpad-settings.h (+2/-2) src/xpad-text-buffer.c (+84/-77) src/xpad-text-buffer.h (+1/-1) src/xpad-text-view.c (+16/-15) src/xpad-toolbar.c (+268/-271) src/xpad-tray.c (+10/-6) src/xpad-undo.c (+16/-28) |
||||||||||||||||||||
| To merge this branch: | bzr merge lp:~arthurborsboom/xpad/xpad-4.2 | ||||||||||||||||||||
| Related bugs: |
|
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Arthur Borsboom | Approve | ||
|
Review via email:
|
|||
Commit message
Description of the change
Fixed crash after deleting pad(s).
Fixed memory leaks
Updated help
Updated changelog
To post a comment you must log in.
Revision history for this message
| Arthur Borsboom (arthurborsboom) : | # |
review:
Approve
lp:~arthurborsboom/xpad/xpad-4.2
updated
- 657. By Arthur Borsboom
-
Fixed crash after deleting pad(s).\nFixed memory leaks.\nUpdated help.\nUpdated changelog.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
| 1 | === modified file 'ChangeLog' |
| 2 | --- ChangeLog 2013-10-09 04:26:23 +0000 |
| 3 | +++ ChangeLog 2013-10-18 18:35:35 +0000 |
| 4 | @@ -1,16 +1,448 @@ |
| 5 | -Changes in v4.2 - Arthur Borsboom <arthurborsboom@gmail.com> |
| 6 | - |
| 7 | -- New: Undo functionality such as CTRL-Z (#1121740) |
| 8 | -- New: Tray click behaviour can now be configured (#345278, #304331, #890335) |
| 9 | -- New: Tray icon can be hidden (#890334) |
| 10 | -- New: Theme builders can now use seperate tray icon by adding xpad-panel.xvg (#907705) |
| 11 | -- Fix: Theme color stays after application restart (#307669) |
| 12 | -- Fix: Translation - get many new translations in from translators (thanks guys!!) |
| 13 | -- Fix: Translation - French typo (#1216388) |
| 14 | -- Fix: Translation - Russian typo which prevented the Help from working (#973825) |
| 15 | -- Fix: added missing configure script (#890492) |
| 16 | -- Fix: performance improvement by reducing the amount of harddisk writes (#1072698, #1207564, #782320) |
| 17 | -- Fix: can now compile against glib-2.34.1 (#974011) |
| 18 | +Version 4.1 |
| 19 | +* New: Undo functionality such as CTRL-Z (#1121740) |
| 20 | +* New: Tray click behaviour can now be configured (#345278, #304331, #890335) |
| 21 | +* New: Tray icon can be hidden (#890334) |
| 22 | +* New: Theme builders can now use seperate tray icon by adding xpad-panel.xvg (#907705) |
| 23 | +* Fix: Theme color stays after application restart (#307669) |
| 24 | +* Fix: Translation - get many new translations in from translators (thanks guys!!) |
| 25 | +* Fix: Translation - French typo (#1216388) |
| 26 | +* Fix: Translation - Russian typo which prevented the Help from working (#973825) |
| 27 | +* Fix: added missing configure script (#890492) |
| 28 | +* Fix: performance improvement by reducing the amount of harddisk writes (#1072698, #1207564, #782320) |
| 29 | +* Fix: can now compile against glib-2.34.1 (#974011) |
| 30 | +* Fix: no errors or crashes after a delete of a pad (#1237211, #1237563) |
| 31 | +* Fix: different memory leaks (#1237211, #1237563) |
| 32 | + |
| 33 | +Version 4.1 |
| 34 | +* Undo/Redo for xpad and bug-fixes. Feature by Sergei Riaguzov |
| 35 | +* Bug #490445: crash when right-clicking on tray icon to display list of notes. Patch by David Hull |
| 36 | +* Bug #360142: Add keyboard shortcuts for formatting. Patch by Dennis Hilmar |
| 37 | +* Bug #591978: xpad critical start. Patch by OBATA Akio |
| 38 | + |
| 39 | + |
| 40 | +Version 4.0 |
| 41 | +* Added --toggle (between --hide and --show). Patch by Paul Ivanov. |
| 42 | +* Updated French, Japanese, Russian, Spanish, and Swedish translations |
| 43 | +* New Croatian, Estonian, German, Portuguese, Thai, and Turkish translations |
| 44 | + |
| 45 | + |
| 46 | +Version 3.1 |
| 47 | +* Updated Danish, French, Russian, Spanish, and Swedish translations |
| 48 | +* New Czech, Japanese, and Latvian translations |
| 49 | + |
| 50 | + |
| 51 | +Version 3.0 |
| 52 | +* Don't wake up every 20 milliseconds to check session management messages. |
| 53 | + Rather, wait for an event. |
| 54 | +* Add --hide/--show, removed --hide-old. --hide and --show affect all pads |
| 55 | + on startup or can be used on an already running xpad instance. Patch by |
| 56 | + Jan Losinski. |
| 57 | +* Update icon to be less aliased |
| 58 | +* Relicense as GPL v3+ |
| 59 | + |
| 60 | + |
| 61 | +Version 2.14 |
| 62 | +* Fix 100% CPU bug |
| 63 | + |
| 64 | + |
| 65 | +Version 2.13 |
| 66 | +* Requires GTK+ 2.12 |
| 67 | +* Fix pads possibly not remembering location after close |
| 68 | +* Fix pad-closed state not being remembered |
| 69 | +* Uses native status icon code in GTK+ |
| 70 | +* Maybe, possibly fix some 'pad on all workspaces' problems |
| 71 | +* New Chinese (simplified) translation (Meng Jie) |
| 72 | +* New English (British) translation (David Lodge) |
| 73 | +* New Finnish translation (Jorma Karvonen) |
| 74 | +* New Korean translation (KwangSub Lee) |
| 75 | +* Updated Dutch translation (Benno Schulenberg) |
| 76 | +* Updated Slovak translation (Andrej Kacian) |
| 77 | +* Fixed Danish, Swedish translations |
| 78 | + |
| 79 | + |
| 80 | +Version 2.12 |
| 81 | +* Fix a crash when loading pads with formatting |
| 82 | + |
| 83 | + |
| 84 | +Version 2.11 |
| 85 | +* If window decorations are turned on, pads will now show up in the taskbar |
| 86 | +* Added -f option to open a file as a note |
| 87 | +* New Chinese (simplified) translation (Meng Jie) |
| 88 | +* New Danish translation (Morten Bo Johansen) |
| 89 | +* New Swedish translation (Daniel Nylander) |
| 90 | +* Updated Chinese (traditional) translation (Wei-Lun Chao) |
| 91 | + |
| 92 | + |
| 93 | +Version 2.10 |
| 94 | +* Fix a possible crash when deleting pads with autohide toolbar |
| 95 | +* Make toolbar buttons smaller |
| 96 | +* Make toolbar appear inside pad if there is enough unused space |
| 97 | +* New Slovak translation (Andrej Kacian) |
| 98 | +* New Slovenian translation (Matej Urbančič) |
| 99 | + |
| 100 | + |
| 101 | +Version 2.9 |
| 102 | +* Fix pads saving slightly off bad x,y values |
| 103 | +* Fix pads saving bad heights when toolbar always on (Sham Chukoury) |
| 104 | +* Fix possible crash from not allocating enough memory (Federico Schwindt) |
| 105 | +* New Malay translation (Sharuzzaman Ahmat Raslan) |
| 106 | + |
| 107 | + |
| 108 | +Version 2.8 |
| 109 | +* Allow translations to be used (broken for a couple versions) |
| 110 | +* New Chinese (traditional) translation (Wei-Lun Chao) |
| 111 | +* Removed half-baked Esperanto translation |
| 112 | + |
| 113 | + |
| 114 | +Version 2.7 |
| 115 | +* Stop pads from popping toolbar while the pad is moving/resizing |
| 116 | +* Make sure pads use correct sizes when autohide is off (Sham Chukoury) |
| 117 | +* New Bulgarian translation (Yavor Doganov) |
| 118 | +* New Kinyarwanda translation (Steve Murphy et al) |
| 119 | + |
| 120 | + |
| 121 | +Version 2.6 |
| 122 | +* Stop pad windows from 'jumping' when dragged via the toolbar |
| 123 | +* Updated Hungarian translation (Németh Csaba) |
| 124 | +* Updated Irish translation (Kevin Patrick Scannell) |
| 125 | +* Updated Vietnamese translation (Clytie Siddall) |
| 126 | + |
| 127 | + |
| 128 | +Version 2.5 |
| 129 | +* Stop making all new pads start in top left |
| 130 | +* Stop closing xpad if toggling window decorations with only one pad open |
| 131 | +* Stop losing pad contents if upgrading from old versions of xpad |
| 132 | + |
| 133 | + |
| 134 | +Version 2.4 |
| 135 | +* Create the configuration directory if it doesn't exist |
| 136 | + |
| 137 | + |
| 138 | +Version 2.3 |
| 139 | +* Fixed a compile bug with binreloc and threading |
| 140 | + |
| 141 | + |
| 142 | +Version 2.2 |
| 143 | +* Bumped GTK+ dependency to 2.6 |
| 144 | +* New About dialog (using GtkAboutDialog) |
| 145 | +* New default location for configuration files: ~/.config/xpad |
| 146 | +* Updated icon (now uses lighter colors) |
| 147 | +* Use GOption for command-line parsing |
| 148 | +* New command-line option --hide-old (or -H) to not show old pads |
| 149 | +* Renamed command-line option --nonew to --no-new and added -N shortcut |
| 150 | +* Allow running from console if we don't need to do anything graphical |
| 151 | +* Readded keyboard shortcuts |
| 152 | +* Updated antiquated man page |
| 153 | +* New Hungarian translation (Németh Csaba) |
| 154 | +* New Vietnamese translation (Clytie Siddall) |
| 155 | +* Updated Irish translation (Kevin Patrick Scannell) |
| 156 | + |
| 157 | + |
| 158 | +Version 2.1 |
| 159 | +* Fix tray icon being the wrong size |
| 160 | +* Fix xpad to close when no tray and no open pads |
| 161 | + |
| 162 | + |
| 163 | +Version 2.0 |
| 164 | +* Fix notes list to display correct number of pads |
| 165 | +* Fix notification icon from not doing anything |
| 166 | +* Fix compilation when BinReloc is disabled |
| 167 | +* Fix compilation with gcc 3.4 |
| 168 | +* Fix endianness issue with preference files |
| 169 | +* Updated Dutch translation (Elros Cyriatan) |
| 170 | + |
| 171 | + |
| 172 | +Version 2.0-b3 |
| 173 | +* Use BinReloc to allow any-prefix installs of xpad to work |
| 174 | +* Fixed a double-free bug that caused some problems with new pads |
| 175 | +* Updated Irish translation (Kevin Patrick Scannell) |
| 176 | +* Updated Spanish translation (Ramon Rey Vicente) |
| 177 | + |
| 178 | + |
| 179 | +Version 2.0-b2 |
| 180 | +* Redesigned preferences and pad properties dialogs |
| 181 | +* If the tray disappears (e.g. killall gnome-panel), xpad's icon reappears |
| 182 | +* More formally ask window manager to make us skip taskbar and pager |
| 183 | +* New, lighter default color for pads |
| 184 | +* Lots of internal code cleanup |
| 185 | +* Fixed a crasher with not being able to find window icons |
| 186 | +* Fixed some crashers with turning off toolbar |
| 187 | +* Fixed bug with text cursor color being one color change behind |
| 188 | + |
| 189 | + |
| 190 | +Version 2.0-b1 |
| 191 | +* The text cursor is now always the same color as the text color |
| 192 | +* Formatting can now be applied to selected text |
| 193 | +* Pads remember their hidden state |
| 194 | +* Rewritten toolbar, allowing easier adding/removing/moving buttons |
| 195 | +* Simplified preferences dialog; many functions are now accessed from popup menu |
| 196 | +* --new now also loads the old pads, instead of the previous broken behavior |
| 197 | +* Fixed bug with pads over the 9th not having numbers in note lists |
| 198 | +* Fixed bug with inter process communicating causing only first communication to work |
| 199 | +* Fixed bug with pads becoming unstyled after closing and reopening |
| 200 | +* New Afrikaans translation (Petri Jooste) |
| 201 | +* New French translation (Michel Robitaille) |
| 202 | + |
| 203 | + |
| 204 | +Version 1.13 |
| 205 | +* Don't close xpad if no pads are open but the system tray is |
| 206 | +* Made translations work again |
| 207 | +* New Spanish translation (Ramon Rey Vicente) |
| 208 | +* Updated Dutch translation (Elros Cyriatan) |
| 209 | +* Updated Irish translation (Kevin Patrick Scannell) |
| 210 | + |
| 211 | + |
| 212 | +Version 1.12 |
| 213 | +* Fixed segfault when clicking on auto-hide toolbar preference |
| 214 | +* Fixed segfault when changing the first toolbar button |
| 215 | +* Added Irish translation (by Kevin Patrick Scannell) |
| 216 | + |
| 217 | + |
| 218 | +Version 1.11 |
| 219 | +* Added Dutch translation (by t.c.witte@phys.uu.nl) |
| 220 | +* Added partial Esperanto translation (by mterry@fastmail.fm) |
| 221 | +* Added Romanian translation (by eugenh@urban-grafx.ro) |
| 222 | +* Added Russian translation (by avl@cad.ru) |
| 223 | +* Added missing "include <sys/time.h>" (by netgeek@speakeasy.net) |
| 224 | +* Added missing #defines for solaris (by alan@cesma.usb.ve) |
| 225 | +* Added new icon and install icon family into new location per icon theme spec |
| 226 | +* Fixed disk-full-causes-xpad-contents-to-disappear bug |
| 227 | +* Made pads not show up in taskbar |
| 228 | +* Added 'pads start sticky' option |
| 229 | + |
| 230 | + |
| 231 | +Version 1.10.1 |
| 232 | +* Fixed some compile-time issues, particularly with GTK+ 2.0 |
| 233 | + |
| 234 | + |
| 235 | +Version 1.10 |
| 236 | +* Rewrote applet popup menu to be more consistent and hopefully useful |
| 237 | +* Fixed crash when closing a pad that had provided text in a cut/paste |
| 238 | +* Normalize pad dimensions when opening in case the values got messed up |
| 239 | +* Misc. small bugs |
| 240 | + |
| 241 | + |
| 242 | +Version 1.9.1 |
| 243 | +* Fix a segfault when show all is selected after a new pad is made |
| 244 | + |
| 245 | + |
| 246 | +Version 1.9 |
| 247 | +* Now use automake/autoconf, which allows for more complete build control |
| 248 | +* Now use gettext, allowing easy translation of xpad |
| 249 | +* Now auto-apply any pad changes to hard drive, making xpad a tad more |
| 250 | + reliable |
| 251 | +* Now can easily change settings for only one pad |
| 252 | +* A little more sane title generation -- now just uses first line |
| 253 | +* X session management support |
| 254 | +* |
| 255 | +* Popup menu is decluttered and altered, with the HIG in mind |
| 256 | +* Fixed crash on exit if we didn't init docklet |
| 257 | +* Fixed new pads randomly starting up as white background |
| 258 | +* Cut/copy/paste are now unsensitive if no content to copy or paste |
| 259 | +* Pads now play nice with the X clipboard (middle mouse button) |
| 260 | +* Fixed a bug with the notification area applet |
| 261 | +* Fixed misc. small bugs |
| 262 | + |
| 263 | + |
| 264 | +Version 1.8 |
| 265 | +* Allow using system text color, background color, and font |
| 266 | +* Eggtray now appears, allowing users to hide all pads (thanks |
| 267 | + jgb3@email.byu.edu) |
| 268 | +* Now we compile using autoconf |
| 269 | +* |
| 270 | +* Xpad won't take 100% cpu sometimes when idle |
| 271 | +* Fixed bug that screwed up last toolbar button's toggle setting |
| 272 | +* Fixed toolbar hiding when you right click on another pad |
| 273 | +* Fixed style locking and sticky status changing on menu popup |
| 274 | +* No deletion confirmation if pad is only whitespace |
| 275 | + |
| 276 | + |
| 277 | +Version 1.7 |
| 278 | +* Popup alerts are more pleasing. (HIG compliant) |
| 279 | +* Added --nonew flag to prevent creation of new pads. |
| 280 | +* Changed --new flag to only open a new pad, not try to open old pads too. |
| 281 | +* Changed window titles from quoted to ellipses at the end. |
| 282 | +* Option to turn off toolbar auto-hide. |
| 283 | +* Added --list, -l, --show, -s. |
| 284 | + |
| 285 | + |
| 286 | +Version 1.6.1 |
| 287 | +* Fix segfault on startup if toolbar is disabled. |
| 288 | + |
| 289 | + |
| 290 | +Version 1.6 |
| 291 | +* Rearrange popup menu |
| 292 | +* More meaningful window titles |
| 293 | +* Add popup menu submenu that allows you to choose window to show |
| 294 | +* Allow reopening of closed pads |
| 295 | +* The return of cut/copy/paste |
| 296 | +* Native sticky support |
| 297 | +* Add a show all command -- via command line or menu |
| 298 | +* Allow turning off of scrollbars |
| 299 | +* Allow reshowing of closed pads (without restarting xpad) |
| 300 | +* |
| 301 | +* Stopped style lock from turning on accidentally |
| 302 | +* Properly handle WM closures |
| 303 | +* Better HIG-style support of keyboard accelerators |
| 304 | + |
| 305 | + |
| 306 | +Version 1.5.1 |
| 307 | +* Fix a possible segfault on startup |
| 308 | + |
| 309 | + |
| 310 | +Version 1.5 |
| 311 | +* Fixed a bug that stopped saving of defaults on shutdown |
| 312 | +* Better error reporting |
| 313 | +* Added a toolbar with customizable buttons |
| 314 | +* Added some new command line options |
| 315 | +* Allow style locking |
| 316 | +* Allow pad clearing |
| 317 | +* Added all new preference help window |
| 318 | + |
| 319 | + |
| 320 | +Version 1.4 |
| 321 | +* Code cleanup |
| 322 | +* We now compile clean with -ansi and -pedantic! ;) |
| 323 | +* Should take up a little less memory |
| 324 | +* Fixed several memory leaks |
| 325 | +* Should be able to compile on windows and beos. |
| 326 | + -- PLEASE let me know how this works for you. |
| 327 | +* Added scrollbars if window isn't big enough to handle text |
| 328 | + -- this fixes two known bugs |
| 329 | +* New xpad processes now handled gracefully |
| 330 | +* Added further optimizations to compilation |
| 331 | + -- let me know if this causes you problems |
| 332 | +* Fixed some possible buffer overflows |
| 333 | +* Fixed some warnings/errors on gcc3 compilation |
| 334 | +* Cursor icon changes when edit lock is on |
| 335 | + |
| 336 | + |
| 337 | +Version 1.3 |
| 338 | +* Added a padding option (thanks Nagy Mate) |
| 339 | +* Redesigned dialogs |
| 340 | +* Preferences now auto-apply |
| 341 | +* You can now choose what the wm close button does, defaults to close |
| 342 | +* Pads have individual titles now |
| 343 | +* Xpad gets along better with various wm's now |
| 344 | +* Cursor no longer blinks if you can't edit pad |
| 345 | +* Fixed double-clicking-doesn't-select-text-when-edit-lock-is-on bug |
| 346 | +* Pads can no longer be individually closed (unless wm decor is on) |
| 347 | + |
| 348 | + |
| 349 | +Version 1.2.1 |
| 350 | +* Fixed segfault on startup if no ~/.xpad directory, plus some related bugs |
| 351 | + |
| 352 | + |
| 353 | +Version 1.2 |
| 354 | +* Fixed an issue causing black on black with big-endian architectures |
| 355 | +* Added "Edit Lock" mode |
| 356 | +* General code cleanup |
| 357 | + |
| 358 | + |
| 359 | +Version 1.1 |
| 360 | +* Simplified popup menu (removed GTK+ default cut/copy/paste/input |
| 361 | + method/insert). If you used them, and miss them, let me know. |
| 362 | +* Added keyboard shortcuts for most menu items |
| 363 | +* Expanded help dialog to include shortcuts |
| 364 | +* Allow border left-drags, right-drags, and right clicks |
| 365 | + |
| 366 | + |
| 367 | +Version 1.0.2 |
| 368 | +* Stopped pads from losing their place on x shut down |
| 369 | + |
| 370 | + |
| 371 | +Version 1.0.1 |
| 372 | +* Fixed a possible runtime warning with autosaving |
| 373 | +* Made window icon code more robust |
| 374 | +* Added icons for all menu items |
| 375 | + |
| 376 | + |
| 377 | +Version 1.0 |
| 378 | +* Added an open file dialog |
| 379 | +* Added a save as dialog |
| 380 | +* Closed pads are handled more consistently |
| 381 | +* Unified color/font change screens |
| 382 | +* Fixed font not being saved correctly |
| 383 | +* Added ability to fine tune default pad settings, including size (before |
| 384 | + this was all handled transparently, but size was not always updated) |
| 385 | +* Added optional confirmation to pad destroys |
| 386 | +* Window decorations can now be turned on (in global pref screen) |
| 387 | +* Added border color and border width options |
| 388 | +* Added gui for sync time (autosaving) control |
| 389 | +* Took out --sync-time and -s (you can do same thing with above gui) |
| 390 | +* Stopped new pads always being placed in same spot |
| 391 | +* Added help screen, which opens when you click on "help" from right-click |
| 392 | + menu and on first run |
| 393 | +* Much cleaner internal api |
| 394 | +* Made xpad more theme-friendly |
| 395 | +* Resizing/moving now works even if numpad is on |
| 396 | +* Xpad 1.0 can now open much older versions of xpad's files (tested to 0.2.1) |
| 397 | +* Added app icon (thanks nestor di) |
| 398 | + |
| 399 | + |
| 400 | +Version 0.2.5 |
| 401 | +* Added --help |
| 402 | +* Added short forms of arguments (e.g. -h, -v, -V, -s) |
| 403 | +* Added more output messages |
| 404 | +* Stopped pad raising above popup on right click |
| 405 | +* Fixed bug where old pads wouldn't open upon startup |
| 406 | +* No size limit on pads |
| 407 | + |
| 408 | + |
| 409 | +Version 0.2.4 |
| 410 | +* Fixed small memory leak if no default-style file |
| 411 | +* Pads rise to foreground if clicked on now |
| 412 | +* Added "close all" option on popup |
| 413 | +* Prints out a message when autosaving |
| 414 | +* Added --verbosity= option. (0 is default - no messages; 1 is |
| 415 | + moderate - important things like autosaving; 2 is debug - |
| 416 | + more info than necessary) |
| 417 | +* Removed some possible buffer overflows if text is too large (a hardcoded |
| 418 | + limit of 20k chars now) |
| 419 | +* Misc. code cleanups |
| 420 | + |
| 421 | + |
| 422 | +Version 0.2.3.1 |
| 423 | +* Fixed nasty bug where, if you didn't have a working ~/.xpad/default-styles |
| 424 | + file, it would seg-fault. my bad |
| 425 | + |
| 426 | + |
| 427 | +Version 0.2.3 |
| 428 | +* Perfected (?) syncing. Now will recover cleanly from anything -- including |
| 429 | + power shut off or random interrupts. This fixes the "pad contents |
| 430 | + disappearing on X-shutdown" bug |
| 431 | +* Moved menu items around a bit |
| 432 | +* Remembers preferred size (only if you change fonts/colors. on TODO) |
| 433 | +* Not always centered now |
| 434 | + |
| 435 | + |
| 436 | +Version 0.2.2 |
| 437 | +* Debian-friendly Makefile fixes |
| 438 | +* Cleaned up code |
| 439 | + |
| 440 | + |
| 441 | +Version 0.2.1 |
| 442 | +* Changed saving to be more fault-tolerant |
| 443 | +* Added about screen with version info |
| 444 | + |
| 445 | + |
| 446 | +Version 0.2 |
| 447 | +* Ported to gtk+-2.0 |
| 448 | +* Now can change font color |
| 449 | +* If xpad is already running, will open new pad, not open old pads again |
| 450 | +* In-xpad moving and resizing now works |
| 451 | +* Xpad now recovers better from being interrupted |
| 452 | +* Remembers your preferred style |
| 453 | +* Many small bugfixes |
| 454 | +* Code reorganization |
| 455 | + |
| 456 | + |
| 457 | +Version 0.1.9.2 |
| 458 | +* Cleaner lack of decorations |
| 459 | +* Fixed "double-click on menu" bug |
| 460 | +* Fixed segfault when only a font size change was requested |
| 461 | +* Added close and destroy items to menu. Now you can close a window without |
| 462 | + losing content |
| 463 | |
| 464 | 2004-09-29 Jeroen T. Vermeulen <jtv@xs4all.nl> |
| 465 | |
| 466 | |
| 467 | === removed file 'NEWS' |
| 468 | --- NEWS 2011-11-14 17:10:03 +0000 |
| 469 | +++ NEWS 1970-01-01 00:00:00 +0000 |
| 470 | @@ -1,430 +0,0 @@ |
| 471 | -Version 4.1 |
| 472 | -* Undo/Redo for xpad and bug-fixes. Feature by Sergei Riaguzov |
| 473 | -* Bug #490445: crash when right-clicking on tray icon to display list of notes. Patch by David Hull |
| 474 | -* Bug #360142: Add keyboard shortcuts for formatting. Patch by Dennis Hilmar |
| 475 | -* Bug #591978: xpad critical start. Patch by OBATA Akio |
| 476 | - |
| 477 | - |
| 478 | -Version 4.0 |
| 479 | -* Added --toggle (between --hide and --show). Patch by Paul Ivanov. |
| 480 | -* Updated French, Japanese, Russian, Spanish, and Swedish translations |
| 481 | -* New Croatian, Estonian, German, Portuguese, Thai, and Turkish translations |
| 482 | - |
| 483 | - |
| 484 | -Version 3.1 |
| 485 | -* Updated Danish, French, Russian, Spanish, and Swedish translations |
| 486 | -* New Czech, Japanese, and Latvian translations |
| 487 | - |
| 488 | - |
| 489 | -Version 3.0 |
| 490 | -* Don't wake up every 20 milliseconds to check session management messages. |
| 491 | - Rather, wait for an event. |
| 492 | -* Add --hide/--show, removed --hide-old. --hide and --show affect all pads |
| 493 | - on startup or can be used on an already running xpad instance. Patch by |
| 494 | - Jan Losinski. |
| 495 | -* Update icon to be less aliased |
| 496 | -* Relicense as GPL v3+ |
| 497 | - |
| 498 | - |
| 499 | -Version 2.14 |
| 500 | -* Fix 100% CPU bug |
| 501 | - |
| 502 | - |
| 503 | -Version 2.13 |
| 504 | -* Requires GTK+ 2.12 |
| 505 | -* Fix pads possibly not remembering location after close |
| 506 | -* Fix pad-closed state not being remembered |
| 507 | -* Uses native status icon code in GTK+ |
| 508 | -* Maybe, possibly fix some 'pad on all workspaces' problems |
| 509 | -* New Chinese (simplified) translation (Meng Jie) |
| 510 | -* New English (British) translation (David Lodge) |
| 511 | -* New Finnish translation (Jorma Karvonen) |
| 512 | -* New Korean translation (KwangSub Lee) |
| 513 | -* Updated Dutch translation (Benno Schulenberg) |
| 514 | -* Updated Slovak translation (Andrej Kacian) |
| 515 | -* Fixed Danish, Swedish translations |
| 516 | - |
| 517 | - |
| 518 | -Version 2.12 |
| 519 | -* Fix a crash when loading pads with formatting |
| 520 | - |
| 521 | - |
| 522 | -Version 2.11 |
| 523 | -* If window decorations are turned on, pads will now show up in the taskbar |
| 524 | -* Added -f option to open a file as a note |
| 525 | -* New Chinese (simplified) translation (Meng Jie) |
| 526 | -* New Danish translation (Morten Bo Johansen) |
| 527 | -* New Swedish translation (Daniel Nylander) |
| 528 | -* Updated Chinese (traditional) translation (Wei-Lun Chao) |
| 529 | - |
| 530 | - |
| 531 | -Version 2.10 |
| 532 | -* Fix a possible crash when deleting pads with autohide toolbar |
| 533 | -* Make toolbar buttons smaller |
| 534 | -* Make toolbar appear inside pad if there is enough unused space |
| 535 | -* New Slovak translation (Andrej Kacian) |
| 536 | -* New Slovenian translation (Matej Urbančič) |
| 537 | - |
| 538 | - |
| 539 | -Version 2.9 |
| 540 | -* Fix pads saving slightly off bad x,y values |
| 541 | -* Fix pads saving bad heights when toolbar always on (Sham Chukoury) |
| 542 | -* Fix possible crash from not allocating enough memory (Federico Schwindt) |
| 543 | -* New Malay translation (Sharuzzaman Ahmat Raslan) |
| 544 | - |
| 545 | - |
| 546 | -Version 2.8 |
| 547 | -* Allow translations to be used (broken for a couple versions) |
| 548 | -* New Chinese (traditional) translation (Wei-Lun Chao) |
| 549 | -* Removed half-baked Esperanto translation |
| 550 | - |
| 551 | - |
| 552 | -Version 2.7 |
| 553 | -* Stop pads from popping toolbar while the pad is moving/resizing |
| 554 | -* Make sure pads use correct sizes when autohide is off (Sham Chukoury) |
| 555 | -* New Bulgarian translation (Yavor Doganov) |
| 556 | -* New Kinyarwanda translation (Steve Murphy et al) |
| 557 | - |
| 558 | - |
| 559 | -Version 2.6 |
| 560 | -* Stop pad windows from 'jumping' when dragged via the toolbar |
| 561 | -* Updated Hungarian translation (Németh Csaba) |
| 562 | -* Updated Irish translation (Kevin Patrick Scannell) |
| 563 | -* Updated Vietnamese translation (Clytie Siddall) |
| 564 | - |
| 565 | - |
| 566 | -Version 2.5 |
| 567 | -* Stop making all new pads start in top left |
| 568 | -* Stop closing xpad if toggling window decorations with only one pad open |
| 569 | -* Stop losing pad contents if upgrading from old versions of xpad |
| 570 | - |
| 571 | - |
| 572 | -Version 2.4 |
| 573 | -* Create the configuration directory if it doesn't exist |
| 574 | - |
| 575 | - |
| 576 | -Version 2.3 |
| 577 | -* Fixed a compile bug with binreloc and threading |
| 578 | - |
| 579 | - |
| 580 | -Version 2.2 |
| 581 | -* Bumped GTK+ dependency to 2.6 |
| 582 | -* New About dialog (using GtkAboutDialog) |
| 583 | -* New default location for configuration files: ~/.config/xpad |
| 584 | -* Updated icon (now uses lighter colors) |
| 585 | -* Use GOption for command-line parsing |
| 586 | -* New command-line option --hide-old (or -H) to not show old pads |
| 587 | -* Renamed command-line option --nonew to --no-new and added -N shortcut |
| 588 | -* Allow running from console if we don't need to do anything graphical |
| 589 | -* Readded keyboard shortcuts |
| 590 | -* Updated antiquated man page |
| 591 | -* New Hungarian translation (Németh Csaba) |
| 592 | -* New Vietnamese translation (Clytie Siddall) |
| 593 | -* Updated Irish translation (Kevin Patrick Scannell) |
| 594 | - |
| 595 | - |
| 596 | -Version 2.1 |
| 597 | -* Fix tray icon being the wrong size |
| 598 | -* Fix xpad to close when no tray and no open pads |
| 599 | - |
| 600 | - |
| 601 | -Version 2.0 |
| 602 | -* Fix notes list to display correct number of pads |
| 603 | -* Fix notification icon from not doing anything |
| 604 | -* Fix compilation when BinReloc is disabled |
| 605 | -* Fix compilation with gcc 3.4 |
| 606 | -* Fix endianness issue with preference files |
| 607 | -* Updated Dutch translation (Elros Cyriatan) |
| 608 | - |
| 609 | - |
| 610 | -Version 2.0-b3 |
| 611 | -* Use BinReloc to allow any-prefix installs of xpad to work |
| 612 | -* Fixed a double-free bug that caused some problems with new pads |
| 613 | -* Updated Irish translation (Kevin Patrick Scannell) |
| 614 | -* Updated Spanish translation (Ramon Rey Vicente) |
| 615 | - |
| 616 | - |
| 617 | -Version 2.0-b2 |
| 618 | -* Redesigned preferences and pad properties dialogs |
| 619 | -* If the tray disappears (e.g. killall gnome-panel), xpad's icon reappears |
| 620 | -* More formally ask window manager to make us skip taskbar and pager |
| 621 | -* New, lighter default color for pads |
| 622 | -* Lots of internal code cleanup |
| 623 | -* Fixed a crasher with not being able to find window icons |
| 624 | -* Fixed some crashers with turning off toolbar |
| 625 | -* Fixed bug with text cursor color being one color change behind |
| 626 | - |
| 627 | - |
| 628 | -Version 2.0-b1 |
| 629 | -* The text cursor is now always the same color as the text color |
| 630 | -* Formatting can now be applied to selected text |
| 631 | -* Pads remember their hidden state |
| 632 | -* Rewritten toolbar, allowing easier adding/removing/moving buttons |
| 633 | -* Simplified preferences dialog; many functions are now accessed from popup menu |
| 634 | -* --new now also loads the old pads, instead of the previous broken behavior |
| 635 | -* Fixed bug with pads over the 9th not having numbers in note lists |
| 636 | -* Fixed bug with inter process communicating causing only first communication to work |
| 637 | -* Fixed bug with pads becoming unstyled after closing and reopening |
| 638 | -* New Afrikaans translation (Petri Jooste) |
| 639 | -* New French translation (Michel Robitaille) |
| 640 | - |
| 641 | - |
| 642 | -Version 1.13 |
| 643 | -* Don't close xpad if no pads are open but the system tray is |
| 644 | -* Made translations work again |
| 645 | -* New Spanish translation (Ramon Rey Vicente) |
| 646 | -* Updated Dutch translation (Elros Cyriatan) |
| 647 | -* Updated Irish translation (Kevin Patrick Scannell) |
| 648 | - |
| 649 | - |
| 650 | -Version 1.12 |
| 651 | -* Fixed segfault when clicking on auto-hide toolbar preference |
| 652 | -* Fixed segfault when changing the first toolbar button |
| 653 | -* Added Irish translation (by Kevin Patrick Scannell) |
| 654 | - |
| 655 | - |
| 656 | -Version 1.11 |
| 657 | -* Added Dutch translation (by t.c.witte@phys.uu.nl) |
| 658 | -* Added partial Esperanto translation (by mterry@fastmail.fm) |
| 659 | -* Added Romanian translation (by eugenh@urban-grafx.ro) |
| 660 | -* Added Russian translation (by avl@cad.ru) |
| 661 | -* Added missing "include <sys/time.h>" (by netgeek@speakeasy.net) |
| 662 | -* Added missing #defines for solaris (by alan@cesma.usb.ve) |
| 663 | -* Added new icon and install icon family into new location per icon theme spec |
| 664 | -* Fixed disk-full-causes-xpad-contents-to-disappear bug |
| 665 | -* Made pads not show up in taskbar |
| 666 | -* Added 'pads start sticky' option |
| 667 | - |
| 668 | - |
| 669 | -Version 1.10.1 |
| 670 | -* Fixed some compile-time issues, particularly with GTK+ 2.0 |
| 671 | - |
| 672 | - |
| 673 | -Version 1.10 |
| 674 | -* Rewrote applet popup menu to be more consistent and hopefully useful |
| 675 | -* Fixed crash when closing a pad that had provided text in a cut/paste |
| 676 | -* Normalize pad dimensions when opening in case the values got messed up |
| 677 | -* Misc. small bugs |
| 678 | - |
| 679 | - |
| 680 | -Version 1.9.1 |
| 681 | -* Fix a segfault when show all is selected after a new pad is made |
| 682 | - |
| 683 | - |
| 684 | -Version 1.9 |
| 685 | -* Now use automake/autoconf, which allows for more complete build control |
| 686 | -* Now use gettext, allowing easy translation of xpad |
| 687 | -* Now auto-apply any pad changes to hard drive, making xpad a tad more |
| 688 | - reliable |
| 689 | -* Now can easily change settings for only one pad |
| 690 | -* A little more sane title generation -- now just uses first line |
| 691 | -* X session management support |
| 692 | -* |
| 693 | -* Popup menu is decluttered and altered, with the HIG in mind |
| 694 | -* Fixed crash on exit if we didn't init docklet |
| 695 | -* Fixed new pads randomly starting up as white background |
| 696 | -* Cut/copy/paste are now unsensitive if no content to copy or paste |
| 697 | -* Pads now play nice with the X clipboard (middle mouse button) |
| 698 | -* Fixed a bug with the notification area applet |
| 699 | -* Fixed misc. small bugs |
| 700 | - |
| 701 | - |
| 702 | -Version 1.8 |
| 703 | -* Allow using system text color, background color, and font |
| 704 | -* Eggtray now appears, allowing users to hide all pads (thanks |
| 705 | - jgb3@email.byu.edu) |
| 706 | -* Now we compile using autoconf |
| 707 | -* |
| 708 | -* Xpad won't take 100% cpu sometimes when idle |
| 709 | -* Fixed bug that screwed up last toolbar button's toggle setting |
| 710 | -* Fixed toolbar hiding when you right click on another pad |
| 711 | -* Fixed style locking and sticky status changing on menu popup |
| 712 | -* No deletion confirmation if pad is only whitespace |
| 713 | - |
| 714 | - |
| 715 | -Version 1.7 |
| 716 | -* Popup alerts are more pleasing. (HIG compliant) |
| 717 | -* Added --nonew flag to prevent creation of new pads. |
| 718 | -* Changed --new flag to only open a new pad, not try to open old pads too. |
| 719 | -* Changed window titles from quoted to ellipses at the end. |
| 720 | -* Option to turn off toolbar auto-hide. |
| 721 | -* Added --list, -l, --show, -s. |
| 722 | - |
| 723 | - |
| 724 | -Version 1.6.1 |
| 725 | -* Fix segfault on startup if toolbar is disabled. |
| 726 | - |
| 727 | - |
| 728 | -Version 1.6 |
| 729 | -* Rearrange popup menu |
| 730 | -* More meaningful window titles |
| 731 | -* Add popup menu submenu that allows you to choose window to show |
| 732 | -* Allow reopening of closed pads |
| 733 | -* The return of cut/copy/paste |
| 734 | -* Native sticky support |
| 735 | -* Add a show all command -- via command line or menu |
| 736 | -* Allow turning off of scrollbars |
| 737 | -* Allow reshowing of closed pads (without restarting xpad) |
| 738 | -* |
| 739 | -* Stopped style lock from turning on accidentally |
| 740 | -* Properly handle WM closures |
| 741 | -* Better HIG-style support of keyboard accelerators |
| 742 | - |
| 743 | - |
| 744 | -Version 1.5.1 |
| 745 | -* Fix a possible segfault on startup |
| 746 | - |
| 747 | - |
| 748 | -Version 1.5 |
| 749 | -* Fixed a bug that stopped saving of defaults on shutdown |
| 750 | -* Better error reporting |
| 751 | -* Added a toolbar with customizable buttons |
| 752 | -* Added some new command line options |
| 753 | -* Allow style locking |
| 754 | -* Allow pad clearing |
| 755 | -* Added all new preference help window |
| 756 | - |
| 757 | - |
| 758 | -Version 1.4 |
| 759 | -* Code cleanup |
| 760 | -* We now compile clean with -ansi and -pedantic! ;) |
| 761 | -* Should take up a little less memory |
| 762 | -* Fixed several memory leaks |
| 763 | -* Should be able to compile on windows and beos. |
| 764 | - -- PLEASE let me know how this works for you. |
| 765 | -* Added scrollbars if window isn't big enough to handle text |
| 766 | - -- this fixes two known bugs |
| 767 | -* New xpad processes now handled gracefully |
| 768 | -* Added further optimizations to compilation |
| 769 | - -- let me know if this causes you problems |
| 770 | -* Fixed some possible buffer overflows |
| 771 | -* Fixed some warnings/errors on gcc3 compilation |
| 772 | -* Cursor icon changes when edit lock is on |
| 773 | - |
| 774 | - |
| 775 | -Version 1.3 |
| 776 | -* Added a padding option (thanks Nagy Mate) |
| 777 | -* Redesigned dialogs |
| 778 | -* Preferences now auto-apply |
| 779 | -* You can now choose what the wm close button does, defaults to close |
| 780 | -* Pads have individual titles now |
| 781 | -* Xpad gets along better with various wm's now |
| 782 | -* Cursor no longer blinks if you can't edit pad |
| 783 | -* Fixed double-clicking-doesn't-select-text-when-edit-lock-is-on bug |
| 784 | -* Pads can no longer be individually closed (unless wm decor is on) |
| 785 | - |
| 786 | - |
| 787 | -Version 1.2.1 |
| 788 | -* Fixed segfault on startup if no ~/.xpad directory, plus some related bugs |
| 789 | - |
| 790 | - |
| 791 | -Version 1.2 |
| 792 | -* Fixed an issue causing black on black with big-endian architectures |
| 793 | -* Added "Edit Lock" mode |
| 794 | -* General code cleanup |
| 795 | - |
| 796 | - |
| 797 | -Version 1.1 |
| 798 | -* Simplified popup menu (removed GTK+ default cut/copy/paste/input |
| 799 | - method/insert). If you used them, and miss them, let me know. |
| 800 | -* Added keyboard shortcuts for most menu items |
| 801 | -* Expanded help dialog to include shortcuts |
| 802 | -* Allow border left-drags, right-drags, and right clicks |
| 803 | - |
| 804 | - |
| 805 | -Version 1.0.2 |
| 806 | -* Stopped pads from losing their place on x shut down |
| 807 | - |
| 808 | - |
| 809 | -Version 1.0.1 |
| 810 | -* Fixed a possible runtime warning with autosaving |
| 811 | -* Made window icon code more robust |
| 812 | -* Added icons for all menu items |
| 813 | - |
| 814 | - |
| 815 | -Version 1.0 |
| 816 | -* Added an open file dialog |
| 817 | -* Added a save as dialog |
| 818 | -* Closed pads are handled more consistently |
| 819 | -* Unified color/font change screens |
| 820 | -* Fixed font not being saved correctly |
| 821 | -* Added ability to fine tune default pad settings, including size (before |
| 822 | - this was all handled transparently, but size was not always updated) |
| 823 | -* Added optional confirmation to pad destroys |
| 824 | -* Window decorations can now be turned on (in global pref screen) |
| 825 | -* Added border color and border width options |
| 826 | -* Added gui for sync time (autosaving) control |
| 827 | -* Took out --sync-time and -s (you can do same thing with above gui) |
| 828 | -* Stopped new pads always being placed in same spot |
| 829 | -* Added help screen, which opens when you click on "help" from right-click |
| 830 | - menu and on first run |
| 831 | -* Much cleaner internal api |
| 832 | -* Made xpad more theme-friendly |
| 833 | -* Resizing/moving now works even if numpad is on |
| 834 | -* Xpad 1.0 can now open much older versions of xpad's files (tested to 0.2.1) |
| 835 | -* Added app icon (thanks nestor di) |
| 836 | - |
| 837 | - |
| 838 | -Version 0.2.5 |
| 839 | -* Added --help |
| 840 | -* Added short forms of arguments (e.g. -h, -v, -V, -s) |
| 841 | -* Added more output messages |
| 842 | -* Stopped pad raising above popup on right click |
| 843 | -* Fixed bug where old pads wouldn't open upon startup |
| 844 | -* No size limit on pads |
| 845 | - |
| 846 | - |
| 847 | -Version 0.2.4 |
| 848 | -* Fixed small memory leak if no default-style file |
| 849 | -* Pads rise to foreground if clicked on now |
| 850 | -* Added "close all" option on popup |
| 851 | -* Prints out a message when autosaving |
| 852 | -* Added --verbosity= option. (0 is default - no messages; 1 is |
| 853 | - moderate - important things like autosaving; 2 is debug - |
| 854 | - more info than necessary) |
| 855 | -* Removed some possible buffer overflows if text is too large (a hardcoded |
| 856 | - limit of 20k chars now) |
| 857 | -* Misc. code cleanups |
| 858 | - |
| 859 | - |
| 860 | -Version 0.2.3.1 |
| 861 | -* Fixed nasty bug where, if you didn't have a working ~/.xpad/default-styles |
| 862 | - file, it would seg-fault. my bad |
| 863 | - |
| 864 | - |
| 865 | -Version 0.2.3 |
| 866 | -* Perfected (?) syncing. Now will recover cleanly from anything -- including |
| 867 | - power shut off or random interrupts. This fixes the "pad contents |
| 868 | - disappearing on X-shutdown" bug |
| 869 | -* Moved menu items around a bit |
| 870 | -* Remembers preferred size (only if you change fonts/colors. on TODO) |
| 871 | -* Not always centered now |
| 872 | - |
| 873 | - |
| 874 | -Version 0.2.2 |
| 875 | -* Debian-friendly Makefile fixes |
| 876 | -* Cleaned up code |
| 877 | - |
| 878 | - |
| 879 | -Version 0.2.1 |
| 880 | -* Changed saving to be more fault-tolerant |
| 881 | -* Added about screen with version info |
| 882 | - |
| 883 | - |
| 884 | -Version 0.2 |
| 885 | -* Ported to gtk+-2.0 |
| 886 | -* Now can change font color |
| 887 | -* If xpad is already running, will open new pad, not open old pads again |
| 888 | -* In-xpad moving and resizing now works |
| 889 | -* Xpad now recovers better from being interrupted |
| 890 | -* Remembers your preferred style |
| 891 | -* Many small bugfixes |
| 892 | -* Code reorganization |
| 893 | - |
| 894 | - |
| 895 | -Version 0.1.9.2 |
| 896 | -* Cleaner lack of decorations |
| 897 | -* Fixed "double-click on menu" bug |
| 898 | -* Fixed segfault when only a font size change was requested |
| 899 | -* Added close and destroy items to menu. Now you can close a window without |
| 900 | - losing content |
| 901 | |
| 902 | === modified file 'src/help.c' |
| 903 | --- src/help.c 2008-09-21 00:03:40 +0000 |
| 904 | +++ src/help.c 2013-10-18 18:35:35 +0000 |
| 905 | @@ -59,8 +59,8 @@ |
| 906 | _("Most actions are available throught the popup menu " |
| 907 | "that appears when you right click on a pad. Try it out and " |
| 908 | "enjoy."), |
| 909 | -_("Please send comments or bug reports to " |
| 910 | -"xpad-devel@lists.sourceforge.net")); |
| 911 | +_("Please send ideas or bug reports to\n" |
| 912 | +"https://bugs.launchpad.net/xpad/+filebug")); |
| 913 | |
| 914 | gtk_label_set_markup (GTK_LABEL (helptext), helptextbuf); |
| 915 | |
| 916 | |
| 917 | === modified file 'src/xpad-app.c' |
| 918 | --- src/xpad-app.c 2013-10-09 14:46:10 +0000 |
| 919 | +++ src/xpad-app.c 2013-10-18 18:35:35 +0000 |
| 920 | @@ -42,6 +42,7 @@ |
| 921 | #include "xpad-pad-group.h" |
| 922 | #include "xpad-periodic.h" |
| 923 | #include "xpad-session-manager.h" |
| 924 | +#include "xpad-settings.h" |
| 925 | #include "xpad-tray.h" |
| 926 | |
| 927 | /* Seems that some systems (sun-sparc-solaris2.8 at least), need the following three #defines. |
| 928 | @@ -98,8 +99,8 @@ |
| 929 | { |
| 930 | gboolean first_time; |
| 931 | gboolean have_gtk; |
| 932 | -/* GdkVisual *visual;*/ |
| 933 | - |
| 934 | + // GdkVisual *visual; |
| 935 | + |
| 936 | /* Set up i18n */ |
| 937 | #ifdef ENABLE_NLS |
| 938 | gtk_set_locale (); |
| 939 | @@ -107,7 +108,7 @@ |
| 940 | bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); |
| 941 | textdomain (GETTEXT_PACKAGE); |
| 942 | #endif |
| 943 | - |
| 944 | + |
| 945 | have_gtk = gtk_init_check (&argc, &argv); |
| 946 | xpad_argc = argc; |
| 947 | xpad_argv = argv; |
| 948 | @@ -253,7 +254,19 @@ |
| 949 | void |
| 950 | xpad_app_quit (void) |
| 951 | { |
| 952 | - xpad_pad_group_save_unsaved_all(xpad_app_get_pad_group()); |
| 953 | + // Free the memory used by the pads belonging to this group |
| 954 | + xpad_pad_group_destroy_pads(xpad_app_get_pad_group()); |
| 955 | + |
| 956 | + // Free the memory used by group. |
| 957 | + g_object_unref(xpad_app_get_pad_group()); |
| 958 | + |
| 959 | + // Free the memory used by the settings menu. |
| 960 | + g_object_unref(XPAD_SETTINGS(xpad_settings())); |
| 961 | + |
| 962 | + // Free the memory used by the tray icon and its menu. |
| 963 | + xpad_tray_close(); |
| 964 | + |
| 965 | + // Give GTK the signal to clean the rest and quit the application. |
| 966 | gtk_main_quit(); |
| 967 | } |
| 968 | |
| 969 | @@ -290,21 +303,24 @@ |
| 970 | { |
| 971 | GSList *dirs = NULL, *i; |
| 972 | gchar *dirname; |
| 973 | - |
| 974 | + |
| 975 | dirname = g_strdup (path); |
| 976 | + |
| 977 | while (!g_file_test (dirname, G_FILE_TEST_EXISTS)) |
| 978 | { |
| 979 | dirs = g_slist_prepend (dirs, dirname); |
| 980 | dirname = g_path_get_dirname (dirname); |
| 981 | } |
| 982 | g_free (dirname); |
| 983 | - |
| 984 | + |
| 985 | for (i = dirs; i; i = i->next) |
| 986 | { |
| 987 | g_mkdir ((gchar *) i->data, 0700); |
| 988 | g_free (i->data); |
| 989 | } |
| 990 | - g_slist_free (dirs); |
| 991 | + |
| 992 | + g_slist_free(dirs); |
| 993 | + g_slist_free(i); |
| 994 | } |
| 995 | |
| 996 | /** |
| 997 | @@ -315,9 +331,9 @@ |
| 998 | make_config_dir (void) |
| 999 | { |
| 1000 | gchar *dir = NULL; |
| 1001 | - |
| 1002 | + |
| 1003 | make_path (g_get_user_config_dir ()); |
| 1004 | - |
| 1005 | + |
| 1006 | dir = g_build_filename (g_get_user_config_dir (), PACKAGE, NULL); |
| 1007 | |
| 1008 | if (!g_file_test (dir, G_FILE_TEST_EXISTS)) |
| 1009 | @@ -391,7 +407,7 @@ |
| 1010 | register_stock_icons (void) |
| 1011 | { |
| 1012 | GtkIconTheme *theme; |
| 1013 | - |
| 1014 | + |
| 1015 | theme = gtk_icon_theme_get_default (); |
| 1016 | gtk_icon_theme_prepend_search_path (theme, THEME_DIR); |
| 1017 | } |
| 1018 | @@ -699,6 +715,7 @@ |
| 1019 | gint size; |
| 1020 | gint bytesRead; |
| 1021 | gboolean connected = FALSE; |
| 1022 | + ssize_t error = NULL; |
| 1023 | |
| 1024 | /* create master socket */ |
| 1025 | client_fd = socket (PF_LOCAL, SOCK_STREAM, 0); |
| 1026 | @@ -713,10 +730,14 @@ |
| 1027 | size = args_to_string (xpad_argc, xpad_argv, &args) + 1; |
| 1028 | |
| 1029 | /* first, write length of string */ |
| 1030 | - write (client_fd, &size, sizeof (size)); |
| 1031 | + error = write (client_fd, &size, sizeof (size)); |
| 1032 | + if (error == -1) |
| 1033 | + g_error("There is a problem writing information to the socket."); |
| 1034 | |
| 1035 | /* now, write string */ |
| 1036 | - write (client_fd, args, size); |
| 1037 | + error = write (client_fd, args, (size_t) size); |
| 1038 | + if (error == -1) |
| 1039 | + g_error("There is a problem writing information to the socket."); |
| 1040 | |
| 1041 | do |
| 1042 | { |
| 1043 | |
| 1044 | === modified file 'src/xpad-grip-tool-item.c' |
| 1045 | --- src/xpad-grip-tool-item.c 2008-09-21 00:03:40 +0000 |
| 1046 | +++ src/xpad-grip-tool-item.c 2013-10-18 18:35:35 +0000 |
| 1047 | @@ -18,15 +18,16 @@ |
| 1048 | |
| 1049 | #include "xpad-grip-tool-item.h" |
| 1050 | |
| 1051 | -G_DEFINE_TYPE(XpadGripToolItem, xpad_grip_tool_item, GTK_TYPE_TOOL_ITEM) |
| 1052 | -#define XPAD_GRIP_TOOL_ITEM_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), XPAD_TYPE_GRIP_TOOL_ITEM, XpadGripToolItemPrivate)) |
| 1053 | - |
| 1054 | struct XpadGripToolItemPrivate |
| 1055 | { |
| 1056 | GtkWidget *drawbox; |
| 1057 | }; |
| 1058 | |
| 1059 | -/*static void xpad_grip_tool_item_size_request (GtkWidget *widget, GtkRequisition *requisition);*/ |
| 1060 | +G_DEFINE_TYPE_WITH_PRIVATE(XpadGripToolItem, xpad_grip_tool_item, GTK_TYPE_TOOL_ITEM) |
| 1061 | + |
| 1062 | +static void xpad_grip_tool_item_dispose (GObject *object); |
| 1063 | +static void xpad_grip_tool_item_finalize (GObject *object); |
| 1064 | + |
| 1065 | static gboolean xpad_grip_tool_item_event_box_expose (GtkWidget *widget, GdkEventExpose *event); |
| 1066 | static void xpad_grip_tool_item_event_box_realize (GtkWidget *widget); |
| 1067 | static gboolean xpad_grip_tool_item_button_pressed_event (GtkWidget *widget, GdkEventButton *event); |
| 1068 | @@ -40,15 +41,10 @@ |
| 1069 | static void |
| 1070 | xpad_grip_tool_item_class_init (XpadGripToolItemClass *klass) |
| 1071 | { |
| 1072 | - GObjectClass *gobject_class; |
| 1073 | - GtkContainerClass *container_class; |
| 1074 | - GtkWidgetClass *widget_class; |
| 1075 | - |
| 1076 | - gobject_class = (GObjectClass *)klass; |
| 1077 | - container_class = (GtkContainerClass *)klass; |
| 1078 | - widget_class = (GtkWidgetClass *)klass; |
| 1079 | - |
| 1080 | - g_type_class_add_private (gobject_class, sizeof (XpadGripToolItemPrivate)); |
| 1081 | + GObjectClass *gobject_class = G_OBJECT_CLASS (klass); |
| 1082 | + |
| 1083 | + gobject_class->dispose = xpad_grip_tool_item_dispose; |
| 1084 | + gobject_class->finalize = xpad_grip_tool_item_finalize; |
| 1085 | } |
| 1086 | |
| 1087 | static void |
| 1088 | @@ -57,7 +53,7 @@ |
| 1089 | GtkWidget *alignment; |
| 1090 | gboolean right; |
| 1091 | |
| 1092 | - grip->priv = XPAD_GRIP_TOOL_ITEM_GET_PRIVATE (grip); |
| 1093 | + grip->priv = xpad_grip_tool_item_get_instance_private(grip); |
| 1094 | |
| 1095 | grip->priv->drawbox = gtk_drawing_area_new (); |
| 1096 | gtk_widget_add_events (grip->priv->drawbox, GDK_BUTTON_PRESS_MASK | GDK_EXPOSURE_MASK); |
| 1097 | @@ -73,6 +69,19 @@ |
| 1098 | gtk_container_add (GTK_CONTAINER (grip), alignment); |
| 1099 | } |
| 1100 | |
| 1101 | +static void |
| 1102 | +xpad_grip_tool_item_dispose (GObject *object) |
| 1103 | +{ |
| 1104 | + G_OBJECT_CLASS (xpad_grip_tool_item_parent_class)->dispose (object); |
| 1105 | +} |
| 1106 | + |
| 1107 | +static void |
| 1108 | +xpad_grip_tool_item_finalize (GObject *object) |
| 1109 | +{ |
| 1110 | + G_OBJECT_CLASS (xpad_grip_tool_item_parent_class)->finalize (object); |
| 1111 | +} |
| 1112 | + |
| 1113 | + |
| 1114 | static gboolean |
| 1115 | xpad_grip_tool_item_button_pressed_event (GtkWidget *widget, GdkEventButton *event) |
| 1116 | { |
| 1117 | |
| 1118 | === modified file 'src/xpad-pad-group.c' |
| 1119 | --- src/xpad-pad-group.c 2013-10-09 14:46:10 +0000 |
| 1120 | +++ src/xpad-pad-group.c 2013-10-18 18:35:35 +0000 |
| 1121 | @@ -18,20 +18,18 @@ |
| 1122 | */ |
| 1123 | |
| 1124 | #include "xpad-pad-group.h" |
| 1125 | +#include "xpad-settings.h" |
| 1126 | #include "xpad-pad.h" |
| 1127 | |
| 1128 | -G_DEFINE_TYPE(XpadPadGroup, xpad_pad_group, G_TYPE_OBJECT) |
| 1129 | - |
| 1130 | -#define XPAD_PAD_GROUP_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), XPAD_TYPE_PAD_GROUP, XpadPadGroupPrivate)) |
| 1131 | - |
| 1132 | struct XpadPadGroupPrivate |
| 1133 | { |
| 1134 | GSList *pads; |
| 1135 | }; |
| 1136 | |
| 1137 | +G_DEFINE_TYPE_WITH_PRIVATE(XpadPadGroup, xpad_pad_group, G_TYPE_OBJECT) |
| 1138 | + |
| 1139 | static void xpad_pad_group_dispose (GObject *object); |
| 1140 | - |
| 1141 | -static void xpad_pad_group_destroy_pads (XpadPadGroup *group); |
| 1142 | +static void xpad_pad_group_finalize (GObject *object); |
| 1143 | |
| 1144 | enum { |
| 1145 | PROP_0 |
| 1146 | @@ -53,11 +51,20 @@ |
| 1147 | } |
| 1148 | |
| 1149 | static void |
| 1150 | +xpad_pad_group_init (XpadPadGroup *group) |
| 1151 | +{ |
| 1152 | + group->priv = xpad_pad_group_get_instance_private(group); |
| 1153 | + |
| 1154 | + group->priv->pads = NULL; |
| 1155 | +} |
| 1156 | + |
| 1157 | +static void |
| 1158 | xpad_pad_group_class_init (XpadPadGroupClass *klass) |
| 1159 | { |
| 1160 | GObjectClass *object_class = G_OBJECT_CLASS (klass); |
| 1161 | |
| 1162 | object_class->dispose = xpad_pad_group_dispose; |
| 1163 | + object_class->finalize = xpad_pad_group_finalize; |
| 1164 | |
| 1165 | signals[PAD_ADDED] = |
| 1166 | g_signal_new ("pad_added", |
| 1167 | @@ -80,8 +87,6 @@ |
| 1168 | G_TYPE_NONE, |
| 1169 | 1, |
| 1170 | GTK_TYPE_WIDGET); |
| 1171 | - |
| 1172 | - g_type_class_add_private (object_class, sizeof (XpadPadGroupPrivate)); |
| 1173 | } |
| 1174 | |
| 1175 | static void |
| 1176 | @@ -89,31 +94,35 @@ |
| 1177 | { |
| 1178 | XpadPadGroup *group = XPAD_PAD_GROUP (object); |
| 1179 | |
| 1180 | - xpad_pad_group_destroy_pads (group); |
| 1181 | + // Save all pads of this group |
| 1182 | + xpad_pad_group_save_unsaved_all(group); |
| 1183 | + |
| 1184 | + G_OBJECT_CLASS (xpad_pad_group_parent_class)->dispose (object); |
| 1185 | } |
| 1186 | |
| 1187 | static void |
| 1188 | -xpad_pad_group_init (XpadPadGroup *group) |
| 1189 | +xpad_pad_group_finalize (GObject *object) |
| 1190 | { |
| 1191 | - group->priv = XPAD_PAD_GROUP_GET_PRIVATE (group); |
| 1192 | - |
| 1193 | + XpadPadGroup *group = XPAD_PAD_GROUP (object); |
| 1194 | + |
| 1195 | + g_slist_free (group->priv->pads); |
| 1196 | group->priv->pads = NULL; |
| 1197 | + |
| 1198 | + G_OBJECT_CLASS (xpad_pad_group_parent_class)->finalize (object); |
| 1199 | } |
| 1200 | |
| 1201 | - |
| 1202 | GSList * |
| 1203 | xpad_pad_group_get_pads (XpadPadGroup *group) |
| 1204 | { |
| 1205 | return g_slist_copy (group->priv->pads); |
| 1206 | } |
| 1207 | |
| 1208 | - |
| 1209 | -/* Subsumes a pad into this group */ |
| 1210 | +/* Add a pad to this group */ |
| 1211 | void |
| 1212 | xpad_pad_group_add (XpadPadGroup *group, GtkWidget *pad) |
| 1213 | { |
| 1214 | g_object_ref(pad); |
| 1215 | - g_object_ref_sink(GTK_OBJECT(pad)); |
| 1216 | + // g_object_ref_sink(GTK_OBJECT(pad)); |
| 1217 | |
| 1218 | group->priv->pads = g_slist_append (group->priv->pads, XPAD_PAD (pad)); |
| 1219 | g_signal_connect_swapped (pad, "destroy", G_CALLBACK (xpad_pad_group_remove), group); |
| 1220 | @@ -121,21 +130,19 @@ |
| 1221 | g_signal_emit (group, signals[PAD_ADDED], 0, pad); |
| 1222 | } |
| 1223 | |
| 1224 | - |
| 1225 | -/* Removes a pad from this group */ |
| 1226 | +/* Remove a pad from this group */ |
| 1227 | void |
| 1228 | xpad_pad_group_remove (XpadPadGroup *group, GtkWidget *pad) |
| 1229 | { |
| 1230 | group->priv->pads = g_slist_remove (group->priv->pads, XPAD_PAD (pad)); |
| 1231 | - |
| 1232 | + g_object_unref(pad); |
| 1233 | + pad = NULL; |
| 1234 | + |
| 1235 | g_signal_emit (group, signals[PAD_REMOVED], 0, pad); |
| 1236 | - |
| 1237 | - g_object_unref(pad); |
| 1238 | } |
| 1239 | |
| 1240 | - |
| 1241 | -/* Deletes all the current pads in the group */ |
| 1242 | -static void |
| 1243 | +/* Delete all the current pads in the group */ |
| 1244 | +void |
| 1245 | xpad_pad_group_destroy_pads (XpadPadGroup *group) |
| 1246 | { |
| 1247 | g_slist_foreach (group->priv->pads, (GFunc) gtk_widget_destroy, NULL); |
| 1248 | @@ -143,6 +150,11 @@ |
| 1249 | group->priv->pads = NULL; |
| 1250 | } |
| 1251 | |
| 1252 | +guint |
| 1253 | +xpad_pad_group_num_pads (XpadPadGroup *group) |
| 1254 | +{ |
| 1255 | + return g_slist_length(group->priv->pads); |
| 1256 | +} |
| 1257 | |
| 1258 | gint |
| 1259 | xpad_pad_group_num_visible_pads (XpadPadGroup *group) |
| 1260 | @@ -156,11 +168,11 @@ |
| 1261 | if (GTK_WIDGET_VISIBLE(GTK_WIDGET(i->data))) |
| 1262 | num ++; |
| 1263 | } |
| 1264 | + g_slist_free(i); |
| 1265 | } |
| 1266 | return num; |
| 1267 | } |
| 1268 | |
| 1269 | - |
| 1270 | void |
| 1271 | xpad_pad_group_close_all (XpadPadGroup *group) |
| 1272 | { |
| 1273 | @@ -182,11 +194,9 @@ |
| 1274 | g_slist_foreach (group->priv->pads, (GFunc) gtk_widget_show, NULL); |
| 1275 | } |
| 1276 | |
| 1277 | - |
| 1278 | void |
| 1279 | xpad_pad_group_toggle_hide(XpadPadGroup *group) |
| 1280 | { |
| 1281 | if (group) |
| 1282 | g_slist_foreach (group->priv->pads, (GFunc) xpad_pad_toggle, NULL); |
| 1283 | } |
| 1284 | - |
| 1285 | |
| 1286 | === modified file 'src/xpad-pad-group.h' |
| 1287 | --- src/xpad-pad-group.h 2013-10-09 14:46:10 +0000 |
| 1288 | +++ src/xpad-pad-group.h 2013-10-18 18:35:35 +0000 |
| 1289 | @@ -64,6 +64,7 @@ |
| 1290 | GSList * xpad_pad_group_get_pads (XpadPadGroup *group); |
| 1291 | gint xpad_pad_group_num_visible_pads (XpadPadGroup *group); |
| 1292 | void xpad_pad_group_save_unsaved_all (XpadPadGroup *group); |
| 1293 | +void xpad_pad_group_destroy_pads (XpadPadGroup *group); |
| 1294 | |
| 1295 | G_END_DECLS |
| 1296 | |
| 1297 | |
| 1298 | === modified file 'src/xpad-pad-properties.c' |
| 1299 | --- src/xpad-pad-properties.c 2008-09-21 00:03:40 +0000 |
| 1300 | +++ src/xpad-pad-properties.c 2013-10-18 18:35:35 +0000 |
| 1301 | @@ -22,9 +22,6 @@ |
| 1302 | #include <glib/gi18n.h> |
| 1303 | #include "xpad-pad-properties.h" |
| 1304 | |
| 1305 | -G_DEFINE_TYPE(XpadPadProperties, xpad_pad_properties, GTK_TYPE_DIALOG) |
| 1306 | -#define XPAD_PAD_PROPERTIES_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), XPAD_TYPE_PAD_PROPERTIES, XpadPadPropertiesPrivate)) |
| 1307 | - |
| 1308 | struct XpadPadPropertiesPrivate |
| 1309 | { |
| 1310 | GtkWidget *fontcheck; |
| 1311 | @@ -40,6 +37,10 @@ |
| 1312 | GtkWidget *fontbutton; |
| 1313 | }; |
| 1314 | |
| 1315 | +G_DEFINE_TYPE_WITH_PRIVATE(XpadPadProperties, xpad_pad_properties, GTK_TYPE_DIALOG) |
| 1316 | + |
| 1317 | +static void xpad_pad_properties_dispose (GObject *object); |
| 1318 | +static void xpad_pad_properties_finalize (GObject *object); |
| 1319 | static void xpad_pad_properties_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); |
| 1320 | static void xpad_pad_properties_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); |
| 1321 | static void xpad_pad_properties_response (GtkDialog *dialog, gint response); |
| 1322 | @@ -71,6 +72,8 @@ |
| 1323 | { |
| 1324 | GObjectClass *gobject_class = G_OBJECT_CLASS (klass); |
| 1325 | |
| 1326 | + gobject_class->dispose = xpad_pad_properties_dispose; |
| 1327 | + gobject_class->finalize = xpad_pad_properties_finalize; |
| 1328 | gobject_class->set_property = xpad_pad_properties_set_property; |
| 1329 | gobject_class->get_property = xpad_pad_properties_get_property; |
| 1330 | |
| 1331 | @@ -115,8 +118,6 @@ |
| 1332 | "The name of the font for the pad", |
| 1333 | NULL, |
| 1334 | G_PARAM_READWRITE)); |
| 1335 | - |
| 1336 | - g_type_class_add_private (gobject_class, sizeof (XpadPadPropertiesPrivate)); |
| 1337 | } |
| 1338 | |
| 1339 | static void |
| 1340 | @@ -127,7 +128,7 @@ |
| 1341 | gchar *text; |
| 1342 | GtkSizeGroup *size_group_labels = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); |
| 1343 | |
| 1344 | - prop->priv = XPAD_PAD_PROPERTIES_GET_PRIVATE (prop); |
| 1345 | + prop->priv = xpad_pad_properties_get_instance_private(prop); |
| 1346 | |
| 1347 | text = g_strconcat ("<b>", _("Appearance"), "</b>", NULL); |
| 1348 | label = GTK_WIDGET (g_object_new (GTK_TYPE_LABEL, |
| 1349 | @@ -233,6 +234,25 @@ |
| 1350 | } |
| 1351 | |
| 1352 | static void |
| 1353 | +xpad_pad_properties_dispose (GObject *object) |
| 1354 | +{ |
| 1355 | + G_OBJECT_CLASS (xpad_pad_properties_parent_class)->dispose (object); |
| 1356 | +} |
| 1357 | + |
| 1358 | +static void |
| 1359 | +xpad_pad_properties_finalize (GObject *object) |
| 1360 | +{ |
| 1361 | + XpadPadProperties *prop = XPAD_PAD_PROPERTIES (object); |
| 1362 | + |
| 1363 | + if (&prop->priv->texttmp) |
| 1364 | + gdk_color_free (&prop->priv->texttmp); |
| 1365 | + if (&prop->priv->backtmp != NULL) |
| 1366 | + gdk_color_free (&prop->priv->backtmp); |
| 1367 | + |
| 1368 | + G_OBJECT_CLASS (xpad_pad_properties_parent_class)->finalize (object); |
| 1369 | +} |
| 1370 | + |
| 1371 | +static void |
| 1372 | xpad_pad_properties_response (GtkDialog *dialog, gint response) |
| 1373 | { |
| 1374 | if (response == GTK_RESPONSE_CLOSE) |
| 1375 | |
| 1376 | === modified file 'src/xpad-pad.c' |
| 1377 | --- src/xpad-pad.c 2013-10-11 19:45:49 +0000 |
| 1378 | +++ src/xpad-pad.c 2013-10-18 18:35:35 +0000 |
| 1379 | @@ -40,13 +40,11 @@ |
| 1380 | #include "xpad-toolbar.h" |
| 1381 | #include "xpad-tray.h" |
| 1382 | |
| 1383 | -G_DEFINE_TYPE(XpadPad, xpad_pad, GTK_TYPE_WINDOW) |
| 1384 | -#define XPAD_PAD_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), XPAD_TYPE_PAD, XpadPadPrivate)) |
| 1385 | - |
| 1386 | struct XpadPadPrivate |
| 1387 | { |
| 1388 | /* saved values */ |
| 1389 | - gint x, y, width, height; |
| 1390 | + gint x, y; |
| 1391 | + guint width, height; |
| 1392 | gboolean location_valid; |
| 1393 | gchar *infoname; |
| 1394 | gchar *contentname; |
| 1395 | @@ -59,7 +57,7 @@ |
| 1396 | /* toolbar stuff */ |
| 1397 | GtkWidget *toolbar; |
| 1398 | guint toolbar_timeout; |
| 1399 | - gint toolbar_height; |
| 1400 | + guint toolbar_height; |
| 1401 | gboolean toolbar_expanded; |
| 1402 | gboolean toolbar_pad_resized; |
| 1403 | |
| 1404 | @@ -72,10 +70,14 @@ |
| 1405 | |
| 1406 | gboolean unsaved_content; |
| 1407 | gboolean unsaved_info; |
| 1408 | + |
| 1409 | + GtkClipboard *clipboard; |
| 1410 | |
| 1411 | XpadPadGroup *group; |
| 1412 | }; |
| 1413 | |
| 1414 | +G_DEFINE_TYPE_WITH_PRIVATE(XpadPad, xpad_pad, GTK_TYPE_WINDOW) |
| 1415 | + |
| 1416 | enum |
| 1417 | { |
| 1418 | CLOSED, |
| 1419 | @@ -221,8 +223,6 @@ |
| 1420 | "Pad Group", |
| 1421 | "Pad group for this pad", |
| 1422 | G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); |
| 1423 | - |
| 1424 | - g_type_class_add_private (gobject_class, sizeof (XpadPadPrivate)); |
| 1425 | } |
| 1426 | |
| 1427 | /* Class pad - initializer */ |
| 1428 | @@ -231,9 +231,8 @@ |
| 1429 | { |
| 1430 | GtkWidget *vbox; |
| 1431 | GtkAccelGroup *accel_group; |
| 1432 | - GtkClipboard *clipboard; |
| 1433 | |
| 1434 | - pad->priv = XPAD_PAD_GET_PRIVATE (pad); |
| 1435 | + pad->priv = xpad_pad_get_instance_private(pad); |
| 1436 | |
| 1437 | pad->priv->x = 0; |
| 1438 | pad->priv->y = 0; |
| 1439 | @@ -251,8 +250,8 @@ |
| 1440 | pad->priv->toolbar_expanded = FALSE; |
| 1441 | pad->priv->toolbar_pad_resized = TRUE; |
| 1442 | pad->priv->properties = NULL; |
| 1443 | - pad->priv->unsaved_content = TRUE; |
| 1444 | - pad->priv->unsaved_info = TRUE; |
| 1445 | + pad->priv->unsaved_content = FALSE; |
| 1446 | + pad->priv->unsaved_info = FALSE; |
| 1447 | pad->priv->group = NULL; |
| 1448 | |
| 1449 | XpadTextView *text_view = g_object_new (XPAD_TYPE_TEXT_VIEW, |
| 1450 | @@ -277,12 +276,11 @@ |
| 1451 | |
| 1452 | accel_group = gtk_accel_group_new (); |
| 1453 | gtk_window_add_accel_group (GTK_WINDOW (pad), accel_group); |
| 1454 | - g_object_unref (G_OBJECT (accel_group)); |
| 1455 | pad->priv->menu = menu_get_popup_no_highlight (pad, accel_group); |
| 1456 | pad->priv->highlight_menu = menu_get_popup_highlight (pad, accel_group); |
| 1457 | gtk_accel_group_connect (accel_group, GDK_Q, GDK_CONTROL_MASK, 0, |
| 1458 | g_cclosure_new_swap (G_CALLBACK (xpad_pad_quit), pad, NULL)); |
| 1459 | - |
| 1460 | + g_object_unref (G_OBJECT (accel_group)); |
| 1461 | |
| 1462 | vbox = GTK_WIDGET (g_object_new (GTK_TYPE_VBOX, |
| 1463 | "homogeneous", FALSE, |
| 1464 | @@ -293,7 +291,7 @@ |
| 1465 | gtk_container_child_set (GTK_CONTAINER (vbox), pad->priv->toolbar, "expand", FALSE, NULL); |
| 1466 | |
| 1467 | gtk_window_set_decorated (GTK_WINDOW(pad), xpad_settings_get_has_decorations (xpad_settings ())); |
| 1468 | - gtk_window_set_default_size (GTK_WINDOW(pad), xpad_settings_get_width (xpad_settings ()), xpad_settings_get_height (xpad_settings ())); |
| 1469 | + gtk_window_set_default_size (GTK_WINDOW(pad), (gint) xpad_settings_get_width (xpad_settings ()), (gint) xpad_settings_get_height (xpad_settings ())); |
| 1470 | gtk_window_set_gravity (GTK_WINDOW(pad), GDK_GRAVITY_STATIC); /* static gravity makes saving pad x,y work */ |
| 1471 | gtk_window_set_skip_pager_hint (GTK_WINDOW(pad),xpad_settings_get_has_decorations (xpad_settings ())); |
| 1472 | gtk_window_set_skip_taskbar_hint (GTK_WINDOW(pad), !xpad_settings_get_has_decorations (xpad_settings ())); |
| 1473 | @@ -309,7 +307,19 @@ |
| 1474 | xpad_pad_notify_clipboard_owner_changed (pad); |
| 1475 | xpad_pad_notify_undo_redo_changed (pad); |
| 1476 | |
| 1477 | - clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD); |
| 1478 | + pad->priv->clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD); |
| 1479 | + |
| 1480 | + if (pad->priv->sticky) |
| 1481 | + gtk_window_stick (GTK_WINDOW (pad)); |
| 1482 | + else |
| 1483 | + gtk_window_unstick (GTK_WINDOW (pad)); |
| 1484 | + |
| 1485 | + xpad_pad_sync_title (pad); |
| 1486 | + |
| 1487 | + gtk_widget_show_all (vbox); |
| 1488 | + |
| 1489 | + gtk_widget_hide (pad->priv->toolbar); |
| 1490 | + xpad_pad_notify_has_toolbar (pad); |
| 1491 | |
| 1492 | /* Set up signals */ |
| 1493 | gtk_widget_add_events (GTK_WIDGET (pad), GDK_BUTTON_PRESS_MASK | GDK_PROPERTY_CHANGE_MASK); |
| 1494 | @@ -332,7 +342,7 @@ |
| 1495 | g_signal_connect_swapped (xpad_settings (), "notify::autohide-toolbar", G_CALLBACK (xpad_pad_notify_autohide_toolbar), pad); |
| 1496 | g_signal_connect_swapped (xpad_settings (), "notify::has-scrollbar", G_CALLBACK (xpad_pad_notify_has_scrollbar), pad); |
| 1497 | 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); |
| 1498 | - g_signal_connect_swapped (clipboard, "owner-change", G_CALLBACK (xpad_pad_notify_clipboard_owner_changed), pad); |
| 1499 | + g_signal_connect_swapped (pad->priv->clipboard, "owner-change", G_CALLBACK (xpad_pad_notify_clipboard_owner_changed), pad); |
| 1500 | |
| 1501 | g_signal_connect_swapped (pad->priv->toolbar, "activate-new", G_CALLBACK (xpad_pad_spawn), pad); |
| 1502 | g_signal_connect_swapped (pad->priv->toolbar, "activate-clear", G_CALLBACK (xpad_pad_clear), pad); |
| 1503 | @@ -352,18 +362,6 @@ |
| 1504 | |
| 1505 | g_signal_connect (pad->priv->menu, "deactivate", G_CALLBACK (xpad_pad_popup_deactivate), pad); |
| 1506 | g_signal_connect (pad->priv->highlight_menu, "deactivate", G_CALLBACK (xpad_pad_popup_deactivate), pad); |
| 1507 | - |
| 1508 | - if (pad->priv->sticky) |
| 1509 | - gtk_window_stick (GTK_WINDOW (pad)); |
| 1510 | - else |
| 1511 | - gtk_window_unstick (GTK_WINDOW (pad)); |
| 1512 | - |
| 1513 | - xpad_pad_sync_title (pad); |
| 1514 | - |
| 1515 | - gtk_widget_show_all (vbox); |
| 1516 | - |
| 1517 | - gtk_widget_hide (pad->priv->toolbar); |
| 1518 | - xpad_pad_notify_has_toolbar (pad); |
| 1519 | } |
| 1520 | |
| 1521 | static void |
| 1522 | @@ -389,18 +387,31 @@ |
| 1523 | xpad_pad_dispose (GObject *object) |
| 1524 | { |
| 1525 | XpadPad *pad = XPAD_PAD (object); |
| 1526 | - |
| 1527 | - if (pad->priv->toolbar_timeout) |
| 1528 | - { |
| 1529 | - g_source_remove (pad->priv->toolbar_timeout); |
| 1530 | - pad->priv->toolbar_timeout = 0; |
| 1531 | - } |
| 1532 | - |
| 1533 | - if (pad->priv->properties) |
| 1534 | - gtk_widget_destroy (pad->priv->properties); |
| 1535 | - |
| 1536 | - gtk_widget_destroy (pad->priv->menu); |
| 1537 | - gtk_widget_destroy (pad->priv->highlight_menu); |
| 1538 | + |
| 1539 | + if (pad->priv->group) { |
| 1540 | + g_object_unref(pad->priv->group); |
| 1541 | + pad->priv->group = NULL; |
| 1542 | + } |
| 1543 | + |
| 1544 | + if (GTK_IS_WIDGET(pad->priv->menu)) { |
| 1545 | + gtk_widget_destroy (pad->priv->menu); |
| 1546 | + pad->priv->menu = NULL; |
| 1547 | + } |
| 1548 | + |
| 1549 | + if (GTK_IS_WIDGET(pad->priv->highlight_menu)) { |
| 1550 | + gtk_widget_destroy (pad->priv->highlight_menu); |
| 1551 | + pad->priv->highlight_menu = NULL; |
| 1552 | + } |
| 1553 | + |
| 1554 | + if (GTK_IS_CLIPBOARD(pad->priv->clipboard)) { |
| 1555 | + // 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. |
| 1556 | + g_signal_handlers_disconnect_matched (pad->priv->clipboard, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, pad); |
| 1557 | + } |
| 1558 | + |
| 1559 | + if (GTK_IS_TOOLBAR(pad->priv->toolbar)) { |
| 1560 | + // 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. |
| 1561 | + g_signal_handlers_disconnect_matched (pad->priv->toolbar, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, pad); |
| 1562 | + } |
| 1563 | |
| 1564 | G_OBJECT_CLASS (xpad_pad_parent_class)->dispose (object); |
| 1565 | } |
| 1566 | @@ -409,12 +420,12 @@ |
| 1567 | xpad_pad_finalize (GObject *object) |
| 1568 | { |
| 1569 | XpadPad *pad = XPAD_PAD (object); |
| 1570 | - |
| 1571 | + |
| 1572 | + g_signal_handlers_disconnect_matched (xpad_settings (), G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, pad); |
| 1573 | + |
| 1574 | g_free (pad->priv->infoname); |
| 1575 | g_free (pad->priv->contentname); |
| 1576 | |
| 1577 | - g_signal_handlers_disconnect_matched (xpad_settings (), G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, pad); |
| 1578 | - |
| 1579 | G_OBJECT_CLASS (xpad_pad_parent_class)->finalize (object); |
| 1580 | } |
| 1581 | |
| 1582 | @@ -458,11 +469,11 @@ |
| 1583 | /* reshow_with_initial_size() seems to set the window back to a never-shown state. |
| 1584 | This is good, as some WMs don't like us changing the above parameters mid-run, |
| 1585 | even if we do a hide/show cycle. */ |
| 1586 | - gtk_window_set_default_size (GTK_WINDOW (pad), pad->priv->width, pad->priv->height); |
| 1587 | + gtk_window_set_default_size (GTK_WINDOW (pad), (gint) pad->priv->width, (gint) pad->priv->height); |
| 1588 | gtk_window_reshow_with_initial_size (GTK_WINDOW (pad)); |
| 1589 | } |
| 1590 | |
| 1591 | -static gint |
| 1592 | +static guint |
| 1593 | xpad_pad_text_and_toolbar_height (XpadPad *pad) |
| 1594 | { |
| 1595 | GdkRectangle rec; |
| 1596 | @@ -477,7 +488,14 @@ |
| 1597 | &textx, &texty); |
| 1598 | gtk_widget_translate_coordinates(pad->priv->textview, GTK_WIDGET(pad), textx, texty, &x, &y); |
| 1599 | |
| 1600 | - return y + pad->priv->toolbar_height + gtk_container_get_border_width(GTK_CONTAINER(pad->priv->textview)); |
| 1601 | + // Safe cast from gint to guint |
| 1602 | + if (y >= 0) { |
| 1603 | + return (guint) y + pad->priv->toolbar_height + gtk_container_get_border_width(GTK_CONTAINER(pad->priv->textview)); |
| 1604 | + } |
| 1605 | + else { |
| 1606 | + g_warning("There is a problem in the program Xpad. In function 'xpad_pad_toolbar_size_allocate' the variable 'event->height' is not a postive number. Please send a bugreport to https://bugs.launchpad.net/xpad/+filebug to help improve Xpad."); |
| 1607 | + return 0; |
| 1608 | + } |
| 1609 | } |
| 1610 | |
| 1611 | static void |
| 1612 | @@ -493,7 +511,14 @@ |
| 1613 | if (!pad->priv->toolbar_height) |
| 1614 | { |
| 1615 | gtk_widget_size_request (pad->priv->toolbar, &req); |
| 1616 | - pad->priv->toolbar_height = req.height; |
| 1617 | + // safe cast from gint to guint |
| 1618 | + if (req.height >= 0) { |
| 1619 | + pad->priv->toolbar_height = (guint) req.height; |
| 1620 | + } |
| 1621 | + else { |
| 1622 | + 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."); |
| 1623 | + pad->priv->toolbar_height = 0; |
| 1624 | + } |
| 1625 | } |
| 1626 | |
| 1627 | /* Do we have room for the toolbar without covering text? */ |
| 1628 | @@ -501,7 +526,7 @@ |
| 1629 | { |
| 1630 | pad->priv->toolbar_expanded = TRUE; |
| 1631 | pad->priv->height += pad->priv->toolbar_height; |
| 1632 | - gtk_window_resize (GTK_WINDOW (pad), pad->priv->width, pad->priv->height); |
| 1633 | + gtk_window_resize (GTK_WINDOW (pad), (gint) pad->priv->width, (gint) pad->priv->height); |
| 1634 | } |
| 1635 | else |
| 1636 | pad->priv->toolbar_expanded = FALSE; |
| 1637 | @@ -526,7 +551,7 @@ |
| 1638 | (pad->priv->toolbar_pad_resized && xpad_pad_text_and_toolbar_height (pad) >= pad->priv->height)) |
| 1639 | { |
| 1640 | pad->priv->height -= pad->priv->toolbar_height; |
| 1641 | - gtk_window_resize (GTK_WINDOW (pad), pad->priv->width, pad->priv->height); |
| 1642 | + gtk_window_resize (GTK_WINDOW (pad), (gint) pad->priv->width, (gint) pad->priv->height); |
| 1643 | pad->priv->toolbar_expanded = FALSE; |
| 1644 | } |
| 1645 | if (GTK_WIDGET (pad)->window) |
| 1646 | @@ -549,6 +574,9 @@ |
| 1647 | static gboolean |
| 1648 | toolbar_timeout (XpadPad *pad) |
| 1649 | { |
| 1650 | + if (pad || !pad->priv || !pad->priv->toolbar_timeout) |
| 1651 | + return FALSE; |
| 1652 | + |
| 1653 | if (pad->priv->toolbar_timeout && |
| 1654 | xpad_settings_get_autohide_toolbar (xpad_settings ()) && |
| 1655 | xpad_settings_get_has_toolbar (xpad_settings ())) |
| 1656 | @@ -597,11 +625,17 @@ |
| 1657 | g_return_if_fail (pad); |
| 1658 | |
| 1659 | XpadToolbar *toolbar = NULL; |
| 1660 | - toolbar = XPAD_TOOLBAR (pad->priv->toolbar); |
| 1661 | - g_return_if_fail (toolbar); |
| 1662 | + // safe cast to toolbar |
| 1663 | + if (XPAD_IS_TOOLBAR(pad->priv->toolbar)) { |
| 1664 | + toolbar = XPAD_TOOLBAR (pad->priv->toolbar); |
| 1665 | + g_return_if_fail (toolbar); |
| 1666 | |
| 1667 | - GtkClipboard *clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD); |
| 1668 | - xpad_toolbar_enable_paste_button (toolbar, gtk_clipboard_wait_is_text_available (clipboard)); |
| 1669 | + GtkClipboard *clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD); |
| 1670 | + xpad_toolbar_enable_paste_button (toolbar, gtk_clipboard_wait_is_text_available (clipboard)); |
| 1671 | + } |
| 1672 | + else { |
| 1673 | + g_warning("There is a problem in the program Xpad. In function 'xpad_pad_notify_clipboard_owner_changed' the variable 'pad->priv->toolbar' is not of type toolbar. Please send a bugreport to https://bugs.launchpad.net/xpad/+filebug to help improve Xpad."); |
| 1674 | + } |
| 1675 | } |
| 1676 | |
| 1677 | void |
| 1678 | @@ -722,6 +756,12 @@ |
| 1679 | static void |
| 1680 | xpad_pad_delete (XpadPad *pad) |
| 1681 | { |
| 1682 | + g_return_if_fail (pad); |
| 1683 | + |
| 1684 | + // With the delayed saving functionality, it is necessary to clear the unsaved flags to prevent usage of non-existing object information. |
| 1685 | + pad->priv->unsaved_info = FALSE; |
| 1686 | + pad->priv->unsaved_content = FALSE; |
| 1687 | + |
| 1688 | if (should_confirm_delete (pad)) |
| 1689 | { |
| 1690 | GtkWidget *dialog; |
| 1691 | @@ -744,11 +784,13 @@ |
| 1692 | return; |
| 1693 | } |
| 1694 | |
| 1695 | + // These two if statements actually erase the pad on the harddisk. |
| 1696 | if (pad->priv->infoname) |
| 1697 | fio_remove_file (pad->priv->infoname); |
| 1698 | if (pad->priv->contentname) |
| 1699 | fio_remove_file (pad->priv->contentname); |
| 1700 | |
| 1701 | + // Remove the pad from the group and destroy it. |
| 1702 | gtk_widget_destroy (GTK_WIDGET (pad)); |
| 1703 | } |
| 1704 | |
| 1705 | @@ -915,7 +957,14 @@ |
| 1706 | static gboolean |
| 1707 | xpad_pad_toolbar_size_allocate (XpadPad *pad, GtkAllocation *event) |
| 1708 | { |
| 1709 | - pad->priv->toolbar_height = event->height; |
| 1710 | + // safe cast from gint to guint |
| 1711 | + if (event->height >= 0) { |
| 1712 | + pad->priv->toolbar_height = (guint) event->height; |
| 1713 | + } |
| 1714 | + else { |
| 1715 | + g_warning("There is a problem in the program Xpad. In function 'xpad_pad_toolbar_size_allocate' the variable 'event->height' is not a postive number. Please send a bugreport to https://bugs.launchpad.net/xpad/+filebug to help improve Xpad."); |
| 1716 | + pad->priv->toolbar_height = 0; |
| 1717 | + } |
| 1718 | return FALSE; |
| 1719 | } |
| 1720 | |
| 1721 | @@ -924,17 +973,27 @@ |
| 1722 | { |
| 1723 | if (!GTK_WIDGET_VISIBLE (pad)) |
| 1724 | return FALSE; |
| 1725 | + |
| 1726 | + int eWidth = event->width; |
| 1727 | + int eHeight = event->height; |
| 1728 | |
| 1729 | - if (pad->priv->width != event->width || pad->priv->height != event->height) |
| 1730 | - pad->priv->toolbar_pad_resized = TRUE; |
| 1731 | + // safe cast from gint to guint |
| 1732 | + if (eWidth >= 0 && eHeight >=0 ) { |
| 1733 | + if (pad->priv->width != (guint) eWidth || pad->priv->height != (guint) eHeight) |
| 1734 | + pad->priv->toolbar_pad_resized = TRUE; |
| 1735 | + |
| 1736 | + pad->priv->width = (guint) event->width; |
| 1737 | + pad->priv->height = (guint) event->height; |
| 1738 | + } |
| 1739 | + else { |
| 1740 | + g_warning("There is a problem in the program Xpad. In function 'xpad_pad_configure_event' the variable 'event->width' or 'event->height' is not a postive number. Please send a bugreport to https://bugs.launchpad.net/xpad/+filebug to help improve Xpad."); |
| 1741 | + } |
| 1742 | |
| 1743 | pad->priv->x = event->x; |
| 1744 | pad->priv->y = event->y; |
| 1745 | - pad->priv->width = event->width; |
| 1746 | - pad->priv->height = event->height; |
| 1747 | pad->priv->location_valid = TRUE; |
| 1748 | |
| 1749 | - xpad_pad_save_content_delayed(pad); |
| 1750 | + xpad_pad_save_info_delayed(pad); |
| 1751 | |
| 1752 | /* Sometimes when moving, if the toolbar tries to hide itself, |
| 1753 | the window manager will not resize it correctly. So, we make |
| 1754 | @@ -974,7 +1033,7 @@ |
| 1755 | case 1: |
| 1756 | if ((event->state & gtk_accelerator_get_default_mod_mask ()) == GDK_CONTROL_MASK) |
| 1757 | { |
| 1758 | - gtk_window_begin_move_drag (GTK_WINDOW (pad), event->button, event->x_root, event->y_root, event->time); |
| 1759 | + gtk_window_begin_move_drag (GTK_WINDOW (pad), (gint) event->button, (gint) event->x_root, (gint) event->y_root, event->time); |
| 1760 | return TRUE; |
| 1761 | } |
| 1762 | break; |
| 1763 | @@ -989,7 +1048,7 @@ |
| 1764 | else |
| 1765 | edge = GDK_WINDOW_EDGE_SOUTH_WEST; |
| 1766 | |
| 1767 | - gtk_window_begin_resize_drag (GTK_WINDOW (pad), edge, event->button, event->x_root, event->y_root, event->time); |
| 1768 | + gtk_window_begin_resize_drag (GTK_WINDOW (pad), edge, (gint) event->button, (gint) event->x_root, (gint) event->y_root, event->time); |
| 1769 | } |
| 1770 | else |
| 1771 | { |
| 1772 | @@ -1010,7 +1069,7 @@ |
| 1773 | switch (event->button) |
| 1774 | { |
| 1775 | case 1: |
| 1776 | - gtk_window_begin_move_drag (GTK_WINDOW (pad), event->button, event->x_root, event->y_root, event->time); |
| 1777 | + gtk_window_begin_move_drag (GTK_WINDOW (pad), (gint) event->button, (gint) event->x_root, (gint) event->y_root, event->time); |
| 1778 | return TRUE; |
| 1779 | |
| 1780 | case 3: |
| 1781 | @@ -1023,7 +1082,7 @@ |
| 1782 | else |
| 1783 | edge = GDK_WINDOW_EDGE_SOUTH_WEST; |
| 1784 | |
| 1785 | - gtk_window_begin_resize_drag (GTK_WINDOW (pad), edge, event->button, event->x_root, event->y_root, event->time); |
| 1786 | + gtk_window_begin_resize_drag (GTK_WINDOW (pad), edge, (gint) event->button, (gint) event->x_root, (gint) event->y_root, event->time); |
| 1787 | } |
| 1788 | else |
| 1789 | { |
| 1790 | @@ -1059,6 +1118,8 @@ |
| 1791 | xpad_pad_set_group (XpadPad *pad, XpadPadGroup *group) |
| 1792 | { |
| 1793 | pad->priv->group = group; |
| 1794 | + g_object_ref(pad->priv->group); |
| 1795 | + |
| 1796 | if (group) |
| 1797 | xpad_pad_group_add (group, GTK_WIDGET (pad)); |
| 1798 | } |
| 1799 | @@ -1143,6 +1204,9 @@ |
| 1800 | gchar *content; |
| 1801 | GtkTextBuffer *buffer; |
| 1802 | |
| 1803 | + if (!pad->priv->unsaved_content) |
| 1804 | + return; |
| 1805 | + |
| 1806 | /* create content file if it doesn't exist yet */ |
| 1807 | if (!pad->priv->contentname) |
| 1808 | { |
| 1809 | @@ -1150,9 +1214,13 @@ |
| 1810 | if (!pad->priv->contentname) |
| 1811 | return; |
| 1812 | } |
| 1813 | - |
| 1814 | - buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (pad->priv->textview)); |
| 1815 | - content = xpad_text_buffer_get_text_with_tags (XPAD_TEXT_BUFFER (buffer)); |
| 1816 | + |
| 1817 | + if (GTK_IS_TEXT_VIEW(pad->priv->textview)) { |
| 1818 | + buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (pad->priv->textview)); |
| 1819 | + content = xpad_text_buffer_get_text_with_tags (XPAD_TEXT_BUFFER (buffer)); |
| 1820 | + } |
| 1821 | + else |
| 1822 | + g_warning("There is a problem in the program Xpad. In function 'xpad_pad_save_content' the variable 'pad->priv->textview' is not of type textview. Please send a bugreport to https://bugs.launchpad.net/xpad/+filebug to help improve Xpad."); |
| 1823 | |
| 1824 | fio_set_file (pad->priv->contentname, content); |
| 1825 | |
| 1826 | @@ -1204,7 +1272,7 @@ |
| 1827 | xpad_pad_show_toolbar (pad); /* these will resize pad at correct height */ |
| 1828 | } |
| 1829 | else |
| 1830 | - gtk_window_resize (GTK_WINDOW (pad), pad->priv->width, pad->priv->height); |
| 1831 | + gtk_window_resize (GTK_WINDOW (pad), (gint) pad->priv->width, (gint) pad->priv->height); |
| 1832 | gtk_window_move (GTK_WINDOW (pad), pad->priv->x, pad->priv->y); |
| 1833 | |
| 1834 | xpad_text_view_set_follow_font_style (XPAD_TEXT_VIEW (pad->priv->textview), follow_font); |
| 1835 | @@ -1268,14 +1336,21 @@ |
| 1836 | |
| 1837 | if (show) |
| 1838 | *show = !hidden; |
| 1839 | + |
| 1840 | + g_free(fontname); |
| 1841 | } |
| 1842 | |
| 1843 | void |
| 1844 | xpad_pad_save_info (XpadPad *pad) |
| 1845 | { |
| 1846 | - gint height; |
| 1847 | - GtkStyle *style; |
| 1848 | - gchar *fontname; |
| 1849 | + guint height = NULL; |
| 1850 | + GtkStyle *style = NULL; |
| 1851 | + gchar *fontname = NULL; |
| 1852 | + |
| 1853 | + g_return_if_fail (pad); |
| 1854 | + |
| 1855 | + if (!pad->priv->unsaved_info) |
| 1856 | + return; |
| 1857 | |
| 1858 | /* Must create pad info file if it doesn't exist yet */ |
| 1859 | if (!pad->priv->infoname) |
| 1860 | @@ -1327,7 +1402,7 @@ |
| 1861 | menu_about (XpadPad *pad) |
| 1862 | { |
| 1863 | const gchar *artists[] = {"Michael Terry <mike@mterry.name>", NULL}; |
| 1864 | - const gchar *authors[] = {"Arthur Borsboom <arthurborsboom@gmail.com", "Jeroen Vermeulen <jtv@xs4all.nl>", "Michael Terry <mike@mterry.name>", "Paul Ivanov <pivanov@berkeley.edu>", NULL}; |
| 1865 | + const gchar *authors[] = {"Arthur Borsboom <arthurborsboom@gmail.com>", "Jeroen Vermeulen <jtv@xs4all.nl>", "Michael Terry <mike@mterry.name>", "Paul Ivanov <pivanov@berkeley.edu>", NULL}; |
| 1866 | const gchar *comments = _("Sticky notes"); |
| 1867 | const gchar *copyright = "© 2001-2007 Michael Terry"; |
| 1868 | /* we use g_strdup_printf because C89 has size limits on static strings */ |
| 1869 | @@ -1460,6 +1535,9 @@ |
| 1870 | gtk_window_present (GTK_WINDOW (pad)); |
| 1871 | |
| 1872 | g_slist_free (pads); |
| 1873 | + g_slist_free (i); |
| 1874 | + pads = NULL; |
| 1875 | + i = NULL; |
| 1876 | } |
| 1877 | |
| 1878 | static void |
| 1879 | @@ -1530,7 +1608,7 @@ |
| 1880 | gtk_window_stick (GTK_WINDOW (pad)); |
| 1881 | else |
| 1882 | gtk_window_unstick (GTK_WINDOW (pad)); |
| 1883 | - xpad_pad_save_info (pad); |
| 1884 | + xpad_pad_save_info_delayed (pad); |
| 1885 | } |
| 1886 | |
| 1887 | static void |
| 1888 | @@ -1781,6 +1859,9 @@ |
| 1889 | g_free (key); |
| 1890 | } |
| 1891 | g_slist_free (pads); |
| 1892 | + g_slist_free (l); |
| 1893 | + pads = NULL; |
| 1894 | + l = NULL; |
| 1895 | } |
| 1896 | } |
| 1897 | |
| 1898 | @@ -1893,10 +1974,6 @@ |
| 1899 | } |
| 1900 | |
| 1901 | /* These functions below are used to reduce the amounts of writes, hence improve the performance. */ |
| 1902 | -void xpad2_save_content (void * vptr) |
| 1903 | -{ |
| 1904 | - xpad_pad_save_content(vptr); |
| 1905 | -} |
| 1906 | void xpad_pad_save_content_delayed (XpadPad *pad) |
| 1907 | { |
| 1908 | pad->priv->unsaved_content = TRUE; |
| 1909 | @@ -1913,6 +1990,6 @@ |
| 1910 | xpad_pad_save_content(pad); |
| 1911 | } |
| 1912 | if(pad->priv->unsaved_info == TRUE) { |
| 1913 | - xpad_pad_save_info(pad); |
| 1914 | + xpad_pad_save_info(pad); |
| 1915 | } |
| 1916 | } |
| 1917 | |
| 1918 | === modified file 'src/xpad-preferences.c' |
| 1919 | --- src/xpad-preferences.c 2008-09-21 00:03:40 +0000 |
| 1920 | +++ src/xpad-preferences.c 2013-10-18 18:35:35 +0000 |
| 1921 | @@ -25,9 +25,6 @@ |
| 1922 | #include "xpad-preferences.h" |
| 1923 | #include "xpad-settings.h" |
| 1924 | |
| 1925 | -G_DEFINE_TYPE(XpadPreferences, xpad_preferences, GTK_TYPE_DIALOG) |
| 1926 | -#define XPAD_PREFERENCES_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), XPAD_TYPE_PREFERENCES, XpadPreferencesPrivate)) |
| 1927 | - |
| 1928 | struct XpadPreferencesPrivate |
| 1929 | { |
| 1930 | GtkWidget *fontcheck; |
| 1931 | @@ -60,6 +57,8 @@ |
| 1932 | guint confirmcheck_handler; |
| 1933 | }; |
| 1934 | |
| 1935 | +G_DEFINE_TYPE_WITH_PRIVATE(XpadPreferences, xpad_preferences, GTK_TYPE_DIALOG) |
| 1936 | + |
| 1937 | static void change_edit_check (GtkToggleButton *button, XpadPreferences *pref); |
| 1938 | static void change_sticky_check (GtkToggleButton *button, XpadPreferences *pref); |
| 1939 | static void change_confirm_check (GtkToggleButton *button, XpadPreferences *pref); |
| 1940 | @@ -74,6 +73,7 @@ |
| 1941 | static void notify_fontname (XpadPreferences *pref); |
| 1942 | static void notify_text_color (XpadPreferences *pref); |
| 1943 | static void notify_back_color (XpadPreferences *pref); |
| 1944 | +static void xpad_preferences_dispose (GObject *object); |
| 1945 | static void xpad_preferences_finalize (GObject *object); |
| 1946 | static void xpad_preferences_response (GtkDialog *dialog, gint response); |
| 1947 | |
| 1948 | @@ -98,10 +98,9 @@ |
| 1949 | xpad_preferences_class_init (XpadPreferencesClass *klass) |
| 1950 | { |
| 1951 | GObjectClass *gobject_class = G_OBJECT_CLASS (klass); |
| 1952 | - |
| 1953 | + |
| 1954 | + gobject_class->dispose = xpad_preferences_dispose; |
| 1955 | gobject_class->finalize = xpad_preferences_finalize; |
| 1956 | - |
| 1957 | - g_type_class_add_private (gobject_class, sizeof (XpadPreferencesPrivate)); |
| 1958 | } |
| 1959 | |
| 1960 | static void |
| 1961 | @@ -117,7 +116,7 @@ |
| 1962 | GtkSizeGroup *size_group_labels = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); |
| 1963 | GtkRequisition req; |
| 1964 | |
| 1965 | - pref->priv = XPAD_PREFERENCES_GET_PRIVATE (pref); |
| 1966 | + pref->priv = xpad_preferences_get_instance_private(pref); |
| 1967 | |
| 1968 | text = g_strconcat ("<b>", _("Appearance"), "</b>", NULL); |
| 1969 | label = GTK_WIDGET (g_object_new (GTK_TYPE_LABEL, |
| 1970 | @@ -312,12 +311,16 @@ |
| 1971 | } |
| 1972 | |
| 1973 | static void |
| 1974 | +xpad_preferences_dispose (GObject *object) |
| 1975 | +{ |
| 1976 | + G_OBJECT_CLASS (xpad_preferences_parent_class)->dispose (object); |
| 1977 | +} |
| 1978 | + |
| 1979 | +static void |
| 1980 | xpad_preferences_finalize (GObject *object) |
| 1981 | { |
| 1982 | XpadPreferences *pref = XPAD_PREFERENCES (object); |
| 1983 | |
| 1984 | - g_signal_handlers_disconnect_matched (xpad_settings (), G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, pref); |
| 1985 | - |
| 1986 | G_OBJECT_CLASS (xpad_preferences_parent_class)->finalize (object); |
| 1987 | } |
| 1988 | |
| 1989 | |
| 1990 | === modified file 'src/xpad-settings.c' |
| 1991 | --- src/xpad-settings.c 2013-10-07 20:07:46 +0000 |
| 1992 | +++ src/xpad-settings.c 2013-10-18 18:35:35 +0000 |
| 1993 | @@ -22,11 +22,6 @@ |
| 1994 | #include "xpad-settings.h" |
| 1995 | #include "fio.h" |
| 1996 | |
| 1997 | -G_DEFINE_TYPE(XpadSettings, xpad_settings, G_TYPE_OBJECT) |
| 1998 | -#define XPAD_SETTINGS_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), XPAD_TYPE_SETTINGS, XpadSettingsPrivate)) |
| 1999 | - |
| 2000 | -#define DEFAULTS_FILENAME "default-style" |
| 2001 | - |
| 2002 | struct XpadSettingsPrivate |
| 2003 | { |
| 2004 | guint width; |
| 2005 | @@ -44,6 +39,10 @@ |
| 2006 | GSList *toolbar_buttons; |
| 2007 | }; |
| 2008 | |
| 2009 | +G_DEFINE_TYPE_WITH_PRIVATE(XpadSettings, xpad_settings, G_TYPE_OBJECT) |
| 2010 | + |
| 2011 | +#define DEFAULTS_FILENAME "default-style" |
| 2012 | + |
| 2013 | enum |
| 2014 | { |
| 2015 | CHANGE_BUTTONS, |
| 2016 | @@ -72,6 +71,7 @@ |
| 2017 | static void save_to_file (XpadSettings *settings, const gchar *filename); |
| 2018 | static void xpad_settings_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); |
| 2019 | static void xpad_settings_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); |
| 2020 | +static void xpad_settings_dispose (GObject *object); |
| 2021 | static void xpad_settings_finalize (GObject *object); |
| 2022 | |
| 2023 | static XpadSettings *_xpad_settings = NULL; |
| 2024 | @@ -91,7 +91,8 @@ |
| 2025 | xpad_settings_class_init (XpadSettingsClass *klass) |
| 2026 | { |
| 2027 | GObjectClass *gobject_class = G_OBJECT_CLASS (klass); |
| 2028 | - |
| 2029 | + |
| 2030 | + gobject_class->dispose = xpad_settings_dispose; |
| 2031 | gobject_class->finalize = xpad_settings_finalize; |
| 2032 | gobject_class->set_property = xpad_settings_set_property; |
| 2033 | gobject_class->get_property = xpad_settings_get_property; |
| 2034 | @@ -207,8 +208,6 @@ |
| 2035 | G_STRUCT_OFFSET (XpadSettingsClass, change_buttons), |
| 2036 | NULL, NULL, |
| 2037 | g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); |
| 2038 | - |
| 2039 | - g_type_class_add_private (gobject_class, sizeof (XpadSettingsPrivate)); |
| 2040 | } |
| 2041 | |
| 2042 | static void |
| 2043 | @@ -216,7 +215,7 @@ |
| 2044 | { |
| 2045 | GdkColor back, text; |
| 2046 | |
| 2047 | - settings->priv = XPAD_SETTINGS_GET_PRIVATE (settings); |
| 2048 | + settings->priv = xpad_settings_get_instance_private(settings); |
| 2049 | |
| 2050 | /* A pleasant light yellow color, similar to |
| 2051 | commercial sticky notes. */ |
| 2052 | @@ -253,13 +252,23 @@ |
| 2053 | } |
| 2054 | |
| 2055 | static void |
| 2056 | +xpad_settings_dispose (GObject *object) |
| 2057 | +{ |
| 2058 | + G_OBJECT_CLASS (xpad_settings_parent_class)->dispose (object); |
| 2059 | +} |
| 2060 | + |
| 2061 | +static void |
| 2062 | xpad_settings_finalize (GObject *object) |
| 2063 | { |
| 2064 | XpadSettings *settings = XPAD_SETTINGS (object); |
| 2065 | |
| 2066 | g_slist_free (settings->priv->toolbar_buttons); |
| 2067 | - gdk_color_free (settings->priv->text); |
| 2068 | - gdk_color_free (settings->priv->back); |
| 2069 | + |
| 2070 | + if (settings->priv->text) |
| 2071 | + gdk_color_free (settings->priv->text); |
| 2072 | + if (settings->priv->back) |
| 2073 | + gdk_color_free (settings->priv->back); |
| 2074 | + |
| 2075 | g_free (settings->priv->fontname); |
| 2076 | |
| 2077 | G_OBJECT_CLASS (xpad_settings_parent_class)->finalize (object); |
| 2078 | @@ -427,20 +436,27 @@ |
| 2079 | g_signal_emit (settings, signals[CHANGE_BUTTONS], 0); |
| 2080 | } |
| 2081 | |
| 2082 | +/* Unused function of previous developer |
| 2083 | gboolean xpad_settings_move_toolbar_button (XpadSettings *settings, gint button, gint new) |
| 2084 | { |
| 2085 | - GSList *element; |
| 2086 | + GSList *element = NULL; |
| 2087 | gpointer data; |
| 2088 | |
| 2089 | - if (button == new) |
| 2090 | + if (button == new) { |
| 2091 | + g_slist_free(element); |
| 2092 | return FALSE; |
| 2093 | + } |
| 2094 | |
| 2095 | - if (new >= g_slist_length (settings->priv->toolbar_buttons) || 0 > new ) |
| 2096 | + if (new >= (gint) g_slist_length (settings->priv->toolbar_buttons) || 0 > new ) { |
| 2097 | + g_slist_free(element); |
| 2098 | return FALSE; |
| 2099 | + } |
| 2100 | |
| 2101 | element = g_slist_nth (settings->priv->toolbar_buttons, button); |
| 2102 | - if (!element) |
| 2103 | + if (!element) { |
| 2104 | + g_slist_free(element); |
| 2105 | return FALSE; |
| 2106 | + } |
| 2107 | |
| 2108 | data = element->data; |
| 2109 | settings->priv->toolbar_buttons = g_slist_delete_link (settings->priv->toolbar_buttons, element); |
| 2110 | @@ -450,8 +466,11 @@ |
| 2111 | |
| 2112 | g_signal_emit (settings, signals[CHANGE_BUTTONS], 0); |
| 2113 | |
| 2114 | + g_slist_free(element); |
| 2115 | + |
| 2116 | return TRUE; |
| 2117 | } |
| 2118 | +*/ |
| 2119 | |
| 2120 | static void xpad_settings_remove_toolbar_list_element (XpadSettings *settings, GSList *element) |
| 2121 | { |
| 2122 | @@ -459,14 +478,17 @@ |
| 2123 | settings->priv->toolbar_buttons = g_slist_delete_link (settings->priv->toolbar_buttons, element); |
| 2124 | } |
| 2125 | |
| 2126 | +/* Unused function of previous developer |
| 2127 | gboolean xpad_settings_remove_toolbar_button (XpadSettings *settings, gint button) |
| 2128 | { |
| 2129 | GSList *element; |
| 2130 | |
| 2131 | element = g_slist_nth (settings->priv->toolbar_buttons, button); |
| 2132 | |
| 2133 | - if (!element) |
| 2134 | + if (!element) { |
| 2135 | + g_slist_free(element); |
| 2136 | return FALSE; |
| 2137 | + } |
| 2138 | |
| 2139 | xpad_settings_remove_toolbar_list_element (settings, element); |
| 2140 | |
| 2141 | @@ -474,8 +496,11 @@ |
| 2142 | |
| 2143 | g_signal_emit (settings, signals[CHANGE_BUTTONS], 0); |
| 2144 | |
| 2145 | + g_slist_free(element); |
| 2146 | + |
| 2147 | return TRUE; |
| 2148 | } |
| 2149 | +*/ |
| 2150 | |
| 2151 | gboolean xpad_settings_remove_all_toolbar_buttons (XpadSettings *settings) |
| 2152 | { |
| 2153 | @@ -503,8 +528,10 @@ |
| 2154 | |
| 2155 | element = g_slist_last (settings->priv->toolbar_buttons); |
| 2156 | |
| 2157 | - if (!element) |
| 2158 | + if (!element) { |
| 2159 | + g_slist_free(element); |
| 2160 | return FALSE; |
| 2161 | + } |
| 2162 | |
| 2163 | xpad_settings_remove_toolbar_list_element (settings, element); |
| 2164 | |
| 2165 | @@ -512,6 +539,8 @@ |
| 2166 | |
| 2167 | g_signal_emit (settings, signals[CHANGE_BUTTONS], 0); |
| 2168 | |
| 2169 | + g_slist_free(element); |
| 2170 | + |
| 2171 | return TRUE; |
| 2172 | } |
| 2173 | |
| 2174 | |
| 2175 | === modified file 'src/xpad-settings.h' |
| 2176 | --- src/xpad-settings.h 2011-11-16 20:16:17 +0000 |
| 2177 | +++ src/xpad-settings.h 2013-10-18 18:35:35 +0000 |
| 2178 | @@ -82,8 +82,8 @@ |
| 2179 | gboolean xpad_settings_get_has_scrollbar (XpadSettings *settings); |
| 2180 | |
| 2181 | void xpad_settings_add_toolbar_button (XpadSettings *settings, const gchar *button); |
| 2182 | -gboolean xpad_settings_move_toolbar_button (XpadSettings *settings, gint button, gint new); |
| 2183 | -gboolean xpad_settings_remove_toolbar_button (XpadSettings *settings, gint button); |
| 2184 | +// gboolean xpad_settings_move_toolbar_button (XpadSettings *settings, gint button, gint new); |
| 2185 | +// gboolean xpad_settings_remove_toolbar_button (XpadSettings *settings, gint button); |
| 2186 | gboolean xpad_settings_remove_all_toolbar_buttons (XpadSettings *settings); |
| 2187 | gboolean xpad_settings_remove_last_toolbar_button (XpadSettings *settings); |
| 2188 | G_CONST_RETURN GSList *xpad_settings_get_toolbar_buttons (XpadSettings *settings); |
| 2189 | |
| 2190 | === modified file 'src/xpad-text-buffer.c' |
| 2191 | --- src/xpad-text-buffer.c 2011-11-16 18:10:04 +0000 |
| 2192 | +++ src/xpad-text-buffer.c 2013-10-18 18:35:35 +0000 |
| 2193 | @@ -21,22 +21,20 @@ |
| 2194 | #include "xpad-undo.h" |
| 2195 | #include "xpad-pad.h" |
| 2196 | |
| 2197 | -G_DEFINE_TYPE(XpadTextBuffer, xpad_text_buffer, GTK_TYPE_TEXT_BUFFER) |
| 2198 | -#define XPAD_TEXT_BUFFER_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), XPAD_TYPE_TEXT_BUFFER, XpadTextBufferPrivate)) |
| 2199 | - |
| 2200 | struct XpadTextBufferPrivate |
| 2201 | { |
| 2202 | XpadUndo *undo; |
| 2203 | XpadPad *pad; |
| 2204 | + GtkTextTagTable *tag_table; |
| 2205 | }; |
| 2206 | |
| 2207 | +G_DEFINE_TYPE_WITH_PRIVATE(XpadTextBuffer, xpad_text_buffer, GTK_TYPE_TEXT_BUFFER) |
| 2208 | + |
| 2209 | /* Unicode chars in the Private Use Area. */ |
| 2210 | static gunichar TAG_CHAR = 0xe000; |
| 2211 | |
| 2212 | static GtkTextTagTable *create_tag_table (void); |
| 2213 | |
| 2214 | -static GtkTextTagTable *global_text_tag_table = NULL; |
| 2215 | - |
| 2216 | enum |
| 2217 | { |
| 2218 | PROP_0, |
| 2219 | @@ -44,81 +42,24 @@ |
| 2220 | LAST_PROP |
| 2221 | }; |
| 2222 | |
| 2223 | +static void xpad_text_buffer_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); |
| 2224 | +static void xpad_text_buffer_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); |
| 2225 | +static void xpad_text_buffer_dispose (GObject *object); |
| 2226 | +static void xpad_text_buffer_finalize (GObject *object); |
| 2227 | + |
| 2228 | XpadTextBuffer * |
| 2229 | -xpad_text_buffer_new (XpadPad *pad) |
| 2230 | -{ |
| 2231 | - if (!global_text_tag_table) |
| 2232 | - global_text_tag_table = create_tag_table (); /* FIXME: never freed */ |
| 2233 | - |
| 2234 | - return XPAD_TEXT_BUFFER (g_object_new (XPAD_TYPE_TEXT_BUFFER, "tag_table", global_text_tag_table, "pad", pad, NULL)); |
| 2235 | -} |
| 2236 | - |
| 2237 | -static void |
| 2238 | -xpad_text_buffer_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) |
| 2239 | -{ |
| 2240 | - XpadTextBuffer *text_buffer = XPAD_TEXT_BUFFER (object); |
| 2241 | - |
| 2242 | - switch (prop_id) |
| 2243 | - { |
| 2244 | - case PROP_PAD: |
| 2245 | - if (text_buffer->priv->pad && G_IS_OBJECT (text_buffer->priv->pad)) |
| 2246 | - g_object_unref (text_buffer->priv->pad); |
| 2247 | - if (G_VALUE_HOLDS_POINTER (value) && G_IS_OBJECT (g_value_get_pointer (value))) |
| 2248 | - { |
| 2249 | - text_buffer->priv->pad = g_value_get_pointer (value); |
| 2250 | - g_object_ref (text_buffer->priv->pad); |
| 2251 | - } |
| 2252 | - break; |
| 2253 | - |
| 2254 | - default: |
| 2255 | - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); |
| 2256 | - break; |
| 2257 | - } |
| 2258 | -} |
| 2259 | - |
| 2260 | -static void |
| 2261 | -xpad_text_buffer_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) |
| 2262 | -{ |
| 2263 | - XpadTextBuffer *text_buffer = XPAD_TEXT_BUFFER (object); |
| 2264 | - |
| 2265 | - switch (prop_id) |
| 2266 | - { |
| 2267 | - case PROP_PAD: |
| 2268 | - g_value_set_pointer (value, text_buffer->priv->pad); |
| 2269 | - break; |
| 2270 | - |
| 2271 | - default: |
| 2272 | - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); |
| 2273 | - break; |
| 2274 | - } |
| 2275 | -} |
| 2276 | - |
| 2277 | - |
| 2278 | -static void |
| 2279 | -xpad_text_buffer_finalize (GObject *object) |
| 2280 | -{ |
| 2281 | - XpadTextBuffer *text_buffer = XPAD_TEXT_BUFFER (object); |
| 2282 | - |
| 2283 | - if (text_buffer->priv->pad) |
| 2284 | - { |
| 2285 | - g_object_unref (text_buffer->priv->pad); |
| 2286 | - text_buffer->priv->pad = NULL; |
| 2287 | - } |
| 2288 | - |
| 2289 | - if (text_buffer->priv->undo) |
| 2290 | - { |
| 2291 | - g_free (text_buffer->priv->undo); |
| 2292 | - text_buffer->priv->undo = NULL; |
| 2293 | - } |
| 2294 | - |
| 2295 | - G_OBJECT_CLASS (xpad_text_buffer_parent_class)->finalize (object); |
| 2296 | +xpad_text_buffer_new (void) |
| 2297 | +{ |
| 2298 | + XpadPad *pad = NULL; |
| 2299 | + return g_object_new (XPAD_TYPE_TEXT_BUFFER, "pad", pad, NULL); |
| 2300 | } |
| 2301 | |
| 2302 | static void |
| 2303 | xpad_text_buffer_class_init (XpadTextBufferClass *klass) |
| 2304 | { |
| 2305 | GObjectClass *gobject_class = G_OBJECT_CLASS (klass); |
| 2306 | - |
| 2307 | + |
| 2308 | + gobject_class->dispose = xpad_text_buffer_dispose; |
| 2309 | gobject_class->finalize = xpad_text_buffer_finalize; |
| 2310 | gobject_class->set_property = xpad_text_buffer_set_property; |
| 2311 | gobject_class->get_property = xpad_text_buffer_get_property; |
| 2312 | @@ -129,18 +70,85 @@ |
| 2313 | "Pad", |
| 2314 | "Pad connected to this buffer", |
| 2315 | G_PARAM_READWRITE)); |
| 2316 | - |
| 2317 | - g_type_class_add_private (gobject_class, sizeof (XpadTextBufferPrivate)); |
| 2318 | } |
| 2319 | |
| 2320 | static void |
| 2321 | xpad_text_buffer_init (XpadTextBuffer *buffer) |
| 2322 | { |
| 2323 | - buffer->priv = XPAD_TEXT_BUFFER_GET_PRIVATE (buffer); |
| 2324 | + buffer->priv = xpad_text_buffer_get_instance_private(buffer); |
| 2325 | |
| 2326 | + buffer->priv->tag_table = create_tag_table (); |
| 2327 | buffer->priv->undo = xpad_undo_new (buffer); |
| 2328 | } |
| 2329 | |
| 2330 | +static void |
| 2331 | +xpad_text_buffer_dispose (GObject *object) |
| 2332 | +{ |
| 2333 | + XpadTextBuffer *buffer = XPAD_TEXT_BUFFER (object); |
| 2334 | + |
| 2335 | + if (buffer->priv->pad) { |
| 2336 | + g_object_unref (buffer->priv->pad); |
| 2337 | + buffer->priv->pad = NULL; |
| 2338 | + } |
| 2339 | + |
| 2340 | + if (buffer->priv->undo) { |
| 2341 | + g_object_unref (buffer->priv->undo); |
| 2342 | + buffer->priv->undo = NULL; |
| 2343 | + } |
| 2344 | + |
| 2345 | + if (buffer->priv->tag_table) { |
| 2346 | + g_object_unref(buffer->priv->tag_table); |
| 2347 | + buffer->priv->tag_table = NULL; |
| 2348 | + } |
| 2349 | + G_OBJECT_CLASS (xpad_text_buffer_parent_class)->dispose (object); |
| 2350 | +} |
| 2351 | + |
| 2352 | +static void |
| 2353 | +xpad_text_buffer_finalize (GObject *object) |
| 2354 | +{ |
| 2355 | + G_OBJECT_CLASS (xpad_text_buffer_parent_class)->finalize (object); |
| 2356 | +} |
| 2357 | + |
| 2358 | +static void |
| 2359 | +xpad_text_buffer_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) |
| 2360 | +{ |
| 2361 | + XpadTextBuffer *buffer = XPAD_TEXT_BUFFER (object); |
| 2362 | + |
| 2363 | + switch (prop_id) |
| 2364 | + { |
| 2365 | + case PROP_PAD: |
| 2366 | + if (buffer->priv->pad && G_IS_OBJECT (buffer->priv->pad)) |
| 2367 | + g_object_unref (buffer->priv->pad); |
| 2368 | + if (G_VALUE_HOLDS_POINTER (value) && G_IS_OBJECT (g_value_get_pointer (value))) |
| 2369 | + { |
| 2370 | + buffer->priv->pad = g_value_get_pointer (value); |
| 2371 | + g_object_ref (buffer->priv->pad); |
| 2372 | + } |
| 2373 | + break; |
| 2374 | + |
| 2375 | + default: |
| 2376 | + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); |
| 2377 | + break; |
| 2378 | + } |
| 2379 | +} |
| 2380 | + |
| 2381 | +static void |
| 2382 | +xpad_text_buffer_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) |
| 2383 | +{ |
| 2384 | + XpadTextBuffer *buffer = XPAD_TEXT_BUFFER (object); |
| 2385 | + |
| 2386 | + switch (prop_id) |
| 2387 | + { |
| 2388 | + case PROP_PAD: |
| 2389 | + g_value_set_pointer (value, buffer->priv->pad); |
| 2390 | + break; |
| 2391 | + |
| 2392 | + default: |
| 2393 | + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); |
| 2394 | + break; |
| 2395 | + } |
| 2396 | +} |
| 2397 | + |
| 2398 | void |
| 2399 | xpad_text_buffer_set_text_with_tags (XpadTextBuffer *buffer, const gchar *text) |
| 2400 | { |
| 2401 | @@ -432,4 +440,3 @@ |
| 2402 | |
| 2403 | g_object_set (G_OBJECT (buffer), "pad", pad, NULL); |
| 2404 | } |
| 2405 | - |
| 2406 | |
| 2407 | === modified file 'src/xpad-text-buffer.h' |
| 2408 | --- src/xpad-text-buffer.h 2011-11-16 18:10:04 +0000 |
| 2409 | +++ src/xpad-text-buffer.h 2013-10-18 18:35:35 +0000 |
| 2410 | @@ -51,7 +51,7 @@ |
| 2411 | |
| 2412 | GType xpad_text_buffer_get_type (void); |
| 2413 | |
| 2414 | -XpadTextBuffer *xpad_text_buffer_new (XpadPad *pad); |
| 2415 | +XpadTextBuffer *xpad_text_buffer_new (void); |
| 2416 | |
| 2417 | void xpad_text_buffer_set_text_with_tags (XpadTextBuffer *buffer, const gchar *text); |
| 2418 | gchar *xpad_text_buffer_get_text_with_tags (XpadTextBuffer *buffer); |
| 2419 | |
| 2420 | === modified file 'src/xpad-text-view.c' |
| 2421 | --- src/xpad-text-view.c 2011-11-16 18:10:04 +0000 |
| 2422 | +++ src/xpad-text-view.c 2013-10-18 18:35:35 +0000 |
| 2423 | @@ -20,9 +20,6 @@ |
| 2424 | #include "xpad-text-buffer.h" |
| 2425 | #include "xpad-settings.h" |
| 2426 | |
| 2427 | -G_DEFINE_TYPE(XpadTextView, xpad_text_view, GTK_TYPE_TEXT_VIEW) |
| 2428 | -#define XPAD_TEXT_VIEW_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), XPAD_TYPE_TEXT_VIEW, XpadTextViewPrivate)) |
| 2429 | - |
| 2430 | struct XpadTextViewPrivate |
| 2431 | { |
| 2432 | gboolean follow_font_style; |
| 2433 | @@ -33,10 +30,13 @@ |
| 2434 | XpadTextBuffer *buffer; |
| 2435 | }; |
| 2436 | |
| 2437 | +G_DEFINE_TYPE_WITH_PRIVATE(XpadTextView, xpad_text_view, GTK_TYPE_TEXT_VIEW) |
| 2438 | + |
| 2439 | static void xpad_text_view_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); |
| 2440 | static void xpad_text_view_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); |
| 2441 | +static void xpad_text_view_dispose (GObject *object); |
| 2442 | +static void xpad_text_view_finalize (GObject *object); |
| 2443 | static void xpad_text_view_realize (XpadTextView *widget); |
| 2444 | -static void xpad_text_view_finalize (GObject *object); |
| 2445 | static gboolean xpad_text_view_button_press_event (GtkWidget *widget, GdkEventButton *event); |
| 2446 | static gboolean xpad_text_view_focus_out_event (GtkWidget *widget, GdkEventFocus *event); |
| 2447 | static void xpad_text_view_notify_edit_lock (XpadTextView *view); |
| 2448 | @@ -64,7 +64,8 @@ |
| 2449 | xpad_text_view_class_init (XpadTextViewClass *klass) |
| 2450 | { |
| 2451 | GObjectClass *gobject_class = G_OBJECT_CLASS (klass); |
| 2452 | - |
| 2453 | + |
| 2454 | + gobject_class->dispose = xpad_text_view_dispose; |
| 2455 | gobject_class->finalize = xpad_text_view_finalize; |
| 2456 | gobject_class->set_property = xpad_text_view_set_property; |
| 2457 | gobject_class->get_property = xpad_text_view_get_property; |
| 2458 | @@ -86,8 +87,6 @@ |
| 2459 | "Whether to use the default xpad color style", |
| 2460 | TRUE, |
| 2461 | G_PARAM_READWRITE)); |
| 2462 | - |
| 2463 | - g_type_class_add_private (gobject_class, sizeof (XpadTextViewPrivate)); |
| 2464 | } |
| 2465 | |
| 2466 | static void |
| 2467 | @@ -95,12 +94,12 @@ |
| 2468 | { |
| 2469 | gchar *name; |
| 2470 | |
| 2471 | - view->priv = XPAD_TEXT_VIEW_GET_PRIVATE (view); |
| 2472 | + view->priv = xpad_text_view_get_instance_private(view); |
| 2473 | |
| 2474 | view->priv->follow_font_style = TRUE; |
| 2475 | view->priv->follow_color_style = TRUE; |
| 2476 | |
| 2477 | - view->priv->buffer = xpad_text_buffer_new (NULL); |
| 2478 | + view->priv->buffer = xpad_text_buffer_new(); |
| 2479 | gtk_text_view_set_buffer (GTK_TEXT_VIEW (view), GTK_TEXT_BUFFER (view->priv->buffer)); |
| 2480 | |
| 2481 | gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (view), GTK_WRAP_WORD); |
| 2482 | @@ -126,18 +125,20 @@ |
| 2483 | } |
| 2484 | |
| 2485 | static void |
| 2486 | -xpad_text_view_finalize (GObject *object) |
| 2487 | +xpad_text_view_dispose (GObject *object) |
| 2488 | { |
| 2489 | XpadTextView *view = XPAD_TEXT_VIEW (object); |
| 2490 | |
| 2491 | - if (view->priv->buffer) |
| 2492 | - { |
| 2493 | + if (view->priv->buffer) { |
| 2494 | g_object_unref (view->priv->buffer); |
| 2495 | - view->priv->buffer = NULL; |
| 2496 | } |
| 2497 | |
| 2498 | - g_signal_handlers_disconnect_matched (xpad_settings (), G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, view); |
| 2499 | - |
| 2500 | + G_OBJECT_CLASS (xpad_text_view_parent_class)->dispose (object); |
| 2501 | +} |
| 2502 | + |
| 2503 | +static void |
| 2504 | +xpad_text_view_finalize (GObject *object) |
| 2505 | +{ |
| 2506 | G_OBJECT_CLASS (xpad_text_view_parent_class)->finalize (object); |
| 2507 | } |
| 2508 | |
| 2509 | |
| 2510 | === modified file 'src/xpad-toolbar.c' |
| 2511 | --- src/xpad-toolbar.c 2011-11-16 20:39:04 +0000 |
| 2512 | +++ src/xpad-toolbar.c 2013-10-18 18:35:35 +0000 |
| 2513 | @@ -26,25 +26,24 @@ |
| 2514 | #include "xpad-settings.h" |
| 2515 | #include "xpad-grip-tool-item.h" |
| 2516 | |
| 2517 | -G_DEFINE_TYPE(XpadToolbar, xpad_toolbar, GTK_TYPE_TOOLBAR) |
| 2518 | -#define XPAD_TOOLBAR_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), XPAD_TYPE_TOOLBAR, XpadToolbarPrivate)) |
| 2519 | - |
| 2520 | -enum { |
| 2521 | - XPAD_BUTTON_TYPE_SEPARATOR, |
| 2522 | - XPAD_BUTTON_TYPE_BUTTON, |
| 2523 | - XPAD_BUTTON_TYPE_TOGGLE |
| 2524 | -}; |
| 2525 | - |
| 2526 | struct XpadToolbarPrivate |
| 2527 | { |
| 2528 | - GtkToolItem *move_button; |
| 2529 | gboolean move_removed; |
| 2530 | guint move_index; |
| 2531 | guint move_motion_handler; |
| 2532 | guint move_button_release_handler; |
| 2533 | guint move_key_press_handler; |
| 2534 | - GtkToolItem *tool_items; |
| 2535 | XpadPad *pad; |
| 2536 | + // GtkToolItem *move_button; |
| 2537 | + // GtkToolItem *tool_items; |
| 2538 | +}; |
| 2539 | + |
| 2540 | +G_DEFINE_TYPE_WITH_PRIVATE(XpadToolbar, xpad_toolbar, GTK_TYPE_TOOLBAR) |
| 2541 | + |
| 2542 | +enum { |
| 2543 | + XPAD_BUTTON_TYPE_SEPARATOR, |
| 2544 | + XPAD_BUTTON_TYPE_BUTTON, |
| 2545 | + XPAD_BUTTON_TYPE_TOGGLE |
| 2546 | }; |
| 2547 | |
| 2548 | typedef struct |
| 2549 | @@ -94,26 +93,28 @@ |
| 2550 | /*{"Minimize to Tray", "gtk-goto-bottom", 1, N_("Minimize Pads to System Tray")}*/ |
| 2551 | }; |
| 2552 | |
| 2553 | - |
| 2554 | static G_CONST_RETURN XpadToolbarButton *xpad_toolbar_button_lookup (XpadToolbar *toolbar, const gchar *name); |
| 2555 | static GtkToolItem *xpad_toolbar_button_to_item (XpadToolbar *toolbar, const XpadToolbarButton *button); |
| 2556 | static void xpad_toolbar_button_activated (GtkToolButton *button); |
| 2557 | static void xpad_toolbar_change_buttons (XpadToolbar *toolbar); |
| 2558 | +static void xpad_toolbar_dispose (GObject *object); |
| 2559 | static void xpad_toolbar_finalize (GObject *object); |
| 2560 | static void xpad_toolbar_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); |
| 2561 | static void xpad_toolbar_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); |
| 2562 | static void xpad_toolbar_remove_all_buttons (); |
| 2563 | static void xpad_toolbar_remove_last_button (); |
| 2564 | static void xpad_toolbar_add_button (const gchar *button_name); |
| 2565 | +static gboolean xpad_toolbar_popup_context_menu (GtkToolbar *toolbar, gint x, gint y, gint button); |
| 2566 | + |
| 2567 | +/* Unfinished new feature of previous developer |
| 2568 | static void xpad_toolbar_remove_button (GtkWidget *button); |
| 2569 | static gboolean xpad_toolbar_button_press_event (GtkWidget *widget, GdkEventButton *event); |
| 2570 | -static gboolean xpad_toolbar_popup_context_menu (GtkToolbar *toolbar, gint x, gint y, gint button); |
| 2571 | static gboolean xpad_toolbar_popup_button_menu (GtkWidget *button, GdkEventButton *event, XpadToolbar *toolbar); |
| 2572 | - |
| 2573 | static gboolean xpad_toolbar_move_button_start (XpadToolbar *toolbar, GtkWidget *button); |
| 2574 | static gboolean xpad_toolbar_move_button_move (XpadToolbar *toolbar, GdkEventMotion *event); |
| 2575 | static gboolean xpad_toolbar_move_button_move_keyboard (XpadToolbar *toolbar, GdkEventKey *event); |
| 2576 | static gboolean xpad_toolbar_move_button_end (XpadToolbar *toolbar); |
| 2577 | +*/ |
| 2578 | |
| 2579 | static guint signals[LAST_SIGNAL] = { 0 }; |
| 2580 | |
| 2581 | @@ -139,6 +140,7 @@ |
| 2582 | gtktoolbar_class->popup_context_menu = xpad_toolbar_popup_context_menu; |
| 2583 | gobject_class->set_property = xpad_toolbar_set_property; |
| 2584 | gobject_class->get_property = xpad_toolbar_get_property; |
| 2585 | + gobject_class->dispose = xpad_toolbar_dispose; |
| 2586 | gobject_class->finalize = xpad_toolbar_finalize; |
| 2587 | |
| 2588 | /* Signals */ |
| 2589 | @@ -260,16 +262,13 @@ |
| 2590 | "Pad ", |
| 2591 | "Pad associated with this toolbar", |
| 2592 | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY)); |
| 2593 | - |
| 2594 | - g_type_class_add_private (gobject_class, sizeof (XpadToolbarPrivate)); |
| 2595 | } |
| 2596 | |
| 2597 | static void |
| 2598 | xpad_toolbar_init (XpadToolbar *toolbar) |
| 2599 | { |
| 2600 | - toolbar->priv = XPAD_TOOLBAR_GET_PRIVATE (toolbar); |
| 2601 | + toolbar->priv = xpad_toolbar_get_instance_private(toolbar); |
| 2602 | |
| 2603 | - toolbar->priv->pad = NULL; |
| 2604 | toolbar->priv->move_motion_handler = 0; |
| 2605 | toolbar->priv->move_button_release_handler = 0; |
| 2606 | toolbar->priv->move_key_press_handler = 0; |
| 2607 | @@ -286,17 +285,21 @@ |
| 2608 | } |
| 2609 | |
| 2610 | static void |
| 2611 | +xpad_toolbar_dispose (GObject *object) |
| 2612 | +{ |
| 2613 | + XpadToolbar *toolbar = XPAD_TOOLBAR (object); |
| 2614 | + |
| 2615 | + if (toolbar->priv->pad) { |
| 2616 | + g_object_unref (toolbar->priv->pad); |
| 2617 | + toolbar->priv->pad = NULL; |
| 2618 | + } |
| 2619 | + |
| 2620 | + G_OBJECT_CLASS (xpad_toolbar_parent_class)->dispose (object); |
| 2621 | +} |
| 2622 | + |
| 2623 | +static void |
| 2624 | xpad_toolbar_finalize (GObject *object) |
| 2625 | { |
| 2626 | - XpadToolbar *toolbar = XPAD_TOOLBAR (object); |
| 2627 | - |
| 2628 | - if (toolbar->priv->move_button) |
| 2629 | - g_object_unref (toolbar->priv->move_button); |
| 2630 | - if (toolbar->priv->pad) |
| 2631 | - g_object_unref (toolbar->priv->pad); |
| 2632 | - |
| 2633 | - g_signal_handlers_disconnect_matched (xpad_settings (), G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, toolbar); |
| 2634 | - |
| 2635 | G_OBJECT_CLASS (xpad_toolbar_parent_class)->finalize (object); |
| 2636 | } |
| 2637 | |
| 2638 | @@ -340,30 +343,10 @@ |
| 2639 | } |
| 2640 | } |
| 2641 | |
| 2642 | -static gboolean |
| 2643 | -xpad_toolbar_button_press_event (GtkWidget *widget, GdkEventButton *event) |
| 2644 | -{ |
| 2645 | - /* Ignore double-clicks and triple-clicks */ |
| 2646 | - if (event->button == 3 && event->type == GDK_BUTTON_PRESS) |
| 2647 | - { |
| 2648 | - XpadToolbar *toolbar = XPAD_TOOLBAR (g_object_get_data (G_OBJECT (widget), "xpad-toolbar")); |
| 2649 | - xpad_toolbar_popup_button_menu (widget, event, toolbar); |
| 2650 | - return TRUE; |
| 2651 | - } |
| 2652 | - else if (event->button == 2 && event->type == GDK_BUTTON_PRESS) |
| 2653 | - { |
| 2654 | - XpadToolbar *toolbar = XPAD_TOOLBAR (g_object_get_data (G_OBJECT (widget), "xpad-toolbar")); |
| 2655 | - xpad_toolbar_move_button_start (toolbar, widget); |
| 2656 | - return TRUE; |
| 2657 | - } |
| 2658 | - |
| 2659 | - return FALSE; |
| 2660 | -} |
| 2661 | - |
| 2662 | static G_CONST_RETURN XpadToolbarButton * |
| 2663 | xpad_toolbar_button_lookup (XpadToolbar *toolbar, const gchar *name) |
| 2664 | { |
| 2665 | - gint i; |
| 2666 | + guint i; |
| 2667 | for (i = 0; i < G_N_ELEMENTS (buttons); i++) |
| 2668 | if (!g_ascii_strcasecmp (name, buttons[i].name)) |
| 2669 | return &buttons[i]; |
| 2670 | @@ -375,7 +358,7 @@ |
| 2671 | xpad_toolbar_button_to_item (XpadToolbar *toolbar, const XpadToolbarButton *button) |
| 2672 | { |
| 2673 | GtkToolItem *item; |
| 2674 | - GtkWidget *child; |
| 2675 | + // GtkWidget *child; |
| 2676 | |
| 2677 | item = GTK_TOOL_ITEM (g_object_get_data (G_OBJECT (toolbar), button->name)); |
| 2678 | if (item) |
| 2679 | @@ -406,17 +389,6 @@ |
| 2680 | if (button->desc) |
| 2681 | gtk_tool_item_set_tooltip_text (item, _(button->desc)); |
| 2682 | |
| 2683 | - // This won't work anymore because we make some buttons insensitive |
| 2684 | - // so we cannot handle right clicks on them anymore. That's why we just add "Remove all butons" |
| 2685 | - // and "Remove last button" to toolbar context menu |
| 2686 | - /* |
| 2687 | - child = gtk_bin_get_child (GTK_BIN (item)); |
| 2688 | - if (child) |
| 2689 | - { |
| 2690 | - g_signal_connect_swapped (child, "button-press-event", G_CALLBACK (xpad_toolbar_button_press_event), item); |
| 2691 | - } |
| 2692 | - */ |
| 2693 | - |
| 2694 | return item; |
| 2695 | } |
| 2696 | |
| 2697 | @@ -437,7 +409,8 @@ |
| 2698 | { |
| 2699 | GList *list, *temp; |
| 2700 | const GSList *slist, *stemp; |
| 2701 | - gint i = 0, j; |
| 2702 | + gint i = 0; |
| 2703 | + guint j = 0; |
| 2704 | GtkToolItem *item; |
| 2705 | |
| 2706 | list = gtk_container_get_children (GTK_CONTAINER (toolbar)); |
| 2707 | @@ -446,6 +419,7 @@ |
| 2708 | gtk_widget_destroy (temp->data); |
| 2709 | |
| 2710 | g_list_free (list); |
| 2711 | + g_list_free (temp); |
| 2712 | |
| 2713 | for (j = 0; j < G_N_ELEMENTS (buttons); j++) |
| 2714 | g_object_set_data (G_OBJECT (toolbar), buttons[j].name, NULL); |
| 2715 | @@ -510,48 +484,247 @@ |
| 2716 | } |
| 2717 | |
| 2718 | static void |
| 2719 | +menu_deactivated (GtkWidget *menu, GtkToolbar *toolbar) |
| 2720 | +{ |
| 2721 | + g_signal_emit (toolbar, signals[POPDOWN], 0, menu); |
| 2722 | +} |
| 2723 | + |
| 2724 | +static gboolean |
| 2725 | +xpad_toolbar_popup_context_menu (GtkToolbar *toolbar, gint x, gint y, gint button) |
| 2726 | +{ |
| 2727 | + GtkWidget *menu; |
| 2728 | + const GSList *current_buttons; |
| 2729 | + guint i; |
| 2730 | + |
| 2731 | + menu = gtk_menu_new (); |
| 2732 | + |
| 2733 | + current_buttons = xpad_settings_get_toolbar_buttons (xpad_settings ()); |
| 2734 | + |
| 2735 | + gboolean is_button = FALSE; |
| 2736 | + |
| 2737 | + for (i = 0; i < G_N_ELEMENTS (buttons); i++) |
| 2738 | + { |
| 2739 | + const GSList *j; |
| 2740 | + GtkWidget *item, *image; |
| 2741 | + |
| 2742 | + if (strcmp (buttons[i].name, "sep") != 0) |
| 2743 | + { |
| 2744 | + for (j = current_buttons; j; j = j->next) |
| 2745 | + if (!g_ascii_strcasecmp (j->data, buttons[i].name)) |
| 2746 | + break; |
| 2747 | + |
| 2748 | + if (j) |
| 2749 | + { |
| 2750 | + is_button = TRUE; |
| 2751 | + continue; |
| 2752 | + } |
| 2753 | + } |
| 2754 | + else |
| 2755 | + { |
| 2756 | + /* Don't let user add separators until we can allow clicks on them. */ |
| 2757 | + continue; |
| 2758 | + } |
| 2759 | + |
| 2760 | + item = gtk_image_menu_item_new_with_mnemonic (buttons[i].menu_desc); |
| 2761 | + |
| 2762 | + image = gtk_image_new_from_stock (GTK_STOCK_ADD, GTK_ICON_SIZE_MENU); |
| 2763 | + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image); |
| 2764 | + |
| 2765 | + g_signal_connect_swapped (item, "activate", G_CALLBACK (xpad_toolbar_add_button), (gpointer) buttons[i].name); |
| 2766 | + |
| 2767 | + gtk_menu_attach (GTK_MENU (menu), item, 0, 1, i, i + 1); |
| 2768 | + gtk_widget_show (item); |
| 2769 | + } |
| 2770 | + |
| 2771 | + if (is_button) |
| 2772 | + { |
| 2773 | + GtkWidget *item, *image; |
| 2774 | + |
| 2775 | + item = gtk_image_menu_item_new_with_mnemonic (N_("Remove All _Buttons")); |
| 2776 | + |
| 2777 | + image = gtk_image_new_from_stock (GTK_STOCK_ADD, GTK_ICON_SIZE_MENU); |
| 2778 | + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image); |
| 2779 | + |
| 2780 | + g_signal_connect_swapped (item, "activate", G_CALLBACK (xpad_toolbar_remove_all_buttons), NULL); |
| 2781 | + |
| 2782 | + gtk_menu_attach (GTK_MENU (menu), item, 0, 1, i, i + 1); |
| 2783 | + gtk_widget_show (item); |
| 2784 | + |
| 2785 | + i++; |
| 2786 | + |
| 2787 | + item = gtk_image_menu_item_new_with_mnemonic (N_("Remo_ve Last Button")); |
| 2788 | + |
| 2789 | + image = gtk_image_new_from_stock (GTK_STOCK_ADD, GTK_ICON_SIZE_MENU); |
| 2790 | + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image); |
| 2791 | + |
| 2792 | + g_signal_connect_swapped (item, "activate", G_CALLBACK (xpad_toolbar_remove_last_button), NULL); |
| 2793 | + |
| 2794 | + gtk_menu_attach (GTK_MENU (menu), item, 0, 1, i, i + 1); |
| 2795 | + gtk_widget_show (item); |
| 2796 | + } |
| 2797 | + |
| 2798 | + g_signal_connect (menu, "deactivate", G_CALLBACK (menu_deactivated), toolbar); |
| 2799 | + |
| 2800 | + gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, (guint) ((button < 0) ? 0 : button), gtk_get_current_event_time ()); |
| 2801 | + |
| 2802 | + g_signal_emit (toolbar, signals[POPUP], 0, menu); |
| 2803 | + |
| 2804 | + return TRUE; |
| 2805 | +} |
| 2806 | + |
| 2807 | +static void |
| 2808 | +xpad_toolbar_enable_button (XpadToolbar *toolbar, const XpadToolbarButton *button, gboolean enable) |
| 2809 | +{ |
| 2810 | + g_return_if_fail (button); |
| 2811 | + GtkToolItem *item = xpad_toolbar_button_to_item (toolbar, button); |
| 2812 | + if (item) |
| 2813 | + gtk_widget_set_sensitive (GTK_WIDGET (item), enable); |
| 2814 | +} |
| 2815 | + |
| 2816 | +void |
| 2817 | +xpad_toolbar_enable_undo_button (XpadToolbar *toolbar, gboolean enable) |
| 2818 | +{ |
| 2819 | + const XpadToolbarButton *button = xpad_toolbar_button_lookup (toolbar, "Undo"); |
| 2820 | + xpad_toolbar_enable_button (toolbar, button, enable); |
| 2821 | +} |
| 2822 | + |
| 2823 | +void |
| 2824 | +xpad_toolbar_enable_redo_button (XpadToolbar *toolbar, gboolean enable) |
| 2825 | +{ |
| 2826 | + const XpadToolbarButton *button = xpad_toolbar_button_lookup (toolbar, "Redo"); |
| 2827 | + xpad_toolbar_enable_button (toolbar, button, enable); |
| 2828 | +} |
| 2829 | + |
| 2830 | +void |
| 2831 | +xpad_toolbar_enable_cut_button (XpadToolbar *toolbar, gboolean enable) |
| 2832 | +{ |
| 2833 | + const XpadToolbarButton *button = xpad_toolbar_button_lookup (toolbar, "Cut"); |
| 2834 | + xpad_toolbar_enable_button (toolbar, button, enable); |
| 2835 | +} |
| 2836 | + |
| 2837 | +void |
| 2838 | +xpad_toolbar_enable_copy_button (XpadToolbar *toolbar, gboolean enable) |
| 2839 | +{ |
| 2840 | + const XpadToolbarButton *button = xpad_toolbar_button_lookup (toolbar, "Copy"); |
| 2841 | + xpad_toolbar_enable_button (toolbar, button, enable); |
| 2842 | +} |
| 2843 | + |
| 2844 | +void |
| 2845 | +xpad_toolbar_enable_paste_button (XpadToolbar *toolbar, gboolean enable) |
| 2846 | +{ |
| 2847 | + const XpadToolbarButton *button = xpad_toolbar_button_lookup (toolbar, "Paste"); |
| 2848 | + xpad_toolbar_enable_button (toolbar, button, enable); |
| 2849 | +} |
| 2850 | + |
| 2851 | +/* |
| 2852 | + * The code below was code in progress of a previous developer |
| 2853 | +static gboolean |
| 2854 | +xpad_toolbar_button_press_event (GtkWidget *widget, GdkEventButton *event) |
| 2855 | +{ |
| 2856 | + // Ignore double-clicks and triple-clicks |
| 2857 | + if (event->button == 3 && event->type == GDK_BUTTON_PRESS) |
| 2858 | + { |
| 2859 | + XpadToolbar *toolbar = XPAD_TOOLBAR (g_object_get_data (G_OBJECT (widget), "xpad-toolbar")); |
| 2860 | + xpad_toolbar_popup_button_menu (widget, event, toolbar); |
| 2861 | + return TRUE; |
| 2862 | + } |
| 2863 | + else if (event->button == 2 && event->type == GDK_BUTTON_PRESS) |
| 2864 | + { |
| 2865 | + XpadToolbar *toolbar = XPAD_TOOLBAR (g_object_get_data (G_OBJECT (widget), "xpad-toolbar")); |
| 2866 | + xpad_toolbar_move_button_start (toolbar, widget); |
| 2867 | + return TRUE; |
| 2868 | + } |
| 2869 | + |
| 2870 | + return FALSE; |
| 2871 | +} |
| 2872 | + |
| 2873 | +static gboolean |
| 2874 | +xpad_toolbar_popup_button_menu (GtkWidget *button, GdkEventButton *event, XpadToolbar *toolbar) |
| 2875 | +{ |
| 2876 | + GtkWidget *menu; |
| 2877 | + GtkWidget *item, *image; |
| 2878 | + |
| 2879 | + menu = gtk_menu_new (); |
| 2880 | + |
| 2881 | + |
| 2882 | + item = gtk_image_menu_item_new_with_mnemonic (_("_Remove From Toolbar")); |
| 2883 | + |
| 2884 | + image = gtk_image_new_from_stock (GTK_STOCK_REMOVE, GTK_ICON_SIZE_MENU); |
| 2885 | + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image); |
| 2886 | + |
| 2887 | + g_signal_connect_swapped (item, "activate", G_CALLBACK (xpad_toolbar_remove_button), button); |
| 2888 | + gtk_menu_attach (GTK_MENU (menu), item, 0, 1, 0, 1); |
| 2889 | + gtk_widget_show (item); |
| 2890 | + |
| 2891 | + |
| 2892 | + item = gtk_menu_item_new_with_mnemonic (_("_Move")); |
| 2893 | + g_signal_connect_swapped (item, "activate", G_CALLBACK (move_menu_item_activated), button); |
| 2894 | + gtk_menu_attach (GTK_MENU (menu), item, 0, 1, 1, 2); |
| 2895 | + gtk_widget_show (item); |
| 2896 | + |
| 2897 | + |
| 2898 | + g_signal_connect (menu, "deactivate", G_CALLBACK (menu_deactivated), toolbar); |
| 2899 | + |
| 2900 | + gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, event ? event->button : 0, gtk_get_current_event_time ()); |
| 2901 | + |
| 2902 | + g_signal_emit (toolbar, signals[POPUP], 0, menu); |
| 2903 | + |
| 2904 | + return TRUE; |
| 2905 | +} |
| 2906 | + |
| 2907 | +static void |
| 2908 | xpad_toolbar_remove_button (GtkWidget *button) |
| 2909 | { |
| 2910 | gint button_num; |
| 2911 | - |
| 2912 | + |
| 2913 | button_num = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (button), "xpad-button-num")); |
| 2914 | - |
| 2915 | + |
| 2916 | xpad_settings_remove_toolbar_button (xpad_settings (), button_num); |
| 2917 | } |
| 2918 | |
| 2919 | +static void |
| 2920 | +move_menu_item_activated (GtkWidget *button) |
| 2921 | +{ |
| 2922 | + XpadToolbar *toolbar; |
| 2923 | + |
| 2924 | + toolbar = XPAD_TOOLBAR (g_object_get_data (G_OBJECT (button), "xpad-toolbar")); |
| 2925 | + |
| 2926 | + xpad_toolbar_move_button_start (toolbar, button); |
| 2927 | +} |
| 2928 | + |
| 2929 | static gboolean |
| 2930 | xpad_toolbar_move_button_start (XpadToolbar *toolbar, GtkWidget *button) |
| 2931 | { |
| 2932 | GdkGrabStatus status; |
| 2933 | GdkCursor *fleur_cursor; |
| 2934 | GtkWidget *widget; |
| 2935 | - |
| 2936 | + |
| 2937 | widget = GTK_WIDGET (toolbar); |
| 2938 | gtk_grab_add (widget); |
| 2939 | - |
| 2940 | + |
| 2941 | fleur_cursor = gdk_cursor_new (GDK_FLEUR); |
| 2942 | - |
| 2943 | - g_object_ref (button); |
| 2944 | + |
| 2945 | + // g_object_ref (button); |
| 2946 | toolbar->priv->move_removed = FALSE; |
| 2947 | toolbar->priv->move_button = GTK_TOOL_ITEM (button); |
| 2948 | toolbar->priv->move_index = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (button), "xpad-button-num")); |
| 2949 | - |
| 2950 | + |
| 2951 | toolbar->priv->move_button_release_handler = g_signal_connect (toolbar, "button-release-event", G_CALLBACK (xpad_toolbar_move_button_end), NULL); |
| 2952 | toolbar->priv->move_key_press_handler = g_signal_connect (toolbar, "key-press-event", G_CALLBACK (xpad_toolbar_move_button_move_keyboard), NULL); |
| 2953 | toolbar->priv->move_motion_handler = g_signal_connect (toolbar, "motion-notify-event", G_CALLBACK (xpad_toolbar_move_button_move), NULL); |
| 2954 | - |
| 2955 | + |
| 2956 | status = gdk_pointer_grab (widget->window, FALSE, |
| 2957 | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK, NULL, |
| 2958 | fleur_cursor, gtk_get_current_event_time ()); |
| 2959 | - |
| 2960 | + |
| 2961 | gdk_cursor_unref (fleur_cursor); |
| 2962 | gdk_flush (); |
| 2963 | - |
| 2964 | + |
| 2965 | if (status != GDK_GRAB_SUCCESS) |
| 2966 | { |
| 2967 | xpad_toolbar_move_button_end (toolbar); |
| 2968 | } |
| 2969 | - |
| 2970 | + |
| 2971 | return TRUE; |
| 2972 | } |
| 2973 | |
| 2974 | @@ -565,27 +738,27 @@ |
| 2975 | toolbar->priv->move_removed = TRUE; |
| 2976 | gtk_container_remove (GTK_CONTAINER (toolbar), GTK_WIDGET (toolbar->priv->move_button)); |
| 2977 | } |
| 2978 | - |
| 2979 | + |
| 2980 | if (toolbar->priv->move_index > 0) |
| 2981 | toolbar->priv->move_index--; |
| 2982 | - |
| 2983 | + |
| 2984 | gtk_toolbar_set_drop_highlight_item (GTK_TOOLBAR (toolbar), toolbar->priv->move_button, toolbar->priv->move_index); |
| 2985 | } |
| 2986 | else if (event->keyval == GDK_Right || event->keyval == GDK_KP_Right) |
| 2987 | { |
| 2988 | gint max; |
| 2989 | - |
| 2990 | + |
| 2991 | if (!toolbar->priv->move_removed) |
| 2992 | { |
| 2993 | toolbar->priv->move_removed = TRUE; |
| 2994 | gtk_container_remove (GTK_CONTAINER (toolbar), GTK_WIDGET (toolbar->priv->move_button)); |
| 2995 | } |
| 2996 | - |
| 2997 | + |
| 2998 | max = gtk_toolbar_get_n_items (GTK_TOOLBAR (toolbar)) - 2; |
| 2999 | - |
| 3000 | + |
| 3001 | if (toolbar->priv->move_index < max) |
| 3002 | toolbar->priv->move_index++; |
| 3003 | - |
| 3004 | + |
| 3005 | gtk_toolbar_set_drop_highlight_item (GTK_TOOLBAR (toolbar), toolbar->priv->move_button, toolbar->priv->move_index); |
| 3006 | } |
| 3007 | else if (event->keyval == GDK_space || event->keyval == GDK_KP_Space || event->keyval == GDK_Return || event->keyval == GDK_KP_Enter) |
| 3008 | @@ -593,7 +766,7 @@ |
| 3009 | xpad_toolbar_move_button_end (toolbar); |
| 3010 | return TRUE; |
| 3011 | } |
| 3012 | - |
| 3013 | + |
| 3014 | return TRUE; |
| 3015 | } |
| 3016 | |
| 3017 | @@ -601,21 +774,21 @@ |
| 3018 | xpad_toolbar_move_button_move (XpadToolbar *toolbar, GdkEventMotion *event) |
| 3019 | { |
| 3020 | gint max; |
| 3021 | - |
| 3022 | + |
| 3023 | if (!toolbar->priv->move_removed) |
| 3024 | { |
| 3025 | toolbar->priv->move_removed = TRUE; |
| 3026 | gtk_container_remove (GTK_CONTAINER (toolbar), GTK_WIDGET (toolbar->priv->move_button)); |
| 3027 | } |
| 3028 | - |
| 3029 | + |
| 3030 | toolbar->priv->move_index = gtk_toolbar_get_drop_index (GTK_TOOLBAR (toolbar), event->x, event->y); |
| 3031 | - |
| 3032 | - /* Must not move past separator or grip */ |
| 3033 | + |
| 3034 | + // Must not move past separator or grip |
| 3035 | max = gtk_toolbar_get_n_items (GTK_TOOLBAR (toolbar)) - 2; |
| 3036 | toolbar->priv->move_index = MIN (toolbar->priv->move_index, max); |
| 3037 | - |
| 3038 | + |
| 3039 | gtk_toolbar_set_drop_highlight_item (GTK_TOOLBAR (toolbar), toolbar->priv->move_button, toolbar->priv->move_index); |
| 3040 | - |
| 3041 | + |
| 3042 | return TRUE; |
| 3043 | } |
| 3044 | |
| 3045 | @@ -624,210 +797,34 @@ |
| 3046 | { |
| 3047 | gint old_spot; |
| 3048 | gint max; |
| 3049 | - |
| 3050 | + |
| 3051 | g_signal_handler_disconnect (toolbar, toolbar->priv->move_button_release_handler); |
| 3052 | g_signal_handler_disconnect (toolbar, toolbar->priv->move_key_press_handler); |
| 3053 | g_signal_handler_disconnect (toolbar, toolbar->priv->move_motion_handler); |
| 3054 | toolbar->priv->move_button_release_handler = 0; |
| 3055 | toolbar->priv->move_key_press_handler = 0; |
| 3056 | toolbar->priv->move_motion_handler = 0; |
| 3057 | - |
| 3058 | + |
| 3059 | gtk_toolbar_set_drop_highlight_item (GTK_TOOLBAR (toolbar), NULL, 0); |
| 3060 | - |
| 3061 | + |
| 3062 | old_spot = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (toolbar->priv->move_button), "xpad-button-num")); |
| 3063 | - |
| 3064 | - /* Must not move past separator or grip */ |
| 3065 | + |
| 3066 | + // Must not move past separator or grip |
| 3067 | max = gtk_toolbar_get_n_items (GTK_TOOLBAR (toolbar)) - 2; |
| 3068 | toolbar->priv->move_index = MIN (toolbar->priv->move_index, max); |
| 3069 | - |
| 3070 | + |
| 3071 | if (!xpad_settings_move_toolbar_button (xpad_settings (), old_spot, toolbar->priv->move_index) && |
| 3072 | toolbar->priv->move_removed) |
| 3073 | { |
| 3074 | gtk_toolbar_insert (GTK_TOOLBAR (toolbar), toolbar->priv->move_button, toolbar->priv->move_index); |
| 3075 | } |
| 3076 | - |
| 3077 | - g_object_unref (toolbar->priv->move_button); |
| 3078 | + |
| 3079 | + // g_object_unref (toolbar->priv->move_button); |
| 3080 | toolbar->priv->move_button = NULL; |
| 3081 | - |
| 3082 | + |
| 3083 | gtk_grab_remove (GTK_WIDGET (toolbar)); |
| 3084 | gdk_pointer_ungrab (gtk_get_current_event_time ()); |
| 3085 | return TRUE; |
| 3086 | } |
| 3087 | |
| 3088 | -static void |
| 3089 | -move_menu_item_activated (GtkWidget *button) |
| 3090 | -{ |
| 3091 | - XpadToolbar *toolbar; |
| 3092 | - |
| 3093 | - toolbar = XPAD_TOOLBAR (g_object_get_data (G_OBJECT (button), "xpad-toolbar")); |
| 3094 | - |
| 3095 | - xpad_toolbar_move_button_start (toolbar, button); |
| 3096 | -} |
| 3097 | - |
| 3098 | -static void |
| 3099 | -menu_deactivated (GtkWidget *menu, GtkToolbar *toolbar) |
| 3100 | -{ |
| 3101 | - g_signal_emit (toolbar, signals[POPDOWN], 0, menu); |
| 3102 | -} |
| 3103 | - |
| 3104 | -static gboolean |
| 3105 | -xpad_toolbar_popup_button_menu (GtkWidget *button, GdkEventButton *event, XpadToolbar *toolbar) |
| 3106 | -{ |
| 3107 | - GtkWidget *menu; |
| 3108 | - GtkWidget *item, *image; |
| 3109 | - |
| 3110 | - menu = gtk_menu_new (); |
| 3111 | - |
| 3112 | - |
| 3113 | - item = gtk_image_menu_item_new_with_mnemonic (_("_Remove From Toolbar")); |
| 3114 | - |
| 3115 | - image = gtk_image_new_from_stock (GTK_STOCK_REMOVE, GTK_ICON_SIZE_MENU); |
| 3116 | - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image); |
| 3117 | - |
| 3118 | - g_signal_connect_swapped (item, "activate", G_CALLBACK (xpad_toolbar_remove_button), button); |
| 3119 | - gtk_menu_attach (GTK_MENU (menu), item, 0, 1, 0, 1); |
| 3120 | - gtk_widget_show (item); |
| 3121 | - |
| 3122 | - |
| 3123 | - item = gtk_menu_item_new_with_mnemonic (_("_Move")); |
| 3124 | - g_signal_connect_swapped (item, "activate", G_CALLBACK (move_menu_item_activated), button); |
| 3125 | - gtk_menu_attach (GTK_MENU (menu), item, 0, 1, 1, 2); |
| 3126 | - gtk_widget_show (item); |
| 3127 | - |
| 3128 | - |
| 3129 | - g_signal_connect (menu, "deactivate", G_CALLBACK (menu_deactivated), toolbar); |
| 3130 | - |
| 3131 | - gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, event ? event->button : 0, gtk_get_current_event_time ()); |
| 3132 | - |
| 3133 | - g_signal_emit (toolbar, signals[POPUP], 0, menu); |
| 3134 | - |
| 3135 | - return TRUE; |
| 3136 | -} |
| 3137 | - |
| 3138 | -static gboolean |
| 3139 | -xpad_toolbar_popup_context_menu (GtkToolbar *toolbar, gint x, gint y, gint button) |
| 3140 | -{ |
| 3141 | - GtkWidget *menu; |
| 3142 | - const GSList *current_buttons; |
| 3143 | - gint i; |
| 3144 | - |
| 3145 | - menu = gtk_menu_new (); |
| 3146 | - |
| 3147 | - current_buttons = xpad_settings_get_toolbar_buttons (xpad_settings ()); |
| 3148 | - |
| 3149 | - gboolean is_button = FALSE; |
| 3150 | - |
| 3151 | - for (i = 0; i < G_N_ELEMENTS (buttons); i++) |
| 3152 | - { |
| 3153 | - const GSList *j; |
| 3154 | - GtkWidget *item, *image; |
| 3155 | - |
| 3156 | - if (strcmp (buttons[i].name, "sep") != 0) |
| 3157 | - { |
| 3158 | - for (j = current_buttons; j; j = j->next) |
| 3159 | - if (!g_ascii_strcasecmp (j->data, buttons[i].name)) |
| 3160 | - break; |
| 3161 | - |
| 3162 | - if (j) |
| 3163 | - { |
| 3164 | - is_button = TRUE; |
| 3165 | - continue; |
| 3166 | - } |
| 3167 | - } |
| 3168 | - else |
| 3169 | - { |
| 3170 | - /* Don't let user add separators until we can allow clicks on them. */ |
| 3171 | - continue; |
| 3172 | - } |
| 3173 | - |
| 3174 | - item = gtk_image_menu_item_new_with_mnemonic (buttons[i].menu_desc); |
| 3175 | - |
| 3176 | - image = gtk_image_new_from_stock (GTK_STOCK_ADD, GTK_ICON_SIZE_MENU); |
| 3177 | - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image); |
| 3178 | - |
| 3179 | - g_signal_connect_swapped (item, "activate", G_CALLBACK (xpad_toolbar_add_button), (gpointer) buttons[i].name); |
| 3180 | - |
| 3181 | - gtk_menu_attach (GTK_MENU (menu), item, 0, 1, i, i + 1); |
| 3182 | - gtk_widget_show (item); |
| 3183 | - } |
| 3184 | - |
| 3185 | - if (is_button) |
| 3186 | - { |
| 3187 | - GtkWidget *item, *image; |
| 3188 | - |
| 3189 | - item = gtk_image_menu_item_new_with_mnemonic (N_("Remove All _Buttons")); |
| 3190 | - |
| 3191 | - image = gtk_image_new_from_stock (GTK_STOCK_ADD, GTK_ICON_SIZE_MENU); |
| 3192 | - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image); |
| 3193 | - |
| 3194 | - g_signal_connect_swapped (item, "activate", G_CALLBACK (xpad_toolbar_remove_all_buttons), NULL); |
| 3195 | - |
| 3196 | - gtk_menu_attach (GTK_MENU (menu), item, 0, 1, i, i + 1); |
| 3197 | - gtk_widget_show (item); |
| 3198 | - |
| 3199 | - i++; |
| 3200 | - |
| 3201 | - item = gtk_image_menu_item_new_with_mnemonic (N_("Remo_ve Last Button")); |
| 3202 | - |
| 3203 | - image = gtk_image_new_from_stock (GTK_STOCK_ADD, GTK_ICON_SIZE_MENU); |
| 3204 | - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image); |
| 3205 | - |
| 3206 | - g_signal_connect_swapped (item, "activate", G_CALLBACK (xpad_toolbar_remove_last_button), NULL); |
| 3207 | - |
| 3208 | - gtk_menu_attach (GTK_MENU (menu), item, 0, 1, i, i + 1); |
| 3209 | - gtk_widget_show (item); |
| 3210 | - } |
| 3211 | - |
| 3212 | - g_signal_connect (menu, "deactivate", G_CALLBACK (menu_deactivated), toolbar); |
| 3213 | - |
| 3214 | - gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, (button < 0) ? 0 : button, gtk_get_current_event_time ()); |
| 3215 | - |
| 3216 | - g_signal_emit (toolbar, signals[POPUP], 0, menu); |
| 3217 | - |
| 3218 | - return TRUE; |
| 3219 | -} |
| 3220 | - |
| 3221 | -static void |
| 3222 | -xpad_toolbar_enable_button (XpadToolbar *toolbar, const XpadToolbarButton *button, gboolean enable) |
| 3223 | -{ |
| 3224 | - g_return_if_fail (button); |
| 3225 | - GtkToolItem *item = xpad_toolbar_button_to_item (toolbar, button); |
| 3226 | - if (item) |
| 3227 | - gtk_widget_set_sensitive (GTK_WIDGET (item), enable); |
| 3228 | -} |
| 3229 | - |
| 3230 | -void |
| 3231 | -xpad_toolbar_enable_undo_button (XpadToolbar *toolbar, gboolean enable) |
| 3232 | -{ |
| 3233 | - const XpadToolbarButton *button = xpad_toolbar_button_lookup (toolbar, "Undo"); |
| 3234 | - xpad_toolbar_enable_button (toolbar, button, enable); |
| 3235 | -} |
| 3236 | - |
| 3237 | -void |
| 3238 | -xpad_toolbar_enable_redo_button (XpadToolbar *toolbar, gboolean enable) |
| 3239 | -{ |
| 3240 | - const XpadToolbarButton *button = xpad_toolbar_button_lookup (toolbar, "Redo"); |
| 3241 | - xpad_toolbar_enable_button (toolbar, button, enable); |
| 3242 | -} |
| 3243 | - |
| 3244 | -void |
| 3245 | -xpad_toolbar_enable_cut_button (XpadToolbar *toolbar, gboolean enable) |
| 3246 | -{ |
| 3247 | - const XpadToolbarButton *button = xpad_toolbar_button_lookup (toolbar, "Cut"); |
| 3248 | - xpad_toolbar_enable_button (toolbar, button, enable); |
| 3249 | -} |
| 3250 | - |
| 3251 | -void |
| 3252 | -xpad_toolbar_enable_copy_button (XpadToolbar *toolbar, gboolean enable) |
| 3253 | -{ |
| 3254 | - const XpadToolbarButton *button = xpad_toolbar_button_lookup (toolbar, "Copy"); |
| 3255 | - xpad_toolbar_enable_button (toolbar, button, enable); |
| 3256 | -} |
| 3257 | - |
| 3258 | -void |
| 3259 | -xpad_toolbar_enable_paste_button (XpadToolbar *toolbar, gboolean enable) |
| 3260 | -{ |
| 3261 | - const XpadToolbarButton *button = xpad_toolbar_button_lookup (toolbar, "Paste"); |
| 3262 | - xpad_toolbar_enable_button (toolbar, button, enable); |
| 3263 | -} |
| 3264 | - |
| 3265 | +*/ |
| 3266 | |
| 3267 | === modified file 'src/xpad-tray.c' |
| 3268 | --- src/xpad-tray.c 2013-10-09 14:46:10 +0000 |
| 3269 | +++ src/xpad-tray.c 2013-10-18 18:35:35 +0000 |
| 3270 | @@ -33,17 +33,19 @@ |
| 3271 | static void xpad_tray_popup_menu_cb (GtkStatusIcon *icon, guint button, guint time); |
| 3272 | |
| 3273 | static GtkStatusIcon *docklet = NULL; |
| 3274 | +static GtkWidget *menu = NULL; |
| 3275 | |
| 3276 | void |
| 3277 | xpad_tray_open (void) |
| 3278 | { |
| 3279 | GtkIconTheme *theme; |
| 3280 | - |
| 3281 | - xpad_tray_close (); |
| 3282 | + |
| 3283 | + // xpad_tray_close (); |
| 3284 | |
| 3285 | theme = gtk_icon_theme_get_default (); |
| 3286 | - if (!gtk_icon_theme_has_icon (theme, PACKAGE)) |
| 3287 | + if (!gtk_icon_theme_has_icon (theme, PACKAGE)) { |
| 3288 | return; |
| 3289 | + } |
| 3290 | |
| 3291 | if (gtk_icon_theme_has_icon (theme, "xpad-panel")) |
| 3292 | { |
| 3293 | @@ -68,6 +70,9 @@ |
| 3294 | g_object_unref (docklet); |
| 3295 | docklet = NULL; |
| 3296 | } |
| 3297 | + |
| 3298 | + if (menu) |
| 3299 | + gtk_widget_destroy(menu); |
| 3300 | } |
| 3301 | |
| 3302 | gboolean |
| 3303 | @@ -111,7 +116,7 @@ |
| 3304 | static void |
| 3305 | xpad_tray_popup_menu_cb (GtkStatusIcon *icon, guint button, guint time) |
| 3306 | { |
| 3307 | - GtkWidget *menu, *item; |
| 3308 | + GtkWidget *item; |
| 3309 | GSList *pads, *l; |
| 3310 | gint n; |
| 3311 | |
| 3312 | @@ -126,7 +131,7 @@ |
| 3313 | item = gtk_separator_menu_item_new (); |
| 3314 | gtk_container_add (GTK_CONTAINER (menu), item); |
| 3315 | gtk_widget_show (item); |
| 3316 | - |
| 3317 | + |
| 3318 | item = gtk_menu_item_new_with_mnemonic (_("_Show All")); |
| 3319 | g_signal_connect_swapped (item, "activate", G_CALLBACK (menu_show_all), xpad_app_get_pad_group ()); |
| 3320 | gtk_container_add (GTK_CONTAINER (menu), item); |
| 3321 | @@ -202,4 +207,3 @@ |
| 3322 | g_slist_foreach (pads, (GFunc) gtk_window_present, NULL); |
| 3323 | g_slist_free (pads); |
| 3324 | } |
| 3325 | - |
| 3326 | |
| 3327 | === modified file 'src/xpad-undo.c' |
| 3328 | --- src/xpad-undo.c 2013-10-09 04:24:36 +0000 |
| 3329 | +++ src/xpad-undo.c 2013-10-18 18:35:35 +0000 |
| 3330 | @@ -26,8 +26,18 @@ |
| 3331 | #include "xpad-undo.h" |
| 3332 | #include "xpad-text-buffer.h" |
| 3333 | |
| 3334 | -G_DEFINE_TYPE(XpadUndo, xpad_undo, G_TYPE_OBJECT) |
| 3335 | -#define XPAD_UNDO_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), XPAD_TYPE_UNDO, XpadUndoPrivate)) |
| 3336 | +struct XpadUndoPrivate |
| 3337 | +{ |
| 3338 | + XpadTextBuffer *buffer; |
| 3339 | + /* We always redo the next element in the list but undo the current one. |
| 3340 | + We insert this guard with NULL data in the beginning to ease coding all of this */ |
| 3341 | + GList *history_start; |
| 3342 | + GList *history_curr; |
| 3343 | + guint user_action; |
| 3344 | + gboolean frozen; |
| 3345 | +}; |
| 3346 | + |
| 3347 | +G_DEFINE_TYPE_WITH_PRIVATE(XpadUndo, xpad_undo, G_TYPE_OBJECT) |
| 3348 | |
| 3349 | static GObject* xpad_undo_constructor(GType gtype, guint n_properties, GObjectConstructParam *properties); |
| 3350 | static void xpad_undo_dispose (GObject *object); |
| 3351 | @@ -62,18 +72,6 @@ |
| 3352 | static void xpad_undo_insert_text (GtkTextBuffer *buffer, GtkTextIter *location, gchar *text, gint len, XpadUndo *undo); |
| 3353 | static void xpad_undo_delete_range (GtkTextBuffer *buffer, GtkTextIter *start, GtkTextIter *end, XpadUndo *undo); |
| 3354 | |
| 3355 | -struct XpadUndoPrivate |
| 3356 | -{ |
| 3357 | - XpadTextBuffer *buffer; |
| 3358 | - XpadPad *pad; |
| 3359 | - /* We always redo the next element in the list but undo the current one. |
| 3360 | - We insert this guard with NULL data in the beginning to ease coding all of this */ |
| 3361 | - GList *history_start; |
| 3362 | - GList *history_curr; |
| 3363 | - guint user_action; |
| 3364 | - gboolean frozen; |
| 3365 | -}; |
| 3366 | - |
| 3367 | enum |
| 3368 | { |
| 3369 | PROP_0, |
| 3370 | @@ -92,8 +90,6 @@ |
| 3371 | { |
| 3372 | GObjectClass *gobject_class = G_OBJECT_CLASS (klass); |
| 3373 | |
| 3374 | - /* TODO: neither dispose nor finalize neither in here nor in xpad-pad.c are |
| 3375 | - actually called, have to fix cleaning up */ |
| 3376 | gobject_class->dispose = xpad_undo_dispose; |
| 3377 | gobject_class->finalize = xpad_undo_finalize; |
| 3378 | gobject_class->set_property = xpad_undo_set_property; |
| 3379 | @@ -106,18 +102,14 @@ |
| 3380 | "Pad Buffer", |
| 3381 | "Pad buffer connected to this undo", |
| 3382 | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY)); |
| 3383 | - |
| 3384 | - g_type_class_add_private (gobject_class, sizeof (XpadUndoPrivate)); |
| 3385 | } |
| 3386 | |
| 3387 | - |
| 3388 | static void |
| 3389 | xpad_undo_init (XpadUndo *undo) |
| 3390 | { |
| 3391 | - undo->priv = XPAD_UNDO_GET_PRIVATE (undo); |
| 3392 | + undo->priv = xpad_undo_get_instance_private(undo); |
| 3393 | |
| 3394 | undo->priv->buffer = NULL; |
| 3395 | - undo->priv->buffer = NULL; |
| 3396 | undo->priv->history_start = g_list_append (NULL, NULL); |
| 3397 | undo->priv->history_curr = undo->priv->history_start; |
| 3398 | undo->priv->user_action = 0; |
| 3399 | @@ -133,7 +125,7 @@ |
| 3400 | XpadUndo *undo = XPAD_UNDO (obj); |
| 3401 | |
| 3402 | /* Assert user passed buffer and pad as construct parameter */ |
| 3403 | - gint i; |
| 3404 | + guint i; |
| 3405 | gboolean found_buffer = FALSE; |
| 3406 | for (i = 0; i < n_properties; i++) |
| 3407 | { |
| 3408 | @@ -148,7 +140,6 @@ |
| 3409 | if (!found_buffer) |
| 3410 | { |
| 3411 | undo->priv->buffer = NULL; |
| 3412 | - undo->priv->buffer = NULL; |
| 3413 | g_warning ("XpadTextBuffer is not passed to XpadUndo constructor, undo will not work!\n"); |
| 3414 | } |
| 3415 | else |
| 3416 | @@ -168,9 +159,7 @@ |
| 3417 | { |
| 3418 | XpadUndo *undo = XPAD_UNDO (object); |
| 3419 | |
| 3420 | - if (undo->priv->buffer && G_IS_OBJECT (undo->priv->buffer)) |
| 3421 | - { |
| 3422 | - g_object_unref (undo->priv->buffer); |
| 3423 | + if (undo->priv->buffer) { |
| 3424 | undo->priv->buffer = NULL; |
| 3425 | } |
| 3426 | |
| 3427 | @@ -186,7 +175,7 @@ |
| 3428 | xpad_undo_clear_history (undo); |
| 3429 | |
| 3430 | /* remove left guard */ |
| 3431 | - g_list_free (undo->priv->history_start); |
| 3432 | + g_list_free(undo->priv->history_start); |
| 3433 | |
| 3434 | G_OBJECT_CLASS (xpad_undo_parent_class)->finalize (object); |
| 3435 | } |
| 3436 | @@ -595,4 +584,3 @@ |
| 3437 | { |
| 3438 | undo->priv->frozen = FALSE; |
| 3439 | } |
| 3440 | - |
