Merge lp:~3v1n0/bamf/libbamf-gdbus into lp:bamf/0.4

Proposed by Marco Trevisan (Treviño)
Status: Superseded
Proposed branch: lp:~3v1n0/bamf/libbamf-gdbus
Merge into: lp:bamf/0.4
Diff against target: 6766 lines (+1812/-2514)
43 files modified
Makefile.am (+2/-1)
configure.ac (+1/-11)
doc/reference/libbamf/Makefile.am (+1/-2)
lib/libbamf-private/Makefile.am (+83/-0)
lib/libbamf-private/bamf-private.h (+33/-0)
lib/libbamf/Makefile.am (+104/-66)
lib/libbamf/bamf-application-private.h (+1/-1)
lib/libbamf/bamf-application.c (+172/-233)
lib/libbamf/bamf-application.h (+5/-1)
lib/libbamf/bamf-control.c (+45/-42)
lib/libbamf/bamf-control.h (+5/-2)
lib/libbamf/bamf-factory.c (+88/-41)
lib/libbamf/bamf-factory.h (+1/-0)
lib/libbamf/bamf-matcher.c (+214/-274)
lib/libbamf/bamf-matcher.h (+10/-3)
lib/libbamf/bamf-tab-source.c (+200/-58)
lib/libbamf/bamf-tab-source.h (+7/-1)
lib/libbamf/bamf-tab.c (+133/-349)
lib/libbamf/bamf-tab.h (+33/-30)
lib/libbamf/bamf-view.c (+285/-518)
lib/libbamf/bamf-view.h (+19/-7)
lib/libbamf/bamf-window.c (+156/-224)
lib/libbamf/bamf-window.h (+7/-2)
lib/libbamf/libbamf3.pc.in (+1/-1)
lib/libbamf/org.ayatana.bamf.tabsource.xml (+36/-59)
src/Makefile.am (+4/-44)
src/bamf-application.c (+26/-20)
src/bamf-application.h (+1/-2)
src/bamf-control.c (+1/-2)
src/bamf-daemon.c (+5/-5)
src/bamf-matcher.c (+19/-0)
src/bamf-tab.c (+2/-2)
src/bamf-view.c (+66/-29)
src/bamf-window.c (+5/-4)
src/bamf.h (+1/-2)
tests/bamfdaemon/Makefile.am (+26/-31)
tests/functional/Makefile.am (+0/-73)
tests/functional/alt-tabber.c (+0/-173)
tests/functional/desktop-file-launcher.c (+0/-44)
tests/functional/interaction-tester.c (+0/-94)
tests/functional/tab-source-test.c (+0/-45)
tests/libbamf/Makefile.am (+14/-15)
tests/libbamf/test-libbamf.c (+0/-3)
To merge this branch: bzr merge lp:~3v1n0/bamf/libbamf-gdbus
Reviewer Review Type Date Requested Status
Unity Team Pending
Review via email: mp+108664@code.launchpad.net

This proposal has been superseded by a proposal from 2013-05-15.

Description of the change

Port the libbamf code to use the gdbus-codegen generated code.

To post a comment you must log in.
lp:~3v1n0/bamf/libbamf-gdbus updated
462. By Marco Trevisan (Treviño)

BamfDBusBrowser: fix the C prefix on generated code

463. By Marco Trevisan (Treviño)

BamfApplication: use gdbus proxy

464. By Marco Trevisan (Treviño)

BamfDaemon, BamfApplication: fix some glib warning, remove traling spaces

465. By Marco Trevisan (Treviño)

libbamf, BamfTabSource, Makefile.am: move to GDBus

466. By Marco Trevisan (Treviño)

configure.in: remove the dbus-glib-1 dependency

467. By Marco Trevisan (Treviño)

Daemon, BamfView: show each object exportation error

468. By Marco Trevisan (Treviño)

Daemon, BamfView: flush the skeleton signals before unexporting the view

469. By Marco Trevisan (Treviño)

Daemon, BamfView: unref the listed interfaces, as requested!

470. By Marco Trevisan (Treviño)

Daemon, BamfView: no need to manually unexport... The skeleton will do it

We only have to flush!

471. By Marco Trevisan (Treviño)

Daemon, BamfView: cache the properties until we don't export the object

At that point, we need to update the dbus skeleton value, so that it
will notify the clients emitting the proper signal.

472. By Marco Trevisan (Treviño)

Code spacing cleanup

473. By Marco Trevisan (Treviño)

BamfWindow: return an unknown window if type if not remote ready

Plus add xprop value check

474. By Marco Trevisan (Treviño)

BamfControl: use g_return_if_fail

475. By Marco Trevisan (Treviño)

BamfFactory: correctly populate the registered_view list

Plus various code improvements

476. By Marco Trevisan (Treviño)

BamfView: check for remote_ready, cache local name, use the proxy object path

No need to store the object path, gdbus do that for us; don't reset
the proxy if the path has not changed.
Also check for closed views in _bamf_view_remote_ready and use it to
prevent errors. Also always cache the name.

477. By Marco Trevisan (Treviño)

BamfView: use the properties change notifications instead of dbus signals

GDBus codegen give us these notifications for free, we can use them
instead of the "old-style" dbus signals

478. By Marco Trevisan (Treviño)

Merging with trunk

479. By Marco Trevisan (Treviño)

lib, BamfView: use DEPRECATED_FOR

480. By Marco Trevisan (Treviño)

BamfTab: minor cleanup and trailing spaces removal

481. By Marco Trevisan (Treviño)

Daemon, BamfMatcher: return a list of tabs when TabPaths is called

482. By Marco Trevisan (Treviño)

BamfTab: port to gdbus proxy

483. By Marco Trevisan (Treviño)

