summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Davenport <qball@gmpclient.org>2017-09-18 17:48:13 +0200
committerDave Davenport <qball@gmpclient.org>2017-09-18 17:48:13 +0200
commit99f2a1a9bf6fedeafe3e882f76aff876274d8ed3 (patch)
treea7c93edd5e9e8c9ad46050b06f39f72860781e89
parentae8e7d996430a48a211075b97727daaf0cb7e157 (diff)
Add @theme import command, that resets the current theme.
-rw-r--r--include/theme.h5
-rw-r--r--lexer/theme-lexer.l6
-rw-r--r--lexer/theme-parser.y4
-rw-r--r--source/theme.c7
4 files changed, 20 insertions, 2 deletions
diff --git a/include/theme.h b/include/theme.h
index df817e7c..843a658a 100644
--- a/include/theme.h
+++ b/include/theme.h
@@ -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.
diff --git a/lexer/theme-lexer.l b/lexer/theme-lexer.l
index 391ed3b8..a576e266 100644
--- a/lexer/theme-lexer.l
+++ b/lexer/theme-lexer.l
@@ -229,6 +229,7 @@ C_COMMENT_OPEN "/*"
INCLUDE "@import"
+THEME "@theme"
CONFIGURATION (?i:configuration)
@@ -302,6 +303,11 @@ if ( queue == NULL ){
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} {}
diff --git a/lexer/theme-parser.y b/lexer/theme-parser.y
index de22b98b..b97bae22 100644
--- a/lexer/theme-parser.y
+++ b/lexer/theme-parser.y
@@ -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
diff --git a/source/theme.c b/source/theme.c
index fed1afc2..06e9e490 100644
--- a/source/theme.c
+++ b/source/theme.c
@@ -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 ) {