[Theme] Make 'sidebar' settable by theme.

Now it needs a configuration option to enable, this should be just part
of the theme now.

Sidebar is the "sidebar" widget.

If not set by theme, old behaviour is still followed.
This commit is contained in:
Dave Davenport 2019-03-05 10:09:48 +01:00
parent ee0d3d828e
commit 2728e4ad23
2 changed files with 19 additions and 19 deletions

View File

@ -503,10 +503,8 @@ void rofi_view_free ( RofiViewState *state )
g_free ( state->distance ); g_free ( state->distance );
// Free the switcher boxes. // Free the switcher boxes.
// When state is free'ed we should no longer need these. // When state is free'ed we should no longer need these.
if ( config.sidebar_mode == TRUE ) { g_free ( state->modi );
g_free ( state->modi ); state->num_modi = 0;
state->num_modi = 0;
}
g_free ( state ); g_free ( state );
} }
@ -1557,7 +1555,11 @@ static void rofi_view_add_widget ( RofiViewState *state, widget *parent_widget,
if ( strcmp ( name, "mainbox" ) == 0 ) { if ( strcmp ( name, "mainbox" ) == 0 ) {
wid = (widget *) box_create ( parent_widget, name, ROFI_ORIENTATION_VERTICAL ); wid = (widget *) box_create ( parent_widget, name, ROFI_ORIENTATION_VERTICAL );
box_add ( (box *) parent_widget, WIDGET ( wid ), TRUE ); box_add ( (box *) parent_widget, WIDGET ( wid ), TRUE );
defaults = "inputbar,message,listview,sidebar"; if ( config.sidebar_mode ) {
defaults = "inputbar,message,listview,sidebar";
} else {
defaults = "inputbar,message,listview";
}
} }
/** /**
* INPUTBAR * INPUTBAR
@ -1649,18 +1651,16 @@ static void rofi_view_add_widget ( RofiViewState *state, widget *parent_widget,
g_error ( "Sidebar widget can only be added once to the layout." ); g_error ( "Sidebar widget can only be added once to the layout." );
return; return;
} }
if ( config.sidebar_mode ) { state->sidebar_bar = box_create ( parent_widget, name, ROFI_ORIENTATION_HORIZONTAL );
state->sidebar_bar = box_create ( parent_widget, name, ROFI_ORIENTATION_HORIZONTAL ); box_add ( (box *) parent_widget, WIDGET ( state->sidebar_bar ), FALSE );
box_add ( (box *) parent_widget, WIDGET ( state->sidebar_bar ), FALSE ); state->num_modi = rofi_get_num_enabled_modi ();
state->num_modi = rofi_get_num_enabled_modi (); state->modi = g_malloc0 ( state->num_modi * sizeof ( textbox * ) );
state->modi = g_malloc0 ( state->num_modi * sizeof ( textbox * ) ); for ( unsigned int j = 0; j < state->num_modi; j++ ) {
for ( unsigned int j = 0; j < state->num_modi; j++ ) { const Mode * mode = rofi_get_mode ( j );
const Mode * mode = rofi_get_mode ( j ); state->modi[j] = textbox_create ( WIDGET ( state->sidebar_bar ), WIDGET_TYPE_SIDEBAR_MODI, "button", TB_AUTOHEIGHT, ( mode == state->sw ) ? HIGHLIGHT : NORMAL,
state->modi[j] = textbox_create ( WIDGET ( state->sidebar_bar ), WIDGET_TYPE_SIDEBAR_MODI, "button", TB_AUTOHEIGHT, ( mode == state->sw ) ? HIGHLIGHT : NORMAL, mode_get_display_name ( mode ), 0.5, 0.5 );
mode_get_display_name ( mode ), 0.5, 0.5 ); box_add ( state->sidebar_bar, WIDGET ( state->modi[j] ), TRUE );
box_add ( state->sidebar_bar, WIDGET ( state->modi[j] ), TRUE ); widget_set_trigger_action_handler ( WIDGET ( state->modi[j] ), textbox_sidebar_modi_trigger_action, state );
widget_set_trigger_action_handler ( WIDGET ( state->modi[j] ), textbox_sidebar_modi_trigger_action, state );
}
} }
} }
else if ( g_ascii_strncasecmp ( name, "textbox", 7 ) == 0 ) { else if ( g_ascii_strncasecmp ( name, "textbox", 7 ) == 0 ) {
@ -1922,7 +1922,7 @@ void rofi_view_switch_mode ( RofiViewState *state, Mode *mode )
if ( state->prompt ) { if ( state->prompt ) {
rofi_view_update_prompt ( state ); rofi_view_update_prompt ( state );
} }
if ( config.sidebar_mode && state->sidebar_bar ) { if ( state->sidebar_bar ) {
for ( unsigned int j = 0; j < state->num_modi; j++ ) { for ( unsigned int j = 0; j < state->num_modi; j++ ) {
const Mode * mode = rofi_get_mode ( j ); const Mode * mode = rofi_get_mode ( j );
textbox_font ( state->modi[j], ( mode == state->sw ) ? HIGHLIGHT : NORMAL ); textbox_font ( state->modi[j], ( mode == state->sw ) ? HIGHLIGHT : NORMAL );

View File

@ -63,7 +63,7 @@
color: @magenta; color: @magenta;
background-color: @transparent; background-color: @transparent;
spacing: 0; spacing: 0;
children: [vertb, mainbox]; children: [mainbox];
orientation: horizontal; orientation: horizontal;
} }