gplugin/gplugin

Set a non-persistent settings backend in viewer

15 months ago, Elliott Sales de Andrade
a4ee5a7bbbe9
Parents bc5f36d168a5
Children bc5116596aba
Set a non-persistent settings backend in viewer

We don't want test or example plugins to write to dconf or the registry just
when viewing them.

Testing Done:
Viewed a plugin with settings, and confirmed that nothing was saved to dconf.

Reviewed at https://reviews.imfreedom.org/r/2147/
--- a/gplugin-gtk4-viewer/gplugin-gtk-viewer.c Tue Dec 13 01:55:01 2022 -0600
+++ b/gplugin-gtk4-viewer/gplugin-gtk-viewer.c Sat Dec 17 01:44:54 2022 -0600
@@ -16,6 +16,8 @@
*/
#include <glib/gi18n.h>
+#define G_SETTINGS_ENABLE_BACKEND
+#include <gio/gsettingsbackend.h>
#include <gtk/gtk.h>
#include <gplugin.h>
#include <gplugin-gtk.h>
@@ -80,6 +82,7 @@
window = gtk_application_get_active_window(GTK_APPLICATION(app));
if(window == NULL) {
GPluginGtkView *view = NULL;
+ GSettingsBackend *backend = NULL;
/* clang-format off */
window = g_object_new(
@@ -92,6 +95,10 @@
GPLUGIN_GTK_VIEWER_WINDOW(window));
gplugin_gtk_view_set_manager(view, gplugin_manager_get_default());
gplugin_gtk_view_set_show_internal(view, show_internal);
+
+ backend = g_memory_settings_backend_new();
+ gplugin_gtk_view_set_settings_backend(view, backend);
+ g_object_unref(backend);
}
gtk_window_present(window);