Merge lp:~muktupavels/compiz/gwd-titlebar-font into lp:compiz/0.9.12
- gwd-titlebar-font
- Merge into 0.9.12
Status: | Merged |
---|---|
Approved by: | Marco Trevisan (Treviño) |
Approved revision: | 4066 |
Merged at revision: | 4056 |
Proposed branch: | lp:~muktupavels/compiz/gwd-titlebar-font |
Merge into: | lp:compiz/0.9.12 |
Prerequisite: | lp:~muktupavels/compiz/gwd-cleanup |
Diff against target: |
807 lines (+202/-253) 10 files modified
gtk/window-decorator/decorator.c (+9/-60) gtk/window-decorator/frames.c (+0/-42) gtk/window-decorator/gtk-window-decorator.c (+5/-9) gtk/window-decorator/gtk-window-decorator.h (+3/-11) gtk/window-decorator/gwd-settings.c (+7/-7) gtk/window-decorator/gwd-theme-metacity.c (+34/-17) gtk/window-decorator/gwd-theme.c (+76/-33) gtk/window-decorator/gwd-theme.h (+50/-46) gtk/window-decorator/tests/test_gwd_settings.cpp (+9/-9) gtk/window-decorator/wnck.c (+9/-19) |
To merge this branch: | bzr merge lp:~muktupavels/compiz/gwd-titlebar-font |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Sam Spilsbury | Approve | ||
Review via email: mp+296773@code.launchpad.net |
Commit message
gtk-window-
In Metacity 3.20 titlebar font is handled internally. To use custom / non-system titlebar font meta_theme_
Previous Metacity versions has function to create titlebar font. Lets use it to make sure that decorations are equal between gtk-window-
Old code on titlebar font change did unneeded work if not-system font was used. In update-frames signal old font was destroyed and then recreated. After that in update-decorations signal it was done again.
Description of the change
In Metacity 3.20 titlebar font is handled internally. To use custom / non-system titlebar font meta_theme_
Previous Metacity versions has function to create titlebar font. Lets use it to make sure that decorations are equal between gtk-window-
Old code on titlebar font change did unneeded work if not-system font was used. In update-frames signal old font was destroyed and then recreated. After that in update-decorations signal it was done again.
- 4064. By Alberts Muktupāvels
-
Merge with lp:~albertsmuktupavels/compiz/gwd-cleanup.
- 4065. By Alberts Muktupāvels
-
Merge with lp:~albertsmuktupavels/compiz/gwd-cleanup.
- 4066. By Alberts Muktupāvels
-
Merge with lp:~albertsmuktupavels/compiz/gwd-cleanup.
Preview Diff
1 | === modified file 'gtk/window-decorator/decorator.c' |
2 | --- gtk/window-decorator/decorator.c 2016-06-09 14:56:11 +0000 |
3 | +++ gtk/window-decorator/decorator.c 2016-06-09 14:56:11 +0000 |
4 | @@ -45,26 +45,6 @@ |
5 | decor_frame_destroy (frame); |
6 | } |
7 | |
8 | - |
9 | -/* |
10 | - * get_titlebar_font |
11 | - * |
12 | - * Returns: PangoFontDescription * or NULL if using system font |
13 | - * Description: Helper function to get the font for the titlebar |
14 | - */ |
15 | -static const PangoFontDescription * |
16 | -get_titlebar_font (decor_frame_t *frame) |
17 | -{ |
18 | - GWDSettings *settings = gwd_theme_get_settings (gwd_theme); |
19 | - const gchar *titlebar_font = gwd_settings_get_titlebar_font (settings); |
20 | - |
21 | - /* Using system font */ |
22 | - if (!titlebar_font) |
23 | - return NULL; |
24 | - else |
25 | - return frame->titlebar_font; |
26 | -} |
27 | - |
28 | /* |
29 | * frame_update_titlebar_font |
30 | * |
31 | @@ -75,49 +55,25 @@ |
32 | void |
33 | frame_update_titlebar_font (decor_frame_t *frame) |
34 | { |
35 | - const PangoFontDescription *font_desc; |
36 | - PangoFontDescription *free_font_desc; |
37 | + PangoFontDescription *font_desc = gwd_theme_get_titlebar_font (gwd_theme, frame); |
38 | + PangoLanguage *lang = pango_context_get_language (frame->pango_context); |
39 | PangoFontMetrics *metrics; |
40 | - PangoLanguage *lang; |
41 | + gint ascent, descent; |
42 | |
43 | - free_font_desc = NULL; |
44 | frame = gwd_decor_frame_ref (frame); |
45 | |
46 | - font_desc = get_titlebar_font (frame); |
47 | - if (!font_desc) |
48 | - { |
49 | - GtkCssProvider *provider = gtk_css_provider_get_default (); |
50 | - GtkStyleContext *context = gtk_style_context_new (); |
51 | - GtkWidgetPath *path = gtk_widget_path_new (); |
52 | - |
53 | - gtk_widget_path_prepend_type (path, GTK_TYPE_WIDGET); |
54 | - gtk_style_context_set_path (context, path); |
55 | - gtk_widget_path_free (path); |
56 | - |
57 | - gtk_style_context_add_provider (context, GTK_STYLE_PROVIDER (provider), GTK_STYLE_PROVIDER_PRIORITY_FALLBACK); |
58 | - |
59 | - gtk_style_context_save (context); |
60 | - gtk_style_context_set_state (context, GTK_STATE_FLAG_NORMAL); |
61 | - gtk_style_context_get (context, GTK_STATE_FLAG_NORMAL, "font", &free_font_desc, NULL); |
62 | - gtk_style_context_restore (context); |
63 | - |
64 | - font_desc = (const PangoFontDescription *) free_font_desc; |
65 | - } |
66 | - |
67 | pango_context_set_font_description (frame->pango_context, font_desc); |
68 | |
69 | - lang = pango_context_get_language (frame->pango_context); |
70 | metrics = pango_context_get_metrics (frame->pango_context, font_desc, lang); |
71 | - |
72 | - frame->text_height = PANGO_PIXELS (pango_font_metrics_get_ascent (metrics) + |
73 | - pango_font_metrics_get_descent (metrics)); |
74 | - |
75 | - gwd_decor_frame_unref (frame); |
76 | + ascent = pango_font_metrics_get_ascent (metrics); |
77 | + descent = pango_font_metrics_get_descent (metrics); |
78 | + |
79 | + frame->text_height = PANGO_PIXELS (ascent + descent); |
80 | |
81 | pango_font_metrics_unref (metrics); |
82 | + pango_font_description_free (font_desc); |
83 | |
84 | - if (free_font_desc) |
85 | - pango_font_description_free (free_font_desc); |
86 | + gwd_decor_frame_unref (frame); |
87 | } |
88 | |
89 | void |
90 | @@ -128,13 +84,6 @@ |
91 | frame_update_titlebar_font ((decor_frame_t *) value); |
92 | } |
93 | |
94 | -void |
95 | -update_titlebar_font () |
96 | -{ |
97 | - gwd_frames_foreach (update_frames_titlebar_fonts, NULL); |
98 | -} |
99 | - |
100 | - |
101 | /* |
102 | * update_event_windows |
103 | * |
104 | |
105 | === modified file 'gtk/window-decorator/frames.c' |
106 | --- gtk/window-decorator/frames.c 2016-06-09 14:56:11 +0000 |
107 | +++ gtk/window-decorator/frames.c 2016-06-09 14:56:11 +0000 |
108 | @@ -264,8 +264,6 @@ |
109 | void |
110 | decor_frame_refresh (decor_frame_t *frame) |
111 | { |
112 | - GWDSettings *settings = gwd_theme_get_settings (gwd_theme); |
113 | - const gchar *titlebar_font = gwd_settings_get_titlebar_font (settings); |
114 | decor_shadow_options_t active_o, inactive_o; |
115 | decor_shadow_info_t *info; |
116 | |
117 | @@ -273,8 +271,6 @@ |
118 | |
119 | update_style (frame->style_window_rgba); |
120 | |
121 | - set_frame_scale (frame, titlebar_font); |
122 | - |
123 | frame_update_titlebar_font (frame); |
124 | |
125 | if (strcmp (frame->type, "switcher") != 0 && strcmp (frame->type, "bare") != 0) |
126 | @@ -441,7 +437,6 @@ |
127 | frame->border_shadow_inactive = NULL; |
128 | frame->max_border_shadow_active = NULL; |
129 | frame->max_border_shadow_inactive = NULL; |
130 | - frame->titlebar_font = NULL; |
131 | |
132 | frame->style_window_rgba = gtk_window_new (GTK_WINDOW_POPUP); |
133 | |
134 | @@ -485,9 +480,6 @@ |
135 | if (frame->pango_context) |
136 | g_object_unref (G_OBJECT (frame->pango_context)); |
137 | |
138 | - if (frame->titlebar_font) |
139 | - pango_font_description_free (frame->titlebar_font); |
140 | - |
141 | if (frame) |
142 | free (frame->type); |
143 | |
144 | @@ -509,37 +501,3 @@ |
145 | |
146 | frames_table = g_hash_table_new (g_str_hash, g_str_equal); |
147 | } |
148 | - |
149 | -void |
150 | -set_frame_scale (decor_frame_t *frame, |
151 | - const gchar *font_str) |
152 | -{ |
153 | - gwd_decor_frame_ref (frame); |
154 | - |
155 | - if (frame->titlebar_font) { |
156 | - pango_font_description_free (frame->titlebar_font); |
157 | - frame->titlebar_font = NULL; |
158 | - } |
159 | - |
160 | - if (font_str) { |
161 | - frame->titlebar_font = pango_font_description_from_string (font_str); |
162 | - gwd_theme_update_titlebar_font_size (gwd_theme, frame, frame->titlebar_font); |
163 | - } |
164 | - |
165 | - gwd_decor_frame_unref (frame); |
166 | -} |
167 | - |
168 | -void |
169 | -set_frames_scales (gpointer key, |
170 | - gpointer value, |
171 | - gpointer user_data) |
172 | -{ |
173 | - decor_frame_t *frame = (decor_frame_t *) value; |
174 | - gchar *font_str = (gchar *) user_data; |
175 | - |
176 | - gwd_decor_frame_ref (frame); |
177 | - |
178 | - set_frame_scale (frame, font_str); |
179 | - |
180 | - gwd_decor_frame_unref (frame); |
181 | -} |
182 | |
183 | === modified file 'gtk/window-decorator/gtk-window-decorator.c' |
184 | --- gtk/window-decorator/gtk-window-decorator.c 2016-06-09 14:56:11 +0000 |
185 | +++ gtk/window-decorator/gtk-window-decorator.c 2016-06-09 14:56:11 +0000 |
186 | @@ -135,14 +135,10 @@ |
187 | } |
188 | |
189 | static void |
190 | -update_frames_cb (GWDSettings *settings, |
191 | - gpointer user_data) |
192 | +update_titlebar_font_cb (GWDSettings *settings, |
193 | + gpointer user_data) |
194 | { |
195 | - const gchar *titlebar_font; |
196 | - |
197 | - titlebar_font = gwd_settings_get_titlebar_font (settings); |
198 | - |
199 | - gwd_frames_foreach (set_frames_scales, (gpointer) titlebar_font); |
200 | + gwd_theme_update_titlebar_font (gwd_theme); |
201 | } |
202 | |
203 | static void |
204 | @@ -310,8 +306,8 @@ |
205 | |
206 | g_signal_connect (settings, "update-decorations", |
207 | G_CALLBACK (update_decorations_cb), NULL); |
208 | - g_signal_connect (settings, "update-frames", |
209 | - G_CALLBACK (update_frames_cb), NULL); |
210 | + g_signal_connect (settings, "update-titlebar-font", |
211 | + G_CALLBACK (update_titlebar_font_cb), NULL); |
212 | g_signal_connect (settings, "update-metacity-theme", |
213 | G_CALLBACK (update_metacity_theme_cb), NULL); |
214 | |
215 | |
216 | === modified file 'gtk/window-decorator/gtk-window-decorator.h' |
217 | --- gtk/window-decorator/gtk-window-decorator.h 2016-06-09 14:56:11 +0000 |
218 | +++ gtk/window-decorator/gtk-window-decorator.h 2016-06-09 14:56:11 +0000 |
219 | @@ -217,7 +217,6 @@ |
220 | decor_context_t window_context_inactive; |
221 | decor_context_t max_window_context_active; |
222 | decor_context_t max_window_context_inactive; |
223 | - PangoFontDescription *titlebar_font; |
224 | PangoContext *pango_context; |
225 | GtkWidget *style_window_rgba; |
226 | gint text_height; |
227 | @@ -388,7 +387,9 @@ |
228 | update_shadow (void); |
229 | |
230 | void |
231 | -update_titlebar_font (); |
232 | +update_frames_titlebar_fonts (gpointer key, |
233 | + gpointer value, |
234 | + gpointer user_data); |
235 | |
236 | void |
237 | update_window_decoration (WnckWindow *win); |
238 | @@ -667,15 +668,6 @@ |
239 | /* settings.c */ |
240 | |
241 | void |
242 | -set_frame_scale (decor_frame_t *frame, |
243 | - const gchar *font_str); |
244 | - |
245 | -void |
246 | -set_frames_scales (gpointer key, |
247 | - gpointer value, |
248 | - gpointer user_data); |
249 | - |
250 | -void |
251 | init_settings (GWDSettings *settings); |
252 | |
253 | void |
254 | |
255 | === modified file 'gtk/window-decorator/gwd-settings.c' |
256 | --- gtk/window-decorator/gwd-settings.c 2016-06-09 14:56:11 +0000 |
257 | +++ gtk/window-decorator/gwd-settings.c 2016-06-09 14:56:11 +0000 |
258 | @@ -110,7 +110,7 @@ |
259 | enum |
260 | { |
261 | UPDATE_DECORATIONS, |
262 | - UPDATE_FRAMES, |
263 | + UPDATE_TITLEBAR_FONT, |
264 | UPDATE_METACITY_THEME, |
265 | UPDATE_METACITY_BUTTON_LAYOUT, |
266 | |
267 | @@ -128,9 +128,9 @@ |
268 | } |
269 | |
270 | static void |
271 | -update_frames (GWDSettings *settings) |
272 | +update_titlebar_font (GWDSettings *settings) |
273 | { |
274 | - g_signal_emit (settings, settings_signals[UPDATE_FRAMES], 0); |
275 | + g_signal_emit (settings, settings_signals[UPDATE_TITLEBAR_FONT], 0); |
276 | } |
277 | |
278 | static void |
279 | @@ -322,8 +322,8 @@ |
280 | GWD_TYPE_SETTINGS, G_SIGNAL_RUN_LAST, |
281 | 0, NULL, NULL, NULL, G_TYPE_NONE, 0); |
282 | |
283 | - settings_signals[UPDATE_FRAMES] = |
284 | - g_signal_new ("update-frames", |
285 | + settings_signals[UPDATE_TITLEBAR_FONT] = |
286 | + g_signal_new ("update-titlebar-font", |
287 | GWD_TYPE_SETTINGS, G_SIGNAL_RUN_LAST, |
288 | 0, NULL, NULL, NULL, G_TYPE_NONE, 0); |
289 | |
290 | @@ -378,7 +378,7 @@ |
291 | * the settings backend can't do it itself */ |
292 | append_to_notify_funcs (settings, update_metacity_theme); |
293 | append_to_notify_funcs (settings, update_metacity_button_layout); |
294 | - append_to_notify_funcs (settings, update_frames); |
295 | + append_to_notify_funcs (settings, update_titlebar_font); |
296 | append_to_notify_funcs (settings, update_decorations); |
297 | } |
298 | |
299 | @@ -710,8 +710,8 @@ |
300 | g_free (settings->titlebar_font); |
301 | settings->titlebar_font = g_strdup (use_font); |
302 | |
303 | + append_to_notify_funcs (settings, update_titlebar_font); |
304 | append_to_notify_funcs (settings, update_decorations); |
305 | - append_to_notify_funcs (settings, update_frames); |
306 | release_notify_funcs (settings); |
307 | |
308 | return TRUE; |
309 | |
310 | === modified file 'gtk/window-decorator/gwd-theme-metacity.c' |
311 | --- gtk/window-decorator/gwd-theme-metacity.c 2016-06-09 14:56:11 +0000 |
312 | +++ gtk/window-decorator/gwd-theme-metacity.c 2016-06-09 14:56:11 +0000 |
313 | @@ -36,12 +36,14 @@ |
314 | |
315 | struct _GWDThemeMetacity |
316 | { |
317 | - GObject parent; |
318 | - |
319 | - MetaTheme *theme; |
320 | - |
321 | - gulong button_layout_id; |
322 | - MetaButtonLayout button_layout; |
323 | + GObject parent; |
324 | + |
325 | + MetaTheme *theme; |
326 | + |
327 | + gulong button_layout_id; |
328 | + MetaButtonLayout button_layout; |
329 | + |
330 | + const PangoFontDescription *titlebar_font; |
331 | }; |
332 | |
333 | G_DEFINE_TYPE (GWDThemeMetacity, gwd_theme_metacity, GWD_TYPE_THEME) |
334 | @@ -928,6 +930,8 @@ |
335 | metacity->button_layout_id = 0; |
336 | } |
337 | |
338 | + metacity->titlebar_font = NULL; |
339 | + |
340 | G_OBJECT_CLASS (gwd_theme_metacity_parent_class)->dispose (object); |
341 | } |
342 | |
343 | @@ -1397,18 +1401,30 @@ |
344 | } |
345 | |
346 | static void |
347 | -gwd_theme_metacity_update_titlebar_font_size (GWDTheme *theme, |
348 | - decor_frame_t *frame, |
349 | - PangoFontDescription *titlebar_font) |
350 | -{ |
351 | - GWDThemeMetacity *metacity = GWD_THEME_METACITY (theme); |
352 | +gwd_theme_metacity_update_titlebar_font (GWDTheme *theme, |
353 | + const PangoFontDescription *titlebar_font) |
354 | +{ |
355 | + GWDThemeMetacity *metacity = GWD_THEME_METACITY (theme); |
356 | + |
357 | + metacity->titlebar_font = titlebar_font; |
358 | +} |
359 | + |
360 | +static PangoFontDescription * |
361 | +gwd_theme_metacity_get_titlebar_font (GWDTheme *theme, |
362 | + decor_frame_t *frame) |
363 | +{ |
364 | + GWDThemeMetacity *metacity = GWD_THEME_METACITY (theme); |
365 | + GdkScreen *screen = gtk_widget_get_screen (frame->style_window_rgba); |
366 | + MetaStyleInfo *style_info = meta_theme_create_style_info (screen, NULL); |
367 | + PangoFontDescription *font_desc = meta_style_info_create_font_desc (style_info); |
368 | MetaFrameType type = frame_type_from_string (frame->type); |
369 | MetaFrameFlags flags = 0xc33; /* FIXME */ |
370 | - MetaFrameStyle *style; |
371 | - |
372 | - style = meta_theme_get_frame_style (metacity->theme, type, flags); |
373 | - |
374 | - meta_frame_style_apply_scale (style, titlebar_font); |
375 | + MetaFrameStyle *style = meta_theme_get_frame_style (metacity->theme, type, flags); |
376 | + |
377 | + pango_font_description_merge (font_desc, metacity->titlebar_font, TRUE); |
378 | + meta_frame_style_apply_scale (style, font_desc); |
379 | + |
380 | + return font_desc; |
381 | } |
382 | |
383 | static void |
384 | @@ -1425,7 +1441,8 @@ |
385 | theme_class->update_border_extents = gwd_theme_metacity_update_border_extents; |
386 | theme_class->get_event_window_position = gwd_theme_metacity_get_event_window_position; |
387 | theme_class->get_button_position = gwd_theme_metacity_get_button_position; |
388 | - theme_class->update_titlebar_font_size = gwd_theme_metacity_update_titlebar_font_size; |
389 | + theme_class->update_titlebar_font = gwd_theme_metacity_update_titlebar_font; |
390 | + theme_class->get_titlebar_font = gwd_theme_metacity_get_titlebar_font; |
391 | } |
392 | |
393 | static void |
394 | |
395 | === modified file 'gtk/window-decorator/gwd-theme.c' |
396 | --- gtk/window-decorator/gwd-theme.c 2016-06-01 11:29:21 +0000 |
397 | +++ gtk/window-decorator/gwd-theme.c 2016-06-09 14:56:11 +0000 |
398 | @@ -18,6 +18,7 @@ |
399 | */ |
400 | |
401 | #include "config.h" |
402 | +#include "gtk-window-decorator.h" |
403 | #include "gwd-settings.h" |
404 | #include "gwd-theme.h" |
405 | #include "gwd-theme-cairo.h" |
406 | @@ -28,7 +29,9 @@ |
407 | |
408 | typedef struct |
409 | { |
410 | - GWDSettings *settings; |
411 | + GWDSettings *settings; |
412 | + |
413 | + PangoFontDescription *titlebar_font; |
414 | } GWDThemePrivate; |
415 | |
416 | enum |
417 | @@ -45,16 +48,26 @@ |
418 | G_DEFINE_TYPE_WITH_PRIVATE (GWDTheme, gwd_theme, G_TYPE_OBJECT) |
419 | |
420 | static void |
421 | +gwd_theme_constructed (GObject *object) |
422 | +{ |
423 | + GWDTheme *theme = GWD_THEME (object); |
424 | + |
425 | + G_OBJECT_CLASS (gwd_theme_parent_class)->constructed (object); |
426 | + |
427 | + gwd_theme_update_titlebar_font (theme); |
428 | +} |
429 | + |
430 | +static void |
431 | gwd_theme_dispose (GObject *object) |
432 | { |
433 | - GWDTheme *theme; |
434 | - GWDThemePrivate *priv; |
435 | - |
436 | - theme = GWD_THEME (object); |
437 | - priv = gwd_theme_get_instance_private (theme); |
438 | + GWDTheme *theme = GWD_THEME (object); |
439 | + GWDThemePrivate *priv = gwd_theme_get_instance_private (theme); |
440 | |
441 | g_clear_object (&priv->settings); |
442 | |
443 | + pango_font_description_free (priv->titlebar_font); |
444 | + priv->titlebar_font = NULL; |
445 | + |
446 | G_OBJECT_CLASS (gwd_theme_parent_class)->dispose (object); |
447 | } |
448 | |
449 | @@ -64,11 +77,8 @@ |
450 | GValue *value, |
451 | GParamSpec *pspec) |
452 | { |
453 | - GWDTheme *theme; |
454 | - GWDThemePrivate *priv; |
455 | - |
456 | - theme = GWD_THEME (object); |
457 | - priv = gwd_theme_get_instance_private (theme); |
458 | + GWDTheme *theme = GWD_THEME (object); |
459 | + GWDThemePrivate *priv = gwd_theme_get_instance_private (theme); |
460 | |
461 | switch (property_id) { |
462 | case PROP_SETTINGS: |
463 | @@ -87,11 +97,8 @@ |
464 | const GValue *value, |
465 | GParamSpec *pspec) |
466 | { |
467 | - GWDTheme *theme; |
468 | - GWDThemePrivate *priv; |
469 | - |
470 | - theme = GWD_THEME (object); |
471 | - priv = gwd_theme_get_instance_private (theme); |
472 | + GWDTheme *theme = GWD_THEME (object); |
473 | + GWDThemePrivate *priv = gwd_theme_get_instance_private (theme); |
474 | |
475 | switch (property_id) { |
476 | case PROP_SETTINGS: |
477 | @@ -110,11 +117,9 @@ |
478 | decor_shadow_options_t *options, |
479 | gboolean active) |
480 | { |
481 | - GWDThemePrivate *priv; |
482 | + GWDThemePrivate *priv = gwd_theme_get_instance_private (theme); |
483 | decor_shadow_options_t shadow; |
484 | |
485 | - priv = gwd_theme_get_instance_private (theme); |
486 | - |
487 | if (active) |
488 | shadow = gwd_settings_get_active_shadow (priv->settings); |
489 | else |
490 | @@ -176,10 +181,16 @@ |
491 | } |
492 | |
493 | static void |
494 | -gwd_theme_real_update_titlebar_font_size (GWDTheme *theme, |
495 | - decor_frame_t *frame, |
496 | - PangoFontDescription *titlebar_font) |
497 | -{ |
498 | +gwd_theme_real_update_titlebar_font (GWDTheme *theme, |
499 | + const PangoFontDescription *titlebar_font) |
500 | +{ |
501 | +} |
502 | + |
503 | +static PangoFontDescription * |
504 | +gwd_theme_real_get_titlebar_font (GWDTheme *theme, |
505 | + decor_frame_t *frame) |
506 | +{ |
507 | + return NULL; |
508 | } |
509 | |
510 | static void |
511 | @@ -189,6 +200,7 @@ |
512 | |
513 | object_class = G_OBJECT_CLASS (theme_class); |
514 | |
515 | + object_class->constructed = gwd_theme_constructed; |
516 | object_class->dispose = gwd_theme_dispose; |
517 | object_class->get_property = gwd_theme_get_property; |
518 | object_class->set_property = gwd_theme_set_property; |
519 | @@ -199,7 +211,8 @@ |
520 | theme_class->update_border_extents = gwd_theme_real_update_border_extents; |
521 | theme_class->get_event_window_position = gwd_theme_real_get_event_window_position; |
522 | theme_class->get_button_position = gwd_theme_real_get_button_position; |
523 | - theme_class->update_titlebar_font_size = gwd_theme_real_update_titlebar_font_size; |
524 | + theme_class->update_titlebar_font = gwd_theme_real_update_titlebar_font; |
525 | + theme_class->get_titlebar_font = gwd_theme_real_get_titlebar_font; |
526 | |
527 | properties[PROP_SETTINGS] = |
528 | g_param_spec_object ("settings", "GWDSettings", "GWDSettings", |
529 | @@ -251,9 +264,7 @@ |
530 | GWDSettings * |
531 | gwd_theme_get_settings (GWDTheme *theme) |
532 | { |
533 | - GWDThemePrivate *priv; |
534 | - |
535 | - priv = gwd_theme_get_instance_private (theme); |
536 | + GWDThemePrivate *priv = gwd_theme_get_instance_private (theme); |
537 | |
538 | return priv->settings; |
539 | } |
540 | @@ -329,10 +340,42 @@ |
541 | } |
542 | |
543 | void |
544 | -gwd_theme_update_titlebar_font_size (GWDTheme *theme, |
545 | - decor_frame_t *frame, |
546 | - PangoFontDescription *titlebar_font) |
547 | -{ |
548 | - GWD_THEME_GET_CLASS (theme)->update_titlebar_font_size (theme, frame, |
549 | - titlebar_font); |
550 | +gwd_theme_update_titlebar_font (GWDTheme *theme) |
551 | +{ |
552 | + GWDThemePrivate *priv = gwd_theme_get_instance_private (theme); |
553 | + const gchar *titlebar_font = gwd_settings_get_titlebar_font (priv->settings); |
554 | + |
555 | + pango_font_description_free (priv->titlebar_font); |
556 | + priv->titlebar_font = NULL; |
557 | + |
558 | + if (titlebar_font != NULL) |
559 | + priv->titlebar_font = pango_font_description_from_string (titlebar_font); |
560 | + |
561 | + GWD_THEME_GET_CLASS (theme)->update_titlebar_font (theme, priv->titlebar_font); |
562 | +} |
563 | + |
564 | +PangoFontDescription * |
565 | +gwd_theme_get_titlebar_font (GWDTheme *theme, |
566 | + decor_frame_t *frame) |
567 | +{ |
568 | + PangoFontDescription *font_desc = NULL; |
569 | + GWDThemePrivate *priv = gwd_theme_get_instance_private (theme); |
570 | + GtkStyleContext *context = gtk_widget_get_style_context (frame->style_window_rgba); |
571 | + |
572 | + /* Check if Metacity or Cairo will create titlebar font */ |
573 | + font_desc = GWD_THEME_GET_CLASS (theme)->get_titlebar_font (theme, frame); |
574 | + if (font_desc) |
575 | + return font_desc; |
576 | + |
577 | + /* Check if non-system font is in use */ |
578 | + if (priv->titlebar_font) |
579 | + return pango_font_description_copy (priv->titlebar_font); |
580 | + |
581 | + /* Use system titlebar font */ |
582 | + gtk_style_context_save (context); |
583 | + gtk_style_context_set_state (context, GTK_STATE_FLAG_NORMAL); |
584 | + gtk_style_context_get (context, GTK_STATE_FLAG_NORMAL, "font", &font_desc, NULL); |
585 | + gtk_style_context_restore (context); |
586 | + |
587 | + return font_desc; |
588 | } |
589 | |
590 | === modified file 'gtk/window-decorator/gwd-theme.h' |
591 | --- gtk/window-decorator/gwd-theme.h 2016-06-01 11:29:21 +0000 |
592 | +++ gtk/window-decorator/gwd-theme.h 2016-06-09 14:56:11 +0000 |
593 | @@ -37,49 +37,51 @@ |
594 | { |
595 | GObjectClass parent_class; |
596 | |
597 | - void (* get_shadow) (GWDTheme *theme, |
598 | - decor_frame_t *frame, |
599 | - decor_shadow_options_t *options, |
600 | - gboolean active); |
601 | - |
602 | - void (* draw_window_decoration) (GWDTheme *theme, |
603 | - decor_t *decor); |
604 | - |
605 | - gboolean (* calc_decoration_size) (GWDTheme *theme, |
606 | - decor_t *decor, |
607 | - gint w, |
608 | - gint h, |
609 | - gint name_width, |
610 | - gint *width, |
611 | - gint *height); |
612 | - |
613 | - void (* update_border_extents) (GWDTheme *theme, |
614 | - decor_frame_t *frame); |
615 | - |
616 | - void (* get_event_window_position) (GWDTheme *theme, |
617 | - decor_t *decor, |
618 | - gint i, |
619 | - gint j, |
620 | - gint width, |
621 | - gint height, |
622 | - gint *x, |
623 | - gint *y, |
624 | - gint *w, |
625 | - gint *h); |
626 | - |
627 | - gboolean (* get_button_position) (GWDTheme *theme, |
628 | - decor_t *decor, |
629 | - gint i, |
630 | - gint width, |
631 | - gint height, |
632 | - gint *x, |
633 | - gint *y, |
634 | - gint *w, |
635 | - gint *h); |
636 | - |
637 | - void (* update_titlebar_font_size) (GWDTheme *theme, |
638 | - decor_frame_t *frame, |
639 | - PangoFontDescription *titlebar_font); |
640 | + void (* get_shadow) (GWDTheme *theme, |
641 | + decor_frame_t *frame, |
642 | + decor_shadow_options_t *options, |
643 | + gboolean active); |
644 | + |
645 | + void (* draw_window_decoration) (GWDTheme *theme, |
646 | + decor_t *decor); |
647 | + |
648 | + gboolean (* calc_decoration_size) (GWDTheme *theme, |
649 | + decor_t *decor, |
650 | + gint w, |
651 | + gint h, |
652 | + gint name_width, |
653 | + gint *width, |
654 | + gint *height); |
655 | + |
656 | + void (* update_border_extents) (GWDTheme *theme, |
657 | + decor_frame_t *frame); |
658 | + |
659 | + void (* get_event_window_position) (GWDTheme *theme, |
660 | + decor_t *decor, |
661 | + gint i, |
662 | + gint j, |
663 | + gint width, |
664 | + gint height, |
665 | + gint *x, |
666 | + gint *y, |
667 | + gint *w, |
668 | + gint *h); |
669 | + |
670 | + gboolean (* get_button_position) (GWDTheme *theme, |
671 | + decor_t *decor, |
672 | + gint i, |
673 | + gint width, |
674 | + gint height, |
675 | + gint *x, |
676 | + gint *y, |
677 | + gint *w, |
678 | + gint *h); |
679 | + |
680 | + void (* update_titlebar_font) (GWDTheme *theme, |
681 | + const PangoFontDescription *titlebar_font); |
682 | + |
683 | + PangoFontDescription * (* get_titlebar_font) (GWDTheme *theme, |
684 | + decor_frame_t *frame); |
685 | }; |
686 | |
687 | typedef enum |
688 | @@ -142,9 +144,11 @@ |
689 | gint *h); |
690 | |
691 | void |
692 | -gwd_theme_update_titlebar_font_size (GWDTheme *theme, |
693 | - decor_frame_t *frame, |
694 | - PangoFontDescription *titlebar_font); |
695 | +gwd_theme_update_titlebar_font (GWDTheme *theme); |
696 | + |
697 | +PangoFontDescription * |
698 | +gwd_theme_get_titlebar_font (GWDTheme *theme, |
699 | + decor_frame_t *frame); |
700 | |
701 | G_END_DECLS |
702 | |
703 | |
704 | === modified file 'gtk/window-decorator/tests/test_gwd_settings.cpp' |
705 | --- gtk/window-decorator/tests/test_gwd_settings.cpp 2016-06-09 14:56:11 +0000 |
706 | +++ gtk/window-decorator/tests/test_gwd_settings.cpp 2016-06-09 14:56:11 +0000 |
707 | @@ -136,8 +136,8 @@ |
708 | { |
709 | g_signal_connect (settings.get (), "update-decorations", |
710 | G_CALLBACK (GWDMockSettingsNotifiedGMock::updateDecorationsCb), this); |
711 | - g_signal_connect (settings.get (), "update-frames", |
712 | - G_CALLBACK (GWDMockSettingsNotifiedGMock::updateFramesCb), this); |
713 | + g_signal_connect (settings.get (), "update-titlebar-font", |
714 | + G_CALLBACK (GWDMockSettingsNotifiedGMock::updateTitlebarFontCb), this); |
715 | g_signal_connect (settings.get (), "update-metacity-theme", |
716 | G_CALLBACK (GWDMockSettingsNotifiedGMock::updateMetacityThemeCb), this); |
717 | g_signal_connect (settings.get (), "update-metacity-button-layout", |
718 | @@ -145,7 +145,7 @@ |
719 | } |
720 | |
721 | MOCK_METHOD0 (updateDecorations, void ()); |
722 | - MOCK_METHOD0 (updateFrames, void ()); |
723 | + MOCK_METHOD0 (updateTitlebarFont, void ()); |
724 | MOCK_METHOD0 (updateMetacityTheme, void ()); |
725 | MOCK_METHOD0 (updateMetacityButtonLayout, void ()); |
726 | |
727 | @@ -157,10 +157,10 @@ |
728 | gmock->updateDecorations (); |
729 | } |
730 | |
731 | - static void updateFramesCb (GWDSettings *settings, |
732 | - GWDMockSettingsNotifiedGMock *gmock) |
733 | + static void updateTitlebarFontCb (GWDSettings *settings, |
734 | + GWDMockSettingsNotifiedGMock *gmock) |
735 | { |
736 | - gmock->updateFrames (); |
737 | + gmock->updateTitlebarFont (); |
738 | } |
739 | |
740 | static void updateMetacityThemeCb (GWDSettings *settings, |
741 | @@ -206,7 +206,7 @@ |
742 | { |
743 | EXPECT_CALL (*mGMockNotified, updateMetacityTheme ()).Times (1); |
744 | EXPECT_CALL (*mGMockNotified, updateMetacityButtonLayout ()).Times (1); |
745 | - EXPECT_CALL (*mGMockNotified, updateFrames ()).Times (1); |
746 | + EXPECT_CALL (*mGMockNotified, updateTitlebarFont ()).Times (1); |
747 | EXPECT_CALL (*mGMockNotified, updateDecorations ()).Times (1); |
748 | |
749 | gwd_settings_thaw_updates (mSettings.get ()); |
750 | @@ -472,7 +472,7 @@ |
751 | |
752 | TEST_F(GWDSettingsTest, TestTitlebarFontChanged) |
753 | { |
754 | - EXPECT_CALL (*mGMockNotified, updateFrames ()); |
755 | + EXPECT_CALL (*mGMockNotified, updateTitlebarFont ()); |
756 | EXPECT_CALL (*mGMockNotified, updateDecorations ()); |
757 | EXPECT_TRUE (gwd_settings_font_changed (mSettings.get (), |
758 | testing_values::NO_USE_SYSTEM_FONT_VALUE, |
759 | @@ -486,7 +486,7 @@ |
760 | { |
761 | const gchar *titlebarFont = NULL; |
762 | |
763 | - EXPECT_CALL (*mGMockNotified, updateFrames ()); |
764 | + EXPECT_CALL (*mGMockNotified, updateTitlebarFont ()); |
765 | EXPECT_CALL (*mGMockNotified, updateDecorations ()); |
766 | EXPECT_TRUE (gwd_settings_font_changed (mSettings.get (), |
767 | testing_values::USE_SYSTEM_FONT_VALUE, |
768 | |
769 | === modified file 'gtk/window-decorator/wnck.c' |
770 | --- gtk/window-decorator/wnck.c 2016-05-26 21:20:20 +0000 |
771 | +++ gtk/window-decorator/wnck.c 2016-06-09 14:56:11 +0000 |
772 | @@ -182,26 +182,16 @@ |
773 | void |
774 | decorations_changed (WnckScreen *screen) |
775 | { |
776 | - GdkDisplay *gdkdisplay; |
777 | - GdkScreen *gdkscreen; |
778 | - GList *windows; |
779 | - Window select; |
780 | - |
781 | - gdkdisplay = gdk_display_get_default (); |
782 | - gdkscreen = gdk_display_get_default_screen (gdkdisplay); |
783 | - |
784 | - GWDSettings *settings = gwd_theme_get_settings (gwd_theme); |
785 | - const gchar *titlebar_font = gwd_settings_get_titlebar_font (settings); |
786 | - |
787 | - gwd_frames_foreach (set_frames_scales, (gpointer) titlebar_font); |
788 | - |
789 | - update_titlebar_font (); |
790 | - gwd_process_frames (update_frames_border_extents, |
791 | - window_type_frames, |
792 | - WINDOW_TYPE_FRAMES_NUM, |
793 | - NULL); |
794 | + GdkDisplay *display = gdk_display_get_default (); |
795 | + GdkScreen *gdkscreen = gdk_display_get_default_screen (display); |
796 | + GList *windows; |
797 | + Window select; |
798 | + |
799 | + gwd_frames_foreach (update_frames_titlebar_fonts, NULL); |
800 | + gwd_process_frames (update_frames_border_extents, window_type_frames, |
801 | + WINDOW_TYPE_FRAMES_NUM, NULL); |
802 | + |
803 | update_shadow (); |
804 | - |
805 | update_default_decorations (gdkscreen); |
806 | |
807 | if (minimal) |
This looks great to me!