summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorDave Davenport <qball@gmpclient.org>2016-11-01 08:04:39 +0100
committerDave Davenport <qball@gmpclient.org>2016-11-01 08:04:39 +0100
commit4c5df96fcd9ff9868a9d892333ac313fe077a7d4 (patch)
treef54c0818fdbda2391032499f9e20b385722a4c87 /source
parentdde77ecd7ce191a51bba6189938ce05903010eaa (diff)
Pull config option access from out of separator widget.
Diffstat (limited to 'source')
-rw-r--r--source/dialogs/drun.c6
-rw-r--r--source/dialogs/run.c6
-rw-r--r--source/dialogs/ssh.c10
-rw-r--r--source/helper.c4
-rw-r--r--source/rofi.c2
-rw-r--r--source/view.c9
-rw-r--r--source/widgets/separator.c67
7 files changed, 67 insertions, 37 deletions
diff --git a/source/dialogs/drun.c b/source/dialogs/drun.c
index cc452e5c..dc88aadd 100644
--- a/source/dialogs/drun.c
+++ b/source/dialogs/drun.c
@@ -278,9 +278,9 @@ static void read_desktop_file ( DRunModePrivateData *pd, const char *root, const
return;
}
size_t nl = ( ( pd->cmd_list_length ) + 1 );
- pd->entry_list = g_realloc ( pd->entry_list, nl * sizeof ( *( pd->entry_list ) ) );
- pd->entry_list[pd->cmd_list_length].root = g_strdup ( root );
- pd->entry_list[pd->cmd_list_length].path = g_strdup ( path );
+ pd->entry_list = g_realloc ( pd->entry_list, nl * sizeof ( *( pd->entry_list ) ) );
+ pd->entry_list[pd->cmd_list_length].root = g_strdup ( root );
+ pd->entry_list[pd->cmd_list_length].path = g_strdup ( path );
gchar *n = g_key_file_get_locale_string ( kf, "Desktop Entry", "Name", NULL, NULL );
pd->entry_list[pd->cmd_list_length].name = n;
gchar *gn = g_key_file_get_locale_string ( kf, "Desktop Entry", "GenericName", NULL, NULL );
diff --git a/source/dialogs/run.c b/source/dialogs/run.c
index b17e712f..ca08f482 100644
--- a/source/dialogs/run.c
+++ b/source/dialogs/run.c
@@ -260,9 +260,9 @@ static char ** get_apps ( unsigned int *length )
return NULL;
}
- 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 ) ) {
+ 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 ) ) {
DIR *dir = opendir ( dirname );
g_log ( LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "Checking path %s for executable.", dirname );
diff --git a/source/dialogs/ssh.c b/source/dialogs/ssh.c
index 828e3d4a..5ad6078f 100644
--- a/source/dialogs/ssh.c
+++ b/source/dialogs/ssh.c
@@ -198,7 +198,7 @@ static char **read_hosts_file ( char ** retv, unsigned int *length )
// Reading one line per time.
while ( getline ( &buffer, &buffer_length, fd ) > 0 ) {
// Evaluate one line.
- unsigned int index = 0, ti = 0;
+ unsigned int index = 0, ti = 0;
char *token = buffer;
// Tokenize it.
@@ -289,16 +289,16 @@ static char ** get_ssh ( unsigned int *length )
fd = fopen ( path, "r" );
if ( fd != NULL ) {
- char *buffer = NULL;
- size_t buffer_length = 0;
- char *strtok_pointer = NULL;
+ char *buffer = NULL;
+ size_t buffer_length = 0;
+ char *strtok_pointer = NULL;
while ( getline ( &buffer, &buffer_length, fd ) > 0 ) {
// Each line is either empty, a comment line starting with a '#'
// character or of the form "keyword [=] arguments", where there may
// 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".
diff --git a/source/helper.c b/source/helper.c
index bf21e0a6..9270e1ed 100644
--- a/source/helper.c
+++ b/source/helper.c
@@ -194,7 +194,7 @@ static GRegex * create_regex ( const char *input, int case_sensitive )
{
#define R( s ) g_regex_new ( s, G_REGEX_OPTIMIZE | ( ( case_sensitive ) ? 0 : G_REGEX_CASELESS ), 0, NULL )
GRegex * retv = NULL;
- gchar *r;
+ gchar *r;
switch ( config.matching_method )
{
case MM_GLOB:
@@ -234,7 +234,7 @@ GRegex **tokenize ( const char *input, int case_sensitive )
}
char *saveptr = NULL, *token;
- GRegex **retv = NULL;
+ GRegex **retv = NULL;
if ( !config.tokenize ) {
retv = g_malloc0 ( sizeof ( GRegex* ) * 2 );
retv[0] = (GRegex *) create_regex ( input, case_sensitive );
diff --git a/source/rofi.c b/source/rofi.c
index f20478a0..11209106 100644
--- a/source/rofi.c
+++ b/source/rofi.c
@@ -352,7 +352,7 @@ static int add_mode ( const char * token )
}
else
#endif // WINDOW_MODE
- // SSh dialog
+ // SSh dialog
if ( strcasecmp ( token, "ssh" ) == 0 ) {
modi[num_modi] = &ssh_mode;
num_modi++;
diff --git a/source/view.c b/source/view.c
index d20aa8e1..8a2e4b55 100644
--- a/source/view.c
+++ b/source/view.c
@@ -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 * ) );
diff --git a/source/widgets/separator.c b/source/widgets/separator.c
index 58e753df..9bbd98d7 100644
--- a/source/widgets/separator.c
+++ b/source/widgets/separator.c
@@ -37,8 +37,9 @@
*/
struct _separator
{
- widget widget;
- separator_type type;
+ widget widget;
+ separator_type type;
+ separator_line_style line_style;
};
/** Configuration value for separator style indicating no line */
@@ -78,27 +79,51 @@ 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 ) ) {
- color_separator ( draw );
- if ( strcmp ( config.separator_style, _separator_style_dash ) == 0 ) {
- const double dashes[1] = { 4 };
- cairo_set_dash ( draw, dashes, 1, 0.0 );
- }
- if ( sep->type == S_HORIZONTAL ) {
- cairo_set_line_width ( draw, wid->h );
- double half = wid->h / 2.0;
- cairo_move_to ( draw, wid->x, wid->y + half );
- cairo_line_to ( draw, wid->x + wid->w, wid->y + half );
- }
- else {
- cairo_set_line_width ( draw, wid->w );
- double half = wid->w / 2.0;
- cairo_move_to ( draw, wid->x + half, wid->y );
- cairo_line_to ( draw, wid->x + half, wid->y + wid->h );
- }
- cairo_stroke ( draw );
+ if ( sep->line_style == S_LINE_NONE ) {
+ // Nothing to draw.
+ return;
+ }
+ color_separator ( draw );
+ if ( sep->line_style == S_LINE_DASH ) {
+ const double dashes[1] = { 4 };
+ cairo_set_dash ( draw, dashes, 1, 0.0 );
+ }
+ if ( sep->type == S_HORIZONTAL ) {
+ cairo_set_line_width ( draw, wid->h );
+ double half = wid->h / 2.0;
+ cairo_move_to ( draw, wid->x, wid->y + half );
+ cairo_line_to ( draw, wid->x + wid->w, wid->y + half );
+ }
+ else {
+ cairo_set_line_width ( draw, wid->w );
+ double half = wid->w / 2.0;
+ cairo_move_to ( draw, wid->x + half, wid->y );
+ cairo_line_to ( draw, wid->x + half, wid->y + wid->h );
}
+ cairo_stroke ( draw );
}