BamfTab: make tab properties read-only (we don't really need them as writable)

484. By Marco Trevisan (Treviño)

BamfMatcher: fix the iteration over the returned arrays

485. By Marco Trevisan (Treviño)

Daemon, BamfView: flush skeleton signals before emitting closed signal

486. By Marco Trevisan (Treviño)

Merged libbamf-private into libbamf-gdbus.

487. By Marco Trevisan (Treviño)

libbamf-private: set the correct name for browser dbus bindings

488. By Marco Trevisan (Treviño)

Merged libbamf-private into libbamf-gdbus.

489. By Marco Trevisan (Treviño)

Merging with lp:~3v1n0/bamf/libbamf-private build fixes

490. By Marco Trevisan (Treviño)

Merged libbamf-private into libbamf-gdbus.

491. By Marco Trevisan (Treviño)

Merged libbamf-private into libbamf-gdbus.

492. By Marco Trevisan (Treviño)

Merged libbamf-private into libbamf-gdbus.

493. By Marco Trevisan (Treviño)

Merging with libbamf-private branch, and set the library as build dependency

494. By Marco Trevisan (Treviño)

Libbamf: use prefixed _bamf_dbus calls, so that they don't get exported in symbols

495. By Marco Trevisan (Treviño)

BamfTab: fix the preview request async reply

496. By Marco Trevisan (Treviño)

Merged libbamf-private into libbamf-gdbus.

497. By Marco Trevisan (Treviño)

Libbamf: removing build dependency from libbamf-private.la

It makes things worse than expected.

498. By Marco Trevisan (Treviño)

BamfFactory: remove unneded null initialization

499. By Marco Trevisan (Treviño)

BamfTab: add annotation to functions, allow to generate bindings for request_preview

500. By Marco Trevisan (Treviño)

BamfTab: removing definitions for unsupported signals

501. By Marco Trevisan (Treviño)

BamfView: add GCancellable to be used for all the dbus calls

Added also the utility macro CANCELLABLE to make easier to use by clients

502. By Marco Trevisan (Treviño)

BamfApplication: use GCancellable for all the sync dbus calls

503. By Marco Trevisan (Treviño)

BamfTab: use GCancellable for all the sync dbus calls

504. By Marco Trevisan (Treviño)

BamfWindow: use GCancellable for all the sync dbus calls

505. By Marco Trevisan (Treviño)

BamfView: Cancel the GCancellable if view is closed, unset on dispose

Also resume some code cleanup lost during lp:bamf merging

506. By Marco Trevisan (Treviño)

BamfView: some code cleanup

507. By Marco Trevisan (Treviño)

Merging with trunk, fixing errors

508. By Marco Trevisan (Treviño)

LibbamfTest: check for singleton, add some cleanup

509. By Marco Trevisan (Treviño)

LibBamf: ignore some fatal errors during tests

510. By Marco Trevisan (Treviño)

BamfPrivate: define BAMF_DBUS_SERVICE_NAME based on testing environment

511. By Marco Trevisan (Treviño)

Daemon, Bamf.h: use defininitions of private library

512. By Marco Trevisan (Treviño)

Bamf.h: removed the file, always using libbamf-private definitions

513. By Marco Trevisan (Treviño)

TestLibBamf: use BAMF_TEST_MODE and export real PATH

514. By Marco Trevisan (Treviño)

debian/control: remove libdbus-glib-dev from build dependencies

515. By Marco Trevisan (Treviño)

LibBamf: Define a common proxy timeout value in libbamf-private and use it for proxies

516. By Marco Trevisan (Treviño)

LibBamf: move declaration of 'new' functions to bamf-view-private.h

Hide one from bamf-tab.h. TODO: hide from .so symbols as well, but this needs some more work

517. By Marco Trevisan (Treviño)

Daemon, BamfTab: use "tab" as stable dbus name

518. By Marco Trevisan (Treviño)

Merging with lp:~3v1n0/bamf/libbamf-private

519. By Marco Trevisan (Treviño)

Merging with parent branch

520. By Marco Trevisan (Treviño)

BamfDaemon: remove unneeded tabs on Makefile.am

521. By Marco Trevisan (Treviño)

Merged libbamf-private into libbamf-gdbus.

522. By Marco Trevisan (Treviño)

TestLibBamf: add deeper matcher singleton testing

523. By Marco Trevisan (Treviño)

TestLibBamf: add further Matcher singleton testing

524. By Marco Trevisan (Treviño)

Libbamf: use proper types for emitting signals

525. By Marco Trevisan (Treviño)

BamfMatcher: add GCancellable

526. By Marco Trevisan (Treviño)

BamfView: use GCancellable also on proxy initialization

527. By Marco Trevisan (Treviño)

Various code style fixes

528. By Marco Trevisan (Treviño)

configure.ac: bump revision to 0.5.0

529. By Marco Trevisan (Treviño)

Merged libbamf-private into libbamf-gdbus.

530. By Marco Trevisan (Treviño)

libbamf-private: fix makefile syntax

531. By Marco Trevisan (Treviño)

Daemon, BamfControl: get bus asynchronously and cleanup on destroy

532. By Marco Trevisan (Treviño)

BamfFactory: only unref a valid view and ref_sink only floating ones

533. By Marco Trevisan (Treviño)

BamfFactory: minor cleanup

534. By Marco Trevisan (Treviño)

BamfMatcher: unref the factory on finalize

535. By Marco Trevisan (Treviño)

BamfMatcher: improve docs for get_window_stack_for_monitor

536. By Marco Trevisan (Treviño)

BamfMatcher: set the correct element-type when returning list of View's

537. By Marco Trevisan (Treviño)

debian/changelog: bump revision to 0.5.0

538. By Marco Trevisan (Treviño)

Updated .bzrignore

539. By Marco Trevisan (Treviño)

TestLibBamf: use a weak pointer to make the test stronger

540. By Marco Trevisan (Treviño)

BamfView: go back to use signals, we'll use properties on upcoming branches...

541. By Marco Trevisan (Treviño)

debian/changelog: be more explicit

Unmerged revisions

541. By Marco Trevisan (Treviño)

debian/changelog: be more explicit

540. By Marco Trevisan (Treviño)

BamfView: go back to use signals, we'll use properties on upcoming branches...

539. By Marco Trevisan (Treviño)

TestLibBamf: use a weak pointer to make the test stronger

538. By Marco Trevisan (Treviño)

Updated .bzrignore

537. By Marco Trevisan (Treviño)

debian/changelog: bump revision to 0.5.0

536. By Marco Trevisan (Treviño)

BamfMatcher: set the correct element-type when returning list of View's

535. By Marco Trevisan (Treviño)

BamfMatcher: improve docs for get_window_stack_for_monitor

534. By Marco Trevisan (Treviño)

BamfMatcher: unref the factory on finalize

533. By Marco Trevisan (Treviño)

BamfFactory: minor cleanup

532. By Marco Trevisan (Treviño)

BamfFactory: only unref a valid view and ref_sink only floating ones

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Makefile.am'
2--- Makefile.am 2012-12-06 21:29:22 +0000
3+++ Makefile.am 2013-05-15 12:27:29 +0000
4@@ -3,9 +3,10 @@
5 include $(top_srcdir)/Makefile.am.coverage
6
7 SUBDIRS = \
8+ lib/libbamf-private \
9 lib/libbamf \
10+ lib/libbamf-private \
11 src \
12- tests/functional \
13 tests/bamfdaemon \
14 tests/libbamf \
15 data \
16
17=== modified file 'configure.ac'
18--- configure.ac 2013-04-17 01:39:17 +0000
19+++ configure.ac 2013-05-15 12:27:29 +0000
20@@ -55,16 +55,6 @@
21 if test -z "$GDBUS_CODEGEN"; then AC_MSG_ERROR([gdbus-codegen is required but was not found]); fi
22
23 #
24-# dbus
25-#
26-PKG_CHECK_MODULES(DBUS, dbus-glib-1 >= 0.76)
27-AC_SUBST(DBUS_LIBS)
28-AC_SUBST(DBUS_CFLAGS)
29-
30-DBUS_GLIB_BIN="`$PKG_CONFIG --variable=exec_prefix dbus-glib-1`/bin"
31-AC_SUBST(DBUS_GLIB_BIN)
32-
33-#
34 # libwnck
35 #
36 PKG_CHECK_MODULES(WNCK, libwnck-3.0 >= 3.4.5)
37@@ -165,10 +155,10 @@
38
39 AC_OUTPUT([
40 Makefile
41+lib/libbamf-private/Makefile
42 lib/libbamf/Makefile
43 lib/libbamf/libbamf3.pc
44 src/Makefile
45-tests/functional/Makefile
46 tests/bamfdaemon/Makefile
47 tests/libbamf/Makefile
48 data/Makefile
49
50=== modified file 'doc/reference/libbamf/Makefile.am'
51--- doc/reference/libbamf/Makefile.am 2012-12-19 19:43:11 +0000
52+++ doc/reference/libbamf/Makefile.am 2013-05-15 12:27:29 +0000
53@@ -32,7 +32,7 @@
54 # Header files to ignore when scanning.
55 IGNORE_HFILES = \
56 bamf-marshal.h \
57- bamf-tab-source-glue.h
58+ bamf-gdbus-tab-source-generated.h
59
60 # Images to copy into HTML directory.
61 HTML_IMAGES =
62@@ -50,7 +50,6 @@
63 GTKDOC_LIBS = \
64 $(GTK_LIBS) \
65 $(GLIB_LIBS) \
66- $(DBUS_LIBS) \
67 $(top_builddir)/lib/libbamf/libbamf$(LIBBAMF_VER).la
68
69 # This includes the standard gtk-doc make rules, copied by gtkdocize.
70
71=== added directory 'lib/libbamf-private'
72=== added file 'lib/libbamf-private/Makefile.am'
73--- lib/libbamf-private/Makefile.am 1970-01-01 00:00:00 +0000
74+++ lib/libbamf-private/Makefile.am 2013-05-15 12:27:29 +0000
75@@ -0,0 +1,83 @@
76+
77+INCLUDE = \
78+ -I. \
79+ $(NULL)
80+
81+noinst_LTLIBRARIES = libbamf-private.la
82+
83+bamf_gdbus_files = \
84+ bamf-gdbus-generated.c \
85+ bamf-gdbus-generated.h \
86+ bamf-gdbus-view-generated.c \
87+ bamf-gdbus-view-generated.h \
88+ bamf-gdbus-browser-generated.c \
89+ bamf-gdbus-browser-generated.h \
90+ $(NULL)
91+
92+bamf_xml_gdbus_files = \
93+ org.ayatana.bamf.xml \
94+ org.ayatana.bamf.view.xml \
95+ org.ayatana.bamf.browser.xml \
96+ $(NULL)
97+
98+bamf_built_sources = \
99+ $(bamf_gdbus_files) \
100+ $(NULL)
101+
102+bamf-gdbus-generated.c bamf-gdbus-generated.h: org.ayatana.bamf.xml
103+ $(AM_V_GEN) $(GDBUS_CODEGEN) \
104+ --generate-c-code bamf-gdbus-generated \
105+ --c-namespace BamfDBus \
106+ --interface-prefix org.ayatana.bamf \
107+ $<
108+
109+bamf-gdbus-view-generated.c bamf-gdbus-view-generated.h: org.ayatana.bamf.view.xml
110+ $(AM_V_GEN) $(GDBUS_CODEGEN) \
111+ --c-generate-object-manager \
112+ --generate-c-code bamf-gdbus-view-generated \
113+ --c-namespace BamfDBusItem \
114+ --interface-prefix org.ayatana.bamf \
115+ $<
116+
117+bamf-gdbus-browser-generated.c bamf-gdbus-browser-generated.h: org.ayatana.bamf.browser.xml
118+ $(AM_V_GEN) $(GDBUS_CODEGEN) \
119+ --generate-c-code bamf-gdbus-browser-generated \
120+ --c-namespace BamfDBus \
121+ --interface-prefix org.ayatana.bamf \
122+ $<
123+
124+libbamf_private_la_CFLAGS = \
125+ $(GLIB_CFLAGS)
126+ $(NULL)
127+
128+libbamf_private_la_LDFLAGS = \
129+ -no-undefined \
130+ $(NULL)
131+
132+libbamf_private_la_LIBADD = \
133+ $(GLIB_LIBS) \
134+ $(NULL)
135+
136+libbamf_private_la_SOURCES = \
137+ bamf-private.h \
138+ $(NULL)
139+
140+nodist_libbamf_private_la_SOURCES = \
141+ $(bamf_built_sources) \
142+ $(NULL)
143+
144+CLEANFILES = \
145+ $(bamf_built_sources) \
146+ $(NULL)
147+
148+DISTCLEANFILES = \
149+ $(bamf_built_sources) \
150+ $(NULL)
151+
152+BUILT_SOURCES = \
153+ $(bamf_gdbus_files) \
154+ $(NULL)
155+
156+EXTRA_DIST = \
157+ $(bamf_xml_gdbus_files) \
158+ $(NULL)
159
160=== added file 'lib/libbamf-private/bamf-private.h'
161--- lib/libbamf-private/bamf-private.h 1970-01-01 00:00:00 +0000
162+++ lib/libbamf-private/bamf-private.h 2013-05-15 12:27:29 +0000
163@@ -0,0 +1,33 @@
164+/*
165+ * Copyright (C) 2011-2013 Canonical Ltd
166+ *
167+ * This program is free software: you can redistribute it and/or modify
168+ * it under the terms of the GNU General Public License version 3 as
169+ * published by the Free Software Foundation.
170+ *
171+ * This program is distributed in the hope that it will be useful,
172+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
173+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
174+ * GNU General Public License for more details.
175+ *
176+ * You should have received a copy of the GNU General Public License
177+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
178+ *
179+ * Authored by: Marco Trevisan (Treviño) <3v1n0@ubuntu.com>
180+ *
181+ */
182+
183+#ifndef __BAMF_PRIVATE_H__
184+#define __BAMF_PRIVATE_H__
185+
186+#include <libbamf-private/bamf-gdbus-generated.h>
187+#include <libbamf-private/bamf-gdbus-view-generated.h>
188+#include <libbamf-private/bamf-gdbus-browser-generated.h>
189+
190+#define BAMF_DBUS_SERVICE_NAME "org.ayatana.bamf"
191+
192+#define BAMF_DBUS_BASE_PATH "/org/ayatana/bamf"
193+#define BAMF_DBUS_CONTROL_PATH BAMF_DBUS_BASE_PATH"/control"
194+#define BAMF_DBUS_MATCHER_PATH BAMF_DBUS_BASE_PATH"/matcher"
195+
196+#endif
197
198=== renamed file 'src/org.ayatana.bamf.browser.xml' => 'lib/libbamf-private/org.ayatana.bamf.browser.xml'
199=== renamed file 'src/org.ayatana.bamf.view.xml' => 'lib/libbamf-private/org.ayatana.bamf.view.xml'
200=== renamed file 'src/org.ayatana.bamf.xml' => 'lib/libbamf-private/org.ayatana.bamf.xml'
201=== modified file 'lib/libbamf/Makefile.am'
202--- lib/libbamf/Makefile.am 2013-03-28 19:03:56 +0000
203+++ lib/libbamf/Makefile.am 2013-05-15 12:27:29 +0000
204@@ -6,75 +6,92 @@
205 include $(top_srcdir)/Makefile.am.marshal
206 -include $(INTROSPECTION_MAKEFILE)
207
208+libbamf_xml_gdbus_files = \
209+ org.ayatana.bamf.tabsource.xml \
210+ $(NULL)
211+
212+libbamf_gdbus_files = \
213+ bamf-gdbus-tab-source-generated.c \
214+ bamf-gdbus-tab-source-generated.h \
215+ $(NULL)
216+
217 libbamf_built_sources = \
218- bamf-marshal.c \
219- bamf-marshal.h \
220- bamf-tab-source-glue.h \
221- $(NULL)
222+ bamf-marshal.c \
223+ bamf-marshal.h \
224+ $(libbamf_gdbus_files) \
225+ $(NULL)
226
227 libbamf_sources = \
228- bamf-application.c \
229- bamf-control.c \
230- bamf-matcher.c \
231- bamf-view.c \
232- bamf-window.c \
233- bamf-factory.c \
234- bamf-tab-source.c \
235- bamf-tab.c \
236- $(NULL)
237+ bamf-application.c \
238+ bamf-control.c \
239+ bamf-matcher.c \
240+ bamf-view.c \
241+ bamf-window.c \
242+ bamf-factory.c \
243+ bamf-tab-source.c \
244+ bamf-tab.c \
245+ $(NULL)
246
247 libbamf_headers = \
248- bamf-application.h \
249- bamf-control.h \
250- bamf-matcher.h \
251- bamf-view.h \
252- bamf-window.h \
253- bamf-tab-source.h \
254- bamf-tab.h \
255- libbamf.h \
256- $(NULL)
257+ bamf-application.h \
258+ bamf-control.h \
259+ bamf-matcher.h \
260+ bamf-view.h \
261+ bamf-window.h \
262+ bamf-tab-source.h \
263+ bamf-tab.h \
264+ libbamf.h \
265+ $(NULL)
266+
267+libbamf_private_headers = \
268+ bamf-factory.h \
269+ bamf-application-private.h \
270+ bamf-view-private.h \
271+ $(NULL)
272+
273+libbamf_la_SOURCES = \
274+ $(libbamf_built_sources) \
275+ $(libbamf_private_headers) \
276+ $(libbamf_headers) \
277+ $(libbamf_sources) \
278+ $(NULL)
279+
280+libbamf_la_LIBADD = \
281+ $(top_builddir)/lib/libbamf-private/libbamf-private.la \
282+ $(LIBWSBIND_LIBS) \
283+ $(GLIB_LIBS) \
284+ $(COVERAGE_LIBS) \
285+ $(NULL)
286+
287+libbamf_la_CPPFLAGS = \
288+ -Wall -std=c99 \
289+ -fPIC \
290+ -DDATADIR=\""$(datadir)"\" \
291+ -I$(top_srcdir)/lib \
292+ -I$(top_srcdir)/lib/libbamf \
293+ -I$(top_builddir)/lib/libbamf \
294+ $(COVERAGE_CFLAGS) \
295+ $(LIBWSBIND_CFLAGS) \
296+ $(GLIB_CFLAGS) \
297+ $(NULL)
298+
299+libbamf_la_LDFLAGS = \
300+ -shared \
301+ -export-symbols-regex "^bamf_" \
302+ -version-info 1:0:0 \
303+ $(COVERAGE_LDFLAGS) \
304+ $(NULL)
305
306 lib_LTLIBRARIES = libbamf3.la
307
308-libbamf3_la_SOURCES = \
309- bamf-factory.h \
310- bamf-application-private.h \
311- bamf-view-private.h \
312- $(libbamf_headers) \
313- $(libbamf_sources) \
314- $(NULL)
315-
316-nodist_libbamf3_la_SOURCES = \
317- $(libbamf_built_sources)
318- $(NULL)
319-
320-libbamf3_la_LIBADD = \
321- $(GLIB_LIBS) \
322- $(DBUS_LIBS) \
323- $(NULL)
324-
325-libbamf3_la_CPPFLAGS = \
326- -Wall -std=c99 \
327- -fPIC \
328- -DDATADIR=\""$(datadir)"\" \
329- -I$(top_srcdir)/lib \
330- -I$(top_builddir)/lib \
331- -I$(top_srcdir)/lib/libbamf \
332- -I$(top_builddir)/lib/libbamf \
333- $(GLIB_CFLAGS) \
334- $(DBUS_CFLAGS) \
335- $(COVERAGE_CFLAGS) \
336- $(NULL)
337-
338-libbamf3_la_LDFLAGS = \
339- -shared \
340- -export-symbols-regex "^bamf_" \
341- -version-info 1:0:0 \
342- $(COVERAGE_LDFLAGS) \
343- $(NULL)
344-
345-glib_marshal_list = bamf-marshal.list
346-glib_marshal_prefix = _bamf_marshal
347+libbamf3_la_SOURCES = $(libbamf_la_SOURCES)
348+libbamf3_la_LIBADD = $(libbamf_la_LIBADD)
349+libbamf3_la_CPPFLAGS = $(libbamf_la_CPPFLAGS)
350+libbamf3_la_LDFLAGS = $(libbamf_la_LDFLAGS)
351+
352+library_includedir=$(includedir)/libbamf$(VER)/libbamf
353+library_include_HEADERS = \
354+ $(sources_h)
355
356 # resetting BUILT_SOURCES here is intended
357 BUILT_SOURCES = \
358@@ -85,11 +102,6 @@
359 $(libbamf_built_sources) \
360 $(NULL)
361
362-bamf-tab-source-glue.h: bamf-tab-source-glue.xml
363- $(AM_V_GEN)$(DBUS_GLIB_BIN)/dbus-binding-tool --prefix=bamf_tab_source --mode=glib-server --output=$@ $<
364-
365-EXTRA_DIST += bamf-tab-source-glue.xml
366-
367 libbamf_includedir=$(includedir)/libbamf$(LIBBAMF_VER)/libbamf
368 libbamf_include_HEADERS = \
369 $(libbamf_headers)
370@@ -98,6 +110,32 @@
371 libbamf_pc_DATA = \
372 libbamf$(LIBBAMF_VER).pc
373
374+glib_marshal_list = bamf-marshal.list
375+glib_marshal_prefix = _bamf_marshal
376+
377+bamf-gdbus-tab-source-generated.c bamf-gdbus-tab-source-generated.h: org.ayatana.bamf.tabsource.xml
378+ $(AM_V_GEN) $(GDBUS_CODEGEN) \
379+ --generate-c-code bamf-gdbus-tab-source-generated \
380+ --c-namespace BamfDBusTab \
381+ --interface-prefix org.ayatana.bamf \
382+ $<
383+
384+BUILT_SOURCES += \
385+ $(libbamf_gdbus_files) \
386+ $(NULL)
387+
388+EXTRA_DIST += \
389+ $(libbamf_xml_gdbus_files) \
390+ $(NULL)
391+
392+DISTCLEANFILES += \
393+ $(libbamf_built_sources) \
394+ $(NULL)
395+
396+CLEANFILES += \
397+ $(libbamf_built_sources) \
398+ $(NULL)
399+
400
401 #########################
402 # GObject Introsepction
403
404=== modified file 'lib/libbamf/bamf-application-private.h'
405--- lib/libbamf/bamf-application-private.h 2012-05-24 20:25:51 +0000
406+++ lib/libbamf/bamf-application-private.h 2013-05-15 12:27:29 +0000
407@@ -25,6 +25,6 @@
408
409 #include <libbamf/bamf-application.h>
410
411-GList *_bamf_application_get_cached_xids (BamfApplication *app);
412+GList * _bamf_application_get_cached_xids (BamfApplication *app);
413
414 #endif
415
416=== modified file 'lib/libbamf/bamf-application.c'
417--- lib/libbamf/bamf-application.c 2012-12-06 16:03:14 +0000
418+++ lib/libbamf/bamf-application.c 2013-05-15 12:27:29 +0000
419@@ -1,5 +1,5 @@
420 /*
421- * Copyright 2010 Canonical Ltd.
422+ * Copyright 2010-2012 Canonical Ltd.
423 *
424 * This program is free software: you can redistribute it and/or modify it
425 * under the terms of either or both of the following licenses:
426@@ -21,6 +21,7 @@
427 *
428 * Authored by: Jason Smith <jason.smith@canonical.com>
429 * Neil Jagdish Patel <neil.patel@canonical.com>
430+ * Marco Trevisan (Treviño) <3v1n0@ubuntu.com>
431 *
432 */
433 /**
434@@ -34,6 +35,7 @@
435 #include <config.h>
436 #endif
437
438+#include <libbamf-private/bamf-private.h>
439 #include "bamf-application.h"
440 #include "bamf-window.h"
441 #include "bamf-factory.h"
442@@ -41,9 +43,6 @@
443 #include "bamf-view-private.h"
444
445 #include <gio/gdesktopappinfo.h>
446-#include <dbus/dbus.h>
447-#include <dbus/dbus-glib.h>
448-#include <dbus/dbus-glib-lowlevel.h>
449 #include <string.h>
450
451 G_DEFINE_TYPE (BamfApplication, bamf_application, BAMF_TYPE_VIEW);
452@@ -63,13 +62,12 @@
453
454 struct _BamfApplicationPrivate
455 {
456- DBusGConnection *connection;
457- DBusGProxy *proxy;
458- gchar *application_type;
459- gchar *desktop_file;
460- GList *cached_xids;
461- gchar **cached_mimes;
462- int show_stubs;
463+ BamfDBusItemApplication *proxy;
464+ gchar *application_type;
465+ gchar *desktop_file;
466+ GList *cached_xids;
467+ gchar **cached_mimes;
468+ int show_stubs;
469 };
470
471 /**
472@@ -81,31 +79,28 @@
473 gchar **
474 bamf_application_get_supported_mime_types (BamfApplication *application)
475 {
476+ BamfApplicationPrivate *priv;
477 GError *error = NULL;
478- gchar **mimes = NULL;
479-
480- if (application->priv->cached_mimes)
481- return g_strdupv (application->priv->cached_mimes);
482+
483+ g_return_val_if_fail (BAMF_IS_APPLICATION (application), NULL);
484+ priv = application->priv;
485+
486+ if (priv->cached_mimes)
487+ return g_strdupv (priv->cached_mimes);
488
489 if (!_bamf_view_remote_ready (BAMF_VIEW (application)))
490 return NULL;
491
492- if (!dbus_g_proxy_call (application->priv->proxy,
493- "SupportedMimeTypes",
494- &error,
495- G_TYPE_INVALID,
496- G_TYPE_STRV, &mimes,
497- G_TYPE_INVALID))
498+ if (!bamf_dbus_item_application_call_supported_mime_types_sync (priv->proxy,
499+ &priv->cached_mimes,
500+ NULL, &error))
501 {
502- g_warning ("Failed to fetch mimes: %s", error->message);
503+ priv->cached_mimes = NULL;
504+ g_warning ("Failed to fetch mimes: %s", error ? error->message : "");
505 g_error_free (error);
506-
507- return NULL;
508 }
509
510- application->priv->cached_mimes = g_strdupv (mimes);
511-
512- return mimes;
513+ return g_strdupv (priv->cached_mimes);
514 }
515
516 /**
517@@ -133,14 +128,9 @@
518 if (!_bamf_view_remote_ready (BAMF_VIEW (application)))
519 return NULL;
520
521- if (!dbus_g_proxy_call (priv->proxy,
522- "DesktopFile",
523- &error,
524- G_TYPE_INVALID,
525- G_TYPE_STRING, &file,
526- G_TYPE_INVALID))
527+ if (!bamf_dbus_item_application_call_desktop_file_sync (priv->proxy, &file, NULL, &error))
528 {
529- g_warning ("Failed to fetch path: %s", error->message);
530+ g_warning ("Failed to fetch path: %s", error ? error->message : "");
531 g_error_free (error);
532
533 return NULL;
534@@ -158,30 +148,28 @@
535
536 gboolean
537 bamf_application_get_application_menu (BamfApplication *application,
538- gchar **name,
539- gchar **object_path)
540+ gchar **name,
541+ gchar **object_path)
542 {
543 BamfApplicationPrivate *priv;
544 GError *error = NULL;
545-
546+
547 g_return_val_if_fail (BAMF_IS_APPLICATION (application), FALSE);
548-
549+ g_return_val_if_fail (name != NULL && object_path != NULL, FALSE);
550+
551 priv = application->priv;
552-
553+
554 if (!_bamf_view_remote_ready (BAMF_VIEW (application)))
555 return FALSE;
556
557- if (!dbus_g_proxy_call (priv->proxy,
558- "ApplicationMenu",
559- &error,
560- G_TYPE_INVALID,
561- G_TYPE_STRING, name,
562- G_TYPE_STRING, object_path,
563- G_TYPE_INVALID))
564+ if (!bamf_dbus_item_application_call_application_menu_sync (priv->proxy, name, object_path, NULL, &error))
565 {
566- g_warning ("Failed to fetch application menu path: %s", error->message);
567+ *name = NULL;
568+ *object_path = NULL;
569+
570+ g_warning ("Failed to fetch application menu path: %s", error ? error->message : "");
571 g_error_free (error);
572-
573+
574 return FALSE;
575 }
576
577@@ -214,14 +202,9 @@
578 if (!_bamf_view_remote_ready (BAMF_VIEW (application)))
579 return NULL;
580
581- if (!dbus_g_proxy_call (priv->proxy,
582- "ApplicationType",
583- &error,
584- G_TYPE_INVALID,
585- G_TYPE_STRING, &type,
586- G_TYPE_INVALID))
587+ if (!bamf_dbus_item_application_call_application_type_sync (priv->proxy, &type, NULL, &error))
588 {
589- g_warning ("Failed to fetch path: %s", error->message);
590+ g_warning ("Failed to fetch path: %s", error ? error->message : "");
591 g_error_free (error);
592
593 return NULL;
594@@ -243,7 +226,10 @@
595 bamf_application_get_xids (BamfApplication *application)
596 {
597 BamfApplicationPrivate *priv;
598+ GVariantIter *iter;
599+ GVariant *xids_variant;
600 GArray *xids;
601+ guint32 xid;
602 GError *error = NULL;
603
604 g_return_val_if_fail (BAMF_IS_APPLICATION (application), FALSE);
605@@ -252,19 +238,29 @@
606 if (!_bamf_view_remote_ready (BAMF_VIEW (application)))
607 return NULL;
608
609- if (!dbus_g_proxy_call (priv->proxy,
610- "Xids",
611- &error,
612- G_TYPE_INVALID,
613- DBUS_TYPE_G_UINT_ARRAY, &xids,
614- G_TYPE_INVALID))
615+ if (!bamf_dbus_item_application_call_xids_sync (priv->proxy, &xids_variant, NULL, &error))
616 {
617- g_warning ("Failed to fetch xids: %s", error->message);
618+ g_warning ("Failed to fetch xids: %s", error ? error->message : "");
619 g_error_free (error);
620
621 return NULL;
622 }
623
624+ g_return_val_if_fail (xids_variant, NULL);
625+ g_return_val_if_fail (g_variant_type_equal (g_variant_get_type (xids_variant),
626+ G_VARIANT_TYPE ("au")), NULL);
627+
628+ xids = g_array_new (FALSE, TRUE, sizeof (guint32));
629+
630+ g_variant_get (xids_variant, "au", &iter);
631+ while (g_variant_iter_loop (iter, "u", &xid))
632+ {
633+ g_array_append_val (xids, xid);
634+ }
635+
636+ g_variant_iter_free (iter);
637+ g_variant_unref (xids_variant);
638+
639 return xids;
640 }
641
642@@ -325,14 +321,9 @@
643
644 if (priv->show_stubs == -1)
645 {
646- if (!dbus_g_proxy_call (application->priv->proxy,
647- "ShowStubs",
648- &error,
649- G_TYPE_INVALID,
650- G_TYPE_BOOLEAN, &result,
651- G_TYPE_INVALID))
652+ if (!bamf_dbus_item_application_call_show_stubs_sync (priv->proxy, &result, NULL, &error))
653 {
654- g_warning ("Failed to fetch show_stubs: %s", error->message);
655+ g_warning ("Failed to fetch show_stubs: %s", error ? error->message : "");
656 g_error_free (error);
657
658 return TRUE;
659@@ -352,62 +343,10 @@
660 {
661 if (!bamf_view_is_running (view))
662 return BAMF_CLICK_BEHAVIOR_OPEN;
663+
664 return 0;
665 }
666
667-static void
668-bamf_application_on_supported_mime_types_changed (DBusGProxy *proxy, const gchar *const *mimes, BamfApplication *self)
669-{
670- if (self->priv->cached_mimes)
671- g_strfreev (self->priv->cached_mimes);
672-
673- self->priv->cached_mimes = g_strdupv ((gchar**)mimes);
674-}
675-
676-static void
677-bamf_application_on_window_added (DBusGProxy *proxy, char *path, BamfApplication *self)
678-{
679- BamfView *view;
680- BamfFactory *factory;
681-
682- g_return_if_fail (BAMF_IS_APPLICATION (self));
683-
684- factory = _bamf_factory_get_default ();
685- view = _bamf_factory_view_for_path_type (factory, path, BAMF_FACTORY_WINDOW);
686-
687- if (BAMF_IS_WINDOW (view))
688- {
689- guint32 xid = bamf_window_get_xid (BAMF_WINDOW (view));
690-
691- if (!g_list_find (self->priv->cached_xids, GUINT_TO_POINTER (xid)))
692- {
693- self->priv->cached_xids = g_list_prepend (self->priv->cached_xids, GUINT_TO_POINTER (xid));
694- }
695-
696- g_signal_emit (G_OBJECT (self), application_signals[WINDOW_ADDED], 0, view);
697- }
698-}
699-
700-static void
701-bamf_application_on_window_removed (DBusGProxy *proxy, char *path, BamfApplication *self)
702-{
703- BamfView *view;
704- BamfFactory *factory;
705-
706- g_return_if_fail (BAMF_IS_APPLICATION (self));
707-
708- factory = _bamf_factory_get_default ();
709- view = _bamf_factory_view_for_path_type (factory, path, BAMF_FACTORY_WINDOW);
710-
711- if (BAMF_IS_WINDOW (view))
712- {
713- guint32 xid = bamf_window_get_xid (BAMF_WINDOW (view));
714- self->priv->cached_xids = g_list_remove (self->priv->cached_xids, GUINT_TO_POINTER (xid));
715-
716- g_signal_emit (G_OBJECT (self), application_signals[WINDOW_REMOVED], 0, view);
717- }
718-}
719-
720 /**
721 * bamf_application_get_focusable_child:
722 * @application: a #BamfApplication
723@@ -424,30 +363,68 @@
724
725 g_return_val_if_fail (BAMF_IS_APPLICATION (application), FALSE);
726 priv = application->priv;
727-
728+
729 if (!_bamf_view_remote_ready (BAMF_VIEW (application)))
730 return NULL;
731
732- if (!dbus_g_proxy_call (priv->proxy,
733- "FocusableChild",
734- &error,
735- G_TYPE_INVALID,
736- G_TYPE_STRING, &path,
737- G_TYPE_INVALID))
738+ if (!bamf_dbus_item_application_call_focusable_child_sync (priv->proxy, &path, NULL, &error))
739 {
740- g_warning ("Failed to fetch focus xids: %s", error->message);
741+ g_warning ("Failed to fetch focusable child: %s", error ? error->message : "");
742 g_error_free (error);
743-
744+
745 return NULL;
746 }
747
748 ret = _bamf_factory_view_for_path (_bamf_factory_get_default (), path);
749-
750 g_free (path);
751-
752+
753 return ret;
754 }
755
756+static void
757+bamf_application_on_window_added (BamfDBusItemApplication *proxy, const char *path, BamfApplication *self)
758+{
759+ BamfView *view;
760+ BamfFactory *factory;
761+
762+ g_return_if_fail (BAMF_IS_APPLICATION (self));
763+
764+ factory = _bamf_factory_get_default ();
765+ view = _bamf_factory_view_for_path_type (factory, path, BAMF_FACTORY_WINDOW);
766+
767+ if (BAMF_IS_WINDOW (view))
768+ {
769+ guint32 xid = bamf_window_get_xid (BAMF_WINDOW (view));
770+
771+ if (!g_list_find (self->priv->cached_xids, GUINT_TO_POINTER (xid)))
772+ {
773+ self->priv->cached_xids = g_list_prepend (self->priv->cached_xids, GUINT_TO_POINTER (xid));
774+ }
775+
776+ g_signal_emit (G_OBJECT (self), application_signals[WINDOW_ADDED], 0, view);
777+ }
778+}
779+
780+static void
781+bamf_application_on_window_removed (BamfDBusItemApplication *proxy, const char *path, BamfApplication *self)
782+{
783+ BamfView *view;
784+ BamfFactory *factory;
785+
786+ g_return_if_fail (BAMF_IS_APPLICATION (self));
787+
788+ factory = _bamf_factory_get_default ();
789+ view = _bamf_factory_view_for_path_type (factory, path, BAMF_FACTORY_WINDOW);
790+
791+ if (BAMF_IS_WINDOW (view))
792+ {
793+ guint32 xid = bamf_window_get_xid (BAMF_WINDOW (view));
794+ self->priv->cached_xids = g_list_remove (self->priv->cached_xids, GUINT_TO_POINTER (xid));
795+
796+ g_signal_emit (G_OBJECT (self), application_signals[WINDOW_REMOVED], 0, view);
797+ }
798+}
799+
800 GList *
801 _bamf_application_get_cached_xids (BamfApplication *self)
802 {
803@@ -457,6 +434,15 @@
804 }
805
806 static void
807+bamf_application_on_supported_mime_types_changed (BamfDBusItemApplication *proxy, const gchar *const *mimes, BamfApplication *self)
808+{
809+ if (self->priv->cached_mimes)
810+ g_strfreev (self->priv->cached_mimes);
811+
812+ self->priv->cached_mimes = g_strdupv ((gchar**)mimes);
813+}
814+
815+static void
816 bamf_application_unset_proxy (BamfApplication* self)
817 {
818 BamfApplicationPrivate *priv;
819@@ -464,25 +450,12 @@
820 g_return_if_fail (BAMF_IS_APPLICATION (self));
821 priv = self->priv;
822
823- if (!priv->proxy)
824- return;
825-
826- dbus_g_proxy_disconnect_signal (priv->proxy,
827- "WindowAdded",
828- (GCallback) bamf_application_on_window_added,
829- self);
830-
831- dbus_g_proxy_disconnect_signal (priv->proxy,
832- "WindowRemoved",
833- (GCallback) bamf_application_on_window_removed,
834- self);
835- dbus_g_proxy_disconnect_signal (priv->proxy,
836- "SupportedMimeTypesChanged",
837- (GCallback) bamf_application_on_supported_mime_types_changed,
838- self);
839-
840- g_object_unref (priv->proxy);
841- priv->proxy = NULL;
842+ if (G_IS_DBUS_PROXY (priv->proxy))
843+ {
844+ g_signal_handlers_disconnect_by_data (priv->proxy, self);
845+ g_object_unref (priv->proxy);
846+ priv->proxy = NULL;
847+ }
848 }
849
850 static void
851@@ -511,7 +484,7 @@
852 g_list_free (priv->cached_xids);
853 priv->cached_xids = NULL;
854 }
855-
856+
857 bamf_application_unset_proxy (self);
858
859 if (G_OBJECT_CLASS (bamf_application_parent_class)->dispose)
860@@ -523,54 +496,31 @@
861 {
862 BamfApplication *self;
863 BamfApplicationPrivate *priv;
864+ GError *error = NULL;
865
866 self = BAMF_APPLICATION (view);
867 priv = self->priv;
868
869 bamf_application_unset_proxy (self);
870+ priv->proxy = bamf_dbus_item_application_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
871+ G_DBUS_PROXY_FLAGS_NONE,
872+ BAMF_DBUS_SERVICE_NAME,
873+ path, NULL, &error);
874
875- priv->proxy = dbus_g_proxy_new_for_name (priv->connection,
876- "org.ayatana.bamf",
877- path,
878- "org.ayatana.bamf.application");
879- if (priv->proxy == NULL)
880+ if (!G_IS_DBUS_PROXY (priv->proxy))
881 {
882- g_critical ("Unable to get org.ayatana.bamf.application application");
883+ g_critical ("Unable to get "BAMF_DBUS_SERVICE_NAME" application: %s", error ? error->message : "");
884 return;
885 }
886
887- dbus_g_proxy_add_signal (priv->proxy,
888- "WindowAdded",
889- G_TYPE_STRING,
890- G_TYPE_INVALID);
891-
892- dbus_g_proxy_add_signal (priv->proxy,
893- "WindowRemoved",
894- G_TYPE_STRING,
895- G_TYPE_INVALID);
896-
897- dbus_g_proxy_add_signal (priv->proxy,
898- "SupportedMimeTypesChanged",
899- G_TYPE_STRV,
900- G_TYPE_INVALID);
901-
902- dbus_g_proxy_connect_signal (priv->proxy,
903- "WindowAdded",
904- (GCallback) bamf_application_on_window_added,
905- self,
906- NULL);
907-
908- dbus_g_proxy_connect_signal (priv->proxy,
909- "WindowRemoved",
910- (GCallback) bamf_application_on_window_removed,
911- self,
912- NULL);
913-
914- dbus_g_proxy_connect_signal (priv->proxy,
915- "SupportedMimeTypesChanged",
916- (GCallback) bamf_application_on_supported_mime_types_changed,
917- self,
918- NULL);
919+ g_signal_connect (priv->proxy, "window-added",
920+ G_CALLBACK (bamf_application_on_window_added), view);
921+
922+ g_signal_connect (priv->proxy, "window-removed",
923+ G_CALLBACK (bamf_application_on_window_removed), view);
924+
925+ g_signal_connect (priv->proxy, "supported-mime-types-changed",
926+ G_CALLBACK (bamf_application_on_supported_mime_types_changed), view);
927
928 GList *children, *l;
929 children = bamf_view_get_children (view);
930@@ -617,23 +567,23 @@
931 name = g_strdup (g_app_info_get_name (G_APP_INFO (desktop_info)));
932
933 if (g_key_file_has_key(keyfile, G_KEY_FILE_DESKTOP_GROUP, "X-GNOME-FullName", NULL))
934- {
935- /* Grab the better name if its available */
936- gchar *fullname = NULL;
937- error = NULL;
938- fullname = g_key_file_get_locale_string (keyfile, G_KEY_FILE_DESKTOP_GROUP, "X-GNOME-FullName", NULL, &error);
939- if (error != NULL)
940- {
941- g_error_free (error);
942- if (fullname)
943- g_free (fullname);
944- }
945- else
946- {
947- g_free (name);
948- name = fullname;
949- }
950- }
951+ {
952+ /* Grab the better name if its available */
953+ gchar *fullname = NULL;
954+ error = NULL;
955+ fullname = g_key_file_get_locale_string (keyfile, G_KEY_FILE_DESKTOP_GROUP, "X-GNOME-FullName", NULL, &error);
956+ if (error != NULL)
957+ {
958+ g_error_free (error);
959+ if (fullname)
960+ g_free (fullname);
961+ }
962+ else
963+ {
964+ g_free (name);
965+ name = fullname;
966+ }
967+ }
968
969 _bamf_view_set_name (BAMF_VIEW (self), name);
970
971@@ -663,22 +613,22 @@
972 g_type_class_add_private (obj_class, sizeof (BamfApplicationPrivate));
973
974 application_signals [WINDOW_ADDED] =
975- g_signal_new ("window-added",
976- G_OBJECT_CLASS_TYPE (klass),
977- 0,
978- 0, NULL, NULL,
979- g_cclosure_marshal_VOID__OBJECT,
980- G_TYPE_NONE, 1,
981- BAMF_TYPE_VIEW);
982+ g_signal_new (BAMF_APPLICATION_SIGNAL_WINDOW_ADDED,
983+ G_OBJECT_CLASS_TYPE (klass),
984+ 0,
985+ 0, NULL, NULL,
986+ g_cclosure_marshal_VOID__OBJECT,
987+ G_TYPE_NONE, 1,
988+ BAMF_TYPE_VIEW);
989
990 application_signals [WINDOW_REMOVED] =
991- g_signal_new ("window-removed",
992- G_OBJECT_CLASS_TYPE (klass),
993- 0,
994- 0, NULL, NULL,
995- g_cclosure_marshal_VOID__OBJECT,
996- G_TYPE_NONE, 1,
997- BAMF_TYPE_VIEW);
998+ g_signal_new (BAMF_APPLICATION_SIGNAL_WINDOW_REMOVED,
999+ G_OBJECT_CLASS_TYPE (klass),
1000+ 0,
1001+ 0, NULL, NULL,
1002+ g_cclosure_marshal_VOID__OBJECT,
1003+ G_TYPE_NONE, 1,
1004+ BAMF_TYPE_VIEW);
1005 }
1006
1007
1008@@ -686,20 +636,9 @@
1009 bamf_application_init (BamfApplication *self)
1010 {
1011 BamfApplicationPrivate *priv;
1012- GError *error = NULL;
1013
1014 priv = self->priv = BAMF_APPLICATION_GET_PRIVATE (self);
1015 priv->show_stubs = -1;
1016-
1017- priv->connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
1018- if (priv->connection == NULL)
1019- {
1020- g_critical ("Failed to open connection to bus: %s",
1021- error != NULL ? error->message : "Unknown");
1022- if (error)
1023- g_error_free (error);
1024- return;
1025- }
1026 }
1027
1028 BamfApplication *
1029
1030=== modified file 'lib/libbamf/bamf-application.h'
1031--- lib/libbamf/bamf-application.h 2012-08-21 22:02:12 +0000
1032+++ lib/libbamf/bamf-application.h 2013-05-15 12:27:29 +0000
1033@@ -1,5 +1,5 @@
1034 /*
1035- * Copyright 2010 Canonical Ltd.
1036+ * Copyright 2010-2011 Canonical Ltd.
1037 *
1038 * This program is free software: you can redistribute it and/or modify it
1039 * under the terms of either or both of the following licenses:
1040@@ -21,6 +21,7 @@
1041 *
1042 * Authored by: Jason Smith <jason.smith@canonical.com>
1043 * Neil Jagdish Patel <neil.patel@canonical.com>
1044+ * Marco Trevisan (Treviño) <3v1n0@ubuntu.com>
1045 *
1046 */
1047
1048@@ -49,6 +50,9 @@
1049 #define BAMF_APPLICATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),\
1050 BAMF_TYPE_APPLICATION, BamfApplicationClass))
1051
1052+#define BAMF_APPLICATION_SIGNAL_WINDOW_ADDED "window-added"
1053+#define BAMF_APPLICATION_SIGNAL_WINDOW_REMOVED "window-removed"
1054+
1055 typedef struct _BamfApplication BamfApplication;
1056 typedef struct _BamfApplicationClass BamfApplicationClass;
1057 typedef struct _BamfApplicationPrivate BamfApplicationPrivate;
1058
1059=== modified file 'lib/libbamf/bamf-control.c'
1060--- lib/libbamf/bamf-control.c 2012-12-18 01:53:22 +0000
1061+++ lib/libbamf/bamf-control.c 2013-05-15 12:27:29 +0000
1062@@ -1,5 +1,5 @@
1063 /*
1064- * Copyright 2010 Canonical Ltd.
1065+ * Copyright 2010-2012 Canonical Ltd.
1066 *
1067 * This program is free software: you can redistribute it and/or modify it
1068 * under the terms of either or both of the following licenses:
1069@@ -21,6 +21,7 @@
1070 *
1071 * Authored by: Jason Smith <jason.smith@canonical.com>
1072 * Neil Jagdish Patel <neil.patel@canonical.com>
1073+ * Marco Trevisan (Treviño) <3v1n0@ubuntu.com>
1074 *
1075 */
1076 /**
1077@@ -34,11 +35,9 @@
1078 #include <config.h>
1079 #endif
1080
1081+#include <libbamf-private/bamf-private.h>
1082 #include "bamf-control.h"
1083
1084-#include <dbus/dbus.h>
1085-#include <dbus/dbus-glib.h>
1086-
1087 G_DEFINE_TYPE (BamfControl, bamf_control, G_TYPE_OBJECT);
1088
1089 #define BAMF_CONTROL_GET_PRIVATE(o) \
1090@@ -46,8 +45,7 @@
1091
1092 struct _BamfControlPrivate
1093 {
1094- DBusGConnection *connection;
1095- DBusGProxy *proxy;
1096+ BamfDBusControl *proxy;
1097 };
1098
1099 /* Globals */
1100@@ -70,20 +68,28 @@
1101 self->priv->proxy = NULL;
1102 }
1103
1104- if (G_OBJECT_CLASS (bamf_control_parent_class)->dispose)
1105- G_OBJECT_CLASS (bamf_control_parent_class)->dispose (object);
1106+ G_OBJECT_CLASS (bamf_control_parent_class)->dispose (object);
1107+}
1108+
1109+static void
1110+bamf_control_finalize (GObject *object)
1111+{
1112+ default_control = NULL;
1113+
1114+ G_OBJECT_CLASS (bamf_control_parent_class)->finalize (object);
1115 }
1116
1117 static void
1118 bamf_control_class_init (BamfControlClass *klass)
1119 {
1120 GObjectClass *obj_class = G_OBJECT_CLASS (klass);
1121+ obj_class->dispose = bamf_control_dispose;
1122+ obj_class->finalize = bamf_control_finalize;
1123
1124 g_type_class_add_private (obj_class, sizeof (BamfControlPrivate));
1125 obj_class->dispose = bamf_control_dispose;
1126 }
1127
1128-
1129 static void
1130 bamf_control_init (BamfControl *self)
1131 {
1132@@ -92,23 +98,16 @@
1133
1134 priv = self->priv = BAMF_CONTROL_GET_PRIVATE (self);
1135
1136- priv->connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
1137- if (priv->connection == NULL)
1138- {
1139- g_warning ("Failed to open connection to bus: %s",
1140- error != NULL ? error->message : "Unknown");
1141- if (error)
1142- g_error_free (error);
1143- return;
1144- }
1145+ priv->proxy = bamf_dbus_control_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
1146+ G_DBUS_PROXY_FLAGS_NONE,
1147+ BAMF_DBUS_SERVICE_NAME,
1148+ BAMF_DBUS_CONTROL_PATH,
1149+ NULL, &error);
1150
1151- priv->proxy = dbus_g_proxy_new_for_name (priv->connection,
1152- "org.ayatana.bamf",
1153- "/org/ayatana/bamf/control",
1154- "org.ayatana.bamf.control");
1155- if (priv->proxy == NULL)
1156+ if (error)
1157 {
1158- g_error ("Unable to get org.bamf.Control control");
1159+ g_error ("Unable to get "BAMF_DBUS_CONTROL_PATH" controller: %s", error->message);
1160+ g_error_free (error);
1161 }
1162 }
1163
1164@@ -127,8 +126,7 @@
1165 }
1166
1167 void
1168-bamf_control_insert_desktop_file (BamfControl *control,
1169- const gchar *desktop_file)
1170+bamf_control_insert_desktop_file (BamfControl *control, const gchar *desktop_file)
1171 {
1172 BamfControlPrivate *priv;
1173 GError *error = NULL;
1174@@ -136,12 +134,9 @@
1175 g_return_if_fail (BAMF_IS_CONTROL (control));
1176 priv = control->priv;
1177
1178- if (!dbus_g_proxy_call (priv->proxy,
1179- "OmNomNomDesktopFile",
1180- &error,
1181- G_TYPE_STRING, desktop_file,
1182- G_TYPE_INVALID,
1183- G_TYPE_INVALID))
1184+ if (!bamf_dbus_control_call_om_nom_nom_desktop_file_sync (priv->proxy,
1185+ desktop_file,
1186+ NULL, &error))
1187 {
1188 g_warning ("Failed to insert desktop file: %s", error->message);
1189 g_error_free (error);
1190@@ -150,7 +145,7 @@
1191
1192 void
1193 bamf_control_register_application_for_pid (BamfControl *control,
1194- const gchar *application,
1195+ const gchar *desktop_file,
1196 gint32 pid)
1197 {
1198 BamfControlPrivate *priv;
1199@@ -159,13 +154,10 @@
1200 g_return_if_fail (BAMF_IS_CONTROL (control));
1201 priv = control->priv;
1202
1203- if (!dbus_g_proxy_call (priv->proxy,
1204- "RegisterApplicationForPid",
1205- &error,
1206- G_TYPE_STRING, application,
1207- G_TYPE_INT, pid,
1208- G_TYPE_INVALID,
1209- G_TYPE_INVALID))
1210+ if (!bamf_dbus_control_call_register_application_for_pid_sync (priv->proxy,
1211+ desktop_file,
1212+ pid, NULL,
1213+ &error))
1214 {
1215 g_warning ("Failed to register application: %s", error->message);
1216 g_error_free (error);
1217@@ -173,7 +165,18 @@
1218 }
1219
1220 void
1221-bamf_control_register_tab_provider (BamfControl *control,
1222- const char *path)
1223+bamf_control_register_tab_provider (BamfControl *control, const char *path)
1224 {
1225+ BamfControlPrivate *priv;
1226+ GError *error = NULL;
1227+
1228+ g_return_if_fail (BAMF_IS_CONTROL (control));
1229+ priv = control->priv;
1230+
1231+ if (!bamf_dbus_control_call_register_tab_provider_sync (priv->proxy, path,
1232+ NULL, &error))
1233+ {
1234+ g_warning ("Failed to register tab provider: %s", error->message);
1235+ g_error_free (error);
1236+ }
1237 }
1238
1239=== modified file 'lib/libbamf/bamf-control.h'
1240--- lib/libbamf/bamf-control.h 2012-12-18 01:53:22 +0000
1241+++ lib/libbamf/bamf-control.h 2013-05-15 12:27:29 +0000
1242@@ -1,5 +1,5 @@
1243 /*
1244- * Copyright 2010 Canonical Ltd.
1245+ * Copyright 2010-2011 Canonical Ltd.
1246 *
1247 * This program is free software: you can redistribute it and/or modify it
1248 * under the terms of either or both of the following licenses:
1249@@ -21,6 +21,7 @@
1250 *
1251 * Authored by: Jason Smith <jason.smith@canonical.com>
1252 * Neil Jagdish Patel <neil.patel@canonical.com>
1253+ * Marco Trevisan (Treviño) <3v1n0@ubuntu.com>
1254 *
1255 */
1256
1257@@ -80,11 +81,13 @@
1258 const gchar *desktop_file);
1259
1260 void bamf_control_register_application_for_pid (BamfControl *control,
1261- const gchar *application,
1262+ const gchar *desktop_file,
1263 gint32 pid);
1264
1265 void bamf_control_register_tab_provider (BamfControl *control,
1266 const char *path);
1267+void bamf_control_set_approver_behavior (BamfControl *control,
1268+ gint32 behavior);
1269
1270 G_END_DECLS
1271 #endif
1272
1273=== modified file 'lib/libbamf/bamf-factory.c'
1274--- lib/libbamf/bamf-factory.c 2012-12-18 01:53:22 +0000
1275+++ lib/libbamf/bamf-factory.c 2013-05-15 12:27:29 +0000
1276@@ -1,5 +1,5 @@
1277 /*
1278- * Copyright 2010 Canonical Ltd.
1279+ * Copyright 2010-2012 Canonical Ltd.
1280 *
1281 * This program is free software: you can redistribute it and/or modify it
1282 * under the terms of either or both of the following licenses:
1283@@ -21,6 +21,7 @@
1284 *
1285 * Authored by: Jason Smith <jason.smith@canonical.com>
1286 * Neil Jagdish Patel <neil.patel@canonical.com>
1287+ * Marco Trevisan (Treviño) <3v1n0@ubuntu.com>
1288 *
1289 */
1290 /**
1291@@ -34,6 +35,7 @@
1292 #include <config.h>
1293 #endif
1294
1295+#include <libbamf-private/bamf-private.h>
1296 #include "bamf-factory.h"
1297 #include "bamf-view.h"
1298 #include "bamf-view-private.h"
1299@@ -42,11 +44,6 @@
1300 #include "bamf-application-private.h"
1301 #include "bamf-tab.h"
1302
1303-#include <dbus/dbus.h>
1304-#include <dbus/dbus-glib.h>
1305-#include <dbus/dbus-glib-lowlevel.h>
1306-#include <string.h>
1307-
1308 G_DEFINE_TYPE (BamfFactory, bamf_factory, G_TYPE_OBJECT);
1309
1310 #define BAMF_FACTORY_GET_PRIVATE(o) \
1311@@ -68,10 +65,47 @@
1312 BamfWindow * bamf_window_new (const char *path);
1313
1314 static void
1315+bamf_factory_dispose (GObject *object)
1316+{
1317+ BamfFactory *self = (BamfFactory *) object;
1318+
1319+ if (self->priv->views)
1320+ {
1321+ g_hash_table_destroy (self->priv->views);
1322+ self->priv->views = NULL;
1323+ }
1324+
1325+ if (self->priv->registered_views)
1326+ {
1327+ g_list_free (self->priv->registered_views);
1328+ self->priv->registered_views = NULL;
1329+ }
1330+
1331+ if (self->priv->local_views)
1332+ {
1333+ g_list_free_full (self->priv->local_views, g_object_unref);
1334+ self->priv->local_views = NULL;
1335+ }
1336+
1337+ G_OBJECT_CLASS (bamf_factory_parent_class)->dispose (object);
1338+}
1339+
1340+static void
1341+bamf_factory_finalize (GObject *object)
1342+{
1343+ factory = NULL;
1344+
1345+ G_OBJECT_CLASS (bamf_factory_parent_class)->finalize (object);
1346+}
1347+
1348+static void
1349 bamf_factory_class_init (BamfFactoryClass *klass)
1350 {
1351 GObjectClass *obj_class = G_OBJECT_CLASS (klass);
1352
1353+ obj_class->dispose = bamf_factory_dispose;
1354+ obj_class->finalize = bamf_factory_finalize;
1355+
1356 g_type_class_add_private (obj_class, sizeof (BamfFactoryPrivate));
1357 }
1358
1359@@ -83,20 +117,21 @@
1360
1361 priv = self->priv = BAMF_FACTORY_GET_PRIVATE (self);
1362
1363- priv->views = g_hash_table_new_full ((GHashFunc) g_str_hash, (GEqualFunc) g_str_equal, (GDestroyNotify) g_free, NULL);
1364+ priv->views = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
1365 }
1366
1367 static void
1368 on_view_closed (BamfView *view, BamfFactory *self)
1369 {
1370 const char *path;
1371-
1372+
1373 g_return_if_fail (BAMF_IS_VIEW (view));
1374-
1375+
1376 path = _bamf_view_get_path (view);
1377+
1378 if (path)
1379 g_hash_table_remove (self->priv->views, path);
1380-
1381+
1382 g_object_unref (view);
1383 }
1384
1385@@ -104,6 +139,7 @@
1386 on_view_weak_unref (BamfFactory *self, BamfView *view)
1387 {
1388 g_return_if_fail (BAMF_IS_FACTORY (self));
1389+
1390 self->priv->local_views = g_list_remove (self->priv->local_views, view);
1391 self->priv->registered_views = g_list_remove (self->priv->registered_views, view);
1392 }
1393@@ -113,26 +149,26 @@
1394 {
1395 GHashTable *views;
1396 views = self->priv->views;
1397-
1398+
1399 g_hash_table_insert (views, g_strdup (path), view);
1400
1401 if (g_list_find (self->priv->registered_views, view))
1402 return;
1403-
1404- self->priv->registered_views = g_list_prepend (self->priv->registered_views, view);
1405-
1406+
1407 g_signal_connect (G_OBJECT (view), "closed", (GCallback) on_view_closed, self);
1408 g_object_weak_ref (G_OBJECT (view), (GWeakNotify) on_view_weak_unref, self);
1409+
1410+ self->priv->registered_views = g_list_prepend (self->priv->registered_views, view);
1411 }
1412
1413-BamfApplication *
1414+BamfApplication *
1415 _bamf_factory_app_for_file (BamfFactory * factory,
1416- const char * path,
1417- gboolean create)
1418+ const char * path,
1419+ gboolean create)
1420 {
1421 BamfApplication *result = NULL, *app;
1422 GList *l;
1423-
1424+
1425 /* check if result is available in known local_views */
1426 for (l = factory->priv->local_views; l; l = l->next)
1427 {
1428@@ -146,16 +182,18 @@
1429 break;
1430 }
1431 }
1432-
1433+
1434 /* else create new */
1435 if (!result && create)
1436 {
1437 /* delay registration until match time */
1438 result = bamf_application_new_favorite (path);
1439- if (result)
1440- factory->priv->local_views = g_list_prepend (factory->priv->local_views, result);
1441+ if (result && !g_list_find (factory->priv->local_views, result))
1442+ {
1443+ factory->priv->local_views = g_list_prepend (factory->priv->local_views, result);
1444+ }
1445 }
1446-
1447+
1448 return result;
1449 }
1450
1451@@ -174,28 +212,28 @@
1452 {
1453 factory_type = BAMF_FACTORY_APPLICATION;
1454 }
1455+ else if (g_strcmp0 (type, "tab") == 0)
1456+ {
1457+ factory_type = BAMF_FACTORY_TAB;
1458+ }
1459 else if (g_strcmp0 (type, "view") == 0)
1460 {
1461 factory_type = BAMF_FACTORY_VIEW;
1462 }
1463- else if (g_strcmp0 (type, "tab") == 0)
1464- {
1465- factory_type = BAMF_FACTORY_TAB;
1466- }
1467 }
1468
1469 return factory_type;
1470 }
1471
1472-BamfView *
1473+BamfView *
1474 _bamf_factory_view_for_path (BamfFactory * factory, const char * path)
1475 {
1476 return _bamf_factory_view_for_path_type (factory, path, BAMF_FACTORY_NONE);
1477 }
1478
1479-BamfView *
1480+BamfView *
1481 _bamf_factory_view_for_path_type_str (BamfFactory * factory, const char * path,
1482- const char * type)
1483+ const char * type)
1484 {
1485 g_return_val_if_fail (BAMF_IS_FACTORY (factory), NULL);
1486 BamfFactoryViewType factory_type = compute_factory_type_by_str (type);
1487@@ -209,27 +247,37 @@
1488 {
1489 GHashTable *views;
1490 BamfView *view;
1491+ BamfDBusItemView *vproxy;
1492 GList *l;
1493 gboolean created = FALSE;
1494
1495 g_return_val_if_fail (BAMF_IS_FACTORY (factory), NULL);
1496-
1497+
1498 if (!path || path[0] == '\0')
1499 return NULL;
1500-
1501+
1502 views = factory->priv->views;
1503 view = g_hash_table_lookup (views, path);
1504-
1505+
1506 if (BAMF_IS_VIEW (view))
1507 return view;
1508
1509+ view = NULL;
1510+
1511 if (type == BAMF_FACTORY_NONE)
1512 {
1513- view = g_object_new (BAMF_TYPE_VIEW, NULL);
1514- _bamf_view_set_path (view, path);
1515- type = compute_factory_type_by_str (bamf_view_get_view_type (view));
1516- g_object_unref (view);
1517- view = NULL;
1518+ vproxy = bamf_dbus_item_view_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
1519+ G_DBUS_PROXY_FLAGS_NONE,
1520+ BAMF_DBUS_SERVICE_NAME,
1521+ path, NULL, NULL);
1522+ if (G_IS_DBUS_PROXY (vproxy))
1523+ {
1524+ char *type_str = NULL;
1525+ bamf_dbus_item_view_call_view_type_sync (vproxy, &type_str, NULL, NULL);
1526+ type = compute_factory_type_by_str (type_str);
1527+ g_free (type_str);
1528+ g_object_unref (vproxy);
1529+ }
1530 }
1531
1532 switch (type)
1533@@ -338,7 +386,7 @@
1534 if (view)
1535 {
1536 bamf_factory_register_view (factory, view, path);
1537-
1538+
1539 if (created)
1540 {
1541 factory->priv->local_views = g_list_prepend (factory->priv->local_views, view);
1542@@ -349,13 +397,12 @@
1543 return view;
1544 }
1545
1546-BamfFactory *
1547+BamfFactory *
1548 _bamf_factory_get_default (void)
1549 {
1550-
1551 if (BAMF_IS_FACTORY (factory))
1552 return factory;
1553-
1554+
1555 factory = (BamfFactory *) g_object_new (BAMF_TYPE_FACTORY, NULL);
1556 return factory;
1557 }
1558
1559=== modified file 'lib/libbamf/bamf-factory.h'
1560--- lib/libbamf/bamf-factory.h 2012-12-18 01:53:22 +0000
1561+++ lib/libbamf/bamf-factory.h 2013-05-15 12:27:29 +0000
1562@@ -21,6 +21,7 @@
1563 *
1564 * Authored by: Jason Smith <jason.smith@canonical.com>
1565 * Neil Jagdish Patel <neil.patel@canonical.com>
1566+ * Marco Trevisan (Treviño) <3v1n0@ubuntu.com>
1567 *
1568 */
1569
1570
1571=== modified file 'lib/libbamf/bamf-matcher.c'
1572--- lib/libbamf/bamf-matcher.c 2012-11-13 20:44:23 +0000
1573+++ lib/libbamf/bamf-matcher.c 2013-05-15 12:27:29 +0000
1574@@ -1,5 +1,5 @@
1575 /*
1576- * Copyright 2010 Canonical Ltd.
1577+ * Copyright 2010-2012 Canonical Ltd.
1578 *
1579 * This program is free software: you can redistribute it and/or modify it
1580 * under the terms of either or both of the following licenses:
1581@@ -21,6 +21,7 @@
1582 *
1583 * Authored by: Jason Smith <jason.smith@canonical.com>
1584 * Neil Jagdish Patel <neil.patel@canonical.com>
1585+ * Marco Trevisan (Treviño) <3v1n0@ubuntu.com>
1586 *
1587 */
1588 /**
1589@@ -34,17 +35,14 @@
1590 #include <config.h>
1591 #endif
1592
1593+#include <libbamf-private/bamf-private.h>
1594 #include "bamf-matcher.h"
1595+#include "bamf-tab.h"
1596 #include "bamf-view.h"
1597 #include "bamf-view-private.h"
1598 #include "bamf-factory.h"
1599 #include "bamf-marshal.h"
1600
1601-#include <string.h>
1602-#include <dbus/dbus.h>
1603-#include <dbus/dbus-glib.h>
1604-#include <dbus/dbus-glib-lowlevel.h>
1605-
1606 G_DEFINE_TYPE (BamfMatcher, bamf_matcher, G_TYPE_OBJECT);
1607
1608 #define BAMF_MATCHER_GET_PRIVATE(o) \
1609@@ -57,7 +55,6 @@
1610 ACTIVE_APPLICATION_CHANGED,
1611 ACTIVE_WINDOW_CHANGED,
1612 STACKING_ORDER_CHANGED,
1613-
1614 LAST_SIGNAL,
1615 };
1616
1617@@ -65,8 +62,7 @@
1618
1619 struct _BamfMatcherPrivate
1620 {
1621- DBusGConnection *connection;
1622- DBusGProxy *proxy;
1623+ BamfDBusMatcher *proxy;
1624 };
1625
1626 static BamfMatcher * default_matcher = NULL;
1627@@ -90,45 +86,44 @@
1628 obj_class->dispose = bamf_matcher_dispose;
1629 obj_class->finalize = bamf_matcher_finalize;
1630
1631- matcher_signals [VIEW_OPENED] =
1632- g_signal_new ("view-opened",
1633- G_OBJECT_CLASS_TYPE (klass),
1634- 0,
1635- 0, NULL, NULL,
1636- g_cclosure_marshal_VOID__OBJECT,
1637- G_TYPE_NONE, 1,
1638- BAMF_TYPE_VIEW);
1639-
1640- matcher_signals [VIEW_CLOSED] =
1641- g_signal_new ("view-closed",
1642- G_OBJECT_CLASS_TYPE (klass),
1643- 0,
1644- 0, NULL, NULL,
1645- g_cclosure_marshal_VOID__OBJECT,
1646- G_TYPE_NONE, 1,
1647- BAMF_TYPE_VIEW);
1648-
1649-
1650- matcher_signals [ACTIVE_APPLICATION_CHANGED] =
1651- g_signal_new ("active-application-changed",
1652- G_OBJECT_CLASS_TYPE (klass),
1653- 0,
1654- 0, NULL, NULL,
1655- _bamf_marshal_VOID__OBJECT_OBJECT,
1656- G_TYPE_NONE, 2,
1657- BAMF_TYPE_VIEW, BAMF_TYPE_VIEW);
1658-
1659- matcher_signals [ACTIVE_WINDOW_CHANGED] =
1660- g_signal_new ("active-window-changed",
1661- G_OBJECT_CLASS_TYPE (klass),
1662- 0,
1663- 0, NULL, NULL,
1664- _bamf_marshal_VOID__OBJECT_OBJECT,
1665- G_TYPE_NONE, 2,
1666- BAMF_TYPE_VIEW, BAMF_TYPE_VIEW);
1667-
1668- matcher_signals [STACKING_ORDER_CHANGED] =
1669- g_signal_new ("stacking-order-changed",
1670+ matcher_signals [VIEW_OPENED] =
1671+ g_signal_new (BAMF_MATCHER_SIGNAL_VIEW_OPENED,
1672+ G_OBJECT_CLASS_TYPE (klass),
1673+ 0,
1674+ 0, NULL, NULL,
1675+ g_cclosure_marshal_VOID__OBJECT,
1676+ G_TYPE_NONE, 1,
1677+ BAMF_TYPE_VIEW);
1678+
1679+ matcher_signals [VIEW_CLOSED] =
1680+ g_signal_new (BAMF_MATCHER_SIGNAL_VIEW_CLOSED,
1681+ G_OBJECT_CLASS_TYPE (klass),
1682+ 0,
1683+ 0, NULL, NULL,
1684+ g_cclosure_marshal_VOID__OBJECT,
1685+ G_TYPE_NONE, 1,
1686+ BAMF_TYPE_VIEW);
1687+
1688+ matcher_signals [ACTIVE_APPLICATION_CHANGED] =
1689+ g_signal_new (BAMF_MATCHER_SIGNAL_ACTIVE_APPLICATION_CHANGED,
1690+ G_OBJECT_CLASS_TYPE (klass),
1691+ 0,
1692+ 0, NULL, NULL,
1693+ _bamf_marshal_VOID__OBJECT_OBJECT,
1694+ G_TYPE_NONE, 2,
1695+ BAMF_TYPE_VIEW, BAMF_TYPE_VIEW);
1696+
1697+ matcher_signals [ACTIVE_WINDOW_CHANGED] =
1698+ g_signal_new (BAMF_MATCHER_SIGNAL_ACTIVE_WINDOW_CHANGED,
1699+ G_OBJECT_CLASS_TYPE (klass),
1700+ 0,
1701+ 0, NULL, NULL,
1702+ _bamf_marshal_VOID__OBJECT_OBJECT,
1703+ G_TYPE_NONE, 2,
1704+ G_TYPE_OBJECT, G_TYPE_OBJECT);
1705+
1706+ matcher_signals [STACKING_ORDER_CHANGED] =
1707+ g_signal_new (BAMF_MATCHER_SIGNAL_STACKING_ORDER_CHANGED,
1708 G_OBJECT_CLASS_TYPE (klass),
1709 0,
1710 0, NULL, NULL,
1711@@ -138,9 +133,9 @@
1712
1713
1714 static void
1715-bamf_matcher_on_view_opened (DBusGProxy *proxy,
1716- char *path,
1717- char *type,
1718+bamf_matcher_on_view_opened (BamfDBusMatcher *proxy,
1719+ const char *path,
1720+ const char *type,
1721 BamfMatcher *matcher)
1722 {
1723 BamfView *view;
1724@@ -157,9 +152,9 @@
1725 }
1726
1727 static void
1728-bamf_matcher_on_view_closed (DBusGProxy *proxy,
1729- char *path,
1730- char *type,
1731+bamf_matcher_on_view_closed (BamfDBusMatcher *proxy,
1732+ const char *path,
1733+ const char *type,
1734 BamfMatcher *matcher)
1735 {
1736 BamfView *view;
1737@@ -176,9 +171,9 @@
1738 }
1739
1740 static void
1741-bamf_matcher_on_active_application_changed (DBusGProxy *proxy,
1742- char *old_path,
1743- char *new_path,
1744+bamf_matcher_on_active_application_changed (BamfDBusMatcher *proxy,
1745+ const char *old_path,
1746+ const char *new_path,
1747 BamfMatcher *matcher)
1748 {
1749 BamfView *old_view;
1750@@ -192,9 +187,9 @@
1751 }
1752
1753 static void
1754-bamf_matcher_on_active_window_changed (DBusGProxy *proxy,
1755- char *old_path,
1756- char *new_path,
1757+bamf_matcher_on_active_window_changed (BamfDBusMatcher *proxy,
1758+ const char *old_path,
1759+ const char *new_path,
1760 BamfMatcher *matcher)
1761 {
1762 BamfView *old_view;
1763@@ -208,7 +203,7 @@
1764 }
1765
1766 static void
1767-bamf_matcher_on_stacking_order_changed (DBusGProxy *proxy, BamfMatcher *matcher)
1768+bamf_matcher_on_stacking_order_changed (BamfDBusMatcher *proxy, BamfMatcher *matcher)
1769 {
1770 g_signal_emit (matcher, matcher_signals[STACKING_ORDER_CHANGED], 0);
1771 }
1772@@ -217,133 +212,53 @@
1773 bamf_matcher_init (BamfMatcher *self)
1774 {
1775 BamfMatcherPrivate *priv;
1776- GError *error = NULL;
1777+ GError *error = NULL;
1778
1779 priv = self->priv = BAMF_MATCHER_GET_PRIVATE (self);
1780-
1781- priv->connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
1782- if (priv->connection == NULL || error != NULL)
1783- {
1784- g_error ("Failed to open connection to bus: %s",
1785- error != NULL ? error->message : "Unknown");
1786- if (error)
1787- g_error_free (error);
1788- return;
1789- }
1790-
1791- priv->proxy = dbus_g_proxy_new_for_name (priv->connection,
1792- "org.ayatana.bamf",
1793- "/org/ayatana/bamf/matcher",
1794- "org.ayatana.bamf.matcher");
1795- if (priv->proxy == NULL)
1796- {
1797- g_error ("Unable to get org.ayatana.bamf.matcher matcher");
1798- }
1799-
1800- dbus_g_object_register_marshaller ((GClosureMarshal) _bamf_marshal_VOID__STRING_STRING,
1801- G_TYPE_NONE,
1802- G_TYPE_STRING, G_TYPE_STRING,
1803- G_TYPE_INVALID);
1804-
1805- dbus_g_proxy_add_signal (priv->proxy,
1806- "ViewOpened",
1807- G_TYPE_STRING,
1808- G_TYPE_STRING,
1809- G_TYPE_INVALID);
1810-
1811- dbus_g_proxy_connect_signal (priv->proxy,
1812- "ViewOpened",
1813- (GCallback) bamf_matcher_on_view_opened,
1814- self, NULL);
1815-
1816- dbus_g_proxy_add_signal (priv->proxy,
1817- "ViewClosed",
1818- G_TYPE_STRING,
1819- G_TYPE_STRING,
1820- G_TYPE_INVALID);
1821-
1822- dbus_g_proxy_connect_signal (priv->proxy,
1823- "ViewClosed",
1824- (GCallback) bamf_matcher_on_view_closed,
1825- self, NULL);
1826-
1827- dbus_g_proxy_add_signal (priv->proxy,
1828- "ActiveApplicationChanged",
1829- G_TYPE_STRING,
1830- G_TYPE_STRING,
1831- G_TYPE_INVALID);
1832-
1833- dbus_g_proxy_connect_signal (priv->proxy,
1834- "ActiveApplicationChanged",
1835- (GCallback) bamf_matcher_on_active_application_changed,
1836- self, NULL);
1837-
1838- dbus_g_proxy_add_signal (priv->proxy,
1839- "ActiveWindowChanged",
1840- G_TYPE_STRING,
1841- G_TYPE_STRING,
1842- G_TYPE_INVALID);
1843-
1844- dbus_g_proxy_connect_signal (priv->proxy,
1845- "ActiveWindowChanged",
1846- (GCallback) bamf_matcher_on_active_window_changed,
1847- self, NULL);
1848-
1849- dbus_g_proxy_add_signal (priv->proxy,
1850- "StackingOrderChanged",
1851- G_TYPE_INVALID);
1852-
1853- dbus_g_proxy_connect_signal (priv->proxy,
1854- "StackingOrderChanged",
1855- (GCallback) bamf_matcher_on_stacking_order_changed,
1856- self, NULL);
1857+ priv->proxy = bamf_dbus_matcher_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
1858+ G_DBUS_PROXY_FLAGS_NONE,
1859+ BAMF_DBUS_SERVICE_NAME,
1860+ BAMF_DBUS_MATCHER_PATH,
1861+ NULL, &error);
1862+
1863+ if (error)
1864+ {
1865+ g_error ("Unable to get "BAMF_DBUS_SERVICE_NAME" matcher: %s", error ? error->message : "");
1866+ g_error_free (error);
1867+ }
1868+
1869+ g_signal_connect (priv->proxy, "view-opened",
1870+ G_CALLBACK (bamf_matcher_on_view_opened), self);
1871+
1872+ g_signal_connect (priv->proxy, "view-closed",
1873+ G_CALLBACK (bamf_matcher_on_view_closed), self);
1874+
1875+ g_signal_connect (priv->proxy, "active-application-changed",
1876+ G_CALLBACK (bamf_matcher_on_active_application_changed), self);
1877+
1878+ g_signal_connect (priv->proxy, "active-window-changed",
1879+ G_CALLBACK (bamf_matcher_on_active_window_changed), self);
1880+
1881+ g_signal_connect (priv->proxy, "stacking-order-changed",
1882+ G_CALLBACK (bamf_matcher_on_stacking_order_changed), self);
1883 }
1884
1885 static void
1886 bamf_matcher_dispose (GObject *object)
1887 {
1888 BamfMatcher *self = BAMF_MATCHER (object);
1889- BamfMatcherPrivate *priv = self->priv;
1890-
1891- if (priv->proxy)
1892- {
1893- dbus_g_proxy_disconnect_signal (priv->proxy,
1894- "ViewOpened",
1895- (GCallback) bamf_matcher_on_view_opened,
1896- self);
1897-
1898- dbus_g_proxy_disconnect_signal (priv->proxy,
1899- "ViewClosed",
1900- (GCallback) bamf_matcher_on_view_closed,
1901- self);
1902-
1903- dbus_g_proxy_disconnect_signal (priv->proxy,
1904- "ActiveApplicationChanged",
1905- (GCallback) bamf_matcher_on_active_application_changed,
1906- self);
1907-
1908- dbus_g_proxy_disconnect_signal (priv->proxy,
1909- "ActiveWindowChanged",
1910- (GCallback) bamf_matcher_on_active_window_changed,
1911- self);
1912-
1913- dbus_g_proxy_disconnect_signal (priv->proxy,
1914- "StackingOrderChanged",
1915- (GCallback) bamf_matcher_on_stacking_order_changed,
1916- self);
1917-
1918- g_object_unref (priv->proxy);
1919- priv->proxy = NULL;
1920- }
1921+
1922+ if (G_IS_DBUS_PROXY (self->priv->proxy))
1923+ {
1924+ g_signal_handlers_disconnect_by_data (self->priv->proxy, self);
1925+ g_object_unref (self->priv->proxy);
1926+ self->priv->proxy = NULL;
1927+ }
1928
1929 G_OBJECT_CLASS (bamf_matcher_parent_class)->dispose (object);
1930 }
1931
1932 /*
1933- * Private Methods
1934- */
1935-
1936-/*
1937 * Public Methods
1938 */
1939
1940@@ -382,14 +297,10 @@
1941 g_return_val_if_fail (BAMF_IS_MATCHER (matcher), NULL);
1942 priv = matcher->priv;
1943
1944- if (!dbus_g_proxy_call (priv->proxy,
1945- "ActiveApplication",
1946- &error,
1947- G_TYPE_INVALID,
1948- G_TYPE_STRING, &app,
1949- G_TYPE_INVALID))
1950+ if (!bamf_dbus_matcher_call_active_application_sync (priv->proxy, &app,
1951+ NULL, &error))
1952 {
1953- g_warning ("Failed to fetch path: %s", error->message);
1954+ g_warning ("Failed to get active application: %s", error ? error->message : "");
1955 g_error_free (error);
1956 return NULL;
1957 }
1958@@ -432,14 +343,10 @@
1959 g_return_val_if_fail (BAMF_IS_MATCHER (matcher), NULL);
1960 priv = matcher->priv;
1961
1962- if (!dbus_g_proxy_call (priv->proxy,
1963- "ActiveWindow",
1964- &error,
1965- G_TYPE_INVALID,
1966- G_TYPE_STRING, &win,
1967- G_TYPE_INVALID))
1968+ if (!bamf_dbus_matcher_call_active_window_sync (priv->proxy, &win,
1969+ NULL, &error))
1970 {
1971- g_warning ("Failed to fetch path: %s", error->message);
1972+ g_warning ("Failed to get active window: %s", error ? error->message : "");
1973 g_error_free (error);
1974 return NULL;
1975 }
1976@@ -472,16 +379,11 @@
1977 *
1978 * Returns: (transfer none): The #BamfApplication representing the xid passed, or NULL if none exists.
1979 */
1980-BamfApplication *
1981-bamf_matcher_get_application_for_window (BamfMatcher *matcher,
1982- BamfWindow *window)
1983+BamfApplication *
1984+bamf_matcher_get_application_for_window (BamfMatcher *matcher, BamfWindow *window)
1985 {
1986- /* Looks up the window's XID and calls the application_for_xid
1987- function just below here. */
1988-
1989- g_return_val_if_fail(BAMF_IS_WINDOW(window), NULL);
1990- return bamf_matcher_get_application_for_xid (matcher,
1991- bamf_window_get_xid(window));
1992+ g_return_val_if_fail(BAMF_IS_WINDOW(window), NULL);
1993+ return bamf_matcher_get_application_for_xid (matcher, bamf_window_get_xid(window));
1994 }
1995
1996 /**
1997@@ -494,8 +396,7 @@
1998 * Returns: (transfer none): The #BamfApplication representing the xid passed, or NULL if none exists.
1999 */
2000 BamfApplication *
2001-bamf_matcher_get_application_for_xid (BamfMatcher *matcher,
2002- guint32 xid)
2003+bamf_matcher_get_application_for_xid (BamfMatcher *matcher, guint32 xid)
2004 {
2005 BamfMatcherPrivate *priv;
2006 BamfView *view;
2007@@ -505,15 +406,10 @@
2008 g_return_val_if_fail (BAMF_IS_MATCHER (matcher), NULL);
2009 priv = matcher->priv;
2010
2011- if (!dbus_g_proxy_call (priv->proxy,
2012- "ApplicationForXid",
2013- &error,
2014- G_TYPE_UINT, xid,
2015- G_TYPE_INVALID,
2016- G_TYPE_STRING, &app,
2017- G_TYPE_INVALID))
2018+ if (!bamf_dbus_matcher_call_application_for_xid_sync (priv->proxy, xid, &app,
2019+ NULL, &error))
2020 {
2021- g_warning ("Failed to fetch path: %s", error->message);
2022+ g_warning ("Failed to get application for xid %u: %s", xid, error ? error->message : "");
2023 g_error_free (error);
2024 return NULL;
2025 }
2026@@ -529,7 +425,6 @@
2027
2028 BamfFactory *factory = _bamf_factory_get_default ();
2029 view = _bamf_factory_view_for_path_type (factory, app, BAMF_FACTORY_APPLICATION);
2030-
2031 g_free (app);
2032
2033 if (!BAMF_IS_APPLICATION (view))
2034@@ -539,8 +434,7 @@
2035 }
2036
2037 gboolean
2038-bamf_matcher_application_is_running (BamfMatcher *matcher,
2039- const gchar *application)
2040+bamf_matcher_application_is_running (BamfMatcher *matcher, const gchar *app)
2041 {
2042 BamfMatcherPrivate *priv;
2043 gboolean running = FALSE;
2044@@ -549,17 +443,14 @@
2045 g_return_val_if_fail (BAMF_IS_MATCHER (matcher), FALSE);
2046 priv = matcher->priv;
2047
2048- if (!dbus_g_proxy_call (priv->proxy,
2049- "ApplicationIsRunning",
2050- &error,
2051- G_TYPE_STRING, application,
2052- G_TYPE_INVALID,
2053- G_TYPE_BOOLEAN, &running,
2054- G_TYPE_INVALID))
2055+ if (!bamf_dbus_matcher_call_application_is_running_sync (priv->proxy,
2056+ app ? app : "",
2057+ &running,
2058+ NULL, &error))
2059 {
2060- g_warning ("Failed to fetch path: %s", error->message);
2061+ g_warning ("Failed to fetch running status: %s", error ? error->message : "");
2062 g_error_free (error);
2063-
2064+
2065 return FALSE;
2066 }
2067
2068@@ -590,16 +481,11 @@
2069 g_return_val_if_fail (BAMF_IS_MATCHER (matcher), NULL);
2070 priv = matcher->priv;
2071
2072- if (!dbus_g_proxy_call (priv->proxy,
2073- "ApplicationPaths",
2074- &error,
2075- G_TYPE_INVALID,
2076- G_TYPE_STRV, &array,
2077- G_TYPE_INVALID))
2078+ if (!bamf_dbus_matcher_call_application_paths_sync (priv->proxy, &array, NULL, &error))
2079 {
2080- g_warning ("Failed to fetch paths: %s", error->message);
2081+ g_warning ("Failed to fetch applications paths: %s", error ? error->message : "");
2082 g_error_free (error);
2083-
2084+
2085 return NULL;
2086 }
2087
2088@@ -608,7 +494,7 @@
2089
2090 BamfFactory *factory = _bamf_factory_get_default ();
2091 len = g_strv_length (array);
2092- for (i = len-1; i >= 0; i--)
2093+ for (i = len-1; i >= 0; --i)
2094 {
2095 view = _bamf_factory_view_for_path_type (factory, array[i], BAMF_FACTORY_APPLICATION);
2096
2097@@ -644,16 +530,11 @@
2098 g_return_val_if_fail (BAMF_IS_MATCHER (matcher), NULL);
2099 priv = matcher->priv;
2100
2101- if (!dbus_g_proxy_call (priv->proxy,
2102- "WindowPaths",
2103- &error,
2104- G_TYPE_INVALID,
2105- G_TYPE_STRV, &array,
2106- G_TYPE_INVALID))
2107+ if (!bamf_dbus_matcher_call_window_paths_sync (priv->proxy, &array, NULL, &error))
2108 {
2109- g_warning ("Failed to fetch paths: %s", error->message);
2110+ g_warning ("Failed to fetch windows paths: %s", error ? error->message : "");
2111 g_error_free (error);
2112-
2113+
2114 return NULL;
2115 }
2116
2117@@ -662,14 +543,14 @@
2118
2119 BamfFactory *factory = _bamf_factory_get_default ();
2120 len = g_strv_length (array);
2121- for (i = len-1; i >= 0; i--)
2122+ for (i = len-1; i >= 0; --i)
2123 {
2124 view = _bamf_factory_view_for_path_type (factory, array[i], BAMF_FACTORY_WINDOW);
2125
2126 if (BAMF_IS_WINDOW (view))
2127 result = g_list_prepend (result, view);
2128 }
2129-
2130+
2131 g_strfreev (array);
2132 return result;
2133 }
2134@@ -697,18 +578,12 @@
2135 g_return_val_if_fail (BAMF_IS_MATCHER (matcher), NULL);
2136 priv = matcher->priv;
2137
2138- if (!dbus_g_proxy_call (priv->proxy,
2139- "WindowStackForMonitor",
2140- &error,
2141- G_TYPE_INT,
2142- monitor,
2143- G_TYPE_INVALID,
2144- G_TYPE_STRV, &array,
2145- G_TYPE_INVALID))
2146+ if (!bamf_dbus_matcher_call_window_stack_for_monitor_sync (priv->proxy, monitor,
2147+ &array, NULL, &error))
2148 {
2149- g_warning ("Failed to fetch paths: %s", error->message);
2150+ g_warning ("Failed to fetch paths: %s", error ? error->message : "");
2151 g_error_free (error);
2152-
2153+
2154 return NULL;
2155 }
2156
2157@@ -717,18 +592,19 @@
2158
2159 BamfFactory *factory = _bamf_factory_get_default ();
2160 len = g_strv_length (array);
2161- for (i = len-1; i >= 0; i--)
2162+ for (i = len-1; i >= 0; --i)
2163 {
2164 view = _bamf_factory_view_for_path_type (factory, array[i], BAMF_FACTORY_WINDOW);
2165
2166 if (BAMF_IS_WINDOW (view))
2167 result = g_list_prepend (result, view);
2168 }
2169-
2170+
2171 g_strfreev (array);
2172 return result;
2173 }
2174
2175+
2176 /**
2177 * bamf_matcher_register_favorites:
2178 * @matcher: a #BamfMatcher
2179@@ -742,16 +618,19 @@
2180 const gchar **favorites)
2181 {
2182 BamfMatcherPrivate *priv;
2183+ GError *error = NULL;
2184
2185 g_return_if_fail (BAMF_IS_MATCHER (matcher));
2186 g_return_if_fail (favorites);
2187-
2188+
2189 priv = matcher->priv;
2190
2191- dbus_g_proxy_call_no_reply (priv->proxy,
2192- "RegisterFavorites",
2193- G_TYPE_STRV, favorites,
2194- G_TYPE_INVALID);
2195+ if (!bamf_dbus_matcher_call_register_favorites_sync (priv->proxy, favorites,
2196+ NULL, &error))
2197+ {
2198+ g_warning ("Failed to register favorites: %s", error ? error->message : "");
2199+ g_error_free (error);
2200+ }
2201 }
2202
2203 /**
2204@@ -775,16 +654,12 @@
2205 g_return_val_if_fail (BAMF_IS_MATCHER (matcher), NULL);
2206 priv = matcher->priv;
2207
2208- if (!dbus_g_proxy_call (priv->proxy,
2209- "RunningApplications",
2210- &error,
2211- G_TYPE_INVALID,
2212- G_TYPE_STRV, &array,
2213- G_TYPE_INVALID))
2214+ if (!bamf_dbus_matcher_call_running_applications_sync (priv->proxy, &array,
2215+ NULL, &error))
2216 {
2217- g_warning ("Failed to fetch paths: %s", error->message);
2218+ g_warning ("Failed to get running applications: %s", error ? error->message : "");
2219 g_error_free (error);
2220-
2221+
2222 return NULL;
2223 }
2224
2225@@ -793,7 +668,7 @@
2226
2227 BamfFactory *factory = _bamf_factory_get_default ();
2228 len = g_strv_length (array);
2229- for (i = len-1; i >= 0; i--)
2230+ for (i = len-1; i >= 0; --i)
2231 {
2232 view = _bamf_factory_view_for_path_type (factory, array[i], BAMF_FACTORY_APPLICATION);
2233
2234@@ -816,8 +691,38 @@
2235 GList *
2236 bamf_matcher_get_tabs (BamfMatcher *matcher)
2237 {
2238- /* FIXME */
2239- return NULL;
2240+ BamfMatcherPrivate *priv;
2241+ BamfView *view;
2242+ char **array = NULL;
2243+ int i, len;
2244+ GList *result = NULL;
2245+ GError *error = NULL;
2246+
2247+ g_return_val_if_fail (BAMF_IS_MATCHER (matcher), NULL);
2248+ priv = matcher->priv;
2249+
2250+ if (!bamf_dbus_matcher_call_tab_paths_sync (priv->proxy, &array, NULL, &error))
2251+ {
2252+ g_warning ("Failed to get tabs: %s", error ? error->message : "");
2253+ g_error_free (error);
2254+
2255+ return NULL;
2256+ }
2257+
2258+ g_return_val_if_fail (array, NULL);
2259+
2260+ BamfFactory *factory = _bamf_factory_get_default ();
2261+ len = g_strv_length (array);
2262+ for (i = len-1; i >= 0; --i)
2263+ {
2264+ view = _bamf_factory_view_for_path_type (factory, array[i], BAMF_FACTORY_TAB);
2265+
2266+ if (BAMF_IS_TAB (view))
2267+ result = g_list_prepend (result, view);
2268+ }
2269+
2270+ g_strfreev (array);
2271+ return result;
2272 }
2273
2274 /**
2275@@ -825,7 +730,7 @@
2276 * @matcher: a #BamfMatcher
2277 *
2278 * Used to fetch all xid's associated with an application. Useful for performing window
2279- *
2280+ *
2281 *
2282 * Returns: (element-type guint32) (transfer full): A list of xids.
2283 */
2284@@ -833,8 +738,41 @@
2285 bamf_matcher_get_xids_for_application (BamfMatcher *matcher,
2286 const gchar *application)
2287 {
2288- /* FIXME */
2289- return NULL;
2290+ BamfMatcherPrivate *priv;
2291+ GArray *result = NULL;
2292+ GVariant *xids = NULL;
2293+ GVariantIter *iter;
2294+ GError *error = NULL;
2295+ guint32 xid = 0;
2296+
2297+ g_return_val_if_fail (BAMF_IS_MATCHER (matcher), NULL);
2298+ priv = matcher->priv;
2299+
2300+ if (!bamf_dbus_matcher_call_xids_for_application_sync (priv->proxy, application,
2301+ &xids, NULL, &error))
2302+ {
2303+ g_warning ("Failed to get xids: %s", error ? error->message : "");
2304+ g_error_free (error);
2305+
2306+ return NULL;
2307+ }
2308+
2309+ g_return_val_if_fail (xids, NULL);
2310+ g_return_val_if_fail (g_variant_type_equal (g_variant_get_type (xids),
2311+ G_VARIANT_TYPE ("au")), NULL);
2312+
2313+ result = g_array_new (FALSE, TRUE, sizeof (guint32));
2314+
2315+ g_variant_get (xids, "au", &iter);
2316+ while (g_variant_iter_loop (iter, "u", &xid))
2317+ {
2318+ g_array_append_val (result, xid);
2319+ }
2320+
2321+ g_variant_iter_free (iter);
2322+ g_variant_unref (xids);
2323+
2324+ return result;
2325 }
2326
2327 /**
2328@@ -845,21 +783,23 @@
2329 *
2330 * Returns: (transfer none): A #BamfApplication for given desktop file.
2331 */
2332-BamfApplication *
2333+BamfApplication *
2334 bamf_matcher_get_application_for_desktop_file (BamfMatcher *matcher,
2335 const gchar *desktop_file_path,
2336 gboolean create_if_not_found)
2337 {
2338 BamfApplication *app;
2339 const gchar ** favs;
2340-
2341+
2342 app = _bamf_factory_app_for_file (_bamf_factory_get_default (), desktop_file_path, create_if_not_found);
2343+
2344 if (app)
2345 {
2346- favs = g_malloc0 (sizeof (gchar *) * 2),
2347- favs[0] = desktop_file_path;
2348+ favs = g_new0 (const gchar *, 2);
2349+ favs[0] = desktop_file_path;
2350 bamf_matcher_register_favorites (matcher, favs);
2351 g_free (favs);
2352 }
2353+
2354 return app;
2355 }
2356
2357=== modified file 'lib/libbamf/bamf-matcher.h'
2358--- lib/libbamf/bamf-matcher.h 2012-07-01 18:13:55 +0000
2359+++ lib/libbamf/bamf-matcher.h 2013-05-15 12:27:29 +0000
2360@@ -1,5 +1,5 @@
2361 /*
2362- * Copyright 2010 Canonical Ltd.
2363+ * Copyright 2010-2011 Canonical Ltd.
2364 *
2365 * This program is free software: you can redistribute it and/or modify it
2366 * under the terms of either or both of the following licenses:
2367@@ -21,6 +21,7 @@
2368 *
2369 * Authored by: Jason Smith <jason.smith@canonical.com>
2370 * Neil Jagdish Patel <neil.patel@canonical.com>
2371+ * Marco Trevisan (Treviño) <3v1n0@ubuntu.com>
2372 *
2373 */
2374
2375@@ -50,6 +51,12 @@
2376 #define BAMF_MATCHER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),\
2377 BAMF_TYPE_MATCHER, BamfMatcherClass))
2378
2379+#define BAMF_MATCHER_SIGNAL_VIEW_OPENED "view-opened"
2380+#define BAMF_MATCHER_SIGNAL_VIEW_CLOSED "view-closed"
2381+#define BAMF_MATCHER_SIGNAL_ACTIVE_APPLICATION_CHANGED "active-application-changed"
2382+#define BAMF_MATCHER_SIGNAL_ACTIVE_WINDOW_CHANGED "active-window-changed"
2383+#define BAMF_MATCHER_SIGNAL_STACKING_ORDER_CHANGED "stacking-order-changed"
2384+
2385 typedef struct _BamfMatcher BamfMatcher;
2386 typedef struct _BamfMatcherClass BamfMatcherClass;
2387 typedef struct _BamfMatcherPrivate BamfMatcherPrivate;
2388@@ -88,7 +95,7 @@
2389 BamfWindow *window);
2390
2391 gboolean bamf_matcher_application_is_running (BamfMatcher *matcher,
2392- const gchar *application);
2393+ const gchar *desktop_file);
2394
2395 GList * bamf_matcher_get_applications (BamfMatcher *matcher);
2396
2397@@ -100,7 +107,7 @@
2398 GList * bamf_matcher_get_tabs (BamfMatcher *matcher);
2399
2400 GArray * bamf_matcher_get_xids_for_application (BamfMatcher *matcher,
2401- const gchar *application);
2402+ const gchar *desktop_file);
2403
2404 GList * bamf_matcher_get_windows (BamfMatcher *matcher);
2405
2406
2407=== modified file 'lib/libbamf/bamf-tab-source.c'
2408--- lib/libbamf/bamf-tab-source.c 2012-10-08 16:34:51 +0000
2409+++ lib/libbamf/bamf-tab-source.c 2013-05-15 12:27:29 +0000
2410@@ -1,5 +1,5 @@
2411 /*
2412- * Copyright 2010 Canonical Ltd.
2413+ * Copyright 2010-2012 Canonical Ltd.
2414 *
2415 * This program is free software: you can redistribute it and/or modify it
2416 * under the terms of either or both of the following licenses:
2417@@ -20,12 +20,16 @@
2418 * <http://www.gnu.org/licenses/>
2419 *
2420 * Authored by: Jason Smith <jason.smith@canonical.com>
2421+ * Neil Jagdish Patel <neil.patel@canonical.com>
2422+ * Marco Trevisan (Treviño) <3v1n0@ubuntu.com>
2423 *
2424 */
2425
2426+#include <libbamf-private/bamf-private.h>
2427 #include "bamf-tab-source.h"
2428-#include "bamf-tab-source-glue.h"
2429 #include "bamf-marshal.h"
2430+#include "bamf-control.h"
2431+#include "bamf-gdbus-tab-source-generated.h"
2432
2433 #define BAMF_TAB_SOURCE_PATH "/org/bamf/tabsource"
2434
2435@@ -52,6 +56,7 @@
2436
2437 struct _BamfTabSourcePrivate
2438 {
2439+ BamfDBusTabTabsource *dbus_iface;
2440 char *id;
2441 };
2442
2443@@ -128,6 +133,121 @@
2444 return 0;
2445 }
2446
2447+static gboolean
2448+on_dbus_handle_show_tab (BamfDBusItemView *interface,
2449+ GDBusMethodInvocation *invocation,
2450+ gchar *tab_id,
2451+ BamfTabSource *self)
2452+{
2453+ bamf_tab_source_show_tab (self, tab_id, NULL);
2454+ g_dbus_method_invocation_return_value (invocation, NULL);
2455+
2456+ return TRUE;
2457+}
2458+
2459+static gboolean
2460+on_dbus_handle_tab_ids (BamfDBusItemView *interface,
2461+ GDBusMethodInvocation *invocation,
2462+ BamfTabSource *self)
2463+{
2464+ GVariantBuilder b;
2465+ int i = 0;
2466+ char **tabs = bamf_tab_source_get_tab_ids (self);
2467+
2468+ g_variant_builder_init (&b, G_VARIANT_TYPE ("(as)"));
2469+ g_variant_builder_open (&b, G_VARIANT_TYPE ("as"));
2470+
2471+ if (tabs)
2472+ {
2473+ while (tabs[i])
2474+ {
2475+ g_variant_builder_add (&b, "s", tabs[i]);
2476+ ++i;
2477+ }
2478+ }
2479+
2480+ g_variant_builder_close (&b);
2481+ g_dbus_method_invocation_return_value (invocation, g_variant_builder_end (&b));
2482+
2483+ return TRUE;
2484+}
2485+
2486+static gboolean
2487+on_dbus_handle_tab_preview (BamfDBusItemView *interface,
2488+ GDBusMethodInvocation *invocation,
2489+ gchar *tab_id,
2490+ BamfTabSource *self)
2491+{
2492+ GVariantBuilder b;
2493+ int i = 0;
2494+ GArray *preview = bamf_tab_source_get_tab_preview (self, tab_id);
2495+
2496+ g_variant_builder_init (&b, G_VARIANT_TYPE ("(ay)"));
2497+ g_variant_builder_open (&b, G_VARIANT_TYPE ("ay"));
2498+
2499+ if (preview)
2500+ {
2501+ for (i = 0; i < preview->len; ++i)
2502+ {
2503+ g_variant_builder_add (&b, "y", g_array_index (preview, guchar, i));
2504+ ++i;
2505+ }
2506+ }
2507+
2508+ g_variant_builder_close (&b);
2509+ g_dbus_method_invocation_return_value (invocation, g_variant_builder_end (&b));
2510+
2511+ return TRUE;
2512+}
2513+
2514+static gboolean
2515+on_dbus_handle_tab_uri (BamfDBusItemView *interface,
2516+ GDBusMethodInvocation *invocation,
2517+ gchar *tab_id,
2518+ BamfTabSource *self)
2519+{
2520+ char *uri = bamf_tab_source_get_tab_uri (self, tab_id);
2521+ g_dbus_method_invocation_return_value (invocation,
2522+ g_variant_new ("(s)", uri ? uri : ""));
2523+ g_free (uri);
2524+
2525+ return TRUE;
2526+}
2527+
2528+static gboolean
2529+on_dbus_handle_tab_xid (BamfDBusItemView *interface,
2530+ GDBusMethodInvocation *invocation,
2531+ gchar *tab_id,
2532+ BamfTabSource *self)
2533+{
2534+ guint32 xid = bamf_tab_source_get_tab_xid (self, tab_id);
2535+ g_dbus_method_invocation_return_value (invocation, g_variant_new ("(u)", xid));
2536+
2537+ return TRUE;
2538+}
2539+
2540+static void
2541+on_tab_opened (BamfTabSource *self, const gchar *tab_uri, gpointer _not_used)
2542+{
2543+ g_return_if_fail (BAMF_IS_TAB_SOURCE (self));
2544+ bamf_dbus_tab_tabsource_emit_tab_opened (self->priv->dbus_iface, self->priv->id, tab_uri);
2545+}
2546+
2547+static void
2548+on_tab_closed (BamfTabSource *self, const gchar *tab_id, gpointer _not_used)
2549+{
2550+ g_return_if_fail (BAMF_IS_TAB_SOURCE (self));
2551+ bamf_dbus_tab_tabsource_emit_tab_closed (self->priv->dbus_iface, self->priv->id);
2552+}
2553+
2554+static void
2555+on_tab_uri_changed (BamfTabSource *self, const gchar *tab_id, const gchar *old_uri,
2556+ const gchar *new_uri, gpointer _not_used)
2557+{
2558+ g_return_if_fail (BAMF_IS_TAB_SOURCE (self));
2559+ bamf_dbus_tab_tabsource_emit_tab_uri_changed (self->priv->dbus_iface, self->priv->id, old_uri, new_uri);
2560+}
2561+
2562 static void
2563 bamf_tab_source_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
2564 {
2565@@ -138,6 +258,7 @@
2566 switch (property_id)
2567 {
2568 case PROP_ID:
2569+ g_free (self->priv->id);
2570 self->priv->id = g_strdup (g_value_get_string (value));
2571 break;
2572 default:
2573@@ -167,45 +288,69 @@
2574 static void
2575 bamf_tab_source_dispose (GObject *object)
2576 {
2577+ BamfTabSource *self = BAMF_TAB_SOURCE (object);
2578+
2579+ if (self->priv->id)
2580+ {
2581+ g_free (self->priv->id);
2582+ self->priv->id = NULL;
2583+ }
2584+
2585 G_OBJECT_CLASS (bamf_tab_source_parent_class)->dispose (object);
2586 }
2587
2588 static void
2589 bamf_tab_source_constructed (GObject *object)
2590 {
2591+ BamfTabSource *self;
2592+ BamfControl *control;
2593+ GDBusConnection* bus;
2594+ GDBusInterfaceSkeleton *iface;
2595+ GError *error = NULL;
2596 char *path;
2597- DBusGConnection *bus;
2598- DBusGProxy *proxy;
2599- GError *error = NULL;
2600+
2601+ self = BAMF_TAB_SOURCE (object);
2602+
2603+ bus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL);
2604+ g_return_if_fail (bus);
2605+
2606+ self->priv->dbus_iface = bamf_dbus_tab_tabsource_skeleton_new ();
2607+ path = g_strconcat (BAMF_TAB_SOURCE_PATH"/", self->priv->id, NULL);
2608+ iface = G_DBUS_INTERFACE_SKELETON (self->priv->dbus_iface);
2609+ g_dbus_interface_skeleton_export (iface, bus, path, &error);
2610+ g_return_if_fail (!error);
2611+
2612+ /* We need to connect to the object own signals to redirect them to the dbus
2613+ * interface */
2614+ g_signal_connect (self, "tab-opened", G_CALLBACK (on_tab_opened), NULL);
2615+ g_signal_connect (self, "tab-closed", G_CALLBACK (on_tab_closed), NULL);
2616+ g_signal_connect (self, "tab-uri-changed", G_CALLBACK (on_tab_uri_changed), NULL);
2617+
2618+ /* Registering signal callbacks to reply to dbus method calls */
2619+ g_signal_connect (self->priv->dbus_iface, "handle-show-tab",
2620+ G_CALLBACK (on_dbus_handle_show_tab), self);
2621+
2622+ g_signal_connect (self->priv->dbus_iface, "handle-tab-ids",
2623+ G_CALLBACK (on_dbus_handle_tab_ids), self);
2624+
2625+ g_signal_connect (self->priv->dbus_iface, "handle-tab-preview",
2626+ G_CALLBACK (on_dbus_handle_tab_preview), self);
2627+
2628+ g_signal_connect (self->priv->dbus_iface, "handle-tab-uri",
2629+ G_CALLBACK (on_dbus_handle_tab_uri), self);
2630+
2631+ g_signal_connect (self->priv->dbus_iface, "handle-tab-xid",
2632+ G_CALLBACK (on_dbus_handle_tab_xid), self);
2633+
2634+ control = bamf_control_get_default ();
2635+ bamf_control_register_tab_provider (control, path);
2636+
2637+ g_object_unref (bus);
2638+ g_object_unref (control);
2639+ g_free (path);
2640
2641 if (G_OBJECT_CLASS (bamf_tab_source_parent_class)->constructed)
2642 G_OBJECT_CLASS (bamf_tab_source_parent_class)->constructed (object);
2643-
2644- bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
2645- g_return_if_fail (bus);
2646-
2647- path = g_strdup_printf ("%s%s", BAMF_TAB_SOURCE_PATH, BAMF_TAB_SOURCE (object)->priv->id);
2648-
2649- dbus_g_connection_register_g_object (bus, path, object);
2650-
2651- proxy = dbus_g_proxy_new_for_name (bus,
2652- "org.ayatana.bamf",
2653- "/org/ayatana/bamf/control",
2654- "org.ayatana.bamf.control");
2655-
2656- error = NULL;
2657- if (!dbus_g_proxy_call (proxy,
2658- "RegisterTabProvider",
2659- &error,
2660- G_TYPE_STRING, path,
2661- G_TYPE_INVALID,
2662- G_TYPE_INVALID))
2663- {
2664- g_warning ("Could not register tab source: %s", error->message);
2665- g_error_free (error);
2666- }
2667-
2668- g_object_unref (proxy);
2669 }
2670
2671 static void
2672@@ -224,38 +369,35 @@
2673
2674 g_type_class_add_private (object_class, sizeof (BamfTabSourcePrivate));
2675
2676- dbus_g_object_type_install_info (BAMF_TYPE_TAB_SOURCE,
2677- &dbus_glib_bamf_tab_source_object_info);
2678-
2679 bamf_tab_source_signals [TAB_URI_CHANGED] =
2680- g_signal_new ("tab-uri-changed",
2681- G_OBJECT_CLASS_TYPE (klass),
2682- G_SIGNAL_RUN_FIRST,
2683- 0,
2684- NULL, NULL,
2685- _bamf_marshal_VOID__STRING_STRING_STRING,
2686- G_TYPE_NONE, 3,
2687- G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
2688+ g_signal_new (BAMF_TAB_SOURCE_SIGNAL_TAB_URI_CHANGED,
2689+ G_OBJECT_CLASS_TYPE (klass),
2690+ G_SIGNAL_RUN_FIRST,
2691+ 0,
2692+ NULL, NULL,
2693+ _bamf_marshal_VOID__STRING_STRING_STRING,
2694+ G_TYPE_NONE, 3,
2695+ G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
2696
2697 bamf_tab_source_signals [TAB_OPENED] =
2698- g_signal_new ("tab-opened",
2699- G_OBJECT_CLASS_TYPE (klass),
2700- G_SIGNAL_RUN_FIRST,
2701- 0,
2702- NULL, NULL,
2703- g_cclosure_marshal_VOID__STRING,
2704- G_TYPE_NONE, 1,
2705- G_TYPE_STRING);
2706+ g_signal_new (BAMF_TAB_SOURCE_SIGNAL_TAB_OPENED,
2707+ G_OBJECT_CLASS_TYPE (klass),
2708+ G_SIGNAL_RUN_FIRST,
2709+ 0,
2710+ NULL, NULL,
2711+ g_cclosure_marshal_VOID__STRING,
2712+ G_TYPE_NONE, 1,
2713+ G_TYPE_STRING);
2714
2715 bamf_tab_source_signals [TAB_CLOSED] =
2716- g_signal_new ("tab-closed",
2717- G_OBJECT_CLASS_TYPE (klass),
2718- G_SIGNAL_RUN_FIRST,
2719- 0,
2720- NULL, NULL,
2721- g_cclosure_marshal_VOID__STRING,
2722- G_TYPE_NONE, 1,
2723- G_TYPE_STRING);
2724+ g_signal_new (BAMF_TAB_SOURCE_SIGNAL_TAB_CLOSED,
2725+ G_OBJECT_CLASS_TYPE (klass),
2726+ G_SIGNAL_RUN_FIRST,
2727+ 0,
2728+ NULL, NULL,
2729+ g_cclosure_marshal_VOID__STRING,
2730+ G_TYPE_NONE, 1,
2731+ G_TYPE_STRING);
2732 }
2733
2734 static void
2735
2736=== modified file 'lib/libbamf/bamf-tab-source.h'
2737--- lib/libbamf/bamf-tab-source.h 2012-08-21 22:02:12 +0000
2738+++ lib/libbamf/bamf-tab-source.h 2013-05-15 12:27:29 +0000
2739@@ -1,5 +1,5 @@
2740 /*
2741- * Copyright 2010 Canonical Ltd.
2742+ * Copyright 2010-2011 Canonical Ltd.
2743 *
2744 * This program is free software: you can redistribute it and/or modify it
2745 * under the terms of either or both of the following licenses:
2746@@ -20,6 +20,8 @@
2747 * <http://www.gnu.org/licenses/>
2748 *
2749 * Authored by: Jason Smith <jason.smith@canonical.com>
2750+ * Neil Jagdish Patel <neil.patel@canonical.com>
2751+ * Marco Trevisan (Treviño) <3v1n0@ubuntu.com>
2752 *
2753 */
2754
2755@@ -39,6 +41,10 @@
2756 #define BAMF_IS_TAB_SOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BAMF_TYPE_TAB_SOURCE))
2757 #define BAMF_TAB_SOURCE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BAMF_TYPE_TAB_SOURCE, BamfTabSourceClass))
2758
2759+#define BAMF_TAB_SOURCE_SIGNAL_TAB_OPENED "tab-opened"
2760+#define BAMF_TAB_SOURCE_SIGNAL_TAB_CLOSED "tab-closed"
2761+#define BAMF_TAB_SOURCE_SIGNAL_TAB_URI_CHANGED "tab-uri-changed"
2762+
2763 typedef struct _BamfTabSource BamfTabSource;
2764 typedef struct _BamfTabSourceClass BamfTabSourceClass;
2765 typedef struct _BamfTabSourcePrivate BamfTabSourcePrivate;
2766
2767=== modified file 'lib/libbamf/bamf-tab.c'
2768--- lib/libbamf/bamf-tab.c 2012-12-19 15:38:44 +0000
2769+++ lib/libbamf/bamf-tab.c 2013-05-15 12:27:29 +0000
2770@@ -1,36 +1,36 @@
2771 /*
2772- * bamf-tab.c
2773- * This file is part of BAMF
2774- *
2775- * Copyright (C) 2012 Canonical LTD
2776- * Authors: Robert Carr <racarr@canonical.com>
2777- *
2778- * BAMF is free software; you can redistribute it and/or modify
2779- * it under the terms of the GNU General Public License as published by
2780- * the Free Software Foundation; either version 2 of the License, or
2781- * (at your option) any later version.
2782- *
2783- * BAMF is distributed in the hope that it will be useful,
2784- * but WITHOUT ANY WARRANTY; without even the implied warranty of
2785- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2786- * GNU General Public License for more details.
2787- *
2788- * You should have received a copy of the GNU General Public License
2789- * along with BAMF; if not, write to the Free Software
2790- * Foundation, Inc., 51 Franklin St, Fifth Floor,
2791- * Boston, MA 02110-1301 USA
2792+ * Copyright 2010-2013 Canonical Ltd.
2793+ *
2794+ * This program is free software: you can redistribute it and/or modify it
2795+ * under the terms of either or both of the following licenses:
2796+ *
2797+ * 1) the GNU Lesser General Public License version 3, as published by the
2798+ * Free Software Foundation; and/or
2799+ * 2) the GNU Lesser General Public License version 2.1, as published by
2800+ * the Free Software Foundation.
2801+ *
2802+ * This program is distributed in the hope that it will be useful, but
2803+ * WITHOUT ANY WARRANTY; without even the implied warranties of
2804+ * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
2805+ * PURPOSE. See the applicable version of the GNU Lesser General Public
2806+ * License for more details.
2807+ *
2808+ * You should have received a copy of both the GNU Lesser General Public
2809+ * License version 3 and version 2.1 along with this program. If not, see
2810+ * <http://www.gnu.org/licenses/>
2811+ *
2812+ * Authored by: Jason Smith <jason.smith@canonical.com>
2813+ Robert Carr <racarr@canonical.com>
2814+ * Marco Trevisan (Treviño) <3v1n0@ubuntu.com>
2815+ *
2816 */
2817
2818+#include <libbamf-private/bamf-private.h>
2819 #include "bamf-tab.h"
2820 #include "bamf-marshal.h"
2821 #include "bamf-view-private.h"
2822
2823-#include <dbus/dbus.h>
2824-#include <dbus/dbus-glib.h>
2825-#include <dbus/dbus-glib-lowlevel.h>
2826-
2827-
2828-#define BAMF_TAB_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE((object), BAMF_TYPE_TAB, BamfTabPrivate))
2829+#define BAMF_TAB_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE (object, BAMF_TYPE_TAB, BamfTabPrivate))
2830
2831 enum
2832 {
2833@@ -40,226 +40,76 @@
2834 PROP_XID,
2835 PROP_IS_FOREGROUND_TAB
2836 };
2837-
2838-
2839-enum
2840-{
2841- FILL,
2842- LAST_SIGNAL,
2843-};
2844-
2845-//static guint tab_signals[LAST_SIGNAL] = { 0 };
2846
2847 struct _BamfTabPrivate
2848 {
2849- DBusGConnection *connection;
2850- DBusGProxy *tab_proxy;
2851- DBusGProxy *properties_proxy;
2852-
2853- gchar *location;
2854- gchar *desktop_name;
2855- guint64 xid;
2856- gboolean is_foreground;
2857+ BamfDBusItemTab *proxy;
2858 };
2859
2860 static void bamf_tab_unset_proxy (BamfTab *self);
2861
2862-G_DEFINE_TYPE (BamfTab, bamf_tab, BAMF_TYPE_VIEW)
2863-
2864-static void
2865-bamf_tab_got_properties (DBusGProxy *proxy,
2866- DBusGProxyCall *call_id,
2867- void *user_data)
2868-{
2869- BamfTab *self;
2870- GHashTable *properties;
2871- GError *error;
2872- GHashTableIter iter;
2873- gpointer key, value;
2874-
2875-
2876- self = BAMF_TAB (user_data);
2877-
2878- error = NULL;
2879-
2880- dbus_g_proxy_end_call (proxy, call_id, &error,
2881- dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE), &properties,
2882- G_TYPE_INVALID);
2883-
2884- if (error != NULL)
2885- {
2886- g_critical ("Failed to fetch BamfTab properties: %s", error->message);
2887- g_error_free (error);
2888-
2889- return;
2890- }
2891-
2892- if (properties == NULL)
2893- {
2894- return;
2895- }
2896-
2897- g_hash_table_iter_init (&iter, properties);
2898-
2899- while (g_hash_table_iter_next (&iter, &key, &value))
2900- {
2901- g_object_set_property (G_OBJECT (self), (const gchar *)key, (GValue *)value);
2902- }
2903-
2904-}
2905-
2906-
2907-static void
2908-bamf_tab_fetch_properties (BamfTab *self)
2909-{
2910- dbus_g_proxy_begin_call (self->priv->properties_proxy,
2911- "GetAll",
2912- bamf_tab_got_properties,
2913- g_object_ref (G_OBJECT (self)),
2914- (GDestroyNotify)g_object_unref,
2915- G_TYPE_STRING, "org.ayatana.bamf.tab",
2916- G_TYPE_INVALID);
2917-
2918-}
2919-
2920-static void
2921-bamf_tab_on_properties_changed (DBusGProxy *proxy,
2922- const gchar *interface_name,
2923- GHashTable *changed_properties,
2924- const gchar **invalidated_properties,
2925- gpointer user_data)
2926-{
2927- BamfTab *self;
2928- GHashTableIter iter;
2929- gpointer key, value;
2930- guint i, len;
2931-
2932- if (g_strcmp0 (interface_name, "org.ayatana.bamf.tab") != 0)
2933- {
2934- return;
2935- }
2936-
2937- self = (BamfTab *)user_data;
2938-
2939- g_hash_table_iter_init (&iter, changed_properties);
2940-
2941- while (g_hash_table_iter_next (&iter, &key, &value))
2942- {
2943- g_object_set_property (G_OBJECT (self), (const gchar *)key, (GValue *)value);
2944- }
2945-
2946- if (invalidated_properties == NULL)
2947- {
2948- return;
2949- }
2950-
2951- len = g_strv_length ((gchar **)invalidated_properties);
2952- for (i = 0; i < len; i++)
2953- {
2954- g_critical("Invalidated prop: %s\n", invalidated_properties[i]);
2955- }
2956+G_DEFINE_TYPE (BamfTab, bamf_tab, BAMF_TYPE_VIEW);
2957+
2958+static void
2959+on_proxy_property_change (GObject *gobject, GParamSpec *pspec, gpointer user_data)
2960+{
2961+ BamfTab *self = BAMF_TAB (user_data);
2962+
2963+ if (g_object_class_find_property (G_OBJECT_GET_CLASS (self), pspec->name))
2964+ g_object_notify (G_OBJECT (self), pspec->name);
2965 }
2966
2967 static void
2968 bamf_tab_set_path (BamfView *view, const gchar *path)
2969 {
2970 BamfTab *self;
2971-
2972+ BamfTabPrivate *priv;
2973+ GError *error = NULL;
2974+
2975 self = BAMF_TAB (view);
2976-
2977+ priv = self->priv;
2978+
2979 bamf_tab_unset_proxy (self);
2980-
2981- self->priv->tab_proxy = dbus_g_proxy_new_for_name (self->priv->connection,
2982- "org.ayatana.bamf",
2983- path,
2984- "org.ayatana.bamf.tab");
2985-
2986- if (self->priv->tab_proxy == NULL)
2987- {
2988- g_warning ("Unable to get org.ayatana.bamf.tab proxy: %s", path);
2989- return;
2990- }
2991-
2992- self->priv->properties_proxy = dbus_g_proxy_new_for_name (self->priv->connection,
2993- "org.ayatana.bamf",
2994- path,
2995- "org.freedesktop.DBus.Properties");
2996-
2997- if (self->priv->properties_proxy == NULL)
2998- {
2999- g_warning ("Unable to get org.freedesktop.DBus.properties proxy on tab object: %s", path);
3000- return;
3001- }
3002-
3003- bamf_tab_fetch_properties (self);
3004-
3005- dbus_g_object_register_marshaller ((GClosureMarshal) _bamf_marshal_VOID__STRING_BOXED_POINTER,
3006- G_TYPE_NONE,
3007- G_TYPE_STRING,
3008- G_TYPE_BOXED,
3009- G_TYPE_STRV,
3010- G_TYPE_INVALID);
3011-
3012- dbus_g_proxy_add_signal (self->priv->properties_proxy,
3013- "PropertiesChanged",
3014- G_TYPE_STRING,
3015- dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE),
3016- G_TYPE_STRV,
3017- G_TYPE_INVALID);
3018- dbus_g_proxy_connect_signal (self->priv->properties_proxy,
3019- "PropertiesChanged",
3020- (GCallback) bamf_tab_on_properties_changed,
3021- self,
3022- NULL);
3023- }
3024-
3025-static void
3026-bamf_tab_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
3027-{
3028- BamfTab *self;
3029-
3030- self = BAMF_TAB (object);
3031-
3032- switch (property_id)
3033- {
3034- case PROP_LOCATION:
3035- self->priv->location = g_value_dup_string (value);
3036- break;
3037- case PROP_DESKTOP_ID:
3038- g_return_if_fail (self->priv->desktop_name == NULL);
3039- self->priv->desktop_name = g_value_dup_string (value);
3040- break;
3041- case PROP_XID:
3042- self->priv->xid = g_value_get_uint64 (value);
3043- break;
3044- case PROP_IS_FOREGROUND_TAB:
3045- self->priv->is_foreground = g_value_get_boolean (value);
3046- break;
3047- default:
3048- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
3049- }
3050+ priv->proxy = bamf_dbus_item_tab_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
3051+ G_DBUS_PROXY_FLAGS_NONE,
3052+ BAMF_DBUS_SERVICE_NAME,
3053+ path, NULL, &error);
3054+ if (!G_IS_DBUS_PROXY (priv->proxy))
3055+ {
3056+ g_error ("Unable to get "BAMF_DBUS_SERVICE_NAME" tab: %s", error ? error->message : "");
3057+ g_error_free (error);
3058+ return;
3059+ }
3060+
3061+ g_signal_connect (priv->proxy, "notify", G_CALLBACK (on_proxy_property_change), self);
3062 }
3063
3064 static void
3065 bamf_tab_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec)
3066 {
3067 BamfTab *self;
3068-
3069+
3070 self = BAMF_TAB (object);
3071-
3072+
3073+ if (!_bamf_view_remote_ready (BAMF_VIEW (self)))
3074+ {
3075+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
3076+ return;
3077+ }
3078+
3079 switch (property_id)
3080 {
3081 case PROP_LOCATION:
3082- g_value_set_string (value, self->priv->location);
3083+ g_value_set_string (value, bamf_dbus_item_tab_get_location (self->priv->proxy));
3084 break;
3085 case PROP_DESKTOP_ID:
3086- g_value_set_string (value, self->priv->desktop_name);
3087+ g_value_set_string (value, bamf_dbus_item_tab_get_desktop_id (self->priv->proxy));
3088 break;
3089 case PROP_XID:
3090- g_value_set_uint64 (value, self->priv->xid);
3091+ g_value_set_uint64 (value, bamf_dbus_item_tab_get_xid (self->priv->proxy));
3092 break;
3093 case PROP_IS_FOREGROUND_TAB:
3094- g_value_set_boolean (value, self->priv->is_foreground);
3095+ g_value_set_boolean (value, bamf_dbus_item_tab_get_is_foreground_tab (self->priv->proxy));
3096 break;
3097 default:
3098 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
3099@@ -269,45 +119,20 @@
3100 static void
3101 bamf_tab_unset_proxy (BamfTab *self)
3102 {
3103- if (self->priv->tab_proxy)
3104- {
3105- g_object_unref (G_OBJECT (self->priv->tab_proxy));
3106- self->priv->tab_proxy = NULL;
3107- }
3108-
3109- if (self->priv->properties_proxy)
3110- {
3111- dbus_g_proxy_disconnect_signal (self->priv->properties_proxy,
3112- "PropertiesChanged",
3113- (GCallback) bamf_tab_on_properties_changed,
3114- self);
3115- g_object_unref (G_OBJECT (self->priv->properties_proxy));
3116- self->priv->properties_proxy = NULL;
3117- }
3118-}
3119-
3120-static void
3121-bamf_tab_finalize (GObject *object)
3122-{
3123- BamfTab *self;
3124-
3125- self = BAMF_TAB (object);
3126-
3127- if (self->priv->location != NULL)
3128- {
3129- g_free (self->priv->location);
3130- }
3131- if (self->priv->desktop_name != NULL)
3132- {
3133- g_free (self->priv->desktop_name);
3134- }
3135+ if (!G_IS_DBUS_PROXY (self->priv->proxy))
3136+ return;
3137+
3138+ g_signal_handlers_disconnect_by_data (self->priv->proxy, self);
3139+
3140+ g_object_unref (self->priv->proxy);
3141+ self->priv->proxy = NULL;
3142 }
3143
3144 static void
3145 bamf_tab_dispose (GObject *object)
3146 {
3147 BamfTab *self;
3148-
3149+
3150 self = BAMF_TAB (object);
3151
3152 bamf_tab_unset_proxy (self);
3153@@ -316,102 +141,72 @@
3154 G_OBJECT_CLASS (bamf_tab_parent_class)->dispose (object);
3155 }
3156
3157-
3158 static void
3159 bamf_tab_class_init (BamfTabClass *klass)
3160 {
3161 GParamSpec *pspec;
3162 GObjectClass *obj_class = G_OBJECT_CLASS (klass);
3163 BamfViewClass *view_class = BAMF_VIEW_CLASS (klass);
3164-
3165- obj_class->finalize = bamf_tab_finalize;
3166+
3167 obj_class->dispose = bamf_tab_dispose;
3168 obj_class->get_property = bamf_tab_get_property;
3169- obj_class->set_property = bamf_tab_set_property;
3170-
3171+
3172 view_class->set_path = bamf_tab_set_path;
3173
3174 pspec = g_param_spec_string("location", "Location", "The Current location of the remote Tab",
3175- NULL, G_PARAM_READWRITE);
3176+ NULL, G_PARAM_READABLE);
3177 g_object_class_install_property (obj_class, PROP_LOCATION, pspec);
3178-
3179+
3180 pspec = g_param_spec_string("desktop-id", "Desktop Name", "The Desktop ID assosciated with the application hosted in the remote Tab",
3181- NULL, G_PARAM_READWRITE);
3182+ NULL, G_PARAM_READABLE);
3183 g_object_class_install_property (obj_class, PROP_DESKTOP_ID, pspec);
3184-
3185+
3186 pspec = g_param_spec_uint64("xid", "xid", "XID for the toplevel window containing the remote Tab",
3187- 0, G_MAXUINT64, 0, G_PARAM_READWRITE);
3188+ 0, G_MAXUINT64, 0, G_PARAM_READABLE);
3189 g_object_class_install_property (obj_class, PROP_XID, pspec);
3190-
3191+
3192 pspec = g_param_spec_boolean("is-foreground-tab", "Foreground tab", "Whether the tab is the foreground tab in it's toplevel container",
3193- FALSE, G_PARAM_READWRITE);
3194+ FALSE, G_PARAM_READABLE);
3195 g_object_class_install_property (obj_class, PROP_IS_FOREGROUND_TAB, pspec);
3196-
3197+
3198 g_type_class_add_private (obj_class, sizeof(BamfTabPrivate));
3199-
3200 }
3201
3202 static void
3203 bamf_tab_init (BamfTab *self)
3204 {
3205- GError *error = NULL;
3206-
3207 self->priv = BAMF_TAB_GET_PRIVATE (self);
3208-
3209- self->priv->tab_proxy = NULL;
3210- self->priv->properties_proxy = NULL;
3211-
3212- self->priv->location = NULL;
3213- self->priv->desktop_name = NULL;
3214- self->priv->xid = 0;
3215-
3216-
3217- self->priv->connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
3218-
3219- if (error != NULL)
3220- {
3221- g_warning ("Failed to open connection to bus: %s", error->message);
3222- g_error_free (error);
3223-
3224- return;
3225- }
3226 }
3227
3228 BamfTab *
3229 bamf_tab_new (const gchar *path)
3230 {
3231 BamfTab *self;
3232-
3233+
3234 self = g_object_new (BAMF_TYPE_TAB, NULL);
3235-
3236 _bamf_view_set_path (BAMF_VIEW (self), path);
3237-
3238+
3239 return self;
3240 }
3241
3242 gboolean
3243 bamf_tab_raise (BamfTab *self)
3244 {
3245- GError *error;
3246+ GError *error = NULL;
3247
3248 g_return_val_if_fail (BAMF_IS_TAB (self), FALSE);
3249-
3250+
3251 if (!_bamf_view_remote_ready (BAMF_VIEW (self)))
3252 return FALSE;
3253-
3254- error = NULL;
3255-
3256- if (!dbus_g_proxy_call (self->priv->tab_proxy,
3257- "Raise",
3258- &error,
3259- G_TYPE_INVALID))
3260+
3261+ if (!bamf_dbus_item_tab_call_raise_sync (self->priv->proxy, NULL, &error))
3262 {
3263- g_warning ("Failed to invoke Raise method: %s", error->message);
3264+ g_warning ("Failed to invoke Raise method: %s", error ? error->message : "");
3265 g_error_free (error);
3266-
3267+
3268 return FALSE;
3269 }
3270-
3271+
3272 return TRUE;
3273 }
3274
3275@@ -421,85 +216,74 @@
3276 GError *error;
3277
3278 g_return_val_if_fail (BAMF_IS_TAB (self), FALSE);
3279-
3280+
3281 if (!_bamf_view_remote_ready (BAMF_VIEW (self)))
3282 return FALSE;
3283-
3284+
3285 error = NULL;
3286-
3287- if (!dbus_g_proxy_call (self->priv->tab_proxy,
3288- "Close",
3289- &error,
3290- G_TYPE_INVALID))
3291+
3292+ if (!bamf_dbus_item_tab_call_close_sync (self->priv->proxy, NULL, &error))
3293 {
3294 g_warning ("Failed to invoke Close method: %s", error->message);
3295 g_error_free (error);
3296-
3297+
3298 return FALSE;
3299 }
3300-
3301+
3302 return TRUE;
3303 }
3304
3305-typedef struct _bamf_tab_preview_request_user_data {
3306+typedef struct _BamfTabPreviewRequestData
3307+{
3308 BamfTab *self;
3309 BamfTabPreviewReadyCallback callback;
3310 gpointer user_data;
3311-} bamf_tab_preview_request_user_data;
3312+} BamfTabPreviewRequestData;
3313
3314 static void
3315-bamf_tab_on_preview_ready (DBusGProxy *proxy,
3316- DBusGProxyCall *call_id,
3317- gpointer user_data)
3318+bamf_tab_on_preview_ready (GObject *source_object, GAsyncResult *res, gpointer user_data)
3319 {
3320 BamfTab *self;
3321- bamf_tab_preview_request_user_data *data;
3322+ BamfTabPreviewRequestData *data;
3323 gchar *preview_data = NULL;
3324- GError *error;
3325-
3326- data = (bamf_tab_preview_request_user_data *)user_data;
3327+ GError *error = NULL;
3328+
3329+ data = user_data;
3330 self = data->self;
3331-
3332- error = NULL;
3333-
3334- dbus_g_proxy_end_call (proxy, call_id, &error, G_TYPE_STRING, &preview_data, G_TYPE_INVALID);
3335-
3336- if (error != NULL)
3337+
3338+ if (bamf_dbus_item_tab_call_request_preview_finish (self->priv->proxy, &preview_data, res, &error))
3339 {
3340- g_warning ("Error requesting BamfTab preview: %s", error->message);
3341+ data->callback (self, NULL, data->user_data);
3342+
3343+ g_warning ("Error requesting BamfTab preview: %s", error ? error->message : "");
3344 g_error_free (error);
3345-
3346+ g_free (data);
3347 return;
3348 }
3349-
3350+
3351 data->callback (self, preview_data, data->user_data);
3352-
3353- g_free (preview_data);
3354+
3355+ g_free (preview_data);
3356+ g_free (data);
3357 }
3358
3359 void
3360 bamf_tab_request_preview (BamfTab *self, BamfTabPreviewReadyCallback callback, gpointer user_data)
3361 {
3362- bamf_tab_preview_request_user_data *data;
3363+ BamfTabPreviewRequestData *data;
3364
3365 g_return_if_fail (BAMF_IS_TAB (self));
3366 g_return_if_fail (callback != NULL);
3367-
3368- data = g_malloc0 (sizeof (bamf_tab_preview_request_user_data));
3369+
3370+ data = g_malloc (sizeof (BamfTabPreviewRequestData));
3371 data->self = self;
3372 data->callback = callback;
3373 data->user_data = user_data;
3374-
3375- dbus_g_proxy_begin_call (self->priv->tab_proxy,
3376- "RequestPreview",
3377- bamf_tab_on_preview_ready,
3378- data,
3379- (GDestroyNotify)g_free,
3380- G_TYPE_INVALID);
3381-
3382- }
3383-
3384-
3385+
3386+ bamf_dbus_item_tab_call_request_preview (self->priv->proxy, NULL,
3387+ bamf_tab_on_preview_ready, data);
3388+}
3389+
3390 const gchar *
3391 bamf_tab_get_location (BamfTab *self)
3392 {
3393@@ -507,8 +291,8 @@
3394
3395 if (BAMF_TAB_GET_CLASS (self)->get_location)
3396 return BAMF_TAB_GET_CLASS (self)->get_location (self);
3397-
3398- return self->priv->location;
3399+
3400+ return bamf_dbus_item_tab_get_location (self->priv->proxy);
3401 }
3402
3403 const gchar *
3404@@ -518,8 +302,8 @@
3405
3406 if (BAMF_TAB_GET_CLASS (self)->get_desktop_name)
3407 return BAMF_TAB_GET_CLASS (self)->get_desktop_name (self);
3408-
3409- return self->priv->desktop_name;
3410+
3411+ return bamf_dbus_item_tab_get_desktop_id (self->priv->proxy);
3412 }
3413
3414 guint64
3415@@ -529,17 +313,17 @@
3416
3417 if (BAMF_TAB_GET_CLASS (self)->get_xid)
3418 return BAMF_TAB_GET_CLASS (self)->get_xid (self);
3419-
3420- return self->priv->xid;
3421+
3422+ return bamf_dbus_item_tab_get_xid (self->priv->proxy);
3423 }
3424
3425 gboolean
3426 bamf_tab_get_is_foreground_tab (BamfTab *self)
3427 {
3428- g_return_val_if_fail (BAMF_IS_TAB (self), 0);
3429+ g_return_val_if_fail (BAMF_IS_TAB (self), FALSE);
3430
3431 if (BAMF_TAB_GET_CLASS (self)->get_is_foreground_tab)
3432 return BAMF_TAB_GET_CLASS (self)->get_is_foreground_tab (self);
3433-
3434- return self->priv->is_foreground;
3435+
3436+ return bamf_dbus_item_tab_get_is_foreground_tab (self->priv->proxy);
3437 }
3438
3439=== modified file 'lib/libbamf/bamf-tab.h'
3440--- lib/libbamf/bamf-tab.h 2012-12-19 15:55:33 +0000
3441+++ lib/libbamf/bamf-tab.h 2013-05-15 12:27:29 +0000
3442@@ -1,27 +1,29 @@
3443 /*
3444- * bamf-tab.h
3445- * This file is part of BAMF
3446- *
3447- * Copyright (C) 2010 - Jason Smith
3448- *
3449- * BAMF is free software; you can redistribute it and/or modify
3450- * it under the terms of the GNU General Public License as published by
3451- * the Free Software Foundation; either version 2 of the License, or
3452- * (at your option) any later version.
3453- *
3454- * BAMF is distributed in the hope that it will be useful,
3455- * but WITHOUT ANY WARRANTY; without even the implied warranty of
3456- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3457- * GNU General Public License for more details.
3458- *
3459- * You should have received a copy of the GNU General Public License
3460- * along with BAMF; if not, write to the Free Software
3461- * Foundation, Inc., 51 Franklin St, Fifth Floor,
3462- * Boston, MA 02110-1301 USA
3463+ * Copyright 2010-2011 Canonical Ltd.
3464+ *
3465+ * This program is free software: you can redistribute it and/or modify it
3466+ * under the terms of either or both of the following licenses:
3467+ *
3468+ * 1) the GNU Lesser General Public License version 3, as published by the
3469+ * Free Software Foundation; and/or
3470+ * 2) the GNU Lesser General Public License version 2.1, as published by
3471+ * the Free Software Foundation.
3472+ *
3473+ * This program is distributed in the hope that it will be useful, but
3474+ * WITHOUT ANY WARRANTY; without even the implied warranties of
3475+ * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
3476+ * PURPOSE. See the applicable version of the GNU Lesser General Public
3477+ * License for more details.
3478+ *
3479+ * You should have received a copy of both the GNU Lesser General Public
3480+ * License version 3 and version 2.1 along with this program. If not, see
3481+ * <http://www.gnu.org/licenses/>
3482+ *
3483+ * Authored by: Jason Smith <jason.smith@canonical.com>
3484+ * Marco Trevisan (Treviño) <3v1n0@ubuntu.com>
3485+ *
3486 */
3487
3488-
3489-
3490 #ifndef __BAMF_TAB_H__
3491 #define __BAMF_TAB_H__
3492
3493@@ -38,17 +40,21 @@
3494 #define BAMF_IS_TAB_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BAMF_TYPE_TAB))
3495 #define BAMF_TAB_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BAMF_TYPE_TAB, BamfTabClass))
3496
3497+#define BAMF_TAB_SIGNAL_URI_CHANGED "uri-changed"
3498+#define BAMF_TAB_SIGNAL_PREVIEW_UPDATED "preview-updated"
3499+
3500 typedef struct _BamfTab BamfTab;
3501 typedef struct _BamfTabClass BamfTabClass;
3502 typedef struct _BamfTabPrivate BamfTabPrivate;
3503
3504-struct _BamfTab {
3505+struct _BamfTab
3506+{
3507 BamfView parent;
3508-
3509 BamfTabPrivate *priv;
3510 };
3511
3512-struct _BamfTabClass {
3513+struct _BamfTabClass
3514+{
3515 BamfViewClass parent_class;
3516
3517 const gchar * (*get_desktop_name) (BamfTab *self);
3518@@ -71,17 +77,14 @@
3519
3520 gboolean bamf_tab_raise (BamfTab *self);
3521 gboolean bamf_tab_close (BamfTab *self);
3522-void bamf_tab_request_preview (BamfTab *self, BamfTabPreviewReadyCallback callback, gpointer user_data);
3523-
3524+void bamf_tab_request_preview (BamfTab *self,
3525+ BamfTabPreviewReadyCallback callback,
3526+ gpointer user_data);
3527 const gchar *bamf_tab_get_desktop_name (BamfTab *self);
3528 const gchar *bamf_tab_get_location (BamfTab *self);
3529 guint64 bamf_tab_get_xid (BamfTab *self);
3530-
3531 gboolean bamf_tab_get_is_foreground_tab (BamfTab *self);
3532
3533-
3534-
3535-
3536 G_END_DECLS
3537
3538 #endif /* __BAMF_TAB_H__ */
3539
3540=== modified file 'lib/libbamf/bamf-view.c'
3541--- lib/libbamf/bamf-view.c 2012-12-18 01:53:22 +0000
3542+++ lib/libbamf/bamf-view.c 2013-05-15 12:27:29 +0000
3543@@ -1,5 +1,5 @@
3544 /*
3545- * Copyright 2010 Canonical Ltd.
3546+ * Copyright 2010-2012 Canonical Ltd.
3547 *
3548 * This program is free software: you can redistribute it and/or modify it
3549 * under the terms of either or both of the following licenses:
3550@@ -21,6 +21,7 @@
3551 *
3552 * Authored by: Jason Smith <jason.smith@canonical.com>
3553 * Neil Jagdish Patel <neil.patel@canonical.com>
3554+ * Marco Trevisan (Treviño) <3v1n0@ubuntu.com>
3555 *
3556 */
3557 /**
3558@@ -34,16 +35,14 @@
3559 #include <config.h>
3560 #endif
3561
3562+#include <libbamf-private/bamf-private.h>
3563+
3564 #include "bamf-view.h"
3565 #include "bamf-view-private.h"
3566 #include "bamf-factory.h"
3567+#include "bamf-tab.h"
3568 #include "bamf-window.h"
3569 #include "bamf-marshal.h"
3570-#include "bamf-tab.h"
3571-
3572-#include <dbus/dbus.h>
3573-#include <dbus/dbus-glib.h>
3574-#include <dbus/dbus-glib-lowlevel.h>
3575
3576 G_DEFINE_TYPE (BamfView, bamf_view, G_TYPE_INITIALLY_UNOWNED);
3577
3578@@ -52,23 +51,15 @@
3579
3580 enum
3581 {
3582- BAMF_VIEW_RUNNING_FLAG = 1 << 0,
3583- BAMF_VIEW_URGENT_FLAG = 1 << 1,
3584- BAMF_VIEW_VISIBLE_FLAG = 1 << 2,
3585- BAMF_VIEW_ACTIVE_FLAG = 1 << 3,
3586-};
3587-
3588-enum
3589-{
3590 ACTIVE_CHANGED,
3591 CLOSED,
3592 CHILD_ADDED,
3593 CHILD_REMOVED,
3594+ CHILD_MOVED,
3595 RUNNING_CHANGED,
3596 URGENT_CHANGED,
3597 VISIBLE_CHANGED,
3598 NAME_CHANGED,
3599- CHILD_MOVED,
3600 LAST_SIGNAL,
3601 };
3602
3603@@ -87,62 +78,16 @@
3604
3605 struct _BamfViewPrivate
3606 {
3607- DBusGConnection *connection;
3608- DBusGProxy *proxy;
3609- gchar *path;
3610- gchar *type;
3611- gchar *local_icon;
3612- gchar *local_name;
3613- guint checked_flags;
3614- guint set_flags;
3615- gboolean is_closed;
3616- gboolean sticky;
3617- GList *cached_children;
3618-};
3619+ BamfDBusItemView *proxy;
3620+ gchar *type;
3621+ gchar *local_icon;
3622+ gchar *local_name;
3623+ gboolean is_closed;
3624+ gboolean sticky;
3625+ GList *cached_children;};
3626
3627 static void bamf_view_unset_proxy (BamfView *self);
3628
3629-static void
3630-bamf_view_set_flag (BamfView *view, guint flag, gboolean value)
3631-{
3632- BamfViewPrivate *priv;
3633-
3634- g_return_if_fail (BAMF_IS_VIEW (view));
3635-
3636- priv = view->priv;
3637-
3638- if (value)
3639- priv->set_flags |= flag;
3640- else
3641- priv->set_flags &= ~flag;
3642-
3643- priv->checked_flags |= flag;
3644-}
3645-
3646-static gboolean
3647-bamf_view_flag_is_set (BamfView *view, guint flag)
3648-{
3649- BamfViewPrivate *priv;
3650-
3651- g_return_val_if_fail (BAMF_IS_VIEW (view), FALSE);
3652-
3653- priv = view->priv;
3654-
3655- return priv->checked_flags & flag;
3656-}
3657-
3658-static gboolean
3659-bamf_view_get_flag (BamfView *view, guint flag)
3660-{
3661- BamfViewPrivate *priv;
3662-
3663- g_return_val_if_fail (BAMF_IS_VIEW (view), FALSE);
3664-
3665- priv = view->priv;
3666-
3667- return priv->set_flags & flag;
3668-}
3669-
3670 /**
3671 * bamf_view_get_children:
3672 * @view: a #BamfView
3673@@ -174,14 +119,9 @@
3674 if (priv->cached_children)
3675 return g_list_copy (priv->cached_children);
3676
3677- if (!dbus_g_proxy_call (priv->proxy,
3678- "Children",
3679- &error,
3680- G_TYPE_INVALID,
3681- G_TYPE_STRV, &children,
3682- G_TYPE_INVALID))
3683+ if (!bamf_dbus_item_view_call_children_sync (priv->proxy, &children, NULL, &error))
3684 {
3685- g_warning ("Unable to fetch children: %s\n", error->message);
3686+ g_warning ("Unable to fetch children: %s\n", error ? error->message : "");
3687 g_error_free (error);
3688 return NULL;
3689 }
3690@@ -191,7 +131,7 @@
3691
3692 len = g_strv_length (children);
3693
3694- for (i = len-1; i >= 0; i--)
3695+ for (i = len-1; i >= 0; --i)
3696 {
3697 view = _bamf_factory_view_for_path (_bamf_factory_get_default (), children[i]);
3698 results = g_list_prepend (results, g_object_ref (view));
3699@@ -201,39 +141,6 @@
3700 return g_list_copy (priv->cached_children);
3701 }
3702
3703-static gboolean
3704-bamf_view_get_boolean (BamfView *self, const char *method_name, guint flag)
3705-{
3706- BamfViewPrivate *priv;
3707- gboolean result = FALSE;
3708- GError *error = NULL;
3709-
3710- g_return_val_if_fail (BAMF_IS_VIEW (self), FALSE);
3711- priv = self->priv;
3712-
3713- if (bamf_view_flag_is_set (self, flag))
3714- return bamf_view_get_flag (self, flag);
3715-
3716- if (!_bamf_view_remote_ready (self))
3717- return FALSE;
3718-
3719- if (!dbus_g_proxy_call (priv->proxy,
3720- method_name,
3721- &error,
3722- G_TYPE_INVALID,
3723- G_TYPE_BOOLEAN, &result,
3724- G_TYPE_INVALID))
3725- {
3726- g_warning ("Failed to fetch boolean: %s", error->message);
3727- g_error_free (error);
3728-
3729- return FALSE;
3730- }
3731-
3732- bamf_view_set_flag (self, flag, result);
3733- return result;
3734-}
3735-
3736 /**
3737 * bamf_view_is_closed:
3738 * @view: a #BamfView
3739@@ -262,7 +169,10 @@
3740 if (BAMF_VIEW_GET_CLASS (view)->is_active)
3741 return BAMF_VIEW_GET_CLASS (view)->is_active (view);
3742
3743- return bamf_view_get_boolean (view, "IsActive", BAMF_VIEW_ACTIVE_FLAG);
3744+ if (!_bamf_view_remote_ready (view))
3745+ return FALSE;
3746+
3747+ return bamf_dbus_item_view_get_active (view->priv->proxy);
3748
3749 }
3750
3751@@ -279,8 +189,14 @@
3752 bamf_view_is_user_visible (BamfView *self)
3753 {
3754 g_return_val_if_fail (BAMF_IS_VIEW (self), FALSE);
3755-
3756- return bamf_view_get_boolean (self, "UserVisible", BAMF_VIEW_VISIBLE_FLAG);
3757+
3758+ if (BAMF_VIEW_GET_CLASS (self)->is_user_visible)
3759+ return BAMF_VIEW_GET_CLASS (self)->is_user_visible (self);
3760+
3761+ if (!_bamf_view_remote_ready (self))
3762+ return FALSE;
3763+
3764+ return bamf_dbus_item_view_get_user_visible (self->priv->proxy);
3765 }
3766
3767 /**
3768@@ -308,11 +224,14 @@
3769 bamf_view_is_running (BamfView *self)
3770 {
3771 g_return_val_if_fail (BAMF_IS_VIEW (self), FALSE);
3772-
3773+
3774 if (BAMF_VIEW_GET_CLASS (self)->is_running)
3775 return BAMF_VIEW_GET_CLASS (self)->is_running (self);
3776
3777- return bamf_view_get_boolean (self, "IsRunning", BAMF_VIEW_RUNNING_FLAG);
3778+ if (!_bamf_view_remote_ready (self))
3779+ return FALSE;
3780+
3781+ return bamf_dbus_item_view_get_running (self->priv->proxy);
3782 }
3783
3784 /**
3785@@ -325,28 +244,28 @@
3786 bamf_view_is_urgent (BamfView *self)
3787 {
3788 g_return_val_if_fail (BAMF_IS_VIEW (self), FALSE);
3789-
3790+
3791 if (BAMF_VIEW_GET_CLASS (self)->is_urgent)
3792 return BAMF_VIEW_GET_CLASS (self)->is_urgent (self);
3793
3794- return bamf_view_get_boolean (self, "IsUrgent", BAMF_VIEW_URGENT_FLAG);
3795+ if (!_bamf_view_remote_ready (self))
3796+ return FALSE;
3797+
3798+ return bamf_dbus_item_view_get_urgent (self->priv->proxy);
3799 }
3800
3801 void
3802 _bamf_view_set_name (BamfView *view, const char *name)
3803 {
3804 g_return_if_fail (BAMF_IS_VIEW (view));
3805-
3806- if (!g_strcmp0 (name, view->priv->local_name))
3807+
3808+ if (g_strcmp0 (name, view->priv->local_name) == 0)
3809 return;
3810
3811 g_free (view->priv->local_name);
3812+ view->priv->local_name = NULL;
3813
3814- if (name && name[0] == '\0')
3815- {
3816- view->priv->local_name = NULL;
3817- }
3818- else
3819+ if (name && name[0] != '\0')
3820 {
3821 view->priv->local_name = g_strdup (name);
3822 }
3823@@ -358,35 +277,32 @@
3824 g_return_if_fail (BAMF_IS_VIEW (view));
3825
3826 g_free (view->priv->local_icon);
3827+ view->priv->local_icon = NULL;
3828
3829- if (icon && icon[0] == '\0')
3830- {
3831- view->priv->local_icon = NULL;
3832- }
3833- else
3834+ if (icon && icon[0] != '\0')
3835 {
3836 view->priv->local_icon = g_strdup (icon);
3837 }
3838 }
3839
3840-gboolean
3841+gboolean
3842 bamf_view_is_sticky (BamfView *view)
3843 {
3844 g_return_val_if_fail (BAMF_IS_VIEW (view), FALSE);
3845-
3846+
3847 return view->priv->sticky;
3848 }
3849
3850-void
3851+void
3852 bamf_view_set_sticky (BamfView *view, gboolean value)
3853 {
3854 g_return_if_fail (BAMF_IS_VIEW (view));
3855-
3856+
3857 if (value == view->priv->sticky)
3858 return;
3859
3860 view->priv->sticky = value;
3861-
3862+
3863 if (value)
3864 g_object_ref_sink (view);
3865 else
3866@@ -408,40 +324,32 @@
3867
3868 g_return_val_if_fail (BAMF_IS_VIEW (self), NULL);
3869 priv = self->priv;
3870-
3871+
3872 if (BAMF_VIEW_GET_CLASS (self)->get_icon)
3873 return BAMF_VIEW_GET_CLASS (self)->get_icon (self);
3874
3875 if (!_bamf_view_remote_ready (self))
3876 return g_strdup (priv->local_icon);
3877
3878- if (!dbus_g_proxy_call (priv->proxy,
3879- "Icon",
3880- &error,
3881- G_TYPE_INVALID,
3882- G_TYPE_STRING, &icon,
3883- G_TYPE_INVALID))
3884+ if (!bamf_dbus_item_view_call_icon_sync (priv->proxy, &icon, NULL, &error))
3885 {
3886- g_warning ("Failed to fetch icon: %s", error->message);
3887+ g_warning ("Failed to fetch icon: %s", error ? error->message : "");
3888 g_error_free (error);
3889-
3890- return NULL;
3891- }
3892-
3893- if (icon && icon[0] == '\0')
3894- {
3895- g_free (icon);
3896- return NULL;
3897- }
3898-
3899- return icon;
3900+
3901+ return NULL;
3902+ }
3903+
3904+ _bamf_view_set_icon (self, icon);
3905+ g_free (icon);
3906+
3907+ return g_strdup (priv->local_icon);
3908 }
3909
3910 /**
3911 * bamf_view_get_name:
3912 * @view: a #BamfView
3913 *
3914- * Gets the name of a view. This name is a short name best used to represent the view with text.
3915+ * Gets the name of a view. This name is a short name best used to represent the view with text.
3916 */
3917 gchar *
3918 bamf_view_get_name (BamfView *self)
3919@@ -452,39 +360,31 @@
3920
3921 g_return_val_if_fail (BAMF_IS_VIEW (self), NULL);
3922 priv = self->priv;
3923-
3924+
3925 if (BAMF_VIEW_GET_CLASS (self)->get_name)
3926 return BAMF_VIEW_GET_CLASS (self)->get_name (self);
3927
3928- if (!_bamf_view_remote_ready (self))
3929+ if (!_bamf_view_remote_ready (self) || priv->local_name)
3930 return g_strdup (priv->local_name);
3931-
3932- if (!dbus_g_proxy_call (priv->proxy,
3933- "Name",
3934- &error,
3935- G_TYPE_INVALID,
3936- G_TYPE_STRING, &name,
3937- G_TYPE_INVALID))
3938+
3939+ if (!bamf_dbus_item_view_call_name_sync (priv->proxy, &name, NULL, &error))
3940 {
3941- g_warning ("Failed to fetch name: %s", error->message);
3942+ g_warning ("Failed to fetch name: %s", error ? error->message : "");
3943 g_error_free (error);
3944-
3945- return NULL;
3946- }
3947-
3948- if (name && name[0] == '\0')
3949- {
3950- g_free (name);
3951- return NULL;
3952- }
3953-
3954- return name;
3955+
3956+ return NULL;
3957+ }
3958+
3959+ _bamf_view_set_name (self, name);
3960+ g_free (name);
3961+
3962+ return g_strdup (priv->local_name);
3963 }
3964
3965-gboolean
3966+gboolean
3967 _bamf_view_remote_ready (BamfView *view)
3968 {
3969- if (BAMF_IS_VIEW (view) && view->priv->proxy)
3970+ if (BAMF_IS_VIEW (view) && G_IS_DBUS_PROXY (view->priv->proxy))
3971 return !view->priv->is_closed;
3972
3973 return FALSE;
3974@@ -508,21 +408,20 @@
3975
3976 g_return_val_if_fail (BAMF_IS_VIEW (self), NULL);
3977 priv = self->priv;
3978-
3979+
3980 if (BAMF_VIEW_GET_CLASS (self)->view_type)
3981 return BAMF_VIEW_GET_CLASS (self)->view_type (self);
3982-
3983+
3984 if (priv->type)
3985 return priv->type;
3986
3987- if (!dbus_g_proxy_call (priv->proxy,
3988- "ViewType",
3989- &error,
3990- G_TYPE_INVALID,
3991- G_TYPE_STRING, &type,
3992- G_TYPE_INVALID))
3993+ if (!_bamf_view_remote_ready (self))
3994+ return NULL;
3995+
3996+ if (!bamf_dbus_item_view_call_view_type_sync (priv->proxy, &type, NULL, &error))
3997 {
3998- g_warning ("Failed to fetch view type at %s: %s", dbus_g_proxy_get_path (priv->proxy), error ? error->message : "");
3999+ const gchar *path = g_dbus_proxy_get_object_path (G_DBUS_PROXY (priv->proxy));
4000+ g_warning ("Failed to fetch view type at %s: %s", path, error ? error->message : "");
4001 g_error_free (error);
4002 return NULL;
4003 }
4004@@ -531,14 +430,14 @@
4005 return type;
4006 }
4007
4008-BamfClickBehavior
4009+BamfClickBehavior
4010 bamf_view_get_click_suggestion (BamfView *self)
4011 {
4012 g_return_val_if_fail (BAMF_IS_VIEW (self), BAMF_CLICK_BEHAVIOR_NONE);
4013
4014 if (BAMF_VIEW_GET_CLASS (self)->click_behavior)
4015 return BAMF_VIEW_GET_CLASS (self)->click_behavior (self);
4016-
4017+
4018 return BAMF_CLICK_BEHAVIOR_NONE;
4019 }
4020
4021@@ -546,25 +445,27 @@
4022 bamf_view_child_xid_changed (GObject *object, GParamSpec *pspec, gpointer user_data)
4023 {
4024 BamfView *self;
4025-
4026+
4027 self = (BamfView *)user_data;
4028-
4029+
4030 g_signal_emit (G_OBJECT (self), view_signals[CHILD_MOVED], 0, BAMF_VIEW (object));
4031 g_signal_emit (G_OBJECT (self), view_signals[VISIBLE_CHANGED], 0);
4032 }
4033
4034 static void
4035-bamf_view_on_child_added (DBusGProxy *proxy, char *path, BamfView *self)
4036+bamf_view_on_child_added (BamfDBusItemView *proxy, const char *path, BamfView *self)
4037 {
4038 BamfView *view;
4039 BamfViewPrivate *priv;
4040
4041 view = _bamf_factory_view_for_path (_bamf_factory_get_default (), path);
4042 priv = self->priv;
4043-
4044+
4045 if (BAMF_IS_TAB (view))
4046- g_signal_connect (view, "notify::xid",
4047- G_CALLBACK (bamf_view_child_xid_changed), self);
4048+ {
4049+ g_signal_connect (view, "notify::xid",
4050+ G_CALLBACK (bamf_view_child_xid_changed), self);
4051+ }
4052
4053 if (priv->cached_children)
4054 {
4055@@ -576,13 +477,13 @@
4056 }
4057
4058 static void
4059-bamf_view_on_child_removed (DBusGProxy *proxy, char *path, BamfView *self)
4060+bamf_view_on_child_removed (BamfDBusItemView *proxy, char *path, BamfView *self)
4061 {
4062 BamfView *view;
4063 BamfViewPrivate *priv;
4064 view = _bamf_factory_view_for_path (_bamf_factory_get_default (), path);
4065 priv = self->priv;
4066-
4067+
4068 if (BAMF_IS_TAB (view))
4069 g_signal_handlers_disconnect_by_func (view, bamf_view_on_child_added, self);
4070
4071@@ -596,66 +497,47 @@
4072 }
4073
4074 static void
4075-bamf_view_on_active_changed (DBusGProxy *proxy, gboolean active, BamfView *self)
4076+bamf_view_on_active_changed (BamfDBusItemView *proxy, GParamSpec *param, BamfView *self)
4077 {
4078- bamf_view_set_flag (self, BAMF_VIEW_ACTIVE_FLAG, active);
4079-
4080- g_signal_emit (G_OBJECT(self), view_signals[ACTIVE_CHANGED], 0, active);
4081+ gboolean active = bamf_dbus_item_view_get_active (proxy);
4082+ g_signal_emit (G_OBJECT (self), view_signals[ACTIVE_CHANGED], 0, active);
4083 g_object_notify (G_OBJECT (self), "active");
4084 }
4085
4086 static void
4087-bamf_view_on_name_changed (DBusGProxy* proxy,
4088- const gchar* old_name,
4089- const gchar* new_name,
4090- BamfView* self)
4091+bamf_view_on_name_changed (BamfDBusItemView *proxy,
4092+ const gchar *old_name,
4093+ const gchar *new_name,
4094+ BamfView *self)
4095 {
4096- g_free (self->priv->local_name);
4097- self->priv->local_name = g_strdup (new_name);
4098-
4099+ _bamf_view_set_name (self, new_name);
4100 g_signal_emit (self, view_signals[NAME_CHANGED], 0, old_name, new_name);
4101 }
4102
4103 static void
4104-bamf_view_on_running_changed (DBusGProxy *proxy, gboolean running, BamfView *self)
4105+bamf_view_on_running_changed (BamfDBusItemView *proxy, GParamSpec *param, BamfView *self)
4106 {
4107- bamf_view_set_flag (self, BAMF_VIEW_RUNNING_FLAG, running);
4108-
4109+ gboolean running = bamf_dbus_item_view_get_running (proxy);
4110 g_signal_emit (G_OBJECT (self), view_signals[RUNNING_CHANGED], 0, running);
4111 g_object_notify (G_OBJECT (self), "running");
4112 }
4113
4114 static void
4115-bamf_view_on_urgent_changed (DBusGProxy *proxy, gboolean urgent, BamfView *self)
4116+bamf_view_on_urgent_changed (BamfDBusItemView *proxy, GParamSpec *param, BamfView *self)
4117 {
4118- bamf_view_set_flag (self, BAMF_VIEW_URGENT_FLAG, urgent);
4119-
4120+ gboolean urgent = bamf_dbus_item_view_get_urgent (proxy);
4121 g_signal_emit (G_OBJECT (self), view_signals[URGENT_CHANGED], 0, urgent);
4122 g_object_notify (G_OBJECT (self), "urgent");
4123 }
4124
4125 static void
4126-bamf_view_on_user_visible_changed (DBusGProxy *proxy, gboolean visible, BamfView *self)
4127+bamf_view_on_user_visible_changed (BamfDBusItemView *proxy, GParamSpec *param, BamfView *self)
4128 {
4129- bamf_view_set_flag (self, BAMF_VIEW_VISIBLE_FLAG, visible);
4130-
4131- g_signal_emit (G_OBJECT (self), view_signals[VISIBLE_CHANGED], 0, visible);
4132+ gboolean user_visible = bamf_dbus_item_view_get_user_visible (proxy);
4133+ g_signal_emit (G_OBJECT (self), view_signals[VISIBLE_CHANGED], 0, user_visible);
4134 g_object_notify (G_OBJECT (self), "user-visible");
4135 }
4136
4137-static void
4138-on_view_proxy_destroyed (GObject *proxy, gpointer user_data)
4139-{
4140- BamfView *view = user_data;
4141- g_return_if_fail (BAMF_IS_VIEW (view));
4142-
4143- view->priv->checked_flags = 0x0;
4144- view->priv->proxy = NULL;
4145-
4146- g_free (view->priv->path);
4147- view->priv->path = NULL;
4148-}
4149-
4150 void
4151 _bamf_view_set_closed (BamfView *view, gboolean closed)
4152 {
4153@@ -677,8 +559,19 @@
4154 }
4155
4156 static void
4157-bamf_view_on_closed (DBusGProxy *proxy, BamfView *self)
4158+bamf_view_on_closed (BamfDBusItemView *proxy, BamfView *self)
4159 {
4160+ BamfViewPrivate *priv;
4161+
4162+ priv = self->priv;
4163+ priv->is_closed = TRUE;
4164+
4165+ if (priv->cached_children)
4166+ {
4167+ g_list_free_full (priv->cached_children, g_object_unref);
4168+ priv->cached_children = NULL;
4169+ }
4170+
4171 _bamf_view_set_closed (self, TRUE);
4172
4173 g_object_ref (self);
4174@@ -692,7 +585,7 @@
4175 switch (property_id)
4176 {
4177 default:
4178- G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
4179+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
4180 }
4181 }
4182
4183@@ -706,27 +599,27 @@
4184 switch (property_id)
4185 {
4186 case PROP_PATH:
4187- g_value_set_string (value, self->priv->is_closed ? NULL : self->priv->path);
4188+ g_value_set_string (value, self->priv->is_closed ? NULL : _bamf_view_get_path (self));
4189 break;
4190-
4191+
4192 case PROP_ACTIVE:
4193 g_value_set_boolean (value, bamf_view_is_active (self));
4194 break;
4195-
4196+
4197 case PROP_RUNNING:
4198 g_value_set_boolean (value, bamf_view_is_running (self));
4199 break;
4200-
4201+
4202 case PROP_URGENT:
4203 g_value_set_boolean (value, bamf_view_is_urgent (self));
4204 break;
4205-
4206+
4207 case PROP_USER_VISIBLE:
4208 g_value_set_boolean (value, bamf_view_is_user_visible (self));
4209 break;
4210-
4211+
4212 default:
4213- G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
4214+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
4215 }
4216 }
4217
4218@@ -741,44 +634,10 @@
4219 if (!priv->proxy)
4220 return;
4221
4222- dbus_g_proxy_disconnect_signal (priv->proxy,
4223- "ActiveChanged",
4224- (GCallback) bamf_view_on_active_changed,
4225- self);
4226-
4227- dbus_g_proxy_disconnect_signal (priv->proxy,
4228- "Closed",
4229- (GCallback) bamf_view_on_closed,
4230- self);
4231-
4232- dbus_g_proxy_disconnect_signal (priv->proxy,
4233- "ChildAdded",
4234- (GCallback) bamf_view_on_child_added,
4235- self);
4236-
4237- dbus_g_proxy_disconnect_signal (priv->proxy,
4238- "ChildRemoved",
4239- (GCallback) bamf_view_on_child_removed,
4240- self);
4241-
4242- dbus_g_proxy_disconnect_signal (priv->proxy,
4243- "RunningChanged",
4244- (GCallback) bamf_view_on_running_changed,
4245- self);
4246-
4247- dbus_g_proxy_disconnect_signal (priv->proxy,
4248- "UrgentChanged",
4249- (GCallback) bamf_view_on_urgent_changed,
4250- self);
4251-
4252- dbus_g_proxy_disconnect_signal (priv->proxy,
4253- "UserVisibleChanged",
4254- (GCallback) bamf_view_on_user_visible_changed,
4255- self);
4256-
4257- g_signal_handlers_disconnect_by_func (priv->proxy, on_view_proxy_destroyed, self);
4258- g_object_unref (priv->proxy);
4259- priv->proxy = NULL;
4260+ g_signal_handlers_disconnect_by_data (priv->proxy, self);
4261+
4262+ g_object_unref (priv->proxy);
4263+ priv->proxy = NULL;
4264 }
4265
4266 static void
4267@@ -791,18 +650,12 @@
4268
4269 priv = view->priv;
4270
4271- if (priv->path)
4272- {
4273- g_free (priv->path);
4274- priv->path = NULL;
4275- }
4276-
4277 if (priv->type)
4278 {
4279 g_free (priv->type);
4280 priv->type = NULL;
4281 }
4282-
4283+
4284 if (priv->local_icon)
4285 {
4286 g_free (priv->local_icon);
4287@@ -831,170 +684,96 @@
4288 {
4289 g_return_val_if_fail (BAMF_IS_VIEW (view), NULL);
4290
4291- return view->priv->path;
4292+ if (G_IS_DBUS_PROXY (view->priv->proxy))
4293+ return g_dbus_proxy_get_object_path (G_DBUS_PROXY (view->priv->proxy));
4294+
4295+ return NULL;
4296 }
4297
4298 void
4299 _bamf_view_reset_flags (BamfView *view)
4300 {
4301- BamfViewPrivate *priv;
4302+ gboolean user_visible;
4303+ gboolean active;
4304+ gboolean running;
4305+ gboolean urgent;
4306+
4307 g_return_if_fail (BAMF_IS_VIEW (view));
4308
4309- priv = view->priv;
4310- priv->checked_flags = 0x0;
4311-
4312- if (bamf_view_is_user_visible (view))
4313- {
4314- g_signal_emit (G_OBJECT(view), view_signals[VISIBLE_CHANGED], 0, TRUE);
4315- g_object_notify (G_OBJECT (view), "user-visible");
4316- }
4317-
4318- if (bamf_view_is_active (view))
4319- {
4320- g_signal_emit (G_OBJECT(view), view_signals[ACTIVE_CHANGED], 0, TRUE);
4321- g_object_notify (G_OBJECT (view), "active");
4322- }
4323-
4324- if (bamf_view_is_running (view))
4325- {
4326- g_signal_emit (G_OBJECT(view), view_signals[RUNNING_CHANGED], 0, TRUE);
4327- g_object_notify (G_OBJECT (view), "running");
4328- }
4329-
4330- if (bamf_view_is_urgent (view))
4331- {
4332- g_signal_emit (G_OBJECT(view), view_signals[URGENT_CHANGED], 0, TRUE);
4333- g_object_notify (G_OBJECT (view), "urgent");
4334- }
4335+ user_visible = bamf_view_is_user_visible (view);
4336+ g_signal_emit (G_OBJECT (view), view_signals[VISIBLE_CHANGED], 0, user_visible);
4337+ g_object_notify (G_OBJECT (view), "user-visible");
4338+
4339+ active = bamf_view_is_active (view);
4340+ g_signal_emit (G_OBJECT (view), view_signals[ACTIVE_CHANGED], 0, active);
4341+ g_object_notify (G_OBJECT (view), "active");
4342+
4343+ running = bamf_view_is_running (view);
4344+ g_signal_emit (G_OBJECT (view), view_signals[RUNNING_CHANGED], 0, running);
4345+ g_object_notify (G_OBJECT (view), "running");
4346+
4347+ urgent = bamf_view_is_urgent (view);
4348+ g_signal_emit (G_OBJECT (view), view_signals[URGENT_CHANGED], 0, urgent);
4349+ g_object_notify (G_OBJECT (view), "urgent");
4350 }
4351
4352 void
4353 _bamf_view_set_path (BamfView *view, const char *path)
4354 {
4355 BamfViewPrivate *priv;
4356+ GError *error = NULL;
4357
4358 g_return_if_fail (BAMF_IS_VIEW (view));
4359 g_return_if_fail (path);
4360
4361 priv = view->priv;
4362
4363- _bamf_view_set_closed (view, FALSE);
4364-
4365- if (priv->proxy && g_strcmp0 (priv->path, path) == 0)
4366- {
4367- // The proxy path has not been changed, no need to unset and re-set it again
4368- return;
4369- }
4370-
4371- g_free (priv->path);
4372+ priv->is_closed = FALSE;
4373+
4374+ if (g_strcmp0 (_bamf_view_get_path (view), path) == 0)
4375+ {
4376+ // The proxy path has not been changed, no need to unset and re-set it again
4377+ _bamf_view_reset_flags (view);
4378+ return;
4379+ }
4380+
4381 bamf_view_unset_proxy (view);
4382-
4383- priv->path = g_strdup (path);
4384- priv->proxy = dbus_g_proxy_new_for_name (priv->connection,
4385- "org.ayatana.bamf",
4386- priv->path,
4387- "org.ayatana.bamf.view");
4388-
4389- if (priv->proxy == NULL)
4390+ priv->proxy = bamf_dbus_item_view_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
4391+ G_DBUS_PROXY_FLAGS_NONE,
4392+ BAMF_DBUS_SERVICE_NAME,
4393+ path, NULL, &error);
4394+ if (!G_IS_DBUS_PROXY (priv->proxy))
4395 {
4396- g_critical ("Unable to get org.ayatana.bamf.view view");
4397+ g_critical ("Unable to get "BAMF_DBUS_SERVICE_NAME" view: %s", error ? error ? error->message : "" : "");
4398+ g_error_free (error);
4399 return;
4400 }
4401
4402- g_signal_connect (priv->proxy, "destroy", G_CALLBACK (on_view_proxy_destroyed), view);
4403-
4404- dbus_g_proxy_add_signal (priv->proxy,
4405- "ActiveChanged",
4406- G_TYPE_BOOLEAN,
4407- G_TYPE_INVALID);
4408-
4409- dbus_g_proxy_add_signal (priv->proxy,
4410- "Closed",
4411- G_TYPE_INVALID);
4412-
4413- dbus_g_proxy_add_signal (priv->proxy,
4414- "ChildAdded",
4415- G_TYPE_STRING,
4416- G_TYPE_INVALID);
4417-
4418- dbus_g_proxy_add_signal (priv->proxy,
4419- "ChildRemoved",
4420- G_TYPE_STRING,
4421- G_TYPE_INVALID);
4422-
4423- dbus_g_proxy_add_signal (priv->proxy,
4424- "RunningChanged",
4425- G_TYPE_BOOLEAN,
4426- G_TYPE_INVALID);
4427-
4428- dbus_g_proxy_add_signal (priv->proxy,
4429- "UrgentChanged",
4430- G_TYPE_BOOLEAN,
4431- G_TYPE_INVALID);
4432-
4433- dbus_g_proxy_add_signal (priv->proxy,
4434- "UserVisibleChanged",
4435- G_TYPE_BOOLEAN,
4436- G_TYPE_INVALID);
4437-
4438- dbus_g_proxy_add_signal (priv->proxy,
4439- "NameChanged",
4440- G_TYPE_STRING,
4441- G_TYPE_STRING,
4442- G_TYPE_INVALID);
4443-
4444- dbus_g_proxy_connect_signal (priv->proxy,
4445- "ActiveChanged",
4446- (GCallback) bamf_view_on_active_changed,
4447- view,
4448- NULL);
4449-
4450- dbus_g_proxy_connect_signal (priv->proxy,
4451- "Closed",
4452- (GCallback) bamf_view_on_closed,
4453- view,
4454- NULL);
4455-
4456- dbus_g_proxy_connect_signal (priv->proxy,
4457- "ChildAdded",
4458- (GCallback) bamf_view_on_child_added,
4459- view,
4460- NULL);
4461-
4462- dbus_g_proxy_connect_signal (priv->proxy,
4463- "ChildRemoved",
4464- (GCallback) bamf_view_on_child_removed,
4465- view,
4466- NULL);
4467-
4468- dbus_g_proxy_connect_signal (priv->proxy,
4469- "RunningChanged",
4470- (GCallback) bamf_view_on_running_changed,
4471- view,
4472- NULL);
4473-
4474- dbus_g_proxy_connect_signal (priv->proxy,
4475- "UrgentChanged",
4476- (GCallback) bamf_view_on_urgent_changed,
4477- view,
4478- NULL);
4479-
4480- dbus_g_proxy_connect_signal (priv->proxy,
4481- "UserVisibleChanged",
4482- (GCallback) bamf_view_on_user_visible_changed,
4483- view,
4484- NULL);
4485-
4486- dbus_g_proxy_connect_signal (priv->proxy,
4487- "NameChanged",
4488- (GCallback) bamf_view_on_name_changed,
4489- view,
4490- NULL);
4491-
4492- if (bamf_view_is_sticky (view))
4493- {
4494- _bamf_view_reset_flags (view);
4495- }
4496+ _bamf_view_reset_flags (view);
4497+
4498+ g_signal_connect (priv->proxy, "notify::active",
4499+ G_CALLBACK (bamf_view_on_active_changed), view);
4500+
4501+ g_signal_connect (priv->proxy, "notify::running",
4502+ G_CALLBACK (bamf_view_on_running_changed), view);
4503+
4504+ g_signal_connect (priv->proxy, "notify::urgent",
4505+ G_CALLBACK (bamf_view_on_urgent_changed), view);
4506+
4507+ g_signal_connect (priv->proxy, "notify::user-visible",
4508+ G_CALLBACK (bamf_view_on_user_visible_changed), view);
4509+
4510+ g_signal_connect (priv->proxy, "name-changed",
4511+ G_CALLBACK (bamf_view_on_name_changed), view);
4512+
4513+ g_signal_connect (priv->proxy, "child-added",
4514+ G_CALLBACK (bamf_view_on_child_added), view);
4515+
4516+ g_signal_connect (priv->proxy, "child-removed",
4517+ G_CALLBACK (bamf_view_on_child_removed), view);
4518+
4519+ g_signal_connect (priv->proxy, "closed",
4520+ G_CALLBACK (bamf_view_on_closed), view);
4521
4522 if (BAMF_VIEW_GET_CLASS (view)->set_path)
4523 BAMF_VIEW_GET_CLASS (view)->set_path (view, path);
4524@@ -1020,62 +799,62 @@
4525
4526 pspec = g_param_spec_string ("path", "path", "path", NULL, G_PARAM_READABLE);
4527 g_object_class_install_property (obj_class, PROP_PATH, pspec);
4528-
4529+
4530 pspec = g_param_spec_boolean ("active", "active", "active", FALSE, G_PARAM_READABLE);
4531 g_object_class_install_property (obj_class, PROP_ACTIVE, pspec);
4532
4533 pspec = g_param_spec_boolean ("urgent", "urgent", "urgent", FALSE, G_PARAM_READABLE);
4534 g_object_class_install_property (obj_class, PROP_URGENT, pspec);
4535-
4536+
4537 pspec = g_param_spec_boolean ("running", "running", "running", FALSE, G_PARAM_READABLE);
4538 g_object_class_install_property (obj_class, PROP_RUNNING, pspec);
4539-
4540+
4541 pspec = g_param_spec_boolean ("user-visible", "user-visible", "user-visible", FALSE, G_PARAM_READABLE);
4542 g_object_class_install_property (obj_class, PROP_USER_VISIBLE, pspec);
4543
4544 g_type_class_add_private (obj_class, sizeof (BamfViewPrivate));
4545
4546- view_signals [ACTIVE_CHANGED] =
4547- g_signal_new ("active-changed",
4548- G_OBJECT_CLASS_TYPE (klass),
4549- G_SIGNAL_RUN_FIRST,
4550- G_STRUCT_OFFSET (BamfViewClass, active_changed),
4551- NULL, NULL,
4552- g_cclosure_marshal_VOID__BOOLEAN,
4553- G_TYPE_NONE, 1,
4554- G_TYPE_BOOLEAN);
4555-
4556- view_signals [CLOSED] =
4557- g_signal_new ("closed",
4558- G_OBJECT_CLASS_TYPE (klass),
4559- G_SIGNAL_RUN_FIRST,
4560- G_STRUCT_OFFSET (BamfViewClass, closed),
4561- NULL, NULL,
4562- g_cclosure_marshal_VOID__VOID,
4563- G_TYPE_NONE, 0);
4564-
4565- view_signals [CHILD_ADDED] =
4566- g_signal_new ("child-added",
4567- G_OBJECT_CLASS_TYPE (klass),
4568- G_SIGNAL_RUN_FIRST,
4569- G_STRUCT_OFFSET (BamfViewClass, child_added),
4570- NULL, NULL,
4571- g_cclosure_marshal_VOID__OBJECT,
4572- G_TYPE_NONE, 1,
4573- BAMF_TYPE_VIEW);
4574-
4575- view_signals [CHILD_REMOVED] =
4576- g_signal_new ("child-removed",
4577- G_OBJECT_CLASS_TYPE (klass),
4578- G_SIGNAL_RUN_FIRST,
4579- G_STRUCT_OFFSET (BamfViewClass, child_removed),
4580- NULL, NULL,
4581- g_cclosure_marshal_VOID__OBJECT,
4582- G_TYPE_NONE, 1,
4583- BAMF_TYPE_VIEW);
4584-
4585- view_signals [CHILD_MOVED] =
4586- g_signal_new ("child-moved",
4587+ view_signals [ACTIVE_CHANGED] =
4588+ g_signal_new (BAMF_VIEW_SIGNAL_ACTIVE_CHANGED,
4589+ G_OBJECT_CLASS_TYPE (klass),
4590+ G_SIGNAL_RUN_FIRST,
4591+ G_STRUCT_OFFSET (BamfViewClass, active_changed),
4592+ NULL, NULL,
4593+ g_cclosure_marshal_VOID__BOOLEAN,
4594+ G_TYPE_NONE, 1,
4595+ G_TYPE_BOOLEAN);
4596+
4597+ view_signals [CLOSED] =
4598+ g_signal_new (BAMF_VIEW_SIGNAL_CLOSED,
4599+ G_OBJECT_CLASS_TYPE (klass),
4600+ G_SIGNAL_RUN_FIRST,
4601+ G_STRUCT_OFFSET (BamfViewClass, closed),
4602+ NULL, NULL,
4603+ g_cclosure_marshal_VOID__VOID,
4604+ G_TYPE_NONE, 0);
4605+
4606+ view_signals [CHILD_ADDED] =
4607+ g_signal_new (BAMF_VIEW_SIGNAL_CHILD_ADDED,
4608+ G_OBJECT_CLASS_TYPE (klass),
4609+ G_SIGNAL_RUN_FIRST,
4610+ G_STRUCT_OFFSET (BamfViewClass, child_added),
4611+ NULL, NULL,
4612+ g_cclosure_marshal_VOID__OBJECT,
4613+ G_TYPE_NONE, 1,
4614+ BAMF_TYPE_VIEW);
4615+
4616+ view_signals [CHILD_REMOVED] =
4617+ g_signal_new (BAMF_VIEW_SIGNAL_CHILD_REMOVED,
4618+ G_OBJECT_CLASS_TYPE (klass),
4619+ G_SIGNAL_RUN_FIRST,
4620+ G_STRUCT_OFFSET (BamfViewClass, child_removed),
4621+ NULL, NULL,
4622+ g_cclosure_marshal_VOID__OBJECT,
4623+ G_TYPE_NONE, 1,
4624+ BAMF_TYPE_VIEW);
4625+
4626+ view_signals [CHILD_MOVED] =
4627+ g_signal_new (BAMF_VIEW_SIGNAL_CHILD_MOVED,
4628 G_OBJECT_CLASS_TYPE (klass),
4629 G_SIGNAL_RUN_FIRST,
4630 G_STRUCT_OFFSET (BamfViewClass, child_moved),
4631@@ -1084,65 +863,53 @@
4632 G_TYPE_NONE, 1,
4633 BAMF_TYPE_VIEW);
4634
4635- view_signals [RUNNING_CHANGED] =
4636- g_signal_new ("running-changed",
4637- G_OBJECT_CLASS_TYPE (klass),
4638- G_SIGNAL_RUN_FIRST,
4639- G_STRUCT_OFFSET (BamfViewClass, running_changed),
4640- NULL, NULL,
4641- g_cclosure_marshal_VOID__BOOLEAN,
4642- G_TYPE_NONE, 1,
4643- G_TYPE_BOOLEAN);
4644-
4645- view_signals [URGENT_CHANGED] =
4646- g_signal_new ("urgent-changed",
4647- G_OBJECT_CLASS_TYPE (klass),
4648- G_SIGNAL_RUN_FIRST,
4649- G_STRUCT_OFFSET (BamfViewClass, urgent_changed),
4650- NULL, NULL,
4651- g_cclosure_marshal_VOID__BOOLEAN,
4652- G_TYPE_NONE, 1,
4653- G_TYPE_BOOLEAN);
4654-
4655- view_signals [VISIBLE_CHANGED] =
4656- g_signal_new ("user-visible-changed",
4657- G_OBJECT_CLASS_TYPE (klass),
4658- G_SIGNAL_RUN_FIRST,
4659- G_STRUCT_OFFSET (BamfViewClass, user_visible_changed),
4660- NULL, NULL,
4661- g_cclosure_marshal_VOID__BOOLEAN,
4662- G_TYPE_NONE, 1,
4663- G_TYPE_BOOLEAN);
4664+ view_signals [RUNNING_CHANGED] =
4665+ g_signal_new (BAMF_VIEW_SIGNAL_RUNNING_CHANGED,
4666+ G_OBJECT_CLASS_TYPE (klass),
4667+ G_SIGNAL_RUN_FIRST,
4668+ G_STRUCT_OFFSET (BamfViewClass, running_changed),
4669+ NULL, NULL,
4670+ g_cclosure_marshal_VOID__BOOLEAN,
4671+ G_TYPE_NONE, 1,
4672+ G_TYPE_BOOLEAN);
4673+
4674+ view_signals [URGENT_CHANGED] =
4675+ g_signal_new (BAMF_VIEW_SIGNAL_URGENT_CHANGED,
4676+ G_OBJECT_CLASS_TYPE (klass),
4677+ G_SIGNAL_RUN_FIRST,
4678+ G_STRUCT_OFFSET (BamfViewClass, urgent_changed),
4679+ NULL, NULL,
4680+ g_cclosure_marshal_VOID__BOOLEAN,
4681+ G_TYPE_NONE, 1,
4682+ G_TYPE_BOOLEAN);
4683+
4684+ view_signals [VISIBLE_CHANGED] =
4685+ g_signal_new (BAMF_VIEW_SIGNAL_USER_VISIBLE_CHANGED,
4686+ G_OBJECT_CLASS_TYPE (klass),
4687+ G_SIGNAL_RUN_FIRST,
4688+ G_STRUCT_OFFSET (BamfViewClass, user_visible_changed),
4689+ NULL, NULL,
4690+ g_cclosure_marshal_VOID__BOOLEAN,
4691+ G_TYPE_NONE, 1,
4692+ G_TYPE_BOOLEAN);
4693
4694 view_signals [NAME_CHANGED] =
4695- g_signal_new ("name-changed",
4696- G_OBJECT_CLASS_TYPE (klass),
4697- 0,
4698- G_STRUCT_OFFSET (BamfViewClass, name_changed),
4699- NULL, NULL,
4700- _bamf_marshal_VOID__STRING_STRING,
4701- G_TYPE_NONE, 2,
4702- G_TYPE_STRING,
4703- G_TYPE_STRING);
4704+ g_signal_new (BAMF_VIEW_SIGNAL_NAME_CHANGED,
4705+ G_OBJECT_CLASS_TYPE (klass),
4706+ 0,
4707+ G_STRUCT_OFFSET (BamfViewClass, name_changed),
4708+ NULL, NULL,
4709+ _bamf_marshal_VOID__STRING_STRING,
4710+ G_TYPE_NONE, 2,
4711+ G_TYPE_STRING,
4712+ G_TYPE_STRING);
4713 }
4714
4715-
4716 static void
4717 bamf_view_init (BamfView *self)
4718 {
4719 BamfViewPrivate *priv;
4720- GError *error = NULL;
4721
4722 priv = self->priv = BAMF_VIEW_GET_PRIVATE (self);
4723- _bamf_view_set_closed (self, TRUE);
4724-
4725- priv->connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
4726- if (priv->connection == NULL)
4727- {
4728- g_critical ("Failed to open connection to bus: %s",
4729- error != NULL ? error->message : "Unknown");
4730- if (error)
4731- g_error_free (error);
4732- return;
4733- }
4734+ priv->is_closed = TRUE;
4735 }
4736
4737=== modified file 'lib/libbamf/bamf-view.h'
4738--- lib/libbamf/bamf-view.h 2012-10-08 13:12:08 +0000
4739+++ lib/libbamf/bamf-view.h 2013-05-15 12:27:29 +0000
4740@@ -1,5 +1,5 @@
4741 /*
4742- * Copyright 2010 Canonical Ltd.
4743+ * Copyright 2010-2011 Canonical Ltd.
4744 *
4745 * This program is free software: you can redistribute it and/or modify it
4746 * under the terms of either or both of the following licenses:
4747@@ -21,6 +21,7 @@
4748 *
4749 * Authored by: Jason Smith <jason.smith@canonical.com>
4750 * Neil Jagdish Patel <neil.patel@canonical.com>
4751+ * Marco Trevisan (Treviño) <3v1n0@ubuntu.com>
4752 *
4753 */
4754
4755@@ -48,6 +49,16 @@
4756 #define BAMF_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),\
4757 BAMF_TYPE_VIEW, BamfViewClass))
4758
4759+#define BAMF_VIEW_SIGNAL_ACTIVE_CHANGED "active-changed"
4760+#define BAMF_VIEW_SIGNAL_RUNNING_CHANGED "running-changed"
4761+#define BAMF_VIEW_SIGNAL_URGENT_CHANGED "urgent-changed"
4762+#define BAMF_VIEW_SIGNAL_USER_VISIBLE_CHANGED "user-visible-changed"
4763+#define BAMF_VIEW_SIGNAL_NAME_CHANGED "name-changed"
4764+#define BAMF_VIEW_SIGNAL_CHILD_ADDED "child-added"
4765+#define BAMF_VIEW_SIGNAL_CHILD_REMOVED "child-removed"
4766+#define BAMF_VIEW_SIGNAL_CHILD_MOVED "child-moved"
4767+#define BAMF_VIEW_SIGNAL_CLOSED "closed"
4768+
4769 typedef enum
4770 {
4771 BAMF_CLICK_BEHAVIOR_NONE,
4772@@ -74,18 +85,18 @@
4773 struct _BamfViewClass
4774 {
4775 GInitiallyUnownedClass parent_class;
4776-
4777+
4778 GList * (*get_children) (BamfView *view);
4779 gboolean (*is_active) (BamfView *view);
4780 gboolean (*is_running) (BamfView *view);
4781 gboolean (*is_urgent) (BamfView *view);
4782+ gboolean (*is_user_visible) (BamfView *view);
4783 gchar * (*get_name) (BamfView *view);
4784 gchar * (*get_icon) (BamfView *view);
4785 const gchar * (*view_type) (BamfView *view);
4786 void (*set_path) (BamfView *view, const gchar *path);
4787 BamfClickBehavior (*click_behavior) (BamfView *view);
4788-
4789-
4790+
4791 /*< signals >*/
4792 void (*active_changed) (BamfView *view, gboolean active);
4793 void (*closed) (BamfView *view);
4794@@ -122,9 +133,6 @@
4795
4796 gchar * bamf_view_get_icon (BamfView *view);
4797
4798-GLIB_DEPRECATED
4799-gboolean bamf_view_user_visible (BamfView *view);
4800-
4801 const gchar * bamf_view_get_view_type (BamfView *view);
4802
4803 void bamf_view_set_sticky (BamfView *view, gboolean value);
4804@@ -133,6 +141,10 @@
4805
4806 BamfClickBehavior bamf_view_get_click_suggestion (BamfView *view);
4807
4808+/* Deprecated symbols */
4809+G_GNUC_DEPRECATED_FOR (bamf_view_user_visible)
4810+gboolean bamf_view_user_visible (BamfView *view);
4811+
4812 G_END_DECLS
4813
4814 #endif
4815
4816=== modified file 'lib/libbamf/bamf-window.c'
4817--- lib/libbamf/bamf-window.c 2012-12-19 15:38:44 +0000
4818+++ lib/libbamf/bamf-window.c 2013-05-15 12:27:29 +0000
4819@@ -1,5 +1,5 @@
4820 /*
4821- * Copyright 2010 Canonical Ltd.
4822+ * Copyright 2010-2012 Canonical Ltd.
4823 *
4824 * This program is free software: you can redistribute it and/or modify it
4825 * under the terms of either or both of the following licenses:
4826@@ -21,6 +21,7 @@
4827 *
4828 * Authored by: Jason Smith <jason.smith@canonical.com>
4829 * Neil Jagdish Patel <neil.patel@canonical.com>
4830+ * Marco Trevisan (Treviño) <3v1n0@ubuntu.com>
4831 *
4832 */
4833 /**
4834@@ -34,13 +35,11 @@
4835 #include <config.h>
4836 #endif
4837
4838+#include <libbamf-private/bamf-private.h>
4839 #include "bamf-view-private.h"
4840 #include "bamf-window.h"
4841 #include "bamf-factory.h"
4842 #include "bamf-marshal.h"
4843-#include <dbus/dbus.h>
4844-#include <dbus/dbus-glib.h>
4845-#include <dbus/dbus-glib-lowlevel.h>
4846
4847 G_DEFINE_TYPE (BamfWindow, bamf_window, BAMF_TYPE_VIEW);
4848
4849@@ -49,12 +48,12 @@
4850
4851 struct _BamfWindowPrivate
4852 {
4853- DBusGConnection *connection;
4854- DBusGProxy *proxy;
4855- guint32 xid;
4856- guint32 pid;
4857- time_t last_active;
4858- gint monitor;
4859+ BamfDBusItemWindow *proxy;
4860+ guint32 xid;
4861+ guint32 pid;
4862+ time_t last_active;
4863+ gint monitor;
4864+ BamfWindowType type;
4865 BamfWindowMaximizationType maximized;
4866 };
4867
4868@@ -68,13 +67,14 @@
4869
4870 static guint window_signals[LAST_SIGNAL] = { 0 };
4871
4872-time_t bamf_window_last_active (BamfWindow *self)
4873+time_t
4874+bamf_window_last_active (BamfWindow *self)
4875 {
4876- g_return_val_if_fail (BAMF_IS_WINDOW (self), (time_t) 0);
4877+ g_return_val_if_fail (BAMF_IS_WINDOW (self), 0);
4878
4879 if (BAMF_WINDOW_GET_CLASS (self)->last_active)
4880 return BAMF_WINDOW_GET_CLASS (self)->last_active (self);
4881-
4882+
4883 return self->priv->last_active;
4884 }
4885
4886@@ -85,7 +85,8 @@
4887 * Returns: (transfer none) (allow-none): A transient for this #BamfWindow.
4888 */
4889
4890-BamfWindow * bamf_window_get_transient (BamfWindow *self)
4891+BamfWindow *
4892+bamf_window_get_transient (BamfWindow *self)
4893 {
4894 BamfWindowPrivate *priv;
4895 BamfView *transient;
4896@@ -93,7 +94,7 @@
4897 GError *error = NULL;
4898
4899 g_return_val_if_fail (BAMF_IS_WINDOW (self), FALSE);
4900-
4901+
4902 if (BAMF_WINDOW_GET_CLASS (self)->get_transient)
4903 return BAMF_WINDOW_GET_CLASS (self)->get_transient (self);
4904
4905@@ -102,35 +103,36 @@
4906 if (!_bamf_view_remote_ready (BAMF_VIEW (self)))
4907 return NULL;
4908
4909- if (!dbus_g_proxy_call (priv->proxy,
4910- "Transient",
4911- &error,
4912- G_TYPE_INVALID,
4913- G_TYPE_STRING, &path,
4914- G_TYPE_INVALID))
4915+ if (!bamf_dbus_item_window_call_transient_sync (priv->proxy, &path, NULL, &error))
4916 {
4917- g_warning ("Failed to fetch path: %s", error->message);
4918+ g_warning ("Failed to fetch path: %s", error ? error->message : "");
4919 g_error_free (error);
4920- return 0;
4921+ return NULL;
4922 }
4923-
4924+
4925 if (!path)
4926 return NULL;
4927
4928+ if (path[0] == '\0')
4929+ {
4930+ g_free (path);
4931+ return NULL;
4932+ }
4933+
4934 BamfFactory *factory = _bamf_factory_get_default ();
4935 transient = _bamf_factory_view_for_path_type (factory, path, BAMF_FACTORY_WINDOW);
4936- g_free (path);
4937+ g_free (path);
4938
4939 if (!BAMF_IS_WINDOW (transient))
4940 return NULL;
4941-
4942+
4943 return BAMF_WINDOW (transient);
4944 }
4945
4946-BamfWindowType bamf_window_get_window_type (BamfWindow *self)
4947+BamfWindowType
4948+bamf_window_get_window_type (BamfWindow *self)
4949 {
4950 BamfWindowPrivate *priv;
4951- guint32 type = 0;
4952 GError *error = NULL;
4953
4954 g_return_val_if_fail (BAMF_IS_WINDOW (self), FALSE);
4955@@ -140,28 +142,26 @@
4956
4957 priv = self->priv;
4958
4959+ if (priv->type != BAMF_WINDOW_UNKNOWN)
4960+ return priv->type;
4961+
4962 if (!_bamf_view_remote_ready (BAMF_VIEW (self)))
4963- return 0;
4964+ return priv->type;
4965
4966- if (!dbus_g_proxy_call (priv->proxy,
4967- "WindowType",
4968- &error,
4969- G_TYPE_INVALID,
4970- G_TYPE_UINT, &type,
4971- G_TYPE_INVALID))
4972+ if (!bamf_dbus_item_window_call_window_type_sync (priv->proxy, &priv->type, NULL, &error))
4973 {
4974- g_warning ("Failed to fetch type: %s", error->message);
4975+ priv->type = BAMF_WINDOW_UNKNOWN;
4976+ g_warning ("Failed to fetch type: %s", error ? error->message : "");
4977 g_error_free (error);
4978- return 0;
4979 }
4980
4981- return (BamfWindowType) type;
4982+ return priv->type;
4983 }
4984
4985-guint32 bamf_window_get_pid (BamfWindow *self)
4986+guint32
4987+bamf_window_get_pid (BamfWindow *self)
4988 {
4989 BamfWindowPrivate *priv;
4990- guint32 pid = 0;
4991 GError *error = NULL;
4992
4993 g_return_val_if_fail (BAMF_IS_WINDOW (self), FALSE);
4994@@ -175,159 +175,45 @@
4995 return priv->pid;
4996
4997 if (!_bamf_view_remote_ready (BAMF_VIEW (self)))
4998- return 0;
4999+ return priv->pid;
5000
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches