Merge lp:~3v1n0/libappindicator/incons-paths-on-snap into lp:libappindicator/16.10
- incons-paths-on-snap
- Merge into trunk.16.10
Status: | Merged |
---|---|
Approved by: | Andrea Azzarone |
Approved revision: | 288 |
Merged at revision: | 277 |
Proposed branch: | lp:~3v1n0/libappindicator/incons-paths-on-snap |
Merge into: | lp:libappindicator/16.10 |
Diff against target: |
353 lines (+124/-14) 5 files modified
configure.ac (+1/-1) debian/control (+1/-0) debian/rules (+0/-2) example/simple-client-vala.vala (+1/-1) src/app-indicator.c (+121/-10) |
To merge this branch: | bzr merge lp:~3v1n0/libappindicator/incons-paths-on-snap |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Andrea Azzarone (community) | Approve | ||
unity-api-1-bot | continuous-integration | Needs Fixing | |
Review via email: mp+311424@code.launchpad.net |
Commit message
AppIndicator: fix icon and theme paths when running in $SNAP environment
Prepend $SNAP path to icons and theme paths when running in a sandboxed
environment, this allows to run app indicators without caring about the fact
they've been designed or compiled to run in a snap world or not.
Description of the change
See gtk2/gtk3 examples using this at https:/
unity-api-1-bot (unity-api-1-bot) wrote : | # |
unity-api-1-bot (unity-api-1-bot) wrote : | # |
FAILED: Continuous integration, rev:284
https:/
Executed test runs:
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
unity-api-1-bot (unity-api-1-bot) wrote : | # |
FAILED: Continuous integration, rev:285
https:/
Executed test runs:
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
unity-api-1-bot (unity-api-1-bot) wrote : | # |
FAILED: Continuous integration, rev:286
https:/
Executed test runs:
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
unity-api-1-bot (unity-api-1-bot) wrote : | # |
FAILED: Continuous integration, rev:287
https:/
Executed test runs:
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
Marco Trevisan (Treviño) (3v1n0) wrote : | # |
Actually I've noticed that this is not correct when the developer uses an hardcoded path suc has /snap/$
So it needs some tuning.
- 288. By Marco Trevisan (Treviño)
-
app-indicator: get real path on snap when trying to transform it
So when pointing to /snap/<
name>/current will be automatically translated
to /snap/<name>/< current_ revision> /...
Marco Trevisan (Treviño) (3v1n0) wrote : | # |
Done this part too...
unity-api-1-bot (unity-api-1-bot) wrote : | # |
FAILED: Continuous integration, rev:288
https:/
Executed test runs:
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
unity-api-1-bot (unity-api-1-bot) wrote : | # |
FAILED: Continuous integration, rev:288
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Preview Diff
1 | === modified file 'configure.ac' | |||
2 | --- configure.ac 2013-01-29 17:50:13 +0000 | |||
3 | +++ configure.ac 2016-11-29 17:27:34 +0000 | |||
4 | @@ -121,7 +121,7 @@ | |||
5 | 121 | RUNTIME=mono | 121 | RUNTIME=mono |
6 | 122 | fi | 122 | fi |
7 | 123 | 123 | ||
9 | 124 | AC_PATH_PROG(CSC, gmcs, no) | 124 | AC_PATH_PROG(CSC, mono-csc, no) |
10 | 125 | LIB_PREFIX=.so | 125 | LIB_PREFIX=.so |
11 | 126 | LIB_SUFFIX= | 126 | LIB_SUFFIX= |
12 | 127 | fi | 127 | fi |
13 | 128 | 128 | ||
14 | === modified file 'debian/control' | |||
15 | --- debian/control 2013-12-19 14:37:54 +0000 | |||
16 | +++ debian/control 2016-11-29 17:27:34 +0000 | |||
17 | @@ -8,6 +8,7 @@ | |||
18 | 8 | python-all-dev, | 8 | python-all-dev, |
19 | 9 | at-spi2-core, | 9 | at-spi2-core, |
20 | 10 | cli-common-dev (>= 0.5.7) [!arm64 !ppc64el], | 10 | cli-common-dev (>= 0.5.7) [!arm64 !ppc64el], |
21 | 11 | gnome-common, | ||
22 | 11 | gobject-introspection, | 12 | gobject-introspection, |
23 | 12 | intltool, | 13 | intltool, |
24 | 13 | gtk-doc-tools, | 14 | gtk-doc-tools, |
25 | 14 | 15 | ||
26 | === modified file 'debian/rules' | |||
27 | --- debian/rules 2013-12-19 14:37:54 +0000 | |||
28 | +++ debian/rules 2016-11-29 17:27:34 +0000 | |||
29 | @@ -15,8 +15,6 @@ | |||
30 | 15 | CONFIGURE_FLAGS_gtk2 = --with-gtk=2 --enable-gtk-doc | 15 | CONFIGURE_FLAGS_gtk2 = --with-gtk=2 --enable-gtk-doc |
31 | 16 | CONFIGURE_FLAGS_gtk3 = --with-gtk=3 --enable-gtk-doc=no | 16 | CONFIGURE_FLAGS_gtk3 = --with-gtk=3 --enable-gtk-doc=no |
32 | 17 | 17 | ||
33 | 18 | export CSC=/usr/bin/mono-csc | ||
34 | 19 | |||
35 | 20 | export DPKG_GENSYMBOLS_CHECK_LEVEL = 4 | 18 | export DPKG_GENSYMBOLS_CHECK_LEVEL = 4 |
36 | 21 | 19 | ||
37 | 22 | CFLAGS += -fPIC | 20 | CFLAGS += -fPIC |
38 | 23 | 21 | ||
39 | === modified file 'example/simple-client-vala.vala' | |||
40 | --- example/simple-client-vala.vala 2012-03-21 18:02:41 +0000 | |||
41 | +++ example/simple-client-vala.vala 2016-11-29 17:27:34 +0000 | |||
42 | @@ -104,7 +104,7 @@ | |||
43 | 104 | print(@"Got scroll event! delta: $delta, direction: $direction\n"); | 104 | print(@"Got scroll event! delta: $delta, direction: $direction\n"); |
44 | 105 | }); | 105 | }); |
45 | 106 | 106 | ||
47 | 107 | Timeout.add_seconds(1, () => { | 107 | GLib.Timeout.add_seconds(1, () => { |
48 | 108 | percentage = (percentage + 1) % 100; | 108 | percentage = (percentage + 1) % 100; |
49 | 109 | if (can_haz_label) { | 109 | if (can_haz_label) { |
50 | 110 | ci.set_label(@"$(percentage+1)%", ""); | 110 | ci.set_label(@"$(percentage+1)%", ""); |
51 | 111 | 111 | ||
52 | === modified file 'src/app-indicator.c' | |||
53 | --- src/app-indicator.c 2015-07-02 17:03:37 +0000 | |||
54 | +++ src/app-indicator.c 2016-11-29 17:27:34 +0000 | |||
55 | @@ -38,6 +38,8 @@ | |||
56 | 38 | 38 | ||
57 | 39 | #include <libindicator/indicator-desktop-shortcuts.h> | 39 | #include <libindicator/indicator-desktop-shortcuts.h> |
58 | 40 | 40 | ||
59 | 41 | #include <stdlib.h> | ||
60 | 42 | |||
61 | 41 | #include "app-indicator.h" | 43 | #include "app-indicator.h" |
62 | 42 | #include "app-indicator-enum-types.h" | 44 | #include "app-indicator-enum-types.h" |
63 | 43 | #include "application-service-marshal.h" | 45 | #include "application-service-marshal.h" |
64 | @@ -71,8 +73,11 @@ | |||
65 | 71 | AppIndicatorCategory category; | 73 | AppIndicatorCategory category; |
66 | 72 | AppIndicatorStatus status; | 74 | AppIndicatorStatus status; |
67 | 73 | gchar *icon_name; | 75 | gchar *icon_name; |
68 | 76 | gchar *absolute_icon_name; | ||
69 | 74 | gchar *attention_icon_name; | 77 | gchar *attention_icon_name; |
70 | 78 | gchar *absolute_attention_icon_name; | ||
71 | 75 | gchar *icon_theme_path; | 79 | gchar *icon_theme_path; |
72 | 80 | gchar *absolute_icon_theme_path; | ||
73 | 76 | DbusmenuServer *menuservice; | 81 | DbusmenuServer *menuservice; |
74 | 77 | GtkWidget *menu; | 82 | GtkWidget *menu; |
75 | 78 | GtkWidget *sec_activate_target; | 83 | GtkWidget *sec_activate_target; |
76 | @@ -190,6 +195,8 @@ | |||
77 | 190 | static void status_icon_menu_activate (GtkStatusIcon *status_icon, guint button, guint activate_time, gpointer user_data); | 195 | static void status_icon_menu_activate (GtkStatusIcon *status_icon, guint button, guint activate_time, gpointer user_data); |
78 | 191 | static void unfallback (AppIndicator * self, GtkStatusIcon * status_icon); | 196 | static void unfallback (AppIndicator * self, GtkStatusIcon * status_icon); |
79 | 192 | static gchar * append_panel_icon_suffix (const gchar * icon_name); | 197 | static gchar * append_panel_icon_suffix (const gchar * icon_name); |
80 | 198 | static gchar * get_real_theme_path (AppIndicator * self); | ||
81 | 199 | static gchar * append_snap_prefix (const gchar * path); | ||
82 | 193 | static void theme_changed_cb (GtkIconTheme * theme, gpointer user_data); | 200 | static void theme_changed_cb (GtkIconTheme * theme, gpointer user_data); |
83 | 194 | static void sec_activate_target_parent_changed(GtkWidget *menuitem, GtkWidget *old_parent, gpointer user_data); | 201 | static void sec_activate_target_parent_changed(GtkWidget *menuitem, GtkWidget *old_parent, gpointer user_data); |
84 | 195 | static GVariant * bus_get_prop (GDBusConnection * connection, const gchar * sender, const gchar * path, const gchar * interface, const gchar * property, GError ** error, gpointer user_data); | 202 | static GVariant * bus_get_prop (GDBusConnection * connection, const gchar * sender, const gchar * path, const gchar * interface, const gchar * property, GError ** error, gpointer user_data); |
85 | @@ -389,7 +396,7 @@ | |||
86 | 389 | "An additional place to look for icon names that may be installed by the application.", | 396 | "An additional place to look for icon names that may be installed by the application.", |
87 | 390 | NULL, | 397 | NULL, |
88 | 391 | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT)); | 398 | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT)); |
90 | 392 | 399 | ||
91 | 393 | /** | 400 | /** |
92 | 394 | * AppIndicator:connected: | 401 | * AppIndicator:connected: |
93 | 395 | * | 402 | * |
94 | @@ -640,6 +647,7 @@ | |||
95 | 640 | app_indicator_init (AppIndicator *self) | 647 | app_indicator_init (AppIndicator *self) |
96 | 641 | { | 648 | { |
97 | 642 | AppIndicatorPrivate * priv = APP_INDICATOR_GET_PRIVATE(self); | 649 | AppIndicatorPrivate * priv = APP_INDICATOR_GET_PRIVATE(self); |
98 | 650 | self->priv = priv; | ||
99 | 643 | 651 | ||
100 | 644 | priv->id = NULL; | 652 | priv->id = NULL; |
101 | 645 | priv->clean_id = NULL; | 653 | priv->clean_id = NULL; |
102 | @@ -648,6 +656,7 @@ | |||
103 | 648 | priv->icon_name = NULL; | 656 | priv->icon_name = NULL; |
104 | 649 | priv->attention_icon_name = NULL; | 657 | priv->attention_icon_name = NULL; |
105 | 650 | priv->icon_theme_path = NULL; | 658 | priv->icon_theme_path = NULL; |
106 | 659 | priv->absolute_icon_theme_path = get_real_theme_path (self); | ||
107 | 651 | priv->menu = NULL; | 660 | priv->menu = NULL; |
108 | 652 | priv->menuservice = NULL; | 661 | priv->menuservice = NULL; |
109 | 653 | priv->ordering_index = 0; | 662 | priv->ordering_index = 0; |
110 | @@ -676,8 +685,6 @@ | |||
111 | 676 | (GBusNameVanishedCallback) name_vanished_handler, | 685 | (GBusNameVanishedCallback) name_vanished_handler, |
112 | 677 | self, NULL); | 686 | self, NULL); |
113 | 678 | 687 | ||
114 | 679 | self->priv = priv; | ||
115 | 680 | |||
116 | 681 | /* Start getting the session bus */ | 688 | /* Start getting the session bus */ |
117 | 682 | g_object_ref(self); /* ref for the bus creation callback */ | 689 | g_object_ref(self); /* ref for the bus creation callback */ |
118 | 683 | g_bus_get(G_BUS_TYPE_SESSION, NULL, bus_creation, self); | 690 | g_bus_get(G_BUS_TYPE_SESSION, NULL, bus_creation, self); |
119 | @@ -794,16 +801,31 @@ | |||
120 | 794 | priv->icon_name = NULL; | 801 | priv->icon_name = NULL; |
121 | 795 | } | 802 | } |
122 | 796 | 803 | ||
123 | 804 | if (priv->absolute_icon_name != NULL) { | ||
124 | 805 | g_free(priv->absolute_icon_name); | ||
125 | 806 | priv->absolute_icon_name = NULL; | ||
126 | 807 | } | ||
127 | 808 | |||
128 | 797 | if (priv->attention_icon_name != NULL) { | 809 | if (priv->attention_icon_name != NULL) { |
129 | 798 | g_free(priv->attention_icon_name); | 810 | g_free(priv->attention_icon_name); |
130 | 799 | priv->attention_icon_name = NULL; | 811 | priv->attention_icon_name = NULL; |
131 | 800 | } | 812 | } |
132 | 801 | 813 | ||
133 | 814 | if (priv->absolute_attention_icon_name != NULL) { | ||
134 | 815 | g_free(priv->absolute_attention_icon_name); | ||
135 | 816 | priv->absolute_attention_icon_name = NULL; | ||
136 | 817 | } | ||
137 | 818 | |||
138 | 802 | if (priv->icon_theme_path != NULL) { | 819 | if (priv->icon_theme_path != NULL) { |
139 | 803 | g_free(priv->icon_theme_path); | 820 | g_free(priv->icon_theme_path); |
140 | 804 | priv->icon_theme_path = NULL; | 821 | priv->icon_theme_path = NULL; |
141 | 805 | } | 822 | } |
143 | 806 | 823 | ||
144 | 824 | if (priv->absolute_icon_theme_path != NULL) { | ||
145 | 825 | g_free(priv->absolute_icon_theme_path); | ||
146 | 826 | priv->absolute_icon_theme_path = NULL; | ||
147 | 827 | } | ||
148 | 828 | |||
149 | 807 | if (priv->title != NULL) { | 829 | if (priv->title != NULL) { |
150 | 808 | g_free(priv->title); | 830 | g_free(priv->title); |
151 | 809 | priv->title = NULL; | 831 | priv->title = NULL; |
152 | @@ -1188,8 +1210,14 @@ | |||
153 | 1188 | enum_value = g_enum_get_value ((GEnumClass *) g_type_class_ref (APP_INDICATOR_TYPE_INDICATOR_STATUS), priv->status); | 1210 | enum_value = g_enum_get_value ((GEnumClass *) g_type_class_ref (APP_INDICATOR_TYPE_INDICATOR_STATUS), priv->status); |
154 | 1189 | return g_variant_new_string(enum_value->value_nick ? enum_value->value_nick : ""); | 1211 | return g_variant_new_string(enum_value->value_nick ? enum_value->value_nick : ""); |
155 | 1190 | } else if (g_strcmp0(property, "IconName") == 0) { | 1212 | } else if (g_strcmp0(property, "IconName") == 0) { |
156 | 1213 | if (priv->absolute_icon_name) { | ||
157 | 1214 | return g_variant_new_string(priv->absolute_icon_name); | ||
158 | 1215 | } | ||
159 | 1191 | return g_variant_new_string(priv->icon_name ? priv->icon_name : ""); | 1216 | return g_variant_new_string(priv->icon_name ? priv->icon_name : ""); |
160 | 1192 | } else if (g_strcmp0(property, "AttentionIconName") == 0) { | 1217 | } else if (g_strcmp0(property, "AttentionIconName") == 0) { |
161 | 1218 | if (priv->absolute_attention_icon_name) { | ||
162 | 1219 | return g_variant_new_string(priv->absolute_attention_icon_name); | ||
163 | 1220 | } | ||
164 | 1193 | return g_variant_new_string(priv->attention_icon_name ? priv->attention_icon_name : ""); | 1221 | return g_variant_new_string(priv->attention_icon_name ? priv->attention_icon_name : ""); |
165 | 1194 | } else if (g_strcmp0(property, "Title") == 0) { | 1222 | } else if (g_strcmp0(property, "Title") == 0) { |
166 | 1195 | const gchar * output = NULL; | 1223 | const gchar * output = NULL; |
167 | @@ -1205,6 +1233,9 @@ | |||
168 | 1205 | } | 1233 | } |
169 | 1206 | return g_variant_new_string(output); | 1234 | return g_variant_new_string(output); |
170 | 1207 | } else if (g_strcmp0(property, "IconThemePath") == 0) { | 1235 | } else if (g_strcmp0(property, "IconThemePath") == 0) { |
171 | 1236 | if (priv->absolute_icon_theme_path) { | ||
172 | 1237 | return g_variant_new_string(priv->absolute_icon_theme_path); | ||
173 | 1238 | } | ||
174 | 1208 | return g_variant_new_string(priv->icon_theme_path ? priv->icon_theme_path : ""); | 1239 | return g_variant_new_string(priv->icon_theme_path ? priv->icon_theme_path : ""); |
175 | 1209 | } else if (g_strcmp0(property, "Menu") == 0) { | 1240 | } else if (g_strcmp0(property, "Menu") == 0) { |
176 | 1210 | if (priv->menuservice != NULL) { | 1241 | if (priv->menuservice != NULL) { |
177 | @@ -1571,19 +1602,23 @@ | |||
178 | 1571 | 1602 | ||
179 | 1572 | /* add the icon_theme_path once if needed */ | 1603 | /* add the icon_theme_path once if needed */ |
180 | 1573 | GtkIconTheme *icon_theme = gtk_icon_theme_get_default(); | 1604 | GtkIconTheme *icon_theme = gtk_icon_theme_get_default(); |
182 | 1574 | if (self->priv->icon_theme_path != NULL) { | 1605 | const gchar *theme_path = self->priv->absolute_icon_theme_path ? |
183 | 1606 | self->priv->absolute_icon_theme_path : | ||
184 | 1607 | self->priv->icon_theme_path; | ||
185 | 1608 | |||
186 | 1609 | if (theme_path != NULL) { | ||
187 | 1575 | gchar **path; | 1610 | gchar **path; |
188 | 1576 | gint n_elements, i; | 1611 | gint n_elements, i; |
189 | 1577 | gboolean found=FALSE; | 1612 | gboolean found=FALSE; |
190 | 1578 | gtk_icon_theme_get_search_path(icon_theme, &path, &n_elements); | 1613 | gtk_icon_theme_get_search_path(icon_theme, &path, &n_elements); |
191 | 1579 | for (i=0; i< n_elements || path[i] == NULL; i++) { | 1614 | for (i=0; i< n_elements || path[i] == NULL; i++) { |
193 | 1580 | if(g_strcmp0(path[i], self->priv->icon_theme_path) == 0) { | 1615 | if(g_strcmp0(path[i], theme_path) == 0) { |
194 | 1581 | found=TRUE; | 1616 | found=TRUE; |
195 | 1582 | break; | 1617 | break; |
196 | 1583 | } | 1618 | } |
197 | 1584 | } | 1619 | } |
198 | 1585 | if(!found) { | 1620 | if(!found) { |
200 | 1586 | gtk_icon_theme_append_search_path(icon_theme, self->priv->icon_theme_path); | 1621 | gtk_icon_theme_append_search_path(icon_theme, theme_path); |
201 | 1587 | } | 1622 | } |
202 | 1588 | g_strfreev (path); | 1623 | g_strfreev (path); |
203 | 1589 | } | 1624 | } |
204 | @@ -1607,8 +1642,12 @@ | |||
205 | 1607 | }; | 1642 | }; |
206 | 1608 | 1643 | ||
207 | 1609 | if (icon_name != NULL) { | 1644 | if (icon_name != NULL) { |
208 | 1645 | gchar *snapped_icon = append_snap_prefix(icon_name); | ||
209 | 1646 | |||
210 | 1610 | if (g_file_test(icon_name, G_FILE_TEST_EXISTS)) { | 1647 | if (g_file_test(icon_name, G_FILE_TEST_EXISTS)) { |
211 | 1611 | gtk_status_icon_set_from_file(icon, icon_name); | 1648 | gtk_status_icon_set_from_file(icon, icon_name); |
212 | 1649 | } else if (snapped_icon && g_file_test(snapped_icon, G_FILE_TEST_EXISTS)) { | ||
213 | 1650 | gtk_status_icon_set_from_file(icon, snapped_icon); | ||
214 | 1612 | } else { | 1651 | } else { |
215 | 1613 | gchar *longname = append_panel_icon_suffix(icon_name); | 1652 | gchar *longname = append_panel_icon_suffix(icon_name); |
216 | 1614 | 1653 | ||
217 | @@ -1620,6 +1659,8 @@ | |||
218 | 1620 | 1659 | ||
219 | 1621 | g_free(longname); | 1660 | g_free(longname); |
220 | 1622 | } | 1661 | } |
221 | 1662 | |||
222 | 1663 | g_free(snapped_icon); | ||
223 | 1623 | } | 1664 | } |
224 | 1624 | 1665 | ||
225 | 1625 | return; | 1666 | return; |
226 | @@ -1633,7 +1674,7 @@ | |||
227 | 1633 | GtkMenu * menu = app_indicator_get_menu(APP_INDICATOR(data)); | 1674 | GtkMenu * menu = app_indicator_get_menu(APP_INDICATOR(data)); |
228 | 1634 | if (menu == NULL) | 1675 | if (menu == NULL) |
229 | 1635 | return; | 1676 | return; |
231 | 1636 | 1677 | ||
232 | 1637 | gtk_menu_popup(menu, | 1678 | gtk_menu_popup(menu, |
233 | 1638 | NULL, /* Parent Menu */ | 1679 | NULL, /* Parent Menu */ |
234 | 1639 | NULL, /* Parent item */ | 1680 | NULL, /* Parent item */ |
235 | @@ -1681,7 +1722,7 @@ | |||
236 | 1681 | long_name = g_strdup (icon_name); | 1722 | long_name = g_strdup (icon_name); |
237 | 1682 | } | 1723 | } |
238 | 1683 | 1724 | ||
240 | 1684 | return long_name; | 1725 | return long_name; |
241 | 1685 | } | 1726 | } |
242 | 1686 | 1727 | ||
243 | 1687 | static gboolean | 1728 | static gboolean |
244 | @@ -1858,6 +1899,14 @@ | |||
245 | 1858 | if (g_strcmp0 (self->priv->attention_icon_name, icon_name) != 0) { | 1899 | if (g_strcmp0 (self->priv->attention_icon_name, icon_name) != 0) { |
246 | 1859 | g_free (self->priv->attention_icon_name); | 1900 | g_free (self->priv->attention_icon_name); |
247 | 1860 | self->priv->attention_icon_name = g_strdup (icon_name); | 1901 | self->priv->attention_icon_name = g_strdup (icon_name); |
248 | 1902 | |||
249 | 1903 | g_free(self->priv->absolute_attention_icon_name); | ||
250 | 1904 | self->priv->absolute_attention_icon_name = NULL; | ||
251 | 1905 | |||
252 | 1906 | if (icon_name && icon_name[0] == '/') { | ||
253 | 1907 | self->priv->absolute_attention_icon_name = append_snap_prefix (icon_name); | ||
254 | 1908 | } | ||
255 | 1909 | |||
256 | 1861 | changed = TRUE; | 1910 | changed = TRUE; |
257 | 1862 | } | 1911 | } |
258 | 1863 | 1912 | ||
259 | @@ -1933,6 +1982,14 @@ | |||
260 | 1933 | } | 1982 | } |
261 | 1934 | 1983 | ||
262 | 1935 | self->priv->icon_name = g_strdup(icon_name); | 1984 | self->priv->icon_name = g_strdup(icon_name); |
263 | 1985 | |||
264 | 1986 | g_free(self->priv->absolute_icon_name); | ||
265 | 1987 | self->priv->absolute_icon_name = NULL; | ||
266 | 1988 | |||
267 | 1989 | if (icon_name && icon_name[0] == '/') { | ||
268 | 1990 | self->priv->absolute_icon_name = append_snap_prefix (icon_name); | ||
269 | 1991 | } | ||
270 | 1992 | |||
271 | 1936 | changed = TRUE; | 1993 | changed = TRUE; |
272 | 1937 | } | 1994 | } |
273 | 1938 | 1995 | ||
274 | @@ -1994,6 +2051,54 @@ | |||
275 | 1994 | return; | 2051 | return; |
276 | 1995 | } | 2052 | } |
277 | 1996 | 2053 | ||
278 | 2054 | static const gchar * | ||
279 | 2055 | get_snap_prefix () | ||
280 | 2056 | { | ||
281 | 2057 | const gchar *snap = g_getenv ("SNAP"); | ||
282 | 2058 | return (snap && *snap != '\0') ? snap : NULL; | ||
283 | 2059 | } | ||
284 | 2060 | |||
285 | 2061 | static gchar * | ||
286 | 2062 | append_snap_prefix (const gchar *path) | ||
287 | 2063 | { | ||
288 | 2064 | gchar real_path[PATH_MAX]; | ||
289 | 2065 | const gchar *snap = get_snap_prefix (); | ||
290 | 2066 | |||
291 | 2067 | if (snap != NULL && path != NULL) { | ||
292 | 2068 | if (realpath (path, real_path) != NULL) { | ||
293 | 2069 | path = real_path; | ||
294 | 2070 | } | ||
295 | 2071 | |||
296 | 2072 | if (g_str_has_prefix (path, "/tmp/")) { | ||
297 | 2073 | g_warning ("Using '/tmp' paths in SNAP environment will lead to unreadable resources"); | ||
298 | 2074 | return NULL; | ||
299 | 2075 | } | ||
300 | 2076 | |||
301 | 2077 | if (g_str_has_prefix (path, snap)) { | ||
302 | 2078 | return g_strdup (path); | ||
303 | 2079 | } | ||
304 | 2080 | |||
305 | 2081 | return g_build_path (G_DIR_SEPARATOR_S, snap, path, NULL); | ||
306 | 2082 | } | ||
307 | 2083 | |||
308 | 2084 | return NULL; | ||
309 | 2085 | } | ||
310 | 2086 | |||
311 | 2087 | static gchar * | ||
312 | 2088 | get_real_theme_path (AppIndicator * self) | ||
313 | 2089 | { | ||
314 | 2090 | const gchar *theme_path = self->priv->icon_theme_path; | ||
315 | 2091 | gchar *snapped_path = append_snap_prefix (theme_path); | ||
316 | 2092 | |||
317 | 2093 | if (snapped_path != NULL) { | ||
318 | 2094 | return snapped_path; | ||
319 | 2095 | } else if (get_snap_prefix ()) { | ||
320 | 2096 | return g_build_path (G_DIR_SEPARATOR_S, g_get_user_data_dir (), "icons", NULL); | ||
321 | 2097 | } | ||
322 | 2098 | |||
323 | 2099 | return NULL; | ||
324 | 2100 | } | ||
325 | 2101 | |||
326 | 1997 | /** | 2102 | /** |
327 | 1998 | * app_indicator_set_icon_theme_path: | 2103 | * app_indicator_set_icon_theme_path: |
328 | 1999 | * @self: The #AppIndicator object to use | 2104 | * @self: The #AppIndicator object to use |
329 | @@ -2012,9 +2117,15 @@ | |||
330 | 2012 | 2117 | ||
331 | 2013 | self->priv->icon_theme_path = g_strdup(icon_theme_path); | 2118 | self->priv->icon_theme_path = g_strdup(icon_theme_path); |
332 | 2014 | 2119 | ||
333 | 2120 | g_free (self->priv->absolute_icon_theme_path); | ||
334 | 2121 | self->priv->absolute_icon_theme_path = get_real_theme_path (self); | ||
335 | 2122 | |||
336 | 2015 | g_signal_emit (self, signals[NEW_ICON_THEME_PATH], 0, self->priv->icon_theme_path, TRUE); | 2123 | g_signal_emit (self, signals[NEW_ICON_THEME_PATH], 0, self->priv->icon_theme_path, TRUE); |
337 | 2016 | 2124 | ||
338 | 2017 | if (self->priv->dbus_registration != 0 && self->priv->connection != NULL) { | 2125 | if (self->priv->dbus_registration != 0 && self->priv->connection != NULL) { |
339 | 2126 | const gchar *theme_path = self->priv->absolute_icon_theme_path ? | ||
340 | 2127 | self->priv->absolute_icon_theme_path : | ||
341 | 2128 | self->priv->icon_theme_path; | ||
342 | 2018 | GError * error = NULL; | 2129 | GError * error = NULL; |
343 | 2019 | 2130 | ||
344 | 2020 | g_dbus_connection_emit_signal(self->priv->connection, | 2131 | g_dbus_connection_emit_signal(self->priv->connection, |
345 | @@ -2022,7 +2133,7 @@ | |||
346 | 2022 | self->priv->path, | 2133 | self->priv->path, |
347 | 2023 | NOTIFICATION_ITEM_DBUS_IFACE, | 2134 | NOTIFICATION_ITEM_DBUS_IFACE, |
348 | 2024 | "NewIconThemePath", | 2135 | "NewIconThemePath", |
350 | 2025 | g_variant_new("(s)", self->priv->icon_theme_path), | 2136 | g_variant_new("(s)", theme_path ? theme_path : ""), |
351 | 2026 | &error); | 2137 | &error); |
352 | 2027 | 2138 | ||
353 | 2028 | if (error != NULL) { | 2139 | if (error != NULL) { |
FAILED: Continuous integration, rev:283 /jenkins. canonical. com/unity- api-1/job/ lp-libappindica tor-ci/ 1/ /jenkins. canonical. com/unity- api-1/job/ build/1142/ console /jenkins. canonical. com/unity- api-1/job/ build-0- fetch/1149/ console
https:/
Executed test runs:
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild: /jenkins. canonical. com/unity- api-1/job/ lp-libappindica tor-ci/ 1/rebuild
https:/