summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Davenport <qball@gmpclient.org>2016-12-20 09:17:19 +0100
committerDave Davenport <qball@gmpclient.org>2016-12-20 09:17:19 +0100
commit8793475501377e27c922cecf2fbe0d04cb08cf9c (patch)
tree70095ca02eaa625d1c0fbeb576fe87fd880f432e
parent9c6019d3d0dc8d6e127d41754c05bd42a2ec07e8 (diff)
Fix and document resolving.
-rw-r--r--doc/themer.md61
-rw-r--r--source/theme.c96
-rw-r--r--source/view.c1
3 files changed, 75 insertions, 83 deletions
diff --git a/doc/themer.md b/doc/themer.md
index 220586c5..2f44ed25 100644
--- a/doc/themer.md
+++ b/doc/themer.md
@@ -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
+
diff --git a/source/theme.c b/source/theme.c
index 868cf769..ef3cb1b8 100644
--- a/source/theme.c
+++ b/source/theme.c
@@ -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;
}
-
-int rofi_theme_get_integer ( const char *wclass, const char *name, const char *state, const char *property, int def )
+static Widget *rofi_theme_find_widget ( const char *wclass, const char *name, const char *state )
{
- 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 ){
+ // 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);
+ widget = rofi_theme_find ( rofi_theme, wclass, TRUE);
+ widget = rofi_theme_find ( widget, state, TRUE );
}
- widget = rofi_theme_find ( widget, state );
+ 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 )
+{
+ 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,
diff --git a/source/view.c b/source/view.c
index fed17648..bbf5d328 100644
--- a/source/view.c
+++ b/source/view.c
@@ -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 );
}