Merge lp:~3v1n0/bamf/bamfdaemon-gdbus into lp:bamf/0.4
- bamfdaemon-gdbus
- Merge into 0.4
Status: | Merged | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Approved by: | Marco Trevisan (Treviño) | ||||||||||||
Approved revision: | 450 | ||||||||||||
Merged at revision: | 426 | ||||||||||||
Proposed branch: | lp:~3v1n0/bamf/bamfdaemon-gdbus | ||||||||||||
Merge into: | lp:bamf/0.4 | ||||||||||||
Diff against target: |
7188 lines (+2713/-1892) 43 files modified
configure.in (+7/-2) src/Makefile.am (+66/-63) src/bamf-application-glue.xml (+0/-45) src/bamf-application.c (+164/-88) src/bamf-application.h (+24/-25) src/bamf-control-glue.xml (+0/-35) src/bamf-control.c (+126/-81) src/bamf-control.h (+20/-24) src/bamf-daemon.c (+215/-0) src/bamf-daemon.h (+61/-0) src/bamf-indicator-glue.xml (+0/-23) src/bamf-indicator-source-glue.xml (+0/-28) src/bamf-indicator-source.c (+225/-167) src/bamf-indicator-source.h (+21/-24) src/bamf-indicator.c (+133/-67) src/bamf-indicator.h (+30/-32) src/bamf-marshal.list (+2/-5) src/bamf-matcher-glue.xml (+0/-108) src/bamf-matcher.c (+283/-158) src/bamf-matcher.h (+28/-31) src/bamf-tab-glue.xml (+0/-39) src/bamf-tab-source.c (+159/-140) src/bamf-tab-source.h (+3/-2) src/bamf-tab.c (+132/-31) src/bamf-tab.h (+4/-3) src/bamf-view-glue.xml (+0/-109) src/bamf-view.c (+386/-225) src/bamf-view.h (+50/-60) src/bamf-window-glue.xml (+0/-30) src/bamf-window.c (+102/-37) src/bamf-window.h (+4/-4) src/bamf.h (+7/-1) src/com.canonical.StatusNotifierApprover.xml (+19/-0) src/main.c (+9/-49) src/main.h (+4/-9) src/org.ayatana.bamf.browser.xml (+35/-0) src/org.ayatana.bamf.view.xml (+120/-0) src/org.ayatana.bamf.xml (+77/-0) tests/bamfdaemon/Makefile.am (+23/-25) tests/bamfdaemon/run-xvfb.sh (+16/-0) tests/bamfdaemon/test-application.c (+46/-24) tests/bamfdaemon/test-bamf.c (+63/-59) tests/bamfdaemon/test-view.c (+49/-39) |
||||||||||||
To merge this branch: | bzr merge lp:~3v1n0/bamf/bamfdaemon-gdbus | ||||||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Jason Smith (community) | Approve | ||
Mikkel Kamstrup Erlandsen | Pending | ||
Review via email: mp+86843@code.launchpad.net |
Commit message
Description of the change
Ported the BAMF daemon to GDBus, using gdbus-codegen to generate most of the low-level code.
The BamfMatcher and BamfControl are directly extending the generated skeleton class, while the Views are now extending the generated BamfDBusItemObj
Then, I've added a BamfDaemon class to handle the daemon initialization and termination, and I've updated the tests against the new internal APIs.
Finally, I've also ported all the code for indicators and tabs, while I guess that this is now quite obsolete (the indicator part shouldn't totally, but the tabs really are), so maybe it could safely be removed.
I also want to make clear that the public DBus API interface has not been touched by this porting, so the new bamfdaemon can safely replace the old one (in fact I'm using it on my PC for some days with no crashes or unexpected behavior).
The port of libbamf will begin soon as well, and doing that maybe we should refine also the DBus interface.
PS: of course I've also included some random code fixes and cleanup.
Michal Hruby (mhr3) wrote : | # |
Marco Trevisan (Treviño) (3v1n0) wrote : | # |
Thanks for your review. I've made the changes you suggested to me.
Also, I've disabled the indicator approver, since it is currently deprecated (after a chat with Ted).
Unity Merger (unity-merger) wrote : | # |
The Jenkins job https:/
Not merging it.
Jason Smith (jassmith) wrote : | # |
Works for me, please fix jenkins issues :)
Mikkel Kamstrup Erlandsen (kamstrup) wrote : | # |
Marking branch approved again. I have no idea why jenkins silently fails...
Unity Merger (unity-merger) wrote : | # |
Attempt to merge into lp:bamf failed due to conflicts:
text conflict in configure.in
Unity Merger (unity-merger) wrote : | # |
The Jenkins job https:/
Not merging it.
Unity Merger (unity-merger) wrote : | # |
The Jenkins job https:/
Not merging it.
Unity Merger (unity-merger) wrote : | # |
The Jenkins job https:/
Not merging it.
Unity Merger (unity-merger) wrote : | # |
The Jenkins job https:/
Not merging it.
Unity Merger (unity-merger) wrote : | # |
There are additional revisions which have not been approved in review. Please seek review and approval of these new revisions.
Unity Merger (unity-merger) wrote : | # |
The Jenkins job https:/
Not merging it.
Unity Merger (unity-merger) wrote : | # |
The Jenkins job https:/
Not merging it.
Unity Merger (unity-merger) wrote : | # |
The Jenkins job https:/
Not merging it.
- 450. By Marco Trevisan (Treviño)
-
tests, BamfDaemon: removed typo.
Preview Diff
1 | === modified file 'configure.in' | |||
2 | --- configure.in 2012-01-12 15:08:42 +0000 | |||
3 | +++ configure.in 2012-01-19 19:16:25 +0000 | |||
4 | @@ -2,7 +2,7 @@ | |||
5 | 2 | # Process this file with autoconf to produce a configure script. | 2 | # Process this file with autoconf to produce a configure script. |
6 | 3 | 3 | ||
7 | 4 | AC_PREREQ([2.63]) | 4 | AC_PREREQ([2.63]) |
9 | 5 | AC_INIT(bamf, 0.2.106, dx-team@canonical.com) | 5 | AC_INIT(bamf, 0.2.107, dx-team@canonical.com) |
10 | 6 | AC_PREREQ(2.62) | 6 | AC_PREREQ(2.62) |
11 | 7 | 7 | ||
12 | 8 | AC_CONFIG_SRCDIR(src/main.c) | 8 | AC_CONFIG_SRCDIR(src/main.c) |
13 | @@ -56,7 +56,12 @@ | |||
14 | 56 | # | 56 | # |
15 | 57 | # glib | 57 | # glib |
16 | 58 | # | 58 | # |
18 | 59 | PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.28.0 gio-2.0 gio-unix-2.0) | 59 | PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.28.0 gio-2.0 >= 2.30.0 gio-unix-2.0) |
19 | 60 | |||
20 | 61 | # | ||
21 | 62 | # gdbus-codegen | ||
22 | 63 | # | ||
23 | 64 | AC_PATH_PROG([GDBUS_CODEGEN], [gdbus-codegen], AC_MSG_ERROR([gdbus-codegen is required but was not found])) | ||
24 | 60 | 65 | ||
25 | 61 | # | 66 | # |
26 | 62 | # dbus | 67 | # dbus |
27 | 63 | 68 | ||
28 | === modified file 'src/Makefile.am' | |||
29 | --- src/Makefile.am 2010-07-09 08:05:06 +0000 | |||
30 | +++ src/Makefile.am 2012-01-19 19:16:25 +0000 | |||
31 | @@ -5,10 +5,10 @@ | |||
32 | 5 | 5 | ||
33 | 6 | include $(top_srcdir)/Makefile.am.marshal | 6 | include $(top_srcdir)/Makefile.am.marshal |
34 | 7 | 7 | ||
39 | 8 | INCLUDE = \ | 8 | INCLUDE = \ |
40 | 9 | -I. \ | 9 | -I. \ |
41 | 10 | -I$(srcdir) \ | 10 | -I$(srcdir) \ |
42 | 11 | $(NULL) | 11 | $(NULL) |
43 | 12 | 12 | ||
44 | 13 | bamfdaemondir = $(libexecdir) | 13 | bamfdaemondir = $(libexecdir) |
45 | 14 | 14 | ||
46 | @@ -16,39 +16,36 @@ | |||
47 | 16 | bamfdaemon \ | 16 | bamfdaemon \ |
48 | 17 | $(NULL) | 17 | $(NULL) |
49 | 18 | 18 | ||
59 | 19 | bamfdaemon_glue_files = \ | 19 | bamfdaemon_gdbus_files = \ |
60 | 20 | bamf-application-glue.h \ | 20 | bamf-gdbus-generated.c \ |
61 | 21 | bamf-control-glue.h \ | 21 | bamf-gdbus-generated.h \ |
62 | 22 | bamf-matcher-glue.h \ | 22 | bamf-gdbus-view-generated.c \ |
63 | 23 | bamf-window-glue.h \ | 23 | bamf-gdbus-view-generated.h \ |
64 | 24 | bamf-view-glue.h \ | 24 | bamf-gdbus-browser-generated.c \ |
65 | 25 | bamf-tab-glue.h \ | 25 | bamf-gdbus-browser-generated.h \ |
66 | 26 | bamf-indicator-source-glue.h \ | 26 | bamf-gdbus-indicator-source-generated.c \ |
67 | 27 | bamf-indicator-glue.h \ | 27 | bamf-gdbus-indicator-source-generated.h \ |
68 | 28 | $(NULL) | 28 | $(NULL) |
79 | 29 | 29 | ||
80 | 30 | bamfdaemon_xml_glue_files = \ | 30 | bamfdaemon_xml_gdbus_files = \ |
81 | 31 | bamf-application-glue.xml \ | 31 | org.ayatana.bamf.xml \ |
82 | 32 | bamf-control-glue.xml \ | 32 | org.ayatana.bamf.view.xml \ |
83 | 33 | bamf-matcher-glue.xml \ | 33 | org.ayatana.bamf.browser.xml \ |
84 | 34 | bamf-window-glue.xml \ | 34 | com.canonical.StatusNotifierApprover.xml \ |
75 | 35 | bamf-view-glue.xml \ | ||
76 | 36 | bamf-tab-glue.xml \ | ||
77 | 37 | bamf-indicator-source-glue.xml \ | ||
78 | 38 | bamf-indicator-glue.xml \ | ||
85 | 39 | $(NULL) | 35 | $(NULL) |
86 | 40 | 36 | ||
87 | 41 | bamfdaemon_built_sources = \ | 37 | bamfdaemon_built_sources = \ |
88 | 42 | bamf-marshal.c \ | 38 | bamf-marshal.c \ |
89 | 43 | bamf-marshal.h \ | 39 | bamf-marshal.h \ |
91 | 44 | $(bamfdaemon_glue_files) \ | 40 | $(bamfdaemon_gdbus_files) \ |
92 | 45 | $(NULL) | 41 | $(NULL) |
93 | 46 | 42 | ||
94 | 47 | bamfdaemon_sources = \ | 43 | bamfdaemon_sources = \ |
95 | 48 | main.c \ | 44 | main.c \ |
96 | 45 | bamf-daemon.c \ | ||
97 | 49 | bamf-legacy-window.c \ | 46 | bamf-legacy-window.c \ |
98 | 50 | bamf-legacy-window-test.c \ | 47 | bamf-legacy-window-test.c \ |
100 | 51 | bamf-legacy-screen.c \ | 48 | bamf-legacy-screen.c \ |
101 | 52 | bamf-view.c \ | 49 | bamf-view.c \ |
102 | 53 | bamf-control.c \ | 50 | bamf-control.c \ |
103 | 54 | bamf-matcher.c \ | 51 | bamf-matcher.c \ |
104 | @@ -63,9 +60,10 @@ | |||
105 | 63 | bamfdaemon_headers = \ | 60 | bamfdaemon_headers = \ |
106 | 64 | main.h \ | 61 | main.h \ |
107 | 65 | bamf.h \ | 62 | bamf.h \ |
108 | 63 | bamf-daemon.h \ | ||
109 | 66 | bamf-legacy-window.h \ | 64 | bamf-legacy-window.h \ |
110 | 67 | bamf-legacy-window-test.h \ | 65 | bamf-legacy-window-test.h \ |
112 | 68 | bamf-legacy-screen.h \ | 66 | bamf-legacy-screen.h \ |
113 | 69 | bamf-view.h \ | 67 | bamf-view.h \ |
114 | 70 | bamf-control.h \ | 68 | bamf-control.h \ |
115 | 71 | bamf-matcher.h \ | 69 | bamf-matcher.h \ |
116 | @@ -78,27 +76,22 @@ | |||
117 | 78 | $(NULL) | 76 | $(NULL) |
118 | 79 | 77 | ||
119 | 80 | bamfdaemon_SOURCES = \ | 78 | bamfdaemon_SOURCES = \ |
121 | 81 | $(bamfdaemon_built_sources) \ | 79 | $(bamfdaemon_built_sources) \ |
122 | 82 | $(bamfdaemon_sources) \ | 80 | $(bamfdaemon_sources) \ |
123 | 83 | $(bamfdaemon_headers) \ | 81 | $(bamfdaemon_headers) \ |
124 | 84 | $(NULL) | 82 | $(NULL) |
125 | 85 | 83 | ||
126 | 86 | nodist_EXTRA_bamfdaemon_SOURCES = \ | 84 | nodist_EXTRA_bamfdaemon_SOURCES = \ |
128 | 87 | $(bamfdaemon_glue_files) \ | 85 | $(bamfdaemon_gdbus_files) \ |
129 | 88 | $(NULL) | 86 | $(NULL) |
130 | 89 | 87 | ||
131 | 90 | glib_marshal_list = bamf-marshal.list | 88 | glib_marshal_list = bamf-marshal.list |
132 | 91 | glib_marshal_prefix = bamf_marshal | 89 | glib_marshal_prefix = bamf_marshal |
133 | 92 | 90 | ||
134 | 93 | DISTCLEANFILES += \ | ||
135 | 94 | $(bamfdaemon_glue_files) \ | ||
136 | 95 | $(NULL) | ||
137 | 96 | |||
138 | 97 | bamfdaemon_LDADD = \ | 91 | bamfdaemon_LDADD = \ |
139 | 98 | $(X_LIBS) \ | 92 | $(X_LIBS) \ |
140 | 99 | $(GLIB_LIBS) \ | 93 | $(GLIB_LIBS) \ |
141 | 100 | $(GTK_LIBS) \ | 94 | $(GTK_LIBS) \ |
142 | 101 | $(DBUS_LIBS) \ | ||
143 | 102 | $(WNCK_LIBS) \ | 95 | $(WNCK_LIBS) \ |
144 | 103 | $(GTOP_LIBS) \ | 96 | $(GTOP_LIBS) \ |
145 | 104 | $(NULL) | 97 | $(NULL) |
146 | @@ -109,7 +102,6 @@ | |||
147 | 109 | -DWNCK_I_KNOW_THIS_IS_UNSTABLE \ | 102 | -DWNCK_I_KNOW_THIS_IS_UNSTABLE \ |
148 | 110 | $(GLIB_CFLAGS) \ | 103 | $(GLIB_CFLAGS) \ |
149 | 111 | $(GTK_CFLAGS) \ | 104 | $(GTK_CFLAGS) \ |
150 | 112 | $(DBUS_CFLAGS) \ | ||
151 | 113 | $(WNCK_CFLAGS) \ | 105 | $(WNCK_CFLAGS) \ |
152 | 114 | $(GTOP_CFLAGS) \ | 106 | $(GTOP_CFLAGS) \ |
153 | 115 | $(NULL) | 107 | $(NULL) |
154 | @@ -118,36 +110,47 @@ | |||
155 | 118 | -Xlinker -export-dynamic -Wl,-O1 -Wl,-Bsymbolic-functions \ | 110 | -Xlinker -export-dynamic -Wl,-O1 -Wl,-Bsymbolic-functions \ |
156 | 119 | $(NULL) | 111 | $(NULL) |
157 | 120 | 112 | ||
181 | 121 | bamf-application-glue.h: bamf-application-glue.xml Makefile | 113 | bamf-gdbus-generated.c bamf-gdbus-generated.h: org.ayatana.bamf.xml |
182 | 122 | $(LIBTOOL) --mode=execute $(DBUS_GLIB_BIN)/dbus-binding-tool --prefix=bamf_application --mode=glib-server --output=$@ $< | 114 | $(AM_V_GEN) $(GDBUS_CODEGEN) \ |
183 | 123 | 115 | --generate-c-code bamf-gdbus-generated \ | |
184 | 124 | bamf-control-glue.h: bamf-control-glue.xml Makefile | 116 | --c-namespace BamfDBus \ |
185 | 125 | $(LIBTOOL) --mode=execute $(DBUS_GLIB_BIN)/dbus-binding-tool --prefix=bamf_control --mode=glib-server --output=$@ $< | 117 | --interface-prefix org.ayatana.bamf \ |
186 | 126 | 118 | $< | |
187 | 127 | bamf-matcher-glue.h: bamf-matcher-glue.xml Makefile | 119 | |
188 | 128 | $(LIBTOOL) --mode=execute $(DBUS_GLIB_BIN)/dbus-binding-tool --prefix=bamf_matcher --mode=glib-server --output=$@ $< | 120 | bamf-gdbus-view-generated.c bamf-gdbus-view-generated.h: org.ayatana.bamf.view.xml |
189 | 129 | 121 | $(AM_V_GEN) $(GDBUS_CODEGEN) \ | |
190 | 130 | bamf-window-glue.h: bamf-window-glue.xml Makefile | 122 | --c-generate-object-manager \ |
191 | 131 | $(LIBTOOL) --mode=execute $(DBUS_GLIB_BIN)/dbus-binding-tool --prefix=bamf_window --mode=glib-server --output=$@ $< | 123 | --generate-c-code bamf-gdbus-view-generated \ |
192 | 132 | 124 | --c-namespace BamfDBusItem \ | |
193 | 133 | bamf-view-glue.h: bamf-view-glue.xml Makefile | 125 | --interface-prefix org.ayatana.bamf \ |
194 | 134 | $(LIBTOOL) --mode=execute $(DBUS_GLIB_BIN)/dbus-binding-tool --prefix=bamf_view --mode=glib-server --output=$@ $< | 126 | $< |
195 | 135 | 127 | ||
196 | 136 | bamf-tab-glue.h: bamf-tab-glue.xml Makefile | 128 | bamf-gdbus-browser-generated.c bamf-gdbus-browser-generated.h: org.ayatana.bamf.browser.xml |
197 | 137 | $(LIBTOOL) --mode=execute $(DBUS_GLIB_BIN)/dbus-binding-tool --prefix=bamf_tab --mode=glib-server --output=$@ $< | 129 | $(AM_V_GEN) $(GDBUS_CODEGEN) \ |
198 | 138 | 130 | --generate-c-code bamf-gdbus-browser-generated \ | |
199 | 139 | bamf-indicator-source-glue.h: bamf-indicator-source-glue.xml Makefile | 131 | --c-namespace BamfDBusBrowser \ |
200 | 140 | $(LIBTOOL) --mode=execute $(DBUS_GLIB_BIN)/dbus-binding-tool --prefix=bamf_indicator_source --mode=glib-server --output=$@ $< | 132 | --interface-prefix org.ayatana.bamf.browser \ |
201 | 141 | 133 | $< | |
202 | 142 | bamf-indicator-glue.h: bamf-indicator-glue.xml Makefile | 134 | |
203 | 143 | $(LIBTOOL) --mode=execute $(DBUS_GLIB_BIN)/dbus-binding-tool --prefix=bamf_indicator --mode=glib-server --output=$@ $< | 135 | bamf-gdbus-indicator-source-generated.c bamf-gdbus-indicator-source-generated.h: com.canonical.StatusNotifierApprover.xml |
204 | 136 | $(AM_V_GEN) $(GDBUS_CODEGEN) \ | ||
205 | 137 | --generate-c-code bamf-gdbus-indicator-source-generated \ | ||
206 | 138 | --c-namespace StatusNotifierApprover \ | ||
207 | 139 | --interface-prefix com.canonical.StatusNotifierApprover \ | ||
208 | 140 | $< | ||
209 | 144 | 141 | ||
210 | 145 | BUILT_SOURCES += \ | 142 | BUILT_SOURCES += \ |
213 | 146 | $(bamfdaemon_glue_files) \ | 143 | $(bamfdaemon_gdbus_files) \ |
214 | 147 | $(NULL) | 144 | $(NULL) |
215 | 148 | 145 | ||
216 | 149 | EXTRA_DIST += \ | 146 | EXTRA_DIST += \ |
221 | 150 | $(bamfdaemon_xml_glue_files) \ | 147 | $(bamfdaemon_xml_gdbus_files) \ |
222 | 151 | $(NULL) | 148 | $(NULL) |
223 | 152 | 149 | ||
224 | 153 | 150 | DISTCLEANFILES += \ | |
225 | 151 | $(bamfdaemon_built_sources) \ | ||
226 | 152 | $(NULL) | ||
227 | 153 | |||
228 | 154 | CLEANFILES += \ | ||
229 | 155 | $(bamfdaemon_built_sources) \ | ||
230 | 156 | $(NULL) | ||
231 | 154 | 157 | ||
232 | === removed file 'src/bamf-application-glue.xml' | |||
233 | --- src/bamf-application-glue.xml 2010-09-10 16:41:41 +0000 | |||
234 | +++ src/bamf-application-glue.xml 1970-01-01 00:00:00 +0000 | |||
235 | @@ -1,45 +0,0 @@ | |||
236 | 1 | <?xml version="1.0" encoding="UTF-8" ?> | ||
237 | 2 | |||
238 | 3 | <node name="/org/ayatana/bamf"> | ||
239 | 4 | |||
240 | 5 | <interface name="org.ayatana.bamf.application"> | ||
241 | 6 | |||
242 | 7 | <signal name="WindowAdded"> | ||
243 | 8 | <arg type="s" name="path" direction="out" /> | ||
244 | 9 | </signal> | ||
245 | 10 | |||
246 | 11 | <signal name="WindowRemoved"> | ||
247 | 12 | <arg type="s" name="path" direction="out" /> | ||
248 | 13 | </signal> | ||
249 | 14 | |||
250 | 15 | <method name="ApplicationType"> | ||
251 | 16 | <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_application_get_application_type" /> | ||
252 | 17 | <arg type="s" name="type" direction="out"> | ||
253 | 18 | <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/> | ||
254 | 19 | </arg> | ||
255 | 20 | </method> | ||
256 | 21 | |||
257 | 22 | <method name="DesktopFile"> | ||
258 | 23 | <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_application_get_desktop_file" /> | ||
259 | 24 | <arg type="s" name="desktop_file" direction="out"> | ||
260 | 25 | <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/> | ||
261 | 26 | </arg> | ||
262 | 27 | </method> | ||
263 | 28 | |||
264 | 29 | <method name="Xids"> | ||
265 | 30 | <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_application_get_xids" /> | ||
266 | 31 | <arg type="au" name="xids" direction="out"> | ||
267 | 32 | <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/> | ||
268 | 33 | </arg> | ||
269 | 34 | </method> | ||
270 | 35 | |||
271 | 36 | <method name="ShowStubs"> | ||
272 | 37 | <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_application_get_show_stubs" /> | ||
273 | 38 | <arg type="b" name="show_stubs" direction="out"> | ||
274 | 39 | <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/> | ||
275 | 40 | </arg> | ||
276 | 41 | </method> | ||
277 | 42 | |||
278 | 43 | </interface> | ||
279 | 44 | |||
280 | 45 | </node> | ||
281 | 46 | 0 | ||
282 | === modified file 'src/bamf-application.c' | |||
283 | --- src/bamf-application.c 2011-12-14 03:17:37 +0000 | |||
284 | +++ src/bamf-application.c 2012-01-19 19:16:25 +0000 | |||
285 | @@ -1,5 +1,5 @@ | |||
286 | 1 | /* | 1 | /* |
288 | 2 | * Copyright (C) 2010 Canonical Ltd | 2 | * Copyright (C) 2010-2011 Canonical Ltd |
289 | 3 | * | 3 | * |
290 | 4 | * This program is free software: you can redistribute it and/or modify | 4 | * This program is free software: you can redistribute it and/or modify |
291 | 5 | * it under the terms of the GNU General Public License version 3 as | 5 | * it under the terms of the GNU General Public License version 3 as |
292 | @@ -14,12 +14,11 @@ | |||
293 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
294 | 15 | * | 15 | * |
295 | 16 | * Authored by: Jason Smith <jason.smith@canonical.com> | 16 | * Authored by: Jason Smith <jason.smith@canonical.com> |
296 | 17 | * Marco Trevisan (Treviño) <3v1n0@ubuntu.com> | ||
297 | 17 | * | 18 | * |
298 | 18 | */ | 19 | */ |
299 | 19 | 20 | ||
300 | 20 | |||
301 | 21 | #include "bamf-application.h" | 21 | #include "bamf-application.h" |
302 | 22 | #include "bamf-application-glue.h" | ||
303 | 23 | #include "bamf-window.h" | 22 | #include "bamf-window.h" |
304 | 24 | #include "bamf-matcher.h" | 23 | #include "bamf-matcher.h" |
305 | 25 | #include "bamf-indicator.h" | 24 | #include "bamf-indicator.h" |
306 | @@ -28,22 +27,17 @@ | |||
307 | 28 | #include <string.h> | 27 | #include <string.h> |
308 | 29 | #include <gio/gdesktopappinfo.h> | 28 | #include <gio/gdesktopappinfo.h> |
309 | 30 | 29 | ||
310 | 31 | G_DEFINE_TYPE (BamfApplication, bamf_application, BAMF_TYPE_VIEW); | ||
311 | 32 | #define BAMF_APPLICATION_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE(obj, \ | 30 | #define BAMF_APPLICATION_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE(obj, \ |
312 | 33 | BAMF_TYPE_APPLICATION, BamfApplicationPrivate)) | 31 | BAMF_TYPE_APPLICATION, BamfApplicationPrivate)) |
313 | 34 | 32 | ||
323 | 35 | enum | 33 | static void bamf_application_dbus_application_iface_init (BamfDBusItemApplicationIface *iface); |
324 | 36 | { | 34 | G_DEFINE_TYPE_WITH_CODE (BamfApplication, bamf_application, BAMF_TYPE_VIEW, |
325 | 37 | WINDOW_ADDED, | 35 | G_IMPLEMENT_INTERFACE (BAMF_DBUS_ITEM_TYPE_APPLICATION, |
326 | 38 | WINDOW_REMOVED, | 36 | bamf_application_dbus_application_iface_init)); |
318 | 39 | |||
319 | 40 | LAST_SIGNAL, | ||
320 | 41 | }; | ||
321 | 42 | |||
322 | 43 | static guint application_signals[LAST_SIGNAL] = { 0 }; | ||
327 | 44 | 37 | ||
328 | 45 | struct _BamfApplicationPrivate | 38 | struct _BamfApplicationPrivate |
329 | 46 | { | 39 | { |
330 | 40 | BamfDBusItemApplication *dbus_iface; | ||
331 | 47 | char * desktop_file; | 41 | char * desktop_file; |
332 | 48 | GList * desktop_file_list; | 42 | GList * desktop_file_list; |
333 | 49 | char * app_type; | 43 | char * app_type; |
334 | @@ -153,27 +147,32 @@ | |||
335 | 153 | /* This will error to return false, which is okay as it seems | 147 | /* This will error to return false, which is okay as it seems |
336 | 154 | unlikely anyone will want to set this flag except to turn | 148 | unlikely anyone will want to set this flag except to turn |
337 | 155 | off the stub menus. */ | 149 | off the stub menus. */ |
339 | 156 | self->priv->show_stubs = g_key_file_get_boolean(keyfile, G_KEY_FILE_DESKTOP_GROUP, STUB_KEY, NULL); | 150 | self->priv->show_stubs = g_key_file_get_boolean (keyfile, |
340 | 151 | G_KEY_FILE_DESKTOP_GROUP, | ||
341 | 152 | STUB_KEY, NULL); | ||
342 | 157 | } | 153 | } |
343 | 158 | 154 | ||
362 | 159 | if (g_key_file_has_key(keyfile, G_KEY_FILE_DESKTOP_GROUP, "X-GNOME-FullName", NULL)) | 155 | if (g_key_file_has_key (keyfile, G_KEY_FILE_DESKTOP_GROUP, "X-GNOME-FullName", NULL)) |
363 | 160 | { | 156 | { |
364 | 161 | /* Grab the better name if its available */ | 157 | /* Grab the better name if its available */ |
365 | 162 | gchar *fullname = NULL; | 158 | gchar *fullname = NULL; |
366 | 163 | error = NULL; | 159 | error = NULL; |
367 | 164 | fullname = g_key_file_get_locale_string (keyfile, G_KEY_FILE_DESKTOP_GROUP, "X-GNOME-FullName", NULL, &error); | 160 | fullname = g_key_file_get_locale_string (keyfile, |
368 | 165 | if (error != NULL) | 161 | G_KEY_FILE_DESKTOP_GROUP, |
369 | 166 | { | 162 | "X-GNOME-FullName", NULL, |
370 | 167 | g_error_free (error); | 163 | &error); |
371 | 168 | if (fullname) | 164 | if (error != NULL) |
372 | 169 | g_free (fullname); | 165 | { |
373 | 170 | } | 166 | g_error_free (error); |
374 | 171 | else | 167 | if (fullname) |
375 | 172 | { | 168 | g_free (fullname); |
376 | 173 | g_free (name); | 169 | } |
377 | 174 | name = fullname; | 170 | else |
378 | 175 | } | 171 | { |
379 | 176 | } | 172 | g_free (name); |
380 | 173 | name = fullname; | ||
381 | 174 | } | ||
382 | 175 | } | ||
383 | 177 | 176 | ||
384 | 178 | g_object_unref (desktop); | 177 | g_object_unref (desktop); |
385 | 179 | g_key_file_free(keyfile); | 178 | g_key_file_free(keyfile); |
386 | @@ -274,17 +273,18 @@ | |||
387 | 274 | application->priv->wmclass = NULL; | 273 | application->priv->wmclass = NULL; |
388 | 275 | } | 274 | } |
389 | 276 | 275 | ||
391 | 277 | GArray * | 276 | GVariant * |
392 | 278 | bamf_application_get_xids (BamfApplication *application) | 277 | bamf_application_get_xids (BamfApplication *application) |
393 | 279 | { | 278 | { |
394 | 280 | GList *l; | 279 | GList *l; |
396 | 281 | GArray *xids; | 280 | GVariantBuilder b; |
397 | 282 | BamfView *view; | 281 | BamfView *view; |
398 | 283 | guint32 xid; | 282 | guint32 xid; |
399 | 284 | 283 | ||
400 | 285 | g_return_val_if_fail (BAMF_IS_APPLICATION (application), NULL); | 284 | g_return_val_if_fail (BAMF_IS_APPLICATION (application), NULL); |
401 | 286 | 285 | ||
403 | 287 | xids = g_array_new (FALSE, TRUE, sizeof (guint32)); | 286 | g_variant_builder_init (&b, G_VARIANT_TYPE ("(au)")); |
404 | 287 | g_variant_builder_open (&b, G_VARIANT_TYPE ("au")); | ||
405 | 288 | 288 | ||
406 | 289 | for (l = bamf_view_get_children (BAMF_VIEW (application)); l; l = l->next) | 289 | for (l = bamf_view_get_children (BAMF_VIEW (application)); l; l = l->next) |
407 | 290 | { | 290 | { |
408 | @@ -294,11 +294,12 @@ | |||
409 | 294 | continue; | 294 | continue; |
410 | 295 | 295 | ||
411 | 296 | xid = bamf_window_get_xid (BAMF_WINDOW (view)); | 296 | xid = bamf_window_get_xid (BAMF_WINDOW (view)); |
414 | 297 | 297 | g_variant_builder_add (&b, "u", xid); | |
413 | 298 | g_array_append_val (xids, xid); | ||
415 | 299 | } | 298 | } |
416 | 300 | 299 | ||
418 | 301 | return xids; | 300 | g_variant_builder_close (&b); |
419 | 301 | |||
420 | 302 | return g_variant_builder_end (&b); | ||
421 | 302 | } | 303 | } |
422 | 303 | 304 | ||
423 | 304 | gboolean | 305 | gboolean |
424 | @@ -339,32 +340,32 @@ | |||
425 | 339 | bamf_application_manages_xid (BamfApplication *application, | 340 | bamf_application_manages_xid (BamfApplication *application, |
426 | 340 | guint32 xid) | 341 | guint32 xid) |
427 | 341 | { | 342 | { |
430 | 342 | GArray *xids; | 343 | GList *l; |
429 | 343 | int i; | ||
431 | 344 | gboolean result = FALSE; | 344 | gboolean result = FALSE; |
432 | 345 | 345 | ||
433 | 346 | g_return_val_if_fail (BAMF_IS_APPLICATION (application), FALSE); | 346 | g_return_val_if_fail (BAMF_IS_APPLICATION (application), FALSE); |
434 | 347 | 347 | ||
438 | 348 | xids = bamf_application_get_xids (application); | 348 | for (l = bamf_view_get_children (BAMF_VIEW (application)); l; l = l->next) |
436 | 349 | |||
437 | 350 | for (i = 0; i < xids->len; i++) | ||
439 | 351 | { | 349 | { |
441 | 352 | if (g_array_index (xids, guint32, i) == xid) | 350 | BamfView *view = l->data; |
442 | 351 | |||
443 | 352 | if (!BAMF_IS_WINDOW (view)) | ||
444 | 353 | continue; | ||
445 | 354 | |||
446 | 355 | if (bamf_window_get_xid (BAMF_WINDOW (view)) == xid) | ||
447 | 353 | { | 356 | { |
448 | 354 | result = TRUE; | 357 | result = TRUE; |
449 | 355 | break; | 358 | break; |
450 | 356 | } | 359 | } |
451 | 357 | } | 360 | } |
452 | 358 | 361 | ||
453 | 359 | g_array_free (xids, TRUE); | ||
454 | 360 | |||
455 | 361 | return result; | 362 | return result; |
456 | 362 | } | 363 | } |
457 | 363 | 364 | ||
459 | 364 | static char * | 365 | static const char * |
460 | 365 | bamf_application_get_view_type (BamfView *view) | 366 | bamf_application_get_view_type (BamfView *view) |
461 | 366 | { | 367 | { |
463 | 367 | return g_strdup ("application"); | 368 | return "application"; |
464 | 368 | } | 369 | } |
465 | 369 | 370 | ||
466 | 370 | static char * | 371 | static char * |
467 | @@ -455,7 +456,7 @@ | |||
468 | 455 | static void | 456 | static void |
469 | 456 | view_exported (BamfView *view, BamfApplication *self) | 457 | view_exported (BamfView *view, BamfApplication *self) |
470 | 457 | { | 458 | { |
472 | 458 | g_signal_emit (self, application_signals[WINDOW_ADDED], 0, bamf_view_get_path (view)); | 459 | g_signal_emit_by_name (self, "window-added", bamf_view_get_path (view)); |
473 | 459 | } | 460 | } |
474 | 460 | 461 | ||
475 | 461 | static void | 462 | static void |
476 | @@ -468,7 +469,7 @@ | |||
477 | 468 | if (BAMF_IS_WINDOW (child)) | 469 | if (BAMF_IS_WINDOW (child)) |
478 | 469 | { | 470 | { |
479 | 470 | if (bamf_view_is_on_bus (child)) | 471 | if (bamf_view_is_on_bus (child)) |
481 | 471 | g_signal_emit (BAMF_APPLICATION (view), application_signals[WINDOW_ADDED], 0, bamf_view_get_path (child)); | 472 | g_signal_emit_by_name (BAMF_APPLICATION (view), "window-added", bamf_view_get_path (child)); |
482 | 472 | else | 473 | else |
483 | 473 | g_signal_connect (G_OBJECT (child), "exported", | 474 | g_signal_connect (G_OBJECT (child), "exported", |
484 | 474 | (GCallback) view_exported, view); | 475 | (GCallback) view_exported, view); |
485 | @@ -486,15 +487,6 @@ | |||
486 | 486 | bamf_application_setup_icon_and_name (application); | 487 | bamf_application_setup_icon_and_name (application); |
487 | 487 | } | 488 | } |
488 | 488 | 489 | ||
489 | 489 | static gboolean | ||
490 | 490 | on_empty (GObject *object) | ||
491 | 491 | { | ||
492 | 492 | g_return_val_if_fail (BAMF_IS_VIEW (object), FALSE); | ||
493 | 493 | |||
494 | 494 | bamf_view_close (BAMF_VIEW (object)); | ||
495 | 495 | return FALSE; | ||
496 | 496 | } | ||
497 | 497 | |||
498 | 498 | static char * | 490 | static char * |
499 | 499 | bamf_application_favorite_from_list (BamfApplication *self, GList *list) | 491 | bamf_application_favorite_from_list (BamfApplication *self, GList *list) |
500 | 500 | { | 492 | { |
501 | @@ -518,7 +510,7 @@ | |||
502 | 518 | } | 510 | } |
503 | 519 | } | 511 | } |
504 | 520 | } | 512 | } |
506 | 521 | 513 | ||
507 | 522 | return result; | 514 | return result; |
508 | 523 | } | 515 | } |
509 | 524 | 516 | ||
510 | @@ -560,7 +552,8 @@ | |||
511 | 560 | if (BAMF_IS_WINDOW (child)) | 552 | if (BAMF_IS_WINDOW (child)) |
512 | 561 | { | 553 | { |
513 | 562 | if (bamf_view_is_on_bus (child)) | 554 | if (bamf_view_is_on_bus (child)) |
515 | 563 | g_signal_emit (BAMF_APPLICATION (view), application_signals[WINDOW_REMOVED],0, bamf_view_get_path (child)); | 555 | g_signal_emit_by_name (BAMF_APPLICATION (view), "window-removed", |
516 | 556 | bamf_view_get_path (child)); | ||
517 | 564 | } | 557 | } |
518 | 565 | 558 | ||
519 | 566 | g_signal_handlers_disconnect_by_func (G_OBJECT (child), view_active_changed, view); | 559 | g_signal_handlers_disconnect_by_func (G_OBJECT (child), view_active_changed, view); |
520 | @@ -569,9 +562,9 @@ | |||
521 | 569 | 562 | ||
522 | 570 | bamf_application_ensure_flags (BAMF_APPLICATION (view)); | 563 | bamf_application_ensure_flags (BAMF_APPLICATION (view)); |
523 | 571 | 564 | ||
525 | 572 | if (g_list_length (bamf_view_get_children (view)) == 0) | 565 | if (bamf_view_get_children (view) == NULL) |
526 | 573 | { | 566 | { |
528 | 574 | g_idle_add ((GSourceFunc) on_empty, view); | 567 | bamf_view_close (view); |
529 | 575 | } | 568 | } |
530 | 576 | } | 569 | } |
531 | 577 | 570 | ||
532 | @@ -584,7 +577,7 @@ | |||
533 | 584 | g_return_if_fail (BAMF_IS_MATCHER (matcher)); | 577 | g_return_if_fail (BAMF_IS_MATCHER (matcher)); |
534 | 585 | 578 | ||
535 | 586 | new_desktop_file = bamf_application_favorite_from_list (self, self->priv->desktop_file_list); | 579 | new_desktop_file = bamf_application_favorite_from_list (self, self->priv->desktop_file_list); |
537 | 587 | 580 | ||
538 | 588 | if (new_desktop_file) | 581 | if (new_desktop_file) |
539 | 589 | { | 582 | { |
540 | 590 | bamf_application_set_desktop_file (self, new_desktop_file); | 583 | bamf_application_set_desktop_file (self, new_desktop_file); |
541 | @@ -592,6 +585,67 @@ | |||
542 | 592 | } | 585 | } |
543 | 593 | 586 | ||
544 | 594 | static void | 587 | static void |
545 | 588 | on_window_added (BamfApplication *self, const gchar *win_path, gpointer _not_used) | ||
546 | 589 | { | ||
547 | 590 | g_return_if_fail (BAMF_IS_APPLICATION (self)); | ||
548 | 591 | g_signal_emit_by_name (self->priv->dbus_iface, "window-added", win_path); | ||
549 | 592 | } | ||
550 | 593 | |||
551 | 594 | static void | ||
552 | 595 | on_window_removed (BamfApplication *self, const gchar *win_path, gpointer _not_used) | ||
553 | 596 | { | ||
554 | 597 | g_return_if_fail (BAMF_IS_APPLICATION (self)); | ||
555 | 598 | g_signal_emit_by_name (self->priv->dbus_iface, "window-removed", win_path); | ||
556 | 599 | } | ||
557 | 600 | |||
558 | 601 | static gboolean | ||
559 | 602 | on_dbus_handle_show_stubs (BamfDBusItemApplication *interface, | ||
560 | 603 | GDBusMethodInvocation *invocation, | ||
561 | 604 | BamfApplication *self) | ||
562 | 605 | { | ||
563 | 606 | gboolean show_stubs = bamf_application_get_show_stubs (self); | ||
564 | 607 | g_dbus_method_invocation_return_value (invocation, | ||
565 | 608 | g_variant_new ("(b)", show_stubs)); | ||
566 | 609 | |||
567 | 610 | return TRUE; | ||
568 | 611 | } | ||
569 | 612 | |||
570 | 613 | static gboolean | ||
571 | 614 | on_dbus_handle_xids (BamfDBusItemApplication *interface, | ||
572 | 615 | GDBusMethodInvocation *invocation, | ||
573 | 616 | BamfApplication *self) | ||
574 | 617 | { | ||
575 | 618 | GVariant *xids = bamf_application_get_xids (self); | ||
576 | 619 | g_dbus_method_invocation_return_value (invocation, xids); | ||
577 | 620 | |||
578 | 621 | return TRUE; | ||
579 | 622 | } | ||
580 | 623 | |||
581 | 624 | static gboolean | ||
582 | 625 | on_dbus_handle_desktop_file (BamfDBusItemApplication *interface, | ||
583 | 626 | GDBusMethodInvocation *invocation, | ||
584 | 627 | BamfApplication *self) | ||
585 | 628 | { | ||
586 | 629 | const char *desktop_file = self->priv->desktop_file ? self->priv->desktop_file : ""; | ||
587 | 630 | g_dbus_method_invocation_return_value (invocation, | ||
588 | 631 | g_variant_new ("(s)", desktop_file)); | ||
589 | 632 | |||
590 | 633 | return TRUE; | ||
591 | 634 | } | ||
592 | 635 | |||
593 | 636 | static gboolean | ||
594 | 637 | on_dbus_handle_application_type (BamfDBusItemApplication *interface, | ||
595 | 638 | GDBusMethodInvocation *invocation, | ||
596 | 639 | BamfApplication *self) | ||
597 | 640 | { | ||
598 | 641 | const char *type = self->priv->app_type ? self->priv->app_type : ""; | ||
599 | 642 | g_dbus_method_invocation_return_value (invocation, | ||
600 | 643 | g_variant_new ("(s)", type)); | ||
601 | 644 | |||
602 | 645 | return TRUE; | ||
603 | 646 | } | ||
604 | 647 | |||
605 | 648 | static void | ||
606 | 595 | bamf_application_dispose (GObject *object) | 649 | bamf_application_dispose (GObject *object) |
607 | 596 | { | 650 | { |
608 | 597 | BamfApplication *app; | 651 | BamfApplication *app; |
609 | @@ -629,13 +683,25 @@ | |||
610 | 629 | g_free (priv->wmclass); | 683 | g_free (priv->wmclass); |
611 | 630 | priv->wmclass = NULL; | 684 | priv->wmclass = NULL; |
612 | 631 | } | 685 | } |
615 | 632 | 686 | ||
616 | 633 | g_signal_handlers_disconnect_by_func (G_OBJECT (bamf_matcher_get_default ()), matcher_favorites_changed, object); | 687 | g_signal_handlers_disconnect_by_func (G_OBJECT (bamf_matcher_get_default ()), |
617 | 688 | matcher_favorites_changed, object); | ||
618 | 634 | 689 | ||
619 | 635 | G_OBJECT_CLASS (bamf_application_parent_class)->dispose (object); | 690 | G_OBJECT_CLASS (bamf_application_parent_class)->dispose (object); |
620 | 636 | } | 691 | } |
621 | 637 | 692 | ||
622 | 638 | static void | 693 | static void |
623 | 694 | bamf_application_finalize (GObject *object) | ||
624 | 695 | { | ||
625 | 696 | BamfApplication *self; | ||
626 | 697 | self = BAMF_APPLICATION (object); | ||
627 | 698 | |||
628 | 699 | g_object_unref (self->priv->dbus_iface); | ||
629 | 700 | |||
630 | 701 | G_OBJECT_CLASS (bamf_application_parent_class)->finalize (object); | ||
631 | 702 | } | ||
632 | 703 | |||
633 | 704 | static void | ||
634 | 639 | bamf_application_init (BamfApplication * self) | 705 | bamf_application_init (BamfApplication * self) |
635 | 640 | { | 706 | { |
636 | 641 | BamfApplicationPrivate *priv; | 707 | BamfApplicationPrivate *priv; |
637 | @@ -645,18 +711,49 @@ | |||
638 | 645 | priv->app_type = g_strdup ("system"); | 711 | priv->app_type = g_strdup ("system"); |
639 | 646 | priv->show_stubs = TRUE; | 712 | priv->show_stubs = TRUE; |
640 | 647 | priv->wmclass = NULL; | 713 | priv->wmclass = NULL; |
642 | 648 | 714 | ||
643 | 715 | /* Initializing the dbus interface */ | ||
644 | 716 | priv->dbus_iface = bamf_dbus_item_application_skeleton_new (); | ||
645 | 717 | |||
646 | 718 | /* We need to connect to the object own signals to redirect them to the dbus | ||
647 | 719 | * interface */ | ||
648 | 720 | g_signal_connect (self, "window-added", G_CALLBACK (on_window_added), NULL); | ||
649 | 721 | g_signal_connect (self, "window-removed", G_CALLBACK (on_window_removed), NULL); | ||
650 | 722 | |||
651 | 723 | /* Registering signal callbacks to reply to dbus method calls */ | ||
652 | 724 | g_signal_connect (priv->dbus_iface, "handle-show-stubs", | ||
653 | 725 | G_CALLBACK (on_dbus_handle_show_stubs), self); | ||
654 | 726 | |||
655 | 727 | g_signal_connect (priv->dbus_iface, "handle-xids", | ||
656 | 728 | G_CALLBACK (on_dbus_handle_xids), self); | ||
657 | 729 | |||
658 | 730 | g_signal_connect (priv->dbus_iface, "handle-desktop-file", | ||
659 | 731 | G_CALLBACK (on_dbus_handle_desktop_file), self); | ||
660 | 732 | |||
661 | 733 | g_signal_connect (priv->dbus_iface, "handle-application-type", | ||
662 | 734 | G_CALLBACK (on_dbus_handle_application_type), self); | ||
663 | 735 | |||
664 | 736 | /* Setting the interface for the dbus object */ | ||
665 | 737 | bamf_dbus_item_object_skeleton_set_application (BAMF_DBUS_ITEM_OBJECT_SKELETON (self), | ||
666 | 738 | priv->dbus_iface); | ||
667 | 739 | |||
668 | 649 | g_signal_connect (G_OBJECT (bamf_matcher_get_default ()), "favorites-changed", | 740 | g_signal_connect (G_OBJECT (bamf_matcher_get_default ()), "favorites-changed", |
669 | 650 | (GCallback) matcher_favorites_changed, self); | 741 | (GCallback) matcher_favorites_changed, self); |
670 | 651 | } | 742 | } |
671 | 652 | 743 | ||
672 | 653 | static void | 744 | static void |
673 | 745 | bamf_application_dbus_application_iface_init (BamfDBusItemApplicationIface *iface) | ||
674 | 746 | { | ||
675 | 747 | } | ||
676 | 748 | |||
677 | 749 | static void | ||
678 | 654 | bamf_application_class_init (BamfApplicationClass * klass) | 750 | bamf_application_class_init (BamfApplicationClass * klass) |
679 | 655 | { | 751 | { |
680 | 656 | GObjectClass *object_class = G_OBJECT_CLASS (klass); | 752 | GObjectClass *object_class = G_OBJECT_CLASS (klass); |
681 | 657 | BamfViewClass *view_class = BAMF_VIEW_CLASS (klass); | 753 | BamfViewClass *view_class = BAMF_VIEW_CLASS (klass); |
682 | 658 | 754 | ||
683 | 659 | object_class->dispose = bamf_application_dispose; | 755 | object_class->dispose = bamf_application_dispose; |
684 | 756 | object_class->finalize = bamf_application_finalize; | ||
685 | 660 | 757 | ||
686 | 661 | view_class->view_type = bamf_application_get_view_type; | 758 | view_class->view_type = bamf_application_get_view_type; |
687 | 662 | view_class->child_added = bamf_application_child_added; | 759 | view_class->child_added = bamf_application_child_added; |
688 | @@ -665,27 +762,6 @@ | |||
689 | 665 | view_class->stable_bus_name = bamf_application_get_stable_bus_name; | 762 | view_class->stable_bus_name = bamf_application_get_stable_bus_name; |
690 | 666 | 763 | ||
691 | 667 | g_type_class_add_private (klass, sizeof (BamfApplicationPrivate)); | 764 | g_type_class_add_private (klass, sizeof (BamfApplicationPrivate)); |
692 | 668 | |||
693 | 669 | dbus_g_object_type_install_info (BAMF_TYPE_APPLICATION, | ||
694 | 670 | &dbus_glib_bamf_application_object_info); | ||
695 | 671 | |||
696 | 672 | application_signals [WINDOW_ADDED] = | ||
697 | 673 | g_signal_new ("window-added", | ||
698 | 674 | G_OBJECT_CLASS_TYPE (klass), | ||
699 | 675 | 0, | ||
700 | 676 | 0, NULL, NULL, | ||
701 | 677 | g_cclosure_marshal_VOID__STRING, | ||
702 | 678 | G_TYPE_NONE, 1, | ||
703 | 679 | G_TYPE_STRING); | ||
704 | 680 | |||
705 | 681 | application_signals [WINDOW_REMOVED] = | ||
706 | 682 | g_signal_new ("window-removed", | ||
707 | 683 | G_OBJECT_CLASS_TYPE (klass), | ||
708 | 684 | 0, | ||
709 | 685 | 0, NULL, NULL, | ||
710 | 686 | g_cclosure_marshal_VOID__STRING, | ||
711 | 687 | G_TYPE_NONE, 1, | ||
712 | 688 | G_TYPE_STRING); | ||
713 | 689 | } | 765 | } |
714 | 690 | 766 | ||
715 | 691 | BamfApplication * | 767 | BamfApplication * |
716 | 692 | 768 | ||
717 | === modified file 'src/bamf-application.h' | |||
718 | --- src/bamf-application.h 2011-06-21 23:45:49 +0000 | |||
719 | +++ src/bamf-application.h 2012-01-19 19:16:25 +0000 | |||
720 | @@ -1,5 +1,5 @@ | |||
721 | 1 | /* | 1 | /* |
723 | 2 | * Copyright (C) 2010 Canonical Ltd | 2 | * Copyright (C) 2010-2011 Canonical Ltd |
724 | 3 | * | 3 | * |
725 | 4 | * This program is free software: you can redistribute it and/or modify | 4 | * This program is free software: you can redistribute it and/or modify |
726 | 5 | * it under the terms of the GNU General Public License version 3 as | 5 | * it under the terms of the GNU General Public License version 3 as |
727 | @@ -14,6 +14,7 @@ | |||
728 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
729 | 15 | * | 15 | * |
730 | 16 | * Authored by: Jason Smith <jason.smith@canonical.com> | 16 | * Authored by: Jason Smith <jason.smith@canonical.com> |
731 | 17 | * Marco Trevisan (Treviño) <3v1n0@ubuntu.com> | ||
732 | 17 | * | 18 | * |
733 | 18 | */ | 19 | */ |
734 | 19 | 20 | ||
735 | @@ -50,33 +51,31 @@ | |||
736 | 50 | BamfApplicationPrivate *priv; | 51 | BamfApplicationPrivate *priv; |
737 | 51 | }; | 52 | }; |
738 | 52 | 53 | ||
751 | 53 | GType bamf_application_get_type (void) G_GNUC_CONST; | 54 | GType bamf_application_get_type (void) G_GNUC_CONST; |
752 | 54 | 55 | ||
753 | 55 | char * bamf_application_get_application_type (BamfApplication *application); | 56 | char * bamf_application_get_desktop_file (BamfApplication *application); |
754 | 56 | 57 | void bamf_application_set_desktop_file (BamfApplication *application, | |
755 | 57 | char * bamf_application_get_desktop_file (BamfApplication *application); | 58 | const char * desktop_file); |
756 | 58 | void bamf_application_set_desktop_file (BamfApplication *application, | 59 | |
757 | 59 | const char * desktop_file); | 60 | GVariant * bamf_application_get_xids (BamfApplication *application); |
758 | 60 | 61 | ||
759 | 61 | GArray * bamf_application_get_xids (BamfApplication *application); | 62 | gboolean bamf_application_manages_xid (BamfApplication *application, |
760 | 62 | 63 | guint32 xid); | |
749 | 63 | gboolean bamf_application_manages_xid (BamfApplication *application, | ||
750 | 64 | guint32 xid); | ||
761 | 65 | 64 | ||
762 | 66 | gboolean bamf_application_contains_similar_to_window (BamfApplication *app, | 65 | gboolean bamf_application_contains_similar_to_window (BamfApplication *app, |
763 | 67 | BamfWindow *window); | 66 | BamfWindow *window); |
764 | 68 | 67 | ||
777 | 69 | char * bamf_application_get_wmclass (BamfApplication *application); | 68 | char * bamf_application_get_wmclass (BamfApplication *application); |
778 | 70 | void bamf_application_set_wmclass (BamfApplication *application, | 69 | void bamf_application_set_wmclass (BamfApplication *application, |
779 | 71 | const char *wmclass); | 70 | const char *wmclass); |
780 | 72 | 71 | ||
781 | 73 | BamfApplication * bamf_application_new (void); | 72 | BamfApplication * bamf_application_new (void); |
782 | 74 | 73 | ||
783 | 75 | BamfApplication * bamf_application_new_from_desktop_file (const char * desktop_file); | 74 | BamfApplication * bamf_application_new_from_desktop_file (const char * desktop_file); |
784 | 76 | gboolean bamf_application_get_show_stubs (BamfApplication *application); | 75 | gboolean bamf_application_get_show_stubs (BamfApplication *application); |
785 | 77 | 76 | ||
786 | 78 | BamfApplication * bamf_application_new_from_desktop_files (GList * desktop_files); | 77 | BamfApplication * bamf_application_new_from_desktop_files (GList * desktop_files); |
787 | 79 | 78 | ||
788 | 80 | BamfApplication * bamf_application_new_with_wmclass (const char *wmclass); | 79 | BamfApplication * bamf_application_new_with_wmclass (const char *wmclass); |
789 | 81 | 80 | ||
790 | 82 | #endif | 81 | #endif |
791 | 83 | 82 | ||
792 | === removed file 'src/bamf-control-glue.xml' | |||
793 | --- src/bamf-control-glue.xml 2010-08-18 23:22:58 +0000 | |||
794 | +++ src/bamf-control-glue.xml 1970-01-01 00:00:00 +0000 | |||
795 | @@ -1,35 +0,0 @@ | |||
796 | 1 | <?xml version="1.0" encoding="UTF-8" ?> | ||
797 | 2 | |||
798 | 3 | <node name="/org/ayatana/bamf"> | ||
799 | 4 | |||
800 | 5 | <interface name="org.ayatana.bamf.control"> | ||
801 | 6 | |||
802 | 7 | <method name="RegisterApplicationForPid"> | ||
803 | 8 | <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_control_register_application_for_pid" /> | ||
804 | 9 | <arg type="s" name="application" direction="in" /> | ||
805 | 10 | <arg type="i" name="pid" direction="in" /> | ||
806 | 11 | </method> | ||
807 | 12 | |||
808 | 13 | <method name="RegisterTabProvider"> | ||
809 | 14 | <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_control_register_tab_provider" /> | ||
810 | 15 | <annotation name="org.freedesktop.DBus.GLib.Async" value="" /> | ||
811 | 16 | <arg type="s" name="tab_path" direction="in" /> | ||
812 | 17 | </method> | ||
813 | 18 | |||
814 | 19 | <method name="OmNomNomDesktopFile"> | ||
815 | 20 | <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_control_insert_desktop_file" /> | ||
816 | 21 | <arg type="s" name="tab_path" direction="in" /> | ||
817 | 22 | </method> | ||
818 | 23 | |||
819 | 24 | <method name="SetApproverBehavior"> | ||
820 | 25 | <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_control_set_approver_behavior" /> | ||
821 | 26 | <arg type="i" name="behavior" direction="in" /> | ||
822 | 27 | </method> | ||
823 | 28 | |||
824 | 29 | <method name="Quit"> | ||
825 | 30 | <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_control_quit" /> | ||
826 | 31 | </method> | ||
827 | 32 | |||
828 | 33 | </interface> | ||
829 | 34 | |||
830 | 35 | </node> | ||
831 | 36 | 0 | ||
832 | === modified file 'src/bamf-control.c' | |||
833 | --- src/bamf-control.c 2011-08-01 23:25:01 +0000 | |||
834 | +++ src/bamf-control.c 2012-01-19 19:16:25 +0000 | |||
835 | @@ -1,5 +1,5 @@ | |||
836 | 1 | /* | 1 | /* |
838 | 2 | * Copyright (C) 2010 Canonical Ltd | 2 | * Copyright (C) 2010-2011 Canonical Ltd |
839 | 3 | * | 3 | * |
840 | 4 | * This program is free software: you can redistribute it and/or modify | 4 | * This program is free software: you can redistribute it and/or modify |
841 | 5 | * it under the terms of the GNU General Public License version 3 as | 5 | * it under the terms of the GNU General Public License version 3 as |
842 | @@ -14,6 +14,7 @@ | |||
843 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
844 | 15 | * | 15 | * |
845 | 16 | * Authored by: Jason Smith <jason.smith@canonical.com> | 16 | * Authored by: Jason Smith <jason.smith@canonical.com> |
846 | 17 | * Marco Trevisan (Treviño) <3v1n0@ubuntu.com> | ||
847 | 17 | * | 18 | * |
848 | 18 | */ | 19 | */ |
849 | 19 | 20 | ||
850 | @@ -21,11 +22,10 @@ | |||
851 | 21 | #include "bamf-tab-source.h" | 22 | #include "bamf-tab-source.h" |
852 | 22 | #include "bamf-matcher.h" | 23 | #include "bamf-matcher.h" |
853 | 23 | #include "bamf-control.h" | 24 | #include "bamf-control.h" |
854 | 24 | #include "bamf-control-glue.h" | ||
855 | 25 | #include "bamf-indicator-source.h" | 25 | #include "bamf-indicator-source.h" |
857 | 26 | #include <gtk/gtk.h> | 26 | #include "bamf-daemon.h" |
858 | 27 | 27 | ||
860 | 28 | G_DEFINE_TYPE (BamfControl, bamf_control, G_TYPE_OBJECT); | 28 | G_DEFINE_TYPE (BamfControl, bamf_control, BAMF_DBUS_TYPE_CONTROL_SKELETON); |
861 | 29 | #define BAMF_CONTROL_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE(obj, \ | 29 | #define BAMF_CONTROL_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE(obj, \ |
862 | 30 | BAMF_TYPE_CONTROL, BamfControlPrivate)) | 30 | BAMF_TYPE_CONTROL, BamfControlPrivate)) |
863 | 31 | 31 | ||
864 | @@ -56,26 +56,12 @@ | |||
865 | 56 | static void | 56 | static void |
866 | 57 | bamf_control_constructed (GObject *object) | 57 | bamf_control_constructed (GObject *object) |
867 | 58 | { | 58 | { |
871 | 59 | BamfControl *control; | 59 | GDBusConnection *gbus; |
869 | 60 | DBusGConnection *bus; | ||
870 | 61 | GError *error = NULL; | ||
872 | 62 | 60 | ||
873 | 63 | if (G_OBJECT_CLASS (bamf_control_parent_class)->constructed) | 61 | if (G_OBJECT_CLASS (bamf_control_parent_class)->constructed) |
874 | 64 | G_OBJECT_CLASS (bamf_control_parent_class)->constructed (object); | 62 | G_OBJECT_CLASS (bamf_control_parent_class)->constructed (object); |
875 | 65 | 63 | ||
876 | 66 | control = BAMF_CONTROL (object); | ||
877 | 67 | |||
878 | 68 | bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error); | ||
879 | 69 | |||
880 | 70 | g_return_if_fail (bus); | ||
881 | 71 | |||
882 | 72 | dbus_g_connection_register_g_object (bus, BAMF_CONTROL_PATH, | ||
883 | 73 | G_OBJECT (control)); | ||
884 | 74 | |||
885 | 75 | |||
886 | 76 | GDBusConnection *gbus; | ||
887 | 77 | gbus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL); | 64 | gbus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL); |
888 | 78 | |||
889 | 79 | g_dbus_connection_signal_subscribe (gbus, | 65 | g_dbus_connection_signal_subscribe (gbus, |
890 | 80 | NULL, | 66 | NULL, |
891 | 81 | "org.gtk.gio.DesktopAppInfo", | 67 | "org.gtk.gio.DesktopAppInfo", |
892 | @@ -84,14 +70,100 @@ | |||
893 | 84 | NULL, | 70 | NULL, |
894 | 85 | 0, | 71 | 0, |
895 | 86 | bamf_control_on_launched_callback, | 72 | bamf_control_on_launched_callback, |
897 | 87 | control, | 73 | BAMF_CONTROL (object), |
898 | 88 | NULL); | 74 | NULL); |
899 | 89 | } | 75 | } |
900 | 90 | 76 | ||
901 | 77 | static gboolean | ||
902 | 78 | on_dbus_handle_quit (BamfDBusControl *interface, | ||
903 | 79 | GDBusMethodInvocation *invocation, | ||
904 | 80 | BamfControl *self) | ||
905 | 81 | { | ||
906 | 82 | bamf_control_quit (self); | ||
907 | 83 | g_dbus_method_invocation_return_value (invocation, NULL); | ||
908 | 84 | |||
909 | 85 | return TRUE; | ||
910 | 86 | } | ||
911 | 87 | |||
912 | 88 | static gboolean | ||
913 | 89 | on_dbus_handle_set_approver_behavior (BamfDBusControl *interface, | ||
914 | 90 | GDBusMethodInvocation *invocation, | ||
915 | 91 | gint behavior, | ||
916 | 92 | BamfControl *self) | ||
917 | 93 | { | ||
918 | 94 | bamf_control_set_approver_behavior (self, behavior); | ||
919 | 95 | g_dbus_method_invocation_return_value (invocation, NULL); | ||
920 | 96 | |||
921 | 97 | return TRUE; | ||
922 | 98 | } | ||
923 | 99 | |||
924 | 100 | static gboolean | ||
925 | 101 | on_dbus_handle_om_nom_nom_desktop_file (BamfDBusControl *interface, | ||
926 | 102 | GDBusMethodInvocation *invocation, | ||
927 | 103 | const gchar *desktop_file, | ||
928 | 104 | BamfControl *self) | ||
929 | 105 | { | ||
930 | 106 | bamf_control_insert_desktop_file (self, desktop_file); | ||
931 | 107 | g_dbus_method_invocation_return_value (invocation, NULL); | ||
932 | 108 | |||
933 | 109 | return TRUE; | ||
934 | 110 | } | ||
935 | 111 | |||
936 | 112 | static gboolean | ||
937 | 113 | on_dbus_handle_register_tab_provider (BamfDBusControl *interface, | ||
938 | 114 | GDBusMethodInvocation *invocation, | ||
939 | 115 | const gchar *tab_path, | ||
940 | 116 | BamfControl *self) | ||
941 | 117 | { | ||
942 | 118 | const gchar *sender = g_dbus_method_invocation_get_sender (invocation); | ||
943 | 119 | bamf_control_register_tab_provider (self, sender, tab_path); | ||
944 | 120 | g_dbus_method_invocation_return_value (invocation, NULL); | ||
945 | 121 | |||
946 | 122 | return TRUE; | ||
947 | 123 | } | ||
948 | 124 | |||
949 | 125 | static gboolean | ||
950 | 126 | on_dbus_handle_register_application_for_pid (BamfDBusControl *interface, | ||
951 | 127 | GDBusMethodInvocation *invocation, | ||
952 | 128 | const gchar *application, | ||
953 | 129 | guint pid, | ||
954 | 130 | BamfControl *self) | ||
955 | 131 | { | ||
956 | 132 | bamf_control_register_application_for_pid (self, application, pid); | ||
957 | 133 | g_dbus_method_invocation_return_value (invocation, NULL); | ||
958 | 134 | |||
959 | 135 | return TRUE; | ||
960 | 136 | } | ||
961 | 137 | |||
962 | 91 | static void | 138 | static void |
963 | 92 | bamf_control_init (BamfControl * self) | 139 | bamf_control_init (BamfControl * self) |
964 | 93 | { | 140 | { |
965 | 94 | self->priv = BAMF_CONTROL_GET_PRIVATE (self); | 141 | self->priv = BAMF_CONTROL_GET_PRIVATE (self); |
966 | 142 | self->priv->sources = NULL; | ||
967 | 143 | |||
968 | 144 | /* Registering signal callbacks to reply to dbus method calls */ | ||
969 | 145 | g_signal_connect (self, "handle-quit", | ||
970 | 146 | G_CALLBACK (on_dbus_handle_quit), self); | ||
971 | 147 | |||
972 | 148 | g_signal_connect (self, "handle-set-approver-behavior", | ||
973 | 149 | G_CALLBACK (on_dbus_handle_set_approver_behavior), self); | ||
974 | 150 | |||
975 | 151 | g_signal_connect (self, "handle-om-nom-nom-desktop-file", | ||
976 | 152 | G_CALLBACK (on_dbus_handle_om_nom_nom_desktop_file), self); | ||
977 | 153 | |||
978 | 154 | g_signal_connect (self, "handle-register-tab-provider", | ||
979 | 155 | G_CALLBACK (on_dbus_handle_register_tab_provider), self); | ||
980 | 156 | |||
981 | 157 | g_signal_connect (self, "handle-register-application-for-pid", | ||
982 | 158 | G_CALLBACK (on_dbus_handle_register_application_for_pid), self); | ||
983 | 159 | } | ||
984 | 160 | |||
985 | 161 | static void | ||
986 | 162 | bamf_control_finalize (GObject *object) | ||
987 | 163 | { | ||
988 | 164 | BamfControl *self = BAMF_CONTROL (object); | ||
989 | 165 | g_list_free_full (self->priv->sources, g_object_unref); | ||
990 | 166 | self->priv->sources = NULL; | ||
991 | 95 | } | 167 | } |
992 | 96 | 168 | ||
993 | 97 | static void | 169 | static void |
994 | @@ -100,94 +172,68 @@ | |||
995 | 100 | GObjectClass *obj_class = G_OBJECT_CLASS (klass); | 172 | GObjectClass *obj_class = G_OBJECT_CLASS (klass); |
996 | 101 | 173 | ||
997 | 102 | obj_class->constructed = bamf_control_constructed; | 174 | obj_class->constructed = bamf_control_constructed; |
1001 | 103 | 175 | obj_class->finalize = bamf_control_finalize; | |
999 | 104 | dbus_g_object_type_install_info (BAMF_TYPE_CONTROL, | ||
1000 | 105 | &dbus_glib_bamf_control_object_info); | ||
1002 | 106 | 176 | ||
1003 | 107 | g_type_class_add_private (klass, sizeof (BamfControlPrivate)); | 177 | g_type_class_add_private (klass, sizeof (BamfControlPrivate)); |
1004 | 108 | } | 178 | } |
1005 | 109 | 179 | ||
1007 | 110 | gboolean | 180 | void |
1008 | 111 | bamf_control_set_approver_behavior (BamfControl *control, | 181 | bamf_control_set_approver_behavior (BamfControl *control, |
1011 | 112 | gint32 behavior, | 182 | gint32 behavior) |
1010 | 113 | GError **error) | ||
1012 | 114 | { | 183 | { |
1016 | 115 | bamf_indicator_source_set_behavior (bamf_indicator_source_get_default (), behavior); | 184 | BamfIndicatorSource *indicator_source = bamf_indicator_source_get_default (); |
1017 | 116 | 185 | bamf_indicator_source_set_behavior (indicator_source, behavior); | |
1015 | 117 | return TRUE; | ||
1018 | 118 | } | 186 | } |
1019 | 119 | 187 | ||
1021 | 120 | gboolean | 188 | void |
1022 | 121 | bamf_control_register_application_for_pid (BamfControl *control, | 189 | bamf_control_register_application_for_pid (BamfControl *control, |
1026 | 122 | char *application, | 190 | const char *application, |
1027 | 123 | gint32 pid, | 191 | gint32 pid) |
1025 | 124 | GError **error) | ||
1028 | 125 | { | 192 | { |
1033 | 126 | bamf_matcher_register_desktop_file_for_pid (bamf_matcher_get_default (), | 193 | BamfMatcher *matcher = bamf_matcher_get_default (); |
1034 | 127 | application, pid); | 194 | bamf_matcher_register_desktop_file_for_pid (matcher, application, pid); |
1031 | 128 | |||
1032 | 129 | return TRUE; | ||
1035 | 130 | } | 195 | } |
1036 | 131 | 196 | ||
1038 | 132 | gboolean | 197 | void |
1039 | 133 | bamf_control_insert_desktop_file (BamfControl *control, | 198 | bamf_control_insert_desktop_file (BamfControl *control, |
1042 | 134 | char *path, | 199 | const char *path) |
1041 | 135 | GError **error) | ||
1043 | 136 | { | 200 | { |
1047 | 137 | bamf_matcher_load_desktop_file (bamf_matcher_get_default (), path); | 201 | BamfMatcher *matcher = bamf_matcher_get_default (); |
1048 | 138 | 202 | bamf_matcher_load_desktop_file (matcher, path); | |
1046 | 139 | return TRUE; | ||
1049 | 140 | } | 203 | } |
1050 | 141 | 204 | ||
1052 | 142 | gboolean | 205 | void |
1053 | 143 | bamf_control_register_tab_provider (BamfControl *control, | 206 | bamf_control_register_tab_provider (BamfControl *control, |
1056 | 144 | char *path, | 207 | const char *sender, |
1057 | 145 | DBusGMethodInvocation *context) | 208 | const char *path) |
1058 | 146 | { | 209 | { |
1059 | 147 | BamfTabSource *source; | 210 | BamfTabSource *source; |
1088 | 148 | char *bus; | 211 | |
1089 | 149 | 212 | if (!path || !sender) | |
1090 | 150 | if (!path) | 213 | { |
1091 | 151 | { | 214 | return; |
1092 | 152 | dbus_g_method_return (context); | 215 | } |
1093 | 153 | return TRUE; | 216 | |
1094 | 154 | } | 217 | source = bamf_tab_source_new (g_strdup (sender), g_strdup (path)); |
1095 | 155 | 218 | ||
1096 | 156 | bus = dbus_g_method_get_sender (context); | 219 | if (BAMF_IS_TAB_SOURCE (source)) |
1097 | 157 | 220 | { | |
1098 | 158 | if (!bus) | 221 | control->priv->sources = g_list_prepend (control->priv->sources, source); |
1099 | 159 | { | 222 | } |
1072 | 160 | dbus_g_method_return (context); | ||
1073 | 161 | return TRUE; | ||
1074 | 162 | } | ||
1075 | 163 | |||
1076 | 164 | source = bamf_tab_source_new (bus, path); | ||
1077 | 165 | |||
1078 | 166 | if (!BAMF_IS_TAB_SOURCE (source)) | ||
1079 | 167 | { | ||
1080 | 168 | dbus_g_method_return (context); | ||
1081 | 169 | return TRUE; | ||
1082 | 170 | } | ||
1083 | 171 | |||
1084 | 172 | control->priv->sources = g_list_prepend (control->priv->sources, source); | ||
1085 | 173 | |||
1086 | 174 | dbus_g_method_return (context); | ||
1087 | 175 | return TRUE; | ||
1100 | 176 | } | 223 | } |
1101 | 177 | 224 | ||
1102 | 178 | static gboolean | 225 | static gboolean |
1103 | 179 | bamf_control_on_quit (BamfControl *control) | 226 | bamf_control_on_quit (BamfControl *control) |
1104 | 180 | { | 227 | { |
1106 | 181 | gtk_main_quit (); | 228 | BamfDaemon *daemon = bamf_daemon_get_default (); |
1107 | 229 | bamf_daemon_stop (daemon); | ||
1108 | 182 | return FALSE; | 230 | return FALSE; |
1109 | 183 | } | 231 | } |
1110 | 184 | 232 | ||
1114 | 185 | gboolean | 233 | void |
1115 | 186 | bamf_control_quit (BamfControl *control, | 234 | bamf_control_quit (BamfControl *control) |
1113 | 187 | GError **error) | ||
1116 | 188 | { | 235 | { |
1117 | 189 | g_idle_add ((GSourceFunc) bamf_control_on_quit, control); | 236 | g_idle_add ((GSourceFunc) bamf_control_on_quit, control); |
1118 | 190 | return TRUE; | ||
1119 | 191 | } | 237 | } |
1120 | 192 | 238 | ||
1121 | 193 | BamfControl * | 239 | BamfControl * |
1122 | @@ -198,8 +244,7 @@ | |||
1123 | 198 | if (!BAMF_IS_CONTROL (control)) | 244 | if (!BAMF_IS_CONTROL (control)) |
1124 | 199 | { | 245 | { |
1125 | 200 | control = (BamfControl *) g_object_new (BAMF_TYPE_CONTROL, NULL); | 246 | control = (BamfControl *) g_object_new (BAMF_TYPE_CONTROL, NULL); |
1126 | 201 | return control; | ||
1127 | 202 | } | 247 | } |
1128 | 203 | 248 | ||
1130 | 204 | return g_object_ref (G_OBJECT (control)); | 249 | return control; |
1131 | 205 | } | 250 | } |
1132 | 206 | 251 | ||
1133 | === modified file 'src/bamf-control.h' | |||
1134 | --- src/bamf-control.h 2010-08-18 23:22:58 +0000 | |||
1135 | +++ src/bamf-control.h 2012-01-19 19:16:25 +0000 | |||
1136 | @@ -1,5 +1,5 @@ | |||
1137 | 1 | /* | 1 | /* |
1139 | 2 | * Copyright (C) 2010 Canonical Ltd | 2 | * Copyright (C) 2010-2011 Canonical Ltd |
1140 | 3 | * | 3 | * |
1141 | 4 | * This program is free software: you can redistribute it and/or modify | 4 | * This program is free software: you can redistribute it and/or modify |
1142 | 5 | * it under the terms of the GNU General Public License version 3 as | 5 | * it under the terms of the GNU General Public License version 3 as |
1143 | @@ -14,6 +14,7 @@ | |||
1144 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1145 | 15 | * | 15 | * |
1146 | 16 | * Authored by: Jason Smith <jason.smith@canonical.com> | 16 | * Authored by: Jason Smith <jason.smith@canonical.com> |
1147 | 17 | * Marco Trevisan (Treviño) <3v1n0@ubuntu.com> | ||
1148 | 17 | * | 18 | * |
1149 | 18 | */ | 19 | */ |
1150 | 19 | 20 | ||
1151 | @@ -24,8 +25,7 @@ | |||
1152 | 24 | #include "bamf.h" | 25 | #include "bamf.h" |
1153 | 25 | #include <glib.h> | 26 | #include <glib.h> |
1154 | 26 | #include <glib-object.h> | 27 | #include <glib-object.h> |
1157 | 27 | #include <dbus/dbus-glib.h> | 28 | #include <gio/gio.h> |
1156 | 28 | #include <dbus/dbus-glib-lowlevel.h> | ||
1158 | 29 | 29 | ||
1159 | 30 | #define BAMF_TYPE_CONTROL (bamf_control_get_type ()) | 30 | #define BAMF_TYPE_CONTROL (bamf_control_get_type ()) |
1160 | 31 | #define BAMF_CONTROL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BAMF_TYPE_CONTROL, BamfControl)) | 31 | #define BAMF_CONTROL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BAMF_TYPE_CONTROL, BamfControl)) |
1161 | @@ -40,12 +40,12 @@ | |||
1162 | 40 | 40 | ||
1163 | 41 | struct _BamfControlClass | 41 | struct _BamfControlClass |
1164 | 42 | { | 42 | { |
1166 | 43 | GObjectClass parent; | 43 | BamfDBusControlSkeletonClass parent; |
1167 | 44 | }; | 44 | }; |
1168 | 45 | 45 | ||
1169 | 46 | struct _BamfControl | 46 | struct _BamfControl |
1170 | 47 | { | 47 | { |
1172 | 48 | GObject parent; | 48 | BamfDBusControlSkeleton parent; |
1173 | 49 | 49 | ||
1174 | 50 | /* private */ | 50 | /* private */ |
1175 | 51 | BamfControlPrivate *priv; | 51 | BamfControlPrivate *priv; |
1176 | @@ -53,25 +53,21 @@ | |||
1177 | 53 | 53 | ||
1178 | 54 | GType bamf_control_get_type (void) G_GNUC_CONST; | 54 | GType bamf_control_get_type (void) G_GNUC_CONST; |
1179 | 55 | 55 | ||
1199 | 56 | gboolean bamf_control_register_application_for_pid (BamfControl *control, | 56 | void bamf_control_register_application_for_pid (BamfControl *control, |
1200 | 57 | char *application, | 57 | const char *application, |
1201 | 58 | gint32 pid, | 58 | gint32 pid); |
1202 | 59 | GError **error); | 59 | |
1203 | 60 | 60 | void bamf_control_register_tab_provider (BamfControl *control, | |
1204 | 61 | gboolean bamf_control_register_tab_provider (BamfControl *control, | 61 | const char *sender, |
1205 | 62 | char *path, | 62 | const char *path); |
1206 | 63 | DBusGMethodInvocation *context); | 63 | |
1207 | 64 | 64 | void bamf_control_insert_desktop_file (BamfControl *control, | |
1208 | 65 | gboolean bamf_control_insert_desktop_file (BamfControl *control, | 65 | const char *path); |
1209 | 66 | char *path, | 66 | |
1210 | 67 | GError **error); | 67 | void bamf_control_set_approver_behavior (BamfControl *control, |
1211 | 68 | 68 | gint32 behavior); | |
1212 | 69 | gboolean bamf_control_set_approver_behavior (BamfControl *control, | 69 | |
1213 | 70 | gint32 behavior, | 70 | void bamf_control_quit (BamfControl *control); |
1195 | 71 | GError **error); | ||
1196 | 72 | |||
1197 | 73 | gboolean bamf_control_quit (BamfControl *control, | ||
1198 | 74 | GError **error); | ||
1214 | 75 | 71 | ||
1215 | 76 | BamfControl * bamf_control_get_default (void); | 72 | BamfControl * bamf_control_get_default (void); |
1216 | 77 | 73 | ||
1217 | 78 | 74 | ||
1218 | === added file 'src/bamf-daemon.c' | |||
1219 | --- src/bamf-daemon.c 1970-01-01 00:00:00 +0000 | |||
1220 | +++ src/bamf-daemon.c 2012-01-19 19:16:25 +0000 | |||
1221 | @@ -0,0 +1,215 @@ | |||
1222 | 1 | /* | ||
1223 | 2 | * Copyright (C) 2011 Canonical Ltd | ||
1224 | 3 | * | ||
1225 | 4 | * This program is free software: you can redistribute it and/or modify | ||
1226 | 5 | * it under the terms of the GNU General Public License version 3 as | ||
1227 | 6 | * published by the Free Software Foundation. | ||
1228 | 7 | * | ||
1229 | 8 | * This program is distributed in the hope that it will be useful, | ||
1230 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1231 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1232 | 11 | * GNU General Public License for more details. | ||
1233 | 12 | * | ||
1234 | 13 | * You should have received a copy of the GNU General Public License | ||
1235 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1236 | 15 | * | ||
1237 | 16 | * Authored by: Marco Trevisan (Treviño) <3v1n0@ubuntu.com> | ||
1238 | 17 | * | ||
1239 | 18 | */ | ||
1240 | 19 | |||
1241 | 20 | #include "bamf.h" | ||
1242 | 21 | |||
1243 | 22 | #include "bamf-daemon.h" | ||
1244 | 23 | #include "bamf-matcher.h" | ||
1245 | 24 | #include "bamf-control.h" | ||
1246 | 25 | #include "bamf-indicator-source.h" | ||
1247 | 26 | |||
1248 | 27 | G_DEFINE_TYPE (BamfDaemon, bamf_daemon, G_TYPE_OBJECT); | ||
1249 | 28 | #define BAMF_DAEMON_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE(obj, \ | ||
1250 | 29 | BAMF_TYPE_DAEMON, BamfDaemonPrivate)) | ||
1251 | 30 | |||
1252 | 31 | static BamfDaemon *instance = NULL; | ||
1253 | 32 | |||
1254 | 33 | struct _BamfDaemonPrivate | ||
1255 | 34 | { | ||
1256 | 35 | BamfMatcher *matcher; | ||
1257 | 36 | BamfControl *control; | ||
1258 | 37 | BamfIndicatorSource *approver; | ||
1259 | 38 | GMainLoop *loop; | ||
1260 | 39 | }; | ||
1261 | 40 | |||
1262 | 41 | gboolean | ||
1263 | 42 | bamf_daemon_is_running (BamfDaemon *self) | ||
1264 | 43 | { | ||
1265 | 44 | g_return_val_if_fail (self, FALSE); | ||
1266 | 45 | |||
1267 | 46 | if (self->priv->loop && g_main_loop_is_running (self->priv->loop)) | ||
1268 | 47 | { | ||
1269 | 48 | return TRUE; | ||
1270 | 49 | } | ||
1271 | 50 | |||
1272 | 51 | return FALSE; | ||
1273 | 52 | } | ||
1274 | 53 | |||
1275 | 54 | static void | ||
1276 | 55 | bamf_on_bus_acquired (GDBusConnection *connection, const gchar *name, | ||
1277 | 56 | BamfDaemon *self) | ||
1278 | 57 | { | ||
1279 | 58 | GError *error = NULL; | ||
1280 | 59 | g_return_if_fail (BAMF_IS_DAEMON (self)); | ||
1281 | 60 | |||
1282 | 61 | g_debug ("Acquired a message bus connection"); | ||
1283 | 62 | |||
1284 | 63 | g_dbus_connection_set_exit_on_close (connection, TRUE); | ||
1285 | 64 | |||
1286 | 65 | self->priv->matcher = bamf_matcher_get_default (); | ||
1287 | 66 | self->priv->control = bamf_control_get_default (); | ||
1288 | 67 | //self->priv->approver = bamf_indicator_source_get_default (); | ||
1289 | 68 | |||
1290 | 69 | g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (self->priv->matcher), | ||
1291 | 70 | connection, | ||
1292 | 71 | BAMF_MATCHER_PATH, | ||
1293 | 72 | &error); | ||
1294 | 73 | |||
1295 | 74 | if (error) | ||
1296 | 75 | { | ||
1297 | 76 | g_critical ("Can't register BAMF matcher at path %s: %s", BAMF_MATCHER_PATH, | ||
1298 | 77 | error->message); | ||
1299 | 78 | g_clear_error (&error); | ||
1300 | 79 | } | ||
1301 | 80 | |||
1302 | 81 | g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (self->priv->control), | ||
1303 | 82 | connection, | ||
1304 | 83 | BAMF_CONTROL_PATH, | ||
1305 | 84 | &error); | ||
1306 | 85 | |||
1307 | 86 | if (error) | ||
1308 | 87 | { | ||
1309 | 88 | g_critical ("Can't register BAMF control at path %s: %s", BAMF_CONTROL_PATH, | ||
1310 | 89 | error->message); | ||
1311 | 90 | g_clear_error (&error); | ||
1312 | 91 | } | ||
1313 | 92 | /* | ||
1314 | 93 | g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (self->priv->approver), | ||
1315 | 94 | connection, | ||
1316 | 95 | BAMF_INDICATOR_SOURCE_PATH, | ||
1317 | 96 | &error); | ||
1318 | 97 | |||
1319 | 98 | if (error) | ||
1320 | 99 | { | ||
1321 | 100 | g_critical ("Can't register BAMF approver at path %s: %s", | ||
1322 | 101 | BAMF_INDICATOR_SOURCE_PATH, error->message); | ||
1323 | 102 | g_clear_error (&error); | ||
1324 | 103 | } | ||
1325 | 104 | */ | ||
1326 | 105 | } | ||
1327 | 106 | |||
1328 | 107 | static void | ||
1329 | 108 | bamf_on_name_acquired (GDBusConnection *connection, const gchar *name, | ||
1330 | 109 | BamfDaemon *self) | ||
1331 | 110 | { | ||
1332 | 111 | g_debug ("Acquired the name %s", name); | ||
1333 | 112 | } | ||
1334 | 113 | |||
1335 | 114 | static void | ||
1336 | 115 | bamf_on_name_lost (GDBusConnection *connection, const gchar *name, BamfDaemon *self) | ||
1337 | 116 | { | ||
1338 | 117 | g_critical ("Lost the name %s, another BAMF daemon is currently running", name); | ||
1339 | 118 | |||
1340 | 119 | bamf_daemon_stop (self); | ||
1341 | 120 | } | ||
1342 | 121 | |||
1343 | 122 | void | ||
1344 | 123 | bamf_daemon_start (BamfDaemon *self) | ||
1345 | 124 | { | ||
1346 | 125 | g_return_if_fail (BAMF_IS_DAEMON (self)); | ||
1347 | 126 | |||
1348 | 127 | if (bamf_daemon_is_running (self)) | ||
1349 | 128 | return; | ||
1350 | 129 | |||
1351 | 130 | g_bus_own_name (G_BUS_TYPE_SESSION, BAMF_DBUS_SERVICE, | ||
1352 | 131 | G_BUS_NAME_OWNER_FLAGS_NONE, | ||
1353 | 132 | (GBusAcquiredCallback) bamf_on_bus_acquired, | ||
1354 | 133 | (GBusNameAcquiredCallback) bamf_on_name_acquired, | ||
1355 | 134 | (GBusNameLostCallback) bamf_on_name_lost, | ||
1356 | 135 | self, NULL); | ||
1357 | 136 | |||
1358 | 137 | g_main_loop_run (self->priv->loop); | ||
1359 | 138 | } | ||
1360 | 139 | |||
1361 | 140 | void | ||
1362 | 141 | bamf_daemon_stop (BamfDaemon *self) | ||
1363 | 142 | { | ||
1364 | 143 | g_return_if_fail (BAMF_IS_DAEMON (self)); | ||
1365 | 144 | |||
1366 | 145 | if (self->priv->matcher) | ||
1367 | 146 | { | ||
1368 | 147 | g_object_unref (self->priv->matcher); | ||
1369 | 148 | self->priv->matcher = NULL; | ||
1370 | 149 | } | ||
1371 | 150 | |||
1372 | 151 | if (self->priv->control) | ||
1373 | 152 | { | ||
1374 | 153 | g_object_unref (self->priv->control); | ||
1375 | 154 | self->priv->control = NULL; | ||
1376 | 155 | } | ||
1377 | 156 | |||
1378 | 157 | if (self->priv->approver) | ||
1379 | 158 | { | ||
1380 | 159 | g_object_unref (self->priv->approver); | ||
1381 | 160 | self->priv->approver = NULL; | ||
1382 | 161 | } | ||
1383 | 162 | |||
1384 | 163 | g_main_loop_quit (self->priv->loop); | ||
1385 | 164 | } | ||
1386 | 165 | |||
1387 | 166 | static void | ||
1388 | 167 | bamf_daemon_dispose (GObject *object) | ||
1389 | 168 | { | ||
1390 | 169 | BamfDaemon *self = BAMF_DAEMON (object); | ||
1391 | 170 | |||
1392 | 171 | bamf_daemon_stop (self); | ||
1393 | 172 | |||
1394 | 173 | if (self->priv->loop) | ||
1395 | 174 | { | ||
1396 | 175 | g_main_loop_unref (self->priv->loop); | ||
1397 | 176 | self->priv->loop = NULL; | ||
1398 | 177 | } | ||
1399 | 178 | |||
1400 | 179 | G_OBJECT_CLASS (bamf_daemon_parent_class)->dispose (object); | ||
1401 | 180 | } | ||
1402 | 181 | |||
1403 | 182 | static void | ||
1404 | 183 | bamf_daemon_finalize (GObject *object) | ||
1405 | 184 | { | ||
1406 | 185 | instance = NULL; | ||
1407 | 186 | } | ||
1408 | 187 | |||
1409 | 188 | static void | ||
1410 | 189 | bamf_daemon_init (BamfDaemon *self) | ||
1411 | 190 | { | ||
1412 | 191 | BamfDaemonPrivate *priv; | ||
1413 | 192 | priv = self->priv = BAMF_DAEMON_GET_PRIVATE (self); | ||
1414 | 193 | |||
1415 | 194 | priv->loop = g_main_loop_new (NULL, FALSE); | ||
1416 | 195 | } | ||
1417 | 196 | |||
1418 | 197 | static void | ||
1419 | 198 | bamf_daemon_class_init (BamfDaemonClass * klass) | ||
1420 | 199 | { | ||
1421 | 200 | GObjectClass *object_class = G_OBJECT_CLASS (klass); | ||
1422 | 201 | |||
1423 | 202 | object_class->dispose = bamf_daemon_dispose; | ||
1424 | 203 | object_class->finalize = bamf_daemon_finalize; | ||
1425 | 204 | |||
1426 | 205 | g_type_class_add_private (klass, sizeof (BamfDaemonPrivate)); | ||
1427 | 206 | } | ||
1428 | 207 | |||
1429 | 208 | BamfDaemon * | ||
1430 | 209 | bamf_daemon_get_default (void) | ||
1431 | 210 | { | ||
1432 | 211 | if (!BAMF_IS_DAEMON (instance)) | ||
1433 | 212 | instance = (BamfDaemon *) g_object_new (BAMF_TYPE_DAEMON, NULL); | ||
1434 | 213 | |||
1435 | 214 | return instance; | ||
1436 | 215 | } | ||
1437 | 0 | 216 | ||
1438 | === added file 'src/bamf-daemon.h' | |||
1439 | --- src/bamf-daemon.h 1970-01-01 00:00:00 +0000 | |||
1440 | +++ src/bamf-daemon.h 2012-01-19 19:16:25 +0000 | |||
1441 | @@ -0,0 +1,61 @@ | |||
1442 | 1 | /* | ||
1443 | 2 | * Copyright (C) 2011 Canonical Ltd | ||
1444 | 3 | * | ||
1445 | 4 | * This program is free software: you can redistribute it and/or modify | ||
1446 | 5 | * it under the terms of the GNU General Public License version 3 as | ||
1447 | 6 | * published by the Free Software Foundation. | ||
1448 | 7 | * | ||
1449 | 8 | * This program is distributed in the hope that it will be useful, | ||
1450 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1451 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1452 | 11 | * GNU General Public License for more details. | ||
1453 | 12 | * | ||
1454 | 13 | * You should have received a copy of the GNU General Public License | ||
1455 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1456 | 15 | * | ||
1457 | 16 | * Authored by: Marco Trevisan (Treviño) <3v1n0@ubuntu.com> | ||
1458 | 17 | * | ||
1459 | 18 | */ | ||
1460 | 19 | |||
1461 | 20 | #ifndef __BAMFDAEMON_H__ | ||
1462 | 21 | #define __BAMFDAEMON_H__ | ||
1463 | 22 | |||
1464 | 23 | #include "bamf.h" | ||
1465 | 24 | #include <glib.h> | ||
1466 | 25 | #include <glib-object.h> | ||
1467 | 26 | |||
1468 | 27 | #define BAMF_TYPE_DAEMON (bamf_daemon_get_type ()) | ||
1469 | 28 | #define BAMF_DAEMON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BAMF_TYPE_DAEMON, BamfDaemon)) | ||
1470 | 29 | #define BAMF_IS_DAEMON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BAMF_TYPE_DAEMON)) | ||
1471 | 30 | #define BAMF_DAEMON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BAMF_TYPE_DAEMON, BamfDaemonClass)) | ||
1472 | 31 | #define BAMF_IS_DAEMON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BAMF_TYPE_DAEMON)) | ||
1473 | 32 | #define BAMF_DAEMON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BAMF_TYPE_DAEMON, BamfDaemonClass)) | ||
1474 | 33 | |||
1475 | 34 | typedef struct _BamfDaemon BamfDaemon; | ||
1476 | 35 | typedef struct _BamfDaemonClass BamfDaemonClass; | ||
1477 | 36 | typedef struct _BamfDaemonPrivate BamfDaemonPrivate; | ||
1478 | 37 | |||
1479 | 38 | struct _BamfDaemonClass | ||
1480 | 39 | { | ||
1481 | 40 | GObjectClass parent; | ||
1482 | 41 | }; | ||
1483 | 42 | |||
1484 | 43 | struct _BamfDaemon | ||
1485 | 44 | { | ||
1486 | 45 | GObject parent; | ||
1487 | 46 | |||
1488 | 47 | /* private */ | ||
1489 | 48 | BamfDaemonPrivate *priv; | ||
1490 | 49 | }; | ||
1491 | 50 | |||
1492 | 51 | GType bamf_daemon_get_type (void) G_GNUC_CONST; | ||
1493 | 52 | |||
1494 | 53 | void bamf_daemon_start (BamfDaemon *self); | ||
1495 | 54 | |||
1496 | 55 | void bamf_daemon_stop (BamfDaemon *self); | ||
1497 | 56 | |||
1498 | 57 | gboolean bamf_daemon_is_running (BamfDaemon *self); | ||
1499 | 58 | |||
1500 | 59 | BamfDaemon * bamf_daemon_get_default (void); | ||
1501 | 60 | |||
1502 | 61 | #endif //__BAMFDAEMON_H__ | ||
1503 | 0 | 62 | ||
1504 | === removed file 'src/bamf-indicator-glue.xml' | |||
1505 | --- src/bamf-indicator-glue.xml 2010-07-09 08:05:06 +0000 | |||
1506 | +++ src/bamf-indicator-glue.xml 1970-01-01 00:00:00 +0000 | |||
1507 | @@ -1,23 +0,0 @@ | |||
1508 | 1 | <?xml version="1.0" encoding="UTF-8" ?> | ||
1509 | 2 | |||
1510 | 3 | <node name="/org/ayatana/bamf"> | ||
1511 | 4 | |||
1512 | 5 | <interface name="org.ayatana.bamf.indicator"> | ||
1513 | 6 | |||
1514 | 7 | <method name="Path"> | ||
1515 | 8 | <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_indicator_get_path" /> | ||
1516 | 9 | <arg type="s" name="path" direction="out"> | ||
1517 | 10 | <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/> | ||
1518 | 11 | </arg> | ||
1519 | 12 | </method> | ||
1520 | 13 | |||
1521 | 14 | <method name="Address"> | ||
1522 | 15 | <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_indicator_get_address" /> | ||
1523 | 16 | <arg type="s" name="address" direction="out"> | ||
1524 | 17 | <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/> | ||
1525 | 18 | </arg> | ||
1526 | 19 | </method> | ||
1527 | 20 | |||
1528 | 21 | </interface> | ||
1529 | 22 | |||
1530 | 23 | </node> | ||
1531 | 24 | 0 | ||
1532 | === removed file 'src/bamf-indicator-source-glue.xml' | |||
1533 | --- src/bamf-indicator-source-glue.xml 2011-01-14 06:35:14 +0000 | |||
1534 | +++ src/bamf-indicator-source-glue.xml 1970-01-01 00:00:00 +0000 | |||
1535 | @@ -1,28 +0,0 @@ | |||
1536 | 1 | <?xml version="1.0" encoding="UTF-8"?> | ||
1537 | 2 | <node name="/org/ayatana/bamf"> | ||
1538 | 3 | <interface name="com.canonical.StatusNotifierApprover"> | ||
1539 | 4 | <signal name="ReviseJudgement"> | ||
1540 | 5 | <arg type="b" name="approved" direction="out" /> | ||
1541 | 6 | <arg type="s" name="address" direction="out" /> | ||
1542 | 7 | <arg type="o" name="path" direction="out" /> | ||
1543 | 8 | </signal> | ||
1544 | 9 | |||
1545 | 10 | <!-- Methods --> | ||
1546 | 11 | <method name="ApproveItem"> | ||
1547 | 12 | <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_indicator_source_approve_item" /> | ||
1548 | 13 | <!-- KSNI ID --> | ||
1549 | 14 | <arg type="s" name="id" direction="in" /> | ||
1550 | 15 | <!-- KSNI Category --> | ||
1551 | 16 | <arg type="s" name="category" direction="in" /> | ||
1552 | 17 | <!-- Application PID --> | ||
1553 | 18 | <arg type="u" name="pid" direction="in" /> | ||
1554 | 19 | <!-- Application DBus Address --> | ||
1555 | 20 | <arg type="s" name="address" direction="in" /> | ||
1556 | 21 | <!-- Application DBus Path for KSNI interface --> | ||
1557 | 22 | <arg type="o" name="path" direction="in" /> | ||
1558 | 23 | <!-- So, what do you think? --> | ||
1559 | 24 | <arg type="b" name="approved" direction="out" /> | ||
1560 | 25 | </method> | ||
1561 | 26 | |||
1562 | 27 | </interface> | ||
1563 | 28 | </node> | ||
1564 | 29 | 0 | ||
1565 | === modified file 'src/bamf-indicator-source.c' | |||
1566 | --- src/bamf-indicator-source.c 2011-02-09 18:45:53 +0000 | |||
1567 | +++ src/bamf-indicator-source.c 2012-01-19 19:16:25 +0000 | |||
1568 | @@ -1,39 +1,32 @@ | |||
1569 | 1 | /* | 1 | /* |
1581 | 2 | * bamf-notification-approver.c | 2 | * Copyright (C) 2010-2011 Canonical Ltd |
1582 | 3 | * This file is part of BAMF | 3 | * |
1583 | 4 | * | 4 | * This program is free software: you can redistribute it and/or modify |
1584 | 5 | * Copyright (C) 2010 - Jason Smith | 5 | * it under the terms of the GNU General Public License version 3 as |
1585 | 6 | * | 6 | * published by the Free Software Foundation. |
1586 | 7 | * BAMF is free software; you can redistribute it and/or modify | 7 | * |
1587 | 8 | * it under the terms of the GNU General Public License as published by | 8 | * This program is distributed in the hope that it will be useful, |
1577 | 9 | * the Free Software Foundation; either version 2 of the License, or | ||
1578 | 10 | * (at your option) any later version. | ||
1579 | 11 | * | ||
1580 | 12 | * BAMF is distributed in the hope that it will be useful, | ||
1588 | 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1589 | 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1590 | 15 | * GNU General Public License for more details. | 11 | * GNU General Public License for more details. |
1591 | 16 | * | 12 | * |
1592 | 17 | * You should have received a copy of the GNU General Public License | 13 | * You should have received a copy of the GNU General Public License |
1596 | 18 | * along with BAMF; if not, write to the Free Software | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1597 | 19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, | 15 | * |
1598 | 20 | * Boston, MA 02110-1301 USA | 16 | * Authored by: Jason Smith <jason.smith@canonical.com> |
1599 | 17 | * Marco Trevisan (Treviño) <3v1n0@ubuntu.com> | ||
1600 | 18 | * | ||
1601 | 21 | */ | 19 | */ |
1602 | 22 | 20 | ||
1603 | 23 | |||
1604 | 24 | #include "bamf-marshal.h" | ||
1605 | 25 | #include "bamf-indicator-source.h" | 21 | #include "bamf-indicator-source.h" |
1606 | 26 | #include "bamf-indicator-source-glue.h" | ||
1607 | 27 | #include <dbus/dbus-glib-bindings.h> | ||
1608 | 28 | 22 | ||
1611 | 29 | #define BAMF_INDICATOR_SOURCE_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE((object), BAMF_TYPE_INDICATOR_SOURCE, BamfIndicatorSourcePrivate)) | 23 | #define BAMF_INDICATOR_SOURCE_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE((object), \ |
1612 | 30 | #define BAMF_INDICATOR_SOURCE_PATH "/org/ayatana/bamf/IndicatorSource" | 24 | BAMF_TYPE_INDICATOR_SOURCE, BamfIndicatorSourcePrivate)) |
1613 | 31 | 25 | ||
1614 | 32 | enum | 26 | enum |
1615 | 33 | { | 27 | { |
1616 | 34 | INDICATOR_OPENED, | 28 | INDICATOR_OPENED, |
1617 | 35 | INDICATOR_CLOSED, | 29 | INDICATOR_CLOSED, |
1618 | 36 | REVISE_JUDGEMENT, | ||
1619 | 37 | 30 | ||
1620 | 38 | LAST_SIGNAL, | 31 | LAST_SIGNAL, |
1621 | 39 | }; | 32 | }; |
1622 | @@ -43,17 +36,17 @@ | |||
1623 | 43 | struct _BamfIndicatorSourcePrivate | 36 | struct _BamfIndicatorSourcePrivate |
1624 | 44 | { | 37 | { |
1625 | 45 | GList *indicators; | 38 | GList *indicators; |
1627 | 46 | DBusGProxy *proxy; | 39 | GDBusProxy *proxy; |
1628 | 47 | int behavior; | 40 | int behavior; |
1629 | 48 | }; | 41 | }; |
1630 | 49 | 42 | ||
1632 | 50 | G_DEFINE_TYPE (BamfIndicatorSource, bamf_indicator_source, G_TYPE_OBJECT) | 43 | G_DEFINE_TYPE (BamfIndicatorSource, bamf_indicator_source, STATUS_NOTIFIER_APPROVER_TYPE__SKELETON) |
1633 | 51 | 44 | ||
1634 | 52 | GList * | 45 | GList * |
1635 | 53 | bamf_indicator_source_get_indicators (BamfIndicatorSource *self) | 46 | bamf_indicator_source_get_indicators (BamfIndicatorSource *self) |
1636 | 54 | { | 47 | { |
1637 | 55 | g_return_val_if_fail (BAMF_IS_INDICATOR_SOURCE (self), NULL); | 48 | g_return_val_if_fail (BAMF_IS_INDICATOR_SOURCE (self), NULL); |
1639 | 56 | 49 | ||
1640 | 57 | return self->priv->indicators; | 50 | return self->priv->indicators; |
1641 | 58 | } | 51 | } |
1642 | 59 | 52 | ||
1643 | @@ -61,15 +54,15 @@ | |||
1644 | 61 | on_indicator_closed (BamfView *view, BamfIndicatorSource *self) | 54 | on_indicator_closed (BamfView *view, BamfIndicatorSource *self) |
1645 | 62 | { | 55 | { |
1646 | 63 | BamfIndicator *indicator; | 56 | BamfIndicator *indicator; |
1648 | 64 | 57 | ||
1649 | 65 | g_return_if_fail (BAMF_IS_INDICATOR (view)); | 58 | g_return_if_fail (BAMF_IS_INDICATOR (view)); |
1650 | 66 | g_return_if_fail (BAMF_IS_INDICATOR_SOURCE (self)); | 59 | g_return_if_fail (BAMF_IS_INDICATOR_SOURCE (self)); |
1652 | 67 | 60 | ||
1653 | 68 | indicator = BAMF_INDICATOR (view); | 61 | indicator = BAMF_INDICATOR (view); |
1655 | 69 | 62 | ||
1656 | 70 | self->priv->indicators = g_list_remove (self->priv->indicators, indicator); | 63 | self->priv->indicators = g_list_remove (self->priv->indicators, indicator); |
1657 | 71 | g_signal_emit (self, indicator_source_signals[INDICATOR_CLOSED], 0, indicator); | 64 | g_signal_emit (self, indicator_source_signals[INDICATOR_CLOSED], 0, indicator); |
1659 | 72 | 65 | ||
1660 | 73 | g_object_unref (G_OBJECT (indicator)); | 66 | g_object_unref (G_OBJECT (indicator)); |
1661 | 74 | } | 67 | } |
1662 | 75 | 68 | ||
1663 | @@ -78,9 +71,10 @@ | |||
1664 | 78 | { | 71 | { |
1665 | 79 | g_return_if_fail (BAMF_IS_INDICATOR (indicator)); | 72 | g_return_if_fail (BAMF_IS_INDICATOR (indicator)); |
1666 | 80 | g_return_if_fail (BAMF_IS_INDICATOR_SOURCE (self)); | 73 | g_return_if_fail (BAMF_IS_INDICATOR_SOURCE (self)); |
1670 | 81 | 74 | ||
1671 | 82 | char *address = bamf_indicator_get_address (indicator); | 75 | const char *address = bamf_indicator_get_address (indicator); |
1672 | 83 | char *path = bamf_indicator_get_path (indicator); | 76 | const char *path = bamf_indicator_get_path (indicator); |
1673 | 77 | GList *parents = bamf_view_get_parents (BAMF_VIEW (indicator)); | ||
1674 | 84 | gboolean approve = TRUE; | 78 | gboolean approve = TRUE; |
1675 | 85 | 79 | ||
1676 | 86 | switch (self->priv->behavior) | 80 | switch (self->priv->behavior) |
1677 | @@ -89,17 +83,14 @@ | |||
1678 | 89 | approve = FALSE; | 83 | approve = FALSE; |
1679 | 90 | break; | 84 | break; |
1680 | 91 | case BAMF_INDICATOR_SOURCE_APPROVE_MATCHED: | 85 | case BAMF_INDICATOR_SOURCE_APPROVE_MATCHED: |
1682 | 92 | approve = g_list_length (bamf_view_get_parents (BAMF_VIEW (indicator))) == 0; | 86 | approve = (parents == NULL); |
1683 | 93 | break; | 87 | break; |
1684 | 94 | case BAMF_INDICATOR_SOURCE_APPROVE_ALL: | 88 | case BAMF_INDICATOR_SOURCE_APPROVE_ALL: |
1685 | 95 | approve = TRUE; | 89 | approve = TRUE; |
1686 | 96 | break; | 90 | break; |
1687 | 97 | } | 91 | } |
1693 | 98 | 92 | ||
1694 | 99 | g_signal_emit (self, indicator_source_signals[REVISE_JUDGEMENT], 0, approve, address, path); | 93 | g_signal_emit_by_name (self, "revise-judgement", approve, address, path); |
1690 | 100 | |||
1691 | 101 | g_free (address); | ||
1692 | 102 | g_free (path); | ||
1695 | 103 | } | 94 | } |
1696 | 104 | 95 | ||
1697 | 105 | void | 96 | void |
1698 | @@ -114,9 +105,9 @@ | |||
1699 | 114 | 105 | ||
1700 | 115 | if (priv->behavior == behavior) | 106 | if (priv->behavior == behavior) |
1701 | 116 | return; | 107 | return; |
1703 | 117 | 108 | ||
1704 | 118 | priv->behavior = behavior; | 109 | priv->behavior = behavior; |
1706 | 119 | 110 | ||
1707 | 120 | g_list_foreach (priv->indicators, (GFunc) rejudge_approval, self); | 111 | g_list_foreach (priv->indicators, (GFunc) rejudge_approval, self); |
1708 | 121 | } | 112 | } |
1709 | 122 | 113 | ||
1710 | @@ -126,61 +117,80 @@ | |||
1711 | 126 | const char *category, | 117 | const char *category, |
1712 | 127 | guint32 pid, | 118 | guint32 pid, |
1713 | 128 | const char *address, | 119 | const char *address, |
1717 | 129 | const char *path, | 120 | const char *path) |
1715 | 130 | gboolean *approve, | ||
1716 | 131 | GError **remote_error) | ||
1718 | 132 | { | 121 | { |
1719 | 133 | DBusGConnection *bus; | ||
1720 | 134 | DBusGProxy *dbus_proxy; | ||
1721 | 135 | GList *l; | 122 | GList *l; |
1722 | 136 | GError *error = NULL; | 123 | GError *error = NULL; |
1723 | 137 | BamfIndicator *indicator = NULL; | 124 | BamfIndicator *indicator = NULL; |
1727 | 138 | *approve = TRUE; | 125 | |
1725 | 139 | guint remote_pid; | ||
1726 | 140 | |||
1728 | 141 | g_return_val_if_fail (category, TRUE); | 126 | g_return_val_if_fail (category, TRUE); |
1729 | 142 | g_return_val_if_fail (path, TRUE); | 127 | g_return_val_if_fail (path, TRUE); |
1730 | 143 | g_return_val_if_fail (address, TRUE); | 128 | g_return_val_if_fail (address, TRUE); |
1731 | 144 | g_return_val_if_fail (BAMF_IS_INDICATOR_SOURCE (self), TRUE); | 129 | g_return_val_if_fail (BAMF_IS_INDICATOR_SOURCE (self), TRUE); |
1733 | 145 | 130 | ||
1734 | 146 | if (g_strcmp0 (category, "ApplicationStatus") != 0 || | 131 | if (g_strcmp0 (category, "ApplicationStatus") != 0 || |
1735 | 147 | g_strcmp0 (path, "/com/canonical/NotificationItem/dropbox_client") == 0) | 132 | g_strcmp0 (path, "/com/canonical/NotificationItem/dropbox_client") == 0) |
1736 | 148 | return TRUE; | 133 | return TRUE; |
1738 | 149 | 134 | ||
1739 | 150 | if (pid == 0) | 135 | if (pid == 0) |
1740 | 151 | { | 136 | { |
1761 | 152 | g_warning ("Remote service passed indicator with pid of 0, manually fetching pid\n"); | 137 | GDBusProxy *gproxy; |
1762 | 153 | 138 | GVariant *remote_pid; | |
1763 | 154 | bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error); | 139 | |
1764 | 155 | g_return_val_if_fail (bus, TRUE); | 140 | g_warning ("Remote service passed indicator with pid of 0, manually fetching pid"); |
1765 | 156 | 141 | ||
1766 | 157 | dbus_proxy = dbus_g_proxy_new_for_name (bus, | 142 | gproxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION, |
1767 | 158 | DBUS_SERVICE_DBUS, | 143 | G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES| |
1768 | 159 | DBUS_PATH_DBUS, | 144 | G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS, |
1769 | 160 | DBUS_INTERFACE_DBUS); | 145 | NULL, |
1770 | 161 | g_return_val_if_fail (dbus_proxy, TRUE); | 146 | "org.freedesktop.DBus", |
1771 | 162 | 147 | "/org/freedesktop/DBus", | |
1772 | 163 | error = NULL; | 148 | "org.freedesktop.DBus", |
1773 | 164 | if (!org_freedesktop_DBus_get_connection_unix_process_id (dbus_proxy, address, &remote_pid, &error)) | 149 | NULL, |
1774 | 165 | { | 150 | &error); |
1775 | 166 | g_warning ("Could not get indicator process id: %s\n", error->message); | 151 | |
1776 | 167 | g_error_free (error); | 152 | if (error) |
1777 | 168 | } | 153 | { |
1778 | 169 | 154 | g_warning ("Could not get indicator process id: %s", error->message); | |
1779 | 170 | g_object_unref (G_OBJECT (dbus_proxy)); | 155 | g_clear_error (&error); |
1780 | 171 | pid = (guint32) remote_pid; | 156 | } |
1781 | 157 | |||
1782 | 158 | g_return_val_if_fail (G_IS_DBUS_PROXY (gproxy), TRUE); | ||
1783 | 159 | |||
1784 | 160 | remote_pid = g_dbus_proxy_call_sync (gproxy, "GetConnectionUnixProcessID", | ||
1785 | 161 | g_variant_new ("(s)", address), | ||
1786 | 162 | G_DBUS_CALL_FLAGS_NONE, | ||
1787 | 163 | -1, | ||
1788 | 164 | NULL, | ||
1789 | 165 | &error); | ||
1790 | 166 | if (error) | ||
1791 | 167 | { | ||
1792 | 168 | g_warning ("Could not get indicator process id: %s", error->message); | ||
1793 | 169 | g_clear_error (&error); | ||
1794 | 170 | return TRUE; | ||
1795 | 171 | } | ||
1796 | 172 | |||
1797 | 173 | g_return_val_if_fail (remote_pid, TRUE); | ||
1798 | 174 | |||
1799 | 175 | pid = g_variant_get_uint32 (g_variant_get_child_value (remote_pid, 0)); | ||
1800 | 176 | |||
1801 | 177 | g_object_unref (gproxy); | ||
1802 | 178 | g_variant_unref (remote_pid); | ||
1803 | 179 | |||
1804 | 180 | if (pid == 0) | ||
1805 | 181 | return TRUE; | ||
1806 | 172 | } | 182 | } |
1808 | 173 | 183 | ||
1809 | 174 | for (l = self->priv->indicators; l; l = l->next) | 184 | for (l = self->priv->indicators; l; l = l->next) |
1810 | 175 | { | 185 | { |
1811 | 176 | if (bamf_indicator_matches_signature (BAMF_INDICATOR (l->data), pid, address, path)) | 186 | if (bamf_indicator_matches_signature (BAMF_INDICATOR (l->data), pid, address, path)) |
1812 | 177 | { | 187 | { |
1814 | 178 | g_debug ("NotifierWatcher service passed already known indicator, ignoring\n"); | 188 | g_debug ("NotifierWatcher service passed already known indicator, ignoring"); |
1815 | 179 | indicator = BAMF_INDICATOR (l->data); | 189 | indicator = BAMF_INDICATOR (l->data); |
1816 | 180 | break; | 190 | break; |
1817 | 181 | } | 191 | } |
1818 | 182 | } | 192 | } |
1820 | 183 | 193 | ||
1821 | 184 | if (!indicator) | 194 | if (!indicator) |
1822 | 185 | { | 195 | { |
1823 | 186 | indicator = bamf_indicator_new (id, path, address, pid); | 196 | indicator = bamf_indicator_new (id, path, address, pid); |
1824 | @@ -189,101 +199,145 @@ | |||
1825 | 189 | g_signal_connect (G_OBJECT (indicator), "closed", (GCallback) on_indicator_closed, self); | 199 | g_signal_connect (G_OBJECT (indicator), "closed", (GCallback) on_indicator_closed, self); |
1826 | 190 | g_signal_emit (self, indicator_source_signals[INDICATOR_OPENED], 0, indicator); | 200 | g_signal_emit (self, indicator_source_signals[INDICATOR_OPENED], 0, indicator); |
1827 | 191 | } | 201 | } |
1829 | 192 | 202 | ||
1830 | 203 | GList *parents = bamf_view_get_parents (BAMF_VIEW (indicator)); | ||
1831 | 204 | |||
1832 | 193 | switch (self->priv->behavior) | 205 | switch (self->priv->behavior) |
1833 | 194 | { | 206 | { |
1834 | 195 | case BAMF_INDICATOR_SOURCE_APPROVE_NONE: | 207 | case BAMF_INDICATOR_SOURCE_APPROVE_NONE: |
1838 | 196 | *approve = FALSE; | 208 | return FALSE; |
1839 | 197 | break; | 209 | |
1837 | 198 | |||
1840 | 199 | case BAMF_INDICATOR_SOURCE_APPROVE_MATCHED: | 210 | case BAMF_INDICATOR_SOURCE_APPROVE_MATCHED: |
1844 | 200 | *approve = !(indicator && g_list_length (bamf_view_get_parents (BAMF_VIEW (indicator))) > 0); | 211 | return !(indicator && parents); |
1845 | 201 | break; | 212 | |
1843 | 202 | |||
1846 | 203 | case BAMF_INDICATOR_SOURCE_APPROVE_ALL: | 213 | case BAMF_INDICATOR_SOURCE_APPROVE_ALL: |
1849 | 204 | *approve = TRUE; | 214 | return TRUE; |
1848 | 205 | break; | ||
1850 | 206 | } | 215 | } |
1852 | 207 | 216 | ||
1853 | 208 | return TRUE; | 217 | return TRUE; |
1854 | 209 | } | 218 | } |
1855 | 210 | 219 | ||
1857 | 211 | static void on_proxy_destroy (DBusGProxy *proxy, BamfIndicatorSource *self); | 220 | static void status_notifier_proxy_owner_changed (GObject *object, GParamSpec *pspec, BamfIndicatorSource *self); |
1858 | 212 | 221 | ||
1859 | 213 | static gboolean | 222 | static gboolean |
1860 | 214 | bamf_indicator_source_register_notification_approver (BamfIndicatorSource *self) | 223 | bamf_indicator_source_register_notification_approver (BamfIndicatorSource *self) |
1861 | 215 | { | 224 | { |
1862 | 216 | DBusGConnection *bus; | ||
1863 | 217 | GError *error = NULL; | ||
1864 | 218 | static int retry_count = 0; | 225 | static int retry_count = 0; |
1884 | 219 | 226 | GDBusProxy *gproxy; | |
1885 | 220 | bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error); | 227 | GError *error = NULL; |
1886 | 221 | g_return_val_if_fail (bus, FALSE); | 228 | gchar *owner; |
1887 | 222 | 229 | ||
1888 | 223 | self->priv->proxy = dbus_g_proxy_new_for_name_owner (bus, | 230 | gproxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION, |
1889 | 224 | "com.canonical.indicator.application", | 231 | G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES| |
1890 | 225 | "/StatusNotifierWatcher", | 232 | G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS| |
1891 | 226 | "org.kde.StatusNotifierWatcher", | 233 | G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START, |
1892 | 227 | &error); | 234 | NULL, |
1893 | 228 | 235 | "org.kde.StatusNotifierWatcher",//"com.canonical.indicator.application", | |
1894 | 229 | if (self->priv->proxy) | 236 | "/StatusNotifierWatcher", |
1895 | 230 | { | 237 | "org.kde.StatusNotifierWatcher", |
1896 | 231 | if (dbus_g_proxy_call (self->priv->proxy, | 238 | NULL, |
1897 | 232 | "XAyatanaRegisterNotificationApprover", | 239 | &error); |
1898 | 233 | &error, | 240 | |
1899 | 234 | DBUS_TYPE_G_OBJECT_PATH, BAMF_INDICATOR_SOURCE_PATH, | 241 | if (error) |
1900 | 235 | G_TYPE_STRV, NULL, | 242 | { |
1901 | 236 | G_TYPE_INVALID, | 243 | g_debug ("Failed to get notification approver proxy: %s", error->message); |
1902 | 237 | G_TYPE_INVALID)) | 244 | g_error_free (error); |
1903 | 245 | } | ||
1904 | 246 | else | ||
1905 | 247 | { | ||
1906 | 248 | owner = g_dbus_proxy_get_name_owner (gproxy); | ||
1907 | 249 | |||
1908 | 250 | if (owner) | ||
1909 | 238 | { | 251 | { |
1914 | 239 | g_debug ("Remote notification approver registered\n"); | 252 | g_free (owner); |
1915 | 240 | g_signal_connect (G_OBJECT (self->priv->proxy), "destroy", (GCallback) on_proxy_destroy, self); | 253 | |
1916 | 241 | retry_count = 0; | 254 | GVariantBuilder tuple, array; |
1917 | 242 | return FALSE; | 255 | g_variant_builder_init (&tuple, G_VARIANT_TYPE_TUPLE); |
1918 | 256 | g_variant_builder_add_value (&tuple, g_variant_new_object_path (BAMF_INDICATOR_SOURCE_PATH)); | ||
1919 | 257 | g_variant_builder_init (&array, G_VARIANT_TYPE ("as")); | ||
1920 | 258 | g_variant_builder_add_value (&tuple, g_variant_builder_end (&array)); | ||
1921 | 259 | |||
1922 | 260 | g_dbus_proxy_call_sync (gproxy, "XAyatanaRegisterNotificationApprover", | ||
1923 | 261 | g_variant_builder_end (&tuple), | ||
1924 | 262 | G_DBUS_CALL_FLAGS_NONE, | ||
1925 | 263 | -1, | ||
1926 | 264 | NULL, | ||
1927 | 265 | &error); | ||
1928 | 266 | |||
1929 | 267 | if (!error) | ||
1930 | 268 | { | ||
1931 | 269 | g_debug ("Remote notification approver registered"); | ||
1932 | 270 | g_signal_connect (G_OBJECT (gproxy), "notify::g-name-owner", | ||
1933 | 271 | (GCallback) status_notifier_proxy_owner_changed, | ||
1934 | 272 | self); | ||
1935 | 273 | |||
1936 | 274 | if (self->priv->proxy) | ||
1937 | 275 | g_object_unref (self->priv->proxy); | ||
1938 | 276 | |||
1939 | 277 | self->priv->proxy = gproxy; | ||
1940 | 278 | retry_count = 0; | ||
1941 | 279 | return FALSE; | ||
1942 | 280 | } | ||
1943 | 281 | else | ||
1944 | 282 | { | ||
1945 | 283 | g_debug ("Failed to register as approver: %s", error->message); | ||
1946 | 284 | g_error_free (error); | ||
1947 | 285 | } | ||
1948 | 243 | } | 286 | } |
1949 | 244 | else | 287 | else |
1950 | 245 | { | 288 | { |
1953 | 246 | g_debug ("Failed to register as approver: %s\n", error->message); | 289 | g_debug ("Failed to get notification approver proxy: no owner available"); |
1952 | 247 | g_error_free (error); | ||
1954 | 248 | } | 290 | } |
1961 | 249 | } | 291 | |
1962 | 250 | else | 292 | g_object_unref (gproxy); |
1963 | 251 | { | 293 | } |
1964 | 252 | g_debug ("Failed to get notification approver proxy: %s\n", error->message); | 294 | |
1959 | 253 | g_error_free (error); | ||
1960 | 254 | } | ||
1965 | 255 | retry_count++; | 295 | retry_count++; |
1967 | 256 | 296 | ||
1968 | 257 | if (retry_count > 10) | 297 | if (retry_count > 10) |
1969 | 258 | { | 298 | { |
1971 | 259 | g_debug ("Retry count expired\n"); | 299 | g_debug ("Retry count expired"); |
1972 | 260 | return FALSE; | 300 | return FALSE; |
1973 | 261 | } | 301 | } |
1976 | 262 | 302 | ||
1977 | 263 | g_debug ("Retrying registration in 2 seconds\n"); | 303 | g_debug ("Retrying registration in 2 seconds"); |
1978 | 264 | return TRUE; | 304 | return TRUE; |
1979 | 265 | } | 305 | } |
1980 | 266 | 306 | ||
1981 | 267 | static void | 307 | static void |
1983 | 268 | on_proxy_destroy (DBusGProxy *proxy, BamfIndicatorSource *self) | 308 | status_notifier_proxy_owner_changed (GObject *object, GParamSpec *pspec, |
1984 | 309 | BamfIndicatorSource *self) | ||
1985 | 269 | { | 310 | { |
1990 | 270 | g_return_if_fail (BAMF_IS_INDICATOR_SOURCE (self)); | 311 | g_debug ("Remote approver service died, re-establishing connection"); |
1991 | 271 | 312 | g_object_unref (self->priv->proxy); | |
1992 | 272 | g_debug ("Remote approver service died, re-establishing connection\n"); | 313 | self->priv->proxy = NULL; |
1993 | 273 | 314 | ||
1994 | 274 | if (bamf_indicator_source_register_notification_approver (self)) | 315 | if (bamf_indicator_source_register_notification_approver (self)) |
1996 | 275 | g_timeout_add (2 * 1000, (GSourceFunc) bamf_indicator_source_register_notification_approver, self); | 316 | g_timeout_add_seconds (2, (GSourceFunc) bamf_indicator_source_register_notification_approver, self); |
1997 | 317 | } | ||
1998 | 318 | |||
1999 | 319 | static gboolean | ||
2000 | 320 | on_dbus_handle_approve_item (BamfDBusMatcher *interface, | ||
2001 | 321 | GDBusMethodInvocation *invocation, | ||
2002 | 322 | const gchar *id, | ||
2003 | 323 | const gchar *category, | ||
2004 | 324 | guint pid, | ||
2005 | 325 | const gchar *address, | ||
2006 | 326 | const gchar *path, | ||
2007 | 327 | BamfIndicatorSource *self) | ||
2008 | 328 | { | ||
2009 | 329 | gboolean approved = bamf_indicator_source_approve_item (self, id, category, | ||
2010 | 330 | pid, address, path); | ||
2011 | 331 | g_dbus_method_invocation_return_value (invocation, | ||
2012 | 332 | g_variant_new ("(b)", approved)); | ||
2013 | 333 | |||
2014 | 334 | return TRUE; | ||
2015 | 276 | } | 335 | } |
2016 | 277 | 336 | ||
2017 | 278 | static void | 337 | static void |
2018 | 279 | bamf_indicator_source_constructed (GObject *object) | 338 | bamf_indicator_source_constructed (GObject *object) |
2019 | 280 | { | 339 | { |
2020 | 281 | BamfIndicatorSource *self; | 340 | BamfIndicatorSource *self; |
2021 | 282 | DBusGConnection *bus; | ||
2022 | 283 | GError *error = NULL; | ||
2023 | 284 | |||
2024 | 285 | bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error); | ||
2025 | 286 | g_return_if_fail (bus); | ||
2026 | 287 | 341 | ||
2027 | 288 | self = BAMF_INDICATOR_SOURCE (object); | 342 | self = BAMF_INDICATOR_SOURCE (object); |
2028 | 289 | 343 | ||
2029 | @@ -292,15 +346,27 @@ | |||
2030 | 292 | 346 | ||
2031 | 293 | self->priv->behavior = BAMF_INDICATOR_SOURCE_APPROVE_ALL; | 347 | self->priv->behavior = BAMF_INDICATOR_SOURCE_APPROVE_ALL; |
2032 | 294 | 348 | ||
2033 | 295 | dbus_g_connection_register_g_object (bus, BAMF_INDICATOR_SOURCE_PATH, object); | ||
2034 | 296 | |||
2035 | 297 | if (bamf_indicator_source_register_notification_approver (self)) | 349 | if (bamf_indicator_source_register_notification_approver (self)) |
2037 | 298 | g_timeout_add (2 * 1000, (GSourceFunc) bamf_indicator_source_register_notification_approver, self); | 350 | g_timeout_add_seconds (2, (GSourceFunc) bamf_indicator_source_register_notification_approver, self); |
2038 | 299 | } | 351 | } |
2039 | 300 | 352 | ||
2040 | 301 | static void | 353 | static void |
2041 | 302 | bamf_indicator_source_dispose (GObject *object) | 354 | bamf_indicator_source_dispose (GObject *object) |
2042 | 303 | { | 355 | { |
2043 | 356 | BamfIndicatorSource *self = BAMF_INDICATOR_SOURCE (object); | ||
2044 | 357 | |||
2045 | 358 | if (self->priv->indicators) | ||
2046 | 359 | { | ||
2047 | 360 | g_list_free_full (self->priv->indicators, g_object_unref); | ||
2048 | 361 | self->priv->indicators = NULL; | ||
2049 | 362 | } | ||
2050 | 363 | |||
2051 | 364 | if (self->priv->proxy) | ||
2052 | 365 | { | ||
2053 | 366 | g_object_unref (self->priv->proxy); | ||
2054 | 367 | self->priv->proxy = NULL; | ||
2055 | 368 | } | ||
2056 | 369 | |||
2057 | 304 | G_OBJECT_CLASS (bamf_indicator_source_parent_class)->dispose (object); | 370 | G_OBJECT_CLASS (bamf_indicator_source_parent_class)->dispose (object); |
2058 | 305 | } | 371 | } |
2059 | 306 | 372 | ||
2060 | @@ -308,50 +374,41 @@ | |||
2061 | 308 | bamf_indicator_source_class_init (BamfIndicatorSourceClass *klass) | 374 | bamf_indicator_source_class_init (BamfIndicatorSourceClass *klass) |
2062 | 309 | { | 375 | { |
2063 | 310 | GObjectClass *object_class = G_OBJECT_CLASS (klass); | 376 | GObjectClass *object_class = G_OBJECT_CLASS (klass); |
2065 | 311 | 377 | ||
2066 | 312 | object_class->dispose = bamf_indicator_source_dispose; | 378 | object_class->dispose = bamf_indicator_source_dispose; |
2067 | 313 | object_class->constructed = bamf_indicator_source_constructed; | 379 | object_class->constructed = bamf_indicator_source_constructed; |
2068 | 314 | 380 | ||
2078 | 315 | indicator_source_signals [REVISE_JUDGEMENT] = | 381 | g_type_class_add_private (object_class, sizeof (BamfIndicatorSourcePrivate)); |
2070 | 316 | g_signal_new ("revise-judgement", | ||
2071 | 317 | G_OBJECT_CLASS_TYPE (klass), | ||
2072 | 318 | G_SIGNAL_RUN_FIRST, | ||
2073 | 319 | G_STRUCT_OFFSET (BamfIndicatorSourceClass, revise_judgement), | ||
2074 | 320 | NULL, NULL, | ||
2075 | 321 | bamf_marshal_VOID__BOOL_STRING_STRING, | ||
2076 | 322 | G_TYPE_NONE, 3, | ||
2077 | 323 | G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_STRING); | ||
2079 | 324 | 382 | ||
2080 | 325 | indicator_source_signals [INDICATOR_OPENED] = | 383 | indicator_source_signals [INDICATOR_OPENED] = |
2089 | 326 | g_signal_new ("indicator-opened", | 384 | g_signal_new ("indicator-opened", |
2090 | 327 | G_OBJECT_CLASS_TYPE (klass), | 385 | G_OBJECT_CLASS_TYPE (klass), |
2091 | 328 | G_SIGNAL_RUN_FIRST, | 386 | G_SIGNAL_RUN_FIRST, |
2092 | 329 | G_STRUCT_OFFSET (BamfIndicatorSourceClass, indicator_opened), | 387 | G_STRUCT_OFFSET (BamfIndicatorSourceClass, indicator_opened), |
2093 | 330 | NULL, NULL, | 388 | NULL, NULL, |
2094 | 331 | g_cclosure_marshal_VOID__OBJECT, | 389 | g_cclosure_marshal_VOID__OBJECT, |
2095 | 332 | G_TYPE_NONE, 1, | 390 | G_TYPE_NONE, 1, |
2096 | 333 | BAMF_TYPE_INDICATOR); | 391 | BAMF_TYPE_INDICATOR); |
2097 | 334 | 392 | ||
2098 | 335 | indicator_source_signals [INDICATOR_CLOSED] = | 393 | indicator_source_signals [INDICATOR_CLOSED] = |
2112 | 336 | g_signal_new ("indicator-closed", | 394 | g_signal_new ("indicator-closed", |
2113 | 337 | G_OBJECT_CLASS_TYPE (klass), | 395 | G_OBJECT_CLASS_TYPE (klass), |
2114 | 338 | G_SIGNAL_RUN_FIRST, | 396 | G_SIGNAL_RUN_FIRST, |
2115 | 339 | G_STRUCT_OFFSET (BamfIndicatorSourceClass, indicator_closed), | 397 | G_STRUCT_OFFSET (BamfIndicatorSourceClass, indicator_closed), |
2116 | 340 | NULL, NULL, | 398 | NULL, NULL, |
2117 | 341 | g_cclosure_marshal_VOID__OBJECT, | 399 | g_cclosure_marshal_VOID__OBJECT, |
2118 | 342 | G_TYPE_NONE, 1, | 400 | G_TYPE_NONE, 1, |
2119 | 343 | BAMF_TYPE_INDICATOR); | 401 | BAMF_TYPE_INDICATOR); |
2107 | 344 | |||
2108 | 345 | dbus_g_object_type_install_info (BAMF_TYPE_INDICATOR_SOURCE, | ||
2109 | 346 | &dbus_glib_bamf_indicator_source_object_info); | ||
2110 | 347 | |||
2111 | 348 | g_type_class_add_private (object_class, sizeof (BamfIndicatorSourcePrivate)); | ||
2120 | 349 | } | 402 | } |
2121 | 350 | 403 | ||
2122 | 351 | static void | 404 | static void |
2123 | 352 | bamf_indicator_source_init (BamfIndicatorSource *self) | 405 | bamf_indicator_source_init (BamfIndicatorSource *self) |
2124 | 353 | { | 406 | { |
2125 | 354 | self->priv = BAMF_INDICATOR_SOURCE_GET_PRIVATE (self); | 407 | self->priv = BAMF_INDICATOR_SOURCE_GET_PRIVATE (self); |
2126 | 408 | |||
2127 | 409 | /* Registering signal callbacks to reply to dbus method calls */ | ||
2128 | 410 | g_signal_connect (self, "handle-approve-item", | ||
2129 | 411 | G_CALLBACK (on_dbus_handle_approve_item), self); | ||
2130 | 355 | } | 412 | } |
2131 | 356 | 413 | ||
2132 | 357 | static BamfIndicatorSource *approver = NULL; | 414 | static BamfIndicatorSource *approver = NULL; |
2133 | @@ -360,6 +417,7 @@ | |||
2134 | 360 | bamf_indicator_source_get_default () | 417 | bamf_indicator_source_get_default () |
2135 | 361 | { | 418 | { |
2136 | 362 | if (!approver) | 419 | if (!approver) |
2139 | 363 | return approver = g_object_new (BAMF_TYPE_INDICATOR_SOURCE, NULL); | 420 | approver = g_object_new (BAMF_TYPE_INDICATOR_SOURCE, NULL); |
2140 | 364 | return BAMF_INDICATOR_SOURCE (g_object_ref (approver)); | 421 | |
2141 | 422 | return approver; | ||
2142 | 365 | } | 423 | } |
2143 | 366 | 424 | ||
2144 | === modified file 'src/bamf-indicator-source.h' | |||
2145 | --- src/bamf-indicator-source.h 2010-08-18 23:22:58 +0000 | |||
2146 | +++ src/bamf-indicator-source.h 2012-01-19 19:16:25 +0000 | |||
2147 | @@ -1,23 +1,21 @@ | |||
2148 | 1 | /* | 1 | /* |
2160 | 2 | * bamf-notification-approver.h | 2 | * Copyright (C) 2010-2011 Canonical Ltd |
2161 | 3 | * This file is part of BAMF | 3 | * |
2162 | 4 | * | 4 | * This program is free software: you can redistribute it and/or modify |
2163 | 5 | * Copyright (C) 2010 - Jason Smith | 5 | * it under the terms of the GNU General Public License version 3 as |
2164 | 6 | * | 6 | * published by the Free Software Foundation. |
2165 | 7 | * BAMF is free software; you can redistribute it and/or modify | 7 | * |
2166 | 8 | * it under the terms of the GNU General Public License as published by | 8 | * This program is distributed in the hope that it will be useful, |
2156 | 9 | * the Free Software Foundation; either version 2 of the License, or | ||
2157 | 10 | * (at your option) any later version. | ||
2158 | 11 | * | ||
2159 | 12 | * BAMF is distributed in the hope that it will be useful, | ||
2167 | 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2168 | 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2169 | 15 | * GNU General Public License for more details. | 11 | * GNU General Public License for more details. |
2170 | 16 | * | 12 | * |
2171 | 17 | * You should have received a copy of the GNU General Public License | 13 | * You should have received a copy of the GNU General Public License |
2175 | 18 | * along with BAMF; if not, write to the Free Software | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2176 | 19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, | 15 | * |
2177 | 20 | * Boston, MA 02110-1301 USA | 16 | * Authored by: Jason Smith <jason.smith@canonical.com> |
2178 | 17 | * Marco Trevisan (Treviño) <3v1n0@ubuntu.com> | ||
2179 | 18 | * | ||
2180 | 21 | */ | 19 | */ |
2181 | 22 | 20 | ||
2182 | 23 | #ifndef __BAMF_INDICATOR_SOURCE_H__ | 21 | #ifndef __BAMF_INDICATOR_SOURCE_H__ |
2183 | @@ -25,6 +23,7 @@ | |||
2184 | 25 | 23 | ||
2185 | 26 | #include <glib-object.h> | 24 | #include <glib-object.h> |
2186 | 27 | #include "bamf-indicator.h" | 25 | #include "bamf-indicator.h" |
2187 | 26 | #include "bamf-gdbus-indicator-source-generated.h" | ||
2188 | 28 | 27 | ||
2189 | 29 | G_BEGIN_DECLS | 28 | G_BEGIN_DECLS |
2190 | 30 | 29 | ||
2191 | @@ -48,13 +47,13 @@ | |||
2192 | 48 | }; | 47 | }; |
2193 | 49 | 48 | ||
2194 | 50 | struct _BamfIndicatorSource { | 49 | struct _BamfIndicatorSource { |
2197 | 51 | GObject parent; | 50 | StatusNotifierApproverSkeleton parent; |
2198 | 52 | 51 | ||
2199 | 53 | BamfIndicatorSourcePrivate *priv; | 52 | BamfIndicatorSourcePrivate *priv; |
2200 | 54 | }; | 53 | }; |
2201 | 55 | 54 | ||
2202 | 56 | struct _BamfIndicatorSourceClass { | 55 | struct _BamfIndicatorSourceClass { |
2204 | 57 | GObjectClass parent_class; | 56 | StatusNotifierApproverSkeletonClass parent_class; |
2205 | 58 | 57 | ||
2206 | 59 | /*< signals >*/ | 58 | /*< signals >*/ |
2207 | 60 | void (*indicator_opened) (BamfIndicatorSource *approver, BamfIndicator *indicator); | 59 | void (*indicator_opened) (BamfIndicatorSource *approver, BamfIndicator *indicator); |
2208 | @@ -73,13 +72,11 @@ | |||
2209 | 73 | GList * bamf_indicator_source_get_indicators (BamfIndicatorSource *self); | 72 | GList * bamf_indicator_source_get_indicators (BamfIndicatorSource *self); |
2210 | 74 | 73 | ||
2211 | 75 | gboolean bamf_indicator_source_approve_item (BamfIndicatorSource *self, | 74 | gboolean bamf_indicator_source_approve_item (BamfIndicatorSource *self, |
2219 | 76 | const char *id, | 75 | const char *id, |
2220 | 77 | const char *category, | 76 | const char *category, |
2221 | 78 | guint32 pid, | 77 | guint32 pid, |
2222 | 79 | const char *address, | 78 | const char *address, |
2223 | 80 | const char *proxy, | 79 | const char *proxy); |
2217 | 81 | gboolean *approve, | ||
2218 | 82 | GError **error); | ||
2224 | 83 | 80 | ||
2225 | 84 | void bamf_indicator_source_set_behavior (BamfIndicatorSource *self, | 81 | void bamf_indicator_source_set_behavior (BamfIndicatorSource *self, |
2226 | 85 | gint32 behavior); | 82 | gint32 behavior); |
2227 | 86 | 83 | ||
2228 | === modified file 'src/bamf-indicator.c' | |||
2229 | --- src/bamf-indicator.c 2011-01-14 15:53:35 +0000 | |||
2230 | +++ src/bamf-indicator.c 2012-01-19 19:16:25 +0000 | |||
2231 | @@ -1,30 +1,27 @@ | |||
2232 | 1 | /* | 1 | /* |
2244 | 2 | * bamf-indicator.c | 2 | * Copyright (C) 2010-2011 Canonical Ltd |
2245 | 3 | * This file is part of BAMF | 3 | * |
2246 | 4 | * | 4 | * This program is free software: you can redistribute it and/or modify |
2247 | 5 | * Copyright (C) 2010 - Jason Smith | 5 | * it under the terms of the GNU General Public License version 3 as |
2248 | 6 | * | 6 | * published by the Free Software Foundation. |
2249 | 7 | * BAMF is free software; you can redistribute it and/or modify | 7 | * |
2250 | 8 | * it under the terms of the GNU General Public License as published by | 8 | * This program is distributed in the hope that it will be useful, |
2240 | 9 | * the Free Software Foundation; either version 2 of the License, or | ||
2241 | 10 | * (at your option) any later version. | ||
2242 | 11 | * | ||
2243 | 12 | * BAMF is distributed in the hope that it will be useful, | ||
2251 | 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2253 | 14 | * MERCHANINDICATORILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2254 | 15 | * GNU General Public License for more details. | 11 | * GNU General Public License for more details. |
2255 | 16 | * | 12 | * |
2256 | 17 | * You should have received a copy of the GNU General Public License | 13 | * You should have received a copy of the GNU General Public License |
2260 | 18 | * along with BAMF; if not, write to the Free Software | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2261 | 19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, | 15 | * |
2262 | 20 | * Boston, MA 02110-1301 USA | 16 | * Authored by: Jason Smith <jason.smith@canonical.com> |
2263 | 17 | * Marco Trevisan (Treviño) <3v1n0@ubuntu.com> | ||
2264 | 18 | * | ||
2265 | 21 | */ | 19 | */ |
2266 | 22 | 20 | ||
2267 | 23 | #include "bamf-indicator.h" | 21 | #include "bamf-indicator.h" |
2272 | 24 | #include "bamf-indicator-glue.h" | 22 | |
2273 | 25 | 23 | #define BAMF_INDICATOR_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE((object), \ | |
2274 | 26 | 24 | BAMF_TYPE_INDICATOR, BamfIndicatorPrivate)) | |
2271 | 27 | #define BAMF_INDICATOR_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE((object), BAMF_TYPE_INDICATOR, BamfIndicatorPrivate)) | ||
2275 | 28 | 25 | ||
2276 | 29 | enum | 26 | enum |
2277 | 30 | { | 27 | { |
2278 | @@ -39,34 +36,35 @@ | |||
2279 | 39 | 36 | ||
2280 | 40 | struct _BamfIndicatorPrivate | 37 | struct _BamfIndicatorPrivate |
2281 | 41 | { | 38 | { |
2282 | 39 | BamfDBusItemIndicator *dbus_iface; | ||
2283 | 42 | char *id; | 40 | char *id; |
2284 | 43 | char *path; | 41 | char *path; |
2285 | 44 | char *address; | 42 | char *address; |
2286 | 45 | guint32 pid; | 43 | guint32 pid; |
2288 | 46 | DBusGProxy *proxy; | 44 | GDBusProxy *proxy; |
2289 | 47 | }; | 45 | }; |
2290 | 48 | 46 | ||
2291 | 49 | G_DEFINE_TYPE (BamfIndicator, bamf_indicator, BAMF_TYPE_VIEW) | 47 | G_DEFINE_TYPE (BamfIndicator, bamf_indicator, BAMF_TYPE_VIEW) |
2292 | 50 | 48 | ||
2294 | 51 | char * | 49 | const char * |
2295 | 52 | bamf_indicator_get_path (BamfIndicator *self) | 50 | bamf_indicator_get_path (BamfIndicator *self) |
2296 | 53 | { | 51 | { |
2297 | 54 | g_return_val_if_fail (BAMF_IS_INDICATOR (self), NULL); | 52 | g_return_val_if_fail (BAMF_IS_INDICATOR (self), NULL); |
2299 | 55 | return g_strdup (self->priv->path); | 53 | return self->priv->path; |
2300 | 56 | } | 54 | } |
2301 | 57 | 55 | ||
2303 | 58 | char * | 56 | const char * |
2304 | 59 | bamf_indicator_get_address (BamfIndicator *self) | 57 | bamf_indicator_get_address (BamfIndicator *self) |
2305 | 60 | { | 58 | { |
2306 | 61 | g_return_val_if_fail (BAMF_IS_INDICATOR (self), NULL); | 59 | g_return_val_if_fail (BAMF_IS_INDICATOR (self), NULL); |
2308 | 62 | return g_strdup (self->priv->address); | 60 | return self->priv->address; |
2309 | 63 | } | 61 | } |
2310 | 64 | 62 | ||
2312 | 65 | char * | 63 | const char * |
2313 | 66 | bamf_indicator_get_id (BamfIndicator *self) | 64 | bamf_indicator_get_id (BamfIndicator *self) |
2314 | 67 | { | 65 | { |
2315 | 68 | g_return_val_if_fail (BAMF_IS_INDICATOR (self), NULL); | 66 | g_return_val_if_fail (BAMF_IS_INDICATOR (self), NULL); |
2317 | 69 | return g_strdup (self->priv->id); | 67 | return self->priv->id; |
2318 | 70 | } | 68 | } |
2319 | 71 | 69 | ||
2320 | 72 | guint32 | 70 | guint32 |
2321 | @@ -86,10 +84,10 @@ | |||
2322 | 86 | pid == self->priv->pid; | 84 | pid == self->priv->pid; |
2323 | 87 | } | 85 | } |
2324 | 88 | 86 | ||
2326 | 89 | static char * | 87 | static const char * |
2327 | 90 | bamf_indicator_get_view_type (BamfView *view) | 88 | bamf_indicator_get_view_type (BamfView *view) |
2328 | 91 | { | 89 | { |
2330 | 92 | return g_strdup ("indicator"); | 90 | return "indicator"; |
2331 | 93 | } | 91 | } |
2332 | 94 | 92 | ||
2333 | 95 | static char * | 93 | static char * |
2334 | @@ -104,7 +102,8 @@ | |||
2335 | 104 | } | 102 | } |
2336 | 105 | 103 | ||
2337 | 106 | static void | 104 | static void |
2339 | 107 | bamf_indicator_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) | 105 | bamf_indicator_set_property (GObject *object, guint property_id, |
2340 | 106 | const GValue *value, GParamSpec *pspec) | ||
2341 | 108 | { | 107 | { |
2342 | 109 | BamfIndicator *self; | 108 | BamfIndicator *self; |
2343 | 110 | 109 | ||
2344 | @@ -129,7 +128,7 @@ | |||
2345 | 129 | break; | 128 | break; |
2346 | 130 | 129 | ||
2347 | 131 | default: | 130 | default: |
2349 | 132 | G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); | 131 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); |
2350 | 133 | } | 132 | } |
2351 | 134 | } | 133 | } |
2352 | 135 | 134 | ||
2353 | @@ -159,53 +158,96 @@ | |||
2354 | 159 | break; | 158 | break; |
2355 | 160 | 159 | ||
2356 | 161 | default: | 160 | default: |
2358 | 162 | G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); | 161 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); |
2359 | 163 | } | 162 | } |
2360 | 164 | } | 163 | } |
2361 | 165 | 164 | ||
2362 | 166 | static void | 165 | static void |
2364 | 167 | bamf_indicator_on_destroy (DBusGProxy *proxy, BamfIndicator *self) | 166 | bamf_indicator_on_destroy (GObject *object, GParamSpec *pspec, BamfIndicator *self) |
2365 | 168 | { | 167 | { |
2366 | 168 | g_object_unref (self->priv->proxy); | ||
2367 | 169 | self->priv->proxy = NULL; | ||
2368 | 170 | |||
2369 | 169 | bamf_view_close (BAMF_VIEW (self)); | 171 | bamf_view_close (BAMF_VIEW (self)); |
2370 | 170 | } | 172 | } |
2371 | 171 | 173 | ||
2372 | 174 | static gboolean | ||
2373 | 175 | on_dbus_handle_path (BamfDBusItemIndicator *interface, | ||
2374 | 176 | GDBusMethodInvocation *invocation, | ||
2375 | 177 | BamfIndicator *self) | ||
2376 | 178 | { | ||
2377 | 179 | const char *path = bamf_indicator_get_path (self); | ||
2378 | 180 | g_dbus_method_invocation_return_value (invocation, | ||
2379 | 181 | g_variant_new ("(s)", path ? path : "")); | ||
2380 | 182 | |||
2381 | 183 | return TRUE; | ||
2382 | 184 | } | ||
2383 | 185 | |||
2384 | 186 | static gboolean | ||
2385 | 187 | on_dbus_handle_address (BamfDBusItemIndicator *interface, | ||
2386 | 188 | GDBusMethodInvocation *invocation, | ||
2387 | 189 | BamfIndicator *self) | ||
2388 | 190 | { | ||
2389 | 191 | const char *address = bamf_indicator_get_address (self); | ||
2390 | 192 | g_dbus_method_invocation_return_value (invocation, | ||
2391 | 193 | g_variant_new ("(s)", address ? address : "")); | ||
2392 | 194 | |||
2393 | 195 | return TRUE; | ||
2394 | 196 | } | ||
2395 | 197 | |||
2396 | 172 | static void | 198 | static void |
2397 | 173 | bamf_indicator_constructed (GObject *object) | 199 | bamf_indicator_constructed (GObject *object) |
2398 | 174 | { | 200 | { |
2399 | 175 | BamfIndicator *self; | 201 | BamfIndicator *self; |
2400 | 176 | BamfIndicatorPrivate *priv; | 202 | BamfIndicatorPrivate *priv; |
2403 | 177 | DBusGProxy *proxy; | 203 | GDBusProxy *proxy; |
2402 | 178 | DBusGConnection *bus; | ||
2404 | 179 | GError *error = NULL; | 204 | GError *error = NULL; |
2405 | 180 | 205 | ||
2406 | 181 | if (G_OBJECT_CLASS (bamf_indicator_parent_class)->constructed) | 206 | if (G_OBJECT_CLASS (bamf_indicator_parent_class)->constructed) |
2407 | 182 | G_OBJECT_CLASS (bamf_indicator_parent_class)->constructed (object); | 207 | G_OBJECT_CLASS (bamf_indicator_parent_class)->constructed (object); |
2409 | 183 | 208 | ||
2410 | 184 | self = BAMF_INDICATOR (object); | 209 | self = BAMF_INDICATOR (object); |
2411 | 185 | priv = self->priv; | 210 | priv = self->priv; |
2435 | 186 | 211 | ||
2436 | 187 | bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error); | 212 | proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION, |
2437 | 188 | 213 | G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES| | |
2438 | 189 | if (!bus) | 214 | G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS| |
2439 | 190 | { | 215 | G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START, |
2440 | 191 | g_warning ("Could not get session bus\n"); | 216 | NULL, |
2441 | 192 | return; | 217 | priv->address, |
2442 | 193 | } | 218 | priv->path, |
2443 | 194 | 219 | "org.ayatana.indicator.application.service", | |
2444 | 195 | error = NULL; | 220 | NULL, |
2445 | 196 | if (!(proxy = dbus_g_proxy_new_for_name_owner (bus, | 221 | &error); |
2446 | 197 | priv->address, | 222 | |
2447 | 198 | priv->path, | 223 | if (error) |
2448 | 199 | "org.ayatana.indicator.application.service", | 224 | { |
2449 | 200 | &error))) | 225 | g_debug ("Could not setup proxy: %s %s: %s", priv->address, priv->path, |
2450 | 201 | { | 226 | error->message); |
2451 | 202 | g_warning ("Could not setup proxy: %s %s\n", priv->address, priv->path); | 227 | g_error_free (error); |
2452 | 203 | return; | 228 | } |
2453 | 204 | } | 229 | else |
2454 | 205 | 230 | { | |
2455 | 206 | priv->proxy = proxy; | 231 | gchar *owner = g_dbus_proxy_get_name_owner (proxy); |
2456 | 207 | 232 | ||
2457 | 208 | g_signal_connect (G_OBJECT (proxy), "destroy", (GCallback) bamf_indicator_on_destroy, self); | 233 | if (owner) |
2458 | 234 | { | ||
2459 | 235 | g_free (owner); | ||
2460 | 236 | |||
2461 | 237 | g_signal_connect (G_OBJECT (proxy), "notify::g-name-owner", | ||
2462 | 238 | G_CALLBACK (bamf_indicator_on_destroy), self); | ||
2463 | 239 | |||
2464 | 240 | if (priv->proxy) | ||
2465 | 241 | g_object_unref (priv->proxy); | ||
2466 | 242 | |||
2467 | 243 | priv->proxy = proxy; | ||
2468 | 244 | } | ||
2469 | 245 | else | ||
2470 | 246 | { | ||
2471 | 247 | g_debug ("Failed to get notification approver proxy: no owner available"); | ||
2472 | 248 | g_object_unref (proxy); | ||
2473 | 249 | } | ||
2474 | 250 | } | ||
2475 | 209 | } | 251 | } |
2476 | 210 | 252 | ||
2477 | 211 | static void | 253 | static void |
2478 | @@ -243,17 +285,31 @@ | |||
2479 | 243 | } | 285 | } |
2480 | 244 | 286 | ||
2481 | 245 | static void | 287 | static void |
2482 | 288 | bamf_indicator_finalize (GObject *object) | ||
2483 | 289 | { | ||
2484 | 290 | BamfIndicatorPrivate *priv; | ||
2485 | 291 | |||
2486 | 292 | priv = BAMF_INDICATOR (object)->priv; | ||
2487 | 293 | |||
2488 | 294 | g_object_unref (priv->dbus_iface); | ||
2489 | 295 | |||
2490 | 296 | G_OBJECT_CLASS (bamf_indicator_parent_class)->finalize (object); | ||
2491 | 297 | } | ||
2492 | 298 | |||
2493 | 299 | static void | ||
2494 | 246 | bamf_indicator_class_init (BamfIndicatorClass *klass) | 300 | bamf_indicator_class_init (BamfIndicatorClass *klass) |
2495 | 247 | { | 301 | { |
2496 | 248 | GParamSpec *pspec; | 302 | GParamSpec *pspec; |
2497 | 249 | GObjectClass *object_class = G_OBJECT_CLASS (klass); | 303 | GObjectClass *object_class = G_OBJECT_CLASS (klass); |
2498 | 250 | BamfViewClass *view_class = BAMF_VIEW_CLASS (klass); | 304 | BamfViewClass *view_class = BAMF_VIEW_CLASS (klass); |
2505 | 251 | 305 | ||
2506 | 252 | object_class->constructed = bamf_indicator_constructed; | 306 | object_class->constructed = bamf_indicator_constructed; |
2507 | 253 | object_class->get_property = bamf_indicator_get_property; | 307 | object_class->get_property = bamf_indicator_get_property; |
2508 | 254 | object_class->set_property = bamf_indicator_set_property; | 308 | object_class->set_property = bamf_indicator_set_property; |
2509 | 255 | object_class->dispose = bamf_indicator_dispose; | 309 | object_class->dispose = bamf_indicator_dispose; |
2510 | 256 | view_class->view_type = bamf_indicator_get_view_type; | 310 | object_class->finalize = bamf_indicator_finalize; |
2511 | 311 | |||
2512 | 312 | view_class->view_type = bamf_indicator_get_view_type; | ||
2513 | 257 | view_class->stable_bus_name = bamf_indicator_get_stable_bus_name; | 313 | view_class->stable_bus_name = bamf_indicator_get_stable_bus_name; |
2514 | 258 | 314 | ||
2515 | 259 | pspec = g_param_spec_string ("address", "address", "address", NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT); | 315 | pspec = g_param_spec_string ("address", "address", "address", NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT); |
2516 | @@ -268,9 +324,6 @@ | |||
2517 | 268 | pspec = g_param_spec_uint ("pid", "pid", "pid", 0, G_MAXUINT32, 0, G_PARAM_READWRITE); | 324 | pspec = g_param_spec_uint ("pid", "pid", "pid", 0, G_MAXUINT32, 0, G_PARAM_READWRITE); |
2518 | 269 | g_object_class_install_property (object_class, PROP_PID, pspec); | 325 | g_object_class_install_property (object_class, PROP_PID, pspec); |
2519 | 270 | 326 | ||
2520 | 271 | dbus_g_object_type_install_info (BAMF_TYPE_INDICATOR, | ||
2521 | 272 | &dbus_glib_bamf_indicator_object_info); | ||
2522 | 273 | |||
2523 | 274 | g_type_class_add_private (object_class, sizeof (BamfIndicatorPrivate)); | 327 | g_type_class_add_private (object_class, sizeof (BamfIndicatorPrivate)); |
2524 | 275 | } | 328 | } |
2525 | 276 | 329 | ||
2526 | @@ -278,6 +331,19 @@ | |||
2527 | 278 | bamf_indicator_init (BamfIndicator *self) | 331 | bamf_indicator_init (BamfIndicator *self) |
2528 | 279 | { | 332 | { |
2529 | 280 | self->priv = BAMF_INDICATOR_GET_PRIVATE (self); | 333 | self->priv = BAMF_INDICATOR_GET_PRIVATE (self); |
2530 | 334 | |||
2531 | 335 | self->priv->dbus_iface = bamf_dbus_item_indicator_skeleton_new (); | ||
2532 | 336 | |||
2533 | 337 | /* Registering signal callbacks to reply to dbus method calls */ | ||
2534 | 338 | g_signal_connect (self->priv->dbus_iface, "handle-path", | ||
2535 | 339 | G_CALLBACK (on_dbus_handle_path), self); | ||
2536 | 340 | |||
2537 | 341 | g_signal_connect (self->priv->dbus_iface, "handle-address", | ||
2538 | 342 | G_CALLBACK (on_dbus_handle_address), self); | ||
2539 | 343 | |||
2540 | 344 | /* Setting the interface for the dbus object */ | ||
2541 | 345 | bamf_dbus_item_object_skeleton_set_indicator (BAMF_DBUS_ITEM_OBJECT_SKELETON (self), | ||
2542 | 346 | self->priv->dbus_iface); | ||
2543 | 281 | } | 347 | } |
2544 | 282 | 348 | ||
2545 | 283 | BamfIndicator * | 349 | BamfIndicator * |
2546 | 284 | 350 | ||
2547 | === modified file 'src/bamf-indicator.h' | |||
2548 | --- src/bamf-indicator.h 2010-07-09 23:22:44 +0000 | |||
2549 | +++ src/bamf-indicator.h 2012-01-19 19:16:25 +0000 | |||
2550 | @@ -1,23 +1,21 @@ | |||
2551 | 1 | /* | 1 | /* |
2563 | 2 | * bamf-indicator.h | 2 | * Copyright (C) 2010-2011 Canonical Ltd |
2564 | 3 | * This file is part of BAMF | 3 | * |
2565 | 4 | * | 4 | * This program is free software: you can redistribute it and/or modify |
2566 | 5 | * Copyright (C) 2010 - Jason Smith | 5 | * it under the terms of the GNU General Public License version 3 as |
2567 | 6 | * | 6 | * published by the Free Software Foundation. |
2568 | 7 | * BAMF is free software; you can redistribute it and/or modify | 7 | * |
2569 | 8 | * it under the terms of the GNU General Public License as published by | 8 | * This program is distributed in the hope that it will be useful, |
2559 | 9 | * the Free Software Foundation; either version 2 of the License, or | ||
2560 | 10 | * (at your option) any later version. | ||
2561 | 11 | * | ||
2562 | 12 | * BAMF is distributed in the hope that it will be useful, | ||
2570 | 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2571 | 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2572 | 15 | * GNU General Public License for more details. | 11 | * GNU General Public License for more details. |
2573 | 16 | * | 12 | * |
2574 | 17 | * You should have received a copy of the GNU General Public License | 13 | * You should have received a copy of the GNU General Public License |
2578 | 18 | * along with BAMF; if not, write to the Free Software | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2579 | 19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, | 15 | * |
2580 | 20 | * Boston, MA 02110-1301 USA | 16 | * Authored by: Jason Smith <jason.smith@canonical.com> |
2581 | 17 | * Marco Trevisan (Treviño) <3v1n0@ubuntu.com> | ||
2582 | 18 | * | ||
2583 | 21 | */ | 19 | */ |
2584 | 22 | 20 | ||
2585 | 23 | #ifndef __BAMF_INDICATOR_H__ | 21 | #ifndef __BAMF_INDICATOR_H__ |
2586 | @@ -42,7 +40,7 @@ | |||
2587 | 42 | 40 | ||
2588 | 43 | struct _BamfIndicator { | 41 | struct _BamfIndicator { |
2589 | 44 | BamfView parent; | 42 | BamfView parent; |
2591 | 45 | 43 | ||
2592 | 46 | BamfIndicatorPrivate *priv; | 44 | BamfIndicatorPrivate *priv; |
2593 | 47 | }; | 45 | }; |
2594 | 48 | 46 | ||
2595 | @@ -52,23 +50,23 @@ | |||
2596 | 52 | 50 | ||
2597 | 53 | GType bamf_indicator_get_type (void) G_GNUC_CONST; | 51 | GType bamf_indicator_get_type (void) G_GNUC_CONST; |
2598 | 54 | 52 | ||
2616 | 55 | char * bamf_indicator_get_id (BamfIndicator *self); | 53 | const char * bamf_indicator_get_id (BamfIndicator *self); |
2617 | 56 | 54 | ||
2618 | 57 | char * bamf_indicator_get_path (BamfIndicator *self); | 55 | const char * bamf_indicator_get_path (BamfIndicator *self); |
2619 | 58 | 56 | ||
2620 | 59 | char * bamf_indicator_get_address (BamfIndicator *self); | 57 | const char * bamf_indicator_get_address (BamfIndicator *self); |
2621 | 60 | 58 | ||
2622 | 61 | guint32 bamf_indicator_get_pid (BamfIndicator *self); | 59 | guint32 bamf_indicator_get_pid (BamfIndicator *self); |
2623 | 62 | 60 | ||
2624 | 63 | gboolean bamf_indicator_matches_signature (BamfIndicator *self, | 61 | gboolean bamf_indicator_matches_signature (BamfIndicator *self, |
2625 | 64 | gint pid, | 62 | gint pid, |
2626 | 65 | const char *address, | 63 | const char *address, |
2627 | 66 | const char *path); | 64 | const char *path); |
2628 | 67 | 65 | ||
2629 | 68 | BamfIndicator *bamf_indicator_new (const char *id, | 66 | BamfIndicator * bamf_indicator_new (const char *id, |
2630 | 69 | const char *proxy, | 67 | const char *proxy, |
2631 | 70 | const char *address, | 68 | const char *address, |
2632 | 71 | guint32 pid); | 69 | guint32 pid); |
2633 | 72 | 70 | ||
2634 | 73 | G_END_DECLS | 71 | G_END_DECLS |
2635 | 74 | 72 | ||
2636 | 75 | 73 | ||
2637 | === modified file 'src/bamf-marshal.list' | |||
2638 | --- src/bamf-marshal.list 2010-08-18 23:22:58 +0000 | |||
2639 | +++ src/bamf-marshal.list 2012-01-19 19:16:25 +0000 | |||
2640 | @@ -1,9 +1,10 @@ | |||
2641 | 1 | # Marshaller definitions to be generated. | 1 | # Marshaller definitions to be generated. |
2642 | 2 | # | 2 | # |
2644 | 3 | # Copyright 2010 Canonical Ltd. | 3 | # Copyright 2010-2011 Canonical Ltd. |
2645 | 4 | # | 4 | # |
2646 | 5 | # Authors: | 5 | # Authors: |
2647 | 6 | # Jason Smith <jason.smith@canonical.com> | 6 | # Jason Smith <jason.smith@canonical.com> |
2648 | 7 | # Marco Trevisan (Treviño) <3v1n0@ubuntu.com> | ||
2649 | 7 | # | 8 | # |
2650 | 8 | # This program is free software: you can redistribute it and/or modify it | 9 | # This program is free software: you can redistribute it and/or modify it |
2651 | 9 | # under the terms of the GNU General Public License version 3, as published | 10 | # under the terms of the GNU General Public License version 3, as published |
2652 | @@ -17,8 +18,4 @@ | |||
2653 | 17 | # You should have received a copy of the GNU General Public License along | 18 | # You should have received a copy of the GNU General Public License along |
2654 | 18 | # with this program. If not, see <http://www.gnu.org/licenses/>. | 19 | # with this program. If not, see <http://www.gnu.org/licenses/>. |
2655 | 19 | 20 | ||
2656 | 20 | VOID: BOOL, STRING, STRING | ||
2657 | 21 | VOID: STRING, STRING | ||
2658 | 22 | VOID: STRING, STRING, STRING | 21 | VOID: STRING, STRING, STRING |
2659 | 23 | VOID: OBJECT, OBJECT | ||
2660 | 24 | VOID: STRING, INT, STRING, STRING, STRING | ||
2661 | 25 | 22 | ||
2662 | === removed file 'src/bamf-matcher-glue.xml' | |||
2663 | --- src/bamf-matcher-glue.xml 2010-09-08 23:38:35 +0000 | |||
2664 | +++ src/bamf-matcher-glue.xml 1970-01-01 00:00:00 +0000 | |||
2665 | @@ -1,108 +0,0 @@ | |||
2666 | 1 | <?xml version="1.0" encoding="UTF-8" ?> | ||
2667 | 2 | |||
2668 | 3 | <node name="/org/ayatana/bamf"> | ||
2669 | 4 | |||
2670 | 5 | <interface name="org.ayatana.bamf.matcher"> | ||
2671 | 6 | |||
2672 | 7 | <signal name="ViewOpened"> | ||
2673 | 8 | <arg type="s" name="path" direction="out" /> | ||
2674 | 9 | <arg type="s" name="type" direction="out" /> | ||
2675 | 10 | </signal> | ||
2676 | 11 | |||
2677 | 12 | <signal name="ViewClosed"> | ||
2678 | 13 | <arg type="s" name="path" direction="out" /> | ||
2679 | 14 | <arg type="s" name="type" direction="out" /> | ||
2680 | 15 | </signal> | ||
2681 | 16 | |||
2682 | 17 | <signal name="ActiveWindowChanged"> | ||
2683 | 18 | <arg type="s" name="old" direction="out" /> | ||
2684 | 19 | <arg type="s" name="new" direction="out" /> | ||
2685 | 20 | </signal> | ||
2686 | 21 | |||
2687 | 22 | <signal name="ActiveApplicationChanged"> | ||
2688 | 23 | <arg type="s" name="old" direction="out" /> | ||
2689 | 24 | <arg type="s" name="new" direction="out" /> | ||
2690 | 25 | </signal> | ||
2691 | 26 | |||
2692 | 27 | <method name="ActiveApplication"> | ||
2693 | 28 | <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_matcher_get_active_application" /> | ||
2694 | 29 | <arg type="s" name="application" direction="out"> | ||
2695 | 30 | <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/> | ||
2696 | 31 | </arg> | ||
2697 | 32 | </method> | ||
2698 | 33 | |||
2699 | 34 | <method name="ActiveWindow"> | ||
2700 | 35 | <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_matcher_get_active_window" /> | ||
2701 | 36 | <arg type="s" name="window" direction="out"> | ||
2702 | 37 | <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/> | ||
2703 | 38 | </arg> | ||
2704 | 39 | </method> | ||
2705 | 40 | |||
2706 | 41 | <method name="ApplicationForXid"> | ||
2707 | 42 | <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_matcher_application_for_xid" /> | ||
2708 | 43 | <arg type="u" name="xid" direction="in" /> | ||
2709 | 44 | <arg type="s" name="application" direction="out"> | ||
2710 | 45 | <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/> | ||
2711 | 46 | </arg> | ||
2712 | 47 | </method> | ||
2713 | 48 | |||
2714 | 49 | <method name="ApplicationIsRunning"> | ||
2715 | 50 | <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_matcher_application_is_running" /> | ||
2716 | 51 | <arg type="s" name="application" direction="in" /> | ||
2717 | 52 | <arg type="b" name="running" direction="out"> | ||
2718 | 53 | <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/> | ||
2719 | 54 | </arg> | ||
2720 | 55 | </method> | ||
2721 | 56 | |||
2722 | 57 | <method name="ApplicationPaths"> | ||
2723 | 58 | <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_matcher_application_dbus_paths" /> | ||
2724 | 59 | <arg type="as" name="paths" direction="out"> | ||
2725 | 60 | <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/> | ||
2726 | 61 | </arg> | ||
2727 | 62 | </method> | ||
2728 | 63 | |||
2729 | 64 | <method name="WindowPaths"> | ||
2730 | 65 | <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_matcher_window_dbus_paths" /> | ||
2731 | 66 | <arg type="as" name="paths" direction="out"> | ||
2732 | 67 | <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/> | ||
2733 | 68 | </arg> | ||
2734 | 69 | </method> | ||
2735 | 70 | |||
2736 | 71 | <method name="PathForApplication"> | ||
2737 | 72 | <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_matcher_dbus_path_for_application" /> | ||
2738 | 73 | <arg type="s" name="applicaiton" direction="in" /> | ||
2739 | 74 | <arg type="s" name="path" direction="out"> | ||
2740 | 75 | <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/> | ||
2741 | 76 | </arg> | ||
2742 | 77 | </method> | ||
2743 | 78 | |||
2744 | 79 | <method name="RegisterFavorites"> | ||
2745 | 80 | <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_matcher_register_favorites" /> | ||
2746 | 81 | <arg type="as" name="favorites" direction="in" /> | ||
2747 | 82 | </method> | ||
2748 | 83 | |||
2749 | 84 | <method name="RunningApplications"> | ||
2750 | 85 | <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_matcher_running_application_paths" /> | ||
2751 | 86 | <arg type="as" name="paths" direction="out"> | ||
2752 | 87 | <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/> | ||
2753 | 88 | </arg> | ||
2754 | 89 | </method> | ||
2755 | 90 | |||
2756 | 91 | <method name="TabPaths"> | ||
2757 | 92 | <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_matcher_tab_dbus_paths" /> | ||
2758 | 93 | <arg type="as" name="paths" direction="out"> | ||
2759 | 94 | <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/> | ||
2760 | 95 | </arg> | ||
2761 | 96 | </method> | ||
2762 | 97 | |||
2763 | 98 | <method name="XidsForApplication"> | ||
2764 | 99 | <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_matcher_xids_for_application" /> | ||
2765 | 100 | <arg type="s" name="application" direction="in" /> | ||
2766 | 101 | <arg type="au" name="xids" direction="out"> | ||
2767 | 102 | <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/> | ||
2768 | 103 | </arg> | ||
2769 | 104 | </method> | ||
2770 | 105 | |||
2771 | 106 | </interface> | ||
2772 | 107 | |||
2773 | 108 | </node> | ||
2774 | 109 | 0 | ||
2775 | === modified file 'src/bamf-matcher.c' | |||
2776 | --- src/bamf-matcher.c 2011-12-15 11:30:52 +0000 | |||
2777 | +++ src/bamf-matcher.c 2012-01-19 19:16:25 +0000 | |||
2778 | @@ -1,5 +1,5 @@ | |||
2779 | 1 | /* | 1 | /* |
2781 | 2 | * Copyright (C) 2010 Canonical Ltd | 2 | * Copyright (C) 2010-2011 Canonical Ltd |
2782 | 3 | * | 3 | * |
2783 | 4 | * This program is free software: you can redistribute it and/or modify | 4 | * This program is free software: you can redistribute it and/or modify |
2784 | 5 | * it under the terms of the GNU General Public License version 3 as | 5 | * it under the terms of the GNU General Public License version 3 as |
2785 | @@ -22,9 +22,7 @@ | |||
2786 | 22 | 22 | ||
2787 | 23 | #include <gdk/gdkx.h> | 23 | #include <gdk/gdkx.h> |
2788 | 24 | 24 | ||
2789 | 25 | #include "bamf-marshal.h" | ||
2790 | 26 | #include "bamf-matcher.h" | 25 | #include "bamf-matcher.h" |
2791 | 27 | #include "bamf-matcher-glue.h" | ||
2792 | 28 | #include "bamf-application.h" | 26 | #include "bamf-application.h" |
2793 | 29 | #include "bamf-window.h" | 27 | #include "bamf-window.h" |
2794 | 30 | #include "bamf-legacy-window.h" | 28 | #include "bamf-legacy-window.h" |
2795 | @@ -32,16 +30,12 @@ | |||
2796 | 32 | #include "bamf-legacy-screen.h" | 30 | #include "bamf-legacy-screen.h" |
2797 | 33 | #include "bamf-indicator-source.h" | 31 | #include "bamf-indicator-source.h" |
2798 | 34 | 32 | ||
2800 | 35 | G_DEFINE_TYPE (BamfMatcher, bamf_matcher, G_TYPE_OBJECT); | 33 | G_DEFINE_TYPE (BamfMatcher, bamf_matcher, BAMF_DBUS_TYPE_MATCHER_SKELETON); |
2801 | 36 | #define BAMF_MATCHER_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE(obj, \ | 34 | #define BAMF_MATCHER_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE(obj, \ |
2803 | 37 | BAMF_TYPE_MATCHER, BamfMatcherPrivate)) | 35 | BAMF_TYPE_MATCHER, BamfMatcherPrivate)) |
2804 | 38 | 36 | ||
2805 | 39 | enum | 37 | enum |
2806 | 40 | { | 38 | { |
2807 | 41 | VIEW_OPENED, | ||
2808 | 42 | VIEW_CLOSED, | ||
2809 | 43 | ACTIVE_APPLICATION_CHANGED, | ||
2810 | 44 | ACTIVE_WINDOW_CHANGED, | ||
2811 | 45 | FAVORITES_CHANGED, | 39 | FAVORITES_CHANGED, |
2812 | 46 | 40 | ||
2813 | 47 | LAST_SIGNAL, | 41 | LAST_SIGNAL, |
2814 | @@ -49,16 +43,6 @@ | |||
2815 | 49 | 43 | ||
2816 | 50 | static guint matcher_signals[LAST_SIGNAL] = { 0 }; | 44 | static guint matcher_signals[LAST_SIGNAL] = { 0 }; |
2817 | 51 | 45 | ||
2818 | 52 | typedef struct _OpenOfficeTimeoutArgs OpenOfficeTimeoutArgs; | ||
2819 | 53 | |||
2820 | 54 | struct _OpenOfficeTimeoutArgs | ||
2821 | 55 | { | ||
2822 | 56 | BamfMatcher *matcher; | ||
2823 | 57 | BamfLegacyWindow *window; | ||
2824 | 58 | int count; | ||
2825 | 59 | }; | ||
2826 | 60 | |||
2827 | 61 | |||
2828 | 62 | struct _BamfMatcherPrivate | 46 | struct _BamfMatcherPrivate |
2829 | 63 | { | 47 | { |
2830 | 64 | GArray * bad_prefixes; | 48 | GArray * bad_prefixes; |
2831 | @@ -103,11 +87,9 @@ | |||
2832 | 103 | else | 87 | else |
2833 | 104 | priv->active_app = NULL; | 88 | priv->active_app = NULL; |
2834 | 105 | 89 | ||
2840 | 106 | g_signal_emit (matcher, | 90 | g_signal_emit_by_name (matcher, "active-application-changed", |
2841 | 107 | matcher_signals[ACTIVE_APPLICATION_CHANGED], | 91 | BAMF_IS_VIEW (last) ? bamf_view_get_path (BAMF_VIEW (last)) : "", |
2842 | 108 | 0, | 92 | BAMF_IS_VIEW (priv->active_app) ? bamf_view_get_path (BAMF_VIEW (priv->active_app)) : ""); |
2838 | 109 | BAMF_IS_VIEW (last) ? bamf_view_get_path (BAMF_VIEW (last)) : NULL, | ||
2839 | 110 | BAMF_IS_VIEW (priv->active_app) ? bamf_view_get_path (BAMF_VIEW (priv->active_app)) : NULL); | ||
2843 | 111 | } | 93 | } |
2844 | 112 | else if (BAMF_IS_WINDOW (view)) | 94 | else if (BAMF_IS_WINDOW (view)) |
2845 | 113 | { | 95 | { |
2846 | @@ -127,11 +109,10 @@ | |||
2847 | 127 | else | 109 | else |
2848 | 128 | priv->active_win = NULL; | 110 | priv->active_win = NULL; |
2849 | 129 | 111 | ||
2855 | 130 | g_signal_emit (matcher, | 112 | |
2856 | 131 | matcher_signals[ACTIVE_WINDOW_CHANGED], | 113 | g_signal_emit_by_name (matcher, "active-window-changed", |
2857 | 132 | 0, | 114 | BAMF_IS_VIEW (last) ? bamf_view_get_path (BAMF_VIEW (last)) : "", |
2858 | 133 | BAMF_IS_VIEW (last) ? bamf_view_get_path (BAMF_VIEW (last)) : NULL, | 115 | BAMF_IS_VIEW (priv->active_win) ? bamf_view_get_path (BAMF_VIEW (priv->active_win)) : ""); |
2854 | 134 | BAMF_IS_VIEW (priv->active_win) ? bamf_view_get_path (BAMF_VIEW (priv->active_win)) : NULL); | ||
2859 | 135 | } | 116 | } |
2860 | 136 | } | 117 | } |
2861 | 137 | 118 | ||
2862 | @@ -146,9 +127,12 @@ | |||
2863 | 146 | static void | 127 | static void |
2864 | 147 | bamf_matcher_register_view (BamfMatcher *self, BamfView *view) | 128 | bamf_matcher_register_view (BamfMatcher *self, BamfView *view) |
2865 | 148 | { | 129 | { |
2867 | 149 | char * path, * type; | 130 | const char *path, *type; |
2868 | 131 | GDBusConnection *connection; | ||
2869 | 132 | GDBusInterfaceSkeleton *dbus_interface = G_DBUS_INTERFACE_SKELETON (self); | ||
2870 | 150 | 133 | ||
2872 | 151 | path = bamf_view_export_on_bus (view); | 134 | connection = g_dbus_interface_skeleton_get_connection (dbus_interface); |
2873 | 135 | path = bamf_view_export_on_bus (view, connection); | ||
2874 | 152 | type = bamf_view_get_view_type (view); | 136 | type = bamf_view_get_view_type (view); |
2875 | 153 | 137 | ||
2876 | 154 | g_signal_connect (G_OBJECT (view), "closed-internal", | 138 | g_signal_connect (G_OBJECT (view), "closed-internal", |
2877 | @@ -159,8 +143,7 @@ | |||
2878 | 159 | self->priv->views = g_list_prepend (self->priv->views, view); | 143 | self->priv->views = g_list_prepend (self->priv->views, view); |
2879 | 160 | g_object_ref (view); | 144 | g_object_ref (view); |
2880 | 161 | 145 | ||
2883 | 162 | g_signal_emit (self, matcher_signals[VIEW_OPENED],0, path, type); | 146 | g_signal_emit_by_name (self, "view-opened", path, type); |
2882 | 163 | g_free (type); | ||
2884 | 164 | 147 | ||
2885 | 165 | // trigger manually since this is already active | 148 | // trigger manually since this is already active |
2886 | 166 | if (bamf_view_is_active (view)) | 149 | if (bamf_view_is_active (view)) |
2887 | @@ -171,12 +154,12 @@ | |||
2888 | 171 | bamf_matcher_unregister_view (BamfMatcher *self, BamfView *view, gboolean unref) | 154 | bamf_matcher_unregister_view (BamfMatcher *self, BamfView *view, gboolean unref) |
2889 | 172 | { | 155 | { |
2890 | 173 | const char * path; | 156 | const char * path; |
2892 | 174 | char * type; | 157 | const char * type; |
2893 | 175 | 158 | ||
2894 | 176 | path = bamf_view_get_path (view); | 159 | path = bamf_view_get_path (view); |
2895 | 177 | type = bamf_view_get_view_type (view); | 160 | type = bamf_view_get_view_type (view); |
2896 | 178 | 161 | ||
2898 | 179 | g_signal_emit (self, matcher_signals[VIEW_CLOSED],0, path, type); | 162 | g_signal_emit_by_name (self, "view-closed", path, type); |
2899 | 180 | 163 | ||
2900 | 181 | g_signal_handlers_disconnect_by_func (G_OBJECT (view), on_view_closed, self); | 164 | g_signal_handlers_disconnect_by_func (G_OBJECT (view), on_view_closed, self); |
2901 | 182 | g_signal_handlers_disconnect_by_func (G_OBJECT (view), on_view_active_changed, self); | 165 | g_signal_handlers_disconnect_by_func (G_OBJECT (view), on_view_active_changed, self); |
2902 | @@ -186,8 +169,6 @@ | |||
2903 | 186 | self->priv->views = g_list_remove (self->priv->views, view); | 169 | self->priv->views = g_list_remove (self->priv->views, view); |
2904 | 187 | g_object_unref (view); | 170 | g_object_unref (view); |
2905 | 188 | } | 171 | } |
2906 | 189 | |||
2907 | 190 | g_free (type); | ||
2908 | 191 | } | 172 | } |
2909 | 192 | 173 | ||
2910 | 193 | static char * | 174 | static char * |
2911 | @@ -317,7 +298,8 @@ | |||
2912 | 317 | gboolean regexFail; | 298 | gboolean regexFail; |
2913 | 318 | GRegex *regex; | 299 | GRegex *regex; |
2914 | 319 | 300 | ||
2916 | 320 | g_return_val_if_fail ((execString && execString[0] != '\0'), g_strdup (execString)); | 301 | if (!execString || (execString && execString[0] == '\0')) |
2917 | 302 | return NULL; | ||
2918 | 321 | 303 | ||
2919 | 322 | exec = g_utf8_casefold (execString, -1); | 304 | exec = g_utf8_casefold (execString, -1); |
2920 | 323 | parts = g_strsplit (exec, " ", 0); | 305 | parts = g_strsplit (exec, " ", 0); |
2921 | @@ -983,7 +965,7 @@ | |||
2922 | 983 | path = g_file_get_path (file); | 965 | path = g_file_get_path (file); |
2923 | 984 | filetype = g_file_query_file_type (file, G_FILE_QUERY_INFO_NONE, NULL); | 966 | filetype = g_file_query_file_type (file, G_FILE_QUERY_INFO_NONE, NULL); |
2924 | 985 | monitored_dir = g_object_get_data (G_OBJECT (monitor), "root"); | 967 | monitored_dir = g_object_get_data (G_OBJECT (monitor), "root"); |
2926 | 986 | 968 | ||
2927 | 987 | if (!g_str_has_suffix (path, ".desktop") && | 969 | if (!g_str_has_suffix (path, ".desktop") && |
2928 | 988 | filetype != G_FILE_TYPE_DIRECTORY && | 970 | filetype != G_FILE_TYPE_DIRECTORY && |
2929 | 989 | type != G_FILE_MONITOR_EVENT_DELETED) | 971 | type != G_FILE_MONITOR_EVENT_DELETED) |
2930 | @@ -1367,7 +1349,7 @@ | |||
2931 | 1367 | g_free (exec_string); | 1349 | g_free (exec_string); |
2932 | 1368 | } | 1350 | } |
2933 | 1369 | 1351 | ||
2935 | 1370 | if (g_list_length (result) > 0) | 1352 | if (result) |
2936 | 1371 | { | 1353 | { |
2937 | 1372 | result = g_list_reverse (result); | 1354 | result = g_list_reverse (result); |
2938 | 1373 | return result; | 1355 | return result; |
2939 | @@ -1885,7 +1867,7 @@ | |||
2940 | 1885 | 1867 | ||
2941 | 1886 | void | 1868 | void |
2942 | 1887 | bamf_matcher_load_desktop_file (BamfMatcher * self, | 1869 | bamf_matcher_load_desktop_file (BamfMatcher * self, |
2944 | 1888 | char * desktop_file) | 1870 | const char * desktop_file) |
2945 | 1889 | { | 1871 | { |
2946 | 1890 | g_return_if_fail (BAMF_IS_MATCHER (self)); | 1872 | g_return_if_fail (BAMF_IS_MATCHER (self)); |
2947 | 1891 | 1873 | ||
2948 | @@ -1937,7 +1919,7 @@ | |||
2949 | 1937 | return 0; | 1919 | return 0; |
2950 | 1938 | } | 1920 | } |
2951 | 1939 | 1921 | ||
2953 | 1940 | char * | 1922 | const char * |
2954 | 1941 | bamf_matcher_get_active_application (BamfMatcher *matcher) | 1923 | bamf_matcher_get_active_application (BamfMatcher *matcher) |
2955 | 1942 | { | 1924 | { |
2956 | 1943 | GList *l; | 1925 | GList *l; |
2957 | @@ -1957,14 +1939,14 @@ | |||
2958 | 1957 | 1939 | ||
2959 | 1958 | if (bamf_view_is_active (view)) | 1940 | if (bamf_view_is_active (view)) |
2960 | 1959 | { | 1941 | { |
2962 | 1960 | return g_strdup (bamf_view_get_path (view)); | 1942 | return bamf_view_get_path (view); |
2963 | 1961 | } | 1943 | } |
2964 | 1962 | } | 1944 | } |
2965 | 1963 | 1945 | ||
2967 | 1964 | return NULL; | 1946 | return ""; |
2968 | 1965 | } | 1947 | } |
2969 | 1966 | 1948 | ||
2971 | 1967 | char * | 1949 | const char * |
2972 | 1968 | bamf_matcher_get_active_window (BamfMatcher *matcher) | 1950 | bamf_matcher_get_active_window (BamfMatcher *matcher) |
2973 | 1969 | { | 1951 | { |
2974 | 1970 | GList *l; | 1952 | GList *l; |
2975 | @@ -1984,14 +1966,14 @@ | |||
2976 | 1984 | 1966 | ||
2977 | 1985 | if (bamf_view_is_active (view)) | 1967 | if (bamf_view_is_active (view)) |
2978 | 1986 | { | 1968 | { |
2980 | 1987 | return g_strdup (bamf_view_get_path (view)); | 1969 | return bamf_view_get_path (view); |
2981 | 1988 | } | 1970 | } |
2982 | 1989 | } | 1971 | } |
2983 | 1990 | 1972 | ||
2985 | 1991 | return NULL; | 1973 | return ""; |
2986 | 1992 | } | 1974 | } |
2987 | 1993 | 1975 | ||
2989 | 1994 | char * | 1976 | const char * |
2990 | 1995 | bamf_matcher_application_for_xid (BamfMatcher *matcher, | 1977 | bamf_matcher_application_for_xid (BamfMatcher *matcher, |
2991 | 1996 | guint32 xid) | 1978 | guint32 xid) |
2992 | 1997 | { | 1979 | { |
2993 | @@ -2012,16 +1994,16 @@ | |||
2994 | 2012 | 1994 | ||
2995 | 2013 | if (bamf_application_manages_xid (BAMF_APPLICATION (view), xid)) | 1995 | if (bamf_application_manages_xid (BAMF_APPLICATION (view), xid)) |
2996 | 2014 | { | 1996 | { |
2998 | 2015 | return g_strdup (bamf_view_get_path (view)); | 1997 | return bamf_view_get_path (view); |
2999 | 2016 | } | 1998 | } |
3000 | 2017 | } | 1999 | } |
3001 | 2018 | 2000 | ||
3003 | 2019 | return NULL; | 2001 | return ""; |
3004 | 2020 | } | 2002 | } |
3005 | 2021 | 2003 | ||
3006 | 2022 | gboolean | 2004 | gboolean |
3007 | 2023 | bamf_matcher_application_is_running (BamfMatcher *matcher, | 2005 | bamf_matcher_application_is_running (BamfMatcher *matcher, |
3009 | 2024 | char *application) | 2006 | const char *application) |
3010 | 2025 | { | 2007 | { |
3011 | 2026 | char * desktop_file; | 2008 | char * desktop_file; |
3012 | 2027 | GList *l; | 2009 | GList *l; |
3013 | @@ -2051,22 +2033,21 @@ | |||
3014 | 2051 | return FALSE; | 2033 | return FALSE; |
3015 | 2052 | } | 2034 | } |
3016 | 2053 | 2035 | ||
3018 | 2054 | char ** | 2036 | GVariant * |
3019 | 2055 | bamf_matcher_window_dbus_paths (BamfMatcher *matcher) | 2037 | bamf_matcher_window_dbus_paths (BamfMatcher *matcher) |
3020 | 2056 | { | 2038 | { |
3021 | 2057 | char ** paths; | ||
3022 | 2058 | int i; | ||
3023 | 2059 | GList *l; | 2039 | GList *l; |
3024 | 2060 | BamfView *view; | 2040 | BamfView *view; |
3025 | 2061 | BamfMatcherPrivate *priv; | 2041 | BamfMatcherPrivate *priv; |
3026 | 2042 | GVariantBuilder b; | ||
3027 | 2062 | 2043 | ||
3028 | 2063 | g_return_val_if_fail (BAMF_IS_MATCHER (matcher), NULL); | 2044 | g_return_val_if_fail (BAMF_IS_MATCHER (matcher), NULL); |
3029 | 2064 | 2045 | ||
3030 | 2046 | g_variant_builder_init (&b, G_VARIANT_TYPE ("(as)")); | ||
3031 | 2047 | g_variant_builder_open (&b, G_VARIANT_TYPE ("as")); | ||
3032 | 2048 | |||
3033 | 2065 | priv = matcher->priv; | 2049 | priv = matcher->priv; |
3034 | 2066 | 2050 | ||
3035 | 2067 | paths = g_malloc0 (sizeof (char *) * (g_list_length (priv->views) + 1)); | ||
3036 | 2068 | |||
3037 | 2069 | i = 0; | ||
3038 | 2070 | for (l = priv->views; l; l = l->next) | 2051 | for (l = priv->views; l; l = l->next) |
3039 | 2071 | { | 2052 | { |
3040 | 2072 | view = l->data; | 2053 | view = l->data; |
3041 | @@ -2074,29 +2055,29 @@ | |||
3042 | 2074 | if (!BAMF_IS_WINDOW (view)) | 2055 | if (!BAMF_IS_WINDOW (view)) |
3043 | 2075 | continue; | 2056 | continue; |
3044 | 2076 | 2057 | ||
3047 | 2077 | paths[i] = g_strdup (bamf_view_get_path (view)); | 2058 | g_variant_builder_add (&b, "s", bamf_view_get_path (view)); |
3046 | 2078 | i++; | ||
3048 | 2079 | } | 2059 | } |
3049 | 2080 | 2060 | ||
3051 | 2081 | return paths; | 2061 | g_variant_builder_close (&b); |
3052 | 2062 | |||
3053 | 2063 | return g_variant_builder_end (&b); | ||
3054 | 2082 | } | 2064 | } |
3055 | 2083 | 2065 | ||
3057 | 2084 | char ** | 2066 | GVariant * |
3058 | 2085 | bamf_matcher_application_dbus_paths (BamfMatcher *matcher) | 2067 | bamf_matcher_application_dbus_paths (BamfMatcher *matcher) |
3059 | 2086 | { | 2068 | { |
3060 | 2087 | char ** paths; | ||
3061 | 2088 | int i; | ||
3062 | 2089 | GList *l; | 2069 | GList *l; |
3063 | 2090 | BamfView *view; | 2070 | BamfView *view; |
3064 | 2091 | BamfMatcherPrivate *priv; | 2071 | BamfMatcherPrivate *priv; |
3065 | 2072 | GVariantBuilder b; | ||
3066 | 2092 | 2073 | ||
3067 | 2093 | g_return_val_if_fail (BAMF_IS_MATCHER (matcher), NULL); | 2074 | g_return_val_if_fail (BAMF_IS_MATCHER (matcher), NULL); |
3068 | 2094 | 2075 | ||
3069 | 2076 | g_variant_builder_init (&b, G_VARIANT_TYPE ("(as)")); | ||
3070 | 2077 | g_variant_builder_open (&b, G_VARIANT_TYPE ("as")); | ||
3071 | 2078 | |||
3072 | 2095 | priv = matcher->priv; | 2079 | priv = matcher->priv; |
3073 | 2096 | 2080 | ||
3074 | 2097 | paths = g_malloc0 (sizeof (char *) * (g_list_length (priv->views) + 1)); | ||
3075 | 2098 | |||
3076 | 2099 | i = 0; | ||
3077 | 2100 | for (l = priv->views; l; l = l->next) | 2081 | for (l = priv->views; l; l = l->next) |
3078 | 2101 | { | 2082 | { |
3079 | 2102 | view = l->data; | 2083 | view = l->data; |
3080 | @@ -2104,18 +2085,19 @@ | |||
3081 | 2104 | if (!BAMF_IS_APPLICATION (view)) | 2085 | if (!BAMF_IS_APPLICATION (view)) |
3082 | 2105 | continue; | 2086 | continue; |
3083 | 2106 | 2087 | ||
3086 | 2107 | paths[i] = g_strdup (bamf_view_get_path (view)); | 2088 | g_variant_builder_add (&b, "s", bamf_view_get_path (view)); |
3085 | 2108 | i++; | ||
3087 | 2109 | } | 2089 | } |
3088 | 2110 | 2090 | ||
3090 | 2111 | return paths; | 2091 | g_variant_builder_close (&b); |
3091 | 2092 | |||
3092 | 2093 | return g_variant_builder_end (&b); | ||
3093 | 2112 | } | 2094 | } |
3094 | 2113 | 2095 | ||
3096 | 2114 | char * | 2096 | const char * |
3097 | 2115 | bamf_matcher_dbus_path_for_application (BamfMatcher *matcher, | 2097 | bamf_matcher_dbus_path_for_application (BamfMatcher *matcher, |
3099 | 2116 | char *application) | 2098 | const char *application) |
3100 | 2117 | { | 2099 | { |
3102 | 2118 | char * path = NULL; | 2100 | const char * path = ""; |
3103 | 2119 | char * desktop_file; | 2101 | char * desktop_file; |
3104 | 2120 | GList *l; | 2102 | GList *l; |
3105 | 2121 | BamfView *view; | 2103 | BamfView *view; |
3106 | @@ -2135,7 +2117,7 @@ | |||
3107 | 2135 | desktop_file = bamf_application_get_desktop_file (BAMF_APPLICATION (view)); | 2117 | desktop_file = bamf_application_get_desktop_file (BAMF_APPLICATION (view)); |
3108 | 2136 | if (g_strcmp0 (desktop_file, application) == 0) | 2118 | if (g_strcmp0 (desktop_file, application) == 0) |
3109 | 2137 | { | 2119 | { |
3111 | 2138 | path = g_strdup (bamf_view_get_path (view)); | 2120 | path = bamf_view_get_path (view); |
3112 | 2139 | } | 2121 | } |
3113 | 2140 | g_free (desktop_file); | 2122 | g_free (desktop_file); |
3114 | 2141 | } | 2123 | } |
3115 | @@ -2151,18 +2133,16 @@ | |||
3116 | 2151 | return matcher->priv->favorites; | 2133 | return matcher->priv->favorites; |
3117 | 2152 | } | 2134 | } |
3118 | 2153 | 2135 | ||
3120 | 2154 | gboolean | 2136 | void |
3121 | 2155 | bamf_matcher_register_favorites (BamfMatcher *matcher, | 2137 | bamf_matcher_register_favorites (BamfMatcher *matcher, |
3124 | 2156 | char **favorites, | 2138 | const char **favorites) |
3123 | 2157 | GError *error) | ||
3125 | 2158 | { | 2139 | { |
3128 | 2159 | char *fav; | 2140 | const char *fav; |
3129 | 2160 | char **favs; | 2141 | const char **favs; |
3130 | 2161 | BamfMatcherPrivate *priv; | 2142 | BamfMatcherPrivate *priv; |
3135 | 2162 | 2143 | ||
3136 | 2163 | g_return_val_if_fail (BAMF_IS_MATCHER (matcher), TRUE); | 2144 | g_return_if_fail (BAMF_IS_MATCHER (matcher)); |
3137 | 2164 | g_return_val_if_fail (favorites, TRUE); | 2145 | g_return_if_fail (favorites); |
3134 | 2165 | |||
3138 | 2166 | priv = matcher->priv; | 2146 | priv = matcher->priv; |
3139 | 2167 | 2147 | ||
3140 | 2168 | for (favs = favorites; *favs; favs++) | 2148 | for (favs = favorites; *favs; favs++) |
3141 | @@ -2171,33 +2151,29 @@ | |||
3142 | 2171 | /* ignore things already in the list */ | 2151 | /* ignore things already in the list */ |
3143 | 2172 | if (g_list_find_custom (priv->favorites, fav, (GCompareFunc) g_strcmp0)) | 2152 | if (g_list_find_custom (priv->favorites, fav, (GCompareFunc) g_strcmp0)) |
3144 | 2173 | continue; | 2153 | continue; |
3147 | 2174 | 2154 | ||
3146 | 2175 | |||
3148 | 2176 | priv->favorites = g_list_prepend (priv->favorites, g_strdup (fav)); | 2155 | priv->favorites = g_list_prepend (priv->favorites, g_strdup (fav)); |
3149 | 2177 | bamf_matcher_load_desktop_file (matcher, fav); | 2156 | bamf_matcher_load_desktop_file (matcher, fav); |
3150 | 2178 | } | 2157 | } |
3152 | 2179 | 2158 | ||
3153 | 2180 | g_signal_emit (matcher, matcher_signals[FAVORITES_CHANGED], 0); | 2159 | g_signal_emit (matcher, matcher_signals[FAVORITES_CHANGED], 0); |
3154 | 2181 | |||
3155 | 2182 | return TRUE; | ||
3156 | 2183 | } | 2160 | } |
3157 | 2184 | 2161 | ||
3159 | 2185 | char ** | 2162 | GVariant * |
3160 | 2186 | bamf_matcher_running_application_paths (BamfMatcher *matcher) | 2163 | bamf_matcher_running_application_paths (BamfMatcher *matcher) |
3161 | 2187 | { | 2164 | { |
3162 | 2188 | char ** paths; | ||
3163 | 2189 | int i; | ||
3164 | 2190 | GList *l; | 2165 | GList *l; |
3165 | 2191 | BamfView *view; | 2166 | BamfView *view; |
3166 | 2192 | BamfMatcherPrivate *priv; | 2167 | BamfMatcherPrivate *priv; |
3167 | 2168 | GVariantBuilder b; | ||
3168 | 2193 | 2169 | ||
3169 | 2194 | g_return_val_if_fail (BAMF_IS_MATCHER (matcher), NULL); | 2170 | g_return_val_if_fail (BAMF_IS_MATCHER (matcher), NULL); |
3170 | 2195 | 2171 | ||
3171 | 2172 | g_variant_builder_init (&b, G_VARIANT_TYPE ("(as)")); | ||
3172 | 2173 | g_variant_builder_open (&b, G_VARIANT_TYPE ("as")); | ||
3173 | 2174 | |||
3174 | 2196 | priv = matcher->priv; | 2175 | priv = matcher->priv; |
3175 | 2197 | 2176 | ||
3176 | 2198 | paths = g_malloc0 (sizeof (char *) * (g_list_length (priv->views) + 1)); | ||
3177 | 2199 | |||
3178 | 2200 | i = 0; | ||
3179 | 2201 | for (l = priv->views; l; l = l->next) | 2177 | for (l = priv->views; l; l = l->next) |
3180 | 2202 | { | 2178 | { |
3181 | 2203 | view = l->data; | 2179 | view = l->data; |
3182 | @@ -2205,24 +2181,31 @@ | |||
3183 | 2205 | if (!BAMF_IS_APPLICATION (view) || !bamf_view_is_running (view)) | 2181 | if (!BAMF_IS_APPLICATION (view) || !bamf_view_is_running (view)) |
3184 | 2206 | continue; | 2182 | continue; |
3185 | 2207 | 2183 | ||
3188 | 2208 | paths[i] = g_strdup (bamf_view_get_path (view)); | 2184 | g_variant_builder_add (&b, "s", bamf_view_get_path (view)); |
3187 | 2209 | i++; | ||
3189 | 2210 | } | 2185 | } |
3190 | 2211 | 2186 | ||
3192 | 2212 | return paths; | 2187 | g_variant_builder_close (&b); |
3193 | 2188 | |||
3194 | 2189 | return g_variant_builder_end (&b); | ||
3195 | 2213 | } | 2190 | } |
3196 | 2214 | 2191 | ||
3198 | 2215 | char ** | 2192 | GVariant * |
3199 | 2216 | bamf_matcher_tab_dbus_paths (BamfMatcher *matcher) | 2193 | bamf_matcher_tab_dbus_paths (BamfMatcher *matcher) |
3200 | 2217 | { | 2194 | { |
3202 | 2218 | return NULL; | 2195 | GVariantBuilder b; |
3203 | 2196 | |||
3204 | 2197 | g_variant_builder_init (&b, G_VARIANT_TYPE ("(as)")); | ||
3205 | 2198 | g_variant_builder_open (&b, G_VARIANT_TYPE ("as")); | ||
3206 | 2199 | g_variant_builder_close (&b); | ||
3207 | 2200 | return g_variant_builder_end (&b); | ||
3208 | 2219 | } | 2201 | } |
3209 | 2220 | 2202 | ||
3211 | 2221 | GArray * | 2203 | GVariant * |
3212 | 2222 | bamf_matcher_xids_for_application (BamfMatcher *matcher, | 2204 | bamf_matcher_xids_for_application (BamfMatcher *matcher, |
3214 | 2223 | char *application) | 2205 | const char *application) |
3215 | 2224 | { | 2206 | { |
3217 | 2225 | GArray * xids = NULL; | 2207 | GVariantBuilder b; |
3218 | 2208 | GVariant *xids; | ||
3219 | 2226 | char * desktop_file; | 2209 | char * desktop_file; |
3220 | 2227 | GList *l; | 2210 | GList *l; |
3221 | 2228 | BamfView *view; | 2211 | BamfView *view; |
3222 | @@ -2231,6 +2214,7 @@ | |||
3223 | 2231 | g_return_val_if_fail (BAMF_IS_MATCHER (matcher), NULL); | 2214 | g_return_val_if_fail (BAMF_IS_MATCHER (matcher), NULL); |
3224 | 2232 | 2215 | ||
3225 | 2233 | priv = matcher->priv; | 2216 | priv = matcher->priv; |
3226 | 2217 | xids = NULL; | ||
3227 | 2234 | 2218 | ||
3228 | 2235 | for (l = priv->views; l; l = l->next) | 2219 | for (l = priv->views; l; l = l->next) |
3229 | 2236 | { | 2220 | { |
3230 | @@ -2249,19 +2233,159 @@ | |||
3231 | 2249 | g_free (desktop_file); | 2233 | g_free (desktop_file); |
3232 | 2250 | } | 2234 | } |
3233 | 2251 | 2235 | ||
3234 | 2236 | if (!xids) | ||
3235 | 2237 | { | ||
3236 | 2238 | g_variant_builder_init (&b, G_VARIANT_TYPE ("(au)")); | ||
3237 | 2239 | g_variant_builder_open (&b, G_VARIANT_TYPE ("au")); | ||
3238 | 2240 | g_variant_builder_close (&b); | ||
3239 | 2241 | xids = g_variant_builder_end (&b); | ||
3240 | 2242 | } | ||
3241 | 2243 | |||
3242 | 2252 | return xids; | 2244 | return xids; |
3243 | 2253 | } | 2245 | } |
3244 | 2254 | 2246 | ||
3245 | 2247 | static gboolean | ||
3246 | 2248 | on_dbus_handle_xids_for_application (BamfDBusMatcher *interface, | ||
3247 | 2249 | GDBusMethodInvocation *invocation, | ||
3248 | 2250 | const gchar *application, | ||
3249 | 2251 | BamfMatcher *self) | ||
3250 | 2252 | { | ||
3251 | 2253 | GVariant *xids = bamf_matcher_xids_for_application (self, application); | ||
3252 | 2254 | g_dbus_method_invocation_return_value (invocation, xids); | ||
3253 | 2255 | |||
3254 | 2256 | return TRUE; | ||
3255 | 2257 | } | ||
3256 | 2258 | |||
3257 | 2259 | static gboolean | ||
3258 | 2260 | on_dbus_handle_tab_paths (BamfDBusMatcher *interface, | ||
3259 | 2261 | GDBusMethodInvocation *invocation, | ||
3260 | 2262 | BamfMatcher *self) | ||
3261 | 2263 | { | ||
3262 | 2264 | GVariant *tab_paths = bamf_matcher_tab_dbus_paths (self); | ||
3263 | 2265 | g_dbus_method_invocation_return_value (invocation, tab_paths); | ||
3264 | 2266 | |||
3265 | 2267 | return TRUE; | ||
3266 | 2268 | } | ||
3267 | 2269 | |||
3268 | 2270 | static gboolean | ||
3269 | 2271 | on_dbus_handle_application_paths (BamfDBusMatcher *interface, | ||
3270 | 2272 | GDBusMethodInvocation *invocation, | ||
3271 | 2273 | BamfMatcher *self) | ||
3272 | 2274 | { | ||
3273 | 2275 | GVariant *app_paths = bamf_matcher_application_dbus_paths (self); | ||
3274 | 2276 | g_dbus_method_invocation_return_value (invocation, app_paths); | ||
3275 | 2277 | |||
3276 | 2278 | return TRUE; | ||
3277 | 2279 | } | ||
3278 | 2280 | |||
3279 | 2281 | |||
3280 | 2282 | static gboolean | ||
3281 | 2283 | on_dbus_handle_window_paths (BamfDBusMatcher *interface, | ||
3282 | 2284 | GDBusMethodInvocation *invocation, | ||
3283 | 2285 | BamfMatcher *self) | ||
3284 | 2286 | { | ||
3285 | 2287 | GVariant *win_paths = bamf_matcher_window_dbus_paths (self); | ||
3286 | 2288 | g_dbus_method_invocation_return_value (invocation, win_paths); | ||
3287 | 2289 | |||
3288 | 2290 | return TRUE; | ||
3289 | 2291 | } | ||
3290 | 2292 | |||
3291 | 2293 | static gboolean | ||
3292 | 2294 | on_dbus_handle_running_applications (BamfDBusMatcher *interface, | ||
3293 | 2295 | GDBusMethodInvocation *invocation, | ||
3294 | 2296 | BamfMatcher *self) | ||
3295 | 2297 | { | ||
3296 | 2298 | GVariant *running_apps = bamf_matcher_running_application_paths (self); | ||
3297 | 2299 | g_dbus_method_invocation_return_value (invocation, running_apps); | ||
3298 | 2300 | |||
3299 | 2301 | return TRUE; | ||
3300 | 2302 | } | ||
3301 | 2303 | |||
3302 | 2304 | static gboolean | ||
3303 | 2305 | on_dbus_handle_active_application (BamfDBusMatcher *interface, | ||
3304 | 2306 | GDBusMethodInvocation *invocation, | ||
3305 | 2307 | BamfMatcher *self) | ||
3306 | 2308 | { | ||
3307 | 2309 | const gchar *active_app = bamf_matcher_get_active_application (self); | ||
3308 | 2310 | |||
3309 | 2311 | g_dbus_method_invocation_return_value (invocation, | ||
3310 | 2312 | g_variant_new ("(s)", active_app)); | ||
3311 | 2313 | return TRUE; | ||
3312 | 2314 | } | ||
3313 | 2315 | |||
3314 | 2316 | static gboolean | ||
3315 | 2317 | on_dbus_handle_active_window (BamfDBusMatcher *interface, | ||
3316 | 2318 | GDBusMethodInvocation *invocation, | ||
3317 | 2319 | BamfMatcher *self) | ||
3318 | 2320 | { | ||
3319 | 2321 | const gchar *active_win = bamf_matcher_get_active_window (self); | ||
3320 | 2322 | |||
3321 | 2323 | g_dbus_method_invocation_return_value (invocation, | ||
3322 | 2324 | g_variant_new ("(s)", active_win)); | ||
3323 | 2325 | return TRUE; | ||
3324 | 2326 | } | ||
3325 | 2327 | |||
3326 | 2328 | static gboolean | ||
3327 | 2329 | on_dbus_handle_application_is_running (BamfDBusMatcher *interface, | ||
3328 | 2330 | GDBusMethodInvocation *invocation, | ||
3329 | 2331 | const gchar *application, | ||
3330 | 2332 | BamfMatcher *self) | ||
3331 | 2333 | { | ||
3332 | 2334 | gboolean is_running = bamf_matcher_application_is_running (self, application); | ||
3333 | 2335 | |||
3334 | 2336 | g_dbus_method_invocation_return_value (invocation, | ||
3335 | 2337 | g_variant_new ("(b)", is_running)); | ||
3336 | 2338 | return TRUE; | ||
3337 | 2339 | } | ||
3338 | 2340 | |||
3339 | 2341 | static gboolean | ||
3340 | 2342 | on_dbus_handle_register_favorites (BamfDBusMatcher *interface, | ||
3341 | 2343 | GDBusMethodInvocation *invocation, | ||
3342 | 2344 | const char **favorites, | ||
3343 | 2345 | BamfMatcher *self) | ||
3344 | 2346 | { | ||
3345 | 2347 | bamf_matcher_register_favorites (self, favorites); | ||
3346 | 2348 | g_dbus_method_invocation_return_value (invocation, NULL); | ||
3347 | 2349 | |||
3348 | 2350 | return TRUE; | ||
3349 | 2351 | } | ||
3350 | 2352 | |||
3351 | 2353 | static gboolean | ||
3352 | 2354 | on_dbus_handle_path_for_application (BamfDBusMatcher *interface, | ||
3353 | 2355 | GDBusMethodInvocation *invocation, | ||
3354 | 2356 | const gchar *application, | ||
3355 | 2357 | BamfMatcher *self) | ||
3356 | 2358 | { | ||
3357 | 2359 | const gchar *app_path = bamf_matcher_dbus_path_for_application (self, application); | ||
3358 | 2360 | |||
3359 | 2361 | g_dbus_method_invocation_return_value (invocation, | ||
3360 | 2362 | g_variant_new ("(s)", app_path)); | ||
3361 | 2363 | |||
3362 | 2364 | return TRUE; | ||
3363 | 2365 | } | ||
3364 | 2366 | |||
3365 | 2367 | static gboolean | ||
3366 | 2368 | on_dbus_handle_application_for_xid (BamfDBusMatcher *interface, | ||
3367 | 2369 | GDBusMethodInvocation *invocation, | ||
3368 | 2370 | guint xid, | ||
3369 | 2371 | BamfMatcher *self) | ||
3370 | 2372 | { | ||
3371 | 2373 | const gchar *app_path = bamf_matcher_application_for_xid (self, xid); | ||
3372 | 2374 | |||
3373 | 2375 | g_dbus_method_invocation_return_value (invocation, | ||
3374 | 2376 | g_variant_new ("(s)", app_path)); | ||
3375 | 2377 | |||
3376 | 2378 | return TRUE; | ||
3377 | 2379 | } | ||
3378 | 2380 | |||
3379 | 2255 | static void | 2381 | static void |
3380 | 2256 | bamf_matcher_init (BamfMatcher * self) | 2382 | bamf_matcher_init (BamfMatcher * self) |
3381 | 2257 | { | 2383 | { |
3382 | 2384 | BamfMatcherPrivate *priv; | ||
3383 | 2385 | BamfLegacyScreen *screen; | ||
3384 | 2386 | BamfIndicatorSource *approver; | ||
3385 | 2258 | GArray *prefixstrings; | 2387 | GArray *prefixstrings; |
3386 | 2259 | int i; | 2388 | int i; |
3387 | 2260 | DBusGConnection *bus; | ||
3388 | 2261 | GError *error = NULL; | ||
3389 | 2262 | BamfMatcherPrivate *priv; | ||
3390 | 2263 | BamfLegacyScreen *screen; | ||
3391 | 2264 | BamfIndicatorSource *approver; | ||
3392 | 2265 | 2389 | ||
3393 | 2266 | priv = self->priv = BAMF_MATCHER_GET_PRIVATE (self); | 2390 | priv = self->priv = BAMF_MATCHER_GET_PRIVATE (self); |
3394 | 2267 | 2391 | ||
3395 | @@ -2294,11 +2418,56 @@ | |||
3396 | 2294 | 2418 | ||
3397 | 2295 | XSetErrorHandler (x_error_handler); | 2419 | XSetErrorHandler (x_error_handler); |
3398 | 2296 | 2420 | ||
3404 | 2297 | bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error); | 2421 | /* Registering signal callbacks to reply to dbus method calls */ |
3405 | 2298 | 2422 | g_signal_connect (self, "handle-xids-for-application", | |
3406 | 2299 | g_return_if_fail (bus); | 2423 | G_CALLBACK (on_dbus_handle_xids_for_application), self); |
3407 | 2300 | 2424 | ||
3408 | 2301 | dbus_g_connection_register_g_object (bus, BAMF_MATCHER_PATH, G_OBJECT (self)); | 2425 | g_signal_connect (self, "handle-tab-paths", |
3409 | 2426 | G_CALLBACK (on_dbus_handle_tab_paths), self); | ||
3410 | 2427 | |||
3411 | 2428 | g_signal_connect (self, "handle-application-paths", | ||
3412 | 2429 | G_CALLBACK (on_dbus_handle_application_paths), self); | ||
3413 | 2430 | |||
3414 | 2431 | g_signal_connect (self, "handle-window-paths", | ||
3415 | 2432 | G_CALLBACK (on_dbus_handle_window_paths), self); | ||
3416 | 2433 | |||
3417 | 2434 | g_signal_connect (self, "handle-running-applications", | ||
3418 | 2435 | G_CALLBACK (on_dbus_handle_running_applications), self); | ||
3419 | 2436 | |||
3420 | 2437 | g_signal_connect (self, "handle-active-window", | ||
3421 | 2438 | G_CALLBACK (on_dbus_handle_active_window), self); | ||
3422 | 2439 | |||
3423 | 2440 | g_signal_connect (self, "handle-active-application", | ||
3424 | 2441 | G_CALLBACK (on_dbus_handle_active_application), self); | ||
3425 | 2442 | |||
3426 | 2443 | g_signal_connect (self, "handle-application-is-running", | ||
3427 | 2444 | G_CALLBACK (on_dbus_handle_application_is_running), self); | ||
3428 | 2445 | |||
3429 | 2446 | g_signal_connect (self, "handle-register-favorites", | ||
3430 | 2447 | G_CALLBACK (on_dbus_handle_register_favorites), self); | ||
3431 | 2448 | |||
3432 | 2449 | g_signal_connect (self, "handle-path-for-application", | ||
3433 | 2450 | G_CALLBACK (on_dbus_handle_path_for_application), self); | ||
3434 | 2451 | |||
3435 | 2452 | g_signal_connect (self, "handle-application-for-xid", | ||
3436 | 2453 | G_CALLBACK (on_dbus_handle_application_for_xid), self); | ||
3437 | 2454 | } | ||
3438 | 2455 | |||
3439 | 2456 | static void | ||
3440 | 2457 | bamf_matcher_dispose (GObject *object) | ||
3441 | 2458 | { | ||
3442 | 2459 | BamfMatcher *self = (BamfMatcher *) object; | ||
3443 | 2460 | BamfMatcherPrivate *priv = self->priv; | ||
3444 | 2461 | GList *l; | ||
3445 | 2462 | |||
3446 | 2463 | for (l = priv->views; l; l = l->next) | ||
3447 | 2464 | { | ||
3448 | 2465 | bamf_matcher_unregister_view (self, (BamfView*)l->data, FALSE); | ||
3449 | 2466 | } | ||
3450 | 2467 | g_list_free_full (priv->views, g_object_unref); | ||
3451 | 2468 | priv->views = NULL; | ||
3452 | 2469 | |||
3453 | 2470 | G_OBJECT_CLASS (bamf_matcher_parent_class)->dispose (object); | ||
3454 | 2302 | } | 2471 | } |
3455 | 2303 | 2472 | ||
3456 | 2304 | static void | 2473 | static void |
3457 | @@ -2322,12 +2491,7 @@ | |||
3458 | 2322 | g_hash_table_destroy (priv->desktop_class_table); | 2491 | g_hash_table_destroy (priv->desktop_class_table); |
3459 | 2323 | g_hash_table_destroy (priv->registered_pids); | 2492 | g_hash_table_destroy (priv->registered_pids); |
3460 | 2324 | 2493 | ||
3461 | 2325 | for (l = priv->views; l; l = l->next) | ||
3462 | 2326 | { | ||
3463 | 2327 | bamf_matcher_unregister_view (self, (BamfView*)l->data, FALSE); | ||
3464 | 2328 | } | ||
3465 | 2329 | g_list_free_full (priv->views, g_object_unref); | 2494 | g_list_free_full (priv->views, g_object_unref); |
3466 | 2330 | priv->views = NULL; | ||
3467 | 2331 | 2495 | ||
3468 | 2332 | for (l = priv->monitors; l; l = l->next) | 2496 | for (l = priv->monitors; l; l = l->next) |
3469 | 2333 | { | 2497 | { |
3470 | @@ -2350,49 +2514,11 @@ | |||
3471 | 2350 | bamf_matcher_class_init (BamfMatcherClass * klass) | 2514 | bamf_matcher_class_init (BamfMatcherClass * klass) |
3472 | 2351 | { | 2515 | { |
3473 | 2352 | GObjectClass *object_class = G_OBJECT_CLASS (klass); | 2516 | GObjectClass *object_class = G_OBJECT_CLASS (klass); |
3474 | 2517 | |||
3475 | 2353 | g_type_class_add_private (klass, sizeof (BamfMatcherPrivate)); | 2518 | g_type_class_add_private (klass, sizeof (BamfMatcherPrivate)); |
3480 | 2354 | 2519 | object_class->dispose = bamf_matcher_dispose; | |
3477 | 2355 | dbus_g_object_type_install_info (BAMF_TYPE_MATCHER, | ||
3478 | 2356 | &dbus_glib_bamf_matcher_object_info); | ||
3479 | 2357 | |||
3481 | 2358 | object_class->finalize = bamf_matcher_finalize; | 2520 | object_class->finalize = bamf_matcher_finalize; |
3482 | 2359 | 2521 | ||
3483 | 2360 | matcher_signals [VIEW_OPENED] = | ||
3484 | 2361 | g_signal_new ("view-opened", | ||
3485 | 2362 | G_OBJECT_CLASS_TYPE (klass), | ||
3486 | 2363 | 0, | ||
3487 | 2364 | 0, NULL, NULL, | ||
3488 | 2365 | bamf_marshal_VOID__STRING_STRING, | ||
3489 | 2366 | G_TYPE_NONE, 2, | ||
3490 | 2367 | G_TYPE_STRING, G_TYPE_STRING); | ||
3491 | 2368 | |||
3492 | 2369 | matcher_signals [VIEW_CLOSED] = | ||
3493 | 2370 | g_signal_new ("view-closed", | ||
3494 | 2371 | G_OBJECT_CLASS_TYPE (klass), | ||
3495 | 2372 | 0, | ||
3496 | 2373 | 0, NULL, NULL, | ||
3497 | 2374 | bamf_marshal_VOID__STRING_STRING, | ||
3498 | 2375 | G_TYPE_NONE, 2, | ||
3499 | 2376 | G_TYPE_STRING, G_TYPE_STRING); | ||
3500 | 2377 | |||
3501 | 2378 | matcher_signals [ACTIVE_APPLICATION_CHANGED] = | ||
3502 | 2379 | g_signal_new ("active-application-changed", | ||
3503 | 2380 | G_OBJECT_CLASS_TYPE (klass), | ||
3504 | 2381 | 0, | ||
3505 | 2382 | 0, NULL, NULL, | ||
3506 | 2383 | bamf_marshal_VOID__STRING_STRING, | ||
3507 | 2384 | G_TYPE_NONE, 2, | ||
3508 | 2385 | G_TYPE_STRING, G_TYPE_STRING); | ||
3509 | 2386 | |||
3510 | 2387 | matcher_signals [ACTIVE_WINDOW_CHANGED] = | ||
3511 | 2388 | g_signal_new ("active-window-changed", | ||
3512 | 2389 | G_OBJECT_CLASS_TYPE (klass), | ||
3513 | 2390 | 0, | ||
3514 | 2391 | 0, NULL, NULL, | ||
3515 | 2392 | bamf_marshal_VOID__STRING_STRING, | ||
3516 | 2393 | G_TYPE_NONE, 2, | ||
3517 | 2394 | G_TYPE_STRING, G_TYPE_STRING); | ||
3518 | 2395 | |||
3519 | 2396 | matcher_signals [FAVORITES_CHANGED] = | 2522 | matcher_signals [FAVORITES_CHANGED] = |
3520 | 2397 | g_signal_new ("favorites-changed", | 2523 | g_signal_new ("favorites-changed", |
3521 | 2398 | G_OBJECT_CLASS_TYPE (klass), | 2524 | G_OBJECT_CLASS_TYPE (klass), |
3522 | @@ -2410,8 +2536,7 @@ | |||
3523 | 2410 | if (!BAMF_IS_MATCHER (matcher)) | 2536 | if (!BAMF_IS_MATCHER (matcher)) |
3524 | 2411 | { | 2537 | { |
3525 | 2412 | matcher = (BamfMatcher *) g_object_new (BAMF_TYPE_MATCHER, NULL); | 2538 | matcher = (BamfMatcher *) g_object_new (BAMF_TYPE_MATCHER, NULL); |
3526 | 2413 | return matcher; | ||
3527 | 2414 | } | 2539 | } |
3528 | 2415 | 2540 | ||
3530 | 2416 | return g_object_ref (G_OBJECT (matcher)); | 2541 | return matcher; |
3531 | 2417 | } | 2542 | } |
3532 | 2418 | 2543 | ||
3533 | === modified file 'src/bamf-matcher.h' | |||
3534 | --- src/bamf-matcher.h 2011-08-01 23:01:36 +0000 | |||
3535 | +++ src/bamf-matcher.h 2012-01-19 19:16:25 +0000 | |||
3536 | @@ -14,6 +14,7 @@ | |||
3537 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
3538 | 15 | * | 15 | * |
3539 | 16 | * Authored by: Jason Smith <jason.smith@canonical.com> | 16 | * Authored by: Jason Smith <jason.smith@canonical.com> |
3540 | 17 | * Marco Trevisan (Treviño) <3v1n0@ubuntu.com> | ||
3541 | 17 | * | 18 | * |
3542 | 18 | */ | 19 | */ |
3543 | 19 | 20 | ||
3544 | @@ -26,9 +27,6 @@ | |||
3545 | 26 | #include <stdlib.h> | 27 | #include <stdlib.h> |
3546 | 27 | #include <unistd.h> | 28 | #include <unistd.h> |
3547 | 28 | #include <sys/types.h> | 29 | #include <sys/types.h> |
3548 | 29 | #include <dbus/dbus.h> | ||
3549 | 30 | #include <dbus/dbus-glib.h> | ||
3550 | 31 | #include <dbus/dbus-glib-lowlevel.h> | ||
3551 | 32 | #include <gdk/gdk.h> | 30 | #include <gdk/gdk.h> |
3552 | 33 | #include <glib.h> | 31 | #include <glib.h> |
3553 | 34 | #include <glib-object.h> | 32 | #include <glib-object.h> |
3554 | @@ -47,7 +45,7 @@ | |||
3555 | 47 | #define BAMF_IS_MATCHER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BAMF_TYPE_MATCHER)) | 45 | #define BAMF_IS_MATCHER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BAMF_TYPE_MATCHER)) |
3556 | 48 | #define BAMF_MATCHER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BAMF_TYPE_MATCHER, BamfMatcherClass)) | 46 | #define BAMF_MATCHER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BAMF_TYPE_MATCHER, BamfMatcherClass)) |
3557 | 49 | 47 | ||
3559 | 50 | #define _NET_WM_DESKTOP_FILE "_NET_WM_DESKTOP_FILE" | 48 | #define _NET_WM_DESKTOP_FILE "_NET_WM_DESKTOP_FILE" |
3560 | 51 | 49 | ||
3561 | 52 | typedef struct _BamfMatcher BamfMatcher; | 50 | typedef struct _BamfMatcher BamfMatcher; |
3562 | 53 | typedef struct _BamfMatcherClass BamfMatcherClass; | 51 | typedef struct _BamfMatcherClass BamfMatcherClass; |
3563 | @@ -55,12 +53,12 @@ | |||
3564 | 55 | 53 | ||
3565 | 56 | struct _BamfMatcherClass | 54 | struct _BamfMatcherClass |
3566 | 57 | { | 55 | { |
3568 | 58 | GObjectClass parent; | 56 | BamfDBusMatcherSkeletonClass parent; |
3569 | 59 | }; | 57 | }; |
3570 | 60 | 58 | ||
3571 | 61 | struct _BamfMatcher | 59 | struct _BamfMatcher |
3572 | 62 | { | 60 | { |
3574 | 63 | GObject parent; | 61 | BamfDBusMatcherSkeleton parent; |
3575 | 64 | 62 | ||
3576 | 65 | /* private */ | 63 | /* private */ |
3577 | 66 | BamfMatcherPrivate *priv; | 64 | BamfMatcherPrivate *priv; |
3578 | @@ -69,41 +67,40 @@ | |||
3579 | 69 | GType bamf_matcher_get_type (void) G_GNUC_CONST; | 67 | GType bamf_matcher_get_type (void) G_GNUC_CONST; |
3580 | 70 | 68 | ||
3581 | 71 | void bamf_matcher_load_desktop_file (BamfMatcher * self, | 69 | void bamf_matcher_load_desktop_file (BamfMatcher * self, |
3583 | 72 | char * desktop_file); | 70 | const char * desktop_file); |
3584 | 73 | 71 | ||
3585 | 74 | void bamf_matcher_register_desktop_file_for_pid (BamfMatcher * self, | 72 | void bamf_matcher_register_desktop_file_for_pid (BamfMatcher * self, |
3587 | 75 | const char * desktopFile, | 73 | const char *application, |
3588 | 76 | gint pid); | 74 | gint pid); |
3589 | 77 | 75 | ||
3595 | 78 | char * bamf_matcher_get_active_application (BamfMatcher *matcher); | 76 | const char * bamf_matcher_get_active_application (BamfMatcher *matcher); |
3596 | 79 | 77 | ||
3597 | 80 | char * bamf_matcher_get_active_window (BamfMatcher *matcher); | 78 | const char * bamf_matcher_get_active_window (BamfMatcher *matcher); |
3598 | 81 | 79 | ||
3599 | 82 | char * bamf_matcher_application_for_xid (BamfMatcher *matcher, | 80 | const char * bamf_matcher_application_for_xid (BamfMatcher *matcher, |
3600 | 83 | guint32 xid); | 81 | guint32 xid); |
3601 | 84 | 82 | ||
3602 | 85 | gboolean bamf_matcher_application_is_running (BamfMatcher *matcher, | 83 | gboolean bamf_matcher_application_is_running (BamfMatcher *matcher, |
3615 | 86 | char *application); | 84 | const char *application); |
3616 | 87 | 85 | ||
3617 | 88 | char ** bamf_matcher_application_dbus_paths (BamfMatcher *matcher); | 86 | GVariant * bamf_matcher_application_dbus_paths (BamfMatcher *matcher); |
3618 | 89 | 87 | ||
3619 | 90 | char ** bamf_matcher_window_dbus_paths (BamfMatcher *matcher); | 88 | GVariant * bamf_matcher_window_dbus_paths (BamfMatcher *matcher); |
3620 | 91 | 89 | ||
3621 | 92 | char * bamf_matcher_dbus_path_for_application (BamfMatcher *matcher, | 90 | const char * bamf_matcher_dbus_path_for_application (BamfMatcher *matcher, |
3622 | 93 | char *application); | 91 | const char *application); |
3623 | 94 | 92 | ||
3624 | 95 | gboolean bamf_matcher_register_favorites (BamfMatcher *matcher, | 93 | void bamf_matcher_register_favorites (BamfMatcher *matcher, |
3625 | 96 | char **favorites, | 94 | const char **favorites); |
3614 | 97 | GError *error); | ||
3626 | 98 | 95 | ||
3627 | 99 | GList * bamf_matcher_get_favorites (BamfMatcher *matcher); | 96 | GList * bamf_matcher_get_favorites (BamfMatcher *matcher); |
3628 | 100 | 97 | ||
3635 | 101 | char ** bamf_matcher_running_application_paths (BamfMatcher *matcher); | 98 | GVariant * bamf_matcher_running_application_paths (BamfMatcher *matcher); |
3636 | 102 | 99 | ||
3637 | 103 | char ** bamf_matcher_tab_dbus_paths (BamfMatcher *matcher); | 100 | GVariant * bamf_matcher_tab_dbus_paths (BamfMatcher *matcher); |
3638 | 104 | 101 | ||
3639 | 105 | GArray * bamf_matcher_xids_for_application (BamfMatcher *matcher, | 102 | GVariant * bamf_matcher_xids_for_application (BamfMatcher *matcher, |
3640 | 106 | char *application); | 103 | const char *application); |
3641 | 107 | 104 | ||
3642 | 108 | BamfMatcher * bamf_matcher_get_default (void); | 105 | BamfMatcher * bamf_matcher_get_default (void); |
3643 | 109 | 106 | ||
3644 | 110 | 107 | ||
3645 | === removed file 'src/bamf-tab-glue.xml' | |||
3646 | --- src/bamf-tab-glue.xml 2010-05-18 19:55:44 +0000 | |||
3647 | +++ src/bamf-tab-glue.xml 1970-01-01 00:00:00 +0000 | |||
3648 | @@ -1,39 +0,0 @@ | |||
3649 | 1 | <?xml version="1.0" encoding="UTF-8" ?> | ||
3650 | 2 | |||
3651 | 3 | <node name="/org/ayatana/bamf"> | ||
3652 | 4 | |||
3653 | 5 | <interface name="org.ayatana.bamf.tab"> | ||
3654 | 6 | |||
3655 | 7 | <signal name="UriChanged"> | ||
3656 | 8 | <arg type="s" name="old" direction="out" /> | ||
3657 | 9 | <arg type="s" name="new" direction="out" /> | ||
3658 | 10 | </signal> | ||
3659 | 11 | |||
3660 | 12 | <method name="ShowTab"> | ||
3661 | 13 | <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_tab_show" /> | ||
3662 | 14 | </method> | ||
3663 | 15 | |||
3664 | 16 | <method name="ParentXid"> | ||
3665 | 17 | <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_tab_parent_xid" /> | ||
3666 | 18 | <arg type="u" name="xid" direction="out"> | ||
3667 | 19 | <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/> | ||
3668 | 20 | </arg> | ||
3669 | 21 | </method> | ||
3670 | 22 | |||
3671 | 23 | <method name="CurrentUri"> | ||
3672 | 24 | <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_tab_current_uri" /> | ||
3673 | 25 | <arg type="s" name="uri" direction="out"> | ||
3674 | 26 | <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/> | ||
3675 | 27 | </arg> | ||
3676 | 28 | </method> | ||
3677 | 29 | |||
3678 | 30 | <method name="Preview"> | ||
3679 | 31 | <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_tab_get_preview" /> | ||
3680 | 32 | <arg type="ay" name="data" direction="out"> | ||
3681 | 33 | <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/> | ||
3682 | 34 | </arg> | ||
3683 | 35 | </method> | ||
3684 | 36 | |||
3685 | 37 | </interface> | ||
3686 | 38 | |||
3687 | 39 | </node> | ||
3688 | 40 | 0 | ||
3689 | === modified file 'src/bamf-tab-source.c' | |||
3690 | --- src/bamf-tab-source.c 2011-08-01 23:25:01 +0000 | |||
3691 | +++ src/bamf-tab-source.c 2012-01-19 19:16:25 +0000 | |||
3692 | @@ -1,5 +1,5 @@ | |||
3693 | 1 | /* | 1 | /* |
3695 | 2 | * Copyright (C) 2010 Canonical Ltd | 2 | * Copyright (C) 2010-2011 Canonical Ltd |
3696 | 3 | * | 3 | * |
3697 | 4 | * This program is free software: you can redistribute it and/or modify | 4 | * This program is free software: you can redistribute it and/or modify |
3698 | 5 | * it under the terms of the GNU General Public License version 3 as | 5 | * it under the terms of the GNU General Public License version 3 as |
3699 | @@ -14,15 +14,15 @@ | |||
3700 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
3701 | 15 | * | 15 | * |
3702 | 16 | * Authored by: Jason Smith <jason.smith@canonical.com> | 16 | * Authored by: Jason Smith <jason.smith@canonical.com> |
3703 | 17 | * Marco Trevisan (Treviño) <3v1n0@ubuntu.com> | ||
3704 | 17 | * | 18 | * |
3705 | 18 | */ | 19 | */ |
3706 | 19 | 20 | ||
3707 | 20 | |||
3708 | 21 | #include "bamf-view.h" | 21 | #include "bamf-view.h" |
3709 | 22 | #include "bamf-tab-source.h" | 22 | #include "bamf-tab-source.h" |
3710 | 23 | #include "bamf-tab.h" | 23 | #include "bamf-tab.h" |
3711 | 24 | #include "bamf-marshal.h" | 24 | #include "bamf-marshal.h" |
3713 | 25 | #include <dbus/dbus-glib.h> | 25 | #include "bamf-gdbus-browser-generated.h" |
3714 | 26 | 26 | ||
3715 | 27 | G_DEFINE_TYPE (BamfTabSource, bamf_tab_source, G_TYPE_OBJECT); | 27 | G_DEFINE_TYPE (BamfTabSource, bamf_tab_source, G_TYPE_OBJECT); |
3716 | 28 | #define BAMF_TAB_SOURCE_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE(obj, \ | 28 | #define BAMF_TAB_SOURCE_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE(obj, \ |
3717 | @@ -51,9 +51,9 @@ | |||
3718 | 51 | 51 | ||
3719 | 52 | struct _BamfTabSourcePrivate | 52 | struct _BamfTabSourcePrivate |
3720 | 53 | { | 53 | { |
3721 | 54 | BamfDBusBrowser *proxy; | ||
3722 | 54 | char *bus; | 55 | char *bus; |
3723 | 55 | char *path; | 56 | char *path; |
3724 | 56 | DBusGProxy *proxy; | ||
3725 | 57 | GHashTable *tabs; | 57 | GHashTable *tabs; |
3726 | 58 | }; | 58 | }; |
3727 | 59 | 59 | ||
3728 | @@ -67,12 +67,7 @@ | |||
3729 | 67 | g_return_val_if_fail (BAMF_IS_TAB_SOURCE (self), NULL); | 67 | g_return_val_if_fail (BAMF_IS_TAB_SOURCE (self), NULL); |
3730 | 68 | priv = self->priv; | 68 | priv = self->priv; |
3731 | 69 | 69 | ||
3738 | 70 | if (!dbus_g_proxy_call (priv->proxy, | 70 | if (!bamf_dbus_browser__call_tab_ids_sync (priv->proxy, &ids, NULL, &error)) |
3733 | 71 | "TabIds", | ||
3734 | 72 | &error, | ||
3735 | 73 | G_TYPE_INVALID, | ||
3736 | 74 | G_TYPE_STRV, &ids, | ||
3737 | 75 | G_TYPE_INVALID)) | ||
3739 | 76 | { | 71 | { |
3740 | 77 | g_warning ("Failed to get tab ids: %s", error->message); | 72 | g_warning ("Failed to get tab ids: %s", error->message); |
3741 | 78 | g_error_free (error); | 73 | g_error_free (error); |
3742 | @@ -83,8 +78,7 @@ | |||
3743 | 83 | } | 78 | } |
3744 | 84 | 79 | ||
3745 | 85 | void | 80 | void |
3748 | 86 | bamf_tab_source_show_tab (BamfTabSource *self, | 81 | bamf_tab_source_show_tab (BamfTabSource *self, char *id) |
3747 | 87 | char *id) | ||
3749 | 88 | { | 82 | { |
3750 | 89 | BamfTabSourcePrivate *priv; | 83 | BamfTabSourcePrivate *priv; |
3751 | 90 | GError *error = NULL; | 84 | GError *error = NULL; |
3752 | @@ -92,36 +86,26 @@ | |||
3753 | 92 | g_return_if_fail (BAMF_IS_TAB_SOURCE (self)); | 86 | g_return_if_fail (BAMF_IS_TAB_SOURCE (self)); |
3754 | 93 | priv = self->priv; | 87 | priv = self->priv; |
3755 | 94 | 88 | ||
3762 | 95 | if (!dbus_g_proxy_call (priv->proxy, | 89 | if (!bamf_dbus_browser__call_show_tab_sync (priv->proxy, id, NULL, &error)) |
3757 | 96 | "ShowTab", | ||
3758 | 97 | &error, | ||
3759 | 98 | G_TYPE_STRING, id, | ||
3760 | 99 | G_TYPE_INVALID, | ||
3761 | 100 | G_TYPE_INVALID)) | ||
3763 | 101 | { | 90 | { |
3764 | 102 | g_warning ("Failed to show tab: %s", error->message); | 91 | g_warning ("Failed to show tab: %s", error->message); |
3765 | 103 | g_error_free (error); | 92 | g_error_free (error); |
3766 | 104 | } | 93 | } |
3767 | 105 | } | 94 | } |
3768 | 106 | 95 | ||
3770 | 107 | GArray * | 96 | gchar * |
3771 | 108 | bamf_tab_source_get_tab_preview (BamfTabSource *self, | 97 | bamf_tab_source_get_tab_preview (BamfTabSource *self, |
3772 | 109 | char *id) | 98 | char *id) |
3773 | 110 | { | 99 | { |
3774 | 111 | BamfTabSourcePrivate *priv; | 100 | BamfTabSourcePrivate *priv; |
3775 | 112 | GError *error = NULL; | 101 | GError *error = NULL; |
3777 | 113 | GArray *preview_data = NULL; | 102 | gchar *preview_data = NULL; |
3778 | 114 | 103 | ||
3779 | 115 | g_return_val_if_fail (BAMF_IS_TAB_SOURCE (self), NULL); | 104 | g_return_val_if_fail (BAMF_IS_TAB_SOURCE (self), NULL); |
3780 | 116 | priv = self->priv; | 105 | priv = self->priv; |
3781 | 117 | 106 | ||
3789 | 118 | if (!dbus_g_proxy_call (priv->proxy, | 107 | if (!bamf_dbus_browser__call_tab_preview_sync (priv->proxy, id, &preview_data, |
3790 | 119 | "TabUri", | 108 | NULL, &error)) |
3784 | 120 | &error, | ||
3785 | 121 | G_TYPE_STRING, id, | ||
3786 | 122 | G_TYPE_INVALID, | ||
3787 | 123 | G_TYPE_ARRAY, &preview_data, | ||
3788 | 124 | G_TYPE_INVALID)) | ||
3791 | 125 | { | 109 | { |
3792 | 126 | g_warning ("Failed to get tab preview data: %s", error->message); | 110 | g_warning ("Failed to get tab preview data: %s", error->message); |
3793 | 127 | g_error_free (error); | 111 | g_error_free (error); |
3794 | @@ -142,13 +126,7 @@ | |||
3795 | 142 | g_return_val_if_fail (BAMF_IS_TAB_SOURCE (self), NULL); | 126 | g_return_val_if_fail (BAMF_IS_TAB_SOURCE (self), NULL); |
3796 | 143 | priv = self->priv; | 127 | priv = self->priv; |
3797 | 144 | 128 | ||
3805 | 145 | if (!dbus_g_proxy_call (priv->proxy, | 129 | if (!bamf_dbus_browser__call_tab_uri_sync (priv->proxy, id, &uri, NULL, &error)) |
3799 | 146 | "TabUri", | ||
3800 | 147 | &error, | ||
3801 | 148 | G_TYPE_STRING, id, | ||
3802 | 149 | G_TYPE_INVALID, | ||
3803 | 150 | G_TYPE_STRING, &uri, | ||
3804 | 151 | G_TYPE_INVALID)) | ||
3806 | 152 | { | 130 | { |
3807 | 153 | g_warning ("Failed to get tab URI: %s", error->message); | 131 | g_warning ("Failed to get tab URI: %s", error->message); |
3808 | 154 | g_error_free (error); | 132 | g_error_free (error); |
3809 | @@ -169,13 +147,7 @@ | |||
3810 | 169 | g_return_val_if_fail (BAMF_IS_TAB_SOURCE (self), 0); | 147 | g_return_val_if_fail (BAMF_IS_TAB_SOURCE (self), 0); |
3811 | 170 | priv = self->priv; | 148 | priv = self->priv; |
3812 | 171 | 149 | ||
3820 | 172 | if (!dbus_g_proxy_call (priv->proxy, | 150 | if (!bamf_dbus_browser__call_tab_xid_sync (priv->proxy, id, &xid, NULL, &error)) |
3814 | 173 | "TabXid", | ||
3815 | 174 | &error, | ||
3816 | 175 | G_TYPE_STRING, id, | ||
3817 | 176 | G_TYPE_INVALID, | ||
3818 | 177 | G_TYPE_UINT, &xid, | ||
3819 | 178 | G_TYPE_INVALID)) | ||
3821 | 179 | { | 151 | { |
3822 | 180 | g_warning ("Failed to get tab XID: %s", error->message); | 152 | g_warning ("Failed to get tab XID: %s", error->message); |
3823 | 181 | g_error_free (error); | 153 | g_error_free (error); |
3824 | @@ -186,7 +158,8 @@ | |||
3825 | 186 | } | 158 | } |
3826 | 187 | 159 | ||
3827 | 188 | static void | 160 | static void |
3829 | 189 | bamf_tab_source_on_tab_opened (DBusGProxy *proxy, char *id, BamfTabSource *source) | 161 | bamf_tab_source_on_tab_opened (BamfDBusBrowser *proxy, const char *id, |
3830 | 162 | BamfTabSource *source) | ||
3831 | 190 | { | 163 | { |
3832 | 191 | BamfTab *tab; | 164 | BamfTab *tab; |
3833 | 192 | 165 | ||
3834 | @@ -201,7 +174,8 @@ | |||
3835 | 201 | } | 174 | } |
3836 | 202 | 175 | ||
3837 | 203 | static void | 176 | static void |
3839 | 204 | bamf_tab_source_on_tab_closed (DBusGProxy *proxy, char *id, BamfTabSource *source) | 177 | bamf_tab_source_on_tab_closed (BamfDBusBrowser *proxy, const char *id, |
3840 | 178 | BamfTabSource *source) | ||
3841 | 205 | { | 179 | { |
3842 | 206 | BamfTab *tab; | 180 | BamfTab *tab; |
3843 | 207 | 181 | ||
3844 | @@ -221,7 +195,8 @@ | |||
3845 | 221 | } | 195 | } |
3846 | 222 | 196 | ||
3847 | 223 | static void | 197 | static void |
3849 | 224 | bamf_tab_source_on_uri_changed (DBusGProxy *proxy, char *id, char *old_uri, char *new_uri, BamfTabSource *source) | 198 | bamf_tab_source_on_uri_changed (BamfDBusBrowser *proxy, const char *id, |
3850 | 199 | const char *old_uri, char *new_uri, BamfTabSource *source) | ||
3851 | 225 | { | 200 | { |
3852 | 226 | g_signal_emit (source, REMOTE_TAB_URI_CHANGED, 0, id, old_uri, new_uri); | 201 | g_signal_emit (source, REMOTE_TAB_URI_CHANGED, 0, id, old_uri, new_uri); |
3853 | 227 | } | 202 | } |
3854 | @@ -266,13 +241,82 @@ | |||
3855 | 266 | } | 241 | } |
3856 | 267 | } | 242 | } |
3857 | 268 | 243 | ||
3858 | 244 | static void bamf_tab_source_reconnect (GObject *object, GParamSpec *pspec, BamfTabSource *self); | ||
3859 | 245 | |||
3860 | 246 | static void | ||
3861 | 247 | on_proxy_ready_cb (GDBusProxy *proxy, GAsyncResult *res, BamfTabSource *self) | ||
3862 | 248 | { | ||
3863 | 249 | BamfDBusBrowser *bproxy; | ||
3864 | 250 | GError *error = NULL; | ||
3865 | 251 | g_return_if_fail (BAMF_IS_TAB_SOURCE (self)); | ||
3866 | 252 | |||
3867 | 253 | bproxy = bamf_dbus_browser__proxy_new_for_bus_finish (res, &error); | ||
3868 | 254 | |||
3869 | 255 | if (error) | ||
3870 | 256 | { | ||
3871 | 257 | g_critical ("Unable to get org.ayatana.bamf.browser object from bus %s: %s", | ||
3872 | 258 | self->priv->bus, error->message); | ||
3873 | 259 | g_error_free (error); | ||
3874 | 260 | } | ||
3875 | 261 | else | ||
3876 | 262 | { | ||
3877 | 263 | gchar *owner = g_dbus_proxy_get_name_owner (G_DBUS_PROXY (bproxy)); | ||
3878 | 264 | |||
3879 | 265 | if (owner) | ||
3880 | 266 | { | ||
3881 | 267 | g_free (owner); | ||
3882 | 268 | |||
3883 | 269 | if (self->priv->proxy) | ||
3884 | 270 | g_object_unref (self->priv->proxy); | ||
3885 | 271 | |||
3886 | 272 | self->priv->proxy = bproxy; | ||
3887 | 273 | |||
3888 | 274 | g_signal_connect (self->priv->proxy, "tab-uri-changed", | ||
3889 | 275 | (GCallback) bamf_tab_source_on_uri_changed, self); | ||
3890 | 276 | |||
3891 | 277 | g_signal_connect (self->priv->proxy, "tab-opened", | ||
3892 | 278 | (GCallback) bamf_tab_source_on_tab_opened, self); | ||
3893 | 279 | |||
3894 | 280 | g_signal_connect (self->priv->proxy, "tab-closed", | ||
3895 | 281 | (GCallback) bamf_tab_source_on_tab_closed, self); | ||
3896 | 282 | |||
3897 | 283 | g_signal_connect (self->priv->proxy, "notify::g-name-owner", | ||
3898 | 284 | G_CALLBACK (bamf_tab_source_reconnect), self); | ||
3899 | 285 | |||
3900 | 286 | } | ||
3901 | 287 | else | ||
3902 | 288 | { | ||
3903 | 289 | g_debug ("Failed to get notification approver proxy: no owner available"); | ||
3904 | 290 | g_object_unref (proxy); | ||
3905 | 291 | } | ||
3906 | 292 | } | ||
3907 | 293 | } | ||
3908 | 294 | |||
3909 | 295 | static void | ||
3910 | 296 | bamf_tab_source_reconnect (GObject *object, GParamSpec *pspec, BamfTabSource *self) | ||
3911 | 297 | { | ||
3912 | 298 | g_return_if_fail (BAMF_IS_TAB_SOURCE (self)); | ||
3913 | 299 | |||
3914 | 300 | if (self->priv->proxy) | ||
3915 | 301 | { | ||
3916 | 302 | g_object_unref (self->priv->proxy); | ||
3917 | 303 | self->priv->proxy = NULL; | ||
3918 | 304 | } | ||
3919 | 305 | |||
3920 | 306 | bamf_dbus_browser__proxy_new_for_bus (G_BUS_TYPE_SESSION, | ||
3921 | 307 | G_DBUS_PROXY_FLAGS_NONE, | ||
3922 | 308 | self->priv->bus, | ||
3923 | 309 | self->priv->path, | ||
3924 | 310 | NULL, | ||
3925 | 311 | (GAsyncReadyCallback) on_proxy_ready_cb, | ||
3926 | 312 | self); | ||
3927 | 313 | } | ||
3928 | 314 | |||
3929 | 269 | static void | 315 | static void |
3930 | 270 | bamf_tab_source_constructed (GObject *object) | 316 | bamf_tab_source_constructed (GObject *object) |
3931 | 271 | { | 317 | { |
3932 | 272 | BamfTabSource *source; | 318 | BamfTabSource *source; |
3933 | 273 | BamfTabSourcePrivate *priv; | 319 | BamfTabSourcePrivate *priv; |
3934 | 274 | DBusGConnection *connection; | ||
3935 | 275 | GError *error = NULL; | ||
3936 | 276 | 320 | ||
3937 | 277 | if (G_OBJECT_CLASS (bamf_tab_source_parent_class)->constructed) | 321 | if (G_OBJECT_CLASS (bamf_tab_source_parent_class)->constructed) |
3938 | 278 | G_OBJECT_CLASS (bamf_tab_source_parent_class)->constructed (object); | 322 | G_OBJECT_CLASS (bamf_tab_source_parent_class)->constructed (object); |
3939 | @@ -280,65 +324,40 @@ | |||
3940 | 280 | source = BAMF_TAB_SOURCE (object); | 324 | source = BAMF_TAB_SOURCE (object); |
3941 | 281 | priv = source->priv; | 325 | priv = source->priv; |
3942 | 282 | 326 | ||
3997 | 283 | connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error); | 327 | bamf_dbus_browser__proxy_new_for_bus (G_BUS_TYPE_SESSION, |
3998 | 284 | if (connection == NULL) | 328 | G_DBUS_PROXY_FLAGS_NONE, |
3999 | 285 | { | 329 | priv->bus, |
4000 | 286 | g_critical ("Failed to open connection to bus: %s", | 330 | priv->path, |
4001 | 287 | error != NULL ? error->message : "Unknown"); | 331 | NULL, |
4002 | 288 | if (error) | 332 | (GAsyncReadyCallback) on_proxy_ready_cb, |
4003 | 289 | g_error_free (error); | 333 | source); |
3950 | 290 | return; | ||
3951 | 291 | } | ||
3952 | 292 | |||
3953 | 293 | priv->proxy = dbus_g_proxy_new_for_name (connection, | ||
3954 | 294 | priv->bus, | ||
3955 | 295 | priv->path, | ||
3956 | 296 | "org.ayatana.bamf.browser"); | ||
3957 | 297 | |||
3958 | 298 | if (priv->proxy == NULL) | ||
3959 | 299 | { | ||
3960 | 300 | g_critical ("Unable to get org.ayatana.bamf.browser object from bus"); | ||
3961 | 301 | } | ||
3962 | 302 | |||
3963 | 303 | dbus_g_proxy_add_signal (priv->proxy, | ||
3964 | 304 | "TabUriChanged", | ||
3965 | 305 | G_TYPE_STRING, | ||
3966 | 306 | G_TYPE_STRING, | ||
3967 | 307 | G_TYPE_STRING, | ||
3968 | 308 | G_TYPE_INVALID); | ||
3969 | 309 | |||
3970 | 310 | dbus_g_proxy_add_signal (priv->proxy, | ||
3971 | 311 | "TabOpened", | ||
3972 | 312 | G_TYPE_STRING, | ||
3973 | 313 | G_TYPE_INVALID); | ||
3974 | 314 | |||
3975 | 315 | dbus_g_proxy_add_signal (priv->proxy, | ||
3976 | 316 | "TabClosed", | ||
3977 | 317 | G_TYPE_STRING, | ||
3978 | 318 | G_TYPE_INVALID); | ||
3979 | 319 | |||
3980 | 320 | dbus_g_proxy_connect_signal (priv->proxy, | ||
3981 | 321 | "TabUriChanged", | ||
3982 | 322 | (GCallback) bamf_tab_source_on_uri_changed, | ||
3983 | 323 | source, | ||
3984 | 324 | NULL); | ||
3985 | 325 | |||
3986 | 326 | dbus_g_proxy_connect_signal (priv->proxy, | ||
3987 | 327 | "TabOpened", | ||
3988 | 328 | (GCallback) bamf_tab_source_on_tab_opened, | ||
3989 | 329 | source, | ||
3990 | 330 | NULL); | ||
3991 | 331 | |||
3992 | 332 | dbus_g_proxy_connect_signal (priv->proxy, | ||
3993 | 333 | "TabClosed", | ||
3994 | 334 | (GCallback) bamf_tab_source_on_tab_closed, | ||
3995 | 335 | source, | ||
3996 | 336 | NULL); | ||
4004 | 337 | } | 334 | } |
4005 | 338 | 335 | ||
4006 | 339 | static void | 336 | static void |
4007 | 340 | bamf_tab_source_dispose (GObject *object) | 337 | bamf_tab_source_dispose (GObject *object) |
4008 | 341 | { | 338 | { |
4009 | 339 | BamfTabSource *self; | ||
4010 | 340 | |||
4011 | 341 | self = BAMF_TAB_SOURCE (object); | ||
4012 | 342 | |||
4013 | 343 | if (self->priv->bus) | ||
4014 | 344 | { | ||
4015 | 345 | g_free (self->priv->bus); | ||
4016 | 346 | self->priv->bus = NULL; | ||
4017 | 347 | } | ||
4018 | 348 | |||
4019 | 349 | if (self->priv->path) | ||
4020 | 350 | { | ||
4021 | 351 | g_free (self->priv->path); | ||
4022 | 352 | self->priv->path = NULL; | ||
4023 | 353 | } | ||
4024 | 354 | |||
4025 | 355 | if (self->priv->proxy) | ||
4026 | 356 | { | ||
4027 | 357 | g_object_unref (self->priv->proxy); | ||
4028 | 358 | self->priv->proxy = NULL; | ||
4029 | 359 | } | ||
4030 | 360 | |||
4031 | 342 | G_OBJECT_CLASS (bamf_tab_source_parent_class)->dispose (object); | 361 | G_OBJECT_CLASS (bamf_tab_source_parent_class)->dispose (object); |
4032 | 343 | } | 362 | } |
4033 | 344 | 363 | ||
4034 | @@ -374,54 +393,54 @@ | |||
4035 | 374 | g_object_class_install_property (object_class, PROP_BUS, pspec); | 393 | g_object_class_install_property (object_class, PROP_BUS, pspec); |
4036 | 375 | 394 | ||
4037 | 376 | bamf_tab_source_signals [REMOTE_TAB_URI_CHANGED] = | 395 | bamf_tab_source_signals [REMOTE_TAB_URI_CHANGED] = |
4046 | 377 | g_signal_new ("remote-tab-uri-changed", | 396 | g_signal_new ("remote-tab-uri-changed", |
4047 | 378 | G_OBJECT_CLASS_TYPE (klass), | 397 | G_OBJECT_CLASS_TYPE (klass), |
4048 | 379 | G_SIGNAL_RUN_FIRST, | 398 | G_SIGNAL_RUN_FIRST, |
4049 | 380 | 0, | 399 | 0, |
4050 | 381 | NULL, NULL, | 400 | NULL, NULL, |
4051 | 382 | bamf_marshal_VOID__STRING_STRING_STRING, | 401 | bamf_marshal_VOID__STRING_STRING_STRING, |
4052 | 383 | G_TYPE_NONE, 3, | 402 | G_TYPE_NONE, 3, |
4053 | 384 | G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING); | 403 | G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING); |
4054 | 385 | 404 | ||
4055 | 386 | bamf_tab_source_signals [REMOTE_TAB_OPENED] = | 405 | bamf_tab_source_signals [REMOTE_TAB_OPENED] = |
4064 | 387 | g_signal_new ("remote-tab-opened", | 406 | g_signal_new ("remote-tab-opened", |
4065 | 388 | G_OBJECT_CLASS_TYPE (klass), | 407 | G_OBJECT_CLASS_TYPE (klass), |
4066 | 389 | G_SIGNAL_RUN_FIRST, | 408 | G_SIGNAL_RUN_FIRST, |
4067 | 390 | 0, | 409 | 0, |
4068 | 391 | NULL, NULL, | 410 | NULL, NULL, |
4069 | 392 | g_cclosure_marshal_VOID__STRING, | 411 | g_cclosure_marshal_VOID__STRING, |
4070 | 393 | G_TYPE_NONE, 1, | 412 | G_TYPE_NONE, 1, |
4071 | 394 | G_TYPE_STRING); | 413 | G_TYPE_STRING); |
4072 | 395 | 414 | ||
4073 | 396 | bamf_tab_source_signals [REMOTE_TAB_CLOSED] = | 415 | bamf_tab_source_signals [REMOTE_TAB_CLOSED] = |
4082 | 397 | g_signal_new ("remote-tab-closed", | 416 | g_signal_new ("remote-tab-closed", |
4083 | 398 | G_OBJECT_CLASS_TYPE (klass), | 417 | G_OBJECT_CLASS_TYPE (klass), |
4084 | 399 | G_SIGNAL_RUN_FIRST, | 418 | G_SIGNAL_RUN_FIRST, |
4085 | 400 | 0, | 419 | 0, |
4086 | 401 | NULL, NULL, | 420 | NULL, NULL, |
4087 | 402 | g_cclosure_marshal_VOID__STRING, | 421 | g_cclosure_marshal_VOID__STRING, |
4088 | 403 | G_TYPE_NONE, 1, | 422 | G_TYPE_NONE, 1, |
4089 | 404 | G_TYPE_STRING); | 423 | G_TYPE_STRING); |
4090 | 405 | 424 | ||
4091 | 406 | bamf_tab_source_signals [TAB_OPENED] = | 425 | bamf_tab_source_signals [TAB_OPENED] = |
4100 | 407 | g_signal_new ("tab-opened", | 426 | g_signal_new ("tab-opened", |
4101 | 408 | G_OBJECT_CLASS_TYPE (klass), | 427 | G_OBJECT_CLASS_TYPE (klass), |
4102 | 409 | G_SIGNAL_RUN_FIRST, | 428 | G_SIGNAL_RUN_FIRST, |
4103 | 410 | 0, | 429 | 0, |
4104 | 411 | NULL, NULL, | 430 | NULL, NULL, |
4105 | 412 | g_cclosure_marshal_VOID__OBJECT, | 431 | g_cclosure_marshal_VOID__OBJECT, |
4106 | 413 | G_TYPE_NONE, 1, | 432 | G_TYPE_NONE, 1, |
4107 | 414 | BAMF_TYPE_TAB); | 433 | BAMF_TYPE_TAB); |
4108 | 415 | 434 | ||
4109 | 416 | bamf_tab_source_signals [TAB_CLOSED] = | 435 | bamf_tab_source_signals [TAB_CLOSED] = |
4118 | 417 | g_signal_new ("tab-closed", | 436 | g_signal_new ("tab-closed", |
4119 | 418 | G_OBJECT_CLASS_TYPE (klass), | 437 | G_OBJECT_CLASS_TYPE (klass), |
4120 | 419 | G_SIGNAL_RUN_FIRST, | 438 | G_SIGNAL_RUN_FIRST, |
4121 | 420 | 0, | 439 | 0, |
4122 | 421 | NULL, NULL, | 440 | NULL, NULL, |
4123 | 422 | g_cclosure_marshal_VOID__OBJECT, | 441 | g_cclosure_marshal_VOID__OBJECT, |
4124 | 423 | G_TYPE_NONE, 1, | 442 | G_TYPE_NONE, 1, |
4125 | 424 | BAMF_TYPE_TAB); | 443 | BAMF_TYPE_TAB); |
4126 | 425 | } | 444 | } |
4127 | 426 | 445 | ||
4128 | 427 | BamfTabSource * | 446 | BamfTabSource * |
4129 | 428 | 447 | ||
4130 | === modified file 'src/bamf-tab-source.h' | |||
4131 | --- src/bamf-tab-source.h 2010-05-25 13:47:38 +0000 | |||
4132 | +++ src/bamf-tab-source.h 2012-01-19 19:16:25 +0000 | |||
4133 | @@ -1,5 +1,5 @@ | |||
4134 | 1 | /* | 1 | /* |
4136 | 2 | * Copyright (C) 2010 Canonical Ltd | 2 | * Copyright (C) 2010-2011 Canonical Ltd |
4137 | 3 | * | 3 | * |
4138 | 4 | * This program is free software: you can redistribute it and/or modify | 4 | * This program is free software: you can redistribute it and/or modify |
4139 | 5 | * it under the terms of the GNU General Public License version 3 as | 5 | * it under the terms of the GNU General Public License version 3 as |
4140 | @@ -14,6 +14,7 @@ | |||
4141 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
4142 | 15 | * | 15 | * |
4143 | 16 | * Authored by: Jason Smith <jason.smith@canonical.com> | 16 | * Authored by: Jason Smith <jason.smith@canonical.com> |
4144 | 17 | * Marco Trevisan (Treviño) <3v1n0@ubuntu.com> | ||
4145 | 17 | * | 18 | * |
4146 | 18 | */ | 19 | */ |
4147 | 19 | 20 | ||
4148 | @@ -59,7 +60,7 @@ | |||
4149 | 59 | 60 | ||
4150 | 60 | void bamf_tab_source_show_tab (BamfTabSource *self, char *id); | 61 | void bamf_tab_source_show_tab (BamfTabSource *self, char *id); |
4151 | 61 | 62 | ||
4153 | 62 | GArray * bamf_tab_source_get_tab_preview (BamfTabSource *self, char *id); | 63 | gchar * bamf_tab_source_get_tab_preview (BamfTabSource *self, char *id); |
4154 | 63 | 64 | ||
4155 | 64 | char * bamf_tab_source_get_tab_uri (BamfTabSource *self, char *id); | 65 | char * bamf_tab_source_get_tab_uri (BamfTabSource *self, char *id); |
4156 | 65 | 66 | ||
4157 | 66 | 67 | ||
4158 | === modified file 'src/bamf-tab.c' | |||
4159 | --- src/bamf-tab.c 2011-08-01 23:25:01 +0000 | |||
4160 | +++ src/bamf-tab.c 2012-01-19 19:16:25 +0000 | |||
4161 | @@ -1,5 +1,5 @@ | |||
4162 | 1 | /* | 1 | /* |
4164 | 2 | * Copyright (C) 2010 Canonical Ltd | 2 | * Copyright (C) 2010-2011 Canonical Ltd |
4165 | 3 | * | 3 | * |
4166 | 4 | * This program is free software: you can redistribute it and/or modify | 4 | * This program is free software: you can redistribute it and/or modify |
4167 | 5 | * it under the terms of the GNU General Public License version 3 as | 5 | * it under the terms of the GNU General Public License version 3 as |
4168 | @@ -14,24 +14,20 @@ | |||
4169 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
4170 | 15 | * | 15 | * |
4171 | 16 | * Authored by: Jason Smith <jason.smith@canonical.com> | 16 | * Authored by: Jason Smith <jason.smith@canonical.com> |
4172 | 17 | * Marco Trevisan (Treviño) <3v1n0@ubuntu.com> | ||
4173 | 17 | * | 18 | * |
4174 | 18 | */ | 19 | */ |
4175 | 19 | 20 | ||
4176 | 20 | #include "bamf-tab.h" | 21 | #include "bamf-tab.h" |
4177 | 21 | #include "bamf-tab-glue.h" | ||
4178 | 22 | #include "bamf-tab-source.h" | 22 | #include "bamf-tab-source.h" |
4179 | 23 | #include "bamf-marshal.h" | ||
4180 | 24 | 23 | ||
4181 | 25 | G_DEFINE_TYPE (BamfTab, bamf_tab, BAMF_TYPE_VIEW); | ||
4182 | 26 | #define BAMF_TAB_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE(obj, \ | 24 | #define BAMF_TAB_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE(obj, \ |
4183 | 27 | BAMF_TYPE_TAB, BamfTabPrivate)) | 25 | BAMF_TYPE_TAB, BamfTabPrivate)) |
4184 | 28 | 26 | ||
4191 | 29 | enum | 27 | static void bamf_tab_dbus_iface_init (BamfDBusItemTabIface *iface); |
4192 | 30 | { | 28 | G_DEFINE_TYPE_WITH_CODE (BamfTab, bamf_tab, BAMF_TYPE_VIEW, |
4193 | 31 | URI_CHANGED, | 29 | G_IMPLEMENT_INTERFACE (BAMF_DBUS_ITEM_TYPE_TAB, |
4194 | 32 | 30 | bamf_tab_dbus_iface_init)); | |
4189 | 33 | LAST_SIGNAL, | ||
4190 | 34 | }; | ||
4195 | 35 | 31 | ||
4196 | 36 | enum | 32 | enum |
4197 | 37 | { | 33 | { |
4198 | @@ -41,10 +37,9 @@ | |||
4199 | 41 | PROP_SOURCE, | 37 | PROP_SOURCE, |
4200 | 42 | }; | 38 | }; |
4201 | 43 | 39 | ||
4202 | 44 | static guint tab_signals[LAST_SIGNAL] = { 0 }; | ||
4203 | 45 | |||
4204 | 46 | struct _BamfTabPrivate | 40 | struct _BamfTabPrivate |
4205 | 47 | { | 41 | { |
4206 | 42 | BamfDBusItemTab *dbus_iface; | ||
4207 | 48 | char *id; | 43 | char *id; |
4208 | 49 | char *uri; | 44 | char *uri; |
4209 | 50 | BamfTabSource *source; | 45 | BamfTabSource *source; |
4210 | @@ -73,20 +68,21 @@ | |||
4211 | 73 | return bamf_tab_source_get_tab_xid (tab->priv->source, tab->priv->id); | 68 | return bamf_tab_source_get_tab_xid (tab->priv->source, tab->priv->id); |
4212 | 74 | } | 69 | } |
4213 | 75 | 70 | ||
4215 | 76 | GArray * | 71 | gchar * |
4216 | 77 | bamf_tab_get_preview (BamfTab *tab) | 72 | bamf_tab_get_preview (BamfTab *tab) |
4217 | 78 | { | 73 | { |
4218 | 79 | return bamf_tab_source_get_tab_preview (tab->priv->source, tab->priv->id); | 74 | return bamf_tab_source_get_tab_preview (tab->priv->source, tab->priv->id); |
4219 | 80 | } | 75 | } |
4220 | 81 | 76 | ||
4222 | 82 | static char * | 77 | static const char * |
4223 | 83 | bamf_tab_get_view_type (BamfView *view) | 78 | bamf_tab_get_view_type (BamfView *view) |
4224 | 84 | { | 79 | { |
4226 | 85 | return g_strdup ("tab"); | 80 | return "tab"; |
4227 | 86 | } | 81 | } |
4228 | 87 | 82 | ||
4229 | 88 | static void | 83 | static void |
4231 | 89 | on_tab_uri_changed (BamfTabSource *source, char *id, char *old_uri, char *new_uri, BamfTab *self) | 84 | on_tab_source_uri_changed (BamfTabSource *source, char *id, |
4232 | 85 | char *old_uri, char *new_uri, BamfTab *self) | ||
4233 | 90 | { | 86 | { |
4234 | 91 | if (g_strcmp0 (id, self->priv->id) != 0) | 87 | if (g_strcmp0 (id, self->priv->id) != 0) |
4235 | 92 | return; | 88 | return; |
4236 | @@ -94,7 +90,70 @@ | |||
4237 | 94 | g_free (self->priv->uri); | 90 | g_free (self->priv->uri); |
4238 | 95 | self->priv->uri = g_strdup (new_uri); | 91 | self->priv->uri = g_strdup (new_uri); |
4239 | 96 | 92 | ||
4241 | 97 | g_signal_emit (self, URI_CHANGED, 0, old_uri, new_uri); | 93 | g_signal_emit_by_name (self, "uri-changed", old_uri, new_uri); |
4242 | 94 | } | ||
4243 | 95 | |||
4244 | 96 | static void | ||
4245 | 97 | on_uri_changed (BamfTab *self, const gchar *old_uri, const gchar *new_uri, gpointer _not_used) | ||
4246 | 98 | { | ||
4247 | 99 | g_return_if_fail (BAMF_IS_TAB (self)); | ||
4248 | 100 | g_signal_emit_by_name (self->priv->dbus_iface, "uri-changed", old_uri, new_uri); | ||
4249 | 101 | } | ||
4250 | 102 | |||
4251 | 103 | static gboolean | ||
4252 | 104 | on_dbus_handle_show_tab (BamfDBusItemTab *interface, | ||
4253 | 105 | GDBusMethodInvocation *invocation, | ||
4254 | 106 | BamfTab *self) | ||
4255 | 107 | { | ||
4256 | 108 | bamf_tab_show (self); | ||
4257 | 109 | g_dbus_method_invocation_return_value (invocation, NULL); | ||
4258 | 110 | |||
4259 | 111 | return TRUE; | ||
4260 | 112 | } | ||
4261 | 113 | |||
4262 | 114 | static gboolean | ||
4263 | 115 | on_dbus_handle_parent_xid (BamfDBusItemTab *interface, | ||
4264 | 116 | GDBusMethodInvocation *invocation, | ||
4265 | 117 | BamfTab *self) | ||
4266 | 118 | { | ||
4267 | 119 | guint32 parent_xid = bamf_tab_parent_xid (self); | ||
4268 | 120 | g_dbus_method_invocation_return_value (invocation, | ||
4269 | 121 | g_variant_new ("(u)", parent_xid)); | ||
4270 | 122 | |||
4271 | 123 | return TRUE; | ||
4272 | 124 | } | ||
4273 | 125 | |||
4274 | 126 | static gboolean | ||
4275 | 127 | on_dbus_handle_current_uri (BamfDBusItemTab *interface, | ||
4276 | 128 | GDBusMethodInvocation *invocation, | ||
4277 | 129 | BamfTab *self) | ||
4278 | 130 | { | ||
4279 | 131 | char *current_uri = self->priv->uri ? self->priv->uri : ""; | ||
4280 | 132 | g_dbus_method_invocation_return_value (invocation, | ||
4281 | 133 | g_variant_new ("(s)", current_uri)); | ||
4282 | 134 | |||
4283 | 135 | return TRUE; | ||
4284 | 136 | } | ||
4285 | 137 | |||
4286 | 138 | static gboolean | ||
4287 | 139 | on_dbus_handle_preview (BamfDBusItemTab *interface, | ||
4288 | 140 | GDBusMethodInvocation *invocation, | ||
4289 | 141 | BamfTab *self) | ||
4290 | 142 | { | ||
4291 | 143 | gchar *preview = bamf_tab_get_preview (self); | ||
4292 | 144 | |||
4293 | 145 | if (preview) | ||
4294 | 146 | { | ||
4295 | 147 | bamf_dbus_item_tab_complete_preview (interface, invocation, preview); | ||
4296 | 148 | g_free (preview); | ||
4297 | 149 | } | ||
4298 | 150 | else | ||
4299 | 151 | { | ||
4300 | 152 | g_dbus_method_invocation_return_value (invocation, | ||
4301 | 153 | g_variant_new ("(ay)", NULL)); | ||
4302 | 154 | } | ||
4303 | 155 | |||
4304 | 156 | return TRUE; | ||
4305 | 98 | } | 157 | } |
4306 | 99 | 158 | ||
4307 | 100 | static void | 159 | static void |
4308 | @@ -151,19 +210,72 @@ | |||
4309 | 151 | 210 | ||
4310 | 152 | self = BAMF_TAB (object); | 211 | self = BAMF_TAB (object); |
4311 | 153 | 212 | ||
4313 | 154 | g_signal_connect (self->priv->source, "remote-tab-uri-changed", (GCallback) on_tab_uri_changed, self); | 213 | g_signal_connect (self->priv->source, "remote-tab-uri-changed", |
4314 | 214 | G_CALLBACK (on_tab_source_uri_changed), self); | ||
4315 | 155 | } | 215 | } |
4316 | 156 | 216 | ||
4317 | 157 | static void | 217 | static void |
4318 | 158 | bamf_tab_dispose (GObject *object) | 218 | bamf_tab_dispose (GObject *object) |
4319 | 159 | { | 219 | { |
4320 | 220 | BamfTab *self = BAMF_TAB (object); | ||
4321 | 221 | |||
4322 | 222 | if (self->priv->id) | ||
4323 | 223 | { | ||
4324 | 224 | g_free (self->priv->id); | ||
4325 | 225 | self->priv->id = NULL; | ||
4326 | 226 | } | ||
4327 | 227 | |||
4328 | 228 | if (self->priv->uri) | ||
4329 | 229 | { | ||
4330 | 230 | g_free (self->priv->uri); | ||
4331 | 231 | self->priv->uri = NULL; | ||
4332 | 232 | } | ||
4333 | 233 | |||
4334 | 160 | G_OBJECT_CLASS (bamf_tab_parent_class)->dispose (object); | 234 | G_OBJECT_CLASS (bamf_tab_parent_class)->dispose (object); |
4335 | 161 | } | 235 | } |
4336 | 162 | 236 | ||
4337 | 163 | static void | 237 | static void |
4338 | 238 | bamf_tab_finalize (GObject *object) | ||
4339 | 239 | { | ||
4340 | 240 | BamfTab *self = BAMF_TAB (object); | ||
4341 | 241 | |||
4342 | 242 | g_object_unref (self->priv->dbus_iface); | ||
4343 | 243 | |||
4344 | 244 | G_OBJECT_CLASS (bamf_tab_parent_class)->finalize (object); | ||
4345 | 245 | } | ||
4346 | 246 | |||
4347 | 247 | static void | ||
4348 | 164 | bamf_tab_init (BamfTab * self) | 248 | bamf_tab_init (BamfTab * self) |
4349 | 165 | { | 249 | { |
4350 | 166 | self->priv = BAMF_TAB_GET_PRIVATE (self); | 250 | self->priv = BAMF_TAB_GET_PRIVATE (self); |
4351 | 251 | |||
4352 | 252 | /* Initializing the dbus interface */ | ||
4353 | 253 | self->priv->dbus_iface = bamf_dbus_item_tab_skeleton_new (); | ||
4354 | 254 | |||
4355 | 255 | /* We need to connect to the object own signals to redirect them to the dbus | ||
4356 | 256 | * interface */ | ||
4357 | 257 | g_signal_connect (self, "uri-changed", G_CALLBACK (on_uri_changed), NULL); | ||
4358 | 258 | |||
4359 | 259 | /* Registering signal callbacks to reply to dbus method calls */ | ||
4360 | 260 | g_signal_connect (self->priv->dbus_iface, "handle-show-tab", | ||
4361 | 261 | G_CALLBACK (on_dbus_handle_show_tab), self); | ||
4362 | 262 | |||
4363 | 263 | g_signal_connect (self->priv->dbus_iface, "handle-parent-xid", | ||
4364 | 264 | G_CALLBACK (on_dbus_handle_parent_xid), self); | ||
4365 | 265 | |||
4366 | 266 | g_signal_connect (self->priv->dbus_iface, "handle-current-uri", | ||
4367 | 267 | G_CALLBACK (on_dbus_handle_current_uri), self); | ||
4368 | 268 | |||
4369 | 269 | g_signal_connect (self->priv->dbus_iface, "handle-preview", | ||
4370 | 270 | G_CALLBACK (on_dbus_handle_preview), self); | ||
4371 | 271 | |||
4372 | 272 | /* Setting the interface for the dbus object */ | ||
4373 | 273 | bamf_dbus_item_object_skeleton_set_tab (BAMF_DBUS_ITEM_OBJECT_SKELETON (self), | ||
4374 | 274 | self->priv->dbus_iface); | ||
4375 | 275 | } | ||
4376 | 276 | |||
4377 | 277 | static void bamf_tab_dbus_iface_init (BamfDBusItemTabIface *iface) | ||
4378 | 278 | { | ||
4379 | 167 | } | 279 | } |
4380 | 168 | 280 | ||
4381 | 169 | static void | 281 | static void |
4382 | @@ -177,6 +289,7 @@ | |||
4383 | 177 | object_class->get_property = bamf_tab_get_property; | 289 | object_class->get_property = bamf_tab_get_property; |
4384 | 178 | object_class->set_property = bamf_tab_set_property; | 290 | object_class->set_property = bamf_tab_set_property; |
4385 | 179 | object_class->dispose = bamf_tab_dispose; | 291 | object_class->dispose = bamf_tab_dispose; |
4386 | 292 | object_class->finalize = bamf_tab_finalize; | ||
4387 | 180 | view_class->view_type = bamf_tab_get_view_type; | 293 | view_class->view_type = bamf_tab_get_view_type; |
4388 | 181 | 294 | ||
4389 | 182 | pspec = g_param_spec_string ("id", "id", "id", NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT); | 295 | pspec = g_param_spec_string ("id", "id", "id", NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT); |
4390 | @@ -186,22 +299,10 @@ | |||
4391 | 186 | g_object_class_install_property (object_class, PROP_SOURCE, pspec); | 299 | g_object_class_install_property (object_class, PROP_SOURCE, pspec); |
4392 | 187 | 300 | ||
4393 | 188 | g_type_class_add_private (klass, sizeof (BamfTabPrivate)); | 301 | g_type_class_add_private (klass, sizeof (BamfTabPrivate)); |
4394 | 189 | |||
4395 | 190 | dbus_g_object_type_install_info (BAMF_TYPE_TAB, | ||
4396 | 191 | &dbus_glib_bamf_tab_object_info); | ||
4397 | 192 | |||
4398 | 193 | tab_signals [URI_CHANGED] = | ||
4399 | 194 | g_signal_new ("uri-changed", | ||
4400 | 195 | G_OBJECT_CLASS_TYPE (klass), | ||
4401 | 196 | 0, | ||
4402 | 197 | 0, NULL, NULL, | ||
4403 | 198 | bamf_marshal_VOID__STRING_STRING, | ||
4404 | 199 | G_TYPE_NONE, 2, | ||
4405 | 200 | G_TYPE_STRING, G_TYPE_STRING); | ||
4406 | 201 | } | 302 | } |
4407 | 202 | 303 | ||
4408 | 203 | BamfTab * | 304 | BamfTab * |
4410 | 204 | bamf_tab_new (BamfTabSource *source, char *id) | 305 | bamf_tab_new (BamfTabSource *source, const char *id) |
4411 | 205 | { | 306 | { |
4412 | 206 | BamfTab *self; | 307 | BamfTab *self; |
4413 | 207 | self = (BamfTab *) g_object_new (BAMF_TYPE_TAB, | 308 | self = (BamfTab *) g_object_new (BAMF_TYPE_TAB, |
4414 | 208 | 309 | ||
4415 | === modified file 'src/bamf-tab.h' | |||
4416 | --- src/bamf-tab.h 2010-05-25 13:47:38 +0000 | |||
4417 | +++ src/bamf-tab.h 2012-01-19 19:16:25 +0000 | |||
4418 | @@ -1,5 +1,5 @@ | |||
4419 | 1 | /* | 1 | /* |
4421 | 2 | * Copyright (C) 2010 Canonical Ltd | 2 | * Copyright (C) 2010-2011 Canonical Ltd |
4422 | 3 | * | 3 | * |
4423 | 4 | * This program is free software: you can redistribute it and/or modify | 4 | * This program is free software: you can redistribute it and/or modify |
4424 | 5 | * it under the terms of the GNU General Public License version 3 as | 5 | * it under the terms of the GNU General Public License version 3 as |
4425 | @@ -14,6 +14,7 @@ | |||
4426 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
4427 | 15 | * | 15 | * |
4428 | 16 | * Authored by: Jason Smith <jason.smith@canonical.com> | 16 | * Authored by: Jason Smith <jason.smith@canonical.com> |
4429 | 17 | * Marco Trevisan (Treviño) <3v1n0@ubuntu.com> | ||
4430 | 17 | * | 18 | * |
4431 | 18 | */ | 19 | */ |
4432 | 19 | 20 | ||
4433 | @@ -58,8 +59,8 @@ | |||
4434 | 58 | 59 | ||
4435 | 59 | guint32 bamf_tab_parent_xid (BamfTab *tab); | 60 | guint32 bamf_tab_parent_xid (BamfTab *tab); |
4436 | 60 | 61 | ||
4438 | 61 | GArray * bamf_tab_get_preview (BamfTab *tab); | 62 | gchar * bamf_tab_get_preview (BamfTab *tab); |
4439 | 62 | 63 | ||
4441 | 63 | BamfTab * bamf_tab_new (BamfTabSource *source, char *tab_id); | 64 | BamfTab * bamf_tab_new (BamfTabSource *source, const char *tab_id); |
4442 | 64 | 65 | ||
4443 | 65 | #endif | 66 | #endif |
4444 | 66 | 67 | ||
4445 | === removed file 'src/bamf-view-glue.xml' | |||
4446 | --- src/bamf-view-glue.xml 2011-01-26 09:54:11 +0000 | |||
4447 | +++ src/bamf-view-glue.xml 1970-01-01 00:00:00 +0000 | |||
4448 | @@ -1,109 +0,0 @@ | |||
4449 | 1 | <?xml version="1.0" encoding="UTF-8" ?> | ||
4450 | 2 | |||
4451 | 3 | <node name="/org/ayatana/bamf"> | ||
4452 | 4 | |||
4453 | 5 | <interface name="org.ayatana.bamf.view"> | ||
4454 | 6 | |||
4455 | 7 | <signal name="ActiveChanged"> | ||
4456 | 8 | <arg type="b" name="new_state" direction="out" /> | ||
4457 | 9 | </signal> | ||
4458 | 10 | |||
4459 | 11 | <signal name="Closed"> | ||
4460 | 12 | </signal> | ||
4461 | 13 | |||
4462 | 14 | <signal name="ChildAdded"> | ||
4463 | 15 | <arg type="s" name="path" direction="out" /> | ||
4464 | 16 | </signal> | ||
4465 | 17 | |||
4466 | 18 | <signal name="ChildRemoved"> | ||
4467 | 19 | <arg type="s" name="path" direction="out" /> | ||
4468 | 20 | </signal> | ||
4469 | 21 | |||
4470 | 22 | <signal name="RunningChanged"> | ||
4471 | 23 | <arg type="b" name="new_state" direction="out" /> | ||
4472 | 24 | </signal> | ||
4473 | 25 | |||
4474 | 26 | <signal name="UrgentChanged"> | ||
4475 | 27 | <arg type="b" name="new_state" direction="out" /> | ||
4476 | 28 | </signal> | ||
4477 | 29 | |||
4478 | 30 | <signal name="UserVisibleChanged"> | ||
4479 | 31 | <arg type="b" name="new_state" direction="out" /> | ||
4480 | 32 | </signal> | ||
4481 | 33 | |||
4482 | 34 | <signal name="NameChanged"> | ||
4483 | 35 | <arg type="s" name="old_name" direction="out" /> | ||
4484 | 36 | <arg type="s" name="new_name" direction="out" /> | ||
4485 | 37 | </signal> | ||
4486 | 38 | |||
4487 | 39 | <property name="Active" type="b" access="read" /> | ||
4488 | 40 | <property name="Urgent" type="b" access="read" /> | ||
4489 | 41 | <property name="Running" type="b" access="read" /> | ||
4490 | 42 | <property name="UserVisible" type="b" access="read" /> | ||
4491 | 43 | |||
4492 | 44 | <method name="Children"> | ||
4493 | 45 | <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_view_get_children_paths" /> | ||
4494 | 46 | <arg type="as" name="children" direction="out"> | ||
4495 | 47 | <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/> | ||
4496 | 48 | </arg> | ||
4497 | 49 | </method> | ||
4498 | 50 | |||
4499 | 51 | <method name="Parents"> | ||
4500 | 52 | <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_view_get_parent_paths" /> | ||
4501 | 53 | <arg type="as" name="parents" direction="out"> | ||
4502 | 54 | <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/> | ||
4503 | 55 | </arg> | ||
4504 | 56 | </method> | ||
4505 | 57 | |||
4506 | 58 | <method name="IsActive"> | ||
4507 | 59 | <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_view_is_active" /> | ||
4508 | 60 | <arg type="b" name="active" direction="out"> | ||
4509 | 61 | <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/> | ||
4510 | 62 | </arg> | ||
4511 | 63 | </method> | ||
4512 | 64 | |||
4513 | 65 | <method name="IsRunning"> | ||
4514 | 66 | <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_view_is_running" /> | ||
4515 | 67 | <arg type="b" name="running" direction="out"> | ||
4516 | 68 | <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/> | ||
4517 | 69 | </arg> | ||
4518 | 70 | </method> | ||
4519 | 71 | |||
4520 | 72 | <method name="IsUrgent"> | ||
4521 | 73 | <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_view_is_urgent" /> | ||
4522 | 74 | <arg type="b" name="urgent" direction="out"> | ||
4523 | 75 | <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/> | ||
4524 | 76 | </arg> | ||
4525 | 77 | </method> | ||
4526 | 78 | |||
4527 | 79 | <method name="Name"> | ||
4528 | 80 | <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_view_get_name" /> | ||
4529 | 81 | <arg type="s" name="name" direction="out"> | ||
4530 | 82 | <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/> | ||
4531 | 83 | </arg> | ||
4532 | 84 | </method> | ||
4533 | 85 | |||
4534 | 86 | <method name="Icon"> | ||
4535 | 87 | <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_view_get_icon" /> | ||
4536 | 88 | <arg type="s" name="name" direction="out"> | ||
4537 | 89 | <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/> | ||
4538 | 90 | </arg> | ||
4539 | 91 | </method> | ||
4540 | 92 | |||
4541 | 93 | <method name="UserVisible"> | ||
4542 | 94 | <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_view_user_visible" /> | ||
4543 | 95 | <arg type="b" name="visible" direction="out"> | ||
4544 | 96 | <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/> | ||
4545 | 97 | </arg> | ||
4546 | 98 | </method> | ||
4547 | 99 | |||
4548 | 100 | <method name="ViewType"> | ||
4549 | 101 | <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_view_get_view_type" /> | ||
4550 | 102 | <arg type="s" name="view_type" direction="out"> | ||
4551 | 103 | <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/> | ||
4552 | 104 | </arg> | ||
4553 | 105 | </method> | ||
4554 | 106 | |||
4555 | 107 | </interface> | ||
4556 | 108 | |||
4557 | 109 | </node> | ||
4558 | 110 | 0 | ||
4559 | === modified file 'src/bamf-view.c' | |||
4560 | --- src/bamf-view.c 2011-12-14 03:19:47 +0000 | |||
4561 | +++ src/bamf-view.c 2012-01-19 19:16:25 +0000 | |||
4562 | @@ -1,5 +1,5 @@ | |||
4563 | 1 | /* | 1 | /* |
4565 | 2 | * Copyright (C) 2010 Canonical Ltd | 2 | * Copyright (C) 2010-2011 Canonical Ltd |
4566 | 3 | * | 3 | * |
4567 | 4 | * This program is free software: you can redistribute it and/or modify | 4 | * This program is free software: you can redistribute it and/or modify |
4568 | 5 | * it under the terms of the GNU General Public License version 3 as | 5 | * it under the terms of the GNU General Public License version 3 as |
4569 | @@ -14,21 +14,24 @@ | |||
4570 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
4571 | 15 | * | 15 | * |
4572 | 16 | * Authored by: Jason Smith <jason.smith@canonical.com> | 16 | * Authored by: Jason Smith <jason.smith@canonical.com> |
4573 | 17 | * Marco Trevisan (Treviño) <3v1n0@ubuntu.com> | ||
4574 | 17 | * | 18 | * |
4575 | 18 | */ | 19 | */ |
4576 | 19 | 20 | ||
4577 | 20 | #include "bamf-marshal.h" | ||
4578 | 21 | #include "bamf-view.h" | 21 | #include "bamf-view.h" |
4579 | 22 | #include "bamf-view-glue.h" | ||
4580 | 23 | 22 | ||
4581 | 24 | G_DEFINE_TYPE (BamfView, bamf_view, G_TYPE_OBJECT); | ||
4582 | 25 | #define BAMF_VIEW_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE(obj, \ | 23 | #define BAMF_VIEW_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE(obj, \ |
4584 | 26 | BAMF_TYPE_VIEW, BamfViewPrivate)) | 24 | BAMF_TYPE_VIEW, BamfViewPrivate)) |
4585 | 25 | |||
4586 | 26 | static void bamf_view_dbus_view_iface_init (BamfDBusItemViewIface *iface); | ||
4587 | 27 | G_DEFINE_TYPE_WITH_CODE (BamfView, bamf_view, BAMF_DBUS_ITEM_TYPE_OBJECT_SKELETON, | ||
4588 | 28 | G_IMPLEMENT_INTERFACE (BAMF_DBUS_ITEM_TYPE_VIEW, | ||
4589 | 29 | bamf_view_dbus_view_iface_init)); | ||
4590 | 27 | 30 | ||
4591 | 28 | enum | 31 | enum |
4592 | 29 | { | 32 | { |
4593 | 30 | PROP_0, | 33 | PROP_0, |
4595 | 31 | 34 | ||
4596 | 32 | PROP_ACTIVE, | 35 | PROP_ACTIVE, |
4597 | 33 | PROP_RUNNING, | 36 | PROP_RUNNING, |
4598 | 34 | PROP_URGENT, | 37 | PROP_URGENT, |
4599 | @@ -37,16 +40,8 @@ | |||
4600 | 37 | 40 | ||
4601 | 38 | enum | 41 | enum |
4602 | 39 | { | 42 | { |
4603 | 40 | ACTIVE_CHANGED, | ||
4604 | 41 | CLOSED, | ||
4605 | 42 | CLOSED_INTERNAL, | 43 | CLOSED_INTERNAL, |
4606 | 43 | CHILD_ADDED, | ||
4607 | 44 | CHILD_REMOVED, | ||
4608 | 45 | EXPORTED, | 44 | EXPORTED, |
4609 | 46 | RUNNING_CHANGED, | ||
4610 | 47 | URGENT_CHANGED, | ||
4611 | 48 | USER_VISIBLE_CHANGED, | ||
4612 | 49 | NAME_CHANGED, | ||
4613 | 50 | 45 | ||
4614 | 51 | LAST_SIGNAL, | 46 | LAST_SIGNAL, |
4615 | 52 | }; | 47 | }; |
4616 | @@ -55,20 +50,19 @@ | |||
4617 | 55 | 50 | ||
4618 | 56 | struct _BamfViewPrivate | 51 | struct _BamfViewPrivate |
4619 | 57 | { | 52 | { |
4620 | 53 | BamfDBusItemView *dbus_iface; | ||
4621 | 58 | char * name; | 54 | char * name; |
4622 | 59 | char * path; | 55 | char * path; |
4623 | 60 | GList * children; | 56 | GList * children; |
4624 | 61 | GList * parents; | 57 | GList * parents; |
4625 | 62 | gboolean closed; | 58 | gboolean closed; |
4626 | 63 | gboolean is_active; | ||
4627 | 64 | gboolean is_running; | ||
4628 | 65 | gboolean is_urgent; | ||
4629 | 66 | gboolean user_visible; | ||
4630 | 67 | }; | 59 | }; |
4631 | 68 | 60 | ||
4632 | 69 | static void | 61 | static void |
4633 | 70 | bamf_view_active_changed (BamfView *view, gboolean active) | 62 | bamf_view_active_changed (BamfView *view, gboolean active) |
4634 | 71 | { | 63 | { |
4635 | 64 | g_return_if_fail (BAMF_IS_VIEW (view)); | ||
4636 | 65 | |||
4637 | 72 | gboolean emit = TRUE; | 66 | gboolean emit = TRUE; |
4638 | 73 | if (BAMF_VIEW_GET_CLASS (view)->active_changed) | 67 | if (BAMF_VIEW_GET_CLASS (view)->active_changed) |
4639 | 74 | { | 68 | { |
4640 | @@ -76,16 +70,17 @@ | |||
4641 | 76 | } | 70 | } |
4642 | 77 | 71 | ||
4643 | 78 | if (emit) | 72 | if (emit) |
4646 | 79 | g_signal_emit (view, view_signals[ACTIVE_CHANGED], 0, active); | 73 | g_signal_emit_by_name (view, "active-changed", active); |
4645 | 80 | |||
4647 | 81 | } | 74 | } |
4648 | 82 | 75 | ||
4649 | 83 | static void | 76 | static void |
4653 | 84 | bamf_view_name_changed (BamfView* view, | 77 | bamf_view_name_changed (BamfView *view, |
4654 | 85 | const gchar* old_name, | 78 | const gchar *old_name, |
4655 | 86 | const gchar* new_name) | 79 | const gchar *new_name) |
4656 | 87 | { | 80 | { |
4658 | 88 | g_signal_emit (view, view_signals[NAME_CHANGED], 0, old_name, new_name); | 81 | g_return_if_fail (BAMF_IS_VIEW (view)); |
4659 | 82 | |||
4660 | 83 | g_signal_emit_by_name (view, "name-changed", old_name, new_name); | ||
4661 | 89 | 84 | ||
4662 | 90 | if (view->priv->name) | 85 | if (view->priv->name) |
4663 | 91 | g_free (view->priv->name); | 86 | g_free (view->priv->name); |
4664 | @@ -96,6 +91,8 @@ | |||
4665 | 96 | static void | 91 | static void |
4666 | 97 | bamf_view_user_visible_changed (BamfView *view, gboolean user_visible) | 92 | bamf_view_user_visible_changed (BamfView *view, gboolean user_visible) |
4667 | 98 | { | 93 | { |
4668 | 94 | g_return_if_fail (BAMF_IS_VIEW (view)); | ||
4669 | 95 | |||
4670 | 99 | gboolean emit = TRUE; | 96 | gboolean emit = TRUE; |
4671 | 100 | if (BAMF_VIEW_GET_CLASS (view)->user_visible_changed) | 97 | if (BAMF_VIEW_GET_CLASS (view)->user_visible_changed) |
4672 | 101 | { | 98 | { |
4673 | @@ -103,12 +100,14 @@ | |||
4674 | 103 | } | 100 | } |
4675 | 104 | 101 | ||
4676 | 105 | if (emit) | 102 | if (emit) |
4678 | 106 | g_signal_emit (view, view_signals[USER_VISIBLE_CHANGED], 0, user_visible); | 103 | g_signal_emit_by_name (view, "user-visible-changed", user_visible); |
4679 | 107 | } | 104 | } |
4680 | 108 | 105 | ||
4681 | 109 | static void | 106 | static void |
4682 | 110 | bamf_view_running_changed (BamfView *view, gboolean running) | 107 | bamf_view_running_changed (BamfView *view, gboolean running) |
4683 | 111 | { | 108 | { |
4684 | 109 | g_return_if_fail (BAMF_IS_VIEW (view)); | ||
4685 | 110 | |||
4686 | 112 | gboolean emit = TRUE; | 111 | gboolean emit = TRUE; |
4687 | 113 | if (BAMF_VIEW_GET_CLASS (view)->running_changed) | 112 | if (BAMF_VIEW_GET_CLASS (view)->running_changed) |
4688 | 114 | { | 113 | { |
4689 | @@ -116,12 +115,14 @@ | |||
4690 | 116 | } | 115 | } |
4691 | 117 | 116 | ||
4692 | 118 | if (emit) | 117 | if (emit) |
4694 | 119 | g_signal_emit (view, view_signals[RUNNING_CHANGED], 0, running); | 118 | g_signal_emit_by_name (view, "running-changed", running); |
4695 | 120 | } | 119 | } |
4696 | 121 | 120 | ||
4697 | 122 | static void | 121 | static void |
4698 | 123 | bamf_view_urgent_changed (BamfView *view, gboolean urgent) | 122 | bamf_view_urgent_changed (BamfView *view, gboolean urgent) |
4699 | 124 | { | 123 | { |
4700 | 124 | g_return_if_fail (BAMF_IS_VIEW (view)); | ||
4701 | 125 | |||
4702 | 125 | gboolean emit = TRUE; | 126 | gboolean emit = TRUE; |
4703 | 126 | if (BAMF_VIEW_GET_CLASS (view)->urgent_changed) | 127 | if (BAMF_VIEW_GET_CLASS (view)->urgent_changed) |
4704 | 127 | { | 128 | { |
4705 | @@ -129,7 +130,7 @@ | |||
4706 | 129 | } | 130 | } |
4707 | 130 | 131 | ||
4708 | 131 | if (emit) | 132 | if (emit) |
4710 | 132 | g_signal_emit (view, view_signals[URGENT_CHANGED], 0, urgent); | 133 | g_signal_emit_by_name (view, "urgent-changed", urgent); |
4711 | 133 | } | 134 | } |
4712 | 134 | 135 | ||
4713 | 135 | void | 136 | void |
4714 | @@ -138,19 +139,20 @@ | |||
4715 | 138 | BamfViewPrivate *priv; | 139 | BamfViewPrivate *priv; |
4716 | 139 | gboolean emit = TRUE; | 140 | gboolean emit = TRUE; |
4717 | 140 | GList *l; | 141 | GList *l; |
4719 | 141 | 142 | ||
4720 | 143 | g_return_if_fail (BAMF_IS_VIEW (view)); | ||
4721 | 142 | priv = view->priv; | 144 | priv = view->priv; |
4722 | 143 | 145 | ||
4723 | 144 | if (priv->closed) | 146 | if (priv->closed) |
4724 | 145 | return; | 147 | return; |
4726 | 146 | 148 | ||
4727 | 147 | priv->closed = TRUE; | 149 | priv->closed = TRUE; |
4728 | 148 | 150 | ||
4729 | 149 | if (BAMF_VIEW_GET_CLASS (view)->closed) | 151 | if (BAMF_VIEW_GET_CLASS (view)->closed) |
4730 | 150 | { | 152 | { |
4731 | 151 | emit = !BAMF_VIEW_GET_CLASS (view)->closed (view); | 153 | emit = !BAMF_VIEW_GET_CLASS (view)->closed (view); |
4732 | 152 | } | 154 | } |
4734 | 153 | 155 | ||
4735 | 154 | if (priv->children) | 156 | if (priv->children) |
4736 | 155 | { | 157 | { |
4737 | 156 | for (l = priv->children; l; l = l->next) | 158 | for (l = priv->children; l; l = l->next) |
4738 | @@ -164,10 +166,10 @@ | |||
4739 | 164 | 166 | ||
4740 | 165 | if (emit) | 167 | if (emit) |
4741 | 166 | { | 168 | { |
4743 | 167 | g_object_ref (G_OBJECT (view)); | 169 | g_object_ref (view); |
4744 | 168 | g_signal_emit (view, view_signals[CLOSED_INTERNAL], 0); | 170 | g_signal_emit (view, view_signals[CLOSED_INTERNAL], 0); |
4747 | 169 | g_signal_emit (view, view_signals[CLOSED], 0); | 171 | g_signal_emit_by_name (view, "closed"); |
4748 | 170 | g_object_unref (G_OBJECT (view)); | 172 | g_object_unref (view); |
4749 | 171 | } | 173 | } |
4750 | 172 | } | 174 | } |
4751 | 173 | 175 | ||
4752 | @@ -179,35 +181,31 @@ | |||
4753 | 179 | return view->priv->path; | 181 | return view->priv->path; |
4754 | 180 | } | 182 | } |
4755 | 181 | 183 | ||
4757 | 182 | char ** | 184 | GVariant * |
4758 | 183 | bamf_view_get_children_paths (BamfView *view) | 185 | bamf_view_get_children_paths (BamfView *view) |
4759 | 184 | { | 186 | { |
4765 | 185 | char ** paths; | 187 | GVariantBuilder b; |
4766 | 186 | const char *path; | 188 | GList *l; |
4762 | 187 | int n_items, i; | ||
4763 | 188 | GList *child; | ||
4764 | 189 | BamfView *cview; | ||
4767 | 190 | 189 | ||
4768 | 191 | g_return_val_if_fail (BAMF_IS_VIEW (view), NULL); | 190 | g_return_val_if_fail (BAMF_IS_VIEW (view), NULL); |
4769 | 192 | 191 | ||
4776 | 193 | n_items = g_list_length (view->priv->children); | 192 | g_variant_builder_init (&b, G_VARIANT_TYPE ("(as)")); |
4777 | 194 | 193 | g_variant_builder_open (&b, G_VARIANT_TYPE ("as")); | |
4778 | 195 | paths = g_malloc0 (sizeof (char *) * (n_items + 1)); | 194 | |
4779 | 196 | 195 | for (l = view->priv->children; l; l = l->next) | |
4774 | 197 | i = 0; | ||
4775 | 198 | for (child = view->priv->children; child; child = child->next) | ||
4780 | 199 | { | 196 | { |
4783 | 200 | cview = child->data; | 197 | BamfView *child = l->data; |
4784 | 201 | path = bamf_view_get_path (cview); | 198 | const char *path = bamf_view_get_path (child); |
4785 | 202 | 199 | ||
4786 | 203 | if (!path) | 200 | if (!path) |
4787 | 204 | continue; | 201 | continue; |
4788 | 205 | 202 | ||
4791 | 206 | paths[i] = g_strdup (path); | 203 | g_variant_builder_add (&b, "s", path); |
4790 | 207 | i++; | ||
4792 | 208 | } | 204 | } |
4793 | 209 | 205 | ||
4795 | 210 | return paths; | 206 | g_variant_builder_close (&b); |
4796 | 207 | |||
4797 | 208 | return g_variant_builder_end (&b); | ||
4798 | 211 | } | 209 | } |
4799 | 212 | 210 | ||
4800 | 213 | GList * | 211 | GList * |
4801 | @@ -218,35 +216,31 @@ | |||
4802 | 218 | return view->priv->children; | 216 | return view->priv->children; |
4803 | 219 | } | 217 | } |
4804 | 220 | 218 | ||
4806 | 221 | char ** | 219 | GVariant * |
4807 | 222 | bamf_view_get_parent_paths (BamfView *view) | 220 | bamf_view_get_parent_paths (BamfView *view) |
4808 | 223 | { | 221 | { |
4814 | 224 | char ** paths; | 222 | GVariantBuilder b; |
4815 | 225 | const char *path; | 223 | GList *l; |
4811 | 226 | int n_items, i; | ||
4812 | 227 | GList *parent; | ||
4813 | 228 | BamfView *pview; | ||
4816 | 229 | 224 | ||
4817 | 230 | g_return_val_if_fail (BAMF_IS_VIEW (view), NULL); | 225 | g_return_val_if_fail (BAMF_IS_VIEW (view), NULL); |
4818 | 231 | 226 | ||
4825 | 232 | n_items = g_list_length (view->priv->parents); | 227 | g_variant_builder_init (&b, G_VARIANT_TYPE ("(as)")); |
4826 | 233 | 228 | g_variant_builder_open (&b, G_VARIANT_TYPE ("as")); | |
4827 | 234 | paths = g_malloc0 (sizeof (char *) * (n_items + 1)); | 229 | |
4828 | 235 | 230 | for (l = view->priv->parents; l; l = l->next) | |
4823 | 236 | i = 0; | ||
4824 | 237 | for (parent = view->priv->parents; parent; parent = parent->next) | ||
4829 | 238 | { | 231 | { |
4832 | 239 | pview = parent->data; | 232 | BamfView *parent = l->data; |
4833 | 240 | path = bamf_view_get_path (pview); | 233 | const char *path = bamf_view_get_path (parent); |
4834 | 241 | 234 | ||
4835 | 242 | if (!path) | 235 | if (!path) |
4836 | 243 | continue; | 236 | continue; |
4837 | 244 | 237 | ||
4840 | 245 | paths[i] = g_strdup (path); | 238 | g_variant_builder_add (&b, "s", path); |
4839 | 246 | i++; | ||
4841 | 247 | } | 239 | } |
4842 | 248 | 240 | ||
4844 | 249 | return paths; | 241 | g_variant_builder_close (&b); |
4845 | 242 | |||
4846 | 243 | return g_variant_builder_end (&b); | ||
4847 | 250 | } | 244 | } |
4848 | 251 | 245 | ||
4849 | 252 | GList * | 246 | GList * |
4850 | @@ -274,7 +268,7 @@ | |||
4851 | 274 | g_return_if_fail (BAMF_IS_VIEW (child)); | 268 | g_return_if_fail (BAMF_IS_VIEW (child)); |
4852 | 275 | 269 | ||
4853 | 276 | g_signal_connect (G_OBJECT (child), "closed-internal", | 270 | g_signal_connect (G_OBJECT (child), "closed-internal", |
4855 | 277 | (GCallback) bamf_view_handle_child_closed, view); | 271 | (GCallback) bamf_view_handle_child_closed, view); |
4856 | 278 | 272 | ||
4857 | 279 | /* Make sure our parent child lists are ok, pay attention to whose list you add parents to */ | 273 | /* Make sure our parent child lists are ok, pay attention to whose list you add parents to */ |
4858 | 280 | view->priv->children = g_list_prepend (view->priv->children, child); | 274 | view->priv->children = g_list_prepend (view->priv->children, child); |
4859 | @@ -285,7 +279,7 @@ | |||
4860 | 285 | BAMF_VIEW_GET_CLASS (view)->child_added (view, child); | 279 | BAMF_VIEW_GET_CLASS (view)->child_added (view, child); |
4861 | 286 | 280 | ||
4862 | 287 | added = bamf_view_get_path (child); | 281 | added = bamf_view_get_path (child); |
4864 | 288 | g_signal_emit (view, view_signals[CHILD_ADDED], 0, added); | 282 | g_signal_emit_by_name (view, "child-added", added); |
4865 | 289 | } | 283 | } |
4866 | 290 | 284 | ||
4867 | 291 | void | 285 | void |
4868 | @@ -303,12 +297,12 @@ | |||
4869 | 303 | view->priv->children = g_list_remove (view->priv->children, child); | 297 | view->priv->children = g_list_remove (view->priv->children, child); |
4870 | 304 | child->priv->parents = g_list_remove (child->priv->parents, view); | 298 | child->priv->parents = g_list_remove (child->priv->parents, view); |
4871 | 305 | 299 | ||
4872 | 300 | removed = bamf_view_get_path (child); | ||
4873 | 301 | g_signal_emit_by_name (view, "child-removed", removed); | ||
4874 | 302 | |||
4875 | 306 | // Do this by hand so we can pass and object instead of a string | 303 | // Do this by hand so we can pass and object instead of a string |
4876 | 307 | if (BAMF_VIEW_GET_CLASS (view)->child_removed) | 304 | if (BAMF_VIEW_GET_CLASS (view)->child_removed) |
4877 | 308 | BAMF_VIEW_GET_CLASS (view)->child_removed (view, child); | 305 | BAMF_VIEW_GET_CLASS (view)->child_removed (view, child); |
4878 | 309 | |||
4879 | 310 | removed = bamf_view_get_path (child); | ||
4880 | 311 | g_signal_emit (view, view_signals[CHILD_REMOVED], 0, removed); | ||
4881 | 312 | } | 306 | } |
4882 | 313 | 307 | ||
4883 | 314 | gboolean | 308 | gboolean |
4884 | @@ -316,7 +310,7 @@ | |||
4885 | 316 | { | 310 | { |
4886 | 317 | g_return_val_if_fail (BAMF_IS_VIEW (view), FALSE); | 311 | g_return_val_if_fail (BAMF_IS_VIEW (view), FALSE); |
4887 | 318 | 312 | ||
4889 | 319 | return view->priv->is_active; | 313 | return bamf_dbus_item_view_get_active (view->priv->dbus_iface); |
4890 | 320 | } | 314 | } |
4891 | 321 | 315 | ||
4892 | 322 | void | 316 | void |
4893 | @@ -325,10 +319,10 @@ | |||
4894 | 325 | { | 319 | { |
4895 | 326 | g_return_if_fail (BAMF_IS_VIEW (view)); | 320 | g_return_if_fail (BAMF_IS_VIEW (view)); |
4896 | 327 | 321 | ||
4898 | 328 | if (active == view->priv->is_active) | 322 | if (active == bamf_view_is_active (view)) |
4899 | 329 | return; | 323 | return; |
4900 | 330 | 324 | ||
4902 | 331 | view->priv->is_active = active; | 325 | bamf_dbus_item_view_set_active (view->priv->dbus_iface, active); |
4903 | 332 | bamf_view_active_changed (view, active); | 326 | bamf_view_active_changed (view, active); |
4904 | 333 | } | 327 | } |
4905 | 334 | 328 | ||
4906 | @@ -337,7 +331,7 @@ | |||
4907 | 337 | { | 331 | { |
4908 | 338 | g_return_val_if_fail (BAMF_IS_VIEW (view), FALSE); | 332 | g_return_val_if_fail (BAMF_IS_VIEW (view), FALSE); |
4909 | 339 | 333 | ||
4911 | 340 | return view->priv->is_urgent; | 334 | return bamf_dbus_item_view_get_urgent (view->priv->dbus_iface); |
4912 | 341 | } | 335 | } |
4913 | 342 | 336 | ||
4914 | 343 | void | 337 | void |
4915 | @@ -346,10 +340,10 @@ | |||
4916 | 346 | { | 340 | { |
4917 | 347 | g_return_if_fail (BAMF_IS_VIEW (view)); | 341 | g_return_if_fail (BAMF_IS_VIEW (view)); |
4918 | 348 | 342 | ||
4920 | 349 | if (urgent == view->priv->is_urgent) | 343 | if (urgent == bamf_view_is_urgent (view)) |
4921 | 350 | return; | 344 | return; |
4922 | 351 | 345 | ||
4924 | 352 | view->priv->is_urgent = urgent; | 346 | bamf_dbus_item_view_set_urgent (view->priv->dbus_iface, urgent); |
4925 | 353 | bamf_view_urgent_changed (view, urgent); | 347 | bamf_view_urgent_changed (view, urgent); |
4926 | 354 | } | 348 | } |
4927 | 355 | 349 | ||
4928 | @@ -358,7 +352,7 @@ | |||
4929 | 358 | { | 352 | { |
4930 | 359 | g_return_val_if_fail (BAMF_IS_VIEW (view), FALSE); | 353 | g_return_val_if_fail (BAMF_IS_VIEW (view), FALSE); |
4931 | 360 | 354 | ||
4933 | 361 | return view->priv->is_running; | 355 | return bamf_dbus_item_view_get_running (view->priv->dbus_iface); |
4934 | 362 | } | 356 | } |
4935 | 363 | 357 | ||
4936 | 364 | void | 358 | void |
4937 | @@ -367,10 +361,10 @@ | |||
4938 | 367 | { | 361 | { |
4939 | 368 | g_return_if_fail (BAMF_IS_VIEW (view)); | 362 | g_return_if_fail (BAMF_IS_VIEW (view)); |
4940 | 369 | 363 | ||
4942 | 370 | if (running == view->priv->is_running) | 364 | if (running == bamf_view_is_running (view)) |
4943 | 371 | return; | 365 | return; |
4944 | 372 | 366 | ||
4946 | 373 | view->priv->is_running = running; | 367 | bamf_dbus_item_view_set_running (view->priv->dbus_iface, running); |
4947 | 374 | bamf_view_running_changed (view, running); | 368 | bamf_view_running_changed (view, running); |
4948 | 375 | } | 369 | } |
4949 | 376 | 370 | ||
4950 | @@ -379,7 +373,7 @@ | |||
4951 | 379 | { | 373 | { |
4952 | 380 | g_return_val_if_fail (BAMF_IS_VIEW (view), FALSE); | 374 | g_return_val_if_fail (BAMF_IS_VIEW (view), FALSE); |
4953 | 381 | 375 | ||
4955 | 382 | return view->priv->user_visible; | 376 | return bamf_dbus_item_view_get_user_visible (view->priv->dbus_iface); |
4956 | 383 | } | 377 | } |
4957 | 384 | 378 | ||
4958 | 385 | void | 379 | void |
4959 | @@ -387,10 +381,10 @@ | |||
4960 | 387 | { | 381 | { |
4961 | 388 | g_return_if_fail (BAMF_IS_VIEW (view)); | 382 | g_return_if_fail (BAMF_IS_VIEW (view)); |
4962 | 389 | 383 | ||
4964 | 390 | if (user_visible == view->priv->user_visible) | 384 | if (user_visible == bamf_view_user_visible (view)) |
4965 | 391 | return; | 385 | return; |
4966 | 392 | 386 | ||
4968 | 393 | view->priv->user_visible = user_visible; | 387 | bamf_dbus_item_view_set_user_visible (view->priv->dbus_iface, user_visible); |
4969 | 394 | bamf_view_user_visible_changed (view, user_visible); | 388 | bamf_view_user_visible_changed (view, user_visible); |
4970 | 395 | } | 389 | } |
4971 | 396 | 390 | ||
4972 | @@ -422,10 +416,10 @@ | |||
4973 | 422 | if (!g_strcmp0 (name, view->priv->name)) | 416 | if (!g_strcmp0 (name, view->priv->name)) |
4974 | 423 | return; | 417 | return; |
4975 | 424 | 418 | ||
4977 | 425 | bamf_view_name_changed (view, view->priv->name, (gchar*) name); | 419 | bamf_view_name_changed (view, view->priv->name, name); |
4978 | 426 | } | 420 | } |
4979 | 427 | 421 | ||
4981 | 428 | char * | 422 | const char * |
4982 | 429 | bamf_view_get_view_type (BamfView *view) | 423 | bamf_view_get_view_type (BamfView *view) |
4983 | 430 | { | 424 | { |
4984 | 431 | g_return_val_if_fail (BAMF_IS_VIEW (view), NULL); | 425 | g_return_val_if_fail (BAMF_IS_VIEW (view), NULL); |
4985 | @@ -433,7 +427,7 @@ | |||
4986 | 433 | if (BAMF_VIEW_GET_CLASS (view)->view_type) | 427 | if (BAMF_VIEW_GET_CLASS (view)->view_type) |
4987 | 434 | return BAMF_VIEW_GET_CLASS (view)->view_type (view); | 428 | return BAMF_VIEW_GET_CLASS (view)->view_type (view); |
4988 | 435 | 429 | ||
4990 | 436 | return g_strdup ("view"); | 430 | return "view"; |
4991 | 437 | } | 431 | } |
4992 | 438 | 432 | ||
4993 | 439 | char * | 433 | char * |
4994 | @@ -447,14 +441,15 @@ | |||
4995 | 447 | return g_strdup_printf ("view%p", view); | 441 | return g_strdup_printf ("view%p", view); |
4996 | 448 | } | 442 | } |
4997 | 449 | 443 | ||
5000 | 450 | char * | 444 | const char * |
4999 | 451 | bamf_view_export_on_bus (BamfView *view) |
A few things from a quick look: (in merge request line numbers)
1) please enable silent rules
339 + const GList *children, *l;
Please get rid of the const, this isn't C++ and afaict it's wrong in this case. (same for 405, 439, 449, 490, ...)
Same applies to methods returning const GList* - in that case the qualifier is correct, but all GList methods require non-const list anyway, so you're forcing the consumer to cast away the const-ness.
1335 + g_error_free (error);
1336 + error = NULL;
There are also multiple instances of this and it can be simplified using g_clear_error().