On Sat, 14 Oct 2017 19:37:02 +0800
許永寬 <[email protected]> wrote:
> Thank to release IUP3.23!
>
> (1) Using new IUP3.23 on Linux mint 18.2, I change IupText FGCOLOR and
> BGCOLOR then the color of selectionr is gone, but it's OK on Windows
> 7.0 (2) Using IupFlatTabs insert a IupText as tabitem, it can be
> APPEND/INSERT/VALUE a text, but it can't key in a word and cursor
> and the color of selectionr is gone.( OK on Windows 7.0 )
>
> thanks~
Hello,
the problem (1) is not specific to IUP 3.23 only. It existed
before and affects other versions using Gtk driver too.
The issue is that IUP uses gtk_widget_override_background_color() for
setting background color. Unfortunately, the function has been
deprecated in Gtk 3.16. But what is more important and even worse, the
function doesn't work properly (depending on which Gtk theme is used).
Some references to the problem:
*
https://developer.gnome.org/gtk3/stable/GtkWidget.html#gtk-widget-override-background-color
* https://bugzilla.gnome.org/show_bug.cgi?id=656461
* https://mail.gnome.org/archives/gtk-app-devel-list/2016-August/msg00021.html
I have prepared a patch that fixes the issue by using CSS styling. See
the patch in the attachment.
Regarding the second point, I am not sure from your description what is
your complaint exactly about. But, I guess, it may be the same problem.
Best regards,
blueowl
From e0c60249eded5eb75e644264515fa4a51c2ed5ad Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ji=C5=99=C3=AD=20Klime=C5=A1?= <[email protected]>
Date: Mon, 16 Oct 2017 18:14:46 +0200
Subject: [PATCH] gtk: fix iupgtkSetBgColor() by using CSS styles to set
background color
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
gtk_widget_override_background_color() function is deprecated and it doesn't
work properly in some GTK themes (including default Adwaita) [1],[2],[3],[4].
Instead, CSS styling should be used ([5]). That's the concept which GtK 3 is
based on.
[1] https://mail.gnome.org/archives/gtk-app-devel-list/2016-August/msg00021.html
[2] https://bugzilla.gnome.org/show_bug.cgi?id=656461
[3] https://bugs.eclipse.org/bugs/show_bug.cgi?id=483096
[4] https://developer.gnome.org/gtk3/stable/GtkWidget.html#gtk-widget-override-background-color
[5] https://developer.gnome.org/gtk3/stable/chap-css-overview.html
Signed-off-by: JiÅà KlimeÅ¡ <[email protected]>
---
src/gtk/iupgtk_common.c | 28 ++++++++++++++++++++--------
1 file changed, 20 insertions(+), 8 deletions(-)
diff --git a/src/gtk/iupgtk_common.c b/src/gtk/iupgtk_common.c
index 9400fcec..07b73410 100644
--- a/src/gtk/iupgtk_common.c
+++ b/src/gtk/iupgtk_common.c
@@ -448,6 +448,9 @@ void iupgtkSetBgColor(InativeHandle* handle, unsigned char r, unsigned char g, u
{
#if GTK_CHECK_VERSION(3, 0, 0)
GdkRGBA rgba, light_rgba, dark_rgba;
+ char *bg, *bg_light, *bg_dark;
+ char *css;
+ GtkCssProvider *provider;
int is_txt = 0;
if (GTK_IS_TREE_VIEW(handle) ||
@@ -460,14 +463,23 @@ void iupgtkSetBgColor(InativeHandle* handle, unsigned char r, unsigned char g, u
dark_rgba = gtkDarkerRGBA(&rgba);
light_rgba = gtkLighterRGBA(&rgba);
- gtk_widget_override_background_color(handle, GTK_STATE_FLAG_NORMAL, &rgba);
- gtk_widget_override_background_color(handle, GTK_STATE_ACTIVE, &dark_rgba);
- gtk_widget_override_background_color(handle, GTK_STATE_PRELIGHT, &light_rgba);
-
- if (is_txt)
- gtk_widget_override_background_color(handle, GTK_STATE_INSENSITIVE, &light_rgba);
- else
- gtk_widget_override_background_color(handle, GTK_STATE_INSENSITIVE, &rgba);
+ bg = gdk_rgba_to_string(&rgba);
+ bg_light = gdk_rgba_to_string(&light_rgba);
+ bg_dark = gdk_rgba_to_string(&dark_rgba);
+
+ /* style background color using CSS */
+ provider = gtk_css_provider_new();
+ css = g_strdup_printf("*:not(selection) { background-color: %s; background-image: none; }"
+ "*:hover { background-color: %s; }"
+ "*:active { background-color: %s; }"
+ "*:disabled { background-color: %s; }",
+ bg, bg_light, bg_dark, is_txt ? bg_light : bg);
+ gtk_style_context_add_provider(gtk_widget_get_style_context(handle), GTK_STYLE_PROVIDER(provider), GTK_STYLE_PROVIDER_PRIORITY_USER);
+ gtk_css_provider_load_from_data(provider, css, -1, NULL);
+
+ g_free(bg); g_free(bg_light); g_free(bg_dark);
+ g_free(css);
+ g_object_unref(provider);
#else
GtkRcStyle *rc_style;
GdkColor color;
--
2.14.2
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Iup-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/iup-users