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

[View] Add icon-current-entry widget.

This commit is contained in:
Dave Davenport 2022-06-27 17:09:21 +02:00
parent 8ee05a718e
commit 9c18aaef22
5 changed files with 41 additions and 14 deletions

View file

@ -1246,6 +1246,8 @@ The current widgets available in \fBrofi\fP:
\fB\fCnum-filtered-rows\fR: Shows the total number of rows after filtering.
.IP \(bu 2
\fB\fCtextbox-current-entry\fR: Shows the text of the currently selected entry.
.IP \(bu 2
\fB\fCicon-current-entry\fR: Shows the icon of the currently selected entry.
.RE

View file

@ -774,6 +774,7 @@ The current widgets available in **rofi**:
* `num-rows`: Shows the total number of rows.
* `num-filtered-rows`: Shows the total number of rows after filtering.
* `textbox-current-entry`: Shows the text of the currently selected entry.
* `icon-current-entry`: Shows the icon of the currently selected entry.
* `listview`: The listview.
* `scrollbar`: the listview scrollbar
* `element`: a box in the listview holding the entries

View file

@ -108,6 +108,7 @@ struct RofiViewState {
textbox *tb_filtered_rows;
textbox *tb_current_entry;
icon *icon_current_entry;
/** Settings of the menu */
MenuFlags menu_flags;

View file

@ -1010,9 +1010,7 @@ inline static void rofi_view_nav_last(RofiViewState *state) {
static void selection_changed_callback(listview *lv, unsigned int index,
void *udata) {
RofiViewState *state = (RofiViewState *)udata;
if (state->tb_current_entry == NULL) {
return;
}
if (state->tb_current_entry) {
if (index < state->filtered_lines) {
int fstate = 0;
char *text = mode_get_display_value(state->sw, state->line_map[index],
@ -1024,6 +1022,19 @@ static void selection_changed_callback(listview *lv, unsigned int index,
textbox_text(state->tb_current_entry, "");
}
}
if (state->icon_current_entry) {
if (index < state->filtered_lines) {
int icon_height =
widget_get_desired_height(WIDGET(state->icon_current_entry),
WIDGET(state->icon_current_entry)->w);
cairo_surface_t *icon =
mode_get_icon(state->sw, state->line_map[index], icon_height);
icon_set_surface(state->icon_current_entry, icon);
} else {
icon_set_surface(state->icon_current_entry, NULL);
}
}
}
static void update_callback(textbox *t, icon *ico, unsigned int index,
void *udata, TextBoxFontType *type, gboolean full) {
RofiViewState *state = (RofiViewState *)udata;
@ -1898,6 +1909,10 @@ static void rofi_view_add_widget(RofiViewState *state, widget *parent_widget,
TB_MARKUP | TB_AUTOHEIGHT, NORMAL, "", 0, 0);
box_add((box *)parent_widget, WIDGET(state->tb_current_entry), FALSE);
defaults = NULL;
} else if (strcmp(name, "icon-current-entry") == 0) {
state->icon_current_entry = icon_create(parent_widget, name);
box_add((box *)parent_widget, WIDGET(state->icon_current_entry), FALSE);
defaults = NULL;
}
/**
* CASE INDICATOR

View file

@ -63,7 +63,7 @@ textbox-current-entry {
}
element-icon {
expand: true;
size: 20mm;
size: 10mm;
vertial-align: 0.5;
horizontal-align: 0.5;
padding: 2mm;
@ -74,13 +74,21 @@ mainbox {
expand: true;
background-color: transparent;
spacing: 5mm;
children: [ inputbar,textbox-current-entry, listview ];
children: [
inputbar,
listview,
icon-current-entry,
textbox-current-entry
];
}
icon-current-entry {
size: 100mm;
}
listview {
padding: 0em;
dynamic: false;
lines: 0;
columns: 5;
columns: 8;
flow: horizontal;
}
element selected normal {