mirror of
https://github.com/davatorium/rofi.git
synced 2024-11-25 13:55:34 -05:00
Add support for adding textbox widgets to listview elements (#1792)
* Add support for adding textbox-widgets to listview entries * Add support for adding icons and buttons to listview elements
This commit is contained in:
parent
a5bd8bc630
commit
c870d512ff
3 changed files with 30 additions and 1 deletions
|
@ -29,6 +29,7 @@
|
|||
#define ROFI_VIEW_H
|
||||
|
||||
#include "mode.h"
|
||||
#include "widgets/widget.h"
|
||||
#include <pango/pango.h>
|
||||
#include <xcb/xcb.h>
|
||||
/**
|
||||
|
@ -355,5 +356,10 @@ void rofi_view_ellipsize_listview(RofiViewState *state,
|
|||
*/
|
||||
gboolean rofi_set_im_window_pos(int new_x, int new_y);
|
||||
|
||||
|
||||
WidgetTriggerActionResult textbox_button_trigger_action(
|
||||
widget *wid, MouseBindingMouseDefaultAction action, G_GNUC_UNUSED gint x,
|
||||
G_GNUC_UNUSED gint y, G_GNUC_UNUSED void *user_data);
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
|
|
|
@ -2115,7 +2115,7 @@ static int rofi_view_calculate_height(RofiViewState *state) {
|
|||
return widget_get_desired_height(main_window, state->width);
|
||||
}
|
||||
|
||||
static WidgetTriggerActionResult textbox_button_trigger_action(
|
||||
WidgetTriggerActionResult textbox_button_trigger_action(
|
||||
widget *wid, MouseBindingMouseDefaultAction action, G_GNUC_UNUSED gint x,
|
||||
G_GNUC_UNUSED gint y, G_GNUC_UNUSED void *user_data) {
|
||||
RofiViewState *state = (RofiViewState *)user_data;
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
|
||||
#include "settings.h"
|
||||
#include "theme.h"
|
||||
#include "view.h"
|
||||
|
||||
#include "timings.h"
|
||||
|
||||
|
@ -182,6 +183,28 @@ static void listview_add_widget(listview *lv, _listview_row *row, widget *wid,
|
|||
textbox_create(WIDGET(wid), WIDGET_TYPE_TEXTBOX_TEXT, "element-index",
|
||||
TB_AUTOHEIGHT, NORMAL, " ", 0, 0);
|
||||
box_add((box *)wid, WIDGET(row->index), FALSE);
|
||||
} else if (strncasecmp(label, "textbox", 7) == 0) {
|
||||
textbox *textbox_custom =
|
||||
textbox_create(wid, WIDGET_TYPE_TEXTBOX_TEXT, label,
|
||||
TB_AUTOHEIGHT | TB_WRAP, NORMAL, "", 0, 0);
|
||||
box_add((box *)wid, WIDGET(textbox_custom), TRUE);
|
||||
} else if (strncasecmp(label, "button", 6) == 0) {
|
||||
textbox *button_custom =
|
||||
textbox_create(wid, WIDGET_TYPE_EDITBOX, label,
|
||||
TB_AUTOHEIGHT | TB_WRAP, NORMAL, "", 0, 0);
|
||||
box_add((box *)wid, WIDGET(button_custom), TRUE);
|
||||
widget_set_trigger_action_handler(WIDGET(button_custom), textbox_button_trigger_action,
|
||||
lv->udata);
|
||||
} else if (strncasecmp(label, "icon", 4) == 0) {
|
||||
icon *icon_custom = icon_create(wid, label);
|
||||
/* small hack to make it clickable */
|
||||
const char *type = rofi_theme_get_string(WIDGET(icon_custom), "action", NULL);
|
||||
if (type) {
|
||||
WIDGET(icon_custom)->type = WIDGET_TYPE_EDITBOX;
|
||||
}
|
||||
box_add((box *)wid, WIDGET(icon_custom), TRUE);
|
||||
widget_set_trigger_action_handler(WIDGET(icon_custom), textbox_button_trigger_action,
|
||||
lv->udata);
|
||||
} else {
|
||||
widget *wid2 = (widget *)box_create(wid, label, ROFI_ORIENTATION_VERTICAL);
|
||||
box_add((box *)wid, WIDGET(wid2), TRUE);
|
||||
|
|
Loading…
Reference in a new issue