Fix and document resolving.

This commit is contained in:
Dave Davenport 2016-12-20 09:17:19 +01:00
parent 9c6019d3d0
commit 8793475501
3 changed files with 75 additions and 83 deletions

View File

@ -32,25 +32,25 @@ Names are prefixed with a `#`
List of names in **rofi**:
* #window
* #mainbox
* #mainbox.box: The main vertical @box
* #inputbar
* #inputbar.box: The horizontal @box packing the widgets.
* #inputbar.separator: The separator under/above the inputbar.
* #inputbar.case-indicator: The case/sort indicator @textbox
* #inputbar.prompt: The prompt @textbox
* #inputbar.entry: The main entry @textbox
* #listview
* #listview.scrollbar: The listview scrollbar
* #listview.element: The entries in the listview
* #sidebar
* #sidebar.box: The main horizontal @box packing the buttons.
* #sidebar.button: The buttons @textbox for each mode.
* #sidebar.separator: The separator under/above the sidebar.
* #message
* #message.textbox: The message textbox.
* #message.separator: The separator under/above the sidebar.
* `#window`
* `#mainbox`
* `#mainbox.box`: The main vertical @box
* `#inputbar`
* `#inputbar.box`: The horizontal @box packing the widgets.
* `#inputbar.separator`: The separator under/above the inputbar.
* `#inputbar.case-indicator`: The case/sort indicator @textbox
* `#inputbar.prompt`: The prompt @textbox
* `#inputbar.entry`: The main entry @textbox
* `#listview`
* `#listview.scrollbar`: The listview scrollbar
* `#listview.element`: The entries in the listview
* `#sidebar`
* `#sidebar.box`: The main horizontal @box packing the buttons.
* `#sidebar.button`: The buttons @textbox for each mode.
* `#sidebar.separator`: The separator under/above the sidebar.
* `#message`
* `#message.textbox`: The message textbox.
* `#message.separator`: The separator under/above the sidebar.
## State
@ -165,3 +165,26 @@ The following properties are currently supports:
* scrollbar: boolean
* scrollbar-width: integer
* cycle: boolean
## Resolving properties
Current matching does:
1. Find exact name match, with exact state match.
If found return
1. Find exact class match, with exact state match.
If found return
1. Find fuzzy name match, with fuzzy state.
If found is not root node, return
1. Find fuzzy class match, with fuzzy state.
return

View File

