[gnome-boxes/wip/ui-files: 5/5] tmp
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes/wip/ui-files: 5/5] tmp
- Date: Wed, 25 Dec 2013 01:31:18 +0000 (UTC)
commit 0f4d21cf788ce6778e831456c81c7e3a1d031eaf
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Tue Dec 24 20:24:51 2013 +0000
tmp
data/gnome-boxes.gresource.xml | 2 +
data/ui/wizard-scrolled.ui | 29 +++++
data/ui/wizard-source.ui | 272 ++++++++++++++++++++++++++++++++++++++++
src/wizard-source.vala | 201 +++++++++--------------------
4 files changed, 365 insertions(+), 139 deletions(-)
---
diff --git a/data/gnome-boxes.gresource.xml b/data/gnome-boxes.gresource.xml
index 9d07baa..8d464dc 100644
--- a/data/gnome-boxes.gresource.xml
+++ b/data/gnome-boxes.gresource.xml
@@ -6,5 +6,7 @@
<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>
+ <file preprocess="xml-stripblanks">ui/wizard-source.ui</file>
</gresource>
</gresources>
diff --git a/data/ui/wizard-scrolled.ui b/data/ui/wizard-scrolled.ui
new file mode 100644
index 0000000..167d1e4
--- /dev/null
+++ b/data/ui/wizard-scrolled.ui
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <!-- interface-requires gtk+ 3.9 -->
+ <template class="BoxesWizardScrolled" parent="Gtk.ScrolledWindow">
+ <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="GtkViewport" id="viewport">
+ <child>
+ <object class="GtkBox" id="vbox">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">0</property>
+ <property name="margin-top">15</property>
+ <property name="margin-bottom">15</property>
+ <style>
+ <class name="boxes-menu"/>
+ </style>
+ </object>
+ </child>
+ </object>
+ </child>
+ </template>
+</interface>
diff --git a/data/ui/wizard-source.ui b/data/ui/wizard-source.ui
new file mode 100644
index 0000000..d64eb97
--- /dev/null
+++ b/data/ui/wizard-source.ui
@@ -0,0 +1,272 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <!-- interface-requires gtk+ 3.9 -->
+ <template class="BoxesWizardSource" parent="GtkNotebook">
+ <property name="visible">True</property>
+ <property name="width-request">500</property>
+ <property name="show-tabs">False</property>
+ <style>
+ <class name="boxes-source-nb"/>
+ </style>
+
+ <!-- main page -->
+ <child>
+ <object class="GtkBox" id="main_vbox">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">0</property>
+ <property name="margin-top">15</property>
+ <property name="margin-bottom">15</property>
+ <style>
+ <class name="boxes-menu"/>
+ </style>
+ <child>
+ <object class="BoxesScrolledWindow" id="media_scrolled"/>
+ </child>
+
+ <child>
+ <object class="GtkButton" id="enter_url_button">
+ <signal name="clicked" handler="on_enter_url_button_clicked"/>
+ <child>
+ <object class="GtkBox" id="enter_url_box">
+ <property name="visible">True</property>
+ <property name="margin-top">10</property>
+ <property name="margin-bottom">10</property>
+ <property name="margin-left">20</property>
+ <property name="margin-right">20</property>
+ <property name="spacing">20</property>
+ <property name="orientation">horizontal</property>
+ <style>
+ <class name="boxes-menu-row"/>
+ </style>
+ <child>
+ <object class="Label" id="enter_url_label">
+ <property name="visible">True</property>
+ <property name="x-align">0.0</property>
+ <property name="label" translatable="yes">Enter URL</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ <child>
+ <object class="Label" id="enter_url_next_label">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">▶</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+
+ <child>
+ <object class="GtkButton" id="select_file_button">
+ <signal name="clicked" handler="on_select_file_button_clicked"/>
+ <child>
+ <object class="GtkBox" id="select_file_box">
+ <property name="visible">True</property>
+ <property name="margin-top">10</property>
+ <property name="margin-bottom">10</property>
+ <property name="margin-left">20</property>
+ <property name="margin-right">20</property>
+ <property name="spacing">20</property>
+ <property name="orientation">horizontal</property>
+ <style>
+ <class name="boxes-menu-row"/>
+ </style>
+ <child>
+ <object class="Label" id="select_file_label">
+ <property name="visible">True</property>
+ <property name="x-align">0.0</property>
+ <property name="label" translatable="yes">Select a file</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ <child>
+ <object class="Label" id="select_file_next_label">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">▶</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+
+ <child>
+ <object class="GtkButton" id="libvirt_sys_import_button">
+ <property name="visible">False</property>
+ <signal name="clicked" handler="on_libvirt_sys_import_button_clicked"/>
+ <child>
+ <object class="GtkBox" id="libvirt_sys_import_box">
+ <property name="visible">True</property>
+ <property name="margin-top">10</property>
+ <property name="margin-bottom">10</property>
+ <property name="margin-left">20</property>
+ <property name="margin-right">20</property>
+ <property name="spacing">20</property>
+ <property name="orientation">horizontal</property>
+ <style>
+ <class name="boxes-menu-row"/>
+ </style>
+ <child>
+ <object class="Label" id="libvirt_sys_import_label">
+ <property name="visible">True</property>
+ <property name="x-align">0.0</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ <child>
+ <object class="Label" id="libvirt_sys_import_next_label">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">▶</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+
+ <!-- URL page -->
+ <child>
+ <object class="GtkBox" id="url_menubox">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">0</property>
+ <property name="margin-top">15</property>
+ <property name="margin-bottom">15</property>
+ <style>
+ <class name="boxes-menu"/>
+ </style>
+ <child>
+ <object class="GtkButton" id="url_back_button">
+ <signal name="clicked" handler="on_url_back_button_clicked"/>
+ <child>
+ <object class="GtkBox" id="url_back_box">
+ <property name="visible">True</property>
+ <property name="margin-top">10</property>
+ <property name="margin-bottom">10</property>
+ <property name="margin-left">20</property>
+ <property name="margin-right">20</property>
+ <property name="spacing">20</property>
+ <property name="orientation">horizontal</property>
+ <style>
+ <class name="boxes-menu-row"/>
+ </style>
+ <child>
+ <object class="Label" id="enter_url_back_label">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">◀</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ <child>
+ <object class="Label" id="enter_url_label2">
+ <property name="visible">True</property>
+ <property name="x-align">0.0</property>
+ <property name="label" translatable="yes">Enter URL</property>
+ <style>
+ <class name="boxes-source-label"/>
+ </style>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+
+ <child>
+ <object class="Gtk.Alignment" id="url_entry_bin">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0</property>
+ <property name="xscale">1</property>
+ <property name="yscale">1</property>
+ <child>
+ <object class="GtkBox" id="url_entry_vbox">
+ <property name="visible">True</property>
+ <property name="margin-top">10</property>
+ <property name="margin-bottom">10</property>
+ <property name="margin-left">20</property>
+ <property name="margin-right">20</property>
+ <property name="spacing">20</property>
+ <property name="orientation">vertical</property>
+ <style>
+ <class name="boxes-menu-row"/>
+ </style>
+ <child>
+ <object class="GtkEntry" id="url_entry"/>
+ </child>
+
+ <child>
+ <object class="GtkBox" id="url_entry_hbox"/>
+ <property name="visible">True</property>
+ <property name="spacing">0</property>
+ <property name="orientation">horizontal</property>
+ <child>
+ <object class="GtkImage" id="url_image"/>
+ <property name="visible">True</property>
+ <property name="icon-name">network-workgroup</property>
+ <property name="icon-size">0</property>
+ <property name="pixel-size">96</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <object class="GtkLabel" id="url_description_label"/>
+ <property name="visible">True</property>
+ <property name="use-markup">True</property>
+ <property name="wrap">True</property>
+ <property name="label" translatable="yes"><b>Desktop Access</b>\n\nWill
add boxes for all systems available from this account.</property>
+ <property name="xalign">0</property>
+ <!-- Work around clutter size allocation issue (bz#677260) -->
+ <property name="width_chars">30</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </template>
+</interface>
diff --git a/src/wizard-source.vala b/src/wizard-source.vala
index ea7add2..a7ecb2f 100644
--- a/src/wizard-source.vala
+++ b/src/wizard-source.vala
@@ -11,12 +11,21 @@ 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/wizard-scrolled.ui")]
private class Boxes.WizardScrolled : Gtk.ScrolledWindow {
- private int num_visible;
- public WizardScrolled (int num_visible) {
+ [GtkChild]
+ private Gtk.Box vbox;
+
+ int num_visible;
+
+ // Ideally, we shouldn't need this fuction but is there a way to connect
+ // vscrollbar signals from the UI template?
+ public setup (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 ();
@@ -49,15 +58,15 @@ private class Boxes.WizardScrolled : Gtk.ScrolledWindow {
}
}
-private class Boxes.WizardSource: GLib.Object {
- public Gtk.Widget widget { get { return notebook; } }
+[GtkTemplate (ui = "/org/gnome/Boxes/wizard-source.ui")]
+private class Boxes.WizardSource: Gtk.Notebook {
public Gtk.Widget? selected { get; set; }
private SourcePage _page;
public SourcePage page {
get { return _page; }
set {
_page = value;
- notebook.set_current_page (page);
+ set_current_page (page);
if (selected != null)
selected.grab_focus ();
switch (page) {
@@ -81,12 +90,17 @@ private class Boxes.WizardSource: GLib.Object {
public LibvirtSystemImporter libvirt_sys_importer { get; private set; }
public bool libvirt_sys_import;
+ [GtkChild]
private Gtk.Box main_vbox;
+ [GtkChild]
private Gtk.Box media_vbox;
- private Gtk.ScrolledWindow media_scrolled;
- private Gtk.Notebook notebook;
- private Gtk.Label url_label;
+ [GtkChild]
+ private Boxes.WizardScrolled media_scrolled;
+ [GtkChild]
+ private Gtk.Label url_description_label;
+ [GtkChild]
private Gtk.Image url_image;
+ [GtkChild]
public Gtk.Entry url_entry;
public signal void activate (); // Emitted on user activating a source
@@ -96,91 +110,28 @@ private class Boxes.WizardSource: GLib.Object {
public WizardSource (MediaManager media_manager) {
this.media_manager = media_manager;
- notebook = new Gtk.Notebook ();
- notebook.width_request = 500;
- notebook.get_style_context ().add_class ("boxes-source-nb");
- notebook.show_tabs = false;
-
- /* main page */
- main_vbox = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
- main_vbox.get_style_context ().add_class ("boxes-menu");
- main_vbox.margin_top = main_vbox.margin_bottom = 15;
main_vbox.grab_focus ();
- 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);
- main_vbox.add (media_scrolled);
+ media_scrolled.setup (5);
+ draw_as_css_box (url_entry_bin);
- var hbox = add_entry (main_vbox, () => {
- page = SourcePage.URL;
-
- return false;
- });
- var label = new Gtk.Label (_("Enter URL"));
- label.xalign = 0.0f;
- hbox.pack_start (label, true, true);
- var next = new Gtk.Label ("▶");
- hbox.pack_start (next, false, false);
-
- hbox = add_entry (main_vbox, launch_file_selection_dialog);
- label = new Gtk.Label (_("Select a file"));
- label.xalign = 0.0f;
- hbox.pack_start (label, true, true);
- next = new Gtk.Label ("▶");
- hbox.pack_start (next, false, false);
-
- /* URL page */
- var url_menubox = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
- url_menubox.get_style_context ().add_class ("boxes-menu");
- url_menubox.margin_top = url_menubox.margin_bottom = 15;
- notebook.append_page (url_menubox, null);
-
- hbox = add_entry (url_menubox, () => {
- selected = null;
- page = SourcePage.MAIN;
-
- return false;
- });
- var prev = new Gtk.Label ("◀");
- hbox.pack_start (prev, false, false);
- label = new Gtk.Label (_("Enter URL"));
- label.get_style_context ().add_class ("boxes-source-label");
- hbox.pack_start (label, true, true);
-
- var vbox = add_entry (url_menubox);
- vbox.set_orientation (Gtk.Orientation.VERTICAL);
- url_entry = new Gtk.Entry ();
- vbox.add (url_entry);
-
- hbox = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
- url_image = new Gtk.Image.from_icon_name ("network-workgroup", 0);
- // var image = new Gtk.Image.from_icon_name ("krfb", 0);
- url_image.pixel_size = 96;
- hbox.pack_start (url_image, false, false);
-
- url_label = new Gtk.Label (null);
- url_label.xalign = 0.0f;
- url_label.set_markup (_("<b>Desktop Access</b>\n\nWill add boxes for all systems available from this
account."));
- url_label.set_use_markup (true);
- url_label.wrap = true;
- // Work around clutter size allocation issue (bz#677260)
- url_label.width_chars = 30;
-
- hbox.pack_start (url_label, true, true);
- vbox.add (hbox);
+ update_libvirt_sytem_entry_visibility.begin ();
+ add_media_entries.begin ();
+ }
- notebook.show_all ();
+ [GtkCallback]
+ private void on_enter_url_button_clicked () {
+ page = SourcePage.URL;
+ }
- add_libvirt_sytem_entry.begin ();
- add_media_entries.begin ();
+ [GtkCallback]
+ private void on_url_back_button_clicked () {
+ selected = null;
+ page = SourcePage.MAIN;
}
public void update_url_page(string title, string text, string icon_name) {
- url_label.set_markup ("<b>" + title + "</b>\n\n" + text);
+ url_description_label.set_markup ("<b>" + title + "</b>\n\n" + text);
url_image.icon_name = icon_name;
}
@@ -225,11 +176,21 @@ private class Boxes.WizardSource: GLib.Object {
}
private void add_media_entry (InstallerMedia media) {
- var hbox = add_entry (media_vbox, () => {
+ var button = new Gtk.Button ();
+ media_vbox.add (button);
+ button.get_style_context ().add_class ("boxes-menu-row");
+ button.clicked.connect (() => {
on_media_selected (media);
- return true;
- }, 15, 5, media.device_file);
+ selected = button;
+ });
+
+ var hbox = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 20);
+ button.add (hbox);
+
+ hbox.margin_left = hbox.margin_right = 15;
+ hbox.margin_top = hbox.margin_bottom = 5;
+ button.set_data ("boxes-media", media.device_file);
var image = new Gtk.Image.from_icon_name ("media-optical", 0);
image.pixel_size = 64;
@@ -272,7 +233,7 @@ private class Boxes.WizardSource: GLib.Object {
media_scrolled.show ();
}
- private async void add_libvirt_sytem_entry () {
+ private async void update_libvirt_sytem_entry_visibility () {
try {
libvirt_sys_importer = yield new LibvirtSystemImporter ();
} catch (LibvirtSystemImporterError.NO_IMPORTS error) {
@@ -280,54 +241,11 @@ private class Boxes.WizardSource: GLib.Object {
return;
}
-
- var hbox = add_entry (main_vbox, () => {
- libvirt_sys_import = true;
- activate ();
-
- return true;
- });
- var label = new Gtk.Label (libvirt_sys_importer.wizard_menu_label);
- label.xalign = 0.0f;
- hbox.pack_start (label, true, true);
- var next = new Gtk.Label ("▶");
- hbox.pack_start (next, false, false);
main_vbox.show_all ();
}
- private Gtk.Box add_entry (Gtk.Box box,
- owned ClickedFunc? clicked = null,
- int h_margin = 20,
- int v_margin = 10,
- string? media = null) {
- Gtk.Container row;
- if (clicked != null) {
- var button = new Gtk.Button ();
- button.clicked.connect (() => {
- if (clicked ())
- selected = button;
- });
- row = button;
- } else {
- var bin = new Gtk.Alignment (0,0,1,1);
- draw_as_css_box (bin);
- row = bin;
- }
- var hbox = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 20);
- row.add (hbox);
- row.get_style_context ().add_class ("boxes-menu-row");
-
- box.add (row);
- if (media != null)
- row.set_data ("boxes-media", media);
-
- hbox.margin_left = hbox.margin_right = h_margin;
- hbox.margin_top = hbox.margin_bottom = v_margin;
-
- return hbox;
- }
-
- private bool launch_file_selection_dialog () {
+ [GtkCallback]
+ private void on_select_file_button_clicked () {
var dialog = new Gtk.FileChooserDialog (_("Select a device or ISO file"),
App.app.window,
Gtk.FileChooserAction.OPEN,
@@ -338,19 +256,24 @@ private class Boxes.WizardSource: GLib.Object {
dialog.filter.add_mime_type ("application/x-cd-image");
foreach (var extension in InstalledMedia.supported_extensions)
dialog.filter.add_pattern ("*" + extension);
- var ret = false;
if (dialog.run () == Gtk.ResponseType.ACCEPT) {
uri = dialog.get_uri ();
// clean install_media as this may be set already when going back in the wizard
install_media = null;
activate ();
- ret = true;
+ selected = select_file_button;
}
dialog.destroy ();
+ }
+
+ [GtkCallback]
+ private void on_libvirt_sys_import_button_clicked () {
+ libvirt_sys_import = true;
+ activate ();
- return ret;
+ selected = libvirt_sys_import_button;
}
private void on_media_selected (InstallerMedia media) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]