Skip to content

Commit

Permalink
Transition to gtk4 UI themes
Browse files Browse the repository at this point in the history
Start recognizing gtk4 theme names instead of gtk3 ones.
Update reference to "themes" submodule to include latest changes.
  • Loading branch information
mikekov committed Nov 8, 2024
1 parent 27f7092 commit c906c2e
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 24 deletions.
2 changes: 1 addition & 1 deletion share/themes
Submodule themes updated from 2fc6ec to 0a8234
38 changes: 19 additions & 19 deletions share/ui/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -773,28 +773,28 @@ button.square-button image {
.inkscape-toolbar {
margin: 4px;
}

.inkscape-toolbar > * {
margin-right: 2px;
margin-left: 1px;
margin-left: 2px;
}

.inkscape-toolbar > * > * {
.inkscape-toolbar > box > image,
.inkscape-toolbar > box > label {
margin-right: 2px;
margin-left: 1px;
}

.inkscape-toolbar > popover > box {
margin: 4px 3px;
}

.inkscape-toolbar > popover > box > * {
margin-right: 3px;
}

.inkscape-toolbar > popover > box > *:last-child {
margin-right: 0;
}
.inkscape-toolbar popover content > * {
margin-right: 2px;
margin-left: 2px;
}
/* Revise for gtk4: There's no box in popover */
/*.inkscape-toolbar > popover > box {*/
/* margin: 4px 3px;*/
/*}*/
/*.inkscape-toolbar > popover > box > * {*/
/* margin-right: 3px;*/
/*}*/
/*.inkscape-toolbar > popover > box > *:last-child {*/
/* margin-right: 0;*/
/*}*/

/* for dialogs with "Apply" button (or equivalent) - larger hit target */
.wide-apply-button {
Expand All @@ -811,9 +811,9 @@ button.menu-btn-tight {
}

#DialogMenuButton {
padding: 0px;
padding: 0;
border: none;
opacity: 0.5;
opacity: 0.7;
}
#DialogMenuButton:hover {
opacity: 1;
Expand Down
12 changes: 8 additions & 4 deletions src/ui/themes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,18 @@ ThemeContext::~ThemeContext() = default;
/**
* Inkscape fill gtk, taken from glib/gtk code with our own checks.
*/
void
ThemeContext::inkscape_fill_gtk(const gchar *path, gtkThemeList &themes)
void ThemeContext::inkscape_fill_gtk(const gchar *path, gtkThemeList &themes)
{
const gchar *dir_entry;
GDir *dir = g_dir_open(path, 0, nullptr);
if (!dir)
return;
while ((dir_entry = g_dir_read_name(dir))) {
gchar *filename = g_build_filename(path, dir_entry, "gtk-3.0", "gtk.css", nullptr);
gchar *filename = g_build_filename(path, dir_entry, "gtk-4.0", "gtk.css", nullptr);
bool has_prefer_dark = false;

Glib::ustring theme = dir_entry;
gchar *filenamedark = g_build_filename(path, dir_entry, "gtk-3.0", "gtk-dark.css", nullptr);
gchar *filenamedark = g_build_filename(path, dir_entry, "gtk-4.0", "gtk-dark.css", nullptr);
if (g_file_test(filenamedark, G_FILE_TEST_IS_REGULAR))
has_prefer_dark = true;
if (themes.find(theme) != themes.end() && !has_prefer_dark) {
Expand All @@ -96,6 +95,11 @@ ThemeContext::inkscape_fill_gtk(const gchar *path, gtkThemeList &themes)
std::map<Glib::ustring, bool>
ThemeContext::get_available_themes()
{
// NOTE: This function tries to mimic what _gtk_css_find_theme in gtk4 does to locate a theme;
// that is we traverse resources and then certain directories looking for themes.
// We only gather theme names as this is what's saved in gtk settings to select a UI theme.
// gtk4 will load a theme based solely on its name searching for it in a list of folders (that we cannot change).

gtkThemeList themes;
Glib::ustring theme = "";
gchar *path;
Expand Down

0 comments on commit c906c2e

Please sign in to comment.