mirror of
https://github.com/davatorium/rofi.git
synced 2024-11-25 13:55:34 -05:00
Remove class system from new theme format. Fix theme converter.
This commit is contained in:
parent
645fe24890
commit
85a0e1a57e
13 changed files with 127 additions and 141 deletions
|
@ -111,13 +111,13 @@ extern ThemeWidget *rofi_theme;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param base Handle to the current level in the theme.
|
* @param base Handle to the current level in the theme.
|
||||||
* @param class Name of the new element.
|
* @param name Name of the new element.
|
||||||
*
|
*
|
||||||
* Create a new element in the theme structure.
|
* Create a new element in the theme structure.
|
||||||
*
|
*
|
||||||
* @returns handle to the new entry.
|
* @returns handle to the new entry.
|
||||||
*/
|
*/
|
||||||
ThemeWidget *rofi_theme_find_or_create_class ( ThemeWidget *base, const char *class );
|
ThemeWidget *rofi_theme_find_or_create_name ( ThemeWidget *base, const char *class );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param widget The widget handle.
|
* @param widget The widget handle.
|
||||||
|
@ -169,7 +169,6 @@ void rofi_theme_widget_add_properties ( ThemeWidget *widget, GHashTable *table )
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param wclass The widget class
|
|
||||||
* @param name The name class
|
* @param name The name class
|
||||||
* @param state The widget current state
|
* @param state The widget current state
|
||||||
* @param property The property to query.
|
* @param property The property to query.
|
||||||
|
@ -179,10 +178,9 @@ void rofi_theme_widget_add_properties ( ThemeWidget *widget, GHashTable *table )
|
||||||
*
|
*
|
||||||
* @returns The distance value of this property for this widget.
|
* @returns The distance value of this property for this widget.
|
||||||
*/
|
*/
|
||||||
Distance rofi_theme_get_distance ( const char *wclass, const char *name, const char *state, const char *property, int def );
|
Distance rofi_theme_get_distance ( const char *name, const char *state, const char *property, int def );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param wclass The widget class
|
|
||||||
* @param name The name class
|
* @param name The name class
|
||||||
* @param state The widget current state
|
* @param state The widget current state
|
||||||
* @param property The property to query.
|
* @param property The property to query.
|
||||||
|
@ -192,10 +190,9 @@ Distance rofi_theme_get_distance ( const char *wclass, const char *name, const
|
||||||
*
|
*
|
||||||
* @returns The integer value of this property for this widget.
|
* @returns The integer value of this property for this widget.
|
||||||
*/
|
*/
|
||||||
int rofi_theme_get_integer ( const char *wclass, const char *name, const char *state, const char *property, int def );
|
int rofi_theme_get_integer ( const char *name, const char *state, const char *property, int def );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param wclass The widget class
|
|
||||||
* @param name The name class
|
* @param name The name class
|
||||||
* @param state The widget current state
|
* @param state The widget current state
|
||||||
* @param property The property to query.
|
* @param property The property to query.
|
||||||
|
@ -205,10 +202,9 @@ int rofi_theme_get_integer ( const char *wclass, const char *name, const char
|
||||||
*
|
*
|
||||||
* @returns The boolean value of this property for this widget.
|
* @returns The boolean value of this property for this widget.
|
||||||
*/
|
*/
|
||||||
int rofi_theme_get_boolean ( const char *wclass, const char *name, const char *state, const char *property, int def );
|
int rofi_theme_get_boolean ( const char *name, const char *state, const char *property, int def );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param wclass The widget class
|
|
||||||
* @param name The name class
|
* @param name The name class
|
||||||
* @param state The widget current state
|
* @param state The widget current state
|
||||||
* @param property The property to query.
|
* @param property The property to query.
|
||||||
|
@ -218,10 +214,9 @@ int rofi_theme_get_boolean ( const char *wclass, const char *name, const char
|
||||||
*
|
*
|
||||||
* @returns The string value of this property for this widget.
|
* @returns The string value of this property for this widget.
|
||||||
*/
|
*/
|
||||||
char *rofi_theme_get_string ( const char *wclass, const char *name, const char *state, const char *property, char *def );
|
char *rofi_theme_get_string ( const char *name, const char *state, const char *property, char *def );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param wclass The widget class
|
|
||||||
* @param name The name class
|
* @param name The name class
|
||||||
* @param state The widget current state
|
* @param state The widget current state
|
||||||
* @param property The property to query.
|
* @param property The property to query.
|
||||||
|
@ -231,10 +226,9 @@ char *rofi_theme_get_string ( const char *wclass, const char *name, const char
|
||||||
*
|
*
|
||||||
* @returns The double value of this property for this widget.
|
* @returns The double value of this property for this widget.
|
||||||
*/
|
*/
|
||||||
double rofi_theme_get_double ( const char *wclass, const char *name, const char *state, const char *property, double def );
|
double rofi_theme_get_double ( const char *name, const char *state, const char *property, double def );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param wclass The widget class
|
|
||||||
* @param name The name class
|
* @param name The name class
|
||||||
* @param state The widget current state
|
* @param state The widget current state
|
||||||
* @param property The property to query.
|
* @param property The property to query.
|
||||||
|
@ -243,10 +237,9 @@ double rofi_theme_get_double ( const char *wclass, const char *name, const char
|
||||||
* Obtain the color of the widget and applies this to the drawable d.
|
* Obtain the color of the widget and applies this to the drawable d.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void rofi_theme_get_color ( const char *wclass, const char *name, const char *state, const char *property, cairo_t *d);
|
void rofi_theme_get_color ( const char *name, const char *state, const char *property, cairo_t *d);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param wclass The widget class
|
|
||||||
* @param name The name class
|
* @param name The name class
|
||||||
* @param state The widget current state
|
* @param state The widget current state
|
||||||
* @param property The property to query.
|
* @param property The property to query.
|
||||||
|
@ -256,7 +249,7 @@ void rofi_theme_get_color ( const char *wclass, const char *name, const char *s
|
||||||
*
|
*
|
||||||
* @returns The padding of this property for this widget.
|
* @returns The padding of this property for this widget.
|
||||||
*/
|
*/
|
||||||
Padding rofi_theme_get_padding ( const char *wclass, const char *name, const char *state, const char *property, Padding pad );
|
Padding rofi_theme_get_padding ( const char *name, const char *state, const char *property, Padding pad );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param d The distance handle.
|
* @param d The distance handle.
|
||||||
|
|
|
@ -56,19 +56,17 @@ struct _widget
|
||||||
|
|
||||||
/** Name of widget (used for theming) */
|
/** Name of widget (used for theming) */
|
||||||
char *name;
|
char *name;
|
||||||
char *class_name;
|
|
||||||
const char *state;
|
const char *state;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param widget The widget to initialize.
|
* @param widget The widget to initialize.
|
||||||
* @param name The name of the widget.
|
* @param name The name of the widget.
|
||||||
* @param class_name The name of the class of the widget.
|
|
||||||
*
|
*
|
||||||
* Initializes the widget structure.
|
* Initializes the widget structure.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void widget_init ( widget *widget , const char *name, const char *class_name );
|
void widget_init ( widget *widget , const char *name );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param widget The widget handle.
|
* @param widget The widget handle.
|
||||||
|
|
|
@ -90,7 +90,6 @@ if ( queue == NULL ){
|
||||||
return BCLOSE;
|
return BCLOSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
<INITIAL>"@" { g_queue_push_head ( queue, GINT_TO_POINTER (YY_START) ); BEGIN(NAMESTR);return CLASS_PREFIX;}
|
|
||||||
<INITIAL>"#" { g_queue_push_head ( queue, GINT_TO_POINTER (YY_START) ); BEGIN(NAMESTR);return NAME_PREFIX;}
|
<INITIAL>"#" { g_queue_push_head ( queue, GINT_TO_POINTER (YY_START) ); BEGIN(NAMESTR);return NAME_PREFIX;}
|
||||||
<INITIAL,NAMESTR>"." { return NSEP; }
|
<INITIAL,NAMESTR>"." { return NSEP; }
|
||||||
<INITIAL,ENTRY>{WORD} { yylval->sval = g_strdup(yytext); return N_STRING;}
|
<INITIAL,ENTRY>{WORD} { yylval->sval = g_strdup(yytext); return N_STRING;}
|
||||||
|
|
|
@ -42,7 +42,6 @@ int yylex (YYSTYPE *, YYLTYPE *);
|
||||||
%token <bval> T_BOOLEAN
|
%token <bval> T_BOOLEAN
|
||||||
%token <colorval> T_COLOR
|
%token <colorval> T_COLOR
|
||||||
%token <distance> T_PIXEL
|
%token <distance> T_PIXEL
|
||||||
%token <sval> CLASS_NAME
|
|
||||||
%token <sval> FIRST_NAME
|
%token <sval> FIRST_NAME
|
||||||
|
|
||||||
%token BOPEN "bracket open";
|
%token BOPEN "bracket open";
|
||||||
|
@ -50,13 +49,11 @@ int yylex (YYSTYPE *, YYLTYPE *);
|
||||||
%token PSEP "property separator";
|
%token PSEP "property separator";
|
||||||
%token PCLOSE "property close";
|
%token PCLOSE "property close";
|
||||||
%token NSEP "Name separator";
|
%token NSEP "Name separator";
|
||||||
%token CLASS_PREFIX "Class prefix";
|
|
||||||
%token NAME_PREFIX "Name prefix";
|
%token NAME_PREFIX "Name prefix";
|
||||||
%token WHITESPACE "White space";
|
%token WHITESPACE "White space";
|
||||||
|
|
||||||
%type <sval> entry
|
%type <sval> entry
|
||||||
%type <sval> pvalue
|
%type <sval> pvalue
|
||||||
%type <sval> class_name
|
|
||||||
%type <theme> entries
|
%type <theme> entries
|
||||||
%type <theme> start
|
%type <theme> start
|
||||||
%type <name_path> name_path
|
%type <name_path> name_path
|
||||||
|
@ -91,31 +88,17 @@ entries:
|
||||||
;
|
;
|
||||||
|
|
||||||
entry:
|
entry:
|
||||||
CLASS_PREFIX class_name state_path BOPEN optional_properties BCLOSE
|
NAME_PREFIX name_path state_path BOPEN optional_properties BCLOSE
|
||||||
{
|
|
||||||
gchar *classn = g_strconcat ( "@", $2, NULL);
|
|
||||||
ThemeWidget *widget = rofi_theme_find_or_create_class ( rofi_theme , classn );
|
|
||||||
g_free(classn);
|
|
||||||
widget->set = TRUE;
|
|
||||||
for ( GList *iter = g_list_first ( $3 ); iter ; iter = g_list_next ( iter ) ) {
|
|
||||||
widget = rofi_theme_find_or_create_class ( widget, iter->data );
|
|
||||||
}
|
|
||||||
g_list_foreach ( $3, (GFunc)g_free , NULL );
|
|
||||||
g_list_free ( $3 );
|
|
||||||
widget->set = TRUE;
|
|
||||||
rofi_theme_widget_add_properties ( widget, $5);
|
|
||||||
}
|
|
||||||
| NAME_PREFIX name_path state_path BOPEN optional_properties BCLOSE
|
|
||||||
{
|
{
|
||||||
ThemeWidget *widget = rofi_theme;
|
ThemeWidget *widget = rofi_theme;
|
||||||
for ( GList *iter = g_list_first ( $2 ); iter ; iter = g_list_next ( iter ) ) {
|
for ( GList *iter = g_list_first ( $2 ); iter ; iter = g_list_next ( iter ) ) {
|
||||||
widget = rofi_theme_find_or_create_class ( widget, iter->data );
|
widget = rofi_theme_find_or_create_name ( widget, iter->data );
|
||||||
}
|
}
|
||||||
g_list_foreach ( $2, (GFunc)g_free , NULL );
|
g_list_foreach ( $2, (GFunc)g_free , NULL );
|
||||||
g_list_free ( $2 );
|
g_list_free ( $2 );
|
||||||
widget->set = TRUE;
|
widget->set = TRUE;
|
||||||
for ( GList *iter = g_list_first ( $3 ); iter ; iter = g_list_next ( iter ) ) {
|
for ( GList *iter = g_list_first ( $3 ); iter ; iter = g_list_next ( iter ) ) {
|
||||||
widget = rofi_theme_find_or_create_class ( widget, iter->data );
|
widget = rofi_theme_find_or_create_name ( widget, iter->data );
|
||||||
}
|
}
|
||||||
g_list_foreach ( $3, (GFunc)g_free , NULL );
|
g_list_foreach ( $3, (GFunc)g_free , NULL );
|
||||||
g_list_free ( $3 );
|
g_list_free ( $3 );
|
||||||
|
@ -191,7 +174,6 @@ property
|
||||||
;
|
;
|
||||||
|
|
||||||
pvalue: N_STRING { $$ = $1; }
|
pvalue: N_STRING { $$ = $1; }
|
||||||
class_name: NAME_ELEMENT {$$ = $1;}
|
|
||||||
|
|
||||||
name_path:
|
name_path:
|
||||||
NAME_ELEMENT { $$ = g_list_append ( NULL, $1 );}
|
NAME_ELEMENT { $$ = g_list_append ( NULL, $1 );}
|
||||||
|
|
146
source/theme.c
146
source/theme.c
|
@ -13,10 +13,10 @@
|
||||||
|
|
||||||
void yyerror ( YYLTYPE *ylloc, const char *);
|
void yyerror ( YYLTYPE *ylloc, const char *);
|
||||||
|
|
||||||
ThemeWidget *rofi_theme_find_or_create_class ( ThemeWidget *base, const char *class )
|
ThemeWidget *rofi_theme_find_or_create_name ( ThemeWidget *base, const char *name )
|
||||||
{
|
{
|
||||||
for ( unsigned int i = 0; i < base->num_widgets;i++){
|
for ( unsigned int i = 0; i < base->num_widgets;i++){
|
||||||
if ( g_strcmp0(base->widgets[i]->name, class) == 0 ){
|
if ( g_strcmp0(base->widgets[i]->name, name) == 0 ){
|
||||||
return base->widgets[i];
|
return base->widgets[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ ThemeWidget *rofi_theme_find_or_create_class ( ThemeWidget *base, const char *cl
|
||||||
base->widgets[base->num_widgets] = g_malloc0(sizeof(ThemeWidget));
|
base->widgets[base->num_widgets] = g_malloc0(sizeof(ThemeWidget));
|
||||||
ThemeWidget *retv = base->widgets[base->num_widgets];
|
ThemeWidget *retv = base->widgets[base->num_widgets];
|
||||||
retv->parent = base;
|
retv->parent = base;
|
||||||
retv->name = g_strdup(class);
|
retv->name = g_strdup(name);
|
||||||
base->num_widgets++;
|
base->num_widgets++;
|
||||||
return retv;
|
return retv;
|
||||||
}
|
}
|
||||||
|
@ -269,31 +269,23 @@ static Property *rofi_theme_find_property ( ThemeWidget *widget, PropertyType ty
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
static ThemeWidget *rofi_theme_find_widget ( const char *wclass, const char *name, const char *state )
|
static ThemeWidget *rofi_theme_find_widget ( const char *name, const char *state )
|
||||||
{
|
{
|
||||||
// First find exact match based on name.
|
// First find exact match based on name.
|
||||||
ThemeWidget *widget = rofi_theme_find ( rofi_theme, name, TRUE );
|
ThemeWidget *widget = rofi_theme_find ( rofi_theme, name, TRUE );
|
||||||
widget = rofi_theme_find ( widget, state, TRUE );
|
widget = rofi_theme_find ( widget, state, TRUE );
|
||||||
|
|
||||||
if ( widget == NULL ){
|
|
||||||
// Fall back to class
|
|
||||||
widget = rofi_theme_find ( rofi_theme, wclass, TRUE);
|
|
||||||
widget = rofi_theme_find ( widget, state, TRUE );
|
|
||||||
}
|
|
||||||
if ( widget == NULL ){
|
if ( widget == NULL ){
|
||||||
// Fuzzy finder
|
// Fuzzy finder
|
||||||
widget = rofi_theme_find ( rofi_theme, name, FALSE );
|
widget = rofi_theme_find ( rofi_theme, name, FALSE );
|
||||||
if ( widget == rofi_theme ){
|
|
||||||
widget = rofi_theme_find ( widget, wclass, FALSE );
|
|
||||||
}
|
|
||||||
widget = rofi_theme_find ( widget, state, FALSE );
|
widget = rofi_theme_find ( widget, state, FALSE );
|
||||||
}
|
}
|
||||||
return widget;
|
return widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
int rofi_theme_get_integer ( const char *wclass, const char *name, const char *state, const char *property, int def )
|
int rofi_theme_get_integer ( const char *name, const char *state, const char *property, int def )
|
||||||
{
|
{
|
||||||
ThemeWidget *widget = rofi_theme_find_widget ( wclass, name, state );
|
ThemeWidget *widget = rofi_theme_find_widget ( name, state );
|
||||||
Property *p = rofi_theme_find_property ( widget, P_INTEGER, property );
|
Property *p = rofi_theme_find_property ( widget, P_INTEGER, property );
|
||||||
if ( p ){
|
if ( p ){
|
||||||
return p->value.i;
|
return p->value.i;
|
||||||
|
@ -301,9 +293,9 @@ int rofi_theme_get_integer ( const char *wclass, const char *name, const char *
|
||||||
g_log ( LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "Theme entry: #%s %s property %s unset.", name, state?state:"", property );
|
g_log ( LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "Theme entry: #%s %s property %s unset.", name, state?state:"", property );
|
||||||
return def;
|
return def;
|
||||||
}
|
}
|
||||||
Distance rofi_theme_get_distance ( const char *wclass, const char *name, const char *state, const char *property, int def )
|
Distance rofi_theme_get_distance ( const char *name, const char *state, const char *property, int def )
|
||||||
{
|
{
|
||||||
ThemeWidget *widget = rofi_theme_find_widget ( wclass, name, state );
|
ThemeWidget *widget = rofi_theme_find_widget ( name, state );
|
||||||
Property *p = rofi_theme_find_property ( widget, P_PADDING, property );
|
Property *p = rofi_theme_find_property ( widget, P_PADDING, property );
|
||||||
if ( p ){
|
if ( p ){
|
||||||
return p->value.padding.left;
|
return p->value.padding.left;
|
||||||
|
@ -317,9 +309,9 @@ Distance rofi_theme_get_distance ( const char *wclass, const char *name, const
|
||||||
return (Distance){def, PW_PX};
|
return (Distance){def, PW_PX};
|
||||||
}
|
}
|
||||||
|
|
||||||
int rofi_theme_get_boolean ( const char *wclass, const char *name, const char *state, const char *property, int def )
|
int rofi_theme_get_boolean ( const char *name, const char *state, const char *property, int def )
|
||||||
{
|
{
|
||||||
ThemeWidget *widget = rofi_theme_find_widget ( wclass, name, state );
|
ThemeWidget *widget = rofi_theme_find_widget ( name, state );
|
||||||
Property *p = rofi_theme_find_property ( widget, P_BOOLEAN, property );
|
Property *p = rofi_theme_find_property ( widget, P_BOOLEAN, property );
|
||||||
if ( p ){
|
if ( p ){
|
||||||
return p->value.b;
|
return p->value.b;
|
||||||
|
@ -328,9 +320,9 @@ int rofi_theme_get_boolean ( const char *wclass, const char *name, const char *
|
||||||
return def;
|
return def;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *rofi_theme_get_string ( const char *wclass, const char *name, const char *state, const char *property, char *def )
|
char *rofi_theme_get_string ( const char *name, const char *state, const char *property, char *def )
|
||||||
{
|
{
|
||||||
ThemeWidget *widget = rofi_theme_find_widget ( wclass, name, state );
|
ThemeWidget *widget = rofi_theme_find_widget ( name, state );
|
||||||
Property *p = rofi_theme_find_property ( widget, P_STRING, property );
|
Property *p = rofi_theme_find_property ( widget, P_STRING, property );
|
||||||
if ( p ){
|
if ( p ){
|
||||||
return p->value.s;
|
return p->value.s;
|
||||||
|
@ -338,9 +330,9 @@ char *rofi_theme_get_string ( const char *wclass, const char *name, const char
|
||||||
g_log ( LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "Theme entry: #%s %s property %s unset.", name, state?state:"", property );
|
g_log ( LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "Theme entry: #%s %s property %s unset.", name, state?state:"", property );
|
||||||
return def;
|
return def;
|
||||||
}
|
}
|
||||||
double rofi_theme_get_double ( const char *wclass, const char *name, const char *state, const char *property, double def )
|
double rofi_theme_get_double ( const char *name, const char *state, const char *property, double def )
|
||||||
{
|
{
|
||||||
ThemeWidget *widget = rofi_theme_find_widget ( wclass, name, state );
|
ThemeWidget *widget = rofi_theme_find_widget ( name, state );
|
||||||
Property *p = rofi_theme_find_property ( widget, P_DOUBLE, property );
|
Property *p = rofi_theme_find_property ( widget, P_DOUBLE, property );
|
||||||
if ( p ){
|
if ( p ){
|
||||||
return p->value.b;
|
return p->value.b;
|
||||||
|
@ -348,9 +340,9 @@ double rofi_theme_get_double ( const char *wclass, const char *name, const char
|
||||||
g_log ( LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "Theme entry: #%s %s property %s unset.", name, state?state:"", property );
|
g_log ( LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "Theme entry: #%s %s property %s unset.", name, state?state:"", property );
|
||||||
return def;
|
return def;
|
||||||
}
|
}
|
||||||
void rofi_theme_get_color ( const char *wclass, const char *name, const char *state, const char *property, cairo_t *d)
|
void rofi_theme_get_color ( const char *name, const char *state, const char *property, cairo_t *d)
|
||||||
{
|
{
|
||||||
ThemeWidget *widget = rofi_theme_find_widget ( wclass, name, state );
|
ThemeWidget *widget = rofi_theme_find_widget ( name, state );
|
||||||
Property *p = rofi_theme_find_property ( widget, P_COLOR, property );
|
Property *p = rofi_theme_find_property ( widget, P_COLOR, property );
|
||||||
if ( p ){
|
if ( p ){
|
||||||
cairo_set_source_rgba ( d,
|
cairo_set_source_rgba ( d,
|
||||||
|
@ -363,9 +355,9 @@ void rofi_theme_get_color ( const char *wclass, const char *name, const char *s
|
||||||
g_log ( LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "Theme entry: #%s %s property %s unset.", name, state?state:"", property );
|
g_log ( LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "Theme entry: #%s %s property %s unset.", name, state?state:"", property );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Padding rofi_theme_get_padding ( const char *wclass, const char *name, const char *state, const char *property, Padding pad )
|
Padding rofi_theme_get_padding ( const char *name, const char *state, const char *property, Padding pad )
|
||||||
{
|
{
|
||||||
ThemeWidget *widget = rofi_theme_find_widget ( wclass, name, state );
|
ThemeWidget *widget = rofi_theme_find_widget ( name, state );
|
||||||
Property *p = rofi_theme_find_property ( widget, P_PADDING, property );
|
Property *p = rofi_theme_find_property ( widget, P_PADDING, property );
|
||||||
if ( p ){
|
if ( p ){
|
||||||
pad = p->value.padding;
|
pad = p->value.padding;
|
||||||
|
@ -412,9 +404,11 @@ static Property* rofi_theme_convert_get_color ( const char *color, const char *n
|
||||||
|
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
static GHashTable * rofi_theme_convert_create_property_ht ( void )
|
static void rofi_theme_convert_create_property_ht ( ThemeWidget *widget )
|
||||||
{
|
{
|
||||||
return g_hash_table_new_full ( g_str_hash, g_str_equal, NULL, (GDestroyNotify)rofi_theme_property_free );
|
if ( widget->properties == NULL ) {
|
||||||
|
widget->properties = g_hash_table_new_full ( g_str_hash, g_str_equal, NULL, (GDestroyNotify)rofi_theme_property_free );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void rofi_theme_convert_old_theme ( void )
|
void rofi_theme_convert_old_theme ( void )
|
||||||
|
@ -424,27 +418,37 @@ void rofi_theme_convert_old_theme ( void )
|
||||||
}
|
}
|
||||||
rofi_theme = (ThemeWidget*)g_malloc0 ( sizeof ( ThemeWidget ) );
|
rofi_theme = (ThemeWidget*)g_malloc0 ( sizeof ( ThemeWidget ) );
|
||||||
rofi_theme->name = g_strdup ( "Root" );
|
rofi_theme->name = g_strdup ( "Root" );
|
||||||
rofi_theme->properties = rofi_theme_convert_create_property_ht ( );
|
rofi_theme_convert_create_property_ht ( rofi_theme );
|
||||||
{
|
{
|
||||||
// Spacing
|
// Spacing
|
||||||
ThemeWidget *box_widget = rofi_theme_find_or_create_class ( rofi_theme , "@box" );
|
|
||||||
box_widget->properties = rofi_theme_convert_create_property_ht ( );
|
|
||||||
Property *p = rofi_theme_property_create ( P_INTEGER );
|
Property *p = rofi_theme_property_create ( P_INTEGER );
|
||||||
p->name = g_strdup("spacing");
|
p->name = g_strdup("spacing");
|
||||||
p->value.i = config.padding;
|
p->value.i = config.padding;
|
||||||
g_hash_table_replace ( box_widget->properties, p->name, p );
|
g_hash_table_replace ( rofi_theme->properties, p->name, p );
|
||||||
|
|
||||||
|
p = rofi_theme_property_create ( P_STRING );
|
||||||
|
p->name = g_strdup ( "line-style" );
|
||||||
|
p->value.s= g_strdup(config.separator_style);
|
||||||
|
g_hash_table_replace ( rofi_theme->properties, p->name, p );
|
||||||
|
|
||||||
|
ThemeWidget *inputbar_widget = rofi_theme_find_or_create_name ( rofi_theme , "inputbar" );
|
||||||
|
rofi_theme_convert_create_property_ht ( inputbar_widget );
|
||||||
|
p = rofi_theme_property_create ( P_INTEGER );
|
||||||
|
p->name = g_strdup("spacing");
|
||||||
|
p->value.i = 0;
|
||||||
|
g_hash_table_replace ( inputbar_widget->properties, p->name, p );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
// Spacing
|
// Spacing
|
||||||
ThemeWidget *listview_widget = rofi_theme_find_or_create_class ( rofi_theme , "@listview" );
|
ThemeWidget *listview_widget = rofi_theme_find_or_create_name ( rofi_theme , "listview" );
|
||||||
listview_widget->properties = rofi_theme_convert_create_property_ht ( );
|
rofi_theme_convert_create_property_ht ( listview_widget );
|
||||||
Property *p = rofi_theme_property_create ( P_INTEGER );
|
Property *p = rofi_theme_property_create ( P_INTEGER );
|
||||||
p->name = g_strdup("spacing");
|
p->name = g_strdup("spacing");
|
||||||
p->value.i = config.padding;
|
p->value.i = config.padding;
|
||||||
g_hash_table_replace ( listview_widget->properties, p->name, p );
|
g_hash_table_replace ( listview_widget->properties, p->name, p );
|
||||||
p = rofi_theme_property_create ( P_INTEGER );
|
p = rofi_theme_property_create ( P_INTEGER );
|
||||||
p->name = g_strdup("columns");
|
p->name = g_strdup("columns");
|
||||||
p->value.i = config.padding;
|
p->value.i = config.menu_columns;
|
||||||
g_hash_table_replace ( listview_widget->properties, p->name, p );
|
g_hash_table_replace ( listview_widget->properties, p->name, p );
|
||||||
p = rofi_theme_property_create ( P_INTEGER );
|
p = rofi_theme_property_create ( P_INTEGER );
|
||||||
p->name = g_strdup("fixed-height");
|
p->name = g_strdup("fixed-height");
|
||||||
|
@ -453,8 +457,8 @@ void rofi_theme_convert_old_theme ( void )
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
// Border width.
|
// Border width.
|
||||||
ThemeWidget *window_widget = rofi_theme_find_or_create_class ( rofi_theme , "window" );
|
ThemeWidget *window_widget = rofi_theme_find_or_create_name ( rofi_theme , "window" );
|
||||||
window_widget->properties = rofi_theme_convert_create_property_ht ( );
|
rofi_theme_convert_create_property_ht ( window_widget );
|
||||||
// Padding
|
// Padding
|
||||||
Property *p = rofi_theme_property_create ( P_INTEGER );
|
Property *p = rofi_theme_property_create ( P_INTEGER );
|
||||||
p->name = g_strdup("padding");
|
p->name = g_strdup("padding");
|
||||||
|
@ -477,9 +481,12 @@ void rofi_theme_convert_old_theme ( void )
|
||||||
p = rofi_theme_convert_get_color ( vals[1], "foreground" );
|
p = rofi_theme_convert_get_color ( vals[1], "foreground" );
|
||||||
g_hash_table_replace ( rofi_theme->properties, p->name, p );
|
g_hash_table_replace ( rofi_theme->properties, p->name, p );
|
||||||
|
|
||||||
|
ThemeWidget *widget = rofi_theme_find_or_create_name ( rofi_theme , "inputbar.separator" );
|
||||||
|
rofi_theme_convert_create_property_ht ( widget );
|
||||||
if ( vals[2] != NULL ) {
|
if ( vals[2] != NULL ) {
|
||||||
ThemeWidget *widget = rofi_theme_find_or_create_class ( rofi_theme , "@separator" );
|
p = rofi_theme_convert_get_color ( vals[2], "foreground" );
|
||||||
widget->properties = rofi_theme_convert_create_property_ht ();
|
g_hash_table_replace ( widget->properties, p->name, p );
|
||||||
|
} else {
|
||||||
p = rofi_theme_convert_get_color ( vals[1], "foreground" );
|
p = rofi_theme_convert_get_color ( vals[1], "foreground" );
|
||||||
g_hash_table_replace ( widget->properties, p->name, p );
|
g_hash_table_replace ( widget->properties, p->name, p );
|
||||||
}
|
}
|
||||||
|
@ -490,56 +497,73 @@ void rofi_theme_convert_old_theme ( void )
|
||||||
g_strfreev ( vals );
|
g_strfreev ( vals );
|
||||||
{
|
{
|
||||||
Property *p = NULL;
|
Property *p = NULL;
|
||||||
ThemeWidget *widget = rofi_theme_find_or_create_class ( rofi_theme , "@textbox" );
|
ThemeWidget *listview= rofi_theme_find_or_create_name ( rofi_theme , "listview" );
|
||||||
|
ThemeWidget *widget = rofi_theme_find_or_create_name ( listview , "element" );
|
||||||
|
|
||||||
ThemeWidget *wnormal = rofi_theme_find_or_create_class ( widget, "normal" );
|
ThemeWidget *wnormal = rofi_theme_find_or_create_name ( widget, "normal" );
|
||||||
ThemeWidget *wselected = rofi_theme_find_or_create_class ( widget, "selected" );
|
ThemeWidget *wselected = rofi_theme_find_or_create_name ( widget, "selected" );
|
||||||
ThemeWidget *walternate = rofi_theme_find_or_create_class ( widget, "alternate" );
|
ThemeWidget *walternate = rofi_theme_find_or_create_name ( widget, "alternate" );
|
||||||
|
|
||||||
|
|
||||||
gchar **vals = g_strsplit ( config.color_normal, ",", 5 );
|
gchar **vals = g_strsplit ( config.color_normal, ",", 5 );
|
||||||
if ( g_strv_length (vals) == 5 ) {
|
if ( g_strv_length (vals) == 5 ) {
|
||||||
ThemeWidget *wnn = rofi_theme_find_or_create_class ( wnormal, "normal" );
|
ThemeWidget *wnn = rofi_theme_find_or_create_name ( wnormal, "normal" );
|
||||||
wnn->properties = rofi_theme_convert_create_property_ht ();
|
rofi_theme_convert_create_property_ht ( wnn );
|
||||||
p = rofi_theme_convert_get_color ( vals[0], "background" );
|
p = rofi_theme_convert_get_color ( vals[0], "background" );
|
||||||
g_hash_table_replace ( wnn->properties, p->name, p );
|
g_hash_table_replace ( wnn->properties, p->name, p );
|
||||||
p = rofi_theme_convert_get_color ( vals[1], "foreground" );
|
p = rofi_theme_convert_get_color ( vals[1], "foreground" );
|
||||||
g_hash_table_replace ( wnn->properties, p->name, p );
|
g_hash_table_replace ( wnn->properties, p->name, p );
|
||||||
|
|
||||||
ThemeWidget *wsl = rofi_theme_find_or_create_class ( wselected, "normal" );
|
ThemeWidget *wsl = rofi_theme_find_or_create_name ( wselected, "normal" );
|
||||||
wsl->properties = rofi_theme_convert_create_property_ht ();
|
rofi_theme_convert_create_property_ht ( wsl );
|
||||||
p = rofi_theme_convert_get_color ( vals[3], "background" );
|
p = rofi_theme_convert_get_color ( vals[3], "background" );
|
||||||
g_hash_table_replace ( wsl->properties, p->name, p );
|
g_hash_table_replace ( wsl->properties, p->name, p );
|
||||||
p = rofi_theme_convert_get_color ( vals[4], "foreground" );
|
p = rofi_theme_convert_get_color ( vals[4], "foreground" );
|
||||||
g_hash_table_replace ( wsl->properties, p->name, p );
|
g_hash_table_replace ( wsl->properties, p->name, p );
|
||||||
|
|
||||||
ThemeWidget *wal = rofi_theme_find_or_create_class ( walternate, "normal" );
|
ThemeWidget *wal = rofi_theme_find_or_create_name ( walternate, "normal" );
|
||||||
wal->properties = rofi_theme_convert_create_property_ht ();
|
rofi_theme_convert_create_property_ht ( wal );
|
||||||
p = rofi_theme_convert_get_color ( vals[2], "background" );
|
p = rofi_theme_convert_get_color ( vals[2], "background" );
|
||||||
g_hash_table_replace ( wal->properties, p->name, p );
|
g_hash_table_replace ( wal->properties, p->name, p );
|
||||||
p = rofi_theme_convert_get_color ( vals[1], "foreground" );
|
p = rofi_theme_convert_get_color ( vals[1], "foreground" );
|
||||||
g_hash_table_replace ( wal->properties, p->name, p );
|
g_hash_table_replace ( wal->properties, p->name, p );
|
||||||
|
|
||||||
|
ThemeWidget *inputbar = rofi_theme_find_or_create_name ( rofi_theme, "inputbar" );
|
||||||
|
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 );
|
||||||
|
|
||||||
|
ThemeWidget *message = rofi_theme_find_or_create_name ( rofi_theme, "message" );
|
||||||
|
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 );
|
||||||
}
|
}
|
||||||
g_strfreev ( vals );
|
g_strfreev ( vals );
|
||||||
|
|
||||||
vals = g_strsplit ( config.color_urgent, ",", 5 );
|
vals = g_strsplit ( config.color_urgent, ",", 5 );
|
||||||
if ( g_strv_length (vals) == 5 ) {
|
if ( g_strv_length (vals) == 5 ) {
|
||||||
ThemeWidget *wnn = rofi_theme_find_or_create_class ( wnormal, "urgent" );
|
ThemeWidget *wnn = rofi_theme_find_or_create_name ( wnormal, "urgent" );
|
||||||
wnn->properties = rofi_theme_convert_create_property_ht ();
|
rofi_theme_convert_create_property_ht ( wnn );
|
||||||
p = rofi_theme_convert_get_color ( vals[0], "background" );
|
p = rofi_theme_convert_get_color ( vals[0], "background" );
|
||||||
g_hash_table_replace ( wnn->properties, p->name, p );
|
g_hash_table_replace ( wnn->properties, p->name, p );
|
||||||
p = rofi_theme_convert_get_color ( vals[1], "foreground" );
|
p = rofi_theme_convert_get_color ( vals[1], "foreground" );
|
||||||
g_hash_table_replace ( wnn->properties, p->name, p );
|
g_hash_table_replace ( wnn->properties, p->name, p );
|
||||||
|
|
||||||
ThemeWidget *wsl = rofi_theme_find_or_create_class ( wselected, "urgent" );
|
ThemeWidget *wsl = rofi_theme_find_or_create_name ( wselected, "urgent" );
|
||||||
wsl->properties = rofi_theme_convert_create_property_ht ();
|
rofi_theme_convert_create_property_ht ( wsl );
|
||||||
p = rofi_theme_convert_get_color ( vals[3], "background" );
|
p = rofi_theme_convert_get_color ( vals[3], "background" );
|
||||||
g_hash_table_replace ( wsl->properties, p->name, p );
|
g_hash_table_replace ( wsl->properties, p->name, p );
|
||||||
p = rofi_theme_convert_get_color ( vals[4], "foreground" );
|
p = rofi_theme_convert_get_color ( vals[4], "foreground" );
|
||||||
g_hash_table_replace ( wsl->properties, p->name, p );
|
g_hash_table_replace ( wsl->properties, p->name, p );
|
||||||
|
|
||||||
ThemeWidget *wal = rofi_theme_find_or_create_class ( walternate, "urgent" );
|
ThemeWidget *wal = rofi_theme_find_or_create_name ( walternate, "urgent" );
|
||||||
wal->properties = rofi_theme_convert_create_property_ht ();
|
rofi_theme_convert_create_property_ht ( wal );
|
||||||
p = rofi_theme_convert_get_color ( vals[2], "background" );
|
p = rofi_theme_convert_get_color ( vals[2], "background" );
|
||||||
g_hash_table_replace ( wal->properties, p->name, p );
|
g_hash_table_replace ( wal->properties, p->name, p );
|
||||||
p = rofi_theme_convert_get_color ( vals[1], "foreground" );
|
p = rofi_theme_convert_get_color ( vals[1], "foreground" );
|
||||||
|
@ -549,22 +573,22 @@ void rofi_theme_convert_old_theme ( void )
|
||||||
|
|
||||||
vals = g_strsplit ( config.color_active, ",", 5 );
|
vals = g_strsplit ( config.color_active, ",", 5 );
|
||||||
if ( g_strv_length (vals) == 5 ) {
|
if ( g_strv_length (vals) == 5 ) {
|
||||||
ThemeWidget *wnn = rofi_theme_find_or_create_class ( wnormal, "active" );
|
ThemeWidget *wnn = rofi_theme_find_or_create_name ( wnormal, "active" );
|
||||||
wnn->properties = rofi_theme_convert_create_property_ht ();
|
rofi_theme_convert_create_property_ht ( wnn );
|
||||||
p = rofi_theme_convert_get_color ( vals[0], "background" );
|
p = rofi_theme_convert_get_color ( vals[0], "background" );
|
||||||
g_hash_table_replace ( wnn->properties, p->name, p );
|
g_hash_table_replace ( wnn->properties, p->name, p );
|
||||||
p = rofi_theme_convert_get_color ( vals[1], "foreground" );
|
p = rofi_theme_convert_get_color ( vals[1], "foreground" );
|
||||||
g_hash_table_replace ( wnn->properties, p->name, p );
|
g_hash_table_replace ( wnn->properties, p->name, p );
|
||||||
|
|
||||||
ThemeWidget *wsl = rofi_theme_find_or_create_class ( wselected, "active" );
|
ThemeWidget *wsl = rofi_theme_find_or_create_name ( wselected, "active" );
|
||||||
wsl->properties = rofi_theme_convert_create_property_ht ();
|
rofi_theme_convert_create_property_ht ( wsl );
|
||||||
p = rofi_theme_convert_get_color ( vals[3], "background" );
|
p = rofi_theme_convert_get_color ( vals[3], "background" );
|
||||||
g_hash_table_replace ( wsl->properties, p->name, p );
|
g_hash_table_replace ( wsl->properties, p->name, p );
|
||||||
p = rofi_theme_convert_get_color ( vals[4], "foreground" );
|
p = rofi_theme_convert_get_color ( vals[4], "foreground" );
|
||||||
g_hash_table_replace ( wsl->properties, p->name, p );
|
g_hash_table_replace ( wsl->properties, p->name, p );
|
||||||
|
|
||||||
ThemeWidget *wal = rofi_theme_find_or_create_class ( walternate, "active" );
|
ThemeWidget *wal = rofi_theme_find_or_create_name ( walternate, "active" );
|
||||||
wal->properties = rofi_theme_convert_create_property_ht ();
|
rofi_theme_convert_create_property_ht ( wal );
|
||||||
p = rofi_theme_convert_get_color ( vals[2], "background" );
|
p = rofi_theme_convert_get_color ( vals[2], "background" );
|
||||||
g_hash_table_replace ( wal->properties, p->name, p );
|
g_hash_table_replace ( wal->properties, p->name, p );
|
||||||
p = rofi_theme_convert_get_color ( vals[1], "foreground" );
|
p = rofi_theme_convert_get_color ( vals[1], "foreground" );
|
||||||
|
|
|
@ -612,7 +612,7 @@ void __create_window ( MenuFlags menu_flags )
|
||||||
pango_cairo_font_map_set_resolution ( (PangoCairoFontMap *) font_map, (double) config.dpi );
|
pango_cairo_font_map_set_resolution ( (PangoCairoFontMap *) font_map, (double) config.dpi );
|
||||||
}
|
}
|
||||||
// Setup font.
|
// Setup font.
|
||||||
char *font = rofi_theme_get_string ("@window" , "window", NULL, "font" , config.menu_font );
|
char *font = rofi_theme_get_string ( "window", NULL, "font" , config.menu_font );
|
||||||
if ( font ) {
|
if ( font ) {
|
||||||
PangoFontDescription *pfd = pango_font_description_from_string ( font );
|
PangoFontDescription *pfd = pango_font_description_from_string ( font );
|
||||||
pango_context_set_font_description ( p, pfd );
|
pango_context_set_font_description ( p, pfd );
|
||||||
|
@ -650,7 +650,7 @@ void __create_window ( MenuFlags menu_flags )
|
||||||
CacheState.flags = menu_flags;
|
CacheState.flags = menu_flags;
|
||||||
monitor_active ( &( CacheState.mon ) );
|
monitor_active ( &( CacheState.mon ) );
|
||||||
|
|
||||||
char *transparency = rofi_theme_get_string ( "@window", "window", NULL, "transparency", NULL);
|
char *transparency = rofi_theme_get_string ( "window", NULL, "transparency", NULL);
|
||||||
if ( transparency == NULL && config.fake_transparency ){
|
if ( transparency == NULL && config.fake_transparency ){
|
||||||
transparency = config.fake_background;
|
transparency = config.fake_background;
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,9 +33,6 @@
|
||||||
|
|
||||||
#define LOG_DOMAIN "Widgets.Box"
|
#define LOG_DOMAIN "Widgets.Box"
|
||||||
|
|
||||||
/** Class name of box widget */
|
|
||||||
const char *BOX_CLASS_NAME = "@box";
|
|
||||||
|
|
||||||
/** Default spacing used in the box*/
|
/** Default spacing used in the box*/
|
||||||
#define DEFAULT_SPACING 2
|
#define DEFAULT_SPACING 2
|
||||||
|
|
||||||
|
@ -282,8 +279,8 @@ void box_add ( box *box, widget *child, gboolean expand, gboolean end )
|
||||||
height = MAX (height, child->h+widget_padding_get_padding_height ( WIDGET ( box )));
|
height = MAX (height, child->h+widget_padding_get_padding_height ( WIDGET ( box )));
|
||||||
box->widget.h = height;
|
box->widget.h = height;
|
||||||
}
|
}
|
||||||
child->expand = rofi_theme_get_boolean ( child->class_name, child->name, child->state, "expand", expand);
|
child->expand = rofi_theme_get_boolean ( child->name, child->state, "expand", expand);
|
||||||
child->end = rofi_theme_get_boolean ( child->class_name, child->name, child->state, "end", end);
|
child->end = rofi_theme_get_boolean ( child->name, child->state, "end", end);
|
||||||
child->parent = WIDGET ( box );
|
child->parent = WIDGET ( box );
|
||||||
box->children = g_list_append ( box->children, (void *) child );
|
box->children = g_list_append ( box->children, (void *) child );
|
||||||
widget_update ( WIDGET ( box ) );
|
widget_update ( WIDGET ( box ) );
|
||||||
|
@ -338,7 +335,7 @@ box * box_create ( const char *name, boxType type )
|
||||||
{
|
{
|
||||||
box *b = g_malloc0 ( sizeof ( box ) );
|
box *b = g_malloc0 ( sizeof ( box ) );
|
||||||
// Initialize widget.
|
// Initialize widget.
|
||||||
widget_init ( WIDGET(b), name, BOX_CLASS_NAME);
|
widget_init ( WIDGET(b), name );
|
||||||
b->type = type;
|
b->type = type;
|
||||||
b->widget.draw = box_draw;
|
b->widget.draw = box_draw;
|
||||||
b->widget.free = box_free;
|
b->widget.free = box_free;
|
||||||
|
@ -349,7 +346,7 @@ box * box_create ( const char *name, boxType type )
|
||||||
b->widget.get_desired_height = box_get_desired_height;
|
b->widget.get_desired_height = box_get_desired_height;
|
||||||
b->widget.enabled = TRUE;
|
b->widget.enabled = TRUE;
|
||||||
|
|
||||||
b->spacing = rofi_theme_get_distance ( b->widget.class_name, b->widget.name, NULL, "spacing",DEFAULT_SPACING );
|
b->spacing = rofi_theme_get_distance ( b->widget.name, NULL, "spacing",DEFAULT_SPACING );
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -340,7 +340,7 @@ listview *listview_create ( const char *name, listview_update_callback cb, void
|
||||||
{
|
{
|
||||||
listview *lv = g_malloc0 ( sizeof ( listview ) );
|
listview *lv = g_malloc0 ( sizeof ( listview ) );
|
||||||
|
|
||||||
widget_init ( WIDGET ( lv ), name, "@listview" );
|
widget_init ( WIDGET ( lv ), name );
|
||||||
lv->widget.free = listview_free;
|
lv->widget.free = listview_free;
|
||||||
lv->widget.resize = listview_resize;
|
lv->widget.resize = listview_resize;
|
||||||
lv->widget.draw = listview_draw;
|
lv->widget.draw = listview_draw;
|
||||||
|
@ -366,15 +366,15 @@ listview *listview_create ( const char *name, listview_update_callback cb, void
|
||||||
lv->udata = udata;
|
lv->udata = udata;
|
||||||
|
|
||||||
// Some settings.
|
// Some settings.
|
||||||
lv->spacing = rofi_theme_get_distance (lv->widget.class_name, lv->widget.name, NULL, "spacing", DEFAULT_SPACING );
|
lv->spacing = rofi_theme_get_distance ( lv->widget.name, NULL, "spacing", DEFAULT_SPACING );
|
||||||
lv->menu_columns = rofi_theme_get_integer (lv->widget.class_name, lv->widget.name, NULL, "columns", config.menu_columns );
|
lv->menu_columns = rofi_theme_get_integer ( lv->widget.name, NULL, "columns", config.menu_columns );
|
||||||
lv->fixed_num_lines = rofi_theme_get_boolean (lv->widget.class_name, lv->widget.name, NULL, "fixed-height", config.fixed_num_lines );
|
lv->fixed_num_lines = rofi_theme_get_boolean ( lv->widget.name, NULL, "fixed-height", config.fixed_num_lines );
|
||||||
lv->dynamic = rofi_theme_get_boolean (lv->widget.class_name, lv->widget.name, NULL, "dynamic", TRUE );
|
lv->dynamic = rofi_theme_get_boolean ( lv->widget.name, NULL, "dynamic", TRUE );
|
||||||
|
|
||||||
lv->reverse = rofi_theme_get_boolean (lv->widget.class_name, lv->widget.name, NULL, "reverse", reverse );
|
lv->reverse = rofi_theme_get_boolean ( lv->widget.name, NULL, "reverse", reverse );
|
||||||
listview_set_show_scrollbar ( lv, rofi_theme_get_boolean ( lv->widget.class_name, lv->widget.name, NULL, "scrollbar", !config.hide_scrollbar ));
|
listview_set_show_scrollbar ( lv, rofi_theme_get_boolean ( lv->widget.name, NULL, "scrollbar", !config.hide_scrollbar ));
|
||||||
listview_set_scrollbar_width ( lv, rofi_theme_get_integer ( lv->widget.class_name, lv->widget.name, NULL, "scrollbar-width", config.scrollbar_width ));
|
listview_set_scrollbar_width ( lv, rofi_theme_get_integer ( lv->widget.name, NULL, "scrollbar-width", config.scrollbar_width ));
|
||||||
lv->cycle = rofi_theme_get_boolean ( lv->widget.class_name, lv->widget.name, NULL, "cycle", config.cycle );
|
lv->cycle = rofi_theme_get_boolean ( lv->widget.name, NULL, "cycle", config.cycle );
|
||||||
|
|
||||||
|
|
||||||
return lv;
|
return lv;
|
||||||
|
|
|
@ -44,7 +44,7 @@ static int scrollbar_get_desired_height ( widget *wid )
|
||||||
scrollbar *scrollbar_create ( const char *name, int width )
|
scrollbar *scrollbar_create ( const char *name, int width )
|
||||||
{
|
{
|
||||||
scrollbar *sb = g_malloc0 ( sizeof ( scrollbar ) );
|
scrollbar *sb = g_malloc0 ( sizeof ( scrollbar ) );
|
||||||
widget_init ( WIDGET (sb), name, "@scrollbar" );
|
widget_init ( WIDGET (sb), name );
|
||||||
sb->widget.x = 0;
|
sb->widget.x = 0;
|
||||||
sb->widget.y = 0;
|
sb->widget.y = 0;
|
||||||
sb->widget.w = widget_padding_get_padding_width ( WIDGET (sb) ) +width;
|
sb->widget.w = widget_padding_get_padding_width ( WIDGET (sb) ) +width;
|
||||||
|
@ -118,7 +118,7 @@ static void scrollbar_draw ( widget *wid, cairo_t *draw )
|
||||||
// Never go out of bar.
|
// Never go out of bar.
|
||||||
height = MAX ( 2, height );
|
height = MAX ( 2, height );
|
||||||
// Cap length;
|
// Cap length;
|
||||||
rofi_theme_get_color ( sb->widget.class_name, sb->widget.name, "handle", "foreground", draw );
|
rofi_theme_get_color ( sb->widget.name, "handle", "foreground", draw );
|
||||||
|
|
||||||
cairo_rectangle ( draw,
|
cairo_rectangle ( draw,
|
||||||
widget_padding_get_left ( wid ),
|
widget_padding_get_left ( wid ),
|
||||||
|
|
|
@ -32,7 +32,6 @@
|
||||||
#include "x11-helper.h"
|
#include "x11-helper.h"
|
||||||
#include "theme.h"
|
#include "theme.h"
|
||||||
|
|
||||||
const char *SEPARATOR_CLASS_NAME = "@separator";
|
|
||||||
/**
|
/**
|
||||||
* @param sp The separator widget handle.
|
* @param sp The separator widget handle.
|
||||||
* @param style_str String representation of the style.
|
* @param style_str String representation of the style.
|
||||||
|
@ -78,7 +77,7 @@ static int separator_get_desired_height ( widget *wid )
|
||||||
separator *separator_create ( const char *name, separator_type type, short sw )
|
separator *separator_create ( const char *name, separator_type type, short sw )
|
||||||
{
|
{
|
||||||
separator *sb = g_malloc0 ( sizeof ( separator ) );
|
separator *sb = g_malloc0 ( sizeof ( separator ) );
|
||||||
widget_init ( WIDGET (sb), name, SEPARATOR_CLASS_NAME );
|
widget_init ( WIDGET (sb), name );
|
||||||
sb->type = type;
|
sb->type = type;
|
||||||
sb->separator_width = sw;
|
sb->separator_width = sw;
|
||||||
sb->widget.x = 0;
|
sb->widget.x = 0;
|
||||||
|
@ -99,7 +98,7 @@ separator *separator_create ( const char *name, separator_type type, short sw )
|
||||||
// Enabled by default
|
// Enabled by default
|
||||||
sb->widget.enabled = TRUE;
|
sb->widget.enabled = TRUE;
|
||||||
|
|
||||||
const char *line_style = rofi_theme_get_string ( sb->widget.class_name, sb->widget.name, NULL, "line-style", "solid");
|
const char *line_style = rofi_theme_get_string ( sb->widget.name, NULL, "line-style", "solid");
|
||||||
separator_set_line_style_from_string ( sb, line_style );
|
separator_set_line_style_from_string ( sb, line_style );
|
||||||
return sb;
|
return sb;
|
||||||
}
|
}
|
||||||
|
@ -140,7 +139,7 @@ static void separator_draw ( widget *wid, cairo_t *draw )
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
color_separator ( draw );
|
color_separator ( draw );
|
||||||
rofi_theme_get_color ( wid->class_name, wid->name, NULL, "foreground", draw );
|
rofi_theme_get_color ( wid->name, NULL, "foreground", draw );
|
||||||
if ( sep->line_style == S_LINE_DASH ) {
|
if ( sep->line_style == S_LINE_DASH ) {
|
||||||
const double dashes[1] = { 4 };
|
const double dashes[1] = { 4 };
|
||||||
cairo_set_dash ( draw, dashes, 1, 0.0 );
|
cairo_set_dash ( draw, dashes, 1, 0.0 );
|
||||||
|
|
|
@ -95,7 +95,7 @@ textbox* textbox_create ( const char *name, TextboxFlags flags, TextBoxFontType
|
||||||
{
|
{
|
||||||
textbox *tb = g_slice_new0 ( textbox );
|
textbox *tb = g_slice_new0 ( textbox );
|
||||||
|
|
||||||
widget_init ( WIDGET (tb), name, "@textbox" );
|
widget_init ( WIDGET (tb), name );
|
||||||
|
|
||||||
tb->widget.draw = textbox_draw;
|
tb->widget.draw = textbox_draw;
|
||||||
tb->widget.free = textbox_free;
|
tb->widget.free = textbox_free;
|
||||||
|
@ -365,7 +365,7 @@ static void texbox_update ( textbox *tb )
|
||||||
//cairo_set_source_rgba ( tb->main_draw, 0,0,0,0.0);
|
//cairo_set_source_rgba ( tb->main_draw, 0,0,0,0.0);
|
||||||
//cairo_paint ( tb->main_draw );
|
//cairo_paint ( tb->main_draw );
|
||||||
|
|
||||||
rofi_theme_get_color ( tb->widget.class_name, tb->widget.name, tb->widget.state, "foreground", tb->main_draw);
|
rofi_theme_get_color ( tb->widget.name, tb->widget.state, "foreground", tb->main_draw);
|
||||||
// draw the cursor
|
// draw the cursor
|
||||||
if ( tb->flags & TB_EDITABLE && tb->blink ) {
|
if ( tb->flags & TB_EDITABLE && tb->blink ) {
|
||||||
cairo_rectangle ( tb->main_draw, x + cursor_x, y+cursor_y, cursor_width, cursor_height);
|
cairo_rectangle ( tb->main_draw, x + cursor_x, y+cursor_y, cursor_width, cursor_height);
|
||||||
|
|
|
@ -4,17 +4,16 @@
|
||||||
#include "theme.h"
|
#include "theme.h"
|
||||||
|
|
||||||
|
|
||||||
void widget_init ( widget *widget , const char *name, const char *class_name )
|
void widget_init ( widget *widget , const char *name )
|
||||||
{
|
{
|
||||||
widget->name = g_strdup(name);
|
widget->name = g_strdup(name);
|
||||||
widget->class_name = g_strdup(class_name);
|
|
||||||
widget->padding = (Padding){ {0, PW_PX}, {0, PW_PX}, {0, PW_PX}, {0, PW_PX}};
|
widget->padding = (Padding){ {0, PW_PX}, {0, PW_PX}, {0, PW_PX}, {0, PW_PX}};
|
||||||
widget->padding = rofi_theme_get_padding (widget->class_name, widget->name, NULL, "padding", widget->padding);
|
widget->padding = rofi_theme_get_padding ( widget->name, NULL, "padding", widget->padding);
|
||||||
widget->border = (Padding){ {0, PW_PX}, {0, PW_PX}, {0, PW_PX}, {0, PW_PX}};
|
widget->border = (Padding){ {0, PW_PX}, {0, PW_PX}, {0, PW_PX}, {0, PW_PX}};
|
||||||
widget->border = rofi_theme_get_padding (widget->class_name, widget->name, NULL, "border", widget->border);
|
widget->border = rofi_theme_get_padding ( widget->name, NULL, "border", widget->border);
|
||||||
|
|
||||||
widget->margin = (Padding){ {0, PW_PX}, {0, PW_PX}, {0, PW_PX}, {0, PW_PX}};
|
widget->margin = (Padding){ {0, PW_PX}, {0, PW_PX}, {0, PW_PX}, {0, PW_PX}};
|
||||||
widget->margin = rofi_theme_get_padding (widget->class_name, widget->name, NULL, "margin", widget->margin);
|
widget->margin = rofi_theme_get_padding ( widget->name, NULL, "margin", widget->margin);
|
||||||
}
|
}
|
||||||
|
|
||||||
void widget_set_state ( widget *widget, const char *state )
|
void widget_set_state ( widget *widget, const char *state )
|
||||||
|
@ -108,7 +107,7 @@ void widget_draw ( widget *widget, cairo_t *d )
|
||||||
);
|
);
|
||||||
cairo_clip ( d );
|
cairo_clip ( d );
|
||||||
|
|
||||||
rofi_theme_get_color ( widget->class_name, widget->name, widget->state, "background", d );
|
rofi_theme_get_color ( widget->name, widget->state, "background", d );
|
||||||
cairo_paint( d ) ;
|
cairo_paint( d ) ;
|
||||||
|
|
||||||
// Set new x/y possition.
|
// Set new x/y possition.
|
||||||
|
@ -119,7 +118,7 @@ void widget_draw ( widget *widget, cairo_t *d )
|
||||||
int right = distance_get_pixel ( widget->border.right, ORIENTATION_VERTICAL );
|
int right = distance_get_pixel ( widget->border.right, ORIENTATION_VERTICAL );
|
||||||
int bottom = distance_get_pixel ( widget->border.bottom, ORIENTATION_VERTICAL );
|
int bottom = distance_get_pixel ( widget->border.bottom, ORIENTATION_VERTICAL );
|
||||||
if ( left || top || right || bottom ) {
|
if ( left || top || right || bottom ) {
|
||||||
rofi_theme_get_color ( widget->class_name, widget->name, widget->state, "foreground", d );
|
rofi_theme_get_color ( widget->name, widget->state, "foreground", d );
|
||||||
if ( left > 0 ) {
|
if ( left > 0 ) {
|
||||||
cairo_set_line_width ( d, left );
|
cairo_set_line_width ( d, left );
|
||||||
cairo_move_to ( d, margin_left + left/2.0, margin_top );
|
cairo_move_to ( d, margin_left + left/2.0, margin_top );
|
||||||
|
@ -157,9 +156,6 @@ void widget_free ( widget *wid )
|
||||||
if ( wid->name ) {
|
if ( wid->name ) {
|
||||||
g_free ( wid->name );
|
g_free ( wid->name );
|
||||||
}
|
}
|
||||||
if ( wid->class_name ) {
|
|
||||||
g_free( wid->class_name );
|
|
||||||
}
|
|
||||||
if ( wid->free ) {
|
if ( wid->free ) {
|
||||||
wid->free ( wid );
|
wid->free ( wid );
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,8 +35,6 @@
|
||||||
|
|
||||||
/** The default border width of the window */
|
/** The default border width of the window */
|
||||||
#define DEFAULT_BORDER_WIDTH 2
|
#define DEFAULT_BORDER_WIDTH 2
|
||||||
/** The class name of the window */
|
|
||||||
const char *WINDOW_CLASS_NAME = "@window";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param window Handle to the window widget.
|
* @param window Handle to the window widget.
|
||||||
|
@ -129,7 +127,7 @@ window * window_create ( const char *name )
|
||||||
{
|
{
|
||||||
window *b = g_malloc0 ( sizeof ( window ) );
|
window *b = g_malloc0 ( sizeof ( window ) );
|
||||||
// Initialize widget.
|
// Initialize widget.
|
||||||
widget_init ( WIDGET(b), name, WINDOW_CLASS_NAME);
|
widget_init ( WIDGET(b), name );
|
||||||
b->widget.draw = window_draw;
|
b->widget.draw = window_draw;
|
||||||
b->widget.free = window_free;
|
b->widget.free = window_free;
|
||||||
b->widget.resize = window_resize;
|
b->widget.resize = window_resize;
|
||||||
|
|
Loading…
Reference in a new issue