Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do i make my gtk app use the dark theme?

Tags:

c

themes

gtk

gnome

Some apps on the gnome desktop like the image viewer use a dark variation of the theme. What code is required to make my own gtk program use this dark variation of the theme?

like image 683
Askaga Avatar asked Apr 14 '13 09:04

Askaga


People also ask

How do I set my GTK to dark?

GTK. To change the light/dark mode, you have to change the used theme. Most themes do have a dark variant and those have by convention the suffix -dark . For example the default GTK theme Adwaita has the variant Adwaita-dark .

How do I change my app to a Dark theme?

Important: When you turn on Dark theme for your phone, many apps also use Dark theme. On your phone, open the Settings app. Tap Display. Turn Dark theme on or off.

How do I change the color of my GTK theme?

Once installed, launch GTK Theme Preferences from Dash / the menu, make any changes you want, make sure the "Custom widgets" toggle switch is turned on (or else the changes won't be used by your GTK theme!) and click Apply. Then, you'll have to log out and log back in to see the changes.


1 Answers

Use the gtk-application-prefer-dark-theme setting. This ought to do it:

g_object_set(gtk_settings_get_default(),
    "gtk-application-prefer-dark-theme", TRUE,
    NULL);

You may need to make sure you do it before you create any widgets.

like image 87
ptomato Avatar answered Oct 28 '22 21:10

ptomato