handle trailing colons when parsing gtk-decoration-layout

postmarketOS Phosh has the default gtk-decoration-layout set to "menu:".
We don't want window decorations there by default.
This commit is contained in:
Julian Winkler
2024-12-30 09:38:49 +01:00
parent 054fb9276a
commit d6f50e160c

View File

@@ -457,9 +457,13 @@ static void open(GtkApplication *app, GFile **files, gint nfiles, const gchar *h
if (disable_decoration_env)
decorated = !strcmp(disable_decoration_env, "0") || !strcmp(disable_decoration_env, "false");
else { // by default only enable decorations if there are any action buttons to show in the title bar
const char *decoration_layout;
char *decoration_layout;
g_object_get(G_OBJECT(gtk_settings_get_default()), "gtk-decoration-layout", &decoration_layout, NULL);
decorated = strcmp(decoration_layout, "") && strcmp(decoration_layout, "menu");
GString *gstring = g_string_new_take(decoration_layout);
g_string_replace(gstring, "menu", "", 0); // ignore menu button
g_string_replace(gstring, ":", "", 0); // ignore leading or trailing colon
decorated = gstring->len > 0;
g_string_free(gstring, TRUE);
}
gtk_window_set_decorated(GTK_WINDOW(window), decorated);