public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] gconfig: avoid use of hard coded colors for rows
@ 2020-11-23 21:33 Ebrahim Byagowi
  2020-11-23 21:51 ` Ebrahim Byagowi
  0 siblings, 1 reply; 3+ messages in thread
From: Ebrahim Byagowi @ 2020-11-23 21:33 UTC (permalink / raw)
  To: Masahiro Yamada, linux-kbuild, linux-kernel

This makes the tool to avoids use of hard coded colors for
options rows by using theme provided theme provided colors
to fix issue of rows being not readable when system theme
is set to a dark theme.

Signed-off-by: Ebrahim Byagowi <ebrahim@gnu.org>
---
 scripts/kconfig/gconf.c | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/scripts/kconfig/gconf.c b/scripts/kconfig/gconf.c
index 5527482c3..b96570c28 100644
--- a/scripts/kconfig/gconf.c
+++ b/scripts/kconfig/gconf.c
@@ -49,6 +49,8 @@ GtkWidget *back_btn = NULL;
 GtkWidget *save_btn = NULL;
 GtkWidget *save_menu_item = NULL;
 
+GtkStyle *style;
+
 GtkTextTag *tag1, *tag2;
 GdkColor color;
 
@@ -109,7 +111,7 @@ static const char *dbg_sym_flags(int val)
 #endif
 
 static void replace_button_icon(GladeXML *xml, GdkDrawable *window,
-				GtkStyle *style, gchar *btn_name, gchar **xpm)
+				gchar *btn_name, gchar **xpm)
 {
 	GdkPixmap *pixmap;
 	GdkBitmap *mask;
@@ -132,7 +134,6 @@ static void init_main_window(const gchar *glade_file)
 	GladeXML *xml;
 	GtkWidget *widget;
 	GtkTextBuffer *txtbuf;
-	GtkStyle *style;
 
 	xml = glade_xml_new(glade_file, "window1", NULL);
 	if (!xml)
@@ -168,11 +169,11 @@ static void init_main_window(const gchar *glade_file)
 	style = gtk_widget_get_style(main_wnd);
 	widget = glade_xml_get_widget(xml, "toolbar1");
 
-	replace_button_icon(xml, main_wnd->window, style,
+	replace_button_icon(xml, main_wnd->window,
 			    "button4", (gchar **) xpm_single_view);
-	replace_button_icon(xml, main_wnd->window, style,
+	replace_button_icon(xml, main_wnd->window,
 			    "button5", (gchar **) xpm_split_view);
-	replace_button_icon(xml, main_wnd->window, style,
+	replace_button_icon(xml, main_wnd->window,
 			    "button6", (gchar **) xpm_tree_view);
 
 	txtbuf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_w));
@@ -1052,13 +1053,15 @@ static gchar **fill_row(struct menu *menu)
 	    g_strdup_printf("%s %s", menu_get_prompt(menu),
 			    sym && !sym_has_value(sym) ? "(NEW)" : "");
 
+	GdkColor *color;
 	if (opt_mode == OPT_ALL && !menu_is_visible(menu))
-		row[COL_COLOR] = g_strdup("DarkGray");
+		color = &style->text[GTK_STATE_INSENSITIVE];
 	else if (opt_mode == OPT_PROMPT &&
 			menu_has_prompt(menu) && !menu_is_visible(menu))
-		row[COL_COLOR] = g_strdup("DarkGray");
+		color = &style->text[GTK_STATE_INSENSITIVE];
 	else
-		row[COL_COLOR] = g_strdup("Black");
+		color = &style->text[GTK_STATE_NORMAL];
+	row[COL_COLOR] = gdk_color_to_string(color);
 
 	ptype = menu->prompt ? menu->prompt->type : P_UNKNOWN;
 	switch (ptype) {
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] gconfig: avoid use of hard coded colors for rows
  2020-11-23 21:33 [PATCH] gconfig: avoid use of hard coded colors for rows Ebrahim Byagowi
@ 2020-11-23 21:51 ` Ebrahim Byagowi
  2020-12-02  1:02   ` Randy Dunlap
  0 siblings, 1 reply; 3+ messages in thread
From: Ebrahim Byagowi @ 2020-11-23 21:51 UTC (permalink / raw)
  To: Masahiro Yamada, linux-kbuild, linux-kernel

Not an important thing of course just that I was unable to
use gconfig on my system with a theme dark is set like [1]
and this turns it into [2] without noticable change to the
light theme.

I had hit this minor issue also in the past but decided to
fix it this time.

This isn't the best possible approach as now we have we have
a GdkColor -> gchar * -> GdkColor round trip, yet wanted to
keep the change small and maybe go for a larger change later
if it worths it.

Hope you find it useful also.

  [1]: https://i.imgur.com/MJfIkup.png
  [2]: https://i.imgur.com/lgvod9V.png

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] gconfig: avoid use of hard coded colors for rows
  2020-11-23 21:51 ` Ebrahim Byagowi
@ 2020-12-02  1:02   ` Randy Dunlap
  0 siblings, 0 replies; 3+ messages in thread
From: Randy Dunlap @ 2020-12-02  1:02 UTC (permalink / raw)
  To: Ebrahim Byagowi, Masahiro Yamada, linux-kbuild, linux-kernel

On 11/23/20 1:51 PM, Ebrahim Byagowi wrote:
> Not an important thing of course just that I was unable to
> use gconfig on my system with a theme dark is set like [1]
> and this turns it into [2] without noticable change to the
> light theme.
> 
> I had hit this minor issue also in the past but decided to
> fix it this time.
> 
> This isn't the best possible approach as now we have we have
> a GdkColor -> gchar * -> GdkColor round trip, yet wanted to
> keep the change small and maybe go for a larger change later
> if it worths it.
> 
> Hope you find it useful also.
> 
>   [1]: https://i.imgur.com/MJfIkup.png
>   [2]: https://i.imgur.com/lgvod9V.png

Hi,

AFAIK, this makes one known gconfig user.
I was hoping that we could remove it...


-- 
~Randy


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-12-02  1:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-11-23 21:33 [PATCH] gconfig: avoid use of hard coded colors for rows Ebrahim Byagowi
2020-11-23 21:51 ` Ebrahim Byagowi
2020-12-02  1:02   ` Randy Dunlap

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox