[totem] preferences: Embed preferences.ui as a GResource



commit e23c46619ae1996d237e27b75ba80cc2ec23be34
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Wed May 5 00:00:07 2021 -0300

    preferences: Embed preferences.ui as a GResource
    
    Instead of installing preferences.ui and opening the file, embed it
    as a GResource and load it using gtk_builder_new_from_resource().
    We don't need extra caution because the file is now guaranteed to
    be embedded into the application.
    
    This will be very handy for the next commit where we start using
    a GtkBuilder template for the preferences dialog.

 data/meson.build         | 9 ++++++++-
 data/totem.gresource.xml | 6 ++++++
 src/meson.build          | 2 ++
 src/totem-preferences.c  | 3 ++-
 4 files changed, 18 insertions(+), 2 deletions(-)
---
diff --git a/data/meson.build b/data/meson.build
index 4c6df3ba3..b38997400 100644
--- a/data/meson.build
+++ b/data/meson.build
@@ -42,7 +42,6 @@ endif
 ui_files = files(
   'controls.ui',
   'playlist.ui',
-  'preferences.ui',
   'shortcuts.ui',
   'totem.ui',
   'uri.ui'
@@ -53,6 +52,14 @@ install_data(
   install_dir: totem_pkgdatadir
 )
 
+ui_resources = gnome.compile_resources(
+  'totemresources',
+  'totem.gresource.xml',
+  export: true,
+  source_dir: '.',
+  c_name: 'totem'
+)
+
 r = run_command(desktop_sh, mime_type_list, uri_schemes_list)
 
 desktop_conf = configuration_data()
diff --git a/data/totem.gresource.xml b/data/totem.gresource.xml
new file mode 100644
index 000000000..9fffc1a3d
--- /dev/null
+++ b/data/totem.gresource.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+  <gresource prefix="/org/gnome/totem/ui">
+    <file compressed="true">preferences.ui</file>
+  </gresource>
+</gresources>
diff --git a/src/meson.build b/src/meson.build
index 1ad816adf..6b359d633 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -137,6 +137,8 @@ libtotem_sources += gnome.compile_resources(
   c_name: '_totem'
 )
 
+libtotem_sources += ui_resources
+
 libtotem_deps = [
   libtotem_player_dep,
   libbacon_video_widget_dep,
diff --git a/src/totem-preferences.c b/src/totem-preferences.c
index 8eae3e260..439fe18c7 100644
--- a/src/totem-preferences.c
+++ b/src/totem-preferences.c
@@ -234,7 +234,8 @@ totem_setup_preferences (Totem *totem)
 
        g_return_if_fail (totem->settings != NULL);
 
-       totem->prefs_xml = totem_interface_load ("preferences.ui", TRUE, NULL, totem);
+       totem->prefs_xml = gtk_builder_new_from_resource ("/org/gnome/totem/ui/preferences.ui");
+       gtk_builder_connect_signals (totem->prefs_xml, totem);
        totem->prefs = GTK_WIDGET (gtk_builder_get_object (totem->prefs_xml, "totem_preferences_window"));
 
        gtk_window_set_transient_for (GTK_WINDOW (totem->prefs), GTK_WINDOW(totem->win));


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]