From 4ac428bace65c0856c1b8914c20f551fe8bf3c9d Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Tue, 7 Nov 2017 20:03:42 +0100 Subject: [PATCH] [Combi] Add hide prefix option. --- config/config.c | 1 + doc/test_xr.txt | 2 ++ include/settings.h | 1 + source/dialogs/combi.c | 9 ++++++--- source/xrmoptions.c | 2 ++ 5 files changed, 12 insertions(+), 3 deletions(-) diff --git a/config/config.c b/config/config.c index 7c43abf9..61833b23 100644 --- a/config/config.c +++ b/config/config.c @@ -146,4 +146,5 @@ Settings config = { .color_window = NULL, .plugin_path = PLUGIN_PATH, .max_history_size = 25, + .combi_hide_mode_prefix = FALSE, }; diff --git a/doc/test_xr.txt b/doc/test_xr.txt index 14a3ebd5..a3d1534f 100644 --- a/doc/test_xr.txt +++ b/doc/test_xr.txt @@ -112,6 +112,8 @@ rofi.scroll-method: 0 ! rofi.color-window: ! "Max history size (WARNING: can cause slowdowns when set to high)." Set from: Default ! rofi.max-history-size: 25 +! "Hide the prefix mode prefix on the combi view." Set from: Default +! rofi.combi-hide-mode-prefix: false ! "Pidfile location" Set from: File rofi.pid: /tmp/rofi.pid ! "Paste primary selection" Set from: File diff --git a/include/settings.h b/include/settings.h index cbd0f2d4..6361b969 100644 --- a/include/settings.h +++ b/include/settings.h @@ -164,6 +164,7 @@ typedef struct /** Maximum history length per mode. */ unsigned int max_history_size; + gboolean combi_hide_mode_prefix; } Settings; /** Global Settings structure. */ extern Settings config; diff --git a/source/dialogs/combi.c b/source/dialogs/combi.c index 077527e2..6e34d422 100644 --- a/source/dialogs/combi.c +++ b/source/dialogs/combi.c @@ -214,10 +214,13 @@ 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].mode, selected_line - pd->starts[i], state, attr_list, TRUE ); + char * retv; + char * str = retv = mode_get_display_value ( pd->switchers[i].mode, selected_line - pd->starts[i], state, attr_list, TRUE ); const char *dname = mode_get_display_name ( pd->switchers[i].mode ); - char * retv = g_strdup_printf ( "%s %s", dname, str ); - g_free ( str ); + if ( !config.combi_hide_mode_prefix ) { + retv = g_strdup_printf ( "%s %s", dname, str ); + g_free ( str ); + } if ( attr_list != NULL ) { ThemeWidget *wid = rofi_theme_find_widget ( sw->name, NULL, TRUE ); diff --git a/source/xrmoptions.c b/source/xrmoptions.c index 9491db9e..62b89a6e 100644 --- a/source/xrmoptions.c +++ b/source/xrmoptions.c @@ -208,6 +208,8 @@ static XrmOption xrmOptions[] = { "Color scheme window", CONFIG_DEFAULT }, { xrm_Number, "max-history-size", { .num = &config.max_history_size }, NULL, "Max history size (WARNING: can cause slowdowns when set to high).", CONFIG_DEFAULT }, + { xrm_Boolean, "combi-hide-mode-prefix", { .snum = &config.combi_hide_mode_prefix }, NULL, + "Hide the prefix mode prefix on the combi view.", CONFIG_DEFAULT }, }; /** Dynamic array of extra options */