mirror of
https://github.com/davatorium/rofi.git
synced 2024-11-18 13:54:36 -05:00
[DMenu|Script] Add per row urgent/active option.
Instead of having a global list of entries to highlight urgent/active, you can now to it per row.
This commit is contained in:
parent
236c12bfb2
commit
9fda280be1
5 changed files with 34 additions and 1 deletions
|
@ -165,6 +165,10 @@ The following options are supported:
|
||||||
\fBnonselectable\fP: If true the row cannot activated.
|
\fBnonselectable\fP: If true the row cannot activated.
|
||||||
.IP \(bu 2
|
.IP \(bu 2
|
||||||
\fBinfo\fP: Info that, on selection, gets placed in the \fB\fCROFI_INFO\fR environment variable. This entry does not get searched.
|
\fBinfo\fP: Info that, on selection, gets placed in the \fB\fCROFI_INFO\fR environment variable. This entry does not get searched.
|
||||||
|
.IP \(bu 2
|
||||||
|
\fBurgent\fP: Set urgent flag on entry (true/false)
|
||||||
|
.IP \(bu 2
|
||||||
|
\fBactive\fP: Set active flag on entry (true/false)
|
||||||
|
|
||||||
.RE
|
.RE
|
||||||
|
|
||||||
|
|
|
@ -112,6 +112,8 @@ The following options are supported:
|
||||||
* **meta**: Specify invisible search terms.
|
* **meta**: Specify invisible search terms.
|
||||||
* **nonselectable**: If true the row cannot activated.
|
* **nonselectable**: If true the row cannot activated.
|
||||||
* **info**: Info that, on selection, gets placed in the `ROFI_INFO` environment variable. This entry does not get searched.
|
* **info**: Info that, on selection, gets placed in the `ROFI_INFO` environment variable. This entry does not get searched.
|
||||||
|
* **urgent**: Set urgent flag on entry (true/false)
|
||||||
|
* **active**: Set active flag on entry (true/false)
|
||||||
|
|
||||||
multiple entries can be passed using the `\x1f` separator.
|
multiple entries can be passed using the `\x1f` separator.
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,11 @@ typedef struct {
|
||||||
|
|
||||||
/** non-selectable */
|
/** non-selectable */
|
||||||
gboolean nonselectable;
|
gboolean nonselectable;
|
||||||
|
|
||||||
|
/** urgent */
|
||||||
|
gboolean urgent;
|
||||||
|
/** active */
|
||||||
|
gboolean active;
|
||||||
} DmenuScriptEntry;
|
} DmenuScriptEntry;
|
||||||
/**
|
/**
|
||||||
* @param sw Unused
|
* @param sw Unused
|
||||||
|
|
|
@ -168,6 +168,8 @@ static void read_add(DmenuModePrivateData *pd, char *data, gsize len) {
|
||||||
pd->cmd_list[pd->cmd_list_length].icon_name = NULL;
|
pd->cmd_list[pd->cmd_list_length].icon_name = NULL;
|
||||||
pd->cmd_list[pd->cmd_list_length].meta = NULL;
|
pd->cmd_list[pd->cmd_list_length].meta = NULL;
|
||||||
pd->cmd_list[pd->cmd_list_length].info = NULL;
|
pd->cmd_list[pd->cmd_list_length].info = NULL;
|
||||||
|
pd->cmd_list[pd->cmd_list_length].active = FALSE;
|
||||||
|
pd->cmd_list[pd->cmd_list_length].urgent = FALSE;
|
||||||
pd->cmd_list[pd->cmd_list_length].nonselectable = FALSE;
|
pd->cmd_list[pd->cmd_list_length].nonselectable = FALSE;
|
||||||
char *end = data;
|
char *end = data;
|
||||||
while (end < data + len && *end != '\0') {
|
while (end < data + len && *end != '\0') {
|
||||||
|
@ -448,6 +450,12 @@ static char *get_display_data(const Mode *data, unsigned int index, int *state,
|
||||||
if (pd->do_markup) {
|
if (pd->do_markup) {
|
||||||
*state |= MARKUP;
|
*state |= MARKUP;
|
||||||
}
|
}
|
||||||
|
if ( pd->cmd_list[index].urgent ) {
|
||||||
|
*state |= URGENT;
|
||||||
|
}
|
||||||
|
if ( pd->cmd_list[index].active ) {
|
||||||
|
*state |= ACTIVE;
|
||||||
|
}
|
||||||
char *my_retv =
|
char *my_retv =
|
||||||
(get_entry ? dmenu_format_output_string(pd, retv[index].entry, index,
|
(get_entry ? dmenu_format_output_string(pd, retv[index].entry, index,
|
||||||
pd->multi_select)
|
pd->multi_select)
|
||||||
|
|
|
@ -94,7 +94,13 @@ void dmenuscript_parse_entry_extras(G_GNUC_UNUSED Mode *sw,
|
||||||
} else if (strcasecmp(key, "info") == 0) {
|
} else if (strcasecmp(key, "info") == 0) {
|
||||||
entry->info = value;
|
entry->info = value;
|
||||||
} else if (strcasecmp(key, "nonselectable") == 0) {
|
} else if (strcasecmp(key, "nonselectable") == 0) {
|
||||||
entry->nonselectable = strcasecmp(value, "true") == 0;
|
entry->nonselectable = g_ascii_strcasecmp(value, "true") == 0;
|
||||||
|
g_free(value);
|
||||||
|
} else if (strcasecmp(key, "urgent") == 0) {
|
||||||
|
entry->urgent = g_ascii_strcasecmp(value, "true") == 0;
|
||||||
|
g_free(value);
|
||||||
|
} else if (strcasecmp(key, "active") == 0) {
|
||||||
|
entry->active = g_ascii_strcasecmp(value, "true") == 0;
|
||||||
g_free(value);
|
g_free(value);
|
||||||
} else {
|
} else {
|
||||||
g_free(value);
|
g_free(value);
|
||||||
|
@ -231,6 +237,8 @@ static DmenuScriptEntry *execute_executor(Mode *sw, char *arg,
|
||||||
retv[(*length)].icon_name = NULL;
|
retv[(*length)].icon_name = NULL;
|
||||||
retv[(*length)].meta = NULL;
|
retv[(*length)].meta = NULL;
|
||||||
retv[(*length)].info = NULL;
|
retv[(*length)].info = NULL;
|
||||||
|
retv[(*length)].active = FALSE;
|
||||||
|
retv[(*length)].urgent = FALSE;
|
||||||
retv[(*length)].icon_fetch_uid = 0;
|
retv[(*length)].icon_fetch_uid = 0;
|
||||||
retv[(*length)].icon_fetch_size = 0;
|
retv[(*length)].icon_fetch_size = 0;
|
||||||
retv[(*length)].nonselectable = FALSE;
|
retv[(*length)].nonselectable = FALSE;
|
||||||
|
@ -413,6 +421,12 @@ static char *_get_display_value(const Mode *sw, unsigned int selected_line,
|
||||||
*state |= URGENT;
|
*state |= URGENT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ( pd->cmd_list[selected_line].urgent ) {
|
||||||
|
*state |= URGENT;
|
||||||
|
}
|
||||||
|
if ( pd->cmd_list[selected_line].active ) {
|
||||||
|
*state |= ACTIVE;
|
||||||
|
}
|
||||||
if (pd->do_markup) {
|
if (pd->do_markup) {
|
||||||
*state |= MARKUP;
|
*state |= MARKUP;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue