[gnome-boxes] Add TransferInfoRow
- From: Felipe Borges <felipeborges src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] Add TransferInfoRow
- Date: Mon, 5 Feb 2018 14:56:28 +0000 (UTC)
commit e66d3fb4da40794f191484b2cb196f794588d1ec
Author: Visarion Alexandru <viorel visarion gmail com>
Date: Thu Dec 14 19:05:53 2017 +0200
Add TransferInfoRow
Add a custom row which represents a file transfer between
the host and a guest machine.
https://bugzilla.gnome.org/show_bug.cgi?id=762321
data/gnome-boxes.gresource.xml | 1 +
data/ui/transfer-info-row.ui | 81 ++++++++++++++++++++++++++++++++++++++++++
src/Makefile.am | 1 +
src/meson.build | 1 +
src/transfer-info-row.vala | 53 +++++++++++++++++++++++++++
5 files changed, 137 insertions(+)
---
diff --git a/data/gnome-boxes.gresource.xml b/data/gnome-boxes.gresource.xml
index 2abaa94c..df3de724 100644
--- a/data/gnome-boxes.gresource.xml
+++ b/data/gnome-boxes.gresource.xml
@@ -30,6 +30,7 @@
<file preprocess="xml-stripblanks">ui/shared-folder-popover.ui</file>
<file preprocess="xml-stripblanks">ui/snapshot-list-row.ui</file>
<file preprocess="xml-stripblanks">ui/topbar.ui</file>
+ <file preprocess="xml-stripblanks">ui/transfer-info-row.ui</file>
<file preprocess="xml-stripblanks">ui/troubleshoot-log.ui</file>
<file preprocess="xml-stripblanks">ui/troubleshoot-view.ui</file>
<file preprocess="xml-stripblanks">ui/unattended-setup-box.ui</file>
diff --git a/data/ui/transfer-info-row.ui b/data/ui/transfer-info-row.ui
new file mode 100644
index 00000000..0fa5e238
--- /dev/null
+++ b/data/ui/transfer-info-row.ui
@@ -0,0 +1,81 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <template class="BoxesTransferInfoRow" parent="GtkGrid">
+ <property name="visible">True</property>
+ <property name="margin-start">5</property>
+ <property name="margin-end">5</property>
+ <child>
+ <object class="GtkLabel" id="status_label">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="width-request">300</property>
+ <property name="max-width-chars">40</property>
+ <property name="ellipsize">middle</property>
+ <property name="margin-bottom">6</property>
+ <property name="hexpand">True</property>
+ </object>
+ <packing>
+ <property name="top-attach">0</property>
+ <property name="left-attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkProgressBar" id="progress_bar">
+ <property name="visible">True</property>
+ <property name="valign">center</property>
+ <property name="pulse-step">0.05</property>
+ <property name="margin_start">2</property>
+ <property name="margin-bottom">4</property>
+ <property name="hexpand">True</property>
+ </object>
+ <packing>
+ <property name="top-attach">1</property>
+ <property name="left-attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="cancel_button">
+ <property name="visible">True</property>
+ <property name="receives_default">True</property>
+ <property name="margin_start">20</property>
+ <property name="valign">center</property>
+ <property name="image">cancel_image</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <style>
+ <class name="nautilus-circular-button"/>
+ </style>
+ </object>
+ <packing>
+ <property name="height">3</property>
+ <property name="top-attach">0</property>
+ <property name="left-attach">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="details_label">
+ <property name="visible">True</property>
+ <property name="label" translatable="no">label</property>
+ <property name="ellipsize">end</property>
+ <property name="xalign">0</property>
+ <property name="wrap">True</property>
+ <property name="wrap-mode">word-char</property>
+ <style>
+ <class name="dim-label"/>
+ </style>
+ </object>
+ <packing>
+ <property name="top-attach">2</property>
+ <property name="left-attach">0</property>
+ </packing>
+ </child>
+ </template>
+ <object class="GtkImage" id="cancel_image">
+ <property name="visible">True</property>
+ <property name="icon_name">window-close-symbolic</property>
+ </object>
+ <object class="GtkImage" id="done_image">
+ <property name="visible">True</property>
+ <property name="icon_name">object-select-symbolic</property>
+ </object>
+</interface>
diff --git a/src/Makefile.am b/src/Makefile.am
index 598a7cd7..7ecb62e9 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -160,6 +160,7 @@ gnome_boxes_SOURCES = \
downloader.vala \
empty-boxes.vala \
tracker-iso-query.vala \
+ transfer-info-row.vala \
troubleshoot-log.vala \
troubleshoot-view.vala \
shared-folder-popover.vala \
diff --git a/src/meson.build b/src/meson.build
index 708f74fc..4b9c66ec 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -86,6 +86,7 @@ vala_sources = [
'selection-toolbar.vala',
'shared-folder-popover.vala',
'spice-display.vala',
+ 'transfer-info-row.vala',
'troubleshoot-view.vala',
'topbar.vala',
'ui.vala',
diff --git a/src/transfer-info-row.vala b/src/transfer-info-row.vala
new file mode 100644
index 00000000..4dc1f7dc
--- /dev/null
+++ b/src/transfer-info-row.vala
@@ -0,0 +1,53 @@
+// This file is part of GNOME Boxes. License: LGPLv2+
+using Gtk;
+
+[GtkTemplate (ui = "/org/gnome/Boxes/ui/transfer-info-row.ui")]
+private class Boxes.TransferInfoRow: Gtk.Grid {
+ [GtkChild]
+ private Gtk.Label status_label;
+ [GtkChild]
+ private Gtk.Label details_label;
+ [GtkChild]
+ private Gtk.Button cancel_button;
+ [GtkChild]
+ private Gtk.ProgressBar progress_bar;
+ [GtkChild]
+ private Gtk.Image done_image;
+
+ public signal void finished ();
+
+ public double progress {get; set; }
+ public uint64 transferred_bytes {
+ set {
+ details_label.set_text ("%s / %s".printf (GLib.format_size (value), GLib.format_size
(total_bytes)));
+ }
+ }
+ public uint64 total_bytes { get; set; }
+
+ public TransferInfoRow (string name) {
+ progress = 0;
+
+ // Translators: "%s" is a file name.
+ var msg = _("Copying “%s” to “Downloads”".printf (trim_string (name)));
+ status_label.set_text (msg);
+
+ bind_property ("progress", progress_bar, "fraction", BindingFlags.BIDIRECTIONAL);
+ cancel_button.clicked.connect (() => {
+ finalize_transfer ();
+ finished ();
+ });
+ }
+
+ public void finalize_transfer () {
+ cancel_button.image = done_image;
+ cancel_button.set_sensitive (false);
+ cancel_button.queue_draw ();
+ }
+
+ private string trim_string (string s) {
+ if (s.length > 23)
+ return s.substring (0, 15) + "…" + s.substring (-4, -1);
+
+ return s;
+ }
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]