[Doc][Config] Update documentation for new fallback icon

* Allow multiple config be combined.
This commit is contained in:
Dave Davenport 2022-05-12 19:52:35 +02:00
parent fc64265343
commit 141bd3d197
7 changed files with 91 additions and 77 deletions

View file

@ -431,12 +431,6 @@ Specify icon theme to be used.
If not specified default theme from DE is used, \fIAdwaita\fP and \fIgnome\fP themes act as
fallback themes.
.PP
\fB\fC-application-fallback-icon\fR
.PP
Specify an icon to be used when the application icon in run/drun are not yet loaded or is not available.
.PP
\fB\fC-markup\fR
@ -464,6 +458,38 @@ The limit of elements that is used to switch from instant to delayed filter mode
.PP
Default: 8192
.PP
A fallback icon can be specified for each mode:
.PP
.RS
.nf
configuration {
<mode>{
fallback-icon: "<icon name>";
}
}
.fi
.RE
.PP
Example
.PP
.RS
.nf
configuration {
run,drun {
fallback-icon: "application-x-addon";
}
}
.fi
.RE
.SS Matching
.PP
\fB\fC-matching\fR \fImethod\fP
@ -1000,7 +1026,7 @@ Default: {mode} {text}
.RE
.PP
Note: This setting is ignored if \fB\fCcombi-hide-mode-prefix\fR is eanbled.
Note: This setting is ignored if \fB\fCcombi-hide-mode-prefix\fR is enabled.
.SS History and Sorting
.PP

View file

@ -258,10 +258,6 @@ Specify icon theme to be used.
If not specified default theme from DE is used, *Adwaita* and *gnome* themes act as
fallback themes.
`-application-fallback-icon`
Specify an icon to be used when the application icon in run/drun are not yet loaded or is not available.
`-markup`
Use Pango markup to format output wherever possible.
@ -280,6 +276,27 @@ The limit of elements that is used to switch from instant to delayed filter mode
Default: 8192
A fallback icon can be specified for each mode:
```css
configuration {
<mode>{
fallback-icon: "<icon name>";
}
}
```
Example
```css
configuration {
run,drun {
fallback-icon: "application-x-addon";
}
}
```
### Matching
`-matching` *method*

View file

@ -489,7 +489,7 @@ if ( queue == NULL ) {
}
<NAMESTR>\.|{WHITESPACE} { return T_NSEP; }
<NAMESTR>,{WHITESPACE}* { return T_SSEP; }
<NAMESTR,SECTION>,{WHITESPACE}* { return T_SSEP; }
/* Alias color to text-color */
<SECTION>"color" { yylval->sval = g_strdup("text-color"); return T_PROP_NAME;}
<SECTION>{WORD} { yylval->sval = g_strdup(yytext); return T_PROP_NAME;}
@ -820,7 +820,6 @@ if ( queue == NULL ) {
}
<SECTION>. {
yytext[yyleng-1] = '\0';
fprintf(stderr,"section found: |%s|\n", yytext);
return T_ERROR_SECTION;
}
<PROPERTIES_ARRAY,PROPERTIES_VAR>{WORD_ELEMENT} {

View file

@ -278,6 +278,7 @@ static ThemeColor hwb_to_rgb ( double h, double w, double b )
%type <theme> t_entry_list
%type <theme> t_entry_list_included
%type <list> t_entry_name_path
%type <list> t_property_name_list
%type <list> t_entry_name_path_selectors
%type <list> t_color_list
%type <property> t_property
@ -459,16 +460,19 @@ t_config_property
// We don't keep any reference to this after this point, so the property can be free'ed.
rofi_theme_property_free ( $1 );
}
| t_property_name T_BOPEN t_property_list_optional T_BCLOSE
| t_property_name_list T_BOPEN t_property_list_optional T_BCLOSE
{
for ( GList *iter = g_list_first( $1) ; iter; iter = g_list_next(iter)){
ThemeWidget *widget = rofi_configuration;
widget = rofi_theme_find_or_create_name ( widget, $1 );
widget = rofi_theme_find_or_create_name ( widget, iter->data );
widget->set = TRUE;
rofi_theme_widget_add_properties ( widget, $3);
}
if ( $3 ) {
g_hash_table_destroy ( $3 );
}
g_free ( $1 );
g_list_free_full ( $1, g_free );
}
;
@ -1049,5 +1053,11 @@ T_NAME_ELEMENT { $$ = g_list_append ( NULL, $1 );}
| t_entry_name_path T_NSEP { $$ = $1; }
;
t_property_name_list:
t_property_name { $$ = g_list_append ( NULL, $1 );}
| t_property_name_list T_SSEP t_property_name { $$ = g_list_append ( $1, $3);}
;
%%

View file

