[gnome-boxes] empty-boxes: Move UI setup to .ui file
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] empty-boxes: Move UI setup to .ui file
- Date: Thu, 6 Feb 2014 19:54:13 +0000 (UTC)
commit e16d2c492793898a47099cd27e9580ebe9a6bfb8
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Wed Feb 5 16:36:38 2014 +0000
empty-boxes: Move UI setup to .ui file
data/gnome-boxes.gresource.xml | 1 +
data/ui/empty-boxes.ui | 62 ++++++++++++++++++++++++++++++++++++++++
src/empty-boxes.vala | 44 ++--------------------------
3 files changed, 66 insertions(+), 41 deletions(-)
---
diff --git a/data/gnome-boxes.gresource.xml b/data/gnome-boxes.gresource.xml
index 61c2a65..8580926 100644
--- a/data/gnome-boxes.gresource.xml
+++ b/data/gnome-boxes.gresource.xml
@@ -8,6 +8,7 @@
<file>icons/boxes-gray.png</file>
<file preprocess="xml-stripblanks">ui/display-page.ui</file>
<file preprocess="xml-stripblanks">ui/display-toolbar.ui</file>
+ <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/searchbar.ui</file>
diff --git a/data/ui/empty-boxes.ui b/data/ui/empty-boxes.ui
new file mode 100644
index 0000000..e7530b9
--- /dev/null
+++ b/data/ui/empty-boxes.ui
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <!-- interface-requires gtk+ 3.9 -->
+ <template class="BoxesEmptyBoxes" parent="GtkGrid">
+ <property name="visible">True</property>
+ <property name="orientation">horizontal</property>
+ <property name="column-spacing">12</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
+ <property name="halign">center</property>
+ <property name="valign">center</property>
+ <property name="row-homogeneous">True</property>
+ <style>
+ <class name="dim-label"/>
+ </style>
+
+ <child>
+ <object class="GtkImage" id="image">
+ <property name="visible">True</property>
+ <property name="icon-name">application-x-appliance-symbolic</property>
+ <property name="icon-size">6</property>
+ <property name="pixel-size">96</property>
+ <style>
+ <class name="boxes-empty-image"/>
+ </style>
+ </object>
+ </child>
+
+ <child>
+ <object class="GtkGrid" id="labels_grid">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+
+ <child>
+ <object class="GtkLabel" id="no_boxes_found_label">
+ <property name="visible">True</property>
+ <property name="use-markup">True</property>
+ <property name="halign">start</property>
+ <property name="vexpand">True</property>
+ <property name="label" translatable="yes"><b><span size="large">No boxes
found</span></b></property>
+ </object>
+ </child>
+
+ <child>
+ <object class="GtkLabel" id="instructions_label">
+ <property name="visible">True</property>
+ <property name="use-markup">True</property>
+ <property name="halign">start</property>
+ <property name="vexpand">True</property>
+ <property name="xalign">0</property>
+ <property name="max-width-chars">24</property>
+ <property name="wrap">True</property>
+ <property name="label" translatable="yes">Create one using the button on the top left.</property>
+ <style>
+ <class name="boxes-empty-details-label"/>
+ </style>
+ </object>
+ </child>
+ </object>
+ </child>
+ </template>
+</interface>
diff --git a/src/empty-boxes.vala b/src/empty-boxes.vala
index 65a91f6..9246505 100644
--- a/src/empty-boxes.vala
+++ b/src/empty-boxes.vala
@@ -1,51 +1,15 @@
// This file is part of GNOME Boxes. License: LGPLv2+
-private class Boxes.EmptyBoxes : GLib.Object, Boxes.UI {
+[GtkTemplate (ui = "/org/gnome/Boxes/ui/empty-boxes.ui")]
+private class Boxes.EmptyBoxes : Gtk.Grid, Boxes.UI {
public Clutter.Actor actor { get { return gtk_actor; } }
public UIState previous_ui_state { get; protected set; }
public UIState ui_state { get; protected set; }
private GtkClutter.Actor gtk_actor;
- private Gtk.Grid grid;
public EmptyBoxes () {
- grid = new Gtk.Grid ();
- grid.orientation = Gtk.Orientation.HORIZONTAL;
- grid.column_spacing = 12;
- grid.hexpand = true;
- grid.vexpand = true;
- grid.halign = Gtk.Align.CENTER;
- grid.valign = Gtk.Align.CENTER;
- grid.row_homogeneous = true;
- grid.get_style_context ().add_class ("dim-label");
-
- var image = new Gtk.Image.from_icon_name ("application-x-appliance-symbolic", Gtk.IconSize.DIALOG);
- image.get_style_context ().add_class ("boxes-empty-image");
- image.pixel_size = 96;
- grid.add (image);
-
- var labels_grid = new Gtk.Grid ();
- labels_grid.orientation = Gtk.Orientation.VERTICAL;
- grid.add (labels_grid);
-
- var label = new Gtk.Label ("<b><span size=\"large\">" +
- _("No boxes found") +
- "</span></b>");
- label.use_markup = true;
- label.halign = Gtk.Align.START;
- label.vexpand = true;
- labels_grid.add (label);
-
- label = new Gtk.Label (_("Create one using the button on the top left."));
- label.get_style_context ().add_class ("boxes-empty-details-label");
- label.halign = Gtk.Align.START;
- label.vexpand = true;
- label.xalign = 0;
- label.max_width_chars = 24;
- label.wrap = true;
- labels_grid.add (label);
-
- gtk_actor = new GtkClutter.Actor.with_contents (grid);
+ gtk_actor = new GtkClutter.Actor.with_contents (this);
gtk_actor.get_widget ().get_style_context ().add_class ("boxes-bg");
gtk_actor.opacity = 255;
gtk_actor.x_align = Clutter.ActorAlign.FILL;
@@ -53,8 +17,6 @@ private class Boxes.EmptyBoxes : GLib.Object, Boxes.UI {
gtk_actor.x_expand = true;
gtk_actor.y_expand = true;
- grid.show_all ();
-
App.app.collection.item_added.connect (update_visibility);
App.app.collection.item_removed.connect (update_visibility);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]