diff options
author | Andrew Hayzen <ahayzen@gmail.com> | 2020-06-20 15:05:30 +0200 |
---|---|---|
committer | Gaƫl Bonithon <gael@xfce.org> | 2021-05-05 11:12:03 +0200 |
commit | 3e4994edf8c0358007513b39bf27ada58df32482 (patch) | |
tree | 52e0c3fa6664e6ae9a8fc0bc520b2d8435152d45 | |
parent | 1da63db54047902b71201d6ae5b5beedbbb6fcf1 (diff) | |
download | xfce4-settings-3e4994edf8c0358007513b39bf27ada58df32482.tar.gz |
appearence: Sync theme, icon, font names to gsettings
Sync gsettings values so that tools such as flatpak are able
to determine the correct gtk theme.
(This may also help Wayland support later)
Related to #179
-rw-r--r-- | dialogs/appearance-settings/main.c | 37 | ||||
-rw-r--r-- | dialogs/mouse-settings/main.c | 14 |
2 files changed, 51 insertions, 0 deletions
diff --git a/dialogs/appearance-settings/main.c b/dialogs/appearance-settings/main.c index fc2ab9bc..afe3df55 100644 --- a/dialogs/appearance-settings/main.c +++ b/dialogs/appearance-settings/main.c @@ -40,6 +40,8 @@ #include <gdk/gdkx.h> +#include <gio/gio.h> + #include <libxfce4ui/libxfce4ui.h> #include <libxfce4util/libxfce4util.h> #include <xfconf/xfconf.h> @@ -80,6 +82,8 @@ enum { NUM_SYMBOLIC_COLORS }; +static const gchar *gsettings_category_gnome_interface = "org.gnome.desktop.interface"; + /* String arrays with the settings in combo boxes */ static const gchar* toolbar_styles_array[] = { @@ -659,6 +663,7 @@ appearance_settings_dialog_channel_property_changed (XfconfChannel *channel, guint i; gint antialias, dpi, custom_dpi; GtkTreeModel *model; + g_autoptr(GSettings) gsettings = NULL; g_return_if_fail (property_name != NULL); g_return_if_fail (GTK_IS_BUILDER (builder)); @@ -778,6 +783,13 @@ appearance_settings_dialog_channel_property_changed (XfconfChannel *channel, g_free (selected_name); g_free (new_name); } + + /* Keep gsettings in sync */ + gsettings = g_settings_new (gsettings_category_gnome_interface); + if (gsettings) + { + g_settings_set_string (gsettings, "gtk-theme", xfconf_channel_get_string (channel, property_name, NULL)); + } } else if (strcmp (property_name, "/Net/IconThemeName") == 0) { @@ -818,6 +830,31 @@ appearance_settings_dialog_channel_property_changed (XfconfChannel *channel, pd, (GDestroyNotify) preview_data_free); } + + /* Keep gsettings in sync */ + gsettings = g_settings_new (gsettings_category_gnome_interface); + if (gsettings) + { + g_settings_set_string (gsettings, "icon-theme", xfconf_channel_get_string (channel, property_name, NULL)); + } + } + else if (strcmp (property_name, "/Gtk/FontName") == 0) + { + /* Keep gsettings in sync */ + gsettings = g_settings_new (gsettings_category_gnome_interface); + if (gsettings) + { + g_settings_set_string (gsettings, "font-name", xfconf_channel_get_string (channel, property_name, NULL)); + } + } + else if (strcmp (property_name, "/Gtk/MonospaceFontName") == 0) + { + /* Keep gsettings in sync */ + gsettings = g_settings_new (gsettings_category_gnome_interface); + if (gsettings) + { + g_settings_set_string (gsettings, "monospace-font-name", xfconf_channel_get_string (channel, property_name, NULL)); + } } } diff --git a/dialogs/mouse-settings/main.c b/dialogs/mouse-settings/main.c index b9bc04c8..6564e896 100644 --- a/dialogs/mouse-settings/main.c +++ b/dialogs/mouse-settings/main.c @@ -34,6 +34,8 @@ #include <xfsettingsd/pointers-defines.h> #ifdef HAVE_XCURSOR #include <X11/Xcursor/Xcursor.h> + +#include <gio/gio.h> #endif /* !HAVE_XCURSOR */ #ifdef HAVE_LIBINPUT @@ -87,6 +89,8 @@ static GOptionEntry option_entries[] = }; #ifdef HAVE_XCURSOR +static const gchar *gsettings_category_gnome_interface = "org.gnome.desktop.interface"; + /* icon names for the preview widget */ static const gchar *preview_names[] = { "left_ptr", "left_ptr_watch", "watch", "hand2", @@ -336,6 +340,7 @@ mouse_settings_themes_selection_changed (GtkTreeSelection *selection, gboolean has_selection; gchar *path, *name; GObject *image; + g_autoptr(GSettings) gsettings = NULL; has_selection = gtk_tree_selection_get_selected (selection, &model, &iter); if (G_LIKELY (has_selection)) @@ -350,8 +355,17 @@ mouse_settings_themes_selection_changed (GtkTreeSelection *selection, /* write configuration (not during a lock) */ if (locked == 0) + { xfconf_channel_set_string (xsettings_channel, "/Gtk/CursorThemeName", name); + /* Keep gsettings in sync */ + gsettings = g_settings_new (gsettings_category_gnome_interface); + if (gsettings) + { + g_settings_set_string (gsettings, "cursor-theme", name); + } + } + /* cleanup */ g_free (path); g_free (name); |