Merge lp:~gordallott/libunity-misc/port-to-gdk3-gtk3 into lp:libunity-misc
- port-to-gdk3-gtk3
- Merge into trunk
Proposed by
Gord Allott
Status: | Merged |
---|---|
Merge reported by: | Neil J. Patel |
Merged at revision: | not available |
Proposed branch: | lp:~gordallott/libunity-misc/port-to-gdk3-gtk3 |
Merge into: | lp:libunity-misc |
Diff against target: |
1303 lines (+438/-262) 10 files modified
configure.ac (+3/-3) examples/Makefile.am (+4/-4) gtk-doc.make (+39/-20) unity-misc/fixedtip.c (+30/-17) unity-misc/na-tray-child.c (+39/-48) unity-misc/na-tray-child.h (+1/-1) unity-misc/na-tray-manager.c (+218/-87) unity-misc/na-tray-manager.h (+17/-0) unity-misc/na-tray.c (+76/-72) unity-misc/na-tray.h (+11/-10) |
To merge this branch: | bzr merge lp:~gordallott/libunity-misc/port-to-gdk3-gtk3 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Neil J. Patel (community) | Approve | ||
Review via email: mp+64820@code.launchpad.net |
Commit message
Description of the change
imports from the gnome-panel notification applet for the tray stuff to push us up to gtk/gdk3
To post a comment you must log in.
Revision history for this message
Neil J. Patel (njpatel) : | # |
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'configure.ac' | |||
2 | --- configure.ac 2011-02-17 17:42:41 +0000 | |||
3 | +++ configure.ac 2011-06-16 13:19:23 +0000 | |||
4 | @@ -68,9 +68,9 @@ | |||
5 | 68 | PKG_CHECK_MODULES(UNITY_MISC, | 68 | PKG_CHECK_MODULES(UNITY_MISC, |
6 | 69 | glib-2.0 >= 2.22 | 69 | glib-2.0 >= 2.22 |
7 | 70 | gobject-2.0 >= 2.22 | 70 | gobject-2.0 >= 2.22 |
11 | 71 | gdk-x11-2.0 >= 2.18 | 71 | gdk-x11-3.0 >= 3.0 |
12 | 72 | gtk+-2.0 >= 2.18 | 72 | gtk+-3.0 >= 3.0 |
13 | 73 | gtk+-x11-2.0 >= 2.18 | 73 | gtk+-x11-3.0 >= 3.0 |
14 | 74 | ) | 74 | ) |
15 | 75 | AC_SUBST(UNITY_MISC_CFLAGS) | 75 | AC_SUBST(UNITY_MISC_CFLAGS) |
16 | 76 | AC_SUBST(UNITY_MISC_LIBS) | 76 | AC_SUBST(UNITY_MISC_LIBS) |
17 | 77 | 77 | ||
18 | === modified file 'examples/Makefile.am' | |||
19 | --- examples/Makefile.am 2011-02-13 16:15:41 +0000 | |||
20 | +++ examples/Makefile.am 2011-06-16 13:19:23 +0000 | |||
21 | @@ -1,5 +1,5 @@ | |||
24 | 1 | noinst_PROGRAMS = \ | 1 | #noinst_PROGRAMS = \ |
25 | 2 | systray | 2 | # systray |
26 | 3 | 3 | ||
27 | 4 | AM_CPPFLAGS = \ | 4 | AM_CPPFLAGS = \ |
28 | 5 | -I$(top_srcdir) \ | 5 | -I$(top_srcdir) \ |
29 | @@ -8,5 +8,5 @@ | |||
30 | 8 | $(UNITY_MISC_CFLAGS) \ | 8 | $(UNITY_MISC_CFLAGS) \ |
31 | 9 | $(MAINTAINER_CFLAGS) | 9 | $(MAINTAINER_CFLAGS) |
32 | 10 | 10 | ||
35 | 11 | systray_SOURCES = systray.c | 11 | #systray_SOURCES = systray.c |
36 | 12 | systray_LDADD = $(top_builddir)/unity-misc/libunity-misc.la $(UNITY_MISC_LIBS) | 12 | #systray_LDADD = $(top_builddir)/unity-misc/libunity-misc.la $(UNITY_MISC_LIBS) |
37 | 13 | 13 | ||
38 | === modified file 'gtk-doc.make' | |||
39 | --- gtk-doc.make 2011-02-13 16:15:41 +0000 | |||
40 | +++ gtk-doc.make 2011-06-16 13:19:23 +0000 | |||
41 | @@ -23,13 +23,15 @@ | |||
42 | 23 | 23 | ||
43 | 24 | TARGET_DIR=$(HTML_DIR)/$(DOC_MODULE) | 24 | TARGET_DIR=$(HTML_DIR)/$(DOC_MODULE) |
44 | 25 | 25 | ||
46 | 26 | EXTRA_DIST = \ | 26 | SETUP_FILES = \ |
47 | 27 | $(content_files) \ | 27 | $(content_files) \ |
48 | 28 | $(HTML_IMAGES) \ | ||
49 | 29 | $(DOC_MAIN_SGML_FILE) \ | 28 | $(DOC_MAIN_SGML_FILE) \ |
50 | 30 | $(DOC_MODULE)-sections.txt \ | 29 | $(DOC_MODULE)-sections.txt \ |
51 | 31 | $(DOC_MODULE)-overrides.txt | 30 | $(DOC_MODULE)-overrides.txt |
52 | 32 | 31 | ||
53 | 32 | EXTRA_DIST = \ | ||
54 | 33 | $(SETUP_FILES) | ||
55 | 34 | |||
56 | 33 | DOC_STAMPS=setup-build.stamp scan-build.stamp tmpl-build.stamp sgml-build.stamp \ | 35 | DOC_STAMPS=setup-build.stamp scan-build.stamp tmpl-build.stamp sgml-build.stamp \ |
57 | 34 | html-build.stamp pdf-build.stamp \ | 36 | html-build.stamp pdf-build.stamp \ |
58 | 35 | setup.stamp tmpl.stamp sgml.stamp html.stamp pdf.stamp | 37 | setup.stamp tmpl.stamp sgml.stamp html.stamp pdf.stamp |
59 | @@ -71,17 +73,20 @@ | |||
60 | 71 | 73 | ||
61 | 72 | #### setup #### | 74 | #### setup #### |
62 | 73 | 75 | ||
64 | 74 | setup-build.stamp:: | 76 | setup-build.stamp: |
65 | 75 | -@if test "$(abs_srcdir)" != "$(abs_builddir)" ; then \ | 77 | -@if test "$(abs_srcdir)" != "$(abs_builddir)" ; then \ |
72 | 76 | cp -a $(abs_srcdir)/$(DOC_MAIN_SGML_FILE) $(abs_builddir)/; \ | 78 | echo 'gtk-doc: Preparing build'; \ |
73 | 77 | cp -a $(abs_srcdir)/$(DOC_MODULE)* $(abs_builddir)/; \ | 79 | files=`echo $(SETUP_FILES) $(expand_content_files) $(DOC_MODULE).types`; \ |
74 | 78 | if test "x$(content_files)" != "x" ; then \ | 80 | if test "x$$files" != "x" ; then \ |
75 | 79 | for file in $(content_files) ; do \ | 81 | for file in $$files ; do \ |
76 | 80 | test -f $(abs_srcdir)/$$file || \ | 82 | test -f $(abs_srcdir)/$$file && \ |
77 | 81 | cp -a $(abs_srcdir)/$$file $(abs_builddir)/; \ | 83 | cp -p $(abs_srcdir)/$$file $(abs_builddir)/; \ |
78 | 82 | done \ | 84 | done \ |
80 | 83 | fi \ | 85 | fi; \ |
81 | 86 | test -f $(abs_srcdir)/tmpl && \ | ||
82 | 87 | cp -rp $(abs_srcdir)/tmpl $(abs_builddir)/; \ | ||
83 | 84 | fi | 88 | fi |
84 | 89 | @touch setup-build.stamp | ||
85 | 85 | 90 | ||
86 | 86 | 91 | ||
87 | 87 | setup.stamp: setup-build.stamp | 92 | setup.stamp: setup-build.stamp |
88 | @@ -92,7 +97,7 @@ | |||
89 | 92 | 97 | ||
90 | 93 | scan-build.stamp: $(HFILE_GLOB) $(CFILE_GLOB) | 98 | scan-build.stamp: $(HFILE_GLOB) $(CFILE_GLOB) |
91 | 94 | @echo 'gtk-doc: Scanning header files' | 99 | @echo 'gtk-doc: Scanning header files' |
93 | 95 | @_source_dir='' ; | 100 | @_source_dir='' ; \ |
94 | 96 | for i in $(DOC_SOURCE_DIR) ; do \ | 101 | for i in $(DOC_SOURCE_DIR) ; do \ |
95 | 97 | _source_dir="$${_source_dir} --source-dir=$$i" ; \ | 102 | _source_dir="$${_source_dir} --source-dir=$$i" ; \ |
96 | 98 | done ; \ | 103 | done ; \ |
97 | @@ -111,9 +116,14 @@ | |||
98 | 111 | 116 | ||
99 | 112 | #### templates #### | 117 | #### templates #### |
100 | 113 | 118 | ||
102 | 114 | tmpl-build.stamp: $(DOC_MODULE)-decl.txt $(SCANOBJ_FILES) $(DOC_MODULE)-sections.txt $(DOC_MODULE)-overrides.txt | 119 | tmpl-build.stamp: setup.stamp $(DOC_MODULE)-decl.txt $(SCANOBJ_FILES) $(DOC_MODULE)-sections.txt $(DOC_MODULE)-overrides.txt |
103 | 115 | @echo 'gtk-doc: Rebuilding template files' | 120 | @echo 'gtk-doc: Rebuilding template files' |
104 | 116 | @gtkdoc-mktmpl --module=$(DOC_MODULE) $(MKTMPL_OPTIONS) | 121 | @gtkdoc-mktmpl --module=$(DOC_MODULE) $(MKTMPL_OPTIONS) |
105 | 122 | @if test "$(abs_srcdir)" != "$(abs_builddir)" ; then \ | ||
106 | 123 | if test -w $(abs_srcdir) ; then \ | ||
107 | 124 | cp -rp $(abs_builddir)/tmpl $(abs_srcdir)/; \ | ||
108 | 125 | fi \ | ||
109 | 126 | fi | ||
110 | 117 | @touch tmpl-build.stamp | 127 | @touch tmpl-build.stamp |
111 | 118 | 128 | ||
112 | 119 | tmpl.stamp: tmpl-build.stamp | 129 | tmpl.stamp: tmpl-build.stamp |
113 | @@ -149,7 +159,15 @@ | |||
114 | 149 | mkhtml_options=--path="$(abs_srcdir)"; \ | 159 | mkhtml_options=--path="$(abs_srcdir)"; \ |
115 | 150 | fi; \ | 160 | fi; \ |
116 | 151 | cd html && gtkdoc-mkhtml $$mkhtml_options $(MKHTML_OPTIONS) $(DOC_MODULE) ../$(DOC_MAIN_SGML_FILE) | 161 | cd html && gtkdoc-mkhtml $$mkhtml_options $(MKHTML_OPTIONS) $(DOC_MODULE) ../$(DOC_MAIN_SGML_FILE) |
118 | 152 | @test "x$(HTML_IMAGES)" = "x" || ( cd $(srcdir) && cp $(HTML_IMAGES) $(abs_builddir)/html ) | 162 | -@test "x$(HTML_IMAGES)" = "x" || \ |
119 | 163 | for file in $(HTML_IMAGES) ; do \ | ||
120 | 164 | if test -f $(abs_srcdir)/$$file ; then \ | ||
121 | 165 | cp $(abs_srcdir)/$$file $(abs_builddir)/html; \ | ||
122 | 166 | fi; \ | ||
123 | 167 | if test -f $(abs_builddir)/$$file ; then \ | ||
124 | 168 | cp $(abs_builddir)/$$file $(abs_builddir)/html; \ | ||
125 | 169 | fi; \ | ||
126 | 170 | done; | ||
127 | 153 | @echo 'gtk-doc: Fixing cross-references' | 171 | @echo 'gtk-doc: Fixing cross-references' |
128 | 154 | @gtkdoc-fixxref --module=$(DOC_MODULE) --module-dir=html --html-dir=$(HTML_DIR) $(FIXXREF_OPTIONS) | 172 | @gtkdoc-fixxref --module=$(DOC_MODULE) --module-dir=html --html-dir=$(HTML_DIR) $(FIXXREF_OPTIONS) |
129 | 155 | @touch html-build.stamp | 173 | @touch html-build.stamp |
130 | @@ -179,10 +197,11 @@ | |||
131 | 179 | rm -rf .libs | 197 | rm -rf .libs |
132 | 180 | 198 | ||
133 | 181 | distclean-local: | 199 | distclean-local: |
135 | 182 | rm -rf xml $(REPORT_FILES) $(DOC_MODULE).pdf \ | 200 | rm -rf xml html $(REPORT_FILES) $(DOC_MODULE).pdf \ |
136 | 183 | $(DOC_MODULE)-decl-list.txt $(DOC_MODULE)-decl.txt | 201 | $(DOC_MODULE)-decl-list.txt $(DOC_MODULE)-decl.txt |
137 | 184 | if test "$(abs_srcdir)" != "$(abs_builddir)" ; then \ | 202 | if test "$(abs_srcdir)" != "$(abs_builddir)" ; then \ |
139 | 185 | rm -f $(DOC_MAIN_SGML_FILE) $(DOC_MODULE)*; \ | 203 | rm -f $(SETUP_FILES) $(expand_content_files) $(DOC_MODULE).types; \ |
140 | 204 | rm -rf tmpl; \ | ||
141 | 186 | fi | 205 | fi |
142 | 187 | 206 | ||
143 | 188 | maintainer-clean-local: clean | 207 | maintainer-clean-local: clean |
144 | @@ -234,11 +253,11 @@ | |||
145 | 234 | dist-hook: dist-check-gtkdoc dist-hook-local | 253 | dist-hook: dist-check-gtkdoc dist-hook-local |
146 | 235 | mkdir $(distdir)/tmpl | 254 | mkdir $(distdir)/tmpl |
147 | 236 | mkdir $(distdir)/html | 255 | mkdir $(distdir)/html |
153 | 237 | -cp $(srcdir)/tmpl/*.sgml $(distdir)/tmpl | 256 | -cp $(build)/tmpl/*.sgml $(distdir)/tmpl |
154 | 238 | cp $(srcdir)/html/* $(distdir)/html | 257 | cp $(builddir)/html/* $(distdir)/html |
155 | 239 | -cp $(srcdir)/$(DOC_MODULE).pdf $(distdir)/ | 258 | -cp $(builddir)/$(DOC_MODULE).pdf $(distdir)/ |
156 | 240 | -cp $(srcdir)/$(DOC_MODULE).types $(distdir)/ | 259 | -cp $(build)/$(DOC_MODULE).types $(distdir)/ |
157 | 241 | -cp $(srcdir)/$(DOC_MODULE)-sections.txt $(distdir)/ | 260 | -cp $(build)/$(DOC_MODULE)-sections.txt $(distdir)/ |
158 | 242 | cd $(distdir) && rm -f $(DISTCLEANFILES) | 261 | cd $(distdir) && rm -f $(DISTCLEANFILES) |
159 | 243 | $(GTKDOC_REBASE) --online --relative --html-dir=$(distdir)/html | 262 | $(GTKDOC_REBASE) --online --relative --html-dir=$(distdir)/html |
160 | 244 | 263 | ||
161 | 245 | 264 | ||
162 | === modified file 'unity-misc/fixedtip.c' | |||
163 | --- unity-misc/fixedtip.c 2011-02-14 10:15:57 +0000 | |||
164 | +++ unity-misc/fixedtip.c 2011-06-16 13:19:23 +0000 | |||
165 | @@ -52,17 +52,29 @@ | |||
166 | 52 | } | 52 | } |
167 | 53 | 53 | ||
168 | 54 | static gboolean | 54 | static gboolean |
170 | 55 | expose_handler (GtkWidget *fixedtip) | 55 | na_fixed_tip_draw (GtkWidget *widget, cairo_t *cr) |
171 | 56 | { | 56 | { |
181 | 57 | GtkRequisition req; | 57 | GtkStyleContext *context; |
182 | 58 | 58 | GtkStateFlags state; | |
183 | 59 | gtk_widget_size_request (fixedtip, &req); | 59 | int width, height; |
184 | 60 | 60 | ||
185 | 61 | gtk_paint_flat_box (gtk_widget_get_style (fixedtip), | 61 | width = gtk_widget_get_allocated_width (widget); |
186 | 62 | gtk_widget_get_window (fixedtip), | 62 | height = gtk_widget_get_allocated_height (widget); |
187 | 63 | GTK_STATE_NORMAL, GTK_SHADOW_OUT, | 63 | |
188 | 64 | NULL, fixedtip, "tooltip", | 64 | state = gtk_widget_get_state_flags (widget); |
189 | 65 | 0, 0, req.width, req.height); | 65 | context = gtk_widget_get_style_context (widget); |
190 | 66 | gtk_style_context_save (context); | ||
191 | 67 | gtk_style_context_add_class (context, GTK_STYLE_CLASS_TOOLTIP); | ||
192 | 68 | gtk_style_context_set_state (context, state); | ||
193 | 69 | |||
194 | 70 | cairo_save (cr); | ||
195 | 71 | gtk_render_background (context, cr, | ||
196 | 72 | 0., 0., | ||
197 | 73 | (gdouble)width, | ||
198 | 74 | (gdouble)height); | ||
199 | 75 | cairo_restore (cr); | ||
200 | 76 | |||
201 | 77 | gtk_style_context_restore (context); | ||
202 | 66 | 78 | ||
203 | 67 | return FALSE; | 79 | return FALSE; |
204 | 68 | } | 80 | } |
205 | @@ -70,6 +82,10 @@ | |||
206 | 70 | static void | 82 | static void |
207 | 71 | na_fixed_tip_class_init (NaFixedTipClass *class) | 83 | na_fixed_tip_class_init (NaFixedTipClass *class) |
208 | 72 | { | 84 | { |
209 | 85 | GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class); | ||
210 | 86 | |||
211 | 87 | widget_class->draw = na_fixed_tip_draw; | ||
212 | 88 | |||
213 | 73 | fixedtip_signals[CLICKED] = | 89 | fixedtip_signals[CLICKED] = |
214 | 74 | g_signal_new ("clicked", | 90 | g_signal_new ("clicked", |
215 | 75 | G_OBJECT_CLASS_TYPE (class), | 91 | G_OBJECT_CLASS_TYPE (class), |
216 | @@ -106,11 +122,8 @@ | |||
217 | 106 | gtk_container_add (GTK_CONTAINER (fixedtip), label); | 122 | gtk_container_add (GTK_CONTAINER (fixedtip), label); |
218 | 107 | fixedtip->priv->label = label; | 123 | fixedtip->priv->label = label; |
219 | 108 | 124 | ||
220 | 109 | g_signal_connect (fixedtip, "expose_event", | ||
221 | 110 | G_CALLBACK (expose_handler), NULL); | ||
222 | 111 | |||
223 | 112 | gtk_widget_add_events (GTK_WIDGET (fixedtip), GDK_BUTTON_PRESS_MASK); | 125 | gtk_widget_add_events (GTK_WIDGET (fixedtip), GDK_BUTTON_PRESS_MASK); |
225 | 113 | 126 | ||
226 | 114 | g_signal_connect (fixedtip, "button_press_event", | 127 | g_signal_connect (fixedtip, "button_press_event", |
227 | 115 | G_CALLBACK (button_press_handler), NULL); | 128 | G_CALLBACK (button_press_handler), NULL); |
228 | 116 | 129 | ||
229 | @@ -135,11 +148,11 @@ | |||
230 | 135 | 148 | ||
231 | 136 | gtk_window_set_screen (GTK_WINDOW (fixedtip), screen); | 149 | gtk_window_set_screen (GTK_WINDOW (fixedtip), screen); |
232 | 137 | 150 | ||
234 | 138 | gtk_widget_size_request (GTK_WIDGET (fixedtip), &req); | 151 | gtk_widget_get_preferred_size (GTK_WIDGET (fixedtip), &req, NULL); |
235 | 139 | 152 | ||
236 | 140 | gdk_window_get_origin (parent_window, &root_x, &root_y); | 153 | gdk_window_get_origin (parent_window, &root_x, &root_y); |
239 | 141 | gdk_drawable_get_size (GDK_DRAWABLE (parent_window), | 154 | parent_width = gdk_window_get_width (parent_window); |
240 | 142 | &parent_width, &parent_height); | 155 | parent_height = gdk_window_get_height (parent_window); |
241 | 143 | 156 | ||
242 | 144 | screen_width = gdk_screen_get_width (screen); | 157 | screen_width = gdk_screen_get_width (screen); |
243 | 145 | screen_height = gdk_screen_get_height (screen); | 158 | screen_height = gdk_screen_get_height (screen); |
244 | 146 | 159 | ||
245 | === modified file 'unity-misc/na-tray-child.c' | |||
246 | --- unity-misc/na-tray-child.c 2011-02-14 10:15:57 +0000 | |||
247 | +++ unity-misc/na-tray-child.c 2011-06-16 13:19:23 +0000 | |||
248 | @@ -24,7 +24,6 @@ | |||
249 | 24 | 24 | ||
250 | 25 | #include "na-tray-child.h" | 25 | #include "na-tray-child.h" |
251 | 26 | 26 | ||
252 | 27 | #include <glib/gi18n.h> | ||
253 | 28 | #include <gdk/gdk.h> | 27 | #include <gdk/gdk.h> |
254 | 29 | #include <gdk/gdkx.h> | 28 | #include <gdk/gdkx.h> |
255 | 30 | #include <X11/Xatom.h> | 29 | #include <X11/Xatom.h> |
256 | @@ -54,17 +53,18 @@ | |||
257 | 54 | * extension. */ | 53 | * extension. */ |
258 | 55 | 54 | ||
259 | 56 | /* Set a transparent background */ | 55 | /* Set a transparent background */ |
262 | 57 | GdkColor transparent = { 0, 0, 0, 0 }; /* only pixel=0 matters */ | 56 | cairo_pattern_t *transparent = cairo_pattern_create_rgba (0, 0, 0, 0); |
263 | 58 | gdk_window_set_background (window, &transparent); | 57 | gdk_window_set_background_pattern (window, transparent); |
264 | 59 | gdk_window_set_composited (window, TRUE); | 58 | gdk_window_set_composited (window, TRUE); |
265 | 59 | cairo_pattern_destroy (transparent); | ||
266 | 60 | 60 | ||
267 | 61 | child->parent_relative_bg = FALSE; | 61 | child->parent_relative_bg = FALSE; |
268 | 62 | } | 62 | } |
270 | 63 | else if (visual == gdk_drawable_get_visual (GDK_DRAWABLE (gdk_window_get_parent (window)))) | 63 | else if (visual == gdk_window_get_visual (gdk_window_get_parent (window))) |
271 | 64 | { | 64 | { |
272 | 65 | /* Otherwise, if the visual matches the visual of the parent window, we | 65 | /* Otherwise, if the visual matches the visual of the parent window, we |
273 | 66 | * can use a parent-relative background and fake transparency. */ | 66 | * can use a parent-relative background and fake transparency. */ |
275 | 67 | gdk_window_set_back_pixmap (window, NULL, TRUE); | 67 | gdk_window_set_background_pattern (window, NULL); |
276 | 68 | 68 | ||
277 | 69 | child->parent_relative_bg = TRUE; | 69 | child->parent_relative_bg = TRUE; |
278 | 70 | } | 70 | } |
279 | @@ -172,32 +172,46 @@ | |||
280 | 172 | } | 172 | } |
281 | 173 | 173 | ||
282 | 174 | /* The plug window should completely occupy the area of the child, so we won't | 174 | /* The plug window should completely occupy the area of the child, so we won't |
285 | 175 | * get an expose event. But in case we do (the plug unmaps itself, say), this | 175 | * get a draw event. But in case we do (the plug unmaps itself, say), this |
286 | 176 | * expose handler draws with real or fake transparency. | 176 | * draw handler draws with real or fake transparency. |
287 | 177 | */ | 177 | */ |
288 | 178 | static gboolean | 178 | static gboolean |
291 | 179 | na_tray_child_expose_event (GtkWidget *widget, | 179 | na_tray_child_draw (GtkWidget *widget, |
292 | 180 | GdkEventExpose *event) | 180 | cairo_t *cr) |
293 | 181 | { | 181 | { |
294 | 182 | NaTrayChild *child = NA_TRAY_CHILD (widget); | 182 | NaTrayChild *child = NA_TRAY_CHILD (widget); |
295 | 183 | GdkWindow *window = gtk_widget_get_window (widget); | ||
296 | 184 | 183 | ||
297 | 185 | if (na_tray_child_has_alpha (child)) | 184 | if (na_tray_child_has_alpha (child)) |
298 | 186 | { | 185 | { |
299 | 187 | /* Clear to transparent */ | 186 | /* Clear to transparent */ |
300 | 188 | cairo_t *cr = gdk_cairo_create (window); | ||
301 | 189 | cairo_set_source_rgba (cr, 0, 0, 0, 0); | 187 | cairo_set_source_rgba (cr, 0, 0, 0, 0); |
302 | 190 | cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE); | 188 | cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE); |
306 | 191 | gdk_cairo_region (cr, event->region); | 189 | cairo_paint (cr); |
304 | 192 | cairo_fill (cr); | ||
305 | 193 | cairo_destroy (cr); | ||
307 | 194 | } | 190 | } |
308 | 195 | else if (child->parent_relative_bg) | 191 | else if (child->parent_relative_bg) |
309 | 196 | { | 192 | { |
314 | 197 | /* Clear to parent-relative pixmap */ | 193 | GdkWindow *window; |
315 | 198 | gdk_window_clear_area (window, | 194 | cairo_surface_t *target; |
316 | 199 | event->area.x, event->area.y, | 195 | GdkRectangle clip_rect; |
317 | 200 | event->area.width, event->area.height); | 196 | |
318 | 197 | window = gtk_widget_get_window (widget); | ||
319 | 198 | target = cairo_get_group_target (cr); | ||
320 | 199 | |||
321 | 200 | gdk_cairo_get_clip_rectangle (cr, &clip_rect); | ||
322 | 201 | |||
323 | 202 | /* Clear to parent-relative pixmap | ||
324 | 203 | * We need to use direct X access here because GDK doesn't know about | ||
325 | 204 | * the parent relative pixmap. */ | ||
326 | 205 | cairo_surface_flush (target); | ||
327 | 206 | |||
328 | 207 | XClearArea (GDK_WINDOW_XDISPLAY (window), | ||
329 | 208 | GDK_WINDOW_XID (window), | ||
330 | 209 | clip_rect.x, clip_rect.y, | ||
331 | 210 | clip_rect.width, clip_rect.height, | ||
332 | 211 | False); | ||
333 | 212 | cairo_surface_mark_dirty_rectangle (target, | ||
334 | 213 | clip_rect.x, clip_rect.y, | ||
335 | 214 | clip_rect.width, clip_rect.height); | ||
336 | 201 | } | 215 | } |
337 | 202 | 216 | ||
338 | 203 | return FALSE; | 217 | return FALSE; |
339 | @@ -221,7 +235,7 @@ | |||
340 | 221 | widget_class->style_set = na_tray_child_style_set; | 235 | widget_class->style_set = na_tray_child_style_set; |
341 | 222 | widget_class->realize = na_tray_child_realize; | 236 | widget_class->realize = na_tray_child_realize; |
342 | 223 | widget_class->size_allocate = na_tray_child_size_allocate; | 237 | widget_class->size_allocate = na_tray_child_size_allocate; |
344 | 224 | widget_class->expose_event = na_tray_child_expose_event; | 238 | widget_class->draw = na_tray_child_draw; |
345 | 225 | } | 239 | } |
346 | 226 | 240 | ||
347 | 227 | GtkWidget * | 241 | GtkWidget * |
348 | @@ -233,8 +247,6 @@ | |||
349 | 233 | NaTrayChild *child; | 247 | NaTrayChild *child; |
350 | 234 | GdkVisual *visual; | 248 | GdkVisual *visual; |
351 | 235 | gboolean visual_has_alpha; | 249 | gboolean visual_has_alpha; |
352 | 236 | GdkColormap *colormap; | ||
353 | 237 | gboolean new_colormap; | ||
354 | 238 | int red_prec, green_prec, blue_prec, depth; | 250 | int red_prec, green_prec, blue_prec, depth; |
355 | 239 | int result; | 251 | int result; |
356 | 240 | 252 | ||
357 | @@ -250,7 +262,7 @@ | |||
358 | 250 | gdk_error_trap_push (); | 262 | gdk_error_trap_push (); |
359 | 251 | result = XGetWindowAttributes (xdisplay, icon_window, | 263 | result = XGetWindowAttributes (xdisplay, icon_window, |
360 | 252 | &window_attributes); | 264 | &window_attributes); |
362 | 253 | gdk_error_trap_pop (); | 265 | gdk_error_trap_pop_ignored (); |
363 | 254 | 266 | ||
364 | 255 | if (!result) /* Window already gone */ | 267 | if (!result) /* Window already gone */ |
365 | 256 | return NULL; | 268 | return NULL; |
366 | @@ -260,24 +272,10 @@ | |||
367 | 260 | if (!visual) /* Icon window is on another screen? */ | 272 | if (!visual) /* Icon window is on another screen? */ |
368 | 261 | return NULL; | 273 | return NULL; |
369 | 262 | 274 | ||
370 | 263 | new_colormap = FALSE; | ||
371 | 264 | |||
372 | 265 | if (visual == gdk_screen_get_rgb_visual (screen)) | ||
373 | 266 | colormap = gdk_screen_get_rgb_colormap (screen); | ||
374 | 267 | else if (visual == gdk_screen_get_rgba_visual (screen)) | ||
375 | 268 | colormap = gdk_screen_get_rgba_colormap (screen); | ||
376 | 269 | else if (visual == gdk_screen_get_system_visual (screen)) | ||
377 | 270 | colormap = gdk_screen_get_system_colormap (screen); | ||
378 | 271 | else | ||
379 | 272 | { | ||
380 | 273 | colormap = gdk_colormap_new (visual, FALSE); | ||
381 | 274 | new_colormap = TRUE; | ||
382 | 275 | } | ||
383 | 276 | |||
384 | 277 | child = g_object_new (NA_TYPE_TRAY_CHILD, NULL); | 275 | child = g_object_new (NA_TYPE_TRAY_CHILD, NULL); |
385 | 278 | child->icon_window = icon_window; | 276 | child->icon_window = icon_window; |
386 | 279 | 277 | ||
388 | 280 | gtk_widget_set_colormap (GTK_WIDGET (child), colormap); | 278 | gtk_widget_set_visual (GTK_WIDGET (child), visual); |
389 | 281 | 279 | ||
390 | 282 | /* We have alpha if the visual has something other than red, green, | 280 | /* We have alpha if the visual has something other than red, green, |
391 | 283 | * and blue */ | 281 | * and blue */ |
392 | @@ -292,9 +290,6 @@ | |||
393 | 292 | 290 | ||
394 | 293 | child->composited = child->has_alpha; | 291 | child->composited = child->has_alpha; |
395 | 294 | 292 | ||
396 | 295 | if (new_colormap) | ||
397 | 296 | g_object_unref (colormap); | ||
398 | 297 | |||
399 | 298 | return GTK_WIDGET (child); | 293 | return GTK_WIDGET (child); |
400 | 299 | } | 294 | } |
401 | 300 | 295 | ||
402 | @@ -422,7 +417,7 @@ | |||
403 | 422 | gtk_widget_get_allocation (widget, &allocation); | 417 | gtk_widget_get_allocation (widget, &allocation); |
404 | 423 | 418 | ||
405 | 424 | xev.xexpose.type = Expose; | 419 | xev.xexpose.type = Expose; |
407 | 425 | xev.xexpose.window = GDK_WINDOW_XWINDOW (plug_window); | 420 | xev.xexpose.window = GDK_WINDOW_XID (plug_window); |
408 | 426 | xev.xexpose.x = 0; | 421 | xev.xexpose.x = 0; |
409 | 427 | xev.xexpose.y = 0; | 422 | xev.xexpose.y = 0; |
410 | 428 | xev.xexpose.width = allocation.width; | 423 | xev.xexpose.width = allocation.width; |
411 | @@ -430,15 +425,11 @@ | |||
412 | 430 | xev.xexpose.count = 0; | 425 | xev.xexpose.count = 0; |
413 | 431 | 426 | ||
414 | 432 | gdk_error_trap_push (); | 427 | gdk_error_trap_push (); |
416 | 433 | XSendEvent (GDK_DISPLAY_XDISPLAY (gtk_widget_get_display (widget)), | 428 | XSendEvent (xdisplay, |
417 | 434 | xev.xexpose.window, | 429 | xev.xexpose.window, |
418 | 435 | False, ExposureMask, | 430 | False, ExposureMask, |
419 | 436 | &xev); | 431 | &xev); |
425 | 437 | /* We have to sync to reliably catch errors from the XSendEvent(), | 432 | gdk_error_trap_pop_ignored (); |
421 | 438 | * since that is asynchronous. | ||
422 | 439 | */ | ||
423 | 440 | XSync (xdisplay, False); | ||
424 | 441 | gdk_error_trap_pop (); | ||
426 | 442 | #else | 433 | #else |
427 | 443 | /* Hiding and showing is the safe way to do it, but can result in more | 434 | /* Hiding and showing is the safe way to do it, but can result in more |
428 | 444 | * flickering. | 435 | * flickering. |
429 | @@ -482,7 +473,7 @@ | |||
430 | 482 | 473 | ||
431 | 483 | gdk_error_trap_push (); | 474 | gdk_error_trap_push (); |
432 | 484 | XGetClassHint (xdisplay, xwindow, &ch); | 475 | XGetClassHint (xdisplay, xwindow, &ch); |
434 | 485 | gdk_error_trap_pop (); | 476 | gdk_error_trap_pop_ignored (); |
435 | 486 | 477 | ||
436 | 487 | if (res_class) | 478 | if (res_class) |
437 | 488 | *res_class = NULL; | 479 | *res_class = NULL; |
438 | 489 | 480 | ||
439 | === modified file 'unity-misc/na-tray-child.h' | |||
440 | --- unity-misc/na-tray-child.h 2011-02-14 10:15:57 +0000 | |||
441 | +++ unity-misc/na-tray-child.h 2011-06-16 13:19:23 +0000 | |||
442 | @@ -24,7 +24,7 @@ | |||
443 | 24 | #define __NA_TRAY_CHILD_H__ | 24 | #define __NA_TRAY_CHILD_H__ |
444 | 25 | 25 | ||
445 | 26 | #include <gtk/gtk.h> | 26 | #include <gtk/gtk.h> |
447 | 27 | #include <gdk/gdkx.h> | 27 | #include <gtk/gtkx.h> |
448 | 28 | 28 | ||
449 | 29 | G_BEGIN_DECLS | 29 | G_BEGIN_DECLS |
450 | 30 | 30 | ||
451 | 31 | 31 | ||
452 | === modified file 'unity-misc/na-tray-manager.c' | |||
453 | --- unity-misc/na-tray-manager.c 2011-02-14 10:15:57 +0000 | |||
454 | +++ unity-misc/na-tray-manager.c 2011-06-16 13:19:23 +0000 | |||
455 | @@ -26,8 +26,6 @@ | |||
456 | 26 | 26 | ||
457 | 27 | #include "na-tray-manager.h" | 27 | #include "na-tray-manager.h" |
458 | 28 | 28 | ||
459 | 29 | #include <gdkconfig.h> | ||
460 | 30 | #include <glib/gi18n.h> | ||
461 | 31 | #if defined (GDK_WINDOWING_X11) | 29 | #if defined (GDK_WINDOWING_X11) |
462 | 32 | #include <gdk/gdkx.h> | 30 | #include <gdk/gdkx.h> |
463 | 33 | #include <X11/Xatom.h> | 31 | #include <X11/Xatom.h> |
464 | @@ -98,6 +96,25 @@ | |||
465 | 98 | { | 96 | { |
466 | 99 | manager->invisible = NULL; | 97 | manager->invisible = NULL; |
467 | 100 | manager->socket_table = g_hash_table_new (NULL, NULL); | 98 | manager->socket_table = g_hash_table_new (NULL, NULL); |
468 | 99 | |||
469 | 100 | manager->padding = 0; | ||
470 | 101 | manager->icon_size = 0; | ||
471 | 102 | |||
472 | 103 | manager->fg.red = 0; | ||
473 | 104 | manager->fg.green = 0; | ||
474 | 105 | manager->fg.blue = 0; | ||
475 | 106 | |||
476 | 107 | manager->error.red = 0xffff; | ||
477 | 108 | manager->error.green = 0; | ||
478 | 109 | manager->error.blue = 0; | ||
479 | 110 | |||
480 | 111 | manager->warning.red = 0xffff; | ||
481 | 112 | manager->warning.green = 0xffff; | ||
482 | 113 | manager->warning.blue = 0; | ||
483 | 114 | |||
484 | 115 | manager->success.red = 0; | ||
485 | 116 | manager->success.green = 0xffff; | ||
486 | 117 | manager->success.blue = 0; | ||
487 | 101 | } | 118 | } |
488 | 102 | 119 | ||
489 | 103 | static void | 120 | static void |
490 | @@ -299,8 +316,8 @@ | |||
491 | 299 | if (!gtk_socket_get_plug_window (GTK_SOCKET (child))) | 316 | if (!gtk_socket_get_plug_window (GTK_SOCKET (child))) |
492 | 300 | { | 317 | { |
493 | 301 | /* Embedding failed, we won't get a plug-removed signal */ | 318 | /* Embedding failed, we won't get a plug-removed signal */ |
494 | 319 | /* This signal destroys the socket */ | ||
495 | 302 | g_signal_emit (manager, manager_signals[TRAY_ICON_REMOVED], 0, child); | 320 | g_signal_emit (manager, manager_signals[TRAY_ICON_REMOVED], 0, child); |
496 | 303 | gtk_widget_destroy (child); | ||
497 | 304 | return; | 321 | return; |
498 | 305 | } | 322 | } |
499 | 306 | 323 | ||
500 | @@ -316,19 +333,13 @@ | |||
501 | 316 | g_free (message); | 333 | g_free (message); |
502 | 317 | } | 334 | } |
503 | 318 | 335 | ||
508 | 319 | static GdkFilterReturn | 336 | static void |
509 | 320 | na_tray_manager_handle_client_message_message_data (GdkXEvent *xev, | 337 | na_tray_manager_handle_message_data (NaTrayManager *manager, |
510 | 321 | GdkEvent *event, | 338 | XClientMessageEvent *xevent) |
507 | 322 | gpointer data) | ||
511 | 323 | { | 339 | { |
516 | 324 | XClientMessageEvent *xevent; | 340 | GList *p; |
517 | 325 | NaTrayManager *manager; | 341 | int len; |
514 | 326 | GList *p; | ||
515 | 327 | int len; | ||
518 | 328 | 342 | ||
519 | 329 | xevent = (XClientMessageEvent *) xev; | ||
520 | 330 | manager = data; | ||
521 | 331 | |||
522 | 332 | /* Try to see if we can find the pending message in the list */ | 343 | /* Try to see if we can find the pending message in the list */ |
523 | 333 | for (p = manager->messages; p; p = p->next) | 344 | for (p = manager->messages; p; p = p->next) |
524 | 334 | { | 345 | { |
525 | @@ -362,8 +373,6 @@ | |||
526 | 362 | break; | 373 | break; |
527 | 363 | } | 374 | } |
528 | 364 | } | 375 | } |
529 | 365 | |||
530 | 366 | return GDK_FILTER_REMOVE; | ||
531 | 367 | } | 376 | } |
532 | 368 | 377 | ||
533 | 369 | static void | 378 | static void |
534 | @@ -383,13 +392,17 @@ | |||
535 | 383 | if (!socket) | 392 | if (!socket) |
536 | 384 | return; | 393 | return; |
537 | 385 | 394 | ||
538 | 395 | timeout = xevent->data.l[2]; | ||
539 | 396 | len = xevent->data.l[3]; | ||
540 | 397 | id = xevent->data.l[4]; | ||
541 | 398 | |||
542 | 386 | /* Check if the same message is already in the queue and remove it if so */ | 399 | /* Check if the same message is already in the queue and remove it if so */ |
543 | 387 | for (p = manager->messages; p; p = p->next) | 400 | for (p = manager->messages; p; p = p->next) |
544 | 388 | { | 401 | { |
545 | 389 | PendingMessage *pmsg = p->data; | 402 | PendingMessage *pmsg = p->data; |
546 | 390 | 403 | ||
547 | 391 | if (xevent->window == pmsg->window && | 404 | if (xevent->window == pmsg->window && |
549 | 392 | xevent->data.l[4] == pmsg->id) | 405 | id == pmsg->id) |
550 | 393 | { | 406 | { |
551 | 394 | /* Hmm, we found it, now remove it */ | 407 | /* Hmm, we found it, now remove it */ |
552 | 395 | pending_message_free (pmsg); | 408 | pending_message_free (pmsg); |
553 | @@ -399,10 +412,6 @@ | |||
554 | 399 | } | 412 | } |
555 | 400 | } | 413 | } |
556 | 401 | 414 | ||
557 | 402 | timeout = xevent->data.l[2]; | ||
558 | 403 | len = xevent->data.l[3]; | ||
559 | 404 | id = xevent->data.l[4]; | ||
560 | 405 | |||
561 | 406 | if (len == 0) | 415 | if (len == 0) |
562 | 407 | { | 416 | { |
563 | 408 | g_signal_emit (manager, manager_signals[MESSAGE_SENT], 0, | 417 | g_signal_emit (manager, manager_signals[MESSAGE_SENT], 0, |
564 | @@ -429,6 +438,9 @@ | |||
565 | 429 | { | 438 | { |
566 | 430 | GList *p; | 439 | GList *p; |
567 | 431 | GtkSocket *socket; | 440 | GtkSocket *socket; |
568 | 441 | long id; | ||
569 | 442 | |||
570 | 443 | id = xevent->data.l[2]; | ||
571 | 432 | 444 | ||
572 | 433 | /* Check if the message is in the queue and remove it if so */ | 445 | /* Check if the message is in the queue and remove it if so */ |
573 | 434 | for (p = manager->messages; p; p = p->next) | 446 | for (p = manager->messages; p; p = p->next) |
574 | @@ -436,7 +448,7 @@ | |||
575 | 436 | PendingMessage *msg = p->data; | 448 | PendingMessage *msg = p->data; |
576 | 437 | 449 | ||
577 | 438 | if (xevent->window == msg->window && | 450 | if (xevent->window == msg->window && |
579 | 439 | xevent->data.l[4] == msg->id) | 451 | id == msg->id) |
580 | 440 | { | 452 | { |
581 | 441 | pending_message_free (msg); | 453 | pending_message_free (msg); |
582 | 442 | manager->messages = g_list_remove_link (manager->messages, p); | 454 | manager->messages = g_list_remove_link (manager->messages, p); |
583 | @@ -456,39 +468,6 @@ | |||
584 | 456 | } | 468 | } |
585 | 457 | 469 | ||
586 | 458 | static GdkFilterReturn | 470 | static GdkFilterReturn |
587 | 459 | na_tray_manager_handle_client_message_opcode (GdkXEvent *xev, | ||
588 | 460 | GdkEvent *event, | ||
589 | 461 | gpointer data) | ||
590 | 462 | { | ||
591 | 463 | XClientMessageEvent *xevent; | ||
592 | 464 | NaTrayManager *manager; | ||
593 | 465 | |||
594 | 466 | xevent = (XClientMessageEvent *) xev; | ||
595 | 467 | manager = data; | ||
596 | 468 | |||
597 | 469 | switch (xevent->data.l[1]) | ||
598 | 470 | { | ||
599 | 471 | case SYSTEM_TRAY_REQUEST_DOCK: | ||
600 | 472 | /* Ignore this one since we don't know on which window this was received | ||
601 | 473 | * and so we can't know for which screen this is. It will be handled | ||
602 | 474 | * in na_tray_manager_window_filter() since we also receive it there */ | ||
603 | 475 | break; | ||
604 | 476 | |||
605 | 477 | case SYSTEM_TRAY_BEGIN_MESSAGE: | ||
606 | 478 | na_tray_manager_handle_begin_message (manager, xevent); | ||
607 | 479 | return GDK_FILTER_REMOVE; | ||
608 | 480 | |||
609 | 481 | case SYSTEM_TRAY_CANCEL_MESSAGE: | ||
610 | 482 | na_tray_manager_handle_cancel_message (manager, xevent); | ||
611 | 483 | return GDK_FILTER_REMOVE; | ||
612 | 484 | default: | ||
613 | 485 | break; | ||
614 | 486 | } | ||
615 | 487 | |||
616 | 488 | return GDK_FILTER_CONTINUE; | ||
617 | 489 | } | ||
618 | 490 | |||
619 | 491 | static GdkFilterReturn | ||
620 | 492 | na_tray_manager_window_filter (GdkXEvent *xev, | 471 | na_tray_manager_window_filter (GdkXEvent *xev, |
621 | 493 | GdkEvent *event, | 472 | GdkEvent *event, |
622 | 494 | gpointer data) | 473 | gpointer data) |
623 | @@ -498,8 +477,7 @@ | |||
624 | 498 | 477 | ||
625 | 499 | if (xevent->type == ClientMessage) | 478 | if (xevent->type == ClientMessage) |
626 | 500 | { | 479 | { |
629 | 501 | /* We handle this client message here. See comment in | 480 | /* _NET_SYSTEM_TRAY_OPCODE: SYSTEM_TRAY_REQUEST_DOCK */ |
628 | 502 | * na_tray_manager_handle_client_message_opcode() for details */ | ||
630 | 503 | if (xevent->xclient.message_type == manager->opcode_atom && | 481 | if (xevent->xclient.message_type == manager->opcode_atom && |
631 | 504 | xevent->xclient.data.l[1] == SYSTEM_TRAY_REQUEST_DOCK) | 482 | xevent->xclient.data.l[1] == SYSTEM_TRAY_REQUEST_DOCK) |
632 | 505 | { | 483 | { |
633 | @@ -507,6 +485,29 @@ | |||
634 | 507 | (XClientMessageEvent *) xevent); | 485 | (XClientMessageEvent *) xevent); |
635 | 508 | return GDK_FILTER_REMOVE; | 486 | return GDK_FILTER_REMOVE; |
636 | 509 | } | 487 | } |
637 | 488 | /* _NET_SYSTEM_TRAY_OPCODE: SYSTEM_TRAY_BEGIN_MESSAGE */ | ||
638 | 489 | else if (xevent->xclient.message_type == manager->opcode_atom && | ||
639 | 490 | xevent->xclient.data.l[1] == SYSTEM_TRAY_BEGIN_MESSAGE) | ||
640 | 491 | { | ||
641 | 492 | na_tray_manager_handle_begin_message (manager, | ||
642 | 493 | (XClientMessageEvent *) event); | ||
643 | 494 | return GDK_FILTER_REMOVE; | ||
644 | 495 | } | ||
645 | 496 | /* _NET_SYSTEM_TRAY_OPCODE: SYSTEM_TRAY_CANCEL_MESSAGE */ | ||
646 | 497 | else if (xevent->xclient.message_type == manager->opcode_atom && | ||
647 | 498 | xevent->xclient.data.l[1] == SYSTEM_TRAY_CANCEL_MESSAGE) | ||
648 | 499 | { | ||
649 | 500 | na_tray_manager_handle_cancel_message (manager, | ||
650 | 501 | (XClientMessageEvent *) event); | ||
651 | 502 | return GDK_FILTER_REMOVE; | ||
652 | 503 | } | ||
653 | 504 | /* _NET_SYSTEM_TRAY_MESSAGE_DATA */ | ||
654 | 505 | else if (xevent->xclient.message_type == manager->message_data_atom) | ||
655 | 506 | { | ||
656 | 507 | na_tray_manager_handle_message_data (manager, | ||
657 | 508 | (XClientMessageEvent *) event); | ||
658 | 509 | return GDK_FILTER_REMOVE; | ||
659 | 510 | } | ||
660 | 510 | } | 511 | } |
661 | 511 | else if (xevent->type == SelectionClear) | 512 | else if (xevent->type == SelectionClear) |
662 | 512 | { | 513 | { |
663 | @@ -564,9 +565,6 @@ | |||
664 | 564 | TRUE); | 565 | TRUE); |
665 | 565 | } | 566 | } |
666 | 566 | 567 | ||
667 | 567 | //FIXME: we should also use gdk_remove_client_message_filter when it's | ||
668 | 568 | //available | ||
669 | 569 | // See bug #351254 | ||
670 | 570 | gdk_window_remove_filter (window, | 568 | gdk_window_remove_filter (window, |
671 | 571 | na_tray_manager_window_filter, manager); | 569 | na_tray_manager_window_filter, manager); |
672 | 572 | 570 | ||
673 | @@ -585,11 +583,9 @@ | |||
674 | 585 | Atom orientation_atom; | 583 | Atom orientation_atom; |
675 | 586 | gulong data[1]; | 584 | gulong data[1]; |
676 | 587 | 585 | ||
679 | 588 | if (!manager->invisible) | 586 | g_return_if_fail (manager->invisible != NULL); |
678 | 589 | return; | ||
680 | 590 | window = gtk_widget_get_window (manager->invisible); | 587 | window = gtk_widget_get_window (manager->invisible); |
683 | 591 | if (!window) | 588 | g_return_if_fail (window != NULL); |
682 | 592 | return; | ||
684 | 593 | 589 | ||
685 | 594 | display = gtk_widget_get_display (manager->invisible); | 590 | display = gtk_widget_get_display (manager->invisible); |
686 | 595 | orientation_atom = gdk_x11_get_xatom_by_name_for_display (display, | 591 | orientation_atom = gdk_x11_get_xatom_by_name_for_display (display, |
687 | @@ -600,7 +596,7 @@ | |||
688 | 600 | SYSTEM_TRAY_ORIENTATION_VERT; | 596 | SYSTEM_TRAY_ORIENTATION_VERT; |
689 | 601 | 597 | ||
690 | 602 | XChangeProperty (GDK_DISPLAY_XDISPLAY (display), | 598 | XChangeProperty (GDK_DISPLAY_XDISPLAY (display), |
692 | 603 | GDK_WINDOW_XWINDOW (window), | 599 | GDK_WINDOW_XID (window), |
693 | 604 | orientation_atom, | 600 | orientation_atom, |
694 | 605 | XA_CARDINAL, 32, | 601 | XA_CARDINAL, 32, |
695 | 606 | PropModeReplace, | 602 | PropModeReplace, |
696 | @@ -618,11 +614,9 @@ | |||
697 | 618 | Atom visual_atom; | 614 | Atom visual_atom; |
698 | 619 | gulong data[1]; | 615 | gulong data[1]; |
699 | 620 | 616 | ||
702 | 621 | if (!manager->invisible) | 617 | g_return_if_fail (manager->invisible != NULL); |
701 | 622 | return; | ||
703 | 623 | window = gtk_widget_get_window (manager->invisible); | 618 | window = gtk_widget_get_window (manager->invisible); |
706 | 624 | if (!window) | 619 | g_return_if_fail (window != NULL); |
705 | 625 | return; | ||
707 | 626 | 620 | ||
708 | 627 | /* The visual property is a hint to the tray icons as to what visual they | 621 | /* The visual property is a hint to the tray icons as to what visual they |
709 | 628 | * should use for their windows. If the X server has RGBA colormaps, then | 622 | * should use for their windows. If the X server has RGBA colormaps, then |
710 | @@ -638,25 +632,20 @@ | |||
711 | 638 | 632 | ||
712 | 639 | if (gdk_screen_get_rgba_visual (manager->screen) != NULL && | 633 | if (gdk_screen_get_rgba_visual (manager->screen) != NULL && |
713 | 640 | gdk_display_supports_composite (display)) | 634 | gdk_display_supports_composite (display)) |
717 | 641 | { | 635 | xvisual = GDK_VISUAL_XVISUAL (gdk_screen_get_rgba_visual (manager->screen)); |
715 | 642 | xvisual = GDK_VISUAL_XVISUAL (gdk_screen_get_rgba_visual (manager->screen)); | ||
716 | 643 | } | ||
718 | 644 | else | 636 | else |
719 | 645 | { | 637 | { |
720 | 646 | /* We actually want the visual of the tray where the icons will | 638 | /* We actually want the visual of the tray where the icons will |
721 | 647 | * be embedded. In almost all cases, this will be the same as the visual | 639 | * be embedded. In almost all cases, this will be the same as the visual |
722 | 648 | * of the screen. | 640 | * of the screen. |
723 | 649 | */ | 641 | */ |
728 | 650 | GdkColormap *colormap; | 642 | xvisual = GDK_VISUAL_XVISUAL (gdk_screen_get_system_visual (manager->screen)); |
725 | 651 | |||
726 | 652 | colormap = gdk_screen_get_default_colormap (manager->screen); | ||
727 | 653 | xvisual = GDK_VISUAL_XVISUAL (gdk_colormap_get_visual (colormap)); | ||
729 | 654 | } | 643 | } |
730 | 655 | 644 | ||
731 | 656 | data[0] = XVisualIDFromVisual (xvisual); | 645 | data[0] = XVisualIDFromVisual (xvisual); |
732 | 657 | 646 | ||
733 | 658 | XChangeProperty (GDK_DISPLAY_XDISPLAY (display), | 647 | XChangeProperty (GDK_DISPLAY_XDISPLAY (display), |
735 | 659 | GDK_WINDOW_XWINDOW (window), | 648 | GDK_WINDOW_XID (window), |
736 | 660 | visual_atom, | 649 | visual_atom, |
737 | 661 | XA_VISUALID, 32, | 650 | XA_VISUALID, 32, |
738 | 662 | PropModeReplace, | 651 | PropModeReplace, |
739 | @@ -664,6 +653,101 @@ | |||
740 | 664 | #endif | 653 | #endif |
741 | 665 | } | 654 | } |
742 | 666 | 655 | ||
743 | 656 | static void | ||
744 | 657 | na_tray_manager_set_padding_property (NaTrayManager *manager) | ||
745 | 658 | { | ||
746 | 659 | #ifdef GDK_WINDOWING_X11 | ||
747 | 660 | GdkWindow *window; | ||
748 | 661 | GdkDisplay *display; | ||
749 | 662 | Atom atom; | ||
750 | 663 | gulong data[1]; | ||
751 | 664 | |||
752 | 665 | g_return_if_fail (manager->invisible != NULL); | ||
753 | 666 | window = gtk_widget_get_window (manager->invisible); | ||
754 | 667 | g_return_if_fail (window != NULL); | ||
755 | 668 | |||
756 | 669 | display = gtk_widget_get_display (manager->invisible); | ||
757 | 670 | atom = gdk_x11_get_xatom_by_name_for_display (display, | ||
758 | 671 | "_NET_SYSTEM_TRAY_PADDING"); | ||
759 | 672 | |||
760 | 673 | data[0] = manager->padding; | ||
761 | 674 | |||
762 | 675 | XChangeProperty (GDK_DISPLAY_XDISPLAY (display), | ||
763 | 676 | GDK_WINDOW_XID (window), | ||
764 | 677 | atom, | ||
765 | 678 | XA_CARDINAL, 32, | ||
766 | 679 | PropModeReplace, | ||
767 | 680 | (guchar *) &data, 1); | ||
768 | 681 | #endif | ||
769 | 682 | } | ||
770 | 683 | |||
771 | 684 | static void | ||
772 | 685 | na_tray_manager_set_icon_size_property (NaTrayManager *manager) | ||
773 | 686 | { | ||
774 | 687 | #ifdef GDK_WINDOWING_X11 | ||
775 | 688 | GdkWindow *window; | ||
776 | 689 | GdkDisplay *display; | ||
777 | 690 | Atom atom; | ||
778 | 691 | gulong data[1]; | ||
779 | 692 | |||
780 | 693 | g_return_if_fail (manager->invisible != NULL); | ||
781 | 694 | window = gtk_widget_get_window (manager->invisible); | ||
782 | 695 | g_return_if_fail (window != NULL); | ||
783 | 696 | |||
784 | 697 | display = gtk_widget_get_display (manager->invisible); | ||
785 | 698 | atom = gdk_x11_get_xatom_by_name_for_display (display, | ||
786 | 699 | "_NET_SYSTEM_TRAY_ICON_SIZE"); | ||
787 | 700 | |||
788 | 701 | data[0] = manager->icon_size; | ||
789 | 702 | |||
790 | 703 | XChangeProperty (GDK_DISPLAY_XDISPLAY (display), | ||
791 | 704 | GDK_WINDOW_XID (window), | ||
792 | 705 | atom, | ||
793 | 706 | XA_CARDINAL, 32, | ||
794 | 707 | PropModeReplace, | ||
795 | 708 | (guchar *) &data, 1); | ||
796 | 709 | #endif | ||
797 | 710 | } | ||
798 | 711 | |||
799 | 712 | static void | ||
800 | 713 | na_tray_manager_set_colors_property (NaTrayManager *manager) | ||
801 | 714 | { | ||
802 | 715 | #ifdef GDK_WINDOWING_X11 | ||
803 | 716 | GdkWindow *window; | ||
804 | 717 | GdkDisplay *display; | ||
805 | 718 | Atom atom; | ||
806 | 719 | gulong data[12]; | ||
807 | 720 | |||
808 | 721 | g_return_if_fail (manager->invisible != NULL); | ||
809 | 722 | window = gtk_widget_get_window (manager->invisible); | ||
810 | 723 | g_return_if_fail (window != NULL); | ||
811 | 724 | |||
812 | 725 | display = gtk_widget_get_display (manager->invisible); | ||
813 | 726 | atom = gdk_x11_get_xatom_by_name_for_display (display, | ||
814 | 727 | "_NET_SYSTEM_TRAY_COLORS"); | ||
815 | 728 | |||
816 | 729 | data[0] = manager->fg.red; | ||
817 | 730 | data[1] = manager->fg.green; | ||
818 | 731 | data[2] = manager->fg.blue; | ||
819 | 732 | data[3] = manager->error.red; | ||
820 | 733 | data[4] = manager->error.green; | ||
821 | 734 | data[5] = manager->error.blue; | ||
822 | 735 | data[6] = manager->warning.red; | ||
823 | 736 | data[7] = manager->warning.green; | ||
824 | 737 | data[8] = manager->warning.blue; | ||
825 | 738 | data[9] = manager->success.red; | ||
826 | 739 | data[10] = manager->success.green; | ||
827 | 740 | data[11] = manager->success.blue; | ||
828 | 741 | |||
829 | 742 | XChangeProperty (GDK_DISPLAY_XDISPLAY (display), | ||
830 | 743 | GDK_WINDOW_XID (window), | ||
831 | 744 | atom, | ||
832 | 745 | XA_CARDINAL, 32, | ||
833 | 746 | PropModeReplace, | ||
834 | 747 | (guchar *) &data, 12); | ||
835 | 748 | #endif | ||
836 | 749 | } | ||
837 | 750 | |||
838 | 667 | #ifdef GDK_WINDOWING_X11 | 751 | #ifdef GDK_WINDOWING_X11 |
839 | 668 | 752 | ||
840 | 669 | static gboolean | 753 | static gboolean |
841 | @@ -709,6 +793,9 @@ | |||
842 | 709 | 793 | ||
843 | 710 | na_tray_manager_set_orientation_property (manager); | 794 | na_tray_manager_set_orientation_property (manager); |
844 | 711 | na_tray_manager_set_visual_property (manager); | 795 | na_tray_manager_set_visual_property (manager); |
845 | 796 | na_tray_manager_set_padding_property (manager); | ||
846 | 797 | na_tray_manager_set_icon_size_property (manager); | ||
847 | 798 | na_tray_manager_set_colors_property (manager); | ||
848 | 712 | 799 | ||
849 | 713 | window = gtk_widget_get_window (invisible); | 800 | window = gtk_widget_get_window (invisible); |
850 | 714 | 801 | ||
851 | @@ -734,7 +821,7 @@ | |||
852 | 734 | xev.data.l[0] = timestamp; | 821 | xev.data.l[0] = timestamp; |
853 | 735 | xev.data.l[1] = gdk_x11_atom_to_xatom_for_display (display, | 822 | xev.data.l[1] = gdk_x11_atom_to_xatom_for_display (display, |
854 | 736 | manager->selection_atom); | 823 | manager->selection_atom); |
856 | 737 | xev.data.l[2] = GDK_WINDOW_XWINDOW (window); | 824 | xev.data.l[2] = GDK_WINDOW_XID (window); |
857 | 738 | xev.data.l[3] = 0; /* manager specific data */ | 825 | xev.data.l[3] = 0; /* manager specific data */ |
858 | 739 | xev.data.l[4] = 0; /* manager specific data */ | 826 | xev.data.l[4] = 0; /* manager specific data */ |
859 | 740 | 827 | ||
860 | @@ -748,6 +835,8 @@ | |||
861 | 748 | 835 | ||
862 | 749 | message_data_atom = gdk_atom_intern ("_NET_SYSTEM_TRAY_MESSAGE_DATA", | 836 | message_data_atom = gdk_atom_intern ("_NET_SYSTEM_TRAY_MESSAGE_DATA", |
863 | 750 | FALSE); | 837 | FALSE); |
864 | 838 | manager->message_data_atom = gdk_x11_atom_to_xatom_for_display (display, | ||
865 | 839 | message_data_atom); | ||
866 | 751 | 840 | ||
867 | 752 | /* Add a window filter */ | 841 | /* Add a window filter */ |
868 | 753 | #if 0 | 842 | #if 0 |
869 | @@ -756,17 +845,8 @@ | |||
870 | 756 | G_CALLBACK (na_tray_manager_selection_clear_event), | 845 | G_CALLBACK (na_tray_manager_selection_clear_event), |
871 | 757 | manager); | 846 | manager); |
872 | 758 | #endif | 847 | #endif |
873 | 759 | /* This is for SYSTEM_TRAY_REQUEST_DOCK and SelectionClear */ | ||
874 | 760 | gdk_window_add_filter (window, | 848 | gdk_window_add_filter (window, |
875 | 761 | na_tray_manager_window_filter, manager); | 849 | na_tray_manager_window_filter, manager); |
876 | 762 | /* This is for SYSTEM_TRAY_BEGIN_MESSAGE and SYSTEM_TRAY_CANCEL_MESSAGE */ | ||
877 | 763 | gdk_display_add_client_message_filter (display, opcode_atom, | ||
878 | 764 | na_tray_manager_handle_client_message_opcode, | ||
879 | 765 | manager); | ||
880 | 766 | /* This is for _NET_SYSTEM_TRAY_MESSAGE_DATA */ | ||
881 | 767 | gdk_display_add_client_message_filter (display, message_data_atom, | ||
882 | 768 | na_tray_manager_handle_client_message_message_data, | ||
883 | 769 | manager); | ||
884 | 770 | return TRUE; | 850 | return TRUE; |
885 | 771 | } | 851 | } |
886 | 772 | else | 852 | else |
887 | @@ -850,6 +930,57 @@ | |||
888 | 850 | } | 930 | } |
889 | 851 | } | 931 | } |
890 | 852 | 932 | ||
891 | 933 | void | ||
892 | 934 | na_tray_manager_set_padding (NaTrayManager *manager, | ||
893 | 935 | gint padding) | ||
894 | 936 | { | ||
895 | 937 | g_return_if_fail (NA_IS_TRAY_MANAGER (manager)); | ||
896 | 938 | |||
897 | 939 | if (manager->padding != padding) | ||
898 | 940 | { | ||
899 | 941 | manager->padding = padding; | ||
900 | 942 | |||
901 | 943 | na_tray_manager_set_padding_property (manager); | ||
902 | 944 | } | ||
903 | 945 | } | ||
904 | 946 | |||
905 | 947 | void | ||
906 | 948 | na_tray_manager_set_icon_size (NaTrayManager *manager, | ||
907 | 949 | gint icon_size) | ||
908 | 950 | { | ||
909 | 951 | g_return_if_fail (NA_IS_TRAY_MANAGER (manager)); | ||
910 | 952 | |||
911 | 953 | if (manager->icon_size != icon_size) | ||
912 | 954 | { | ||
913 | 955 | manager->icon_size = icon_size; | ||
914 | 956 | |||
915 | 957 | na_tray_manager_set_icon_size_property (manager); | ||
916 | 958 | } | ||
917 | 959 | } | ||
918 | 960 | |||
919 | 961 | void | ||
920 | 962 | na_tray_manager_set_colors (NaTrayManager *manager, | ||
921 | 963 | GdkColor *fg, | ||
922 | 964 | GdkColor *error, | ||
923 | 965 | GdkColor *warning, | ||
924 | 966 | GdkColor *success) | ||
925 | 967 | { | ||
926 | 968 | g_return_if_fail (NA_IS_TRAY_MANAGER (manager)); | ||
927 | 969 | |||
928 | 970 | if (!gdk_color_equal (&manager->fg, fg) || | ||
929 | 971 | !gdk_color_equal (&manager->error, error) || | ||
930 | 972 | !gdk_color_equal (&manager->warning, warning) || | ||
931 | 973 | !gdk_color_equal (&manager->success, success)) | ||
932 | 974 | { | ||
933 | 975 | manager->fg = *fg; | ||
934 | 976 | manager->error = *error; | ||
935 | 977 | manager->warning = *warning; | ||
936 | 978 | manager->success = *success; | ||
937 | 979 | |||
938 | 980 | na_tray_manager_set_colors_property (manager); | ||
939 | 981 | } | ||
940 | 982 | } | ||
941 | 983 | |||
942 | 853 | GtkOrientation | 984 | GtkOrientation |
943 | 854 | na_tray_manager_get_orientation (NaTrayManager *manager) | 985 | na_tray_manager_get_orientation (NaTrayManager *manager) |
944 | 855 | { | 986 | { |
945 | 856 | 987 | ||
946 | === modified file 'unity-misc/na-tray-manager.h' | |||
947 | --- unity-misc/na-tray-manager.h 2010-01-12 11:34:41 +0000 | |||
948 | +++ unity-misc/na-tray-manager.h 2011-06-16 13:19:23 +0000 | |||
949 | @@ -50,11 +50,18 @@ | |||
950 | 50 | #ifdef GDK_WINDOWING_X11 | 50 | #ifdef GDK_WINDOWING_X11 |
951 | 51 | GdkAtom selection_atom; | 51 | GdkAtom selection_atom; |
952 | 52 | Atom opcode_atom; | 52 | Atom opcode_atom; |
953 | 53 | Atom message_data_atom; | ||
954 | 53 | #endif | 54 | #endif |
955 | 54 | 55 | ||
956 | 55 | GtkWidget *invisible; | 56 | GtkWidget *invisible; |
957 | 56 | GdkScreen *screen; | 57 | GdkScreen *screen; |
958 | 57 | GtkOrientation orientation; | 58 | GtkOrientation orientation; |
959 | 59 | gint padding; | ||
960 | 60 | gint icon_size; | ||
961 | 61 | GdkColor fg; | ||
962 | 62 | GdkColor error; | ||
963 | 63 | GdkColor warning; | ||
964 | 64 | GdkColor success; | ||
965 | 58 | 65 | ||
966 | 59 | GList *messages; | 66 | GList *messages; |
967 | 60 | GHashTable *socket_table; | 67 | GHashTable *socket_table; |
968 | @@ -91,6 +98,16 @@ | |||
969 | 91 | void na_tray_manager_set_orientation (NaTrayManager *manager, | 98 | void na_tray_manager_set_orientation (NaTrayManager *manager, |
970 | 92 | GtkOrientation orientation); | 99 | GtkOrientation orientation); |
971 | 93 | GtkOrientation na_tray_manager_get_orientation (NaTrayManager *manager); | 100 | GtkOrientation na_tray_manager_get_orientation (NaTrayManager *manager); |
972 | 101 | void na_tray_manager_set_padding (NaTrayManager *manager, | ||
973 | 102 | gint padding); | ||
974 | 103 | void na_tray_manager_set_icon_size (NaTrayManager *manager, | ||
975 | 104 | gint padding); | ||
976 | 105 | void na_tray_manager_set_colors (NaTrayManager *manager, | ||
977 | 106 | GdkColor *fg, | ||
978 | 107 | GdkColor *error, | ||
979 | 108 | GdkColor *warning, | ||
980 | 109 | GdkColor *success); | ||
981 | 110 | |||
982 | 94 | 111 | ||
983 | 95 | G_END_DECLS | 112 | G_END_DECLS |
984 | 96 | 113 | ||
985 | 97 | 114 | ||
986 | === modified file 'unity-misc/na-tray.c' | |||
987 | --- unity-misc/na-tray.c 2011-02-14 20:01:14 +0000 | |||
988 | +++ unity-misc/na-tray.c 2011-06-16 13:19:23 +0000 | |||
989 | @@ -29,7 +29,7 @@ | |||
990 | 29 | 29 | ||
991 | 30 | #include "na-tray.h" | 30 | #include "na-tray.h" |
992 | 31 | 31 | ||
994 | 32 | #define ICON_SPACING 3 | 32 | #define ICON_SPACING 1 |
995 | 33 | #define MIN_BOX_SIZE 3 | 33 | #define MIN_BOX_SIZE 3 |
996 | 34 | 34 | ||
997 | 35 | typedef struct | 35 | typedef struct |
998 | @@ -51,9 +51,6 @@ | |||
999 | 51 | guint idle_redraw_id; | 51 | guint idle_redraw_id; |
1000 | 52 | 52 | ||
1001 | 53 | GtkOrientation orientation; | 53 | GtkOrientation orientation; |
1002 | 54 | |||
1003 | 55 | NaTrayFilterCallback cb; | ||
1004 | 56 | gpointer data; | ||
1005 | 57 | }; | 54 | }; |
1006 | 58 | 55 | ||
1007 | 59 | typedef struct | 56 | typedef struct |
1008 | @@ -85,25 +82,6 @@ | |||
1009 | 85 | 82 | ||
1010 | 86 | static void icon_tip_show_next (IconTip *icontip); | 83 | static void icon_tip_show_next (IconTip *icontip); |
1011 | 87 | 84 | ||
1012 | 88 | /* NaBox, an instantiable GtkBox */ | ||
1013 | 89 | |||
1014 | 90 | typedef GtkBox NaBox; | ||
1015 | 91 | typedef GtkBoxClass NaBoxClass; | ||
1016 | 92 | |||
1017 | 93 | static GType na_box_get_type (void); | ||
1018 | 94 | |||
1019 | 95 | G_DEFINE_TYPE (NaBox, na_box, GTK_TYPE_BOX) | ||
1020 | 96 | |||
1021 | 97 | static void | ||
1022 | 98 | na_box_init (NaBox *box) | ||
1023 | 99 | { | ||
1024 | 100 | } | ||
1025 | 101 | |||
1026 | 102 | static void | ||
1027 | 103 | na_box_class_init (NaBoxClass *klass) | ||
1028 | 104 | { | ||
1029 | 105 | } | ||
1030 | 106 | |||
1031 | 107 | /* NaTray */ | 85 | /* NaTray */ |
1032 | 108 | 86 | ||
1033 | 109 | G_DEFINE_TYPE (NaTray, na_tray, GTK_TYPE_BIN) | 87 | G_DEFINE_TYPE (NaTray, na_tray, GTK_TYPE_BIN) |
1034 | @@ -233,11 +211,6 @@ | |||
1035 | 233 | 211 | ||
1036 | 234 | g_assert (priv->trays_screen == trays_screen); | 212 | g_assert (priv->trays_screen == trays_screen); |
1037 | 235 | 213 | ||
1038 | 236 | if (priv->cb && !priv->cb (tray, icon, priv->data)) | ||
1039 | 237 | { | ||
1040 | 238 | return; | ||
1041 | 239 | } | ||
1042 | 240 | |||
1043 | 241 | g_hash_table_insert (trays_screen->icon_table, icon, tray); | 214 | g_hash_table_insert (trays_screen->icon_table, icon, tray); |
1044 | 242 | 215 | ||
1045 | 243 | position = find_icon_position (tray, icon); | 216 | position = find_icon_position (tray, icon); |
1046 | @@ -253,13 +226,18 @@ | |||
1047 | 253 | TraysScreen *trays_screen) | 226 | TraysScreen *trays_screen) |
1048 | 254 | { | 227 | { |
1049 | 255 | NaTray *tray; | 228 | NaTray *tray; |
1050 | 229 | NaTrayPrivate *priv; | ||
1051 | 256 | 230 | ||
1052 | 257 | tray = g_hash_table_lookup (trays_screen->icon_table, icon); | 231 | tray = g_hash_table_lookup (trays_screen->icon_table, icon); |
1053 | 258 | if (tray == NULL) | 232 | if (tray == NULL) |
1054 | 259 | return; | 233 | return; |
1055 | 260 | 234 | ||
1056 | 235 | priv = tray->priv; | ||
1057 | 236 | |||
1058 | 261 | g_assert (tray->priv->trays_screen == trays_screen); | 237 | g_assert (tray->priv->trays_screen == trays_screen); |
1059 | 262 | 238 | ||
1060 | 239 | gtk_container_remove (GTK_CONTAINER (priv->box), icon); | ||
1061 | 240 | |||
1062 | 263 | g_hash_table_remove (trays_screen->icon_table, icon); | 241 | g_hash_table_remove (trays_screen->icon_table, icon); |
1063 | 264 | /* this will also destroy the tip associated to this icon */ | 242 | /* this will also destroy the tip associated to this icon */ |
1064 | 265 | g_hash_table_remove (trays_screen->tip_table, icon); | 243 | g_hash_table_remove (trays_screen->tip_table, icon); |
1065 | @@ -533,10 +511,10 @@ | |||
1066 | 533 | * gdk_window_set_composited(). We need to paint these children ourselves. | 511 | * gdk_window_set_composited(). We need to paint these children ourselves. |
1067 | 534 | */ | 512 | */ |
1068 | 535 | static void | 513 | static void |
1071 | 536 | na_tray_expose_icon (GtkWidget *widget, | 514 | na_tray_draw_icon (GtkWidget *widget, |
1072 | 537 | gpointer data) | 515 | gpointer data) |
1073 | 538 | { | 516 | { |
1075 | 539 | cairo_t *cr = data; | 517 | cairo_t *cr = (cairo_t *) data; |
1076 | 540 | 518 | ||
1077 | 541 | if (na_tray_child_has_alpha (NA_TRAY_CHILD (widget))) | 519 | if (na_tray_child_has_alpha (NA_TRAY_CHILD (widget))) |
1078 | 542 | { | 520 | { |
1079 | @@ -544,26 +522,23 @@ | |||
1080 | 544 | 522 | ||
1081 | 545 | gtk_widget_get_allocation (widget, &allocation); | 523 | gtk_widget_get_allocation (widget, &allocation); |
1082 | 546 | 524 | ||
1084 | 547 | gdk_cairo_set_source_pixmap (cr, | 525 | cairo_save (cr); |
1085 | 526 | gdk_cairo_set_source_window (cr, | ||
1086 | 548 | gtk_widget_get_window (widget), | 527 | gtk_widget_get_window (widget), |
1087 | 549 | allocation.x, | 528 | allocation.x, |
1088 | 550 | allocation.y); | 529 | allocation.y); |
1089 | 530 | cairo_rectangle (cr, allocation.x, allocation.y, allocation.width, allocation.height); | ||
1090 | 531 | cairo_clip (cr); | ||
1091 | 551 | cairo_paint (cr); | 532 | cairo_paint (cr); |
1092 | 533 | cairo_restore (cr); | ||
1093 | 552 | } | 534 | } |
1094 | 553 | } | 535 | } |
1095 | 554 | 536 | ||
1096 | 555 | static void | 537 | static void |
1099 | 556 | na_tray_expose_box (GtkWidget *box, | 538 | na_tray_draw_box (GtkWidget *box, |
1100 | 557 | GdkEventExpose *event) | 539 | cairo_t *cr) |
1101 | 558 | { | 540 | { |
1110 | 559 | cairo_t *cr = gdk_cairo_create (gtk_widget_get_window (box)); | 541 | gtk_container_foreach (GTK_CONTAINER (box), na_tray_draw_icon, cr); |
1103 | 560 | |||
1104 | 561 | gdk_cairo_region (cr, event->region); | ||
1105 | 562 | cairo_clip (cr); | ||
1106 | 563 | |||
1107 | 564 | gtk_container_foreach (GTK_CONTAINER (box), na_tray_expose_icon, cr); | ||
1108 | 565 | |||
1109 | 566 | cairo_destroy (cr); | ||
1111 | 567 | } | 542 | } |
1112 | 568 | 543 | ||
1113 | 569 | static void | 544 | static void |
1114 | @@ -580,10 +555,9 @@ | |||
1115 | 580 | gtk_container_add (GTK_CONTAINER (tray), priv->frame); | 555 | gtk_container_add (GTK_CONTAINER (tray), priv->frame); |
1116 | 581 | gtk_widget_show (priv->frame); | 556 | gtk_widget_show (priv->frame); |
1117 | 582 | 557 | ||
1122 | 583 | priv->box = g_object_new (na_box_get_type (), NULL); | 558 | priv->box = gtk_box_new (priv->orientation, ICON_SPACING); |
1123 | 584 | g_signal_connect (priv->box, "expose-event", | 559 | g_signal_connect (priv->box, "draw", |
1124 | 585 | G_CALLBACK (na_tray_expose_box), tray); | 560 | G_CALLBACK (na_tray_draw_box), NULL); |
1121 | 586 | gtk_box_set_spacing (GTK_BOX (priv->box), ICON_SPACING); | ||
1125 | 587 | gtk_container_add (GTK_CONTAINER (priv->frame), priv->box); | 561 | gtk_container_add (GTK_CONTAINER (priv->frame), priv->box); |
1126 | 588 | gtk_widget_show (priv->box); | 562 | gtk_widget_show (priv->box); |
1127 | 589 | } | 563 | } |
1128 | @@ -736,10 +710,23 @@ | |||
1129 | 736 | } | 710 | } |
1130 | 737 | 711 | ||
1131 | 738 | static void | 712 | static void |
1136 | 739 | na_tray_size_request (GtkWidget *widget, | 713 | na_tray_get_preferred_width (GtkWidget *widget, |
1137 | 740 | GtkRequisition *requisition) | 714 | gint *minimal_width, |
1138 | 741 | { | 715 | gint *natural_width) |
1139 | 742 | gtk_widget_size_request (gtk_bin_get_child (GTK_BIN (widget)), requisition); | 716 | { |
1140 | 717 | gtk_widget_get_preferred_width (gtk_bin_get_child (GTK_BIN (widget)), | ||
1141 | 718 | minimal_width, | ||
1142 | 719 | natural_width); | ||
1143 | 720 | } | ||
1144 | 721 | |||
1145 | 722 | static void | ||
1146 | 723 | na_tray_get_preferred_height (GtkWidget *widget, | ||
1147 | 724 | gint *minimal_height, | ||
1148 | 725 | gint *natural_height) | ||
1149 | 726 | { | ||
1150 | 727 | gtk_widget_get_preferred_height (gtk_bin_get_child (GTK_BIN (widget)), | ||
1151 | 728 | minimal_height, | ||
1152 | 729 | natural_height); | ||
1153 | 743 | } | 730 | } |
1154 | 744 | 731 | ||
1155 | 745 | static void | 732 | static void |
1156 | @@ -747,6 +734,7 @@ | |||
1157 | 747 | GtkAllocation *allocation) | 734 | GtkAllocation *allocation) |
1158 | 748 | { | 735 | { |
1159 | 749 | gtk_widget_size_allocate (gtk_bin_get_child (GTK_BIN (widget)), allocation); | 736 | gtk_widget_size_allocate (gtk_bin_get_child (GTK_BIN (widget)), allocation); |
1160 | 737 | gtk_widget_set_allocation (widget, allocation); | ||
1161 | 750 | } | 738 | } |
1162 | 751 | 739 | ||
1163 | 752 | static void | 740 | static void |
1164 | @@ -758,8 +746,8 @@ | |||
1165 | 758 | gobject_class->constructor = na_tray_constructor; | 746 | gobject_class->constructor = na_tray_constructor; |
1166 | 759 | gobject_class->set_property = na_tray_set_property; | 747 | gobject_class->set_property = na_tray_set_property; |
1167 | 760 | gobject_class->dispose = na_tray_dispose; | 748 | gobject_class->dispose = na_tray_dispose; |
1170 | 761 | 749 | widget_class->get_preferred_width = na_tray_get_preferred_width; | |
1171 | 762 | widget_class->size_request = na_tray_size_request; | 750 | widget_class->get_preferred_height = na_tray_get_preferred_height; |
1172 | 763 | widget_class->size_allocate = na_tray_size_allocate; | 751 | widget_class->size_allocate = na_tray_size_allocate; |
1173 | 764 | 752 | ||
1174 | 765 | g_object_class_install_property | 753 | g_object_class_install_property |
1175 | @@ -789,22 +777,13 @@ | |||
1176 | 789 | } | 777 | } |
1177 | 790 | 778 | ||
1178 | 791 | NaTray * | 779 | NaTray * |
1183 | 792 | na_tray_new_for_screen (GdkScreen *screen, | 780 | na_tray_new_for_screen (GdkScreen *screen, |
1184 | 793 | GtkOrientation orientation, | 781 | GtkOrientation orientation) |
1181 | 794 | NaTrayFilterCallback cb, | ||
1182 | 795 | gpointer data) | ||
1185 | 796 | { | 782 | { |
1189 | 797 | NaTray *tray; | 783 | return g_object_new (NA_TYPE_TRAY, |
1187 | 798 | |||
1188 | 799 | tray = g_object_new (NA_TYPE_TRAY, | ||
1190 | 800 | "screen", screen, | 784 | "screen", screen, |
1191 | 801 | "orientation", orientation, | 785 | "orientation", orientation, |
1192 | 802 | NULL); | 786 | NULL); |
1193 | 803 | |||
1194 | 804 | tray->priv->cb = cb; | ||
1195 | 805 | tray->priv->data = data; | ||
1196 | 806 | |||
1197 | 807 | return tray; | ||
1198 | 808 | } | 787 | } |
1199 | 809 | 788 | ||
1200 | 810 | void | 789 | void |
1201 | @@ -840,6 +819,39 @@ | |||
1202 | 840 | } | 819 | } |
1203 | 841 | 820 | ||
1204 | 842 | void | 821 | void |
1205 | 822 | na_tray_set_padding (NaTray *tray, | ||
1206 | 823 | gint padding) | ||
1207 | 824 | { | ||
1208 | 825 | NaTrayPrivate *priv = tray->priv; | ||
1209 | 826 | |||
1210 | 827 | if (get_tray (priv->trays_screen) == tray) | ||
1211 | 828 | na_tray_manager_set_padding (priv->trays_screen->tray_manager, padding); | ||
1212 | 829 | } | ||
1213 | 830 | |||
1214 | 831 | void | ||
1215 | 832 | na_tray_set_icon_size (NaTray *tray, | ||
1216 | 833 | gint size) | ||
1217 | 834 | { | ||
1218 | 835 | NaTrayPrivate *priv = tray->priv; | ||
1219 | 836 | |||
1220 | 837 | if (get_tray (priv->trays_screen) == tray) | ||
1221 | 838 | na_tray_manager_set_icon_size (priv->trays_screen->tray_manager, size); | ||
1222 | 839 | } | ||
1223 | 840 | |||
1224 | 841 | void | ||
1225 | 842 | na_tray_set_colors (NaTray *tray, | ||
1226 | 843 | GdkColor *fg, | ||
1227 | 844 | GdkColor *error, | ||
1228 | 845 | GdkColor *warning, | ||
1229 | 846 | GdkColor *success) | ||
1230 | 847 | { | ||
1231 | 848 | NaTrayPrivate *priv = tray->priv; | ||
1232 | 849 | |||
1233 | 850 | if (get_tray (priv->trays_screen) == tray) | ||
1234 | 851 | na_tray_manager_set_colors (priv->trays_screen->tray_manager, fg, error, warning, success); | ||
1235 | 852 | } | ||
1236 | 853 | |||
1237 | 854 | void | ||
1238 | 843 | na_tray_force_redraw (NaTray *tray) | 855 | na_tray_force_redraw (NaTray *tray) |
1239 | 844 | { | 856 | { |
1240 | 845 | NaTrayPrivate *priv = tray->priv; | 857 | NaTrayPrivate *priv = tray->priv; |
1241 | @@ -849,11 +861,3 @@ | |||
1242 | 849 | if (priv->idle_redraw_id == 0) | 861 | if (priv->idle_redraw_id == 0) |
1243 | 850 | priv->idle_redraw_id = g_idle_add ((GSourceFunc) idle_redraw_cb, tray); | 862 | priv->idle_redraw_id = g_idle_add ((GSourceFunc) idle_redraw_cb, tray); |
1244 | 851 | } | 863 | } |
1245 | 852 | |||
1246 | 853 | NaTrayManager * | ||
1247 | 854 | na_tray_get_manager (NaTray *tray) | ||
1248 | 855 | { | ||
1249 | 856 | g_return_val_if_fail (NA_IS_TRAY (tray), NULL); | ||
1250 | 857 | |||
1251 | 858 | return tray->priv->trays_screen->tray_manager; | ||
1252 | 859 | } | ||
1253 | 860 | 864 | ||
1254 | === modified file 'unity-misc/na-tray.h' | |||
1255 | --- unity-misc/na-tray.h 2011-02-14 20:01:14 +0000 | |||
1256 | +++ unity-misc/na-tray.h 2011-06-16 13:19:23 +0000 | |||
1257 | @@ -29,8 +29,6 @@ | |||
1258 | 29 | #endif | 29 | #endif |
1259 | 30 | #include <gtk/gtk.h> | 30 | #include <gtk/gtk.h> |
1260 | 31 | 31 | ||
1261 | 32 | #include <unity-misc/na-tray-manager.h> | ||
1262 | 33 | |||
1263 | 34 | G_BEGIN_DECLS | 32 | G_BEGIN_DECLS |
1264 | 35 | 33 | ||
1265 | 36 | #define NA_TYPE_TRAY (na_tray_get_type ()) | 34 | #define NA_TYPE_TRAY (na_tray_get_type ()) |
1266 | @@ -44,8 +42,6 @@ | |||
1267 | 44 | typedef struct _NaTrayPrivate NaTrayPrivate; | 42 | typedef struct _NaTrayPrivate NaTrayPrivate; |
1268 | 45 | typedef struct _NaTrayClass NaTrayClass; | 43 | typedef struct _NaTrayClass NaTrayClass; |
1269 | 46 | 44 | ||
1270 | 47 | typedef gboolean (*NaTrayFilterCallback) (NaTray *tray, GtkWidget *icon, gpointer data); | ||
1271 | 48 | |||
1272 | 49 | struct _NaTray | 45 | struct _NaTray |
1273 | 50 | { | 46 | { |
1274 | 51 | GtkBin parent_instance; | 47 | GtkBin parent_instance; |
1275 | @@ -59,17 +55,22 @@ | |||
1276 | 59 | }; | 55 | }; |
1277 | 60 | 56 | ||
1278 | 61 | GType na_tray_get_type (void); | 57 | GType na_tray_get_type (void); |
1283 | 62 | NaTray *na_tray_new_for_screen (GdkScreen *screen, | 58 | NaTray *na_tray_new_for_screen (GdkScreen *screen, |
1284 | 63 | GtkOrientation orientation, | 59 | GtkOrientation orientation); |
1281 | 64 | NaTrayFilterCallback cb, | ||
1282 | 65 | gpointer data); | ||
1285 | 66 | void na_tray_set_orientation (NaTray *tray, | 60 | void na_tray_set_orientation (NaTray *tray, |
1286 | 67 | GtkOrientation orientation); | 61 | GtkOrientation orientation); |
1287 | 68 | GtkOrientation na_tray_get_orientation (NaTray *tray); | 62 | GtkOrientation na_tray_get_orientation (NaTray *tray); |
1288 | 63 | void na_tray_set_padding (NaTray *tray, | ||
1289 | 64 | gint padding); | ||
1290 | 65 | void na_tray_set_icon_size (NaTray *tray, | ||
1291 | 66 | gint icon_size); | ||
1292 | 67 | void na_tray_set_colors (NaTray *tray, | ||
1293 | 68 | GdkColor *fg, | ||
1294 | 69 | GdkColor *error, | ||
1295 | 70 | GdkColor *warning, | ||
1296 | 71 | GdkColor *success); | ||
1297 | 69 | void na_tray_force_redraw (NaTray *tray); | 72 | void na_tray_force_redraw (NaTray *tray); |
1298 | 70 | 73 | ||
1299 | 71 | NaTrayManager * na_tray_get_manager (NaTray *tray); | ||
1300 | 72 | |||
1301 | 73 | G_END_DECLS | 74 | G_END_DECLS |
1302 | 74 | 75 | ||
1303 | 75 | #endif /* __NA_TRAY_H__ */ | 76 | #endif /* __NA_TRAY_H__ */ |