diff --git a/include/theme.h b/include/theme.h index 751d83b3..0ed71460 100644 --- a/include/theme.h +++ b/include/theme.h @@ -249,6 +249,16 @@ double rofi_theme_get_double ( const widget *widget, const char *property, doub */ void rofi_theme_get_color ( const widget *widget, const char *property, cairo_t *d ); + +/** + * @param widget The widget to query + * @param property The property to query. + * + * Check if a rofi theme has a property set. + * + */ +gboolean rofi_theme_has_property ( const widget *widget, const char *property ); + /** * @param widget The widget to query * @param property The property to query. diff --git a/source/dialogs/script.c b/source/dialogs/script.c index db5e6c96..1991ac3e 100644 --- a/source/dialogs/script.c +++ b/source/dialogs/script.c @@ -77,10 +77,11 @@ typedef struct void dmenuscript_parse_entry_extras ( G_GNUC_UNUSED Mode *sw, DmenuScriptEntry *entry, char *buffer, size_t length ) { size_t length_key = 0; //strlen ( line ); - while ( length_key <= length && buffer[length_key] != '\x1f' ) { + while ( length_key < length && buffer[length_key] != '\x1f' ) { length_key++; } - if ( length_key < length ) { + // Should be not last character in buffer. + if ( length_key < (length-1) ) { buffer[length_key] = '\0'; char *value = buffer + length_key + 1; if ( strcasecmp ( buffer, "icon" ) == 0 ) { diff --git a/source/theme.c b/source/theme.c index 85062f8c..069b9ef3 100644 --- a/source/theme.c +++ b/source/theme.c @@ -1158,3 +1158,20 @@ ThemeMediaType rofi_theme_parse_media_type ( const char *type ) } return THEME_MEDIA_TYPE_INVALID; } + + +gboolean rofi_theme_has_property ( const widget *widget, const char *property ) +{ + ThemeWidget *wid = rofi_theme_find_widget ( widget->name, widget->state, FALSE ); + Property *p = rofi_theme_find_property ( wid, P_STRING, property, FALSE ); + if ( p ) { + if ( p->type == P_INHERIT ) { + if ( widget->parent ) { + return rofi_theme_has_property ( widget->parent, property ); + } + return FALSE; + } + return TRUE; + } + return FALSE; +}