[gnome-boxes] spice-display: Add UI for 'Folder Shares' section
- From: Felipe Borges <felipeborges src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] spice-display: Add UI for 'Folder Shares' section
- Date: Thu, 15 Jun 2017 14:57:10 +0000 (UTC)
commit c89f76fd410fc559e9aff009e22ce9b2680b621e
Author: Visarion Alexandru <viorel visarion gmail com>
Date: Tue May 16 00:58:47 2017 +0300
spice-display: Add UI for 'Folder Shares' section
Let's add the main UI elements, to support the upcoming patches
which will implement multiple shared folders.
https://bugzilla.gnome.org/show_bug.cgi?id=730259
data/gnome-boxes.gresource.xml | 1 +
data/ui/properties-shared-folder-row.ui | 61 +++++++++++++++++++++++
src/spice-display.vala | 81 +++++++++++++++++++++++++++++++
3 files changed, 143 insertions(+), 0 deletions(-)
---
diff --git a/data/gnome-boxes.gresource.xml b/data/gnome-boxes.gresource.xml
index 818e0e0..751e6e2 100644
--- a/data/gnome-boxes.gresource.xml
+++ b/data/gnome-boxes.gresource.xml
@@ -18,6 +18,7 @@
<file preprocess="xml-stripblanks">ui/list-view.ui</file>
<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-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-shared-folder-row.ui b/data/ui/properties-shared-folder-row.ui
new file mode 100644
index 0000000..b703084
--- /dev/null
+++ b/data/ui/properties-shared-folder-row.ui
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.20.0 -->
+<interface>
+ <requires lib="gtk+" version="3.19"/>
+ <template class="BoxesSharedFolderRow" parent="GtkListBoxRow">
+ <property name="visible">True</property>
+
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="margin">12</property>
+ <property name="margin-top">6</property>
+ <property name="margin-bottom">6</property>
+
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <property name="expand">true</property>
+
+ <child>
+ <object class="GtkLabel" id="folder_path_label">
+ <property name="visible">True</property>
+ <property name="halign">start</property>
+ <style>
+ <class name="dim-label"/>
+ </style>
+ </object>
+ </child>
+
+ <child>
+ <object class="GtkLabel" id="folder_name_label">
+ <property name="visible">True</property>
+ <property name="halign">start</property>
+ </object>
+ </child>
+ </object>
+ </child>
+
+ <child>
+ <object class="GtkButton">
+ <property name="visible">True</property>
+ <property name="valign">center</property>
+ <signal name="clicked" handler="on_delete_button_clicked"/>
+ <style>
+ <class name="flat"/>
+ </style>
+
+ <child>
+ <object class="GtkImage">
+ <property name="visible">True</property>
+ <property name="halign">end</property>
+ <property name="icon-name">window-close-symbolic</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </template>
+</interface>
diff --git a/src/spice-display.vala b/src/spice-display.vala
index a92c847..d930771 100644
--- a/src/spice-display.vala
+++ b/src/spice-display.vala
@@ -361,6 +361,10 @@ private class Boxes.SpiceDisplay: Boxes.Display {
} catch (GLib.Error error) {
}
+ var frame = create_shared_folders_frame ();
+
+ add_property (ref list, _("Folder Shares"), new Gtk.Label (""), frame);
+
break;
}
@@ -469,6 +473,58 @@ private class Boxes.SpiceDisplay: Boxes.Display {
return frame;
}
+ private Gtk.Frame create_shared_folders_frame () {
+ var frame = new Gtk.Frame (null);
+ var box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
+ var listbox = new Gtk.ListBox ();
+ var button_plus = new Gtk.Button.from_icon_name ("list-add-symbolic", IconSize.BUTTON);
+ button_plus.halign = Gtk.Align.CENTER;
+ button_plus.get_style_context ().add_class ("flat");
+
+ box.pack_start (listbox, true, true, 0);
+ box.pack_end (button_plus, false, false, 6);
+ frame.add (box);
+
+ var popover = new SharedFolderPopover ();
+
+ button_plus.clicked.connect (() => {
+ popover.relative_to = button_plus;
+ popover.target_position = -1;
+
+ popover.popup ();
+ });
+
+ listbox.row_activated.connect ((row) => {
+ popover.relative_to = row;
+ popover.target_position = row.get_index ();
+
+ var folder_row = row as SharedFolderRow;
+ popover.file_chooser_button.set_uri ("file://" + folder_row.folder_path);
+ popover.name_entry.set_text (folder_row.folder_name);
+
+ popover.popup ();
+ });
+
+ popover.saved.connect ((path, name, target_position) => {
+ add_listbox_row (listbox, path, name, target_position);
+ });
+
+ return frame;
+ }
+
+ private void add_listbox_row (Gtk.ListBox listbox, string path, string name, int target_position) {
+ var listboxrow = new SharedFolderRow (path, name);
+
+ if (target_position != -1)
+ listbox.remove (listbox.get_row_at_index (target_position));
+
+ listbox.insert (listboxrow, target_position);
+
+ listboxrow.removed.connect (() => {
+ listbox.remove (listboxrow);
+ });
+ }
+
private bool is_usb_kbd_or_mouse (uint8 class, uint8 subclass, uint8 protocol) {
var ret = false;
@@ -577,3 +633,28 @@ static void spice_validate_uri (string uri_as_text,
throw new Boxes.Error.INVALID (_("Invalid URL"));
}
}
+
+[GtkTemplate (ui = "/org/gnome/Boxes/ui/properties-shared-folder-row.ui")]
+private class Boxes.SharedFolderRow : Gtk.ListBoxRow {
+ public string folder_path { set; get; }
+ public string folder_name { set; get; }
+
+ public signal void removed ();
+ [GtkChild]
+ private Gtk.Label folder_path_label;
+ [GtkChild]
+ private Gtk.Label folder_name_label;
+
+ public SharedFolderRow (string path, string name) {
+ this.folder_path = path;
+ this.folder_name = name;
+
+ bind_property ("folder_path", folder_path_label, "label", BindingFlags.SYNC_CREATE);
+ bind_property ("folder_name", folder_name_label, "label", BindingFlags.SYNC_CREATE);
+ }
+
+ [GtkCallback]
+ private void on_delete_button_clicked () {
+ removed ();
+ }
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]