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

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
Reviewer Review Type Date Requested Status
Arthur Borsboom Approve
Review via email: mp+191858@code.launchpad.net

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
=== modified file 'ChangeLog'
--- ChangeLog 2013-10-09 04:26:23 +0000
+++ ChangeLog 2013-10-18 18:35:35 +0000
@@ -1,16 +1,448 @@
1Changes in v4.2 - Arthur Borsboom <arthurborsboom@gmail.com>1Version 4.1
22* New: Undo functionality such as CTRL-Z (#1121740)
3- New: Undo functionality such as CTRL-Z (#1121740)3* New: Tray click behaviour can now be configured (#345278, #304331, #890335)
4- New: Tray click behaviour can now be configured (#345278, #304331, #890335)4* New: Tray icon can be hidden (#890334)
5- New: Tray icon can be hidden (#890334)5* New: Theme builders can now use seperate tray icon by adding xpad-panel.xvg (#907705)
6- New: Theme builders can now use seperate tray icon by adding xpad-panel.xvg (#907705)6* Fix: Theme color stays after application restart (#307669)
7- Fix: Theme color stays after application restart (#307669)7* Fix: Translation - get many new translations in from translators (thanks guys!!)
8- Fix: Translation - get many new translations in from translators (thanks guys!!)8* Fix: Translation - French typo (#1216388)
9- Fix: Translation - French typo (#1216388)9* Fix: Translation - Russian typo which prevented the Help from working (#973825)
10- Fix: Translation - Russian typo which prevented the Help from working (#973825)10* Fix: added missing configure script (#890492)
11- Fix: added missing configure script (#890492)11* Fix: performance improvement by reducing the amount of harddisk writes (#1072698, #1207564, #782320)
12- Fix: performance improvement by reducing the amount of harddisk writes (#1072698, #1207564, #782320)12* Fix: can now compile against glib-2.34.1 (#974011)
13- Fix: can now compile against glib-2.34.1 (#974011)13* Fix: no errors or crashes after a delete of a pad (#1237211, #1237563)
14* Fix: different memory leaks (#1237211, #1237563)
15
16Version 4.1
17* Undo/Redo for xpad and bug-fixes. Feature by Sergei Riaguzov
18* Bug #490445: crash when right-clicking on tray icon to display list of notes. Patch by David Hull
19* Bug #360142: Add keyboard shortcuts for formatting. Patch by Dennis Hilmar
20* Bug #591978: xpad critical start. Patch by OBATA Akio
21
22
23Version 4.0
24* Added --toggle (between --hide and --show). Patch by Paul Ivanov.
25* Updated French, Japanese, Russian, Spanish, and Swedish translations
26* New Croatian, Estonian, German, Portuguese, Thai, and Turkish translations
27
28
29Version 3.1
30* Updated Danish, French, Russian, Spanish, and Swedish translations
31* New Czech, Japanese, and Latvian translations
32
33
34Version 3.0
35* Don't wake up every 20 milliseconds to check session management messages.
36 Rather, wait for an event.
37* Add --hide/--show, removed --hide-old. --hide and --show affect all pads
38 on startup or can be used on an already running xpad instance. Patch by
39 Jan Losinski.
40* Update icon to be less aliased
41* Relicense as GPL v3+
42
43
44Version 2.14
45* Fix 100% CPU bug
46
47
48Version 2.13
49* Requires GTK+ 2.12
50* Fix pads possibly not remembering location after close
51* Fix pad-closed state not being remembered
52* Uses native status icon code in GTK+
53* Maybe, possibly fix some 'pad on all workspaces' problems
54* New Chinese (simplified) translation (Meng Jie)
55* New English (British) translation (David Lodge)
56* New Finnish translation (Jorma Karvonen)
57* New Korean translation (KwangSub Lee)
58* Updated Dutch translation (Benno Schulenberg)
59* Updated Slovak translation (Andrej Kacian)
60* Fixed Danish, Swedish translations
61
62
63Version 2.12
64* Fix a crash when loading pads with formatting
65
66
67Version 2.11
68* If window decorations are turned on, pads will now show up in the taskbar
69* Added -f option to open a file as a note
70* New Chinese (simplified) translation (Meng Jie)
71* New Danish translation (Morten Bo Johansen)
72* New Swedish translation (Daniel Nylander)
73* Updated Chinese (traditional) translation (Wei-Lun Chao)
74
75
76Version 2.10
77* Fix a possible crash when deleting pads with autohide toolbar
78* Make toolbar buttons smaller
79* Make toolbar appear inside pad if there is enough unused space
80* New Slovak translation (Andrej Kacian)
81* New Slovenian translation (Matej Urbančič)
82
83
84Version 2.9
85* Fix pads saving slightly off bad x,y values
86* Fix pads saving bad heights when toolbar always on (Sham Chukoury)
87* Fix possible crash from not allocating enough memory (Federico Schwindt)
88* New Malay translation (Sharuzzaman Ahmat Raslan)
89
90
91Version 2.8
92* Allow translations to be used (broken for a couple versions)
93* New Chinese (traditional) translation (Wei-Lun Chao)
94* Removed half-baked Esperanto translation
95
96
97Version 2.7
98* Stop pads from popping toolbar while the pad is moving/resizing
99* Make sure pads use correct sizes when autohide is off (Sham Chukoury)
100* New Bulgarian translation (Yavor Doganov)
101* New Kinyarwanda translation (Steve Murphy et al)
102
103
104Version 2.6
105* Stop pad windows from 'jumping' when dragged via the toolbar
106* Updated Hungarian translation (Németh Csaba)
107* Updated Irish translation (Kevin Patrick Scannell)
108* Updated Vietnamese translation (Clytie Siddall)
109
110
111Version 2.5
112* Stop making all new pads start in top left
113* Stop closing xpad if toggling window decorations with only one pad open
114* Stop losing pad contents if upgrading from old versions of xpad
115
116
117Version 2.4
118* Create the configuration directory if it doesn't exist
119
120
121Version 2.3
122* Fixed a compile bug with binreloc and threading
123
124
125Version 2.2
126* Bumped GTK+ dependency to 2.6
127* New About dialog (using GtkAboutDialog)
128* New default location for configuration files: ~/.config/xpad
129* Updated icon (now uses lighter colors)
130* Use GOption for command-line parsing
131* New command-line option --hide-old (or -H) to not show old pads
132* Renamed command-line option --nonew to --no-new and added -N shortcut
133* Allow running from console if we don't need to do anything graphical
134* Readded keyboard shortcuts
135* Updated antiquated man page
136* New Hungarian translation (Németh Csaba)
137* New Vietnamese translation (Clytie Siddall)
138* Updated Irish translation (Kevin Patrick Scannell)
139
140
141Version 2.1
142* Fix tray icon being the wrong size
143* Fix xpad to close when no tray and no open pads
144
145
146Version 2.0
147* Fix notes list to display correct number of pads
148* Fix notification icon from not doing anything
149* Fix compilation when BinReloc is disabled
150* Fix compilation with gcc 3.4
151* Fix endianness issue with preference files
152* Updated Dutch translation (Elros Cyriatan)
153
154
155Version 2.0-b3
156* Use BinReloc to allow any-prefix installs of xpad to work
157* Fixed a double-free bug that caused some problems with new pads
158* Updated Irish translation (Kevin Patrick Scannell)
159* Updated Spanish translation (Ramon Rey Vicente)
160
161
162Version 2.0-b2
163* Redesigned preferences and pad properties dialogs
164* If the tray disappears (e.g. killall gnome-panel), xpad's icon reappears
165* More formally ask window manager to make us skip taskbar and pager
166* New, lighter default color for pads
167* Lots of internal code cleanup
168* Fixed a crasher with not being able to find window icons
169* Fixed some crashers with turning off toolbar
170* Fixed bug with text cursor color being one color change behind
171
172
173Version 2.0-b1
174* The text cursor is now always the same color as the text color
175* Formatting can now be applied to selected text
176* Pads remember their hidden state
177* Rewritten toolbar, allowing easier adding/removing/moving buttons
178* Simplified preferences dialog; many functions are now accessed from popup menu
179* --new now also loads the old pads, instead of the previous broken behavior
180* Fixed bug with pads over the 9th not having numbers in note lists
181* Fixed bug with inter process communicating causing only first communication to work
182* Fixed bug with pads becoming unstyled after closing and reopening
183* New Afrikaans translation (Petri Jooste)
184* New French translation (Michel Robitaille)
185
186
187Version 1.13
188* Don't close xpad if no pads are open but the system tray is
189* Made translations work again
190* New Spanish translation (Ramon Rey Vicente)
191* Updated Dutch translation (Elros Cyriatan)
192* Updated Irish translation (Kevin Patrick Scannell)
193
194
195Version 1.12
196* Fixed segfault when clicking on auto-hide toolbar preference
197* Fixed segfault when changing the first toolbar button
198* Added Irish translation (by Kevin Patrick Scannell)
199
200
201Version 1.11
202* Added Dutch translation (by t.c.witte@phys.uu.nl)
203* Added partial Esperanto translation (by mterry@fastmail.fm)
204* Added Romanian translation (by eugenh@urban-grafx.ro)
205* Added Russian translation (by avl@cad.ru)
206* Added missing "include <sys/time.h>" (by netgeek@speakeasy.net)
207* Added missing #defines for solaris (by alan@cesma.usb.ve)
208* Added new icon and install icon family into new location per icon theme spec
209* Fixed disk-full-causes-xpad-contents-to-disappear bug
210* Made pads not show up in taskbar
211* Added 'pads start sticky' option
212
213
214Version 1.10.1
215* Fixed some compile-time issues, particularly with GTK+ 2.0
216
217
218Version 1.10
219* Rewrote applet popup menu to be more consistent and hopefully useful
220* Fixed crash when closing a pad that had provided text in a cut/paste
221* Normalize pad dimensions when opening in case the values got messed up
222* Misc. small bugs
223
224
225Version 1.9.1
226* Fix a segfault when show all is selected after a new pad is made
227
228
229Version 1.9
230* Now use automake/autoconf, which allows for more complete build control
231* Now use gettext, allowing easy translation of xpad
232* Now auto-apply any pad changes to hard drive, making xpad a tad more
233 reliable
234* Now can easily change settings for only one pad
235* A little more sane title generation -- now just uses first line
236* X session management support
237*
238* Popup menu is decluttered and altered, with the HIG in mind
239* Fixed crash on exit if we didn't init docklet
240* Fixed new pads randomly starting up as white background
241* Cut/copy/paste are now unsensitive if no content to copy or paste
242* Pads now play nice with the X clipboard (middle mouse button)
243* Fixed a bug with the notification area applet
244* Fixed misc. small bugs
245
246
247Version 1.8
248* Allow using system text color, background color, and font
249* Eggtray now appears, allowing users to hide all pads (thanks
250 jgb3@email.byu.edu)
251* Now we compile using autoconf
252*
253* Xpad won't take 100% cpu sometimes when idle
254* Fixed bug that screwed up last toolbar button's toggle setting
255* Fixed toolbar hiding when you right click on another pad
256* Fixed style locking and sticky status changing on menu popup
257* No deletion confirmation if pad is only whitespace
258
259
260Version 1.7
261* Popup alerts are more pleasing. (HIG compliant)
262* Added --nonew flag to prevent creation of new pads.
263* Changed --new flag to only open a new pad, not try to open old pads too.
264* Changed window titles from quoted to ellipses at the end.
265* Option to turn off toolbar auto-hide.
266* Added --list, -l, --show, -s.
267
268
269Version 1.6.1
270* Fix segfault on startup if toolbar is disabled.
271
272
273Version 1.6
274* Rearrange popup menu
275* More meaningful window titles
276* Add popup menu submenu that allows you to choose window to show
277* Allow reopening of closed pads
278* The return of cut/copy/paste
279* Native sticky support
280* Add a show all command -- via command line or menu
281* Allow turning off of scrollbars
282* Allow reshowing of closed pads (without restarting xpad)
283*
284* Stopped style lock from turning on accidentally
285* Properly handle WM closures
286* Better HIG-style support of keyboard accelerators
287
288
289Version 1.5.1
290* Fix a possible segfault on startup
291
292
293Version 1.5
294* Fixed a bug that stopped saving of defaults on shutdown
295* Better error reporting
296* Added a toolbar with customizable buttons
297* Added some new command line options
298* Allow style locking
299* Allow pad clearing
300* Added all new preference help window
301
302
303Version 1.4
304* Code cleanup
305* We now compile clean with -ansi and -pedantic! ;)
306* Should take up a little less memory
307* Fixed several memory leaks
308* Should be able to compile on windows and beos.
309 -- PLEASE let me know how this works for you.
310* Added scrollbars if window isn't big enough to handle text
311 -- this fixes two known bugs
312* New xpad processes now handled gracefully
313* Added further optimizations to compilation
314 -- let me know if this causes you problems
315* Fixed some possible buffer overflows
316* Fixed some warnings/errors on gcc3 compilation
317* Cursor icon changes when edit lock is on
318
319
320Version 1.3
321* Added a padding option (thanks Nagy Mate)
322* Redesigned dialogs
323* Preferences now auto-apply
324* You can now choose what the wm close button does, defaults to close
325* Pads have individual titles now
326* Xpad gets along better with various wm's now
327* Cursor no longer blinks if you can't edit pad
328* Fixed double-clicking-doesn't-select-text-when-edit-lock-is-on bug
329* Pads can no longer be individually closed (unless wm decor is on)
330
331
332Version 1.2.1
333* Fixed segfault on startup if no ~/.xpad directory, plus some related bugs
334
335
336Version 1.2
337* Fixed an issue causing black on black with big-endian architectures
338* Added "Edit Lock" mode
339* General code cleanup
340
341
342Version 1.1
343* Simplified popup menu (removed GTK+ default cut/copy/paste/input
344 method/insert). If you used them, and miss them, let me know.
345* Added keyboard shortcuts for most menu items
346* Expanded help dialog to include shortcuts
347* Allow border left-drags, right-drags, and right clicks
348
349
350Version 1.0.2
351* Stopped pads from losing their place on x shut down
352
353
354Version 1.0.1
355* Fixed a possible runtime warning with autosaving
356* Made window icon code more robust
357* Added icons for all menu items
358
359
360Version 1.0
361* Added an open file dialog
362* Added a save as dialog
363* Closed pads are handled more consistently
364* Unified color/font change screens
365* Fixed font not being saved correctly
366* Added ability to fine tune default pad settings, including size (before
367 this was all handled transparently, but size was not always updated)
368* Added optional confirmation to pad destroys
369* Window decorations can now be turned on (in global pref screen)
370* Added border color and border width options
371* Added gui for sync time (autosaving) control
372* Took out --sync-time and -s (you can do same thing with above gui)
373* Stopped new pads always being placed in same spot
374* Added help screen, which opens when you click on "help" from right-click
375 menu and on first run
376* Much cleaner internal api
377* Made xpad more theme-friendly
378* Resizing/moving now works even if numpad is on
379* Xpad 1.0 can now open much older versions of xpad's files (tested to 0.2.1)
380* Added app icon (thanks nestor di)
381
382
383Version 0.2.5
384* Added --help
385* Added short forms of arguments (e.g. -h, -v, -V, -s)
386* Added more output messages
387* Stopped pad raising above popup on right click
388* Fixed bug where old pads wouldn't open upon startup
389* No size limit on pads
390
391
392Version 0.2.4
393* Fixed small memory leak if no default-style file
394* Pads rise to foreground if clicked on now
395* Added "close all" option on popup
396* Prints out a message when autosaving
397* Added --verbosity= option. (0 is default - no messages; 1 is
398 moderate - important things like autosaving; 2 is debug -
399 more info than necessary)
400* Removed some possible buffer overflows if text is too large (a hardcoded
401 limit of 20k chars now)
402* Misc. code cleanups
403
404
405Version 0.2.3.1
406* Fixed nasty bug where, if you didn't have a working ~/.xpad/default-styles
407 file, it would seg-fault. my bad
408
409
410Version 0.2.3
411* Perfected (?) syncing. Now will recover cleanly from anything -- including
412 power shut off or random interrupts. This fixes the "pad contents
413 disappearing on X-shutdown" bug
414* Moved menu items around a bit
415* Remembers preferred size (only if you change fonts/colors. on TODO)
416* Not always centered now
417
418
419Version 0.2.2
420* Debian-friendly Makefile fixes
421* Cleaned up code
422
423
424Version 0.2.1
425* Changed saving to be more fault-tolerant
426* Added about screen with version info
427
428
429Version 0.2
430* Ported to gtk+-2.0
431* Now can change font color
432* If xpad is already running, will open new pad, not open old pads again
433* In-xpad moving and resizing now works
434* Xpad now recovers better from being interrupted
435* Remembers your preferred style
436* Many small bugfixes
437* Code reorganization
438
439
440Version 0.1.9.2
441* Cleaner lack of decorations
442* Fixed "double-click on menu" bug
443* Fixed segfault when only a font size change was requested
444* Added close and destroy items to menu. Now you can close a window without
445 losing content
14446
152004-09-29 Jeroen T. Vermeulen <jtv@xs4all.nl>4472004-09-29 Jeroen T. Vermeulen <jtv@xs4all.nl>
16448
17449
=== removed file 'NEWS'
--- NEWS 2011-11-14 17:10:03 +0000
+++ NEWS 1970-01-01 00:00:00 +0000
@@ -1,430 +0,0 @@
1Version 4.1
2* Undo/Redo for xpad and bug-fixes. Feature by Sergei Riaguzov
3* Bug #490445: crash when right-clicking on tray icon to display list of notes. Patch by David Hull
4* Bug #360142: Add keyboard shortcuts for formatting. Patch by Dennis Hilmar
5* Bug #591978: xpad critical start. Patch by OBATA Akio
6
7
8Version 4.0
9* Added --toggle (between --hide and --show). Patch by Paul Ivanov.
10* Updated French, Japanese, Russian, Spanish, and Swedish translations
11* New Croatian, Estonian, German, Portuguese, Thai, and Turkish translations
12
13
14Version 3.1
15* Updated Danish, French, Russian, Spanish, and Swedish translations
16* New Czech, Japanese, and Latvian translations
17
18
19Version 3.0
20* Don't wake up every 20 milliseconds to check session management messages.
21 Rather, wait for an event.
22* Add --hide/--show, removed --hide-old. --hide and --show affect all pads
23 on startup or can be used on an already running xpad instance. Patch by
24 Jan Losinski.
25* Update icon to be less aliased
26* Relicense as GPL v3+
27
28
29Version 2.14
30* Fix 100% CPU bug
31
32
33Version 2.13
34* Requires GTK+ 2.12
35* Fix pads possibly not remembering location after close
36* Fix pad-closed state not being remembered
37* Uses native status icon code in GTK+
38* Maybe, possibly fix some 'pad on all workspaces' problems
39* New Chinese (simplified) translation (Meng Jie)
40* New English (British) translation (David Lodge)
41* New Finnish translation (Jorma Karvonen)
42* New Korean translation (KwangSub Lee)
43* Updated Dutch translation (Benno Schulenberg)
44* Updated Slovak translation (Andrej Kacian)
45* Fixed Danish, Swedish translations
46
47
48Version 2.12
49* Fix a crash when loading pads with formatting
50
51
52Version 2.11
53* If window decorations are turned on, pads will now show up in the taskbar
54* Added -f option to open a file as a note
55* New Chinese (simplified) translation (Meng Jie)
56* New Danish translation (Morten Bo Johansen)
57* New Swedish translation (Daniel Nylander)
58* Updated Chinese (traditional) translation (Wei-Lun Chao)
59
60
61Version 2.10
62* Fix a possible crash when deleting pads with autohide toolbar
63* Make toolbar buttons smaller
64* Make toolbar appear inside pad if there is enough unused space
65* New Slovak translation (Andrej Kacian)
66* New Slovenian translation (Matej Urbančič)
67
68
69Version 2.9
70* Fix pads saving slightly off bad x,y values
71* Fix pads saving bad heights when toolbar always on (Sham Chukoury)
72* Fix possible crash from not allocating enough memory (Federico Schwindt)
73* New Malay translation (Sharuzzaman Ahmat Raslan)
74
75
76Version 2.8
77* Allow translations to be used (broken for a couple versions)
78* New Chinese (traditional) translation (Wei-Lun Chao)
79* Removed half-baked Esperanto translation
80
81
82Version 2.7
83* Stop pads from popping toolbar while the pad is moving/resizing
84* Make sure pads use correct sizes when autohide is off (Sham Chukoury)
85* New Bulgarian translation (Yavor Doganov)
86* New Kinyarwanda translation (Steve Murphy et al)
87
88
89Version 2.6
90* Stop pad windows from 'jumping' when dragged via the toolbar
91* Updated Hungarian translation (Németh Csaba)
92* Updated Irish translation (Kevin Patrick Scannell)
93* Updated Vietnamese translation (Clytie Siddall)
94
95
96Version 2.5
97* Stop making all new pads start in top left
98* Stop closing xpad if toggling window decorations with only one pad open
99* Stop losing pad contents if upgrading from old versions of xpad
100
101
102Version 2.4
103* Create the configuration directory if it doesn't exist
104
105
106Version 2.3
107* Fixed a compile bug with binreloc and threading
108
109
110Version 2.2
111* Bumped GTK+ dependency to 2.6
112* New About dialog (using GtkAboutDialog)
113* New default location for configuration files: ~/.config/xpad
114* Updated icon (now uses lighter colors)
115* Use GOption for command-line parsing
116* New command-line option --hide-old (or -H) to not show old pads
117* Renamed command-line option --nonew to --no-new and added -N shortcut
118* Allow running from console if we don't need to do anything graphical
119* Readded keyboard shortcuts
120* Updated antiquated man page
121* New Hungarian translation (Németh Csaba)
122* New Vietnamese translation (Clytie Siddall)
123* Updated Irish translation (Kevin Patrick Scannell)
124
125
126Version 2.1
127* Fix tray icon being the wrong size
128* Fix xpad to close when no tray and no open pads
129
130
131Version 2.0
132* Fix notes list to display correct number of pads
133* Fix notification icon from not doing anything
134* Fix compilation when BinReloc is disabled
135* Fix compilation with gcc 3.4
136* Fix endianness issue with preference files
137* Updated Dutch translation (Elros Cyriatan)
138
139
140Version 2.0-b3
141* Use BinReloc to allow any-prefix installs of xpad to work
142* Fixed a double-free bug that caused some problems with new pads
143* Updated Irish translation (Kevin Patrick Scannell)
144* Updated Spanish translation (Ramon Rey Vicente)
145
146
147Version 2.0-b2
148* Redesigned preferences and pad properties dialogs
149* If the tray disappears (e.g. killall gnome-panel), xpad's icon reappears
150* More formally ask window manager to make us skip taskbar and pager
151* New, lighter default color for pads
152* Lots of internal code cleanup
153* Fixed a crasher with not being able to find window icons
154* Fixed some crashers with turning off toolbar
155* Fixed bug with text cursor color being one color change behind
156
157
158Version 2.0-b1
159* The text cursor is now always the same color as the text color
160* Formatting can now be applied to selected text
161* Pads remember their hidden state
162* Rewritten toolbar, allowing easier adding/removing/moving buttons
163* Simplified preferences dialog; many functions are now accessed from popup menu
164* --new now also loads the old pads, instead of the previous broken behavior
165* Fixed bug with pads over the 9th not having numbers in note lists
166* Fixed bug with inter process communicating causing only first communication to work
167* Fixed bug with pads becoming unstyled after closing and reopening
168* New Afrikaans translation (Petri Jooste)
169* New French translation (Michel Robitaille)
170
171
172Version 1.13
173* Don't close xpad if no pads are open but the system tray is
174* Made translations work again
175* New Spanish translation (Ramon Rey Vicente)
176* Updated Dutch translation (Elros Cyriatan)
177* Updated Irish translation (Kevin Patrick Scannell)
178
179
180Version 1.12
181* Fixed segfault when clicking on auto-hide toolbar preference
182* Fixed segfault when changing the first toolbar button
183* Added Irish translation (by Kevin Patrick Scannell)
184
185
186Version 1.11
187* Added Dutch translation (by t.c.witte@phys.uu.nl)
188* Added partial Esperanto translation (by mterry@fastmail.fm)
189* Added Romanian translation (by eugenh@urban-grafx.ro)
190* Added Russian translation (by avl@cad.ru)
191* Added missing "include <sys/time.h>" (by netgeek@speakeasy.net)
192* Added missing #defines for solaris (by alan@cesma.usb.ve)
193* Added new icon and install icon family into new location per icon theme spec
194* Fixed disk-full-causes-xpad-contents-to-disappear bug
195* Made pads not show up in taskbar
196* Added 'pads start sticky' option
197
198
199Version 1.10.1
200* Fixed some compile-time issues, particularly with GTK+ 2.0
201
202
203Version 1.10
204* Rewrote applet popup menu to be more consistent and hopefully useful
205* Fixed crash when closing a pad that had provided text in a cut/paste
206* Normalize pad dimensions when opening in case the values got messed up
207* Misc. small bugs
208
209
210Version 1.9.1
211* Fix a segfault when show all is selected after a new pad is made
212
213
214Version 1.9
215* Now use automake/autoconf, which allows for more complete build control
216* Now use gettext, allowing easy translation of xpad
217* Now auto-apply any pad changes to hard drive, making xpad a tad more
218 reliable
219* Now can easily change settings for only one pad
220* A little more sane title generation -- now just uses first line
221* X session management support
222*
223* Popup menu is decluttered and altered, with the HIG in mind
224* Fixed crash on exit if we didn't init docklet
225* Fixed new pads randomly starting up as white background
226* Cut/copy/paste are now unsensitive if no content to copy or paste
227* Pads now play nice with the X clipboard (middle mouse button)
228* Fixed a bug with the notification area applet
229* Fixed misc. small bugs
230
231
232Version 1.8
233* Allow using system text color, background color, and font
234* Eggtray now appears, allowing users to hide all pads (thanks
235 jgb3@email.byu.edu)
236* Now we compile using autoconf
237*
238* Xpad won't take 100% cpu sometimes when idle
239* Fixed bug that screwed up last toolbar button's toggle setting
240* Fixed toolbar hiding when you right click on another pad
241* Fixed style locking and sticky status changing on menu popup
242* No deletion confirmation if pad is only whitespace
243
244
245Version 1.7
246* Popup alerts are more pleasing. (HIG compliant)
247* Added --nonew flag to prevent creation of new pads.
248* Changed --new flag to only open a new pad, not try to open old pads too.
249* Changed window titles from quoted to ellipses at the end.
250* Option to turn off toolbar auto-hide.
251* Added --list, -l, --show, -s.
252
253
254Version 1.6.1
255* Fix segfault on startup if toolbar is disabled.
256
257
258Version 1.6
259* Rearrange popup menu
260* More meaningful window titles
261* Add popup menu submenu that allows you to choose window to show
262* Allow reopening of closed pads
263* The return of cut/copy/paste
264* Native sticky support
265* Add a show all command -- via command line or menu
266* Allow turning off of scrollbars
267* Allow reshowing of closed pads (without restarting xpad)
268*
269* Stopped style lock from turning on accidentally
270* Properly handle WM closures
271* Better HIG-style support of keyboard accelerators
272
273
274Version 1.5.1
275* Fix a possible segfault on startup
276
277
278Version 1.5
279* Fixed a bug that stopped saving of defaults on shutdown
280* Better error reporting
281* Added a toolbar with customizable buttons
282* Added some new command line options
283* Allow style locking
284* Allow pad clearing
285* Added all new preference help window
286
287
288Version 1.4
289* Code cleanup
290* We now compile clean with -ansi and -pedantic! ;)
291* Should take up a little less memory
292* Fixed several memory leaks
293* Should be able to compile on windows and beos.
294 -- PLEASE let me know how this works for you.
295* Added scrollbars if window isn't big enough to handle text
296 -- this fixes two known bugs
297* New xpad processes now handled gracefully
298* Added further optimizations to compilation
299 -- let me know if this causes you problems
300* Fixed some possible buffer overflows
301* Fixed some warnings/errors on gcc3 compilation
302* Cursor icon changes when edit lock is on
303
304
305Version 1.3
306* Added a padding option (thanks Nagy Mate)
307* Redesigned dialogs
308* Preferences now auto-apply
309* You can now choose what the wm close button does, defaults to close
310* Pads have individual titles now
311* Xpad gets along better with various wm's now
312* Cursor no longer blinks if you can't edit pad
313* Fixed double-clicking-doesn't-select-text-when-edit-lock-is-on bug
314* Pads can no longer be individually closed (unless wm decor is on)
315
316
317Version 1.2.1
318* Fixed segfault on startup if no ~/.xpad directory, plus some related bugs
319
320
321Version 1.2
322* Fixed an issue causing black on black with big-endian architectures
323* Added "Edit Lock" mode
324* General code cleanup
325
326
327Version 1.1
328* Simplified popup menu (removed GTK+ default cut/copy/paste/input
329 method/insert). If you used them, and miss them, let me know.
330* Added keyboard shortcuts for most menu items
331* Expanded help dialog to include shortcuts
332* Allow border left-drags, right-drags, and right clicks
333
334
335Version 1.0.2
336* Stopped pads from losing their place on x shut down
337
338
339Version 1.0.1
340* Fixed a possible runtime warning with autosaving
341* Made window icon code more robust
342* Added icons for all menu items
343
344
345Version 1.0
346* Added an open file dialog
347* Added a save as dialog
348* Closed pads are handled more consistently
349* Unified color/font change screens
350* Fixed font not being saved correctly
351* Added ability to fine tune default pad settings, including size (before
352 this was all handled transparently, but size was not always updated)
353* Added optional confirmation to pad destroys
354* Window decorations can now be turned on (in global pref screen)
355* Added border color and border width options
356* Added gui for sync time (autosaving) control
357* Took out --sync-time and -s (you can do same thing with above gui)
358* Stopped new pads always being placed in same spot
359* Added help screen, which opens when you click on "help" from right-click
360 menu and on first run
361* Much cleaner internal api
362* Made xpad more theme-friendly
363* Resizing/moving now works even if numpad is on
364* Xpad 1.0 can now open much older versions of xpad's files (tested to 0.2.1)
365* Added app icon (thanks nestor di)
366
367
368Version 0.2.5
369* Added --help
370* Added short forms of arguments (e.g. -h, -v, -V, -s)
371* Added more output messages
372* Stopped pad raising above popup on right click
373* Fixed bug where old pads wouldn't open upon startup
374* No size limit on pads
375
376
377Version 0.2.4
378* Fixed small memory leak if no default-style file
379* Pads rise to foreground if clicked on now
380* Added "close all" option on popup
381* Prints out a message when autosaving
382* Added --verbosity= option. (0 is default - no messages; 1 is
383 moderate - important things like autosaving; 2 is debug -
384 more info than necessary)
385* Removed some possible buffer overflows if text is too large (a hardcoded
386 limit of 20k chars now)
387* Misc. code cleanups
388
389
390Version 0.2.3.1
391* Fixed nasty bug where, if you didn't have a working ~/.xpad/default-styles
392 file, it would seg-fault. my bad
393
394
395Version 0.2.3
396* Perfected (?) syncing. Now will recover cleanly from anything -- including
397 power shut off or random interrupts. This fixes the "pad contents
398 disappearing on X-shutdown" bug
399* Moved menu items around a bit
400* Remembers preferred size (only if you change fonts/colors. on TODO)
401* Not always centered now
402
403
404Version 0.2.2
405* Debian-friendly Makefile fixes
406* Cleaned up code
407
408
409Version 0.2.1
410* Changed saving to be more fault-tolerant
411* Added about screen with version info
412
413
414Version 0.2
415* Ported to gtk+-2.0
416* Now can change font color
417* If xpad is already running, will open new pad, not open old pads again
418* In-xpad moving and resizing now works
419* Xpad now recovers better from being interrupted
420* Remembers your preferred style
421* Many small bugfixes
422* Code reorganization
423
424
425Version 0.1.9.2
426* Cleaner lack of decorations
427* Fixed "double-click on menu" bug
428* Fixed segfault when only a font size change was requested
429* Added close and destroy items to menu. Now you can close a window without
430 losing content
4310
=== modified file 'src/help.c'
--- src/help.c 2008-09-21 00:03:40 +0000
+++ src/help.c 2013-10-18 18:35:35 +0000
@@ -59,8 +59,8 @@
59_("Most actions are available throught the popup menu "59_("Most actions are available throught the popup menu "
60"that appears when you right click on a pad. Try it out and "60"that appears when you right click on a pad. Try it out and "
61"enjoy."),61"enjoy."),
62_("Please send comments or bug reports to "62_("Please send ideas or bug reports to\n"
63"xpad-devel@lists.sourceforge.net"));63"https://bugs.launchpad.net/xpad/+filebug"));
64 64
65 gtk_label_set_markup (GTK_LABEL (helptext), helptextbuf);65 gtk_label_set_markup (GTK_LABEL (helptext), helptextbuf);
66 66
6767
=== modified file 'src/xpad-app.c'
--- src/xpad-app.c 2013-10-09 14:46:10 +0000
+++ src/xpad-app.c 2013-10-18 18:35:35 +0000
@@ -42,6 +42,7 @@
42#include "xpad-pad-group.h"42#include "xpad-pad-group.h"
43#include "xpad-periodic.h"43#include "xpad-periodic.h"
44#include "xpad-session-manager.h"44#include "xpad-session-manager.h"
45#include "xpad-settings.h"
45#include "xpad-tray.h"46#include "xpad-tray.h"
4647
47/* Seems that some systems (sun-sparc-solaris2.8 at least), need the following three #defines. 48/* Seems that some systems (sun-sparc-solaris2.8 at least), need the following three #defines.
@@ -98,8 +99,8 @@
98{99{
99 gboolean first_time;100 gboolean first_time;
100 gboolean have_gtk;101 gboolean have_gtk;
101/* GdkVisual *visual;*/102 // GdkVisual *visual;
102 103
103 /* Set up i18n */104 /* Set up i18n */
104#ifdef ENABLE_NLS105#ifdef ENABLE_NLS
105 gtk_set_locale ();106 gtk_set_locale ();
@@ -107,7 +108,7 @@
107 bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");108 bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
108 textdomain (GETTEXT_PACKAGE);109 textdomain (GETTEXT_PACKAGE);
109#endif110#endif
110 111
111 have_gtk = gtk_init_check (&argc, &argv);112 have_gtk = gtk_init_check (&argc, &argv);
112 xpad_argc = argc;113 xpad_argc = argc;
113 xpad_argv = argv;114 xpad_argv = argv;
@@ -253,7 +254,19 @@
253void254void
254xpad_app_quit (void)255xpad_app_quit (void)
255{256{
256 xpad_pad_group_save_unsaved_all(xpad_app_get_pad_group());257 // Free the memory used by the pads belonging to this group
258 xpad_pad_group_destroy_pads(xpad_app_get_pad_group());
259
260 // Free the memory used by group.
261 g_object_unref(xpad_app_get_pad_group());
262
263 // Free the memory used by the settings menu.
264 g_object_unref(XPAD_SETTINGS(xpad_settings()));
265
266 // Free the memory used by the tray icon and its menu.
267 xpad_tray_close();
268
269 // Give GTK the signal to clean the rest and quit the application.
257 gtk_main_quit();270 gtk_main_quit();
258}271}
259272
@@ -290,21 +303,24 @@
290{303{
291 GSList *dirs = NULL, *i;304 GSList *dirs = NULL, *i;
292 gchar *dirname;305 gchar *dirname;
293 306
294 dirname = g_strdup (path);307 dirname = g_strdup (path);
308
295 while (!g_file_test (dirname, G_FILE_TEST_EXISTS))309 while (!g_file_test (dirname, G_FILE_TEST_EXISTS))
296 {310 {
297 dirs = g_slist_prepend (dirs, dirname);311 dirs = g_slist_prepend (dirs, dirname);
298 dirname = g_path_get_dirname (dirname);312 dirname = g_path_get_dirname (dirname);
299 }313 }
300 g_free (dirname);314 g_free (dirname);
301 315
302 for (i = dirs; i; i = i->next)316 for (i = dirs; i; i = i->next)
303 {317 {
304 g_mkdir ((gchar *) i->data, 0700);318 g_mkdir ((gchar *) i->data, 0700);
305 g_free (i->data);319 g_free (i->data);
306 }320 }
307 g_slist_free (dirs);321
322 g_slist_free(dirs);
323 g_slist_free(i);
308}324}
309325
310/**326/**
@@ -315,9 +331,9 @@
315make_config_dir (void)331make_config_dir (void)
316{332{
317 gchar *dir = NULL;333 gchar *dir = NULL;
318 334
319 make_path (g_get_user_config_dir ());335 make_path (g_get_user_config_dir ());
320 336
321 dir = g_build_filename (g_get_user_config_dir (), PACKAGE, NULL);337 dir = g_build_filename (g_get_user_config_dir (), PACKAGE, NULL);
322 338
323 if (!g_file_test (dir, G_FILE_TEST_EXISTS))339 if (!g_file_test (dir, G_FILE_TEST_EXISTS))
@@ -391,7 +407,7 @@
391register_stock_icons (void)407register_stock_icons (void)
392{408{
393 GtkIconTheme *theme;409 GtkIconTheme *theme;
394 410
395 theme = gtk_icon_theme_get_default ();411 theme = gtk_icon_theme_get_default ();
396 gtk_icon_theme_prepend_search_path (theme, THEME_DIR);412 gtk_icon_theme_prepend_search_path (theme, THEME_DIR);
397}413}
@@ -699,6 +715,7 @@
699 gint size;715 gint size;
700 gint bytesRead;716 gint bytesRead;
701 gboolean connected = FALSE;717 gboolean connected = FALSE;
718 ssize_t error = NULL;
702 719
703 /* create master socket */720 /* create master socket */
704 client_fd = socket (PF_LOCAL, SOCK_STREAM, 0);721 client_fd = socket (PF_LOCAL, SOCK_STREAM, 0);
@@ -713,10 +730,14 @@
713 size = args_to_string (xpad_argc, xpad_argv, &args) + 1;730 size = args_to_string (xpad_argc, xpad_argv, &args) + 1;
714 731
715 /* first, write length of string */732 /* first, write length of string */
716 write (client_fd, &size, sizeof (size));733 error = write (client_fd, &size, sizeof (size));
734 if (error == -1)
735 g_error("There is a problem writing information to the socket.");
717 736
718 /* now, write string */737 /* now, write string */
719 write (client_fd, args, size);738 error = write (client_fd, args, (size_t) size);
739 if (error == -1)
740 g_error("There is a problem writing information to the socket.");
720 741
721 do742 do
722 {743 {
723744
=== modified file 'src/xpad-grip-tool-item.c'
--- src/xpad-grip-tool-item.c 2008-09-21 00:03:40 +0000
+++ src/xpad-grip-tool-item.c 2013-10-18 18:35:35 +0000
@@ -18,15 +18,16 @@
1818
19#include "xpad-grip-tool-item.h"19#include "xpad-grip-tool-item.h"
2020
21G_DEFINE_TYPE(XpadGripToolItem, xpad_grip_tool_item, GTK_TYPE_TOOL_ITEM)
22#define XPAD_GRIP_TOOL_ITEM_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), XPAD_TYPE_GRIP_TOOL_ITEM, XpadGripToolItemPrivate))
23
24struct XpadGripToolItemPrivate21struct XpadGripToolItemPrivate
25{22{
26 GtkWidget *drawbox;23 GtkWidget *drawbox;
27};24};
2825
29/*static void xpad_grip_tool_item_size_request (GtkWidget *widget, GtkRequisition *requisition);*/26G_DEFINE_TYPE_WITH_PRIVATE(XpadGripToolItem, xpad_grip_tool_item, GTK_TYPE_TOOL_ITEM)
27
28static void xpad_grip_tool_item_dispose (GObject *object);
29static void xpad_grip_tool_item_finalize (GObject *object);
30
30static gboolean xpad_grip_tool_item_event_box_expose (GtkWidget *widget, GdkEventExpose *event);31static gboolean xpad_grip_tool_item_event_box_expose (GtkWidget *widget, GdkEventExpose *event);
31static void xpad_grip_tool_item_event_box_realize (GtkWidget *widget);32static void xpad_grip_tool_item_event_box_realize (GtkWidget *widget);
32static gboolean xpad_grip_tool_item_button_pressed_event (GtkWidget *widget, GdkEventButton *event);33static gboolean xpad_grip_tool_item_button_pressed_event (GtkWidget *widget, GdkEventButton *event);
@@ -40,15 +41,10 @@
40static void41static void
41xpad_grip_tool_item_class_init (XpadGripToolItemClass *klass)42xpad_grip_tool_item_class_init (XpadGripToolItemClass *klass)
42{43{
43 GObjectClass *gobject_class;44 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
44 GtkContainerClass *container_class;45
45 GtkWidgetClass *widget_class;46 gobject_class->dispose = xpad_grip_tool_item_dispose;
46 47 gobject_class->finalize = xpad_grip_tool_item_finalize;
47 gobject_class = (GObjectClass *)klass;
48 container_class = (GtkContainerClass *)klass;
49 widget_class = (GtkWidgetClass *)klass;
50
51 g_type_class_add_private (gobject_class, sizeof (XpadGripToolItemPrivate));
52}48}
5349
54static void50static void
@@ -57,7 +53,7 @@
57 GtkWidget *alignment;53 GtkWidget *alignment;
58 gboolean right;54 gboolean right;
59 55
60 grip->priv = XPAD_GRIP_TOOL_ITEM_GET_PRIVATE (grip);56 grip->priv = xpad_grip_tool_item_get_instance_private(grip);
61 57
62 grip->priv->drawbox = gtk_drawing_area_new ();58 grip->priv->drawbox = gtk_drawing_area_new ();
63 gtk_widget_add_events (grip->priv->drawbox, GDK_BUTTON_PRESS_MASK | GDK_EXPOSURE_MASK);59 gtk_widget_add_events (grip->priv->drawbox, GDK_BUTTON_PRESS_MASK | GDK_EXPOSURE_MASK);
@@ -73,6 +69,19 @@
73 gtk_container_add (GTK_CONTAINER (grip), alignment);69 gtk_container_add (GTK_CONTAINER (grip), alignment);
74}70}
7571
72static void
73xpad_grip_tool_item_dispose (GObject *object)
74{
75 G_OBJECT_CLASS (xpad_grip_tool_item_parent_class)->dispose (object);
76}
77
78static void
79xpad_grip_tool_item_finalize (GObject *object)
80{
81 G_OBJECT_CLASS (xpad_grip_tool_item_parent_class)->finalize (object);
82}
83
84
76static gboolean85static gboolean
77xpad_grip_tool_item_button_pressed_event (GtkWidget *widget, GdkEventButton *event)86xpad_grip_tool_item_button_pressed_event (GtkWidget *widget, GdkEventButton *event)
78{87{
7988
=== modified file 'src/xpad-pad-group.c'
--- src/xpad-pad-group.c 2013-10-09 14:46:10 +0000
+++ src/xpad-pad-group.c 2013-10-18 18:35:35 +0000
@@ -18,20 +18,18 @@
18 */18 */
1919
20#include "xpad-pad-group.h"20#include "xpad-pad-group.h"
21#include "xpad-settings.h"
21#include "xpad-pad.h"22#include "xpad-pad.h"
2223
23G_DEFINE_TYPE(XpadPadGroup, xpad_pad_group, G_TYPE_OBJECT)
24
25#define XPAD_PAD_GROUP_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), XPAD_TYPE_PAD_GROUP, XpadPadGroupPrivate))
26
27struct XpadPadGroupPrivate24struct XpadPadGroupPrivate
28{25{
29 GSList *pads;26 GSList *pads;
30};27};
3128
29G_DEFINE_TYPE_WITH_PRIVATE(XpadPadGroup, xpad_pad_group, G_TYPE_OBJECT)
30
32static void xpad_pad_group_dispose (GObject *object);31static void xpad_pad_group_dispose (GObject *object);
3332static void xpad_pad_group_finalize (GObject *object);
34static void xpad_pad_group_destroy_pads (XpadPadGroup *group);
3533
36enum {34enum {
37 PROP_035 PROP_0
@@ -53,11 +51,20 @@
53}51}
5452
55static void53static void
54xpad_pad_group_init (XpadPadGroup *group)
55{
56 group->priv = xpad_pad_group_get_instance_private(group);
57
58 group->priv->pads = NULL;
59}
60
61static void
56xpad_pad_group_class_init (XpadPadGroupClass *klass)62xpad_pad_group_class_init (XpadPadGroupClass *klass)
57{63{
58 GObjectClass *object_class = G_OBJECT_CLASS (klass);64 GObjectClass *object_class = G_OBJECT_CLASS (klass);
59 65
60 object_class->dispose = xpad_pad_group_dispose;66 object_class->dispose = xpad_pad_group_dispose;
67 object_class->finalize = xpad_pad_group_finalize;
61 68
62 signals[PAD_ADDED] =69 signals[PAD_ADDED] =
63 g_signal_new ("pad_added",70 g_signal_new ("pad_added",
@@ -80,8 +87,6 @@
80 G_TYPE_NONE,87 G_TYPE_NONE,
81 1,88 1,
82 GTK_TYPE_WIDGET);89 GTK_TYPE_WIDGET);
83
84 g_type_class_add_private (object_class, sizeof (XpadPadGroupPrivate));
85}90}
8691
87static void92static void
@@ -89,31 +94,35 @@
89{94{
90 XpadPadGroup *group = XPAD_PAD_GROUP (object);95 XpadPadGroup *group = XPAD_PAD_GROUP (object);
9196
92 xpad_pad_group_destroy_pads (group);97 // Save all pads of this group
98 xpad_pad_group_save_unsaved_all(group);
99
100 G_OBJECT_CLASS (xpad_pad_group_parent_class)->dispose (object);
93}101}
94102
95static void103static void
96xpad_pad_group_init (XpadPadGroup *group)104xpad_pad_group_finalize (GObject *object)
97{105{
98 group->priv = XPAD_PAD_GROUP_GET_PRIVATE (group);106 XpadPadGroup *group = XPAD_PAD_GROUP (object);
99 107
108 g_slist_free (group->priv->pads);
100 group->priv->pads = NULL;109 group->priv->pads = NULL;
110
111 G_OBJECT_CLASS (xpad_pad_group_parent_class)->finalize (object);
101}112}
102113
103
104GSList *114GSList *
105xpad_pad_group_get_pads (XpadPadGroup *group)115xpad_pad_group_get_pads (XpadPadGroup *group)
106{116{
107 return g_slist_copy (group->priv->pads);117 return g_slist_copy (group->priv->pads);
108}118}
109119
110120/* Add a pad to this group */
111/* Subsumes a pad into this group */
112void121void
113xpad_pad_group_add (XpadPadGroup *group, GtkWidget *pad)122xpad_pad_group_add (XpadPadGroup *group, GtkWidget *pad)
114{123{
115 g_object_ref(pad);124 g_object_ref(pad);
116 g_object_ref_sink(GTK_OBJECT(pad));125 // g_object_ref_sink(GTK_OBJECT(pad));
117 126
118 group->priv->pads = g_slist_append (group->priv->pads, XPAD_PAD (pad));127 group->priv->pads = g_slist_append (group->priv->pads, XPAD_PAD (pad));
119 g_signal_connect_swapped (pad, "destroy", G_CALLBACK (xpad_pad_group_remove), group);128 g_signal_connect_swapped (pad, "destroy", G_CALLBACK (xpad_pad_group_remove), group);
@@ -121,21 +130,19 @@
121 g_signal_emit (group, signals[PAD_ADDED], 0, pad);130 g_signal_emit (group, signals[PAD_ADDED], 0, pad);
122}131}
123132
124133/* Remove a pad from this group */
125/* Removes a pad from this group */
126void134void
127xpad_pad_group_remove (XpadPadGroup *group, GtkWidget *pad)135xpad_pad_group_remove (XpadPadGroup *group, GtkWidget *pad)
128{136{
129 group->priv->pads = g_slist_remove (group->priv->pads, XPAD_PAD (pad));137 group->priv->pads = g_slist_remove (group->priv->pads, XPAD_PAD (pad));
130 138 g_object_unref(pad);
139 pad = NULL;
140
131 g_signal_emit (group, signals[PAD_REMOVED], 0, pad);141 g_signal_emit (group, signals[PAD_REMOVED], 0, pad);
132
133 g_object_unref(pad);
134}142}
135143
136144/* Delete all the current pads in the group */
137/* Deletes all the current pads in the group */145void
138static void
139xpad_pad_group_destroy_pads (XpadPadGroup *group)146xpad_pad_group_destroy_pads (XpadPadGroup *group)
140{147{
141 g_slist_foreach (group->priv->pads, (GFunc) gtk_widget_destroy, NULL);148 g_slist_foreach (group->priv->pads, (GFunc) gtk_widget_destroy, NULL);
@@ -143,6 +150,11 @@
143 group->priv->pads = NULL;150 group->priv->pads = NULL;
144}151}
145152
153guint
154xpad_pad_group_num_pads (XpadPadGroup *group)
155{
156 return g_slist_length(group->priv->pads);
157}
146158
147gint159gint
148xpad_pad_group_num_visible_pads (XpadPadGroup *group)160xpad_pad_group_num_visible_pads (XpadPadGroup *group)
@@ -156,11 +168,11 @@
156 if (GTK_WIDGET_VISIBLE(GTK_WIDGET(i->data)))168 if (GTK_WIDGET_VISIBLE(GTK_WIDGET(i->data)))
157 num ++;169 num ++;
158 }170 }
171 g_slist_free(i);
159 }172 }
160 return num;173 return num;
161}174}
162175
163
164void176void
165xpad_pad_group_close_all (XpadPadGroup *group)177xpad_pad_group_close_all (XpadPadGroup *group)
166{178{
@@ -182,11 +194,9 @@
182 g_slist_foreach (group->priv->pads, (GFunc) gtk_widget_show, NULL);194 g_slist_foreach (group->priv->pads, (GFunc) gtk_widget_show, NULL);
183}195}
184196
185
186void197void
187xpad_pad_group_toggle_hide(XpadPadGroup *group)198xpad_pad_group_toggle_hide(XpadPadGroup *group)
188{199{
189 if (group)200 if (group)
190 g_slist_foreach (group->priv->pads, (GFunc) xpad_pad_toggle, NULL);201 g_slist_foreach (group->priv->pads, (GFunc) xpad_pad_toggle, NULL);
191}202}
192
193203
=== modified file 'src/xpad-pad-group.h'
--- src/xpad-pad-group.h 2013-10-09 14:46:10 +0000
+++ src/xpad-pad-group.h 2013-10-18 18:35:35 +0000
@@ -64,6 +64,7 @@
64GSList * xpad_pad_group_get_pads (XpadPadGroup *group);64GSList * xpad_pad_group_get_pads (XpadPadGroup *group);
65gint xpad_pad_group_num_visible_pads (XpadPadGroup *group);65gint xpad_pad_group_num_visible_pads (XpadPadGroup *group);
66void xpad_pad_group_save_unsaved_all (XpadPadGroup *group);66void xpad_pad_group_save_unsaved_all (XpadPadGroup *group);
67void xpad_pad_group_destroy_pads (XpadPadGroup *group);
6768
68G_END_DECLS69G_END_DECLS
6970
7071
=== modified file 'src/xpad-pad-properties.c'
--- src/xpad-pad-properties.c 2008-09-21 00:03:40 +0000
+++ src/xpad-pad-properties.c 2013-10-18 18:35:35 +0000
@@ -22,9 +22,6 @@
22#include <glib/gi18n.h>22#include <glib/gi18n.h>
23#include "xpad-pad-properties.h"23#include "xpad-pad-properties.h"
2424
25G_DEFINE_TYPE(XpadPadProperties, xpad_pad_properties, GTK_TYPE_DIALOG)
26#define XPAD_PAD_PROPERTIES_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), XPAD_TYPE_PAD_PROPERTIES, XpadPadPropertiesPrivate))
27
28struct XpadPadPropertiesPrivate 25struct XpadPadPropertiesPrivate
29{26{
30 GtkWidget *fontcheck;27 GtkWidget *fontcheck;
@@ -40,6 +37,10 @@
40 GtkWidget *fontbutton;37 GtkWidget *fontbutton;
41};38};
4239
40G_DEFINE_TYPE_WITH_PRIVATE(XpadPadProperties, xpad_pad_properties, GTK_TYPE_DIALOG)
41
42static void xpad_pad_properties_dispose (GObject *object);
43static void xpad_pad_properties_finalize (GObject *object);
43static void xpad_pad_properties_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);44static void xpad_pad_properties_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
44static void xpad_pad_properties_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);45static void xpad_pad_properties_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
45static void xpad_pad_properties_response (GtkDialog *dialog, gint response);46static void xpad_pad_properties_response (GtkDialog *dialog, gint response);
@@ -71,6 +72,8 @@
71{72{
72 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);73 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
73 74
75 gobject_class->dispose = xpad_pad_properties_dispose;
76 gobject_class->finalize = xpad_pad_properties_finalize;
74 gobject_class->set_property = xpad_pad_properties_set_property;77 gobject_class->set_property = xpad_pad_properties_set_property;
75 gobject_class->get_property = xpad_pad_properties_get_property;78 gobject_class->get_property = xpad_pad_properties_get_property;
76 79
@@ -115,8 +118,6 @@
115 "The name of the font for the pad",118 "The name of the font for the pad",
116 NULL,119 NULL,
117 G_PARAM_READWRITE));120 G_PARAM_READWRITE));
118
119 g_type_class_add_private (gobject_class, sizeof (XpadPadPropertiesPrivate));
120}121}
121122
122static void123static void
@@ -127,7 +128,7 @@
127 gchar *text;128 gchar *text;
128 GtkSizeGroup *size_group_labels = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);129 GtkSizeGroup *size_group_labels = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
129 130
130 prop->priv = XPAD_PAD_PROPERTIES_GET_PRIVATE (prop);131 prop->priv = xpad_pad_properties_get_instance_private(prop);
131 132
132 text = g_strconcat ("<b>", _("Appearance"), "</b>", NULL);133 text = g_strconcat ("<b>", _("Appearance"), "</b>", NULL);
133 label = GTK_WIDGET (g_object_new (GTK_TYPE_LABEL,134 label = GTK_WIDGET (g_object_new (GTK_TYPE_LABEL,
@@ -233,6 +234,25 @@
233}234}
234235
235static void236static void
237xpad_pad_properties_dispose (GObject *object)
238{
239 G_OBJECT_CLASS (xpad_pad_properties_parent_class)->dispose (object);
240}
241
242static void
243xpad_pad_properties_finalize (GObject *object)
244{
245 XpadPadProperties *prop = XPAD_PAD_PROPERTIES (object);
246
247 if (&prop->priv->texttmp)
248 gdk_color_free (&prop->priv->texttmp);
249 if (&prop->priv->backtmp != NULL)
250 gdk_color_free (&prop->priv->backtmp);
251
252 G_OBJECT_CLASS (xpad_pad_properties_parent_class)->finalize (object);
253}
254
255static void
236xpad_pad_properties_response (GtkDialog *dialog, gint response)256xpad_pad_properties_response (GtkDialog *dialog, gint response)
237{257{
238 if (response == GTK_RESPONSE_CLOSE)258 if (response == GTK_RESPONSE_CLOSE)
239259
=== modified file 'src/xpad-pad.c'
--- src/xpad-pad.c 2013-10-11 19:45:49 +0000
+++ src/xpad-pad.c 2013-10-18 18:35:35 +0000
@@ -40,13 +40,11 @@
40#include "xpad-toolbar.h"40#include "xpad-toolbar.h"
41#include "xpad-tray.h"41#include "xpad-tray.h"
4242
43G_DEFINE_TYPE(XpadPad, xpad_pad, GTK_TYPE_WINDOW)
44#define XPAD_PAD_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), XPAD_TYPE_PAD, XpadPadPrivate))
45
46struct XpadPadPrivate 43struct XpadPadPrivate
47{44{
48 /* saved values */45 /* saved values */
49 gint x, y, width, height;46 gint x, y;
47 guint width, height;
50 gboolean location_valid;48 gboolean location_valid;
51 gchar *infoname;49 gchar *infoname;
52 gchar *contentname;50 gchar *contentname;
@@ -59,7 +57,7 @@
59 /* toolbar stuff */57 /* toolbar stuff */
60 GtkWidget *toolbar;58 GtkWidget *toolbar;
61 guint toolbar_timeout;59 guint toolbar_timeout;
62 gint toolbar_height;60 guint toolbar_height;
63 gboolean toolbar_expanded;61 gboolean toolbar_expanded;
64 gboolean toolbar_pad_resized;62 gboolean toolbar_pad_resized;
65 63
@@ -72,10 +70,14 @@
7270
73 gboolean unsaved_content;71 gboolean unsaved_content;
74 gboolean unsaved_info;72 gboolean unsaved_info;
73
74 GtkClipboard *clipboard;
75 75
76 XpadPadGroup *group;76 XpadPadGroup *group;
77};77};
7878
79G_DEFINE_TYPE_WITH_PRIVATE(XpadPad, xpad_pad, GTK_TYPE_WINDOW)
80
79enum81enum
80{82{
81 CLOSED,83 CLOSED,
@@ -221,8 +223,6 @@
221 "Pad Group",223 "Pad Group",
222 "Pad group for this pad",224 "Pad group for this pad",
223 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));225 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
224
225 g_type_class_add_private (gobject_class, sizeof (XpadPadPrivate));
226}226}
227227
228/* Class pad - initializer */228/* Class pad - initializer */
@@ -231,9 +231,8 @@
231{231{
232 GtkWidget *vbox;232 GtkWidget *vbox;
233 GtkAccelGroup *accel_group;233 GtkAccelGroup *accel_group;
234 GtkClipboard *clipboard;
235234
236 pad->priv = XPAD_PAD_GET_PRIVATE (pad);235 pad->priv = xpad_pad_get_instance_private(pad);
237236
238 pad->priv->x = 0;237 pad->priv->x = 0;
239 pad->priv->y = 0;238 pad->priv->y = 0;
@@ -251,8 +250,8 @@
251 pad->priv->toolbar_expanded = FALSE;250 pad->priv->toolbar_expanded = FALSE;
252 pad->priv->toolbar_pad_resized = TRUE;251 pad->priv->toolbar_pad_resized = TRUE;
253 pad->priv->properties = NULL;252 pad->priv->properties = NULL;
254 pad->priv->unsaved_content = TRUE;253 pad->priv->unsaved_content = FALSE;
255 pad->priv->unsaved_info = TRUE;254 pad->priv->unsaved_info = FALSE;
256 pad->priv->group = NULL;255 pad->priv->group = NULL;
257256
258 XpadTextView *text_view = g_object_new (XPAD_TYPE_TEXT_VIEW,257 XpadTextView *text_view = g_object_new (XPAD_TYPE_TEXT_VIEW,
@@ -277,12 +276,11 @@
277276
278 accel_group = gtk_accel_group_new ();277 accel_group = gtk_accel_group_new ();
279 gtk_window_add_accel_group (GTK_WINDOW (pad), accel_group);278 gtk_window_add_accel_group (GTK_WINDOW (pad), accel_group);
280 g_object_unref (G_OBJECT (accel_group));
281 pad->priv->menu = menu_get_popup_no_highlight (pad, accel_group);279 pad->priv->menu = menu_get_popup_no_highlight (pad, accel_group);
282 pad->priv->highlight_menu = menu_get_popup_highlight (pad, accel_group);280 pad->priv->highlight_menu = menu_get_popup_highlight (pad, accel_group);
283 gtk_accel_group_connect (accel_group, GDK_Q, GDK_CONTROL_MASK, 0,281 gtk_accel_group_connect (accel_group, GDK_Q, GDK_CONTROL_MASK, 0,
284 g_cclosure_new_swap (G_CALLBACK (xpad_pad_quit), pad, NULL));282 g_cclosure_new_swap (G_CALLBACK (xpad_pad_quit), pad, NULL));
285283 g_object_unref (G_OBJECT (accel_group));
286284
287 vbox = GTK_WIDGET (g_object_new (GTK_TYPE_VBOX,285 vbox = GTK_WIDGET (g_object_new (GTK_TYPE_VBOX,
288 "homogeneous", FALSE,286 "homogeneous", FALSE,
@@ -293,7 +291,7 @@
293 gtk_container_child_set (GTK_CONTAINER (vbox), pad->priv->toolbar, "expand", FALSE, NULL);291 gtk_container_child_set (GTK_CONTAINER (vbox), pad->priv->toolbar, "expand", FALSE, NULL);
294292
295 gtk_window_set_decorated (GTK_WINDOW(pad), xpad_settings_get_has_decorations (xpad_settings ()));293 gtk_window_set_decorated (GTK_WINDOW(pad), xpad_settings_get_has_decorations (xpad_settings ()));
296 gtk_window_set_default_size (GTK_WINDOW(pad), xpad_settings_get_width (xpad_settings ()), xpad_settings_get_height (xpad_settings ()));294 gtk_window_set_default_size (GTK_WINDOW(pad), (gint) xpad_settings_get_width (xpad_settings ()), (gint) xpad_settings_get_height (xpad_settings ()));
297 gtk_window_set_gravity (GTK_WINDOW(pad), GDK_GRAVITY_STATIC); /* static gravity makes saving pad x,y work */295 gtk_window_set_gravity (GTK_WINDOW(pad), GDK_GRAVITY_STATIC); /* static gravity makes saving pad x,y work */
298 gtk_window_set_skip_pager_hint (GTK_WINDOW(pad),xpad_settings_get_has_decorations (xpad_settings ()));296 gtk_window_set_skip_pager_hint (GTK_WINDOW(pad),xpad_settings_get_has_decorations (xpad_settings ()));
299 gtk_window_set_skip_taskbar_hint (GTK_WINDOW(pad), !xpad_settings_get_has_decorations (xpad_settings ()));297 gtk_window_set_skip_taskbar_hint (GTK_WINDOW(pad), !xpad_settings_get_has_decorations (xpad_settings ()));
@@ -309,7 +307,19 @@
309 xpad_pad_notify_clipboard_owner_changed (pad);307 xpad_pad_notify_clipboard_owner_changed (pad);
310 xpad_pad_notify_undo_redo_changed (pad);308 xpad_pad_notify_undo_redo_changed (pad);
311309
312 clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD);310 pad->priv->clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD);
311
312 if (pad->priv->sticky)
313 gtk_window_stick (GTK_WINDOW (pad));
314 else
315 gtk_window_unstick (GTK_WINDOW (pad));
316
317 xpad_pad_sync_title (pad);
318
319 gtk_widget_show_all (vbox);
320
321 gtk_widget_hide (pad->priv->toolbar);
322 xpad_pad_notify_has_toolbar (pad);
313323
314 /* Set up signals */324 /* Set up signals */
315 gtk_widget_add_events (GTK_WIDGET (pad), GDK_BUTTON_PRESS_MASK | GDK_PROPERTY_CHANGE_MASK);325 gtk_widget_add_events (GTK_WIDGET (pad), GDK_BUTTON_PRESS_MASK | GDK_PROPERTY_CHANGE_MASK);
@@ -332,7 +342,7 @@
332 g_signal_connect_swapped (xpad_settings (), "notify::autohide-toolbar", G_CALLBACK (xpad_pad_notify_autohide_toolbar), pad);342 g_signal_connect_swapped (xpad_settings (), "notify::autohide-toolbar", G_CALLBACK (xpad_pad_notify_autohide_toolbar), pad);
333 g_signal_connect_swapped (xpad_settings (), "notify::has-scrollbar", G_CALLBACK (xpad_pad_notify_has_scrollbar), pad);343 g_signal_connect_swapped (xpad_settings (), "notify::has-scrollbar", G_CALLBACK (xpad_pad_notify_has_scrollbar), pad);
334 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);344 g_signal_connect_swapped (gtk_text_view_get_buffer (GTK_TEXT_VIEW (pad->priv->textview)), "notify::has-selection", G_CALLBACK (xpad_pad_notify_has_selection), pad);
335 g_signal_connect_swapped (clipboard, "owner-change", G_CALLBACK (xpad_pad_notify_clipboard_owner_changed), pad);345 g_signal_connect_swapped (pad->priv->clipboard, "owner-change", G_CALLBACK (xpad_pad_notify_clipboard_owner_changed), pad);
336346
337 g_signal_connect_swapped (pad->priv->toolbar, "activate-new", G_CALLBACK (xpad_pad_spawn), pad);347 g_signal_connect_swapped (pad->priv->toolbar, "activate-new", G_CALLBACK (xpad_pad_spawn), pad);
338 g_signal_connect_swapped (pad->priv->toolbar, "activate-clear", G_CALLBACK (xpad_pad_clear), pad);348 g_signal_connect_swapped (pad->priv->toolbar, "activate-clear", G_CALLBACK (xpad_pad_clear), pad);
@@ -352,18 +362,6 @@
352362
353 g_signal_connect (pad->priv->menu, "deactivate", G_CALLBACK (xpad_pad_popup_deactivate), pad);363 g_signal_connect (pad->priv->menu, "deactivate", G_CALLBACK (xpad_pad_popup_deactivate), pad);
354 g_signal_connect (pad->priv->highlight_menu, "deactivate", G_CALLBACK (xpad_pad_popup_deactivate), pad);364 g_signal_connect (pad->priv->highlight_menu, "deactivate", G_CALLBACK (xpad_pad_popup_deactivate), pad);
355
356 if (pad->priv->sticky)
357 gtk_window_stick (GTK_WINDOW (pad));
358 else
359 gtk_window_unstick (GTK_WINDOW (pad));
360
361 xpad_pad_sync_title (pad);
362
363 gtk_widget_show_all (vbox);
364
365 gtk_widget_hide (pad->priv->toolbar);
366 xpad_pad_notify_has_toolbar (pad);
367}365}
368366
369static void367static void
@@ -389,18 +387,31 @@
389xpad_pad_dispose (GObject *object)387xpad_pad_dispose (GObject *object)
390{388{
391 XpadPad *pad = XPAD_PAD (object);389 XpadPad *pad = XPAD_PAD (object);
392 390
393 if (pad->priv->toolbar_timeout)391 if (pad->priv->group) {
394 {392 g_object_unref(pad->priv->group);
395 g_source_remove (pad->priv->toolbar_timeout);393 pad->priv->group = NULL;
396 pad->priv->toolbar_timeout = 0;394 }
397 }395
398 396 if (GTK_IS_WIDGET(pad->priv->menu)) {
399 if (pad->priv->properties)397 gtk_widget_destroy (pad->priv->menu);
400 gtk_widget_destroy (pad->priv->properties);398 pad->priv->menu = NULL;
401 399 }
402 gtk_widget_destroy (pad->priv->menu);400
403 gtk_widget_destroy (pad->priv->highlight_menu);401 if (GTK_IS_WIDGET(pad->priv->highlight_menu)) {
402 gtk_widget_destroy (pad->priv->highlight_menu);
403 pad->priv->highlight_menu = NULL;
404 }
405
406 if (GTK_IS_CLIPBOARD(pad->priv->clipboard)) {
407 // For some reason the clipboard handler does not get automatically disconnected (or not at the right moment), leading to errors after deleting a pad. This manual disconnect prevents this error.
408 g_signal_handlers_disconnect_matched (pad->priv->clipboard, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, pad);
409 }
410
411 if (GTK_IS_TOOLBAR(pad->priv->toolbar)) {
412 // For some reason the toolbar handler does not get automatically disconnected (or not at the right moment), leading to errors after deleting a pad. This manual disconnect prevents this error.
413 g_signal_handlers_disconnect_matched (pad->priv->toolbar, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, pad);
414 }
404 415
405 G_OBJECT_CLASS (xpad_pad_parent_class)->dispose (object);416 G_OBJECT_CLASS (xpad_pad_parent_class)->dispose (object);
406}417}
@@ -409,12 +420,12 @@
409xpad_pad_finalize (GObject *object)420xpad_pad_finalize (GObject *object)
410{421{
411 XpadPad *pad = XPAD_PAD (object);422 XpadPad *pad = XPAD_PAD (object);
412 423
424 g_signal_handlers_disconnect_matched (xpad_settings (), G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, pad);
425
413 g_free (pad->priv->infoname);426 g_free (pad->priv->infoname);
414 g_free (pad->priv->contentname);427 g_free (pad->priv->contentname);
415 428
416 g_signal_handlers_disconnect_matched (xpad_settings (), G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, pad);
417
418 G_OBJECT_CLASS (xpad_pad_parent_class)->finalize (object);429 G_OBJECT_CLASS (xpad_pad_parent_class)->finalize (object);
419}430}
420431
@@ -458,11 +469,11 @@
458 /* reshow_with_initial_size() seems to set the window back to a never-shown state.469 /* reshow_with_initial_size() seems to set the window back to a never-shown state.
459 This is good, as some WMs don't like us changing the above parameters mid-run,470 This is good, as some WMs don't like us changing the above parameters mid-run,
460 even if we do a hide/show cycle. */471 even if we do a hide/show cycle. */
461 gtk_window_set_default_size (GTK_WINDOW (pad), pad->priv->width, pad->priv->height);472 gtk_window_set_default_size (GTK_WINDOW (pad), (gint) pad->priv->width, (gint) pad->priv->height);
462 gtk_window_reshow_with_initial_size (GTK_WINDOW (pad));473 gtk_window_reshow_with_initial_size (GTK_WINDOW (pad));
463}474}
464475
465static gint476static guint
466xpad_pad_text_and_toolbar_height (XpadPad *pad)477xpad_pad_text_and_toolbar_height (XpadPad *pad)
467{478{
468 GdkRectangle rec;479 GdkRectangle rec;
@@ -477,7 +488,14 @@
477 &textx, &texty);488 &textx, &texty);
478 gtk_widget_translate_coordinates(pad->priv->textview, GTK_WIDGET(pad), textx, texty, &x, &y);489 gtk_widget_translate_coordinates(pad->priv->textview, GTK_WIDGET(pad), textx, texty, &x, &y);
479490
480 return y + pad->priv->toolbar_height + gtk_container_get_border_width(GTK_CONTAINER(pad->priv->textview));491 // Safe cast from gint to guint
492 if (y >= 0) {
493 return (guint) y + pad->priv->toolbar_height + gtk_container_get_border_width(GTK_CONTAINER(pad->priv->textview));
494 }
495 else {
496 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.");
497 return 0;
498 }
481}499}
482500
483static void501static void
@@ -493,7 +511,14 @@
493 if (!pad->priv->toolbar_height)511 if (!pad->priv->toolbar_height)
494 {512 {
495 gtk_widget_size_request (pad->priv->toolbar, &req);513 gtk_widget_size_request (pad->priv->toolbar, &req);
496 pad->priv->toolbar_height = req.height;514 // safe cast from gint to guint
515 if (req.height >= 0) {
516 pad->priv->toolbar_height = (guint) req.height;
517 }
518 else {
519 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.");
520 pad->priv->toolbar_height = 0;
521 }
497 }522 }
498523
499 /* Do we have room for the toolbar without covering text? */524 /* Do we have room for the toolbar without covering text? */
@@ -501,7 +526,7 @@
501 {526 {
502 pad->priv->toolbar_expanded = TRUE;527 pad->priv->toolbar_expanded = TRUE;
503 pad->priv->height += pad->priv->toolbar_height;528 pad->priv->height += pad->priv->toolbar_height;
504 gtk_window_resize (GTK_WINDOW (pad), pad->priv->width, pad->priv->height);529 gtk_window_resize (GTK_WINDOW (pad), (gint) pad->priv->width, (gint) pad->priv->height);
505 }530 }
506 else531 else
507 pad->priv->toolbar_expanded = FALSE;532 pad->priv->toolbar_expanded = FALSE;
@@ -526,7 +551,7 @@
526 (pad->priv->toolbar_pad_resized && xpad_pad_text_and_toolbar_height (pad) >= pad->priv->height))551 (pad->priv->toolbar_pad_resized && xpad_pad_text_and_toolbar_height (pad) >= pad->priv->height))
527 {552 {
528 pad->priv->height -= pad->priv->toolbar_height;553 pad->priv->height -= pad->priv->toolbar_height;
529 gtk_window_resize (GTK_WINDOW (pad), pad->priv->width, pad->priv->height);554 gtk_window_resize (GTK_WINDOW (pad), (gint) pad->priv->width, (gint) pad->priv->height);
530 pad->priv->toolbar_expanded = FALSE;555 pad->priv->toolbar_expanded = FALSE;
531 }556 }
532 if (GTK_WIDGET (pad)->window)557 if (GTK_WIDGET (pad)->window)
@@ -549,6 +574,9 @@
549static gboolean574static gboolean
550toolbar_timeout (XpadPad *pad)575toolbar_timeout (XpadPad *pad)
551{576{
577 if (pad || !pad->priv || !pad->priv->toolbar_timeout)
578 return FALSE;
579
552 if (pad->priv->toolbar_timeout &&580 if (pad->priv->toolbar_timeout &&
553 xpad_settings_get_autohide_toolbar (xpad_settings ()) &&581 xpad_settings_get_autohide_toolbar (xpad_settings ()) &&
554 xpad_settings_get_has_toolbar (xpad_settings ()))582 xpad_settings_get_has_toolbar (xpad_settings ()))
@@ -597,11 +625,17 @@
597 g_return_if_fail (pad);625 g_return_if_fail (pad);
598626
599 XpadToolbar *toolbar = NULL;627 XpadToolbar *toolbar = NULL;
600 toolbar = XPAD_TOOLBAR (pad->priv->toolbar);628 // safe cast to toolbar
601 g_return_if_fail (toolbar);629 if (XPAD_IS_TOOLBAR(pad->priv->toolbar)) {
630 toolbar = XPAD_TOOLBAR (pad->priv->toolbar);
631 g_return_if_fail (toolbar);
602632
603 GtkClipboard *clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD);633 GtkClipboard *clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD);
604 xpad_toolbar_enable_paste_button (toolbar, gtk_clipboard_wait_is_text_available (clipboard));634 xpad_toolbar_enable_paste_button (toolbar, gtk_clipboard_wait_is_text_available (clipboard));
635 }
636 else {
637 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.");
638 }
605}639}
606640
607void641void
@@ -722,6 +756,12 @@
722static void756static void
723xpad_pad_delete (XpadPad *pad)757xpad_pad_delete (XpadPad *pad)
724{758{
759 g_return_if_fail (pad);
760
761 // With the delayed saving functionality, it is necessary to clear the unsaved flags to prevent usage of non-existing object information.
762 pad->priv->unsaved_info = FALSE;
763 pad->priv->unsaved_content = FALSE;
764
725 if (should_confirm_delete (pad))765 if (should_confirm_delete (pad))
726 {766 {
727 GtkWidget *dialog;767 GtkWidget *dialog;
@@ -744,11 +784,13 @@
744 return;784 return;
745 }785 }
746 786
787 // These two if statements actually erase the pad on the harddisk.
747 if (pad->priv->infoname)788 if (pad->priv->infoname)
748 fio_remove_file (pad->priv->infoname);789 fio_remove_file (pad->priv->infoname);
749 if (pad->priv->contentname)790 if (pad->priv->contentname)
750 fio_remove_file (pad->priv->contentname);791 fio_remove_file (pad->priv->contentname);
751 792
793 // Remove the pad from the group and destroy it.
752 gtk_widget_destroy (GTK_WIDGET (pad));794 gtk_widget_destroy (GTK_WIDGET (pad));
753}795}
754796
@@ -915,7 +957,14 @@
915static gboolean957static gboolean
916xpad_pad_toolbar_size_allocate (XpadPad *pad, GtkAllocation *event)958xpad_pad_toolbar_size_allocate (XpadPad *pad, GtkAllocation *event)
917{959{
918 pad->priv->toolbar_height = event->height;960 // safe cast from gint to guint
961 if (event->height >= 0) {
962 pad->priv->toolbar_height = (guint) event->height;
963 }
964 else {
965 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.");
966 pad->priv->toolbar_height = 0;
967 }
919 return FALSE;968 return FALSE;
920}969}
921970
@@ -924,17 +973,27 @@
924{973{
925 if (!GTK_WIDGET_VISIBLE (pad))974 if (!GTK_WIDGET_VISIBLE (pad))
926 return FALSE;975 return FALSE;
976
977 int eWidth = event->width;
978 int eHeight = event->height;
927 979
928 if (pad->priv->width != event->width || pad->priv->height != event->height)980 // safe cast from gint to guint
929 pad->priv->toolbar_pad_resized = TRUE;981 if (eWidth >= 0 && eHeight >=0 ) {
982 if (pad->priv->width != (guint) eWidth || pad->priv->height != (guint) eHeight)
983 pad->priv->toolbar_pad_resized = TRUE;
984
985 pad->priv->width = (guint) event->width;
986 pad->priv->height = (guint) event->height;
987 }
988 else {
989 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.");
990 }
930 991
931 pad->priv->x = event->x;992 pad->priv->x = event->x;
932 pad->priv->y = event->y;993 pad->priv->y = event->y;
933 pad->priv->width = event->width;
934 pad->priv->height = event->height;
935 pad->priv->location_valid = TRUE;994 pad->priv->location_valid = TRUE;
936 995
937 xpad_pad_save_content_delayed(pad);996 xpad_pad_save_info_delayed(pad);
938 997
939 /* Sometimes when moving, if the toolbar tries to hide itself,998 /* Sometimes when moving, if the toolbar tries to hide itself,
940 the window manager will not resize it correctly. So, we make999 the window manager will not resize it correctly. So, we make
@@ -974,7 +1033,7 @@
974 case 1:1033 case 1:
975 if ((event->state & gtk_accelerator_get_default_mod_mask ()) == GDK_CONTROL_MASK)1034 if ((event->state & gtk_accelerator_get_default_mod_mask ()) == GDK_CONTROL_MASK)
976 {1035 {
977 gtk_window_begin_move_drag (GTK_WINDOW (pad), event->button, event->x_root, event->y_root, event->time);1036 gtk_window_begin_move_drag (GTK_WINDOW (pad), (gint) event->button, (gint) event->x_root, (gint) event->y_root, event->time);
978 return TRUE;1037 return TRUE;
979 }1038 }
980 break;1039 break;
@@ -989,7 +1048,7 @@
989 else1048 else
990 edge = GDK_WINDOW_EDGE_SOUTH_WEST;1049 edge = GDK_WINDOW_EDGE_SOUTH_WEST;
991 1050
992 gtk_window_begin_resize_drag (GTK_WINDOW (pad), edge, event->button, event->x_root, event->y_root, event->time);1051 gtk_window_begin_resize_drag (GTK_WINDOW (pad), edge, (gint) event->button, (gint) event->x_root, (gint) event->y_root, event->time);
993 }1052 }
994 else1053 else
995 {1054 {
@@ -1010,7 +1069,7 @@
1010 switch (event->button)1069 switch (event->button)
1011 {1070 {
1012 case 1:1071 case 1:
1013 gtk_window_begin_move_drag (GTK_WINDOW (pad), event->button, event->x_root, event->y_root, event->time);1072 gtk_window_begin_move_drag (GTK_WINDOW (pad), (gint) event->button, (gint) event->x_root, (gint) event->y_root, event->time);
1014 return TRUE;1073 return TRUE;
1015 1074
1016 case 3:1075 case 3:
@@ -1023,7 +1082,7 @@
1023 else1082 else
1024 edge = GDK_WINDOW_EDGE_SOUTH_WEST;1083 edge = GDK_WINDOW_EDGE_SOUTH_WEST;
1025 1084
1026 gtk_window_begin_resize_drag (GTK_WINDOW (pad), edge, event->button, event->x_root, event->y_root, event->time);1085 gtk_window_begin_resize_drag (GTK_WINDOW (pad), edge, (gint) event->button, (gint) event->x_root, (gint) event->y_root, event->time);
1027 }1086 }
1028 else1087 else
1029 {1088 {
@@ -1059,6 +1118,8 @@
1059xpad_pad_set_group (XpadPad *pad, XpadPadGroup *group)1118xpad_pad_set_group (XpadPad *pad, XpadPadGroup *group)
1060{1119{
1061 pad->priv->group = group;1120 pad->priv->group = group;
1121 g_object_ref(pad->priv->group);
1122
1062 if (group)1123 if (group)
1063 xpad_pad_group_add (group, GTK_WIDGET (pad));1124 xpad_pad_group_add (group, GTK_WIDGET (pad));
1064}1125}
@@ -1143,6 +1204,9 @@
1143 gchar *content;1204 gchar *content;
1144 GtkTextBuffer *buffer;1205 GtkTextBuffer *buffer;
1145 1206
1207 if (!pad->priv->unsaved_content)
1208 return;
1209
1146 /* create content file if it doesn't exist yet */1210 /* create content file if it doesn't exist yet */
1147 if (!pad->priv->contentname)1211 if (!pad->priv->contentname)
1148 {1212 {
@@ -1150,9 +1214,13 @@
1150 if (!pad->priv->contentname)1214 if (!pad->priv->contentname)
1151 return;1215 return;
1152 }1216 }
1153 1217
1154 buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (pad->priv->textview));1218 if (GTK_IS_TEXT_VIEW(pad->priv->textview)) {
1155 content = xpad_text_buffer_get_text_with_tags (XPAD_TEXT_BUFFER (buffer));1219 buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (pad->priv->textview));
1220 content = xpad_text_buffer_get_text_with_tags (XPAD_TEXT_BUFFER (buffer));
1221 }
1222 else
1223 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.");
1156 1224
1157 fio_set_file (pad->priv->contentname, content);1225 fio_set_file (pad->priv->contentname, content);
11581226
@@ -1204,7 +1272,7 @@
1204 xpad_pad_show_toolbar (pad); /* these will resize pad at correct height */1272 xpad_pad_show_toolbar (pad); /* these will resize pad at correct height */
1205 }1273 }
1206 else1274 else
1207 gtk_window_resize (GTK_WINDOW (pad), pad->priv->width, pad->priv->height);1275 gtk_window_resize (GTK_WINDOW (pad), (gint) pad->priv->width, (gint) pad->priv->height);
1208 gtk_window_move (GTK_WINDOW (pad), pad->priv->x, pad->priv->y);1276 gtk_window_move (GTK_WINDOW (pad), pad->priv->x, pad->priv->y);
1209 1277
1210 xpad_text_view_set_follow_font_style (XPAD_TEXT_VIEW (pad->priv->textview), follow_font);1278 xpad_text_view_set_follow_font_style (XPAD_TEXT_VIEW (pad->priv->textview), follow_font);
@@ -1268,14 +1336,21 @@
1268 1336
1269 if (show)1337 if (show)
1270 *show = !hidden;1338 *show = !hidden;
1339
1340 g_free(fontname);
1271}1341}
12721342
1273void1343void
1274xpad_pad_save_info (XpadPad *pad)1344xpad_pad_save_info (XpadPad *pad)
1275{1345{
1276 gint height;1346 guint height = NULL;
1277 GtkStyle *style;1347 GtkStyle *style = NULL;
1278 gchar *fontname;1348 gchar *fontname = NULL;
1349
1350 g_return_if_fail (pad);
1351
1352 if (!pad->priv->unsaved_info)
1353 return;
1279 1354
1280 /* Must create pad info file if it doesn't exist yet */1355 /* Must create pad info file if it doesn't exist yet */
1281 if (!pad->priv->infoname)1356 if (!pad->priv->infoname)
@@ -1327,7 +1402,7 @@
1327menu_about (XpadPad *pad)1402menu_about (XpadPad *pad)
1328{1403{
1329 const gchar *artists[] = {"Michael Terry <mike@mterry.name>", NULL};1404 const gchar *artists[] = {"Michael Terry <mike@mterry.name>", NULL};
1330 const gchar *authors[] = {"Arthur Borsboom <arthurborsboom@gmail.com", "Jeroen Vermeulen <jtv@xs4all.nl>", "Michael Terry <mike@mterry.name>", "Paul Ivanov <pivanov@berkeley.edu>", NULL};1405 const gchar *authors[] = {"Arthur Borsboom <arthurborsboom@gmail.com>", "Jeroen Vermeulen <jtv@xs4all.nl>", "Michael Terry <mike@mterry.name>", "Paul Ivanov <pivanov@berkeley.edu>", NULL};
1331 const gchar *comments = _("Sticky notes");1406 const gchar *comments = _("Sticky notes");
1332 const gchar *copyright = "© 2001-2007 Michael Terry";1407 const gchar *copyright = "© 2001-2007 Michael Terry";
1333 /* we use g_strdup_printf because C89 has size limits on static strings */1408 /* we use g_strdup_printf because C89 has size limits on static strings */
@@ -1460,6 +1535,9 @@
1460 gtk_window_present (GTK_WINDOW (pad));1535 gtk_window_present (GTK_WINDOW (pad));
1461 1536
1462 g_slist_free (pads);1537 g_slist_free (pads);
1538 g_slist_free (i);
1539 pads = NULL;
1540 i = NULL;
1463}1541}
14641542
1465static void1543static void
@@ -1530,7 +1608,7 @@
1530 gtk_window_stick (GTK_WINDOW (pad));1608 gtk_window_stick (GTK_WINDOW (pad));
1531 else1609 else
1532 gtk_window_unstick (GTK_WINDOW (pad));1610 gtk_window_unstick (GTK_WINDOW (pad));
1533 xpad_pad_save_info (pad);1611 xpad_pad_save_info_delayed (pad);
1534}1612}
15351613
1536static void1614static void
@@ -1781,6 +1859,9 @@
1781 g_free (key);1859 g_free (key);
1782 }1860 }
1783 g_slist_free (pads);1861 g_slist_free (pads);
1862 g_slist_free (l);
1863 pads = NULL;
1864 l = NULL;
1784 }1865 }
1785}1866}
17861867
@@ -1893,10 +1974,6 @@
1893}1974}
18941975
1895/* These functions below are used to reduce the amounts of writes, hence improve the performance. */1976/* These functions below are used to reduce the amounts of writes, hence improve the performance. */
1896void xpad2_save_content (void * vptr)
1897{
1898 xpad_pad_save_content(vptr);
1899}
1900void xpad_pad_save_content_delayed (XpadPad *pad)1977void xpad_pad_save_content_delayed (XpadPad *pad)
1901{1978{
1902 pad->priv->unsaved_content = TRUE;1979 pad->priv->unsaved_content = TRUE;
@@ -1913,6 +1990,6 @@
1913 xpad_pad_save_content(pad);1990 xpad_pad_save_content(pad);
1914 }1991 }
1915 if(pad->priv->unsaved_info == TRUE) {1992 if(pad->priv->unsaved_info == TRUE) {
1916 xpad_pad_save_info(pad);1993 xpad_pad_save_info(pad);
1917 }1994 }
1918}1995}
19191996
=== modified file 'src/xpad-preferences.c'
--- src/xpad-preferences.c 2008-09-21 00:03:40 +0000
+++ src/xpad-preferences.c 2013-10-18 18:35:35 +0000
@@ -25,9 +25,6 @@
25#include "xpad-preferences.h"25#include "xpad-preferences.h"
26#include "xpad-settings.h"26#include "xpad-settings.h"
2727
28G_DEFINE_TYPE(XpadPreferences, xpad_preferences, GTK_TYPE_DIALOG)
29#define XPAD_PREFERENCES_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), XPAD_TYPE_PREFERENCES, XpadPreferencesPrivate))
30
31struct XpadPreferencesPrivate 28struct XpadPreferencesPrivate
32{29{
33 GtkWidget *fontcheck;30 GtkWidget *fontcheck;
@@ -60,6 +57,8 @@
60 guint confirmcheck_handler;57 guint confirmcheck_handler;
61};58};
6259
60G_DEFINE_TYPE_WITH_PRIVATE(XpadPreferences, xpad_preferences, GTK_TYPE_DIALOG)
61
63static void change_edit_check (GtkToggleButton *button, XpadPreferences *pref);62static void change_edit_check (GtkToggleButton *button, XpadPreferences *pref);
64static void change_sticky_check (GtkToggleButton *button, XpadPreferences *pref);63static void change_sticky_check (GtkToggleButton *button, XpadPreferences *pref);
65static void change_confirm_check (GtkToggleButton *button, XpadPreferences *pref);64static void change_confirm_check (GtkToggleButton *button, XpadPreferences *pref);
@@ -74,6 +73,7 @@
74static void notify_fontname (XpadPreferences *pref);73static void notify_fontname (XpadPreferences *pref);
75static void notify_text_color (XpadPreferences *pref);74static void notify_text_color (XpadPreferences *pref);
76static void notify_back_color (XpadPreferences *pref);75static void notify_back_color (XpadPreferences *pref);
76static void xpad_preferences_dispose (GObject *object);
77static void xpad_preferences_finalize (GObject *object);77static void xpad_preferences_finalize (GObject *object);
78static void xpad_preferences_response (GtkDialog *dialog, gint response);78static void xpad_preferences_response (GtkDialog *dialog, gint response);
7979
@@ -98,10 +98,9 @@
98xpad_preferences_class_init (XpadPreferencesClass *klass)98xpad_preferences_class_init (XpadPreferencesClass *klass)
99{99{
100 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);100 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
101 101
102 gobject_class->dispose = xpad_preferences_dispose;
102 gobject_class->finalize = xpad_preferences_finalize;103 gobject_class->finalize = xpad_preferences_finalize;
103
104 g_type_class_add_private (gobject_class, sizeof (XpadPreferencesPrivate));
105}104}
106105
107static void106static void
@@ -117,7 +116,7 @@
117 GtkSizeGroup *size_group_labels = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);116 GtkSizeGroup *size_group_labels = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
118 GtkRequisition req;117 GtkRequisition req;
119 118
120 pref->priv = XPAD_PREFERENCES_GET_PRIVATE (pref);119 pref->priv = xpad_preferences_get_instance_private(pref);
121 120
122 text = g_strconcat ("<b>", _("Appearance"), "</b>", NULL);121 text = g_strconcat ("<b>", _("Appearance"), "</b>", NULL);
123 label = GTK_WIDGET (g_object_new (GTK_TYPE_LABEL,122 label = GTK_WIDGET (g_object_new (GTK_TYPE_LABEL,
@@ -312,12 +311,16 @@
312}311}
313312
314static void313static void
314xpad_preferences_dispose (GObject *object)
315{
316 G_OBJECT_CLASS (xpad_preferences_parent_class)->dispose (object);
317}
318
319static void
315xpad_preferences_finalize (GObject *object)320xpad_preferences_finalize (GObject *object)
316{321{
317 XpadPreferences *pref = XPAD_PREFERENCES (object);322 XpadPreferences *pref = XPAD_PREFERENCES (object);
318 323
319 g_signal_handlers_disconnect_matched (xpad_settings (), G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, pref);
320
321 G_OBJECT_CLASS (xpad_preferences_parent_class)->finalize (object);324 G_OBJECT_CLASS (xpad_preferences_parent_class)->finalize (object);
322}325}
323326
324327
=== modified file 'src/xpad-settings.c'
--- src/xpad-settings.c 2013-10-07 20:07:46 +0000
+++ src/xpad-settings.c 2013-10-18 18:35:35 +0000
@@ -22,11 +22,6 @@
22#include "xpad-settings.h"22#include "xpad-settings.h"
23#include "fio.h"23#include "fio.h"
2424
25G_DEFINE_TYPE(XpadSettings, xpad_settings, G_TYPE_OBJECT)
26#define XPAD_SETTINGS_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), XPAD_TYPE_SETTINGS, XpadSettingsPrivate))
27
28#define DEFAULTS_FILENAME "default-style"
29
30struct XpadSettingsPrivate 25struct XpadSettingsPrivate
31{26{
32 guint width;27 guint width;
@@ -44,6 +39,10 @@
44 GSList *toolbar_buttons;39 GSList *toolbar_buttons;
45};40};
4641
42G_DEFINE_TYPE_WITH_PRIVATE(XpadSettings, xpad_settings, G_TYPE_OBJECT)
43
44#define DEFAULTS_FILENAME "default-style"
45
47enum46enum
48{47{
49 CHANGE_BUTTONS,48 CHANGE_BUTTONS,
@@ -72,6 +71,7 @@
72static void save_to_file (XpadSettings *settings, const gchar *filename);71static void save_to_file (XpadSettings *settings, const gchar *filename);
73static void xpad_settings_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);72static void xpad_settings_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
74static void xpad_settings_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);73static void xpad_settings_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
74static void xpad_settings_dispose (GObject *object);
75static void xpad_settings_finalize (GObject *object);75static void xpad_settings_finalize (GObject *object);
7676
77static XpadSettings *_xpad_settings = NULL;77static XpadSettings *_xpad_settings = NULL;
@@ -91,7 +91,8 @@
91xpad_settings_class_init (XpadSettingsClass *klass)91xpad_settings_class_init (XpadSettingsClass *klass)
92{92{
93 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);93 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
94 94
95 gobject_class->dispose = xpad_settings_dispose;
95 gobject_class->finalize = xpad_settings_finalize;96 gobject_class->finalize = xpad_settings_finalize;
96 gobject_class->set_property = xpad_settings_set_property;97 gobject_class->set_property = xpad_settings_set_property;
97 gobject_class->get_property = xpad_settings_get_property;98 gobject_class->get_property = xpad_settings_get_property;
@@ -207,8 +208,6 @@
207 G_STRUCT_OFFSET (XpadSettingsClass, change_buttons),208 G_STRUCT_OFFSET (XpadSettingsClass, change_buttons),
208 NULL, NULL,209 NULL, NULL,
209 g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);210 g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
210
211 g_type_class_add_private (gobject_class, sizeof (XpadSettingsPrivate));
212}211}
213212
214static void213static void
@@ -216,7 +215,7 @@
216{215{
217 GdkColor back, text;216 GdkColor back, text;
218 217
219 settings->priv = XPAD_SETTINGS_GET_PRIVATE (settings);218 settings->priv = xpad_settings_get_instance_private(settings);
220 219
221 /* A pleasant light yellow color, similar to 220 /* A pleasant light yellow color, similar to
222 commercial sticky notes. */221 commercial sticky notes. */
@@ -253,13 +252,23 @@
253}252}
254253
255static void254static void
255xpad_settings_dispose (GObject *object)
256{
257 G_OBJECT_CLASS (xpad_settings_parent_class)->dispose (object);
258}
259
260static void
256xpad_settings_finalize (GObject *object)261xpad_settings_finalize (GObject *object)
257{262{
258 XpadSettings *settings = XPAD_SETTINGS (object);263 XpadSettings *settings = XPAD_SETTINGS (object);
259 264
260 g_slist_free (settings->priv->toolbar_buttons);265 g_slist_free (settings->priv->toolbar_buttons);
261 gdk_color_free (settings->priv->text);266
262 gdk_color_free (settings->priv->back);267 if (settings->priv->text)
268 gdk_color_free (settings->priv->text);
269 if (settings->priv->back)
270 gdk_color_free (settings->priv->back);
271
263 g_free (settings->priv->fontname);272 g_free (settings->priv->fontname);
264 273
265 G_OBJECT_CLASS (xpad_settings_parent_class)->finalize (object);274 G_OBJECT_CLASS (xpad_settings_parent_class)->finalize (object);
@@ -427,20 +436,27 @@
427 g_signal_emit (settings, signals[CHANGE_BUTTONS], 0);436 g_signal_emit (settings, signals[CHANGE_BUTTONS], 0);
428}437}
429438
439/* Unused function of previous developer
430gboolean xpad_settings_move_toolbar_button (XpadSettings *settings, gint button, gint new)440gboolean xpad_settings_move_toolbar_button (XpadSettings *settings, gint button, gint new)
431{441{
432 GSList *element;442 GSList *element = NULL;
433 gpointer data;443 gpointer data;
434 444
435 if (button == new)445 if (button == new) {
446 g_slist_free(element);
436 return FALSE;447 return FALSE;
448 }
437 449
438 if (new >= g_slist_length (settings->priv->toolbar_buttons) || 0 > new )450 if (new >= (gint) g_slist_length (settings->priv->toolbar_buttons) || 0 > new ) {
451 g_slist_free(element);
439 return FALSE;452 return FALSE;
453 }
440 454
441 element = g_slist_nth (settings->priv->toolbar_buttons, button);455 element = g_slist_nth (settings->priv->toolbar_buttons, button);
442 if (!element)456 if (!element) {
457 g_slist_free(element);
443 return FALSE;458 return FALSE;
459 }
444 460
445 data = element->data;461 data = element->data;
446 settings->priv->toolbar_buttons = g_slist_delete_link (settings->priv->toolbar_buttons, element);462 settings->priv->toolbar_buttons = g_slist_delete_link (settings->priv->toolbar_buttons, element);
@@ -450,8 +466,11 @@
450 466
451 g_signal_emit (settings, signals[CHANGE_BUTTONS], 0);467 g_signal_emit (settings, signals[CHANGE_BUTTONS], 0);
452 468
469 g_slist_free(element);
470
453 return TRUE;471 return TRUE;
454}472}
473*/
455474
456static void xpad_settings_remove_toolbar_list_element (XpadSettings *settings, GSList *element)475static void xpad_settings_remove_toolbar_list_element (XpadSettings *settings, GSList *element)
457{476{
@@ -459,14 +478,17 @@
459 settings->priv->toolbar_buttons = g_slist_delete_link (settings->priv->toolbar_buttons, element);478 settings->priv->toolbar_buttons = g_slist_delete_link (settings->priv->toolbar_buttons, element);
460}479}
461480
481/* Unused function of previous developer
462gboolean xpad_settings_remove_toolbar_button (XpadSettings *settings, gint button)482gboolean xpad_settings_remove_toolbar_button (XpadSettings *settings, gint button)
463{483{
464 GSList *element;484 GSList *element;
465 485
466 element = g_slist_nth (settings->priv->toolbar_buttons, button);486 element = g_slist_nth (settings->priv->toolbar_buttons, button);
467 487
468 if (!element)488 if (!element) {
489 g_slist_free(element);
469 return FALSE;490 return FALSE;
491 }
470 492
471 xpad_settings_remove_toolbar_list_element (settings, element);493 xpad_settings_remove_toolbar_list_element (settings, element);
472 494
@@ -474,8 +496,11 @@
474 496
475 g_signal_emit (settings, signals[CHANGE_BUTTONS], 0);497 g_signal_emit (settings, signals[CHANGE_BUTTONS], 0);
476 498
499 g_slist_free(element);
500
477 return TRUE;501 return TRUE;
478}502}
503*/
479504
480gboolean xpad_settings_remove_all_toolbar_buttons (XpadSettings *settings)505gboolean xpad_settings_remove_all_toolbar_buttons (XpadSettings *settings)
481{506{
@@ -503,8 +528,10 @@
503 528
504 element = g_slist_last (settings->priv->toolbar_buttons);529 element = g_slist_last (settings->priv->toolbar_buttons);
505 530
506 if (!element)531 if (!element) {
532 g_slist_free(element);
507 return FALSE;533 return FALSE;
534 }
508 535
509 xpad_settings_remove_toolbar_list_element (settings, element);536 xpad_settings_remove_toolbar_list_element (settings, element);
510 537
@@ -512,6 +539,8 @@
512 539
513 g_signal_emit (settings, signals[CHANGE_BUTTONS], 0);540 g_signal_emit (settings, signals[CHANGE_BUTTONS], 0);
514 541
542 g_slist_free(element);
543
515 return TRUE;544 return TRUE;
516}545}
517546
518547
=== modified file 'src/xpad-settings.h'
--- src/xpad-settings.h 2011-11-16 20:16:17 +0000
+++ src/xpad-settings.h 2013-10-18 18:35:35 +0000
@@ -82,8 +82,8 @@
82gboolean xpad_settings_get_has_scrollbar (XpadSettings *settings);82gboolean xpad_settings_get_has_scrollbar (XpadSettings *settings);
8383
84void xpad_settings_add_toolbar_button (XpadSettings *settings, const gchar *button);84void xpad_settings_add_toolbar_button (XpadSettings *settings, const gchar *button);
85gboolean xpad_settings_move_toolbar_button (XpadSettings *settings, gint button, gint new);85// gboolean xpad_settings_move_toolbar_button (XpadSettings *settings, gint button, gint new);
86gboolean xpad_settings_remove_toolbar_button (XpadSettings *settings, gint button);86// gboolean xpad_settings_remove_toolbar_button (XpadSettings *settings, gint button);
87gboolean xpad_settings_remove_all_toolbar_buttons (XpadSettings *settings);87gboolean xpad_settings_remove_all_toolbar_buttons (XpadSettings *settings);
88gboolean xpad_settings_remove_last_toolbar_button (XpadSettings *settings);88gboolean xpad_settings_remove_last_toolbar_button (XpadSettings *settings);
89G_CONST_RETURN GSList *xpad_settings_get_toolbar_buttons (XpadSettings *settings);89G_CONST_RETURN GSList *xpad_settings_get_toolbar_buttons (XpadSettings *settings);
9090
=== modified file 'src/xpad-text-buffer.c'
--- src/xpad-text-buffer.c 2011-11-16 18:10:04 +0000
+++ src/xpad-text-buffer.c 2013-10-18 18:35:35 +0000
@@ -21,22 +21,20 @@
21#include "xpad-undo.h"21#include "xpad-undo.h"
22#include "xpad-pad.h"22#include "xpad-pad.h"
2323
24G_DEFINE_TYPE(XpadTextBuffer, xpad_text_buffer, GTK_TYPE_TEXT_BUFFER)
25#define XPAD_TEXT_BUFFER_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), XPAD_TYPE_TEXT_BUFFER, XpadTextBufferPrivate))
26
27struct XpadTextBufferPrivate 24struct XpadTextBufferPrivate
28{25{
29 XpadUndo *undo;26 XpadUndo *undo;
30 XpadPad *pad;27 XpadPad *pad;
28 GtkTextTagTable *tag_table;
31};29};
3230
31G_DEFINE_TYPE_WITH_PRIVATE(XpadTextBuffer, xpad_text_buffer, GTK_TYPE_TEXT_BUFFER)
32
33/* Unicode chars in the Private Use Area. */33/* Unicode chars in the Private Use Area. */
34static gunichar TAG_CHAR = 0xe000;34static gunichar TAG_CHAR = 0xe000;
3535
36static GtkTextTagTable *create_tag_table (void);36static GtkTextTagTable *create_tag_table (void);
3737
38static GtkTextTagTable *global_text_tag_table = NULL;
39
40enum38enum
41{39{
42 PROP_0,40 PROP_0,
@@ -44,81 +42,24 @@
44 LAST_PROP42 LAST_PROP
45};43};
4644
45static void xpad_text_buffer_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
46static void xpad_text_buffer_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
47static void xpad_text_buffer_dispose (GObject *object);
48static void xpad_text_buffer_finalize (GObject *object);
49
47XpadTextBuffer *50XpadTextBuffer *
48xpad_text_buffer_new (XpadPad *pad)51xpad_text_buffer_new (void)
49{52{
50 if (!global_text_tag_table)53 XpadPad *pad = NULL;
51 global_text_tag_table = create_tag_table (); /* FIXME: never freed */54 return g_object_new (XPAD_TYPE_TEXT_BUFFER, "pad", pad, NULL);
52
53 return XPAD_TEXT_BUFFER (g_object_new (XPAD_TYPE_TEXT_BUFFER, "tag_table", global_text_tag_table, "pad", pad, NULL));
54}
55
56static void
57xpad_text_buffer_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
58{
59 XpadTextBuffer *text_buffer = XPAD_TEXT_BUFFER (object);
60
61 switch (prop_id)
62 {
63 case PROP_PAD:
64 if (text_buffer->priv->pad && G_IS_OBJECT (text_buffer->priv->pad))
65 g_object_unref (text_buffer->priv->pad);
66 if (G_VALUE_HOLDS_POINTER (value) && G_IS_OBJECT (g_value_get_pointer (value)))
67 {
68 text_buffer->priv->pad = g_value_get_pointer (value);
69 g_object_ref (text_buffer->priv->pad);
70 }
71 break;
72
73 default:
74 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
75 break;
76 }
77}
78
79static void
80xpad_text_buffer_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
81{
82 XpadTextBuffer *text_buffer = XPAD_TEXT_BUFFER (object);
83
84 switch (prop_id)
85 {
86 case PROP_PAD:
87 g_value_set_pointer (value, text_buffer->priv->pad);
88 break;
89
90 default:
91 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
92 break;
93 }
94}
95
96
97static void
98xpad_text_buffer_finalize (GObject *object)
99{
100 XpadTextBuffer *text_buffer = XPAD_TEXT_BUFFER (object);
101
102 if (text_buffer->priv->pad)
103 {
104 g_object_unref (text_buffer->priv->pad);
105 text_buffer->priv->pad = NULL;
106 }
107
108 if (text_buffer->priv->undo)
109 {
110 g_free (text_buffer->priv->undo);
111 text_buffer->priv->undo = NULL;
112 }
113
114 G_OBJECT_CLASS (xpad_text_buffer_parent_class)->finalize (object);
115}55}
11656
117static void57static void
118xpad_text_buffer_class_init (XpadTextBufferClass *klass)58xpad_text_buffer_class_init (XpadTextBufferClass *klass)
119{59{
120 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);60 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
121 61
62 gobject_class->dispose = xpad_text_buffer_dispose;
122 gobject_class->finalize = xpad_text_buffer_finalize;63 gobject_class->finalize = xpad_text_buffer_finalize;
123 gobject_class->set_property = xpad_text_buffer_set_property;64 gobject_class->set_property = xpad_text_buffer_set_property;
124 gobject_class->get_property = xpad_text_buffer_get_property;65 gobject_class->get_property = xpad_text_buffer_get_property;
@@ -129,18 +70,85 @@
129 "Pad",70 "Pad",
130 "Pad connected to this buffer",71 "Pad connected to this buffer",
131 G_PARAM_READWRITE));72 G_PARAM_READWRITE));
132
133 g_type_class_add_private (gobject_class, sizeof (XpadTextBufferPrivate));
134}73}
13574
136static void75static void
137xpad_text_buffer_init (XpadTextBuffer *buffer)76xpad_text_buffer_init (XpadTextBuffer *buffer)
138{77{
139 buffer->priv = XPAD_TEXT_BUFFER_GET_PRIVATE (buffer);78 buffer->priv = xpad_text_buffer_get_instance_private(buffer);
14079
80 buffer->priv->tag_table = create_tag_table ();
141 buffer->priv->undo = xpad_undo_new (buffer);81 buffer->priv->undo = xpad_undo_new (buffer);
142}82}
14383
84static void
85xpad_text_buffer_dispose (GObject *object)
86{
87 XpadTextBuffer *buffer = XPAD_TEXT_BUFFER (object);
88
89 if (buffer->priv->pad) {
90 g_object_unref (buffer->priv->pad);
91 buffer->priv->pad = NULL;
92 }
93
94 if (buffer->priv->undo) {
95 g_object_unref (buffer->priv->undo);
96 buffer->priv->undo = NULL;
97 }
98
99 if (buffer->priv->tag_table) {
100 g_object_unref(buffer->priv->tag_table);
101 buffer->priv->tag_table = NULL;
102 }
103 G_OBJECT_CLASS (xpad_text_buffer_parent_class)->dispose (object);
104}
105
106static void
107xpad_text_buffer_finalize (GObject *object)
108{
109 G_OBJECT_CLASS (xpad_text_buffer_parent_class)->finalize (object);
110}
111
112static void
113xpad_text_buffer_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
114{
115 XpadTextBuffer *buffer = XPAD_TEXT_BUFFER (object);
116
117 switch (prop_id)
118 {
119 case PROP_PAD:
120 if (buffer->priv->pad && G_IS_OBJECT (buffer->priv->pad))
121 g_object_unref (buffer->priv->pad);
122 if (G_VALUE_HOLDS_POINTER (value) && G_IS_OBJECT (g_value_get_pointer (value)))
123 {
124 buffer->priv->pad = g_value_get_pointer (value);
125 g_object_ref (buffer->priv->pad);
126 }
127 break;
128
129 default:
130 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
131 break;
132 }
133}
134
135static void
136xpad_text_buffer_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
137{
138 XpadTextBuffer *buffer = XPAD_TEXT_BUFFER (object);
139
140 switch (prop_id)
141 {
142 case PROP_PAD:
143 g_value_set_pointer (value, buffer->priv->pad);
144 break;
145
146 default:
147 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
148 break;
149 }
150}
151
144void152void
145xpad_text_buffer_set_text_with_tags (XpadTextBuffer *buffer, const gchar *text)153xpad_text_buffer_set_text_with_tags (XpadTextBuffer *buffer, const gchar *text)
146{154{
@@ -432,4 +440,3 @@
432440
433 g_object_set (G_OBJECT (buffer), "pad", pad, NULL);441 g_object_set (G_OBJECT (buffer), "pad", pad, NULL);
434}442}
435
436443
=== modified file 'src/xpad-text-buffer.h'
--- src/xpad-text-buffer.h 2011-11-16 18:10:04 +0000
+++ src/xpad-text-buffer.h 2013-10-18 18:35:35 +0000
@@ -51,7 +51,7 @@
5151
52GType xpad_text_buffer_get_type (void);52GType xpad_text_buffer_get_type (void);
5353
54XpadTextBuffer *xpad_text_buffer_new (XpadPad *pad);54XpadTextBuffer *xpad_text_buffer_new (void);
5555
56void xpad_text_buffer_set_text_with_tags (XpadTextBuffer *buffer, const gchar *text);56void xpad_text_buffer_set_text_with_tags (XpadTextBuffer *buffer, const gchar *text);
57gchar *xpad_text_buffer_get_text_with_tags (XpadTextBuffer *buffer);57gchar *xpad_text_buffer_get_text_with_tags (XpadTextBuffer *buffer);
5858
=== modified file 'src/xpad-text-view.c'
--- src/xpad-text-view.c 2011-11-16 18:10:04 +0000
+++ src/xpad-text-view.c 2013-10-18 18:35:35 +0000
@@ -20,9 +20,6 @@
20#include "xpad-text-buffer.h"20#include "xpad-text-buffer.h"
21#include "xpad-settings.h"21#include "xpad-settings.h"
2222
23G_DEFINE_TYPE(XpadTextView, xpad_text_view, GTK_TYPE_TEXT_VIEW)
24#define XPAD_TEXT_VIEW_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), XPAD_TYPE_TEXT_VIEW, XpadTextViewPrivate))
25
26struct XpadTextViewPrivate 23struct XpadTextViewPrivate
27{24{
28 gboolean follow_font_style;25 gboolean follow_font_style;
@@ -33,10 +30,13 @@
33 XpadTextBuffer *buffer;30 XpadTextBuffer *buffer;
34};31};
3532
33G_DEFINE_TYPE_WITH_PRIVATE(XpadTextView, xpad_text_view, GTK_TYPE_TEXT_VIEW)
34
36static void xpad_text_view_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);35static void xpad_text_view_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
37static void xpad_text_view_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);36static void xpad_text_view_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
37static void xpad_text_view_dispose (GObject *object);
38static void xpad_text_view_finalize (GObject *object);
38static void xpad_text_view_realize (XpadTextView *widget);39static void xpad_text_view_realize (XpadTextView *widget);
39static void xpad_text_view_finalize (GObject *object);
40static gboolean xpad_text_view_button_press_event (GtkWidget *widget, GdkEventButton *event);40static gboolean xpad_text_view_button_press_event (GtkWidget *widget, GdkEventButton *event);
41static gboolean xpad_text_view_focus_out_event (GtkWidget *widget, GdkEventFocus *event);41static gboolean xpad_text_view_focus_out_event (GtkWidget *widget, GdkEventFocus *event);
42static void xpad_text_view_notify_edit_lock (XpadTextView *view);42static void xpad_text_view_notify_edit_lock (XpadTextView *view);
@@ -64,7 +64,8 @@
64xpad_text_view_class_init (XpadTextViewClass *klass)64xpad_text_view_class_init (XpadTextViewClass *klass)
65{65{
66 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);66 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
67 67
68 gobject_class->dispose = xpad_text_view_dispose;
68 gobject_class->finalize = xpad_text_view_finalize;69 gobject_class->finalize = xpad_text_view_finalize;
69 gobject_class->set_property = xpad_text_view_set_property;70 gobject_class->set_property = xpad_text_view_set_property;
70 gobject_class->get_property = xpad_text_view_get_property;71 gobject_class->get_property = xpad_text_view_get_property;
@@ -86,8 +87,6 @@
86 "Whether to use the default xpad color style",87 "Whether to use the default xpad color style",
87 TRUE,88 TRUE,
88 G_PARAM_READWRITE));89 G_PARAM_READWRITE));
89
90 g_type_class_add_private (gobject_class, sizeof (XpadTextViewPrivate));
91}90}
9291
93static void92static void
@@ -95,12 +94,12 @@
95{94{
96 gchar *name;95 gchar *name;
97 96
98 view->priv = XPAD_TEXT_VIEW_GET_PRIVATE (view);97 view->priv = xpad_text_view_get_instance_private(view);
99 98
100 view->priv->follow_font_style = TRUE;99 view->priv->follow_font_style = TRUE;
101 view->priv->follow_color_style = TRUE;100 view->priv->follow_color_style = TRUE;
102 101
103 view->priv->buffer = xpad_text_buffer_new (NULL);102 view->priv->buffer = xpad_text_buffer_new();
104 gtk_text_view_set_buffer (GTK_TEXT_VIEW (view), GTK_TEXT_BUFFER (view->priv->buffer));103 gtk_text_view_set_buffer (GTK_TEXT_VIEW (view), GTK_TEXT_BUFFER (view->priv->buffer));
105 104
106 gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (view), GTK_WRAP_WORD);105 gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (view), GTK_WRAP_WORD);
@@ -126,18 +125,20 @@
126}125}
127126
128static void127static void
129xpad_text_view_finalize (GObject *object)128xpad_text_view_dispose (GObject *object)
130{129{
131 XpadTextView *view = XPAD_TEXT_VIEW (object);130 XpadTextView *view = XPAD_TEXT_VIEW (object);
132131
133 if (view->priv->buffer)132 if (view->priv->buffer) {
134 {
135 g_object_unref (view->priv->buffer);133 g_object_unref (view->priv->buffer);
136 view->priv->buffer = NULL;
137 }134 }
138 135
139 g_signal_handlers_disconnect_matched (xpad_settings (), G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, view);136 G_OBJECT_CLASS (xpad_text_view_parent_class)->dispose (object);
140 137}
138
139static void
140xpad_text_view_finalize (GObject *object)
141{
141 G_OBJECT_CLASS (xpad_text_view_parent_class)->finalize (object);142 G_OBJECT_CLASS (xpad_text_view_parent_class)->finalize (object);
142}143}
143144
144145
=== modified file 'src/xpad-toolbar.c'
--- src/xpad-toolbar.c 2011-11-16 20:39:04 +0000
+++ src/xpad-toolbar.c 2013-10-18 18:35:35 +0000
@@ -26,25 +26,24 @@
26#include "xpad-settings.h"26#include "xpad-settings.h"
27#include "xpad-grip-tool-item.h"27#include "xpad-grip-tool-item.h"
2828
29G_DEFINE_TYPE(XpadToolbar, xpad_toolbar, GTK_TYPE_TOOLBAR)
30#define XPAD_TOOLBAR_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), XPAD_TYPE_TOOLBAR, XpadToolbarPrivate))
31
32enum {
33 XPAD_BUTTON_TYPE_SEPARATOR,
34 XPAD_BUTTON_TYPE_BUTTON,
35 XPAD_BUTTON_TYPE_TOGGLE
36};
37
38struct XpadToolbarPrivate29struct XpadToolbarPrivate
39{30{
40 GtkToolItem *move_button;
41 gboolean move_removed;31 gboolean move_removed;
42 guint move_index;32 guint move_index;
43 guint move_motion_handler;33 guint move_motion_handler;
44 guint move_button_release_handler;34 guint move_button_release_handler;
45 guint move_key_press_handler;35 guint move_key_press_handler;
46 GtkToolItem *tool_items;
47 XpadPad *pad;36 XpadPad *pad;
37 // GtkToolItem *move_button;
38 // GtkToolItem *tool_items;
39};
40
41G_DEFINE_TYPE_WITH_PRIVATE(XpadToolbar, xpad_toolbar, GTK_TYPE_TOOLBAR)
42
43enum {
44 XPAD_BUTTON_TYPE_SEPARATOR,
45 XPAD_BUTTON_TYPE_BUTTON,
46 XPAD_BUTTON_TYPE_TOGGLE
48};47};
4948
50typedef struct49typedef struct
@@ -94,26 +93,28 @@
94 /*{"Minimize to Tray", "gtk-goto-bottom", 1, N_("Minimize Pads to System Tray")}*/93 /*{"Minimize to Tray", "gtk-goto-bottom", 1, N_("Minimize Pads to System Tray")}*/
95};94};
9695
97
98static G_CONST_RETURN XpadToolbarButton *xpad_toolbar_button_lookup (XpadToolbar *toolbar, const gchar *name);96static G_CONST_RETURN XpadToolbarButton *xpad_toolbar_button_lookup (XpadToolbar *toolbar, const gchar *name);
99static GtkToolItem *xpad_toolbar_button_to_item (XpadToolbar *toolbar, const XpadToolbarButton *button);97static GtkToolItem *xpad_toolbar_button_to_item (XpadToolbar *toolbar, const XpadToolbarButton *button);
100static void xpad_toolbar_button_activated (GtkToolButton *button);98static void xpad_toolbar_button_activated (GtkToolButton *button);
101static void xpad_toolbar_change_buttons (XpadToolbar *toolbar);99static void xpad_toolbar_change_buttons (XpadToolbar *toolbar);
100static void xpad_toolbar_dispose (GObject *object);
102static void xpad_toolbar_finalize (GObject *object);101static void xpad_toolbar_finalize (GObject *object);
103static void xpad_toolbar_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);102static void xpad_toolbar_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
104static void xpad_toolbar_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);103static void xpad_toolbar_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
105static void xpad_toolbar_remove_all_buttons ();104static void xpad_toolbar_remove_all_buttons ();
106static void xpad_toolbar_remove_last_button ();105static void xpad_toolbar_remove_last_button ();
107static void xpad_toolbar_add_button (const gchar *button_name);106static void xpad_toolbar_add_button (const gchar *button_name);
107static gboolean xpad_toolbar_popup_context_menu (GtkToolbar *toolbar, gint x, gint y, gint button);
108
109/* Unfinished new feature of previous developer
108static void xpad_toolbar_remove_button (GtkWidget *button);110static void xpad_toolbar_remove_button (GtkWidget *button);
109static gboolean xpad_toolbar_button_press_event (GtkWidget *widget, GdkEventButton *event);111static gboolean xpad_toolbar_button_press_event (GtkWidget *widget, GdkEventButton *event);
110static gboolean xpad_toolbar_popup_context_menu (GtkToolbar *toolbar, gint x, gint y, gint button);
111static gboolean xpad_toolbar_popup_button_menu (GtkWidget *button, GdkEventButton *event, XpadToolbar *toolbar);112static gboolean xpad_toolbar_popup_button_menu (GtkWidget *button, GdkEventButton *event, XpadToolbar *toolbar);
112
113static gboolean xpad_toolbar_move_button_start (XpadToolbar *toolbar, GtkWidget *button);113static gboolean xpad_toolbar_move_button_start (XpadToolbar *toolbar, GtkWidget *button);
114static gboolean xpad_toolbar_move_button_move (XpadToolbar *toolbar, GdkEventMotion *event);114static gboolean xpad_toolbar_move_button_move (XpadToolbar *toolbar, GdkEventMotion *event);
115static gboolean xpad_toolbar_move_button_move_keyboard (XpadToolbar *toolbar, GdkEventKey *event);115static gboolean xpad_toolbar_move_button_move_keyboard (XpadToolbar *toolbar, GdkEventKey *event);
116static gboolean xpad_toolbar_move_button_end (XpadToolbar *toolbar);116static gboolean xpad_toolbar_move_button_end (XpadToolbar *toolbar);
117*/
117118
118static guint signals[LAST_SIGNAL] = { 0 };119static guint signals[LAST_SIGNAL] = { 0 };
119120
@@ -139,6 +140,7 @@
139 gtktoolbar_class->popup_context_menu = xpad_toolbar_popup_context_menu;140 gtktoolbar_class->popup_context_menu = xpad_toolbar_popup_context_menu;
140 gobject_class->set_property = xpad_toolbar_set_property;141 gobject_class->set_property = xpad_toolbar_set_property;
141 gobject_class->get_property = xpad_toolbar_get_property;142 gobject_class->get_property = xpad_toolbar_get_property;
143 gobject_class->dispose = xpad_toolbar_dispose;
142 gobject_class->finalize = xpad_toolbar_finalize;144 gobject_class->finalize = xpad_toolbar_finalize;
143 145
144 /* Signals */146 /* Signals */
@@ -260,16 +262,13 @@
260 "Pad ",262 "Pad ",
261 "Pad associated with this toolbar",263 "Pad associated with this toolbar",
262 G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));264 G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
263
264 g_type_class_add_private (gobject_class, sizeof (XpadToolbarPrivate));
265}265}
266266
267static void267static void
268xpad_toolbar_init (XpadToolbar *toolbar)268xpad_toolbar_init (XpadToolbar *toolbar)
269{269{
270 toolbar->priv = XPAD_TOOLBAR_GET_PRIVATE (toolbar);270 toolbar->priv = xpad_toolbar_get_instance_private(toolbar);
271271
272 toolbar->priv->pad = NULL;
273 toolbar->priv->move_motion_handler = 0;272 toolbar->priv->move_motion_handler = 0;
274 toolbar->priv->move_button_release_handler = 0;273 toolbar->priv->move_button_release_handler = 0;
275 toolbar->priv->move_key_press_handler = 0;274 toolbar->priv->move_key_press_handler = 0;
@@ -286,17 +285,21 @@
286}285}
287286
288static void287static void
288xpad_toolbar_dispose (GObject *object)
289{
290 XpadToolbar *toolbar = XPAD_TOOLBAR (object);
291
292 if (toolbar->priv->pad) {
293 g_object_unref (toolbar->priv->pad);
294 toolbar->priv->pad = NULL;
295 }
296
297 G_OBJECT_CLASS (xpad_toolbar_parent_class)->dispose (object);
298}
299
300static void
289xpad_toolbar_finalize (GObject *object)301xpad_toolbar_finalize (GObject *object)
290{302{
291 XpadToolbar *toolbar = XPAD_TOOLBAR (object);
292
293 if (toolbar->priv->move_button)
294 g_object_unref (toolbar->priv->move_button);
295 if (toolbar->priv->pad)
296 g_object_unref (toolbar->priv->pad);
297
298 g_signal_handlers_disconnect_matched (xpad_settings (), G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, toolbar);
299
300 G_OBJECT_CLASS (xpad_toolbar_parent_class)->finalize (object);303 G_OBJECT_CLASS (xpad_toolbar_parent_class)->finalize (object);
301}304}
302305
@@ -340,30 +343,10 @@
340 }343 }
341}344}
342345
343static gboolean
344xpad_toolbar_button_press_event (GtkWidget *widget, GdkEventButton *event)
345{
346 /* Ignore double-clicks and triple-clicks */
347 if (event->button == 3 && event->type == GDK_BUTTON_PRESS)
348 {
349 XpadToolbar *toolbar = XPAD_TOOLBAR (g_object_get_data (G_OBJECT (widget), "xpad-toolbar"));
350 xpad_toolbar_popup_button_menu (widget, event, toolbar);
351 return TRUE;
352 }
353 else if (event->button == 2 && event->type == GDK_BUTTON_PRESS)
354 {
355 XpadToolbar *toolbar = XPAD_TOOLBAR (g_object_get_data (G_OBJECT (widget), "xpad-toolbar"));
356 xpad_toolbar_move_button_start (toolbar, widget);
357 return TRUE;
358 }
359
360 return FALSE;
361}
362
363static G_CONST_RETURN XpadToolbarButton *346static G_CONST_RETURN XpadToolbarButton *
364xpad_toolbar_button_lookup (XpadToolbar *toolbar, const gchar *name)347xpad_toolbar_button_lookup (XpadToolbar *toolbar, const gchar *name)
365{348{
366 gint i;349 guint i;
367 for (i = 0; i < G_N_ELEMENTS (buttons); i++)350 for (i = 0; i < G_N_ELEMENTS (buttons); i++)
368 if (!g_ascii_strcasecmp (name, buttons[i].name))351 if (!g_ascii_strcasecmp (name, buttons[i].name))
369 return &buttons[i];352 return &buttons[i];
@@ -375,7 +358,7 @@
375xpad_toolbar_button_to_item (XpadToolbar *toolbar, const XpadToolbarButton *button)358xpad_toolbar_button_to_item (XpadToolbar *toolbar, const XpadToolbarButton *button)
376{359{
377 GtkToolItem *item;360 GtkToolItem *item;
378 GtkWidget *child;361 // GtkWidget *child;
379362
380 item = GTK_TOOL_ITEM (g_object_get_data (G_OBJECT (toolbar), button->name));363 item = GTK_TOOL_ITEM (g_object_get_data (G_OBJECT (toolbar), button->name));
381 if (item)364 if (item)
@@ -406,17 +389,6 @@
406 if (button->desc)389 if (button->desc)
407 gtk_tool_item_set_tooltip_text (item, _(button->desc));390 gtk_tool_item_set_tooltip_text (item, _(button->desc));
408391
409 // This won't work anymore because we make some buttons insensitive
410 // so we cannot handle right clicks on them anymore. That's why we just add "Remove all butons"
411 // and "Remove last button" to toolbar context menu
412 /*
413 child = gtk_bin_get_child (GTK_BIN (item));
414 if (child)
415 {
416 g_signal_connect_swapped (child, "button-press-event", G_CALLBACK (xpad_toolbar_button_press_event), item);
417 }
418 */
419
420 return item;392 return item;
421}393}
422394
@@ -437,7 +409,8 @@
437{409{
438 GList *list, *temp;410 GList *list, *temp;
439 const GSList *slist, *stemp;411 const GSList *slist, *stemp;
440 gint i = 0, j;412 gint i = 0;
413 guint j = 0;
441 GtkToolItem *item;414 GtkToolItem *item;
442 415
443 list = gtk_container_get_children (GTK_CONTAINER (toolbar));416 list = gtk_container_get_children (GTK_CONTAINER (toolbar));
@@ -446,6 +419,7 @@
446 gtk_widget_destroy (temp->data);419 gtk_widget_destroy (temp->data);
447 420
448 g_list_free (list);421 g_list_free (list);
422 g_list_free (temp);
449423
450 for (j = 0; j < G_N_ELEMENTS (buttons); j++)424 for (j = 0; j < G_N_ELEMENTS (buttons); j++)
451 g_object_set_data (G_OBJECT (toolbar), buttons[j].name, NULL);425 g_object_set_data (G_OBJECT (toolbar), buttons[j].name, NULL);
@@ -510,48 +484,247 @@
510}484}
511485
512static void486static void
487menu_deactivated (GtkWidget *menu, GtkToolbar *toolbar)
488{
489 g_signal_emit (toolbar, signals[POPDOWN], 0, menu);
490}
491
492static gboolean
493xpad_toolbar_popup_context_menu (GtkToolbar *toolbar, gint x, gint y, gint button)
494{
495 GtkWidget *menu;
496 const GSList *current_buttons;
497 guint i;
498
499 menu = gtk_menu_new ();
500
501 current_buttons = xpad_settings_get_toolbar_buttons (xpad_settings ());
502
503 gboolean is_button = FALSE;
504
505 for (i = 0; i < G_N_ELEMENTS (buttons); i++)
506 {
507 const GSList *j;
508 GtkWidget *item, *image;
509
510 if (strcmp (buttons[i].name, "sep") != 0)
511 {
512 for (j = current_buttons; j; j = j->next)
513 if (!g_ascii_strcasecmp (j->data, buttons[i].name))
514 break;
515
516 if (j)
517 {
518 is_button = TRUE;
519 continue;
520 }
521 }
522 else
523 {
524 /* Don't let user add separators until we can allow clicks on them. */
525 continue;
526 }
527
528 item = gtk_image_menu_item_new_with_mnemonic (buttons[i].menu_desc);
529
530 image = gtk_image_new_from_stock (GTK_STOCK_ADD, GTK_ICON_SIZE_MENU);
531 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
532
533 g_signal_connect_swapped (item, "activate", G_CALLBACK (xpad_toolbar_add_button), (gpointer) buttons[i].name);
534
535 gtk_menu_attach (GTK_MENU (menu), item, 0, 1, i, i + 1);
536 gtk_widget_show (item);
537 }
538
539 if (is_button)
540 {
541 GtkWidget *item, *image;
542
543 item = gtk_image_menu_item_new_with_mnemonic (N_("Remove All _Buttons"));
544
545 image = gtk_image_new_from_stock (GTK_STOCK_ADD, GTK_ICON_SIZE_MENU);
546 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
547
548 g_signal_connect_swapped (item, "activate", G_CALLBACK (xpad_toolbar_remove_all_buttons), NULL);
549
550 gtk_menu_attach (GTK_MENU (menu), item, 0, 1, i, i + 1);
551 gtk_widget_show (item);
552
553 i++;
554
555 item = gtk_image_menu_item_new_with_mnemonic (N_("Remo_ve Last Button"));
556
557 image = gtk_image_new_from_stock (GTK_STOCK_ADD, GTK_ICON_SIZE_MENU);
558 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
559
560 g_signal_connect_swapped (item, "activate", G_CALLBACK (xpad_toolbar_remove_last_button), NULL);
561
562 gtk_menu_attach (GTK_MENU (menu), item, 0, 1, i, i + 1);
563 gtk_widget_show (item);
564 }
565
566 g_signal_connect (menu, "deactivate", G_CALLBACK (menu_deactivated), toolbar);
567
568 gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, (guint) ((button < 0) ? 0 : button), gtk_get_current_event_time ());
569
570 g_signal_emit (toolbar, signals[POPUP], 0, menu);
571
572 return TRUE;
573}
574
575static void
576xpad_toolbar_enable_button (XpadToolbar *toolbar, const XpadToolbarButton *button, gboolean enable)
577{
578 g_return_if_fail (button);
579 GtkToolItem *item = xpad_toolbar_button_to_item (toolbar, button);
580 if (item)
581 gtk_widget_set_sensitive (GTK_WIDGET (item), enable);
582}
583
584void
585xpad_toolbar_enable_undo_button (XpadToolbar *toolbar, gboolean enable)
586{
587 const XpadToolbarButton *button = xpad_toolbar_button_lookup (toolbar, "Undo");
588 xpad_toolbar_enable_button (toolbar, button, enable);
589}
590
591void
592xpad_toolbar_enable_redo_button (XpadToolbar *toolbar, gboolean enable)
593{
594 const XpadToolbarButton *button = xpad_toolbar_button_lookup (toolbar, "Redo");
595 xpad_toolbar_enable_button (toolbar, button, enable);
596}
597
598void
599xpad_toolbar_enable_cut_button (XpadToolbar *toolbar, gboolean enable)
600{
601 const XpadToolbarButton *button = xpad_toolbar_button_lookup (toolbar, "Cut");
602 xpad_toolbar_enable_button (toolbar, button, enable);
603}
604
605void
606xpad_toolbar_enable_copy_button (XpadToolbar *toolbar, gboolean enable)
607{
608 const XpadToolbarButton *button = xpad_toolbar_button_lookup (toolbar, "Copy");
609 xpad_toolbar_enable_button (toolbar, button, enable);
610}
611
612void
613xpad_toolbar_enable_paste_button (XpadToolbar *toolbar, gboolean enable)
614{
615 const XpadToolbarButton *button = xpad_toolbar_button_lookup (toolbar, "Paste");
616 xpad_toolbar_enable_button (toolbar, button, enable);
617}
618
619/*
620 * The code below was code in progress of a previous developer
621static gboolean
622xpad_toolbar_button_press_event (GtkWidget *widget, GdkEventButton *event)
623{
624 // Ignore double-clicks and triple-clicks
625 if (event->button == 3 && event->type == GDK_BUTTON_PRESS)
626 {
627 XpadToolbar *toolbar = XPAD_TOOLBAR (g_object_get_data (G_OBJECT (widget), "xpad-toolbar"));
628 xpad_toolbar_popup_button_menu (widget, event, toolbar);
629 return TRUE;
630 }
631 else if (event->button == 2 && event->type == GDK_BUTTON_PRESS)
632 {
633 XpadToolbar *toolbar = XPAD_TOOLBAR (g_object_get_data (G_OBJECT (widget), "xpad-toolbar"));
634 xpad_toolbar_move_button_start (toolbar, widget);
635 return TRUE;
636 }
637
638 return FALSE;
639}
640
641static gboolean
642xpad_toolbar_popup_button_menu (GtkWidget *button, GdkEventButton *event, XpadToolbar *toolbar)
643{
644 GtkWidget *menu;
645 GtkWidget *item, *image;
646
647 menu = gtk_menu_new ();
648
649
650 item = gtk_image_menu_item_new_with_mnemonic (_("_Remove From Toolbar"));
651
652 image = gtk_image_new_from_stock (GTK_STOCK_REMOVE, GTK_ICON_SIZE_MENU);
653 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
654
655 g_signal_connect_swapped (item, "activate", G_CALLBACK (xpad_toolbar_remove_button), button);
656 gtk_menu_attach (GTK_MENU (menu), item, 0, 1, 0, 1);
657 gtk_widget_show (item);
658
659
660 item = gtk_menu_item_new_with_mnemonic (_("_Move"));
661 g_signal_connect_swapped (item, "activate", G_CALLBACK (move_menu_item_activated), button);
662 gtk_menu_attach (GTK_MENU (menu), item, 0, 1, 1, 2);
663 gtk_widget_show (item);
664
665
666 g_signal_connect (menu, "deactivate", G_CALLBACK (menu_deactivated), toolbar);
667
668 gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, event ? event->button : 0, gtk_get_current_event_time ());
669
670 g_signal_emit (toolbar, signals[POPUP], 0, menu);
671
672 return TRUE;
673}
674
675static void
513xpad_toolbar_remove_button (GtkWidget *button)676xpad_toolbar_remove_button (GtkWidget *button)
514{677{
515 gint button_num;678 gint button_num;
516 679
517 button_num = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (button), "xpad-button-num"));680 button_num = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (button), "xpad-button-num"));
518 681
519 xpad_settings_remove_toolbar_button (xpad_settings (), button_num);682 xpad_settings_remove_toolbar_button (xpad_settings (), button_num);
520}683}
521684
685static void
686move_menu_item_activated (GtkWidget *button)
687{
688 XpadToolbar *toolbar;
689
690 toolbar = XPAD_TOOLBAR (g_object_get_data (G_OBJECT (button), "xpad-toolbar"));
691
692 xpad_toolbar_move_button_start (toolbar, button);
693}
694
522static gboolean695static gboolean
523xpad_toolbar_move_button_start (XpadToolbar *toolbar, GtkWidget *button)696xpad_toolbar_move_button_start (XpadToolbar *toolbar, GtkWidget *button)
524{697{
525 GdkGrabStatus status;698 GdkGrabStatus status;
526 GdkCursor *fleur_cursor;699 GdkCursor *fleur_cursor;
527 GtkWidget *widget;700 GtkWidget *widget;
528 701
529 widget = GTK_WIDGET (toolbar);702 widget = GTK_WIDGET (toolbar);
530 gtk_grab_add (widget);703 gtk_grab_add (widget);
531 704
532 fleur_cursor = gdk_cursor_new (GDK_FLEUR);705 fleur_cursor = gdk_cursor_new (GDK_FLEUR);
533 706
534 g_object_ref (button);707 // g_object_ref (button);
535 toolbar->priv->move_removed = FALSE;708 toolbar->priv->move_removed = FALSE;
536 toolbar->priv->move_button = GTK_TOOL_ITEM (button);709 toolbar->priv->move_button = GTK_TOOL_ITEM (button);
537 toolbar->priv->move_index = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (button), "xpad-button-num"));710 toolbar->priv->move_index = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (button), "xpad-button-num"));
538 711
539 toolbar->priv->move_button_release_handler = g_signal_connect (toolbar, "button-release-event", G_CALLBACK (xpad_toolbar_move_button_end), NULL);712 toolbar->priv->move_button_release_handler = g_signal_connect (toolbar, "button-release-event", G_CALLBACK (xpad_toolbar_move_button_end), NULL);
540 toolbar->priv->move_key_press_handler = g_signal_connect (toolbar, "key-press-event", G_CALLBACK (xpad_toolbar_move_button_move_keyboard), NULL);713 toolbar->priv->move_key_press_handler = g_signal_connect (toolbar, "key-press-event", G_CALLBACK (xpad_toolbar_move_button_move_keyboard), NULL);
541 toolbar->priv->move_motion_handler = g_signal_connect (toolbar, "motion-notify-event", G_CALLBACK (xpad_toolbar_move_button_move), NULL);714 toolbar->priv->move_motion_handler = g_signal_connect (toolbar, "motion-notify-event", G_CALLBACK (xpad_toolbar_move_button_move), NULL);
542 715
543 status = gdk_pointer_grab (widget->window, FALSE,716 status = gdk_pointer_grab (widget->window, FALSE,
544 GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK, NULL,717 GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK, NULL,
545 fleur_cursor, gtk_get_current_event_time ());718 fleur_cursor, gtk_get_current_event_time ());
546 719
547 gdk_cursor_unref (fleur_cursor);720 gdk_cursor_unref (fleur_cursor);
548 gdk_flush ();721 gdk_flush ();
549 722
550 if (status != GDK_GRAB_SUCCESS)723 if (status != GDK_GRAB_SUCCESS)
551 {724 {
552 xpad_toolbar_move_button_end (toolbar);725 xpad_toolbar_move_button_end (toolbar);
553 }726 }
554 727
555 return TRUE;728 return TRUE;
556}729}
557730
@@ -565,27 +738,27 @@
565 toolbar->priv->move_removed = TRUE;738 toolbar->priv->move_removed = TRUE;
566 gtk_container_remove (GTK_CONTAINER (toolbar), GTK_WIDGET (toolbar->priv->move_button));739 gtk_container_remove (GTK_CONTAINER (toolbar), GTK_WIDGET (toolbar->priv->move_button));
567 }740 }
568 741
569 if (toolbar->priv->move_index > 0)742 if (toolbar->priv->move_index > 0)
570 toolbar->priv->move_index--;743 toolbar->priv->move_index--;
571 744
572 gtk_toolbar_set_drop_highlight_item (GTK_TOOLBAR (toolbar), toolbar->priv->move_button, toolbar->priv->move_index);745 gtk_toolbar_set_drop_highlight_item (GTK_TOOLBAR (toolbar), toolbar->priv->move_button, toolbar->priv->move_index);
573 }746 }
574 else if (event->keyval == GDK_Right || event->keyval == GDK_KP_Right)747 else if (event->keyval == GDK_Right || event->keyval == GDK_KP_Right)
575 {748 {
576 gint max;749 gint max;
577 750
578 if (!toolbar->priv->move_removed)751 if (!toolbar->priv->move_removed)
579 {752 {
580 toolbar->priv->move_removed = TRUE;753 toolbar->priv->move_removed = TRUE;
581 gtk_container_remove (GTK_CONTAINER (toolbar), GTK_WIDGET (toolbar->priv->move_button));754 gtk_container_remove (GTK_CONTAINER (toolbar), GTK_WIDGET (toolbar->priv->move_button));
582 }755 }
583 756
584 max = gtk_toolbar_get_n_items (GTK_TOOLBAR (toolbar)) - 2;757 max = gtk_toolbar_get_n_items (GTK_TOOLBAR (toolbar)) - 2;
585 758
586 if (toolbar->priv->move_index < max)759 if (toolbar->priv->move_index < max)
587 toolbar->priv->move_index++;760 toolbar->priv->move_index++;
588 761
589 gtk_toolbar_set_drop_highlight_item (GTK_TOOLBAR (toolbar), toolbar->priv->move_button, toolbar->priv->move_index);762 gtk_toolbar_set_drop_highlight_item (GTK_TOOLBAR (toolbar), toolbar->priv->move_button, toolbar->priv->move_index);
590 }763 }
591 else if (event->keyval == GDK_space || event->keyval == GDK_KP_Space || event->keyval == GDK_Return || event->keyval == GDK_KP_Enter)764 else if (event->keyval == GDK_space || event->keyval == GDK_KP_Space || event->keyval == GDK_Return || event->keyval == GDK_KP_Enter)
@@ -593,7 +766,7 @@
593 xpad_toolbar_move_button_end (toolbar);766 xpad_toolbar_move_button_end (toolbar);
594 return TRUE;767 return TRUE;
595 }768 }
596 769
597 return TRUE;770 return TRUE;
598}771}
599772
@@ -601,21 +774,21 @@
601xpad_toolbar_move_button_move (XpadToolbar *toolbar, GdkEventMotion *event)774xpad_toolbar_move_button_move (XpadToolbar *toolbar, GdkEventMotion *event)
602{775{
603 gint max;776 gint max;
604 777
605 if (!toolbar->priv->move_removed)778 if (!toolbar->priv->move_removed)
606 {779 {
607 toolbar->priv->move_removed = TRUE;780 toolbar->priv->move_removed = TRUE;
608 gtk_container_remove (GTK_CONTAINER (toolbar), GTK_WIDGET (toolbar->priv->move_button));781 gtk_container_remove (GTK_CONTAINER (toolbar), GTK_WIDGET (toolbar->priv->move_button));
609 }782 }
610 783
611 toolbar->priv->move_index = gtk_toolbar_get_drop_index (GTK_TOOLBAR (toolbar), event->x, event->y);784 toolbar->priv->move_index = gtk_toolbar_get_drop_index (GTK_TOOLBAR (toolbar), event->x, event->y);
612 785
613 /* Must not move past separator or grip */786 // Must not move past separator or grip
614 max = gtk_toolbar_get_n_items (GTK_TOOLBAR (toolbar)) - 2;787 max = gtk_toolbar_get_n_items (GTK_TOOLBAR (toolbar)) - 2;
615 toolbar->priv->move_index = MIN (toolbar->priv->move_index, max);788 toolbar->priv->move_index = MIN (toolbar->priv->move_index, max);
616 789
617 gtk_toolbar_set_drop_highlight_item (GTK_TOOLBAR (toolbar), toolbar->priv->move_button, toolbar->priv->move_index);790 gtk_toolbar_set_drop_highlight_item (GTK_TOOLBAR (toolbar), toolbar->priv->move_button, toolbar->priv->move_index);
618 791
619 return TRUE;792 return TRUE;
620}793}
621794
@@ -624,210 +797,34 @@
624{797{
625 gint old_spot;798 gint old_spot;
626 gint max;799 gint max;
627 800
628 g_signal_handler_disconnect (toolbar, toolbar->priv->move_button_release_handler);801 g_signal_handler_disconnect (toolbar, toolbar->priv->move_button_release_handler);
629 g_signal_handler_disconnect (toolbar, toolbar->priv->move_key_press_handler);802 g_signal_handler_disconnect (toolbar, toolbar->priv->move_key_press_handler);
630 g_signal_handler_disconnect (toolbar, toolbar->priv->move_motion_handler);803 g_signal_handler_disconnect (toolbar, toolbar->priv->move_motion_handler);
631 toolbar->priv->move_button_release_handler = 0;804 toolbar->priv->move_button_release_handler = 0;
632 toolbar->priv->move_key_press_handler = 0;805 toolbar->priv->move_key_press_handler = 0;
633 toolbar->priv->move_motion_handler = 0;806 toolbar->priv->move_motion_handler = 0;
634 807
635 gtk_toolbar_set_drop_highlight_item (GTK_TOOLBAR (toolbar), NULL, 0);808 gtk_toolbar_set_drop_highlight_item (GTK_TOOLBAR (toolbar), NULL, 0);
636 809
637 old_spot = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (toolbar->priv->move_button), "xpad-button-num"));810 old_spot = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (toolbar->priv->move_button), "xpad-button-num"));
638 811
639 /* Must not move past separator or grip */812 // Must not move past separator or grip
640 max = gtk_toolbar_get_n_items (GTK_TOOLBAR (toolbar)) - 2;813 max = gtk_toolbar_get_n_items (GTK_TOOLBAR (toolbar)) - 2;
641 toolbar->priv->move_index = MIN (toolbar->priv->move_index, max);814 toolbar->priv->move_index = MIN (toolbar->priv->move_index, max);
642 815
643 if (!xpad_settings_move_toolbar_button (xpad_settings (), old_spot, toolbar->priv->move_index) &&816 if (!xpad_settings_move_toolbar_button (xpad_settings (), old_spot, toolbar->priv->move_index) &&
644 toolbar->priv->move_removed)817 toolbar->priv->move_removed)
645 {818 {
646 gtk_toolbar_insert (GTK_TOOLBAR (toolbar), toolbar->priv->move_button, toolbar->priv->move_index);819 gtk_toolbar_insert (GTK_TOOLBAR (toolbar), toolbar->priv->move_button, toolbar->priv->move_index);
647 }820 }
648 821
649 g_object_unref (toolbar->priv->move_button);822 // g_object_unref (toolbar->priv->move_button);
650 toolbar->priv->move_button = NULL;823 toolbar->priv->move_button = NULL;
651 824
652 gtk_grab_remove (GTK_WIDGET (toolbar));825 gtk_grab_remove (GTK_WIDGET (toolbar));
653 gdk_pointer_ungrab (gtk_get_current_event_time ());826 gdk_pointer_ungrab (gtk_get_current_event_time ());
654 return TRUE;827 return TRUE;
655}828}
656829
657static void830*/
658move_menu_item_activated (GtkWidget *button)
659{
660 XpadToolbar *toolbar;
661
662 toolbar = XPAD_TOOLBAR (g_object_get_data (G_OBJECT (button), "xpad-toolbar"));
663
664 xpad_toolbar_move_button_start (toolbar, button);
665}
666
667static void
668menu_deactivated (GtkWidget *menu, GtkToolbar *toolbar)
669{
670 g_signal_emit (toolbar, signals[POPDOWN], 0, menu);
671}
672
673static gboolean
674xpad_toolbar_popup_button_menu (GtkWidget *button, GdkEventButton *event, XpadToolbar *toolbar)
675{
676 GtkWidget *menu;
677 GtkWidget *item, *image;
678
679 menu = gtk_menu_new ();
680
681
682 item = gtk_image_menu_item_new_with_mnemonic (_("_Remove From Toolbar"));
683
684 image = gtk_image_new_from_stock (GTK_STOCK_REMOVE, GTK_ICON_SIZE_MENU);
685 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
686
687 g_signal_connect_swapped (item, "activate", G_CALLBACK (xpad_toolbar_remove_button), button);
688 gtk_menu_attach (GTK_MENU (menu), item, 0, 1, 0, 1);
689 gtk_widget_show (item);
690
691
692 item = gtk_menu_item_new_with_mnemonic (_("_Move"));
693 g_signal_connect_swapped (item, "activate", G_CALLBACK (move_menu_item_activated), button);
694 gtk_menu_attach (GTK_MENU (menu), item, 0, 1, 1, 2);
695 gtk_widget_show (item);
696
697
698 g_signal_connect (menu, "deactivate", G_CALLBACK (menu_deactivated), toolbar);
699
700 gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, event ? event->button : 0, gtk_get_current_event_time ());
701
702 g_signal_emit (toolbar, signals[POPUP], 0, menu);
703
704 return TRUE;
705}
706
707static gboolean
708xpad_toolbar_popup_context_menu (GtkToolbar *toolbar, gint x, gint y, gint button)
709{
710 GtkWidget *menu;
711 const GSList *current_buttons;
712 gint i;
713
714 menu = gtk_menu_new ();
715
716 current_buttons = xpad_settings_get_toolbar_buttons (xpad_settings ());
717
718 gboolean is_button = FALSE;
719
720 for (i = 0; i < G_N_ELEMENTS (buttons); i++)
721 {
722 const GSList *j;
723 GtkWidget *item, *image;
724
725 if (strcmp (buttons[i].name, "sep") != 0)
726 {
727 for (j = current_buttons; j; j = j->next)
728 if (!g_ascii_strcasecmp (j->data, buttons[i].name))
729 break;
730
731 if (j)
732 {
733 is_button = TRUE;
734 continue;
735 }
736 }
737 else
738 {
739 /* Don't let user add separators until we can allow clicks on them. */
740 continue;
741 }
742
743 item = gtk_image_menu_item_new_with_mnemonic (buttons[i].menu_desc);
744
745 image = gtk_image_new_from_stock (GTK_STOCK_ADD, GTK_ICON_SIZE_MENU);
746 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
747
748 g_signal_connect_swapped (item, "activate", G_CALLBACK (xpad_toolbar_add_button), (gpointer) buttons[i].name);
749
750 gtk_menu_attach (GTK_MENU (menu), item, 0, 1, i, i + 1);
751 gtk_widget_show (item);
752 }
753
754 if (is_button)
755 {
756 GtkWidget *item, *image;
757
758 item = gtk_image_menu_item_new_with_mnemonic (N_("Remove All _Buttons"));
759
760 image = gtk_image_new_from_stock (GTK_STOCK_ADD, GTK_ICON_SIZE_MENU);
761 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
762
763 g_signal_connect_swapped (item, "activate", G_CALLBACK (xpad_toolbar_remove_all_buttons), NULL);
764
765 gtk_menu_attach (GTK_MENU (menu), item, 0, 1, i, i + 1);
766 gtk_widget_show (item);
767
768 i++;
769
770 item = gtk_image_menu_item_new_with_mnemonic (N_("Remo_ve Last Button"));
771
772 image = gtk_image_new_from_stock (GTK_STOCK_ADD, GTK_ICON_SIZE_MENU);
773 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
774
775 g_signal_connect_swapped (item, "activate", G_CALLBACK (xpad_toolbar_remove_last_button), NULL);
776
777 gtk_menu_attach (GTK_MENU (menu), item, 0, 1, i, i + 1);
778 gtk_widget_show (item);
779 }
780
781 g_signal_connect (menu, "deactivate", G_CALLBACK (menu_deactivated), toolbar);
782
783 gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, (button < 0) ? 0 : button, gtk_get_current_event_time ());
784
785 g_signal_emit (toolbar, signals[POPUP], 0, menu);
786
787 return TRUE;
788}
789
790static void
791xpad_toolbar_enable_button (XpadToolbar *toolbar, const XpadToolbarButton *button, gboolean enable)
792{
793 g_return_if_fail (button);
794 GtkToolItem *item = xpad_toolbar_button_to_item (toolbar, button);
795 if (item)
796 gtk_widget_set_sensitive (GTK_WIDGET (item), enable);
797}
798
799void
800xpad_toolbar_enable_undo_button (XpadToolbar *toolbar, gboolean enable)
801{
802 const XpadToolbarButton *button = xpad_toolbar_button_lookup (toolbar, "Undo");
803 xpad_toolbar_enable_button (toolbar, button, enable);
804}
805
806void
807xpad_toolbar_enable_redo_button (XpadToolbar *toolbar, gboolean enable)
808{
809 const XpadToolbarButton *button = xpad_toolbar_button_lookup (toolbar, "Redo");
810 xpad_toolbar_enable_button (toolbar, button, enable);
811}
812
813void
814xpad_toolbar_enable_cut_button (XpadToolbar *toolbar, gboolean enable)
815{
816 const XpadToolbarButton *button = xpad_toolbar_button_lookup (toolbar, "Cut");
817 xpad_toolbar_enable_button (toolbar, button, enable);
818}
819
820void
821xpad_toolbar_enable_copy_button (XpadToolbar *toolbar, gboolean enable)
822{
823 const XpadToolbarButton *button = xpad_toolbar_button_lookup (toolbar, "Copy");
824 xpad_toolbar_enable_button (toolbar, button, enable);
825}
826
827void
828xpad_toolbar_enable_paste_button (XpadToolbar *toolbar, gboolean enable)
829{
830 const XpadToolbarButton *button = xpad_toolbar_button_lookup (toolbar, "Paste");
831 xpad_toolbar_enable_button (toolbar, button, enable);
832}
833
834831
=== modified file 'src/xpad-tray.c'
--- src/xpad-tray.c 2013-10-09 14:46:10 +0000
+++ src/xpad-tray.c 2013-10-18 18:35:35 +0000
@@ -33,17 +33,19 @@
33static void xpad_tray_popup_menu_cb (GtkStatusIcon *icon, guint button, guint time);33static void xpad_tray_popup_menu_cb (GtkStatusIcon *icon, guint button, guint time);
3434
35static GtkStatusIcon *docklet = NULL;35static GtkStatusIcon *docklet = NULL;
36static GtkWidget *menu = NULL;
3637
37void38void
38xpad_tray_open (void)39xpad_tray_open (void)
39{40{
40 GtkIconTheme *theme;41 GtkIconTheme *theme;
41 42
42 xpad_tray_close ();43 // xpad_tray_close ();
43 44
44 theme = gtk_icon_theme_get_default ();45 theme = gtk_icon_theme_get_default ();
45 if (!gtk_icon_theme_has_icon (theme, PACKAGE))46 if (!gtk_icon_theme_has_icon (theme, PACKAGE)) {
46 return;47 return;
48 }
47 49
48 if (gtk_icon_theme_has_icon (theme, "xpad-panel"))50 if (gtk_icon_theme_has_icon (theme, "xpad-panel"))
49 {51 {
@@ -68,6 +70,9 @@
68 g_object_unref (docklet);70 g_object_unref (docklet);
69 docklet = NULL;71 docklet = NULL;
70 }72 }
73
74 if (menu)
75 gtk_widget_destroy(menu);
71}76}
7277
73gboolean78gboolean
@@ -111,7 +116,7 @@
111static void116static void
112xpad_tray_popup_menu_cb (GtkStatusIcon *icon, guint button, guint time)117xpad_tray_popup_menu_cb (GtkStatusIcon *icon, guint button, guint time)
113{118{
114 GtkWidget *menu, *item;119 GtkWidget *item;
115 GSList *pads, *l;120 GSList *pads, *l;
116 gint n;121 gint n;
117 122
@@ -126,7 +131,7 @@
126 item = gtk_separator_menu_item_new ();131 item = gtk_separator_menu_item_new ();
127 gtk_container_add (GTK_CONTAINER (menu), item);132 gtk_container_add (GTK_CONTAINER (menu), item);
128 gtk_widget_show (item);133 gtk_widget_show (item);
129 134
130 item = gtk_menu_item_new_with_mnemonic (_("_Show All"));135 item = gtk_menu_item_new_with_mnemonic (_("_Show All"));
131 g_signal_connect_swapped (item, "activate", G_CALLBACK (menu_show_all), xpad_app_get_pad_group ());136 g_signal_connect_swapped (item, "activate", G_CALLBACK (menu_show_all), xpad_app_get_pad_group ());
132 gtk_container_add (GTK_CONTAINER (menu), item);137 gtk_container_add (GTK_CONTAINER (menu), item);
@@ -202,4 +207,3 @@
202 g_slist_foreach (pads, (GFunc) gtk_window_present, NULL);207 g_slist_foreach (pads, (GFunc) gtk_window_present, NULL);
203 g_slist_free (pads);208 g_slist_free (pads);
204}209}
205
206210
=== modified file 'src/xpad-undo.c'
--- src/xpad-undo.c 2013-10-09 04:24:36 +0000
+++ src/xpad-undo.c 2013-10-18 18:35:35 +0000
@@ -26,8 +26,18 @@
26#include "xpad-undo.h"26#include "xpad-undo.h"
27#include "xpad-text-buffer.h"27#include "xpad-text-buffer.h"
2828
29G_DEFINE_TYPE(XpadUndo, xpad_undo, G_TYPE_OBJECT)29struct XpadUndoPrivate
30#define XPAD_UNDO_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), XPAD_TYPE_UNDO, XpadUndoPrivate))30{
31 XpadTextBuffer *buffer;
32 /* We always redo the next element in the list but undo the current one.
33 We insert this guard with NULL data in the beginning to ease coding all of this */
34 GList *history_start;
35 GList *history_curr;
36 guint user_action;
37 gboolean frozen;
38};
39
40G_DEFINE_TYPE_WITH_PRIVATE(XpadUndo, xpad_undo, G_TYPE_OBJECT)
3141
32static GObject* xpad_undo_constructor(GType gtype, guint n_properties, GObjectConstructParam *properties);42static GObject* xpad_undo_constructor(GType gtype, guint n_properties, GObjectConstructParam *properties);
33static void xpad_undo_dispose (GObject *object);43static void xpad_undo_dispose (GObject *object);
@@ -62,18 +72,6 @@
62static void xpad_undo_insert_text (GtkTextBuffer *buffer, GtkTextIter *location, gchar *text, gint len, XpadUndo *undo);72static void xpad_undo_insert_text (GtkTextBuffer *buffer, GtkTextIter *location, gchar *text, gint len, XpadUndo *undo);
63static void xpad_undo_delete_range (GtkTextBuffer *buffer, GtkTextIter *start, GtkTextIter *end, XpadUndo *undo);73static void xpad_undo_delete_range (GtkTextBuffer *buffer, GtkTextIter *start, GtkTextIter *end, XpadUndo *undo);
6474
65struct XpadUndoPrivate
66{
67 XpadTextBuffer *buffer;
68 XpadPad *pad;
69 /* We always redo the next element in the list but undo the current one.
70 We insert this guard with NULL data in the beginning to ease coding all of this */
71 GList *history_start;
72 GList *history_curr;
73 guint user_action;
74 gboolean frozen;
75};
76
77enum75enum
78{76{
79 PROP_0,77 PROP_0,
@@ -92,8 +90,6 @@
92{90{
93 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);91 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
9492
95 /* TODO: neither dispose nor finalize neither in here nor in xpad-pad.c are
96 actually called, have to fix cleaning up */
97 gobject_class->dispose = xpad_undo_dispose;93 gobject_class->dispose = xpad_undo_dispose;
98 gobject_class->finalize = xpad_undo_finalize;94 gobject_class->finalize = xpad_undo_finalize;
99 gobject_class->set_property = xpad_undo_set_property;95 gobject_class->set_property = xpad_undo_set_property;
@@ -106,18 +102,14 @@
106 "Pad Buffer",102 "Pad Buffer",
107 "Pad buffer connected to this undo",103 "Pad buffer connected to this undo",
108 G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));104 G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
109
110 g_type_class_add_private (gobject_class, sizeof (XpadUndoPrivate));
111}105}
112106
113
114static void107static void
115xpad_undo_init (XpadUndo *undo)108xpad_undo_init (XpadUndo *undo)
116{109{
117 undo->priv = XPAD_UNDO_GET_PRIVATE (undo);110 undo->priv = xpad_undo_get_instance_private(undo);
118111
119 undo->priv->buffer = NULL;112 undo->priv->buffer = NULL;
120 undo->priv->buffer = NULL;
121 undo->priv->history_start = g_list_append (NULL, NULL);113 undo->priv->history_start = g_list_append (NULL, NULL);
122 undo->priv->history_curr = undo->priv->history_start;114 undo->priv->history_curr = undo->priv->history_start;
123 undo->priv->user_action = 0;115 undo->priv->user_action = 0;
@@ -133,7 +125,7 @@
133 XpadUndo *undo = XPAD_UNDO (obj);125 XpadUndo *undo = XPAD_UNDO (obj);
134126
135 /* Assert user passed buffer and pad as construct parameter */127 /* Assert user passed buffer and pad as construct parameter */
136 gint i;128 guint i;
137 gboolean found_buffer = FALSE;129 gboolean found_buffer = FALSE;
138 for (i = 0; i < n_properties; i++)130 for (i = 0; i < n_properties; i++)
139 {131 {
@@ -148,7 +140,6 @@
148 if (!found_buffer)140 if (!found_buffer)
149 {141 {
150 undo->priv->buffer = NULL;142 undo->priv->buffer = NULL;
151 undo->priv->buffer = NULL;
152 g_warning ("XpadTextBuffer is not passed to XpadUndo constructor, undo will not work!\n");143 g_warning ("XpadTextBuffer is not passed to XpadUndo constructor, undo will not work!\n");
153 }144 }
154 else145 else
@@ -168,9 +159,7 @@
168{159{
169 XpadUndo *undo = XPAD_UNDO (object);160 XpadUndo *undo = XPAD_UNDO (object);
170161
171 if (undo->priv->buffer && G_IS_OBJECT (undo->priv->buffer))162 if (undo->priv->buffer) {
172 {
173 g_object_unref (undo->priv->buffer);
174 undo->priv->buffer = NULL;163 undo->priv->buffer = NULL;
175 }164 }
176165
@@ -186,7 +175,7 @@
186 xpad_undo_clear_history (undo);175 xpad_undo_clear_history (undo);
187176
188 /* remove left guard */177 /* remove left guard */
189 g_list_free (undo->priv->history_start);178 g_list_free(undo->priv->history_start);
190179
191 G_OBJECT_CLASS (xpad_undo_parent_class)->finalize (object);180 G_OBJECT_CLASS (xpad_undo_parent_class)->finalize (object);
192}181}
@@ -595,4 +584,3 @@
595{584{
596 undo->priv->frozen = FALSE;585 undo->priv->frozen = FALSE;
597}586}
598

Subscribers

People subscribed via source and target branches