diff options
author | Dave Davenport <qball@gmpclient.org> | 2017-04-02 12:32:11 +0200 |
---|---|---|
committer | Dave Davenport <qball@gmpclient.org> | 2017-04-02 12:32:11 +0200 |
commit | a754815d14492c4e0d38226965c19773cbe96350 (patch) | |
tree | 477de834f954a71777da7c949117ef9101b84d46 /source | |
parent | c28dd35f3d80b12d5788404cd9a4a1deea9fbdc9 (diff) |
Add converter back for old theme format.
Diffstat (limited to 'source')
-rw-r--r-- | source/dialogs/ssh.c | 2 | ||||
-rw-r--r-- | source/helper.c | 6 | ||||
-rw-r--r-- | source/rofi.c | 26 | ||||
-rw-r--r-- | source/theme.c | 65 | ||||
-rw-r--r-- | source/widgets/listview.c | 12 | ||||
-rw-r--r-- | source/xrmoptions.c | 8 |
6 files changed, 106 insertions, 13 deletions
diff --git a/source/dialogs/ssh.c b/source/dialogs/ssh.c index 97c353b4..a332dd5f 100644 --- a/source/dialogs/ssh.c +++ b/source/dialogs/ssh.c @@ -206,7 +206,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. diff --git a/source/helper.c b/source/helper.c index 12a49109..ff1d002c 100644 --- a/source/helper.c +++ b/source/helper.c @@ -255,7 +255,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 ); @@ -866,8 +866,8 @@ int rofi_scorer_fuzzy_evaluate ( const char *pattern, glong plen, const char *st // uleft: value of the upper left cell; ulefts: maximum value of uleft and cells on the left. The arbitrary initial // values suppress warnings. int uleft = 0, ulefts = 0, left, lefts; - const gchar *pit = pattern, *sit; - enum CharClass prev = NON_WORD, cur; + const gchar *pit = pattern, *sit; + enum CharClass prev = NON_WORD, cur; for ( si = 0, sit = str; si < slen; si++, sit = g_utf8_next_char ( sit ) ) { cur = rofi_scorer_get_character_class ( g_utf8_get_char ( sit ) ); score[si] = rofi_scorer_get_score_for ( prev, cur ); diff --git a/source/rofi.c b/source/rofi.c index e4e3ccbe..7e326a9c 100644 --- a/source/rofi.c +++ b/source/rofi.c @@ -197,12 +197,12 @@ static void run_switcher ( ModeMode mode ) // Otherwise check if requested mode is enabled. for ( unsigned int i = 0; i < num_modi; i++ ) { if ( !mode_init ( modi[i] ) ) { - GString *str= g_string_new ( "Failed to initialize the mode: "); + GString *str = g_string_new ( "Failed to initialize the mode: " ); g_string_append ( str, modi[i]->name ); - g_string_append ( str, "\n"); + g_string_append ( str, "\n" ); rofi_view_error_dialog ( str->str, ERROR_MSG_MARKUP ); - g_string_free (str, FALSE); + g_string_free ( str, FALSE ); break; } } @@ -350,12 +350,12 @@ static void help_print_disabled_mode ( const char *mode ) // Only output to terminal if ( is_term ) { fprintf ( stderr, "Mode %s%s%s is not enabled. I have enabled it for now.\n", - color_red, mode, color_reset); + color_red, mode, color_reset ); fprintf ( stderr, "Please consider adding %s%s%s to the list of enabled modi: %smodi: %s%s%s,%s%s.\n", - color_red, mode, color_reset, - color_green, config.modi,color_reset, - color_red, mode, color_reset - ); + color_red, mode, color_reset, + color_green, config.modi, color_reset, + color_red, mode, color_reset + ); } } static void help_print_no_arguments ( void ) @@ -391,7 +391,7 @@ static void help_print_no_arguments ( void ) } } fprintf ( stderr, "\nTo activate a mode, add it to the list of modi in the %smodi%s setting.", - is_term?color_green:"",is_term?color_reset:"" ); + is_term ? color_green : "", is_term ? color_reset : "" ); } /** @@ -1140,10 +1140,18 @@ int main ( int argc, char *argv[] ) if ( rofi_theme_is_empty ( ) ) { if ( rofi_theme_parse_string ( default_theme ) ) { fprintf ( stderr, "Failed to parse default theme. Giving up..\n" ); + if ( list_of_error_msgs ) { + for ( GList *iter = g_list_first ( list_of_error_msgs ); + iter != NULL; iter = g_list_next ( iter ) ) { + fprintf ( stderr, "Error: %s%s%s\n", + color_bold, ( (GString *) iter->data )->str, color_reset ); + } + } rofi_theme = NULL; cleanup (); return EXIT_FAILURE; } + rofi_theme_convert_old (); } if ( find_arg ( "-dump-theme" ) >= 0 ) { diff --git a/source/theme.c b/source/theme.c index d6ced01e..890ced85 100644 --- a/source/theme.c +++ b/source/theme.c @@ -574,3 +574,68 @@ gboolean rofi_theme_is_empty ( void ) return FALSE; } +void rofi_theme_convert_old ( void ) +{ + if ( config.color_window ) { + char **retv = g_strsplit ( config.color_window, ",", -1 ); + const char const *conf[] = { + "* { background: %s; }", + "* { bordercolor: %s; }", + "* { separatorcolor: %s; }" + }; + for ( int i = 0; retv && retv[i]; i++ ) { + char *str = g_strdup_printf ( conf[i], retv[i] ); + rofi_theme_parse_string ( str ); + g_free ( str ); + } + g_strfreev ( retv ); + } + if ( config.color_normal ) { + char **retv = g_strsplit ( config.color_normal, ",", -1 ); + const char const *conf[] = { + "* { normal-background: %s; }", + "* { foreground: %s; normal-foreground: @foreground; alternate-normal-foreground: @foreground; }", + "* { alternate-normal-background: %s; }", + "* { selected-normal-background: %s; }", + "* { selected-normal-foreground: %s; }" + }; + for ( int i = 0; retv && retv[i]; i++ ) { + char *str = g_strdup_printf ( conf[i], retv[i] ); + rofi_theme_parse_string ( str ); + g_free ( str ); + } + g_strfreev ( retv ); + } + if ( config.color_urgent ) { + char **retv = g_strsplit ( config.color_urgent, ",", -1 ); + const char const *conf[] = { + "* { urgent-background: %s; }", + "* { urgent-foreground: %s; alternate-urgent-foreground: @urgent-foreground;}", + "* { alternate-urgent-background: %s; }", + "* { selected-urgent-background: %s; }", + "* { selected-urgent-foreground: %s; }" + }; + for ( int i = 0; retv && retv[i]; i++ ) { + char *str = g_strdup_printf ( conf[i], retv[i] ); + rofi_theme_parse_string ( str ); + g_free ( str ); + } + g_strfreev ( retv ); + } + if ( config.color_active ) { + char **retv = g_strsplit ( config.color_active, ",", -1 ); + const char const *conf[] = { + "* { active-background: %s; }", + "* { active-foreground: %s; alternate-active-foreground: @active-foreground;}", + "* { alternate-active-background: %s; }", + "* { selected-active-background: %s; }", + "* { selected-active-foreground: %s; }" + }; + for ( int i = 0; retv && retv[i]; i++ ) { + char *str = g_strdup_printf ( conf[i], retv[i] ); + rofi_theme_parse_string ( str ); + g_free ( str ); + } + g_strfreev ( retv ); + } +} diff --git a/source/widgets/listview.c b/source/widgets/listview.c index 6dc092a8..84a6bbce 100644 --- a/source/widgets/listview.c +++ b/source/widgets/listview.c @@ -433,6 +433,9 @@ static void listview_nav_down_int ( listview *lv ) void listview_nav_up ( listview *lv ) { + if ( lv == NULL ) { + return; + } if ( lv->reverse ) { listview_nav_down_int ( lv ); } @@ -442,6 +445,9 @@ void listview_nav_up ( listview *lv ) } void listview_nav_down ( listview *lv ) { + if ( lv == NULL ) { + return; + } if ( lv->reverse ) { listview_nav_up_int ( lv ); } @@ -514,6 +520,9 @@ static void listview_nav_page_next_int ( listview *lv ) void listview_nav_page_prev ( listview *lv ) { + if ( lv == NULL ) { + return; + } if ( lv->reverse ) { listview_nav_page_next_int ( lv ); } @@ -523,6 +532,9 @@ void listview_nav_page_prev ( listview *lv ) } void listview_nav_page_next ( listview *lv ) { + if ( lv == NULL ) { + return; + } if ( lv->reverse ) { listview_nav_page_prev_int ( lv ); } diff --git a/source/xrmoptions.c b/source/xrmoptions.c index 5713e22d..dd200a3d 100644 --- a/source/xrmoptions.c +++ b/source/xrmoptions.c @@ -171,6 +171,14 @@ static XrmOption xrmOptions[] = { "Indicate how it match by underlining it.", CONFIG_DEFAULT }, { xrm_String, "theme", { .str = &config.theme }, NULL, "New style theme file", CONFIG_DEFAULT }, + { xrm_String, "color-normal", { .str = &config.color_normal }, NULL, + "Color scheme for normal row", CONFIG_DEFAULT }, + { xrm_String, "color-urgent", { .str = &config.color_urgent }, NULL, + "Color scheme for urgent row", CONFIG_DEFAULT }, + { xrm_String, "color-active", { .str = &config.color_active }, NULL, + "Color scheme for active row", CONFIG_DEFAULT }, + { xrm_String, "color-window", { .str = &config.color_window }, NULL, + "Color scheme window", CONFIG_DEFAULT }, }; /** Dynamic array of extra options */ |