summaryrefslogtreecommitdiff
path: root/libslab/slab-section.c
diff options
context:
space:
mode:
authorzhuyaliang <[email protected]>2023-10-08 22:39:44 +0800
committerraveit65 <[email protected]>2023-10-11 15:27:35 +0200
commitb4205246abe19ce52c11c326dd83b1dcda01d2bd (patch)
tree1db0277b0194341566a3da621a02f388c0baf9c0 /libslab/slab-section.c
parent9df51ef52b7c6e29dd02a1c44d488074893d0c28 (diff)
downloadmate-control-center-b4205246abe19ce52c11c326dd83b1dcda01d2bd.tar.bz2
mate-control-center-b4205246abe19ce52c11c326dd83b1dcda01d2bd.tar.xz
libslab: Fix compilation warnings and replace deprecated functions
Diffstat (limited to 'libslab/slab-section.c')
-rw-r--r--libslab/slab-section.c50
1 files changed, 44 insertions, 6 deletions
diff --git a/libslab/slab-section.c b/libslab/slab-section.c
index 530a0826..f86820cf 100644
--- a/libslab/slab-section.c
+++ b/libslab/slab-section.c
@@ -46,21 +46,59 @@ slab_section_finalize (GObject * obj)
}
static void
+set_override_color (GtkWidget *widget,
+ GdkRGBA *rgba)
+{
+ gchar *css;
+ GtkCssProvider *provider;
+
+ provider = gtk_css_provider_new ();
+
+ css = g_strdup_printf ("* { color: %s;}",
+ gdk_rgba_to_string (rgba));
+ gtk_css_provider_load_from_data (provider, css, -1, NULL);
+ g_free (css);
+
+ gtk_style_context_add_provider (gtk_widget_get_style_context (widget),
+ GTK_STYLE_PROVIDER (provider),
+ GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+ g_object_unref (provider);
+}
+
+static void
slab_section_set_title_color (GtkWidget * widget)
{
+ GtkStyleContext *context;
+ GdkRGBA *rgba = NULL;
+
+ context = gtk_widget_get_style_context (widget);
+
switch (SLAB_SECTION (widget)->style)
{
case Style1:
- gtk_widget_modify_fg (SLAB_SECTION (widget)->title, GTK_STATE_NORMAL,
- &gtk_widget_get_style (widget)->bg[GTK_STATE_SELECTED]);
+ gtk_style_context_get (context,
+ GTK_STATE_FLAG_SELECTED,
+ "background-color", &rgba,
+ NULL);
+ set_override_color (SLAB_SECTION (widget)->title, rgba);
break;
case Style2:
if (SLAB_SECTION (widget)->selected)
- gtk_widget_modify_fg (SLAB_SECTION (widget)->title, GTK_STATE_NORMAL,
- &gtk_widget_get_style (widget)->dark[GTK_STATE_SELECTED]);
+ {
+ gtk_style_context_get (context,
+ GTK_STATE_FLAG_SELECTED,
+ "background-color", &rgba,
+ NULL);
+ set_override_color (SLAB_SECTION (widget)->title, rgba);
+ }
else
- gtk_widget_modify_fg (SLAB_SECTION (widget)->title, GTK_STATE_NORMAL,
- &gtk_widget_get_style (widget)->text[GTK_STATE_INSENSITIVE]);
+ {
+ gtk_style_context_get (context,
+ GTK_STATE_FLAG_INSENSITIVE,
+ "color", &rgba,
+ NULL);
+ set_override_color (SLAB_SECTION (widget)->title, rgba);
+ }
break;
default:
g_assert_not_reached ();