[gnome-boxes] notification: Move UI setup to .ui file



commit d135516fe8f1c5ca82cf51233f4def22dcfb4328
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Thu Feb 6 10:48:22 2014 +0000

    notification: Move UI setup to .ui file

 data/gnome-boxes.gresource.xml |    1 +
 src/notification.vala          |   28 ++++++++++++----------------
 2 files changed, 13 insertions(+), 16 deletions(-)
---
diff --git a/data/gnome-boxes.gresource.xml b/data/gnome-boxes.gresource.xml
index 8580926..3257a5a 100644
--- a/data/gnome-boxes.gresource.xml
+++ b/data/gnome-boxes.gresource.xml
@@ -11,6 +11,7 @@
     <file preprocess="xml-stripblanks">ui/empty-boxes.ui</file>
     <file preprocess="xml-stripblanks">ui/editable-entry.ui</file>
     <file preprocess="xml-stripblanks">ui/mini-graph.ui</file>
+    <file preprocess="xml-stripblanks">ui/notification.ui</file>
     <file preprocess="xml-stripblanks">ui/searchbar.ui</file>
     <file preprocess="xml-stripblanks">ui/selectionbar.ui</file>
     <file preprocess="xml-stripblanks">ui/sidebar.ui</file>
diff --git a/src/notification.vala b/src/notification.vala
index 38703b0..645b318 100644
--- a/src/notification.vala
+++ b/src/notification.vala
@@ -1,19 +1,26 @@
 // This file is part of GNOME Boxes. License: LGPLv2+
 using Gtk;
 
+[GtkTemplate (ui = "/org/gnome/Boxes/ui/notification.ui")]
 private class Boxes.Notification: Gd.Notification {
     public const int DEFAULT_TIMEOUT = 6;
 
     public delegate void OKFunc ();
     public delegate void CancelFunc ();
 
+    [GtkChild]
+    private Gtk.Label message_label;
+    [GtkChild]
+    private Gtk.Label ok_button_label;
+    [GtkChild]
+    private Gtk.Button ok_button;
+
     public Notification (string            message,
                          MessageType       message_type,
                          string?           ok_label,
                          owned OKFunc?     ok_func,
                          owned CancelFunc? cancel_func,
                          int               timeout) {
-        valign = Gtk.Align.START;
         this.timeout = timeout;
 
         bool ok_pressed = false;
@@ -22,21 +29,10 @@ private class Boxes.Notification: Gd.Notification {
                 cancel_func ();
         });
 
-        var grid = new Gtk.Grid ();
-        grid.set_orientation (Gtk.Orientation.HORIZONTAL);
-        grid.margin_left = 12;
-        grid.margin_right = 12;
-        grid.column_spacing = 12;
-        grid.valign = Gtk.Align.CENTER;
-        add (grid);
-
-        var message_label = new Label (message);
-        grid.add (message_label);
+        message_label.label = message;
 
         if (ok_label != null) {
-            var ok_button = new Button.with_mnemonic (ok_label);
-            ok_button.halign = Gtk.Align.END;
-            grid.add (ok_button);
+            ok_button_label.label = ok_label;
 
             ok_button.clicked.connect ( () => {
                 ok_pressed = true;
@@ -44,8 +40,8 @@ private class Boxes.Notification: Gd.Notification {
                     ok_func ();
                 dismiss ();
             });
-        }
 
-        show_all ();
+            ok_button.show_all ();
+        }
     }
 }


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