[gnome-boxes] Move WizardScrolled widget setup to .ui file



commit 1264cd0def412edafc662d401fc77942af362fd1
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Thu Jan 2 19:31:44 2014 +0000

    Move WizardScrolled widget setup to .ui file
    
    This introduces a critical warning at runtime:
    
    (gnome-boxes:15496): Gtk-CRITICAL **: gtk_range_get_adjustment:
    assertion 'GTK_IS_RANGE (range)' failed
    
    But its either gtk+ or vala bug:
    
    https://bugzilla.gnome.org/show_bug.cgi?id=721407

 data/gnome-boxes.gresource.xml |    1 +
 data/ui/wizard-scrolled.ui     |   20 ++++++++++++++++++++
 po/POTFILES.in                 |    1 +
 src/wizard-source.vala         |   17 ++++++++++-------
 4 files changed, 32 insertions(+), 7 deletions(-)
---
diff --git a/data/gnome-boxes.gresource.xml b/data/gnome-boxes.gresource.xml
index 9d07baa..ce518e6 100644
--- a/data/gnome-boxes.gresource.xml
+++ b/data/gnome-boxes.gresource.xml
@@ -6,5 +6,6 @@
     <file>icons/boxes-dark.png</file>
     <file>icons/boxes-gray.png</file>
     <file preprocess="xml-stripblanks">ui/unattended-setup-box.ui</file>
+    <file preprocess="xml-stripblanks">ui/wizard-scrolled.ui</file>
   </gresource>
 </gresources>
diff --git a/data/ui/wizard-scrolled.ui b/data/ui/wizard-scrolled.ui
new file mode 100644
index 0000000..a9e48f4
--- /dev/null
+++ b/data/ui/wizard-scrolled.ui
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <!-- interface-requires gtk+ 3.9 -->
+  <template class="BoxesWizardScrolled" parent="GtkScrolledWindow">
+    <property name="visible">True</property>
+    <property name="hscrollbar-policy">never</property>
+    <property name="vscrollbar-policy">automatic</property>
+    <property name="no-show-all">True</property>
+    <style>
+      <class name="boxes-menu-scrolled"/>
+    </style>
+    <child>
+      <object class="GtkBox" id="vbox">
+        <property name="visible">True</property>
+        <property name="orientation">vertical</property>
+        <property name="spacing">0</property>
+      </object>
+    </child>
+  </template>
+</interface>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 0ce4927..00b5a82 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -3,6 +3,7 @@ data/gnome-boxes.desktop.in.in
 [type: gettext/ini]data/gnome-boxes-search-provider.ini.in
 data/org.gnome.boxes.gschema.xml.in
 [type: gettext/glade]data/ui/unattended-setup-box.ui
+[type: gettext/glade]data/ui/wizard-scrolled.ui
 src/app.vala
 src/collection-view.vala
 src/display-page.vala
diff --git a/src/wizard-source.vala b/src/wizard-source.vala
index 2e2b7f9..866c2bb 100644
--- a/src/wizard-source.vala
+++ b/src/wizard-source.vala
@@ -11,12 +11,18 @@ public delegate bool ClickedFunc ();
 
 /* Subclass of ScrolledWindow that shows at allocates enough
    space to not scroll for at most N children. */
+[GtkTemplate (ui = "/org/gnome/Boxes/ui/wizard-scrolled.ui")]
 private class Boxes.WizardScrolled : Gtk.ScrolledWindow {
+    [GtkChild]
+    public Gtk.Box vbox;
+
     private int num_visible;
     public WizardScrolled (int num_visible) {
         this.num_visible = num_visible;
-        this.get_style_context ().add_class ("boxes-menu-scrolled");
-        this.set_policy (Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC);
+
+        notify["num-visible"].connect (() => {
+            queue_resize ();
+        });
         get_vscrollbar ().show.connect (() => {
             this.get_style_context ().add_class ("boxes-menu-scrolled");
             this.reset_style ();
@@ -83,7 +89,7 @@ private class Boxes.WizardSource: GLib.Object {
 
     private Gtk.Box main_vbox;
     private Gtk.Box media_vbox;
-    private Gtk.ScrolledWindow media_scrolled;
+    private Boxes.WizardScrolled media_scrolled;
     private Gtk.Notebook notebook;
     private Gtk.Label url_label;
     private Gtk.Image url_image;
@@ -109,10 +115,7 @@ private class Boxes.WizardSource: GLib.Object {
         notebook.append_page (main_vbox, null);
 
         media_scrolled = new WizardScrolled (5);
-
-        media_vbox = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
-        media_scrolled.set_no_show_all (true);
-        media_scrolled.add_with_viewport (media_vbox);
+        media_vbox = media_scrolled.vbox;
         main_vbox.add (media_scrolled);
 
         var hbox = add_entry (main_vbox, () => {


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