summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Davenport <qball@blame.services>2022-05-12 19:52:35 +0200
committerDave Davenport <qball@blame.services>2022-05-12 19:52:35 +0200
commit141bd3d197c405c0cabd7b6d76b8105ffd514094 (patch)
tree0923e659fb504a70eb8394786e7167da72ae8756
parentfc6426534351fdcb0fa15d7d5f5aa17f29726c65 (diff)
[Doc][Config] Update documentation for new fallback icon
* Allow multiple config be combined.
-rw-r--r--doc/rofi.140
-rw-r--r--doc/rofi.1.markdown25
-rw-r--r--lexer/theme-lexer.l3
-rw-r--r--lexer/theme-parser.y22
-rw-r--r--source/mode.c23
-rw-r--r--source/modes/drun.c26
-rw-r--r--source/modes/run.c29
7 files changed, 91 insertions, 77 deletions
diff --git a/doc/rofi.1 b/doc/rofi.1
index ecdea8e1..41e85690 100644
--- a/doc/rofi.1
+++ b/doc/rofi.1
@@ -432,12 +432,6 @@ If not specified default theme from DE is used, \fIAdwaita\fP and \fIgnome\fP th
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
.PP
@@ -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
diff --git a/doc/rofi.1.markdown b/doc/rofi.1.markdown
index 5b7aa7d5..9d3ad7d8 100644
--- a/doc/rofi.1.markdown
+++ b/doc/rofi.1.markdown
@@ -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*
diff --git a/lexer/theme-lexer.l b/lexer/theme-lexer.l
index 1439bc51..416f1e84 100644
--- a/lexer/theme-lexer.l
+++ b/lexer/theme-lexer.l
@@ -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} {
diff --git a/lexer/theme-parser.y b/lexer/theme-parser.y
index 33323dcd..8f1721e4 100644
--- a/lexer/theme-parser.y
+++ b/lexer/theme-parser.y
@@ -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
{
- ThemeWidget *widget = rofi_configuration;
- widget = rofi_theme_find_or_create_name ( widget, $1 );
- widget->set = TRUE;
- rofi_theme_widget_add_properties ( widget, $3);
+
+ 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, 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);}
+;
+
+
%%
diff --git a/source/mode.c b/source/mode.c
index 3cb129aa..588f9718 100644
--- a/source/mode.c
+++ b/source/mode.c
@@ -78,28 +78,29 @@ cairo_surface_t *mode_get_icon(Mode *mode, unsigned int selected_line,
if (mode->_get_icon != NULL) {
cairo_surface_t *icon = mode->_get_icon(mode, selected_line, height);
- if ( icon ) {
+ if (icon) {
return icon;
}
}
-
- if ( mode->fallback_icon_not_found == TRUE) {
+ 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);
- if (p != NULL && (p->type == P_STRING && p->value.s)) {
- mode->fallback_icon_fetch_uid =
- rofi_icon_fetcher_query(p->value.s, height);
+ if (wid) {
+ /** Load user entires */
+ 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);
return NULL;
- }
+ }
}
mode->fallback_icon_not_found = TRUE;
return NULL;
diff --git a/source/modes/drun.c b/source/modes/drun.c
index 8d4278e8..fc07bdeb 100644
--- a/source/modes/drun.c
+++ b/source/modes/drun.c
@@ -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);
+ return icon;
}
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 icon;
}
- return fallback_icon(pd, height);
+ return NULL;
}
static char *drun_get_completion(const Mode *sw, unsigned int index) {
diff --git a/source/modes/run.c b/source/modes/run.c
index 47a9634e..3cc4d838 100644
--- a/source/modes/run.c
+++ b/source/modes/run.c
@@ -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,10 +539,7 @@ 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);
+ return icon;
}
/** lookup icon */
char **str = g_strsplit(dr->entry, " ", 2);
@@ -564,11 +547,9 @@ static cairo_surface_t *_get_icon(const Mode *sw, unsigned int selected_line,
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 icon;
}
- return fallback_icon(pd, height);
+ return NULL;
}
#include "mode-private.h"