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

Add option to make entry non-selectable in dmenu/script.

Fixes: #1024
This commit is contained in:
Dave Davenport 2020-02-02 14:21:29 +01:00
parent b169289996
commit 7dcc3f450c
4 changed files with 20 additions and 2 deletions

View file

@ -24,6 +24,7 @@ else
echo -en "aap\0icon\x1ffolder\n"
echo "noot"
echo "mies"
echo -en "-------------\0nonselectable\x1ftrue\n"
echo "testing"
echo "<b>Bold</b>"
echo "quit"

View file

@ -11,6 +11,8 @@ typedef struct
uint32_t icon_fetch_uid;
/** Hidden meta keywords. */
char *meta;
/** non-selectable */
gboolean nonselectable;
} DmenuScriptEntry;
/**
* @param sw Unused

View file

@ -554,6 +554,10 @@ static void dmenu_finalize ( RofiViewState *state )
}
}
else if ( ( mretv & ( MENU_OK | MENU_QUICK_SWITCH ) ) && cmd_list[pd->selected_line].entry != NULL ) {
if ( cmd_list[pd->selected_line].nonselectable == TRUE ) {
g_free ( input );
return;
}
dmenu_print_results ( pd, input );
retv = TRUE;
if ( ( mretv & MENU_QUICK_SWITCH ) ) {
@ -579,6 +583,11 @@ static void dmenu_finalize ( RofiViewState *state )
restart = FALSE;
// Normal mode
if ( ( mretv & MENU_OK ) && pd->selected_line != UINT32_MAX && cmd_list[pd->selected_line].entry != NULL ) {
// Check if entry is non-selectable.
if ( cmd_list[pd->selected_line].nonselectable == TRUE ) {
g_free ( input );
return;
}
if ( ( mretv & MENU_CUSTOM_ACTION ) && pd->multi_select ) {
restart = TRUE;
if ( pd->selected_list == NULL ) {

View file

@ -85,9 +85,12 @@ void dmenuscript_parse_entry_extras ( G_GNUC_UNUSED Mode *sw, DmenuScriptEntry *
if ( strcasecmp ( buffer, "icon" ) == 0 ) {
entry->icon_name = g_strdup ( value );
}
if ( strcasecmp ( buffer, "meta" ) == 0 ) {
else if ( strcasecmp ( buffer, "meta" ) == 0 ) {
entry->meta = g_strdup ( value );
}
else if ( strcasecmp ( buffer, "nonselectable" ) == 0 ) {
entry->nonselectable = strcasecmp ( value, "true" ) == 0;
}
}
}
@ -244,7 +247,7 @@ static ModeMode script_mode_result ( Mode *sw, int mretv, char **input, unsigned
unsigned int new_length = 0;
if ( ( mretv & MENU_NEXT ) ) {
retv = NEXT_DIALOG;
retv = RELOAD_DIALOG;;
}
else if ( ( mretv & MENU_PREVIOUS ) ) {
retv = PREVIOUS_DIALOG;
@ -253,6 +256,9 @@ static ModeMode script_mode_result ( Mode *sw, int mretv, char **input, unsigned
retv = ( mretv & MENU_LOWER_MASK );
}
else if ( ( mretv & MENU_OK ) && rmpd->cmd_list[selected_line].entry != NULL ) {
if ( rmpd->cmd_list[selected_line].nonselectable ) {
return FALSE;
}
script_mode_reset_highlight ( sw );
new_list = execute_executor ( sw, rmpd->cmd_list[selected_line].entry, &new_length );
}