Merge lp:~3v1n0/bamf/create-local-desktop into lp:bamf
- create-local-desktop
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Christopher Townsend |
Approved revision: | 645 |
Merged at revision: | 572 |
Proposed branch: | lp:~3v1n0/bamf/create-local-desktop |
Merge into: | lp:bamf |
Diff against target: |
1319 lines (+731/-51) 23 files modified
debian/libbamf3-1.symbols (+1/-0) lib/libbamf-private/org.ayatana.bamf.view.xml (+3/-0) lib/libbamf-private/org.ayatana.bamf.xml (+8/-1) lib/libbamf/bamf-application.c (+21/-0) lib/libbamf/bamf-application.h (+3/-2) lib/libbamf/bamf-control.c (+31/-5) lib/libbamf/bamf-control.h (+4/-0) lib/libbamf/bamf-tab-source.c (+1/-1) src/bamf-application.c (+272/-2) src/bamf-application.h (+2/-0) src/bamf-control.c (+45/-8) src/bamf-control.h (+3/-0) src/bamf-legacy-window-test.c (+2/-2) src/bamf-legacy-window.c (+20/-17) src/bamf-legacy-window.h (+5/-3) src/bamf-matcher.c (+27/-2) src/bamf-matcher.h (+2/-0) src/bamf-tab.c (+2/-4) src/bamf-unity-webapps-application.c (+10/-1) src/bamf-unity-webapps-observer.c (+0/-1) tests/bamfdaemon/test-application.c (+220/-2) tests/bamfdaemon/test-bamf.c (+12/-0) tests/bamfdaemon/test-matcher.c (+37/-0) |
To merge this branch: | bzr merge lp:~3v1n0/bamf/create-local-desktop |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Christopher Townsend (community) | Approve | ||
PS Jenkins bot (community) | continuous-integration | Approve | |
Marco Trevisan (Treviño) | Pending | ||
Review via email: mp+178794@code.launchpad.net |
Commit message
BamfControl: add an API to allow generation of local .desktop file for a BamfApplication.
Add a bamf_control dbus method that requests to generate a new local .desktop
file for the provided application path. In case the application has alredy
a desktop file, the request is ignored. Otherwise we use some euristic to
generate an hopefully valid file saved in $XDG_DATA_HOME dir.
Also added a new DesktopUpdated signal to the BamfApplication DBus interface
that is emitted when the .desktop file for an application is set (for now).
Description of the change
Add a bamf_control dbus method that requests to generate a new local .desktop
file for the provided application path. In case the application has alredy
a desktop file, the request is ignored. Otherwise we use some euristic to
generate an hopefully valid file saved in $XDG_DATA_HOME dir.
Also added a new DesktopUpdated signal to the BamfApplication DBus interface
that is emitted when the .desktop file for an application is set (for now).
All the dbus changes have been reflected to the libbamf API.
New unit tests added.
PS Jenkins bot (ps-jenkins) wrote : | # |
- 645. By Marco Trevisan (Treviño)
-
debian: update libbamf3-1 symbols file
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:645
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Christopher Townsend (townsend) wrote : | # |
Merges and builds cleanly and all tests new and old pass. Code looks good.
I did not try the actual creating the desktop file since that is done by https:/
Preview Diff
1 | === modified file 'debian/libbamf3-1.symbols' | |||
2 | --- debian/libbamf3-1.symbols 2012-12-19 16:21:01 +0000 | |||
3 | +++ debian/libbamf3-1.symbols 2013-08-06 16:20:35 +0000 | |||
4 | @@ -10,6 +10,7 @@ | |||
5 | 10 | bamf_application_get_xids@Base 0.2.20 | 10 | bamf_application_get_xids@Base 0.2.20 |
6 | 11 | bamf_application_new@Base 0.2.20 | 11 | bamf_application_new@Base 0.2.20 |
7 | 12 | bamf_application_new_favorite@Base 0.2.60 | 12 | bamf_application_new_favorite@Base 0.2.60 |
8 | 13 | bamf_control_create_local_desktop_file@Base 0.5.0 | ||
9 | 13 | bamf_control_get_default@Base 0.2.20 | 14 | bamf_control_get_default@Base 0.2.20 |
10 | 14 | bamf_control_get_type@Base 0.2.20 | 15 | bamf_control_get_type@Base 0.2.20 |
11 | 15 | bamf_control_insert_desktop_file@Base 0.2.20 | 16 | bamf_control_insert_desktop_file@Base 0.2.20 |
12 | 16 | 17 | ||
13 | === modified file 'lib/libbamf-private/org.ayatana.bamf.view.xml' | |||
14 | --- lib/libbamf-private/org.ayatana.bamf.view.xml 2013-06-19 19:31:58 +0000 | |||
15 | +++ lib/libbamf-private/org.ayatana.bamf.view.xml 2013-08-06 16:20:35 +0000 | |||
16 | @@ -105,6 +105,9 @@ | |||
17 | 105 | <signal name="SupportedMimeTypesChanged"> | 105 | <signal name="SupportedMimeTypesChanged"> |
18 | 106 | <arg name="dnd_mimes" type="as"/> | 106 | <arg name="dnd_mimes" type="as"/> |
19 | 107 | </signal> | 107 | </signal> |
20 | 108 | <signal name="DesktopFileUpdated"> | ||
21 | 109 | <arg name="desktop_file" type="s"/> | ||
22 | 110 | </signal> | ||
23 | 108 | </interface> | 111 | </interface> |
24 | 109 | 112 | ||
25 | 110 | <interface name="org.ayatana.bamf.window"> | 113 | <interface name="org.ayatana.bamf.window"> |
26 | 111 | 114 | ||
27 | === modified file 'lib/libbamf-private/org.ayatana.bamf.xml' | |||
28 | --- lib/libbamf-private/org.ayatana.bamf.xml 2013-06-08 13:54:06 +0000 | |||
29 | +++ lib/libbamf-private/org.ayatana.bamf.xml 2013-08-06 16:20:35 +0000 | |||
30 | @@ -4,7 +4,7 @@ | |||
31 | 4 | <interface name="org.ayatana.bamf.control"> | 4 | <interface name="org.ayatana.bamf.control"> |
32 | 5 | <method name="Quit"> | 5 | <method name="Quit"> |
33 | 6 | </method> | 6 | </method> |
35 | 7 | <method name="OmNomNomDesktopFile"> | 7 | <method name="InsertDesktopFile"> |
36 | 8 | <arg name="tab_path" type="s" direction="in"/> | 8 | <arg name="tab_path" type="s" direction="in"/> |
37 | 9 | </method> | 9 | </method> |
38 | 10 | <method name="RegisterTabProvider"> | 10 | <method name="RegisterTabProvider"> |
39 | @@ -14,6 +14,13 @@ | |||
40 | 14 | <arg name="application" type="s" direction="in"/> | 14 | <arg name="application" type="s" direction="in"/> |
41 | 15 | <arg name="pid" type="i" direction="in"/> | 15 | <arg name="pid" type="i" direction="in"/> |
42 | 16 | </method> | 16 | </method> |
43 | 17 | <method name="CreateLocalDesktopFile"> | ||
44 | 18 | <arg name="application" type="s" direction="in"/> | ||
45 | 19 | </method> | ||
46 | 20 | <method name="OmNomNomDesktopFile"> | ||
47 | 21 | <annotation name="org.freedesktop.DBus.Deprecated" value="true"/> | ||
48 | 22 | <arg name="tab_path" type="s" direction="in"/> | ||
49 | 23 | </method> | ||
50 | 17 | </interface> | 24 | </interface> |
51 | 18 | 25 | ||
52 | 19 | <interface name="org.ayatana.bamf.matcher"> | 26 | <interface name="org.ayatana.bamf.matcher"> |
53 | 20 | 27 | ||
54 | === modified file 'lib/libbamf/bamf-application.c' | |||
55 | --- lib/libbamf/bamf-application.c 2013-07-20 14:57:45 +0000 | |||
56 | +++ lib/libbamf/bamf-application.c 2013-08-06 16:20:35 +0000 | |||
57 | @@ -52,6 +52,7 @@ | |||
58 | 52 | 52 | ||
59 | 53 | enum | 53 | enum |
60 | 54 | { | 54 | { |
61 | 55 | DESKTOP_FILE_UPDATED, | ||
62 | 55 | WINDOW_ADDED, | 56 | WINDOW_ADDED, |
63 | 56 | WINDOW_REMOVED, | 57 | WINDOW_REMOVED, |
64 | 57 | 58 | ||
65 | @@ -408,6 +409,15 @@ | |||
66 | 408 | } | 409 | } |
67 | 409 | 410 | ||
68 | 410 | static void | 411 | static void |
69 | 412 | bamf_application_on_desktop_file_updated (BamfDBusItemApplication *proxy, const char *desktop_file, BamfApplication *self) | ||
70 | 413 | { | ||
71 | 414 | g_free (self->priv->desktop_file); | ||
72 | 415 | self->priv->desktop_file = g_strdup (desktop_file); | ||
73 | 416 | |||
74 | 417 | g_signal_emit (self, application_signals[DESKTOP_FILE_UPDATED], 0, desktop_file); | ||
75 | 418 | } | ||
76 | 419 | |||
77 | 420 | static void | ||
78 | 411 | bamf_application_on_window_added (BamfDBusItemApplication *proxy, const char *path, BamfApplication *self) | 421 | bamf_application_on_window_added (BamfDBusItemApplication *proxy, const char *path, BamfApplication *self) |
79 | 412 | { | 422 | { |
80 | 413 | BamfView *view; | 423 | BamfView *view; |
81 | @@ -549,6 +559,9 @@ | |||
82 | 549 | 559 | ||
83 | 550 | g_dbus_proxy_set_default_timeout (G_DBUS_PROXY (priv->proxy), BAMF_DBUS_DEFAULT_TIMEOUT); | 560 | g_dbus_proxy_set_default_timeout (G_DBUS_PROXY (priv->proxy), BAMF_DBUS_DEFAULT_TIMEOUT); |
84 | 551 | 561 | ||
85 | 562 | g_signal_connect (priv->proxy, "desktop-file-updated", | ||
86 | 563 | G_CALLBACK (bamf_application_on_desktop_file_updated), view); | ||
87 | 564 | |||
88 | 552 | g_signal_connect (priv->proxy, "window-added", | 565 | g_signal_connect (priv->proxy, "window-added", |
89 | 553 | G_CALLBACK (bamf_application_on_window_added), view); | 566 | G_CALLBACK (bamf_application_on_window_added), view); |
90 | 554 | 567 | ||
91 | @@ -678,6 +691,14 @@ | |||
92 | 678 | 691 | ||
93 | 679 | g_type_class_add_private (obj_class, sizeof (BamfApplicationPrivate)); | 692 | g_type_class_add_private (obj_class, sizeof (BamfApplicationPrivate)); |
94 | 680 | 693 | ||
95 | 694 | application_signals [DESKTOP_FILE_UPDATED] = | ||
96 | 695 | g_signal_new (BAMF_APPLICATION_SIGNAL_DESKTOP_FILE_UPDATED, | ||
97 | 696 | G_OBJECT_CLASS_TYPE (klass), | ||
98 | 697 | 0, | ||
99 | 698 | 0, NULL, NULL, NULL, | ||
100 | 699 | G_TYPE_NONE, 1, | ||
101 | 700 | G_TYPE_STRING); | ||
102 | 701 | |||
103 | 681 | application_signals [WINDOW_ADDED] = | 702 | application_signals [WINDOW_ADDED] = |
104 | 682 | g_signal_new (BAMF_APPLICATION_SIGNAL_WINDOW_ADDED, | 703 | g_signal_new (BAMF_APPLICATION_SIGNAL_WINDOW_ADDED, |
105 | 683 | G_OBJECT_CLASS_TYPE (klass), | 704 | G_OBJECT_CLASS_TYPE (klass), |
106 | 684 | 705 | ||
107 | === modified file 'lib/libbamf/bamf-application.h' | |||
108 | --- lib/libbamf/bamf-application.h 2013-06-18 14:46:15 +0000 | |||
109 | +++ lib/libbamf/bamf-application.h 2013-08-06 16:20:35 +0000 | |||
110 | @@ -50,8 +50,9 @@ | |||
111 | 50 | #define BAMF_APPLICATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),\ | 50 | #define BAMF_APPLICATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),\ |
112 | 51 | BAMF_TYPE_APPLICATION, BamfApplicationClass)) | 51 | BAMF_TYPE_APPLICATION, BamfApplicationClass)) |
113 | 52 | 52 | ||
116 | 53 | #define BAMF_APPLICATION_SIGNAL_WINDOW_ADDED "window-added" | 53 | #define BAMF_APPLICATION_SIGNAL_DESKTOP_FILE_UPDATED "desktop-file-updated" |
117 | 54 | #define BAMF_APPLICATION_SIGNAL_WINDOW_REMOVED "window-removed" | 54 | #define BAMF_APPLICATION_SIGNAL_WINDOW_ADDED "window-added" |
118 | 55 | #define BAMF_APPLICATION_SIGNAL_WINDOW_REMOVED "window-removed" | ||
119 | 55 | 56 | ||
120 | 56 | typedef struct _BamfApplication BamfApplication; | 57 | typedef struct _BamfApplication BamfApplication; |
121 | 57 | typedef struct _BamfApplicationClass BamfApplicationClass; | 58 | typedef struct _BamfApplicationClass BamfApplicationClass; |
122 | 58 | 59 | ||
123 | === modified file 'lib/libbamf/bamf-control.c' | |||
124 | --- lib/libbamf/bamf-control.c 2013-06-08 13:54:06 +0000 | |||
125 | +++ lib/libbamf/bamf-control.c 2013-08-06 16:20:35 +0000 | |||
126 | @@ -37,6 +37,7 @@ | |||
127 | 37 | 37 | ||
128 | 38 | #include <libbamf-private/bamf-private.h> | 38 | #include <libbamf-private/bamf-private.h> |
129 | 39 | #include "bamf-control.h" | 39 | #include "bamf-control.h" |
130 | 40 | #include "bamf-view-private.h" | ||
131 | 40 | 41 | ||
132 | 41 | G_DEFINE_TYPE (BamfControl, bamf_control, G_TYPE_OBJECT); | 42 | G_DEFINE_TYPE (BamfControl, bamf_control, G_TYPE_OBJECT); |
133 | 42 | 43 | ||
134 | @@ -117,7 +118,7 @@ | |||
135 | 117 | /** | 118 | /** |
136 | 118 | * bamf_control_get_default: | 119 | * bamf_control_get_default: |
137 | 119 | * | 120 | * |
139 | 120 | * Returns: (transfer none): The default #BamfControl reference. | 121 | * Returns: (transfer full): The default #BamfControl reference. |
140 | 121 | */ | 122 | */ |
141 | 122 | BamfControl * | 123 | BamfControl * |
142 | 123 | bamf_control_get_default (void) | 124 | bamf_control_get_default (void) |
143 | @@ -125,7 +126,9 @@ | |||
144 | 125 | if (BAMF_IS_CONTROL (default_control)) | 126 | if (BAMF_IS_CONTROL (default_control)) |
145 | 126 | return g_object_ref (default_control); | 127 | return g_object_ref (default_control); |
146 | 127 | 128 | ||
148 | 128 | return (default_control = g_object_new (BAMF_TYPE_CONTROL, NULL)); | 129 | default_control = g_object_new (BAMF_TYPE_CONTROL, NULL); |
149 | 130 | |||
150 | 131 | return default_control; | ||
151 | 129 | } | 132 | } |
152 | 130 | 133 | ||
153 | 131 | void | 134 | void |
154 | @@ -137,9 +140,8 @@ | |||
155 | 137 | g_return_if_fail (BAMF_IS_CONTROL (control)); | 140 | g_return_if_fail (BAMF_IS_CONTROL (control)); |
156 | 138 | priv = control->priv; | 141 | priv = control->priv; |
157 | 139 | 142 | ||
161 | 140 | if (!_bamf_dbus_control_call_om_nom_nom_desktop_file_sync (priv->proxy, | 143 | if (!_bamf_dbus_control_call_insert_desktop_file_sync (priv->proxy, desktop_file, |
162 | 141 | desktop_file, | 144 | NULL, &error)) |
160 | 142 | NULL, &error)) | ||
163 | 143 | { | 145 | { |
164 | 144 | g_warning ("Failed to insert desktop file: %s", error->message); | 146 | g_warning ("Failed to insert desktop file: %s", error->message); |
165 | 145 | g_error_free (error); | 147 | g_error_free (error); |
166 | @@ -147,6 +149,30 @@ | |||
167 | 147 | } | 149 | } |
168 | 148 | 150 | ||
169 | 149 | void | 151 | void |
170 | 152 | bamf_control_create_local_desktop_file (BamfControl *control, BamfApplication *app) | ||
171 | 153 | { | ||
172 | 154 | BamfControlPrivate *priv; | ||
173 | 155 | const gchar *app_path; | ||
174 | 156 | GError *error = NULL; | ||
175 | 157 | |||
176 | 158 | g_return_if_fail (BAMF_IS_CONTROL (control)); | ||
177 | 159 | g_return_if_fail (BAMF_IS_APPLICATION (app)); | ||
178 | 160 | |||
179 | 161 | priv = control->priv; | ||
180 | 162 | app_path = _bamf_view_get_path (BAMF_VIEW (app)); | ||
181 | 163 | |||
182 | 164 | if (!app_path) | ||
183 | 165 | return; | ||
184 | 166 | |||
185 | 167 | if (!_bamf_dbus_control_call_create_local_desktop_file_sync (priv->proxy, app_path, | ||
186 | 168 | NULL, &error)) | ||
187 | 169 | { | ||
188 | 170 | g_warning ("Failed to create local desktop file: %s", error->message); | ||
189 | 171 | g_error_free (error); | ||
190 | 172 | } | ||
191 | 173 | } | ||
192 | 174 | |||
193 | 175 | void | ||
194 | 150 | bamf_control_register_application_for_pid (BamfControl *control, | 176 | bamf_control_register_application_for_pid (BamfControl *control, |
195 | 151 | const gchar *desktop_file, | 177 | const gchar *desktop_file, |
196 | 152 | gint32 pid) | 178 | gint32 pid) |
197 | 153 | 179 | ||
198 | === modified file 'lib/libbamf/bamf-control.h' | |||
199 | --- lib/libbamf/bamf-control.h 2013-06-08 13:54:06 +0000 | |||
200 | +++ lib/libbamf/bamf-control.h 2013-08-06 16:20:35 +0000 | |||
201 | @@ -29,6 +29,7 @@ | |||
202 | 29 | #define _BAMF_CONTROL_H_ | 29 | #define _BAMF_CONTROL_H_ |
203 | 30 | 30 | ||
204 | 31 | #include <glib-object.h> | 31 | #include <glib-object.h> |
205 | 32 | #include "bamf-application.h" | ||
206 | 32 | 33 | ||
207 | 33 | G_BEGIN_DECLS | 34 | G_BEGIN_DECLS |
208 | 34 | 35 | ||
209 | @@ -80,6 +81,9 @@ | |||
210 | 80 | void bamf_control_insert_desktop_file (BamfControl *control, | 81 | void bamf_control_insert_desktop_file (BamfControl *control, |
211 | 81 | const gchar *desktop_file); | 82 | const gchar *desktop_file); |
212 | 82 | 83 | ||
213 | 84 | void bamf_control_create_local_desktop_file (BamfControl *control, | ||
214 | 85 | BamfApplication *application); | ||
215 | 86 | |||
216 | 83 | void bamf_control_register_application_for_pid (BamfControl *control, | 87 | void bamf_control_register_application_for_pid (BamfControl *control, |
217 | 84 | const gchar *desktop_file, | 88 | const gchar *desktop_file, |
218 | 85 | gint32 pid); | 89 | gint32 pid); |
219 | 86 | 90 | ||
220 | === modified file 'lib/libbamf/bamf-tab-source.c' | |||
221 | --- lib/libbamf/bamf-tab-source.c 2013-06-13 22:20:25 +0000 | |||
222 | +++ lib/libbamf/bamf-tab-source.c 2013-08-06 16:20:35 +0000 | |||
223 | @@ -138,8 +138,8 @@ | |||
224 | 138 | gchar *tab_id, | 138 | gchar *tab_id, |
225 | 139 | BamfTabSource *self) | 139 | BamfTabSource *self) |
226 | 140 | { | 140 | { |
227 | 141 | g_dbus_method_invocation_return_value (invocation, NULL); | ||
228 | 141 | bamf_tab_source_show_tab (self, tab_id, NULL); | 142 | bamf_tab_source_show_tab (self, tab_id, NULL); |
229 | 142 | g_dbus_method_invocation_return_value (invocation, NULL); | ||
230 | 143 | 143 | ||
231 | 144 | return TRUE; | 144 | return TRUE; |
232 | 145 | } | 145 | } |
233 | 146 | 146 | ||
234 | === modified file 'src/bamf-application.c' | |||
235 | --- src/bamf-application.c 2013-07-23 22:40:05 +0000 | |||
236 | +++ src/bamf-application.c 2013-08-06 16:20:35 +0000 | |||
237 | @@ -40,6 +40,7 @@ | |||
238 | 40 | BamfDBusItemApplication *dbus_iface; | 40 | BamfDBusItemApplication *dbus_iface; |
239 | 41 | BamfApplicationType app_type; | 41 | BamfApplicationType app_type; |
240 | 42 | BamfView * main_child; | 42 | BamfView * main_child; |
241 | 43 | GCancellable * cancellable; | ||
242 | 43 | char * desktop_file; | 44 | char * desktop_file; |
243 | 44 | GList * desktop_file_list; | 45 | GList * desktop_file_list; |
244 | 45 | char * wmclass; | 46 | char * wmclass; |
245 | @@ -104,7 +105,7 @@ | |||
246 | 104 | 105 | ||
247 | 105 | GKeyFile* key_file = g_key_file_new (); | 106 | GKeyFile* key_file = g_key_file_new (); |
248 | 106 | 107 | ||
250 | 107 | if (!g_key_file_load_from_file (key_file, desktop_file, (GKeyFileFlags) 0, NULL)) | 108 | if (!g_key_file_load_from_file (key_file, desktop_file, G_KEY_FILE_NONE, NULL)) |
251 | 108 | { | 109 | { |
252 | 109 | g_key_file_free (key_file); | 110 | g_key_file_free (key_file); |
253 | 110 | return NULL; | 111 | return NULL; |
254 | @@ -340,7 +341,7 @@ | |||
255 | 340 | 341 | ||
256 | 341 | if (!icon) | 342 | if (!icon) |
257 | 342 | { | 343 | { |
259 | 343 | icon = g_strdup (bamf_legacy_window_save_mini_icon (legacy_window)); | 344 | icon = bamf_legacy_window_save_mini_icon (legacy_window); |
260 | 344 | 345 | ||
261 | 345 | if (!icon) | 346 | if (!icon) |
262 | 346 | { | 347 | { |
263 | @@ -388,6 +389,9 @@ | |||
264 | 388 | on_main_child_name_changed, application); | 389 | on_main_child_name_changed, application); |
265 | 389 | } | 390 | } |
266 | 390 | 391 | ||
267 | 392 | g_signal_emit_by_name (application, "desktop-file-updated", | ||
268 | 393 | application->priv->desktop_file); | ||
269 | 394 | |||
270 | 391 | bamf_application_setup_icon_and_name (application, TRUE); | 395 | bamf_application_setup_icon_and_name (application, TRUE); |
271 | 392 | } | 396 | } |
272 | 393 | 397 | ||
273 | @@ -414,6 +418,255 @@ | |||
274 | 414 | return TRUE; | 418 | return TRUE; |
275 | 415 | } | 419 | } |
276 | 416 | 420 | ||
277 | 421 | static GFile * | ||
278 | 422 | try_create_subdir (GFile *parent, const gchar *child_name, GCancellable *cancellable) | ||
279 | 423 | { | ||
280 | 424 | GFile *child; | ||
281 | 425 | GError *error = NULL; | ||
282 | 426 | |||
283 | 427 | child = g_file_get_child (parent, child_name); | ||
284 | 428 | g_return_val_if_fail (G_IS_FILE (child), NULL); | ||
285 | 429 | |||
286 | 430 | g_file_make_directory_with_parents (child, cancellable, &error); | ||
287 | 431 | |||
288 | 432 | if (error) | ||
289 | 433 | { | ||
290 | 434 | if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_EXISTS)) | ||
291 | 435 | { | ||
292 | 436 | g_error ("Impossible to create `%s` directory: %s", child_name, error->message); | ||
293 | 437 | g_clear_object (&child); | ||
294 | 438 | } | ||
295 | 439 | |||
296 | 440 | g_error_free (error); | ||
297 | 441 | } | ||
298 | 442 | |||
299 | 443 | return child; | ||
300 | 444 | } | ||
301 | 445 | |||
302 | 446 | static GFile * | ||
303 | 447 | try_create_child (GFile *parent, const gchar *basename, const gchar *extension, GCancellable *cancellable) | ||
304 | 448 | { | ||
305 | 449 | gchar *down, *child_name; | ||
306 | 450 | |||
307 | 451 | down = g_ascii_strdown (basename, -1); | ||
308 | 452 | g_strdelimit (down, "/\\&%\"'!?`*.;:^|()= <>[]{}", '_'); | ||
309 | 453 | |||
310 | 454 | child_name = g_strconcat (down, extension, NULL); | ||
311 | 455 | |||
312 | 456 | GFile *child = g_file_get_child (parent, child_name); | ||
313 | 457 | g_return_val_if_fail (G_IS_FILE (child), NULL); | ||
314 | 458 | |||
315 | 459 | if (g_file_query_exists (child, cancellable)) | ||
316 | 460 | g_clear_object (&child); | ||
317 | 461 | |||
318 | 462 | g_free (child_name); | ||
319 | 463 | g_free (down); | ||
320 | 464 | |||
321 | 465 | return child; | ||
322 | 466 | } | ||
323 | 467 | |||
324 | 468 | gboolean | ||
325 | 469 | try_create_local_desktop_data (GFile *apps_dir, GFile *icons_dir, const char *basename, | ||
326 | 470 | GFile **out_desktop_file, GFile **out_icon_file, | ||
327 | 471 | GCancellable *cancellable) | ||
328 | 472 | { | ||
329 | 473 | g_return_val_if_fail (out_desktop_file, NULL); | ||
330 | 474 | |||
331 | 475 | if (!apps_dir) | ||
332 | 476 | { | ||
333 | 477 | *out_desktop_file = NULL; | ||
334 | 478 | g_warn_if_reached (); | ||
335 | 479 | } | ||
336 | 480 | |||
337 | 481 | *out_desktop_file = try_create_child (apps_dir, basename, ".desktop", cancellable); | ||
338 | 482 | |||
339 | 483 | if (G_IS_FILE (*out_desktop_file)) | ||
340 | 484 | { | ||
341 | 485 | if (G_IS_FILE (icons_dir) && out_icon_file) | ||
342 | 486 | *out_icon_file = try_create_child (icons_dir, basename, ".png", cancellable); | ||
343 | 487 | |||
344 | 488 | return TRUE; | ||
345 | 489 | } | ||
346 | 490 | |||
347 | 491 | return FALSE; | ||
348 | 492 | } | ||
349 | 493 | |||
350 | 494 | gboolean | ||
351 | 495 | bamf_application_create_local_desktop_file (BamfApplication *self) | ||
352 | 496 | { | ||
353 | 497 | BamfApplicationPrivate *priv; | ||
354 | 498 | BamfLegacyWindow *window; | ||
355 | 499 | GKeyFile *key_file; | ||
356 | 500 | const gchar *name, *icon, *iclass, *nclass, *class, *exec; | ||
357 | 501 | GFile *data_dir, *apps_dir, *icons_dir, *desktop_file, *icon_file, *mini_icon; | ||
358 | 502 | GError *error = NULL; | ||
359 | 503 | |||
360 | 504 | g_return_val_if_fail (BAMF_IS_APPLICATION (self), FALSE); | ||
361 | 505 | priv = self->priv; | ||
362 | 506 | |||
363 | 507 | if (priv->desktop_file || !BAMF_IS_WINDOW (priv->main_child)) | ||
364 | 508 | { | ||
365 | 509 | return FALSE; | ||
366 | 510 | } | ||
367 | 511 | |||
368 | 512 | window = bamf_window_get_window (BAMF_WINDOW (priv->main_child)); | ||
369 | 513 | exec = bamf_legacy_window_get_exec_string (window); | ||
370 | 514 | |||
371 | 515 | if (!exec) | ||
372 | 516 | { | ||
373 | 517 | return FALSE; | ||
374 | 518 | } | ||
375 | 519 | |||
376 | 520 | data_dir = g_file_new_for_path (g_get_user_data_dir ()); | ||
377 | 521 | name = bamf_view_get_name (BAMF_VIEW (self)); | ||
378 | 522 | icon = bamf_view_get_icon (BAMF_VIEW (self)); | ||
379 | 523 | iclass = bamf_legacy_window_get_class_instance_name (window); | ||
380 | 524 | nclass = bamf_legacy_window_get_class_name (window); | ||
381 | 525 | mini_icon = bamf_legacy_window_get_saved_mini_icon (window); | ||
382 | 526 | |||
383 | 527 | apps_dir = try_create_subdir (data_dir, "applications", priv->cancellable); | ||
384 | 528 | icons_dir = NULL; | ||
385 | 529 | |||
386 | 530 | if (!G_IS_FILE (apps_dir)) | ||
387 | 531 | { | ||
388 | 532 | g_object_unref (data_dir); | ||
389 | 533 | return FALSE; | ||
390 | 534 | } | ||
391 | 535 | |||
392 | 536 | if (icon && G_IS_FILE (mini_icon)) | ||
393 | 537 | icons_dir = try_create_subdir (data_dir, "icons", priv->cancellable); | ||
394 | 538 | |||
395 | 539 | g_clear_object (&data_dir); | ||
396 | 540 | |||
397 | 541 | desktop_file = NULL; | ||
398 | 542 | icon_file = NULL; | ||
399 | 543 | class = (iclass) ? iclass : nclass; | ||
400 | 544 | |||
401 | 545 | if (class) | ||
402 | 546 | { | ||
403 | 547 | try_create_local_desktop_data (apps_dir, icons_dir, class, | ||
404 | 548 | &desktop_file, &icon_file, priv->cancellable); | ||
405 | 549 | } | ||
406 | 550 | |||
407 | 551 | if (!G_IS_FILE (desktop_file)) | ||
408 | 552 | { | ||
409 | 553 | BamfMatcher *matcher = bamf_matcher_get_default (); | ||
410 | 554 | gchar *trimmed_exec = bamf_matcher_get_trimmed_exec (matcher, exec); | ||
411 | 555 | try_create_local_desktop_data (apps_dir, icons_dir, trimmed_exec, | ||
412 | 556 | &desktop_file, &icon_file, priv->cancellable); | ||
413 | 557 | g_free (trimmed_exec); | ||
414 | 558 | } | ||
415 | 559 | |||
416 | 560 | if (!G_IS_FILE (desktop_file)) | ||
417 | 561 | { | ||
418 | 562 | try_create_local_desktop_data (apps_dir, icons_dir, exec, | ||
419 | 563 | &desktop_file, &icon_file, priv->cancellable); | ||
420 | 564 | } | ||
421 | 565 | |||
422 | 566 | g_object_unref (apps_dir); | ||
423 | 567 | |||
424 | 568 | if (!G_IS_FILE (desktop_file)) | ||
425 | 569 | { | ||
426 | 570 | g_critical ("Impossible to find a valid path where to save a .desktop file"); | ||
427 | 571 | g_clear_object (&icons_dir); | ||
428 | 572 | g_clear_object (&icon_file); | ||
429 | 573 | return FALSE; | ||
430 | 574 | } | ||
431 | 575 | |||
432 | 576 | if (G_IS_FILE (icons_dir) && !G_IS_FILE (icon_file)) | ||
433 | 577 | { | ||
434 | 578 | gchar *basename = g_file_get_basename (mini_icon); | ||
435 | 579 | icon_file = try_create_child (icons_dir, basename+1, ".png", priv->cancellable); | ||
436 | 580 | g_free (basename); | ||
437 | 581 | } | ||
438 | 582 | |||
439 | 583 | g_clear_object (&icons_dir); | ||
440 | 584 | |||
441 | 585 | if (G_IS_FILE (icon_file)) | ||
442 | 586 | { | ||
443 | 587 | if (!g_file_copy (mini_icon, icon_file, G_FILE_COPY_NONE, | ||
444 | 588 | priv->cancellable, NULL, NULL, &error)) | ||
445 | 589 | { | ||
446 | 590 | g_warning ("Impossible to copy icon to final destination: %s", error->message); | ||
447 | 591 | g_clear_error (&error); | ||
448 | 592 | g_clear_object (&icon_file); | ||
449 | 593 | } | ||
450 | 594 | } | ||
451 | 595 | |||
452 | 596 | key_file = g_key_file_new (); | ||
453 | 597 | g_key_file_set_string (key_file, G_KEY_FILE_DESKTOP_GROUP, | ||
454 | 598 | G_KEY_FILE_DESKTOP_KEY_TYPE, | ||
455 | 599 | G_KEY_FILE_DESKTOP_TYPE_APPLICATION); | ||
456 | 600 | |||
457 | 601 | if (name) | ||
458 | 602 | { | ||
459 | 603 | g_key_file_set_string (key_file, G_KEY_FILE_DESKTOP_GROUP, | ||
460 | 604 | G_KEY_FILE_DESKTOP_KEY_NAME, name); | ||
461 | 605 | } | ||
462 | 606 | |||
463 | 607 | if (icon_file) | ||
464 | 608 | { | ||
465 | 609 | gchar *basename = g_file_get_basename (icon_file); | ||
466 | 610 | g_key_file_set_string (key_file, G_KEY_FILE_DESKTOP_GROUP, | ||
467 | 611 | G_KEY_FILE_DESKTOP_KEY_ICON, basename); | ||
468 | 612 | bamf_view_set_icon (BAMF_VIEW (self), basename); | ||
469 | 613 | g_free (basename); | ||
470 | 614 | g_clear_object (&icon_file); | ||
471 | 615 | } | ||
472 | 616 | else if (icon) | ||
473 | 617 | { | ||
474 | 618 | g_key_file_set_string (key_file, G_KEY_FILE_DESKTOP_GROUP, | ||
475 | 619 | G_KEY_FILE_DESKTOP_KEY_ICON, icon); | ||
476 | 620 | } | ||
477 | 621 | |||
478 | 622 | g_key_file_set_string (key_file, G_KEY_FILE_DESKTOP_GROUP, | ||
479 | 623 | G_KEY_FILE_DESKTOP_KEY_EXEC, exec); | ||
480 | 624 | |||
481 | 625 | g_key_file_set_boolean (key_file, G_KEY_FILE_DESKTOP_GROUP, | ||
482 | 626 | G_KEY_FILE_DESKTOP_KEY_STARTUP_NOTIFY, TRUE); | ||
483 | 627 | |||
484 | 628 | if (class) | ||
485 | 629 | { | ||
486 | 630 | g_key_file_set_string (key_file, G_KEY_FILE_DESKTOP_GROUP, | ||
487 | 631 | G_KEY_FILE_DESKTOP_KEY_STARTUP_WM_CLASS, class); | ||
488 | 632 | } | ||
489 | 633 | |||
490 | 634 | gsize data_length = 0; | ||
491 | 635 | gchar *data = g_key_file_to_data (key_file, &data_length, &error); | ||
492 | 636 | g_key_file_free (key_file); | ||
493 | 637 | |||
494 | 638 | if (error) | ||
495 | 639 | { | ||
496 | 640 | g_critical ("Impossible to generate local desktop file: %s", error->message); | ||
497 | 641 | g_clear_error (&error); | ||
498 | 642 | g_clear_pointer (&data, g_free); | ||
499 | 643 | } | ||
500 | 644 | |||
501 | 645 | if (data) | ||
502 | 646 | { | ||
503 | 647 | g_file_replace_contents (desktop_file, data, data_length, NULL, FALSE, | ||
504 | 648 | G_FILE_CREATE_NONE, NULL, priv->cancellable, &error); | ||
505 | 649 | g_free (data); | ||
506 | 650 | |||
507 | 651 | if (error) | ||
508 | 652 | { | ||
509 | 653 | g_critical ("Impossible to create local desktop file: %s", error->message); | ||
510 | 654 | g_clear_error (&error); | ||
511 | 655 | g_object_unref (desktop_file); | ||
512 | 656 | |||
513 | 657 | return FALSE; | ||
514 | 658 | } | ||
515 | 659 | } | ||
516 | 660 | |||
517 | 661 | gchar *desktop_path = g_file_get_path (desktop_file); | ||
518 | 662 | g_object_unref (desktop_file); | ||
519 | 663 | |||
520 | 664 | bamf_application_set_desktop_file (self, desktop_path); | ||
521 | 665 | g_free (desktop_path); | ||
522 | 666 | |||
523 | 667 | return TRUE; | ||
524 | 668 | } | ||
525 | 669 | |||
526 | 417 | void | 670 | void |
527 | 418 | bamf_application_set_wmclass (BamfApplication *application, | 671 | bamf_application_set_wmclass (BamfApplication *application, |
528 | 419 | const char *wmclass) | 672 | const char *wmclass) |
529 | @@ -888,6 +1141,13 @@ | |||
530 | 888 | g_signal_emit_by_name (self->priv->dbus_iface, "window-removed", win_path); | 1141 | g_signal_emit_by_name (self->priv->dbus_iface, "window-removed", win_path); |
531 | 889 | } | 1142 | } |
532 | 890 | 1143 | ||
533 | 1144 | static void | ||
534 | 1145 | on_desktop_file_updated (BamfApplication *self, const gchar *file, gpointer _not_used) | ||
535 | 1146 | { | ||
536 | 1147 | g_return_if_fail (BAMF_IS_APPLICATION (self)); | ||
537 | 1148 | g_signal_emit_by_name (self->priv->dbus_iface, "desktop-file-updated", file); | ||
538 | 1149 | } | ||
539 | 1150 | |||
540 | 891 | static gboolean | 1151 | static gboolean |
541 | 892 | on_dbus_handle_show_stubs (BamfDBusItemApplication *interface, | 1152 | on_dbus_handle_show_stubs (BamfDBusItemApplication *interface, |
542 | 893 | GDBusMethodInvocation *invocation, | 1153 | GDBusMethodInvocation *invocation, |
543 | @@ -1056,6 +1316,13 @@ | |||
544 | 1056 | priv->main_child = NULL; | 1316 | priv->main_child = NULL; |
545 | 1057 | } | 1317 | } |
546 | 1058 | 1318 | ||
547 | 1319 | if (priv->cancellable) | ||
548 | 1320 | { | ||
549 | 1321 | g_cancellable_cancel (priv->cancellable); | ||
550 | 1322 | g_object_unref (priv->cancellable); | ||
551 | 1323 | priv->cancellable = NULL; | ||
552 | 1324 | } | ||
553 | 1325 | |||
554 | 1059 | g_strfreev (priv->mimes); | 1326 | g_strfreev (priv->mimes); |
555 | 1060 | priv->mimes = NULL; | 1327 | priv->mimes = NULL; |
556 | 1061 | 1328 | ||
557 | @@ -1085,6 +1352,8 @@ | |||
558 | 1085 | priv->app_type = BAMF_APPLICATION_SYSTEM; | 1352 | priv->app_type = BAMF_APPLICATION_SYSTEM; |
559 | 1086 | priv->show_stubs = TRUE; | 1353 | priv->show_stubs = TRUE; |
560 | 1087 | 1354 | ||
561 | 1355 | priv->cancellable = g_cancellable_new (); | ||
562 | 1356 | |||
563 | 1088 | /* Initializing the dbus interface */ | 1357 | /* Initializing the dbus interface */ |
564 | 1089 | priv->dbus_iface = _bamf_dbus_item_application_skeleton_new (); | 1358 | priv->dbus_iface = _bamf_dbus_item_application_skeleton_new (); |
565 | 1090 | 1359 | ||
566 | @@ -1092,6 +1361,7 @@ | |||
567 | 1092 | * interface */ | 1361 | * interface */ |
568 | 1093 | g_signal_connect (self, "window-added", G_CALLBACK (on_window_added), NULL); | 1362 | g_signal_connect (self, "window-added", G_CALLBACK (on_window_added), NULL); |
569 | 1094 | g_signal_connect (self, "window-removed", G_CALLBACK (on_window_removed), NULL); | 1363 | g_signal_connect (self, "window-removed", G_CALLBACK (on_window_removed), NULL); |
570 | 1364 | g_signal_connect (self, "desktop-file-updated", G_CALLBACK (on_desktop_file_updated), NULL); | ||
571 | 1095 | 1365 | ||
572 | 1096 | /* Registering signal callbacks to reply to dbus method calls */ | 1366 | /* Registering signal callbacks to reply to dbus method calls */ |
573 | 1097 | g_signal_connect (priv->dbus_iface, "handle-show-stubs", | 1367 | g_signal_connect (priv->dbus_iface, "handle-show-stubs", |
574 | 1098 | 1368 | ||
575 | === modified file 'src/bamf-application.h' | |||
576 | --- src/bamf-application.h 2013-07-16 16:17:38 +0000 | |||
577 | +++ src/bamf-application.h 2013-08-06 16:20:35 +0000 | |||
578 | @@ -84,6 +84,8 @@ | |||
579 | 84 | gboolean bamf_application_contains_similar_to_window (BamfApplication *app, | 84 | gboolean bamf_application_contains_similar_to_window (BamfApplication *app, |
580 | 85 | BamfWindow *window); | 85 | BamfWindow *window); |
581 | 86 | 86 | ||
582 | 87 | gboolean bamf_application_create_local_desktop_file (BamfApplication *app); | ||
583 | 88 | |||
584 | 87 | const char * bamf_application_get_wmclass (BamfApplication *application); | 89 | const char * bamf_application_get_wmclass (BamfApplication *application); |
585 | 88 | void bamf_application_set_wmclass (BamfApplication *application, | 90 | void bamf_application_set_wmclass (BamfApplication *application, |
586 | 89 | const char *wmclass); | 91 | const char *wmclass); |
587 | 90 | 92 | ||
588 | === modified file 'src/bamf-control.c' | |||
589 | --- src/bamf-control.c 2013-06-08 13:54:06 +0000 | |||
590 | +++ src/bamf-control.c 2013-08-06 16:20:35 +0000 | |||
591 | @@ -19,9 +19,12 @@ | |||
592 | 19 | */ | 19 | */ |
593 | 20 | 20 | ||
594 | 21 | 21 | ||
596 | 22 | #include "bamf-matcher.h" | 22 | #include <libbamf-private/bamf-private.h> |
597 | 23 | |||
598 | 23 | #include "bamf-control.h" | 24 | #include "bamf-control.h" |
599 | 25 | #include "bamf-application.h" | ||
600 | 24 | #include "bamf-daemon.h" | 26 | #include "bamf-daemon.h" |
601 | 27 | #include "bamf-matcher.h" | ||
602 | 25 | 28 | ||
603 | 26 | G_DEFINE_TYPE (BamfControl, bamf_control, BAMF_DBUS_TYPE_CONTROL_SKELETON); | 29 | G_DEFINE_TYPE (BamfControl, bamf_control, BAMF_DBUS_TYPE_CONTROL_SKELETON); |
604 | 27 | #define BAMF_CONTROL_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE(obj, \ | 30 | #define BAMF_CONTROL_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE(obj, \ |
605 | @@ -96,20 +99,20 @@ | |||
606 | 96 | GDBusMethodInvocation *invocation, | 99 | GDBusMethodInvocation *invocation, |
607 | 97 | BamfControl *self) | 100 | BamfControl *self) |
608 | 98 | { | 101 | { |
609 | 102 | g_dbus_method_invocation_return_value (invocation, NULL); | ||
610 | 99 | bamf_control_quit (self); | 103 | bamf_control_quit (self); |
611 | 100 | g_dbus_method_invocation_return_value (invocation, NULL); | ||
612 | 101 | 104 | ||
613 | 102 | return TRUE; | 105 | return TRUE; |
614 | 103 | } | 106 | } |
615 | 104 | 107 | ||
616 | 105 | static gboolean | 108 | static gboolean |
621 | 106 | on_dbus_handle_om_nom_nom_desktop_file (BamfDBusControl *interface, | 109 | on_dbus_handle_insert_desktop_file (BamfDBusControl *interface, |
622 | 107 | GDBusMethodInvocation *invocation, | 110 | GDBusMethodInvocation *invocation, |
623 | 108 | const gchar *desktop_file, | 111 | const gchar *desktop_file, |
624 | 109 | BamfControl *self) | 112 | BamfControl *self) |
625 | 110 | { | 113 | { |
626 | 114 | g_dbus_method_invocation_return_value (invocation, NULL); | ||
627 | 111 | bamf_control_insert_desktop_file (self, desktop_file); | 115 | bamf_control_insert_desktop_file (self, desktop_file); |
628 | 112 | g_dbus_method_invocation_return_value (invocation, NULL); | ||
629 | 113 | 116 | ||
630 | 114 | return TRUE; | 117 | return TRUE; |
631 | 115 | } | 118 | } |
632 | @@ -121,8 +124,20 @@ | |||
633 | 121 | guint pid, | 124 | guint pid, |
634 | 122 | BamfControl *self) | 125 | BamfControl *self) |
635 | 123 | { | 126 | { |
636 | 127 | g_dbus_method_invocation_return_value (invocation, NULL); | ||
637 | 124 | bamf_control_register_application_for_pid (self, application, pid); | 128 | bamf_control_register_application_for_pid (self, application, pid); |
638 | 129 | |||
639 | 130 | return TRUE; | ||
640 | 131 | } | ||
641 | 132 | |||
642 | 133 | static gboolean | ||
643 | 134 | on_dbus_handle_create_local_desktop_file (BamfDBusControl *interface, | ||
644 | 135 | GDBusMethodInvocation *invocation, | ||
645 | 136 | const gchar *desktop_file, | ||
646 | 137 | BamfControl *self) | ||
647 | 138 | { | ||
648 | 125 | g_dbus_method_invocation_return_value (invocation, NULL); | 139 | g_dbus_method_invocation_return_value (invocation, NULL); |
649 | 140 | bamf_control_create_local_desktop_file (self, desktop_file); | ||
650 | 126 | 141 | ||
651 | 127 | return TRUE; | 142 | return TRUE; |
652 | 128 | } | 143 | } |
653 | @@ -138,10 +153,16 @@ | |||
654 | 138 | G_CALLBACK (on_dbus_handle_quit), self); | 153 | G_CALLBACK (on_dbus_handle_quit), self); |
655 | 139 | 154 | ||
656 | 140 | g_signal_connect (self, "handle-om-nom-nom-desktop-file", | 155 | g_signal_connect (self, "handle-om-nom-nom-desktop-file", |
658 | 141 | G_CALLBACK (on_dbus_handle_om_nom_nom_desktop_file), self); | 156 | G_CALLBACK (on_dbus_handle_insert_desktop_file), self); |
659 | 157 | |||
660 | 158 | g_signal_connect (self, "handle-insert-desktop-file", | ||
661 | 159 | G_CALLBACK (on_dbus_handle_insert_desktop_file), self); | ||
662 | 142 | 160 | ||
663 | 143 | g_signal_connect (self, "handle-register-application-for-pid", | 161 | g_signal_connect (self, "handle-register-application-for-pid", |
664 | 144 | G_CALLBACK (on_dbus_handle_register_application_for_pid), self); | 162 | G_CALLBACK (on_dbus_handle_register_application_for_pid), self); |
665 | 163 | |||
666 | 164 | g_signal_connect (self, "handle-create-local-desktop-file", | ||
667 | 165 | G_CALLBACK (on_dbus_handle_create_local_desktop_file), self); | ||
668 | 145 | } | 166 | } |
669 | 146 | 167 | ||
670 | 147 | static void | 168 | static void |
671 | @@ -191,6 +212,22 @@ | |||
672 | 191 | bamf_matcher_load_desktop_file (matcher, path); | 212 | bamf_matcher_load_desktop_file (matcher, path); |
673 | 192 | } | 213 | } |
674 | 193 | 214 | ||
675 | 215 | void | ||
676 | 216 | bamf_control_create_local_desktop_file (BamfControl *control, const char *app_path) | ||
677 | 217 | { | ||
678 | 218 | BamfMatcher *matcher; | ||
679 | 219 | BamfView *view; | ||
680 | 220 | |||
681 | 221 | g_return_if_fail (BAMF_IS_CONTROL (control)); | ||
682 | 222 | g_return_if_fail (app_path); | ||
683 | 223 | |||
684 | 224 | matcher = bamf_matcher_get_default (); | ||
685 | 225 | view = bamf_matcher_get_view_by_path (matcher, app_path); | ||
686 | 226 | |||
687 | 227 | if (BAMF_IS_APPLICATION (view)) | ||
688 | 228 | bamf_application_create_local_desktop_file (BAMF_APPLICATION (view)); | ||
689 | 229 | } | ||
690 | 230 | |||
691 | 194 | static gboolean | 231 | static gboolean |
692 | 195 | bamf_control_on_quit (BamfControl *control) | 232 | bamf_control_on_quit (BamfControl *control) |
693 | 196 | { | 233 | { |
694 | 197 | 234 | ||
695 | === modified file 'src/bamf-control.h' | |||
696 | --- src/bamf-control.h 2013-06-08 13:54:06 +0000 | |||
697 | +++ src/bamf-control.h 2013-08-06 16:20:35 +0000 | |||
698 | @@ -63,6 +63,9 @@ | |||
699 | 63 | void bamf_control_insert_desktop_file (BamfControl *control, | 63 | void bamf_control_insert_desktop_file (BamfControl *control, |
700 | 64 | const char *path); | 64 | const char *path); |
701 | 65 | 65 | ||
702 | 66 | void bamf_control_create_local_desktop_file (BamfControl *control, | ||
703 | 67 | const char *desktop_file); | ||
704 | 68 | |||
705 | 66 | void bamf_control_quit (BamfControl *control); | 69 | void bamf_control_quit (BamfControl *control); |
706 | 67 | 70 | ||
707 | 68 | BamfControl * bamf_control_get_default (void); | 71 | BamfControl * bamf_control_get_default (void); |
708 | 69 | 72 | ||
709 | === modified file 'src/bamf-legacy-window-test.c' | |||
710 | --- src/bamf-legacy-window-test.c 2013-07-23 22:40:05 +0000 | |||
711 | +++ src/bamf-legacy-window-test.c 2013-08-06 16:20:35 +0000 | |||
712 | @@ -420,10 +420,10 @@ | |||
713 | 420 | return g_hash_table_insert (self->hints, g_strdup (name), g_strdup (value)); | 420 | return g_hash_table_insert (self->hints, g_strdup (name), g_strdup (value)); |
714 | 421 | } | 421 | } |
715 | 422 | 422 | ||
717 | 423 | static const char * | 423 | static char * |
718 | 424 | bamf_legacy_window_test_save_mini_icon (BamfLegacyWindow *window) | 424 | bamf_legacy_window_test_save_mini_icon (BamfLegacyWindow *window) |
719 | 425 | { | 425 | { |
721 | 426 | return BAMF_LEGACY_WINDOW_TEST (window)->icon; | 426 | return g_strdup (BAMF_LEGACY_WINDOW_TEST (window)->icon); |
722 | 427 | } | 427 | } |
723 | 428 | 428 | ||
724 | 429 | static void | 429 | static void |
725 | 430 | 430 | ||
726 | === modified file 'src/bamf-legacy-window.c' | |||
727 | --- src/bamf-legacy-window.c 2013-07-23 22:40:05 +0000 | |||
728 | +++ src/bamf-legacy-window.c 2013-08-06 16:20:35 +0000 | |||
729 | @@ -51,7 +51,7 @@ | |||
730 | 51 | struct _BamfLegacyWindowPrivate | 51 | struct _BamfLegacyWindowPrivate |
731 | 52 | { | 52 | { |
732 | 53 | WnckWindow * legacy_window; | 53 | WnckWindow * legacy_window; |
734 | 54 | gchar * mini_icon_path; | 54 | GFile * mini_icon; |
735 | 55 | gchar * exec_string; | 55 | gchar * exec_string; |
736 | 56 | gboolean is_closed; | 56 | gboolean is_closed; |
737 | 57 | }; | 57 | }; |
738 | @@ -260,7 +260,7 @@ | |||
739 | 260 | return self->priv->exec_string; | 260 | return self->priv->exec_string; |
740 | 261 | } | 261 | } |
741 | 262 | 262 | ||
743 | 263 | const char * | 263 | char * |
744 | 264 | bamf_legacy_window_save_mini_icon (BamfLegacyWindow *self) | 264 | bamf_legacy_window_save_mini_icon (BamfLegacyWindow *self) |
745 | 265 | { | 265 | { |
746 | 266 | WnckWindow *window; | 266 | WnckWindow *window; |
747 | @@ -274,16 +274,16 @@ | |||
748 | 274 | if (BAMF_LEGACY_WINDOW_GET_CLASS (self)->save_mini_icon) | 274 | if (BAMF_LEGACY_WINDOW_GET_CLASS (self)->save_mini_icon) |
749 | 275 | return BAMF_LEGACY_WINDOW_GET_CLASS (self)->save_mini_icon (self); | 275 | return BAMF_LEGACY_WINDOW_GET_CLASS (self)->save_mini_icon (self); |
750 | 276 | 276 | ||
752 | 277 | if (self->priv->mini_icon_path) | 277 | if (self->priv->mini_icon) |
753 | 278 | { | 278 | { |
755 | 279 | if (g_file_test (self->priv->mini_icon_path, G_FILE_TEST_EXISTS)) | 279 | if (g_file_query_exists (self->priv->mini_icon, NULL)) |
756 | 280 | { | 280 | { |
758 | 281 | return self->priv->mini_icon_path; | 281 | return g_file_get_path (self->priv->mini_icon); |
759 | 282 | } | 282 | } |
760 | 283 | else | 283 | else |
761 | 284 | { | 284 | { |
764 | 285 | g_free (self->priv->mini_icon_path); | 285 | g_object_unref (self->priv->mini_icon); |
765 | 286 | self->priv->mini_icon_path = NULL; | 286 | self->priv->mini_icon = NULL; |
766 | 287 | } | 287 | } |
767 | 288 | } | 288 | } |
768 | 289 | 289 | ||
769 | @@ -305,13 +305,21 @@ | |||
770 | 305 | 305 | ||
771 | 306 | if (gdk_pixbuf_save_to_stream (pbuf, output, "png", NULL, NULL, NULL)) | 306 | if (gdk_pixbuf_save_to_stream (pbuf, output, "png", NULL, NULL, NULL)) |
772 | 307 | { | 307 | { |
774 | 308 | self->priv->mini_icon_path = g_file_get_path (tmp); | 308 | self->priv->mini_icon = g_object_ref (tmp); |
775 | 309 | } | 309 | } |
776 | 310 | 310 | ||
777 | 311 | g_object_unref (iostream); | 311 | g_object_unref (iostream); |
778 | 312 | g_object_unref (tmp); | 312 | g_object_unref (tmp); |
779 | 313 | 313 | ||
781 | 314 | return self->priv->mini_icon_path; | 314 | return g_file_get_path (self->priv->mini_icon); |
782 | 315 | } | ||
783 | 316 | |||
784 | 317 | GFile * | ||
785 | 318 | bamf_legacy_window_get_saved_mini_icon (BamfLegacyWindow *self) | ||
786 | 319 | { | ||
787 | 320 | g_return_val_if_fail (BAMF_IS_LEGACY_WINDOW (self), NULL); | ||
788 | 321 | |||
789 | 322 | return self->priv->mini_icon; | ||
790 | 315 | } | 323 | } |
791 | 316 | 324 | ||
792 | 317 | guint | 325 | guint |
793 | @@ -563,19 +571,14 @@ | |||
794 | 563 | bamf_legacy_window_dispose (GObject *object) | 571 | bamf_legacy_window_dispose (GObject *object) |
795 | 564 | { | 572 | { |
796 | 565 | BamfLegacyWindow *self; | 573 | BamfLegacyWindow *self; |
797 | 566 | GFile *file; | ||
798 | 567 | guint i; | 574 | guint i; |
799 | 568 | 575 | ||
800 | 569 | self = BAMF_LEGACY_WINDOW (object); | 576 | self = BAMF_LEGACY_WINDOW (object); |
801 | 570 | 577 | ||
803 | 571 | if (self->priv->mini_icon_path) | 578 | if (self->priv->mini_icon) |
804 | 572 | { | 579 | { |
811 | 573 | file = g_file_new_for_path (self->priv->mini_icon_path); | 580 | g_file_delete (self->priv->mini_icon, NULL, NULL); |
812 | 574 | g_file_delete (file, NULL, NULL); | 581 | g_object_unref (self->priv->mini_icon); |
807 | 575 | g_object_unref (file); | ||
808 | 576 | |||
809 | 577 | g_free (self->priv->mini_icon_path); | ||
810 | 578 | self->priv->mini_icon_path = NULL; | ||
813 | 579 | } | 582 | } |
814 | 580 | 583 | ||
815 | 581 | if (self->priv->exec_string) | 584 | if (self->priv->exec_string) |
816 | 582 | 585 | ||
817 | === modified file 'src/bamf-legacy-window.h' | |||
818 | --- src/bamf-legacy-window.h 2013-07-23 22:40:05 +0000 | |||
819 | +++ src/bamf-legacy-window.h 2013-08-06 16:20:35 +0000 | |||
820 | @@ -76,8 +76,8 @@ | |||
821 | 76 | const char * (*get_role) (BamfLegacyWindow *legacy_window); | 76 | const char * (*get_role) (BamfLegacyWindow *legacy_window); |
822 | 77 | const char * (*get_class_name) (BamfLegacyWindow *legacy_window); | 77 | const char * (*get_class_name) (BamfLegacyWindow *legacy_window); |
823 | 78 | const char * (*get_class_instance_name) (BamfLegacyWindow *legacy_window); | 78 | const char * (*get_class_instance_name) (BamfLegacyWindow *legacy_window); |
824 | 79 | const char * (*save_mini_icon) (BamfLegacyWindow *legacy_window); | ||
825 | 80 | const char * (*get_exec_string) (BamfLegacyWindow *legacy_window); | 79 | const char * (*get_exec_string) (BamfLegacyWindow *legacy_window); |
826 | 80 | char * (*save_mini_icon) (BamfLegacyWindow *legacy_window); | ||
827 | 81 | char * (*get_process_name) (BamfLegacyWindow *legacy_window); | 81 | char * (*get_process_name) (BamfLegacyWindow *legacy_window); |
828 | 82 | char * (*get_app_id) (BamfLegacyWindow *legacy_window); | 82 | char * (*get_app_id) (BamfLegacyWindow *legacy_window); |
829 | 83 | char * (*get_unique_bus_name) (BamfLegacyWindow *legacy_window); | 83 | char * (*get_unique_bus_name) (BamfLegacyWindow *legacy_window); |
830 | @@ -147,10 +147,12 @@ | |||
831 | 147 | 147 | ||
832 | 148 | const char * bamf_legacy_window_get_role (BamfLegacyWindow *self); | 148 | const char * bamf_legacy_window_get_role (BamfLegacyWindow *self); |
833 | 149 | 149 | ||
834 | 150 | const char * bamf_legacy_window_save_mini_icon (BamfLegacyWindow *self); | ||
835 | 151 | |||
836 | 152 | const char * bamf_legacy_window_get_exec_string (BamfLegacyWindow *self); | 150 | const char * bamf_legacy_window_get_exec_string (BamfLegacyWindow *self); |
837 | 153 | 151 | ||
838 | 152 | char * bamf_legacy_window_save_mini_icon (BamfLegacyWindow *self); | ||
839 | 153 | |||
840 | 154 | GFile * bamf_legacy_window_get_saved_mini_icon (BamfLegacyWindow *self); | ||
841 | 155 | |||
842 | 154 | char * bamf_legacy_window_get_process_name (BamfLegacyWindow *self); | 156 | char * bamf_legacy_window_get_process_name (BamfLegacyWindow *self); |
843 | 155 | 157 | ||
844 | 156 | BamfLegacyWindow * bamf_legacy_window_get_transient (BamfLegacyWindow *self); | 158 | BamfLegacyWindow * bamf_legacy_window_get_transient (BamfLegacyWindow *self); |
845 | 157 | 159 | ||
846 | === modified file 'src/bamf-matcher.c' | |||
847 | --- src/bamf-matcher.c 2013-07-24 00:11:01 +0000 | |||
848 | +++ src/bamf-matcher.c 2013-08-06 16:20:35 +0000 | |||
849 | @@ -191,6 +191,31 @@ | |||
850 | 191 | return NULL; | 191 | return NULL; |
851 | 192 | } | 192 | } |
852 | 193 | 193 | ||
853 | 194 | |||
854 | 195 | BamfView * | ||
855 | 196 | bamf_matcher_get_view_by_path (BamfMatcher *self, const char *view_path) | ||
856 | 197 | { | ||
857 | 198 | GList *l; | ||
858 | 199 | BamfView *view; | ||
859 | 200 | |||
860 | 201 | g_return_val_if_fail (BAMF_IS_MATCHER (self), NULL); | ||
861 | 202 | |||
862 | 203 | for (l = self->priv->views; l; l = l->next) | ||
863 | 204 | { | ||
864 | 205 | view = l->data; | ||
865 | 206 | |||
866 | 207 | if (!BAMF_IS_VIEW (view)) | ||
867 | 208 | continue; | ||
868 | 209 | |||
869 | 210 | if (g_strcmp0 (bamf_view_get_path (view), view_path) == 0) | ||
870 | 211 | { | ||
871 | 212 | return view; | ||
872 | 213 | } | ||
873 | 214 | } | ||
874 | 215 | |||
875 | 216 | return NULL; | ||
876 | 217 | } | ||
877 | 218 | |||
878 | 194 | static gboolean | 219 | static gboolean |
879 | 195 | emit_paths_changed (gpointer user_data) | 220 | emit_paths_changed (gpointer user_data) |
880 | 196 | { | 221 | { |
881 | @@ -2835,8 +2860,8 @@ | |||
882 | 2835 | const char **favorites, | 2860 | const char **favorites, |
883 | 2836 | BamfMatcher *self) | 2861 | BamfMatcher *self) |
884 | 2837 | { | 2862 | { |
885 | 2863 | g_dbus_method_invocation_return_value (invocation, NULL); | ||
886 | 2838 | bamf_matcher_register_favorites (self, favorites); | 2864 | bamf_matcher_register_favorites (self, favorites); |
887 | 2839 | g_dbus_method_invocation_return_value (invocation, NULL); | ||
888 | 2840 | 2865 | ||
889 | 2841 | return TRUE; | 2866 | return TRUE; |
890 | 2842 | } | 2867 | } |
891 | @@ -2917,7 +2942,7 @@ | |||
892 | 2917 | webapp_tab = BAMF_UNITY_WEBAPPS_TAB (child); | 2942 | webapp_tab = BAMF_UNITY_WEBAPPS_TAB (child); |
893 | 2918 | legacy_window = bamf_unity_webapps_tab_get_legacy_window_for (webapp_tab); | 2943 | legacy_window = bamf_unity_webapps_tab_get_legacy_window_for (webapp_tab); |
894 | 2919 | 2944 | ||
896 | 2920 | if (is_web_app_window (legacy_window)) | 2945 | if (legacy_window && is_web_app_window (legacy_window)) |
897 | 2921 | { | 2946 | { |
898 | 2922 | /* If we have a chromeless window, we remove the window from the | 2947 | /* If we have a chromeless window, we remove the window from the |
899 | 2923 | * application children list, so that it won't be duplicated in launcher */ | 2948 | * application children list, so that it won't be duplicated in launcher */ |
900 | 2924 | 2949 | ||
901 | === modified file 'src/bamf-matcher.h' | |||
902 | --- src/bamf-matcher.h 2013-06-26 20:34:40 +0000 | |||
903 | +++ src/bamf-matcher.h 2013-08-06 16:20:35 +0000 | |||
904 | @@ -114,6 +114,8 @@ | |||
905 | 114 | char * bamf_matcher_get_trimmed_exec (BamfMatcher *matcher, | 114 | char * bamf_matcher_get_trimmed_exec (BamfMatcher *matcher, |
906 | 115 | const char *exec_string); | 115 | const char *exec_string); |
907 | 116 | 116 | ||
908 | 117 | BamfView * bamf_matcher_get_view_by_path (BamfMatcher *matcher, | ||
909 | 118 | const char *view_path); | ||
910 | 117 | 119 | ||
911 | 118 | BamfMatcher * bamf_matcher_get_default (void); | 120 | BamfMatcher * bamf_matcher_get_default (void); |
912 | 119 | 121 | ||
913 | 120 | 122 | ||
914 | === modified file 'src/bamf-tab.c' | |||
915 | --- src/bamf-tab.c 2013-06-13 17:08:07 +0000 | |||
916 | +++ src/bamf-tab.c 2013-08-06 16:20:35 +0000 | |||
917 | @@ -122,10 +122,9 @@ | |||
918 | 122 | GDBusMethodInvocation *invocation, | 122 | GDBusMethodInvocation *invocation, |
919 | 123 | BamfTab *self) | 123 | BamfTab *self) |
920 | 124 | { | 124 | { |
921 | 125 | g_dbus_method_invocation_return_value (invocation, NULL); | ||
922 | 125 | bamf_tab_raise (self); | 126 | bamf_tab_raise (self); |
923 | 126 | 127 | ||
924 | 127 | g_dbus_method_invocation_return_value (invocation, NULL); | ||
925 | 128 | |||
926 | 129 | return TRUE; | 128 | return TRUE; |
927 | 130 | } | 129 | } |
928 | 131 | 130 | ||
929 | @@ -134,10 +133,9 @@ | |||
930 | 134 | GDBusMethodInvocation *invocation, | 133 | GDBusMethodInvocation *invocation, |
931 | 135 | BamfTab *self) | 134 | BamfTab *self) |
932 | 136 | { | 135 | { |
933 | 136 | g_dbus_method_invocation_return_value (invocation, NULL); | ||
934 | 137 | bamf_tab_close (self); | 137 | bamf_tab_close (self); |
935 | 138 | 138 | ||
936 | 139 | g_dbus_method_invocation_return_value (invocation, NULL); | ||
937 | 140 | |||
938 | 141 | return TRUE; | 139 | return TRUE; |
939 | 142 | } | 140 | } |
940 | 143 | 141 | ||
941 | 144 | 142 | ||
942 | === modified file 'src/bamf-unity-webapps-application.c' | |||
943 | --- src/bamf-unity-webapps-application.c 2013-06-26 11:54:58 +0000 | |||
944 | +++ src/bamf-unity-webapps-application.c 2013-08-06 16:20:35 +0000 | |||
945 | @@ -229,7 +229,16 @@ | |||
946 | 229 | static gchar * | 229 | static gchar * |
947 | 230 | bamf_unity_webapps_application_get_stable_bus_name (BamfView *view) | 230 | bamf_unity_webapps_application_get_stable_bus_name (BamfView *view) |
948 | 231 | { | 231 | { |
950 | 232 | return g_strdup_printf ("application%i", abs (g_str_hash (bamf_application_get_desktop_file (BAMF_APPLICATION (view))))); | 232 | const gchar *desktop_file; |
951 | 233 | |||
952 | 234 | desktop_file = bamf_application_get_desktop_file (BAMF_APPLICATION (view)); | ||
953 | 235 | |||
954 | 236 | if (desktop_file) | ||
955 | 237 | { | ||
956 | 238 | return g_strdup_printf ("application%i", abs (g_str_hash (desktop_file))); | ||
957 | 239 | } | ||
958 | 240 | |||
959 | 241 | return g_strdup_printf ("application%p", view); | ||
960 | 233 | } | 242 | } |
961 | 234 | 243 | ||
962 | 235 | 244 | ||
963 | 236 | 245 | ||
964 | === modified file 'src/bamf-unity-webapps-observer.c' | |||
965 | --- src/bamf-unity-webapps-observer.c 2013-07-16 16:19:42 +0000 | |||
966 | +++ src/bamf-unity-webapps-observer.c 2013-08-06 16:20:35 +0000 | |||
967 | @@ -155,7 +155,6 @@ | |||
968 | 155 | unity_webapps_service_on_context_vanished (observer->priv->service, bamf_unity_webapps_observer_context_vanished, observer); | 155 | unity_webapps_service_on_context_vanished (observer->priv->service, bamf_unity_webapps_observer_context_vanished, observer); |
969 | 156 | 156 | ||
970 | 157 | bamf_unity_webapps_observer_register_existing_contexts (observer, observer->priv->service); | 157 | bamf_unity_webapps_observer_register_existing_contexts (observer, observer->priv->service); |
971 | 158 | |||
972 | 159 | } | 158 | } |
973 | 160 | 159 | ||
974 | 161 | static void | 160 | static void |
975 | 162 | 161 | ||
976 | === modified file 'tests/bamfdaemon/test-application.c' | |||
977 | --- tests/bamfdaemon/test-application.c 2013-07-23 21:45:59 +0000 | |||
978 | +++ tests/bamfdaemon/test-application.c 2013-08-06 16:20:35 +0000 | |||
979 | @@ -328,7 +328,7 @@ | |||
980 | 328 | g_assert (g_file_test (test_icon, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)); | 328 | g_assert (g_file_test (test_icon, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)); |
981 | 329 | 329 | ||
982 | 330 | key_file = g_key_file_new (); | 330 | key_file = g_key_file_new (); |
984 | 331 | g_key_file_load_from_file (key_file, test_app, (GKeyFileFlags)0, NULL); | 331 | g_key_file_load_from_file (key_file, test_app, G_KEY_FILE_NONE, NULL); |
985 | 332 | g_key_file_set_string (key_file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_ICON, test_icon); | 332 | g_key_file_set_string (key_file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_ICON, test_icon); |
986 | 333 | 333 | ||
987 | 334 | gchar *key_data = g_key_file_to_data (key_file, NULL, NULL); | 334 | gchar *key_data = g_key_file_to_data (key_file, NULL, NULL); |
988 | @@ -358,7 +358,7 @@ | |||
989 | 358 | g_assert (!g_file_test (invalid_test_icon, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)); | 358 | g_assert (!g_file_test (invalid_test_icon, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)); |
990 | 359 | 359 | ||
991 | 360 | key_file = g_key_file_new (); | 360 | key_file = g_key_file_new (); |
993 | 361 | g_key_file_load_from_file (key_file, test_app, (GKeyFileFlags)0, NULL); | 361 | g_key_file_load_from_file (key_file, test_app, G_KEY_FILE_NONE, NULL); |
994 | 362 | g_key_file_set_string (key_file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_ICON, invalid_test_icon); | 362 | g_key_file_set_string (key_file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_ICON, invalid_test_icon); |
995 | 363 | 363 | ||
996 | 364 | gchar *key_data = g_key_file_to_data (key_file, NULL, NULL); | 364 | gchar *key_data = g_key_file_to_data (key_file, NULL, NULL); |
997 | @@ -1099,6 +1099,218 @@ | |||
998 | 1099 | } | 1099 | } |
999 | 1100 | 1100 | ||
1000 | 1101 | static void | 1101 | static void |
1001 | 1102 | test_desktop_app_create_local_desktop_file (void) | ||
1002 | 1103 | { | ||
1003 | 1104 | BamfApplication *application; | ||
1004 | 1105 | BamfLegacyWindowTest *lwin; | ||
1005 | 1106 | BamfWindow *win; | ||
1006 | 1107 | |||
1007 | 1108 | application = bamf_application_new (); | ||
1008 | 1109 | bamf_application_set_desktop_file (application, DESKTOP_FILE); | ||
1009 | 1110 | lwin = bamf_legacy_window_test_new (20, "window", "test-bamf-class", "execution-binary"); | ||
1010 | 1111 | win = bamf_window_new (BAMF_LEGACY_WINDOW (lwin)); | ||
1011 | 1112 | bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (win)); | ||
1012 | 1113 | |||
1013 | 1114 | g_assert (!bamf_application_create_local_desktop_file (application)); | ||
1014 | 1115 | |||
1015 | 1116 | g_object_unref (lwin); | ||
1016 | 1117 | g_object_unref (win); | ||
1017 | 1118 | g_object_unref (application); | ||
1018 | 1119 | } | ||
1019 | 1120 | |||
1020 | 1121 | static void | ||
1021 | 1122 | test_desktopless_app_create_local_desktop_file_invalid_exec (void) | ||
1022 | 1123 | { | ||
1023 | 1124 | BamfApplication *application; | ||
1024 | 1125 | BamfLegacyWindowTest *lwin; | ||
1025 | 1126 | BamfWindow *win; | ||
1026 | 1127 | |||
1027 | 1128 | application = bamf_application_new (); | ||
1028 | 1129 | lwin = bamf_legacy_window_test_new (20, "window", "test-bamf-class", NULL); | ||
1029 | 1130 | win = bamf_window_new (BAMF_LEGACY_WINDOW (lwin)); | ||
1030 | 1131 | bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (win)); | ||
1031 | 1132 | |||
1032 | 1133 | g_assert (!bamf_application_create_local_desktop_file (application)); | ||
1033 | 1134 | |||
1034 | 1135 | g_object_unref (lwin); | ||
1035 | 1136 | g_object_unref (win); | ||
1036 | 1137 | g_object_unref (application); | ||
1037 | 1138 | } | ||
1038 | 1139 | |||
1039 | 1140 | static void | ||
1040 | 1141 | verify_application_desktop_file_content (BamfApplication *application) | ||
1041 | 1142 | { | ||
1042 | 1143 | GKeyFile *key_file; | ||
1043 | 1144 | const gchar *desktop_file, *exec, *class; | ||
1044 | 1145 | gchar *str_value; | ||
1045 | 1146 | GError *error = NULL; | ||
1046 | 1147 | BamfView *main_child; | ||
1047 | 1148 | BamfLegacyWindow *main_window; | ||
1048 | 1149 | |||
1049 | 1150 | desktop_file = bamf_application_get_desktop_file (application); | ||
1050 | 1151 | |||
1051 | 1152 | key_file = g_key_file_new (); | ||
1052 | 1153 | g_key_file_load_from_file (key_file, desktop_file, G_KEY_FILE_NONE, NULL); | ||
1053 | 1154 | |||
1054 | 1155 | str_value = g_key_file_get_string (key_file, G_KEY_FILE_DESKTOP_GROUP, | ||
1055 | 1156 | G_KEY_FILE_DESKTOP_KEY_TYPE, &error); | ||
1056 | 1157 | g_assert (!error); | ||
1057 | 1158 | g_assert_cmpstr (str_value, ==, G_KEY_FILE_DESKTOP_TYPE_APPLICATION); | ||
1058 | 1159 | g_clear_pointer (&str_value, g_free); | ||
1059 | 1160 | |||
1060 | 1161 | if (bamf_view_get_name (BAMF_VIEW (application))) | ||
1061 | 1162 | { | ||
1062 | 1163 | str_value = g_key_file_get_string (key_file, G_KEY_FILE_DESKTOP_GROUP, | ||
1063 | 1164 | G_KEY_FILE_DESKTOP_KEY_NAME, &error); | ||
1064 | 1165 | g_assert (!error); | ||
1065 | 1166 | g_assert_cmpstr (str_value, ==, bamf_view_get_name (BAMF_VIEW (application))); | ||
1066 | 1167 | g_clear_pointer (&str_value, g_free); | ||
1067 | 1168 | } | ||
1068 | 1169 | |||
1069 | 1170 | if (bamf_view_get_icon (BAMF_VIEW (application))) | ||
1070 | 1171 | { | ||
1071 | 1172 | str_value = g_key_file_get_string (key_file, G_KEY_FILE_DESKTOP_GROUP, | ||
1072 | 1173 | G_KEY_FILE_DESKTOP_KEY_ICON, &error); | ||
1073 | 1174 | g_assert (!error); | ||
1074 | 1175 | g_assert_cmpstr (str_value, ==, bamf_view_get_icon (BAMF_VIEW (application))); | ||
1075 | 1176 | g_clear_pointer (&str_value, g_free); | ||
1076 | 1177 | } | ||
1077 | 1178 | |||
1078 | 1179 | main_child = bamf_application_get_main_child (application); | ||
1079 | 1180 | main_window = bamf_window_get_window (BAMF_WINDOW (main_child)); | ||
1080 | 1181 | exec = bamf_legacy_window_get_exec_string (main_window); | ||
1081 | 1182 | |||
1082 | 1183 | str_value = g_key_file_get_string (key_file, G_KEY_FILE_DESKTOP_GROUP, | ||
1083 | 1184 | G_KEY_FILE_DESKTOP_KEY_EXEC, &error); | ||
1084 | 1185 | g_assert (!error); | ||
1085 | 1186 | g_assert_cmpstr (str_value, ==, exec); | ||
1086 | 1187 | g_clear_pointer (&str_value, g_free); | ||
1087 | 1188 | |||
1088 | 1189 | g_assert (g_key_file_get_boolean (key_file, G_KEY_FILE_DESKTOP_GROUP, | ||
1089 | 1190 | G_KEY_FILE_DESKTOP_KEY_STARTUP_NOTIFY, &error)); | ||
1090 | 1191 | g_assert (!error); | ||
1091 | 1192 | |||
1092 | 1193 | class = bamf_legacy_window_get_class_instance_name (main_window); | ||
1093 | 1194 | class = class ? class : bamf_legacy_window_get_class_name (main_window); | ||
1094 | 1195 | |||
1095 | 1196 | if (class) | ||
1096 | 1197 | { | ||
1097 | 1198 | str_value = g_key_file_get_string (key_file, G_KEY_FILE_DESKTOP_GROUP, | ||
1098 | 1199 | G_KEY_FILE_DESKTOP_KEY_STARTUP_WM_CLASS, &error); | ||
1099 | 1200 | g_assert (!error); | ||
1100 | 1201 | g_assert_cmpstr (str_value, ==, class); | ||
1101 | 1202 | g_clear_pointer (&str_value, g_free); | ||
1102 | 1203 | } | ||
1103 | 1204 | |||
1104 | 1205 | g_key_file_free (key_file); | ||
1105 | 1206 | } | ||
1106 | 1207 | |||
1107 | 1208 | static void | ||
1108 | 1209 | test_desktopless_app_create_local_desktop_file_using_instance_class_basename (void) | ||
1109 | 1210 | { | ||
1110 | 1211 | BamfApplication *application; | ||
1111 | 1212 | BamfLegacyWindowTest *lwin; | ||
1112 | 1213 | BamfWindow *win; | ||
1113 | 1214 | const gchar *desktop_path; | ||
1114 | 1215 | |||
1115 | 1216 | application = bamf_application_new (); | ||
1116 | 1217 | lwin = bamf_legacy_window_test_new (20, "window", NULL, "awesome --exec"); | ||
1117 | 1218 | bamf_legacy_window_test_set_wmclass (lwin, "application-class", "instance-class"); | ||
1118 | 1219 | win = bamf_window_new (BAMF_LEGACY_WINDOW (lwin)); | ||
1119 | 1220 | bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (win)); | ||
1120 | 1221 | |||
1121 | 1222 | g_assert (bamf_application_create_local_desktop_file (application)); | ||
1122 | 1223 | |||
1123 | 1224 | desktop_path = bamf_application_get_desktop_file (application); | ||
1124 | 1225 | g_assert (desktop_path); | ||
1125 | 1226 | g_assert (g_str_has_suffix (desktop_path, "instance-class.desktop")); | ||
1126 | 1227 | g_assert (g_file_test (desktop_path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)); | ||
1127 | 1228 | verify_application_desktop_file_content (application); | ||
1128 | 1229 | |||
1129 | 1230 | g_object_unref (lwin); | ||
1130 | 1231 | g_object_unref (win); | ||
1131 | 1232 | g_object_unref (application); | ||
1132 | 1233 | } | ||
1133 | 1234 | |||
1134 | 1235 | static void | ||
1135 | 1236 | test_desktopless_app_create_local_desktop_file_using_name_class_basename (void) | ||
1136 | 1237 | { | ||
1137 | 1238 | BamfApplication *application; | ||
1138 | 1239 | BamfLegacyWindowTest *lwin; | ||
1139 | 1240 | BamfWindow *win; | ||
1140 | 1241 | const gchar *desktop_path; | ||
1141 | 1242 | |||
1142 | 1243 | application = bamf_application_new (); | ||
1143 | 1244 | lwin = bamf_legacy_window_test_new (20, "window", "Application!/?Class", "awesome --exec"); | ||
1144 | 1245 | win = bamf_window_new (BAMF_LEGACY_WINDOW (lwin)); | ||
1145 | 1246 | bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (win)); | ||
1146 | 1247 | |||
1147 | 1248 | g_assert (bamf_application_create_local_desktop_file (application)); | ||
1148 | 1249 | |||
1149 | 1250 | desktop_path = bamf_application_get_desktop_file (application); | ||
1150 | 1251 | g_assert (desktop_path); | ||
1151 | 1252 | g_assert (g_str_has_suffix (desktop_path, "application___class.desktop")); | ||
1152 | 1253 | g_assert (g_file_test (desktop_path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)); | ||
1153 | 1254 | verify_application_desktop_file_content (application); | ||
1154 | 1255 | |||
1155 | 1256 | g_object_unref (lwin); | ||
1156 | 1257 | g_object_unref (win); | ||
1157 | 1258 | g_object_unref (application); | ||
1158 | 1259 | } | ||
1159 | 1260 | |||
1160 | 1261 | static void | ||
1161 | 1262 | test_desktopless_app_create_local_desktop_file_using_exec_basename (void) | ||
1162 | 1263 | { | ||
1163 | 1264 | BamfApplication *application; | ||
1164 | 1265 | BamfLegacyWindowTest *lwin; | ||
1165 | 1266 | BamfWindow *win; | ||
1166 | 1267 | const gchar *desktop_path; | ||
1167 | 1268 | |||
1168 | 1269 | application = bamf_application_new (); | ||
1169 | 1270 | lwin = bamf_legacy_window_test_new (20, "window", NULL, "awesome --exec"); | ||
1170 | 1271 | win = bamf_window_new (BAMF_LEGACY_WINDOW (lwin)); | ||
1171 | 1272 | bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (win)); | ||
1172 | 1273 | |||
1173 | 1274 | g_assert (bamf_application_create_local_desktop_file (application)); | ||
1174 | 1275 | |||
1175 | 1276 | desktop_path = bamf_application_get_desktop_file (application); | ||
1176 | 1277 | g_assert (desktop_path); | ||
1177 | 1278 | g_assert (g_str_has_suffix (desktop_path, "awesome.desktop")); | ||
1178 | 1279 | g_assert (g_file_test (desktop_path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)); | ||
1179 | 1280 | verify_application_desktop_file_content (application); | ||
1180 | 1281 | |||
1181 | 1282 | g_object_unref (lwin); | ||
1182 | 1283 | g_object_unref (win); | ||
1183 | 1284 | g_object_unref (application); | ||
1184 | 1285 | } | ||
1185 | 1286 | |||
1186 | 1287 | static void | ||
1187 | 1288 | test_desktopless_app_create_local_desktop_file_using_trimmed_exec_basename (void) | ||
1188 | 1289 | { | ||
1189 | 1290 | BamfApplication *application; | ||
1190 | 1291 | BamfLegacyWindowTest *lwin; | ||
1191 | 1292 | BamfWindow *win; | ||
1192 | 1293 | const gchar *desktop_path; | ||
1193 | 1294 | |||
1194 | 1295 | application = bamf_application_new (); | ||
1195 | 1296 | lwin = bamf_legacy_window_test_new (20, "window", NULL, "python awesome-script.py"); | ||
1196 | 1297 | win = bamf_window_new (BAMF_LEGACY_WINDOW (lwin)); | ||
1197 | 1298 | bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (win)); | ||
1198 | 1299 | |||
1199 | 1300 | g_assert (bamf_application_create_local_desktop_file (application)); | ||
1200 | 1301 | |||
1201 | 1302 | desktop_path = bamf_application_get_desktop_file (application); | ||
1202 | 1303 | g_assert (desktop_path); | ||
1203 | 1304 | g_assert (g_str_has_suffix (desktop_path, "awesome-script.desktop")); | ||
1204 | 1305 | g_assert (g_file_test (desktop_path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)); | ||
1205 | 1306 | verify_application_desktop_file_content (application); | ||
1206 | 1307 | |||
1207 | 1308 | g_object_unref (lwin); | ||
1208 | 1309 | g_object_unref (win); | ||
1209 | 1310 | g_object_unref (application); | ||
1210 | 1311 | } | ||
1211 | 1312 | |||
1212 | 1313 | static void | ||
1213 | 1102 | test_contain_similar_to_window (void) | 1314 | test_contain_similar_to_window (void) |
1214 | 1103 | { | 1315 | { |
1215 | 1104 | BamfApplication *application; | 1316 | BamfApplication *application; |
1216 | @@ -1202,6 +1414,7 @@ | |||
1217 | 1202 | g_test_add_func (DOMAIN"/DesktopFile/MainChild", test_desktop_app_main_child); | 1414 | g_test_add_func (DOMAIN"/DesktopFile/MainChild", test_desktop_app_main_child); |
1218 | 1203 | g_test_add_func (DOMAIN"/DesktopFile/MainChild/NotMatchEmblems", test_desktop_app_main_child_doesnt_match_emblems); | 1415 | g_test_add_func (DOMAIN"/DesktopFile/MainChild/NotMatchEmblems", test_desktop_app_main_child_doesnt_match_emblems); |
1219 | 1204 | g_test_add_func (DOMAIN"/DesktopFile/MainChild/NotUpdatesEmblems", test_desktop_app_main_child_doesnt_update_emblems); | 1416 | g_test_add_func (DOMAIN"/DesktopFile/MainChild/NotUpdatesEmblems", test_desktop_app_main_child_doesnt_update_emblems); |
1220 | 1417 | g_test_add_func (DOMAIN"/DesktopFile/CreateLocalDesktopFile", test_desktop_app_create_local_desktop_file); | ||
1221 | 1205 | g_test_add_func (DOMAIN"/DesktopLess/Icon/ClassName", test_icon_class_name); | 1418 | g_test_add_func (DOMAIN"/DesktopLess/Icon/ClassName", test_icon_class_name); |
1222 | 1206 | g_test_add_func (DOMAIN"/DesktopLess/Icon/Exec", test_icon_exec_string); | 1419 | g_test_add_func (DOMAIN"/DesktopLess/Icon/Exec", test_icon_exec_string); |
1223 | 1207 | g_test_add_func (DOMAIN"/DesktopLess/Icon/Embedded", test_icon_embedded); | 1420 | g_test_add_func (DOMAIN"/DesktopLess/Icon/Embedded", test_icon_embedded); |
1224 | @@ -1215,6 +1428,11 @@ | |||
1225 | 1215 | g_test_add_func (DOMAIN"/DesktopLess/MainChild/NormalPriority", test_app_main_child_normal_priority); | 1428 | g_test_add_func (DOMAIN"/DesktopLess/MainChild/NormalPriority", test_app_main_child_normal_priority); |
1226 | 1216 | g_test_add_func (DOMAIN"/DesktopLess/MainChild/Removal", test_app_main_child_on_window_removal); | 1429 | g_test_add_func (DOMAIN"/DesktopLess/MainChild/Removal", test_app_main_child_on_window_removal); |
1227 | 1217 | g_test_add_func (DOMAIN"/DesktopLess/MainChild/ReplaceOnRemoval", test_app_main_child_on_window_replace_on_removal); | 1430 | g_test_add_func (DOMAIN"/DesktopLess/MainChild/ReplaceOnRemoval", test_app_main_child_on_window_replace_on_removal); |
1228 | 1431 | g_test_add_func (DOMAIN"/DesktopLess/CreateLocalDesktopFile/InvalidExec", test_desktopless_app_create_local_desktop_file_invalid_exec); | ||
1229 | 1432 | g_test_add_func (DOMAIN"/DesktopLess/CreateLocalDesktopFile/UsingClassInstance", test_desktopless_app_create_local_desktop_file_using_instance_class_basename); | ||
1230 | 1433 | g_test_add_func (DOMAIN"/DesktopLess/CreateLocalDesktopFile/UsingClassName", test_desktopless_app_create_local_desktop_file_using_name_class_basename); | ||
1231 | 1434 | g_test_add_func (DOMAIN"/DesktopLess/CreateLocalDesktopFile/UsingExec", test_desktopless_app_create_local_desktop_file_using_exec_basename); | ||
1232 | 1435 | g_test_add_func (DOMAIN"/DesktopLess/CreateLocalDesktopFile/UsingTrimmedExec", test_desktopless_app_create_local_desktop_file_using_trimmed_exec_basename); | ||
1233 | 1218 | g_test_add_func (DOMAIN"/ManagesXid", test_manages_xid); | 1436 | g_test_add_func (DOMAIN"/ManagesXid", test_manages_xid); |
1234 | 1219 | g_test_add_func (DOMAIN"/GetWindow", test_get_window); | 1437 | g_test_add_func (DOMAIN"/GetWindow", test_get_window); |
1235 | 1220 | g_test_add_func (DOMAIN"/Xids", test_get_xids); | 1438 | g_test_add_func (DOMAIN"/Xids", test_get_xids); |
1236 | 1221 | 1439 | ||
1237 | === modified file 'tests/bamfdaemon/test-bamf.c' | |||
1238 | --- tests/bamfdaemon/test-bamf.c 2013-07-16 14:46:37 +0000 | |||
1239 | +++ tests/bamfdaemon/test-bamf.c 2013-08-06 16:20:35 +0000 | |||
1240 | @@ -82,6 +82,15 @@ | |||
1241 | 82 | { | 82 | { |
1242 | 83 | GMainLoop *loop; | 83 | GMainLoop *loop; |
1243 | 84 | 84 | ||
1244 | 85 | GFile *tmp_dir; | ||
1245 | 86 | gchar *tmp_path; | ||
1246 | 87 | |||
1247 | 88 | tmp_path = g_dir_make_tmp (".bamfhomedataXXXXXX", NULL); | ||
1248 | 89 | tmp_dir = g_file_new_for_path (tmp_path); | ||
1249 | 90 | g_file_make_directory (tmp_dir, NULL, NULL); | ||
1250 | 91 | g_setenv ("XDG_DATA_HOME", tmp_path, TRUE); | ||
1251 | 92 | g_free (tmp_path); | ||
1252 | 93 | |||
1253 | 85 | gtk_init (&argc, &argv); | 94 | gtk_init (&argc, &argv); |
1254 | 86 | g_test_init (&argc, &argv, NULL); | 95 | g_test_init (&argc, &argv, NULL); |
1255 | 87 | glibtop_init (); | 96 | glibtop_init (); |
1256 | @@ -99,5 +108,8 @@ | |||
1257 | 99 | 108 | ||
1258 | 100 | g_main_loop_run (loop); | 109 | g_main_loop_run (loop); |
1259 | 101 | 110 | ||
1260 | 111 | g_file_delete (tmp_dir, NULL, NULL); | ||
1261 | 112 | g_object_unref (tmp_dir); | ||
1262 | 113 | |||
1263 | 102 | return result; | 114 | return result; |
1264 | 103 | } | 115 | } |
1265 | 104 | 116 | ||
1266 | === modified file 'tests/bamfdaemon/test-matcher.c' | |||
1267 | --- tests/bamfdaemon/test-matcher.c 2013-07-24 00:11:46 +0000 | |||
1268 | +++ tests/bamfdaemon/test-matcher.c 2013-08-06 16:20:35 +0000 | |||
1269 | @@ -1176,6 +1176,42 @@ | |||
1270 | 1176 | } | 1176 | } |
1271 | 1177 | } | 1177 | } |
1272 | 1178 | 1178 | ||
1273 | 1179 | static void | ||
1274 | 1180 | test_get_view_by_path (void) | ||
1275 | 1181 | { | ||
1276 | 1182 | BamfMatcher *matcher; | ||
1277 | 1183 | BamfLegacyScreen *screen; | ||
1278 | 1184 | BamfLegacyWindowTest *lwin; | ||
1279 | 1185 | BamfApplication *app; | ||
1280 | 1186 | BamfWindow *win; | ||
1281 | 1187 | GList *app_children; | ||
1282 | 1188 | guint32 xid; | ||
1283 | 1189 | |||
1284 | 1190 | screen = bamf_legacy_screen_get_default(); | ||
1285 | 1191 | matcher = bamf_matcher_get_default (); | ||
1286 | 1192 | |||
1287 | 1193 | cleanup_matcher_tables (matcher); | ||
1288 | 1194 | export_matcher_on_bus (matcher); | ||
1289 | 1195 | |||
1290 | 1196 | xid = g_random_int (); | ||
1291 | 1197 | lwin = bamf_legacy_window_test_new (xid, "Window", NULL, NULL); | ||
1292 | 1198 | _bamf_legacy_screen_open_test_window (screen, lwin); | ||
1293 | 1199 | |||
1294 | 1200 | app = bamf_matcher_get_application_by_xid (matcher, xid); | ||
1295 | 1201 | const char *app_path = bamf_view_get_path (BAMF_VIEW (app)); | ||
1296 | 1202 | g_assert (app == BAMF_APPLICATION (bamf_matcher_get_view_by_path (matcher, app_path))); | ||
1297 | 1203 | |||
1298 | 1204 | app_children = bamf_view_get_children (BAMF_VIEW (app)); | ||
1299 | 1205 | g_assert (app_children); | ||
1300 | 1206 | |||
1301 | 1207 | win = BAMF_WINDOW (app_children->data); | ||
1302 | 1208 | const char *win_path = bamf_view_get_path (BAMF_VIEW (win)); | ||
1303 | 1209 | g_assert (win == BAMF_WINDOW (bamf_matcher_get_view_by_path (matcher, win_path))); | ||
1304 | 1210 | |||
1305 | 1211 | g_object_unref (matcher); | ||
1306 | 1212 | g_object_unref (screen); | ||
1307 | 1213 | } | ||
1308 | 1214 | |||
1309 | 1179 | /* Initialize test suite */ | 1215 | /* Initialize test suite */ |
1310 | 1180 | 1216 | ||
1311 | 1181 | void | 1217 | void |
1312 | @@ -1187,6 +1223,7 @@ | |||
1313 | 1187 | g_test_add_func (DOMAIN"/AutostartDesktopFile/User", test_autostart_desktop_file_user); | 1223 | g_test_add_func (DOMAIN"/AutostartDesktopFile/User", test_autostart_desktop_file_user); |
1314 | 1188 | g_test_add_func (DOMAIN"/AutostartDesktopFile/System", test_autostart_desktop_file_system); | 1224 | g_test_add_func (DOMAIN"/AutostartDesktopFile/System", test_autostart_desktop_file_system); |
1315 | 1189 | g_test_add_func (DOMAIN"/ExecStringTrimming", test_trim_exec_string); | 1225 | g_test_add_func (DOMAIN"/ExecStringTrimming", test_trim_exec_string); |
1316 | 1226 | g_test_add_func (DOMAIN"/GetViewByPath", test_get_view_by_path); | ||
1317 | 1190 | g_test_add_func (DOMAIN"/LoadDesktopFile", test_load_desktop_file); | 1227 | g_test_add_func (DOMAIN"/LoadDesktopFile", test_load_desktop_file); |
1318 | 1191 | g_test_add_func (DOMAIN"/LoadDesktopFile/Autostart", test_load_desktop_file_autostart); | 1228 | g_test_add_func (DOMAIN"/LoadDesktopFile/Autostart", test_load_desktop_file_autostart); |
1319 | 1192 | g_test_add_func (DOMAIN"/LoadDesktopFile/NoDisplay/SameID", test_load_desktop_file_no_display_has_lower_prio_same_id); | 1229 | g_test_add_func (DOMAIN"/LoadDesktopFile/NoDisplay/SameID", test_load_desktop_file_no_display_has_lower_prio_same_id); |
FAILED: Continuous integration, rev:644 jenkins. qa.ubuntu. com/job/ bamf-ci/ 79/ jenkins. qa.ubuntu. com/job/ bamf-saucy- amd64-ci/ 60/console jenkins. qa.ubuntu. com/job/ bamf-saucy- armhf-ci/ 61/console
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild: s-jenkins: 8080/job/ bamf-ci/ 79/rebuild
http://