Merge lp:~muktupavels/compiz/add-gwd-application-v3 into lp:compiz/0.9.12

Proposed by Alberts Muktupāvels
Status: Work in progress
Proposed branch: lp:~muktupavels/compiz/add-gwd-application-v3
Merge into: lp:compiz/0.9.12
Prerequisite: lp:~muktupavels/compiz/gwd-remove-2d
Diff against target: 838 lines (+360/-107)
14 files modified
gtk/window-decorator/CMakeLists.txt (+1/-0)
gtk/window-decorator/blurprops.c (+1/-1)
gtk/window-decorator/decorator.c (+1/-1)
gtk/window-decorator/events.c (+4/-4)
gtk/window-decorator/frames.c (+1/-1)
gtk/window-decorator/gtk-window-decorator.c (+5/-6)
gtk/window-decorator/gtk-window-decorator.h (+2/-0)
gtk/window-decorator/gwd-application.c (+149/-0)
gtk/window-decorator/gwd-application.h (+40/-0)
gtk/window-decorator/gwd-theme-cairo.c (+73/-1)
gtk/window-decorator/gwd-theme-metacity.c (+62/-14)
gtk/window-decorator/gwd-theme.c (+20/-74)
gtk/window-decorator/gwd-theme.h (+0/-4)
gtk/window-decorator/wnck.c (+1/-1)
To merge this branch: bzr merge lp:~muktupavels/compiz/add-gwd-application-v3
Reviewer Review Type Date Requested Status
Sam Spilsbury Needs Fixing
Review via email: mp+295921@code.launchpad.net

Commit message

gtk-window-decorator: add GWDApplication.

Description of the change

gtk-window-decorator: add GWDApplication.

To post a comment you must log in.
Revision history for this message
Sam Spilsbury (smspillaz) wrote :

See diff comments (use after free).

I don't quite understand the purpose of this abstraction either. Could you add a little more detail in the description of the change or the commit message explaining the need to create a GWDApplication? It seems to me like we just moved parts of GWDTheme over to it.

review: Needs Fixing
Revision history for this message
Alberts Muktupāvels (muktupavels) wrote :

> See diff comments (use after free).
>
> I don't quite understand the purpose of this abstraction either. Could you add
> a little more detail in the description of the change or the commit message
> explaining the need to create a GWDApplication? It seems to me like we just
> moved parts of GWDTheme over to it.

Will fix use after free and also update description when I will be back to my main pc. GWDSettings moved to GWDApplication is only small part.

It looks like there is no reason to create style window for each frame style - so I will create only one style window and GWDApplication will be good place to store/keep it.

Also GWDTheme probably can be moved to it like other global variables, for example, frame_table... I simply want keep merge proposals more or less simple so it is easier to review.

Unmerged revisions

4051. By Alberts Muktupāvels

Remove uneeded include.

4050. By Alberts Muktupāvels

Remove get_settings from GWDTheme.

4049. By Alberts Muktupāvels

Add GWDApplication.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'gtk/window-decorator/CMakeLists.txt'
--- gtk/window-decorator/CMakeLists.txt 2016-05-21 11:06:24 +0000
+++ gtk/window-decorator/CMakeLists.txt 2016-05-27 09:42:08 +0000
@@ -79,6 +79,7 @@
79 util.c79 util.c
80 wnck.c80 wnck.c
81 decorator.c81 decorator.c
82 ${CMAKE_CURRENT_SOURCE_DIR}/gwd-application.c
82 ${CMAKE_CURRENT_SOURCE_DIR}/gwd-settings-xproperty-storage.c83 ${CMAKE_CURRENT_SOURCE_DIR}/gwd-settings-xproperty-storage.c
83 ${CMAKE_CURRENT_SOURCE_DIR}/gwd-theme.c84 ${CMAKE_CURRENT_SOURCE_DIR}/gwd-theme.c
84 ${CMAKE_CURRENT_SOURCE_DIR}/gwd-theme-cairo.c85 ${CMAKE_CURRENT_SOURCE_DIR}/gwd-theme-cairo.c
8586
=== modified file 'gtk/window-decorator/blurprops.c'
--- gtk/window-decorator/blurprops.c 2016-05-21 16:08:47 +0000
+++ gtk/window-decorator/blurprops.c 2016-05-27 09:42:08 +0000
@@ -35,7 +35,7 @@
35 Region right_region,35 Region right_region,
36 int right_offset)36 int right_offset)
37{37{
38 GWDSettings *settings = gwd_theme_get_settings (gwd_theme);38 GWDSettings *settings = gwd_application_get_settings (application);
39 gint blur_type = gwd_settings_get_blur_type (settings);39 gint blur_type = gwd_settings_get_blur_type (settings);
40 Display *xdisplay = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());40 Display *xdisplay = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
41 long *data = NULL;41 long *data = NULL;
4242
=== modified file 'gtk/window-decorator/decorator.c'
--- gtk/window-decorator/decorator.c 2016-05-27 09:42:08 +0000
+++ gtk/window-decorator/decorator.c 2016-05-27 09:42:08 +0000
@@ -55,7 +55,7 @@
55static const PangoFontDescription *55static const PangoFontDescription *
56get_titlebar_font (decor_frame_t *frame)56get_titlebar_font (decor_frame_t *frame)
57{57{
58 GWDSettings *settings = gwd_theme_get_settings (gwd_theme);58 GWDSettings *settings = gwd_application_get_settings (application);
59 const gchar *titlebar_font = gwd_settings_get_titlebar_font (settings);59 const gchar *titlebar_font = gwd_settings_get_titlebar_font (settings);
6060
61 /* Using system font */61 /* Using system font */
6262
=== modified file 'gtk/window-decorator/events.c'
--- gtk/window-decorator/events.c 2016-05-27 09:42:08 +0000
+++ gtk/window-decorator/events.c 2016-05-27 09:42:08 +0000
@@ -109,7 +109,7 @@
109 int max,109 int max,
110 char *tooltip)110 char *tooltip)
111{111{
112 GWDSettings *settings = gwd_theme_get_settings (gwd_theme);112 GWDSettings *settings = gwd_application_get_settings (application);
113 gboolean use_tooltips = gwd_settings_get_use_tooltips (settings);113 gboolean use_tooltips = gwd_settings_get_use_tooltips (settings);
114 decor_t *d = g_object_get_data (G_OBJECT (win), "decor");114 decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
115 guint state = d->button_states[button];115 guint state = d->button_states[button];
@@ -448,7 +448,7 @@
448handle_mouse_wheel_title_event (WnckWindow *win,448handle_mouse_wheel_title_event (WnckWindow *win,
449 unsigned int button)449 unsigned int button)
450{450{
451 GWDSettings *settings = gwd_theme_get_settings (gwd_theme);451 GWDSettings *settings = gwd_application_get_settings (application);
452 gint wheel_action = gwd_settings_get_mouse_wheel_action (settings);452 gint wheel_action = gwd_settings_get_mouse_wheel_action (settings);
453453
454 switch (wheel_action) {454 switch (wheel_action) {
@@ -474,7 +474,7 @@
474 decor_event *gtkwd_event,474 decor_event *gtkwd_event,
475 decor_event_type gtkwd_type)475 decor_event_type gtkwd_type)
476{476{
477 GWDSettings *settings = gwd_theme_get_settings (gwd_theme);477 GWDSettings *settings = gwd_application_get_settings (application);
478 static Window last_button_xwindow = None;478 static Window last_button_xwindow = None;
479 static Time last_button_time = 0;479 static Time last_button_time = 0;
480 gint titlebar_action = 0;480 gint titlebar_action = 0;
@@ -541,7 +541,7 @@
541 decor_event *gtkwd_event,541 decor_event *gtkwd_event,
542 decor_event_type gtkwd_type)542 decor_event_type gtkwd_type)
543{543{
544 GWDSettings *settings = gwd_theme_get_settings (gwd_theme);544 GWDSettings *settings = gwd_application_get_settings (application);
545 gint titlebar_action = 0;545 gint titlebar_action = 0;
546546
547 if (gtkwd_type != GButtonPress)547 if (gtkwd_type != GButtonPress)
548548
=== modified file 'gtk/window-decorator/frames.c'
--- gtk/window-decorator/frames.c 2016-05-27 09:42:08 +0000
+++ gtk/window-decorator/frames.c 2016-05-27 09:42:08 +0000
@@ -264,7 +264,7 @@
264void264void
265decor_frame_refresh (decor_frame_t *frame)265decor_frame_refresh (decor_frame_t *frame)
266{266{
267 GWDSettings *settings = gwd_theme_get_settings (gwd_theme);267 GWDSettings *settings = gwd_application_get_settings (application);
268 const gchar *titlebar_font = gwd_settings_get_titlebar_font (settings);268 const gchar *titlebar_font = gwd_settings_get_titlebar_font (settings);
269 decor_shadow_options_t active_o, inactive_o;269 decor_shadow_options_t active_o, inactive_o;
270 decor_shadow_info_t *info;270 decor_shadow_info_t *info;
271271
=== modified file 'gtk/window-decorator/gtk-window-decorator.c'
--- gtk/window-decorator/gtk-window-decorator.c 2016-05-27 09:42:08 +0000
+++ gtk/window-decorator/gtk-window-decorator.c 2016-05-27 09:42:08 +0000
@@ -26,6 +26,7 @@
26#include "gtk-window-decorator.h"26#include "gtk-window-decorator.h"
27#include "gwd-settings.h"27#include "gwd-settings.h"
2828
29GWDApplication *application;
29GWDTheme *gwd_theme;30GWDTheme *gwd_theme;
3031
31gdouble decoration_alpha = 0.5;32gdouble decoration_alpha = 0.5;
@@ -302,10 +303,8 @@
302303
303 initialize_decorations ();304 initialize_decorations ();
304305
305 settings = gwd_settings_new (option_blur_type, option_meta_theme);306 application = gwd_application_new (option_blur_type, option_meta_theme);
306307 settings = gwd_application_get_settings (application);
307 if (!settings)
308 return 1;
309308
310 g_signal_connect (settings, "update-decorations",309 g_signal_connect (settings, "update-decorations",
311 G_CALLBACK (update_decorations_cb), NULL);310 G_CALLBACK (update_decorations_cb), NULL);
@@ -334,7 +333,7 @@
334333
335 if (!create_tooltip_window ())334 if (!create_tooltip_window ())
336 {335 {
337 g_object_unref (settings);336 g_object_unref (application);
338337
339 fprintf (stderr, "%s, Couldn't create tooltip window\n", argv[0]);338 fprintf (stderr, "%s, Couldn't create tooltip window\n", argv[0]);
340 return 1;339 return 1;
@@ -418,7 +417,7 @@
418417
419 g_clear_object (&gwd_theme);418 g_clear_object (&gwd_theme);
420 fini_settings ();419 fini_settings ();
421 g_clear_object (&settings);420 g_clear_object (&application);
422421
423 return 0;422 return 0;
424}423}
425424
=== modified file 'gtk/window-decorator/gtk-window-decorator.h'
--- gtk/window-decorator/gtk-window-decorator.h 2016-05-27 09:42:08 +0000
+++ gtk/window-decorator/gtk-window-decorator.h 2016-05-27 09:42:08 +0000
@@ -63,6 +63,7 @@
63#define _(x) gettext (x)63#define _(x) gettext (x)
64#define N_(x) x64#define N_(x) x
6565
66#include "gwd-application.h"
66#include "gwd-theme.h"67#include "gwd-theme.h"
6768
68extern const unsigned short ICON_SPACE;69extern const unsigned short ICON_SPACE;
@@ -90,6 +91,7 @@
9091
91extern gboolean minimal;92extern gboolean minimal;
9293
94extern GWDApplication *application;
93extern GWDTheme *gwd_theme;95extern GWDTheme *gwd_theme;
9496
95extern gdouble decoration_alpha;97extern gdouble decoration_alpha;
9698
=== added file 'gtk/window-decorator/gwd-application.c'
--- gtk/window-decorator/gwd-application.c 1970-01-01 00:00:00 +0000
+++ gtk/window-decorator/gwd-application.c 2016-05-27 09:42:08 +0000
@@ -0,0 +1,149 @@
1/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4; tab-width: 4 -*- */
2
3/*
4 * Copyright (C) 2016 Alberts Muktupāvels
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#include "config.h"
21#include "gwd-application.h"
22
23struct _GWDApplication
24{
25 GObject parent;
26
27 gint blur_type;
28 gchar *metacity_theme;
29
30 GWDSettings *settings;
31};
32
33enum
34{
35 PROP_0,
36
37 PROP_BLUR_TYPE,
38 PROP_METACITY_THEME,
39
40 LAST_PROP
41};
42
43static GParamSpec *properties[LAST_PROP] = { NULL };
44
45G_DEFINE_TYPE (GWDApplication, gwd_application, G_TYPE_OBJECT)
46
47static void
48gwd_application_constructed (GObject *object)
49{
50 GWDApplication *application = GWD_APPLICATION (object);
51
52 G_OBJECT_CLASS (gwd_application_parent_class)->constructed (object);
53
54 application->settings = gwd_settings_new (application->blur_type,
55 application->metacity_theme);
56}
57
58static void
59gwd_application_dispose (GObject *object)
60{
61 GWDApplication *application = GWD_APPLICATION (object);
62
63 g_clear_object (&application->settings);
64
65 G_OBJECT_CLASS (gwd_application_parent_class)->dispose (object);
66}
67
68static void
69gwd_application_finalize (GObject *object)
70{
71 GWDApplication *application = GWD_APPLICATION (object);
72
73 g_clear_pointer (&application->metacity_theme, g_free);
74
75 G_OBJECT_CLASS (gwd_application_parent_class)->finalize (object);
76}
77
78static void
79gwd_application_set_property (GObject *object,
80 guint property_id,
81 const GValue *value,
82 GParamSpec *pspec)
83{
84 GWDApplication *application = GWD_APPLICATION (object);
85
86 switch (property_id) {
87 case PROP_BLUR_TYPE:
88 application->blur_type = g_value_get_int (value);
89 break;
90
91 case PROP_METACITY_THEME:
92 application->metacity_theme = g_value_dup_string (value);
93 break;
94
95 default:
96 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
97 break;
98 }
99}
100
101static void
102gwd_application_class_init (GWDApplicationClass *application_class)
103{
104 GObjectClass *object_class = G_OBJECT_CLASS (application_class);
105
106 object_class->constructed = gwd_application_constructed;
107 object_class->dispose = gwd_application_dispose;
108 object_class->finalize = gwd_application_finalize;
109 object_class->set_property = gwd_application_set_property;
110
111 properties[PROP_BLUR_TYPE] =
112 g_param_spec_int ("blur-type",
113 "Blur Type",
114 "Blur type",
115 BLUR_TYPE_UNSET, BLUR_TYPE_ALL, BLUR_TYPE_UNSET,
116 G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY |
117 G_PARAM_STATIC_STRINGS);
118
119 properties[PROP_METACITY_THEME] =
120 g_param_spec_string ("metacity-theme",
121 "Metacity Theme",
122 "Metacity Theme",
123 NULL,
124 G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY |
125 G_PARAM_STATIC_STRINGS);
126
127 g_object_class_install_properties (object_class, LAST_PROP, properties);
128}
129
130static void
131gwd_application_init (GWDApplication *application)
132{
133}
134
135GWDApplication *
136gwd_application_new (gint blur_type,
137 const gchar *metacity_theme)
138{
139 return g_object_new (GWD_TYPE_APPLICATION,
140 "blur-type", blur_type,
141 "metacity-theme", metacity_theme,
142 NULL);
143}
144
145GWDSettings *
146gwd_application_get_settings (GWDApplication *application)
147{
148 return application->settings;
149}
0150
=== added file 'gtk/window-decorator/gwd-application.h'
--- gtk/window-decorator/gwd-application.h 1970-01-01 00:00:00 +0000
+++ gtk/window-decorator/gwd-application.h 2016-05-27 09:42:08 +0000
@@ -0,0 +1,40 @@
1/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4; tab-width: 4 -*- */
2
3/*
4 * Copyright (C) 2016 Alberts Muktupāvels
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef GWD_APPLICATION_H
21#define GWD_APPLICATION_H
22
23#include "gwd-settings.h"
24
25G_BEGIN_DECLS
26
27#define GWD_TYPE_APPLICATION gwd_application_get_type ()
28G_DECLARE_FINAL_TYPE (GWDApplication, gwd_application,
29 GWD, APPLICATION, GObject)
30
31GWDApplication *
32gwd_application_new (gint blur_type,
33 const gchar *metacity_theme);
34
35GWDSettings *
36gwd_application_get_settings (GWDApplication *application);
37
38G_END_DECLS
39
40#endif
041
=== modified file 'gtk/window-decorator/gwd-theme-cairo.c'
--- gtk/window-decorator/gwd-theme-cairo.c 2016-05-27 09:42:08 +0000
+++ gtk/window-decorator/gwd-theme-cairo.c 2016-05-27 09:42:08 +0000
@@ -33,7 +33,18 @@
3333
34struct _GWDThemeCairo34struct _GWDThemeCairo
35{35{
36 GObject parent;36 GObject parent;
37
38 GWDSettings *settings;
39};
40
41enum
42{
43 PROP_0,
44
45 PROP_SETTINGS,
46
47 LAST_PROP
37};48};
3849
39G_DEFINE_TYPE (GWDThemeCairo, gwd_theme_cairo, GWD_TYPE_THEME)50G_DEFINE_TYPE (GWDThemeCairo, gwd_theme_cairo, GWD_TYPE_THEME)
@@ -230,6 +241,52 @@
230}241}
231242
232static void243static void
244gwd_theme_cairo_dispose (GObject *object)
245{
246 GWDThemeCairo *cairo = GWD_THEME_CAIRO (object);
247
248 g_clear_object (&cairo->settings);
249
250 G_OBJECT_CLASS (gwd_theme_cairo_parent_class)->dispose (object);
251}
252
253static void
254gwd_theme_cairo_set_property (GObject *object,
255 guint property_id,
256 const GValue *value,
257 GParamSpec *pspec)
258{
259 GWDThemeCairo *cairo = GWD_THEME_CAIRO (object);
260
261 switch (property_id) {
262 case PROP_SETTINGS:
263 cairo->settings = g_value_dup_object (value);
264 break;
265
266 default:
267 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
268 break;
269 }
270}
271
272static void
273gwd_theme_cairo_get_shadow (GWDTheme *theme,
274 decor_frame_t *frame,
275 decor_shadow_options_t *options,
276 gboolean active)
277{
278 GWDThemeCairo *cairo = GWD_THEME_CAIRO (theme);
279 decor_shadow_options_t shadow;
280
281 if (active)
282 shadow = gwd_settings_get_active_shadow (cairo->settings);
283 else
284 shadow = gwd_settings_get_inactive_shadow (cairo->settings);
285
286 memcpy (options, &shadow, sizeof (decor_shadow_options_t));
287}
288
289static void
233gwd_theme_cairo_draw_window_decoration (GWDTheme *theme,290gwd_theme_cairo_draw_window_decoration (GWDTheme *theme,
234 decor_t *decor)291 decor_t *decor)
235{292{
@@ -750,16 +807,31 @@
750 return TRUE;807 return TRUE;
751}808}
752809
810static gfloat
811gwd_theme_cairo_get_title_scale (GWDTheme *theme,
812 decor_frame_t *frame)
813{
814 return 1.0;
815}
816
753static void817static void
754gwd_theme_cairo_class_init (GWDThemeCairoClass *cairo_class)818gwd_theme_cairo_class_init (GWDThemeCairoClass *cairo_class)
755{819{
820 GObjectClass *object_class = G_OBJECT_CLASS (cairo_class);
756 GWDThemeClass *theme_class = GWD_THEME_CLASS (cairo_class);821 GWDThemeClass *theme_class = GWD_THEME_CLASS (cairo_class);
757822
823 object_class->dispose = gwd_theme_cairo_dispose;
824 object_class->set_property = gwd_theme_cairo_set_property;
825
826 theme_class->get_shadow = gwd_theme_cairo_get_shadow;
758 theme_class->draw_window_decoration = gwd_theme_cairo_draw_window_decoration;827 theme_class->draw_window_decoration = gwd_theme_cairo_draw_window_decoration;
759 theme_class->calc_decoration_size = gwd_theme_cairo_calc_decoration_size;828 theme_class->calc_decoration_size = gwd_theme_cairo_calc_decoration_size;
760 theme_class->update_border_extents = gwd_theme_cairo_update_border_extents;829 theme_class->update_border_extents = gwd_theme_cairo_update_border_extents;
761 theme_class->get_event_window_position = gwd_theme_cairo_get_event_window_position;830 theme_class->get_event_window_position = gwd_theme_cairo_get_event_window_position;
762 theme_class->get_button_position = gwd_theme_cairo_get_button_position;831 theme_class->get_button_position = gwd_theme_cairo_get_button_position;
832 theme_class->get_title_scale = gwd_theme_cairo_get_title_scale;
833
834 g_object_class_override_property (object_class, PROP_SETTINGS, "settings");
763}835}
764836
765static void837static void
766838
=== modified file 'gtk/window-decorator/gwd-theme-metacity.c'
--- gtk/window-decorator/gwd-theme-metacity.c 2016-05-27 09:42:08 +0000
+++ gtk/window-decorator/gwd-theme-metacity.c 2016-05-27 09:42:08 +0000
@@ -37,12 +37,23 @@
37{37{
38 GObject parent;38 GObject parent;
3939
40 GWDSettings *settings;
41
40 MetaTheme *theme;42 MetaTheme *theme;
4143
42 gulong button_layout_id;44 gulong button_layout_id;
43 MetaButtonLayout button_layout;45 MetaButtonLayout button_layout;
44};46};
4547
48enum
49{
50 PROP_0,
51
52 PROP_SETTINGS,
53
54 LAST_PROP
55};
56
46G_DEFINE_TYPE (GWDThemeMetacity, gwd_theme_metacity, GWD_TYPE_THEME)57G_DEFINE_TYPE (GWDThemeMetacity, gwd_theme_metacity, GWD_TYPE_THEME)
4758
48static void59static void
@@ -857,8 +868,7 @@
857static gboolean868static gboolean
858setup_theme (GWDThemeMetacity *metacity)869setup_theme (GWDThemeMetacity *metacity)
859{870{
860 GWDSettings *settings = gwd_theme_get_settings (GWD_THEME (metacity));871 const gchar *metacity_theme = gwd_settings_get_metacity_theme (metacity->settings);
861 const gchar *metacity_theme = gwd_settings_get_metacity_theme (settings);
862 MetaTheme *theme;872 MetaTheme *theme;
863873
864 /* metacity_theme can be NULL only in one case - if user has disabled874 /* metacity_theme can be NULL only in one case - if user has disabled
@@ -890,14 +900,13 @@
890static void900static void
891setup_button_layout (GWDThemeMetacity *metacity)901setup_button_layout (GWDThemeMetacity *metacity)
892{902{
893 GWDSettings *settings = gwd_theme_get_settings (GWD_THEME (metacity));903 const gchar *button_layout = gwd_settings_get_metacity_button_layout (metacity->settings);
894 const gchar *button_layout = gwd_settings_get_metacity_button_layout (settings);
895904
896 metacity->button_layout_id =905 metacity->button_layout_id =
897 g_signal_connect (settings, "update-metacity-button-layout",906 g_signal_connect (metacity->settings, "update-metacity-button-layout",
898 G_CALLBACK (update_metacity_button_layout_cb), metacity);907 G_CALLBACK (update_metacity_button_layout_cb), metacity);
899908
900 update_metacity_button_layout_cb (settings, button_layout, metacity);909 update_metacity_button_layout_cb (metacity->settings, button_layout, metacity);
901}910}
902911
903static void912static void
@@ -918,10 +927,10 @@
918{927{
919 GWDThemeMetacity *metacity = GWD_THEME_METACITY (object);928 GWDThemeMetacity *metacity = GWD_THEME_METACITY (object);
920929
930 g_clear_object (&metacity->settings);
931
921 if (metacity->button_layout_id != 0) {932 if (metacity->button_layout_id != 0) {
922 GWDSettings *settings = gwd_theme_get_settings (GWD_THEME (metacity));933 g_signal_handler_disconnect (metacity->settings, metacity->button_layout_id);
923
924 g_signal_handler_disconnect (settings, metacity->button_layout_id);
925 metacity->button_layout_id = 0;934 metacity->button_layout_id = 0;
926 }935 }
927936
@@ -929,11 +938,46 @@
929}938}
930939
931static void940static void
941gwd_theme_metacity_set_property (GObject *object,
942 guint property_id,
943 const GValue *value,
944 GParamSpec *pspec)
945{
946 GWDThemeMetacity *metacity = GWD_THEME_METACITY (object);
947
948 switch (property_id) {
949 case PROP_SETTINGS:
950 metacity->settings = g_value_dup_object (value);
951 break;
952
953 default:
954 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
955 break;
956 }
957}
958
959static void
960gwd_theme_metacity_get_shadow (GWDTheme *theme,
961 decor_frame_t *frame,
962 decor_shadow_options_t *options,
963 gboolean active)
964{
965 GWDThemeMetacity *metacity = GWD_THEME_METACITY (theme);
966 decor_shadow_options_t shadow;
967
968 if (active)
969 shadow = gwd_settings_get_active_shadow (metacity->settings);
970 else
971 shadow = gwd_settings_get_inactive_shadow (metacity->settings);
972
973 memcpy (options, &shadow, sizeof (decor_shadow_options_t));
974}
975
976static void
932gwd_theme_metacity_draw_window_decoration (GWDTheme *theme,977gwd_theme_metacity_draw_window_decoration (GWDTheme *theme,
933 decor_t *decor)978 decor_t *decor)
934{979{
935 GWDThemeMetacity *metacity = GWD_THEME_METACITY (theme);980 GWDThemeMetacity *metacity = GWD_THEME_METACITY (theme);
936 GWDSettings *settings = gwd_theme_get_settings (gwd_theme);
937 GdkDisplay *display;981 GdkDisplay *display;
938 GdkScreen *screen;982 GdkScreen *screen;
939 Display *xdisplay;983 Display *xdisplay;
@@ -969,11 +1013,11 @@
969 right_region = NULL;1013 right_region = NULL;
9701014
971 if (decor->active) {1015 if (decor->active) {
972 alpha = gwd_settings_get_metacity_active_opacity (settings);1016 alpha = gwd_settings_get_metacity_active_opacity (metacity->settings);
973 shade_alpha = gwd_settings_get_metacity_active_shade_opacity (settings);1017 shade_alpha = gwd_settings_get_metacity_active_shade_opacity (metacity->settings);
974 } else {1018 } else {
975 alpha = gwd_settings_get_metacity_inactive_opacity (settings);1019 alpha = gwd_settings_get_metacity_inactive_opacity (metacity->settings);
976 shade_alpha = gwd_settings_get_metacity_inactive_shade_opacity (settings);1020 shade_alpha = gwd_settings_get_metacity_inactive_shade_opacity (metacity->settings);
977 }1021 }
9781022
979 if (decoration_alpha == 1.0)1023 if (decoration_alpha == 1.0)
@@ -1436,13 +1480,17 @@
14361480
1437 object_class->constructed = gwd_theme_metacity_constructed;1481 object_class->constructed = gwd_theme_metacity_constructed;
1438 object_class->dispose = gwd_theme_metacity_dispose;1482 object_class->dispose = gwd_theme_metacity_dispose;
1483 object_class->set_property = gwd_theme_metacity_set_property;
14391484
1485 theme_class->get_shadow = gwd_theme_metacity_get_shadow;
1440 theme_class->draw_window_decoration = gwd_theme_metacity_draw_window_decoration;1486 theme_class->draw_window_decoration = gwd_theme_metacity_draw_window_decoration;
1441 theme_class->calc_decoration_size = gwd_theme_metacity_calc_decoration_size;1487 theme_class->calc_decoration_size = gwd_theme_metacity_calc_decoration_size;
1442 theme_class->update_border_extents = gwd_theme_metacity_update_border_extents;1488 theme_class->update_border_extents = gwd_theme_metacity_update_border_extents;
1443 theme_class->get_event_window_position = gwd_theme_metacity_get_event_window_position;1489 theme_class->get_event_window_position = gwd_theme_metacity_get_event_window_position;
1444 theme_class->get_button_position = gwd_theme_metacity_get_button_position;1490 theme_class->get_button_position = gwd_theme_metacity_get_button_position;
1445 theme_class->get_title_scale = gwd_theme_metacity_get_title_scale;1491 theme_class->get_title_scale = gwd_theme_metacity_get_title_scale;
1492
1493 g_object_class_override_property (object_class, PROP_SETTINGS, "settings");
1446}1494}
14471495
1448static void1496static void
14491497
=== modified file 'gtk/window-decorator/gwd-theme.c'
--- gtk/window-decorator/gwd-theme.c 2016-05-26 13:33:24 +0000
+++ gtk/window-decorator/gwd-theme.c 2016-05-27 09:42:08 +0000
@@ -26,11 +26,6 @@
26#include "gwd-theme-metacity.h"26#include "gwd-theme-metacity.h"
27#endif27#endif
2828
29typedef struct
30{
31 GWDSettings *settings;
32} GWDThemePrivate;
33
34enum29enum
35{30{
36 PROP_0,31 PROP_0,
@@ -42,44 +37,7 @@
4237
43static GParamSpec *properties[LAST_PROP] = { NULL };38static GParamSpec *properties[LAST_PROP] = { NULL };
4439
45G_DEFINE_TYPE_WITH_PRIVATE (GWDTheme, gwd_theme, G_TYPE_OBJECT)40G_DEFINE_TYPE (GWDTheme, gwd_theme, G_TYPE_OBJECT)
46
47static void
48gwd_theme_dispose (GObject *object)
49{
50 GWDTheme *theme;
51 GWDThemePrivate *priv;
52
53 theme = GWD_THEME (object);
54 priv = gwd_theme_get_instance_private (theme);
55
56 g_clear_object (&priv->settings);
57
58 G_OBJECT_CLASS (gwd_theme_parent_class)->dispose (object);
59}
60
61static void
62gwd_theme_get_property (GObject *object,
63 guint property_id,
64 GValue *value,
65 GParamSpec *pspec)
66{
67 GWDTheme *theme;
68 GWDThemePrivate *priv;
69
70 theme = GWD_THEME (object);
71 priv = gwd_theme_get_instance_private (theme);
72
73 switch (property_id) {
74 case PROP_SETTINGS:
75 g_value_set_object (value, priv->settings);
76 break;
77
78 default:
79 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
80 break;
81 }
82}
8341
84static void42static void
85gwd_theme_set_property (GObject *object,43gwd_theme_set_property (GObject *object,
@@ -87,15 +45,8 @@
87 const GValue *value,45 const GValue *value,
88 GParamSpec *pspec)46 GParamSpec *pspec)
89{47{
90 GWDTheme *theme;
91 GWDThemePrivate *priv;
92
93 theme = GWD_THEME (object);
94 priv = gwd_theme_get_instance_private (theme);
95
96 switch (property_id) {48 switch (property_id) {
97 case PROP_SETTINGS:49 case PROP_SETTINGS:
98 priv->settings = g_value_dup_object (value);
99 break;50 break;
10051
101 default:52 default:
@@ -110,23 +61,17 @@
110 decor_shadow_options_t *options,61 decor_shadow_options_t *options,
111 gboolean active)62 gboolean active)
112{63{
113 GWDThemePrivate *priv;64 g_critical ("GWDThemeClass::get_shadow not implemented for '%s'",
114 decor_shadow_options_t shadow;65 g_type_name (G_TYPE_FROM_INSTANCE (theme)));
115
116 priv = gwd_theme_get_instance_private (theme);
117
118 if (active)
119 shadow = gwd_settings_get_active_shadow (priv->settings);
120 else
121 shadow = gwd_settings_get_inactive_shadow (priv->settings);
122
123 memcpy (options, &shadow, sizeof (decor_shadow_options_t));
124}66}
12567
126static void68static void
127gwd_theme_real_draw_window_decoration (GWDTheme *theme,69gwd_theme_real_draw_window_decoration (GWDTheme *theme,
128 decor_t *decor)70 decor_t *decor)
129{71{
72 g_critical ("GWDThemeClass::draw_window_decoration not implemented for '%s'",
73 g_type_name (G_TYPE_FROM_INSTANCE (theme)));
74
130}75}
13176
132static gboolean77static gboolean
@@ -138,6 +83,9 @@
138 gint *width,83 gint *width,
139 gint *height)84 gint *height)
140{85{
86 g_critical ("GWDThemeClass::calc_decoration_size not implemented for '%s'",
87 g_type_name (G_TYPE_FROM_INSTANCE (theme)));
88
141 return FALSE;89 return FALSE;
142}90}
14391
@@ -145,6 +93,8 @@
145gwd_theme_real_update_border_extents (GWDTheme *theme,93gwd_theme_real_update_border_extents (GWDTheme *theme,
146 decor_frame_t *frame)94 decor_frame_t *frame)
147{95{
96 g_critical ("GWDThemeClass::update_border_extents not implemented for '%s'",
97 g_type_name (G_TYPE_FROM_INSTANCE (theme)));
148}98}
14999
150static void100static void
@@ -159,6 +109,8 @@
159 gint *w,109 gint *w,
160 gint *h)110 gint *h)
161{111{
112 g_critical ("GWDThemeClass::get_event_window_position not implemented for '%s'",
113 g_type_name (G_TYPE_FROM_INSTANCE (theme)));
162}114}
163115
164static gboolean116static gboolean
@@ -172,6 +124,9 @@
172 gint *w,124 gint *w,
173 gint *h)125 gint *h)
174{126{
127 g_critical ("GWDThemeClass::get_button_position not implemented for '%s'",
128 g_type_name (G_TYPE_FROM_INSTANCE (theme)));
129
175 return FALSE;130 return FALSE;
176}131}
177132
@@ -179,6 +134,9 @@
179gwd_theme_real_get_title_scale (GWDTheme *theme,134gwd_theme_real_get_title_scale (GWDTheme *theme,
180 decor_frame_t *frame)135 decor_frame_t *frame)
181{136{
137 g_critical ("GWDThemeClass::get_title_scale not implemented for '%s'",
138 g_type_name (G_TYPE_FROM_INSTANCE (theme)));
139
182 return 1.0;140 return 1.0;
183}141}
184142
@@ -189,8 +147,6 @@
189147
190 object_class = G_OBJECT_CLASS (theme_class);148 object_class = G_OBJECT_CLASS (theme_class);
191149
192 object_class->dispose = gwd_theme_dispose;
193 object_class->get_property = gwd_theme_get_property;
194 object_class->set_property = gwd_theme_set_property;150 object_class->set_property = gwd_theme_set_property;
195151
196 theme_class->get_shadow = gwd_theme_real_get_shadow;152 theme_class->get_shadow = gwd_theme_real_get_shadow;
@@ -204,7 +160,7 @@
204 properties[PROP_SETTINGS] =160 properties[PROP_SETTINGS] =
205 g_param_spec_object ("settings", "GWDSettings", "GWDSettings",161 g_param_spec_object ("settings", "GWDSettings", "GWDSettings",
206 GWD_TYPE_SETTINGS,162 GWD_TYPE_SETTINGS,
207 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |163 G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY |
208 G_PARAM_STATIC_STRINGS);164 G_PARAM_STATIC_STRINGS);
209165
210 g_object_class_install_properties (object_class, LAST_PROP, properties);166 g_object_class_install_properties (object_class, LAST_PROP, properties);
@@ -248,16 +204,6 @@
248 NULL);204 NULL);
249}205}
250206
251GWDSettings *
252gwd_theme_get_settings (GWDTheme *theme)
253{
254 GWDThemePrivate *priv;
255
256 priv = gwd_theme_get_instance_private (theme);
257
258 return priv->settings;
259}
260
261void207void
262gwd_theme_get_shadow (GWDTheme *theme,208gwd_theme_get_shadow (GWDTheme *theme,
263 decor_frame_t *frame,209 decor_frame_t *frame,
264210
=== modified file 'gtk/window-decorator/gwd-theme.h'
--- gtk/window-decorator/gwd-theme.h 2016-05-20 11:56:36 +0000
+++ gtk/window-decorator/gwd-theme.h 2016-05-27 09:42:08 +0000
@@ -27,7 +27,6 @@
2727
28typedef struct _decor decor_t;28typedef struct _decor decor_t;
29typedef struct _decor_frame decor_frame_t;29typedef struct _decor_frame decor_frame_t;
30typedef struct _GWDSettings GWDSettings;
3130
32#define GWD_TYPE_THEME gwd_theme_get_type ()31#define GWD_TYPE_THEME gwd_theme_get_type ()
33G_DECLARE_DERIVABLE_TYPE (GWDTheme, gwd_theme, GWD, THEME, GObject)32G_DECLARE_DERIVABLE_TYPE (GWDTheme, gwd_theme, GWD, THEME, GObject)
@@ -90,9 +89,6 @@
90gwd_theme_new (GWDThemeType type,89gwd_theme_new (GWDThemeType type,
91 GWDSettings *settings);90 GWDSettings *settings);
9291
93GWDSettings *
94gwd_theme_get_settings (GWDTheme *theme);
95
96void92void
97gwd_theme_get_shadow (GWDTheme *theme,93gwd_theme_get_shadow (GWDTheme *theme,
98 decor_frame_t *frame,94 decor_frame_t *frame,
9995
=== modified file 'gtk/window-decorator/wnck.c'
--- gtk/window-decorator/wnck.c 2016-05-27 09:42:08 +0000
+++ gtk/window-decorator/wnck.c 2016-05-27 09:42:08 +0000
@@ -190,7 +190,7 @@
190 gdkdisplay = gdk_display_get_default ();190 gdkdisplay = gdk_display_get_default ();
191 gdkscreen = gdk_display_get_default_screen (gdkdisplay);191 gdkscreen = gdk_display_get_default_screen (gdkdisplay);
192192
193 GWDSettings *settings = gwd_theme_get_settings (gwd_theme);193 GWDSettings *settings = gwd_application_get_settings (application);
194 const gchar *titlebar_font = gwd_settings_get_titlebar_font (settings);194 const gchar *titlebar_font = gwd_settings_get_titlebar_font (settings);
195195
196 gwd_frames_foreach (set_frames_scales, (gpointer) titlebar_font);196 gwd_frames_foreach (set_frames_scales, (gpointer) titlebar_font);

Subscribers

People subscribed via source and target branches