mirror of
https://github.com/davatorium/rofi.git
synced 2024-11-18 13:54:36 -05:00
[Helper] Remove fixed key/values and accept keys with NULL as values.
This commit is contained in:
parent
e8edc42f9d
commit
f80e7d52bc
2 changed files with 10 additions and 12 deletions
|
@ -1287,9 +1287,6 @@ char *helper_string_replace_if_exists ( char * string, ... )
|
|||
GError *error = NULL;
|
||||
GHashTable *h;
|
||||
h = g_hash_table_new ( g_str_hash, g_str_equal );
|
||||
// By default, we insert terminal and ssh-client
|
||||
g_hash_table_insert ( h, "{terminal}", config.terminal_emulator );
|
||||
g_hash_table_insert ( h, "{ssh-client}", config.ssh_client );
|
||||
// Add list from variable arguments.
|
||||
va_list ap;
|
||||
va_start ( ap, string );
|
||||
|
@ -1299,9 +1296,6 @@ char *helper_string_replace_if_exists ( char * string, ... )
|
|||
break;
|
||||
}
|
||||
char *value = va_arg ( ap, char * );
|
||||
if ( value == (char *) 0 ) {
|
||||
break;
|
||||
}
|
||||
g_hash_table_insert ( h, key, value );
|
||||
}
|
||||
va_end ( ap );
|
||||
|
|
|
@ -159,26 +159,30 @@ int main ( int argc, char ** argv )
|
|||
|
||||
|
||||
char *a;
|
||||
a = helper_string_replace_if_exists ( "{terminal} [-t {title} blub ]-e {cmd}", "{cmd}", "aap", "{title}", "some title", NULL);
|
||||
a = helper_string_replace_if_exists ( "{terminal} [-t {title} blub ]-e {cmd}", "{cmd}", "aap", "{title}", "some title", "{terminal}", "rofi-sensible-terminal", NULL);
|
||||
printf("%s\n",a);
|
||||
TASSERT ( g_utf8_collate ( a, "rofi-sensible-terminal -t some title blub -e aap") == 0);
|
||||
g_free(a);
|
||||
a = helper_string_replace_if_exists ( "{terminal} [-t {title} blub ]-e {cmd}", "{cmd}", "aap", NULL);
|
||||
a = helper_string_replace_if_exists ( "{terminal} [-t {title} blub ]-e {cmd}", "{cmd}", "aap", "{terminal}", "rofi-sensible-terminal", NULL);
|
||||
printf("%s\n",a);
|
||||
TASSERT ( g_utf8_collate ( a, "rofi-sensible-terminal -e aap") == 0);
|
||||
g_free(a);
|
||||
a = helper_string_replace_if_exists ( "{name} [<span weight='light' size='small'><i>({category})</i></span>]", "{name}", "Librecad", "{category}", "Desktop app", NULL );
|
||||
a = helper_string_replace_if_exists ( "{name} [<span weight='light' size='small'><i>({category})</i></span>]", "{name}", "Librecad", "{category}", "Desktop app", "{terminal}", "rofi-sensible-terminal", NULL );
|
||||
printf("%s\n",a);
|
||||
TASSERT ( g_utf8_collate ( a, "Librecad <span weight='light' size='small'><i>(Desktop app)</i></span>") == 0);
|
||||
g_free(a);
|
||||
a = helper_string_replace_if_exists ( "{name}[ <span weight='light' size='small'><i>({category})</i></span>]", "{name}", "Librecad", NULL );
|
||||
a = helper_string_replace_if_exists ( "{name}[ <span weight='light' size='small'><i>({category})</i></span>]", "{name}", "Librecad", "{terminal}", "rofi-sensible-terminal", NULL );
|
||||
TASSERT ( g_utf8_collate ( a, "Librecad") == 0);
|
||||
g_free(a);
|
||||
a = helper_string_replace_if_exists ( "{terminal} [{title} blub ]-e {cmd}", "{cmd}", "aap", "{title}", "some title", NULL);
|
||||
a = helper_string_replace_if_exists ( "{terminal} [{title} blub ]-e {cmd}", "{cmd}", "aap", "{title}", "some title", "{terminal}", "rofi-sensible-terminal", NULL);
|
||||
printf("%s\n",a);
|
||||
TASSERT ( g_utf8_collate ( a, "rofi-sensible-terminal some title blub -e aap") == 0);
|
||||
g_free(a);
|
||||
a = helper_string_replace_if_exists ( "{terminal} [{title} blub ]-e {cmd}", "{cmd}", "aap", "{title}", NULL, NULL);
|
||||
a = helper_string_replace_if_exists ( "{terminal} [{title} blub ]-e {cmd}",
|
||||
"{cmd}", "aap",
|
||||
"{title}", NULL,
|
||||
"{terminal}", "rofi-sensible-terminal",
|
||||
NULL);
|
||||
printf("%s\n",a);
|
||||
TASSERT ( g_utf8_collate ( a, "rofi-sensible-terminal -e aap") == 0);
|
||||
g_free(a);
|
||||
|
|
Loading…
Reference in a new issue