[pitivi] dialogs: Refactor PluginPreferencesRow to use Gtk Templates
- From: Alexandru Băluț <alexbalut src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi] dialogs: Refactor PluginPreferencesRow to use Gtk Templates
- Date: Wed, 7 Jul 2021 20:42:10 +0000 (UTC)
commit 20555f2e28a6817f56b5e48468b72501f64f3268
Author: Fabián Orccón <cfoch fabian gmail com>
Date: Sun Dec 20 21:11:33 2020 -0500
dialogs: Refactor PluginPreferencesRow to use Gtk Templates
data/ui/pluginpreferencesrow.ui | 73 +++++++++++++++++++++++++++++++++++++++++
pitivi/dialogs/prefs.py | 37 ++++++---------------
2 files changed, 83 insertions(+), 27 deletions(-)
---
diff --git a/data/ui/pluginpreferencesrow.ui b/data/ui/pluginpreferencesrow.ui
new file mode 100644
index 000000000..3c6371cb6
--- /dev/null
+++ b/data/ui/pluginpreferencesrow.ui
@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.38.2 -->
+<interface>
+ <requires lib="gtk+" version="3.24"/>
+ <template class="PluginPreferencesRow" parent="GtkListBoxRow">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="margin-start">12</property>
+ <property name="margin-end">12</property>
+ <property name="margin-top">6</property>
+ <property name="margin-bottom">6</property>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkLabel" id="_title_label">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="_description_label">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="use-markup">True</property>
+ <property name="xalign">0</property>
+ <style>
+ <class name="dim-label"/>
+ </style>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkSwitch" id="switch">
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <property name="valign">center</property>
+ <property name="margin-start">6</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="pack-type">end</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </template>
+</interface>
diff --git a/pitivi/dialogs/prefs.py b/pitivi/dialogs/prefs.py
index 14d593917..22ed36ec4 100644
--- a/pitivi/dialogs/prefs.py
+++ b/pitivi/dialogs/prefs.py
@@ -714,19 +714,22 @@ class CustomShortcutDialog(Gtk.Dialog):
self.destroy()
+@Gtk.Template(filename=os.path.join(get_ui_dir(), "pluginpreferencesrow.ui"))
class PluginPreferencesRow(Gtk.ListBoxRow):
"""A row in the plugins list allowing activating and deactivating a plugin."""
+ __gtype_name__ = "PluginPreferencesRow"
+
+ _title_label = Gtk.Template.Child()
+ _description_label = Gtk.Template.Child()
+ switch = Gtk.Template.Child()
+
def __init__(self, item):
- Gtk.ListBoxRow.__init__(self)
+ super().__init__()
self.plugin_info = item.plugin_info
+ self.switch_handler_id = None
- self._container = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
- self.add(self._container)
-
- self._title_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
- self._title_label = Gtk.Label(self.plugin_info.get_name())
- self._description_label = Gtk.Label()
+ self._title_label.set_text(self.plugin_info.get_name())
description = self.plugin_info.get_description()
if not description:
@@ -736,26 +739,6 @@ class PluginPreferencesRow(Gtk.ListBoxRow):
else:
self._description_label.set_text(description)
- self.switch = Gtk.Switch()
- self.switch.props.valign = Gtk.Align.CENTER
- self.switch_handler_id = None
-
- # Pack widgets.
- self._title_box.pack_start(self._title_label, True, True, 0)
- self._title_box.pack_start(self._description_label, True, True, 0)
- self._container.pack_start(self._title_box, True, True, 0)
- self._container.pack_end(self.switch, False, False, 0)
-
- # Widgets' design.
- self._container.props.margin_left = PADDING * 2
- self._container.props.margin_right = PADDING * 2
- self._container.props.margin_top = PADDING
- self._container.props.margin_bottom = PADDING
- self._title_label.props.xalign = 0
- self._description_label.props.xalign = 0
- self._description_label.get_style_context().add_class("dim-label")
- self.switch.props.margin_left = PADDING
-
class PluginItem(GObject.Object):
"""Holds the data of a plugin info for a Gio.ListStore."""
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]