@ -168,9 +168,9 @@ static Widget *rofi_theme_find_single ( Widget *widget, const char *name)
return widget;
}
static Widget *rofi_theme_find ( Widget *widget , const char *name )
static Widget *rofi_theme_find ( Widget *widget , const char *name, const gboolean exact )
{
if ( name == NULL ) {
if ( widget == NULL || name == NULL ) {
return widget;
}
char **names = g_strsplit ( name, "." , 0 );
@ -184,7 +184,11 @@ static Widget *rofi_theme_find ( Widget *widget , const char *name )
}
}
g_strfreev(names);
return widget;
if ( !exact || found ){
return widget;
} else {
return NULL;
}
}
static Property *rofi_theme_find_property ( Widget *widget, PropertyType type, const char *property )
@ -200,21 +204,31 @@ static Property *rofi_theme_find_property ( Widget *widget, PropertyType type, c
}
return NULL;
}
static Widget *rofi_theme_find_widget ( const char *wclass, const char *name, const char *state )
{
// First find exact match based on name.
Widget *widget = rofi_theme_find ( rofi_theme, name, 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 ){
// Fuzzy finder
Widget *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 );
}
return widget;
}
int rofi_theme_get_integer ( const char *wclass, const char *name, const char *state, const char *property, int def )
{
if ( rofi_theme == NULL ) {
return def;
}
Widget *widget = rofi_theme_find ( rofi_theme, name );
if ( widget != rofi_theme ){
widget = rofi_theme_find ( widget, state );
}
if ( widget == rofi_theme || widget->set == FALSE ){
// Fall back to class
widget = rofi_theme_find ( rofi_theme, wclass);
}
widget = rofi_theme_find ( widget, state );
Widget *widget = rofi_theme_find_widget ( wclass, name, state );
Property *p = rofi_theme_find_property ( widget, P_INTEGER, property );
if ( p ){
return p->value.i;
@ -224,18 +238,7 @@ int rofi_theme_get_integer ( const char *wclass, const char *name, const char *
int rofi_theme_get_boolean ( const char *wclass, const char *name, const char *state, const char *property, int def )
{
if ( rofi_theme == NULL ) {
return def;
}
Widget *widget = rofi_theme_find ( rofi_theme, name );
if ( widget != rofi_theme ){
widget = rofi_theme_find ( widget, state );
}
if ( widget == rofi_theme || widget->set == FALSE ){
// Fall back to class
widget = rofi_theme_find ( rofi_theme, wclass);
}
widget = rofi_theme_find ( widget, state );
Widget *widget = rofi_theme_find_widget ( wclass, name, state );
Property *p = rofi_theme_find_property ( widget, P_BOOLEAN, property );
if ( p ){
return p->value.b;
@ -245,18 +248,7 @@ int rofi_theme_get_boolean ( const char *wclass, const char *name, const char *
char *rofi_theme_get_string ( const char *wclass, const char *name, const char *state, const char *property, char *def )
{
if ( rofi_theme == NULL ) {
return def;
}
Widget *widget = rofi_theme_find ( rofi_theme, name );
if ( widget != rofi_theme ){
widget = rofi_theme_find ( widget, state );
}
if ( widget == rofi_theme || widget->set == FALSE ){
// Fall back to class
widget = rofi_theme_find ( rofi_theme, wclass);
}
widget = rofi_theme_find ( widget, state );
Widget *widget = rofi_theme_find_widget ( wclass, name, state );
Property *p = rofi_theme_find_property ( widget, P_STRING, property );
if ( p ){
return p->value.s;
@ -265,18 +257,7 @@ char *rofi_theme_get_string ( const char *wclass, const char *name, const char
}
double rofi_theme_get_double ( const char *wclass, const char *name, const char *state, const char *property, double def )
{
if ( rofi_theme == NULL ) {
return def;
}
Widget *widget = rofi_theme_find ( rofi_theme, name );
if ( widget != rofi_theme ){
widget = rofi_theme_find ( widget, state );
}
if ( widget == rofi_theme || widget->set == FALSE ){
// Fall back to class
widget = rofi_theme_find ( rofi_theme, wclass);
}
widget = rofi_theme_find ( widget, state );
Widget *widget = rofi_theme_find_widget ( wclass, name, state );
Property *p = rofi_theme_find_property ( widget, P_DOUBLE, property );
if ( p ){
return p->value.b;
@ -285,18 +266,7 @@ double rofi_theme_get_double ( const char *wclass, const char *name, const char
}
void rofi_theme_get_color ( const char *wclass, const char *name, const char *state, const char *property, cairo_t *d)
{
if ( rofi_theme == NULL ) {
return ;
}
Widget *widget = rofi_theme_find ( rofi_theme, name );
if ( widget != rofi_theme ){
widget = rofi_theme_find ( widget, state );
}
if ( widget == rofi_theme || widget->set == FALSE ){
// Fall back to class
widget = rofi_theme_find ( rofi_theme, wclass);
}
widget = rofi_theme_find ( widget, state );
Widget *widget = rofi_theme_find_widget ( wclass, name, state );
Property *p = rofi_theme_find_property ( widget, P_COLOR, property );
if ( p ){
cairo_set_source_rgba ( d,

View File

@ -631,7 +631,6 @@ void __create_window ( MenuFlags menu_flags )
if ( transparency == NULL && config.fake_transparency ){
transparency = config.fake_background;
}
printf("Setup transparency: %s\n", transparency);
if ( transparency ) {
rofi_view_setup_fake_transparency ( transparency );
}