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

Add converter back for old theme format.

This commit is contained in:
Dave Davenport 2017-04-02 12:32:11 +02:00
parent c28dd35f3d
commit a754815d14
12 changed files with 147 additions and 30 deletions

View file

@ -111,4 +111,8 @@ Settings config = {
.click_to_exit = TRUE,
.show_match = TRUE,
.theme = NULL,
.color_normal = NULL,
.color_active = NULL,
.color_urgent = NULL,
.color_window = NULL,
};

View file

@ -64,6 +64,12 @@ typedef struct
/** Font string (pango format) */
char * menu_font;
/** New row colors */
char * color_normal;
char * color_active;
char * color_urgent;
char * color_window;
/** Terminal to use */
char * terminal_emulator;
/** SSH client to use */

View file

@ -409,4 +409,9 @@ Property *rofi_theme_find_property ( ThemeWidget *widget, PropertyType type, con
* @returns TRUE when empty.
*/
gboolean rofi_theme_is_empty ( void );
/**
* Convert old theme colors into default one.
*/
void rofi_theme_convert_old ( void );
#endif

View file

@ -408,6 +408,15 @@ if ( queue == NULL ){
yylval->colorval.alpha = 1.0;
return T_COLOR;
}
<PROPERTIES>argb:{HEX}{1,8} {
union { unsigned int val; struct { unsigned char b,g,r,a;};} val;
val.val = (unsigned int)strtoull ( &yytext[5], NULL, 16);
yylval->colorval.alpha = val.a/255.0;
yylval->colorval.red = val.r/255.0;
yylval->colorval.green = val.g/255.0;
yylval->colorval.blue = val.b/255.0;
return T_COLOR;
}
<PROPERTIES>{CENTER} {
yylval->ival = WL_CENTER;

View file

@ -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 ) {

View file

@ -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 );
}
}

View file

@ -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 );
}

View file

@ -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 */