geo
geo

Reputation: 193

Default gtk css color scheme

GtkStyle has been deprecated. I want to use GtkStyleContext instead (gtk_style_context_lookup_color) to find theme color.

I replaced successfully:

    color = style->bg [GTK_STATE_SELECTED];

with:

    gtk_style_context_lookup_color (context, "theme_selected_bg_color", &color)

but I do not know what color name to use to replace:

    color = style->dark [GTK_STATE_NORMAL];

I need these colors to transfer them to a vumeter create with cairo:

gdk_cairo_set_source_rgba (cr, &color);

Upvotes: 5

Views: 2499

Answers (2)

Emmanuel Touzery
Emmanuel Touzery

Reputation: 9183

as far as I know the list of color names is not part of GTK, but a property of the gtk theme. These are the color names for the default gnome theme, adwaita, for gtk 3.22: https://gitlab.gnome.org/GNOME/gtk/-/blob/gtk-3-22/gtk/theme/Adwaita/_colors-public.scss

I'm copying the names inline:

  • theme_fg_color
  • theme_text_color
  • theme_bg_color
  • theme_base_color
  • theme_selected_bg_color
  • theme_selected_fg_color
  • insensitive_bg_color
  • insensitive_fg_color
  • insensitive_base_color
  • theme_unfocused_fg_color
  • theme_unfocused_text_color
  • theme_unfocused_bg_color
  • theme_unfocused_base_color
  • theme_unfocused_selected_bg_color
  • theme_unfocused_selected_fg_color
  • unfocused_insensitive_color
  • borders
  • unfocused_borders
  • warning_color
  • error_color
  • success_color

Upvotes: 4

user877329
user877329

Reputation: 6240

As I understand it, GTK does not allow you to create custom widgets that respects the current theme, so either

  1. Write custom css for your entire application, ie disabling theming from outside
  2. Use a hack that calls gtk_render_background until you get something useful in a secondary cairo sufrace. See my answer to my own question: https://stackoverflow.com/a/44063175/877329
  3. Choose another toolkit, or stick to Gtk+2 for the sake of being a rebel.

Upvotes: 0

Related Questions