summaryrefslogtreecommitdiffstats
path: root/source/dialogs
diff options
context:
space:
mode:
authorQuentin Glidic <sardemff7+git@sardemff7.net>2017-06-02 14:55:36 +0200
committerQuentin Glidic <sardemff7+git@sardemff7.net>2017-06-02 14:55:36 +0200
commit22fbaa0b50bc65f531a177a324d63e89702051db (patch)
treeb7f24073d10bb977498b2727642b9c298ddfa7d9 /source/dialogs
parent51d34b662e95399ca23caededa9f61f7a7e1dca3 (diff)
drun: Keep the app_id around
Signed-off-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Diffstat (limited to 'source/dialogs')
-rw-r--r--source/dialogs/drun.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/source/dialogs/drun.c b/source/dialogs/drun.c
index f9686b99..eea2a9d6 100644
--- a/source/dialogs/drun.c
+++ b/source/dialogs/drun.c
@@ -66,6 +66,8 @@ typedef struct
char *root;
/* Path to desktop file */
char *path;
+ /* Application id (.desktop filename) */
+ char *app_id;
/* Icon stuff */
char *icon_name;
cairo_surface_t *icon;
@@ -199,7 +201,7 @@ static void exec_cmd_entry ( DRunModeEntry *e )
/**
* This function absorbs/freeÅ› path, so this is no longer available afterwards.
*/
-static gboolean read_desktop_file ( DRunModePrivateData *pd, const char *root, const char *path )
+static gboolean read_desktop_file ( DRunModePrivateData *pd, const char *root, const char *path, const gchar *basename )
{
// Create ID on stack.
// We know strlen (path ) > strlen(root)+1
@@ -275,8 +277,9 @@ static gboolean read_desktop_file ( DRunModePrivateData *pd, const char *root, c
pd->cmd_list_length_actual += 256;
pd->entry_list = g_realloc ( pd->entry_list, pd->cmd_list_length_actual * sizeof ( *( pd->entry_list ) ) );
}
- pd->entry_list[pd->cmd_list_length].root = g_strdup ( root );
- pd->entry_list[pd->cmd_list_length].path = g_strdup ( path );
+ pd->entry_list[pd->cmd_list_length].root = g_strdup ( root );
+ pd->entry_list[pd->cmd_list_length].path = g_strdup ( path );
+ pd->entry_list[pd->cmd_list_length].app_id = g_strndup ( basename, strlen ( basename ) - strlen ( ".desktop" ) );
gchar *n = g_key_file_get_locale_string ( kf, "Desktop Entry", "Name", NULL, NULL );
pd->entry_list[pd->cmd_list_length].name = n;
gchar *gn = g_key_file_get_locale_string ( kf, "Desktop Entry", "GenericName", NULL, NULL );
@@ -353,7 +356,7 @@ static void walk_dir ( DRunModePrivateData *pd, const char *root, const char *di
case DT_REG:
// Skip files not ending on .desktop.
if ( g_str_has_suffix ( file->d_name, ".desktop" ) ) {
- read_desktop_file ( pd, root, filename );
+ read_desktop_file ( pd, root, filename, file->d_name );
}
break;
case DT_DIR:
@@ -388,7 +391,8 @@ static void get_apps_history ( DRunModePrivateData *pd )
for ( unsigned int index = 0; index < length; index++ ) {
char **st = g_strsplit ( retv[index], ":::", 2 );
if ( st && st[0] && st[1] ) {
- if ( !read_desktop_file ( pd, st[0], st[1] ) ) {
+ const gchar *basename = g_utf8_strrchr ( st[1], -1, G_DIR_SEPARATOR );
+ if ( basename == NULL || !read_desktop_file ( pd, st[0], st[1], ++basename ) ) {
history_remove ( path, retv[index] );
}
}
@@ -478,6 +482,7 @@ static void drun_entry_clear ( DRunModeEntry *e )
{
g_free ( e->root );
g_free ( e->path );
+ g_free ( e->app_id );
if ( e->icon != NULL ) {
cairo_surface_destroy ( e->icon );
}