diff options
author | Krifa75 <yahiaoui.fakhri@gmail.com> | 2022-12-04 23:16:39 +0100 |
---|---|---|
committer | Bastien Nocera <hadess@hadess.net> | 2022-12-05 12:30:11 +0100 |
commit | 71b680b72968b19cfa59dd52da780cb6ebbb60de (patch) | |
tree | d5646e907408d902096e72b94df589d30205bfe8 | |
parent | 40c1e7ae428fd60e553485e8a1af9bf8d9a272e9 (diff) | |
download | totem-71b680b72968b19cfa59dd52da780cb6ebbb60de.tar.gz |
opensubtitles: Use GResource for loading UI file
Note that warnings related to _register and _unregister need to be muted
as those generate warnings, caused by:
https://bugzilla.gnome.org/show_bug.cgi?id=684319
-rw-r--r-- | src/plugins/opensubtitles/meson.build | 10 | ||||
-rw-r--r-- | src/plugins/opensubtitles/opensubtitles.gresource.xml | 7 | ||||
-rw-r--r-- | src/plugins/opensubtitles/opensubtitles.py | 11 |
3 files changed, 25 insertions, 3 deletions
diff --git a/src/plugins/opensubtitles/meson.build b/src/plugins/opensubtitles/meson.build index e47681b95..5e249e53a 100644 --- a/src/plugins/opensubtitles/meson.build +++ b/src/plugins/opensubtitles/meson.build @@ -2,10 +2,18 @@ plugin_name = 'opensubtitles' plugin_dir = join_paths(totem_pluginsdir, plugin_name) +gnome.compile_resources( + 'opensubtitles', + 'opensubtitles.gresource.xml', + c_name: 'totem_opensubtitles', + install_dir: plugin_dir, + gresource_bundle: true, + install: true, +) + plugin_files = files( plugin_name + '.py', 'hash.py', - plugin_name + '.ui' ) install_data( diff --git a/src/plugins/opensubtitles/opensubtitles.gresource.xml b/src/plugins/opensubtitles/opensubtitles.gresource.xml new file mode 100644 index 000000000..cb028f2a2 --- /dev/null +++ b/src/plugins/opensubtitles/opensubtitles.gresource.xml @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<gresources> + <gresource prefix="/org/gnome/totem/opensubtitles/"> + <file compressed="true">opensubtitles.ui</file> + </gresource> +</gresources> + diff --git a/src/plugins/opensubtitles/opensubtitles.py b/src/plugins/opensubtitles/opensubtitles.py index 4c051e4ee..dae889a75 100644 --- a/src/plugins/opensubtitles/opensubtitles.py +++ b/src/plugins/opensubtitles/opensubtitles.py @@ -403,6 +403,8 @@ class OpenSubtitles (GObject.Object, # pylint: disable=R0902 schema = 'org.gnome.totem.plugins.opensubtitles' self._settings = Gio.Settings.new (schema) + self._resource = None + self._action = None self._find_button = None @@ -426,6 +428,10 @@ class OpenSubtitles (GObject.Object, # pylint: disable=R0902 """ self._totem = self.object + base_path = os.path.dirname (os.path.abspath (__file__)) + self._resource = Gio.Resource.load(os.path.join(base_path, 'opensubtitles.gresource')) + Gio.Resource._register(self._resource) # pylint: disable=W0212 + # Name of the movie file which the most-recently-downloaded subtitles # are related to. self._filename = None @@ -448,13 +454,14 @@ class OpenSubtitles (GObject.Object, # pylint: disable=R0902 self._dialog.destroy () self._dialog = None + Gio.Resource._unregister(self._resource) # pylint: disable=W0212 + self._delete_menu () # UI related code def _build_dialog (self): - ui_file_path = os.path.dirname (os.path.abspath (__file__)) + sep + 'opensubtitles.ui' - builder = Gtk.Builder.new_from_file (ui_file_path) + builder = Gtk.Builder.new_from_resource("/org/gnome/totem/opensubtitles/opensubtitles.ui") builder.connect_signals(self) # Obtain all the widgets we need to initialize |