summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTamaranch <138-Tamaranch@users.noreply.gitlab.xfce.org>2020-07-09 19:12:03 +0200
committerTamaranch <138-Tamaranch@users.noreply.gitlab.xfce.org>2020-07-17 09:27:18 +0200
commita1d9edeaf1890f18c741d00cd5c9a7fd4610216a (patch)
tree1a23d612110102d6b3272d75f08295c094eedb14 /src
parent2fe15a9604ca217caf52cad32e97ef1d9f221e3a (diff)
downloadxfce4-appfinder-a1d9edeaf1890f18c741d00cd5c9a7fd4610216a.tar.gz
Use shared field codes expansion
Diffstat (limited to 'src')
-rw-r--r--src/appfinder-model.c50
1 files changed, 17 insertions, 33 deletions
diff --git a/src/appfinder-model.c b/src/appfinder-model.c
index 08e357b..b1a96f6 100644
--- a/src/appfinder-model.c
+++ b/src/appfinder-model.c
@@ -2369,10 +2369,10 @@ xfce_appfinder_model_execute (XfceAppfinderModel *model,
gboolean *is_regular_command,
GError **error)
{
- const gchar *command, *p;
+ const gchar *icon;
+ gchar *command, *uri;
GarconMenuItem *item;
ModelItem *mitem;
- GString *string;
gboolean succeed = FALSE;
gchar **argv;
@@ -2390,51 +2390,35 @@ xfce_appfinder_model_execute (XfceAppfinderModel *model,
appfinder_return_val_if_fail (GARCON_IS_MENU_ITEM (item), FALSE);
- command = garcon_menu_item_get_command (item);
+ command = (gchar*) garcon_menu_item_get_command (item);
if (!IS_STRING (command))
{
g_set_error_literal (error, 0, 0, _("Application has no command"));
return FALSE;
}
- string = g_string_sized_new (100);
-
- if (garcon_menu_item_requires_terminal (item))
- g_string_append (string, "exo-open --launch TerminalEmulator ");
-
/* expand the field codes */
- for (p = command; *p != '\0'; ++p)
- {
- if (G_UNLIKELY (p[0] == '%' && p[1] != '\0'))
- {
- switch (*++p)
- {
- case '%':
- g_string_append_c (string, '%');
- break;
-
- /* skip all the other %? values for now we don't have dnd anyways */
- }
- }
- else
- {
- g_string_append_c (string, *p);
- }
- }
-
- if (g_shell_parse_argv (string->str, NULL, &argv, error))
- {
- succeed = xfce_spawn_on_screen (screen, garcon_menu_item_get_path (item),
+ icon = garcon_menu_item_get_icon_name (item);
+ uri = garcon_menu_item_get_uri (item);
+ command = xfce_expand_desktop_entry_field_codes (command, NULL, icon,
+ garcon_menu_item_get_name (item),
+ uri,
+ garcon_menu_item_requires_terminal (item));
+ g_free (uri);
+
+ if (g_shell_parse_argv (command, NULL, &argv, error))
+ {
+ succeed = xfce_spawn_on_screen (screen,
+ garcon_menu_item_get_path (item),
argv, NULL, G_SPAWN_SEARCH_PATH,
garcon_menu_item_supports_startup_notification (item),
gtk_get_current_event_time (),
- garcon_menu_item_get_icon_name (item),
- error);
+ icon, error);
g_strfreev (argv);
}
- g_string_free (string, TRUE);
+ g_free (command);
return succeed;
}