Add @theme import command, that resets the current theme.

This commit is contained in:
Dave Davenport 2017-09-18 17:48:13 +02:00
parent ae8e7d9964
commit 99f2a1a9bf
4 changed files with 20 additions and 2 deletions

View File

@ -288,6 +288,11 @@ GList *rofi_theme_get_list ( const widget *widget, const char * property, const
*/
gboolean rofi_theme_is_empty ( void );
/**
* Reset the current theme.
*/
void rofi_theme_reset ( void );
#ifdef THEME_CONVERTER
/**
* Convert old theme colors into default one.

View File

@ -229,6 +229,7 @@ C_COMMENT_OPEN "/*"
INCLUDE "@import"
THEME "@theme"
CONFIGURATION (?i:configuration)
@ -301,6 +302,11 @@ if ( queue == NULL ){
<INITIAL>{INCLUDE} {
g_queue_push_head ( queue, GINT_TO_POINTER (YY_START) );
BEGIN(INCLUDE);
}
<INITIAL>{THEME} {
rofi_theme_reset();
g_queue_push_head ( queue, GINT_TO_POINTER (YY_START) );
BEGIN(INCLUDE);
}
/** Skip all whitespace */
<INCLUDE>{WHITESPACE} {}

View File

@ -256,8 +256,8 @@ t_entry_list:
%empty {
// There is always a base widget.
if (rofi_theme == NULL ){
$$ = rofi_theme = g_slice_new0 ( ThemeWidget );
rofi_theme->name = g_strdup ( "Root" );
rofi_theme_reset();
$$ = rofi_theme;
}
}
| t_entry_list

View File

@ -111,6 +111,13 @@ void rofi_theme_property_free ( Property *p )
g_slice_free ( Property, p );
}
void rofi_theme_reset ( void )
{
rofi_theme_free ( rofi_theme );
rofi_theme = g_slice_new0 ( ThemeWidget );
rofi_theme->name = g_strdup("Root");
}
void rofi_theme_free ( ThemeWidget *widget )
{
if ( widget == NULL ) {