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

Cleanups.

This commit is contained in:
Dave Davenport 2015-11-07 12:59:08 +01:00
parent c82d8832c9
commit 195dc0fb01

View file

@ -130,13 +130,19 @@ static void get_apps_dir ( DRunModePrivateData *pd, const char *bp )
if ( dent->d_name[0] == '.' ) {
continue;
}
gchar *path = g_build_filename ( bp, dent->d_name, NULL );
GKeyFile *kf = g_key_file_new ();
GError *error = NULL;
// TODO: check what flags to set;
g_key_file_load_from_file ( kf, path, 0, NULL );
gchar *path = g_build_filename ( bp, dent->d_name, NULL );
g_key_file_load_from_file ( kf, path, 0, &error );
g_free ( path );
if ( error == NULL ) {
// If error, skip to next entry
if ( error != NULL ) {
g_error_free ( error );
g_key_file_free ( kf );
continue;
}
// Skip hidden entries.
if ( g_key_file_has_key ( kf, "Desktop Entry", "Hidden", NULL ) ) {
if ( g_key_file_get_boolean ( kf, "Desktop Entry", "Hidden", NULL ) ) {
g_key_file_free ( kf );
@ -144,21 +150,19 @@ static void get_apps_dir ( DRunModePrivateData *pd, const char *bp )
}
}
if ( g_key_file_has_key ( kf, "Desktop Entry", "Exec", NULL ) ) {
pd->cmd_list = g_realloc ( pd->cmd_list, ( ( pd->cmd_list_length ) + 2 ) * sizeof ( *( pd->cmd_list ) ) );
pd->entry_list = g_realloc ( pd->entry_list, ( pd->cmd_list_length + 2 ) * sizeof ( *( pd->entry_list ) ) );
size_t nl = ( ( pd->cmd_list_length ) + 2 );
pd->cmd_list = g_realloc ( pd->cmd_list, nl * sizeof ( *( pd->cmd_list ) ) );
pd->entry_list = g_realloc ( pd->entry_list, nl * sizeof ( *( pd->entry_list ) ) );
if ( g_key_file_has_key ( kf, "Desktop Entry", "Name", NULL ) ) {
gchar *n = NULL;
gchar *gn = NULL;
n = g_key_file_get_locale_string ( kf, "Desktop Entry", "Name", NULL, NULL );
gn = g_key_file_get_locale_string ( kf, "Desktop Entry", "GenericName", NULL, NULL );
gchar *n = g_key_file_get_locale_string ( kf, "Desktop Entry", "Name", NULL, NULL );
gchar *gn = g_key_file_get_locale_string ( kf, "Desktop Entry", "GenericName", NULL, NULL );
if ( gn == NULL ) {
pd->cmd_list[pd->cmd_list_length] = g_markup_escape_text ( n, -1 );
}
else {
( pd->cmd_list )[( pd->cmd_list_length )] = g_markup_printf_escaped (
"%s <span weight='light' size='small'><i>(%s)</i></span>",
n,
gn ? gn : "" );
n, gn ? gn : "" );
}
g_free ( n ); g_free ( gn );
}
@ -172,10 +176,7 @@ static void get_apps_dir ( DRunModePrivateData *pd, const char *bp )
( pd->cmd_list )[( pd->cmd_list_length ) + 1] = NULL;
( pd->cmd_list_length )++;
}
}
else {
g_error_free ( error );
}
g_key_file_free ( kf );
}