[gnome-boxes/move-properties-page-widget-into-ui] properties-page-widget: Move Gtk bits into UI file



commit 9c0a6954ff110ec671ada66cb09aa4757445d8e2
Author: Felipe Borges <felipeborges gnome org>
Date:   Wed Dec 18 14:30:28 2019 +0100

    properties-page-widget: Move Gtk bits into UI file

 data/gnome-boxes.gresource.xml    |  1 +
 data/ui/properties-page-widget.ui | 26 ++++++++++++++++++++++++++
 src/properties-page-widget.vala   | 15 ++-------------
 3 files changed, 29 insertions(+), 13 deletions(-)
---
diff --git a/data/gnome-boxes.gresource.xml b/data/gnome-boxes.gresource.xml
index cc73d70a..96b5b438 100644
--- a/data/gnome-boxes.gresource.xml
+++ b/data/gnome-boxes.gresource.xml
@@ -26,6 +26,7 @@
     <file preprocess="xml-stripblanks">ui/list-view-row.ui</file>
     <file preprocess="xml-stripblanks">ui/notification.ui</file>
     <file preprocess="xml-stripblanks">ui/properties-shared-folder-row.ui</file>
+    <file preprocess="xml-stripblanks">ui/properties-page-widget.ui</file>
     <file preprocess="xml-stripblanks">ui/properties-toolbar.ui</file>
     <file preprocess="xml-stripblanks">ui/properties-window.ui</file>
     <file preprocess="xml-stripblanks">ui/resource-graph.ui</file>
diff --git a/data/ui/properties-page-widget.ui b/data/ui/properties-page-widget.ui
new file mode 100644
index 00000000..0d6da728
--- /dev/null
+++ b/data/ui/properties-page-widget.ui
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <template class="BoxesPropertiesPageWidget" parent="GtkBox">
+    <property name="can_focus">False</property>
+    <style>
+      <class name="transparent-bg"/>
+    </style>
+
+    <child>
+      <object class="GtkScrolledWindow">
+         <property name="visible">True</property>
+         <property name="hscrollbar-policy">never</property>
+         <property name="vscrollbar-policy">automatic</property>
+
+         <child>
+           <object class="GtkGrid" id="grid">
+             <property name="visible">True</property>
+             <property name="margin">20</property>
+             <property name="row-spacing">10</property>
+             <property name="column-spacing">20</property>
+           </object>
+         </child>
+       </object>
+    </child>
+  </template>
+</interface>
diff --git a/src/properties-page-widget.vala b/src/properties-page-widget.vala
index 3374b9d5..a26f8f87 100644
--- a/src/properties-page-widget.vala
+++ b/src/properties-page-widget.vala
@@ -1,9 +1,11 @@
 // This file is part of GNOME Boxes. License: LGPLv2+
 using Gtk;
 
+[GtkTemplate (ui = "/org/gnome/Boxes/ui/properties-page-widget.ui")]
 private class Boxes.PropertiesPageWidget: Gtk.Box {
     public bool empty;
 
+    [GtkChild]
     private Gtk.Grid grid;
     private List<Boxes.Property> properties;
 
@@ -28,19 +30,6 @@ public PropertiesPageWidget (PropertiesPage page, Machine machine) {
             break;
         }
 
-        get_style_context ().add_class ("transparent-bg");
-
-        grid = new Gtk.Grid ();
-        grid.margin = 20;
-        grid.row_spacing = 10;
-        grid.column_spacing = 20;
-        var scrolled_win = new Gtk.ScrolledWindow (null, null);
-        scrolled_win.margin_start = 20;
-        scrolled_win.margin_end = 20;
-        scrolled_win.set_policy (Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC);
-        scrolled_win.add (grid);
-        pack_end (scrolled_win, true, true);
-
         properties = machine.get_properties (page);
         empty = properties.length () == 0;
         if (!empty) {


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