1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2024-11-11 13:50:48 -05:00

Extra checks when parsing file.

This commit is contained in:
Dave Davenport 2016-08-29 08:55:28 +02:00
parent a90ff48032
commit 1f641135e2

View file

@ -171,6 +171,17 @@ static void read_desktop_file ( DRunModePrivateData *pd, const char *root, char
g_free ( id ); g_free ( id );
return; return;
} }
// Skip non Application entries.
if ( g_key_file_has_key ( kf, "Desktop Entry", "Type", NULL )){
gchar *key = g_key_file_get_string ( kf, "Desktop Entry", "Type", NULL );
if ( g_strcmp0(key, "Application")){
g_free(key);
g_key_file_free ( kf );
g_free ( path );
g_free ( id );
return;
}
}
// Skip hidden entries. // Skip hidden entries.
if ( g_key_file_has_key ( kf, "Desktop Entry", "Hidden", NULL ) ) { if ( g_key_file_has_key ( kf, "Desktop Entry", "Hidden", NULL ) ) {
if ( g_key_file_get_boolean ( kf, "Desktop Entry", "Hidden", NULL ) ) { if ( g_key_file_get_boolean ( kf, "Desktop Entry", "Hidden", NULL ) ) {
@ -197,6 +208,14 @@ static void read_desktop_file ( DRunModePrivateData *pd, const char *root, char
g_free ( id ); g_free ( id );
return; return;
} }
// We need Exec, don't support DBusActivatable
if ( !g_key_file_has_key ( kf, "Desktop Entry", "Exec", NULL ) ) {
fprintf(stderr, "DesktopFile has no Exec option, DBusActivatable is not supported: '%s'\n", path);
g_key_file_free ( kf );
g_free ( path );
g_free ( id );
return;
}
if ( g_key_file_has_key ( kf, "Desktop Entry", "Exec", NULL ) ) { if ( g_key_file_has_key ( kf, "Desktop Entry", "Exec", NULL ) ) {
size_t nl = ( ( pd->cmd_list_length ) + 1 ); size_t nl = ( ( pd->cmd_list_length ) + 1 );
pd->entry_list = g_realloc ( pd->entry_list, nl * sizeof ( *( pd->entry_list ) ) ); pd->entry_list = g_realloc ( pd->entry_list, nl * sizeof ( *( pd->entry_list ) ) );
@ -310,7 +329,6 @@ static void get_apps_history ( DRunModePrivateData *pd )
char **st = g_strsplit ( retv[index], ":::", 2 ); char **st = g_strsplit ( retv[index], ":::", 2 );
if ( st && st[0] && st[1] ) { if ( st && st[0] && st[1] ) {
gchar *name = g_path_get_basename ( st[1] ); gchar *name = g_path_get_basename ( st[1] );
printf ( ": %s\n", st[0] );
read_desktop_file ( pd, st[0], g_strdup ( st[1] ), name ); read_desktop_file ( pd, st[0], g_strdup ( st[1] ), name );
g_free ( name ); g_free ( name );
} }