diff --git a/doc/rofi-theme.5 b/doc/rofi-theme.5 index 6c0f53af..f9ff8bfc 100644 --- a/doc/rofi-theme.5 +++ b/doc/rofi-theme.5 @@ -1370,14 +1370,13 @@ This is a textbox widget. The displayed string can be set with \fB\fCstr\fR\&. .IP \(bu 2 \fB\fCicon\fR: This is an icon widget. The displayed icon can be set with \fB\fCfilename\fR and size with \fB\fCsize\fR\&. +If the property \fB\fCaction\fR is set, it acts as a button. +\fB\fCaction\fR can be set to a keybinding name and completes that action. (see rofi \-show keys for a list). .IP \(bu 2 \fB\fCbutton\fR: This is a textbox widget that can have a 'clickable' action. The \fB\fCaction\fR can be set to: -\fB\fCok\fR accept entry. -\fB\fCcustom\fR accept custom input. -\fB\fCok|alternate\fR: accept entry and launch alternate action (for run launch in terminal). -\fB\fCcustom|alternate\fR: accept custom input and launch alternate action. +\fB\fCkeybinding\fR: accepts a keybinging name and completes that action. (see rofi \-show keys for a list). .RE diff --git a/doc/rofi-theme.5.markdown b/doc/rofi-theme.5.markdown index 1da09bb6..a0170665 100644 --- a/doc/rofi-theme.5.markdown +++ b/doc/rofi-theme.5.markdown @@ -848,13 +848,12 @@ There are several special widgets that can be used by prefixing the name of the This is a textbox widget. The displayed string can be set with `str`. * `icon`: This is an icon widget. The displayed icon can be set with `filename` and size with `size`. + If the property `action` is set, it acts as a button. + `action` can be set to a keybinding name and completes that action. (see rofi -show keys for a list). * `button`: This is a textbox widget that can have a 'clickable' action. The `action` can be set to: - `ok` accept entry. - `custom` accept custom input. - `ok|alternate`: accept entry and launch alternate action (for run launch in terminal). - `custom|alternate`: accept custom input and launch alternate action. + `keybinding`: accepts a keybinging name and completes that action. (see rofi -show keys for a list). To specify children, set the `children` property (this always happens on the `box` child, see example below): diff --git a/doc/rofi.1 b/doc/rofi.1 index e6e93fd7..c7bd6a29 100644 --- a/doc/rofi.1 +++ b/doc/rofi.1 @@ -1179,15 +1179,18 @@ configuration { directory: "/some/directory"; /** * Sorting method. Can be set to: - * - "name" - * - "mtime" (modification time) - * - "atime" (access time) - * - "ctime" (change time) + * \- "name" + * \- "mtime" (modification time) + * \- "atime" (access time) + * \- "ctime" (change time) */ - sorting-method: "name"; + sorting\-method: "name"; } } +.fi +.RE + .SS Other .PP \fB\fC\-drun\-use\-desktop\-cache\fR diff --git a/source/view.c b/source/view.c index 479c5254..3259ed56 100644 --- a/source/view.c +++ b/source/view.c @@ -1722,27 +1722,16 @@ static WidgetTriggerActionResult textbox_button_trigger_action ( widget *wid, Mo { case MOUSE_CLICK_DOWN: { - const char * type = rofi_theme_get_string ( wid, "action", "ok" ); - ( state->selected_line ) = state->line_map[listview_get_selected ( state->list_view )]; - if ( strcmp ( type, "ok" ) == 0 ) { - state->retv = MENU_OK; + const char * type = rofi_theme_get_string ( wid, "action", NULL ); + if ( type ) { + ( state->selected_line ) = state->line_map[listview_get_selected ( state->list_view )]; + guint id = key_binding_get_action_from_name(type); + if ( id != UINT32_MAX ) { + rofi_view_trigger_global_action ( id ); + } + state->skip_absorb = TRUE; + return WIDGET_TRIGGER_ACTION_RESULT_HANDLED; } - else if ( strcmp ( type, "ok|alternate" ) == 0 ) { - state->retv = MENU_CUSTOM_ACTION | MENU_OK; - } - else if ( strcmp ( type, "custom" ) ) { - state->retv = MENU_CUSTOM_INPUT; - } - else if ( strcmp ( type, "custom|alternate" ) == 0 ) { - state->retv = MENU_CUSTOM_ACTION | MENU_CUSTOM_INPUT; - } - else { - g_warning ( "Invalid action specified." ); - return WIDGET_TRIGGER_ACTION_RESULT_IGNORED; - } - state->quit = TRUE; - state->skip_absorb = TRUE; - return WIDGET_TRIGGER_ACTION_RESULT_HANDLED; } case MOUSE_CLICK_UP: case MOUSE_DCLICK_DOWN: @@ -1939,7 +1928,13 @@ static void rofi_view_add_widget ( RofiViewState *state, widget *parent_widget, } else if ( g_ascii_strncasecmp ( name, "icon", 4 ) == 0 ) { icon *t = icon_create ( parent_widget, name ); + /* small hack to make it clickable */ + const char * type = rofi_theme_get_string ( WIDGET(t), "action", NULL ); + if ( type ) { + WIDGET(t)->type = WIDGET_TYPE_EDITBOX; + } box_add ( (box *) parent_widget, WIDGET ( t ), TRUE ); + widget_set_trigger_action_handler ( WIDGET ( t ), textbox_button_trigger_action, state ); } else { wid = (widget *) box_create ( parent_widget, name, ROFI_ORIENTATION_VERTICAL ); diff --git a/themes/fancy.rasi b/themes/fancy.rasi index 6d1b8de2..1f6e9df8 100644 --- a/themes/fancy.rasi +++ b/themes/fancy.rasi @@ -44,7 +44,33 @@ window { y-offset: -15.5em; - children: [ inputbar, message, wrapper-mode-switcher, listview ]; + children: [ inputbar, message, wrapper-mode-switcher, listview , pagerbox ]; +} + + +pagerbox { + expand: false; + orientation: horizontal; + children: [ icon-left, pad, icon-right ]; +} + +pad { + expand: true; +} +icon-left { + expand: false; + filename: "go-previous"; + size: 24; + vertical-align: 0.5; + action: "kb-page-prev"; +} + +icon-right { + expand: false; + filename: "go-next"; + size: 24; + vertical-align: 0.5; + action: "kb-page-next"; } @@ -191,9 +217,23 @@ wrapper { border: 2px; border-radius: 5px; padding: 4px; - children: [ icon-k, entry ]; + children: [ icon-k, entry, icon-paste]; spacing: 0.5em; } +button-paste { + expand: false; + str: "gtk-paste"; + size: 24; + vertical-align: 0.5; + action: "kb-cancel"; +} +icon-paste { + expand: false; + filename: "gtk-paste"; + size: 24; + vertical-align: 0.5; + action: "kb-primary-paste"; +} icon-k { expand: false; filename: "input-keyboard";