1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2024-11-25 13:55:34 -05:00

Add message box to view structure. Always add it, disable it when not showing anything

This commit is contained in:
Dave Davenport 2017-03-01 09:37:20 +01:00
parent 9ee61a6447
commit 8bd7db31d2
3 changed files with 17 additions and 6 deletions

View file

@ -40,6 +40,11 @@ struct RofiViewState
listview *list_view; listview *list_view;
/** #textbox widget showing the overlay. */ /** #textbox widget showing the overlay. */
textbox *overlay; textbox *overlay;
/** #container holding the message box */
container *mesg_box;
/** #textbox containing the message entry */
textbox *mesg_tb;
/** Array with the levenshtein distance for each eleemnt. */ /** Array with the levenshtein distance for each eleemnt. */
int *distance; int *distance;
/** Array with the translation between the filtered and unfiltered list. */ /** Array with the translation between the filtered and unfiltered list. */

View file

@ -110,12 +110,17 @@ static void async_close_callback ( GObject *source_object, GAsyncResult *res, G_
static void read_add ( DmenuModePrivateData * pd, char *data, gsize len ) static void read_add ( DmenuModePrivateData * pd, char *data, gsize len )
{ {
if ( pd->cmd_list_real_length > 0 ){
if ( find_arg ( "-replace" ) >= 0 ){
g_free(pd->cmd_list[pd->cmd_list_length]);
pd->cmd_list_length--;
}
}
if ( ( pd->cmd_list_length + 2 ) > pd->cmd_list_real_length ) { if ( ( pd->cmd_list_length + 2 ) > pd->cmd_list_real_length ) {
pd->cmd_list_real_length = MAX ( pd->cmd_list_real_length * 2, 512 ); pd->cmd_list_real_length = MAX ( pd->cmd_list_real_length * 2, 512 );
pd->cmd_list = g_realloc ( pd->cmd_list, ( pd->cmd_list_real_length ) * sizeof ( char* ) ); pd->cmd_list = g_realloc ( pd->cmd_list, ( pd->cmd_list_real_length ) * sizeof ( char* ) );
} }
char *utfstr = rofi_force_utf8 ( data, len ); char *utfstr = rofi_force_utf8 ( data, len );
pd->cmd_list[pd->cmd_list_length] = utfstr; pd->cmd_list[pd->cmd_list_length] = utfstr;
pd->cmd_list[pd->cmd_list_length + 1] = NULL; pd->cmd_list[pd->cmd_list_length + 1] = NULL;

View file

@ -1592,12 +1592,13 @@ RofiViewState *rofi_view_create ( Mode *sw,
box_add ( state->input_bar, WIDGET ( state->text ), TRUE, 2 ); box_add ( state->input_bar, WIDGET ( state->text ), TRUE, 2 );
textbox_text ( state->case_indicator, get_matching_state () ); textbox_text ( state->case_indicator, get_matching_state () );
if ( message ) { state->mesg_box = container_create ( "window.mainbox.message.box" );
container *box = container_create ( "window.mainbox.message.box" ); state->mesg_tb = textbox_create ( "window.mainbox.message.textbox", TB_AUTOHEIGHT | TB_MARKUP | TB_WRAP, NORMAL, message );
textbox *message_tb = textbox_create ( "window.mainbox.message.textbox", TB_AUTOHEIGHT | TB_MARKUP | TB_WRAP, NORMAL, message ); container_add ( state->mesg_box, WIDGET ( state->mesg_tb ) );
container_add ( box, WIDGET ( message_tb ) ); if ( message == NULL ) {
box_add ( state->main_box, WIDGET ( box ), FALSE, end ? 8 : 2 ); widget_disable ( WIDGET( state->mesg_box ) );
} }
box_add ( state->main_box, WIDGET ( state->mesg_box ), FALSE, end ? 8 : 2 );
state->overlay = textbox_create ( "window.overlay", TB_AUTOWIDTH | TB_AUTOHEIGHT, URGENT, "blaat" ); state->overlay = textbox_create ( "window.overlay", TB_AUTOWIDTH | TB_AUTOHEIGHT, URGENT, "blaat" );
state->overlay->widget.parent = WIDGET ( state->main_window ); state->overlay->widget.parent = WIDGET ( state->main_window );