Add set_label/progressbar_csscolor helpers to deal with various Gtk versions
Right now passing NULL to set_label_csscolor should reset the color to default black but that doesn't workmaster
parent
b02c6f44e9
commit
32cf3bae07
|
@ -509,6 +509,56 @@ static t_global_monitor * monitor_new(XfcePanelPlugin *plugin)
|
||||||
return global;
|
return global;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------------------------------------------- */
|
||||||
|
static void set_label_csscolor(GtkWidget* label, GdkRGBA* color)
|
||||||
|
{
|
||||||
|
GtkCssProvider *css_provider;
|
||||||
|
gchar * css;
|
||||||
|
if (color != NULL)
|
||||||
|
{
|
||||||
|
#if GTK_CHECK_VERSION (3, 20, 0)
|
||||||
|
css = g_strdup_printf("label { color: %s; }",
|
||||||
|
#else
|
||||||
|
css = g_strdup_printf(".label { color: %s; }",
|
||||||
|
#endif
|
||||||
|
gdk_rgba_to_string(color));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
css = g_strdup_printf(".label { color: black; }");
|
||||||
|
}
|
||||||
|
css_provider = gtk_css_provider_new ();
|
||||||
|
gtk_css_provider_load_from_data (css_provider, css, strlen(css), NULL);
|
||||||
|
g_free(css);
|
||||||
|
|
||||||
|
DBG("setting label css: %s", gtk_css_provider_to_string (css_provider));
|
||||||
|
gtk_style_context_add_provider (
|
||||||
|
GTK_STYLE_CONTEXT (gtk_widget_get_style_context (GTK_WIDGET (label))),
|
||||||
|
GTK_STYLE_PROVIDER (css_provider),
|
||||||
|
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------------------------------------------- */
|
||||||
|
static void set_progressbar_csscolor(GtkWidget* pbar, GdkRGBA* color)
|
||||||
|
{
|
||||||
|
GtkCssProvider *css_provider;
|
||||||
|
gchar * css;
|
||||||
|
#if GTK_CHECK_VERSION (3, 20, 0)
|
||||||
|
css = g_strdup_printf("progressbar progress { background-color: %s; background-image: none; }",
|
||||||
|
#else
|
||||||
|
css = g_strdup_printf(".progressbar { background-color: %s; background-image: none; }",
|
||||||
|
#endif
|
||||||
|
gdk_rgba_to_string(color));
|
||||||
|
DBG("setting pbar css to %s", css);
|
||||||
|
css_provider = gtk_css_provider_new ();
|
||||||
|
gtk_css_provider_load_from_data (css_provider, css, strlen(css), NULL);
|
||||||
|
g_free(css);
|
||||||
|
gtk_style_context_add_provider (
|
||||||
|
GTK_STYLE_CONTEXT (gtk_widget_get_style_context (GTK_WIDGET (pbar))),
|
||||||
|
GTK_STYLE_PROVIDER (css_provider),
|
||||||
|
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||||
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------------------------------- */
|
||||||
static void setup_monitor(t_global_monitor *global, gboolean supress_warnings)
|
static void setup_monitor(t_global_monitor *global, gboolean supress_warnings)
|
||||||
|
|
Loading…
Reference in New Issue