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

Proposed by Marco Trevisan (Treviño)
Status: Merged
Approved by: Marco Trevisan (Treviño)
Approved revision: 450
Merged at revision: 426
Proposed branch: lp:~3v1n0/bamf/bamfdaemon-gdbus
Merge into: lp:bamf/0.4
Diff against target: 7188 lines (+2713/-1892)
43 files modified
configure.in (+7/-2)
src/Makefile.am (+66/-63)
src/bamf-application-glue.xml (+0/-45)
src/bamf-application.c (+164/-88)
src/bamf-application.h (+24/-25)
src/bamf-control-glue.xml (+0/-35)
src/bamf-control.c (+126/-81)
src/bamf-control.h (+20/-24)
src/bamf-daemon.c (+215/-0)
src/bamf-daemon.h (+61/-0)
src/bamf-indicator-glue.xml (+0/-23)
src/bamf-indicator-source-glue.xml (+0/-28)
src/bamf-indicator-source.c (+225/-167)
src/bamf-indicator-source.h (+21/-24)
src/bamf-indicator.c (+133/-67)
src/bamf-indicator.h (+30/-32)
src/bamf-marshal.list (+2/-5)
src/bamf-matcher-glue.xml (+0/-108)
src/bamf-matcher.c (+283/-158)
src/bamf-matcher.h (+28/-31)
src/bamf-tab-glue.xml (+0/-39)
src/bamf-tab-source.c (+159/-140)
src/bamf-tab-source.h (+3/-2)
src/bamf-tab.c (+132/-31)
src/bamf-tab.h (+4/-3)
src/bamf-view-glue.xml (+0/-109)
src/bamf-view.c (+386/-225)
src/bamf-view.h (+50/-60)
src/bamf-window-glue.xml (+0/-30)
src/bamf-window.c (+102/-37)
src/bamf-window.h (+4/-4)
src/bamf.h (+7/-1)
src/com.canonical.StatusNotifierApprover.xml (+19/-0)
src/main.c (+9/-49)
src/main.h (+4/-9)
src/org.ayatana.bamf.browser.xml (+35/-0)
src/org.ayatana.bamf.view.xml (+120/-0)
src/org.ayatana.bamf.xml (+77/-0)
tests/bamfdaemon/Makefile.am (+23/-25)
tests/bamfdaemon/run-xvfb.sh (+16/-0)
tests/bamfdaemon/test-application.c (+46/-24)
tests/bamfdaemon/test-bamf.c (+63/-59)
tests/bamfdaemon/test-view.c (+49/-39)
To merge this branch: bzr merge lp:~3v1n0/bamf/bamfdaemon-gdbus
Reviewer Review Type Date Requested Status
Jason Smith (community) Approve
Mikkel Kamstrup Erlandsen Pending
Review via email: mp+86843@code.launchpad.net

Description of the change

Ported the BAMF daemon to GDBus, using gdbus-codegen to generate most of the low-level code.

The BamfMatcher and BamfControl are directly extending the generated skeleton class, while the Views are now extending the generated BamfDBusItemObjectSkeleton class, so it has been easily possible to transform each subclass into a kind of proxy to the generated skeleton interface. To reduce code redundancy for initializing signals, some view classes are also implementing the related skeleton interface, but this has been done only for convenience.

Then, I've added a BamfDaemon class to handle the daemon initialization and termination, and I've updated the tests against the new internal APIs.

Finally, I've also ported all the code for indicators and tabs, while I guess that this is now quite obsolete (the indicator part shouldn't totally, but the tabs really are), so maybe it could safely be removed.

I also want to make clear that the public DBus API interface has not been touched by this porting, so the new bamfdaemon can safely replace the old one (in fact I'm using it on my PC for some days with no crashes or unexpected behavior).

The port of libbamf will begin soon as well, and doing that maybe we should refine also the DBus interface.

PS: of course I've also included some random code fixes and cleanup.

To post a comment you must log in.
Revision history for this message
Michal Hruby (mhr3) wrote :

A few things from a quick look: (in merge request line numbers)

1) please enable silent rules

339 + const GList *children, *l;

Please get rid of the const, this isn't C++ and afaict it's wrong in this case. (same for 405, 439, 449, 490, ...)

Same applies to methods returning const GList* - in that case the qualifier is correct, but all GList methods require non-const list anyway, so you're forcing the consumer to cast away the const-ness.

1335 + g_error_free (error);
1336 + error = NULL;

There are also multiple instances of this and it can be simplified using g_clear_error().

Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

Thanks for your review. I've made the changes you suggested to me.

Also, I've disabled the indicator approver, since it is currently deprecated (after a chat with Ted).

Revision history for this message
Unity Merger (unity-merger) wrote :

The Jenkins job https://jenkins.qa.ubuntu.com/job/automerge-bamf/14/console reported an error when processing this lp:~3v1n0/bamf/bamfdaemon-gdbus branch.
Not merging it.

Revision history for this message
Jason Smith (jassmith) wrote :

Works for me, please fix jenkins issues :)

review: Approve
Revision history for this message
Mikkel Kamstrup Erlandsen (kamstrup) wrote :

Marking branch approved again. I have no idea why jenkins silently fails...

Revision history for this message
Unity Merger (unity-merger) wrote :

Attempt to merge into lp:bamf failed due to conflicts:

text conflict in configure.in

Revision history for this message
Unity Merger (unity-merger) wrote :

The Jenkins job https://jenkins.qa.ubuntu.com/job/automerge-bamf/24/console reported an error when processing this lp:~3v1n0/bamf/bamfdaemon-gdbus branch.
Not merging it.

Revision history for this message
Unity Merger (unity-merger) wrote :

The Jenkins job https://jenkins.qa.ubuntu.com/job/automerge-bamf/25/console reported an error when processing this lp:~3v1n0/bamf/bamfdaemon-gdbus branch.
Not merging it.

Revision history for this message
Unity Merger (unity-merger) wrote :

The Jenkins job https://jenkins.qa.ubuntu.com/job/automerge-bamf/26/console reported an error when processing this lp:~3v1n0/bamf/bamfdaemon-gdbus branch.
Not merging it.

Revision history for this message
Unity Merger (unity-merger) wrote :

The Jenkins job https://jenkins.qa.ubuntu.com/job/automerge-bamf/27/console reported an error when processing this lp:~3v1n0/bamf/bamfdaemon-gdbus branch.
Not merging it.

Revision history for this message
Unity Merger (unity-merger) wrote :

There are additional revisions which have not been approved in review. Please seek review and approval of these new revisions.

Revision history for this message
Unity Merger (unity-merger) wrote :

The Jenkins job https://jenkins.qa.ubuntu.com/job/automerge-bamf/28/console reported an error when processing this lp:~3v1n0/bamf/bamfdaemon-gdbus branch.
Not merging it.

Revision history for this message
Unity Merger (unity-merger) wrote :

The Jenkins job https://jenkins.qa.ubuntu.com/job/automerge-bamf/29/console reported an error when processing this lp:~3v1n0/bamf/bamfdaemon-gdbus branch.
Not merging it.

Revision history for this message
Unity Merger (unity-merger) wrote :

The Jenkins job https://jenkins.qa.ubuntu.com/job/automerge-bamf/30/console reported an error when processing this lp:~3v1n0/bamf/bamfdaemon-gdbus branch.
Not merging it.

lp:~3v1n0/bamf/bamfdaemon-gdbus updated
450. By Marco Trevisan (Treviño)

