Commit 086259bc authored by Dave Davenport's avatar Dave Davenport

Only show desktop files that should show

parent 6bfeca81
......@@ -46,7 +46,7 @@ G_MODULE_EXPORT Mode mode;
*/
typedef struct
{
GList *array;
GAppInfo **array;
unsigned int array_length;
} GRUNModePrivateData;
......@@ -60,9 +60,24 @@ static void get_grun ( Mode *sw )
GRUNModePrivateData *pd = (GRUNModePrivateData *) mode_get_private_data ( sw );
GTimer *t = g_timer_new();
pd->array = g_app_info_get_all ();
pd->array_length = g_list_length(pd->array);
GList *list = g_app_info_get_all ();
pd->array_length = g_list_length(list);
pd->array = g_malloc0_n(pd->array_length,sizeof(GAppInfo*));
printf("elapsed calling g_app_info_get_all: %f\n" , g_timer_elapsed(t,NULL));
int i = 0;
for (GList *iter = g_list_first ( list ); iter; iter = g_list_next(iter)) {
GAppInfo *app = (GAppInfo*)iter->data;
if ( g_app_info_should_show ( app ) ) {
pd->array[i] = app;
i++;
}
else {
g_object_unref ( app );
}
}
pd->array_length = i;
g_list_free ( list);
printf("elapsed filtering list: %f\n" , g_timer_elapsed(t,NULL));
g_timer_destroy(t);
}
......@@ -97,7 +112,7 @@ static ModeMode grun_mode_result ( Mode *sw, int mretv, char **input, unsigned i
} else if ( mretv & MENU_QUICK_SWITCH ) {
retv = ( mretv & MENU_LOWER_MASK );
} else if ( ( mretv & MENU_OK ) ) {
GAppInfo *app = g_list_nth_data(pd->array, selected_line);
GAppInfo *app = pd->array[selected_line];
if ( app ) {
g_app_info_launch ( app, NULL, NULL, NULL );
}
......@@ -112,7 +127,10 @@ static void grun_mode_destroy ( Mode *sw )
{
GRUNModePrivateData *pd = (GRUNModePrivateData *) mode_get_private_data ( sw );
if ( pd != NULL ) {
g_list_free_full (pd->array, g_object_unref);
for ( int i = 0; i < pd->array_length; i++) {
g_object_unref ( pd->array[i] );
}
g_free ( pd->array );
g_free ( pd );
mode_set_private_data ( sw, NULL );
}
......@@ -124,7 +142,7 @@ static char *_get_display_value ( const Mode *sw, unsigned int selected_line, G_
if ( get_entry )
{
GAppInfo *app = g_list_nth_data(pd->array, selected_line);
GAppInfo *app = pd->array[selected_line];
if ( app ) {
*state |= MARKUP;
const char *description = g_app_info_get_description ( app );
......@@ -154,7 +172,7 @@ static char *_get_display_value ( const Mode *sw, unsigned int selected_line, G_
static int grun_token_match ( const Mode *sw, rofi_int_matcher **tokens, unsigned int index )
{
GRUNModePrivateData *pd = (GRUNModePrivateData *) mode_get_private_data ( sw );
GAppInfo *app = g_list_nth_data(pd->array, index);
GAppInfo *app = pd->array[index];
int match = 1;
if ( app && tokens ) {
const char *name = g_app_info_get_name ( app );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment