Merge lp:~abreu-alexandre/bamf/remove-webapps-deps into lp:bamf

Proposed by Alexandre Abreu
Status: Merged
Approved by: Marco Trevisan (Treviño)
Approved revision: 600
Merged at revision: 598
Proposed branch: lp:~abreu-alexandre/bamf/remove-webapps-deps
Merge into: lp:bamf
Diff against target: 1571 lines (+1/-1397)
12 files modified
configure.ac (+0/-17)
debian/control (+0/-1)
src/Makefile.am (+0/-21)
src/bamf-matcher-private.h (+0/-4)
src/bamf-matcher.c (+1/-117)
src/bamf-unity-webapps-application.c (+0/-339)
src/bamf-unity-webapps-application.h (+0/-63)
src/bamf-unity-webapps-observer.c (+0/-278)
src/bamf-unity-webapps-observer.h (+0/-54)
src/bamf-unity-webapps-tab.c (+0/-427)
src/bamf-unity-webapps-tab.h (+0/-62)
tests/bamfdaemon/Makefile.am (+0/-14)
To merge this branch: bzr merge lp:~abreu-alexandre/bamf/remove-webapps-deps
Reviewer Review Type Date Requested Status
Marco Trevisan (Treviño) Approve
David Barth (community) Approve
Robert Bruce Park (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+214617@code.launchpad.net

Commit message

Rip out vestigial webapps code (LP: #1280337)

Description of the change

Remove dependancies on libunity-webapps and further usages of this lib.

libunity-webapps is not used anymore since all the old browser tab integration bit has been moved to a standalone container and does not need special treatment from bamf (beside some bits to handle the common webapp launcher).

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Robert Bruce Park (robru) wrote :

Oh my god, all this red is giving me a nerdgasm! I'm putting this in a silo ASAP

Revision history for this message
Robert Bruce Park (robru) wrote :

debian/control looks good to me at least. can't speak for the rest of it though

review: Approve (packaging)
Revision history for this message
Robert Bruce Park (robru) wrote :

Built this in silo 11, tested, confirmed that with this installed, bamf continues to function, and it's possible to uninstall webbrowser-app without taking out unity with it.

review: Approve
Revision history for this message
David Barth (dbarth) :
review: Approve
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

All these things must not be removed, othewise chromium web-apps will stop working:

135 -is_web_app_window (BamfLegacyWindow *window)

177 - skip_hint_set = is_libreoffice_window (window) || is_web_app_window (window) || is_javaws_window (window);

185 {
186 - if (is_web_app_window (window))
187 - {
188 - // This ensures that a new application is created even for unknown webapps
189 - filter_by_wmclass = TRUE;
190 - }
191 - else
192 - {
193 - target_class = class_name;
194 - filter_by_wmclass = bamf_matcher_has_instance_class_desktop_file (self, target_class);
195 - }
196 + target_class = class_name;
197 + filter_by_wmclass = bamf_matcher_has_instance_class_desktop_file (self, target_class);

As said, also, it would be nice to provide changes for libbamf as well not to make it to do anything, but warn about the fact these APIs are deprecated. And at the same way, deprecate all the methods into the headers, providing also a branch for unity.

review: Needs Fixing
Revision history for this message
Alexandre Abreu (abreu-alexandre) wrote :

> All these things must not be removed, othewise chromium web-apps will stop
> working:
>
> 135 -is_web_app_window (BamfLegacyWindow *window)
>
> 177 - skip_hint_set = is_libreoffice_window (window) || is_web_app_window
> (window) || is_javaws_window (window);
>
> 185 {
> 186 - if (is_web_app_window (window))
> 187 - {
> 188 - // This ensures that a new application is created even for unknown
> webapps
> 189 - filter_by_wmclass = TRUE;
> 190 - }
> 191 - else
> 192 - {
> 193 - target_class = class_name;
> 194 - filter_by_wmclass = bamf_matcher_has_instance_class_desktop_file
> (self, target_class);
> 195 - }
> 196 + target_class = class_name;
> 197 + filter_by_wmclass = bamf_matcher_has_instance_class_desktop_file
> (self, target_class);
>

done

> As said, also, it would be nice to provide changes for libbamf as well not to
> make it to do anything, but warn about the fact these APIs are deprecated. And
> at the same way, deprecate all the methods into the headers, providing also a
> branch for unity.

we agreed, to do it in a second step to lower the risks since we would be playing
w/ libbamf & unity and it is a bit scary at this point in the cycle,

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

Ok, it looks fine to me now.

Please, provide an unity branch to remove the unneeded webapp related calls as soon as you can.

Thanks.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'configure.ac'
--- configure.ac 2013-08-30 17:05:52 +0000
+++ configure.ac 2014-04-08 14:38:15 +0000
@@ -91,22 +91,6 @@
91GTK_DOC_CHECK(1.0)91GTK_DOC_CHECK(1.0)
9292
93###########################93###########################
94# libunity_webapps
95###########################
96AC_ARG_ENABLE([webapps],
97 AS_HELP_STRING([--enable-webapps],
98 [Enable libunity-webapps support]),
99 [enable_webapps=$enableval],
100 [enable_webapps=yes])
101if test "x$enable_webapps" = "xyes"; then
102 PKG_CHECK_MODULES(LIBUNITY_WEBAPPS, libunity_webapps-0.2)
103 AC_DEFINE_UNQUOTED(HAVE_WEBAPPS, , [Use libunity-webapps])
104fi
105AM_CONDITIONAL([HAVE_WEBAPPS], [test "x$enable_webapps" = "xyes"])
106AC_SUBST(LIBUNITY_WEBAPPS_CFLAGS)
107AC_SUBST(LIBUNITY_WEBAPPS_LIBS)
108
109###########################
110# gtester2xunit checks #94# gtester2xunit checks #
111###########################95###########################
11296
@@ -184,7 +168,6 @@
184 Build Environment168 Build Environment
185 Install Prefix: ${prefix}169 Install Prefix: ${prefix}
186 Introspection: ${enable_introspection}170 Introspection: ${enable_introspection}
187 Unity Webapps: ${enable_webapps}
188 Headless tests: ${enable_headless_tests}171 Headless tests: ${enable_headless_tests}
189 Coverage Reporting: ${use_gcov}172 Coverage Reporting: ${use_gcov}
190173
191174
=== modified file 'debian/control'
--- debian/control 2013-08-21 09:01:10 +0000
+++ debian/control 2014-04-08 14:38:15 +0000
@@ -11,7 +11,6 @@
11 libglib2.0-dev (>= 2.32.0),11 libglib2.0-dev (>= 2.32.0),
12 libgtop2-dev,12 libgtop2-dev,
13 libgtk-3-dev (>= 3.0.0),13 libgtk-3-dev (>= 3.0.0),
14 libunity-webapps-dev (>= 2.3.3),
15 libwnck-3-dev (>= 3.4.7),14 libwnck-3-dev (>= 3.4.7),
16 libgirepository1.0-dev,15 libgirepository1.0-dev,
17 python-libxslt1,16 python-libxslt1,
1817
=== modified file 'src/Makefile.am'
--- src/Makefile.am 2013-06-13 22:19:56 +0000
+++ src/Makefile.am 2014-04-08 14:38:15 +0000
@@ -37,30 +37,11 @@
37 bamf-xutils.h \37 bamf-xutils.h \
38 $(NULL)38 $(NULL)
3939
40bamfdaemon_webapps_sources = \
41 bamf-unity-webapps-tab.c \
42 bamf-unity-webapps-observer.c \
43 bamf-unity-webapps-application.c \
44 $(NULL)
45
46bamfdaemon_webapps_headers = \
47 bamf-unity-webapps-tab.h \
48 bamf-unity-webapps-observer.h \
49 bamf-unity-webapps-application.h \
50 $(NULL)
51
52bamfdaemon_SOURCES = \40bamfdaemon_SOURCES = \
53 $(bamfdaemon_sources) \41 $(bamfdaemon_sources) \
54 $(bamfdaemon_headers) \42 $(bamfdaemon_headers) \
55 $(NULL)43 $(NULL)
5644
57if HAVE_WEBAPPS
58bamfdaemon_SOURCES += \
59 $(bamfdaemon_webapps_sources) \
60 $(bamfdaemon_webapps_headers) \
61 $(NULL)
62endif
63
64bamfdaemon_LDADD = \45bamfdaemon_LDADD = \
65 $(LIBBAMF_PRIVATE_LIB) \46 $(LIBBAMF_PRIVATE_LIB) \
66 $(X_LIBS) \47 $(X_LIBS) \
@@ -68,7 +49,6 @@
68 $(GTK_LIBS) \49 $(GTK_LIBS) \
69 $(WNCK_LIBS) \50 $(WNCK_LIBS) \
70 $(GTOP_LIBS) \51 $(GTOP_LIBS) \
71 $(LIBUNITY_WEBAPPS_LIBS) \
72 $(NULL)52 $(NULL)
7353
74bamfdaemon_CFLAGS = \54bamfdaemon_CFLAGS = \
@@ -82,7 +62,6 @@
82 $(GTK_CFLAGS) \62 $(GTK_CFLAGS) \
83 $(WNCK_CFLAGS) \63 $(WNCK_CFLAGS) \
84 $(GTOP_CFLAGS) \64 $(GTOP_CFLAGS) \
85 $(LIBUNITY_WEBAPPS_CFLAGS) \
86 $(COVERAGE_CFLAGS) \65 $(COVERAGE_CFLAGS) \
87 $(NULL)66 $(NULL)
8867
8968
=== modified file 'src/bamf-matcher-private.h'
--- src/bamf-matcher-private.h 2013-08-07 15:51:54 +0000
+++ src/bamf-matcher-private.h 2014-04-08 14:38:15 +0000
@@ -25,13 +25,9 @@
25#include "bamf-application.h"25#include "bamf-application.h"
26#include "bamf-window.h"26#include "bamf-window.h"
27#include "bamf-legacy-window.h"27#include "bamf-legacy-window.h"
28#include "bamf-unity-webapps-observer.h"
2928
30struct _BamfMatcherPrivate29struct _BamfMatcherPrivate
31{30{
32#ifdef HAVE_WEBAPPS
33 BamfUnityWebappsObserver *webapps_observer;
34#endif
35 GArray * bad_prefixes;31 GArray * bad_prefixes;
36 GArray * good_prefixes;32 GArray * good_prefixes;
37 GHashTable * desktop_id_table;33 GHashTable * desktop_id_table;
3834
=== modified file 'src/bamf-matcher.c'
--- src/bamf-matcher.c 2014-03-07 17:22:20 +0000
+++ src/bamf-matcher.c 2014-04-08 14:38:15 +0000
@@ -27,10 +27,6 @@
27#include "bamf-window.h"27#include "bamf-window.h"
28#include "bamf-legacy-screen.h"28#include "bamf-legacy-screen.h"
2929
30#ifdef HAVE_WEBAPPS
31#include "bamf-unity-webapps-application.h"
32#include "bamf-unity-webapps-tab.h"
33#endif
34#include <strings.h>30#include <strings.h>
3531
36#define BAMF_INDEX_NAME "bamf-2.index"32#define BAMF_INDEX_NAME "bamf-2.index"
@@ -1492,7 +1488,7 @@
1492 const char *window_class = bamf_legacy_window_get_class_name (window);1488 const char *window_class = bamf_legacy_window_get_class_name (window);
1493 const char *instance_name = bamf_legacy_window_get_class_instance_name (window);1489 const char *instance_name = bamf_legacy_window_get_class_instance_name (window);
14941490
1495 // Chrome/Chromium uses url wm_class strings to represent its web apps.1491 // Chrome/Chromium uses url wm_class strings to represent its web apps (--app mode).
1496 // These apps will still have the same parent pid and hints as the main chrome1492 // These apps will still have the same parent pid and hints as the main chrome
1497 // window, so we skip the hint check.1493 // window, so we skip the hint check.
1498 // We can tell a window is a chrome web app window if its instance name is1494 // We can tell a window is a chrome web app window if its instance name is
@@ -2940,103 +2936,6 @@
2940 return TRUE;2936 return TRUE;
2941}2937}
29422938
2943#ifdef HAVE_WEBAPPS
2944static gboolean
2945bamf_matcher_has_tab_with_parent_xid (BamfMatcher *matcher, guint64 xid)
2946{
2947 GList *l;
2948 g_return_val_if_fail (BAMF_IS_MATCHER (matcher), FALSE);
2949
2950 for (l = matcher->priv->views; l; l = l->next)
2951 {
2952 if (!BAMF_IS_TAB (l->data))
2953 continue;
2954
2955 if (xid == bamf_tab_get_xid (BAMF_TAB (l->data)))
2956 return TRUE;
2957 }
2958
2959 return FALSE;
2960}
2961
2962static void
2963on_webapp_child_added (BamfView *application,
2964 BamfView *child,
2965 gpointer user_data)
2966{
2967 BamfMatcher *self;
2968 BamfLegacyWindow *legacy_window;
2969 BamfUnityWebappsTab *webapp_tab;
2970
2971 g_return_if_fail (BAMF_IS_MATCHER (user_data));
2972 g_return_if_fail (BAMF_IS_UNITY_WEBAPPS_TAB (child));
2973
2974 self = BAMF_MATCHER (user_data);
2975 webapp_tab = BAMF_UNITY_WEBAPPS_TAB (child);
2976 legacy_window = bamf_unity_webapps_tab_get_legacy_window_for (webapp_tab);
2977
2978 if (legacy_window && is_web_app_window (legacy_window))
2979 {
2980 /* If we have a chromeless window, we remove the window from the
2981 * application children list, so that it won't be duplicated in launcher */
2982
2983 guint tab_xid = bamf_tab_get_xid (BAMF_TAB (webapp_tab));
2984
2985 if (!bamf_matcher_has_tab_with_parent_xid (self, tab_xid))
2986 {
2987 BamfApplication *old_application = bamf_matcher_get_application_by_xid (self, tab_xid);
2988
2989 if (BAMF_IS_APPLICATION (old_application))
2990 {
2991 BamfWindow *bamf_window = bamf_application_get_window (old_application, tab_xid);
2992
2993 if (BAMF_IS_VIEW (bamf_window))
2994 bamf_view_remove_child (BAMF_VIEW (old_application), BAMF_VIEW (bamf_window));
2995 }
2996 }
2997 }
2998
2999 bamf_matcher_register_view_stealing_ref (self, child);
3000}
3001
3002static void on_webapp_child_removed (BamfView *application,
3003 BamfView *child,
3004 gpointer user_data)
3005{
3006 BamfLegacyWindow *legacy_window;
3007 BamfUnityWebappsTab *webapp_tab;
3008
3009 g_return_if_fail (BAMF_IS_UNITY_WEBAPPS_TAB (child));
3010
3011 webapp_tab = BAMF_UNITY_WEBAPPS_TAB (child);
3012 legacy_window = bamf_unity_webapps_tab_get_legacy_window_for (webapp_tab);
3013
3014 if (is_web_app_window (legacy_window))
3015 {
3016 /* If we have a chromeless window, we re-match it again as soon as the
3017 * webapp handler is gone, so that we don't lose its control */
3018 bamf_legacy_window_reopen (legacy_window);
3019 }
3020}
3021
3022static void
3023on_webapp_appeared (BamfUnityWebappsObserver *observer,
3024 BamfApplication *application,
3025 gpointer user_data)
3026{
3027 BamfMatcher *self;
3028
3029 self = (BamfMatcher *)user_data;
3030
3031 bamf_matcher_register_view_stealing_ref (self, (BamfView *)application);
3032
3033 g_signal_connect (application, "child-added-internal", G_CALLBACK (on_webapp_child_added), self);
3034 g_signal_connect (application, "child-removed-internal", G_CALLBACK (on_webapp_child_removed), self);
3035
3036 bamf_unity_webapps_application_add_existing_interests (BAMF_UNITY_WEBAPPS_APPLICATION (application));
3037}
3038#endif
3039
3040static void2939static void
3041bamf_matcher_init (BamfMatcher * self)2940bamf_matcher_init (BamfMatcher * self)
3042{2941{
@@ -3117,13 +3016,6 @@
31173016
3118 g_signal_connect (self, "handle-window-stack-for-monitor",3017 g_signal_connect (self, "handle-window-stack-for-monitor",
3119 G_CALLBACK (on_dbus_handle_window_stack_for_monitor), self);3018 G_CALLBACK (on_dbus_handle_window_stack_for_monitor), self);
3120
3121#ifdef HAVE_WEBAPPS
3122 priv->webapps_observer = bamf_unity_webapps_observer_new ();
3123
3124 g_signal_connect (priv->webapps_observer, "application-appeared",
3125 G_CALLBACK (on_webapp_appeared), self);
3126#endif
3127}3019}
31283020
3129static void3021static void
@@ -3137,14 +3029,6 @@
3137 bamf_matcher_unregister_view (self, priv->views->data);3029 bamf_matcher_unregister_view (self, priv->views->data);
3138 }3030 }
31393031
3140#ifdef HAVE_WEBAPPS
3141 if (priv->webapps_observer)
3142 {
3143 g_object_unref (G_OBJECT (priv->webapps_observer));
3144 priv->webapps_observer = NULL;
3145 }
3146#endif
3147
3148 G_OBJECT_CLASS (bamf_matcher_parent_class)->dispose (object);3032 G_OBJECT_CLASS (bamf_matcher_parent_class)->dispose (object);
3149}3033}
31503034
31513035
=== removed file 'src/bamf-unity-webapps-application.c'
--- src/bamf-unity-webapps-application.c 2013-07-31 00:11:27 +0000
+++ src/bamf-unity-webapps-application.c 1970-01-01 00:00:00 +0000
@@ -1,339 +0,0 @@
1/*
2 * Copyright (C) 2010-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 * MERCHANAPPLICATIONILITY 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:
17 * Robert Carr <racarr@canonical.com>
18 *
19 */
20
21#include <stdlib.h>
22
23
24#include "bamf-unity-webapps-application.h"
25#include "bamf-unity-webapps-tab.h"
26#include "bamf-matcher.h"
27
28#include <unity-webapps-context.h>
29
30#define BAMF_UNITY_WEBAPPS_APPLICATION_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE(obj, \
31BAMF_TYPE_UNITY_WEBAPPS_APPLICATION, BamfUnityWebappsApplicationPrivate))
32
33G_DEFINE_TYPE(BamfUnityWebappsApplication, bamf_unity_webapps_application, BAMF_TYPE_APPLICATION);
34
35enum
36{
37 PROP_0,
38 PROP_CONTEXT,
39};
40
41struct _BamfUnityWebappsApplicationPrivate
42{
43 UnityWebappsContext *context;
44};
45
46
47static void
48bamf_unity_webapps_application_get_application_menu (BamfApplication *application,
49 gchar **name,
50 gchar **path)
51{
52 BamfUnityWebappsApplication *self;
53
54 self = (BamfUnityWebappsApplication *)application;
55
56 *name = g_strdup (unity_webapps_context_get_context_name (self->priv->context));
57 *path = g_strdup (UNITY_WEBAPPS_CONTEXT_MENU_PATH);
58}
59
60static void
61bamf_unity_webapps_application_get_property (GObject *object, guint property_id, GValue *gvalue, GParamSpec *pspec)
62{
63 BamfUnityWebappsApplication *self;
64
65 self = BAMF_UNITY_WEBAPPS_APPLICATION (object);
66
67 switch (property_id)
68 {
69 case PROP_CONTEXT:
70 g_value_set_object (gvalue, self->priv->context);
71 break;
72 default:
73 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
74 }
75}
76
77static BamfUnityWebappsTab *
78bamf_unity_webapps_application_find_child_by_interest (BamfUnityWebappsApplication *application,
79 gint interest_id)
80{
81 GList *children, *walk;
82 BamfUnityWebappsTab *child;
83
84 children = bamf_view_get_children (BAMF_VIEW (application));
85
86 for (walk = children; walk != NULL; walk = walk->next)
87 {
88 child = BAMF_UNITY_WEBAPPS_TAB (walk->data);
89
90 if (interest_id == bamf_unity_webapps_tab_get_interest_id (child))
91 {
92 return child;
93 }
94 }
95
96 return NULL;
97}
98
99static BamfView *
100bamf_unity_webapps_application_get_focusable_child (BamfApplication *application)
101{
102 BamfUnityWebappsApplication *self;
103 gint focus_interest;
104
105 self = BAMF_UNITY_WEBAPPS_APPLICATION (application);
106
107 focus_interest = unity_webapps_context_get_focus_interest (self->priv->context);
108
109 if (focus_interest == -1)
110 return NULL;
111
112 return (BamfView *)bamf_unity_webapps_application_find_child_by_interest (self, focus_interest);
113}
114
115
116static void
117bamf_unity_webapps_application_interest_appeared (UnityWebappsContext *context,
118 gint interest_id,
119 gpointer user_data)
120{
121 BamfUnityWebappsApplication *self;
122 BamfUnityWebappsTab *child;
123
124 self = BAMF_UNITY_WEBAPPS_APPLICATION (user_data);
125
126 child = bamf_unity_webapps_application_find_child_by_interest (self, interest_id);
127
128 if (child != NULL)
129 {
130 return;
131 }
132
133 child = bamf_unity_webapps_tab_new (context, interest_id);
134 bamf_view_add_child (BAMF_VIEW (self), BAMF_VIEW (child));
135
136 // It's possible that the context had become lonely (i.e. no children) but not yet shut down.
137 // however, if we gain an interest we are always running and "mapped".
138 bamf_view_set_running (BAMF_VIEW (self), TRUE);
139 bamf_view_set_user_visible (BAMF_VIEW (self), TRUE);
140}
141
142static void
143bamf_unity_webapps_application_interest_vanished (UnityWebappsContext *context,
144 gint interest_id,
145 gpointer user_data)
146{
147 BamfUnityWebappsApplication *self;
148 BamfUnityWebappsTab *child;
149
150 self = (BamfUnityWebappsApplication *)user_data;
151
152 child = bamf_unity_webapps_application_find_child_by_interest (self, interest_id);
153
154 if (child == NULL)
155 {
156 return;
157 }
158
159 bamf_view_remove_child (BAMF_VIEW (self), BAMF_VIEW (child));
160}
161
162/* It doesn't make any sense for a BamfUnityWebappsTab to live without it's assosciated context.
163 * so when our children are removed, dispose of them. */
164static void
165bamf_unity_webapps_application_child_removed (BamfView *view, BamfView *child)
166{
167 // Chain up first before we destroy the object.
168 BAMF_VIEW_CLASS (bamf_unity_webapps_application_parent_class)->child_removed (view, child);
169
170 bamf_view_set_running (child, FALSE);
171 bamf_view_close (BAMF_VIEW (child));
172}
173
174void
175bamf_unity_webapps_application_add_existing_interests (BamfUnityWebappsApplication *self)
176{
177 GVariant *interests, *interest_variant;
178 GVariantIter *variant_iter;
179
180 interests = unity_webapps_context_list_interests (self->priv->context);
181
182 if (interests == NULL)
183 {
184 return;
185 }
186
187 variant_iter = g_variant_iter_new (interests);
188
189 while ((interest_variant = g_variant_iter_next_value (variant_iter)))
190 {
191 gint interest_id;
192
193 interest_id = g_variant_get_int32 (interest_variant);
194
195 bamf_unity_webapps_application_interest_appeared (self->priv->context, interest_id, self);
196 }
197}
198
199static void
200bamf_unity_webapps_application_context_set (BamfUnityWebappsApplication *self)
201{
202 bamf_application_set_desktop_file_from_id (BAMF_APPLICATION (self),
203 unity_webapps_context_get_desktop_name (self->priv->context));
204
205 unity_webapps_context_on_interest_appeared (self->priv->context, bamf_unity_webapps_application_interest_appeared, self);
206 unity_webapps_context_on_interest_vanished (self->priv->context, bamf_unity_webapps_application_interest_vanished, self);
207}
208
209static void
210bamf_unity_webapps_application_set_property (GObject *object, guint property_id, const GValue *gvalue, GParamSpec *pspec)
211{
212 BamfUnityWebappsApplication *self;
213
214 self = BAMF_UNITY_WEBAPPS_APPLICATION (object);
215
216 switch (property_id)
217 {
218 case PROP_CONTEXT:
219 g_assert (self->priv->context == NULL);
220 self->priv->context = g_value_get_object (gvalue);
221
222 bamf_unity_webapps_application_context_set (self);
223 break;
224 default:
225 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
226 }
227}
228
229static gchar *
230bamf_unity_webapps_application_get_stable_bus_name (BamfView *view)
231{
232 const gchar *desktop_file;
233
234 desktop_file = bamf_application_get_desktop_file (BAMF_APPLICATION (view));
235
236 if (desktop_file)
237 {
238 return g_strdup_printf ("webapp/%i", abs (g_str_hash (desktop_file)));
239 }
240
241 return g_strdup_printf ("webapp/%p", view);
242}
243
244
245static void
246bamf_unity_webapps_application_finalize (GObject *object)
247{
248 BamfUnityWebappsApplication *self = BAMF_UNITY_WEBAPPS_APPLICATION (object);
249
250 g_object_unref (self->priv->context);
251
252 G_OBJECT_CLASS (bamf_unity_webapps_application_parent_class)->finalize (object);
253}
254
255static void
256on_accept_data_changed (UnityWebappsContext *context, const gchar **file, gpointer user_data)
257{
258 BamfUnityWebappsApplication *self = BAMF_UNITY_WEBAPPS_APPLICATION (user_data);
259
260 g_signal_emit_by_name (self, "supported-mimes-changed", file);
261}
262
263static void
264bamf_unity_webapps_application_constructed (GObject *object)
265{
266 BamfUnityWebappsApplication *self;
267
268 self = (BamfUnityWebappsApplication *)object;
269
270 g_signal_connect (self->priv->context, "accept-data-changed", G_CALLBACK (on_accept_data_changed), self);
271}
272
273
274static void
275bamf_unity_webapps_application_init (BamfUnityWebappsApplication *self)
276{
277 self->priv = BAMF_UNITY_WEBAPPS_APPLICATION_GET_PRIVATE (self);
278
279 bamf_application_set_application_type (BAMF_APPLICATION (self), BAMF_APPLICATION_WEB);
280
281}
282
283static char **
284bamf_unity_webapps_application_get_supported_mime_types (BamfApplication *application)
285{
286 BamfUnityWebappsApplication *self = BAMF_UNITY_WEBAPPS_APPLICATION (application);
287
288 return unity_webapps_context_get_application_accept_data (self->priv->context);
289}
290
291static gboolean
292bamf_unity_webapps_application_get_close_when_empty (BamfApplication *application)
293{
294 // Sometimes we might have no children for a short period (for example, the page is reloading), in the case
295 // Unity Webapps will keep the context alive for a while. Allowing for new children to appear...before eventually
296 // shutting it down. So we use this flag to ensure BAMF will not shut us down prematurely.
297 return FALSE;
298}
299
300static void
301bamf_unity_webapps_application_class_init (BamfUnityWebappsApplicationClass * klass)
302{
303 GParamSpec *pspec;
304 GObjectClass *object_class = G_OBJECT_CLASS (klass);
305 BamfApplicationClass *bamf_application_class = BAMF_APPLICATION_CLASS (klass);
306 BamfViewClass *bamf_view_class = BAMF_VIEW_CLASS (klass);
307
308 object_class->get_property = bamf_unity_webapps_application_get_property;
309 object_class->set_property = bamf_unity_webapps_application_set_property;
310 object_class->finalize = bamf_unity_webapps_application_finalize;
311 object_class->constructed = bamf_unity_webapps_application_constructed;
312
313 bamf_view_class->stable_bus_name = bamf_unity_webapps_application_get_stable_bus_name;
314 bamf_view_class->child_removed = bamf_unity_webapps_application_child_removed;
315
316 bamf_application_class->get_application_menu = bamf_unity_webapps_application_get_application_menu;
317 bamf_application_class->get_focusable_child = bamf_unity_webapps_application_get_focusable_child;
318 bamf_application_class->get_supported_mime_types = bamf_unity_webapps_application_get_supported_mime_types;
319 bamf_application_class->get_close_when_empty = bamf_unity_webapps_application_get_close_when_empty;
320
321 pspec = g_param_spec_object("context", "Context", "The Unity Webapps Context assosciated with the Application",
322 UNITY_WEBAPPS_TYPE_CONTEXT, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
323 g_object_class_install_property (object_class, PROP_CONTEXT, pspec);
324
325 g_type_class_add_private (klass, sizeof (BamfUnityWebappsApplicationPrivate));
326}
327
328
329BamfApplication *
330bamf_unity_webapps_application_new (UnityWebappsContext *context)
331{
332 return (BamfApplication *)g_object_new (BAMF_TYPE_UNITY_WEBAPPS_APPLICATION, "context", context, NULL);
333}
334
335UnityWebappsContext *
336bamf_unity_webapps_application_get_context (BamfUnityWebappsApplication *application)
337{
338 return application->priv->context;
339}
3400
=== removed file 'src/bamf-unity-webapps-application.h'
--- src/bamf-unity-webapps-application.h 2012-08-21 22:01:48 +0000
+++ src/bamf-unity-webapps-application.h 1970-01-01 00:00:00 +0000
@@ -1,63 +0,0 @@
1/*
2 * Copyright (C) 2010-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 * MERCHANAPPLICATIONILITY 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: Jason Smith <jason.smith@canonical.com>
17 * Marco Trevisan (Treviño) <3v1n0@ubuntu.com>
18 *
19 */
20
21#ifndef __BAMF_UNITY_WEBAPPS_APPLICATION_H__
22#define __BAMF_UNITY_WEBAPPS_APPLICATION_H__
23
24#include <unity-webapps-context.h>
25
26#include "bamf-application.h"
27
28
29#define BAMF_TYPE_UNITY_WEBAPPS_APPLICATION (bamf_unity_webapps_application_get_type ())
30#define BAMF_UNITY_WEBAPPS_APPLICATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BAMF_TYPE_UNITY_WEBAPPS_APPLICATION, BamfUnityWebappsApplication))
31#define BAMF_IS_UNITY_WEBAPPS_APPLICATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BAMF_TYPE_UNITY_WEBAPPS_APPLICATION))
32#define BAMF_UNITY_WEBAPPS_APPLICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BAMF_TYPE_UNITY_WEBAPPS_APPLICATION, BamfUnityWebappsApplicationClass))
33#define BAMF_IS_UNITY_WEBAPPS_APPLICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BAMF_TYPE_UNITY_WEBAPPS_APPLICATION))
34#define BAMF_UNITY_WEBAPPS_APPLICATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BAMF_TYPE_UNITY_WEBAPPS_APPLICATION, BamfUnityWebappsUnityWebappsApplicationClass))
35
36typedef struct _BamfUnityWebappsApplication BamfUnityWebappsApplication;
37typedef struct _BamfUnityWebappsApplicationClass BamfUnityWebappsApplicationClass;
38typedef struct _BamfUnityWebappsApplicationPrivate BamfUnityWebappsApplicationPrivate;
39
40struct _BamfUnityWebappsApplicationClass
41{
42 BamfApplicationClass parent;
43};
44
45struct _BamfUnityWebappsApplication
46{
47 BamfApplication parent;
48
49 /* private */
50 BamfUnityWebappsApplicationPrivate *priv;
51};
52
53GType bamf_unity_webapps_application_get_type (void) G_GNUC_CONST;
54
55BamfApplication *bamf_unity_webapps_application_new (UnityWebappsContext *context);
56UnityWebappsContext *bamf_unity_webapps_application_get_context (BamfUnityWebappsApplication *application);
57
58void
59bamf_unity_webapps_application_add_existing_interests (BamfUnityWebappsApplication *self);
60
61
62
63#endif
640
=== removed file 'src/bamf-unity-webapps-observer.c'
--- src/bamf-unity-webapps-observer.c 2013-07-30 23:56:55 +0000
+++ src/bamf-unity-webapps-observer.c 1970-01-01 00:00:00 +0000
@@ -1,278 +0,0 @@
1/*
2 * bamf-unity-webapps-observer.c
3 * Copyright (C) Canonical LTD 2012
4 *
5 * Author: Robert Carr <racarr@canonical.com>
6 *
7 * This program is free software: you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as published
9 * by the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * unity-webapps is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15 * See the GNU Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.";
19 */
20
21#include "bamf-unity-webapps-tab.h"
22#include "bamf-unity-webapps-observer.h"
23#include "bamf-unity-webapps-application.h"
24#include "bamf-matcher.h"
25
26struct _BamfUnityWebappsObserverPrivate {
27 UnityWebappsService *service;
28
29 GHashTable *applications_by_context_name;
30
31 guint service_watch_id;
32};
33
34G_DEFINE_TYPE(BamfUnityWebappsObserver, bamf_unity_webapps_observer, G_TYPE_OBJECT)
35
36enum
37{
38 APPLICATION_APPEARED,
39 LAST_SIGNAL
40};
41
42static guint webapps_observer_signals[LAST_SIGNAL] = { 0 };
43
44
45#define BAMF_UNITY_WEBAPPS_OBSERVER_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), BAMF_TYPE_UNITY_WEBAPPS_OBSERVER, BamfUnityWebappsObserverPrivate))
46
47static void
48bamf_unity_webapps_observer_context_vanished (UnityWebappsService *service,
49 const gchar *name,
50 gpointer user_data)
51{
52 BamfUnityWebappsObserver *observer;
53 BamfApplication *application;
54
55 observer = (BamfUnityWebappsObserver *)user_data;
56
57 application = g_hash_table_lookup (observer->priv->applications_by_context_name, name);
58
59 if (application == NULL)
60 return;
61
62 bamf_view_set_running (BAMF_VIEW (application), FALSE);
63 bamf_view_close (BAMF_VIEW (application));
64
65 g_hash_table_remove (observer->priv->applications_by_context_name, name);
66
67}
68
69static void
70bamf_unity_webapps_application_closed (BamfView *view,
71 gpointer user_data)
72{
73 BamfUnityWebappsObserver *observer;
74 BamfUnityWebappsApplication *application;
75 UnityWebappsContext *context;
76 const gchar *context_name;
77
78 observer = (BamfUnityWebappsObserver *)user_data;
79
80 application = BAMF_UNITY_WEBAPPS_APPLICATION (view);
81
82 context = bamf_unity_webapps_application_get_context (application);
83 context_name = unity_webapps_context_get_context_name (context);
84
85 g_hash_table_remove (observer->priv->applications_by_context_name, context_name);
86}
87
88static void
89bamf_unity_webapps_observer_context_appeared (UnityWebappsService *service,
90 const gchar *name,
91 gpointer user_data)
92{
93 BamfUnityWebappsObserver *observer;
94 UnityWebappsContext *context;
95 BamfApplication *application;
96
97 if (name == NULL || name[0] == '\0')
98 return;
99
100 observer = (BamfUnityWebappsObserver *)user_data;
101
102 if (g_hash_table_lookup (observer->priv->applications_by_context_name, name) != NULL)
103 return;
104
105 context = unity_webapps_context_new_for_context_name (observer->priv->service, name);
106
107 application = bamf_unity_webapps_application_new (context);
108
109 g_signal_connect (G_OBJECT (application), "closed-internal", G_CALLBACK (bamf_unity_webapps_application_closed),
110 observer);
111
112 g_hash_table_insert (observer->priv->applications_by_context_name, g_strdup (name), application);
113
114 g_signal_emit (observer, webapps_observer_signals[APPLICATION_APPEARED], 0, application);
115}
116
117static void
118bamf_unity_webapps_observer_register_existing_contexts (BamfUnityWebappsObserver *observer,
119 UnityWebappsService *service)
120{
121 gchar **contexts;
122 gint i, len;
123
124 contexts = unity_webapps_service_list_contexts (service);
125
126 if (contexts == NULL)
127 return;
128
129 len = g_strv_length (contexts);
130
131 if (len == 0)
132 return;
133
134 for (i = 0; i < len; i++)
135 {
136 bamf_unity_webapps_observer_context_appeared (service, contexts[i], observer);
137 }
138
139 g_strfreev (contexts);
140}
141
142static void
143bamf_unity_webapps_observer_service_appeared (GDBusConnection *connection,
144 const gchar *name,
145 const gchar *name_owner,
146 gpointer user_data)
147{
148 BamfUnityWebappsObserver *observer;
149
150 observer = (BamfUnityWebappsObserver *)user_data;
151
152 observer->priv->service = unity_webapps_service_new ();
153
154 unity_webapps_service_on_context_appeared (observer->priv->service, bamf_unity_webapps_observer_context_appeared, observer);
155 unity_webapps_service_on_context_vanished (observer->priv->service, bamf_unity_webapps_observer_context_vanished, observer);
156
157 bamf_unity_webapps_observer_register_existing_contexts (observer, observer->priv->service);
158}
159
160static void
161bamf_unity_webapps_observer_close_all (BamfUnityWebappsObserver *observer)
162{
163 GList *names, *walk;
164
165 names = g_hash_table_get_keys (observer->priv->applications_by_context_name);
166
167 for (walk = names; walk != NULL; walk = walk->next)
168 {
169 bamf_unity_webapps_observer_context_vanished (observer->priv->service, (const gchar *)walk->data,
170 observer);
171 }
172
173 g_list_free (names);
174
175
176}
177
178static void
179bamf_unity_webapps_observer_service_vanished (GDBusConnection *connection,
180 const gchar *name,
181 gpointer user_data)
182{
183 BamfUnityWebappsObserver *observer;
184 observer = (BamfUnityWebappsObserver *)user_data;
185
186 if (observer->priv->service == NULL)
187 {
188 return;
189 }
190
191 bamf_unity_webapps_observer_close_all (observer);
192
193 g_object_unref (G_OBJECT (observer->priv->service));
194 observer->priv->service = NULL;
195}
196
197static void
198bamf_unity_webapps_observer_finalize (GObject *object)
199{
200 BamfUnityWebappsObserver *observer;
201
202 observer = BAMF_UNITY_WEBAPPS_OBSERVER (object);
203
204 g_hash_table_destroy (observer->priv->applications_by_context_name);
205
206 if (observer->priv->service_watch_id)
207 {
208 g_bus_unwatch_name (observer->priv->service_watch_id);
209 }
210
211 if (observer->priv->service)
212 {
213 g_object_unref (G_OBJECT (observer->priv->service));
214 }
215
216 G_OBJECT_CLASS (bamf_unity_webapps_observer_parent_class)->finalize (object);
217}
218
219static void
220bamf_unity_webapps_observer_constructed (GObject *object)
221{
222 BamfUnityWebappsObserver *observer;
223
224 observer = (BamfUnityWebappsObserver *)object;
225 if (G_OBJECT_CLASS (bamf_unity_webapps_observer_parent_class)->constructed)
226 {
227 G_OBJECT_CLASS (bamf_unity_webapps_observer_parent_class)->constructed (object);
228 }
229
230 if (g_strcmp0 (g_getenv ("BAMF_TEST_MODE"), "TRUE") == 0)
231 return;
232
233 observer->priv->service_watch_id = g_bus_watch_name (G_BUS_TYPE_SESSION,
234 "com.canonical.Unity.Webapps.Service",
235 G_BUS_NAME_WATCHER_FLAGS_NONE,
236 bamf_unity_webapps_observer_service_appeared,
237 bamf_unity_webapps_observer_service_vanished,
238 observer, NULL /* User data free func */);
239
240}
241
242static void
243bamf_unity_webapps_observer_class_init (BamfUnityWebappsObserverClass *klass)
244{
245 GObjectClass *object_class = G_OBJECT_CLASS (klass);
246
247 object_class->finalize = bamf_unity_webapps_observer_finalize;
248 object_class->constructed = bamf_unity_webapps_observer_constructed;
249
250 g_type_class_add_private (object_class, sizeof(BamfUnityWebappsObserverPrivate));
251
252 webapps_observer_signals [APPLICATION_APPEARED] =
253 g_signal_new ("application-appeared",
254 G_OBJECT_CLASS_TYPE (klass),
255 0, 0, NULL, NULL, NULL,
256 G_TYPE_NONE, 1,
257 BAMF_TYPE_APPLICATION);
258}
259
260
261
262static void
263bamf_unity_webapps_observer_init (BamfUnityWebappsObserver *observer)
264{
265 observer->priv = BAMF_UNITY_WEBAPPS_OBSERVER_GET_PRIVATE (observer);
266
267 observer->priv->service = NULL;
268
269 observer->priv->applications_by_context_name = g_hash_table_new_full (g_str_hash, g_str_equal,
270 g_free, NULL);
271}
272
273BamfUnityWebappsObserver *
274bamf_unity_webapps_observer_new ()
275{
276 return g_object_new (BAMF_TYPE_UNITY_WEBAPPS_OBSERVER, NULL);
277}
278
2790
=== removed file 'src/bamf-unity-webapps-observer.h'
--- src/bamf-unity-webapps-observer.h 2013-06-13 17:08:07 +0000
+++ src/bamf-unity-webapps-observer.h 1970-01-01 00:00:00 +0000
@@ -1,54 +0,0 @@
1/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
2/*
3 * bamf-unity-webapps-observer.h
4 * Copyright (C) Canonical LTD 2011
5 *
6 * Author: Robert Carr <racarr@canonical.com>
7 *
8 * This program is free software: you can redistribute it and/or modify it
9 * under the terms of the GNU Lesser General Public License as published
10 * by the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * unity-webapps is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16 * See the GNU Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.";
20 */
21
22
23#ifndef __BAMF_UNITY_WEBAPPS_OBSERVER_H
24#define __BAMF_UNITY_WEBAPPS_OBSERVER_H
25
26
27#define BAMF_TYPE_UNITY_WEBAPPS_OBSERVER (bamf_unity_webapps_observer_get_type())
28#define BAMF_UNITY_WEBAPPS_OBSERVER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), BAMF_TYPE_UNITY_WEBAPPS_OBSERVER, BamfUnityWebappsObserver))
29#define BAMF_UNITY_WEBAPPS_OBSERVER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), BAMF_TYPE_UNITY_WEBAPPS_OBSERVER, BamfUnityWebappsObserverClass))
30#define BAMF_IS_UNITY_WEBAPPS_OBSERVER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), BAMF_TYPE_UNITY_WEBAPPS_OBSERVER))
31#define BAMF_IS_UNITY_WEBAPPS_OBSERVER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BAMF_TYPE_UNITY_WEBAPPS_OBSERVER))
32#define BAMF_UNITY_WEBAPPS_OBSERVER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), BAMF_TYPE_UNITY_WEBAPPS_OBSERVER, BamfUnityWebappsObserverClass))
33
34typedef struct _BamfUnityWebappsObserverPrivate BamfUnityWebappsObserverPrivate;
35typedef struct _BamfUnityWebappsObserverClass BamfUnityWebappsObserverClass;
36typedef struct _BamfUnityWebappsObserver BamfUnityWebappsObserver;
37
38
39struct _BamfUnityWebappsObserver {
40 GObject object;
41
42 BamfUnityWebappsObserverPrivate *priv;
43};
44
45
46struct _BamfUnityWebappsObserverClass {
47 GObjectClass parent_class;
48};
49
50GType bamf_unity_webapps_observer_get_type (void) G_GNUC_CONST;
51
52BamfUnityWebappsObserver *bamf_unity_webapps_observer_new ();
53
54#endif
550
=== removed file 'src/bamf-unity-webapps-tab.c'
--- src/bamf-unity-webapps-tab.c 2013-06-13 18:40:56 +0000
+++ src/bamf-unity-webapps-tab.c 1970-01-01 00:00:00 +0000
@@ -1,427 +0,0 @@
1/*
2 * Copyright (C) 2010-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:
17 * Robert Carr <racarr@canonical.com>
18 *
19 */
20
21#include "bamf-unity-webapps-tab.h"
22#include "bamf-matcher.h"
23
24#include "bamf-legacy-window.h"
25#include "bamf-legacy-screen.h"
26
27#include <unity-webapps-service.h>
28#include <unity-webapps-context.h>
29
30#define BAMF_UNITY_WEBAPPS_TAB_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE(obj, \
31BAMF_TYPE_UNITY_WEBAPPS_TAB, BamfUnityWebappsTabPrivate))
32
33G_DEFINE_TYPE(BamfUnityWebappsTab, bamf_unity_webapps_tab, BAMF_TYPE_TAB);
34
35enum
36{
37 PROP_0,
38 PROP_CONTEXT,
39 PROP_INTEREST_ID
40};
41
42struct _BamfUnityWebappsTabPrivate
43{
44 UnityWebappsContext *context;
45 BamfLegacyWindow *legacy_window;
46 gint interest_id;
47 gboolean tab_active;
48};
49
50static void
51bamf_unity_webapps_tab_ensure_flags (BamfUnityWebappsTab *self)
52{
53 gboolean window_active;
54
55 // If we don't have a toplevel window assosciated with UnityWebappsContext
56 // determine if it's active. Safer to go with no.
57 if (self->priv->legacy_window == NULL)
58 {
59 bamf_view_set_active (BAMF_VIEW (self), FALSE);
60 return;
61 }
62
63 window_active = bamf_legacy_window_is_active (self->priv->legacy_window);
64
65 bamf_view_set_active (BAMF_VIEW (self), window_active && self->priv->tab_active);
66}
67
68static void
69bamf_unity_webapps_tab_active_window_changed (BamfLegacyScreen *screen, BamfUnityWebappsTab *tab)
70{
71 bamf_unity_webapps_tab_ensure_flags (tab);
72}
73
74static void
75on_window_closed (BamfLegacyWindow *window, gpointer data)
76{
77 BamfUnityWebappsTab *self = data;
78
79 g_signal_handlers_disconnect_by_data (self->priv->legacy_window, self);
80 self->priv->legacy_window = NULL;
81}
82
83static void
84bamf_unity_webapps_tab_set_bamf_window (BamfUnityWebappsTab *self, gulong xid)
85{
86 GList *l;
87 BamfLegacyScreen *screen;
88
89 if (xid == 0)
90 return;
91
92 if (self->priv->legacy_window != NULL)
93 {
94 if (bamf_legacy_window_get_xid (self->priv->legacy_window) == xid)
95 return;
96
97 g_signal_handlers_disconnect_by_data (self->priv->legacy_window, self);
98 self->priv->legacy_window = NULL;
99 }
100
101 screen = bamf_legacy_screen_get_default ();
102
103 for (l = bamf_legacy_screen_get_windows (screen); l; l = l->next)
104 {
105 if (!BAMF_IS_LEGACY_WINDOW (l->data))
106 continue;
107
108 if (bamf_legacy_window_get_xid (BAMF_LEGACY_WINDOW (l->data)) == xid)
109 {
110 self->priv->legacy_window = l->data;
111 g_signal_connect (self->priv->legacy_window, "closed", (GCallback) on_window_closed, self);
112 break;
113 }
114 }
115}
116
117static void
118bamf_unity_webapps_tab_location_changed (UnityWebappsContext *context,
119 gint interest_id,
120 const gchar *location,
121 gpointer user_data)
122{
123 BamfUnityWebappsTab *self;
124
125 self = (BamfUnityWebappsTab *)user_data;
126
127 if ((self->priv->interest_id != interest_id) || (self->priv->interest_id == -1))
128 {
129 return;
130 }
131
132 g_object_set (self, "location", location, NULL);
133}
134
135static void
136bamf_unity_webapps_tab_window_changed (UnityWebappsContext *context,
137 gint interest_id,
138 guint64 xid,
139 gpointer user_data)
140{
141 BamfUnityWebappsTab *self;
142
143 self = (BamfUnityWebappsTab *)user_data;
144
145 if ((self->priv->interest_id != interest_id) || (self->priv->interest_id == -1))
146 {
147 return;
148 }
149
150 g_object_set (self, "xid", xid, NULL);
151
152 bamf_unity_webapps_tab_set_bamf_window (self, xid);
153 bamf_unity_webapps_tab_ensure_flags (self);
154}
155
156/*
157 * The activity signal from unity-webapps signifies the visibility of the tab WITHIN its toplevel XID.
158 * we have to mask this with window activity.
159 */
160static void
161bamf_unity_webapps_tab_active_changed (UnityWebappsContext *context,
162 gint interest_id,
163 gboolean is_active,
164 gpointer user_data)
165{
166 BamfUnityWebappsTab *self;
167
168 self = (BamfUnityWebappsTab *)user_data;
169
170 if ((self->priv->interest_id != interest_id) || (self->priv->interest_id == -1))
171 {
172 return;
173 }
174
175 self->priv->tab_active = is_active;
176 bamf_unity_webapps_tab_ensure_flags (self);
177
178 g_object_set (G_OBJECT (self), "is-foreground-tab", is_active, NULL);
179}
180
181static void
182bamf_unity_webapps_tab_initialize_properties (BamfUnityWebappsTab *self)
183{
184 gchar *location;
185 guint64 xid;
186 gboolean is_active;
187
188 location = unity_webapps_context_get_view_location (self->priv->context, self->priv->interest_id);
189 xid = unity_webapps_context_get_view_window (self->priv->context, self->priv->interest_id);
190 is_active = unity_webapps_context_get_view_is_active (self->priv->context, self->priv->interest_id);
191
192 g_object_set (self, "location", location, "xid", xid, "is-foreground-tab", is_active, NULL);
193
194 self->priv->tab_active = is_active;
195 bamf_unity_webapps_tab_set_bamf_window (self, xid);
196 bamf_unity_webapps_tab_ensure_flags (self);
197
198 g_free (location);
199}
200
201
202static void
203bamf_unity_webapps_tab_interest_id_set (BamfUnityWebappsTab *self)
204{
205 unity_webapps_context_on_view_location_changed (self->priv->context, bamf_unity_webapps_tab_location_changed,
206 self);
207 unity_webapps_context_on_view_window_changed (self->priv->context, bamf_unity_webapps_tab_window_changed,
208 self);
209 unity_webapps_context_on_view_is_active_changed (self->priv->context, bamf_unity_webapps_tab_active_changed,
210 self);
211
212 bamf_unity_webapps_tab_initialize_properties (self);
213
214 bamf_view_set_running (BAMF_VIEW (self), TRUE);
215
216 // We don't really use user_visible here, it's not clear to me if we should or not. Maybe it could be used in stead of the internal
217 // tab is active flag...this would let Unity do the masking. Current behavior works well for the current way the pips are specced though.
218 bamf_view_set_user_visible (BAMF_VIEW (self), TRUE);
219}
220
221
222static void
223bamf_unity_webapps_tab_get_property (GObject *object, guint property_id, GValue *gvalue, GParamSpec *pspec)
224{
225 BamfUnityWebappsTab *self;
226
227 self = BAMF_UNITY_WEBAPPS_TAB (object);
228
229 switch (property_id)
230 {
231 case PROP_CONTEXT:
232 g_value_set_object (gvalue, self->priv->context);
233 break;
234 case PROP_INTEREST_ID:
235 g_value_set_int (gvalue, self->priv->interest_id);
236 break;
237 default:
238 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
239 }
240}
241
242static void
243bamf_unity_webapps_tab_set_property (GObject *object, guint property_id, const GValue *gvalue, GParamSpec *pspec)
244{
245 BamfUnityWebappsTab *self;
246
247 self = BAMF_UNITY_WEBAPPS_TAB (object);
248
249 switch (property_id)
250 {
251 case PROP_CONTEXT:
252 g_assert (self->priv->context == NULL);
253 self->priv->context = g_value_get_object (gvalue);
254 self->priv->context = unity_webapps_context_new_for_context_name (unity_webapps_context_get_service (self->priv->context),
255 unity_webapps_context_get_context_name (self->priv->context));
256 break;
257 case PROP_INTEREST_ID:
258 g_assert (self->priv->interest_id == 0);
259 self->priv->interest_id = g_value_get_int (gvalue);
260 bamf_unity_webapps_tab_interest_id_set (self);
261 break;
262 default:
263 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
264 }
265}
266
267
268static void
269bamf_unity_webapps_tab_dispose (GObject *object)
270{
271 BamfUnityWebappsTab *self = BAMF_UNITY_WEBAPPS_TAB (object);
272
273 g_signal_handlers_disconnect_by_data (bamf_legacy_screen_get_default (), self);
274
275 if (self->priv->legacy_window)
276 {
277 g_signal_handlers_disconnect_by_data (self->priv->legacy_window, self);
278 self->priv->legacy_window = NULL;
279 }
280
281 G_OBJECT_CLASS (bamf_unity_webapps_tab_parent_class)->dispose (object);
282}
283
284static void
285bamf_unity_webapps_tab_finalize (GObject *object)
286{
287 BamfUnityWebappsTab *self = BAMF_UNITY_WEBAPPS_TAB (object);
288
289 g_object_unref (G_OBJECT (self->priv->context));
290
291 G_OBJECT_CLASS (bamf_unity_webapps_tab_parent_class)->finalize (object);
292}
293
294static void
295bamf_unity_webapps_tab_init (BamfUnityWebappsTab *self)
296{
297 self->priv = BAMF_UNITY_WEBAPPS_TAB_GET_PRIVATE (self);
298
299 self->priv->tab_active = FALSE;
300 self->priv->legacy_window = NULL;
301
302 g_signal_connect (G_OBJECT (bamf_legacy_screen_get_default ()), "active-window-changed",
303 (GCallback) bamf_unity_webapps_tab_active_window_changed, self);
304
305}
306
307static void
308bamf_unity_webapps_tab_raise (BamfTab *tab)
309{
310 BamfUnityWebappsTab *self = BAMF_UNITY_WEBAPPS_TAB (tab);
311
312 if (self->priv->interest_id == -1)
313 {
314 return;
315 }
316
317 unity_webapps_context_raise_interest (self->priv->context, self->priv->interest_id);
318}
319
320static void
321bamf_unity_webapps_tab_close (BamfTab *tab)
322{
323 BamfUnityWebappsTab *self = BAMF_UNITY_WEBAPPS_TAB (tab);
324
325 if (self->priv->interest_id == -1)
326 {
327 return;
328 }
329
330 unity_webapps_context_close_interest (self->priv->context, self->priv->interest_id);
331}
332
333typedef struct _bamf_unity_webapps_preview_data {
334 BamfUnityWebappsTab *tab;
335 BamfTabPreviewReadyCallback callback;
336 gpointer user_data;
337} bamf_unity_webapps_preview_data;
338
339static void
340bamf_unity_webapps_tab_preview_ready (UnityWebappsContext *context,
341 gint interest_id,
342 const gchar *preview_data,
343 gpointer user_data)
344{
345 bamf_unity_webapps_preview_data *data;
346
347 data = (bamf_unity_webapps_preview_data *)user_data;
348
349 data->callback ((BamfTab *)data->tab, preview_data, data->user_data);
350
351 g_slice_free1 (sizeof (bamf_unity_webapps_preview_data), data);
352}
353
354static void
355bamf_unity_webapps_tab_request_preview (BamfTab *tab,
356 BamfTabPreviewReadyCallback callback,
357 gpointer user_data)
358{
359 BamfUnityWebappsTab *self;
360 bamf_unity_webapps_preview_data *data;
361
362 self = BAMF_UNITY_WEBAPPS_TAB (tab);
363
364 data = g_slice_alloc0 (sizeof (bamf_unity_webapps_preview_data));
365
366 data->tab = self;
367 data->callback = callback;
368 data->user_data = user_data;
369
370 unity_webapps_context_request_preview (self->priv->context,
371 self->priv->interest_id,
372 bamf_unity_webapps_tab_preview_ready,
373 data);
374
375}
376
377static void
378bamf_unity_webapps_tab_class_init (BamfUnityWebappsTabClass * klass)
379{
380 GParamSpec *pspec;
381 GObjectClass *object_class = G_OBJECT_CLASS (klass);
382 BamfTabClass *bamf_tab_class = BAMF_TAB_CLASS (klass);
383
384 object_class->get_property = bamf_unity_webapps_tab_get_property;
385 object_class->set_property = bamf_unity_webapps_tab_set_property;
386 object_class->dispose = bamf_unity_webapps_tab_dispose;
387 object_class->finalize = bamf_unity_webapps_tab_finalize;
388
389 bamf_tab_class->raise = bamf_unity_webapps_tab_raise;
390 bamf_tab_class->close = bamf_unity_webapps_tab_close;
391 bamf_tab_class->request_preview = bamf_unity_webapps_tab_request_preview;
392
393 pspec = g_param_spec_object("context", "Context", "The Unity Webapps Context assosciated with the Tab",
394 UNITY_WEBAPPS_TYPE_CONTEXT, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
395 g_object_class_install_property (object_class, PROP_CONTEXT, pspec);
396
397 pspec = g_param_spec_int("interest-id", "Interest ID", "The Interest ID (unique to Context) for this Tab",
398 G_MININT, G_MAXINT, -1, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
399 g_object_class_install_property (object_class, PROP_INTEREST_ID, pspec);
400
401 g_type_class_add_private (klass, sizeof (BamfUnityWebappsTabPrivate));
402}
403
404
405gint
406bamf_unity_webapps_tab_get_interest_id (BamfUnityWebappsTab *tab)
407{
408 g_return_val_if_fail(tab != NULL, -1);
409 g_return_val_if_fail(BAMF_IS_UNITY_WEBAPPS_TAB(tab), -1);
410 return tab->priv->interest_id;
411}
412
413BamfLegacyWindow*
414bamf_unity_webapps_tab_get_legacy_window_for (BamfUnityWebappsTab *tab)
415{
416 g_return_val_if_fail(tab != NULL, NULL);
417 g_return_val_if_fail(BAMF_IS_UNITY_WEBAPPS_TAB(tab), NULL);
418 return tab->priv->legacy_window;
419}
420
421BamfUnityWebappsTab *
422bamf_unity_webapps_tab_new (UnityWebappsContext *context, gint interest_id)
423{
424 return (BamfUnityWebappsTab *)g_object_new (BAMF_TYPE_UNITY_WEBAPPS_TAB, "context", context, "interest-id", interest_id, NULL);
425}
426
427
4280
=== removed file 'src/bamf-unity-webapps-tab.h'
--- src/bamf-unity-webapps-tab.h 2013-02-21 15:27:58 +0000
+++ src/bamf-unity-webapps-tab.h 1970-01-01 00:00:00 +0000
@@ -1,62 +0,0 @@
1/*
2 * Copyright (C) 2010-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: Jason Smith <jason.smith@canonical.com>
17 * Marco Trevisan (Treviño) <3v1n0@ubuntu.com>
18 *
19 */
20
21#ifndef __BAMF_UNITY_WEBAPPS_TAB_H__
22#define __BAMF_UNITY_WEBAPPS_TAB_H__
23
24#include <unity-webapps-context.h>
25
26#include "bamf-legacy-window.h"
27#include "bamf-tab.h"
28
29
30#define BAMF_TYPE_UNITY_WEBAPPS_TAB (bamf_unity_webapps_tab_get_type ())
31#define BAMF_UNITY_WEBAPPS_TAB(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BAMF_TYPE_UNITY_WEBAPPS_TAB, BamfUnityWebappsTab))
32#define BAMF_IS_UNITY_WEBAPPS_TAB(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BAMF_TYPE_UNITY_WEBAPPS_TAB))
33#define BAMF_UNITY_WEBAPPS_TAB_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BAMF_TYPE_UNITY_WEBAPPS_TAB, BamfUnityWebappsTabClass))
34#define BAMF_IS_UNITY_WEBAPPS_TAB_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BAMF_TYPE_UNITY_WEBAPPS_TAB))
35#define BAMF_UNITY_WEBAPPS_TAB_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BAMF_TYPE_UNITY_WEBAPPS_TAB, BamfUnityWebappsUnityWebappsTabClass))
36
37typedef struct _BamfUnityWebappsTab BamfUnityWebappsTab;
38typedef struct _BamfUnityWebappsTabClass BamfUnityWebappsTabClass;
39typedef struct _BamfUnityWebappsTabPrivate BamfUnityWebappsTabPrivate;
40
41struct _BamfUnityWebappsTabClass
42{
43 BamfTabClass parent;
44};
45
46struct _BamfUnityWebappsTab
47{
48 BamfTab parent;
49
50 /* private */
51 BamfUnityWebappsTabPrivate *priv;
52};
53
54GType bamf_unity_webapps_tab_get_type (void) G_GNUC_CONST;
55
56BamfUnityWebappsTab *bamf_unity_webapps_tab_new (UnityWebappsContext *context, gint interest_id);
57
58gint bamf_unity_webapps_tab_get_interest_id (BamfUnityWebappsTab *tab);
59BamfLegacyWindow* bamf_unity_webapps_tab_get_legacy_window_for(BamfUnityWebappsTab *tab);
60
61
62#endif
630
=== modified file 'tests/bamfdaemon/Makefile.am'
--- tests/bamfdaemon/Makefile.am 2013-06-13 22:19:56 +0000
+++ tests/bamfdaemon/Makefile.am 2014-04-08 14:38:15 +0000
@@ -30,12 +30,6 @@
30 $(top_srcdir)/src/bamf-xutils.h \30 $(top_srcdir)/src/bamf-xutils.h \
31 $(NULL)31 $(NULL)
3232
33bamf_test_webapps_sources = \
34 $(top_srcdir)/src/bamf-unity-webapps-tab.c \
35 $(top_srcdir)/src/bamf-unity-webapps-observer.c \
36 $(top_srcdir)/src/bamf-unity-webapps-application.c \
37 $(NULL)
38
39test_bamf_SOURCES = \33test_bamf_SOURCES = \
40 $(bamf_test_extra_sources) \34 $(bamf_test_extra_sources) \
41 $(bamf_test_extra_headers) \35 $(bamf_test_extra_headers) \
@@ -45,12 +39,6 @@
45 test-window.c \39 test-window.c \
46 test-matcher.c40 test-matcher.c
4741
48if HAVE_WEBAPPS
49test_bamf_SOURCES += \
50 $(bamf_test_webapps_sources) \
51 $(NULL)
52endif
53
54test_bamf_CFLAGS = \42test_bamf_CFLAGS = \
55 -I$(top_srcdir)/src \43 -I$(top_srcdir)/src \
56 -I$(top_srcdir)/lib \44 -I$(top_srcdir)/lib \
@@ -62,7 +50,6 @@
62 $(GLIB_CFLAGS) \50 $(GLIB_CFLAGS) \
63 $(GTK_CFLAGS) \51 $(GTK_CFLAGS) \
64 $(GTOP_CFLAGS) \52 $(GTOP_CFLAGS) \
65 $(LIBUNITY_WEBAPPS_CFLAGS) \
66 $(MAINTAINER_CFLAGS) \53 $(MAINTAINER_CFLAGS) \
67 $(WNCK_CFLAGS) \54 $(WNCK_CFLAGS) \
68 $(X_CFLAGS) \55 $(X_CFLAGS) \
@@ -73,7 +60,6 @@
73 $(GLIB_LIBS) \60 $(GLIB_LIBS) \
74 $(GTK_LIBS) \61 $(GTK_LIBS) \
75 $(GTOP_LIBS) \62 $(GTOP_LIBS) \
76 $(LIBUNITY_WEBAPPS_LIBS) \
77 $(WNCK_LIBS) \63 $(WNCK_LIBS) \
78 $(X_LIBS) \64 $(X_LIBS) \
79 $(NULL)65 $(NULL)

Subscribers

People subscribed via source and target branches

to all changes: