2016-12-09 18:49:49 +00:00
# include <stdio.h>
# include <stdlib.h>
# include <errno.h>
# include <string.h>
# include "theme.h"
2016-12-12 15:55:31 +00:00
# include "lexer/theme-parser.h"
2016-12-28 11:21:42 +00:00
# include "helper.h"
2017-01-01 00:06:38 +00:00
# include "settings.h"
2016-12-31 22:27:17 +00:00
# include "widgets/textbox.h"
2017-01-03 18:23:09 +00:00
# include "view.h"
2017-02-17 13:06:31 +00:00
# include "rofi.h"
2016-12-31 22:27:17 +00:00
2017-01-08 15:23:17 +00:00
/** Logging domain for theme */
2017-01-08 20:36:06 +00:00
# define LOG_DOMAIN "Theme"
2017-01-04 13:01:28 +00:00
2017-01-09 21:40:11 +00:00
void yyerror ( YYLTYPE * ylloc , const char * , const char * ) ;
2017-01-04 22:11:25 +00:00
static gboolean distance_compare ( Distance d , Distance e )
{
2017-01-08 20:36:06 +00:00
return d . type = = e . type & & d . distance = = e . distance & & d . style = = e . style ;
2017-01-04 22:11:25 +00:00
}
2016-12-09 18:49:49 +00:00
2017-01-04 14:05:39 +00:00
ThemeWidget * rofi_theme_find_or_create_name ( ThemeWidget * base , const char * name )
2016-12-09 18:49:49 +00:00
{
2017-01-08 20:36:06 +00:00
for ( unsigned int i = 0 ; i < base - > num_widgets ; i + + ) {
if ( g_strcmp0 ( base - > widgets [ i ] - > name , name ) = = 0 ) {
2016-12-09 18:49:49 +00:00
return base - > widgets [ i ] ;
2016-12-12 15:55:31 +00:00
}
2016-12-09 18:49:49 +00:00
}
2017-01-08 20:36:06 +00:00
base - > widgets = g_realloc ( base - > widgets , sizeof ( ThemeWidget * ) * ( base - > num_widgets + 1 ) ) ;
2017-03-04 19:09:19 +00:00
base - > widgets [ base - > num_widgets ] = g_slice_new0 ( ThemeWidget ) ;
2017-01-01 17:08:49 +00:00
ThemeWidget * retv = base - > widgets [ base - > num_widgets ] ;
2016-12-09 18:49:49 +00:00
retv - > parent = base ;
2017-01-08 20:36:06 +00:00
retv - > name = g_strdup ( name ) ;
2016-12-09 18:49:49 +00:00
base - > num_widgets + + ;
return retv ;
}
/**
* Properties
*/
Property * rofi_theme_property_create ( PropertyType type )
{
2017-03-04 19:09:19 +00:00
Property * retv = g_slice_new0 ( Property ) ;
2016-12-09 18:49:49 +00:00
retv - > type = type ;
return retv ;
}
void rofi_theme_property_free ( Property * p )
{
if ( p = = NULL ) {
return ;
}
g_free ( p - > name ) ;
if ( p - > type = = P_STRING ) {
g_free ( p - > value . s ) ;
2017-01-08 20:36:06 +00:00
}
else if ( p - > type = = P_LINK ) {
2017-01-05 17:22:34 +00:00
g_free ( p - > value . link . name ) ;
2016-12-09 18:49:49 +00:00
}
2017-03-04 19:09:19 +00:00
g_slice_free ( Property , p ) ;
2016-12-09 18:49:49 +00:00
}
2017-01-01 17:08:49 +00:00
void rofi_theme_free ( ThemeWidget * widget )
2016-12-09 18:49:49 +00:00
{
2017-01-08 20:36:06 +00:00
if ( widget = = NULL ) {
2016-12-09 18:49:49 +00:00
return ;
}
if ( widget - > properties ) {
g_hash_table_destroy ( widget - > properties ) ;
}
2017-01-08 20:36:06 +00:00
for ( unsigned int i = 0 ; i < widget - > num_widgets ; i + + ) {
2016-12-16 08:28:13 +00:00
rofi_theme_free ( widget - > widgets [ i ] ) ;
2016-12-09 18:49:49 +00:00
}
g_free ( widget - > widgets ) ;
g_free ( widget - > name ) ;
2017-03-04 19:09:19 +00:00
g_slice_free ( ThemeWidget , widget ) ;
2016-12-09 18:49:49 +00:00
}
/**
* print
*/
2017-01-04 22:11:25 +00:00
static void rofi_theme_print_distance ( Distance d )
{
if ( d . type = = PW_PX ) {
2017-01-09 07:39:02 +00:00
printf ( " %upx " , ( unsigned int ) d . distance ) ;
2017-01-08 20:36:06 +00:00
}
else if ( d . type = = PW_PERCENT ) {
printf ( " %f%% " , d . distance ) ;
}
else {
printf ( " %fem " , d . distance ) ;
2017-01-04 22:11:25 +00:00
}
if ( d . style = = DASH ) {
2017-01-08 20:36:06 +00:00
printf ( " dash " ) ;
2017-01-04 22:11:25 +00:00
}
}
2017-01-08 17:03:31 +00:00
/** Textual representation of Window Location */
2017-03-17 13:27:08 +00:00
const char * const WindowLocationStr [ 9 ] = {
2017-01-08 17:03:31 +00:00
" center " ,
" northwest " ,
" north " ,
" northeast " ,
" east " ,
" southeast " ,
" south " ,
" southwest " ,
" west "
} ;
static void rofi_theme_print_property_index ( size_t pnl , int depth , Property * p )
2016-12-09 18:49:49 +00:00
{
2017-01-08 17:03:31 +00:00
int pl = strlen ( p - > name ) ;
2017-01-08 20:36:06 +00:00
printf ( " %*s%s:%*s " , depth , " " , p - > name , ( int ) pnl - pl , " " ) ;
2016-12-09 18:49:49 +00:00
switch ( p - > type )
{
2017-01-08 23:09:02 +00:00
case P_HIGHLIGHT :
if ( p - > value . highlight . style & HL_BOLD ) {
printf ( " bold " ) ;
}
if ( p - > value . highlight . style & HL_UNDERLINE ) {
printf ( " underline " ) ;
}
if ( p - > value . highlight . style & HL_ITALIC ) {
printf ( " italic " ) ;
}
if ( p - > value . highlight . style & HL_COLOR ) {
printf ( " #%02X%02X%02X%02X " ,
( unsigned char ) ( p - > value . highlight . color . alpha * 255.0 ) ,
( unsigned char ) ( p - > value . highlight . color . red * 255.0 ) ,
( unsigned char ) ( p - > value . highlight . color . green * 255.0 ) ,
( unsigned char ) ( p - > value . highlight . color . blue * 255.0 ) ) ;
}
printf ( " ; " ) ;
break ;
2017-01-08 20:36:06 +00:00
case P_POSITION :
printf ( " %s; " , WindowLocationStr [ p - > value . i ] ) ;
break ;
case P_STRING :
printf ( " \" %s \" ; " , p - > value . s ) ;
break ;
case P_INTEGER :
printf ( " %d; " , p - > value . i ) ;
break ;
case P_DOUBLE :
printf ( " %.2f; " , p - > value . f ) ;
break ;
case P_BOOLEAN :
printf ( " %s; " , p - > value . b ? " true " : " false " ) ;
break ;
case P_COLOR :
printf ( " #%02X%02X%02X%02X; " ,
( unsigned char ) ( p - > value . color . alpha * 255.0 ) ,
( unsigned char ) ( p - > value . color . red * 255.0 ) ,
( unsigned char ) ( p - > value . color . green * 255.0 ) ,
( unsigned char ) ( p - > value . color . blue * 255.0 ) ) ;
break ;
case P_PADDING :
if ( distance_compare ( p - > value . padding . top , p - > value . padding . bottom ) & &
distance_compare ( p - > value . padding . left , p - > value . padding . right ) & &
distance_compare ( p - > value . padding . left , p - > value . padding . top ) ) {
rofi_theme_print_distance ( p - > value . padding . left ) ;
}
else if ( distance_compare ( p - > value . padding . top , p - > value . padding . bottom ) & &
distance_compare ( p - > value . padding . left , p - > value . padding . right ) ) {
rofi_theme_print_distance ( p - > value . padding . top ) ;
rofi_theme_print_distance ( p - > value . padding . left ) ;
}
else if ( ! distance_compare ( p - > value . padding . top , p - > value . padding . bottom ) & &
distance_compare ( p - > value . padding . left , p - > value . padding . right ) ) {
rofi_theme_print_distance ( p - > value . padding . top ) ;
rofi_theme_print_distance ( p - > value . padding . left ) ;
rofi_theme_print_distance ( p - > value . padding . bottom ) ;
}
else {
rofi_theme_print_distance ( p - > value . padding . top ) ;
rofi_theme_print_distance ( p - > value . padding . right ) ;
rofi_theme_print_distance ( p - > value . padding . bottom ) ;
rofi_theme_print_distance ( p - > value . padding . left ) ;
}
printf ( " ; " ) ;
break ;
case P_LINK :
printf ( " %s; " , p - > value . link . name ) ;
break ;
2016-12-09 18:49:49 +00:00
}
putchar ( ' \n ' ) ;
}
2017-01-01 17:08:49 +00:00
static void rofi_theme_print_index ( ThemeWidget * widget )
2016-12-09 18:49:49 +00:00
{
GHashTableIter iter ;
2017-01-08 20:36:06 +00:00
gpointer key , value ;
if ( widget - > properties ) {
int index = 0 ;
GList * list = NULL ;
ThemeWidget * w = widget ;
while ( w ) {
if ( g_strcmp0 ( w - > name , " Root " ) = = 0 ) {
2017-01-01 00:06:38 +00:00
break ;
}
list = g_list_prepend ( list , w - > name ) ;
2017-01-08 20:36:06 +00:00
w = w - > parent ;
2017-01-01 00:06:38 +00:00
}
if ( g_list_length ( list ) > 0 ) {
index = 4 ;
for ( GList * iter = g_list_first ( list ) ; iter ! = NULL ; iter = g_list_next ( iter ) ) {
2017-01-08 20:36:06 +00:00
char * name = ( char * ) iter - > data ;
if ( iter - > prev = = NULL ) {
2017-01-01 00:06:38 +00:00
putchar ( ' # ' ) ;
}
2017-01-08 20:36:06 +00:00
fputs ( name , stdout ) ;
2017-01-08 16:50:42 +00:00
if ( iter - > next ) {
2017-01-08 20:36:06 +00:00
putchar ( ' . ' ) ;
2017-01-01 00:06:38 +00:00
}
}
2017-01-08 20:36:06 +00:00
printf ( " { \n " ) ;
}
else {
2017-01-08 16:50:42 +00:00
index = 4 ;
2017-01-08 20:36:06 +00:00
printf ( " * { \n " ) ;
2017-01-01 00:06:38 +00:00
}
2017-01-08 17:03:31 +00:00
size_t property_name_length = 0 ;
2017-01-08 20:36:06 +00:00
g_hash_table_iter_init ( & iter , widget - > properties ) ;
while ( g_hash_table_iter_next ( & iter , & key , & value ) ) {
Property * p = ( Property * ) value ;
property_name_length = MAX ( strlen ( p - > name ) , property_name_length ) ;
2017-01-08 17:03:31 +00:00
}
2017-01-08 20:36:06 +00:00
g_hash_table_iter_init ( & iter , widget - > properties ) ;
while ( g_hash_table_iter_next ( & iter , & key , & value ) ) {
Property * p = ( Property * ) value ;
2017-01-08 17:03:31 +00:00
rofi_theme_print_property_index ( property_name_length , index , p ) ;
2016-12-09 18:49:49 +00:00
}
2017-01-08 20:36:06 +00:00
printf ( " } \n " ) ;
2017-01-01 00:06:38 +00:00
g_list_free ( list ) ;
2016-12-09 18:49:49 +00:00
}
2017-01-08 20:36:06 +00:00
for ( unsigned int i = 0 ; i < widget - > num_widgets ; i + + ) {
2017-01-01 00:06:38 +00:00
rofi_theme_print_index ( widget - > widgets [ i ] ) ;
2016-12-09 18:49:49 +00:00
}
}
2017-01-01 17:08:49 +00:00
void rofi_theme_print ( ThemeWidget * widget )
2016-12-09 18:49:49 +00:00
{
2017-01-01 00:06:38 +00:00
rofi_theme_print_index ( widget ) ;
2016-12-09 18:49:49 +00:00
}
2017-01-01 17:08:49 +00:00
/**
* Main lex parser .
*/
2017-01-08 20:36:06 +00:00
int yyparse ( ) ;
2017-01-01 17:08:49 +00:00
/**
* Destroy the internal of lex parser .
*/
2017-01-08 20:36:06 +00:00
void yylex_destroy ( void ) ;
2017-01-01 17:08:49 +00:00
/**
* Global handle input file to flex parser .
*/
2016-12-09 18:49:49 +00:00
extern FILE * yyin ;
2017-01-01 17:08:49 +00:00
/**
* @ param yylloc The file location .
2017-01-09 21:40:11 +00:00
* @ param what What we are parsing , filename or string .
2017-01-01 17:08:49 +00:00
* @ param s Error message string .
*
* Error handler for the lex parser .
*/
2017-01-09 21:29:31 +00:00
void yyerror ( YYLTYPE * yylloc , const char * what , const char * s )
2017-01-08 20:36:06 +00:00
{
2017-01-09 21:40:11 +00:00
char * what_esc = g_markup_escape_text ( what , - 1 ) ;
GString * str = g_string_new ( " " ) ;
2017-03-13 07:54:55 +00:00
g_string_printf ( str , " <big><b>Error while parsing theme:</b></big> <i>%s</i> \n " , what_esc ) ;
2017-01-09 21:29:31 +00:00
g_free ( what_esc ) ;
2017-01-09 21:40:11 +00:00
char * esc = g_markup_escape_text ( s , - 1 ) ;
2017-03-13 15:42:17 +00:00
g_string_append_printf ( str , " \t Parser error: <span size= \" smaller \" style= \" italic \" >%s</span> \n " , esc ) ;
2017-01-09 21:40:11 +00:00
g_free ( esc ) ;
2017-03-13 15:42:17 +00:00
if ( yylloc - > filename ! = NULL ) {
2017-03-17 13:07:11 +00:00
g_string_append_printf ( str , " \t Location: line %d column %d to line %d column %d. \n " \
" \t File '%s' \n " , yylloc - > first_line , yylloc - > first_column , yylloc - > last_line , yylloc - > last_column , yylloc - > filename ) ;
}
else {
2017-03-13 15:42:17 +00:00
g_string_append_printf ( str , " \t Location: line %d column %d to line %d column %d \n " , yylloc - > first_line , yylloc - > first_column , yylloc - > last_line , yylloc - > last_column ) ;
}
2017-01-09 17:32:26 +00:00
rofi_add_error_message ( str ) ;
2016-12-09 21:16:31 +00:00
}
2016-12-16 08:28:13 +00:00
2017-01-08 20:36:06 +00:00
static gboolean rofi_theme_steal_property_int ( gpointer key , gpointer value , gpointer user_data )
2016-12-16 08:28:13 +00:00
{
2017-01-08 20:36:06 +00:00
GHashTable * table = ( GHashTable * ) user_data ;
g_hash_table_replace ( table , key , value ) ;
2016-12-16 08:28:13 +00:00
return TRUE ;
}
2017-01-01 17:08:49 +00:00
void rofi_theme_widget_add_properties ( ThemeWidget * widget , GHashTable * table )
2016-12-16 08:28:13 +00:00
{
if ( table = = NULL ) {
return ;
}
2017-01-08 20:36:06 +00:00
if ( widget - > properties = = NULL ) {
2016-12-16 08:28:13 +00:00
widget - > properties = table ;
return ;
}
g_hash_table_foreach_steal ( table , rofi_theme_steal_property_int , widget - > properties ) ;
g_hash_table_destroy ( table ) ;
}
2016-12-09 21:16:31 +00:00
/**
* Public API
*/
2017-03-14 16:02:03 +00:00
static inline ThemeWidget * rofi_theme_find_single ( ThemeWidget * widget , const char * name )
2016-12-15 08:46:42 +00:00
{
2017-01-08 20:36:06 +00:00
for ( unsigned int j = 0 ; j < widget - > num_widgets ; j + + ) {
if ( g_strcmp0 ( widget - > widgets [ j ] - > name , name ) = = 0 ) {
2016-12-15 08:46:42 +00:00
return widget - > widgets [ j ] ;
}
}
return widget ;
}
2016-12-09 18:49:49 +00:00
2017-01-08 20:36:06 +00:00
static ThemeWidget * rofi_theme_find ( ThemeWidget * widget , const char * name , const gboolean exact )
2016-12-09 21:16:31 +00:00
{
2017-01-08 20:36:06 +00:00
if ( widget = = NULL | | name = = NULL ) {
2016-12-12 08:11:57 +00:00
return widget ;
}
2017-03-17 13:07:11 +00:00
char * tname = g_strdup ( name ) ;
2017-03-06 08:56:02 +00:00
char * saveptr = NULL ;
2017-03-17 13:07:11 +00:00
int found = TRUE ;
for ( const char * iter = strtok_r ( tname , " . " , & saveptr ) ; iter ! = NULL ; iter = strtok_r ( NULL , " . " , & saveptr ) ) {
2016-12-09 21:16:31 +00:00
found = FALSE ;
2017-03-06 08:56:02 +00:00
ThemeWidget * f = rofi_theme_find_single ( widget , iter ) ;
2017-01-08 20:36:06 +00:00
if ( f ! = widget ) {
2016-12-15 08:46:42 +00:00
widget = f ;
2017-01-08 20:36:06 +00:00
found = TRUE ;
2016-12-09 21:16:31 +00:00
}
2016-12-16 08:28:13 +00:00
}
2017-03-06 08:56:02 +00:00
g_free ( tname ) ;
2017-01-08 20:36:06 +00:00
if ( ! exact | | found ) {
2016-12-20 08:17:19 +00:00
return widget ;
2017-01-08 20:36:06 +00:00
}
else {
2016-12-20 08:17:19 +00:00
return NULL ;
}
2016-12-09 21:16:31 +00:00
}
2017-01-05 17:22:34 +00:00
static void rofi_theme_resolve_link_property ( Property * p , int depth )
{
// Set name, remove '@' prefix.
2017-01-08 20:36:06 +00:00
const char * name = p - > value . link . name + 1 ;
if ( depth > 20 ) {
g_log ( LOG_DOMAIN , G_LOG_LEVEL_WARNING , " Found more then 20 redirects for property. Stopping. " ) ;
2017-01-05 17:22:34 +00:00
p - > value . link . ref = p ;
return ;
}
2017-01-08 20:36:06 +00:00
if ( g_hash_table_contains ( rofi_theme - > properties , name ) ) {
2017-01-05 17:22:34 +00:00
Property * pr = g_hash_table_lookup ( rofi_theme - > properties , name ) ;
if ( pr - > type = = P_LINK ) {
if ( pr - > value . link . ref = = NULL ) {
2017-01-08 20:36:06 +00:00
rofi_theme_resolve_link_property ( pr , depth + 1 ) ;
2017-01-05 17:22:34 +00:00
}
2017-01-08 20:36:06 +00:00
if ( pr - > value . link . ref ! = pr ) {
2017-01-05 17:22:34 +00:00
p - > value . link . ref = pr - > value . link . ref ;
return ;
}
2017-01-08 20:36:06 +00:00
}
else {
2017-01-05 17:22:34 +00:00
p - > value . link . ref = pr ;
return ;
}
}
// No found, set ref to self.
p - > value . link . ref = p ;
}
2017-03-10 22:39:29 +00:00
Property * rofi_theme_find_property ( ThemeWidget * widget , PropertyType type , const char * property , gboolean exact )
2016-12-09 21:16:31 +00:00
{
while ( widget ) {
2017-01-08 20:36:06 +00:00
if ( widget - > properties & & g_hash_table_contains ( widget - > properties , property ) ) {
Property * p = g_hash_table_lookup ( widget - > properties , property ) ;
2017-01-05 17:22:34 +00:00
if ( p - > type = = P_LINK ) {
if ( p - > value . link . ref = = NULL ) {
// Resolve link.
rofi_theme_resolve_link_property ( p , 0 ) ;
}
2017-01-08 20:36:06 +00:00
if ( p - > value . link . ref - > type = = type ) {
2017-01-05 17:22:34 +00:00
return p - > value . link . ref ;
}
}
2017-01-08 20:36:06 +00:00
if ( p - > type = = type ) {
2016-12-09 21:16:31 +00:00
return p ;
}
2017-01-04 14:18:12 +00:00
// Padding and integer can be converted.
2017-01-08 20:36:06 +00:00
if ( p - > type = = P_INTEGER & & type = = P_PADDING ) {
2017-01-04 14:18:12 +00:00
return p ;
}
2016-12-16 08:28:13 +00:00
}
2017-01-06 15:41:23 +00:00
if ( exact ) {
return NULL ;
}
2016-12-09 21:16:31 +00:00
widget = widget - > parent ;
}
return NULL ;
}
2017-03-10 22:39:29 +00:00
ThemeWidget * rofi_theme_find_widget ( const char * name , const char * state , gboolean exact )
2016-12-09 21:16:31 +00:00
{
2016-12-20 08:17:19 +00:00
// First find exact match based on name.
2017-01-06 15:41:23 +00:00
ThemeWidget * widget = rofi_theme_find ( rofi_theme , name , exact ) ;
widget = rofi_theme_find ( widget , state , exact ) ;
2016-12-20 08:17:19 +00:00
return widget ;
}
2017-01-06 18:04:25 +00:00
int rofi_theme_get_position ( const widget * widget , const char * property , int def )
{
ThemeWidget * wid = rofi_theme_find_widget ( widget - > name , widget - > state , FALSE ) ;
2017-01-08 20:36:06 +00:00
Property * p = rofi_theme_find_property ( wid , P_POSITION , property , FALSE ) ;
if ( p ) {
2017-01-06 18:04:25 +00:00
return p - > value . i ;
}
2017-01-08 20:36:06 +00:00
g_log ( LOG_DOMAIN , G_LOG_LEVEL_DEBUG , " Theme entry: #%s %s property %s unset. " , widget - > name , widget - > state ? widget - > state : " " , property ) ;
2017-01-06 18:04:25 +00:00
return def ;
}
2017-01-04 21:27:27 +00:00
int rofi_theme_get_integer ( const widget * widget , const char * property , int def )
2016-12-20 08:17:19 +00:00
{
2017-01-06 15:41:23 +00:00
ThemeWidget * wid = rofi_theme_find_widget ( widget - > name , widget - > state , FALSE ) ;
2017-01-08 20:36:06 +00:00
Property * p = rofi_theme_find_property ( wid , P_INTEGER , property , FALSE ) ;
if ( p ) {
2016-12-09 21:16:31 +00:00
return p - > value . i ;
}
2017-01-08 20:36:06 +00:00
g_log ( LOG_DOMAIN , G_LOG_LEVEL_DEBUG , " Theme entry: #%s %s property %s unset. " , widget - > name , widget - > state ? widget - > state : " " , property ) ;
2016-12-09 21:16:31 +00:00
return def ;
}
2017-01-06 15:41:23 +00:00
int rofi_theme_get_integer_exact ( const widget * widget , const char * property , int def )
{
ThemeWidget * wid = rofi_theme_find_widget ( widget - > name , widget - > state , TRUE ) ;
2017-01-08 20:36:06 +00:00
Property * p = rofi_theme_find_property ( wid , P_INTEGER , property , TRUE ) ;
if ( p ) {
2017-01-06 15:41:23 +00:00
return p - > value . i ;
}
2017-01-08 20:36:06 +00:00
g_log ( LOG_DOMAIN , G_LOG_LEVEL_DEBUG , " Theme entry: #%s %s property %s unset. " , widget - > name , widget - > state ? widget - > state : " " , property ) ;
2017-01-06 15:41:23 +00:00
return def ;
}
2017-01-04 21:27:27 +00:00
Distance rofi_theme_get_distance ( const widget * widget , const char * property , int def )
2016-12-31 22:27:17 +00:00
{
2017-01-06 15:41:23 +00:00
ThemeWidget * wid = rofi_theme_find_widget ( widget - > name , widget - > state , FALSE ) ;
2017-01-08 20:36:06 +00:00
Property * p = rofi_theme_find_property ( wid , P_PADDING , property , FALSE ) ;
if ( p ) {
if ( p - > type = = P_INTEGER ) {
return ( Distance ) { p - > value . i , PW_PX , SOLID } ;
}
else {
2017-01-04 21:27:27 +00:00
return p - > value . padding . left ;
}
2016-12-31 22:30:57 +00:00
}
2017-01-08 20:36:06 +00:00
g_log ( LOG_DOMAIN , G_LOG_LEVEL_DEBUG , " Theme entry: #%s %s property %s unset. " , widget - > name , widget - > state ? widget - > state : " " , property ) ;
return ( Distance ) { def , PW_PX , SOLID } ;
2016-12-31 22:27:17 +00:00
}
2016-12-09 21:16:31 +00:00
2017-01-04 21:27:27 +00:00
int rofi_theme_get_boolean ( const widget * widget , const char * property , int def )
2016-12-09 21:16:31 +00:00
{
2017-01-06 15:41:23 +00:00
ThemeWidget * wid = rofi_theme_find_widget ( widget - > name , widget - > state , FALSE ) ;
2017-01-08 20:36:06 +00:00
Property * p = rofi_theme_find_property ( wid , P_BOOLEAN , property , FALSE ) ;
if ( p ) {
2016-12-09 21:16:31 +00:00
return p - > value . b ;
}
2017-01-08 20:36:06 +00:00
g_log ( LOG_DOMAIN , G_LOG_LEVEL_DEBUG , " Theme entry: #%s %s property %s unset. " , widget - > name , widget - > state ? widget - > state : " " , property ) ;
2016-12-09 21:16:31 +00:00
return def ;
}
2017-01-04 21:27:27 +00:00
char * rofi_theme_get_string ( const widget * widget , const char * property , char * def )
2016-12-09 21:16:31 +00:00
{
2017-01-06 15:41:23 +00:00
ThemeWidget * wid = rofi_theme_find_widget ( widget - > name , widget - > state , FALSE ) ;
2017-01-08 20:36:06 +00:00
Property * p = rofi_theme_find_property ( wid , P_STRING , property , FALSE ) ;
if ( p ) {
2016-12-09 21:16:31 +00:00
return p - > value . s ;
}
2017-01-08 20:36:06 +00:00
g_log ( LOG_DOMAIN , G_LOG_LEVEL_DEBUG , " Theme entry: #%s %s property %s unset. " , widget - > name , widget - > state ? widget - > state : " " , property ) ;
2016-12-09 21:16:31 +00:00
return def ;
}
2017-01-04 21:27:27 +00:00
double rofi_theme_get_double ( const widget * widget , const char * property , double def )
2016-12-09 21:16:31 +00:00
{
2017-01-06 15:41:23 +00:00
ThemeWidget * wid = rofi_theme_find_widget ( widget - > name , widget - > state , FALSE ) ;
2017-01-08 20:36:06 +00:00
Property * p = rofi_theme_find_property ( wid , P_DOUBLE , property , FALSE ) ;
if ( p ) {
2016-12-09 21:16:31 +00:00
return p - > value . b ;
}
2017-01-08 20:36:06 +00:00
g_log ( LOG_DOMAIN , G_LOG_LEVEL_DEBUG , " Theme entry: #%s %s property %s unset. " , widget - > name , widget - > state ? widget - > state : " " , property ) ;
2016-12-09 21:16:31 +00:00
return def ;
2016-12-09 18:49:49 +00:00
}
2017-01-08 20:36:06 +00:00
void rofi_theme_get_color ( const widget * widget , const char * property , cairo_t * d )
2016-12-11 11:19:46 +00:00
{
2017-01-06 15:41:23 +00:00
ThemeWidget * wid = rofi_theme_find_widget ( widget - > name , widget - > state , FALSE ) ;
2017-01-08 20:36:06 +00:00
Property * p = rofi_theme_find_property ( wid , P_COLOR , property , FALSE ) ;
if ( p ) {
2016-12-11 11:19:46 +00:00
cairo_set_source_rgba ( d ,
2017-01-08 20:36:06 +00:00
p - > value . color . red ,
p - > value . color . green ,
p - > value . color . blue ,
p - > value . color . alpha
) ;
}
else {
g_log ( LOG_DOMAIN , G_LOG_LEVEL_DEBUG , " Theme entry: #%s %s property %s unset. " , widget - > name , widget - > state ? widget - > state : " " , property ) ;
2016-12-11 11:19:46 +00:00
}
}
2017-01-04 21:27:27 +00:00
Padding rofi_theme_get_padding ( const widget * widget , const char * property , Padding pad )
2016-12-27 21:19:15 +00:00
{
2017-01-06 15:41:23 +00:00
ThemeWidget * wid = rofi_theme_find_widget ( widget - > name , widget - > state , FALSE ) ;
2017-01-08 20:36:06 +00:00
Property * p = rofi_theme_find_property ( wid , P_PADDING , property , FALSE ) ;
if ( p ) {
if ( p - > type = = P_PADDING ) {
2017-01-04 21:27:27 +00:00
pad = p - > value . padding ;
2017-01-08 20:36:06 +00:00
}
else {
Distance d = ( Distance ) { p - > value . i , PW_PX , SOLID } ;
return ( Padding ) { d , d , d , d } ;
2016-12-31 22:34:48 +00:00
}
2016-12-27 21:19:15 +00:00
}
2017-01-08 20:36:06 +00:00
g_log ( LOG_DOMAIN , G_LOG_LEVEL_DEBUG , " Theme entry: #%s %s property %s unset. " , widget - > name , widget - > state ? widget - > state : " " , property ) ;
2016-12-27 21:19:15 +00:00
return pad ;
}
2017-01-08 23:09:02 +00:00
ThemeHighlight rofi_theme_get_highlight ( widget * widget , const char * property , ThemeHighlight th )
{
ThemeWidget * wid = rofi_theme_find_widget ( widget - > name , widget - > state , FALSE ) ;
Property * p = rofi_theme_find_property ( wid , P_HIGHLIGHT , property , FALSE ) ;
if ( p ) {
return p - > value . highlight ;
}
g_log ( LOG_DOMAIN , G_LOG_LEVEL_DEBUG , " Theme entry: #%s %s property %s unset. " , widget - > name , widget - > state ? widget - > state : " " , property ) ;
return th ;
}
2017-01-03 18:23:09 +00:00
int distance_get_pixel ( Distance d , Orientation ori )
2016-12-31 22:27:17 +00:00
{
2017-01-08 20:36:06 +00:00
if ( d . type = = PW_EM ) {
return d . distance * textbox_get_estimated_char_height ( ) ;
}
else if ( d . type = = PW_PERCENT ) {
if ( ori = = ORIENTATION_VERTICAL ) {
2017-01-03 18:23:09 +00:00
int height = 0 ;
rofi_view_get_current_monitor ( NULL , & height ) ;
2017-01-08 20:36:06 +00:00
return ( d . distance * height ) / ( 100.0 ) ;
}
else {
2017-01-03 18:23:09 +00:00
int width = 0 ;
rofi_view_get_current_monitor ( & width , NULL ) ;
2017-01-08 20:36:06 +00:00
return ( d . distance * width ) / ( 100.0 ) ;
2017-01-03 18:23:09 +00:00
}
2016-12-31 22:27:17 +00:00
}
return d . distance ;
}
2017-01-01 00:06:38 +00:00
2017-01-04 21:27:27 +00:00
void distance_get_linestyle ( Distance d , cairo_t * draw )
{
2017-01-08 20:36:06 +00:00
if ( d . style = = DASH ) {
2017-01-04 21:27:27 +00:00
const double dashes [ 1 ] = { 4 } ;
cairo_set_dash ( draw , dashes , 1 , 0.0 ) ;
2017-01-08 20:36:06 +00:00
}
else {
cairo_set_dash ( draw , NULL , 0 , 0.0 ) ;
2017-01-04 21:27:27 +00:00
}
}
2017-03-11 16:06:06 +00:00
gboolean rofi_theme_is_empty ( void )
{
if ( rofi_theme = = NULL ) {
return TRUE ;
}
2017-03-17 13:07:11 +00:00
if ( rofi_theme - > properties = = NULL & & rofi_theme - > num_widgets = = 0 ) {
2017-03-11 16:06:06 +00:00
return TRUE ;
}
return FALSE ;
}
2017-01-01 15:32:01 +00:00
# ifdef THEME_CONVERTER
2017-01-01 00:06:38 +00:00
static Property * rofi_theme_convert_get_color ( const char * color , const char * name )
{
2017-01-08 20:36:06 +00:00
Color c = color_get ( color ) ;
2017-01-01 00:06:38 +00:00
Property * p = rofi_theme_property_create ( P_COLOR ) ;
2017-01-08 20:36:06 +00:00
p - > name = g_strdup ( name ) ;
2017-01-01 00:06:38 +00:00
p - > value . color . alpha = c . alpha ;
p - > value . color . red = c . red ;
p - > value . color . green = c . green ;
p - > value . color . blue = c . blue ;
return p ;
}
2017-01-04 14:05:39 +00:00
static void rofi_theme_convert_create_property_ht ( ThemeWidget * widget )
2017-01-01 00:06:38 +00:00
{
2017-01-04 14:05:39 +00:00
if ( widget - > properties = = NULL ) {
2017-01-08 20:36:06 +00:00
widget - > properties = g_hash_table_new_full ( g_str_hash , g_str_equal , NULL , ( GDestroyNotify ) rofi_theme_property_free ) ;
2017-01-04 14:05:39 +00:00
}
2017-01-01 00:06:38 +00:00
}
void rofi_theme_convert_old_theme ( void )
{
2017-01-08 20:36:06 +00:00
if ( rofi_theme ! = NULL ) {
2017-03-11 16:06:06 +00:00
rofi_theme_free ( rofi_theme ) ;
2017-01-01 00:06:38 +00:00
}
2017-03-04 19:09:19 +00:00
rofi_theme = ( ThemeWidget * ) g_slice_new0 ( ThemeWidget ) ;
2017-01-01 00:06:38 +00:00
rofi_theme - > name = g_strdup ( " Root " ) ;
2017-01-04 14:05:39 +00:00
rofi_theme_convert_create_property_ht ( rofi_theme ) ;
2017-01-08 20:36:06 +00:00
ThemeWidget * window_widget = rofi_theme_find_or_create_name ( rofi_theme , " window " ) ;
2017-01-04 21:27:27 +00:00
rofi_theme_convert_create_property_ht ( window_widget ) ;
ThemeWidget * mainbox_widget = rofi_theme_find_or_create_name ( window_widget , " mainbox " ) ;
rofi_theme_convert_create_property_ht ( mainbox_widget ) ;
2017-01-08 20:36:06 +00:00
ThemeWidget * message = rofi_theme_find_or_create_name ( mainbox_widget , " message " ) ;
2017-01-06 15:53:21 +00:00
ThemeWidget * message_box = rofi_theme_find_or_create_name ( message , " box " ) ;
rofi_theme_convert_create_property_ht ( message_box ) ;
2017-01-04 21:27:27 +00:00
ThemeWidget * listview_widget = rofi_theme_find_or_create_name ( mainbox_widget , " listview " ) ;
rofi_theme_convert_create_property_ht ( listview_widget ) ;
2017-01-08 20:36:06 +00:00
ThemeWidget * sidebar_widget = rofi_theme_find_or_create_name ( mainbox_widget , " sidebar " ) ;
2017-01-06 15:53:21 +00:00
ThemeWidget * sidebarbox_widget = rofi_theme_find_or_create_name ( sidebar_widget , " box " ) ;
rofi_theme_convert_create_property_ht ( sidebarbox_widget ) ;
2017-01-04 21:27:27 +00:00
{
Property * p = rofi_theme_property_create ( P_INTEGER ) ;
2017-01-08 20:36:06 +00:00
p - > name = g_strdup ( " border " ) ;
2017-01-04 21:27:27 +00:00
p - > value . i = 0 ;
2017-01-08 20:36:06 +00:00
g_hash_table_replace ( mainbox_widget - > properties , p - > name , p ) ;
2017-01-04 21:27:27 +00:00
2017-01-08 20:36:06 +00:00
p = rofi_theme_property_create ( P_INTEGER ) ;
p - > name = g_strdup ( " padding " ) ;
2017-01-04 21:27:27 +00:00
p - > value . i = config . padding ;
2017-01-08 20:36:06 +00:00
g_hash_table_replace ( window_widget - > properties , p - > name , p ) ;
2017-01-04 21:27:27 +00:00
2017-01-08 20:36:06 +00:00
p = rofi_theme_property_create ( P_INTEGER ) ;
p - > name = g_strdup ( " padding " ) ;
2017-01-04 21:27:27 +00:00
p - > value . i = 0 ;
2017-01-08 20:36:06 +00:00
g_hash_table_replace ( mainbox_widget - > properties , p - > name , p ) ;
2017-01-04 21:27:27 +00:00
// Spacing
2017-01-08 20:36:06 +00:00
p = rofi_theme_property_create ( P_INTEGER ) ;
p - > name = g_strdup ( " spacing " ) ;
2017-01-04 21:27:27 +00:00
p - > value . i = config . line_margin ;
g_hash_table_replace ( rofi_theme - > properties , p - > name , p ) ;
}
2017-01-01 14:39:02 +00:00
{
2017-01-04 14:18:12 +00:00
// Background
Property * p = rofi_theme_property_create ( P_COLOR ) ;
2017-01-08 20:36:06 +00:00
p - > name = g_strdup ( " background " ) ;
2017-01-04 14:18:12 +00:00
p - > value . color . alpha = 0 ;
2017-01-08 20:36:06 +00:00
p - > value . color . red = 0 ;
p - > value . color . green = 0 ;
p - > value . color . blue = 0 ;
2017-01-04 14:18:12 +00:00
g_hash_table_replace ( rofi_theme - > properties , p - > name , p ) ;
2017-01-04 14:05:39 +00:00
2017-01-04 21:27:27 +00:00
ThemeWidget * inputbar_widget = rofi_theme_find_or_create_name ( mainbox_widget , " inputbar " ) ;
2017-01-04 14:05:39 +00:00
rofi_theme_convert_create_property_ht ( inputbar_widget ) ;
2017-01-08 20:36:06 +00:00
p = rofi_theme_property_create ( P_INTEGER ) ;
p - > name = g_strdup ( " spacing " ) ;
2017-01-04 14:18:12 +00:00
p - > value . i = 0 ;
2017-01-04 14:05:39 +00:00
g_hash_table_replace ( inputbar_widget - > properties , p - > name , p ) ;
2017-01-04 21:27:27 +00:00
2017-01-08 20:36:06 +00:00
LineStyle style = ( g_strcmp0 ( config . separator_style , " dash " ) = = 0 ) ? DASH : SOLID ;
int place_end = ( config . location = = WL_SOUTH_EAST | | config . location = = WL_SOUTH | | config . location = = WL_SOUTH_WEST ) ;
p = rofi_theme_property_create ( P_PADDING ) ;
p - > name = g_strdup ( " border " ) ;
Distance d = ( Distance ) { config . menu_bw , PW_PX , style } ;
if ( place_end ) {
p - > value . padding . bottom = d ;
}
else {
p - > value . padding . top = d ;
2017-01-04 21:27:27 +00:00
}
g_hash_table_replace ( listview_widget - > properties , p - > name , p ) ;
2017-01-08 20:36:06 +00:00
p = rofi_theme_property_create ( P_PADDING ) ;
p - > name = g_strdup ( " border " ) ;
d = ( Distance ) { config . menu_bw , PW_PX , style } ;
if ( place_end ) {
p - > value . padding . bottom = d ;
}
else {
p - > value . padding . top = d ;
2017-01-04 21:27:27 +00:00
}
2017-01-06 15:53:21 +00:00
g_hash_table_replace ( message_box - > properties , p - > name , p ) ;
/**
* Sidebar top
*/
2017-01-08 20:36:06 +00:00
p = rofi_theme_property_create ( P_PADDING ) ;
p - > name = g_strdup ( " border " ) ;
d = ( Distance ) { config . menu_bw , PW_PX , style } ;
p - > value . padding . top = d ;
2017-01-06 15:53:21 +00:00
g_hash_table_replace ( sidebarbox_widget - > properties , p - > name , p ) ;
2017-01-08 20:36:06 +00:00
p = rofi_theme_property_create ( P_PADDING ) ;
p - > name = g_strdup ( " padding " ) ;
d = ( Distance ) { config . line_margin , PW_PX , SOLID } ;
if ( place_end ) {
p - > value . padding . bottom = d ;
}
else {
p - > value . padding . top = d ;
2017-01-04 21:27:27 +00:00
}
g_hash_table_replace ( listview_widget - > properties , p - > name , p ) ;
2017-01-08 20:36:06 +00:00
p = rofi_theme_property_create ( P_PADDING ) ;
p - > name = g_strdup ( " padding " ) ;
d = ( Distance ) { config . line_margin , PW_PX , SOLID } ;
if ( place_end ) {
p - > value . padding . bottom = d ;
}
else {
p - > value . padding . top = d ;
2017-01-04 21:27:27 +00:00
}
2017-01-06 15:53:21 +00:00
g_hash_table_replace ( message_box - > properties , p - > name , p ) ;
2017-01-01 14:39:02 +00:00
}
{
Property * p = rofi_theme_property_create ( P_INTEGER ) ;
2017-01-08 20:36:06 +00:00
p - > name = g_strdup ( " columns " ) ;
2017-01-04 14:05:39 +00:00
p - > value . i = config . menu_columns ;
2017-01-03 13:25:24 +00:00
g_hash_table_replace ( listview_widget - > properties , p - > name , p ) ;
2017-01-08 20:36:06 +00:00
p = rofi_theme_property_create ( P_INTEGER ) ;
p - > name = g_strdup ( " fixed-height " ) ;
p - > value . i = ! ( config . fixed_num_lines ) ;
2017-01-03 13:25:24 +00:00
g_hash_table_replace ( listview_widget - > properties , p - > name , p ) ;
2017-01-01 14:39:02 +00:00
}
{
// Border width.
2017-01-04 14:05:39 +00:00
rofi_theme_convert_create_property_ht ( window_widget ) ;
2017-01-01 14:39:02 +00:00
// Padding
2017-01-03 14:57:40 +00:00
Property * p = rofi_theme_property_create ( P_INTEGER ) ;
2017-01-08 20:36:06 +00:00
p - > name = g_strdup ( " padding " ) ;
2017-01-01 14:39:02 +00:00
p - > value . i = config . padding ;
g_hash_table_replace ( window_widget - > properties , p - > name , p ) ;
2017-01-03 14:57:40 +00:00
2017-01-08 20:36:06 +00:00
p = rofi_theme_property_create ( P_INTEGER ) ;
p - > name = g_strdup ( " border " ) ;
2017-01-03 14:57:40 +00:00
p - > value . i = config . menu_bw ;
g_hash_table_replace ( window_widget - > properties , p - > name , p ) ;
2017-01-01 14:39:02 +00:00
}
2017-01-01 00:06:38 +00:00
{
gchar * * vals = g_strsplit ( config . color_window , " , " , 3 ) ;
2017-01-08 20:36:06 +00:00
if ( vals ! = NULL ) {
2017-01-01 00:06:38 +00:00
if ( vals [ 0 ] ! = NULL ) {
Property * p = rofi_theme_convert_get_color ( vals [ 0 ] , " background " ) ;
2017-01-04 21:27:27 +00:00
g_hash_table_replace ( window_widget - > properties , p - > name , p ) ;
2017-01-01 00:06:38 +00:00
if ( vals [ 1 ] ! = NULL ) {
p = rofi_theme_convert_get_color ( vals [ 1 ] , " foreground " ) ;
2017-01-04 21:27:27 +00:00
g_hash_table_replace ( window_widget - > properties , p - > name , p ) ;
2017-01-01 00:06:38 +00:00
2017-01-04 21:27:27 +00:00
ThemeWidget * inputbar = rofi_theme_find_or_create_name ( mainbox_widget , " inputbar " ) ;
2017-01-08 20:36:06 +00:00
ThemeWidget * widget = rofi_theme_find_or_create_name ( inputbar , " box " ) ;
2017-01-04 14:05:39 +00:00
rofi_theme_convert_create_property_ht ( widget ) ;
2017-01-08 20:36:06 +00:00
if ( vals [ 2 ] ! = NULL ) {
p = rofi_theme_convert_get_color ( vals [ 2 ] , " foreground " ) ;
g_hash_table_replace ( window_widget - > properties , p - > name , p ) ;
}
else {
p = rofi_theme_convert_get_color ( vals [ 1 ] , " foreground " ) ;
g_hash_table_replace ( window_widget - > properties , p - > name , p ) ;
}
2017-01-01 00:06:38 +00:00
}
}
}
g_strfreev ( vals ) ;
{
2017-01-08 20:36:06 +00:00
ThemeWidget * widget = rofi_theme_find_or_create_name ( listview_widget , " element " ) ;
2017-01-04 21:27:27 +00:00
ThemeWidget * scrollbar = rofi_theme_find_or_create_name ( listview_widget , " scrollbar " ) ;
2017-01-08 20:36:06 +00:00
ThemeWidget * wnormal = rofi_theme_find_or_create_name ( widget , " normal " ) ;
ThemeWidget * wselected = rofi_theme_find_or_create_name ( widget , " selected " ) ;
2017-01-04 14:05:39 +00:00
ThemeWidget * walternate = rofi_theme_find_or_create_name ( widget , " alternate " ) ;
2017-01-01 00:06:38 +00:00
2017-01-04 21:27:27 +00:00
rofi_theme_convert_create_property_ht ( widget ) ;
2017-03-18 15:06:41 +00:00
Property * p = rofi_theme_property_create ( P_INTEGER ) ;
2017-01-08 20:36:06 +00:00
p - > name = g_strdup ( " border " ) ;
2017-01-04 21:27:27 +00:00
p - > value . i = 0 ;
2017-01-08 20:36:06 +00:00
g_hash_table_replace ( widget - > properties , p - > name , p ) ;
2017-01-04 21:27:27 +00:00
rofi_theme_convert_create_property_ht ( scrollbar ) ;
2017-01-08 20:36:06 +00:00
p = rofi_theme_property_create ( P_INTEGER ) ;
p - > name = g_strdup ( " border " ) ;
2017-01-04 21:27:27 +00:00
p - > value . i = 0 ;
2017-01-08 20:36:06 +00:00
g_hash_table_replace ( scrollbar - > properties , p - > name , p ) ;
p = rofi_theme_property_create ( P_INTEGER ) ;
p - > name = g_strdup ( " padding " ) ;
2017-01-04 21:27:27 +00:00
p - > value . i = 0 ;
2017-01-08 20:36:06 +00:00
g_hash_table_replace ( scrollbar - > properties , p - > name , p ) ;
2017-01-01 00:06:38 +00:00
gchar * * vals = g_strsplit ( config . color_normal , " , " , 5 ) ;
2017-01-08 20:36:06 +00:00
if ( g_strv_length ( vals ) = = 5 ) {
2017-01-04 14:05:39 +00:00
ThemeWidget * wnn = rofi_theme_find_or_create_name ( wnormal , " normal " ) ;
rofi_theme_convert_create_property_ht ( wnn ) ;
2017-01-01 00:06:38 +00:00
p = rofi_theme_convert_get_color ( vals [ 0 ] , " background " ) ;
g_hash_table_replace ( wnn - > properties , p - > name , p ) ;
p = rofi_theme_convert_get_color ( vals [ 1 ] , " foreground " ) ;
g_hash_table_replace ( wnn - > properties , p - > name , p ) ;
2017-01-04 14:05:39 +00:00
ThemeWidget * wsl = rofi_theme_find_or_create_name ( wselected , " normal " ) ;
rofi_theme_convert_create_property_ht ( wsl ) ;
2017-01-01 00:06:38 +00:00
p = rofi_theme_convert_get_color ( vals [ 3 ] , " background " ) ;
g_hash_table_replace ( wsl - > properties , p - > name , p ) ;
p = rofi_theme_convert_get_color ( vals [ 4 ] , " foreground " ) ;
g_hash_table_replace ( wsl - > properties , p - > name , p ) ;
2017-01-04 14:05:39 +00:00
ThemeWidget * wal = rofi_theme_find_or_create_name ( walternate , " normal " ) ;
rofi_theme_convert_create_property_ht ( wal ) ;
2017-01-01 00:06:38 +00:00
p = rofi_theme_convert_get_color ( vals [ 2 ] , " background " ) ;
g_hash_table_replace ( wal - > properties , p - > name , p ) ;
p = rofi_theme_convert_get_color ( vals [ 1 ] , " foreground " ) ;
g_hash_table_replace ( wal - > properties , p - > name , p ) ;
2017-01-04 14:05:39 +00:00
2017-01-04 21:27:27 +00:00
ThemeWidget * inputbar = rofi_theme_find_or_create_name ( mainbox_widget , " inputbar " ) ;
2017-01-04 14:05:39 +00:00
wnn = rofi_theme_find_or_create_name ( inputbar , " normal " ) ;
rofi_theme_convert_create_property_ht ( wnn ) ;
p = rofi_theme_convert_get_color ( vals [ 0 ] , " background " ) ;
g_hash_table_replace ( wnn - > properties , p - > name , p ) ;
p = rofi_theme_convert_get_color ( vals [ 1 ] , " foreground " ) ;
g_hash_table_replace ( wnn - > properties , p - > name , p ) ;
wnn = rofi_theme_find_or_create_name ( message , " normal " ) ;
rofi_theme_convert_create_property_ht ( wnn ) ;
p = rofi_theme_convert_get_color ( vals [ 0 ] , " background " ) ;
g_hash_table_replace ( wnn - > properties , p - > name , p ) ;
p = rofi_theme_convert_get_color ( vals [ 1 ] , " foreground " ) ;
g_hash_table_replace ( wnn - > properties , p - > name , p ) ;
2017-01-01 00:06:38 +00:00
}
g_strfreev ( vals ) ;
vals = g_strsplit ( config . color_urgent , " , " , 5 ) ;
2017-01-08 20:36:06 +00:00
if ( g_strv_length ( vals ) = = 5 ) {
2017-01-04 14:05:39 +00:00
ThemeWidget * wnn = rofi_theme_find_or_create_name ( wnormal , " urgent " ) ;
rofi_theme_convert_create_property_ht ( wnn ) ;
2017-01-01 00:06:38 +00:00
p = rofi_theme_convert_get_color ( vals [ 0 ] , " background " ) ;
g_hash_table_replace ( wnn - > properties , p - > name , p ) ;
p = rofi_theme_convert_get_color ( vals [ 1 ] , " foreground " ) ;
g_hash_table_replace ( wnn - > properties , p - > name , p ) ;
2017-01-04 14:05:39 +00:00
ThemeWidget * wsl = rofi_theme_find_or_create_name ( wselected , " urgent " ) ;
rofi_theme_convert_create_property_ht ( wsl ) ;
2017-01-01 00:06:38 +00:00
p = rofi_theme_convert_get_color ( vals [ 3 ] , " background " ) ;
g_hash_table_replace ( wsl - > properties , p - > name , p ) ;
p = rofi_theme_convert_get_color ( vals [ 4 ] , " foreground " ) ;
g_hash_table_replace ( wsl - > properties , p - > name , p ) ;
2017-01-04 14:05:39 +00:00
ThemeWidget * wal = rofi_theme_find_or_create_name ( walternate , " urgent " ) ;
rofi_theme_convert_create_property_ht ( wal ) ;
2017-01-01 00:06:38 +00:00
p = rofi_theme_convert_get_color ( vals [ 2 ] , " background " ) ;
g_hash_table_replace ( wal - > properties , p - > name , p ) ;
p = rofi_theme_convert_get_color ( vals [ 1 ] , " foreground " ) ;
g_hash_table_replace ( wal - > properties , p - > name , p ) ;
}
g_strfreev ( vals ) ;
vals = g_strsplit ( config . color_active , " , " , 5 ) ;
2017-01-08 20:36:06 +00:00
if ( g_strv_length ( vals ) = = 5 ) {
2017-01-04 14:05:39 +00:00
ThemeWidget * wnn = rofi_theme_find_or_create_name ( wnormal , " active " ) ;
rofi_theme_convert_create_property_ht ( wnn ) ;
2017-01-01 00:06:38 +00:00
p = rofi_theme_convert_get_color ( vals [ 0 ] , " background " ) ;
g_hash_table_replace ( wnn - > properties , p - > name , p ) ;
p = rofi_theme_convert_get_color ( vals [ 1 ] , " foreground " ) ;
g_hash_table_replace ( wnn - > properties , p - > name , p ) ;
2017-01-04 14:05:39 +00:00
ThemeWidget * wsl = rofi_theme_find_or_create_name ( wselected , " active " ) ;
rofi_theme_convert_create_property_ht ( wsl ) ;
2017-01-01 00:06:38 +00:00
p = rofi_theme_convert_get_color ( vals [ 3 ] , " background " ) ;
g_hash_table_replace ( wsl - > properties , p - > name , p ) ;
p = rofi_theme_convert_get_color ( vals [ 4 ] , " foreground " ) ;
g_hash_table_replace ( wsl - > properties , p - > name , p ) ;
2017-01-04 14:05:39 +00:00
ThemeWidget * wal = rofi_theme_find_or_create_name ( walternate , " active " ) ;
rofi_theme_convert_create_property_ht ( wal ) ;
2017-01-01 00:06:38 +00:00
p = rofi_theme_convert_get_color ( vals [ 2 ] , " background " ) ;
g_hash_table_replace ( wal - > properties , p - > name , p ) ;
p = rofi_theme_convert_get_color ( vals [ 1 ] , " foreground " ) ;
g_hash_table_replace ( wal - > properties , p - > name , p ) ;
}
g_strfreev ( vals ) ;
}
}
}
2017-01-01 15:32:01 +00:00
# endif