Merge lp:~muktupavels/compiz/gwd-remove-settings-interface into lp:compiz/0.9.12
- gwd-remove-settings-interface
- Merge into 0.9.12
Status: | Merged |
---|---|
Approved by: | Marco Trevisan (Treviño) |
Approved revision: | 4021 |
Merged at revision: | 4024 |
Proposed branch: | lp:~muktupavels/compiz/gwd-remove-settings-interface |
Merge into: | lp:compiz/0.9.12 |
Prerequisite: | lp:~muktupavels/compiz/gwd-settings-storage-fix-memory-leaks |
Diff against target: |
2501 lines (+697/-1340) 12 files modified
gtk/window-decorator/CMakeLists.txt (+0/-4) gtk/window-decorator/blurprops.c (+1/-1) gtk/window-decorator/events.c (+1/-1) gtk/window-decorator/gtk-window-decorator.c (+4/-5) gtk/window-decorator/gwd-settings-interface.c (+0/-165) gtk/window-decorator/gwd-settings-interface.h (+0/-103) gtk/window-decorator/gwd-settings.c (+617/-567) gtk/window-decorator/gwd-settings.h (+65/-7) gtk/window-decorator/tests/CMakeLists.txt (+0/-8) gtk/window-decorator/tests/compiz_gwd_mock_settings.cpp (+0/-199) gtk/window-decorator/tests/compiz_gwd_mock_settings.h (+0/-86) gtk/window-decorator/tests/test_gwd_settings.cpp (+9/-194) |
To merge this branch: | bzr merge lp:~muktupavels/compiz/gwd-remove-settings-interface |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Marco Trevisan (Treviño) | Approve | ||
Sam Spilsbury | Approve | ||
Review via email:
|
Commit message
Remove GWDSettingsInte
Description of the change
Remove GWDSettingsInte
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Sam Spilsbury (smspillaz) wrote : | # |
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Alberts Muktupāvels (muktupavels) wrote : | # |
I don't want to agree with coding style things. It looks like gtk-window-
For example gwd_settings_
So if tabs must be used then basically it means all this branch must be reformatted to use tabs in structs, enums, functions... It looks like original code has used spaces so I would prefer to use spaces. Also using spaces allows code to look good everywhere.
I have configured gedit to use spaces and tab width is 2 and I can easily see where spaces or tabs are used.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Sam Spilsbury (smspillaz) wrote : | # |
> I don't want to agree with coding style things. It looks like gtk-window-
> decorator has more lines with spaces then tabs...
>
> For example gwd_settings_
> gwd_settings_
>
> So if tabs must be used then basically it means all this branch must be
> reformatted to use tabs in structs, enums, functions... It looks like original
> code has used spaces so I would prefer to use spaces. Also using spaces allows
> code to look good everywhere.
The reason why some lines appear to have more spaces is that the X11 coding style is mixed spaces/tabs (I know, its completely insane, but consistency trumps here). It goes:
1st level: 4 spaces
2nd level: 1 8-wide tab
3rd level: 1 8-wide tab, 4 spaces
4th level: 2 8-wide tabs
etc.
If there is internal inconsistency (which wouldn't surprise me), perhaps doing a once-over with clang-format wouldn't hurt, though doing that has its drawbacks, like breaking bzr blame. That discussion should probably take place with the other maintainers though.
If I had it my way, I'd change the entire project over to use 4-space indents, but the fact that it would destroy the file level history. Until then, it is better to remain consistent then inconsistent.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Alberts Muktupāvels (muktupavels) wrote : | # |
> The reason why some lines appear to have more spaces is that the X11 coding
> style is mixed spaces/tabs (I know, its completely insane, but consistency
> trumps here). It goes:
>
> 1st level: 4 spaces
> 2nd level: 1 8-wide tab
> 3rd level: 1 8-wide tab, 4 spaces
> 4th level: 2 8-wide tabs
Is there any worse coding style? I am using gedit and it can be configured to use spaces or tabs. How am I supposed to correctly stick to this style? Enter starts new line with same indentation used in previous line, that would mean that I need to delete it and hit tab. New lines I will need to start just by using space 4times.
> If there is internal inconsistency (which wouldn't surprise me), perhaps doing
> a once-over with clang-format wouldn't hurt, though doing that has its
> drawbacks, like breaking bzr blame. That discussion should probably take place
> with the other maintainers though.
>
> If I had it my way, I'd change the entire project over to use 4-space indents,
> but the fact that it would destroy the file level history. Until then, it is
> better to remain consistent then inconsistent.
Lets see what Marco Trevisan will say about this. I think that there is no need to just reformat everything, but when something is changed / rewritten it might be good idea to stick with spaces.
Did you look at diff comment replies? There was two replies not related to code style.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Marco Trevisan (Treviño) (3v1n0) wrote : | # |
I personally find quite insane this Tab/Spaces mix too, but with the time I got used and I agree we can't just restyle everything not to lose history (well we can still preserve by going one level back, but still it's not nice).
At the same time, I'd also prefer to keep things consistent, then unless it's not a big work, at least in the main plugins I'd prefer to keep the old style (and yeah, sadly, but again... Consitency). The decorators have already their own rules, though... So I wouldn't mind if they decide to keep a different styling.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Sam Spilsbury (smspillaz) wrote : | # |
Side note: Chromium had a similar problem a month ago and they wrote a tool called "git hyper-blame" which tries to skip refactors / reformatting in the blame history: https:/
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Sam Spilsbury (smspillaz) : | # |
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Sam Spilsbury (smspillaz) wrote : | # |
> I personally find quite insane this Tab/Spaces mix too, but with the time I
> got used and I agree we can't just restyle everything not to lose history
> (well we can still preserve by going one level back, but still it's not nice).
>
> At the same time, I'd also prefer to keep things consistent, then unless it's
> not a big work, at least in the main plugins I'd prefer to keep the old style
> (and yeah, sadly, but again... Consitency). The decorators have already their
> own rules, though... So I wouldn't mind if they decide to keep a different
> styling.
The incremental approach may be the better one here. I wonder if it would be worth adding modelines to the top of files where the coding style is four-spaces to signify that's the case (and adding a note in the README).
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Alberts Muktupāvels (muktupavels) wrote : | # |
So what is final decision? Lets stick to spaces? Or I need to reformat code?
"Defensive coding paradigm - its better to set things to NULL once the memory is freed to avoid tripping up future maintainers."
Future maintainers should know that finalize is called once. Also object destruction documentation use simply g_free and only speaks about setting to NULL in dispose.
https:/
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Sam Spilsbury (smspillaz) wrote : | # |
> So what is final decision? Lets stick to spaces? Or I need to reformat code?
>
> "Defensive coding paradigm - its better to set things to NULL once the memory
> is freed to avoid tripping up future maintainers."
>
> Future maintainers should know that finalize is called once. Also object
> destruction documentation use simply g_free and only speaks about setting to
> NULL in dispose.
>
> https:/
I was thinking more of the case where a function is called in between freeing the member pointer and _finalize returning. If such a function (or one of its callees) attempted to access the free'd memory, you'd have a non-obvious bug to deal with. To prevent such situations from happening, I would say it is almost always better to use g_clear_pointer or set the pointers to NULL.
Regardless, its only a minor nit of mine and not something I would consider as blocking this review.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Sam Spilsbury (smspillaz) wrote : | # |
> So what is final decision? Lets stick to spaces? Or I need to reformat code?
Personally, I'm in favour of doing the following:
1. Any edited files in this MRQ and future MRQs for gtk-window-
2. Insert the modeline: /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4; tab-width: 4 -*- */ at the top of every file using such indentation.
3. Add a note in the README that files containing such a modeline are to use 4-space indents instead of the X11 style.
I get the impression that Marco was in favour of a similar approach. If Marco is happy with that, so am I.
- 4018. By Alberts Muktupāvels
-
Declare and assign in same line.
- 4019. By Alberts Muktupāvels
-
Use g_clear_pointer in finalize.
- 4020. By Alberts Muktupāvels
-
Update coding style.
- 4021. By Alberts Muktupāvels
-
Add modeline in gwd-settings.[c/h].
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Alberts Muktupāvels (muktupavels) wrote : | # |
Is there any more changes needed in this merge proposal?
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Alberts Muktupāvels (muktupavels) wrote : | # |
Sam?
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Sam Spilsbury (smspillaz) wrote : | # |
Oops, looks like I missed this one.
All looks good to me!
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Marco Trevisan (Treviño) (3v1n0) : | # |
Preview Diff
1 | === modified file 'gtk/window-decorator/CMakeLists.txt' |
2 | --- gtk/window-decorator/CMakeLists.txt 2016-05-19 09:24:18 +0000 |
3 | +++ gtk/window-decorator/CMakeLists.txt 2016-05-19 09:24:18 +0000 |
4 | @@ -29,9 +29,6 @@ |
5 | add_library (gtk_window_decorator_cairo_window_decoration_util |
6 | ${CMAKE_CURRENT_SOURCE_DIR}/gwd-cairo-window-decoration-util.c) |
7 | |
8 | - add_library (gtk_window_decorator_settings_interface STATIC |
9 | - ${CMAKE_CURRENT_SOURCE_DIR}/gwd-settings-interface.c) |
10 | - |
11 | add_library (gtk_window_decorator_settings STATIC |
12 | ${CMAKE_CURRENT_SOURCE_DIR}/gwd-settings.c) |
13 | |
14 | @@ -43,7 +40,6 @@ |
15 | |
16 | set (GTK_WINDOW_DECORATOR_ADDITIONAL_LIBRARIES |
17 | gtk_window_decorator_settings_notified_interface |
18 | - gtk_window_decorator_settings_interface |
19 | gtk_window_decorator_settings_writable_interface |
20 | gtk_window_decorator_settings |
21 | gtk_window_decorator_metacity_window_decoration_util |
22 | |
23 | === modified file 'gtk/window-decorator/blurprops.c' |
24 | --- gtk/window-decorator/blurprops.c 2014-06-20 11:14:55 +0000 |
25 | +++ gtk/window-decorator/blurprops.c 2016-05-19 09:24:18 +0000 |
26 | @@ -20,7 +20,7 @@ |
27 | */ |
28 | |
29 | #include "gtk-window-decorator.h" |
30 | -#include "gwd-settings-interface.h" |
31 | +#include "gwd-settings.h" |
32 | |
33 | void |
34 | decor_update_blur_property (decor_t *d, |
35 | |
36 | === modified file 'gtk/window-decorator/events.c' |
37 | --- gtk/window-decorator/events.c 2016-03-17 17:47:36 +0000 |
38 | +++ gtk/window-decorator/events.c 2016-05-19 09:24:18 +0000 |
39 | @@ -24,7 +24,7 @@ |
40 | */ |
41 | |
42 | #include "gtk-window-decorator.h" |
43 | -#include "gwd-settings-interface.h" |
44 | +#include "gwd-settings.h" |
45 | |
46 | #define DOUBLE_CLICK_DISTANCE 8.0f |
47 | |
48 | |
49 | === modified file 'gtk/window-decorator/gtk-window-decorator.c' |
50 | --- gtk/window-decorator/gtk-window-decorator.c 2016-03-17 17:47:36 +0000 |
51 | +++ gtk/window-decorator/gtk-window-decorator.c 2016-05-19 09:24:18 +0000 |
52 | @@ -26,7 +26,6 @@ |
53 | #include "gtk-window-decorator.h" |
54 | #include "gwd-settings-writable-interface.h" |
55 | #include "gwd-settings.h" |
56 | -#include "gwd-settings-interface.h" |
57 | #include "gwd-settings-notified-interface.h" |
58 | #include "gwd-settings-notified.h" |
59 | |
60 | @@ -290,9 +289,9 @@ |
61 | if (!notified) |
62 | return 1; |
63 | |
64 | - writable = GWD_SETTINGS_WRITABLE_INTERFACE (gwd_settings_impl_new (option_blur_type != BLUR_TYPE_NONE ? &option_blur_type : NULL, |
65 | - option_meta_theme ? &option_meta_theme : NULL, |
66 | - notified)); |
67 | + writable = GWD_SETTINGS_WRITABLE_INTERFACE (gwd_settings_new (option_blur_type != BLUR_TYPE_NONE ? &option_blur_type : NULL, |
68 | + option_meta_theme ? &option_meta_theme : NULL, |
69 | + notified)); |
70 | |
71 | if (!writable) |
72 | { |
73 | @@ -300,7 +299,7 @@ |
74 | return 1; |
75 | } |
76 | |
77 | - settings = GWD_SETTINGS_INTERFACE (writable); |
78 | + settings = GWD_SETTINGS (writable); |
79 | |
80 | gwd_settings_writable_freeze_updates (writable); |
81 | |
82 | |
83 | === removed file 'gtk/window-decorator/gwd-settings-interface.c' |
84 | --- gtk/window-decorator/gwd-settings-interface.c 2016-02-22 12:27:13 +0000 |
85 | +++ gtk/window-decorator/gwd-settings-interface.c 1970-01-01 00:00:00 +0000 |
86 | @@ -1,165 +0,0 @@ |
87 | -/* |
88 | - * Copyright © 2012 Canonical Ltd |
89 | - * |
90 | - * This program is free software; you can redistribute it and/or modify |
91 | - * it under the terms of the GNU General Public License as published by |
92 | - * the Free Software Foundation; either version 2 of the License, or |
93 | - * (at your option) any later version. |
94 | - * |
95 | - * This program is distributed in the hope that it will be useful, |
96 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
97 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
98 | - * GNU General Public License for more details. |
99 | - * |
100 | - * You should have received a copy of the GNU General Public License |
101 | - * along with this program; if not, write to the Free Software Foundation, |
102 | - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
103 | - * |
104 | - * Authored By: Sam Spilsbury <sam.spilsbury@canonical.com> |
105 | - */ |
106 | -#include "gwd-settings-interface.h" |
107 | - |
108 | -const gboolean USE_TOOLTIPS_DEFAULT = FALSE; |
109 | - |
110 | -const gdouble ACTIVE_SHADOW_RADIUS_DEFAULT = 8.0; |
111 | -const gdouble ACTIVE_SHADOW_OPACITY_DEFAULT = 0.5; |
112 | -const gint ACTIVE_SHADOW_OFFSET_X_DEFAULT = 1; |
113 | -const gint ACTIVE_SHADOW_OFFSET_Y_DEFAULT = 1; |
114 | -const gchar *ACTIVE_SHADOW_COLOR_DEFAULT = "#00000000"; |
115 | - |
116 | -const gdouble INACTIVE_SHADOW_RADIUS_DEFAULT = 8.0; |
117 | -const gdouble INACTIVE_SHADOW_OPACITY_DEFAULT = 0/5; |
118 | -const gint INACTIVE_SHADOW_OFFSET_X_DEFAULT = 1; |
119 | -const gint INACTIVE_SHADOW_OFFSET_Y_DEFAULT = 1; |
120 | -const gchar *INACTIVE_SHADOW_COLOR_DEFAULT = "#00000000"; |
121 | - |
122 | -const gint BLUR_TYPE_DEFAULT = BLUR_TYPE_NONE; |
123 | - |
124 | -const gchar *METACITY_THEME_DEFAULT = "Adwaita"; |
125 | -const gdouble METACITY_ACTIVE_OPACITY_DEFAULT = 1.0; |
126 | -const gdouble METACITY_INACTIVE_OPACITY_DEFAULT = 0.75; |
127 | -const gboolean METACITY_ACTIVE_SHADE_OPACITY_DEFAULT = TRUE; |
128 | -const gboolean METACITY_INACTIVE_SHADE_OPACITY_DEFAULT = TRUE; |
129 | - |
130 | -const gchar * METACITY_BUTTON_LAYOUT_DEFAULT = ":minimize,maximize,close"; |
131 | - |
132 | -const guint DOUBLE_CLICK_ACTION_DEFAULT = CLICK_ACTION_MAXIMIZE; |
133 | -const guint MIDDLE_CLICK_ACTION_DEFAULT = CLICK_ACTION_LOWER; |
134 | -const guint RIGHT_CLICK_ACTION_DEFAULT = CLICK_ACTION_MENU; |
135 | -const guint WHEEL_ACTION_DEFAULT = WHEEL_ACTION_NONE; |
136 | - |
137 | -const gchar * TITLEBAR_FONT_DEFAULT = "Sans 12"; |
138 | - |
139 | -static void gwd_settings_interface_default_init (GWDSettingsInterface *settings_interface); |
140 | - |
141 | -G_DEFINE_INTERFACE (GWDSettings, gwd_settings_interface, G_TYPE_OBJECT); |
142 | - |
143 | -static void gwd_settings_interface_default_init (GWDSettingsInterface *settings_interface) |
144 | -{ |
145 | - g_object_interface_install_property (settings_interface, |
146 | - g_param_spec_pointer ("active-shadow", |
147 | - "Active Shadow", |
148 | - "Active Shadow Settings", |
149 | - G_PARAM_READABLE)); |
150 | - g_object_interface_install_property (settings_interface, |
151 | - g_param_spec_pointer ("inactive-shadow", |
152 | - "Inactive Shadow", |
153 | - "Inactive Shadow", |
154 | - G_PARAM_READABLE)); |
155 | - g_object_interface_install_property (settings_interface, |
156 | - g_param_spec_boolean ("use-tooltips", |
157 | - "Use Tooltips", |
158 | - "Use Tooltips Setting", |
159 | - USE_TOOLTIPS_DEFAULT, |
160 | - G_PARAM_READABLE)); |
161 | - g_object_interface_install_property (settings_interface, |
162 | - g_param_spec_int ("blur", |
163 | - "Blur Type", |
164 | - "Blur type property", |
165 | - BLUR_TYPE_NONE, |
166 | - BLUR_TYPE_ALL, |
167 | - BLUR_TYPE_NONE, |
168 | - G_PARAM_READABLE | |
169 | - G_PARAM_WRITABLE | |
170 | - G_PARAM_CONSTRUCT_ONLY)); |
171 | - g_object_interface_install_property (settings_interface, |
172 | - g_param_spec_string ("metacity-theme", |
173 | - "Metacity Theme", |
174 | - "Metacity Theme Setting", |
175 | - METACITY_THEME_DEFAULT, |
176 | - G_PARAM_READABLE | |
177 | - G_PARAM_WRITABLE | |
178 | - G_PARAM_CONSTRUCT_ONLY)); |
179 | - g_object_interface_install_property (settings_interface, |
180 | - g_param_spec_double ("metacity-active-opacity", |
181 | - "Metacity Active Opacity", |
182 | - "Metacity Active Opacity", |
183 | - 0.0, |
184 | - 1.0, |
185 | - METACITY_ACTIVE_OPACITY_DEFAULT, |
186 | - G_PARAM_READABLE)); |
187 | - g_object_interface_install_property (settings_interface, |
188 | - g_param_spec_double ("metacity-inactive-opacity", |
189 | - "Metacity Inactive Opacity", |
190 | - "Metacity Inactive Opacity", |
191 | - 0.0, |
192 | - 1.0, |
193 | - METACITY_INACTIVE_OPACITY_DEFAULT, |
194 | - G_PARAM_READABLE)); |
195 | - g_object_interface_install_property (settings_interface, |
196 | - g_param_spec_boolean ("metacity-active-shade-opacity", |
197 | - "Metacity Active Shade Opacity", |
198 | - "Metacity Active Shade Opacity", |
199 | - METACITY_ACTIVE_SHADE_OPACITY_DEFAULT, |
200 | - G_PARAM_READABLE)); |
201 | - g_object_interface_install_property (settings_interface, |
202 | - g_param_spec_boolean ("metacity-inactive-shade-opacity", |
203 | - "Metacity Inactive Shade Opacity", |
204 | - "Metacity Inactive Shade Opacity", |
205 | - METACITY_INACTIVE_SHADE_OPACITY_DEFAULT, |
206 | - G_PARAM_READABLE)); |
207 | - g_object_interface_install_property (settings_interface, |
208 | - g_param_spec_string ("metacity-button-layout", |
209 | - "Metacity Button Layout", |
210 | - "Metacity Button Layout", |
211 | - METACITY_BUTTON_LAYOUT_DEFAULT, |
212 | - G_PARAM_READABLE)); |
213 | - g_object_interface_install_property (settings_interface, |
214 | - g_param_spec_int ("titlebar-double-click-action", |
215 | - "Titlebar Action Double Click", |
216 | - "Titlebar Action Double Click", |
217 | - CLICK_ACTION_NONE, |
218 | - CLICK_ACTION_MENU, |
219 | - CLICK_ACTION_MAXIMIZE, |
220 | - G_PARAM_READABLE)); |
221 | - g_object_interface_install_property (settings_interface, |
222 | - g_param_spec_int ("titlebar-middle-click-action", |
223 | - "Titlebar Action Middle Click", |
224 | - "Titlebar Action Middle Click", |
225 | - CLICK_ACTION_NONE, |
226 | - CLICK_ACTION_MENU, |
227 | - CLICK_ACTION_LOWER, |
228 | - G_PARAM_READABLE)); |
229 | - g_object_interface_install_property (settings_interface, |
230 | - g_param_spec_int ("titlebar-right-click-action", |
231 | - "Titlebar Action Right Click", |
232 | - "Titlebar Action Right Click", |
233 | - CLICK_ACTION_NONE, |
234 | - CLICK_ACTION_MENU, |
235 | - CLICK_ACTION_MENU, |
236 | - G_PARAM_READABLE)); |
237 | - g_object_interface_install_property (settings_interface, |
238 | - g_param_spec_int ("mouse-wheel-action", |
239 | - "Mouse Wheel Action", |
240 | - "Mouse Wheel Action", |
241 | - WHEEL_ACTION_NONE, |
242 | - WHEEL_ACTION_SHADE, |
243 | - WHEEL_ACTION_SHADE, |
244 | - G_PARAM_READABLE)); |
245 | - g_object_interface_install_property (settings_interface, |
246 | - g_param_spec_string ("titlebar-font", |
247 | - "Titlebar Font", |
248 | - "Titlebar Font", |
249 | - TITLEBAR_FONT_DEFAULT, |
250 | - G_PARAM_READABLE)); |
251 | -} |
252 | |
253 | === removed file 'gtk/window-decorator/gwd-settings-interface.h' |
254 | --- gtk/window-decorator/gwd-settings-interface.h 2012-10-06 16:11:05 +0000 |
255 | +++ gtk/window-decorator/gwd-settings-interface.h 1970-01-01 00:00:00 +0000 |
256 | @@ -1,103 +0,0 @@ |
257 | -/* |
258 | - * Copyright © 2012 Canonical Ltd |
259 | - * |
260 | - * This program is free software; you can redistribute it and/or modify |
261 | - * it under the terms of the GNU General Public License as published by |
262 | - * the Free Software Foundation; either version 2 of the License, or |
263 | - * (at your option) any later version. |
264 | - * |
265 | - * This program is distributed in the hope that it will be useful, |
266 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
267 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
268 | - * GNU General Public License for more details. |
269 | - * |
270 | - * You should have received a copy of the GNU General Public License |
271 | - * along with this program; if not, write to the Free Software Foundation, |
272 | - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
273 | - * |
274 | - * Authored By: Sam Spilsbury <sam.spilsbury@canonical.com> |
275 | - */ |
276 | -#ifndef _COMPIZ_GWD_SETTINGS_INTERFACE_H |
277 | -#define _COMPIZ_GWD_SETTINGS_INTERFACE_H |
278 | - |
279 | -#include <glib-object.h> |
280 | -#include <gwd-fwd.h> |
281 | - |
282 | -G_BEGIN_DECLS |
283 | - |
284 | -#define GWD_SETTINGS_INTERFACE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ |
285 | - GWD_TYPE_SETTINGS_INTERFACE, \ |
286 | - GWDSettings)) |
287 | -#define GWD_SETTINGS_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE(obj, \ |
288 | - GWD_TYPE_SETTINGS_INTERFACE, \ |
289 | - GWDSettingsInterface)) |
290 | -#define GWD_TYPE_SETTINGS_INTERFACE (gwd_settings_interface_get_type ()) |
291 | - |
292 | -typedef struct _GWDSettingsInterface GWDSettingsInterface; |
293 | - |
294 | -struct _GWDSettingsInterface |
295 | -{ |
296 | - GTypeInterface parent; |
297 | -}; |
298 | - |
299 | -enum |
300 | -{ |
301 | - BLUR_TYPE_NONE = 0, |
302 | - BLUR_TYPE_TITLEBAR = 1, |
303 | - BLUR_TYPE_ALL = 2 |
304 | -}; |
305 | - |
306 | -enum |
307 | -{ |
308 | - CLICK_ACTION_NONE, |
309 | - CLICK_ACTION_SHADE, |
310 | - CLICK_ACTION_MAXIMIZE, |
311 | - CLICK_ACTION_MINIMIZE, |
312 | - CLICK_ACTION_RAISE, |
313 | - CLICK_ACTION_LOWER, |
314 | - CLICK_ACTION_MENU |
315 | -}; |
316 | - |
317 | -enum { |
318 | - WHEEL_ACTION_NONE, |
319 | - WHEEL_ACTION_SHADE |
320 | -}; |
321 | - |
322 | -extern const gboolean USE_TOOLTIPS_DEFAULT; |
323 | - |
324 | -extern const gdouble ACTIVE_SHADOW_RADIUS_DEFAULT; |
325 | -extern const gdouble ACTIVE_SHADOW_OPACITY_DEFAULT; |
326 | -extern const gint ACTIVE_SHADOW_OFFSET_X_DEFAULT; |
327 | -extern const gint ACTIVE_SHADOW_OFFSET_Y_DEFAULT; |
328 | -extern const gchar *ACTIVE_SHADOW_COLOR_DEFAULT; |
329 | - |
330 | -extern const gdouble INACTIVE_SHADOW_RADIUS_DEFAULT; |
331 | -extern const gdouble INACTIVE_SHADOW_OPACITY_DEFAULT; |
332 | -extern const gint INACTIVE_SHADOW_OFFSET_X_DEFAULT; |
333 | -extern const gint INACTIVE_SHADOW_OFFSET_Y_DEFAULT; |
334 | -extern const gchar *INACTIVE_SHADOW_COLOR_DEFAULT; |
335 | - |
336 | -extern const guint DRAGGABLE_BORDER_WIDTH_DEFAULT; |
337 | -extern const gboolean ATTACH_MODAL_DIALOGS_DEFAULT; |
338 | -extern const gint BLUR_TYPE_DEFAULT; |
339 | - |
340 | -extern const gchar *METACITY_THEME_DEFAULT; |
341 | -extern const gdouble METACITY_ACTIVE_OPACITY_DEFAULT; |
342 | -extern const gdouble METACITY_INACTIVE_OPACITY_DEFAULT; |
343 | -extern const gboolean METACITY_ACTIVE_SHADE_OPACITY_DEFAULT; |
344 | -extern const gboolean METACITY_INACTIVE_SHADE_OPACITY_DEFAULT; |
345 | - |
346 | -extern const gchar * METACITY_BUTTON_LAYOUT_DEFAULT; |
347 | - |
348 | -extern const guint DOUBLE_CLICK_ACTION_DEFAULT; |
349 | -extern const guint MIDDLE_CLICK_ACTION_DEFAULT; |
350 | -extern const guint RIGHT_CLICK_ACTION_DEFAULT; |
351 | -extern const guint WHEEL_ACTION_DEFAULT; |
352 | - |
353 | -extern const gchar * TITLEBAR_FONT_DEFAULT; |
354 | - |
355 | -GType gwd_settings_interface_get_type (void); |
356 | - |
357 | -G_END_DECLS |
358 | - |
359 | -#endif |
360 | |
361 | === modified file 'gtk/window-decorator/gwd-settings.c' |
362 | --- gtk/window-decorator/gwd-settings.c 2016-02-22 12:27:13 +0000 |
363 | +++ gtk/window-decorator/gwd-settings.c 2016-05-19 09:24:18 +0000 |
364 | @@ -1,3 +1,5 @@ |
365 | +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4; tab-width: 4 -*- */ |
366 | + |
367 | /* |
368 | * Copyright © 2012 Canonical Ltd |
369 | * |
370 | @@ -17,64 +19,47 @@ |
371 | * |
372 | * Authored By: Sam Spilsbury <sam.spilsbury@canonical.com> |
373 | */ |
374 | + |
375 | #include <glib-object.h> |
376 | |
377 | #include <stdlib.h> |
378 | #include <stdio.h> |
379 | |
380 | #include "gwd-settings.h" |
381 | -#include "gwd-settings-interface.h" |
382 | #include "gwd-settings-writable-interface.h" |
383 | #include "gwd-settings-notified-interface.h" |
384 | #include "decoration.h" |
385 | |
386 | -#define GWD_SETTINGS_IMPL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GWD_TYPE_SETTINGS_IMPL, GWDSettingsImpl)) |
387 | -#define GWD_SETTINGS_IMPL_CLASS(obj) (G_TYPE_CHECK_CLASS_CAST ((obj), GWD_TYPE_SETTINGS_IMPL, GWDSettingsImplClass)) |
388 | -#define GWD_IS_SETTINGS_IMPL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GWD_TYPE_SETTINGS_IMPL)) |
389 | -#define GWD_IS_SETTINGS_IMPL_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE ((obj), GWD_TYPE_SETTINGS_IMPL)) |
390 | -#define GWD_SETTINGS_IMPL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GWD_TYPE_SETTINGS_IMPL, GWDSettingsImplClass)) |
391 | - |
392 | -typedef struct _GWDSettingsImpl |
393 | -{ |
394 | - GObject parent; |
395 | -} GWDSettingsImpl; |
396 | - |
397 | -typedef struct _GWDSettingsImplClass |
398 | -{ |
399 | - GObjectClass parent_class; |
400 | -} GWDSettingsImplClass; |
401 | - |
402 | -static void gwd_settings_interface_init (GWDSettingsInterface *interface); |
403 | -static void gwd_settings_writable_interface_init (GWDSettingsWritableInterface *interface); |
404 | - |
405 | -G_DEFINE_TYPE_WITH_CODE (GWDSettingsImpl, gwd_settings_impl, G_TYPE_OBJECT, |
406 | - G_IMPLEMENT_INTERFACE (GWD_TYPE_SETTINGS_INTERFACE, |
407 | - gwd_settings_interface_init) |
408 | - G_IMPLEMENT_INTERFACE (GWD_TYPE_WRITABLE_SETTINGS_INTERFACE, |
409 | - gwd_settings_writable_interface_init)) |
410 | - |
411 | -#define GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GWD_TYPE_SETTINGS_IMPL, GWDSettingsImplPrivate)) |
412 | - |
413 | -enum |
414 | -{ |
415 | - GWD_SETTINGS_IMPL_PROPERTY_ACTIVE_SHADOW = 1, |
416 | - GWD_SETTINGS_IMPL_PROPERTY_INACTIVE_SHADOW = 2, |
417 | - GWD_SETTINGS_IMPL_PROPERTY_USE_TOOLTIPS = 3, |
418 | - GWD_SETTINGS_IMPL_PROPERTY_BLUR_CHANGED = 4, |
419 | - GWD_SETTINGS_IMPL_PROPERTY_METACITY_THEME = 5, |
420 | - GWD_SETTINGS_IMPL_PROPERTY_ACTIVE_OPACITY = 6, |
421 | - GWD_SETTINGS_IMPL_PROPERTY_INACTIVE_OPACITY = 7, |
422 | - GWD_SETTINGS_IMPL_PROPERTY_ACTIVE_SHADE_OPACITY = 8, |
423 | - GWD_SETTINGS_IMPL_PROPERTY_INACTIVE_SHADE_OPACITY = 9, |
424 | - GWD_SETTINGS_IMPL_PROPERTY_BUTTON_LAYOUT = 10, |
425 | - GWD_SETTINGS_IMPL_PROPERTY_TITLEBAR_ACTION_DOUBLE_CLICK = 11, |
426 | - GWD_SETTINGS_IMPL_PROPERTY_TITLEBAR_ACTION_MIDDLE_CLICK = 12, |
427 | - GWD_SETTINGS_IMPL_PROPERTY_TITLEBAR_ACTION_RIGHT_CLICK = 13, |
428 | - GWD_SETTINGS_IMPL_PROPERTY_MOUSE_WHEEL_ACTION = 14, |
429 | - GWD_SETTINGS_IMPL_PROPERTY_TITLEBAR_FONT = 15, |
430 | - GWD_SETTINGS_IMPL_PROPERTY_CMDLINE_OPTIONS = 16, |
431 | - GWD_SETTINGS_IMPL_PROPERTY_SETTINGS_NOTIFIED = 17 |
432 | -}; |
433 | +const gboolean USE_TOOLTIPS_DEFAULT = FALSE; |
434 | + |
435 | +const gdouble ACTIVE_SHADOW_RADIUS_DEFAULT = 8.0; |
436 | +const gdouble ACTIVE_SHADOW_OPACITY_DEFAULT = 0.5; |
437 | +const gint ACTIVE_SHADOW_OFFSET_X_DEFAULT = 1; |
438 | +const gint ACTIVE_SHADOW_OFFSET_Y_DEFAULT = 1; |
439 | +const gchar *ACTIVE_SHADOW_COLOR_DEFAULT = "#00000000"; |
440 | + |
441 | +const gdouble INACTIVE_SHADOW_RADIUS_DEFAULT = 8.0; |
442 | +const gdouble INACTIVE_SHADOW_OPACITY_DEFAULT = 0.5; |
443 | +const gint INACTIVE_SHADOW_OFFSET_X_DEFAULT = 1; |
444 | +const gint INACTIVE_SHADOW_OFFSET_Y_DEFAULT = 1; |
445 | +const gchar *INACTIVE_SHADOW_COLOR_DEFAULT = "#00000000"; |
446 | + |
447 | +const gint BLUR_TYPE_DEFAULT = BLUR_TYPE_NONE; |
448 | + |
449 | +const gchar *METACITY_THEME_DEFAULT = "Adwaita"; |
450 | +const gdouble METACITY_ACTIVE_OPACITY_DEFAULT = 1.0; |
451 | +const gdouble METACITY_INACTIVE_OPACITY_DEFAULT = 0.75; |
452 | +const gboolean METACITY_ACTIVE_SHADE_OPACITY_DEFAULT = TRUE; |
453 | +const gboolean METACITY_INACTIVE_SHADE_OPACITY_DEFAULT = TRUE; |
454 | + |
455 | +const gchar *METACITY_BUTTON_LAYOUT_DEFAULT = ":minimize,maximize,close"; |
456 | + |
457 | +const guint DOUBLE_CLICK_ACTION_DEFAULT = CLICK_ACTION_MAXIMIZE; |
458 | +const guint MIDDLE_CLICK_ACTION_DEFAULT = CLICK_ACTION_LOWER; |
459 | +const guint RIGHT_CLICK_ACTION_DEFAULT = CLICK_ACTION_MENU; |
460 | +const guint WHEEL_ACTION_DEFAULT = WHEEL_ACTION_SHADE; |
461 | + |
462 | +const gchar *TITLEBAR_FONT_DEFAULT = "Sans 12"; |
463 | |
464 | enum |
465 | { |
466 | @@ -84,42 +69,77 @@ |
467 | |
468 | typedef gboolean (*NotifyFunc) (GWDSettingsNotified *); |
469 | |
470 | -typedef struct _GWDSettingsImplPrivate |
471 | +struct _GWDSettings |
472 | { |
473 | - decor_shadow_options_t active_shadow; |
474 | - decor_shadow_options_t inactive_shadow; |
475 | - gboolean use_tooltips; |
476 | - gint blur_type; |
477 | - gchar *metacity_theme; |
478 | - gdouble metacity_active_opacity; |
479 | - gdouble metacity_inactive_opacity; |
480 | - gboolean metacity_active_shade_opacity; |
481 | - gboolean metacity_inactive_shade_opacity; |
482 | - gchar *metacity_button_layout; |
483 | - gint titlebar_double_click_action; |
484 | - gint titlebar_middle_click_action; |
485 | - gint titlebar_right_click_action; |
486 | - gint mouse_wheel_action; |
487 | - gchar *titlebar_font; |
488 | - guint cmdline_opts; |
489 | + GObject parent; |
490 | + |
491 | + decor_shadow_options_t active_shadow; |
492 | + decor_shadow_options_t inactive_shadow; |
493 | + gboolean use_tooltips; |
494 | + gint blur_type; |
495 | + gchar *metacity_theme; |
496 | + gdouble metacity_active_opacity; |
497 | + gdouble metacity_inactive_opacity; |
498 | + gboolean metacity_active_shade_opacity; |
499 | + gboolean metacity_inactive_shade_opacity; |
500 | + gchar *metacity_button_layout; |
501 | + gint titlebar_double_click_action; |
502 | + gint titlebar_middle_click_action; |
503 | + gint titlebar_right_click_action; |
504 | + gint mouse_wheel_action; |
505 | + gchar *titlebar_font; |
506 | + |
507 | + guint cmdline_opts; |
508 | GWDSettingsNotified *notified; |
509 | - guint freeze_count; |
510 | - GList *notify_funcs; |
511 | -} GWDSettingsImplPrivate; |
512 | + |
513 | + guint freeze_count; |
514 | + GList *notify_funcs; |
515 | +}; |
516 | + |
517 | +enum |
518 | +{ |
519 | + PROP_0, |
520 | + |
521 | + PROP_ACTIVE_SHADOW, |
522 | + PROP_INACTIVE_SHADOW, |
523 | + PROP_USE_TOOLTIPS, |
524 | + PROP_BLUR, |
525 | + PROP_METACITY_THEME, |
526 | + PROP_ACTIVE_OPACITY, |
527 | + PROP_INACTIVE_OPACITY, |
528 | + PROP_ACTIVE_SHADE_OPACITY, |
529 | + PROP_INACTIVE_SHADE_OPACITY, |
530 | + PROP_BUTTON_LAYOUT, |
531 | + PROP_TITLEBAR_ACTION_DOUBLE_CLICK, |
532 | + PROP_TITLEBAR_ACTION_MIDDLE_CLICK, |
533 | + PROP_TITLEBAR_ACTION_RIGHT_CLICK, |
534 | + PROP_MOUSE_WHEEL_ACTION, |
535 | + PROP_TITLEBAR_FONT, |
536 | + PROP_CMDLINE_OPTIONS, |
537 | + PROP_SETTINGS_NOTIFIED, |
538 | + |
539 | + LAST_PROP |
540 | +}; |
541 | + |
542 | +static GParamSpec *settings_properties[LAST_PROP] = { NULL }; |
543 | + |
544 | +static void gwd_settings_writable_interface_init (GWDSettingsWritableInterface *interface); |
545 | + |
546 | +G_DEFINE_TYPE_WITH_CODE (GWDSettings, gwd_settings, G_TYPE_OBJECT, |
547 | + G_IMPLEMENT_INTERFACE (GWD_TYPE_WRITABLE_SETTINGS_INTERFACE, |
548 | + gwd_settings_writable_interface_init)) |
549 | |
550 | static void |
551 | -append_to_notify_funcs (GWDSettingsImpl *settings, |
552 | - NotifyFunc func) |
553 | +append_to_notify_funcs (GWDSettings *settings, |
554 | + NotifyFunc func) |
555 | { |
556 | - GWDSettingsImplPrivate *priv = GET_PRIVATE (settings); |
557 | - |
558 | /* Remove if found, the new one will replace the old one */ |
559 | - GList *link = g_list_find (priv->notify_funcs, func); |
560 | + GList *link = g_list_find (settings->notify_funcs, func); |
561 | |
562 | if (link) |
563 | - priv->notify_funcs = g_list_remove_link (priv->notify_funcs, link); |
564 | + settings->notify_funcs = g_list_remove_link (settings->notify_funcs, link); |
565 | |
566 | - priv->notify_funcs = g_list_append (priv->notify_funcs, (gpointer) func); |
567 | + settings->notify_funcs = g_list_append (settings->notify_funcs, (gpointer) func); |
568 | } |
569 | |
570 | static void |
571 | @@ -133,33 +153,30 @@ |
572 | } |
573 | |
574 | static void |
575 | -release_notify_funcs (GWDSettingsImpl *settings) |
576 | +release_notify_funcs (GWDSettings *settings) |
577 | { |
578 | - GWDSettingsImplPrivate *priv = GET_PRIVATE (settings); |
579 | - |
580 | - if (priv->freeze_count) |
581 | - return; |
582 | - |
583 | - g_list_foreach (priv->notify_funcs, invoke_notify_func, priv->notified); |
584 | - g_list_free (priv->notify_funcs); |
585 | - priv->notify_funcs = NULL; |
586 | + if (settings->freeze_count) |
587 | + return; |
588 | + |
589 | + g_list_foreach (settings->notify_funcs, invoke_notify_func, settings->notified); |
590 | + g_list_free (settings->notify_funcs); |
591 | + settings->notify_funcs = NULL; |
592 | } |
593 | |
594 | gboolean |
595 | -gwd_settings_shadow_property_changed (GWDSettingsWritable *settings, |
596 | - gdouble active_shadow_radius, |
597 | - gdouble active_shadow_opacity, |
598 | - gdouble active_shadow_offset_x, |
599 | - gdouble active_shadow_offset_y, |
600 | - const gchar *active_shadow_color, |
601 | - gdouble inactive_shadow_radius, |
602 | - gdouble inactive_shadow_opacity, |
603 | - gdouble inactive_shadow_offset_x, |
604 | - gdouble inactive_shadow_offset_y, |
605 | - const gchar *inactive_shadow_color) |
606 | +gwd_settings_shadow_property_changed (GWDSettingsWritable *writable, |
607 | + gdouble active_shadow_radius, |
608 | + gdouble active_shadow_opacity, |
609 | + gdouble active_shadow_offset_x, |
610 | + gdouble active_shadow_offset_y, |
611 | + const gchar *active_shadow_color, |
612 | + gdouble inactive_shadow_radius, |
613 | + gdouble inactive_shadow_opacity, |
614 | + gdouble inactive_shadow_offset_x, |
615 | + gdouble inactive_shadow_offset_y, |
616 | + const gchar *inactive_shadow_color) |
617 | { |
618 | - GWDSettingsImpl *settings_impl = GWD_SETTINGS_IMPL (settings); |
619 | - GWDSettingsImplPrivate *priv = GET_PRIVATE (settings_impl); |
620 | + GWDSettings *settings = GWD_SETTINGS (writable); |
621 | |
622 | decor_shadow_options_t active_shadow, inactive_shadow; |
623 | unsigned int c[4]; |
624 | @@ -170,269 +187,233 @@ |
625 | active_shadow.shadow_offset_x = active_shadow_offset_x; |
626 | active_shadow.shadow_offset_y = active_shadow_offset_y; |
627 | |
628 | - if (sscanf (active_shadow_color, |
629 | - "#%2x%2x%2x%2x", |
630 | - &c[0], &c[1], &c[2], &c[3]) == 4) |
631 | - { |
632 | - active_shadow.shadow_color[0] = c[0] << 8 | c[0]; |
633 | - active_shadow.shadow_color[1] = c[1] << 8 | c[1]; |
634 | - active_shadow.shadow_color[2] = c[2] << 8 | c[2]; |
635 | + if (sscanf (active_shadow_color, "#%2x%2x%2x%2x", |
636 | + &c[0], &c[1], &c[2], &c[3]) == 4) { |
637 | + active_shadow.shadow_color[0] = c[0] << 8 | c[0]; |
638 | + active_shadow.shadow_color[1] = c[1] << 8 | c[1]; |
639 | + active_shadow.shadow_color[2] = c[2] << 8 | c[2]; |
640 | + } else { |
641 | + return FALSE; |
642 | } |
643 | - else |
644 | - return FALSE; |
645 | |
646 | - if (sscanf (inactive_shadow_color, |
647 | - "#%2x%2x%2x%2x", |
648 | - &c[0], &c[1], &c[2], &c[3]) == 4) |
649 | - { |
650 | - inactive_shadow.shadow_color[0] = c[0] << 8 | c[0]; |
651 | - inactive_shadow.shadow_color[1] = c[1] << 8 | c[1]; |
652 | - inactive_shadow.shadow_color[2] = c[2] << 8 | c[2]; |
653 | + if (sscanf (inactive_shadow_color, "#%2x%2x%2x%2x", |
654 | + &c[0], &c[1], &c[2], &c[3]) == 4) { |
655 | + inactive_shadow.shadow_color[0] = c[0] << 8 | c[0]; |
656 | + inactive_shadow.shadow_color[1] = c[1] << 8 | c[1]; |
657 | + inactive_shadow.shadow_color[2] = c[2] << 8 | c[2]; |
658 | + } else { |
659 | + return FALSE; |
660 | } |
661 | - else |
662 | - return FALSE; |
663 | |
664 | inactive_shadow.shadow_radius = inactive_shadow_radius; |
665 | inactive_shadow.shadow_opacity = inactive_shadow_opacity; |
666 | inactive_shadow.shadow_offset_x = inactive_shadow_offset_x; |
667 | inactive_shadow.shadow_offset_y = inactive_shadow_offset_y; |
668 | |
669 | - if (decor_shadow_options_cmp (&priv->inactive_shadow, |
670 | - &inactive_shadow)) |
671 | - { |
672 | - changed |= TRUE; |
673 | - priv->inactive_shadow = inactive_shadow; |
674 | - } |
675 | - |
676 | - if (decor_shadow_options_cmp (&priv->active_shadow, |
677 | - &active_shadow)) |
678 | - { |
679 | - changed |= TRUE; |
680 | - priv->active_shadow = active_shadow; |
681 | - } |
682 | - |
683 | - if (changed) |
684 | - { |
685 | - append_to_notify_funcs (settings_impl, gwd_settings_notified_update_decorations); |
686 | - release_notify_funcs (settings_impl); |
687 | + if (decor_shadow_options_cmp (&settings->inactive_shadow, &inactive_shadow)) { |
688 | + changed |= TRUE; |
689 | + settings->inactive_shadow = inactive_shadow; |
690 | + } |
691 | + |
692 | + if (decor_shadow_options_cmp (&settings->active_shadow, &active_shadow)) { |
693 | + changed |= TRUE; |
694 | + settings->active_shadow = active_shadow; |
695 | + } |
696 | + |
697 | + if (changed) { |
698 | + append_to_notify_funcs (settings, gwd_settings_notified_update_decorations); |
699 | + release_notify_funcs (settings); |
700 | } |
701 | |
702 | return changed; |
703 | } |
704 | |
705 | static gboolean |
706 | -gwd_settings_use_tooltips_changed (GWDSettingsWritable *settings, |
707 | - gboolean use_tooltips) |
708 | +gwd_settings_use_tooltips_changed (GWDSettingsWritable *writable, |
709 | + gboolean use_tooltips) |
710 | { |
711 | - GWDSettingsImpl *settings_impl = GWD_SETTINGS_IMPL (settings); |
712 | - GWDSettingsImplPrivate *priv = GET_PRIVATE (settings_impl); |
713 | - |
714 | - if (priv->use_tooltips != use_tooltips) |
715 | - { |
716 | - priv->use_tooltips = use_tooltips; |
717 | - append_to_notify_funcs (settings_impl, gwd_settings_notified_update_decorations); |
718 | - release_notify_funcs (settings_impl); |
719 | - return TRUE; |
720 | - } |
721 | - |
722 | - return FALSE; |
723 | + GWDSettings *settings = GWD_SETTINGS (writable); |
724 | + |
725 | + if (settings->use_tooltips == use_tooltips) |
726 | + return FALSE; |
727 | + |
728 | + settings->use_tooltips = use_tooltips; |
729 | + |
730 | + append_to_notify_funcs (settings, gwd_settings_notified_update_decorations); |
731 | + release_notify_funcs (settings); |
732 | + |
733 | + return TRUE; |
734 | } |
735 | |
736 | static gboolean |
737 | -gwd_settings_blur_changed (GWDSettingsWritable *settings, |
738 | - const gchar *type) |
739 | +gwd_settings_blur_changed (GWDSettingsWritable *writable, |
740 | + const gchar *type) |
741 | |
742 | { |
743 | - GWDSettingsImpl *settings_impl = GWD_SETTINGS_IMPL (settings); |
744 | - GWDSettingsImplPrivate *priv = GET_PRIVATE (settings_impl); |
745 | + GWDSettings *settings = GWD_SETTINGS (writable); |
746 | gint new_type = -1; |
747 | |
748 | - if (priv->cmdline_opts & CMDLINE_BLUR) |
749 | - return FALSE; |
750 | + if (settings->cmdline_opts & CMDLINE_BLUR) |
751 | + return FALSE; |
752 | |
753 | if (strcmp (type, "titlebar") == 0) |
754 | - new_type = BLUR_TYPE_TITLEBAR; |
755 | + new_type = BLUR_TYPE_TITLEBAR; |
756 | else if (strcmp (type, "all") == 0) |
757 | - new_type = BLUR_TYPE_ALL; |
758 | + new_type = BLUR_TYPE_ALL; |
759 | else if (strcmp (type, "none") == 0) |
760 | - new_type = BLUR_TYPE_NONE; |
761 | + new_type = BLUR_TYPE_NONE; |
762 | |
763 | if (new_type == -1) |
764 | - return FALSE; |
765 | - |
766 | - if (priv->blur_type != new_type) |
767 | - { |
768 | - priv->blur_type = new_type; |
769 | - append_to_notify_funcs (settings_impl, gwd_settings_notified_update_decorations); |
770 | - release_notify_funcs (settings_impl); |
771 | - return TRUE; |
772 | - } |
773 | - else |
774 | - return FALSE; |
775 | -} |
776 | - |
777 | -static void |
778 | -free_and_set_metacity_theme (GWDSettingsWritable *settings, |
779 | - const gchar *metacity_theme) |
780 | -{ |
781 | - GWDSettingsImpl *settings_impl = GWD_SETTINGS_IMPL (settings); |
782 | - GWDSettingsImplPrivate *priv = GET_PRIVATE (settings_impl); |
783 | - |
784 | - if (priv->metacity_theme) |
785 | - g_free (priv->metacity_theme); |
786 | - |
787 | - priv->metacity_theme = g_strdup (metacity_theme); |
788 | + return FALSE; |
789 | + |
790 | + if (settings->blur_type == new_type) |
791 | + return FALSE; |
792 | + |
793 | + settings->blur_type = new_type; |
794 | + |
795 | + append_to_notify_funcs (settings, gwd_settings_notified_update_decorations); |
796 | + release_notify_funcs (settings); |
797 | + |
798 | + return TRUE; |
799 | } |
800 | |
801 | static gboolean |
802 | -gwd_settings_metacity_theme_changed (GWDSettingsWritable *settings, |
803 | - gboolean use_metacity_theme, |
804 | - const gchar *metacity_theme) |
805 | +gwd_settings_metacity_theme_changed (GWDSettingsWritable *writable, |
806 | + gboolean use_metacity_theme, |
807 | + const gchar *metacity_theme) |
808 | { |
809 | - GWDSettingsImpl *settings_impl = GWD_SETTINGS_IMPL (settings); |
810 | - GWDSettingsImplPrivate *priv = GET_PRIVATE (settings_impl); |
811 | + GWDSettings *settings = GWD_SETTINGS (writable); |
812 | |
813 | - if (priv->cmdline_opts & CMDLINE_THEME) |
814 | - return FALSE; |
815 | + if (settings->cmdline_opts & CMDLINE_THEME) |
816 | + return FALSE; |
817 | |
818 | if (!metacity_theme) |
819 | - return FALSE; |
820 | - |
821 | - if (use_metacity_theme) |
822 | - { |
823 | - if (g_strcmp0 (metacity_theme, priv->metacity_theme) == 0) |
824 | - return FALSE; |
825 | - |
826 | - free_and_set_metacity_theme (settings, metacity_theme); |
827 | + return FALSE; |
828 | + |
829 | + if (use_metacity_theme) { |
830 | + if (g_strcmp0 (metacity_theme, settings->metacity_theme) == 0) |
831 | + return FALSE; |
832 | + |
833 | + g_free (settings->metacity_theme); |
834 | + settings->metacity_theme = g_strdup (metacity_theme); |
835 | + } else { |
836 | + g_free (settings->metacity_theme); |
837 | + settings->metacity_theme = g_strdup (""); |
838 | } |
839 | - else |
840 | - free_and_set_metacity_theme (settings, ""); |
841 | - |
842 | - append_to_notify_funcs (settings_impl, gwd_settings_notified_update_metacity_theme); |
843 | - append_to_notify_funcs (settings_impl, gwd_settings_notified_update_decorations); |
844 | - release_notify_funcs (settings_impl); |
845 | - |
846 | - return TRUE; |
847 | -} |
848 | - |
849 | -static gboolean |
850 | -gwd_settings_opacity_changed (GWDSettingsWritable *settings, |
851 | - gdouble active_opacity, |
852 | - gdouble inactive_opacity, |
853 | - gboolean active_shade_opacity, |
854 | - gboolean inactive_shade_opacity) |
855 | -{ |
856 | - GWDSettingsImpl *settings_impl = GWD_SETTINGS_IMPL (settings); |
857 | - GWDSettingsImplPrivate *priv = GET_PRIVATE (settings_impl); |
858 | - |
859 | - if (priv->metacity_active_opacity == active_opacity && |
860 | - priv->metacity_inactive_opacity == inactive_opacity && |
861 | - priv->metacity_active_shade_opacity == active_shade_opacity && |
862 | - priv->metacity_inactive_shade_opacity == inactive_shade_opacity) |
863 | - return FALSE; |
864 | - |
865 | - priv->metacity_active_opacity = active_opacity; |
866 | - priv->metacity_inactive_opacity = inactive_opacity; |
867 | - priv->metacity_active_shade_opacity = active_shade_opacity; |
868 | - priv->metacity_inactive_shade_opacity = inactive_shade_opacity; |
869 | - |
870 | - append_to_notify_funcs (settings_impl, gwd_settings_notified_update_decorations); |
871 | - release_notify_funcs (settings_impl); |
872 | - |
873 | - return TRUE; |
874 | -} |
875 | - |
876 | -static gboolean |
877 | -gwd_settings_button_layout_changed (GWDSettingsWritable *settings, |
878 | - const gchar *button_layout) |
879 | -{ |
880 | - GWDSettingsImpl *settings_impl = GWD_SETTINGS_IMPL (settings); |
881 | - GWDSettingsImplPrivate *priv = GET_PRIVATE (settings_impl); |
882 | + |
883 | + append_to_notify_funcs (settings, gwd_settings_notified_update_metacity_theme); |
884 | + append_to_notify_funcs (settings, gwd_settings_notified_update_decorations); |
885 | + release_notify_funcs (settings); |
886 | + |
887 | + return TRUE; |
888 | +} |
889 | + |
890 | +static gboolean |
891 | +gwd_settings_opacity_changed (GWDSettingsWritable *writable, |
892 | + gdouble active_opacity, |
893 | + gdouble inactive_opacity, |
894 | + gboolean active_shade_opacity, |
895 | + gboolean inactive_shade_opacity) |
896 | +{ |
897 | + GWDSettings *settings = GWD_SETTINGS (writable); |
898 | + |
899 | + if (settings->metacity_active_opacity == active_opacity && |
900 | + settings->metacity_inactive_opacity == inactive_opacity && |
901 | + settings->metacity_active_shade_opacity == active_shade_opacity && |
902 | + settings->metacity_inactive_shade_opacity == inactive_shade_opacity) |
903 | + return FALSE; |
904 | + |
905 | + settings->metacity_active_opacity = active_opacity; |
906 | + settings->metacity_inactive_opacity = inactive_opacity; |
907 | + settings->metacity_active_shade_opacity = active_shade_opacity; |
908 | + settings->metacity_inactive_shade_opacity = inactive_shade_opacity; |
909 | + |
910 | + append_to_notify_funcs (settings, gwd_settings_notified_update_decorations); |
911 | + release_notify_funcs (settings); |
912 | + |
913 | + return TRUE; |
914 | +} |
915 | + |
916 | +static gboolean |
917 | +gwd_settings_button_layout_changed (GWDSettingsWritable *writable, |
918 | + const gchar *button_layout) |
919 | +{ |
920 | + GWDSettings *settings = GWD_SETTINGS (writable); |
921 | |
922 | if (!button_layout) |
923 | - return FALSE; |
924 | - |
925 | - if (g_strcmp0 (priv->metacity_button_layout, button_layout) == 0) |
926 | - return FALSE; |
927 | - |
928 | - if (priv->metacity_button_layout) |
929 | - g_free (priv->metacity_button_layout); |
930 | - |
931 | - priv->metacity_button_layout = g_strdup (button_layout); |
932 | - |
933 | - append_to_notify_funcs (settings_impl, gwd_settings_notified_metacity_button_layout); |
934 | - append_to_notify_funcs (settings_impl, gwd_settings_notified_update_decorations); |
935 | - release_notify_funcs (settings_impl); |
936 | + return FALSE; |
937 | + |
938 | + if (g_strcmp0 (settings->metacity_button_layout, button_layout) == 0) |
939 | + return FALSE; |
940 | + |
941 | + g_free (settings->metacity_button_layout); |
942 | + settings->metacity_button_layout = g_strdup (button_layout); |
943 | + |
944 | + append_to_notify_funcs (settings, gwd_settings_notified_metacity_button_layout); |
945 | + append_to_notify_funcs (settings, gwd_settings_notified_update_decorations); |
946 | + release_notify_funcs (settings); |
947 | |
948 | return TRUE; |
949 | } |
950 | |
951 | static gboolean |
952 | -gwd_settings_font_changed (GWDSettingsWritable *settings, |
953 | - gboolean titlebar_uses_system_font, |
954 | - const gchar *titlebar_font) |
955 | +gwd_settings_font_changed (GWDSettingsWritable *writable, |
956 | + gboolean titlebar_uses_system_font, |
957 | + const gchar *titlebar_font) |
958 | { |
959 | - GWDSettingsImpl *settings_impl = GWD_SETTINGS_IMPL (settings); |
960 | - GWDSettingsImplPrivate *priv = GET_PRIVATE (settings_impl); |
961 | - |
962 | + GWDSettings *settings = GWD_SETTINGS (writable); |
963 | const gchar *no_font = NULL; |
964 | const gchar *use_font = NULL; |
965 | |
966 | if (!titlebar_font) |
967 | - return FALSE; |
968 | + return FALSE; |
969 | |
970 | if (titlebar_uses_system_font) |
971 | - use_font = no_font; |
972 | + use_font = no_font; |
973 | else |
974 | - use_font = titlebar_font; |
975 | - |
976 | - if (g_strcmp0 (priv->titlebar_font, use_font) == 0) |
977 | - return FALSE; |
978 | - |
979 | - if (priv->titlebar_font) |
980 | - { |
981 | - g_free (priv->titlebar_font); |
982 | - priv->titlebar_font = NULL; |
983 | - } |
984 | - |
985 | - priv->titlebar_font = use_font ? g_strdup (use_font) : NULL; |
986 | - |
987 | - append_to_notify_funcs (settings_impl, gwd_settings_notified_update_decorations); |
988 | - append_to_notify_funcs (settings_impl, gwd_settings_notified_update_frames); |
989 | - release_notify_funcs (settings_impl); |
990 | + use_font = titlebar_font; |
991 | + |
992 | + if (g_strcmp0 (settings->titlebar_font, use_font) == 0) |
993 | + return FALSE; |
994 | + |
995 | + g_free (settings->titlebar_font); |
996 | + settings->titlebar_font = use_font ? g_strdup (use_font) : NULL; |
997 | + |
998 | + append_to_notify_funcs (settings, gwd_settings_notified_update_decorations); |
999 | + append_to_notify_funcs (settings, gwd_settings_notified_update_frames); |
1000 | + release_notify_funcs (settings); |
1001 | |
1002 | return TRUE; |
1003 | } |
1004 | |
1005 | static gboolean |
1006 | get_click_action_value (const gchar *action, |
1007 | - gint *action_value, |
1008 | - gint default_value) |
1009 | + gint *action_value, |
1010 | + gint default_value) |
1011 | { |
1012 | if (!action_value) |
1013 | - return FALSE; |
1014 | + return FALSE; |
1015 | |
1016 | *action_value = -1; |
1017 | |
1018 | if (strcmp (action, "toggle_shade") == 0) |
1019 | - *action_value = CLICK_ACTION_SHADE; |
1020 | + *action_value = CLICK_ACTION_SHADE; |
1021 | else if (strcmp (action, "toggle_maximize") == 0) |
1022 | - *action_value = CLICK_ACTION_MAXIMIZE; |
1023 | + *action_value = CLICK_ACTION_MAXIMIZE; |
1024 | else if (strcmp (action, "minimize") == 0) |
1025 | - *action_value = CLICK_ACTION_MINIMIZE; |
1026 | + *action_value = CLICK_ACTION_MINIMIZE; |
1027 | else if (strcmp (action, "raise") == 0) |
1028 | - *action_value = CLICK_ACTION_RAISE; |
1029 | + *action_value = CLICK_ACTION_RAISE; |
1030 | else if (strcmp (action, "lower") == 0) |
1031 | - *action_value = CLICK_ACTION_LOWER; |
1032 | + *action_value = CLICK_ACTION_LOWER; |
1033 | else if (strcmp (action, "menu") == 0) |
1034 | - *action_value = CLICK_ACTION_MENU; |
1035 | + *action_value = CLICK_ACTION_MENU; |
1036 | else if (strcmp (action, "none") == 0) |
1037 | - *action_value = CLICK_ACTION_NONE; |
1038 | + *action_value = CLICK_ACTION_NONE; |
1039 | |
1040 | - if (*action_value == -1) |
1041 | - { |
1042 | - *action_value = default_value; |
1043 | - return FALSE; |
1044 | + if (*action_value == -1) { |
1045 | + *action_value = default_value; |
1046 | + return FALSE; |
1047 | } |
1048 | |
1049 | return TRUE; |
1050 | @@ -440,52 +421,49 @@ |
1051 | |
1052 | static gboolean |
1053 | get_wheel_action_value (const gchar *action, |
1054 | - gint *action_value, |
1055 | - gint default_value) |
1056 | + gint *action_value, |
1057 | + gint default_value) |
1058 | { |
1059 | if (!action_value) |
1060 | - return FALSE; |
1061 | + return FALSE; |
1062 | |
1063 | *action_value = -1; |
1064 | |
1065 | if (strcmp (action, "shade") == 0) |
1066 | - *action_value = WHEEL_ACTION_SHADE; |
1067 | + *action_value = WHEEL_ACTION_SHADE; |
1068 | else if (strcmp (action, "none") == 0) |
1069 | - *action_value = WHEEL_ACTION_NONE; |
1070 | + *action_value = WHEEL_ACTION_NONE; |
1071 | |
1072 | - if (*action_value == -1) |
1073 | - { |
1074 | - *action_value = default_value; |
1075 | - return FALSE; |
1076 | + if (*action_value == -1) { |
1077 | + *action_value = default_value; |
1078 | + return FALSE; |
1079 | } |
1080 | |
1081 | return TRUE; |
1082 | } |
1083 | |
1084 | static gboolean |
1085 | -gwd_settings_actions_changed (GWDSettingsWritable *settings, |
1086 | - const gchar *action_double_click_titlebar, |
1087 | - const gchar *action_middle_click_titlebar, |
1088 | - const gchar *action_right_click_titlebar, |
1089 | - const gchar *mouse_wheel_action) |
1090 | +gwd_settings_actions_changed (GWDSettingsWritable *writable, |
1091 | + const gchar *action_double_click_titlebar, |
1092 | + const gchar *action_middle_click_titlebar, |
1093 | + const gchar *action_right_click_titlebar, |
1094 | + const gchar *mouse_wheel_action) |
1095 | { |
1096 | - GWDSettingsImpl *settings_impl = GWD_SETTINGS_IMPL (settings); |
1097 | - GWDSettingsImplPrivate *priv = GET_PRIVATE (settings_impl); |
1098 | - |
1099 | + GWDSettings *settings = GWD_SETTINGS (writable); |
1100 | gboolean ret = FALSE; |
1101 | |
1102 | ret |= get_click_action_value (action_double_click_titlebar, |
1103 | - &priv->titlebar_double_click_action, |
1104 | - DOUBLE_CLICK_ACTION_DEFAULT); |
1105 | + &settings->titlebar_double_click_action, |
1106 | + DOUBLE_CLICK_ACTION_DEFAULT); |
1107 | ret |= get_click_action_value (action_middle_click_titlebar, |
1108 | - &priv->titlebar_middle_click_action, |
1109 | - MIDDLE_CLICK_ACTION_DEFAULT); |
1110 | + &settings->titlebar_middle_click_action, |
1111 | + MIDDLE_CLICK_ACTION_DEFAULT); |
1112 | ret |= get_click_action_value (action_right_click_titlebar, |
1113 | - &priv->titlebar_right_click_action, |
1114 | - RIGHT_CLICK_ACTION_DEFAULT); |
1115 | + &settings->titlebar_right_click_action, |
1116 | + RIGHT_CLICK_ACTION_DEFAULT); |
1117 | ret |= get_wheel_action_value (mouse_wheel_action, |
1118 | - &priv->mouse_wheel_action, |
1119 | - WHEEL_ACTION_DEFAULT); |
1120 | + &settings->mouse_wheel_action, |
1121 | + WHEEL_ACTION_DEFAULT); |
1122 | |
1123 | return ret; |
1124 | } |
1125 | @@ -493,19 +471,20 @@ |
1126 | static void |
1127 | gwd_settings_freeze_updates (GWDSettingsWritable *writable) |
1128 | { |
1129 | - GWDSettingsImplPrivate *priv = GET_PRIVATE (writable); |
1130 | - ++priv->freeze_count; |
1131 | + GWDSettings *settings = GWD_SETTINGS (writable); |
1132 | + |
1133 | + ++settings->freeze_count; |
1134 | } |
1135 | |
1136 | static void |
1137 | gwd_settings_thaw_updates (GWDSettingsWritable *writable) |
1138 | { |
1139 | - GWDSettingsImplPrivate *priv = GET_PRIVATE (writable); |
1140 | - |
1141 | - if (priv->freeze_count) |
1142 | - --priv->freeze_count; |
1143 | - |
1144 | - release_notify_funcs (GWD_SETTINGS_IMPL (writable)); |
1145 | + GWDSettings *settings = GWD_SETTINGS (writable); |
1146 | + |
1147 | + if (settings->freeze_count) |
1148 | + --settings->freeze_count; |
1149 | + |
1150 | + release_notify_funcs (settings); |
1151 | } |
1152 | |
1153 | static void |
1154 | @@ -524,271 +503,343 @@ |
1155 | } |
1156 | |
1157 | static void |
1158 | -gwd_settings_interface_init (GWDSettingsInterface *interface) |
1159 | -{ |
1160 | -} |
1161 | - |
1162 | -static void |
1163 | gwd_settings_dispose (GObject *object) |
1164 | { |
1165 | - G_OBJECT_CLASS (gwd_settings_impl_parent_class)->dispose (object); |
1166 | + GWDSettings *settings; |
1167 | + |
1168 | + settings = GWD_SETTINGS (object); |
1169 | + |
1170 | + g_clear_object (&settings->notified); |
1171 | + |
1172 | + G_OBJECT_CLASS (gwd_settings_parent_class)->dispose (object); |
1173 | } |
1174 | |
1175 | static void |
1176 | gwd_settings_finalize (GObject *object) |
1177 | { |
1178 | - GWDSettingsImplPrivate *priv = GET_PRIVATE (object); |
1179 | - G_OBJECT_CLASS (gwd_settings_impl_parent_class)->finalize (object); |
1180 | - |
1181 | - if (priv->metacity_theme) |
1182 | - { |
1183 | - g_free (priv->metacity_theme); |
1184 | - priv->metacity_theme = NULL; |
1185 | - } |
1186 | - |
1187 | - if (priv->metacity_button_layout) |
1188 | - { |
1189 | - g_free (priv->metacity_button_layout); |
1190 | - priv->metacity_button_layout = NULL; |
1191 | - } |
1192 | - |
1193 | - if (priv->titlebar_font) |
1194 | - { |
1195 | - g_free (priv->titlebar_font); |
1196 | - priv->titlebar_font = NULL; |
1197 | - } |
1198 | - |
1199 | - if (priv->notified) |
1200 | - { |
1201 | - g_object_unref (priv->notified); |
1202 | - priv->notified = NULL; |
1203 | - } |
1204 | + GWDSettings *settings; |
1205 | + |
1206 | + settings = GWD_SETTINGS (object); |
1207 | + |
1208 | + g_clear_pointer (&settings->metacity_theme, g_free); |
1209 | + g_clear_pointer (&settings->metacity_button_layout, g_free); |
1210 | + g_clear_pointer (&settings->titlebar_font, g_free); |
1211 | + |
1212 | + G_OBJECT_CLASS (gwd_settings_parent_class)->finalize (object); |
1213 | } |
1214 | |
1215 | static void |
1216 | gwd_settings_set_property (GObject *object, |
1217 | - guint property_id, |
1218 | - const GValue *value, |
1219 | - GParamSpec *pspec) |
1220 | + guint property_id, |
1221 | + const GValue *value, |
1222 | + GParamSpec *pspec) |
1223 | { |
1224 | - GWDSettingsImplPrivate *priv = GET_PRIVATE (object); |
1225 | - |
1226 | - switch (property_id) |
1227 | - { |
1228 | - case GWD_SETTINGS_IMPL_PROPERTY_CMDLINE_OPTIONS: |
1229 | - priv->cmdline_opts = g_value_get_int (value); |
1230 | - break; |
1231 | - case GWD_SETTINGS_IMPL_PROPERTY_BLUR_CHANGED: |
1232 | - priv->blur_type = g_value_get_int (value); |
1233 | - break; |
1234 | - case GWD_SETTINGS_IMPL_PROPERTY_METACITY_THEME: |
1235 | - if (priv->metacity_theme) |
1236 | - g_free (priv->metacity_theme); |
1237 | - |
1238 | - priv->metacity_theme = g_value_dup_string (value); |
1239 | - break; |
1240 | - case GWD_SETTINGS_IMPL_PROPERTY_SETTINGS_NOTIFIED: |
1241 | - g_return_if_fail (!priv->notified); |
1242 | - priv->notified = (GWDSettingsNotified *) g_value_get_pointer (value); |
1243 | - default: |
1244 | - break; |
1245 | + GWDSettings *settings; |
1246 | + |
1247 | + settings = GWD_SETTINGS (object); |
1248 | + |
1249 | + switch (property_id) { |
1250 | + case PROP_CMDLINE_OPTIONS: |
1251 | + settings->cmdline_opts = g_value_get_int (value); |
1252 | + break; |
1253 | + |
1254 | + case PROP_BLUR: |
1255 | + settings->blur_type = g_value_get_int (value); |
1256 | + break; |
1257 | + |
1258 | + case PROP_METACITY_THEME: |
1259 | + g_free (settings->metacity_theme); |
1260 | + settings->metacity_theme = g_value_dup_string (value); |
1261 | + break; |
1262 | + |
1263 | + case PROP_SETTINGS_NOTIFIED: |
1264 | + g_return_if_fail (!settings->notified); |
1265 | + settings->notified = (GWDSettingsNotified *) g_value_get_pointer (value); |
1266 | + break; |
1267 | + |
1268 | + default: |
1269 | + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); |
1270 | + break; |
1271 | } |
1272 | } |
1273 | |
1274 | static void |
1275 | gwd_settings_get_property (GObject *object, |
1276 | - guint property_id, |
1277 | - GValue *value, |
1278 | - GParamSpec *pspec) |
1279 | + guint property_id, |
1280 | + GValue *value, |
1281 | + GParamSpec *pspec) |
1282 | { |
1283 | - GWDSettingsImplPrivate *priv = GET_PRIVATE (object); |
1284 | - |
1285 | - switch (property_id) |
1286 | - { |
1287 | - case GWD_SETTINGS_IMPL_PROPERTY_ACTIVE_SHADOW: |
1288 | - g_value_set_pointer (value, &priv->active_shadow); |
1289 | - break; |
1290 | - case GWD_SETTINGS_IMPL_PROPERTY_INACTIVE_SHADOW: |
1291 | - g_value_set_pointer (value, &priv->inactive_shadow); |
1292 | - break; |
1293 | - case GWD_SETTINGS_IMPL_PROPERTY_USE_TOOLTIPS: |
1294 | - g_value_set_boolean (value, priv->use_tooltips); |
1295 | - break; |
1296 | - case GWD_SETTINGS_IMPL_PROPERTY_BLUR_CHANGED: |
1297 | - g_value_set_int (value, priv->blur_type); |
1298 | - break; |
1299 | - case GWD_SETTINGS_IMPL_PROPERTY_METACITY_THEME: |
1300 | - g_value_set_string (value, priv->metacity_theme); |
1301 | - break; |
1302 | - case GWD_SETTINGS_IMPL_PROPERTY_ACTIVE_OPACITY: |
1303 | - g_value_set_double (value, priv->metacity_active_opacity); |
1304 | - break; |
1305 | - case GWD_SETTINGS_IMPL_PROPERTY_INACTIVE_OPACITY: |
1306 | - g_value_set_double (value, priv->metacity_inactive_opacity); |
1307 | - break; |
1308 | - case GWD_SETTINGS_IMPL_PROPERTY_ACTIVE_SHADE_OPACITY: |
1309 | - g_value_set_boolean (value, priv->metacity_active_shade_opacity); |
1310 | - break; |
1311 | - case GWD_SETTINGS_IMPL_PROPERTY_INACTIVE_SHADE_OPACITY: |
1312 | - g_value_set_boolean (value, priv->metacity_inactive_shade_opacity); |
1313 | - break; |
1314 | - case GWD_SETTINGS_IMPL_PROPERTY_BUTTON_LAYOUT: |
1315 | - g_value_set_string (value, priv->metacity_button_layout); |
1316 | - break; |
1317 | - case GWD_SETTINGS_IMPL_PROPERTY_TITLEBAR_ACTION_DOUBLE_CLICK: |
1318 | - g_value_set_int (value, priv->titlebar_double_click_action); |
1319 | - break; |
1320 | - case GWD_SETTINGS_IMPL_PROPERTY_TITLEBAR_ACTION_MIDDLE_CLICK: |
1321 | - g_value_set_int (value, priv->titlebar_middle_click_action); |
1322 | - break; |
1323 | - case GWD_SETTINGS_IMPL_PROPERTY_TITLEBAR_ACTION_RIGHT_CLICK: |
1324 | - g_value_set_int (value, priv->titlebar_right_click_action); |
1325 | - break; |
1326 | - case GWD_SETTINGS_IMPL_PROPERTY_MOUSE_WHEEL_ACTION: |
1327 | - g_value_set_int (value, priv->mouse_wheel_action); |
1328 | - break; |
1329 | - case GWD_SETTINGS_IMPL_PROPERTY_TITLEBAR_FONT: |
1330 | - g_value_set_string (value, priv->titlebar_font); |
1331 | - break; |
1332 | - default: |
1333 | - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); |
1334 | - break; |
1335 | + GWDSettings *settings; |
1336 | + |
1337 | + settings = GWD_SETTINGS (object); |
1338 | + |
1339 | + switch (property_id) { |
1340 | + case PROP_ACTIVE_SHADOW: |
1341 | + g_value_set_pointer (value, &settings->active_shadow); |
1342 | + break; |
1343 | + |
1344 | + case PROP_INACTIVE_SHADOW: |
1345 | + g_value_set_pointer (value, &settings->inactive_shadow); |
1346 | + break; |
1347 | + |
1348 | + case PROP_USE_TOOLTIPS: |
1349 | + g_value_set_boolean (value, settings->use_tooltips); |
1350 | + break; |
1351 | + |
1352 | + case PROP_BLUR: |
1353 | + g_value_set_int (value, settings->blur_type); |
1354 | + break; |
1355 | + |
1356 | + case PROP_METACITY_THEME: |
1357 | + g_value_set_string (value, settings->metacity_theme); |
1358 | + break; |
1359 | + |
1360 | + case PROP_ACTIVE_OPACITY: |
1361 | + g_value_set_double (value, settings->metacity_active_opacity); |
1362 | + break; |
1363 | + |
1364 | + case PROP_INACTIVE_OPACITY: |
1365 | + g_value_set_double (value, settings->metacity_inactive_opacity); |
1366 | + break; |
1367 | + |
1368 | + case PROP_ACTIVE_SHADE_OPACITY: |
1369 | + g_value_set_boolean (value, settings->metacity_active_shade_opacity); |
1370 | + break; |
1371 | + |
1372 | + case PROP_INACTIVE_SHADE_OPACITY: |
1373 | + g_value_set_boolean (value, settings->metacity_inactive_shade_opacity); |
1374 | + break; |
1375 | + |
1376 | + case PROP_BUTTON_LAYOUT: |
1377 | + g_value_set_string (value, settings->metacity_button_layout); |
1378 | + break; |
1379 | + |
1380 | + case PROP_TITLEBAR_ACTION_DOUBLE_CLICK: |
1381 | + g_value_set_int (value, settings->titlebar_double_click_action); |
1382 | + break; |
1383 | + |
1384 | + case PROP_TITLEBAR_ACTION_MIDDLE_CLICK: |
1385 | + g_value_set_int (value, settings->titlebar_middle_click_action); |
1386 | + break; |
1387 | + |
1388 | + case PROP_TITLEBAR_ACTION_RIGHT_CLICK: |
1389 | + g_value_set_int (value, settings->titlebar_right_click_action); |
1390 | + break; |
1391 | + |
1392 | + case PROP_MOUSE_WHEEL_ACTION: |
1393 | + g_value_set_int (value, settings->mouse_wheel_action); |
1394 | + break; |
1395 | + |
1396 | + case PROP_TITLEBAR_FONT: |
1397 | + g_value_set_string (value, settings->titlebar_font); |
1398 | + break; |
1399 | + |
1400 | + default: |
1401 | + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); |
1402 | + break; |
1403 | } |
1404 | } |
1405 | |
1406 | static void |
1407 | -gwd_settings_impl_class_init (GWDSettingsImplClass *klass) |
1408 | +gwd_settings_class_init (GWDSettingsClass *settings_class) |
1409 | { |
1410 | - GObjectClass *object_class = G_OBJECT_CLASS (klass); |
1411 | + GObjectClass *object_class; |
1412 | |
1413 | - g_type_class_add_private (klass, sizeof (GWDSettingsImplPrivate)); |
1414 | + object_class = G_OBJECT_CLASS (settings_class); |
1415 | |
1416 | object_class->dispose = gwd_settings_dispose; |
1417 | object_class->finalize = gwd_settings_finalize; |
1418 | object_class->get_property = gwd_settings_get_property; |
1419 | object_class->set_property = gwd_settings_set_property; |
1420 | |
1421 | - g_object_class_override_property (object_class, |
1422 | - GWD_SETTINGS_IMPL_PROPERTY_ACTIVE_SHADOW, |
1423 | - "active-shadow"); |
1424 | - g_object_class_override_property (object_class, |
1425 | - GWD_SETTINGS_IMPL_PROPERTY_INACTIVE_SHADOW, |
1426 | - "inactive-shadow"); |
1427 | - g_object_class_override_property (object_class, |
1428 | - GWD_SETTINGS_IMPL_PROPERTY_USE_TOOLTIPS, |
1429 | - "use-tooltips"); |
1430 | - g_object_class_override_property (object_class, |
1431 | - GWD_SETTINGS_IMPL_PROPERTY_BLUR_CHANGED, |
1432 | - "blur"); |
1433 | - g_object_class_override_property (object_class, |
1434 | - GWD_SETTINGS_IMPL_PROPERTY_METACITY_THEME, |
1435 | - "metacity-theme"); |
1436 | - g_object_class_override_property (object_class, |
1437 | - GWD_SETTINGS_IMPL_PROPERTY_ACTIVE_OPACITY, |
1438 | - "metacity-active-opacity"); |
1439 | - g_object_class_override_property (object_class, |
1440 | - GWD_SETTINGS_IMPL_PROPERTY_INACTIVE_OPACITY, |
1441 | - "metacity-inactive-opacity"); |
1442 | - g_object_class_override_property (object_class, |
1443 | - GWD_SETTINGS_IMPL_PROPERTY_ACTIVE_SHADE_OPACITY, |
1444 | - "metacity-active-shade-opacity"); |
1445 | - g_object_class_override_property (object_class, |
1446 | - GWD_SETTINGS_IMPL_PROPERTY_INACTIVE_SHADE_OPACITY, |
1447 | - "metacity-inactive-shade-opacity"); |
1448 | - g_object_class_override_property (object_class, |
1449 | - GWD_SETTINGS_IMPL_PROPERTY_BUTTON_LAYOUT, |
1450 | - "metacity-button-layout"); |
1451 | - g_object_class_override_property (object_class, |
1452 | - GWD_SETTINGS_IMPL_PROPERTY_TITLEBAR_ACTION_DOUBLE_CLICK, |
1453 | - "titlebar-double-click-action"); |
1454 | - g_object_class_override_property (object_class, |
1455 | - GWD_SETTINGS_IMPL_PROPERTY_TITLEBAR_ACTION_MIDDLE_CLICK, |
1456 | - "titlebar-middle-click-action"); |
1457 | - g_object_class_override_property (object_class, |
1458 | - GWD_SETTINGS_IMPL_PROPERTY_TITLEBAR_ACTION_RIGHT_CLICK, |
1459 | - "titlebar-right-click-action"); |
1460 | - g_object_class_override_property (object_class, |
1461 | - GWD_SETTINGS_IMPL_PROPERTY_MOUSE_WHEEL_ACTION, |
1462 | - "mouse-wheel-action"); |
1463 | - g_object_class_override_property (object_class, |
1464 | - GWD_SETTINGS_IMPL_PROPERTY_TITLEBAR_FONT, |
1465 | - "titlebar-font"); |
1466 | - g_object_class_install_property (object_class, |
1467 | - GWD_SETTINGS_IMPL_PROPERTY_CMDLINE_OPTIONS, |
1468 | - g_param_spec_int ("cmdline-options", |
1469 | - "Command line options", |
1470 | - "Which options were specified on the command line", |
1471 | - 0, |
1472 | - G_MAXINT32, |
1473 | - 0, |
1474 | - G_PARAM_READABLE | |
1475 | - G_PARAM_WRITABLE | |
1476 | - G_PARAM_CONSTRUCT_ONLY)); |
1477 | - g_object_class_install_property (object_class, |
1478 | - GWD_SETTINGS_IMPL_PROPERTY_SETTINGS_NOTIFIED, |
1479 | - g_param_spec_pointer ("settings-notified", |
1480 | - "GWDSettingsNotified", |
1481 | - "A GWDSettingsNotified which will be updated", |
1482 | - G_PARAM_WRITABLE | |
1483 | - G_PARAM_CONSTRUCT_ONLY)); |
1484 | + settings_properties[PROP_ACTIVE_SHADOW] = |
1485 | + g_param_spec_pointer ("active-shadow", |
1486 | + "Active Shadow", |
1487 | + "Active Shadow Settings", |
1488 | + G_PARAM_READABLE); |
1489 | + |
1490 | + settings_properties[PROP_INACTIVE_SHADOW] = |
1491 | + g_param_spec_pointer ("inactive-shadow", |
1492 | + "Inactive Shadow", |
1493 | + "Inactive Shadow", |
1494 | + G_PARAM_READABLE); |
1495 | + |
1496 | + settings_properties[PROP_USE_TOOLTIPS] = |
1497 | + g_param_spec_boolean ("use-tooltips", |
1498 | + "Use Tooltips", |
1499 | + "Use Tooltips Setting", |
1500 | + USE_TOOLTIPS_DEFAULT, |
1501 | + G_PARAM_READABLE); |
1502 | + |
1503 | + settings_properties[PROP_BLUR] = |
1504 | + g_param_spec_int ("blur", |
1505 | + "Blur Type", |
1506 | + "Blur type property", |
1507 | + BLUR_TYPE_NONE, |
1508 | + BLUR_TYPE_ALL, |
1509 | + BLUR_TYPE_NONE, |
1510 | + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY); |
1511 | + |
1512 | + settings_properties[PROP_METACITY_THEME] = |
1513 | + g_param_spec_string ("metacity-theme", |
1514 | + "Metacity Theme", |
1515 | + "Metacity Theme Setting", |
1516 | + METACITY_THEME_DEFAULT, |
1517 | + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY); |
1518 | + |
1519 | + settings_properties[PROP_ACTIVE_OPACITY] = |
1520 | + g_param_spec_double ("metacity-active-opacity", |
1521 | + "Metacity Active Opacity", |
1522 | + "Metacity Active Opacity", |
1523 | + 0.0, |
1524 | + 1.0, |
1525 | + METACITY_ACTIVE_OPACITY_DEFAULT, |
1526 | + G_PARAM_READABLE); |
1527 | + |
1528 | + settings_properties[PROP_INACTIVE_OPACITY] = |
1529 | + g_param_spec_double ("metacity-inactive-opacity", |
1530 | + "Metacity Inactive Opacity", |
1531 | + "Metacity Inactive Opacity", |
1532 | + 0.0, |
1533 | + 1.0, |
1534 | + METACITY_INACTIVE_OPACITY_DEFAULT, |
1535 | + G_PARAM_READABLE); |
1536 | + |
1537 | + settings_properties[PROP_ACTIVE_SHADE_OPACITY] = |
1538 | + g_param_spec_boolean ("metacity-active-shade-opacity", |
1539 | + "Metacity Active Shade Opacity", |
1540 | + "Metacity Active Shade Opacity", |
1541 | + METACITY_ACTIVE_SHADE_OPACITY_DEFAULT, |
1542 | + G_PARAM_READABLE); |
1543 | + |
1544 | + settings_properties[PROP_INACTIVE_SHADE_OPACITY] = |
1545 | + g_param_spec_boolean ("metacity-inactive-shade-opacity", |
1546 | + "Metacity Inactive Shade Opacity", |
1547 | + "Metacity Inactive Shade Opacity", |
1548 | + METACITY_INACTIVE_SHADE_OPACITY_DEFAULT, |
1549 | + G_PARAM_READABLE); |
1550 | + |
1551 | + settings_properties[PROP_BUTTON_LAYOUT] = |
1552 | + g_param_spec_string ("metacity-button-layout", |
1553 | + "Metacity Button Layout", |
1554 | + "Metacity Button Layout", |
1555 | + METACITY_BUTTON_LAYOUT_DEFAULT, |
1556 | + G_PARAM_READABLE); |
1557 | + |
1558 | + settings_properties[PROP_TITLEBAR_ACTION_DOUBLE_CLICK] = |
1559 | + g_param_spec_int ("titlebar-double-click-action", |
1560 | + "Titlebar Action Double Click", |
1561 | + "Titlebar Action Double Click", |
1562 | + CLICK_ACTION_NONE, |
1563 | + CLICK_ACTION_MENU, |
1564 | + DOUBLE_CLICK_ACTION_DEFAULT, |
1565 | + G_PARAM_READABLE); |
1566 | + |
1567 | + settings_properties[PROP_TITLEBAR_ACTION_MIDDLE_CLICK] = |
1568 | + g_param_spec_int ("titlebar-middle-click-action", |
1569 | + "Titlebar Action Middle Click", |
1570 | + "Titlebar Action Middle Click", |
1571 | + CLICK_ACTION_NONE, |
1572 | + CLICK_ACTION_MENU, |
1573 | + MIDDLE_CLICK_ACTION_DEFAULT, |
1574 | + G_PARAM_READABLE); |
1575 | + |
1576 | + settings_properties[PROP_TITLEBAR_ACTION_RIGHT_CLICK] = |
1577 | + g_param_spec_int ("titlebar-right-click-action", |
1578 | + "Titlebar Action Right Click", |
1579 | + "Titlebar Action Right Click", |
1580 | + CLICK_ACTION_NONE, |
1581 | + CLICK_ACTION_MENU, |
1582 | + RIGHT_CLICK_ACTION_DEFAULT, |
1583 | + G_PARAM_READABLE); |
1584 | + |
1585 | + settings_properties[PROP_MOUSE_WHEEL_ACTION] = |
1586 | + g_param_spec_int ("mouse-wheel-action", |
1587 | + "Mouse Wheel Action", |
1588 | + "Mouse Wheel Action", |
1589 | + WHEEL_ACTION_NONE, |
1590 | + WHEEL_ACTION_SHADE, |
1591 | + WHEEL_ACTION_DEFAULT, |
1592 | + G_PARAM_READABLE); |
1593 | + |
1594 | + settings_properties[PROP_TITLEBAR_FONT] = |
1595 | + g_param_spec_string ("titlebar-font", |
1596 | + "Titlebar Font", |
1597 | + "Titlebar Font", |
1598 | + TITLEBAR_FONT_DEFAULT, |
1599 | + G_PARAM_READABLE); |
1600 | + |
1601 | + settings_properties[PROP_CMDLINE_OPTIONS] = |
1602 | + g_param_spec_int ("cmdline-options", |
1603 | + "Command line options", |
1604 | + "Which options were specified on the command line", |
1605 | + 0, G_MAXINT32, 0, |
1606 | + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY); |
1607 | + |
1608 | + settings_properties[PROP_SETTINGS_NOTIFIED] = |
1609 | + g_param_spec_pointer ("settings-notified", |
1610 | + "GWDSettingsNotified", |
1611 | + "A GWDSettingsNotified which will be updated", |
1612 | + G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY); |
1613 | + |
1614 | + g_object_class_install_properties (object_class, LAST_PROP, |
1615 | + settings_properties); |
1616 | } |
1617 | |
1618 | -static void gwd_settings_impl_init (GWDSettingsImpl *self) |
1619 | +static void |
1620 | +gwd_settings_init (GWDSettings *settings) |
1621 | { |
1622 | - GWDSettingsImplPrivate *priv = GET_PRIVATE (self); |
1623 | - |
1624 | - priv->use_tooltips = USE_TOOLTIPS_DEFAULT; |
1625 | - priv->active_shadow.shadow_radius = ACTIVE_SHADOW_RADIUS_DEFAULT; |
1626 | - priv->active_shadow.shadow_opacity = ACTIVE_SHADOW_OPACITY_DEFAULT; |
1627 | - priv->active_shadow.shadow_offset_x = ACTIVE_SHADOW_OFFSET_X_DEFAULT; |
1628 | - priv->active_shadow.shadow_offset_y = ACTIVE_SHADOW_OFFSET_Y_DEFAULT; |
1629 | - priv->active_shadow.shadow_color[0] = 0; |
1630 | - priv->active_shadow.shadow_color[1] = 0; |
1631 | - priv->active_shadow.shadow_color[2] = 0; |
1632 | - priv->inactive_shadow.shadow_radius = INACTIVE_SHADOW_RADIUS_DEFAULT; |
1633 | - priv->inactive_shadow.shadow_opacity = INACTIVE_SHADOW_OPACITY_DEFAULT; |
1634 | - priv->inactive_shadow.shadow_offset_x = INACTIVE_SHADOW_OFFSET_X_DEFAULT; |
1635 | - priv->inactive_shadow.shadow_offset_y = INACTIVE_SHADOW_OFFSET_Y_DEFAULT; |
1636 | - priv->inactive_shadow.shadow_color[0] = 0; |
1637 | - priv->inactive_shadow.shadow_color[1] = 0; |
1638 | - priv->inactive_shadow.shadow_color[2] = 0; |
1639 | - priv->blur_type = BLUR_TYPE_DEFAULT; |
1640 | - priv->metacity_theme = g_strdup (METACITY_THEME_DEFAULT); |
1641 | - priv->metacity_active_opacity = METACITY_ACTIVE_OPACITY_DEFAULT; |
1642 | - priv->metacity_inactive_opacity = METACITY_INACTIVE_OPACITY_DEFAULT; |
1643 | - priv->metacity_active_shade_opacity = METACITY_ACTIVE_SHADE_OPACITY_DEFAULT; |
1644 | - priv->metacity_inactive_shade_opacity = METACITY_INACTIVE_SHADE_OPACITY_DEFAULT; |
1645 | - priv->metacity_button_layout = g_strdup (METACITY_BUTTON_LAYOUT_DEFAULT); |
1646 | - priv->titlebar_double_click_action = DOUBLE_CLICK_ACTION_DEFAULT; |
1647 | - priv->titlebar_middle_click_action = MIDDLE_CLICK_ACTION_DEFAULT; |
1648 | - priv->titlebar_right_click_action = RIGHT_CLICK_ACTION_DEFAULT; |
1649 | - priv->mouse_wheel_action = WHEEL_ACTION_DEFAULT; |
1650 | - priv->titlebar_font = g_strdup (TITLEBAR_FONT_DEFAULT); |
1651 | - priv->cmdline_opts = 0; |
1652 | - priv->notified = NULL; |
1653 | - priv->freeze_count = 0; |
1654 | + settings->use_tooltips = USE_TOOLTIPS_DEFAULT; |
1655 | + settings->active_shadow.shadow_radius = ACTIVE_SHADOW_RADIUS_DEFAULT; |
1656 | + settings->active_shadow.shadow_opacity = ACTIVE_SHADOW_OPACITY_DEFAULT; |
1657 | + settings->active_shadow.shadow_offset_x = ACTIVE_SHADOW_OFFSET_X_DEFAULT; |
1658 | + settings->active_shadow.shadow_offset_y = ACTIVE_SHADOW_OFFSET_Y_DEFAULT; |
1659 | + settings->active_shadow.shadow_color[0] = 0; |
1660 | + settings->active_shadow.shadow_color[1] = 0; |
1661 | + settings->active_shadow.shadow_color[2] = 0; |
1662 | + settings->inactive_shadow.shadow_radius = INACTIVE_SHADOW_RADIUS_DEFAULT; |
1663 | + settings->inactive_shadow.shadow_opacity = INACTIVE_SHADOW_OPACITY_DEFAULT; |
1664 | + settings->inactive_shadow.shadow_offset_x = INACTIVE_SHADOW_OFFSET_X_DEFAULT; |
1665 | + settings->inactive_shadow.shadow_offset_y = INACTIVE_SHADOW_OFFSET_Y_DEFAULT; |
1666 | + settings->inactive_shadow.shadow_color[0] = 0; |
1667 | + settings->inactive_shadow.shadow_color[1] = 0; |
1668 | + settings->inactive_shadow.shadow_color[2] = 0; |
1669 | + settings->blur_type = BLUR_TYPE_DEFAULT; |
1670 | + settings->metacity_theme = g_strdup (METACITY_THEME_DEFAULT); |
1671 | + settings->metacity_active_opacity = METACITY_ACTIVE_OPACITY_DEFAULT; |
1672 | + settings->metacity_inactive_opacity = METACITY_INACTIVE_OPACITY_DEFAULT; |
1673 | + settings->metacity_active_shade_opacity = METACITY_ACTIVE_SHADE_OPACITY_DEFAULT; |
1674 | + settings->metacity_inactive_shade_opacity = METACITY_INACTIVE_SHADE_OPACITY_DEFAULT; |
1675 | + settings->metacity_button_layout = g_strdup (METACITY_BUTTON_LAYOUT_DEFAULT); |
1676 | + settings->titlebar_double_click_action = DOUBLE_CLICK_ACTION_DEFAULT; |
1677 | + settings->titlebar_middle_click_action = MIDDLE_CLICK_ACTION_DEFAULT; |
1678 | + settings->titlebar_right_click_action = RIGHT_CLICK_ACTION_DEFAULT; |
1679 | + settings->mouse_wheel_action = WHEEL_ACTION_DEFAULT; |
1680 | + settings->titlebar_font = g_strdup (TITLEBAR_FONT_DEFAULT); |
1681 | + settings->cmdline_opts = 0; |
1682 | + settings->notified = NULL; |
1683 | + settings->freeze_count = 0; |
1684 | |
1685 | /* Append all notify funcs so that external state can be updated in case |
1686 | * the settings backend can't do it itself */ |
1687 | - append_to_notify_funcs (self, gwd_settings_notified_update_metacity_theme); |
1688 | - append_to_notify_funcs (self, gwd_settings_notified_metacity_button_layout); |
1689 | - append_to_notify_funcs (self, gwd_settings_notified_update_frames); |
1690 | - append_to_notify_funcs (self, gwd_settings_notified_update_decorations); |
1691 | + append_to_notify_funcs (settings, gwd_settings_notified_update_metacity_theme); |
1692 | + append_to_notify_funcs (settings, gwd_settings_notified_metacity_button_layout); |
1693 | + append_to_notify_funcs (settings, gwd_settings_notified_update_frames); |
1694 | + append_to_notify_funcs (settings, gwd_settings_notified_update_decorations); |
1695 | } |
1696 | |
1697 | static gboolean |
1698 | -set_blur_construction_value (gint *blur, |
1699 | - GParameter *params, |
1700 | - GValue *blur_value) |
1701 | +set_blur_construction_value (gint *blur, |
1702 | + GParameter *params, |
1703 | + GValue *blur_value) |
1704 | { |
1705 | - if (blur) |
1706 | - { |
1707 | - g_value_set_int (blur_value, *blur); |
1708 | - |
1709 | - params->name = "blur"; |
1710 | - params->value = *blur_value; |
1711 | - |
1712 | - return TRUE; |
1713 | + if (blur) { |
1714 | + g_value_set_int (blur_value, *blur); |
1715 | + |
1716 | + params->name = "blur"; |
1717 | + params->value = *blur_value; |
1718 | + |
1719 | + return TRUE; |
1720 | } |
1721 | |
1722 | return FALSE; |
1723 | @@ -796,38 +847,37 @@ |
1724 | |
1725 | static gboolean |
1726 | set_metacity_theme_construction_value (const gchar **metacity_theme, |
1727 | - GParameter *params, |
1728 | - GValue *metacity_theme_value) |
1729 | + GParameter *params, |
1730 | + GValue *metacity_theme_value) |
1731 | { |
1732 | - if (metacity_theme) |
1733 | - { |
1734 | - g_value_set_string (metacity_theme_value, *metacity_theme); |
1735 | - |
1736 | - params->name = "metacity-theme"; |
1737 | - params->value = *metacity_theme_value; |
1738 | - |
1739 | - return TRUE; |
1740 | + if (metacity_theme) { |
1741 | + g_value_set_string (metacity_theme_value, *metacity_theme); |
1742 | + |
1743 | + params->name = "metacity-theme"; |
1744 | + params->value = *metacity_theme_value; |
1745 | + |
1746 | + return TRUE; |
1747 | } |
1748 | |
1749 | return FALSE; |
1750 | } |
1751 | |
1752 | static guint |
1753 | -set_flag_and_increment (guint n_param, |
1754 | - guint *flags, |
1755 | - guint flag) |
1756 | +set_flag_and_increment (guint n_param, |
1757 | + guint *flags, |
1758 | + guint flag) |
1759 | { |
1760 | if (!flags) |
1761 | - return n_param; |
1762 | + return n_param; |
1763 | |
1764 | *flags |= flag; |
1765 | return n_param + 1; |
1766 | } |
1767 | |
1768 | GWDSettings * |
1769 | -gwd_settings_impl_new (gint *blur, |
1770 | - const gchar **metacity_theme, |
1771 | - GWDSettingsNotified *notified) |
1772 | +gwd_settings_new (gint *blur, |
1773 | + const gchar **metacity_theme, |
1774 | + GWDSettingsNotified *notified) |
1775 | { |
1776 | /* Always N command line parameters + 2 for command line |
1777 | * options enum & notified */ |
1778 | @@ -849,10 +899,10 @@ |
1779 | g_value_init (&settings_notified_value, G_TYPE_POINTER); |
1780 | |
1781 | if (set_blur_construction_value (blur, ¶m[n_param], &blur_value)) |
1782 | - n_param = set_flag_and_increment (n_param, &cmdline_opts, CMDLINE_BLUR); |
1783 | + n_param = set_flag_and_increment (n_param, &cmdline_opts, CMDLINE_BLUR); |
1784 | |
1785 | if (set_metacity_theme_construction_value (metacity_theme, ¶m[n_param], &metacity_theme_value)) |
1786 | - n_param = set_flag_and_increment (n_param, &cmdline_opts, CMDLINE_THEME); |
1787 | + n_param = set_flag_and_increment (n_param, &cmdline_opts, CMDLINE_THEME); |
1788 | |
1789 | g_value_set_int (&cmdline_opts_value, cmdline_opts); |
1790 | |
1791 | @@ -868,7 +918,7 @@ |
1792 | |
1793 | ++n_param; |
1794 | |
1795 | - settings = GWD_SETTINGS_INTERFACE (g_object_newv (GWD_TYPE_SETTINGS_IMPL, n_param, param)); |
1796 | + settings = g_object_newv (GWD_TYPE_SETTINGS, n_param, param); |
1797 | |
1798 | g_value_unset (&blur_value); |
1799 | g_value_unset (&metacity_theme_value); |
1800 | |
1801 | === modified file 'gtk/window-decorator/gwd-settings.h' |
1802 | --- gtk/window-decorator/gwd-settings.h 2012-10-06 16:11:05 +0000 |
1803 | +++ gtk/window-decorator/gwd-settings.h 2016-05-19 09:24:18 +0000 |
1804 | @@ -1,3 +1,5 @@ |
1805 | +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4; tab-width: 4 -*- */ |
1806 | + |
1807 | /* |
1808 | * Copyright © 2012 Canonical Ltd |
1809 | * |
1810 | @@ -17,21 +19,77 @@ |
1811 | * |
1812 | * Authored By: Sam Spilsbury <sam.spilsbury@canonical.com> |
1813 | */ |
1814 | -#ifndef _COMPIZ_GWD_SETTINGS_H |
1815 | -#define _COMPIZ_GWD_SETTINGS_H |
1816 | + |
1817 | +#ifndef GWD_SETTINGS_H |
1818 | +#define GWD_SETTINGS_H |
1819 | |
1820 | #include <glib-object.h> |
1821 | #include <gwd-fwd.h> |
1822 | |
1823 | G_BEGIN_DECLS |
1824 | |
1825 | -#define GWD_TYPE_SETTINGS_IMPL (gwd_settings_impl_get_type ()) |
1826 | -GType gwd_settings_impl_get_type (); |
1827 | +enum |
1828 | +{ |
1829 | + BLUR_TYPE_NONE = 0, |
1830 | + BLUR_TYPE_TITLEBAR = 1, |
1831 | + BLUR_TYPE_ALL = 2 |
1832 | +}; |
1833 | + |
1834 | +enum |
1835 | +{ |
1836 | + CLICK_ACTION_NONE, |
1837 | + CLICK_ACTION_SHADE, |
1838 | + CLICK_ACTION_MAXIMIZE, |
1839 | + CLICK_ACTION_MINIMIZE, |
1840 | + CLICK_ACTION_RAISE, |
1841 | + CLICK_ACTION_LOWER, |
1842 | + CLICK_ACTION_MENU |
1843 | +}; |
1844 | + |
1845 | +enum |
1846 | +{ |
1847 | + WHEEL_ACTION_NONE, |
1848 | + WHEEL_ACTION_SHADE |
1849 | +}; |
1850 | + |
1851 | +extern const gboolean USE_TOOLTIPS_DEFAULT; |
1852 | + |
1853 | +extern const gdouble ACTIVE_SHADOW_RADIUS_DEFAULT; |
1854 | +extern const gdouble ACTIVE_SHADOW_OPACITY_DEFAULT; |
1855 | +extern const gint ACTIVE_SHADOW_OFFSET_X_DEFAULT; |
1856 | +extern const gint ACTIVE_SHADOW_OFFSET_Y_DEFAULT; |
1857 | +extern const gchar *ACTIVE_SHADOW_COLOR_DEFAULT; |
1858 | + |
1859 | +extern const gdouble INACTIVE_SHADOW_RADIUS_DEFAULT; |
1860 | +extern const gdouble INACTIVE_SHADOW_OPACITY_DEFAULT; |
1861 | +extern const gint INACTIVE_SHADOW_OFFSET_X_DEFAULT; |
1862 | +extern const gint INACTIVE_SHADOW_OFFSET_Y_DEFAULT; |
1863 | +extern const gchar *INACTIVE_SHADOW_COLOR_DEFAULT; |
1864 | + |
1865 | +extern const gint BLUR_TYPE_DEFAULT; |
1866 | + |
1867 | +extern const gchar *METACITY_THEME_DEFAULT; |
1868 | +extern const gdouble METACITY_ACTIVE_OPACITY_DEFAULT; |
1869 | +extern const gdouble METACITY_INACTIVE_OPACITY_DEFAULT; |
1870 | +extern const gboolean METACITY_ACTIVE_SHADE_OPACITY_DEFAULT; |
1871 | +extern const gboolean METACITY_INACTIVE_SHADE_OPACITY_DEFAULT; |
1872 | + |
1873 | +extern const gchar *METACITY_BUTTON_LAYOUT_DEFAULT; |
1874 | + |
1875 | +extern const guint DOUBLE_CLICK_ACTION_DEFAULT; |
1876 | +extern const guint MIDDLE_CLICK_ACTION_DEFAULT; |
1877 | +extern const guint RIGHT_CLICK_ACTION_DEFAULT; |
1878 | +extern const guint WHEEL_ACTION_DEFAULT; |
1879 | + |
1880 | +extern const gchar *TITLEBAR_FONT_DEFAULT; |
1881 | + |
1882 | +#define GWD_TYPE_SETTINGS gwd_settings_get_type () |
1883 | +G_DECLARE_FINAL_TYPE (GWDSettings, gwd_settings, GWD, SETTINGS, GObject) |
1884 | |
1885 | GWDSettings * |
1886 | -gwd_settings_impl_new (gint *blur, |
1887 | - const gchar **metacity_theme, |
1888 | - GWDSettingsNotified *notified); |
1889 | +gwd_settings_new (gint *blur, |
1890 | + const gchar **metacity_theme, |
1891 | + GWDSettingsNotified *notified); |
1892 | |
1893 | G_END_DECLS |
1894 | |
1895 | |
1896 | === modified file 'gtk/window-decorator/tests/CMakeLists.txt' |
1897 | --- gtk/window-decorator/tests/CMakeLists.txt 2016-05-19 09:24:18 +0000 |
1898 | +++ gtk/window-decorator/tests/CMakeLists.txt 2016-05-19 09:24:18 +0000 |
1899 | @@ -18,12 +18,6 @@ |
1900 | link_directories (${CMAKE_CURRENT_BINARY_DIR} |
1901 | ${CMAKE_CURRENT_BINARY_DIR}/..) |
1902 | |
1903 | - add_library (gtk_window_decorator_mock_settings STATIC |
1904 | - ${CMAKE_CURRENT_SOURCE_DIR}/compiz_gwd_mock_settings.cpp) |
1905 | - |
1906 | - target_link_libraries (gtk_window_decorator_mock_settings |
1907 | - gtk_window_decorator_settings_interface) |
1908 | - |
1909 | add_library (gtk_window_decorator_mock_settings_writable STATIC |
1910 | ${CMAKE_CURRENT_SOURCE_DIR}/compiz_gwd_mock_settings_writable.cpp) |
1911 | |
1912 | @@ -41,13 +35,11 @@ |
1913 | |
1914 | set (COMPIZ_TEST_GWD_SETTINGS_ADDITIONAL_LIBRARIES |
1915 | gtk_window_decorator_settings |
1916 | - gtk_window_decorator_mock_settings |
1917 | gtk_window_decorator_mock_settings_writable |
1918 | gtk_window_decorator_mock_settings_notified) |
1919 | |
1920 | set (COMPIZ_TEST_GWD_SETTINGS_COVERAGE_TARGETS |
1921 | gtk_window_decorator_settings |
1922 | - gtk_window_decorator_settings_interface |
1923 | gtk_window_decorator_settings_notified_interface) |
1924 | |
1925 | set (_desktop_gschema_name org.gnome.desktop.wm.preferences) |
1926 | |
1927 | === removed file 'gtk/window-decorator/tests/compiz_gwd_mock_settings.cpp' |
1928 | --- gtk/window-decorator/tests/compiz_gwd_mock_settings.cpp 2016-02-22 12:27:13 +0000 |
1929 | +++ gtk/window-decorator/tests/compiz_gwd_mock_settings.cpp 1970-01-01 00:00:00 +0000 |
1930 | @@ -1,199 +0,0 @@ |
1931 | -/* |
1932 | - * Copyright © 2012 Canonical Ltd |
1933 | - * |
1934 | - * This program is free software; you can redistribute it and/or modify |
1935 | - * it under the terms of the GNU General Public License as published by |
1936 | - * the Free Software Foundation; either version 2 of the License, or |
1937 | - * (at your option) any later version. |
1938 | - * |
1939 | - * This program is distributed in the hope that it will be useful, |
1940 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1941 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1942 | - * GNU General Public License for more details. |
1943 | - * |
1944 | - * You should have received a copy of the GNU General Public License |
1945 | - * along with this program; if not, write to the Free Software Foundation, |
1946 | - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
1947 | - * |
1948 | - * Authored By: Sam Spilsbury <sam.spilsbury@canonical.com> |
1949 | - */ |
1950 | -#include <gtest/gtest.h> |
1951 | -#include <gmock/gmock.h> |
1952 | - |
1953 | -#include <glib-object.h> |
1954 | - |
1955 | -#include "gwd-settings-interface.h" |
1956 | -#include "compiz_gwd_mock_settings.h" |
1957 | - |
1958 | -#define GWD_MOCK_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GWD_TYPE_MOCK_SETTINGS, GWDMockSettings)); |
1959 | -#define GWD_MOCK_SETTINGS_CLASS(obj) (G_TYPE_CHECK_CLASS_CAST ((obj), GWD_TYPE_MOCK_SETTINGS, GWDMockSettingsClass)); |
1960 | -#define GWD_IS_MOCK_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GWD_TYPE_MOCK_SETTINGS)); |
1961 | -#define GWD_IS_MOCK_SETTINGS_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE ((obj), GWD_TYPE_MOCK_SETTINGS)); |
1962 | -#define GWD_MOCK_SETTINGS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GWD_TYPE_MOCK_SETTINGS, GWDMockSettingsClass)); |
1963 | - |
1964 | -typedef struct _GWDMockSettings |
1965 | -{ |
1966 | - GObject parent; |
1967 | -} GWDMockSettings; |
1968 | - |
1969 | -typedef struct _GWDMockSettingsClass |
1970 | -{ |
1971 | - GObjectClass parent_class; |
1972 | -} GWDMockSettingsClass; |
1973 | - |
1974 | -static void gwd_mock_settings_interface_init (GWDSettingsInterface *interface); |
1975 | - |
1976 | -G_DEFINE_TYPE_WITH_CODE (GWDMockSettings, gwd_mock_settings, G_TYPE_OBJECT, |
1977 | - G_IMPLEMENT_INTERFACE (GWD_TYPE_SETTINGS_INTERFACE, |
1978 | - gwd_mock_settings_interface_init)) |
1979 | - |
1980 | -#define GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GWD_TYPE_MOCK_SETTINGS, GWDMockSettingsPrivate)) |
1981 | - |
1982 | -typedef struct _GWDMockSettingsPrivate |
1983 | -{ |
1984 | - GWDMockSettingsGMockInterface *mock; |
1985 | -} GWDMockSettingsPrivate; |
1986 | - |
1987 | -static void gwd_mock_settings_interface_init (GWDSettingsInterface *interface) |
1988 | -{ |
1989 | -} |
1990 | - |
1991 | -static void gwd_mock_settings_dispose (GObject *object) |
1992 | -{ |
1993 | - GWDMockSettingsGMockInterface *settingsGMock = GET_PRIVATE (object)->mock; |
1994 | - G_OBJECT_CLASS (gwd_mock_settings_parent_class)->dispose (object); |
1995 | - settingsGMock->dispose (); |
1996 | -} |
1997 | - |
1998 | -static void gwd_mock_settings_finalize (GObject *object) |
1999 | -{ |
2000 | - GWDMockSettingsGMockInterface *settingsGMock = GET_PRIVATE (object)->mock; |
2001 | - G_OBJECT_CLASS (gwd_mock_settings_parent_class)->finalize (object); |
2002 | - settingsGMock->finalize (); |
2003 | -} |
2004 | - |
2005 | -static void gwd_mock_settings_set_property (GObject *object, |
2006 | - guint property_id, |
2007 | - const GValue *value, |
2008 | - GParamSpec *pspec) |
2009 | -{ |
2010 | - GWDMockSettingsPrivate *priv = GET_PRIVATE (object); |
2011 | - |
2012 | - switch (property_id) |
2013 | - { |
2014 | - case GWD_MOCK_SETTINGS_PROPERTY_GMOCK_INTERFACE: |
2015 | - if (!priv->mock) |
2016 | - priv->mock = reinterpret_cast <GWDMockSettingsGMockInterface *> (g_value_get_pointer (value)); |
2017 | - break; |
2018 | - case GWD_MOCK_SETTINGS_PROPERTY_BLUR_CHANGED: |
2019 | - case GWD_MOCK_SETTINGS_PROPERTY_ACTIVE_OPACITY: |
2020 | - case GWD_MOCK_SETTINGS_PROPERTY_ACTIVE_SHADE_OPACITY: |
2021 | - case GWD_MOCK_SETTINGS_PROPERTY_INACTIVE_OPACITY: |
2022 | - case GWD_MOCK_SETTINGS_PROPERTY_INACTIVE_SHADE_OPACITY: |
2023 | - case GWD_MOCK_SETTINGS_PROPERTY_METACITY_THEME: |
2024 | - break; |
2025 | - default: |
2026 | - g_assert_not_reached (); |
2027 | - break; |
2028 | - } |
2029 | -} |
2030 | - |
2031 | -static void gwd_mock_settings_get_property (GObject *object, |
2032 | - guint property_id, |
2033 | - GValue *value, |
2034 | - GParamSpec *pspec) |
2035 | -{ |
2036 | - GWDMockSettingsGMockInterface *settingsGMock = GET_PRIVATE (object)->mock; |
2037 | - settingsGMock->getProperty (property_id, value, pspec); |
2038 | -} |
2039 | - |
2040 | -static void gwd_mock_settings_class_init (GWDMockSettingsClass *klass) |
2041 | -{ |
2042 | - GObjectClass *object_class = G_OBJECT_CLASS (klass); |
2043 | - |
2044 | - g_type_class_add_private (klass, sizeof (GWDMockSettingsPrivate)); |
2045 | - |
2046 | - object_class->dispose = gwd_mock_settings_dispose; |
2047 | - object_class->finalize = gwd_mock_settings_finalize; |
2048 | - object_class->get_property = gwd_mock_settings_get_property; |
2049 | - object_class->set_property = gwd_mock_settings_set_property; |
2050 | - |
2051 | - g_object_class_override_property (object_class, |
2052 | - GWD_MOCK_SETTINGS_PROPERTY_ACTIVE_SHADOW, |
2053 | - "active-shadow"); |
2054 | - g_object_class_override_property (object_class, |
2055 | - GWD_MOCK_SETTINGS_PROPERTY_INACTIVE_SHADOW, |
2056 | - "inactive-shadow"); |
2057 | - g_object_class_override_property (object_class, |
2058 | - GWD_MOCK_SETTINGS_PROPERTY_USE_TOOLTIPS, |
2059 | - "use-tooltips"); |
2060 | - g_object_class_override_property (object_class, |
2061 | - GWD_MOCK_SETTINGS_PROPERTY_BLUR_CHANGED, |
2062 | - "blur"); |
2063 | - g_object_class_override_property (object_class, |
2064 | - GWD_MOCK_SETTINGS_PROPERTY_METACITY_THEME, |
2065 | - "metacity-theme"); |
2066 | - g_object_class_override_property (object_class, |
2067 | - GWD_MOCK_SETTINGS_PROPERTY_ACTIVE_OPACITY, |
2068 | - "metacity-active-opacity"); |
2069 | - g_object_class_override_property (object_class, |
2070 | - GWD_MOCK_SETTINGS_PROPERTY_INACTIVE_OPACITY, |
2071 | - "metacity-inactive-opacity"); |
2072 | - g_object_class_override_property (object_class, |
2073 | - GWD_MOCK_SETTINGS_PROPERTY_ACTIVE_SHADE_OPACITY, |
2074 | - "metacity-active-shade-opacity"); |
2075 | - g_object_class_override_property (object_class, |
2076 | - GWD_MOCK_SETTINGS_PROPERTY_INACTIVE_SHADE_OPACITY, |
2077 | - "metacity-inactive-shade-opacity"); |
2078 | - g_object_class_override_property (object_class, |
2079 | - GWD_MOCK_SETTINGS_PROPERTY_BUTTON_LAYOUT, |
2080 | - "metacity-button-layout"); |
2081 | - g_object_class_override_property (object_class, |
2082 | - GWD_MOCK_SETTINGS_PROPERTY_TITLEBAR_ACTION_DOUBLE_CLICK, |
2083 | - "titlebar-double-click-action"); |
2084 | - g_object_class_override_property (object_class, |
2085 | - GWD_MOCK_SETTINGS_PROPERTY_TITLEBAR_ACTION_MIDDLE_CLICK, |
2086 | - "titlebar-middle-click-action"); |
2087 | - g_object_class_override_property (object_class, |
2088 | - GWD_MOCK_SETTINGS_PROPERTY_TITLEBAR_ACTION_RIGHT_CLICK, |
2089 | - "titlebar-right-click-action"); |
2090 | - g_object_class_override_property (object_class, |
2091 | - GWD_MOCK_SETTINGS_PROPERTY_MOUSE_WHEEL_ACTION, |
2092 | - "mouse-wheel-action"); |
2093 | - g_object_class_override_property (object_class, |
2094 | - GWD_MOCK_SETTINGS_PROPERTY_TITLEBAR_FONT, |
2095 | - "titlebar-font"); |
2096 | - g_object_class_install_property (object_class, |
2097 | - GWD_MOCK_SETTINGS_PROPERTY_GMOCK_INTERFACE, |
2098 | - g_param_spec_pointer ("gmock-interface", |
2099 | - "Google Mock Interface", |
2100 | - "Google Mock Interface", |
2101 | - static_cast <GParamFlags> (G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY))); |
2102 | -} |
2103 | - |
2104 | -static void gwd_mock_settings_init (GWDMockSettings *self) |
2105 | -{ |
2106 | -} |
2107 | - |
2108 | -GWDSettings * |
2109 | -gwd_mock_settings_new (GWDMockSettingsGMockInterface *gmock) |
2110 | -{ |
2111 | - GValue gmock_interface_v = G_VALUE_INIT; |
2112 | - |
2113 | - g_value_init (&gmock_interface_v, G_TYPE_POINTER); |
2114 | - |
2115 | - g_value_set_pointer (&gmock_interface_v, reinterpret_cast <gpointer> (gmock)); |
2116 | - |
2117 | - GParameter param[1] = |
2118 | - { |
2119 | - { "gmock-interface", gmock_interface_v } |
2120 | - }; |
2121 | - |
2122 | - GWDSettings *settings = GWD_SETTINGS_INTERFACE (g_object_newv (GWD_TYPE_MOCK_SETTINGS, 1, param)); |
2123 | - |
2124 | - g_value_unset (&gmock_interface_v); |
2125 | - |
2126 | - return settings; |
2127 | -} |
2128 | - |
2129 | - |
2130 | |
2131 | === removed file 'gtk/window-decorator/tests/compiz_gwd_mock_settings.h' |
2132 | --- gtk/window-decorator/tests/compiz_gwd_mock_settings.h 2012-08-20 09:11:12 +0000 |
2133 | +++ gtk/window-decorator/tests/compiz_gwd_mock_settings.h 1970-01-01 00:00:00 +0000 |
2134 | @@ -1,86 +0,0 @@ |
2135 | -/* |
2136 | - * Copyright © 2012 Canonical Ltd |
2137 | - * |
2138 | - * This program is free software; you can redistribute it and/or modify |
2139 | - * it under the terms of the GNU General Public License as published by |
2140 | - * the Free Software Foundation; either version 2 of the License, or |
2141 | - * (at your option) any later version. |
2142 | - * |
2143 | - * This program is distributed in the hope that it will be useful, |
2144 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2145 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2146 | - * GNU General Public License for more details. |
2147 | - * |
2148 | - * You should have received a copy of the GNU General Public License |
2149 | - * along with this program; if not, write to the Free Software Foundation, |
2150 | - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
2151 | - */ |
2152 | - |
2153 | -#ifndef _COMPIZ_GWD_MOCK_SETTINGS_H |
2154 | -#define _COMPIZ_GWD_MOCK_SETTINGS_H |
2155 | - |
2156 | -#include <gtest/gtest.h> |
2157 | -#include <gmock/gmock.h> |
2158 | - |
2159 | -#include <glib-object.h> |
2160 | - |
2161 | -class GWDMockSettingsGMockInterface; |
2162 | - |
2163 | -typedef struct _GWDSettings GWDSettingsImpl; |
2164 | - |
2165 | -G_BEGIN_DECLS |
2166 | - |
2167 | -#define GWD_TYPE_MOCK_SETTINGS (gwd_mock_settings_get_type ()) |
2168 | -GType gwd_mock_settings_get_type (); |
2169 | - |
2170 | -GWDSettings * |
2171 | -gwd_mock_settings_new (GWDMockSettingsGMockInterface *); |
2172 | - |
2173 | -enum |
2174 | -{ |
2175 | - GWD_MOCK_SETTINGS_PROPERTY_ACTIVE_SHADOW = 1, |
2176 | - GWD_MOCK_SETTINGS_PROPERTY_INACTIVE_SHADOW = 2, |
2177 | - GWD_MOCK_SETTINGS_PROPERTY_USE_TOOLTIPS = 3, |
2178 | - GWD_MOCK_SETTINGS_PROPERTY_DRAGGABLE_BORDER_WIDTH = 4, |
2179 | - GWD_MOCK_SETTINGS_PROPERTY_ATTACH_MODAL_DIALOGS = 5, |
2180 | - GWD_MOCK_SETTINGS_PROPERTY_BLUR_CHANGED = 6, |
2181 | - GWD_MOCK_SETTINGS_PROPERTY_METACITY_THEME = 7, |
2182 | - GWD_MOCK_SETTINGS_PROPERTY_ACTIVE_OPACITY = 8, |
2183 | - GWD_MOCK_SETTINGS_PROPERTY_INACTIVE_OPACITY = 9, |
2184 | - GWD_MOCK_SETTINGS_PROPERTY_ACTIVE_SHADE_OPACITY = 10, |
2185 | - GWD_MOCK_SETTINGS_PROPERTY_INACTIVE_SHADE_OPACITY = 11, |
2186 | - GWD_MOCK_SETTINGS_PROPERTY_BUTTON_LAYOUT = 12, |
2187 | - GWD_MOCK_SETTINGS_PROPERTY_TITLEBAR_ACTION_DOUBLE_CLICK = 13, |
2188 | - GWD_MOCK_SETTINGS_PROPERTY_TITLEBAR_ACTION_MIDDLE_CLICK = 14, |
2189 | - GWD_MOCK_SETTINGS_PROPERTY_TITLEBAR_ACTION_RIGHT_CLICK = 15, |
2190 | - GWD_MOCK_SETTINGS_PROPERTY_MOUSE_WHEEL_ACTION = 16, |
2191 | - GWD_MOCK_SETTINGS_PROPERTY_TITLEBAR_FONT = 17, |
2192 | - GWD_MOCK_SETTINGS_PROPERTY_GMOCK_INTERFACE = 18 |
2193 | -}; |
2194 | - |
2195 | -G_END_DECLS |
2196 | - |
2197 | -class GWDMockSettingsGMockInterface |
2198 | -{ |
2199 | - public: |
2200 | - |
2201 | - virtual ~GWDMockSettingsGMockInterface () {} |
2202 | - |
2203 | - virtual void getProperty (guint property_id, |
2204 | - GValue *property_value, |
2205 | - GParamSpec *pspec) = 0; |
2206 | - virtual void dispose () = 0; |
2207 | - virtual void finalize () = 0; |
2208 | -}; |
2209 | - |
2210 | -class GWDMockSettingsGMock : |
2211 | - public GWDMockSettingsGMockInterface |
2212 | -{ |
2213 | - public: |
2214 | - |
2215 | - MOCK_METHOD3 (getProperty, void (guint, GValue *, GParamSpec *)); |
2216 | - MOCK_METHOD0 (dispose, void ()); |
2217 | - MOCK_METHOD0 (finalize, void ()); |
2218 | -}; |
2219 | - |
2220 | -#endif |
2221 | |
2222 | === modified file 'gtk/window-decorator/tests/test_gwd_settings.cpp' |
2223 | --- gtk/window-decorator/tests/test_gwd_settings.cpp 2016-05-19 09:24:18 +0000 |
2224 | +++ gtk/window-decorator/tests/test_gwd_settings.cpp 2016-05-19 09:24:18 +0000 |
2225 | @@ -41,7 +41,6 @@ |
2226 | |
2227 | #include "compiz_gwd_tests.h" |
2228 | |
2229 | -#include "gwd-settings-interface.h" |
2230 | #include "gwd-settings.h" |
2231 | #include "gwd-settings-storage.h" |
2232 | #include "gwd-settings-writable-interface.h" |
2233 | @@ -49,7 +48,6 @@ |
2234 | |
2235 | #include "decoration.h" |
2236 | |
2237 | -#include "compiz_gwd_mock_settings.h" |
2238 | #include "compiz_gwd_mock_settings_writable.h" |
2239 | #include "compiz_gwd_mock_settings_notified.h" |
2240 | |
2241 | @@ -266,7 +264,7 @@ |
2242 | g_object_unref (G_OBJECT (writable)); |
2243 | } |
2244 | |
2245 | - void gwd_settings_unref (GWDSettingsImpl *settings) |
2246 | + void gwd_settings_unref (GWDSettings *settings) |
2247 | { |
2248 | g_object_unref (G_OBJECT (settings)); |
2249 | } |
2250 | @@ -378,185 +376,10 @@ |
2251 | testing_values::TITLEBAR_ACTION_SHADE.c_str ()), IsTrue ()); |
2252 | } |
2253 | |
2254 | -class GWDMockSettingsTest : |
2255 | - public GWDSettingsTestCommon |
2256 | -{ |
2257 | -}; |
2258 | - |
2259 | -TEST_F(GWDMockSettingsTest, TestMock) |
2260 | -{ |
2261 | - GWDMockSettingsGMock settingsGMock; |
2262 | - boost::shared_ptr <GWDSettingsImpl> settingsMock (gwd_mock_settings_new (&settingsGMock), |
2263 | - boost::bind (gwd_settings_unref, _1)); |
2264 | - |
2265 | - AutoUnsetGValue pointerValue (G_TYPE_POINTER); |
2266 | - AutoUnsetGValue booleanValue (G_TYPE_BOOLEAN); |
2267 | - AutoUnsetGValue stringValue (G_TYPE_STRING); |
2268 | - AutoUnsetGValue integerValue (G_TYPE_INT); |
2269 | - AutoUnsetGValue doubleValue (G_TYPE_DOUBLE); |
2270 | - |
2271 | - GValue &pointerGValue = pointerValue; |
2272 | - GValue &booleanGValue = booleanValue; |
2273 | - GValue &stringGValue = stringValue; |
2274 | - GValue &integerGValue = integerValue; |
2275 | - GValue &doubleGValue = doubleValue; |
2276 | - |
2277 | - int POINTEE_VALUE = 1; |
2278 | - gpointer POINTER_VALUE = &POINTEE_VALUE; |
2279 | - const std::string STRING_VALUE ("test"); |
2280 | - const int INTEGER_VALUE = 2; |
2281 | - const gboolean BOOLEAN_VALUE = TRUE; |
2282 | - const gdouble DOUBLE_VALUE = 2.0; |
2283 | - |
2284 | - g_value_set_pointer (&pointerGValue, POINTER_VALUE); |
2285 | - g_value_set_boolean (&booleanGValue, BOOLEAN_VALUE); |
2286 | - g_value_set_string (&stringGValue, STRING_VALUE.c_str ()); |
2287 | - g_value_set_int (&integerGValue, INTEGER_VALUE); |
2288 | - g_value_set_double (&doubleGValue, DOUBLE_VALUE); |
2289 | - |
2290 | - EXPECT_CALL (settingsGMock, dispose ()); |
2291 | - EXPECT_CALL (settingsGMock, finalize ()); |
2292 | - |
2293 | - /* The order of evaluation of matchers in Google Mock appears to be undefined and |
2294 | - * the way GValueMatch is written makes it particularly unsafe when used with |
2295 | - * matchers of multiple types on the same function, since there's no guaruntee |
2296 | - * that the matchers will be traversed in any order. If a type is passed to |
2297 | - * any of the matchers that it doesn't know how to handle then it will |
2298 | - * call directly through to GValueCmp which will run into undefined behaviour |
2299 | - * in itself. |
2300 | - * |
2301 | - * In reality, the API for GValueMatch is probably a little bit broken in this |
2302 | - * sense, but just satisfying each expectation as soon as its set seems to do |
2303 | - * the job here |
2304 | - */ |
2305 | - |
2306 | - /* calling g_object_get_property actually resets |
2307 | - * the value so expecting 0x0 is correct */ |
2308 | - EXPECT_CALL (settingsGMock, getProperty (GWD_MOCK_SETTINGS_PROPERTY_ACTIVE_SHADOW, |
2309 | - GValueMatch <gpointer> (0x0, g_value_get_pointer), |
2310 | - _)); |
2311 | - |
2312 | - g_object_get_property (G_OBJECT (settingsMock.get ()), |
2313 | - "active-shadow", |
2314 | - &pointerGValue); |
2315 | - |
2316 | - EXPECT_CALL (settingsGMock, getProperty (GWD_MOCK_SETTINGS_PROPERTY_INACTIVE_SHADOW, |
2317 | - GValueMatch <gpointer> (0x0, g_value_get_pointer), |
2318 | - _)); |
2319 | - |
2320 | - g_object_get_property (G_OBJECT (settingsMock.get ()), |
2321 | - "inactive-shadow", |
2322 | - &pointerGValue); |
2323 | - |
2324 | - EXPECT_CALL (settingsGMock, getProperty (GWD_MOCK_SETTINGS_PROPERTY_USE_TOOLTIPS, |
2325 | - GValueMatch <gboolean> (FALSE, g_value_get_boolean), |
2326 | - _)); |
2327 | - |
2328 | - g_object_get_property (G_OBJECT (settingsMock.get ()), |
2329 | - "use-tooltips", |
2330 | - &booleanGValue); |
2331 | - |
2332 | - EXPECT_CALL (settingsGMock, getProperty (GWD_MOCK_SETTINGS_PROPERTY_BLUR_CHANGED, |
2333 | - GValueMatch <gint> (0, g_value_get_int), |
2334 | - _)); |
2335 | - |
2336 | - g_object_get_property (G_OBJECT (settingsMock.get ()), |
2337 | - "blur", |
2338 | - &integerGValue); |
2339 | - |
2340 | - EXPECT_CALL (settingsGMock, getProperty (GWD_MOCK_SETTINGS_PROPERTY_METACITY_THEME, |
2341 | - GValueMatch <const gchar *> (NULL, g_value_get_string), |
2342 | - _)); |
2343 | - |
2344 | - g_object_get_property (G_OBJECT (settingsMock.get ()), |
2345 | - "metacity-theme", |
2346 | - &stringGValue); |
2347 | - |
2348 | - EXPECT_CALL (settingsGMock, getProperty (GWD_MOCK_SETTINGS_PROPERTY_ACTIVE_OPACITY, |
2349 | - GValueMatch <gdouble> (0.0, g_value_get_double), |
2350 | - _)); |
2351 | - |
2352 | - g_object_get_property (G_OBJECT (settingsMock.get ()), |
2353 | - "metacity-active-opacity", |
2354 | - &doubleGValue); |
2355 | - |
2356 | - EXPECT_CALL (settingsGMock, getProperty (GWD_MOCK_SETTINGS_PROPERTY_INACTIVE_OPACITY, |
2357 | - GValueMatch <gdouble> (0.0, g_value_get_double), |
2358 | - _)); |
2359 | - |
2360 | - g_object_get_property (G_OBJECT (settingsMock.get ()), |
2361 | - "metacity-inactive-opacity", |
2362 | - &doubleGValue); |
2363 | - |
2364 | - EXPECT_CALL (settingsGMock, getProperty (GWD_MOCK_SETTINGS_PROPERTY_ACTIVE_SHADE_OPACITY, |
2365 | - GValueMatch <gboolean> (FALSE, g_value_get_boolean), |
2366 | - _)); |
2367 | - |
2368 | - g_object_get_property (G_OBJECT (settingsMock.get ()), |
2369 | - "metacity-active-shade-opacity", |
2370 | - &booleanGValue); |
2371 | - |
2372 | - EXPECT_CALL (settingsGMock, getProperty (GWD_MOCK_SETTINGS_PROPERTY_INACTIVE_SHADE_OPACITY, |
2373 | - GValueMatch <gboolean> (FALSE, g_value_get_boolean), |
2374 | - _)); |
2375 | - |
2376 | - g_object_get_property (G_OBJECT (settingsMock.get ()), |
2377 | - "metacity-inactive-shade-opacity", |
2378 | - &booleanGValue); |
2379 | - |
2380 | - EXPECT_CALL (settingsGMock, getProperty (GWD_MOCK_SETTINGS_PROPERTY_BUTTON_LAYOUT, |
2381 | - GValueMatch <const gchar *> (NULL, g_value_get_string), |
2382 | - _)); |
2383 | - |
2384 | - g_object_get_property (G_OBJECT (settingsMock.get ()), |
2385 | - "metacity-button-layout", |
2386 | - &stringGValue); |
2387 | - |
2388 | - EXPECT_CALL (settingsGMock, getProperty (GWD_MOCK_SETTINGS_PROPERTY_TITLEBAR_ACTION_DOUBLE_CLICK, |
2389 | - GValueMatch <gint> (0, g_value_get_int), |
2390 | - _)); |
2391 | - |
2392 | - g_object_get_property (G_OBJECT (settingsMock.get ()), |
2393 | - "titlebar-double-click-action", |
2394 | - &integerGValue); |
2395 | - |
2396 | - EXPECT_CALL (settingsGMock, getProperty (GWD_MOCK_SETTINGS_PROPERTY_TITLEBAR_ACTION_MIDDLE_CLICK, |
2397 | - GValueMatch <gint> (0, g_value_get_int), |
2398 | - _)); |
2399 | - |
2400 | - g_object_get_property (G_OBJECT (settingsMock.get ()), |
2401 | - "titlebar-middle-click-action", |
2402 | - &integerGValue); |
2403 | - |
2404 | - EXPECT_CALL (settingsGMock, getProperty (GWD_MOCK_SETTINGS_PROPERTY_TITLEBAR_ACTION_RIGHT_CLICK, |
2405 | - GValueMatch <gint> (0, g_value_get_int), |
2406 | - _)); |
2407 | - |
2408 | - g_object_get_property (G_OBJECT (settingsMock.get ()), |
2409 | - "titlebar-right-click-action", |
2410 | - &integerGValue); |
2411 | - |
2412 | - EXPECT_CALL (settingsGMock, getProperty (GWD_MOCK_SETTINGS_PROPERTY_MOUSE_WHEEL_ACTION, |
2413 | - GValueMatch <gint> (0, g_value_get_int), |
2414 | - _)); |
2415 | - |
2416 | - g_object_get_property (G_OBJECT (settingsMock.get ()), |
2417 | - "mouse-wheel-action", |
2418 | - &integerGValue); |
2419 | - |
2420 | - EXPECT_CALL (settingsGMock, getProperty (GWD_MOCK_SETTINGS_PROPERTY_TITLEBAR_FONT, |
2421 | - GValueMatch <const gchar *> (NULL, g_value_get_string), |
2422 | - _)); |
2423 | - |
2424 | - g_object_get_property (G_OBJECT (settingsMock.get ()), |
2425 | - "titlebar-font", |
2426 | - &stringGValue); |
2427 | -} |
2428 | - |
2429 | namespace |
2430 | { |
2431 | void ExpectAllNotificationsOnce (boost::shared_ptr <StrictMock <GWDMockSettingsNotifiedGMock> > &gmockNotified, |
2432 | - boost::shared_ptr <GWDSettingsImpl> &settings) |
2433 | + boost::shared_ptr <GWDSettings> &settings) |
2434 | { |
2435 | InSequence s; |
2436 | |
2437 | @@ -580,9 +403,7 @@ |
2438 | mGMockNotified.reset (new StrictMock <GWDMockSettingsNotifiedGMock> ()); |
2439 | mMockNotified.reset (gwd_mock_settings_notified_new (mGMockNotified.get ()), |
2440 | boost::bind (gwd_settings_notified_do_nothing, _1)); |
2441 | - mSettings.reset (gwd_settings_impl_new (NULL, |
2442 | - NULL, |
2443 | - mMockNotified.get ()), |
2444 | + mSettings.reset (gwd_settings_new (NULL, NULL, mMockNotified.get ()), |
2445 | boost::bind (gwd_settings_unref, _1)); |
2446 | ExpectAllNotificationsOnce (mGMockNotified, mSettings); |
2447 | } |
2448 | @@ -597,7 +418,7 @@ |
2449 | |
2450 | boost::shared_ptr <StrictMock <GWDMockSettingsNotifiedGMock> > mGMockNotified; |
2451 | boost::shared_ptr <GWDSettingsNotified> mMockNotified; |
2452 | - boost::shared_ptr <GWDSettingsImpl> mSettings; |
2453 | + boost::shared_ptr <GWDSettings> mSettings; |
2454 | }; |
2455 | |
2456 | TEST_F(GWDSettingsTest, TestGWDSettingsInstantiation) |
2457 | @@ -791,11 +612,9 @@ |
2458 | gint blurType = testing_values::BLUR_TYPE_ALL_INT_VALUE; |
2459 | |
2460 | /* We need to increment the reference count so that it doesn't |
2461 | - * go away when we create a new GWDSettingsImpl */ |
2462 | + * go away when we create a new GWDSettings */ |
2463 | g_object_ref (mMockNotified.get ()); |
2464 | - mSettings.reset (gwd_settings_impl_new (&blurType, |
2465 | - NULL, |
2466 | - mMockNotified.get ()), |
2467 | + mSettings.reset (gwd_settings_new (&blurType, NULL, mMockNotified.get ()), |
2468 | boost::bind (gwd_settings_unref, _1)); |
2469 | |
2470 | EXPECT_THAT (gwd_settings_writable_blur_changed (GWD_SETTINGS_WRITABLE_INTERFACE (mSettings.get ()), |
2471 | @@ -862,9 +681,7 @@ |
2472 | const gchar *metacityTheme = "Ambiance"; |
2473 | |
2474 | g_object_ref (mMockNotified.get ()); |
2475 | - mSettings.reset (gwd_settings_impl_new (NULL, |
2476 | - &metacityTheme, |
2477 | - mMockNotified.get ()), |
2478 | + mSettings.reset (gwd_settings_new (NULL, &metacityTheme, mMockNotified.get ()), |
2479 | boost::bind (gwd_settings_unref, _1)); |
2480 | |
2481 | EXPECT_THAT (gwd_settings_writable_metacity_theme_changed (GWD_SETTINGS_WRITABLE_INTERFACE (mSettings.get ()), |
2482 | @@ -1046,9 +863,7 @@ |
2483 | mGMockNotified.reset (new GWDMockSettingsNotifiedGMock ()); |
2484 | mMockNotified.reset (gwd_mock_settings_notified_new (mGMockNotified.get ()), |
2485 | boost::bind (gwd_settings_notified_do_nothing, _1)); |
2486 | - mSettings.reset (gwd_settings_impl_new (NULL, |
2487 | - NULL, |
2488 | - mMockNotified.get ()), |
2489 | + mSettings.reset (gwd_settings_new (NULL, NULL, mMockNotified.get ()), |
2490 | boost::bind (gwd_settings_unref, _1)); |
2491 | } |
2492 | |
2493 | @@ -1064,7 +879,7 @@ |
2494 | |
2495 | boost::shared_ptr <GWDMockSettingsNotifiedGMock> mGMockNotified; |
2496 | boost::shared_ptr <GWDSettingsNotified> mMockNotified; |
2497 | - boost::shared_ptr <GWDSettingsImpl> mSettings; |
2498 | + boost::shared_ptr <GWDSettings> mSettings; |
2499 | }; |
2500 | |
2501 | TEST_P(GWDSettingsTestClickActions, TestClickActionsAndMouseActions) |
LGTM structure wise, see the diff comments on coding style things (I've continued the discussion on coding style in the other review).