@ -83,18 +83,19 @@ cairo_surface_t *mode_get_icon(Mode *mode, unsigned int selected_line,
}
}
if (mode->fallback_icon_not_found == TRUE) {
return NULL;
}
if (mode->fallback_icon_fetch_uid > 0) {
cairo_surface_t *icon = rofi_icon_fetcher_get(mode->fallback_icon_fetch_uid);
cairo_surface_t *icon =
rofi_icon_fetcher_get(mode->fallback_icon_fetch_uid);
return icon;
}
ThemeWidget *wid = rofi_config_find_widget(mode->name, NULL, TRUE);
if (wid) {
/** Load user entires */
Property *p = rofi_theme_find_property(wid, P_STRING, "fallback-icon", TRUE);
Property *p =
rofi_theme_find_property(wid, P_STRING, "fallback-icon", TRUE);
if (p != NULL && (p->type == P_STRING && p->value.s)) {
mode->fallback_icon_fetch_uid =
rofi_icon_fetcher_query(p->value.s, height);

View file

@ -213,10 +213,6 @@ struct _DRunModePrivateData {
char *old_completer_input;
uint32_t selected_line;
char *old_input;
/** fallback icon */
uint32_t fallback_icon_fetch_uid;
cairo_surface_t *fallback_icon;
};
struct RegexEvalArg {
@ -1331,17 +1327,6 @@ static char *_get_display_value(const Mode *sw, unsigned int selected_line,
return retv;
}
static cairo_surface_t *fallback_icon(DRunModePrivateData *pd, int height) {
if (config.application_fallback_icon) {
// FALLBACK
if (pd->fallback_icon_fetch_uid > 0) {
return rofi_icon_fetcher_get(pd->fallback_icon_fetch_uid);
}
pd->fallback_icon_fetch_uid =
rofi_icon_fetcher_query(config.application_fallback_icon, height);
}
return NULL;
}
static cairo_surface_t *_get_icon(const Mode *sw, unsigned int selected_line,
int height) {
DRunModePrivateData *pd = (DRunModePrivateData *)mode_get_private_data(sw);
@ -1353,18 +1338,13 @@ static cairo_surface_t *_get_icon(const Mode *sw, unsigned int selected_line,
if (dr->icon_name != NULL) {
if (dr->icon_fetch_uid > 0) {
cairo_surface_t *icon = rofi_icon_fetcher_get(dr->icon_fetch_uid);
if (icon) {
return icon;
}
return fallback_icon(pd, height);
}
dr->icon_fetch_uid = rofi_icon_fetcher_query(dr->icon_name, height);
cairo_surface_t *icon = rofi_icon_fetcher_get(dr->icon_fetch_uid);
if (icon) {
return icon;
}
}
return fallback_icon(pd, height);
return NULL;
}
static char *drun_get_completion(const Mode *sw, unsigned int index) {

View file

@ -46,10 +46,10 @@
#include <sys/types.h>
#include <unistd.h>
#include "modes/filebrowser.h"
#include "modes/run.h"
#include "helper.h"
#include "history.h"
#include "modes/filebrowser.h"
#include "modes/run.h"
#include "rofi.h"
#include "settings.h"
@ -85,9 +85,6 @@ typedef struct {
Mode *completer;
char *old_completer_input;
/** fallback icon */
uint32_t fallback_icon_fetch_uid;
cairo_surface_t *fallback_icon;
} RunModePrivateData;
/**
@ -531,17 +528,6 @@ static char *run_get_message(const Mode *sw) {
}
return NULL;
}
static cairo_surface_t *fallback_icon(RunModePrivateData *pd, int height) {
if (config.application_fallback_icon) {
// FALLBACK
if (pd->fallback_icon_fetch_uid > 0) {
return rofi_icon_fetcher_get(pd->fallback_icon_fetch_uid);
}
pd->fallback_icon_fetch_uid =
rofi_icon_fetcher_query(config.application_fallback_icon, height);
}
return NULL;
}
static cairo_surface_t *_get_icon(const Mode *sw, unsigned int selected_line,
int height) {
RunModePrivateData *pd = (RunModePrivateData *)mode_get_private_data(sw);
@ -553,22 +539,17 @@ static cairo_surface_t *_get_icon(const Mode *sw, unsigned int selected_line,
if (dr->icon_fetch_uid > 0) {
cairo_surface_t *icon = rofi_icon_fetcher_get(dr->icon_fetch_uid);
if (icon) {
return icon;
}
return fallback_icon(pd, height);
}
/** lookup icon */
char **str = g_strsplit(dr->entry, " ", 2);
if (str) {
dr->icon_fetch_uid = rofi_icon_fetcher_query(str[0], height);
g_strfreev(str);
cairo_surface_t *icon = rofi_icon_fetcher_get(dr->icon_fetch_uid);
if (icon) {
return icon;
}
}
return fallback_icon(pd, height);
return NULL;
}
#include "mode-private.h"