summaryrefslogtreecommitdiffstats
path: root/source/dialogs
diff options
context:
space:
mode:
authorDave Davenport <DaveDavenport@users.noreply.github.com>2017-03-10 23:39:29 +0100
committerGitHub <noreply@github.com>2017-03-10 23:39:29 +0100
commitcee753bd3cc2f96743e8771d0cd82beee32fcd2e (patch)
tree63d492fcd35830758e9009093d249878b69a20be /source/dialogs
parent25678d7a59ba7419a2d3b018971d5539124cf750 (diff)
Zeltakmadness (#572)
* Allow modi to set extra pango attributes on displayed rows * Fix some documentation, only highlight the mode name with color. * Small rename.
Diffstat (limited to 'source/dialogs')
-rw-r--r--source/dialogs/combi.c27
-rw-r--r--source/dialogs/dmenu.c2
-rw-r--r--source/dialogs/drun.c2
-rw-r--r--source/dialogs/help-keys.c2
-rw-r--r--source/dialogs/run.c2
-rw-r--r--source/dialogs/script.c2
-rw-r--r--source/dialogs/ssh.c2
-rw-r--r--source/dialogs/window.c2
8 files changed, 29 insertions, 12 deletions
diff --git a/source/dialogs/combi.c b/source/dialogs/combi.c
index 3d408712..4da67f31 100644
--- a/source/dialogs/combi.c
+++ b/source/dialogs/combi.c
@@ -32,6 +32,9 @@
#include "helper.h"
#include <dialogs/dialogs.h>
+#include <pango/pango.h>
+#include "mode-private.h"
+#include <theme.h>
/**
* Combi Mode
@@ -187,13 +190,13 @@ static int combi_mode_match ( const Mode *sw, GRegex **tokens, unsigned int inde
}
return 0;
}
-static char * combi_mgrv ( const Mode *sw, unsigned int selected_line, int *state, int get_entry )
+static char * combi_mgrv ( const Mode *sw, unsigned int selected_line, int *state, GList **attr_list, int get_entry )
{
CombiModePrivateData *pd = mode_get_private_data ( sw );
if ( !get_entry ) {
for ( unsigned i = 0; i < pd->num_switchers; i++ ) {
if ( selected_line >= pd->starts[i] && selected_line < ( pd->starts[i] + pd->lengths[i] ) ) {
- mode_get_display_value ( pd->switchers[i].mode, selected_line - pd->starts[i], state, FALSE );
+ mode_get_display_value ( pd->switchers[i].mode, selected_line - pd->starts[i], state, attr_list, FALSE );
return NULL;
}
}
@@ -201,9 +204,24 @@ 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, TRUE );
- char * retv = g_strdup_printf ( "%s %s", mode_get_display_name ( pd->switchers[i].mode ), str );
+ char * str = 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 ( attr_list != NULL ) {
+ ThemeWidget *wid = rofi_theme_find_widget ( sw->name, NULL, TRUE);
+ Property *p = rofi_theme_find_property ( wid, P_COLOR, pd->switchers[i].mode->name, TRUE);
+ if ( p != NULL ) {
+ PangoAttribute *pa = pango_attr_foreground_new (
+ p->value.color.red * 65535,
+ p->value.color.green * 65535,
+ p->value.color.blue * 65535 );
+ pa->start_index = PANGO_ATTR_INDEX_FROM_TEXT_BEGINNING;
+ pa->end_index = strlen(dname);
+ *attr_list = g_list_append ( *attr_list, pa );
+ }
+ }
return retv;
}
}
@@ -253,7 +271,6 @@ static char * combi_preprocess_input ( Mode *sw, const char *input )
return g_strdup ( input );
}
-#include "mode-private.h"
Mode combi_mode =
{
.name = "combi",
diff --git a/source/dialogs/dmenu.c b/source/dialogs/dmenu.c
index 85bf850a..fecf4c6a 100644
--- a/source/dialogs/dmenu.c
+++ b/source/dialogs/dmenu.c
@@ -271,7 +271,7 @@ static gchar * dmenu_format_output_string ( const DmenuModePrivateData *pd, cons
return retv ? retv : g_strdup ( "" );
}
-static char *get_display_data ( const Mode *data, unsigned int index, int *state, int get_entry )
+static char *get_display_data ( const Mode *data, unsigned int index, int *state, G_GNUC_UNUSED GList **list, int get_entry )
{
Mode *sw = (Mode *) data;
DmenuModePrivateData *pd = (DmenuModePrivateData *) mode_get_private_data ( sw );
diff --git a/source/dialogs/drun.c b/source/dialogs/drun.c
index 03c842c2..1553efb4 100644
--- a/source/dialogs/drun.c
+++ b/source/dialogs/drun.c
@@ -460,7 +460,7 @@ static void drun_mode_destroy ( Mode *sw )
}
}
-static char *_get_display_value ( const Mode *sw, unsigned int selected_line, int *state, int get_entry )
+static char *_get_display_value ( const Mode *sw, unsigned int selected_line, int *state, G_GNUC_UNUSED GList **list, int get_entry )
{
DRunModePrivateData *pd = (DRunModePrivateData *) mode_get_private_data ( sw );
*state |= MARKUP;
diff --git a/source/dialogs/help-keys.c b/source/dialogs/help-keys.c
index 2e0a3101..a550f559 100644
--- a/source/dialogs/help-keys.c
+++ b/source/dialogs/help-keys.c
@@ -93,7 +93,7 @@ static void help_keys_mode_destroy ( Mode *sw )
}
}
-static char *_get_display_value ( const Mode *sw, unsigned int selected_line, int *state, int get_entry )
+static char *_get_display_value ( const Mode *sw, unsigned int selected_line, int *state, G_GNUC_UNUSED GList **list, int get_entry )
{
KeysHelpModePrivateData *pd = (KeysHelpModePrivateData *) mode_get_private_data ( sw );
*state |= MARKUP;
diff --git a/source/dialogs/run.c b/source/dialogs/run.c
index 96ddd352..816f0a41 100644
--- a/source/dialogs/run.c
+++ b/source/dialogs/run.c
@@ -390,7 +390,7 @@ static ModeMode run_mode_result ( Mode *sw, int mretv, char **input, unsigned in
return retv;
}
-static char *_get_display_value ( const Mode *sw, unsigned int selected_line, G_GNUC_UNUSED int *state, int get_entry )
+static char *_get_display_value ( const Mode *sw, unsigned int selected_line, G_GNUC_UNUSED int *state, G_GNUC_UNUSED GList **list, int get_entry )
{
const RunModePrivateData *rmpd = (const RunModePrivateData *) sw->private_data;
return get_entry ? g_strdup ( rmpd->cmd_list[selected_line] ) : NULL;
diff --git a/source/dialogs/script.c b/source/dialogs/script.c
index f653d719..72594a67 100644
--- a/source/dialogs/script.c
+++ b/source/dialogs/script.c
@@ -158,7 +158,7 @@ static void script_mode_destroy ( Mode *sw )
sw->private_data = NULL;
}
}
-static char *_get_display_value ( const Mode *sw, unsigned int selected_line, G_GNUC_UNUSED int *state, int get_entry )
+static char *_get_display_value ( const Mode *sw, unsigned int selected_line, G_GNUC_UNUSED int *state, G_GNUC_UNUSED GList **list, int get_entry )
{
ScriptModePrivateData *rmpd = sw->private_data;
return get_entry ? g_strdup ( rmpd->cmd_list[selected_line] ) : NULL;
diff --git a/source/dialogs/ssh.c b/source/dialogs/ssh.c
index c74f4000..6411b823 100644
--- a/source/dialogs/ssh.c
+++ b/source/dialogs/ssh.c
@@ -505,7 +505,7 @@ static void ssh_mode_destroy ( Mode *sw )
*
* @return the string as it should be displayed and the display state.
*/
-static char *_get_display_value ( const Mode *sw, unsigned int selected_line, G_GNUC_UNUSED int *state, int get_entry )
+static char *_get_display_value ( const Mode *sw, unsigned int selected_line, G_GNUC_UNUSED int *state, G_GNUC_UNUSED GList **list, int get_entry )
{
SSHModePrivateData *rmpd = (SSHModePrivateData *) mode_get_private_data ( sw );
return get_entry ? g_strdup ( rmpd->hosts_list[selected_line] ) : NULL;
diff --git a/source/dialogs/window.c b/source/dialogs/window.c
index 304b6a11..71cd70e0 100644
--- a/source/dialogs/window.c
+++ b/source/dialogs/window.c
@@ -709,7 +709,7 @@ static char * _generate_display_string ( const ModeModePrivateData *pd, client *
return g_strchomp ( res );
}
-static char *_get_display_value ( const Mode *sw, unsigned int selected_line, int *state, int get_entry )
+static char *_get_display_value ( const Mode *sw, unsigned int selected_line, int *state, G_GNUC_UNUSED GList **list, int get_entry )
{
ModeModePrivateData *rmpd = mode_get_private_data ( sw );
client *c = window_client ( rmpd, rmpd->ids->array[selected_line] );