33
private const string APP_PREFIX = "application://";
34
private const string FILE_PREFIX = "file://";
33
36
/* Private class to wire up the DBus stuff. Private so that we don't
34
37
* leak DBus implementation details into the public API */
171
174
Object (app_uri : app_uri);
174
177
public static LauncherEntry get_for_app_uri (string app_uri)
176
179
if (global_entries_map == null)
177
180
global_entries_map =
178
181
new HashTable<string, LauncherEntry> (str_hash, str_equal);
180
LauncherEntry? entry = global_entries_map.lookup (app_uri);
183
string real_app_uri = app_uri;
184
unowned string snap_path = Environment.get_variable ("SNAP");
185
unowned string snap_name = Environment.get_variable ("SNAP_NAME");
187
if (snap_path != null && snap_path != null)
189
debug (@"App is running into a snap container ($snap_name)");
190
string app = app_uri.substring (APP_PREFIX.length);
194
if (!FileUtils.test (app, FileTest.IS_REGULAR))
196
real_app_uri = APP_PREFIX + snap_path + app;
197
debug (@"Impossible to read file $app, trying with snap namespace: $real_app_uri");
202
string snap_app_prefix = snap_name + "_";
204
if (!app.has_prefix (snap_app_prefix))
206
real_app_uri = APP_PREFIX + snap_app_prefix + app;
207
debug (@"App uri does not contain the snap prefix, fixed: '$real_app_uri'");
212
LauncherEntry? entry = global_entries_map.lookup (real_app_uri);
181
213
if (entry != null)
186
entry = new LauncherEntry (app_uri);
187
global_entries_map.insert (app_uri, entry);
218
entry = new LauncherEntry (real_app_uri);
219
global_entries_map.insert (real_app_uri, entry);
191
223
public static LauncherEntry get_for_desktop_id (string desktop_id)
193
return LauncherEntry.get_for_app_uri ("application://" + desktop_id);
225
return LauncherEntry.get_for_app_uri (APP_PREFIX + desktop_id);
196
228
public static LauncherEntry get_for_desktop_file (string desktop_file)