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

Load theme-str after loading fallback themes.

* If no theme loaded, try converting old theme.
 * If still no theme loaded, try default theme.
 * Then load modifications (theme-str option)
This commit is contained in:
Dave Davenport 2017-06-07 07:53:33 +02:00
parent d33edaf09d
commit 07076d154a
3 changed files with 25 additions and 19 deletions

View file

@ -838,16 +838,10 @@ int main ( int argc, char *argv[] )
TICK_N ( "Setup Modi" ); TICK_N ( "Setup Modi" );
} }
const char ** theme_str = find_arg_strv ( "-theme-str" ); if ( rofi_theme_is_empty ( ) ) {
if ( theme_str ) { rofi_theme_convert_old ();
for ( int index = 0; theme_str && theme_str[index]; index++ ) {
if ( rofi_theme_parse_string ( theme_str[index] ) ) {
rofi_theme_free ( rofi_theme );
rofi_theme = NULL;
}
}
g_free ( theme_str );
} }
if ( rofi_theme_is_empty ( ) ) { if ( rofi_theme_is_empty ( ) ) {
if ( rofi_theme_parse_string ( default_theme ) ) { if ( rofi_theme_parse_string ( default_theme ) ) {
g_warning ( "Failed to parse default theme. Giving up.." ); g_warning ( "Failed to parse default theme. Giving up.." );
@ -862,7 +856,19 @@ int main ( int argc, char *argv[] )
cleanup (); cleanup ();
return EXIT_FAILURE; return EXIT_FAILURE;
} }
rofi_theme_convert_old (); }
/**
* Make small commandline changes to the current theme.
*/
const char ** theme_str = find_arg_strv ( "-theme-str" );
if ( theme_str ) {
for ( int index = 0; theme_str && theme_str[index]; index++ ) {
if ( rofi_theme_parse_string ( theme_str[index] ) ) {
rofi_theme_free ( rofi_theme );
rofi_theme = NULL;
}
}
g_free ( theme_str );
} }
if ( find_arg ( "-dump-theme" ) >= 0 ) { if ( find_arg ( "-dump-theme" ) >= 0 ) {

View file

@ -164,17 +164,17 @@ static void rofi_theme_print_property_index ( size_t pnl, int depth, Property *p
switch ( p->type ) switch ( p->type )
{ {
case P_LIST: case P_LIST:
printf ("[ "); printf ( "[ " );
for ( GList *iter = p->value.list; iter != NULL; iter = g_list_next ( iter ) ) { for ( GList *iter = p->value.list; iter != NULL; iter = g_list_next ( iter ) ) {
printf("%s", (char*)(iter->data)); printf ( "%s", (char *) ( iter->data ) );
if ( iter->next != NULL ) { if ( iter->next != NULL ) {
printf(","); printf ( "," );
} }
} }
printf (" ];"); printf ( " ];" );
break; break;
case P_ORIENTATION: case P_ORIENTATION:
printf("%s;", (p->value.i == ROFI_ORIENTATION_HORIZONTAL)? "horizontal":"vertical" ); printf ( "%s;", ( p->value.i == ROFI_ORIENTATION_HORIZONTAL ) ? "horizontal" : "vertical" );
break; break;
case P_HIGHLIGHT: case P_HIGHLIGHT:
if ( p->value.highlight.style & ROFI_HL_BOLD ) { if ( p->value.highlight.style & ROFI_HL_BOLD ) {
@ -624,7 +624,7 @@ GList *rofi_theme_get_list ( const widget *widget, const char * property, const
Property *p = rofi_theme_find_property ( wid2, P_LIST, property, TRUE ); Property *p = rofi_theme_find_property ( wid2, P_LIST, property, TRUE );
if ( p ) { if ( p ) {
if ( p->type == P_LIST ) { if ( p->type == P_LIST ) {
return g_list_copy_deep ( p->value.list, (GCopyFunc)g_strdup, NULL ); return g_list_copy_deep ( p->value.list, (GCopyFunc) g_strdup, NULL );
} }
} }
char **r = defaults ? g_strsplit ( defaults, ",", 0 ) : NULL; char **r = defaults ? g_strsplit ( defaults, ",", 0 ) : NULL;

View file

@ -420,7 +420,7 @@ static void textbox_draw ( widget *wid, cairo_t *draw )
int bottom = widget_padding_get_bottom ( WIDGET ( tb ) ); int bottom = widget_padding_get_bottom ( WIDGET ( tb ) );
top = ( tb->widget.h - bottom - height - top ) * tb->yalign + top; top = ( tb->widget.h - bottom - height - top ) * tb->yalign + top;
} }
y+=top; y += top;
// draw Icon // draw Icon
if ( ( tb->flags & TB_ICON ) == TB_ICON && tb->icon != NULL ) { if ( ( tb->flags & TB_ICON ) == TB_ICON && tb->icon != NULL ) {
@ -447,8 +447,8 @@ static void textbox_draw ( widget *wid, cairo_t *draw )
} }
else if ( tb->flags & TB_CENTER ) { else if ( tb->flags & TB_CENTER ) {
int tw = textbox_get_font_width ( tb ); int tw = textbox_get_font_width ( tb );
x = ( ( tb->widget.w - tw - widget_padding_get_padding_width ( WIDGET ( tb ) ) - offset ) ) / 2; x = ( ( tb->widget.w - tw - widget_padding_get_padding_width ( WIDGET ( tb ) ) - offset ) ) / 2;
x += widget_padding_get_left ( WIDGET (tb) ) ; x += widget_padding_get_left ( WIDGET ( tb ) );
} }
// TODO check if this is still needed after flatning. // TODO check if this is still needed after flatning.
cairo_set_operator ( draw, CAIRO_OPERATOR_OVER ); cairo_set_operator ( draw, CAIRO_OPERATOR_OVER );