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

Pull config option access from out of separator widget.

This commit is contained in:
Dave Davenport 2016-11-01 08:04:39 +01:00
parent dde77ecd7c
commit 4c5df96fcd
9 changed files with 99 additions and 47 deletions

View file

@ -27,6 +27,13 @@ typedef enum
S_VERTICAL = 1
} separator_type;
typedef enum
{
S_LINE_NONE,
S_LINE_SOLID,
S_LINE_DASH
} separator_line_style;
/**
* @param type The type of separator.
* @param sw The thickness of the separator.
@ -37,5 +44,20 @@ typedef enum
*/
separator *separator_create ( separator_type type, short sw );
/**
* @param sp The separator widget handle.
* @param style_str String representation of the style.
*
* Sets the line style based on the string style_str
*/
void separator_set_line_style_from_string ( separator *sp, const char *style_str );
/**
* @param sp The separator widget handle.
* @param style The new style.
*
* Sets the line style.
*/
void separator_set_line_style ( separator *sp, separator_line_style style );
/*@}*/
#endif // ROFI_SEPARATOR_H

View file

@ -262,7 +262,7 @@ static char ** get_apps ( unsigned int *length )
const char *const sep = ":";
char *strtok_savepointer = NULL;
for ( const char *dirname = strtok_r ( path, sep, &strtok_savepointer); dirname != NULL; dirname = strtok_r ( NULL, sep, &strtok_savepointer ) ) {
for ( const char *dirname = strtok_r ( path, sep, &strtok_savepointer ); dirname != NULL; dirname = strtok_r ( NULL, sep, &strtok_savepointer ) ) {
DIR *dir = opendir ( dirname );
g_log ( LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "Checking path %s for executable.", dirname );

View file

@ -298,7 +298,7 @@ static char ** get_ssh ( unsigned int *length )
// be multiple (possibly quoted) arguments separated by whitespace.
// The keyword is separated from its arguments by whitespace OR by
// optional whitespace and a '=' character.
char *token = strtok_r ( buffer, SSH_TOKEN_DELIM, &strtok_pointer);
char *token = strtok_r ( buffer, SSH_TOKEN_DELIM, &strtok_pointer );
// Skip empty lines and comment lines. Also skip lines where the
// keyword is not "Host".

View file

@ -1380,6 +1380,7 @@ RofiViewState *rofi_view_create ( Mode *sw,
state->input_bar = box_create ( BOX_HORIZONTAL, 0, 0, state->width - state->border, line_height );
//box_set_padding ( state->input_bar, config.line_margin );
state->input_bar_separator = separator_create ( S_HORIZONTAL, 2 );
separator_set_line_style_from_string ( state->input_bar_separator, config.separator_style );
if ( ( config.location == WL_EAST_SOUTH || config.location == WL_SOUTH || config.location == WL_SOUTH_WEST ) ) {
box_add ( state->main_box, WIDGET ( state->input_bar_separator ), FALSE, TRUE );
@ -1412,7 +1413,9 @@ RofiViewState *rofi_view_create ( Mode *sw,
textbox *message_tb = textbox_create ( TB_AUTOHEIGHT | TB_MARKUP | TB_WRAP, 0, 0,
state->width - ( 2 * ( state->border ) ), -1, NORMAL, message );
box_add ( state->main_box, WIDGET ( message_tb ), FALSE, FALSE );
box_add ( state->main_box, WIDGET ( separator_create ( S_HORIZONTAL, 2 ) ), FALSE, FALSE );
separator *sep = separator_create ( S_HORIZONTAL, 2 );
box_add ( state->main_box, WIDGET ( sep ), FALSE, FALSE );
separator_set_line_style_from_string ( sep, config.separator_style );
}
state->overlay = textbox_create ( TB_AUTOWIDTH, 0, 0, 20, line_height, URGENT, "blaat" );
@ -1437,7 +1440,9 @@ RofiViewState *rofi_view_create ( Mode *sw,
if ( config.sidebar_mode ) {
state->sidebar_bar = box_create ( BOX_HORIZONTAL, 0, 0, state->width - 2 * state->border, line_height );
box_set_padding ( state->sidebar_bar, config.line_margin );
box_add ( state->main_box, WIDGET ( separator_create ( S_HORIZONTAL, 2 ) ), FALSE, TRUE );
separator *sep = separator_create ( S_HORIZONTAL, 2 );
box_add ( state->main_box, WIDGET ( sep ), FALSE, TRUE );
separator_set_line_style_from_string ( sep, config.separator_style );
box_add ( state->main_box, WIDGET ( state->sidebar_bar ), FALSE, TRUE );
state->num_modi = rofi_get_num_enabled_modi ();
state->modi = g_malloc0 ( state->num_modi * sizeof ( textbox * ) );

View file

@ -39,6 +39,7 @@ struct _separator
{
widget widget;
separator_type type;
separator_line_style line_style;
};
/** Configuration value for separator style indicating no line */
@ -78,12 +79,37 @@ static void separator_free ( widget *wid )
g_free ( sb );
}
void separator_set_line_style ( separator *sp, separator_line_style style )
{
if ( sp ) {
sp->line_style = style;
widget_need_redraw ( WIDGET ( sp ) );
}
}
void separator_set_line_style_from_string ( separator *sp, const char *style_str )
{
if ( !sp ) {
return;
}
separator_line_style style = S_LINE_SOLID;
if ( g_strcmp0 ( style_str, _separator_style_none ) == 0 ) {
style = S_LINE_NONE;
}
else if ( g_strcmp0 ( style_str, _separator_style_dash ) == 0 ) {
style = S_LINE_DASH;
}
separator_set_line_style ( sp, style );
}
static void separator_draw ( widget *wid, cairo_t *draw )
{
separator *sep = (separator *) wid;
if ( strcmp ( config.separator_style, _separator_style_none ) ) {
if ( sep->line_style == S_LINE_NONE ) {
// Nothing to draw.
return;
}
color_separator ( draw );
if ( strcmp ( config.separator_style, _separator_style_dash ) == 0 ) {
if ( sep->line_style == S_LINE_DASH ) {
const double dashes[1] = { 4 };
cairo_set_dash ( draw, dashes, 1, 0.0 );
}
@ -100,5 +126,4 @@ static void separator_draw ( widget *wid, cairo_t *draw )
cairo_line_to ( draw, wid->x + half, wid->y + wid->h );
}
cairo_stroke ( draw );
}
}