tests, BamfDaemon: removed typo.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'configure.in'
--- configure.in 2012-01-12 15:08:42 +0000
+++ configure.in 2012-01-19 19:16:25 +0000
@@ -2,7 +2,7 @@
2# Process this file with autoconf to produce a configure script.2# Process this file with autoconf to produce a configure script.
33
4AC_PREREQ([2.63])4AC_PREREQ([2.63])
5AC_INIT(bamf, 0.2.106, dx-team@canonical.com)5AC_INIT(bamf, 0.2.107, dx-team@canonical.com)
6AC_PREREQ(2.62)6AC_PREREQ(2.62)
77
8AC_CONFIG_SRCDIR(src/main.c)8AC_CONFIG_SRCDIR(src/main.c)
@@ -56,7 +56,12 @@
56#56#
57# glib57# glib
58#58#
59PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.28.0 gio-2.0 gio-unix-2.0)59PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.28.0 gio-2.0 >= 2.30.0 gio-unix-2.0)
60
61#
62# gdbus-codegen
63#
64AC_PATH_PROG([GDBUS_CODEGEN], [gdbus-codegen], AC_MSG_ERROR([gdbus-codegen is required but was not found]))
6065
61#66#
62# dbus67# dbus
6368
=== modified file 'src/Makefile.am'
--- src/Makefile.am 2010-07-09 08:05:06 +0000
+++ src/Makefile.am 2012-01-19 19:16:25 +0000
@@ -5,10 +5,10 @@
55
6include $(top_srcdir)/Makefile.am.marshal6include $(top_srcdir)/Makefile.am.marshal
77
8INCLUDE = \8INCLUDE = \
9 -I. \9 -I. \
10 -I$(srcdir) \10 -I$(srcdir) \
11 $(NULL)11 $(NULL)
1212
13bamfdaemondir = $(libexecdir)13bamfdaemondir = $(libexecdir)
1414
@@ -16,39 +16,36 @@
16 bamfdaemon \16 bamfdaemon \
17 $(NULL)17 $(NULL)
1818
19bamfdaemon_glue_files = \19bamfdaemon_gdbus_files = \
20 bamf-application-glue.h \20 bamf-gdbus-generated.c \
21 bamf-control-glue.h \21 bamf-gdbus-generated.h \
22 bamf-matcher-glue.h \22 bamf-gdbus-view-generated.c \
23 bamf-window-glue.h \23 bamf-gdbus-view-generated.h \
24 bamf-view-glue.h \24 bamf-gdbus-browser-generated.c \
25 bamf-tab-glue.h \25 bamf-gdbus-browser-generated.h \
26 bamf-indicator-source-glue.h \26 bamf-gdbus-indicator-source-generated.c \
27 bamf-indicator-glue.h \27 bamf-gdbus-indicator-source-generated.h \
28 $(NULL)28 $(NULL)
29 29
30bamfdaemon_xml_glue_files = \30bamfdaemon_xml_gdbus_files = \
31 bamf-application-glue.xml \31 org.ayatana.bamf.xml \
32 bamf-control-glue.xml \32 org.ayatana.bamf.view.xml \
33 bamf-matcher-glue.xml \33 org.ayatana.bamf.browser.xml \
34 bamf-window-glue.xml \34 com.canonical.StatusNotifierApprover.xml \
35 bamf-view-glue.xml \
36 bamf-tab-glue.xml \
37 bamf-indicator-source-glue.xml \
38 bamf-indicator-glue.xml \
39 $(NULL)35 $(NULL)
4036
41bamfdaemon_built_sources = \37bamfdaemon_built_sources = \
42 bamf-marshal.c \38 bamf-marshal.c \
43 bamf-marshal.h \39 bamf-marshal.h \
44 $(bamfdaemon_glue_files) \40 $(bamfdaemon_gdbus_files) \
45 $(NULL)41 $(NULL)
4642
47bamfdaemon_sources = \43bamfdaemon_sources = \
48 main.c \44 main.c \
45 bamf-daemon.c \
49 bamf-legacy-window.c \46 bamf-legacy-window.c \
50 bamf-legacy-window-test.c \47 bamf-legacy-window-test.c \
51 bamf-legacy-screen.c \48 bamf-legacy-screen.c \
52 bamf-view.c \49 bamf-view.c \
53 bamf-control.c \50 bamf-control.c \
54 bamf-matcher.c \51 bamf-matcher.c \
@@ -63,9 +60,10 @@
63bamfdaemon_headers = \60bamfdaemon_headers = \
64 main.h \61 main.h \
65 bamf.h \62 bamf.h \
63 bamf-daemon.h \
66 bamf-legacy-window.h \64 bamf-legacy-window.h \
67 bamf-legacy-window-test.h \65 bamf-legacy-window-test.h \
68 bamf-legacy-screen.h \66 bamf-legacy-screen.h \
69 bamf-view.h \67 bamf-view.h \
70 bamf-control.h \68 bamf-control.h \
71 bamf-matcher.h \69 bamf-matcher.h \
@@ -78,27 +76,22 @@
78 $(NULL)76 $(NULL)
7977
80bamfdaemon_SOURCES = \78bamfdaemon_SOURCES = \
81 $(bamfdaemon_built_sources) \79 $(bamfdaemon_built_sources) \
82 $(bamfdaemon_sources) \80 $(bamfdaemon_sources) \
83 $(bamfdaemon_headers) \81 $(bamfdaemon_headers) \
84 $(NULL)82 $(NULL)
8583
86nodist_EXTRA_bamfdaemon_SOURCES = \84nodist_EXTRA_bamfdaemon_SOURCES = \
87 $(bamfdaemon_glue_files) \85 $(bamfdaemon_gdbus_files) \
88 $(NULL)86 $(NULL)
8987
90glib_marshal_list = bamf-marshal.list88glib_marshal_list = bamf-marshal.list
91glib_marshal_prefix = bamf_marshal89glib_marshal_prefix = bamf_marshal
9290
93DISTCLEANFILES += \
94 $(bamfdaemon_glue_files) \
95 $(NULL)
96
97bamfdaemon_LDADD = \91bamfdaemon_LDADD = \
98 $(X_LIBS) \92 $(X_LIBS) \
99 $(GLIB_LIBS) \93 $(GLIB_LIBS) \
100 $(GTK_LIBS) \94 $(GTK_LIBS) \
101 $(DBUS_LIBS) \
102 $(WNCK_LIBS) \95 $(WNCK_LIBS) \
103 $(GTOP_LIBS) \96 $(GTOP_LIBS) \
104 $(NULL)97 $(NULL)
@@ -109,7 +102,6 @@
109 -DWNCK_I_KNOW_THIS_IS_UNSTABLE \102 -DWNCK_I_KNOW_THIS_IS_UNSTABLE \
110 $(GLIB_CFLAGS) \103 $(GLIB_CFLAGS) \
111 $(GTK_CFLAGS) \104 $(GTK_CFLAGS) \
112 $(DBUS_CFLAGS) \
113 $(WNCK_CFLAGS) \105 $(WNCK_CFLAGS) \
114 $(GTOP_CFLAGS) \106 $(GTOP_CFLAGS) \
115 $(NULL)107 $(NULL)
@@ -118,36 +110,47 @@
118 -Xlinker -export-dynamic -Wl,-O1 -Wl,-Bsymbolic-functions \110 -Xlinker -export-dynamic -Wl,-O1 -Wl,-Bsymbolic-functions \
119 $(NULL)111 $(NULL)
120112
121bamf-application-glue.h: bamf-application-glue.xml Makefile113bamf-gdbus-generated.c bamf-gdbus-generated.h: org.ayatana.bamf.xml
122 $(LIBTOOL) --mode=execute $(DBUS_GLIB_BIN)/dbus-binding-tool --prefix=bamf_application --mode=glib-server --output=$@ $<114 $(AM_V_GEN) $(GDBUS_CODEGEN) \
123115 --generate-c-code bamf-gdbus-generated \
124bamf-control-glue.h: bamf-control-glue.xml Makefile116 --c-namespace BamfDBus \
125 $(LIBTOOL) --mode=execute $(DBUS_GLIB_BIN)/dbus-binding-tool --prefix=bamf_control --mode=glib-server --output=$@ $<117 --interface-prefix org.ayatana.bamf \
126118 $<
127bamf-matcher-glue.h: bamf-matcher-glue.xml Makefile119
128 $(LIBTOOL) --mode=execute $(DBUS_GLIB_BIN)/dbus-binding-tool --prefix=bamf_matcher --mode=glib-server --output=$@ $<120bamf-gdbus-view-generated.c bamf-gdbus-view-generated.h: org.ayatana.bamf.view.xml
129121 $(AM_V_GEN) $(GDBUS_CODEGEN) \
130bamf-window-glue.h: bamf-window-glue.xml Makefile122 --c-generate-object-manager \
131 $(LIBTOOL) --mode=execute $(DBUS_GLIB_BIN)/dbus-binding-tool --prefix=bamf_window --mode=glib-server --output=$@ $<123 --generate-c-code bamf-gdbus-view-generated \
132124 --c-namespace BamfDBusItem \
133bamf-view-glue.h: bamf-view-glue.xml Makefile125 --interface-prefix org.ayatana.bamf \
134 $(LIBTOOL) --mode=execute $(DBUS_GLIB_BIN)/dbus-binding-tool --prefix=bamf_view --mode=glib-server --output=$@ $<126 $<
135127
136bamf-tab-glue.h: bamf-tab-glue.xml Makefile128bamf-gdbus-browser-generated.c bamf-gdbus-browser-generated.h: org.ayatana.bamf.browser.xml
137 $(LIBTOOL) --mode=execute $(DBUS_GLIB_BIN)/dbus-binding-tool --prefix=bamf_tab --mode=glib-server --output=$@ $<129 $(AM_V_GEN) $(GDBUS_CODEGEN) \
138130 --generate-c-code bamf-gdbus-browser-generated \
139bamf-indicator-source-glue.h: bamf-indicator-source-glue.xml Makefile131 --c-namespace BamfDBusBrowser \
140 $(LIBTOOL) --mode=execute $(DBUS_GLIB_BIN)/dbus-binding-tool --prefix=bamf_indicator_source --mode=glib-server --output=$@ $<132 --interface-prefix org.ayatana.bamf.browser \
141133 $<
142bamf-indicator-glue.h: bamf-indicator-glue.xml Makefile134
143 $(LIBTOOL) --mode=execute $(DBUS_GLIB_BIN)/dbus-binding-tool --prefix=bamf_indicator --mode=glib-server --output=$@ $<135bamf-gdbus-indicator-source-generated.c bamf-gdbus-indicator-source-generated.h: com.canonical.StatusNotifierApprover.xml
136 $(AM_V_GEN) $(GDBUS_CODEGEN) \
137 --generate-c-code bamf-gdbus-indicator-source-generated \
138 --c-namespace StatusNotifierApprover \
139 --interface-prefix com.canonical.StatusNotifierApprover \
140 $<
144141
145BUILT_SOURCES += \142BUILT_SOURCES += \
146 $(bamfdaemon_glue_files) \143 $(bamfdaemon_gdbus_files) \
147 $(NULL)144 $(NULL)
148145
149EXTRA_DIST += \146EXTRA_DIST += \
150 $(bamfdaemon_xml_glue_files) \147 $(bamfdaemon_xml_gdbus_files) \
151 $(NULL)148 $(NULL)
152149
153150DISTCLEANFILES += \
151 $(bamfdaemon_built_sources) \
152 $(NULL)
153
154CLEANFILES += \
155 $(bamfdaemon_built_sources) \
156 $(NULL)
154157
=== removed file 'src/bamf-application-glue.xml'
--- src/bamf-application-glue.xml 2010-09-10 16:41:41 +0000
+++ src/bamf-application-glue.xml 1970-01-01 00:00:00 +0000
@@ -1,45 +0,0 @@
1<?xml version="1.0" encoding="UTF-8" ?>
2
3<node name="/org/ayatana/bamf">
4
5 <interface name="org.ayatana.bamf.application">
6
7 <signal name="WindowAdded">
8 <arg type="s" name="path" direction="out" />
9 </signal>
10
11 <signal name="WindowRemoved">
12 <arg type="s" name="path" direction="out" />
13 </signal>
14
15 <method name="ApplicationType">
16 <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_application_get_application_type" />
17 <arg type="s" name="type" direction="out">
18 <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/>
19 </arg>
20 </method>
21
22 <method name="DesktopFile">
23 <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_application_get_desktop_file" />
24 <arg type="s" name="desktop_file" direction="out">
25 <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/>
26 </arg>
27 </method>
28
29 <method name="Xids">
30 <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_application_get_xids" />
31 <arg type="au" name="xids" direction="out">
32 <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/>
33 </arg>
34 </method>
35
36 <method name="ShowStubs">
37 <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_application_get_show_stubs" />
38 <arg type="b" name="show_stubs" direction="out">
39 <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/>
40 </arg>
41 </method>
42
43 </interface>
44
45</node>
460
=== modified file 'src/bamf-application.c'
--- src/bamf-application.c 2011-12-14 03:17:37 +0000
+++ src/bamf-application.c 2012-01-19 19:16:25 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright (C) 2010 Canonical Ltd2 * Copyright (C) 2010-2011 Canonical Ltd
3 *3 *
4 * This program is free software: you can redistribute it and/or modify4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as5 * it under the terms of the GNU General Public License version 3 as
@@ -14,12 +14,11 @@
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *15 *
16 * Authored by: Jason Smith <jason.smith@canonical.com>16 * Authored by: Jason Smith <jason.smith@canonical.com>
17 * Marco Trevisan (Treviño) <3v1n0@ubuntu.com>
17 *18 *
18 */19 */
1920
20
21#include "bamf-application.h"21#include "bamf-application.h"
22#include "bamf-application-glue.h"
23#include "bamf-window.h"22#include "bamf-window.h"
24#include "bamf-matcher.h"23#include "bamf-matcher.h"
25#include "bamf-indicator.h"24#include "bamf-indicator.h"
@@ -28,22 +27,17 @@
28#include <string.h>27#include <string.h>
29#include <gio/gdesktopappinfo.h>28#include <gio/gdesktopappinfo.h>
3029
31G_DEFINE_TYPE (BamfApplication, bamf_application, BAMF_TYPE_VIEW);
32#define BAMF_APPLICATION_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE(obj, \30#define BAMF_APPLICATION_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE(obj, \
33BAMF_TYPE_APPLICATION, BamfApplicationPrivate))31BAMF_TYPE_APPLICATION, BamfApplicationPrivate))
3432
35enum33static void bamf_application_dbus_application_iface_init (BamfDBusItemApplicationIface *iface);
36{34G_DEFINE_TYPE_WITH_CODE (BamfApplication, bamf_application, BAMF_TYPE_VIEW,
37 WINDOW_ADDED,35 G_IMPLEMENT_INTERFACE (BAMF_DBUS_ITEM_TYPE_APPLICATION,
38 WINDOW_REMOVED,36 bamf_application_dbus_application_iface_init));
39
40 LAST_SIGNAL,
41};
42
43static guint application_signals[LAST_SIGNAL] = { 0 };
4437
45struct _BamfApplicationPrivate38struct _BamfApplicationPrivate
46{39{
40 BamfDBusItemApplication *dbus_iface;
47 char * desktop_file;41 char * desktop_file;
48 GList * desktop_file_list;42 GList * desktop_file_list;
49 char * app_type;43 char * app_type;
@@ -153,27 +147,32 @@
153 /* This will error to return false, which is okay as it seems147 /* This will error to return false, which is okay as it seems
154 unlikely anyone will want to set this flag except to turn148 unlikely anyone will want to set this flag except to turn
155 off the stub menus. */149 off the stub menus. */
156 self->priv->show_stubs = g_key_file_get_boolean(keyfile, G_KEY_FILE_DESKTOP_GROUP, STUB_KEY, NULL);150 self->priv->show_stubs = g_key_file_get_boolean (keyfile,
151 G_KEY_FILE_DESKTOP_GROUP,
152 STUB_KEY, NULL);
157 }153 }
158 154
159 if (g_key_file_has_key(keyfile, G_KEY_FILE_DESKTOP_GROUP, "X-GNOME-FullName", NULL))155 if (g_key_file_has_key (keyfile, G_KEY_FILE_DESKTOP_GROUP, "X-GNOME-FullName", NULL))
160 {156 {
161 /* Grab the better name if its available */157 /* Grab the better name if its available */
162 gchar *fullname = NULL;158 gchar *fullname = NULL;
163 error = NULL; 159 error = NULL;
164 fullname = g_key_file_get_locale_string (keyfile, G_KEY_FILE_DESKTOP_GROUP, "X-GNOME-FullName", NULL, &error);160 fullname = g_key_file_get_locale_string (keyfile,
165 if (error != NULL)161 G_KEY_FILE_DESKTOP_GROUP,
166 {162 "X-GNOME-FullName", NULL,
167 g_error_free (error);163 &error);
168 if (fullname)164 if (error != NULL)
169 g_free (fullname);165 {
170 }166 g_error_free (error);
171 else167 if (fullname)
172 {168 g_free (fullname);
173 g_free (name);169 }
174 name = fullname;170 else
175 }171 {
176 }172 g_free (name);
173 name = fullname;
174 }
175 }
177176
178 g_object_unref (desktop);177 g_object_unref (desktop);
179 g_key_file_free(keyfile);178 g_key_file_free(keyfile);
@@ -274,17 +273,18 @@
274 application->priv->wmclass = NULL;273 application->priv->wmclass = NULL;
275}274}
276275
277GArray *276GVariant *
278bamf_application_get_xids (BamfApplication *application)277bamf_application_get_xids (BamfApplication *application)
279{278{
280 GList *l;279 GList *l;
281 GArray *xids;280 GVariantBuilder b;
282 BamfView *view;281 BamfView *view;
283 guint32 xid;282 guint32 xid;
284283
285 g_return_val_if_fail (BAMF_IS_APPLICATION (application), NULL);284 g_return_val_if_fail (BAMF_IS_APPLICATION (application), NULL);
286285
287 xids = g_array_new (FALSE, TRUE, sizeof (guint32));286 g_variant_builder_init (&b, G_VARIANT_TYPE ("(au)"));
287 g_variant_builder_open (&b, G_VARIANT_TYPE ("au"));
288288
289 for (l = bamf_view_get_children (BAMF_VIEW (application)); l; l = l->next)289 for (l = bamf_view_get_children (BAMF_VIEW (application)); l; l = l->next)
290 {290 {
@@ -294,11 +294,12 @@
294 continue;294 continue;
295295
296 xid = bamf_window_get_xid (BAMF_WINDOW (view));296 xid = bamf_window_get_xid (BAMF_WINDOW (view));
297297 g_variant_builder_add (&b, "u", xid);
298 g_array_append_val (xids, xid);
299 }298 }
300299
301 return xids;300 g_variant_builder_close (&b);
301
302 return g_variant_builder_end (&b);
302}303}
303304
304gboolean305gboolean
@@ -339,32 +340,32 @@
339bamf_application_manages_xid (BamfApplication *application,340bamf_application_manages_xid (BamfApplication *application,
340 guint32 xid)341 guint32 xid)
341{342{
342 GArray *xids;343 GList *l;
343 int i;
344 gboolean result = FALSE;344 gboolean result = FALSE;
345345
346 g_return_val_if_fail (BAMF_IS_APPLICATION (application), FALSE);346 g_return_val_if_fail (BAMF_IS_APPLICATION (application), FALSE);
347347
348 xids = bamf_application_get_xids (application);348 for (l = bamf_view_get_children (BAMF_VIEW (application)); l; l = l->next)
349
350 for (i = 0; i < xids->len; i++)
351 {349 {
352 if (g_array_index (xids, guint32, i) == xid)350 BamfView *view = l->data;
351
352 if (!BAMF_IS_WINDOW (view))
353 continue;
354
355 if (bamf_window_get_xid (BAMF_WINDOW (view)) == xid)
353 {356 {
354 result = TRUE;357 result = TRUE;
355 break;358 break;
356 }359 }
357 }360 }
358361
359 g_array_free (xids, TRUE);
360
361 return result;362 return result;
362}363}
363364
364static char *365static const char *
365bamf_application_get_view_type (BamfView *view)366bamf_application_get_view_type (BamfView *view)
366{367{
367 return g_strdup ("application");368 return "application";
368}369}
369370
370static char *371static char *
@@ -455,7 +456,7 @@
455static void456static void
456view_exported (BamfView *view, BamfApplication *self)457view_exported (BamfView *view, BamfApplication *self)
457{458{
458 g_signal_emit (self, application_signals[WINDOW_ADDED], 0, bamf_view_get_path (view));459 g_signal_emit_by_name (self, "window-added", bamf_view_get_path (view));
459}460}
460461
461static void462static void
@@ -468,7 +469,7 @@
468 if (BAMF_IS_WINDOW (child))469 if (BAMF_IS_WINDOW (child))
469 {470 {
470 if (bamf_view_is_on_bus (child))471 if (bamf_view_is_on_bus (child))
471 g_signal_emit (BAMF_APPLICATION (view), application_signals[WINDOW_ADDED], 0, bamf_view_get_path (child));472 g_signal_emit_by_name (BAMF_APPLICATION (view), "window-added", bamf_view_get_path (child));
472 else473 else
473 g_signal_connect (G_OBJECT (child), "exported",474 g_signal_connect (G_OBJECT (child), "exported",
474 (GCallback) view_exported, view);475 (GCallback) view_exported, view);
@@ -486,15 +487,6 @@
486 bamf_application_setup_icon_and_name (application);487 bamf_application_setup_icon_and_name (application);
487}488}
488489
489static gboolean
490on_empty (GObject *object)
491{
492 g_return_val_if_fail (BAMF_IS_VIEW (object), FALSE);
493
494 bamf_view_close (BAMF_VIEW (object));
495 return FALSE;
496}
497
498static char *490static char *
499bamf_application_favorite_from_list (BamfApplication *self, GList *list)491bamf_application_favorite_from_list (BamfApplication *self, GList *list)
500{492{
@@ -518,7 +510,7 @@
518 }510 }
519 }511 }
520 }512 }
521 513
522 return result;514 return result;
523}515}
524516
@@ -560,7 +552,8 @@
560 if (BAMF_IS_WINDOW (child))552 if (BAMF_IS_WINDOW (child))
561 {553 {
562 if (bamf_view_is_on_bus (child))554 if (bamf_view_is_on_bus (child))
563 g_signal_emit (BAMF_APPLICATION (view), application_signals[WINDOW_REMOVED],0, bamf_view_get_path (child));555 g_signal_emit_by_name (BAMF_APPLICATION (view), "window-removed",
556 bamf_view_get_path (child));
564 }557 }
565558
566 g_signal_handlers_disconnect_by_func (G_OBJECT (child), view_active_changed, view);559 g_signal_handlers_disconnect_by_func (G_OBJECT (child), view_active_changed, view);
@@ -569,9 +562,9 @@
569562
570 bamf_application_ensure_flags (BAMF_APPLICATION (view));563 bamf_application_ensure_flags (BAMF_APPLICATION (view));
571564
572 if (g_list_length (bamf_view_get_children (view)) == 0)565 if (bamf_view_get_children (view) == NULL)
573 {566 {
574 g_idle_add ((GSourceFunc) on_empty, view);567 bamf_view_close (view);
575 }568 }
576}569}
577570
@@ -584,7 +577,7 @@
584 g_return_if_fail (BAMF_IS_MATCHER (matcher));577 g_return_if_fail (BAMF_IS_MATCHER (matcher));
585 578
586 new_desktop_file = bamf_application_favorite_from_list (self, self->priv->desktop_file_list);579 new_desktop_file = bamf_application_favorite_from_list (self, self->priv->desktop_file_list);
587 580
588 if (new_desktop_file)581 if (new_desktop_file)
589 {582 {
590 bamf_application_set_desktop_file (self, new_desktop_file);583 bamf_application_set_desktop_file (self, new_desktop_file);
@@ -592,6 +585,67 @@
592}585}
593586
594static void587static void
588on_window_added (BamfApplication *self, const gchar *win_path, gpointer _not_used)
589{
590 g_return_if_fail (BAMF_IS_APPLICATION (self));
591 g_signal_emit_by_name (self->priv->dbus_iface, "window-added", win_path);
592}
593
594static void
595on_window_removed (BamfApplication *self, const gchar *win_path, gpointer _not_used)
596{
597 g_return_if_fail (BAMF_IS_APPLICATION (self));
598 g_signal_emit_by_name (self->priv->dbus_iface, "window-removed", win_path);
599}
600
601static gboolean
602on_dbus_handle_show_stubs (BamfDBusItemApplication *interface,
603 GDBusMethodInvocation *invocation,
604 BamfApplication *self)
605{
606 gboolean show_stubs = bamf_application_get_show_stubs (self);
607 g_dbus_method_invocation_return_value (invocation,
608 g_variant_new ("(b)", show_stubs));
609
610 return TRUE;
611}
612
613static gboolean
614on_dbus_handle_xids (BamfDBusItemApplication *interface,
615 GDBusMethodInvocation *invocation,
616 BamfApplication *self)
617{
618 GVariant *xids = bamf_application_get_xids (self);
619 g_dbus_method_invocation_return_value (invocation, xids);
620
621 return TRUE;
622}
623
624static gboolean
625on_dbus_handle_desktop_file (BamfDBusItemApplication *interface,
626 GDBusMethodInvocation *invocation,
627 BamfApplication *self)
628{
629 const char *desktop_file = self->priv->desktop_file ? self->priv->desktop_file : "";
630 g_dbus_method_invocation_return_value (invocation,
631 g_variant_new ("(s)", desktop_file));
632
633 return TRUE;
634}
635
636static gboolean
637on_dbus_handle_application_type (BamfDBusItemApplication *interface,
638 GDBusMethodInvocation *invocation,
639 BamfApplication *self)
640{
641 const char *type = self->priv->app_type ? self->priv->app_type : "";
642 g_dbus_method_invocation_return_value (invocation,
643 g_variant_new ("(s)", type));
644
645 return TRUE;
646}
647
648static void
595bamf_application_dispose (GObject *object)649bamf_application_dispose (GObject *object)
596{650{
597 BamfApplication *app;651 BamfApplication *app;
@@ -629,13 +683,25 @@
629 g_free (priv->wmclass);683 g_free (priv->wmclass);
630 priv->wmclass = NULL;684 priv->wmclass = NULL;
631 }685 }
632 686
633 g_signal_handlers_disconnect_by_func (G_OBJECT (bamf_matcher_get_default ()), matcher_favorites_changed, object);687 g_signal_handlers_disconnect_by_func (G_OBJECT (bamf_matcher_get_default ()),
688 matcher_favorites_changed, object);
634689
635 G_OBJECT_CLASS (bamf_application_parent_class)->dispose (object);690 G_OBJECT_CLASS (bamf_application_parent_class)->dispose (object);
636}691}
637692
638static void693static void
694bamf_application_finalize (GObject *object)
695{
696 BamfApplication *self;
697 self = BAMF_APPLICATION (object);
698
699 g_object_unref (self->priv->dbus_iface);
700
701 G_OBJECT_CLASS (bamf_application_parent_class)->finalize (object);
702}
703
704static void
639bamf_application_init (BamfApplication * self)705bamf_application_init (BamfApplication * self)
640{706{
641 BamfApplicationPrivate *priv;707 BamfApplicationPrivate *priv;
@@ -645,18 +711,49 @@
645 priv->app_type = g_strdup ("system");711 priv->app_type = g_strdup ("system");
646 priv->show_stubs = TRUE;712 priv->show_stubs = TRUE;
647 priv->wmclass = NULL;713 priv->wmclass = NULL;
648 714
715 /* Initializing the dbus interface */
716 priv->dbus_iface = bamf_dbus_item_application_skeleton_new ();
717
718 /* We need to connect to the object own signals to redirect them to the dbus
719 * interface */
720 g_signal_connect (self, "window-added", G_CALLBACK (on_window_added), NULL);
721 g_signal_connect (self, "window-removed", G_CALLBACK (on_window_removed), NULL);
722
723 /* Registering signal callbacks to reply to dbus method calls */
724 g_signal_connect (priv->dbus_iface, "handle-show-stubs",
725 G_CALLBACK (on_dbus_handle_show_stubs), self);
726
727 g_signal_connect (priv->dbus_iface, "handle-xids",
728 G_CALLBACK (on_dbus_handle_xids), self);
729
730 g_signal_connect (priv->dbus_iface, "handle-desktop-file",
731 G_CALLBACK (on_dbus_handle_desktop_file), self);
732
733 g_signal_connect (priv->dbus_iface, "handle-application-type",
734 G_CALLBACK (on_dbus_handle_application_type), self);
735
736 /* Setting the interface for the dbus object */
737 bamf_dbus_item_object_skeleton_set_application (BAMF_DBUS_ITEM_OBJECT_SKELETON (self),
738 priv->dbus_iface);
739
649 g_signal_connect (G_OBJECT (bamf_matcher_get_default ()), "favorites-changed", 740 g_signal_connect (G_OBJECT (bamf_matcher_get_default ()), "favorites-changed",
650 (GCallback) matcher_favorites_changed, self);741 (GCallback) matcher_favorites_changed, self);
651}742}
652743
653static void744static void
745bamf_application_dbus_application_iface_init (BamfDBusItemApplicationIface *iface)
746{
747}
748
749static void
654bamf_application_class_init (BamfApplicationClass * klass)750bamf_application_class_init (BamfApplicationClass * klass)
655{751{
656 GObjectClass *object_class = G_OBJECT_CLASS (klass);752 GObjectClass *object_class = G_OBJECT_CLASS (klass);
657 BamfViewClass *view_class = BAMF_VIEW_CLASS (klass);753 BamfViewClass *view_class = BAMF_VIEW_CLASS (klass);
658754
659 object_class->dispose = bamf_application_dispose;755 object_class->dispose = bamf_application_dispose;
756 object_class->finalize = bamf_application_finalize;
660757
661 view_class->view_type = bamf_application_get_view_type;758 view_class->view_type = bamf_application_get_view_type;
662 view_class->child_added = bamf_application_child_added;759 view_class->child_added = bamf_application_child_added;
@@ -665,27 +762,6 @@
665 view_class->stable_bus_name = bamf_application_get_stable_bus_name;762 view_class->stable_bus_name = bamf_application_get_stable_bus_name;
666763
667 g_type_class_add_private (klass, sizeof (BamfApplicationPrivate));764 g_type_class_add_private (klass, sizeof (BamfApplicationPrivate));
668
669 dbus_g_object_type_install_info (BAMF_TYPE_APPLICATION,
670 &dbus_glib_bamf_application_object_info);
671
672 application_signals [WINDOW_ADDED] =
673 g_signal_new ("window-added",
674 G_OBJECT_CLASS_TYPE (klass),
675 0,
676 0, NULL, NULL,
677 g_cclosure_marshal_VOID__STRING,
678 G_TYPE_NONE, 1,
679 G_TYPE_STRING);
680
681 application_signals [WINDOW_REMOVED] =
682 g_signal_new ("window-removed",
683 G_OBJECT_CLASS_TYPE (klass),
684 0,
685 0, NULL, NULL,
686 g_cclosure_marshal_VOID__STRING,
687 G_TYPE_NONE, 1,
688 G_TYPE_STRING);
689}765}
690766
691BamfApplication *767BamfApplication *
692768
=== modified file 'src/bamf-application.h'
--- src/bamf-application.h 2011-06-21 23:45:49 +0000
+++ src/bamf-application.h 2012-01-19 19:16:25 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright (C) 2010 Canonical Ltd2 * Copyright (C) 2010-2011 Canonical Ltd
3 *3 *
4 * This program is free software: you can redistribute it and/or modify4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as5 * it under the terms of the GNU General Public License version 3 as
@@ -14,6 +14,7 @@
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *15 *
16 * Authored by: Jason Smith <jason.smith@canonical.com>16 * Authored by: Jason Smith <jason.smith@canonical.com>
17 * Marco Trevisan (Treviño) <3v1n0@ubuntu.com>
17 *18 *
18 */19 */
1920
@@ -50,33 +51,31 @@
50 BamfApplicationPrivate *priv;51 BamfApplicationPrivate *priv;
51};52};
5253
53GType bamf_application_get_type (void) G_GNUC_CONST;54GType bamf_application_get_type (void) G_GNUC_CONST;
5455
55char * bamf_application_get_application_type (BamfApplication *application);56char * bamf_application_get_desktop_file (BamfApplication *application);
5657void bamf_application_set_desktop_file (BamfApplication *application,
57char * bamf_application_get_desktop_file (BamfApplication *application);58 const char * desktop_file);
58void bamf_application_set_desktop_file (BamfApplication *application,59
59 const char * desktop_file);60GVariant * bamf_application_get_xids (BamfApplication *application);
6061
61GArray * bamf_application_get_xids (BamfApplication *application);62gboolean bamf_application_manages_xid (BamfApplication *application,
6263 guint32 xid);
63gboolean bamf_application_manages_xid (BamfApplication *application,
64 guint32 xid);
6564
66gboolean bamf_application_contains_similar_to_window (BamfApplication *app, 65gboolean bamf_application_contains_similar_to_window (BamfApplication *app,
67 BamfWindow *window);66 BamfWindow *window);
6867
69char * bamf_application_get_wmclass (BamfApplication *application);68char * bamf_application_get_wmclass (BamfApplication *application);
70void bamf_application_set_wmclass (BamfApplication *application,69void bamf_application_set_wmclass (BamfApplication *application,
71 const char *wmclass);70 const char *wmclass);
7271
73BamfApplication * bamf_application_new (void);72BamfApplication * bamf_application_new (void);
7473
75BamfApplication * bamf_application_new_from_desktop_file (const char * desktop_file);74BamfApplication * bamf_application_new_from_desktop_file (const char * desktop_file);
76gboolean bamf_application_get_show_stubs (BamfApplication *application);75gboolean bamf_application_get_show_stubs (BamfApplication *application);
7776
78BamfApplication * bamf_application_new_from_desktop_files (GList * desktop_files);77BamfApplication * bamf_application_new_from_desktop_files (GList * desktop_files);
7978
80BamfApplication * bamf_application_new_with_wmclass (const char *wmclass);79BamfApplication * bamf_application_new_with_wmclass (const char *wmclass);
8180
82#endif81#endif
8382
=== removed file 'src/bamf-control-glue.xml'
--- src/bamf-control-glue.xml 2010-08-18 23:22:58 +0000
+++ src/bamf-control-glue.xml 1970-01-01 00:00:00 +0000
@@ -1,35 +0,0 @@
1<?xml version="1.0" encoding="UTF-8" ?>
2
3<node name="/org/ayatana/bamf">
4
5 <interface name="org.ayatana.bamf.control">
6
7 <method name="RegisterApplicationForPid">
8 <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_control_register_application_for_pid" />
9 <arg type="s" name="application" direction="in" />
10 <arg type="i" name="pid" direction="in" />
11 </method>
12
13 <method name="RegisterTabProvider">
14 <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_control_register_tab_provider" />
15 <annotation name="org.freedesktop.DBus.GLib.Async" value="" />
16 <arg type="s" name="tab_path" direction="in" />
17 </method>
18
19 <method name="OmNomNomDesktopFile">
20 <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_control_insert_desktop_file" />
21 <arg type="s" name="tab_path" direction="in" />
22 </method>
23
24 <method name="SetApproverBehavior">
25 <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_control_set_approver_behavior" />
26 <arg type="i" name="behavior" direction="in" />
27 </method>
28
29 <method name="Quit">
30 <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_control_quit" />
31 </method>
32
33 </interface>
34
35</node>
360
=== modified file 'src/bamf-control.c'
--- src/bamf-control.c 2011-08-01 23:25:01 +0000
+++ src/bamf-control.c 2012-01-19 19:16:25 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright (C) 2010 Canonical Ltd2 * Copyright (C) 2010-2011 Canonical Ltd
3 *3 *
4 * This program is free software: you can redistribute it and/or modify4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as5 * it under the terms of the GNU General Public License version 3 as
@@ -14,6 +14,7 @@
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *15 *
16 * Authored by: Jason Smith <jason.smith@canonical.com>16 * Authored by: Jason Smith <jason.smith@canonical.com>
17 * Marco Trevisan (Treviño) <3v1n0@ubuntu.com>
17 *18 *
18 */19 */
1920
@@ -21,11 +22,10 @@
21#include "bamf-tab-source.h"22#include "bamf-tab-source.h"
22#include "bamf-matcher.h"23#include "bamf-matcher.h"
23#include "bamf-control.h"24#include "bamf-control.h"
24#include "bamf-control-glue.h"
25#include "bamf-indicator-source.h"25#include "bamf-indicator-source.h"
26#include <gtk/gtk.h>26#include "bamf-daemon.h"
2727
28G_DEFINE_TYPE (BamfControl, bamf_control, G_TYPE_OBJECT);28G_DEFINE_TYPE (BamfControl, bamf_control, BAMF_DBUS_TYPE_CONTROL_SKELETON);
29#define BAMF_CONTROL_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE(obj, \29#define BAMF_CONTROL_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE(obj, \
30BAMF_TYPE_CONTROL, BamfControlPrivate))30BAMF_TYPE_CONTROL, BamfControlPrivate))
3131
@@ -56,26 +56,12 @@
56static void56static void
57bamf_control_constructed (GObject *object)57bamf_control_constructed (GObject *object)
58{58{
59 BamfControl *control;59 GDBusConnection *gbus;
60 DBusGConnection *bus;
61 GError *error = NULL;
6260
63 if (G_OBJECT_CLASS (bamf_control_parent_class)->constructed)61 if (G_OBJECT_CLASS (bamf_control_parent_class)->constructed)
64 G_OBJECT_CLASS (bamf_control_parent_class)->constructed (object);62 G_OBJECT_CLASS (bamf_control_parent_class)->constructed (object);
6563
66 control = BAMF_CONTROL (object);
67
68 bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
69
70 g_return_if_fail (bus);
71
72 dbus_g_connection_register_g_object (bus, BAMF_CONTROL_PATH,
73 G_OBJECT (control));
74
75
76 GDBusConnection *gbus;
77 gbus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL);64 gbus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL);
78
79 g_dbus_connection_signal_subscribe (gbus,65 g_dbus_connection_signal_subscribe (gbus,
80 NULL,66 NULL,
81 "org.gtk.gio.DesktopAppInfo",67 "org.gtk.gio.DesktopAppInfo",
@@ -84,14 +70,100 @@
84 NULL,70 NULL,
85 0,71 0,
86 bamf_control_on_launched_callback,72 bamf_control_on_launched_callback,
87 control,73 BAMF_CONTROL (object),
88 NULL);74 NULL);
89}75}
9076
77static gboolean
78on_dbus_handle_quit (BamfDBusControl *interface,
79 GDBusMethodInvocation *invocation,
80 BamfControl *self)
81{
82 bamf_control_quit (self);
83 g_dbus_method_invocation_return_value (invocation, NULL);
84
85 return TRUE;
86}
87
88static gboolean
89on_dbus_handle_set_approver_behavior (BamfDBusControl *interface,
90 GDBusMethodInvocation *invocation,
91 gint behavior,
92 BamfControl *self)
93{
94 bamf_control_set_approver_behavior (self, behavior);
95 g_dbus_method_invocation_return_value (invocation, NULL);
96
97 return TRUE;
98}
99
100static gboolean
101on_dbus_handle_om_nom_nom_desktop_file (BamfDBusControl *interface,
102 GDBusMethodInvocation *invocation,
103 const gchar *desktop_file,
104 BamfControl *self)
105{
106 bamf_control_insert_desktop_file (self, desktop_file);
107 g_dbus_method_invocation_return_value (invocation, NULL);
108
109 return TRUE;
110}
111
112static gboolean
113on_dbus_handle_register_tab_provider (BamfDBusControl *interface,
114 GDBusMethodInvocation *invocation,
115 const gchar *tab_path,
116 BamfControl *self)
117{
118 const gchar *sender = g_dbus_method_invocation_get_sender (invocation);
119 bamf_control_register_tab_provider (self, sender, tab_path);
120 g_dbus_method_invocation_return_value (invocation, NULL);
121
122 return TRUE;
123}
124
125static gboolean
126on_dbus_handle_register_application_for_pid (BamfDBusControl *interface,
127 GDBusMethodInvocation *invocation,
128 const gchar *application,
129 guint pid,
130 BamfControl *self)
131{
132 bamf_control_register_application_for_pid (self, application, pid);
133 g_dbus_method_invocation_return_value (invocation, NULL);
134
135 return TRUE;
136}
137
91static void138static void
92bamf_control_init (BamfControl * self)139bamf_control_init (BamfControl * self)
93{140{
94 self->priv = BAMF_CONTROL_GET_PRIVATE (self);141 self->priv = BAMF_CONTROL_GET_PRIVATE (self);
142 self->priv->sources = NULL;
143
144 /* Registering signal callbacks to reply to dbus method calls */
145 g_signal_connect (self, "handle-quit",
146 G_CALLBACK (on_dbus_handle_quit), self);
147
148 g_signal_connect (self, "handle-set-approver-behavior",
149 G_CALLBACK (on_dbus_handle_set_approver_behavior), self);
150
151 g_signal_connect (self, "handle-om-nom-nom-desktop-file",
152 G_CALLBACK (on_dbus_handle_om_nom_nom_desktop_file), self);
153
154 g_signal_connect (self, "handle-register-tab-provider",
155 G_CALLBACK (on_dbus_handle_register_tab_provider), self);
156
157 g_signal_connect (self, "handle-register-application-for-pid",
158 G_CALLBACK (on_dbus_handle_register_application_for_pid), self);
159}
160
161static void
162bamf_control_finalize (GObject *object)
163{
164 BamfControl *self = BAMF_CONTROL (object);
165 g_list_free_full (self->priv->sources, g_object_unref);
166 self->priv->sources = NULL;
95}167}
96168
97static void169static void
@@ -100,94 +172,68 @@
100 GObjectClass *obj_class = G_OBJECT_CLASS (klass);172 GObjectClass *obj_class = G_OBJECT_CLASS (klass);
101173
102 obj_class->constructed = bamf_control_constructed;174 obj_class->constructed = bamf_control_constructed;
103175 obj_class->finalize = bamf_control_finalize;
104 dbus_g_object_type_install_info (BAMF_TYPE_CONTROL,
105 &dbus_glib_bamf_control_object_info);
106176
107 g_type_class_add_private (klass, sizeof (BamfControlPrivate));177 g_type_class_add_private (klass, sizeof (BamfControlPrivate));
108}178}
109179
110gboolean180void
111bamf_control_set_approver_behavior (BamfControl *control,181bamf_control_set_approver_behavior (BamfControl *control,
112 gint32 behavior,182 gint32 behavior)
113 GError **error)
114{183{
115 bamf_indicator_source_set_behavior (bamf_indicator_source_get_default (), behavior);184 BamfIndicatorSource *indicator_source = bamf_indicator_source_get_default ();
116 185 bamf_indicator_source_set_behavior (indicator_source, behavior);
117 return TRUE;
118}186}
119187
120gboolean188void
121bamf_control_register_application_for_pid (BamfControl *control,189bamf_control_register_application_for_pid (BamfControl *control,
122 char *application,190 const char *application,
123 gint32 pid,191 gint32 pid)
124 GError **error)
125{192{
126 bamf_matcher_register_desktop_file_for_pid (bamf_matcher_get_default (),193 BamfMatcher *matcher = bamf_matcher_get_default ();
127 application, pid);194 bamf_matcher_register_desktop_file_for_pid (matcher, application, pid);
128
129 return TRUE;
130}195}
131196
132gboolean197void
133bamf_control_insert_desktop_file (BamfControl *control,198bamf_control_insert_desktop_file (BamfControl *control,
134 char *path,199 const char *path)
135 GError **error)
136{200{
137 bamf_matcher_load_desktop_file (bamf_matcher_get_default (), path);201 BamfMatcher *matcher = bamf_matcher_get_default ();
138202 bamf_matcher_load_desktop_file (matcher, path);
139 return TRUE;
140}203}
141204
142gboolean205void
143bamf_control_register_tab_provider (BamfControl *control,206bamf_control_register_tab_provider (BamfControl *control,
144 char *path,207 const char *sender,
145 DBusGMethodInvocation *context)208 const char *path)
146{209{
147 BamfTabSource *source;210 BamfTabSource *source;
148 char *bus;211
149212 if (!path || !sender)
150 if (!path)213 {
151 {214 return;
152 dbus_g_method_return (context);215 }
153 return TRUE;216
154 }217 source = bamf_tab_source_new (g_strdup (sender), g_strdup (path));
155218
156 bus = dbus_g_method_get_sender (context);219 if (BAMF_IS_TAB_SOURCE (source))
157220 {
158 if (!bus)221 control->priv->sources = g_list_prepend (control->priv->sources, source);
159 {222 }
160 dbus_g_method_return (context);
161 return TRUE;
162 }
163
164 source = bamf_tab_source_new (bus, path);
165
166 if (!BAMF_IS_TAB_SOURCE (source))
167 {
168 dbus_g_method_return (context);
169 return TRUE;
170 }
171
172 control->priv->sources = g_list_prepend (control->priv->sources, source);
173
174 dbus_g_method_return (context);
175 return TRUE;
176}223}
177224
178static gboolean225static gboolean
179bamf_control_on_quit (BamfControl *control)226bamf_control_on_quit (BamfControl *control)
180{227{
181 gtk_main_quit ();228 BamfDaemon *daemon = bamf_daemon_get_default ();
229 bamf_daemon_stop (daemon);
182 return FALSE;230 return FALSE;
183}231}
184232
185gboolean233void
186bamf_control_quit (BamfControl *control,234bamf_control_quit (BamfControl *control)
187 GError **error)
188{235{
189 g_idle_add ((GSourceFunc) bamf_control_on_quit, control);236 g_idle_add ((GSourceFunc) bamf_control_on_quit, control);
190 return TRUE;
191}237}
192238
193BamfControl *239BamfControl *
@@ -198,8 +244,7 @@
198 if (!BAMF_IS_CONTROL (control))244 if (!BAMF_IS_CONTROL (control))
199 {245 {
200 control = (BamfControl *) g_object_new (BAMF_TYPE_CONTROL, NULL);246 control = (BamfControl *) g_object_new (BAMF_TYPE_CONTROL, NULL);
201 return control;
202 }247 }
203248
204 return g_object_ref (G_OBJECT (control));249 return control;
205}250}
206251
=== modified file 'src/bamf-control.h'
--- src/bamf-control.h 2010-08-18 23:22:58 +0000
+++ src/bamf-control.h 2012-01-19 19:16:25 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright (C) 2010 Canonical Ltd2 * Copyright (C) 2010-2011 Canonical Ltd
3 *3 *
4 * This program is free software: you can redistribute it and/or modify4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as5 * it under the terms of the GNU General Public License version 3 as
@@ -14,6 +14,7 @@
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *15 *
16 * Authored by: Jason Smith <jason.smith@canonical.com>16 * Authored by: Jason Smith <jason.smith@canonical.com>
17 * Marco Trevisan (Treviño) <3v1n0@ubuntu.com>
17 *18 *
18 */19 */
1920
@@ -24,8 +25,7 @@
24#include "bamf.h"25#include "bamf.h"
25#include <glib.h>26#include <glib.h>
26#include <glib-object.h>27#include <glib-object.h>
27#include <dbus/dbus-glib.h>28#include <gio/gio.h>
28#include <dbus/dbus-glib-lowlevel.h>
2929
30#define BAMF_TYPE_CONTROL (bamf_control_get_type ())30#define BAMF_TYPE_CONTROL (bamf_control_get_type ())
31#define BAMF_CONTROL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BAMF_TYPE_CONTROL, BamfControl))31#define BAMF_CONTROL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BAMF_TYPE_CONTROL, BamfControl))
@@ -40,12 +40,12 @@
4040
41struct _BamfControlClass41struct _BamfControlClass
42{42{
43 GObjectClass parent;43 BamfDBusControlSkeletonClass parent;
44};44};
4545
46struct _BamfControl46struct _BamfControl
47{47{
48 GObject parent;48 BamfDBusControlSkeleton parent;
4949
50 /* private */50 /* private */
51 BamfControlPrivate *priv;51 BamfControlPrivate *priv;
@@ -53,25 +53,21 @@
5353
54GType bamf_control_get_type (void) G_GNUC_CONST;54GType bamf_control_get_type (void) G_GNUC_CONST;
5555
56gboolean bamf_control_register_application_for_pid (BamfControl *control,56void bamf_control_register_application_for_pid (BamfControl *control,
57 char *application,57 const char *application,
58 gint32 pid,58 gint32 pid);
59 GError **error);59
6060void bamf_control_register_tab_provider (BamfControl *control,
61gboolean bamf_control_register_tab_provider (BamfControl *control,61 const char *sender,
62 char *path,62 const char *path);
63 DBusGMethodInvocation *context);63
6464void bamf_control_insert_desktop_file (BamfControl *control,
65gboolean bamf_control_insert_desktop_file (BamfControl *control,65 const char *path);
66 char *path,66
67 GError **error);67void bamf_control_set_approver_behavior (BamfControl *control,
6868 gint32 behavior);
69gboolean bamf_control_set_approver_behavior (BamfControl *control,69
70 gint32 behavior,70void bamf_control_quit (BamfControl *control);
71 GError **error);
72
73gboolean bamf_control_quit (BamfControl *control,
74 GError **error);
7571
76BamfControl * bamf_control_get_default (void);72BamfControl * bamf_control_get_default (void);
7773
7874
=== added file 'src/bamf-daemon.c'
--- src/bamf-daemon.c 1970-01-01 00:00:00 +0000
+++ src/bamf-daemon.c 2012-01-19 19:16:25 +0000
@@ -0,0 +1,215 @@
1/*
2 * Copyright (C) 2011 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Marco Trevisan (Treviño) <3v1n0@ubuntu.com>
17 *
18 */
19
20#include "bamf.h"
21
22#include "bamf-daemon.h"
23#include "bamf-matcher.h"
24#include "bamf-control.h"
25#include "bamf-indicator-source.h"
26
27G_DEFINE_TYPE (BamfDaemon, bamf_daemon, G_TYPE_OBJECT);
28#define BAMF_DAEMON_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE(obj, \
29 BAMF_TYPE_DAEMON, BamfDaemonPrivate))
30
31static BamfDaemon *instance = NULL;
32
33struct _BamfDaemonPrivate
34{
35 BamfMatcher *matcher;
36 BamfControl *control;
37 BamfIndicatorSource *approver;
38 GMainLoop *loop;
39};
40
41gboolean
42bamf_daemon_is_running (BamfDaemon *self)
43{
44 g_return_val_if_fail (self, FALSE);
45
46 if (self->priv->loop && g_main_loop_is_running (self->priv->loop))
47 {
48 return TRUE;
49 }
50
51 return FALSE;
52}
53
54static void
55bamf_on_bus_acquired (GDBusConnection *connection, const gchar *name,
56 BamfDaemon *self)
57{
58 GError *error = NULL;
59 g_return_if_fail (BAMF_IS_DAEMON (self));
60
61 g_debug ("Acquired a message bus connection");
62
63 g_dbus_connection_set_exit_on_close (connection, TRUE);
64
65 self->priv->matcher = bamf_matcher_get_default ();
66 self->priv->control = bamf_control_get_default ();
67 //self->priv->approver = bamf_indicator_source_get_default ();
68
69 g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (self->priv->matcher),
70 connection,
71 BAMF_MATCHER_PATH,
72 &error);
73
74 if (error)
75 {
76 g_critical ("Can't register BAMF matcher at path %s: %s", BAMF_MATCHER_PATH,
77 error->message);
78 g_clear_error (&error);
79 }
80
81 g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (self->priv->control),
82 connection,
83 BAMF_CONTROL_PATH,
84 &error);
85
86 if (error)
87 {
88 g_critical ("Can't register BAMF control at path %s: %s", BAMF_CONTROL_PATH,
89 error->message);
90 g_clear_error (&error);
91 }
92/*
93 g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (self->priv->approver),
94 connection,
95 BAMF_INDICATOR_SOURCE_PATH,
96 &error);
97
98 if (error)
99 {
100 g_critical ("Can't register BAMF approver at path %s: %s",
101 BAMF_INDICATOR_SOURCE_PATH, error->message);
102 g_clear_error (&error);
103 }
104*/
105}
106
107static void
108bamf_on_name_acquired (GDBusConnection *connection, const gchar *name,
109 BamfDaemon *self)
110{
111 g_debug ("Acquired the name %s", name);
112}
113
114static void
115bamf_on_name_lost (GDBusConnection *connection, const gchar *name, BamfDaemon *self)
116{
117 g_critical ("Lost the name %s, another BAMF daemon is currently running", name);
118
119 bamf_daemon_stop (self);
120}
121
122void
123bamf_daemon_start (BamfDaemon *self)
124{
125 g_return_if_fail (BAMF_IS_DAEMON (self));
126
127 if (bamf_daemon_is_running (self))
128 return;
129
130 g_bus_own_name (G_BUS_TYPE_SESSION, BAMF_DBUS_SERVICE,
131 G_BUS_NAME_OWNER_FLAGS_NONE,
132 (GBusAcquiredCallback) bamf_on_bus_acquired,
133 (GBusNameAcquiredCallback) bamf_on_name_acquired,
134 (GBusNameLostCallback) bamf_on_name_lost,
135 self, NULL);
136
137 g_main_loop_run (self->priv->loop);
138}
139
140void
141bamf_daemon_stop (BamfDaemon *self)
142{
143 g_return_if_fail (BAMF_IS_DAEMON (self));
144
145 if (self->priv->matcher)
146 {
147 g_object_unref (self->priv->matcher);
148 self->priv->matcher = NULL;
149 }
150
151 if (self->priv->control)
152 {
153 g_object_unref (self->priv->control);
154 self->priv->control = NULL;
155 }
156
157 if (self->priv->approver)
158 {
159 g_object_unref (self->priv->approver);
160 self->priv->approver = NULL;
161 }
162
163 g_main_loop_quit (self->priv->loop);
164}
165
166static void
167bamf_daemon_dispose (GObject *object)
168{
169 BamfDaemon *self = BAMF_DAEMON (object);
170
171 bamf_daemon_stop (self);
172
173 if (self->priv->loop)
174 {
175 g_main_loop_unref (self->priv->loop);
176 self->priv->loop = NULL;
177 }
178
179 G_OBJECT_CLASS (bamf_daemon_parent_class)->dispose (object);
180}
181
182static void
183bamf_daemon_finalize (GObject *object)
184{
185 instance = NULL;
186}
187
188static void
189bamf_daemon_init (BamfDaemon *self)
190{
191 BamfDaemonPrivate *priv;
192 priv = self->priv = BAMF_DAEMON_GET_PRIVATE (self);
193
194 priv->loop = g_main_loop_new (NULL, FALSE);
195}
196
197static void
198bamf_daemon_class_init (BamfDaemonClass * klass)
199{
200 GObjectClass *object_class = G_OBJECT_CLASS (klass);
201
202 object_class->dispose = bamf_daemon_dispose;
203 object_class->finalize = bamf_daemon_finalize;
204
205 g_type_class_add_private (klass, sizeof (BamfDaemonPrivate));
206}
207
208BamfDaemon *
209bamf_daemon_get_default (void)
210{
211 if (!BAMF_IS_DAEMON (instance))
212 instance = (BamfDaemon *) g_object_new (BAMF_TYPE_DAEMON, NULL);
213
214 return instance;
215}
0216
=== added file 'src/bamf-daemon.h'
--- src/bamf-daemon.h 1970-01-01 00:00:00 +0000
+++ src/bamf-daemon.h 2012-01-19 19:16:25 +0000
@@ -0,0 +1,61 @@
1/*
2 * Copyright (C) 2011 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Marco Trevisan (Treviño) <3v1n0@ubuntu.com>
17 *
18 */
19
20#ifndef __BAMFDAEMON_H__
21#define __BAMFDAEMON_H__
22
23#include "bamf.h"
24#include <glib.h>
25#include <glib-object.h>
26
27#define BAMF_TYPE_DAEMON (bamf_daemon_get_type ())
28#define BAMF_DAEMON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BAMF_TYPE_DAEMON, BamfDaemon))
29#define BAMF_IS_DAEMON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BAMF_TYPE_DAEMON))
30#define BAMF_DAEMON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BAMF_TYPE_DAEMON, BamfDaemonClass))
31#define BAMF_IS_DAEMON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BAMF_TYPE_DAEMON))
32#define BAMF_DAEMON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BAMF_TYPE_DAEMON, BamfDaemonClass))
33
34typedef struct _BamfDaemon BamfDaemon;
35typedef struct _BamfDaemonClass BamfDaemonClass;
36typedef struct _BamfDaemonPrivate BamfDaemonPrivate;
37
38struct _BamfDaemonClass
39{
40 GObjectClass parent;
41};
42
43struct _BamfDaemon
44{
45 GObject parent;
46
47 /* private */
48 BamfDaemonPrivate *priv;
49};
50
51GType bamf_daemon_get_type (void) G_GNUC_CONST;
52
53void bamf_daemon_start (BamfDaemon *self);
54
55void bamf_daemon_stop (BamfDaemon *self);
56
57gboolean bamf_daemon_is_running (BamfDaemon *self);
58
59BamfDaemon * bamf_daemon_get_default (void);
60
61#endif //__BAMFDAEMON_H__
062
=== removed file 'src/bamf-indicator-glue.xml'
--- src/bamf-indicator-glue.xml 2010-07-09 08:05:06 +0000
+++ src/bamf-indicator-glue.xml 1970-01-01 00:00:00 +0000
@@ -1,23 +0,0 @@
1<?xml version="1.0" encoding="UTF-8" ?>
2
3<node name="/org/ayatana/bamf">
4
5 <interface name="org.ayatana.bamf.indicator">
6
7 <method name="Path">
8 <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_indicator_get_path" />
9 <arg type="s" name="path" direction="out">
10 <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/>
11 </arg>
12 </method>
13
14 <method name="Address">
15 <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_indicator_get_address" />
16 <arg type="s" name="address" direction="out">
17 <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/>
18 </arg>
19 </method>
20
21 </interface>
22
23</node>
240
=== removed file 'src/bamf-indicator-source-glue.xml'
--- src/bamf-indicator-source-glue.xml 2011-01-14 06:35:14 +0000
+++ src/bamf-indicator-source-glue.xml 1970-01-01 00:00:00 +0000
@@ -1,28 +0,0 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<node name="/org/ayatana/bamf">
3 <interface name="com.canonical.StatusNotifierApprover">
4 <signal name="ReviseJudgement">
5 <arg type="b" name="approved" direction="out" />
6 <arg type="s" name="address" direction="out" />
7 <arg type="o" name="path" direction="out" />
8 </signal>
9
10 <!-- Methods -->
11 <method name="ApproveItem">
12 <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_indicator_source_approve_item" />
13 <!-- KSNI ID -->
14 <arg type="s" name="id" direction="in" />
15 <!-- KSNI Category -->
16 <arg type="s" name="category" direction="in" />
17 <!-- Application PID -->
18 <arg type="u" name="pid" direction="in" />
19 <!-- Application DBus Address -->
20 <arg type="s" name="address" direction="in" />
21 <!-- Application DBus Path for KSNI interface -->
22 <arg type="o" name="path" direction="in" />
23 <!-- So, what do you think? -->
24 <arg type="b" name="approved" direction="out" />
25 </method>
26
27 </interface>
28</node>
290
=== modified file 'src/bamf-indicator-source.c'
--- src/bamf-indicator-source.c 2011-02-09 18:45:53 +0000
+++ src/bamf-indicator-source.c 2012-01-19 19:16:25 +0000
@@ -1,39 +1,32 @@
1/*1/*
2 * bamf-notification-approver.c2 * Copyright (C) 2010-2011 Canonical Ltd
3 * This file is part of BAMF3 *
4 *4 * This program is free software: you can redistribute it and/or modify
5 * Copyright (C) 2010 - Jason Smith5 * it under the terms of the GNU General Public License version 3 as
6 *6 * published by the Free Software Foundation.
7 * BAMF is free software; you can redistribute it and/or modify7 *
8 * it under the terms of the GNU General Public License as published by8 * This program is distributed in the hope that it will be useful,
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * BAMF is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.11 * GNU General Public License for more details.
16 *12 *
17 * You should have received a copy of the GNU General Public License13 * You should have received a copy of the GNU General Public License
18 * along with BAMF; if not, write to the Free Software14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, 15 *
20 * Boston, MA 02110-1301 USA16 * Authored by: Jason Smith <jason.smith@canonical.com>
17 * Marco Trevisan (Treviño) <3v1n0@ubuntu.com>
18 *
21 */19 */
2220
23
24#include "bamf-marshal.h"
25#include "bamf-indicator-source.h"21#include "bamf-indicator-source.h"
26#include "bamf-indicator-source-glue.h"
27#include <dbus/dbus-glib-bindings.h>
2822
29#define BAMF_INDICATOR_SOURCE_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE((object), BAMF_TYPE_INDICATOR_SOURCE, BamfIndicatorSourcePrivate))23#define BAMF_INDICATOR_SOURCE_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE((object), \
30#define BAMF_INDICATOR_SOURCE_PATH "/org/ayatana/bamf/IndicatorSource"24 BAMF_TYPE_INDICATOR_SOURCE, BamfIndicatorSourcePrivate))
3125
32enum26enum
33{27{
34 INDICATOR_OPENED,28 INDICATOR_OPENED,
35 INDICATOR_CLOSED,29 INDICATOR_CLOSED,
36 REVISE_JUDGEMENT,
3730
38 LAST_SIGNAL,31 LAST_SIGNAL,
39};32};
@@ -43,17 +36,17 @@
43struct _BamfIndicatorSourcePrivate36struct _BamfIndicatorSourcePrivate
44{37{
45 GList *indicators;38 GList *indicators;
46 DBusGProxy *proxy;39 GDBusProxy *proxy;
47 int behavior;40 int behavior;
48};41};
4942
50G_DEFINE_TYPE (BamfIndicatorSource, bamf_indicator_source, G_TYPE_OBJECT)43G_DEFINE_TYPE (BamfIndicatorSource, bamf_indicator_source, STATUS_NOTIFIER_APPROVER_TYPE__SKELETON)
5144
52GList *45GList *
53bamf_indicator_source_get_indicators (BamfIndicatorSource *self)46bamf_indicator_source_get_indicators (BamfIndicatorSource *self)
54{47{
55 g_return_val_if_fail (BAMF_IS_INDICATOR_SOURCE (self), NULL);48 g_return_val_if_fail (BAMF_IS_INDICATOR_SOURCE (self), NULL);
56 49
57 return self->priv->indicators;50 return self->priv->indicators;
58}51}
5952
@@ -61,15 +54,15 @@
61on_indicator_closed (BamfView *view, BamfIndicatorSource *self)54on_indicator_closed (BamfView *view, BamfIndicatorSource *self)
62{55{
63 BamfIndicator *indicator;56 BamfIndicator *indicator;
64 57
65 g_return_if_fail (BAMF_IS_INDICATOR (view));58 g_return_if_fail (BAMF_IS_INDICATOR (view));
66 g_return_if_fail (BAMF_IS_INDICATOR_SOURCE (self));59 g_return_if_fail (BAMF_IS_INDICATOR_SOURCE (self));
67 60
68 indicator = BAMF_INDICATOR (view);61 indicator = BAMF_INDICATOR (view);
69 62
70 self->priv->indicators = g_list_remove (self->priv->indicators, indicator);63 self->priv->indicators = g_list_remove (self->priv->indicators, indicator);
71 g_signal_emit (self, indicator_source_signals[INDICATOR_CLOSED], 0, indicator);64 g_signal_emit (self, indicator_source_signals[INDICATOR_CLOSED], 0, indicator);
72 65
73 g_object_unref (G_OBJECT (indicator));66 g_object_unref (G_OBJECT (indicator));
74}67}
7568
@@ -78,9 +71,10 @@
78{71{
79 g_return_if_fail (BAMF_IS_INDICATOR (indicator));72 g_return_if_fail (BAMF_IS_INDICATOR (indicator));
80 g_return_if_fail (BAMF_IS_INDICATOR_SOURCE (self));73 g_return_if_fail (BAMF_IS_INDICATOR_SOURCE (self));
81 74
82 char *address = bamf_indicator_get_address (indicator);75 const char *address = bamf_indicator_get_address (indicator);
83 char *path = bamf_indicator_get_path (indicator);76 const char *path = bamf_indicator_get_path (indicator);
77 GList *parents = bamf_view_get_parents (BAMF_VIEW (indicator));
84 gboolean approve = TRUE;78 gboolean approve = TRUE;
8579
86 switch (self->priv->behavior)80 switch (self->priv->behavior)
@@ -89,17 +83,14 @@
89 approve = FALSE;83 approve = FALSE;
90 break;84 break;
91 case BAMF_INDICATOR_SOURCE_APPROVE_MATCHED:85 case BAMF_INDICATOR_SOURCE_APPROVE_MATCHED:
92 approve = g_list_length (bamf_view_get_parents (BAMF_VIEW (indicator))) == 0;86 approve = (parents == NULL);
93 break;87 break;
94 case BAMF_INDICATOR_SOURCE_APPROVE_ALL:88 case BAMF_INDICATOR_SOURCE_APPROVE_ALL:
95 approve = TRUE;89 approve = TRUE;
96 break;90 break;
97 }91 }
98 92
99 g_signal_emit (self, indicator_source_signals[REVISE_JUDGEMENT], 0, approve, address, path);93 g_signal_emit_by_name (self, "revise-judgement", approve, address, path);
100
101 g_free (address);
102 g_free (path);
103}94}
10495
105void 96void
@@ -114,9 +105,9 @@
114 105
115 if (priv->behavior == behavior)106 if (priv->behavior == behavior)
116 return;107 return;
117 108
118 priv->behavior = behavior;109 priv->behavior = behavior;
119 110
120 g_list_foreach (priv->indicators, (GFunc) rejudge_approval, self);111 g_list_foreach (priv->indicators, (GFunc) rejudge_approval, self);
121}112}
122113
@@ -126,61 +117,80 @@
126 const char *category,117 const char *category,
127 guint32 pid,118 guint32 pid,
128 const char *address,119 const char *address,
129 const char *path,120 const char *path)
130 gboolean *approve,
131 GError **remote_error)
132{121{
133 DBusGConnection *bus;
134 DBusGProxy *dbus_proxy;
135 GList *l;122 GList *l;
136 GError *error = NULL;123 GError *error = NULL;
137 BamfIndicator *indicator = NULL;124 BamfIndicator *indicator = NULL;
138 *approve = TRUE;125
139 guint remote_pid;
140
141 g_return_val_if_fail (category, TRUE);126 g_return_val_if_fail (category, TRUE);
142 g_return_val_if_fail (path, TRUE);127 g_return_val_if_fail (path, TRUE);
143 g_return_val_if_fail (address, TRUE);128 g_return_val_if_fail (address, TRUE);
144 g_return_val_if_fail (BAMF_IS_INDICATOR_SOURCE (self), TRUE);129 g_return_val_if_fail (BAMF_IS_INDICATOR_SOURCE (self), TRUE);
145 130
146 if (g_strcmp0 (category, "ApplicationStatus") != 0 || 131 if (g_strcmp0 (category, "ApplicationStatus") != 0 ||
147 g_strcmp0 (path, "/com/canonical/NotificationItem/dropbox_client") == 0)132 g_strcmp0 (path, "/com/canonical/NotificationItem/dropbox_client") == 0)
148 return TRUE;133 return TRUE;
149 134
150 if (pid == 0)135 if (pid == 0)
151 {136 {
152 g_warning ("Remote service passed indicator with pid of 0, manually fetching pid\n");137 GDBusProxy *gproxy;
153 138 GVariant *remote_pid;
154 bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error);139
155 g_return_val_if_fail (bus, TRUE);140 g_warning ("Remote service passed indicator with pid of 0, manually fetching pid");
156 141
157 dbus_proxy = dbus_g_proxy_new_for_name (bus,142 gproxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
158 DBUS_SERVICE_DBUS,143 G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES|
159 DBUS_PATH_DBUS,144 G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS,
160 DBUS_INTERFACE_DBUS);145 NULL,
161 g_return_val_if_fail (dbus_proxy, TRUE);146 "org.freedesktop.DBus",
162 147 "/org/freedesktop/DBus",
163 error = NULL;148 "org.freedesktop.DBus",
164 if (!org_freedesktop_DBus_get_connection_unix_process_id (dbus_proxy, address, &remote_pid, &error))149 NULL,
165 {150 &error);
166 g_warning ("Could not get indicator process id: %s\n", error->message);151
167 g_error_free (error);152 if (error)
168 }153 {
169 154 g_warning ("Could not get indicator process id: %s", error->message);
170 g_object_unref (G_OBJECT (dbus_proxy));155 g_clear_error (&error);
171 pid = (guint32) remote_pid;156 }
157
158 g_return_val_if_fail (G_IS_DBUS_PROXY (gproxy), TRUE);
159
160 remote_pid = g_dbus_proxy_call_sync (gproxy, "GetConnectionUnixProcessID",
161 g_variant_new ("(s)", address),
162 G_DBUS_CALL_FLAGS_NONE,
163 -1,
164 NULL,
165 &error);
166 if (error)
167 {
168 g_warning ("Could not get indicator process id: %s", error->message);
169 g_clear_error (&error);
170 return TRUE;
171 }
172
173 g_return_val_if_fail (remote_pid, TRUE);
174
175 pid = g_variant_get_uint32 (g_variant_get_child_value (remote_pid, 0));
176
177 g_object_unref (gproxy);
178 g_variant_unref (remote_pid);
179
180 if (pid == 0)
181 return TRUE;
172 }182 }
173 183
174 for (l = self->priv->indicators; l; l = l->next)184 for (l = self->priv->indicators; l; l = l->next)
175 {185 {
176 if (bamf_indicator_matches_signature (BAMF_INDICATOR (l->data), pid, address, path))186 if (bamf_indicator_matches_signature (BAMF_INDICATOR (l->data), pid, address, path))
177 {187 {
178 g_debug ("NotifierWatcher service passed already known indicator, ignoring\n");188 g_debug ("NotifierWatcher service passed already known indicator, ignoring");
179 indicator = BAMF_INDICATOR (l->data);189 indicator = BAMF_INDICATOR (l->data);
180 break;190 break;
181 }191 }
182 }192 }
183 193
184 if (!indicator)194 if (!indicator)
185 {195 {
186 indicator = bamf_indicator_new (id, path, address, pid);196 indicator = bamf_indicator_new (id, path, address, pid);
@@ -189,101 +199,145 @@
189 g_signal_connect (G_OBJECT (indicator), "closed", (GCallback) on_indicator_closed, self);199 g_signal_connect (G_OBJECT (indicator), "closed", (GCallback) on_indicator_closed, self);
190 g_signal_emit (self, indicator_source_signals[INDICATOR_OPENED], 0, indicator);200 g_signal_emit (self, indicator_source_signals[INDICATOR_OPENED], 0, indicator);
191 }201 }
192 202
203 GList *parents = bamf_view_get_parents (BAMF_VIEW (indicator));
204
193 switch (self->priv->behavior)205 switch (self->priv->behavior)
194 {206 {
195 case BAMF_INDICATOR_SOURCE_APPROVE_NONE:207 case BAMF_INDICATOR_SOURCE_APPROVE_NONE:
196 *approve = FALSE;208 return FALSE;
197 break;209
198
199 case BAMF_INDICATOR_SOURCE_APPROVE_MATCHED:210 case BAMF_INDICATOR_SOURCE_APPROVE_MATCHED:
200 *approve = !(indicator && g_list_length (bamf_view_get_parents (BAMF_VIEW (indicator))) > 0);211 return !(indicator && parents);
201 break;212
202
203 case BAMF_INDICATOR_SOURCE_APPROVE_ALL:213 case BAMF_INDICATOR_SOURCE_APPROVE_ALL:
204 *approve = TRUE;214 return TRUE;
205 break;
206 }215 }
207 216
208 return TRUE;217 return TRUE;
209}218}
210219
211static void on_proxy_destroy (DBusGProxy *proxy, BamfIndicatorSource *self);220static void status_notifier_proxy_owner_changed (GObject *object, GParamSpec *pspec, BamfIndicatorSource *self);
212221
213static gboolean222static gboolean
214bamf_indicator_source_register_notification_approver (BamfIndicatorSource *self)223bamf_indicator_source_register_notification_approver (BamfIndicatorSource *self)
215{224{
216 DBusGConnection *bus;
217 GError *error = NULL;
218 static int retry_count = 0;225 static int retry_count = 0;
219226 GDBusProxy *gproxy;
220 bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error);227 GError *error = NULL;
221 g_return_val_if_fail (bus, FALSE);228 gchar *owner;
222229
223 self->priv->proxy = dbus_g_proxy_new_for_name_owner (bus,230 gproxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
224 "com.canonical.indicator.application",231 G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES|
225 "/StatusNotifierWatcher",232 G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS|
226 "org.kde.StatusNotifierWatcher",233 G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START,
227 &error);234 NULL,
228 235 "org.kde.StatusNotifierWatcher",//"com.canonical.indicator.application",
229 if (self->priv->proxy)236 "/StatusNotifierWatcher",
230 {237 "org.kde.StatusNotifierWatcher",
231 if (dbus_g_proxy_call (self->priv->proxy,238 NULL,
232 "XAyatanaRegisterNotificationApprover",239 &error);
233 &error,240
234 DBUS_TYPE_G_OBJECT_PATH, BAMF_INDICATOR_SOURCE_PATH,241 if (error)
235 G_TYPE_STRV, NULL,242 {
236 G_TYPE_INVALID,243 g_debug ("Failed to get notification approver proxy: %s", error->message);
237 G_TYPE_INVALID))244 g_error_free (error);
245 }
246 else
247 {
248 owner = g_dbus_proxy_get_name_owner (gproxy);
249
250 if (owner)
238 {251 {
239 g_debug ("Remote notification approver registered\n");252 g_free (owner);
240 g_signal_connect (G_OBJECT (self->priv->proxy), "destroy", (GCallback) on_proxy_destroy, self);253
241 retry_count = 0;254 GVariantBuilder tuple, array;
242 return FALSE;255 g_variant_builder_init (&tuple, G_VARIANT_TYPE_TUPLE);
256 g_variant_builder_add_value (&tuple, g_variant_new_object_path (BAMF_INDICATOR_SOURCE_PATH));
257 g_variant_builder_init (&array, G_VARIANT_TYPE ("as"));
258 g_variant_builder_add_value (&tuple, g_variant_builder_end (&array));
259
260 g_dbus_proxy_call_sync (gproxy, "XAyatanaRegisterNotificationApprover",
261 g_variant_builder_end (&tuple),
262 G_DBUS_CALL_FLAGS_NONE,
263 -1,
264 NULL,
265 &error);
266
267 if (!error)
268 {
269 g_debug ("Remote notification approver registered");
270 g_signal_connect (G_OBJECT (gproxy), "notify::g-name-owner",
271 (GCallback) status_notifier_proxy_owner_changed,
272 self);
273
274 if (self->priv->proxy)
275 g_object_unref (self->priv->proxy);
276
277 self->priv->proxy = gproxy;
278 retry_count = 0;
279 return FALSE;
280 }
281 else
282 {
283 g_debug ("Failed to register as approver: %s", error->message);
284 g_error_free (error);
285 }
243 }286 }
244 else287 else
245 {288 {
246 g_debug ("Failed to register as approver: %s\n", error->message);289 g_debug ("Failed to get notification approver proxy: no owner available");
247 g_error_free (error);
248 }290 }
249 }291
250 else292 g_object_unref (gproxy);
251 {293 }
252 g_debug ("Failed to get notification approver proxy: %s\n", error->message);294
253 g_error_free (error);
254 }
255 retry_count++;295 retry_count++;
256 296
257 if (retry_count > 10)297 if (retry_count > 10)
258 {298 {
259 g_debug ("Retry count expired\n");299 g_debug ("Retry count expired");
260 return FALSE;300 return FALSE;
261 }301 }
262 302
263 g_debug ("Retrying registration in 2 seconds\n");303 g_debug ("Retrying registration in 2 seconds");
264 return TRUE;304 return TRUE;
265}305}
266306
267static void307static void
268on_proxy_destroy (DBusGProxy *proxy, BamfIndicatorSource *self)308status_notifier_proxy_owner_changed (GObject *object, GParamSpec *pspec,
309 BamfIndicatorSource *self)
269{310{
270 g_return_if_fail (BAMF_IS_INDICATOR_SOURCE (self));311 g_debug ("Remote approver service died, re-establishing connection");
271 312 g_object_unref (self->priv->proxy);
272 g_debug ("Remote approver service died, re-establishing connection\n");313 self->priv->proxy = NULL;
273 314
274 if (bamf_indicator_source_register_notification_approver (self))315 if (bamf_indicator_source_register_notification_approver (self))
275 g_timeout_add (2 * 1000, (GSourceFunc) bamf_indicator_source_register_notification_approver, self);316 g_timeout_add_seconds (2, (GSourceFunc) bamf_indicator_source_register_notification_approver, self);
317}
318
319static gboolean
320on_dbus_handle_approve_item (BamfDBusMatcher *interface,
321 GDBusMethodInvocation *invocation,
322 const gchar *id,
323 const gchar *category,
324 guint pid,
325 const gchar *address,
326 const gchar *path,
327 BamfIndicatorSource *self)
328{
329 gboolean approved = bamf_indicator_source_approve_item (self, id, category,
330 pid, address, path);
331 g_dbus_method_invocation_return_value (invocation,
332 g_variant_new ("(b)", approved));
333
334 return TRUE;
276}335}
277336
278static void337static void
279bamf_indicator_source_constructed (GObject *object)338bamf_indicator_source_constructed (GObject *object)
280{339{
281 BamfIndicatorSource *self;340 BamfIndicatorSource *self;
282 DBusGConnection *bus;
283 GError *error = NULL;
284
285 bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
286 g_return_if_fail (bus);
287341
288 self = BAMF_INDICATOR_SOURCE (object);342 self = BAMF_INDICATOR_SOURCE (object);
289343
@@ -292,15 +346,27 @@
292346
293 self->priv->behavior = BAMF_INDICATOR_SOURCE_APPROVE_ALL;347 self->priv->behavior = BAMF_INDICATOR_SOURCE_APPROVE_ALL;
294 348
295 dbus_g_connection_register_g_object (bus, BAMF_INDICATOR_SOURCE_PATH, object);
296
297 if (bamf_indicator_source_register_notification_approver (self))349 if (bamf_indicator_source_register_notification_approver (self))
298 g_timeout_add (2 * 1000, (GSourceFunc) bamf_indicator_source_register_notification_approver, self);350 g_timeout_add_seconds (2, (GSourceFunc) bamf_indicator_source_register_notification_approver, self);
299}351}
300352
301static void353static void
302bamf_indicator_source_dispose (GObject *object)354bamf_indicator_source_dispose (GObject *object)
303{355{
356 BamfIndicatorSource *self = BAMF_INDICATOR_SOURCE (object);
357
358 if (self->priv->indicators)
359 {
360 g_list_free_full (self->priv->indicators, g_object_unref);
361 self->priv->indicators = NULL;
362 }
363
364 if (self->priv->proxy)
365 {
366 g_object_unref (self->priv->proxy);
367 self->priv->proxy = NULL;
368 }
369
304 G_OBJECT_CLASS (bamf_indicator_source_parent_class)->dispose (object);370 G_OBJECT_CLASS (bamf_indicator_source_parent_class)->dispose (object);
305}371}
306372
@@ -308,50 +374,41 @@
308bamf_indicator_source_class_init (BamfIndicatorSourceClass *klass)374bamf_indicator_source_class_init (BamfIndicatorSourceClass *klass)
309{375{
310 GObjectClass *object_class = G_OBJECT_CLASS (klass);376 GObjectClass *object_class = G_OBJECT_CLASS (klass);
311 377
312 object_class->dispose = bamf_indicator_source_dispose;378 object_class->dispose = bamf_indicator_source_dispose;
313 object_class->constructed = bamf_indicator_source_constructed;379 object_class->constructed = bamf_indicator_source_constructed;
314380
315 indicator_source_signals [REVISE_JUDGEMENT] =381 g_type_class_add_private (object_class, sizeof (BamfIndicatorSourcePrivate));
316 g_signal_new ("revise-judgement",
317 G_OBJECT_CLASS_TYPE (klass),
318 G_SIGNAL_RUN_FIRST,
319 G_STRUCT_OFFSET (BamfIndicatorSourceClass, revise_judgement),
320 NULL, NULL,
321 bamf_marshal_VOID__BOOL_STRING_STRING,
322 G_TYPE_NONE, 3,
323 G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_STRING);
324382
325 indicator_source_signals [INDICATOR_OPENED] =383 indicator_source_signals [INDICATOR_OPENED] =
326 g_signal_new ("indicator-opened",384 g_signal_new ("indicator-opened",
327 G_OBJECT_CLASS_TYPE (klass),385 G_OBJECT_CLASS_TYPE (klass),
328 G_SIGNAL_RUN_FIRST,386 G_SIGNAL_RUN_FIRST,
329 G_STRUCT_OFFSET (BamfIndicatorSourceClass, indicator_opened),387 G_STRUCT_OFFSET (BamfIndicatorSourceClass, indicator_opened),
330 NULL, NULL,388 NULL, NULL,
331 g_cclosure_marshal_VOID__OBJECT,389 g_cclosure_marshal_VOID__OBJECT,
332 G_TYPE_NONE, 1,390 G_TYPE_NONE, 1,
333 BAMF_TYPE_INDICATOR);391 BAMF_TYPE_INDICATOR);
334392
335 indicator_source_signals [INDICATOR_CLOSED] =393 indicator_source_signals [INDICATOR_CLOSED] =
336 g_signal_new ("indicator-closed",394 g_signal_new ("indicator-closed",
337 G_OBJECT_CLASS_TYPE (klass),395 G_OBJECT_CLASS_TYPE (klass),
338 G_SIGNAL_RUN_FIRST,396 G_SIGNAL_RUN_FIRST,
339 G_STRUCT_OFFSET (BamfIndicatorSourceClass, indicator_closed),397 G_STRUCT_OFFSET (BamfIndicatorSourceClass, indicator_closed),
340 NULL, NULL,398 NULL, NULL,
341 g_cclosure_marshal_VOID__OBJECT,399 g_cclosure_marshal_VOID__OBJECT,
342 G_TYPE_NONE, 1,400 G_TYPE_NONE, 1,
343 BAMF_TYPE_INDICATOR);401 BAMF_TYPE_INDICATOR);
344
345 dbus_g_object_type_install_info (BAMF_TYPE_INDICATOR_SOURCE,
346 &dbus_glib_bamf_indicator_source_object_info);
347
348 g_type_class_add_private (object_class, sizeof (BamfIndicatorSourcePrivate));
349}402}
350403
351static void404static void
352bamf_indicator_source_init (BamfIndicatorSource *self)405bamf_indicator_source_init (BamfIndicatorSource *self)
353{406{
354 self->priv = BAMF_INDICATOR_SOURCE_GET_PRIVATE (self);407 self->priv = BAMF_INDICATOR_SOURCE_GET_PRIVATE (self);
408
409 /* Registering signal callbacks to reply to dbus method calls */
410 g_signal_connect (self, "handle-approve-item",
411 G_CALLBACK (on_dbus_handle_approve_item), self);
355}412}
356413
357static BamfIndicatorSource *approver = NULL;414static BamfIndicatorSource *approver = NULL;
@@ -360,6 +417,7 @@
360bamf_indicator_source_get_default ()417bamf_indicator_source_get_default ()
361{418{
362 if (!approver)419 if (!approver)
363 return approver = g_object_new (BAMF_TYPE_INDICATOR_SOURCE, NULL);420 approver = g_object_new (BAMF_TYPE_INDICATOR_SOURCE, NULL);
364 return BAMF_INDICATOR_SOURCE (g_object_ref (approver));421
422 return approver;
365}423}
366424
=== modified file 'src/bamf-indicator-source.h'
--- src/bamf-indicator-source.h 2010-08-18 23:22:58 +0000
+++ src/bamf-indicator-source.h 2012-01-19 19:16:25 +0000
@@ -1,23 +1,21 @@
1/*1/*
2 * bamf-notification-approver.h2 * Copyright (C) 2010-2011 Canonical Ltd
3 * This file is part of BAMF3 *
4 *4 * This program is free software: you can redistribute it and/or modify
5 * Copyright (C) 2010 - Jason Smith5 * it under the terms of the GNU General Public License version 3 as
6 *6 * published by the Free Software Foundation.
7 * BAMF is free software; you can redistribute it and/or modify7 *
8 * it under the terms of the GNU General Public License as published by8 * This program is distributed in the hope that it will be useful,
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * BAMF is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.11 * GNU General Public License for more details.
16 *12 *
17 * You should have received a copy of the GNU General Public License13 * You should have received a copy of the GNU General Public License
18 * along with BAMF; if not, write to the Free Software14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, 15 *
20 * Boston, MA 02110-1301 USA16 * Authored by: Jason Smith <jason.smith@canonical.com>
17 * Marco Trevisan (Treviño) <3v1n0@ubuntu.com>
18 *
21 */19 */
2220
23#ifndef __BAMF_INDICATOR_SOURCE_H__21#ifndef __BAMF_INDICATOR_SOURCE_H__
@@ -25,6 +23,7 @@
2523
26#include <glib-object.h>24#include <glib-object.h>
27#include "bamf-indicator.h"25#include "bamf-indicator.h"
26#include "bamf-gdbus-indicator-source-generated.h"
2827
29G_BEGIN_DECLS28G_BEGIN_DECLS
3029
@@ -48,13 +47,13 @@
48};47};
4948
50struct _BamfIndicatorSource {49struct _BamfIndicatorSource {
51 GObject parent;50 StatusNotifierApproverSkeleton parent;
52 51
53 BamfIndicatorSourcePrivate *priv;52 BamfIndicatorSourcePrivate *priv;
54};53};
5554
56struct _BamfIndicatorSourceClass {55struct _BamfIndicatorSourceClass {
57 GObjectClass parent_class;56 StatusNotifierApproverSkeletonClass parent_class;
58 57
59 /*< signals >*/58 /*< signals >*/
60 void (*indicator_opened) (BamfIndicatorSource *approver, BamfIndicator *indicator);59 void (*indicator_opened) (BamfIndicatorSource *approver, BamfIndicator *indicator);
@@ -73,13 +72,11 @@
73GList * bamf_indicator_source_get_indicators (BamfIndicatorSource *self);72GList * bamf_indicator_source_get_indicators (BamfIndicatorSource *self);
7473
75gboolean bamf_indicator_source_approve_item (BamfIndicatorSource *self,74gboolean bamf_indicator_source_approve_item (BamfIndicatorSource *self,
76 const char *id,75 const char *id,
77 const char *category,76 const char *category,
78 guint32 pid,77 guint32 pid,
79 const char *address,78 const char *address,
80 const char *proxy,79 const char *proxy);
81 gboolean *approve,
82 GError **error);
83 80
84void bamf_indicator_source_set_behavior (BamfIndicatorSource *self,81void bamf_indicator_source_set_behavior (BamfIndicatorSource *self,
85 gint32 behavior);82 gint32 behavior);
8683
=== modified file 'src/bamf-indicator.c'
--- src/bamf-indicator.c 2011-01-14 15:53:35 +0000
+++ src/bamf-indicator.c 2012-01-19 19:16:25 +0000
@@ -1,30 +1,27 @@
1/*1/*
2 * bamf-indicator.c2 * Copyright (C) 2010-2011 Canonical Ltd
3 * This file is part of BAMF3 *
4 *4 * This program is free software: you can redistribute it and/or modify
5 * Copyright (C) 2010 - Jason Smith5 * it under the terms of the GNU General Public License version 3 as
6 *6 * published by the Free Software Foundation.
7 * BAMF is free software; you can redistribute it and/or modify7 *
8 * it under the terms of the GNU General Public License as published by8 * This program is distributed in the hope that it will be useful,
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * BAMF is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANINDICATORILITY or FITNESS FOR A PARTICULAR PURPOSE. See the10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.11 * GNU General Public License for more details.
16 *12 *
17 * You should have received a copy of the GNU General Public License13 * You should have received a copy of the GNU General Public License
18 * along with BAMF; if not, write to the Free Software14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, 15 *
20 * Boston, MA 02110-1301 USA16 * Authored by: Jason Smith <jason.smith@canonical.com>
17 * Marco Trevisan (Treviño) <3v1n0@ubuntu.com>
18 *
21 */19 */
2220
23#include "bamf-indicator.h"21#include "bamf-indicator.h"
24#include "bamf-indicator-glue.h"22
2523#define BAMF_INDICATOR_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE((object), \
2624 BAMF_TYPE_INDICATOR, BamfIndicatorPrivate))
27#define BAMF_INDICATOR_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE((object), BAMF_TYPE_INDICATOR, BamfIndicatorPrivate))
2825
29enum26enum
30{27{
@@ -39,34 +36,35 @@
3936
40struct _BamfIndicatorPrivate37struct _BamfIndicatorPrivate
41{38{
39 BamfDBusItemIndicator *dbus_iface;
42 char *id;40 char *id;
43 char *path;41 char *path;
44 char *address;42 char *address;
45 guint32 pid;43 guint32 pid;
46 DBusGProxy *proxy;44 GDBusProxy *proxy;
47};45};
4846
49G_DEFINE_TYPE (BamfIndicator, bamf_indicator, BAMF_TYPE_VIEW)47G_DEFINE_TYPE (BamfIndicator, bamf_indicator, BAMF_TYPE_VIEW)
5048
51char *49const char *
52bamf_indicator_get_path (BamfIndicator *self)50bamf_indicator_get_path (BamfIndicator *self)
53{51{
54 g_return_val_if_fail (BAMF_IS_INDICATOR (self), NULL);52 g_return_val_if_fail (BAMF_IS_INDICATOR (self), NULL);
55 return g_strdup (self->priv->path);53 return self->priv->path;
56}54}
5755
58char *56const char *
59bamf_indicator_get_address (BamfIndicator *self)57bamf_indicator_get_address (BamfIndicator *self)
60{58{
61 g_return_val_if_fail (BAMF_IS_INDICATOR (self), NULL);59 g_return_val_if_fail (BAMF_IS_INDICATOR (self), NULL);
62 return g_strdup (self->priv->address);60 return self->priv->address;
63}61}
6462
65char *63const char *
66bamf_indicator_get_id (BamfIndicator *self)64bamf_indicator_get_id (BamfIndicator *self)
67{65{
68 g_return_val_if_fail (BAMF_IS_INDICATOR (self), NULL);66 g_return_val_if_fail (BAMF_IS_INDICATOR (self), NULL);
69 return g_strdup (self->priv->id);67 return self->priv->id;
70}68}
7169
72guint3270guint32
@@ -86,10 +84,10 @@
86 pid == self->priv->pid; 84 pid == self->priv->pid;
87}85}
8886
89static char *87static const char *
90bamf_indicator_get_view_type (BamfView *view)88bamf_indicator_get_view_type (BamfView *view)
91{89{
92 return g_strdup ("indicator");90 return "indicator";
93}91}
9492
95static char *93static char *
@@ -104,7 +102,8 @@
104}102}
105103
106static void104static void
107bamf_indicator_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)105bamf_indicator_set_property (GObject *object, guint property_id,
106 const GValue *value, GParamSpec *pspec)
108{107{
109 BamfIndicator *self;108 BamfIndicator *self;
110109
@@ -129,7 +128,7 @@
129 break;128 break;
130129
131 default:130 default:
132 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);131 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
133 }132 }
134}133}
135134
@@ -159,53 +158,96 @@
159 break;158 break;
160159
161 default:160 default:
162 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);161 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
163 }162 }
164}163}
165164
166static void165static void
167bamf_indicator_on_destroy (DBusGProxy *proxy, BamfIndicator *self)166bamf_indicator_on_destroy (GObject *object, GParamSpec *pspec, BamfIndicator *self)
168{167{
168 g_object_unref (self->priv->proxy);
169 self->priv->proxy = NULL;
170
169 bamf_view_close (BAMF_VIEW (self));171 bamf_view_close (BAMF_VIEW (self));
170}172}
171173
174static gboolean
175on_dbus_handle_path (BamfDBusItemIndicator *interface,
176 GDBusMethodInvocation *invocation,
177 BamfIndicator *self)
178{
179 const char *path = bamf_indicator_get_path (self);
180 g_dbus_method_invocation_return_value (invocation,
181 g_variant_new ("(s)", path ? path : ""));
182
183 return TRUE;
184}
185
186static gboolean
187on_dbus_handle_address (BamfDBusItemIndicator *interface,
188 GDBusMethodInvocation *invocation,
189 BamfIndicator *self)
190{
191 const char *address = bamf_indicator_get_address (self);
192 g_dbus_method_invocation_return_value (invocation,
193 g_variant_new ("(s)", address ? address : ""));
194
195 return TRUE;
196}
197
172static void198static void
173bamf_indicator_constructed (GObject *object)199bamf_indicator_constructed (GObject *object)
174{200{
175 BamfIndicator *self;201 BamfIndicator *self;
176 BamfIndicatorPrivate *priv;202 BamfIndicatorPrivate *priv;
177 DBusGProxy *proxy;203 GDBusProxy *proxy;
178 DBusGConnection *bus;
179 GError *error = NULL;204 GError *error = NULL;
180205
181 if (G_OBJECT_CLASS (bamf_indicator_parent_class)->constructed)206 if (G_OBJECT_CLASS (bamf_indicator_parent_class)->constructed)
182 G_OBJECT_CLASS (bamf_indicator_parent_class)->constructed (object);207 G_OBJECT_CLASS (bamf_indicator_parent_class)->constructed (object);
183 208
184 self = BAMF_INDICATOR (object);209 self = BAMF_INDICATOR (object);
185 priv = self->priv;210 priv = self->priv;
186 211
187 bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error);212 proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
188 213 G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES|
189 if (!bus)214 G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS|
190 {215 G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START,
191 g_warning ("Could not get session bus\n");216 NULL,
192 return;217 priv->address,
193 }218 priv->path,
194 219 "org.ayatana.indicator.application.service",
195 error = NULL;220 NULL,
196 if (!(proxy = dbus_g_proxy_new_for_name_owner (bus, 221 &error);
197 priv->address,222
198 priv->path,223 if (error)
199 "org.ayatana.indicator.application.service",224 {
200 &error)))225 g_debug ("Could not setup proxy: %s %s: %s", priv->address, priv->path,
201 {226 error->message);
202 g_warning ("Could not setup proxy: %s %s\n", priv->address, priv->path);227 g_error_free (error);
203 return;228 }
204 }229 else
205 230 {
206 priv->proxy = proxy;231 gchar *owner = g_dbus_proxy_get_name_owner (proxy);
207 232
208 g_signal_connect (G_OBJECT (proxy), "destroy", (GCallback) bamf_indicator_on_destroy, self);233 if (owner)
234 {
235 g_free (owner);
236
237 g_signal_connect (G_OBJECT (proxy), "notify::g-name-owner",
238 G_CALLBACK (bamf_indicator_on_destroy), self);
239
240 if (priv->proxy)
241 g_object_unref (priv->proxy);
242
243 priv->proxy = proxy;
244 }
245 else
246 {
247 g_debug ("Failed to get notification approver proxy: no owner available");
248 g_object_unref (proxy);
249 }
250 }
209}251}
210252
211static void253static void
@@ -243,17 +285,31 @@
243}285}
244286
245static void287static void
288bamf_indicator_finalize (GObject *object)
289{
290 BamfIndicatorPrivate *priv;
291
292 priv = BAMF_INDICATOR (object)->priv;
293
294 g_object_unref (priv->dbus_iface);
295
296 G_OBJECT_CLASS (bamf_indicator_parent_class)->finalize (object);
297}
298
299static void
246bamf_indicator_class_init (BamfIndicatorClass *klass)300bamf_indicator_class_init (BamfIndicatorClass *klass)
247{301{
248 GParamSpec *pspec;302 GParamSpec *pspec;
249 GObjectClass *object_class = G_OBJECT_CLASS (klass);303 GObjectClass *object_class = G_OBJECT_CLASS (klass);
250 BamfViewClass *view_class = BAMF_VIEW_CLASS (klass);304 BamfViewClass *view_class = BAMF_VIEW_CLASS (klass);
251 305
252 object_class->constructed = bamf_indicator_constructed;306 object_class->constructed = bamf_indicator_constructed;
253 object_class->get_property = bamf_indicator_get_property;307 object_class->get_property = bamf_indicator_get_property;
254 object_class->set_property = bamf_indicator_set_property;308 object_class->set_property = bamf_indicator_set_property;
255 object_class->dispose = bamf_indicator_dispose;309 object_class->dispose = bamf_indicator_dispose;
256 view_class->view_type = bamf_indicator_get_view_type;310 object_class->finalize = bamf_indicator_finalize;
311
312 view_class->view_type = bamf_indicator_get_view_type;
257 view_class->stable_bus_name = bamf_indicator_get_stable_bus_name;313 view_class->stable_bus_name = bamf_indicator_get_stable_bus_name;
258314
259 pspec = g_param_spec_string ("address", "address", "address", NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT);315 pspec = g_param_spec_string ("address", "address", "address", NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
@@ -268,9 +324,6 @@
268 pspec = g_param_spec_uint ("pid", "pid", "pid", 0, G_MAXUINT32, 0, G_PARAM_READWRITE);324 pspec = g_param_spec_uint ("pid", "pid", "pid", 0, G_MAXUINT32, 0, G_PARAM_READWRITE);
269 g_object_class_install_property (object_class, PROP_PID, pspec);325 g_object_class_install_property (object_class, PROP_PID, pspec);
270326
271 dbus_g_object_type_install_info (BAMF_TYPE_INDICATOR,
272 &dbus_glib_bamf_indicator_object_info);
273
274 g_type_class_add_private (object_class, sizeof (BamfIndicatorPrivate));327 g_type_class_add_private (object_class, sizeof (BamfIndicatorPrivate));
275}328}
276329
@@ -278,6 +331,19 @@
278bamf_indicator_init (BamfIndicator *self)331bamf_indicator_init (BamfIndicator *self)
279{332{
280 self->priv = BAMF_INDICATOR_GET_PRIVATE (self);333 self->priv = BAMF_INDICATOR_GET_PRIVATE (self);
334
335 self->priv->dbus_iface = bamf_dbus_item_indicator_skeleton_new ();
336
337 /* Registering signal callbacks to reply to dbus method calls */
338 g_signal_connect (self->priv->dbus_iface, "handle-path",
339 G_CALLBACK (on_dbus_handle_path), self);
340
341 g_signal_connect (self->priv->dbus_iface, "handle-address",
342 G_CALLBACK (on_dbus_handle_address), self);
343
344 /* Setting the interface for the dbus object */
345 bamf_dbus_item_object_skeleton_set_indicator (BAMF_DBUS_ITEM_OBJECT_SKELETON (self),
346 self->priv->dbus_iface);
281}347}
282348
283BamfIndicator *349BamfIndicator *
284350
=== modified file 'src/bamf-indicator.h'
--- src/bamf-indicator.h 2010-07-09 23:22:44 +0000
+++ src/bamf-indicator.h 2012-01-19 19:16:25 +0000
@@ -1,23 +1,21 @@
1/*1/*
2 * bamf-indicator.h2 * Copyright (C) 2010-2011 Canonical Ltd
3 * This file is part of BAMF3 *
4 *4 * This program is free software: you can redistribute it and/or modify
5 * Copyright (C) 2010 - Jason Smith5 * it under the terms of the GNU General Public License version 3 as
6 *6 * published by the Free Software Foundation.
7 * BAMF is free software; you can redistribute it and/or modify7 *
8 * it under the terms of the GNU General Public License as published by8 * This program is distributed in the hope that it will be useful,
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * BAMF is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.11 * GNU General Public License for more details.
16 *12 *
17 * You should have received a copy of the GNU General Public License13 * You should have received a copy of the GNU General Public License
18 * along with BAMF; if not, write to the Free Software14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, 15 *
20 * Boston, MA 02110-1301 USA16 * Authored by: Jason Smith <jason.smith@canonical.com>
17 * Marco Trevisan (Treviño) <3v1n0@ubuntu.com>
18 *
21 */19 */
2220
23#ifndef __BAMF_INDICATOR_H__21#ifndef __BAMF_INDICATOR_H__
@@ -42,7 +40,7 @@
4240
43struct _BamfIndicator {41struct _BamfIndicator {
44 BamfView parent;42 BamfView parent;
45 43
46 BamfIndicatorPrivate *priv;44 BamfIndicatorPrivate *priv;
47};45};
4846
@@ -52,23 +50,23 @@
5250
53GType bamf_indicator_get_type (void) G_GNUC_CONST;51GType bamf_indicator_get_type (void) G_GNUC_CONST;
5452
55char * bamf_indicator_get_id (BamfIndicator *self);53const char * bamf_indicator_get_id (BamfIndicator *self);
5654
57char * bamf_indicator_get_path (BamfIndicator *self);55const char * bamf_indicator_get_path (BamfIndicator *self);
5856
59char * bamf_indicator_get_address (BamfIndicator *self);57const char * bamf_indicator_get_address (BamfIndicator *self);
6058
61guint32 bamf_indicator_get_pid (BamfIndicator *self);59guint32 bamf_indicator_get_pid (BamfIndicator *self);
6260
63gboolean bamf_indicator_matches_signature (BamfIndicator *self, 61gboolean bamf_indicator_matches_signature (BamfIndicator *self,
64 gint pid, 62 gint pid,
65 const char *address, 63 const char *address,
66 const char *path);64 const char *path);
6765
68BamfIndicator *bamf_indicator_new (const char *id,66BamfIndicator * bamf_indicator_new (const char *id,
69 const char *proxy, 67 const char *proxy,
70 const char *address, 68 const char *address,
71 guint32 pid);69 guint32 pid);
7270
73G_END_DECLS71G_END_DECLS
7472
7573
=== modified file 'src/bamf-marshal.list'
--- src/bamf-marshal.list 2010-08-18 23:22:58 +0000
+++ src/bamf-marshal.list 2012-01-19 19:16:25 +0000
@@ -1,9 +1,10 @@
1# Marshaller definitions to be generated.1# Marshaller definitions to be generated.
2# 2#
3# Copyright 2010 Canonical Ltd.3# Copyright 2010-2011 Canonical Ltd.
4# 4#
5# Authors:5# Authors:
6# Jason Smith <jason.smith@canonical.com>6# Jason Smith <jason.smith@canonical.com>
7# Marco Trevisan (Treviño) <3v1n0@ubuntu.com>
7# 8#
8# This program is free software: you can redistribute it and/or modify it 9# This program is free software: you can redistribute it and/or modify it
9# under the terms of the GNU General Public License version 3, as published 10# under the terms of the GNU General Public License version 3, as published
@@ -17,8 +18,4 @@
17# You should have received a copy of the GNU General Public License along 18# You should have received a copy of the GNU General Public License along
18# with this program. If not, see <http://www.gnu.org/licenses/>.19# with this program. If not, see <http://www.gnu.org/licenses/>.
1920
20VOID: BOOL, STRING, STRING
21VOID: STRING, STRING
22VOID: STRING, STRING, STRING21VOID: STRING, STRING, STRING
23VOID: OBJECT, OBJECT
24VOID: STRING, INT, STRING, STRING, STRING
2522
=== removed file 'src/bamf-matcher-glue.xml'
--- src/bamf-matcher-glue.xml 2010-09-08 23:38:35 +0000
+++ src/bamf-matcher-glue.xml 1970-01-01 00:00:00 +0000
@@ -1,108 +0,0 @@
1<?xml version="1.0" encoding="UTF-8" ?>
2
3<node name="/org/ayatana/bamf">
4
5 <interface name="org.ayatana.bamf.matcher">
6
7 <signal name="ViewOpened">
8 <arg type="s" name="path" direction="out" />
9 <arg type="s" name="type" direction="out" />
10 </signal>
11
12 <signal name="ViewClosed">
13 <arg type="s" name="path" direction="out" />
14 <arg type="s" name="type" direction="out" />
15 </signal>
16
17 <signal name="ActiveWindowChanged">
18 <arg type="s" name="old" direction="out" />
19 <arg type="s" name="new" direction="out" />
20 </signal>
21
22 <signal name="ActiveApplicationChanged">
23 <arg type="s" name="old" direction="out" />
24 <arg type="s" name="new" direction="out" />
25 </signal>
26
27 <method name="ActiveApplication">
28 <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_matcher_get_active_application" />
29 <arg type="s" name="application" direction="out">
30 <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/>
31 </arg>
32 </method>
33
34 <method name="ActiveWindow">
35 <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_matcher_get_active_window" />
36 <arg type="s" name="window" direction="out">
37 <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/>
38 </arg>
39 </method>
40
41 <method name="ApplicationForXid">
42 <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_matcher_application_for_xid" />
43 <arg type="u" name="xid" direction="in" />
44 <arg type="s" name="application" direction="out">
45 <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/>
46 </arg>
47 </method>
48
49 <method name="ApplicationIsRunning">
50 <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_matcher_application_is_running" />
51 <arg type="s" name="application" direction="in" />
52 <arg type="b" name="running" direction="out">
53 <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/>
54 </arg>
55 </method>
56
57 <method name="ApplicationPaths">
58 <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_matcher_application_dbus_paths" />
59 <arg type="as" name="paths" direction="out">
60 <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/>
61 </arg>
62 </method>
63
64 <method name="WindowPaths">
65 <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_matcher_window_dbus_paths" />
66 <arg type="as" name="paths" direction="out">
67 <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/>
68 </arg>
69 </method>
70
71 <method name="PathForApplication">
72 <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_matcher_dbus_path_for_application" />
73 <arg type="s" name="applicaiton" direction="in" />
74 <arg type="s" name="path" direction="out">
75 <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/>
76 </arg>
77 </method>
78
79 <method name="RegisterFavorites">
80 <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_matcher_register_favorites" />
81 <arg type="as" name="favorites" direction="in" />
82 </method>
83
84 <method name="RunningApplications">
85 <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_matcher_running_application_paths" />
86 <arg type="as" name="paths" direction="out">
87 <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/>
88 </arg>
89 </method>
90
91 <method name="TabPaths">
92 <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_matcher_tab_dbus_paths" />
93 <arg type="as" name="paths" direction="out">
94 <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/>
95 </arg>
96 </method>
97
98 <method name="XidsForApplication">
99 <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_matcher_xids_for_application" />
100 <arg type="s" name="application" direction="in" />
101 <arg type="au" name="xids" direction="out">
102 <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/>
103 </arg>
104 </method>
105
106 </interface>
107
108</node>
1090
=== modified file 'src/bamf-matcher.c'
--- src/bamf-matcher.c 2011-12-15 11:30:52 +0000
+++ src/bamf-matcher.c 2012-01-19 19:16:25 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright (C) 2010 Canonical Ltd2 * Copyright (C) 2010-2011 Canonical Ltd
3 *3 *
4 * This program is free software: you can redistribute it and/or modify4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as5 * it under the terms of the GNU General Public License version 3 as
@@ -22,9 +22,7 @@
2222
23#include <gdk/gdkx.h>23#include <gdk/gdkx.h>
2424
25#include "bamf-marshal.h"
26#include "bamf-matcher.h"25#include "bamf-matcher.h"
27#include "bamf-matcher-glue.h"
28#include "bamf-application.h"26#include "bamf-application.h"
29#include "bamf-window.h"27#include "bamf-window.h"
30#include "bamf-legacy-window.h"28#include "bamf-legacy-window.h"
@@ -32,16 +30,12 @@
32#include "bamf-legacy-screen.h"30#include "bamf-legacy-screen.h"
33#include "bamf-indicator-source.h"31#include "bamf-indicator-source.h"
3432
35G_DEFINE_TYPE (BamfMatcher, bamf_matcher, G_TYPE_OBJECT);33G_DEFINE_TYPE (BamfMatcher, bamf_matcher, BAMF_DBUS_TYPE_MATCHER_SKELETON);
36#define BAMF_MATCHER_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE(obj, \34#define BAMF_MATCHER_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE(obj, \
37BAMF_TYPE_MATCHER, BamfMatcherPrivate))35 BAMF_TYPE_MATCHER, BamfMatcherPrivate))
3836
39enum37enum
40{38{
41 VIEW_OPENED,
42 VIEW_CLOSED,
43 ACTIVE_APPLICATION_CHANGED,
44 ACTIVE_WINDOW_CHANGED,
45 FAVORITES_CHANGED,39 FAVORITES_CHANGED,
4640
47 LAST_SIGNAL,41 LAST_SIGNAL,
@@ -49,16 +43,6 @@
4943
50static guint matcher_signals[LAST_SIGNAL] = { 0 };44static guint matcher_signals[LAST_SIGNAL] = { 0 };
5145
52typedef struct _OpenOfficeTimeoutArgs OpenOfficeTimeoutArgs;
53
54struct _OpenOfficeTimeoutArgs
55{
56 BamfMatcher *matcher;
57 BamfLegacyWindow *window;
58 int count;
59};
60
61
62struct _BamfMatcherPrivate46struct _BamfMatcherPrivate
63{47{
64 GArray * bad_prefixes;48 GArray * bad_prefixes;
@@ -103,11 +87,9 @@
103 else87 else
104 priv->active_app = NULL;88 priv->active_app = NULL;
10589
106 g_signal_emit (matcher,90 g_signal_emit_by_name (matcher, "active-application-changed",
107 matcher_signals[ACTIVE_APPLICATION_CHANGED],91 BAMF_IS_VIEW (last) ? bamf_view_get_path (BAMF_VIEW (last)) : "",
108 0,92 BAMF_IS_VIEW (priv->active_app) ? bamf_view_get_path (BAMF_VIEW (priv->active_app)) : "");
109 BAMF_IS_VIEW (last) ? bamf_view_get_path (BAMF_VIEW (last)) : NULL,
110 BAMF_IS_VIEW (priv->active_app) ? bamf_view_get_path (BAMF_VIEW (priv->active_app)) : NULL);
111 }93 }
112 else if (BAMF_IS_WINDOW (view))94 else if (BAMF_IS_WINDOW (view))
113 {95 {
@@ -127,11 +109,10 @@
127 else109 else
128 priv->active_win = NULL;110 priv->active_win = NULL;
129111
130 g_signal_emit (matcher,112
131 matcher_signals[ACTIVE_WINDOW_CHANGED],113 g_signal_emit_by_name (matcher, "active-window-changed",
132 0,114 BAMF_IS_VIEW (last) ? bamf_view_get_path (BAMF_VIEW (last)) : "",
133 BAMF_IS_VIEW (last) ? bamf_view_get_path (BAMF_VIEW (last)) : NULL,115 BAMF_IS_VIEW (priv->active_win) ? bamf_view_get_path (BAMF_VIEW (priv->active_win)) : "");
134 BAMF_IS_VIEW (priv->active_win) ? bamf_view_get_path (BAMF_VIEW (priv->active_win)) : NULL);
135 }116 }
136}117}
137118
@@ -146,9 +127,12 @@
146static void127static void
147bamf_matcher_register_view (BamfMatcher *self, BamfView *view)128bamf_matcher_register_view (BamfMatcher *self, BamfView *view)
148{129{
149 char * path, * type;130 const char *path, *type;
131 GDBusConnection *connection;
132 GDBusInterfaceSkeleton *dbus_interface = G_DBUS_INTERFACE_SKELETON (self);
150133
151 path = bamf_view_export_on_bus (view);134 connection = g_dbus_interface_skeleton_get_connection (dbus_interface);
135 path = bamf_view_export_on_bus (view, connection);
152 type = bamf_view_get_view_type (view);136 type = bamf_view_get_view_type (view);
153137
154 g_signal_connect (G_OBJECT (view), "closed-internal",138 g_signal_connect (G_OBJECT (view), "closed-internal",
@@ -159,8 +143,7 @@
159 self->priv->views = g_list_prepend (self->priv->views, view);143 self->priv->views = g_list_prepend (self->priv->views, view);
160 g_object_ref (view);144 g_object_ref (view);
161145
162 g_signal_emit (self, matcher_signals[VIEW_OPENED],0, path, type);146 g_signal_emit_by_name (self, "view-opened", path, type);
163 g_free (type);
164 147
165 // trigger manually since this is already active148 // trigger manually since this is already active
166 if (bamf_view_is_active (view))149 if (bamf_view_is_active (view))
@@ -171,12 +154,12 @@
171bamf_matcher_unregister_view (BamfMatcher *self, BamfView *view, gboolean unref)154bamf_matcher_unregister_view (BamfMatcher *self, BamfView *view, gboolean unref)
172{155{
173 const char * path;156 const char * path;
174 char * type;157 const char * type;
175158
176 path = bamf_view_get_path (view);159 path = bamf_view_get_path (view);
177 type = bamf_view_get_view_type (view);160 type = bamf_view_get_view_type (view);
178161
179 g_signal_emit (self, matcher_signals[VIEW_CLOSED],0, path, type);162 g_signal_emit_by_name (self, "view-closed", path, type);
180163
181 g_signal_handlers_disconnect_by_func (G_OBJECT (view), on_view_closed, self);164 g_signal_handlers_disconnect_by_func (G_OBJECT (view), on_view_closed, self);
182 g_signal_handlers_disconnect_by_func (G_OBJECT (view), on_view_active_changed, self);165 g_signal_handlers_disconnect_by_func (G_OBJECT (view), on_view_active_changed, self);
@@ -186,8 +169,6 @@
186 self->priv->views = g_list_remove (self->priv->views, view);169 self->priv->views = g_list_remove (self->priv->views, view);
187 g_object_unref (view);170 g_object_unref (view);
188 }171 }
189
190 g_free (type);
191}172}
192173
193static char *174static char *
@@ -317,7 +298,8 @@
317 gboolean regexFail;298 gboolean regexFail;
318 GRegex *regex;299 GRegex *regex;
319300
320 g_return_val_if_fail ((execString && execString[0] != '\0'), g_strdup (execString));301 if (!execString || (execString && execString[0] == '\0'))
302 return NULL;
321303
322 exec = g_utf8_casefold (execString, -1);304 exec = g_utf8_casefold (execString, -1);
323 parts = g_strsplit (exec, " ", 0);305 parts = g_strsplit (exec, " ", 0);
@@ -983,7 +965,7 @@
983 path = g_file_get_path (file);965 path = g_file_get_path (file);
984 filetype = g_file_query_file_type (file, G_FILE_QUERY_INFO_NONE, NULL);966 filetype = g_file_query_file_type (file, G_FILE_QUERY_INFO_NONE, NULL);
985 monitored_dir = g_object_get_data (G_OBJECT (monitor), "root");967 monitored_dir = g_object_get_data (G_OBJECT (monitor), "root");
986 968
987 if (!g_str_has_suffix (path, ".desktop") &&969 if (!g_str_has_suffix (path, ".desktop") &&
988 filetype != G_FILE_TYPE_DIRECTORY &&970 filetype != G_FILE_TYPE_DIRECTORY &&
989 type != G_FILE_MONITOR_EVENT_DELETED)971 type != G_FILE_MONITOR_EVENT_DELETED)
@@ -1367,7 +1349,7 @@
1367 g_free (exec_string);1349 g_free (exec_string);
1368 }1350 }
13691351
1370 if (g_list_length (result) > 0)1352 if (result)
1371 {1353 {
1372 result = g_list_reverse (result);1354 result = g_list_reverse (result);
1373 return result;1355 return result;
@@ -1885,7 +1867,7 @@
18851867
1886void1868void
1887bamf_matcher_load_desktop_file (BamfMatcher * self,1869bamf_matcher_load_desktop_file (BamfMatcher * self,
1888 char * desktop_file)1870 const char * desktop_file)
1889{1871{
1890 g_return_if_fail (BAMF_IS_MATCHER (self));1872 g_return_if_fail (BAMF_IS_MATCHER (self));
18911873
@@ -1937,7 +1919,7 @@
1937 return 0;1919 return 0;
1938}1920}
19391921
1940char *1922const char *
1941bamf_matcher_get_active_application (BamfMatcher *matcher)1923bamf_matcher_get_active_application (BamfMatcher *matcher)
1942{1924{
1943 GList *l;1925 GList *l;
@@ -1957,14 +1939,14 @@
19571939
1958 if (bamf_view_is_active (view))1940 if (bamf_view_is_active (view))
1959 {1941 {
1960 return g_strdup (bamf_view_get_path (view));1942 return bamf_view_get_path (view);
1961 }1943 }
1962 }1944 }
19631945
1964 return NULL;1946 return "";
1965}1947}
19661948
1967char *1949const char *
1968bamf_matcher_get_active_window (BamfMatcher *matcher)1950bamf_matcher_get_active_window (BamfMatcher *matcher)
1969{1951{
1970 GList *l;1952 GList *l;
@@ -1984,14 +1966,14 @@
19841966
1985 if (bamf_view_is_active (view))1967 if (bamf_view_is_active (view))
1986 {1968 {
1987 return g_strdup (bamf_view_get_path (view));1969 return bamf_view_get_path (view);
1988 }1970 }
1989 }1971 }
19901972
1991 return NULL;1973 return "";
1992}1974}
19931975
1994char *1976const char *
1995bamf_matcher_application_for_xid (BamfMatcher *matcher,1977bamf_matcher_application_for_xid (BamfMatcher *matcher,
1996 guint32 xid)1978 guint32 xid)
1997{1979{
@@ -2012,16 +1994,16 @@
20121994
2013 if (bamf_application_manages_xid (BAMF_APPLICATION (view), xid))1995 if (bamf_application_manages_xid (BAMF_APPLICATION (view), xid))
2014 {1996 {
2015 return g_strdup (bamf_view_get_path (view));1997 return bamf_view_get_path (view);
2016 }1998 }
2017 }1999 }
20182000
2019 return NULL;2001 return "";
2020}2002}
20212003
2022gboolean2004gboolean
2023bamf_matcher_application_is_running (BamfMatcher *matcher,2005bamf_matcher_application_is_running (BamfMatcher *matcher,
2024 char *application)2006 const char *application)
2025{2007{
2026 char * desktop_file;2008 char * desktop_file;
2027 GList *l;2009 GList *l;
@@ -2051,22 +2033,21 @@
2051 return FALSE;2033 return FALSE;
2052}2034}
20532035
2054char **2036GVariant *
2055bamf_matcher_window_dbus_paths (BamfMatcher *matcher)2037bamf_matcher_window_dbus_paths (BamfMatcher *matcher)
2056{2038{
2057 char ** paths;
2058 int i;
2059 GList *l;2039 GList *l;
2060 BamfView *view;2040 BamfView *view;
2061 BamfMatcherPrivate *priv;2041 BamfMatcherPrivate *priv;
2042 GVariantBuilder b;
20622043
2063 g_return_val_if_fail (BAMF_IS_MATCHER (matcher), NULL);2044 g_return_val_if_fail (BAMF_IS_MATCHER (matcher), NULL);
20642045
2046 g_variant_builder_init (&b, G_VARIANT_TYPE ("(as)"));
2047 g_variant_builder_open (&b, G_VARIANT_TYPE ("as"));
2048
2065 priv = matcher->priv;2049 priv = matcher->priv;
20662050
2067 paths = g_malloc0 (sizeof (char *) * (g_list_length (priv->views) + 1));
2068
2069 i = 0;
2070 for (l = priv->views; l; l = l->next)2051 for (l = priv->views; l; l = l->next)
2071 {2052 {
2072 view = l->data;2053 view = l->data;
@@ -2074,29 +2055,29 @@
2074 if (!BAMF_IS_WINDOW (view))2055 if (!BAMF_IS_WINDOW (view))
2075 continue;2056 continue;
20762057
2077 paths[i] = g_strdup (bamf_view_get_path (view));2058 g_variant_builder_add (&b, "s", bamf_view_get_path (view));
2078 i++;
2079 }2059 }
20802060
2081 return paths;2061 g_variant_builder_close (&b);
2062
2063 return g_variant_builder_end (&b);
2082}2064}
20832065
2084char **2066GVariant *
2085bamf_matcher_application_dbus_paths (BamfMatcher *matcher)2067bamf_matcher_application_dbus_paths (BamfMatcher *matcher)
2086{2068{
2087 char ** paths;
2088 int i;
2089 GList *l;2069 GList *l;
2090 BamfView *view;2070 BamfView *view;
2091 BamfMatcherPrivate *priv;2071 BamfMatcherPrivate *priv;
2072 GVariantBuilder b;
20922073
2093 g_return_val_if_fail (BAMF_IS_MATCHER (matcher), NULL);2074 g_return_val_if_fail (BAMF_IS_MATCHER (matcher), NULL);
20942075
2076 g_variant_builder_init (&b, G_VARIANT_TYPE ("(as)"));
2077 g_variant_builder_open (&b, G_VARIANT_TYPE ("as"));
2078
2095 priv = matcher->priv;2079 priv = matcher->priv;
20962080
2097 paths = g_malloc0 (sizeof (char *) * (g_list_length (priv->views) + 1));
2098
2099 i = 0;
2100 for (l = priv->views; l; l = l->next)2081 for (l = priv->views; l; l = l->next)
2101 {2082 {
2102 view = l->data;2083 view = l->data;
@@ -2104,18 +2085,19 @@
2104 if (!BAMF_IS_APPLICATION (view))2085 if (!BAMF_IS_APPLICATION (view))
2105 continue;2086 continue;
21062087
2107 paths[i] = g_strdup (bamf_view_get_path (view));2088 g_variant_builder_add (&b, "s", bamf_view_get_path (view));
2108 i++;
2109 }2089 }
21102090
2111 return paths;2091 g_variant_builder_close (&b);
2092
2093 return g_variant_builder_end (&b);
2112}2094}
21132095
2114char *2096const char *
2115bamf_matcher_dbus_path_for_application (BamfMatcher *matcher,2097bamf_matcher_dbus_path_for_application (BamfMatcher *matcher,
2116 char *application)2098 const char *application)
2117{2099{
2118 char * path = NULL;2100 const char * path = "";
2119 char * desktop_file;2101 char * desktop_file;
2120 GList *l;2102 GList *l;
2121 BamfView *view;2103 BamfView *view;
@@ -2135,7 +2117,7 @@
2135 desktop_file = bamf_application_get_desktop_file (BAMF_APPLICATION (view));2117 desktop_file = bamf_application_get_desktop_file (BAMF_APPLICATION (view));
2136 if (g_strcmp0 (desktop_file, application) == 0)2118 if (g_strcmp0 (desktop_file, application) == 0)
2137 {2119 {
2138 path = g_strdup (bamf_view_get_path (view));2120 path = bamf_view_get_path (view);
2139 }2121 }
2140 g_free (desktop_file);2122 g_free (desktop_file);
2141 }2123 }
@@ -2151,18 +2133,16 @@
2151 return matcher->priv->favorites;2133 return matcher->priv->favorites;
2152}2134}
21532135
2154gboolean2136void
2155bamf_matcher_register_favorites (BamfMatcher *matcher,2137bamf_matcher_register_favorites (BamfMatcher *matcher,
2156 char **favorites,2138 const char **favorites)
2157 GError *error)
2158{2139{
2159 char *fav;2140 const char *fav;
2160 char **favs;2141 const char **favs;
2161 BamfMatcherPrivate *priv;2142 BamfMatcherPrivate *priv;
2162 2143
2163 g_return_val_if_fail (BAMF_IS_MATCHER (matcher), TRUE);2144 g_return_if_fail (BAMF_IS_MATCHER (matcher));
2164 g_return_val_if_fail (favorites, TRUE);2145 g_return_if_fail (favorites);
2165
2166 priv = matcher->priv;2146 priv = matcher->priv;
2167 2147
2168 for (favs = favorites; *favs; favs++)2148 for (favs = favorites; *favs; favs++)
@@ -2171,33 +2151,29 @@
2171 /* ignore things already in the list */2151 /* ignore things already in the list */
2172 if (g_list_find_custom (priv->favorites, fav, (GCompareFunc) g_strcmp0))2152 if (g_list_find_custom (priv->favorites, fav, (GCompareFunc) g_strcmp0))
2173 continue;2153 continue;
2174 2154
2175
2176 priv->favorites = g_list_prepend (priv->favorites, g_strdup (fav));2155 priv->favorites = g_list_prepend (priv->favorites, g_strdup (fav));
2177 bamf_matcher_load_desktop_file (matcher, fav);2156 bamf_matcher_load_desktop_file (matcher, fav);
2178 }2157 }
2179 2158
2180 g_signal_emit (matcher, matcher_signals[FAVORITES_CHANGED], 0);2159 g_signal_emit (matcher, matcher_signals[FAVORITES_CHANGED], 0);
2181
2182 return TRUE;
2183}2160}
21842161
2185char **2162GVariant *
2186bamf_matcher_running_application_paths (BamfMatcher *matcher)2163bamf_matcher_running_application_paths (BamfMatcher *matcher)
2187{2164{
2188 char ** paths;
2189 int i;
2190 GList *l;2165 GList *l;
2191 BamfView *view;2166 BamfView *view;
2192 BamfMatcherPrivate *priv;2167 BamfMatcherPrivate *priv;
2168 GVariantBuilder b;
21932169
2194 g_return_val_if_fail (BAMF_IS_MATCHER (matcher), NULL);2170 g_return_val_if_fail (BAMF_IS_MATCHER (matcher), NULL);
21952171
2172 g_variant_builder_init (&b, G_VARIANT_TYPE ("(as)"));
2173 g_variant_builder_open (&b, G_VARIANT_TYPE ("as"));
2174
2196 priv = matcher->priv;2175 priv = matcher->priv;
21972176
2198 paths = g_malloc0 (sizeof (char *) * (g_list_length (priv->views) + 1));
2199
2200 i = 0;
2201 for (l = priv->views; l; l = l->next)2177 for (l = priv->views; l; l = l->next)
2202 {2178 {
2203 view = l->data;2179 view = l->data;
@@ -2205,24 +2181,31 @@
2205 if (!BAMF_IS_APPLICATION (view) || !bamf_view_is_running (view))2181 if (!BAMF_IS_APPLICATION (view) || !bamf_view_is_running (view))
2206 continue;2182 continue;
22072183
2208 paths[i] = g_strdup (bamf_view_get_path (view));2184 g_variant_builder_add (&b, "s", bamf_view_get_path (view));
2209 i++;
2210 }2185 }
22112186
2212 return paths;2187 g_variant_builder_close (&b);
2188
2189 return g_variant_builder_end (&b);
2213}2190}
22142191
2215char **2192GVariant *
2216bamf_matcher_tab_dbus_paths (BamfMatcher *matcher)2193bamf_matcher_tab_dbus_paths (BamfMatcher *matcher)
2217{2194{
2218 return NULL;2195 GVariantBuilder b;
2196
2197 g_variant_builder_init (&b, G_VARIANT_TYPE ("(as)"));
2198 g_variant_builder_open (&b, G_VARIANT_TYPE ("as"));
2199 g_variant_builder_close (&b);
2200 return g_variant_builder_end (&b);
2219}2201}
22202202
2221GArray *2203GVariant *
2222bamf_matcher_xids_for_application (BamfMatcher *matcher,2204bamf_matcher_xids_for_application (BamfMatcher *matcher,
2223 char *application)2205 const char *application)
2224{2206{
2225 GArray * xids = NULL;2207 GVariantBuilder b;
2208 GVariant *xids;
2226 char * desktop_file;2209 char * desktop_file;
2227 GList *l;2210 GList *l;
2228 BamfView *view;2211 BamfView *view;
@@ -2231,6 +2214,7 @@
2231 g_return_val_if_fail (BAMF_IS_MATCHER (matcher), NULL);2214 g_return_val_if_fail (BAMF_IS_MATCHER (matcher), NULL);
22322215
2233 priv = matcher->priv;2216 priv = matcher->priv;
2217 xids = NULL;
22342218
2235 for (l = priv->views; l; l = l->next)2219 for (l = priv->views; l; l = l->next)
2236 {2220 {
@@ -2249,19 +2233,159 @@
2249 g_free (desktop_file);2233 g_free (desktop_file);
2250 }2234 }
22512235
2236 if (!xids)
2237 {
2238 g_variant_builder_init (&b, G_VARIANT_TYPE ("(au)"));
2239 g_variant_builder_open (&b, G_VARIANT_TYPE ("au"));
2240 g_variant_builder_close (&b);
2241 xids = g_variant_builder_end (&b);
2242 }
2243
2252 return xids;2244 return xids;
2253}2245}
22542246
2247static gboolean
2248on_dbus_handle_xids_for_application (BamfDBusMatcher *interface,
2249 GDBusMethodInvocation *invocation,
2250 const gchar *application,
2251 BamfMatcher *self)
2252{
2253 GVariant *xids = bamf_matcher_xids_for_application (self, application);
2254 g_dbus_method_invocation_return_value (invocation, xids);
2255
2256 return TRUE;
2257}
2258
2259static gboolean
2260on_dbus_handle_tab_paths (BamfDBusMatcher *interface,
2261 GDBusMethodInvocation *invocation,
2262 BamfMatcher *self)
2263{
2264 GVariant *tab_paths = bamf_matcher_tab_dbus_paths (self);
2265 g_dbus_method_invocation_return_value (invocation, tab_paths);
2266
2267 return TRUE;
2268}
2269
2270static gboolean
2271on_dbus_handle_application_paths (BamfDBusMatcher *interface,
2272 GDBusMethodInvocation *invocation,
2273 BamfMatcher *self)
2274{
2275 GVariant *app_paths = bamf_matcher_application_dbus_paths (self);
2276 g_dbus_method_invocation_return_value (invocation, app_paths);
2277
2278 return TRUE;
2279}
2280
2281
2282static gboolean
2283on_dbus_handle_window_paths (BamfDBusMatcher *interface,
2284 GDBusMethodInvocation *invocation,
2285 BamfMatcher *self)
2286{
2287 GVariant *win_paths = bamf_matcher_window_dbus_paths (self);
2288 g_dbus_method_invocation_return_value (invocation, win_paths);
2289
2290 return TRUE;
2291}
2292
2293static gboolean
2294on_dbus_handle_running_applications (BamfDBusMatcher *interface,
2295 GDBusMethodInvocation *invocation,
2296 BamfMatcher *self)
2297{
2298 GVariant *running_apps = bamf_matcher_running_application_paths (self);
2299 g_dbus_method_invocation_return_value (invocation, running_apps);
2300
2301 return TRUE;
2302}
2303
2304static gboolean
2305on_dbus_handle_active_application (BamfDBusMatcher *interface,
2306 GDBusMethodInvocation *invocation,
2307 BamfMatcher *self)
2308{
2309 const gchar *active_app = bamf_matcher_get_active_application (self);
2310
2311 g_dbus_method_invocation_return_value (invocation,
2312 g_variant_new ("(s)", active_app));
2313 return TRUE;
2314}
2315
2316static gboolean
2317on_dbus_handle_active_window (BamfDBusMatcher *interface,
2318 GDBusMethodInvocation *invocation,
2319 BamfMatcher *self)
2320{
2321 const gchar *active_win = bamf_matcher_get_active_window (self);
2322
2323 g_dbus_method_invocation_return_value (invocation,
2324 g_variant_new ("(s)", active_win));
2325 return TRUE;
2326}
2327
2328static gboolean
2329on_dbus_handle_application_is_running (BamfDBusMatcher *interface,
2330 GDBusMethodInvocation *invocation,
2331 const gchar *application,
2332 BamfMatcher *self)
2333{
2334 gboolean is_running = bamf_matcher_application_is_running (self, application);
2335
2336 g_dbus_method_invocation_return_value (invocation,
2337 g_variant_new ("(b)", is_running));
2338 return TRUE;
2339}
2340
2341static gboolean
2342on_dbus_handle_register_favorites (BamfDBusMatcher *interface,
2343 GDBusMethodInvocation *invocation,
2344 const char **favorites,
2345 BamfMatcher *self)
2346{
2347 bamf_matcher_register_favorites (self, favorites);
2348 g_dbus_method_invocation_return_value (invocation, NULL);
2349
2350 return TRUE;
2351}
2352
2353static gboolean
2354on_dbus_handle_path_for_application (BamfDBusMatcher *interface,
2355 GDBusMethodInvocation *invocation,
2356 const gchar *application,
2357 BamfMatcher *self)
2358{
2359 const gchar *app_path = bamf_matcher_dbus_path_for_application (self, application);
2360
2361 g_dbus_method_invocation_return_value (invocation,
2362 g_variant_new ("(s)", app_path));
2363
2364 return TRUE;
2365}
2366
2367static gboolean
2368on_dbus_handle_application_for_xid (BamfDBusMatcher *interface,
2369 GDBusMethodInvocation *invocation,
2370 guint xid,
2371 BamfMatcher *self)
2372{
2373 const gchar *app_path = bamf_matcher_application_for_xid (self, xid);
2374
2375 g_dbus_method_invocation_return_value (invocation,
2376 g_variant_new ("(s)", app_path));
2377
2378 return TRUE;
2379}
2380
2255static void2381static void
2256bamf_matcher_init (BamfMatcher * self)2382bamf_matcher_init (BamfMatcher * self)
2257{2383{
2384 BamfMatcherPrivate *priv;
2385 BamfLegacyScreen *screen;
2386 BamfIndicatorSource *approver;
2258 GArray *prefixstrings;2387 GArray *prefixstrings;
2259 int i;2388 int i;
2260 DBusGConnection *bus;
2261 GError *error = NULL;
2262 BamfMatcherPrivate *priv;
2263 BamfLegacyScreen *screen;
2264 BamfIndicatorSource *approver;
22652389
2266 priv = self->priv = BAMF_MATCHER_GET_PRIVATE (self);2390 priv = self->priv = BAMF_MATCHER_GET_PRIVATE (self);
22672391
@@ -2294,11 +2418,56 @@
22942418
2295 XSetErrorHandler (x_error_handler);2419 XSetErrorHandler (x_error_handler);
22962420
2297 bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error);2421 /* Registering signal callbacks to reply to dbus method calls */
22982422 g_signal_connect (self, "handle-xids-for-application",
2299 g_return_if_fail (bus);2423 G_CALLBACK (on_dbus_handle_xids_for_application), self);
23002424
2301 dbus_g_connection_register_g_object (bus, BAMF_MATCHER_PATH, G_OBJECT (self));2425 g_signal_connect (self, "handle-tab-paths",
2426 G_CALLBACK (on_dbus_handle_tab_paths), self);
2427
2428 g_signal_connect (self, "handle-application-paths",
2429 G_CALLBACK (on_dbus_handle_application_paths), self);
2430
2431 g_signal_connect (self, "handle-window-paths",
2432 G_CALLBACK (on_dbus_handle_window_paths), self);
2433
2434 g_signal_connect (self, "handle-running-applications",
2435 G_CALLBACK (on_dbus_handle_running_applications), self);
2436
2437 g_signal_connect (self, "handle-active-window",
2438 G_CALLBACK (on_dbus_handle_active_window), self);
2439
2440 g_signal_connect (self, "handle-active-application",
2441 G_CALLBACK (on_dbus_handle_active_application), self);
2442
2443 g_signal_connect (self, "handle-application-is-running",
2444 G_CALLBACK (on_dbus_handle_application_is_running), self);
2445
2446 g_signal_connect (self, "handle-register-favorites",
2447 G_CALLBACK (on_dbus_handle_register_favorites), self);
2448
2449 g_signal_connect (self, "handle-path-for-application",
2450 G_CALLBACK (on_dbus_handle_path_for_application), self);
2451
2452 g_signal_connect (self, "handle-application-for-xid",
2453 G_CALLBACK (on_dbus_handle_application_for_xid), self);
2454}
2455
2456static void
2457bamf_matcher_dispose (GObject *object)
2458{
2459 BamfMatcher *self = (BamfMatcher *) object;
2460 BamfMatcherPrivate *priv = self->priv;
2461 GList *l;
2462
2463 for (l = priv->views; l; l = l->next)
2464 {
2465 bamf_matcher_unregister_view (self, (BamfView*)l->data, FALSE);
2466 }
2467 g_list_free_full (priv->views, g_object_unref);
2468 priv->views = NULL;
2469
2470 G_OBJECT_CLASS (bamf_matcher_parent_class)->dispose (object);
2302}2471}
23032472
2304static void2473static void
@@ -2322,12 +2491,7 @@
2322 g_hash_table_destroy (priv->desktop_class_table);2491 g_hash_table_destroy (priv->desktop_class_table);
2323 g_hash_table_destroy (priv->registered_pids);2492 g_hash_table_destroy (priv->registered_pids);
23242493
2325 for (l = priv->views; l; l = l->next)
2326 {
2327 bamf_matcher_unregister_view (self, (BamfView*)l->data, FALSE);
2328 }
2329 g_list_free_full (priv->views, g_object_unref);2494 g_list_free_full (priv->views, g_object_unref);
2330 priv->views = NULL;
23312495
2332 for (l = priv->monitors; l; l = l->next)2496 for (l = priv->monitors; l; l = l->next)
2333 {2497 {
@@ -2350,49 +2514,11 @@
2350bamf_matcher_class_init (BamfMatcherClass * klass)2514bamf_matcher_class_init (BamfMatcherClass * klass)
2351{2515{
2352 GObjectClass *object_class = G_OBJECT_CLASS (klass);2516 GObjectClass *object_class = G_OBJECT_CLASS (klass);
2517
2353 g_type_class_add_private (klass, sizeof (BamfMatcherPrivate));2518 g_type_class_add_private (klass, sizeof (BamfMatcherPrivate));
23542519 object_class->dispose = bamf_matcher_dispose;
2355 dbus_g_object_type_install_info (BAMF_TYPE_MATCHER,
2356 &dbus_glib_bamf_matcher_object_info);
2357
2358 object_class->finalize = bamf_matcher_finalize;2520 object_class->finalize = bamf_matcher_finalize;
23592521
2360 matcher_signals [VIEW_OPENED] =
2361 g_signal_new ("view-opened",
2362 G_OBJECT_CLASS_TYPE (klass),
2363 0,
2364 0, NULL, NULL,
2365 bamf_marshal_VOID__STRING_STRING,
2366 G_TYPE_NONE, 2,
2367 G_TYPE_STRING, G_TYPE_STRING);
2368
2369 matcher_signals [VIEW_CLOSED] =
2370 g_signal_new ("view-closed",
2371 G_OBJECT_CLASS_TYPE (klass),
2372 0,
2373 0, NULL, NULL,
2374 bamf_marshal_VOID__STRING_STRING,
2375 G_TYPE_NONE, 2,
2376 G_TYPE_STRING, G_TYPE_STRING);
2377
2378 matcher_signals [ACTIVE_APPLICATION_CHANGED] =
2379 g_signal_new ("active-application-changed",
2380 G_OBJECT_CLASS_TYPE (klass),
2381 0,
2382 0, NULL, NULL,
2383 bamf_marshal_VOID__STRING_STRING,
2384 G_TYPE_NONE, 2,
2385 G_TYPE_STRING, G_TYPE_STRING);
2386
2387 matcher_signals [ACTIVE_WINDOW_CHANGED] =
2388 g_signal_new ("active-window-changed",
2389 G_OBJECT_CLASS_TYPE (klass),
2390 0,
2391 0, NULL, NULL,
2392 bamf_marshal_VOID__STRING_STRING,
2393 G_TYPE_NONE, 2,
2394 G_TYPE_STRING, G_TYPE_STRING);
2395
2396 matcher_signals [FAVORITES_CHANGED] =2522 matcher_signals [FAVORITES_CHANGED] =
2397 g_signal_new ("favorites-changed",2523 g_signal_new ("favorites-changed",
2398 G_OBJECT_CLASS_TYPE (klass),2524 G_OBJECT_CLASS_TYPE (klass),
@@ -2410,8 +2536,7 @@
2410 if (!BAMF_IS_MATCHER (matcher))2536 if (!BAMF_IS_MATCHER (matcher))
2411 {2537 {
2412 matcher = (BamfMatcher *) g_object_new (BAMF_TYPE_MATCHER, NULL);2538 matcher = (BamfMatcher *) g_object_new (BAMF_TYPE_MATCHER, NULL);
2413 return matcher;
2414 }2539 }
24152540
2416 return g_object_ref (G_OBJECT (matcher));2541 return matcher;
2417}2542}
24182543
=== modified file 'src/bamf-matcher.h'
--- src/bamf-matcher.h 2011-08-01 23:01:36 +0000
+++ src/bamf-matcher.h 2012-01-19 19:16:25 +0000
@@ -14,6 +14,7 @@
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *15 *
16 * Authored by: Jason Smith <jason.smith@canonical.com>16 * Authored by: Jason Smith <jason.smith@canonical.com>
17 * Marco Trevisan (Treviño) <3v1n0@ubuntu.com>
17 *18 *
18 */19 */
1920
@@ -26,9 +27,6 @@
26#include <stdlib.h>27#include <stdlib.h>
27#include <unistd.h>28#include <unistd.h>
28#include <sys/types.h>29#include <sys/types.h>
29#include <dbus/dbus.h>
30#include <dbus/dbus-glib.h>
31#include <dbus/dbus-glib-lowlevel.h>
32#include <gdk/gdk.h>30#include <gdk/gdk.h>
33#include <glib.h>31#include <glib.h>
34#include <glib-object.h>32#include <glib-object.h>
@@ -47,7 +45,7 @@
47#define BAMF_IS_MATCHER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BAMF_TYPE_MATCHER))45#define BAMF_IS_MATCHER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BAMF_TYPE_MATCHER))
48#define BAMF_MATCHER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BAMF_TYPE_MATCHER, BamfMatcherClass))46#define BAMF_MATCHER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BAMF_TYPE_MATCHER, BamfMatcherClass))
4947
50#define _NET_WM_DESKTOP_FILE "_NET_WM_DESKTOP_FILE"48#define _NET_WM_DESKTOP_FILE "_NET_WM_DESKTOP_FILE"
5149
52typedef struct _BamfMatcher BamfMatcher;50typedef struct _BamfMatcher BamfMatcher;
53typedef struct _BamfMatcherClass BamfMatcherClass;51typedef struct _BamfMatcherClass BamfMatcherClass;
@@ -55,12 +53,12 @@
5553
56struct _BamfMatcherClass54struct _BamfMatcherClass
57{55{
58 GObjectClass parent;56 BamfDBusMatcherSkeletonClass parent;
59};57};
6058
61struct _BamfMatcher59struct _BamfMatcher
62{60{
63 GObject parent;61 BamfDBusMatcherSkeleton parent;
6462
65 /* private */63 /* private */
66 BamfMatcherPrivate *priv;64 BamfMatcherPrivate *priv;
@@ -69,41 +67,40 @@
69GType bamf_matcher_get_type (void) G_GNUC_CONST;67GType bamf_matcher_get_type (void) G_GNUC_CONST;
7068
71void bamf_matcher_load_desktop_file (BamfMatcher * self,69void bamf_matcher_load_desktop_file (BamfMatcher * self,
72 char * desktop_file);70 const char * desktop_file);
7371
74void bamf_matcher_register_desktop_file_for_pid (BamfMatcher * self,72void bamf_matcher_register_desktop_file_for_pid (BamfMatcher * self,
75 const char * desktopFile,73 const char *application,
76 gint pid);74 gint pid);
7775
78char * bamf_matcher_get_active_application (BamfMatcher *matcher);76const char * bamf_matcher_get_active_application (BamfMatcher *matcher);
7977
80char * bamf_matcher_get_active_window (BamfMatcher *matcher);78const char * bamf_matcher_get_active_window (BamfMatcher *matcher);
8179
82char * bamf_matcher_application_for_xid (BamfMatcher *matcher,80const char * bamf_matcher_application_for_xid (BamfMatcher *matcher,
83 guint32 xid);81 guint32 xid);
8482
85gboolean bamf_matcher_application_is_running (BamfMatcher *matcher,83gboolean bamf_matcher_application_is_running (BamfMatcher *matcher,
86 char *application);84 const char *application);
8785
88char ** bamf_matcher_application_dbus_paths (BamfMatcher *matcher);86GVariant * bamf_matcher_application_dbus_paths (BamfMatcher *matcher);
8987
90char ** bamf_matcher_window_dbus_paths (BamfMatcher *matcher);88GVariant * bamf_matcher_window_dbus_paths (BamfMatcher *matcher);
9189
92char * bamf_matcher_dbus_path_for_application (BamfMatcher *matcher,90const char * bamf_matcher_dbus_path_for_application (BamfMatcher *matcher,
93 char *application);91 const char *application);
9492
95gboolean bamf_matcher_register_favorites (BamfMatcher *matcher,93void bamf_matcher_register_favorites (BamfMatcher *matcher,
96 char **favorites,94 const char **favorites);
97 GError *error);
98 95
99GList * bamf_matcher_get_favorites (BamfMatcher *matcher);96GList * bamf_matcher_get_favorites (BamfMatcher *matcher);
10097
101char ** bamf_matcher_running_application_paths (BamfMatcher *matcher);98GVariant * bamf_matcher_running_application_paths (BamfMatcher *matcher);
10299
103char ** bamf_matcher_tab_dbus_paths (BamfMatcher *matcher);100GVariant * bamf_matcher_tab_dbus_paths (BamfMatcher *matcher);
104101
105GArray * bamf_matcher_xids_for_application (BamfMatcher *matcher,102GVariant * bamf_matcher_xids_for_application (BamfMatcher *matcher,
106 char *application);103 const char *application);
107104
108BamfMatcher * bamf_matcher_get_default (void);105BamfMatcher * bamf_matcher_get_default (void);
109106
110107
=== removed file 'src/bamf-tab-glue.xml'
--- src/bamf-tab-glue.xml 2010-05-18 19:55:44 +0000
+++ src/bamf-tab-glue.xml 1970-01-01 00:00:00 +0000
@@ -1,39 +0,0 @@
1<?xml version="1.0" encoding="UTF-8" ?>
2
3<node name="/org/ayatana/bamf">
4
5 <interface name="org.ayatana.bamf.tab">
6
7 <signal name="UriChanged">
8 <arg type="s" name="old" direction="out" />
9 <arg type="s" name="new" direction="out" />
10 </signal>
11
12 <method name="ShowTab">
13 <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_tab_show" />
14 </method>
15
16 <method name="ParentXid">
17 <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_tab_parent_xid" />
18 <arg type="u" name="xid" direction="out">
19 <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/>
20 </arg>
21 </method>
22
23 <method name="CurrentUri">
24 <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_tab_current_uri" />
25 <arg type="s" name="uri" direction="out">
26 <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/>
27 </arg>
28 </method>
29
30 <method name="Preview">
31 <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_tab_get_preview" />
32 <arg type="ay" name="data" direction="out">
33 <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/>
34 </arg>
35 </method>
36
37 </interface>
38
39</node>
400
=== modified file 'src/bamf-tab-source.c'
--- src/bamf-tab-source.c 2011-08-01 23:25:01 +0000
+++ src/bamf-tab-source.c 2012-01-19 19:16:25 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright (C) 2010 Canonical Ltd2 * Copyright (C) 2010-2011 Canonical Ltd
3 *3 *
4 * This program is free software: you can redistribute it and/or modify4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as5 * it under the terms of the GNU General Public License version 3 as
@@ -14,15 +14,15 @@
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *15 *
16 * Authored by: Jason Smith <jason.smith@canonical.com>16 * Authored by: Jason Smith <jason.smith@canonical.com>
17 * Marco Trevisan (Treviño) <3v1n0@ubuntu.com>
17 *18 *
18 */19 */
1920
20
21#include "bamf-view.h"21#include "bamf-view.h"
22#include "bamf-tab-source.h"22#include "bamf-tab-source.h"
23#include "bamf-tab.h"23#include "bamf-tab.h"
24#include "bamf-marshal.h"24#include "bamf-marshal.h"
25#include <dbus/dbus-glib.h>25#include "bamf-gdbus-browser-generated.h"
2626
27G_DEFINE_TYPE (BamfTabSource, bamf_tab_source, G_TYPE_OBJECT);27G_DEFINE_TYPE (BamfTabSource, bamf_tab_source, G_TYPE_OBJECT);
28#define BAMF_TAB_SOURCE_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE(obj, \28#define BAMF_TAB_SOURCE_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE(obj, \
@@ -51,9 +51,9 @@
5151
52struct _BamfTabSourcePrivate52struct _BamfTabSourcePrivate
53{53{
54 BamfDBusBrowser *proxy;
54 char *bus;55 char *bus;
55 char *path;56 char *path;
56 DBusGProxy *proxy;
57 GHashTable *tabs;57 GHashTable *tabs;
58};58};
5959
@@ -67,12 +67,7 @@
67 g_return_val_if_fail (BAMF_IS_TAB_SOURCE (self), NULL);67 g_return_val_if_fail (BAMF_IS_TAB_SOURCE (self), NULL);
68 priv = self->priv;68 priv = self->priv;
6969
70 if (!dbus_g_proxy_call (priv->proxy,70 if (!bamf_dbus_browser__call_tab_ids_sync (priv->proxy, &ids, NULL, &error))
71 "TabIds",
72 &error,
73 G_TYPE_INVALID,
74 G_TYPE_STRV, &ids,
75 G_TYPE_INVALID))
76 {71 {
77 g_warning ("Failed to get tab ids: %s", error->message);72 g_warning ("Failed to get tab ids: %s", error->message);
78 g_error_free (error);73 g_error_free (error);
@@ -83,8 +78,7 @@
83}78}
8479
85void80void
86bamf_tab_source_show_tab (BamfTabSource *self,81bamf_tab_source_show_tab (BamfTabSource *self, char *id)
87 char *id)
88{82{
89 BamfTabSourcePrivate *priv;83 BamfTabSourcePrivate *priv;
90 GError *error = NULL;84 GError *error = NULL;
@@ -92,36 +86,26 @@
92 g_return_if_fail (BAMF_IS_TAB_SOURCE (self));86 g_return_if_fail (BAMF_IS_TAB_SOURCE (self));
93 priv = self->priv;87 priv = self->priv;
9488
95 if (!dbus_g_proxy_call (priv->proxy,89 if (!bamf_dbus_browser__call_show_tab_sync (priv->proxy, id, NULL, &error))
96 "ShowTab",
97 &error,
98 G_TYPE_STRING, id,
99 G_TYPE_INVALID,
100 G_TYPE_INVALID))
101 {90 {
102 g_warning ("Failed to show tab: %s", error->message);91 g_warning ("Failed to show tab: %s", error->message);
103 g_error_free (error);92 g_error_free (error);
104 }93 }
105}94}
10695
107GArray *96gchar *
108bamf_tab_source_get_tab_preview (BamfTabSource *self,97bamf_tab_source_get_tab_preview (BamfTabSource *self,
109 char *id)98 char *id)
110{99{
111 BamfTabSourcePrivate *priv;100 BamfTabSourcePrivate *priv;
112 GError *error = NULL;101 GError *error = NULL;
113 GArray *preview_data = NULL;102 gchar *preview_data = NULL;
114103
115 g_return_val_if_fail (BAMF_IS_TAB_SOURCE (self), NULL);104 g_return_val_if_fail (BAMF_IS_TAB_SOURCE (self), NULL);
116 priv = self->priv;105 priv = self->priv;
117106
118 if (!dbus_g_proxy_call (priv->proxy,107 if (!bamf_dbus_browser__call_tab_preview_sync (priv->proxy, id, &preview_data,
119 "TabUri",108 NULL, &error))
120 &error,
121 G_TYPE_STRING, id,
122 G_TYPE_INVALID,
123 G_TYPE_ARRAY, &preview_data,
124 G_TYPE_INVALID))
125 {109 {
126 g_warning ("Failed to get tab preview data: %s", error->message);110 g_warning ("Failed to get tab preview data: %s", error->message);
127 g_error_free (error);111 g_error_free (error);
@@ -142,13 +126,7 @@
142 g_return_val_if_fail (BAMF_IS_TAB_SOURCE (self), NULL);126 g_return_val_if_fail (BAMF_IS_TAB_SOURCE (self), NULL);
143 priv = self->priv;127 priv = self->priv;
144128
145 if (!dbus_g_proxy_call (priv->proxy,129 if (!bamf_dbus_browser__call_tab_uri_sync (priv->proxy, id, &uri, NULL, &error))
146 "TabUri",
147 &error,
148 G_TYPE_STRING, id,
149 G_TYPE_INVALID,
150 G_TYPE_STRING, &uri,
151 G_TYPE_INVALID))
152 {130 {
153 g_warning ("Failed to get tab URI: %s", error->message);131 g_warning ("Failed to get tab URI: %s", error->message);
154 g_error_free (error);132 g_error_free (error);
@@ -169,13 +147,7 @@
169 g_return_val_if_fail (BAMF_IS_TAB_SOURCE (self), 0);147 g_return_val_if_fail (BAMF_IS_TAB_SOURCE (self), 0);
170 priv = self->priv;148 priv = self->priv;
171149
172 if (!dbus_g_proxy_call (priv->proxy,150 if (!bamf_dbus_browser__call_tab_xid_sync (priv->proxy, id, &xid, NULL, &error))
173 "TabXid",
174 &error,
175 G_TYPE_STRING, id,
176 G_TYPE_INVALID,
177 G_TYPE_UINT, &xid,
178 G_TYPE_INVALID))
179 {151 {
180 g_warning ("Failed to get tab XID: %s", error->message);152 g_warning ("Failed to get tab XID: %s", error->message);
181 g_error_free (error);153 g_error_free (error);
@@ -186,7 +158,8 @@
186}158}
187159
188static void160static void
189bamf_tab_source_on_tab_opened (DBusGProxy *proxy, char *id, BamfTabSource *source)161bamf_tab_source_on_tab_opened (BamfDBusBrowser *proxy, const char *id,
162 BamfTabSource *source)
190{163{
191 BamfTab *tab;164 BamfTab *tab;
192165
@@ -201,7 +174,8 @@
201}174}
202175
203static void176static void
204bamf_tab_source_on_tab_closed (DBusGProxy *proxy, char *id, BamfTabSource *source)177bamf_tab_source_on_tab_closed (BamfDBusBrowser *proxy, const char *id,
178 BamfTabSource *source)
205{179{
206 BamfTab *tab;180 BamfTab *tab;
207181
@@ -221,7 +195,8 @@
221}195}
222196
223static void197static void
224bamf_tab_source_on_uri_changed (DBusGProxy *proxy, char *id, char *old_uri, char *new_uri, BamfTabSource *source)198bamf_tab_source_on_uri_changed (BamfDBusBrowser *proxy, const char *id,
199 const char *old_uri, char *new_uri, BamfTabSource *source)
225{200{
226 g_signal_emit (source, REMOTE_TAB_URI_CHANGED, 0, id, old_uri, new_uri);201 g_signal_emit (source, REMOTE_TAB_URI_CHANGED, 0, id, old_uri, new_uri);
227}202}
@@ -266,13 +241,82 @@
266 }241 }
267}242}
268243
244static void bamf_tab_source_reconnect (GObject *object, GParamSpec *pspec, BamfTabSource *self);
245
246static void
247on_proxy_ready_cb (GDBusProxy *proxy, GAsyncResult *res, BamfTabSource *self)
248{
249 BamfDBusBrowser *bproxy;
250 GError *error = NULL;
251 g_return_if_fail (BAMF_IS_TAB_SOURCE (self));
252
253 bproxy = bamf_dbus_browser__proxy_new_for_bus_finish (res, &error);
254
255 if (error)
256 {
257 g_critical ("Unable to get org.ayatana.bamf.browser object from bus %s: %s",
258 self->priv->bus, error->message);
259 g_error_free (error);
260 }
261 else
262 {
263 gchar *owner = g_dbus_proxy_get_name_owner (G_DBUS_PROXY (bproxy));
264
265 if (owner)
266 {
267 g_free (owner);
268
269 if (self->priv->proxy)
270 g_object_unref (self->priv->proxy);
271
272 self->priv->proxy = bproxy;
273
274 g_signal_connect (self->priv->proxy, "tab-uri-changed",
275 (GCallback) bamf_tab_source_on_uri_changed, self);
276
277 g_signal_connect (self->priv->proxy, "tab-opened",
278 (GCallback) bamf_tab_source_on_tab_opened, self);
279
280 g_signal_connect (self->priv->proxy, "tab-closed",
281 (GCallback) bamf_tab_source_on_tab_closed, self);
282
283 g_signal_connect (self->priv->proxy, "notify::g-name-owner",
284 G_CALLBACK (bamf_tab_source_reconnect), self);
285
286 }
287 else
288 {
289 g_debug ("Failed to get notification approver proxy: no owner available");
290 g_object_unref (proxy);
291 }
292 }
293}
294
295static void
296bamf_tab_source_reconnect (GObject *object, GParamSpec *pspec, BamfTabSource *self)
297{
298 g_return_if_fail (BAMF_IS_TAB_SOURCE (self));
299
300 if (self->priv->proxy)
301 {
302 g_object_unref (self->priv->proxy);
303 self->priv->proxy = NULL;
304 }
305
306 bamf_dbus_browser__proxy_new_for_bus (G_BUS_TYPE_SESSION,
307 G_DBUS_PROXY_FLAGS_NONE,
308 self->priv->bus,
309 self->priv->path,
310 NULL,
311 (GAsyncReadyCallback) on_proxy_ready_cb,
312 self);
313}
314
269static void315static void
270bamf_tab_source_constructed (GObject *object)316bamf_tab_source_constructed (GObject *object)
271{317{
272 BamfTabSource *source;318 BamfTabSource *source;
273 BamfTabSourcePrivate *priv;319 BamfTabSourcePrivate *priv;
274 DBusGConnection *connection;
275 GError *error = NULL;
276320
277 if (G_OBJECT_CLASS (bamf_tab_source_parent_class)->constructed)321 if (G_OBJECT_CLASS (bamf_tab_source_parent_class)->constructed)
278 G_OBJECT_CLASS (bamf_tab_source_parent_class)->constructed (object);322 G_OBJECT_CLASS (bamf_tab_source_parent_class)->constructed (object);
@@ -280,65 +324,40 @@
280 source = BAMF_TAB_SOURCE (object);324 source = BAMF_TAB_SOURCE (object);
281 priv = source->priv;325 priv = source->priv;
282326
283 connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);327 bamf_dbus_browser__proxy_new_for_bus (G_BUS_TYPE_SESSION,
284 if (connection == NULL)328 G_DBUS_PROXY_FLAGS_NONE,
285 {329 priv->bus,
286 g_critical ("Failed to open connection to bus: %s",330 priv->path,
287 error != NULL ? error->message : "Unknown");331 NULL,
288 if (error)332 (GAsyncReadyCallback) on_proxy_ready_cb,
289 g_error_free (error);333 source);
290 return;
291 }
292
293 priv->proxy = dbus_g_proxy_new_for_name (connection,
294 priv->bus,
295 priv->path,
296 "org.ayatana.bamf.browser");
297
298 if (priv->proxy == NULL)
299 {
300 g_critical ("Unable to get org.ayatana.bamf.browser object from bus");
301 }
302
303 dbus_g_proxy_add_signal (priv->proxy,
304 "TabUriChanged",
305 G_TYPE_STRING,
306 G_TYPE_STRING,
307 G_TYPE_STRING,
308 G_TYPE_INVALID);
309
310 dbus_g_proxy_add_signal (priv->proxy,
311 "TabOpened",
312 G_TYPE_STRING,
313 G_TYPE_INVALID);
314
315 dbus_g_proxy_add_signal (priv->proxy,
316 "TabClosed",
317 G_TYPE_STRING,
318 G_TYPE_INVALID);
319
320 dbus_g_proxy_connect_signal (priv->proxy,
321 "TabUriChanged",
322 (GCallback) bamf_tab_source_on_uri_changed,
323 source,
324 NULL);
325
326 dbus_g_proxy_connect_signal (priv->proxy,
327 "TabOpened",
328 (GCallback) bamf_tab_source_on_tab_opened,
329 source,
330 NULL);
331
332 dbus_g_proxy_connect_signal (priv->proxy,
333 "TabClosed",
334 (GCallback) bamf_tab_source_on_tab_closed,
335 source,
336 NULL);
337}334}
338335
339static void336static void
340bamf_tab_source_dispose (GObject *object)337bamf_tab_source_dispose (GObject *object)
341{338{
339 BamfTabSource *self;
340
341 self = BAMF_TAB_SOURCE (object);
342
343 if (self->priv->bus)
344 {
345 g_free (self->priv->bus);
346 self->priv->bus = NULL;
347 }
348
349 if (self->priv->path)
350 {
351 g_free (self->priv->path);
352 self->priv->path = NULL;
353 }
354
355 if (self->priv->proxy)
356 {
357 g_object_unref (self->priv->proxy);
358 self->priv->proxy = NULL;
359 }
360
342 G_OBJECT_CLASS (bamf_tab_source_parent_class)->dispose (object);361 G_OBJECT_CLASS (bamf_tab_source_parent_class)->dispose (object);
343}362}
344363
@@ -374,54 +393,54 @@
374 g_object_class_install_property (object_class, PROP_BUS, pspec);393 g_object_class_install_property (object_class, PROP_BUS, pspec);
375394
376 bamf_tab_source_signals [REMOTE_TAB_URI_CHANGED] =395 bamf_tab_source_signals [REMOTE_TAB_URI_CHANGED] =
377 g_signal_new ("remote-tab-uri-changed",396 g_signal_new ("remote-tab-uri-changed",
378 G_OBJECT_CLASS_TYPE (klass),397 G_OBJECT_CLASS_TYPE (klass),
379 G_SIGNAL_RUN_FIRST,398 G_SIGNAL_RUN_FIRST,
380 0,399 0,
381 NULL, NULL,400 NULL, NULL,
382 bamf_marshal_VOID__STRING_STRING_STRING,401 bamf_marshal_VOID__STRING_STRING_STRING,
383 G_TYPE_NONE, 3,402 G_TYPE_NONE, 3,
384 G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);403 G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
385404
386 bamf_tab_source_signals [REMOTE_TAB_OPENED] =405 bamf_tab_source_signals [REMOTE_TAB_OPENED] =
387 g_signal_new ("remote-tab-opened",406 g_signal_new ("remote-tab-opened",
388 G_OBJECT_CLASS_TYPE (klass),407 G_OBJECT_CLASS_TYPE (klass),
389 G_SIGNAL_RUN_FIRST,408 G_SIGNAL_RUN_FIRST,
390 0,409 0,
391 NULL, NULL,410 NULL, NULL,
392 g_cclosure_marshal_VOID__STRING,411 g_cclosure_marshal_VOID__STRING,
393 G_TYPE_NONE, 1,412 G_TYPE_NONE, 1,
394 G_TYPE_STRING);413 G_TYPE_STRING);
395414
396 bamf_tab_source_signals [REMOTE_TAB_CLOSED] =415 bamf_tab_source_signals [REMOTE_TAB_CLOSED] =
397 g_signal_new ("remote-tab-closed",416 g_signal_new ("remote-tab-closed",
398 G_OBJECT_CLASS_TYPE (klass),417 G_OBJECT_CLASS_TYPE (klass),
399 G_SIGNAL_RUN_FIRST,418 G_SIGNAL_RUN_FIRST,
400 0,419 0,
401 NULL, NULL,420 NULL, NULL,
402 g_cclosure_marshal_VOID__STRING,421 g_cclosure_marshal_VOID__STRING,
403 G_TYPE_NONE, 1,422 G_TYPE_NONE, 1,
404 G_TYPE_STRING);423 G_TYPE_STRING);
405424
406 bamf_tab_source_signals [TAB_OPENED] =425 bamf_tab_source_signals [TAB_OPENED] =
407 g_signal_new ("tab-opened",426 g_signal_new ("tab-opened",
408 G_OBJECT_CLASS_TYPE (klass),427 G_OBJECT_CLASS_TYPE (klass),
409 G_SIGNAL_RUN_FIRST,428 G_SIGNAL_RUN_FIRST,
410 0,429 0,
411 NULL, NULL,430 NULL, NULL,
412 g_cclosure_marshal_VOID__OBJECT,431 g_cclosure_marshal_VOID__OBJECT,
413 G_TYPE_NONE, 1,432 G_TYPE_NONE, 1,
414 BAMF_TYPE_TAB);433 BAMF_TYPE_TAB);
415434
416 bamf_tab_source_signals [TAB_CLOSED] =435 bamf_tab_source_signals [TAB_CLOSED] =
417 g_signal_new ("tab-closed",436 g_signal_new ("tab-closed",
418 G_OBJECT_CLASS_TYPE (klass),437 G_OBJECT_CLASS_TYPE (klass),
419 G_SIGNAL_RUN_FIRST,438 G_SIGNAL_RUN_FIRST,
420 0,439 0,
421 NULL, NULL,440 NULL, NULL,
422 g_cclosure_marshal_VOID__OBJECT,441 g_cclosure_marshal_VOID__OBJECT,
423 G_TYPE_NONE, 1,442 G_TYPE_NONE, 1,
424 BAMF_TYPE_TAB);443 BAMF_TYPE_TAB);
425}444}
426445
427BamfTabSource *446BamfTabSource *
428447
=== modified file 'src/bamf-tab-source.h'
--- src/bamf-tab-source.h 2010-05-25 13:47:38 +0000
+++ src/bamf-tab-source.h 2012-01-19 19:16:25 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright (C) 2010 Canonical Ltd2 * Copyright (C) 2010-2011 Canonical Ltd
3 *3 *
4 * This program is free software: you can redistribute it and/or modify4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as5 * it under the terms of the GNU General Public License version 3 as
@@ -14,6 +14,7 @@
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *15 *
16 * Authored by: Jason Smith <jason.smith@canonical.com>16 * Authored by: Jason Smith <jason.smith@canonical.com>
17 * Marco Trevisan (Treviño) <3v1n0@ubuntu.com>
17 *18 *
18 */19 */
1920
@@ -59,7 +60,7 @@
5960
60void bamf_tab_source_show_tab (BamfTabSource *self, char *id);61void bamf_tab_source_show_tab (BamfTabSource *self, char *id);
6162
62GArray * bamf_tab_source_get_tab_preview (BamfTabSource *self, char *id);63gchar * bamf_tab_source_get_tab_preview (BamfTabSource *self, char *id);
6364
64char * bamf_tab_source_get_tab_uri (BamfTabSource *self, char *id);65char * bamf_tab_source_get_tab_uri (BamfTabSource *self, char *id);
6566
6667
=== modified file 'src/bamf-tab.c'
--- src/bamf-tab.c 2011-08-01 23:25:01 +0000
+++ src/bamf-tab.c 2012-01-19 19:16:25 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright (C) 2010 Canonical Ltd2 * Copyright (C) 2010-2011 Canonical Ltd
3 *3 *
4 * This program is free software: you can redistribute it and/or modify4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as5 * it under the terms of the GNU General Public License version 3 as
@@ -14,24 +14,20 @@
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *15 *
16 * Authored by: Jason Smith <jason.smith@canonical.com>16 * Authored by: Jason Smith <jason.smith@canonical.com>
17 * Marco Trevisan (Treviño) <3v1n0@ubuntu.com>
17 *18 *
18 */19 */
1920
20#include "bamf-tab.h"21#include "bamf-tab.h"
21#include "bamf-tab-glue.h"
22#include "bamf-tab-source.h"22#include "bamf-tab-source.h"
23#include "bamf-marshal.h"
2423
25G_DEFINE_TYPE (BamfTab, bamf_tab, BAMF_TYPE_VIEW);
26#define BAMF_TAB_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE(obj, \24#define BAMF_TAB_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE(obj, \
27BAMF_TYPE_TAB, BamfTabPrivate))25BAMF_TYPE_TAB, BamfTabPrivate))
2826
29enum27static void bamf_tab_dbus_iface_init (BamfDBusItemTabIface *iface);
30{28G_DEFINE_TYPE_WITH_CODE (BamfTab, bamf_tab, BAMF_TYPE_VIEW,
31 URI_CHANGED,29 G_IMPLEMENT_INTERFACE (BAMF_DBUS_ITEM_TYPE_TAB,
3230 bamf_tab_dbus_iface_init));
33 LAST_SIGNAL,
34};
3531
36enum32enum
37{33{
@@ -41,10 +37,9 @@
41 PROP_SOURCE,37 PROP_SOURCE,
42};38};
4339
44static guint tab_signals[LAST_SIGNAL] = { 0 };
45
46struct _BamfTabPrivate40struct _BamfTabPrivate
47{41{
42 BamfDBusItemTab *dbus_iface;
48 char *id;43 char *id;
49 char *uri;44 char *uri;
50 BamfTabSource *source;45 BamfTabSource *source;
@@ -73,20 +68,21 @@
73 return bamf_tab_source_get_tab_xid (tab->priv->source, tab->priv->id);68 return bamf_tab_source_get_tab_xid (tab->priv->source, tab->priv->id);
74}69}
7570
76GArray *71gchar *
77bamf_tab_get_preview (BamfTab *tab)72bamf_tab_get_preview (BamfTab *tab)
78{73{
79 return bamf_tab_source_get_tab_preview (tab->priv->source, tab->priv->id);74 return bamf_tab_source_get_tab_preview (tab->priv->source, tab->priv->id);
80}75}
8176
82static char *77static const char *
83bamf_tab_get_view_type (BamfView *view)78bamf_tab_get_view_type (BamfView *view)
84{79{
85 return g_strdup ("tab");80 return "tab";
86}81}
8782
88static void83static void
89on_tab_uri_changed (BamfTabSource *source, char *id, char *old_uri, char *new_uri, BamfTab *self)84on_tab_source_uri_changed (BamfTabSource *source, char *id,
85 char *old_uri, char *new_uri, BamfTab *self)
90{86{
91 if (g_strcmp0 (id, self->priv->id) != 0)87 if (g_strcmp0 (id, self->priv->id) != 0)
92 return;88 return;
@@ -94,7 +90,70 @@
94 g_free (self->priv->uri);90 g_free (self->priv->uri);
95 self->priv->uri = g_strdup (new_uri);91 self->priv->uri = g_strdup (new_uri);
9692
97 g_signal_emit (self, URI_CHANGED, 0, old_uri, new_uri);93 g_signal_emit_by_name (self, "uri-changed", old_uri, new_uri);
94}
95
96static void
97on_uri_changed (BamfTab *self, const gchar *old_uri, const gchar *new_uri, gpointer _not_used)
98{
99 g_return_if_fail (BAMF_IS_TAB (self));
100 g_signal_emit_by_name (self->priv->dbus_iface, "uri-changed", old_uri, new_uri);
101}
102
103static gboolean
104on_dbus_handle_show_tab (BamfDBusItemTab *interface,
105 GDBusMethodInvocation *invocation,
106 BamfTab *self)
107{
108 bamf_tab_show (self);
109 g_dbus_method_invocation_return_value (invocation, NULL);
110
111 return TRUE;
112}
113
114static gboolean
115on_dbus_handle_parent_xid (BamfDBusItemTab *interface,
116 GDBusMethodInvocation *invocation,
117 BamfTab *self)
118{
119 guint32 parent_xid = bamf_tab_parent_xid (self);
120 g_dbus_method_invocation_return_value (invocation,
121 g_variant_new ("(u)", parent_xid));
122
123 return TRUE;
124}
125
126static gboolean
127on_dbus_handle_current_uri (BamfDBusItemTab *interface,
128 GDBusMethodInvocation *invocation,
129 BamfTab *self)
130{
131 char *current_uri = self->priv->uri ? self->priv->uri : "";
132 g_dbus_method_invocation_return_value (invocation,
133 g_variant_new ("(s)", current_uri));
134
135 return TRUE;
136}
137
138static gboolean
139on_dbus_handle_preview (BamfDBusItemTab *interface,
140 GDBusMethodInvocation *invocation,
141 BamfTab *self)
142{
143 gchar *preview = bamf_tab_get_preview (self);
144
145 if (preview)
146 {
147 bamf_dbus_item_tab_complete_preview (interface, invocation, preview);
148 g_free (preview);
149 }
150 else
151 {
152 g_dbus_method_invocation_return_value (invocation,
153 g_variant_new ("(ay)", NULL));
154 }
155
156 return TRUE;
98}157}
99158
100static void159static void
@@ -151,19 +210,72 @@
151210
152 self = BAMF_TAB (object);211 self = BAMF_TAB (object);
153212
154 g_signal_connect (self->priv->source, "remote-tab-uri-changed", (GCallback) on_tab_uri_changed, self);213 g_signal_connect (self->priv->source, "remote-tab-uri-changed",
214 G_CALLBACK (on_tab_source_uri_changed), self);
155}215}
156216
157static void217static void
158bamf_tab_dispose (GObject *object)218bamf_tab_dispose (GObject *object)
159{219{
220 BamfTab *self = BAMF_TAB (object);
221
222 if (self->priv->id)
223 {
224 g_free (self->priv->id);
225 self->priv->id = NULL;
226 }
227
228 if (self->priv->uri)
229 {
230 g_free (self->priv->uri);
231 self->priv->uri = NULL;
232 }
233
160 G_OBJECT_CLASS (bamf_tab_parent_class)->dispose (object);234 G_OBJECT_CLASS (bamf_tab_parent_class)->dispose (object);
161}235}
162236
163static void237static void
238bamf_tab_finalize (GObject *object)
239{
240 BamfTab *self = BAMF_TAB (object);
241
242 g_object_unref (self->priv->dbus_iface);
243
244 G_OBJECT_CLASS (bamf_tab_parent_class)->finalize (object);
245}
246
247static void
164bamf_tab_init (BamfTab * self)248bamf_tab_init (BamfTab * self)
165{249{
166 self->priv = BAMF_TAB_GET_PRIVATE (self);250 self->priv = BAMF_TAB_GET_PRIVATE (self);
251
252 /* Initializing the dbus interface */
253 self->priv->dbus_iface = bamf_dbus_item_tab_skeleton_new ();
254
255 /* We need to connect to the object own signals to redirect them to the dbus
256 * interface */
257 g_signal_connect (self, "uri-changed", G_CALLBACK (on_uri_changed), NULL);
258
259 /* Registering signal callbacks to reply to dbus method calls */
260 g_signal_connect (self->priv->dbus_iface, "handle-show-tab",
261 G_CALLBACK (on_dbus_handle_show_tab), self);
262
263 g_signal_connect (self->priv->dbus_iface, "handle-parent-xid",
264 G_CALLBACK (on_dbus_handle_parent_xid), self);
265
266 g_signal_connect (self->priv->dbus_iface, "handle-current-uri",
267 G_CALLBACK (on_dbus_handle_current_uri), self);
268
269 g_signal_connect (self->priv->dbus_iface, "handle-preview",
270 G_CALLBACK (on_dbus_handle_preview), self);
271
272 /* Setting the interface for the dbus object */
273 bamf_dbus_item_object_skeleton_set_tab (BAMF_DBUS_ITEM_OBJECT_SKELETON (self),
274 self->priv->dbus_iface);
275}
276
277static void bamf_tab_dbus_iface_init (BamfDBusItemTabIface *iface)
278{
167}279}
168280
169static void281static void
@@ -177,6 +289,7 @@
177 object_class->get_property = bamf_tab_get_property;289 object_class->get_property = bamf_tab_get_property;
178 object_class->set_property = bamf_tab_set_property;290 object_class->set_property = bamf_tab_set_property;
179 object_class->dispose = bamf_tab_dispose;291 object_class->dispose = bamf_tab_dispose;
292 object_class->finalize = bamf_tab_finalize;
180 view_class->view_type = bamf_tab_get_view_type;293 view_class->view_type = bamf_tab_get_view_type;
181294
182 pspec = g_param_spec_string ("id", "id", "id", NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT);295 pspec = g_param_spec_string ("id", "id", "id", NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
@@ -186,22 +299,10 @@
186 g_object_class_install_property (object_class, PROP_SOURCE, pspec);299 g_object_class_install_property (object_class, PROP_SOURCE, pspec);
187300
188 g_type_class_add_private (klass, sizeof (BamfTabPrivate));301 g_type_class_add_private (klass, sizeof (BamfTabPrivate));
189
190 dbus_g_object_type_install_info (BAMF_TYPE_TAB,
191 &dbus_glib_bamf_tab_object_info);
192
193 tab_signals [URI_CHANGED] =
194 g_signal_new ("uri-changed",
195 G_OBJECT_CLASS_TYPE (klass),
196 0,
197 0, NULL, NULL,
198 bamf_marshal_VOID__STRING_STRING,
199 G_TYPE_NONE, 2,
200 G_TYPE_STRING, G_TYPE_STRING);
201}302}
202303
203BamfTab *304BamfTab *
204bamf_tab_new (BamfTabSource *source, char *id)305bamf_tab_new (BamfTabSource *source, const char *id)
205{306{
206 BamfTab *self;307 BamfTab *self;
207 self = (BamfTab *) g_object_new (BAMF_TYPE_TAB,308 self = (BamfTab *) g_object_new (BAMF_TYPE_TAB,
208309
=== modified file 'src/bamf-tab.h'
--- src/bamf-tab.h 2010-05-25 13:47:38 +0000
+++ src/bamf-tab.h 2012-01-19 19:16:25 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright (C) 2010 Canonical Ltd2 * Copyright (C) 2010-2011 Canonical Ltd
3 *3 *
4 * This program is free software: you can redistribute it and/or modify4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as5 * it under the terms of the GNU General Public License version 3 as
@@ -14,6 +14,7 @@
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *15 *
16 * Authored by: Jason Smith <jason.smith@canonical.com>16 * Authored by: Jason Smith <jason.smith@canonical.com>
17 * Marco Trevisan (Treviño) <3v1n0@ubuntu.com>
17 *18 *
18 */19 */
1920
@@ -58,8 +59,8 @@
5859
59guint32 bamf_tab_parent_xid (BamfTab *tab);60guint32 bamf_tab_parent_xid (BamfTab *tab);
6061
61GArray * bamf_tab_get_preview (BamfTab *tab);62gchar * bamf_tab_get_preview (BamfTab *tab);
6263
63BamfTab * bamf_tab_new (BamfTabSource *source, char *tab_id);64BamfTab * bamf_tab_new (BamfTabSource *source, const char *tab_id);
6465
65#endif66#endif
6667
=== removed file 'src/bamf-view-glue.xml'
--- src/bamf-view-glue.xml 2011-01-26 09:54:11 +0000
+++ src/bamf-view-glue.xml 1970-01-01 00:00:00 +0000
@@ -1,109 +0,0 @@
1<?xml version="1.0" encoding="UTF-8" ?>
2
3<node name="/org/ayatana/bamf">
4
5 <interface name="org.ayatana.bamf.view">
6
7 <signal name="ActiveChanged">
8 <arg type="b" name="new_state" direction="out" />
9 </signal>
10
11 <signal name="Closed">
12 </signal>
13
14 <signal name="ChildAdded">
15 <arg type="s" name="path" direction="out" />
16 </signal>
17
18 <signal name="ChildRemoved">
19 <arg type="s" name="path" direction="out" />
20 </signal>
21
22 <signal name="RunningChanged">
23 <arg type="b" name="new_state" direction="out" />
24 </signal>
25
26 <signal name="UrgentChanged">
27 <arg type="b" name="new_state" direction="out" />
28 </signal>
29
30 <signal name="UserVisibleChanged">
31 <arg type="b" name="new_state" direction="out" />
32 </signal>
33
34 <signal name="NameChanged">
35 <arg type="s" name="old_name" direction="out" />
36 <arg type="s" name="new_name" direction="out" />
37 </signal>
38
39 <property name="Active" type="b" access="read" />
40 <property name="Urgent" type="b" access="read" />
41 <property name="Running" type="b" access="read" />
42 <property name="UserVisible" type="b" access="read" />
43
44 <method name="Children">
45 <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_view_get_children_paths" />
46 <arg type="as" name="children" direction="out">
47 <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/>
48 </arg>
49 </method>
50
51 <method name="Parents">
52 <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_view_get_parent_paths" />
53 <arg type="as" name="parents" direction="out">
54 <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/>
55 </arg>
56 </method>
57
58 <method name="IsActive">
59 <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_view_is_active" />
60 <arg type="b" name="active" direction="out">
61 <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/>
62 </arg>
63 </method>
64
65 <method name="IsRunning">
66 <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_view_is_running" />
67 <arg type="b" name="running" direction="out">
68 <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/>
69 </arg>
70 </method>
71
72 <method name="IsUrgent">
73 <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_view_is_urgent" />
74 <arg type="b" name="urgent" direction="out">
75 <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/>
76 </arg>
77 </method>
78
79 <method name="Name">
80 <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_view_get_name" />
81 <arg type="s" name="name" direction="out">
82 <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/>
83 </arg>
84 </method>
85
86 <method name="Icon">
87 <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_view_get_icon" />
88 <arg type="s" name="name" direction="out">
89 <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/>
90 </arg>
91 </method>
92
93 <method name="UserVisible">
94 <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_view_user_visible" />
95 <arg type="b" name="visible" direction="out">
96 <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/>
97 </arg>
98 </method>
99
100 <method name="ViewType">
101 <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="bamf_view_get_view_type" />
102 <arg type="s" name="view_type" direction="out">
103 <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/>
104 </arg>
105 </method>
106
107 </interface>
108
109</node>
1100
=== modified file 'src/bamf-view.c'
--- src/bamf-view.c 2011-12-14 03:19:47 +0000
+++ src/bamf-view.c 2012-01-19 19:16:25 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright (C) 2010 Canonical Ltd2 * Copyright (C) 2010-2011 Canonical Ltd
3 *3 *
4 * This program is free software: you can redistribute it and/or modify4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as5 * it under the terms of the GNU General Public License version 3 as
@@ -14,21 +14,24 @@
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *15 *
16 * Authored by: Jason Smith <jason.smith@canonical.com>16 * Authored by: Jason Smith <jason.smith@canonical.com>
17 * Marco Trevisan (Treviño) <3v1n0@ubuntu.com>
17 *18 *
18 */19 */
1920
20#include "bamf-marshal.h"
21#include "bamf-view.h"21#include "bamf-view.h"
22#include "bamf-view-glue.h"
2322
24G_DEFINE_TYPE (BamfView, bamf_view, G_TYPE_OBJECT);
25#define BAMF_VIEW_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE(obj, \23#define BAMF_VIEW_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE(obj, \
26BAMF_TYPE_VIEW, BamfViewPrivate))24 BAMF_TYPE_VIEW, BamfViewPrivate))
25
26static void bamf_view_dbus_view_iface_init (BamfDBusItemViewIface *iface);
27G_DEFINE_TYPE_WITH_CODE (BamfView, bamf_view, BAMF_DBUS_ITEM_TYPE_OBJECT_SKELETON,
28 G_IMPLEMENT_INTERFACE (BAMF_DBUS_ITEM_TYPE_VIEW,
29 bamf_view_dbus_view_iface_init));
2730
28enum31enum
29{32{
30 PROP_0,33 PROP_0,
31 34
32 PROP_ACTIVE,35 PROP_ACTIVE,
33 PROP_RUNNING,36 PROP_RUNNING,
34 PROP_URGENT,37 PROP_URGENT,
@@ -37,16 +40,8 @@
3740
38enum41enum
39{42{
40 ACTIVE_CHANGED,
41 CLOSED,
42 CLOSED_INTERNAL,43 CLOSED_INTERNAL,
43 CHILD_ADDED,
44 CHILD_REMOVED,
45 EXPORTED,44 EXPORTED,
46 RUNNING_CHANGED,
47 URGENT_CHANGED,
48 USER_VISIBLE_CHANGED,
49 NAME_CHANGED,
5045
51 LAST_SIGNAL,46 LAST_SIGNAL,
52};47};
@@ -55,20 +50,19 @@
5550
56struct _BamfViewPrivate51struct _BamfViewPrivate
57{52{
53 BamfDBusItemView *dbus_iface;
58 char * name;54 char * name;
59 char * path;55 char * path;
60 GList * children;56 GList * children;
61 GList * parents;57 GList * parents;
62 gboolean closed;58 gboolean closed;
63 gboolean is_active;
64 gboolean is_running;
65 gboolean is_urgent;
66 gboolean user_visible;
67};59};
6860
69static void61static void
70bamf_view_active_changed (BamfView *view, gboolean active)62bamf_view_active_changed (BamfView *view, gboolean active)
71{63{
64 g_return_if_fail (BAMF_IS_VIEW (view));
65
72 gboolean emit = TRUE;66 gboolean emit = TRUE;
73 if (BAMF_VIEW_GET_CLASS (view)->active_changed)67 if (BAMF_VIEW_GET_CLASS (view)->active_changed)
74 {68 {
@@ -76,16 +70,17 @@
76 }70 }
7771
78 if (emit)72 if (emit)
79 g_signal_emit (view, view_signals[ACTIVE_CHANGED], 0, active);73 g_signal_emit_by_name (view, "active-changed", active);
80
81}74}
8275
83static void76static void
84bamf_view_name_changed (BamfView* view,77bamf_view_name_changed (BamfView *view,
85 const gchar* old_name,78 const gchar *old_name,
86 const gchar* new_name)79 const gchar *new_name)
87{80{
88 g_signal_emit (view, view_signals[NAME_CHANGED], 0, old_name, new_name);81 g_return_if_fail (BAMF_IS_VIEW (view));
82
83 g_signal_emit_by_name (view, "name-changed", old_name, new_name);
8984
90 if (view->priv->name)85 if (view->priv->name)
91 g_free (view->priv->name);86 g_free (view->priv->name);
@@ -96,6 +91,8 @@
96static void91static void
97bamf_view_user_visible_changed (BamfView *view, gboolean user_visible)92bamf_view_user_visible_changed (BamfView *view, gboolean user_visible)
98{93{
94 g_return_if_fail (BAMF_IS_VIEW (view));
95
99 gboolean emit = TRUE;96 gboolean emit = TRUE;
100 if (BAMF_VIEW_GET_CLASS (view)->user_visible_changed)97 if (BAMF_VIEW_GET_CLASS (view)->user_visible_changed)
101 {98 {
@@ -103,12 +100,14 @@
103 }100 }
104101
105 if (emit)102 if (emit)
106 g_signal_emit (view, view_signals[USER_VISIBLE_CHANGED], 0, user_visible);103 g_signal_emit_by_name (view, "user-visible-changed", user_visible);
107}104}
108105
109static void106static void
110bamf_view_running_changed (BamfView *view, gboolean running)107bamf_view_running_changed (BamfView *view, gboolean running)
111{108{
109 g_return_if_fail (BAMF_IS_VIEW (view));
110
112 gboolean emit = TRUE;111 gboolean emit = TRUE;
113 if (BAMF_VIEW_GET_CLASS (view)->running_changed)112 if (BAMF_VIEW_GET_CLASS (view)->running_changed)
114 {113 {
@@ -116,12 +115,14 @@
116 }115 }
117116
118 if (emit)117 if (emit)
119 g_signal_emit (view, view_signals[RUNNING_CHANGED], 0, running);118 g_signal_emit_by_name (view, "running-changed", running);
120}119}
121120
122static void121static void
123bamf_view_urgent_changed (BamfView *view, gboolean urgent)122bamf_view_urgent_changed (BamfView *view, gboolean urgent)
124{123{
124 g_return_if_fail (BAMF_IS_VIEW (view));
125
125 gboolean emit = TRUE;126 gboolean emit = TRUE;
126 if (BAMF_VIEW_GET_CLASS (view)->urgent_changed)127 if (BAMF_VIEW_GET_CLASS (view)->urgent_changed)
127 {128 {
@@ -129,7 +130,7 @@
129 }130 }
130131
131 if (emit)132 if (emit)
132 g_signal_emit (view, view_signals[URGENT_CHANGED], 0, urgent);133 g_signal_emit_by_name (view, "urgent-changed", urgent);
133}134}
134135
135void136void
@@ -138,19 +139,20 @@
138 BamfViewPrivate *priv;139 BamfViewPrivate *priv;
139 gboolean emit = TRUE;140 gboolean emit = TRUE;
140 GList *l;141 GList *l;
141 142
143 g_return_if_fail (BAMF_IS_VIEW (view));
142 priv = view->priv;144 priv = view->priv;
143145
144 if (priv->closed)146 if (priv->closed)
145 return;147 return;
146 148
147 priv->closed = TRUE;149 priv->closed = TRUE;
148150
149 if (BAMF_VIEW_GET_CLASS (view)->closed)151 if (BAMF_VIEW_GET_CLASS (view)->closed)
150 {152 {
151 emit = !BAMF_VIEW_GET_CLASS (view)->closed (view);153 emit = !BAMF_VIEW_GET_CLASS (view)->closed (view);
152 }154 }
153 155
154 if (priv->children)156 if (priv->children)
155 {157 {
156 for (l = priv->children; l; l = l->next)158 for (l = priv->children; l; l = l->next)
@@ -164,10 +166,10 @@
164166
165 if (emit)167 if (emit)
166 {168 {
167 g_object_ref (G_OBJECT (view));169 g_object_ref (view);
168 g_signal_emit (view, view_signals[CLOSED_INTERNAL], 0);170 g_signal_emit (view, view_signals[CLOSED_INTERNAL], 0);
169 g_signal_emit (view, view_signals[CLOSED], 0);171 g_signal_emit_by_name (view, "closed");
170 g_object_unref (G_OBJECT (view));172 g_object_unref (view);
171 }173 }
172}174}
173175
@@ -179,35 +181,31 @@
179 return view->priv->path;181 return view->priv->path;
180}182}
181183
182char **184GVariant *
183bamf_view_get_children_paths (BamfView *view)185bamf_view_get_children_paths (BamfView *view)
184{186{
185 char ** paths;187 GVariantBuilder b;
186 const char *path;188 GList *l;
187 int n_items, i;
188 GList *child;
189 BamfView *cview;
190189
191 g_return_val_if_fail (BAMF_IS_VIEW (view), NULL);190 g_return_val_if_fail (BAMF_IS_VIEW (view), NULL);
192191
193 n_items = g_list_length (view->priv->children);192 g_variant_builder_init (&b, G_VARIANT_TYPE ("(as)"));
194193 g_variant_builder_open (&b, G_VARIANT_TYPE ("as"));
195 paths = g_malloc0 (sizeof (char *) * (n_items + 1));194
196195 for (l = view->priv->children; l; l = l->next)
197 i = 0;
198 for (child = view->priv->children; child; child = child->next)
199 {196 {
200 cview = child->data;197 BamfView *child = l->data;
201 path = bamf_view_get_path (cview);198 const char *path = bamf_view_get_path (child);
202199
203 if (!path)200 if (!path)
204 continue;201 continue;
205202
206 paths[i] = g_strdup (path);203 g_variant_builder_add (&b, "s", path);
207 i++;
208 }204 }
209205
210 return paths;206 g_variant_builder_close (&b);
207
208 return g_variant_builder_end (&b);
211}209}
212210
213GList *211GList *
@@ -218,35 +216,31 @@
218 return view->priv->children;216 return view->priv->children;
219}217}
220218
221char **219GVariant *
222bamf_view_get_parent_paths (BamfView *view)220bamf_view_get_parent_paths (BamfView *view)
223{221{
224 char ** paths;222 GVariantBuilder b;
225 const char *path;223 GList *l;
226 int n_items, i;
227 GList *parent;
228 BamfView *pview;
229224
230 g_return_val_if_fail (BAMF_IS_VIEW (view), NULL);225 g_return_val_if_fail (BAMF_IS_VIEW (view), NULL);
231226
232 n_items = g_list_length (view->priv->parents);227 g_variant_builder_init (&b, G_VARIANT_TYPE ("(as)"));
233228 g_variant_builder_open (&b, G_VARIANT_TYPE ("as"));
234 paths = g_malloc0 (sizeof (char *) * (n_items + 1));229
235230 for (l = view->priv->parents; l; l = l->next)
236 i = 0;
237 for (parent = view->priv->parents; parent; parent = parent->next)
238 {231 {
239 pview = parent->data;232 BamfView *parent = l->data;
240 path = bamf_view_get_path (pview);233 const char *path = bamf_view_get_path (parent);
241234
242 if (!path)235 if (!path)
243 continue;236 continue;
244237
245 paths[i] = g_strdup (path);238 g_variant_builder_add (&b, "s", path);
246 i++;
247 }239 }
248240
249 return paths;241 g_variant_builder_close (&b);
242
243 return g_variant_builder_end (&b);
250}244}
251245
252GList *246GList *
@@ -274,7 +268,7 @@
274 g_return_if_fail (BAMF_IS_VIEW (child));268 g_return_if_fail (BAMF_IS_VIEW (child));
275269
276 g_signal_connect (G_OBJECT (child), "closed-internal",270 g_signal_connect (G_OBJECT (child), "closed-internal",
277 (GCallback) bamf_view_handle_child_closed, view);271 (GCallback) bamf_view_handle_child_closed, view);
278272
279 /* Make sure our parent child lists are ok, pay attention to whose list you add parents to */273 /* Make sure our parent child lists are ok, pay attention to whose list you add parents to */
280 view->priv->children = g_list_prepend (view->priv->children, child);274 view->priv->children = g_list_prepend (view->priv->children, child);
@@ -285,7 +279,7 @@
285 BAMF_VIEW_GET_CLASS (view)->child_added (view, child);279 BAMF_VIEW_GET_CLASS (view)->child_added (view, child);
286280
287 added = bamf_view_get_path (child);281 added = bamf_view_get_path (child);
288 g_signal_emit (view, view_signals[CHILD_ADDED], 0, added);282 g_signal_emit_by_name (view, "child-added", added);
289}283}
290284
291void285void
@@ -303,12 +297,12 @@
303 view->priv->children = g_list_remove (view->priv->children, child);297 view->priv->children = g_list_remove (view->priv->children, child);
304 child->priv->parents = g_list_remove (child->priv->parents, view);298 child->priv->parents = g_list_remove (child->priv->parents, view);
305299
300 removed = bamf_view_get_path (child);
301 g_signal_emit_by_name (view, "child-removed", removed);
302
306 // Do this by hand so we can pass and object instead of a string303 // Do this by hand so we can pass and object instead of a string
307 if (BAMF_VIEW_GET_CLASS (view)->child_removed)304 if (BAMF_VIEW_GET_CLASS (view)->child_removed)
308 BAMF_VIEW_GET_CLASS (view)->child_removed (view, child);305 BAMF_VIEW_GET_CLASS (view)->child_removed (view, child);
309
310 removed = bamf_view_get_path (child);
311 g_signal_emit (view, view_signals[CHILD_REMOVED], 0, removed);
312}306}
313307
314gboolean308gboolean
@@ -316,7 +310,7 @@
316{310{
317 g_return_val_if_fail (BAMF_IS_VIEW (view), FALSE);311 g_return_val_if_fail (BAMF_IS_VIEW (view), FALSE);
318312
319 return view->priv->is_active;313 return bamf_dbus_item_view_get_active (view->priv->dbus_iface);
320}314}
321315
322void316void
@@ -325,10 +319,10 @@
325{319{
326 g_return_if_fail (BAMF_IS_VIEW (view));320 g_return_if_fail (BAMF_IS_VIEW (view));
327321
328 if (active == view->priv->is_active)322 if (active == bamf_view_is_active (view))
329 return;323 return;
330324
331 view->priv->is_active = active;325 bamf_dbus_item_view_set_active (view->priv->dbus_iface, active);
332 bamf_view_active_changed (view, active);326 bamf_view_active_changed (view, active);
333}327}
334328
@@ -337,7 +331,7 @@
337{331{
338 g_return_val_if_fail (BAMF_IS_VIEW (view), FALSE);332 g_return_val_if_fail (BAMF_IS_VIEW (view), FALSE);
339333
340 return view->priv->is_urgent;334 return bamf_dbus_item_view_get_urgent (view->priv->dbus_iface);
341}335}
342336
343void337void
@@ -346,10 +340,10 @@
346{340{
347 g_return_if_fail (BAMF_IS_VIEW (view));341 g_return_if_fail (BAMF_IS_VIEW (view));
348342
349 if (urgent == view->priv->is_urgent)343 if (urgent == bamf_view_is_urgent (view))
350 return;344 return;
351345
352 view->priv->is_urgent = urgent;346 bamf_dbus_item_view_set_urgent (view->priv->dbus_iface, urgent);
353 bamf_view_urgent_changed (view, urgent);347 bamf_view_urgent_changed (view, urgent);
354}348}
355349
@@ -358,7 +352,7 @@
358{352{
359 g_return_val_if_fail (BAMF_IS_VIEW (view), FALSE);353 g_return_val_if_fail (BAMF_IS_VIEW (view), FALSE);
360354
361 return view->priv->is_running;355 return bamf_dbus_item_view_get_running (view->priv->dbus_iface);
362}356}
363357
364void358void
@@ -367,10 +361,10 @@
367{361{
368 g_return_if_fail (BAMF_IS_VIEW (view));362 g_return_if_fail (BAMF_IS_VIEW (view));
369363
370 if (running == view->priv->is_running)364 if (running == bamf_view_is_running (view))
371 return;365 return;
372366
373 view->priv->is_running = running;367 bamf_dbus_item_view_set_running (view->priv->dbus_iface, running);
374 bamf_view_running_changed (view, running);368 bamf_view_running_changed (view, running);
375}369}
376370
@@ -379,7 +373,7 @@
379{373{
380 g_return_val_if_fail (BAMF_IS_VIEW (view), FALSE);374 g_return_val_if_fail (BAMF_IS_VIEW (view), FALSE);
381375
382 return view->priv->user_visible;376 return bamf_dbus_item_view_get_user_visible (view->priv->dbus_iface);
383}377}
384378
385void379void
@@ -387,10 +381,10 @@
387{381{
388 g_return_if_fail (BAMF_IS_VIEW (view));382 g_return_if_fail (BAMF_IS_VIEW (view));
389383
390 if (user_visible == view->priv->user_visible)384 if (user_visible == bamf_view_user_visible (view))
391 return;385 return;
392386
393 view->priv->user_visible = user_visible;387 bamf_dbus_item_view_set_user_visible (view->priv->dbus_iface, user_visible);
394 bamf_view_user_visible_changed (view, user_visible);388 bamf_view_user_visible_changed (view, user_visible);
395}389}
396390
@@ -422,10 +416,10 @@
422 if (!g_strcmp0 (name, view->priv->name))416 if (!g_strcmp0 (name, view->priv->name))
423 return;417 return;
424418
425 bamf_view_name_changed (view, view->priv->name, (gchar*) name);419 bamf_view_name_changed (view, view->priv->name, name);
426}420}
427421
428char *422const char *
429bamf_view_get_view_type (BamfView *view)423bamf_view_get_view_type (BamfView *view)
430{424{
431 g_return_val_if_fail (BAMF_IS_VIEW (view), NULL);425 g_return_val_if_fail (BAMF_IS_VIEW (view), NULL);
@@ -433,7 +427,7 @@
433 if (BAMF_VIEW_GET_CLASS (view)->view_type)427 if (BAMF_VIEW_GET_CLASS (view)->view_type)
434 return BAMF_VIEW_GET_CLASS (view)->view_type (view);428 return BAMF_VIEW_GET_CLASS (view)->view_type (view);
435429
436 return g_strdup ("view");430 return "view";
437}431}
438432
439char *433char *
@@ -447,14 +441,15 @@
447 return g_strdup_printf ("view%p", view);441 return g_strdup_printf ("view%p", view);
448}442}
449443
450char *444const char *
451bamf_view_export_on_bus (BamfView *view)
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches