mirror of
https://github.com/davatorium/rofi.git
synced 2024-11-25 13:55:34 -05:00
Update display value for modi (testing)
This commit is contained in:
parent
95dbbf6616
commit
cc682f107b
10 changed files with 39 additions and 1 deletions
|
@ -38,6 +38,8 @@ struct _Mode
|
|||
{
|
||||
/** Name (max 31 char long) */
|
||||
char name[32];
|
||||
char cfg_name_key[128];
|
||||
char *display_name;
|
||||
/** Keybindings (keysym and modmask) */
|
||||
char * keycfg;
|
||||
char * keystr;
|
||||
|
|
|
@ -206,5 +206,9 @@ void *mode_get_private_data ( const Mode *mode );
|
|||
* Set the private data object.
|
||||
*/
|
||||
void mode_set_private_data ( Mode *mode, void *pd );
|
||||
|
||||
const char *mode_get_display_name ( const Mode *mode );
|
||||
|
||||
void mode_set_config ( Mode *mode );
|
||||
/*@}*/
|
||||
#endif
|
||||
|
|
|
@ -222,7 +222,7 @@ static char * combi_mgrv ( const Mode *sw, unsigned int selected_line, int *stat
|
|||
for ( unsigned i = 0; i < pd->num_switchers; i++ ) {
|
||||
if ( selected_line >= pd->starts[i] && selected_line < ( pd->starts[i] + pd->lengths[i] ) ) {
|
||||
char * str = mode_get_display_value ( pd->switchers[i], selected_line - pd->starts[i], state, TRUE );
|
||||
char * retv = g_strdup_printf ( "(%s) %s", mode_get_name ( pd->switchers[i] ), str );
|
||||
char * retv = g_strdup_printf ( "%s %s", mode_get_display_name ( pd->switchers[i] ), str );
|
||||
g_free ( str );
|
||||
return retv;
|
||||
}
|
||||
|
@ -257,6 +257,7 @@ static char * combi_get_completion ( const Mode *sw, unsigned int index )
|
|||
Mode combi_mode =
|
||||
{
|
||||
.name = "combi",
|
||||
.cfg_name_key = "display-combi",
|
||||
.keycfg = NULL,
|
||||
.keystr = NULL,
|
||||
.modmask = AnyModifier,
|
||||
|
|
|
@ -330,6 +330,7 @@ static int dmenu_is_not_ascii ( const Mode *sw, unsigned int index )
|
|||
Mode dmenu_mode =
|
||||
{
|
||||
.name = "dmenu",
|
||||
.cfg_name_key = "display-combi",
|
||||
.keycfg = NULL,
|
||||
.keystr = NULL,
|
||||
.modmask = AnyModifier,
|
||||
|
|
|
@ -363,6 +363,7 @@ static int drun_is_not_ascii ( const Mode *sw, unsigned int index )
|
|||
Mode drun_mode =
|
||||
{
|
||||
.name = "drun",
|
||||
.cfg_name_key = "display-drun",
|
||||
.keycfg = NULL,
|
||||
.keystr = NULL,
|
||||
.modmask = AnyModifier,
|
||||
|
|
|
@ -386,6 +386,7 @@ static int run_is_not_ascii ( const Mode *sw, unsigned int index )
|
|||
Mode run_mode =
|
||||
{
|
||||
.name = "run",
|
||||
.cfg_name_key = "display-run",
|
||||
.keycfg = NULL,
|
||||
.keystr = NULL,
|
||||
.modmask = AnyModifier,
|
||||
|
|
|
@ -492,6 +492,7 @@ static int ssh_is_not_ascii ( const Mode *sw, unsigned int index )
|
|||
Mode ssh_mode =
|
||||
{
|
||||
.name = "ssh",
|
||||
.cfg_name_key = "display-ssh",
|
||||
.keycfg = NULL,
|
||||
.keystr = NULL,
|
||||
.modmask = AnyModifier,
|
||||
|
|
|
@ -591,6 +591,7 @@ static int window_is_not_ascii ( const Mode *sw, unsigned int index )
|
|||
Mode window_mode =
|
||||
{
|
||||
.name = "window",
|
||||
.cfg_name_key = "display-window",
|
||||
.keycfg = NULL,
|
||||
.keystr = NULL,
|
||||
.modmask = AnyModifier,
|
||||
|
@ -608,6 +609,7 @@ Mode window_mode =
|
|||
Mode window_mode_cd =
|
||||
{
|
||||
.name = "windowcd",
|
||||
.cfg_name_key = "display-windowcd",
|
||||
.keycfg = NULL,
|
||||
.keystr = NULL,
|
||||
.modmask = AnyModifier,
|
||||
|
|
|
@ -165,4 +165,19 @@ void mode_set_private_data ( Mode *mode, void *pd )
|
|||
}
|
||||
mode->private_data = pd;
|
||||
}
|
||||
|
||||
const char *mode_get_display_name ( const Mode *mode )
|
||||
{
|
||||
if ( mode->display_name != NULL ) {
|
||||
return mode->display_name;
|
||||
}
|
||||
return mode->name;
|
||||
}
|
||||
|
||||
void mode_set_config ( Mode *mode )
|
||||
{
|
||||
snprintf ( mode->cfg_name_key, 128, "display-%s", mode->name );
|
||||
mode->display_name = g_strdup_printf ( "(%s)", mode->name );
|
||||
config_parser_add_option ( xrm_String, mode->cfg_name_key, (void * *) &( mode->display_name ), "The display name of this browser" );
|
||||
}
|
||||
/*@}*/
|
||||
|
|
|
@ -2056,6 +2056,7 @@ static void setup_modi ( void )
|
|||
Mode *sw = script_switcher_parse_setup ( token );
|
||||
if ( sw != NULL ) {
|
||||
modi[num_modi].sw = sw;
|
||||
mode_set_config ( sw );
|
||||
num_modi++;
|
||||
}
|
||||
else{
|
||||
|
@ -2073,6 +2074,15 @@ static void setup_modi ( void )
|
|||
for ( unsigned int i = 0; i < num_modi; i++ ) {
|
||||
mode_setup_keybinding ( modi[i].sw );
|
||||
}
|
||||
mode_set_config ( &ssh_mode );
|
||||
mode_set_config ( &run_mode );
|
||||
mode_set_config ( &drun_mode );
|
||||
|
||||
#ifdef WINDOW_MODE
|
||||
mode_set_config ( &window_mode );
|
||||
mode_set_config ( &window_mode_cd );
|
||||
#endif // WINDOW_MODE
|
||||
mode_set_config ( &combi_mode );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue