[gnome-boxes] display-page: Show drag and drop message
- From: Felipe Borges <felipeborges src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] display-page: Show drag and drop message
- Date: Mon, 5 Feb 2018 14:56:23 +0000 (UTC)
commit 49d32e2764304f888ee85f3eb732db60b0a0ed04
Author: Visarion Alexandru <viorel visarion gmail com>
Date: Sat Nov 11 17:58:43 2017 +0200
display-page: Show drag and drop message
Currently, when transferring files through DnD, the user
isn't aware of the actual destination of the files and doesn't
receive any visual feedback.
Let's show a message when the user is hovering with a file over a
display which can receive files(currently only SPICE), informing him
that he is about to send files to the machine and pointing to him
the destination of the files.
https://bugzilla.gnome.org/show_bug.cgi?id=762321
data/ui/display-page.ui | 84 +++++++++++++++++++++++++++++++++++++++++++++++++
src/display-page.vala | 42 ++++++++++++++++++++++++-
2 files changed, 125 insertions(+), 1 deletion(-)
---
diff --git a/data/ui/display-page.ui b/data/ui/display-page.ui
index 24da3be8..cf2b3aee 100644
--- a/data/ui/display-page.ui
+++ b/data/ui/display-page.ui
@@ -41,6 +41,90 @@
</object>
</child>
+ <child type="overlay">
+ <object class="GtkBox" id="transfer_message_box">
+ <property name="can_focus">False</property>
+ <property name="halign">fill</property>
+ <property name="valign">fill</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
+ <style>
+ <class name="app-notification"/>
+ </style>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">end</property>
+ <property name="valign">center</property>
+ <property name="margin_right">24</property>
+ <property name="stock">gtk-save</property>
+ <property name="icon_size">6</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child type="center">
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">start</property>
+ <property name="valign">center</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">start</property>
+ <property name="margin_left">4</property>
+ <property name="label" translatable="yes">Ready to Receive File</property>
+ <property name="justify">center</property>
+ <style>
+ <class name="tooltip"/>
+ </style>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="vexpand">True</property>
+ <property name="label" translatable="yes">You will find your file in the Downloads
directory.</property>
+ <property name="wrap">True</property>
+ <property name="max_width_chars">25</property>
+ <style>
+ <class name="dim-label"/>
+ </style>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+
<child>
<object class="GtkEventBox" id="event_box">
<property name="visible">True</property>
diff --git a/src/display-page.vala b/src/display-page.vala
index cfbb2e8e..3515bf60 100644
--- a/src/display-page.vala
+++ b/src/display-page.vala
@@ -12,6 +12,8 @@
[GtkChild]
public Gtk.Label size_label;
+ [GtkChild]
+ public Gtk.Box transfer_message_box;
[GtkChild]
private EventBox event_box;
[GtkChild]
@@ -21,6 +23,9 @@
private uint toolbar_hide_id;
private uint toolbar_show_id;
private ulong cursor_id;
+ private ulong widget_drag_motion_id = 0;
+ private ulong transfer_message_box_drag_leave_id = 0;
+ private ulong transfer_message_box_drag_motion_id = 0;
private uint overlay_toolbar_invisible_timeout;
private uint size_label_timeout;
@@ -67,6 +72,12 @@ public void setup_ui (AppWindow window) {
toolbar.setup_ui (window);
overlay_toolbar.setup_ui (window);
+
+ Gtk.TargetEntry[] target_list = {};
+ Gtk.TargetEntry urilist_entry = { "text/uri-list", 0, 0 };
+ target_list += urilist_entry;
+
+ drag_dest_set (transfer_message_box, Gtk.DestDefaults.DROP, target_list, DragAction.ASK);
}
private void update_toolbar_visible() {
@@ -127,6 +138,20 @@ public void replace_display (Boxes.Display display, Widget widget) {
remove_display ();
+ if (display.can_transfer_files) {
+ widget_drag_motion_id = widget.drag_motion.connect (() => {
+ transfer_message_box.visible = true;
+
+ return true;
+ });
+ transfer_message_box_drag_motion_id = transfer_message_box.drag_motion.connect (() => {
+ return true;
+ });
+ transfer_message_box_drag_leave_id = transfer_message_box.drag_leave.connect (() => {
+ transfer_message_box.hide ();
+ });
+ }
+
this.display = display;
mouse_grabbed_id = display.notify["mouse-grabbed"].connect(() => {
// In some cases this is sent inside size_allocate (see bug #692465)
@@ -197,8 +222,23 @@ public void replace_display (Boxes.Display display, Widget widget) {
cursor_id = 0;
}
- if (widget != null)
+ if (transfer_message_box_drag_leave_id != 0) {
+ transfer_message_box.disconnect (transfer_message_box_drag_leave_id);
+ transfer_message_box_drag_leave_id = 0;
+ }
+ if (transfer_message_box_drag_motion_id != 0) {
+ transfer_message_box.disconnect (transfer_message_box_drag_motion_id);
+ transfer_message_box_drag_motion_id = 0;
+ }
+
+ if (widget != null) {
+ if (widget_drag_motion_id != 0) {
+ widget.disconnect (widget_drag_motion_id);
+ widget_drag_motion_id = 0;
+ }
+
event_box.remove (widget);
+ }
return widget;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]