mirror of
https://github.com/davatorium/rofi.git
synced 2024-11-18 13:54:36 -05:00
[DRun] Add keywords to match and printing.
This commit is contained in:
parent
ad74da45d1
commit
aa35ecc40a
6 changed files with 34 additions and 3 deletions
|
@ -117,7 +117,7 @@ Settings config = {
|
|||
.matching = "normal",
|
||||
.matching_method = MM_NORMAL,
|
||||
/** Desktop entry fields to match*/
|
||||
.drun_match_fields = "name,generic,exec,categories",
|
||||
.drun_match_fields = "name,generic,exec,categories,keywords",
|
||||
.drun_categories = NULL,
|
||||
/** Desktop format display */
|
||||
.drun_display_format = "{name} [<span weight='light' size='small'><i>({generic})</i></span>]",
|
||||
|
|
|
@ -79,6 +79,7 @@ element-text {
|
|||
element-icon {
|
||||
background-color: rgba ( 0, 0, 0, 0 % );
|
||||
text-color: inherit;
|
||||
size: 1.2ch;
|
||||
}
|
||||
window {
|
||||
background-color: var(background);
|
||||
|
|
|
@ -27,6 +27,7 @@ DMENU command line options:
|
|||
-u [list] List of row indexes to mark urgent
|
||||
-a [list] List of row indexes to mark active
|
||||
-l [integer] Number of rows to display
|
||||
-window-title [string] Set the dmenu window title
|
||||
-i Set filter to be case insensitive
|
||||
-only-match Force selection or custom entry
|
||||
-no-custom Don't accept custom entry
|
||||
|
|
|
@ -41,7 +41,7 @@ rofi.window-command: xkill -id {window}
|
|||
! "Theme to use to look for icons" Set from: Default
|
||||
! rofi.icon-theme:
|
||||
! "Desktop entry fields to match in drun" Set from: Default
|
||||
! rofi.drun-match-fields: name,generic,exec,categories
|
||||
! rofi.drun-match-fields: name,generic,exec,categories,keywords
|
||||
! "Only show Desktop entry from these categories" Set from: Default
|
||||
! rofi.drun-categories:
|
||||
! "Desktop entry show actions." Set from: Default
|
||||
|
|
|
@ -94,6 +94,8 @@ typedef struct
|
|||
char *generic_name;
|
||||
/* Categories */
|
||||
char **categories;
|
||||
/* Keywords */
|
||||
char **keywords;
|
||||
/* Comments */
|
||||
char *comment;
|
||||
|
||||
|
@ -116,6 +118,7 @@ typedef enum
|
|||
DRUN_MATCH_FIELD_GENERIC,
|
||||
DRUN_MATCH_FIELD_EXEC,
|
||||
DRUN_MATCH_FIELD_CATEGORIES,
|
||||
DRUN_MATCH_FIELD_KEYWORDS,
|
||||
DRUN_MATCH_FIELD_COMMENT,
|
||||
DRUN_MATCH_NUM_FIELDS,
|
||||
} DRunMatchingFields;
|
||||
|
@ -125,6 +128,7 @@ static DRunEntryField matching_entry_fields[DRUN_MATCH_NUM_FIELDS] = {
|
|||
{ .entry_field_name = "generic", .enabled = TRUE, },
|
||||
{ .entry_field_name = "exec", .enabled = TRUE, },
|
||||
{ .entry_field_name = "categories", .enabled = TRUE, },
|
||||
{ .entry_field_name = "keywords", .enabled = TRUE, },
|
||||
{ .entry_field_name = "comment", .enabled = FALSE, }
|
||||
};
|
||||
|
||||
|
@ -455,6 +459,13 @@ static void read_desktop_file ( DRunModePrivateData *pd, const char *root, const
|
|||
pd->entry_list[pd->cmd_list_length].action = DRUN_GROUP_NAME;
|
||||
gchar *gn = g_key_file_get_locale_string ( kf, DRUN_GROUP_NAME, "GenericName", NULL, NULL );
|
||||
pd->entry_list[pd->cmd_list_length].generic_name = gn;
|
||||
|
||||
if ( matching_entry_fields[DRUN_MATCH_FIELD_KEYWORDS].enabled ) {
|
||||
pd->entry_list[pd->cmd_list_length].keywords = g_key_file_get_locale_string_list ( kf, DRUN_GROUP_NAME, "Keywords", NULL, NULL, NULL );
|
||||
} else {
|
||||
pd->entry_list[pd->cmd_list_length].keywords = NULL;
|
||||
}
|
||||
|
||||
if ( matching_entry_fields[DRUN_MATCH_FIELD_CATEGORIES].enabled ) {
|
||||
if ( categories ) {
|
||||
pd->entry_list[pd->cmd_list_length].categories = categories;
|
||||
|
@ -727,6 +738,7 @@ static void drun_entry_clear ( DRunModeEntry *e )
|
|||
g_free ( e->action );
|
||||
}
|
||||
g_strfreev ( e->categories );
|
||||
g_strfreev ( e->keywords );
|
||||
g_key_file_free ( e->key_file );
|
||||
}
|
||||
|
||||
|
@ -801,6 +813,14 @@ static char *_get_display_value ( const Mode *sw, unsigned int selected_line, in
|
|||
g_free (tcats);
|
||||
}
|
||||
}
|
||||
gchar *keywords= NULL;
|
||||
if ( dr->keywords ){
|
||||
char *tkeyw= g_strjoinv(",", dr->keywords);
|
||||
if ( tkeyw ) {
|
||||
keywords = g_markup_escape_text ( tkeyw, -1 );
|
||||
g_free (tkeyw);
|
||||
}
|
||||
}
|
||||
// Needed for display.
|
||||
char *egn = NULL;
|
||||
char *en = NULL;
|
||||
|
@ -822,6 +842,7 @@ static char *_get_display_value ( const Mode *sw, unsigned int selected_line, in
|
|||
"{comment}", ec,
|
||||
"{exec}", dr->exec,
|
||||
"{categories}", cats,
|
||||
"{keywords}", keywords,
|
||||
NULL);
|
||||
g_free ( egn );
|
||||
g_free ( en );
|
||||
|
@ -893,6 +914,15 @@ static int drun_token_match ( const Mode *data, rofi_int_matcher **tokens, unsig
|
|||
}
|
||||
}
|
||||
}
|
||||
if ( matching_entry_fields[DRUN_MATCH_FIELD_KEYWORDS].enabled ) {
|
||||
// Match against category.
|
||||
if ( test == tokens[j]->invert ) {
|
||||
gchar **list = rmpd->entry_list[index].keywords;
|
||||
for ( int iter = 0; test == tokens[j]->invert && list && list[iter]; iter++ ) {
|
||||
test = helper_token_match ( ftokens, list[iter] );
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( matching_entry_fields[DRUN_MATCH_FIELD_COMMENT].enabled ) {
|
||||
// Match executable name.
|
||||
if ( test == tokens[j]->invert && rmpd->entry_list[index].comment ) {
|
||||
|
|
|
@ -13,7 +13,6 @@ tests=(
|
|||
run_dmenu_issue_292
|
||||
run_screenshot_test
|
||||
xr_dump_test
|
||||
run_drun_test
|
||||
run_combi_test
|
||||
run_regex_test
|
||||
run_glob_test
|
||||
|
|
Loading…
Reference in a new issue