Merge lp:~jeremywootten/pantheon-files/bookmark-delete-by-dragging into lp:~elementary-apps/pantheon-files/trunk

Proposed by Jeremy Wootten
Status: Merged
Approved by: Cody Garver
Approved revision: 1437
Merged at revision: 1456
Proposed branch: lp:~jeremywootten/pantheon-files/bookmark-delete-by-dragging
Merge into: lp:~elementary-apps/pantheon-files/trunk
Diff against target: 240 lines (+155/-4)
4 files modified
icons/CMakeLists.txt (+1/-1)
libwidgets/CMakeLists.txt (+8/-2)
libwidgets/PoofWindow.vala (+117/-0)
src/View/Sidebar.vala (+29/-1)
To merge this branch: bzr merge lp:~jeremywootten/pantheon-files/bookmark-delete-by-dragging
Reviewer Review Type Date Requested Status
elementary Apps team Pending
Review via email: mp+206615@code.launchpad.net

This proposal supersedes a proposal from 2014-02-16.

Commit message

Dragging a bookmark completely out of the sidebar window now triggers its removal.
The "PoofWindow" animation code and graphic from Plank has been copied into the Files code. This fixes bug #691696.

Description of the change

Dragging a bookmark completely out of the sidebar window now triggers its removal.
The "PoofWindow" animation code and graphic from Plank has been copied into the Files code.
In the longer term, it would be desirable to have this animation, or a similar one, provided by Granite to both Files and Plank (and potentially other Elementary apps) for consistency and to avoid duplication of code. See https://blueprints.launchpad.net/granite/+spec/granite-animations.

At the moment, the animation is only triggered by dragging out of window. Other means of deleting a bookmark (context menu or keyboard shortcut) are not animated. This could be added if thought desirable.

Re-submitted after replacing tabs by spaces in Plank derived files and removing unused Plank derived file.

To post a comment you must log in.
Revision history for this message
Rico Tzschichholz (ricotz) wrote :

There is no need for the AnimatedRenderer.

Drop CompositedWindows as well and add the needed calls of construct {...} to PoofWindow

1434. By Jeremy Wootten

Merge CompositedWindow construction into PoofWindow

1435. By Jeremy Wootten

Reformat and refactor PoofWindow code - animation speed controlled by MSEC_PER_FRAME

Revision history for this message
Jeremy Wootten (jeremywootten) wrote :

Thanks for the suggestions Rico - I have done as you have suggested. While
refactoring PoofWindow I have added a separate revision that reformats it
according to the coding guidelines and also made it a little clearer (I
think). The animation speed is more easily controlled by setting the
MSEC_PER_FRAME value. I have slowed it down a little but that is a matter
of taste. Bookmarks are less explosive than launchers!?

On Mon, Feb 17, 2014 at 7:55 PM, Rico Tzschichholz <email address hidden>wrote:

> There is no need for the AnimatedRenderer.
>
> Drop CompositedWindows as well and add the needed calls of construct {...}
> to PoofWindow
> --
>
> https://code.launchpad.net/~jeremywootten/pantheon-files/bookmark-delete-by-dragging/+merge/206615
> You are the owner of
> lp:~jeremywootten/pantheon-files/bookmark-delete-by-dragging.
>

Revision history for this message
Cody Garver (codygarver) wrote :

Needs trunk merged in then I will request an animation speed review from Dan

1436. By Jeremy Wootten

Merge changes from trunk and reimplement in sidebar.vala

Revision history for this message
Jeremy Wootten (jeremywootten) wrote :

> Needs trunk merged in then I will request an animation speed review from Dan

Trunk now merged and C code reimplemented in Sidebar.vala

Revision history for this message
Danielle Foré (danrabbit) wrote :

Hmm, how do we feel about something like 60ms per frame? should be a 300ms animation.

1437. By Jeremy Wootten

Set frame rate to 60 msec per frame

Revision history for this message
Jeremy Wootten (jeremywootten) wrote :

OK, done.

On 23 March 2014 19:36, Daniel Fore <email address hidden> wrote:

> Hmm, how do we feel about something like 60ms per frame? should be a 300ms
> animation.
>
> --
>
> https://code.launchpad.net/~jeremywootten/pantheon-files/bookmark-delete-by-dragging/+merge/206615
> You are the owner of
> lp:~jeremywootten/pantheon-files/bookmark-delete-by-dragging.
>

Revision history for this message
Rico Tzschichholz (ricotz) wrote :

@cody: Did you test-built this?

Revision history for this message
Rico Tzschichholz (ricotz) wrote :

@cody: Pushed a fix to trunk

Revision history for this message
Cody Garver (codygarver) wrote :

Thanks a lot Rico

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'icons/CMakeLists.txt'
2--- icons/CMakeLists.txt 2013-05-19 10:30:14 +0000
3+++ icons/CMakeLists.txt 2014-03-24 19:47:08 +0000
4@@ -1,1 +1,1 @@
5-install(FILES thumbnail_frame.png DESTINATION ${PIXMAP_DIR})
6\ No newline at end of file
7+install(FILES thumbnail_frame.png poof.png DESTINATION ${PIXMAP_DIR})
8
9=== added file 'icons/poof.png'
10Binary files icons/poof.png 1970-01-01 00:00:00 +0000 and icons/poof.png 2014-03-24 19:47:08 +0000 differ
11=== modified file 'libwidgets/CMakeLists.txt'
12--- libwidgets/CMakeLists.txt 2014-01-24 18:36:41 +0000
13+++ libwidgets/CMakeLists.txt 2014-03-24 19:47:08 +0000
14@@ -23,19 +23,23 @@
15
16 set(CFLAGS ${DEPS_CFLAGS} ${DEPS_CFLAGS_OTHER})
17 set(LIBS
18- ${DEP_LIBRARIES}
19+ ${DEP_LIBRARIES}
20 )
21 add_definitions(${CFLAGS})
22
23 link_libraries(${LIBS})
24 set(LIB_PATHS
25- ${DEPS_LIBRARY_DIRS}
26+ ${DEPS_LIBRARY_DIRS}
27 )
28 link_directories(${LIB_PATHS})
29
30+include_directories (${CMAKE_CURRENT_BINARY_DIR})
31+include_directories (${CMAKE_BINARY_DIR})
32+
33 vala_precompile(VALA_C ${PKGNAME}
34 Animations.vala
35 LocationBar.vala
36+ PoofWindow.vala
37 BreadcrumbsElements.vala
38 BreadcrumbsEntry.vala
39 PACKAGES
40@@ -43,6 +47,8 @@
41 granite
42 gee-0.8
43 posix
44+ marlincore
45+ marlincore-C
46 OPTIONS
47 --thread
48 GENERATE_VAPI
49
50=== added file 'libwidgets/PoofWindow.vala'
51--- libwidgets/PoofWindow.vala 1970-01-01 00:00:00 +0000
52+++ libwidgets/PoofWindow.vala 2014-03-24 19:47:08 +0000
53@@ -0,0 +1,117 @@
54+//
55+// Copyright (C) 2011-2012 Robert Dyer, Rico Tzschichholz
56+//
57+// This program is free software: you can redistribute it and/or modify
58+// it under the terms of the GNU General Public License as published by
59+// the Free Software Foundation, either version 3 of the License, or
60+// (at your option) any later version.
61+//
62+// This program is distributed in the hope that it will be useful,
63+// but WITHOUT ANY WARRANTY; without even the implied warranty of
64+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
65+// GNU General Public License for more details.
66+//
67+// You should have received a copy of the GNU General Public License
68+// along with this program. If not, see <http://www.gnu.org/licenses/>.
69+//
70+
71+namespace Marlin.Animation
72+{
73+ /**
74+ * An animated window that draws a 'poof' animation.
75+ * Used when dragging items off the dock.
76+ */
77+ public class PoofWindow : Gtk.Window {
78+ const int POOF_SIZE = 128;
79+ const int POOF_FRAMES = 5;
80+ const int MSEC_PER_FRAME = 60;
81+ int frame_number = 0;
82+
83+ static PoofWindow? instance = null;
84+
85+ public static unowned PoofWindow get_default () {
86+ if (instance == null)
87+ instance = new PoofWindow ();
88+
89+ return instance;
90+ }
91+
92+ Gdk.Pixbuf poof_image;
93+
94+ uint animation_timer = 0;
95+
96+ /**
97+ * Creates a new poof window at the screen-relative coordinates specified.
98+ */
99+ public PoofWindow () {
100+ GLib.Object (type: Gtk.WindowType.TOPLEVEL, type_hint: Gdk.WindowTypeHint.DOCK);
101+ }
102+
103+ construct {
104+ app_paintable = true;
105+ decorated = false;
106+ resizable = false;
107+ double_buffered = false;
108+
109+ unowned Gdk.Screen screen = get_screen ();
110+ set_visual (screen.get_rgba_visual () ?? screen.get_system_visual ());
111+ accept_focus = false;
112+ can_focus = false;
113+ set_keep_above (true);
114+
115+ try {
116+ poof_image = new Gdk.Pixbuf.from_file ("%s/poof.png".printf (Config.PIXMAP_DIR));
117+ } catch {
118+ poof_image = new Gdk.Pixbuf (Gdk.Colorspace.RGB, true, 8, 128, 640);
119+ warning ("Unable to load poof animation image");
120+ }
121+
122+ set_size_request (POOF_SIZE, POOF_SIZE);
123+ }
124+
125+ ~PoofWindow () {
126+ if (animation_timer > 0) {
127+ GLib.Source.remove (animation_timer);
128+ animation_timer = 0;
129+ }
130+ }
131+
132+ /**
133+ * Show the animated poof-window at the given coordinates
134+ *
135+ * @param x the x position of the poof window
136+ * @param y the y position of the poof window
137+ */
138+ public void show_at (int x, int y) {
139+ if (animation_timer > 0)
140+ GLib.Source.remove (animation_timer);
141+
142+ frame_number = 0;
143+
144+ show ();
145+ move (x - (POOF_SIZE / 2), y - (POOF_SIZE / 2));
146+
147+ animation_timer = Gdk.threads_add_timeout (MSEC_PER_FRAME, () => {
148+ if (frame_number++ < POOF_FRAMES) {
149+ queue_draw ();
150+ return true;
151+ }
152+
153+ animation_timer = 0;
154+ hide ();
155+ return false;
156+ });
157+ }
158+
159+ public override bool draw (Cairo.Context cr) {
160+ cr.set_operator (Cairo.Operator.SOURCE);
161+ Gdk.cairo_set_source_pixbuf (cr,
162+ poof_image,
163+ 0,
164+ -POOF_SIZE * frame_number);
165+ cr.paint ();
166+
167+ return true;
168+ }
169+ }
170+}
171
172=== modified file 'src/View/Sidebar.vala'
173--- src/View/Sidebar.vala 2014-03-16 18:08:56 +0000
174+++ src/View/Sidebar.vala 2014-03-24 19:47:08 +0000
175@@ -70,6 +70,8 @@
176 Gdk.DragContext drag_context;
177 bool received_drag_data;
178 bool drop_occurred;
179+ bool internal_drag_started;
180+ bool dragged_out_of_window;
181
182 /* Identifiers for target types */
183 public enum TargetType {
184@@ -260,6 +262,8 @@
185 tree_view.drag_leave.connect (drag_leave_callback);
186 tree_view.drag_data_received.connect (drag_data_received_callback);
187 tree_view.drag_drop.connect (drag_drop_callback);
188+ tree_view.drag_failed.connect (drag_failed_callback);
189+ tree_view.drag_end.connect (drag_end_callback);
190
191 (tree_view.get_selection ()).changed.connect (selection_changed_cb);
192 tree_view.popup_menu.connect (popup_menu_cb);
193@@ -692,6 +696,27 @@
194
195 /* DRAG N DROP FUNCTIONS START */
196
197+ private bool drag_failed_callback (Gdk.DragContext context, Gtk.DragResult result) {
198+ int x, y;
199+ Gdk.Device device;
200+ Marlin.Animation.PoofWindow poof_window;
201+
202+ if (internal_drag_started && dragged_out_of_window) {
203+ device = context.get_device ();
204+ device.get_position (null, out x, out y);
205+ poof_window = Marlin.Animation.PoofWindow.get_default ();
206+ poof_window.show_at (x, y);
207+ remove_selected_bookmarks ();
208+ return true;
209+ } else
210+ return false;
211+ }
212+
213+ private void drag_end_callback (Gdk.DragContext context) {
214+ internal_drag_started = false;
215+ dragged_out_of_window = false;
216+ }
217+
218 private bool drag_motion_callback (Gdk.DragContext context,
219 int x,
220 int y,
221@@ -709,8 +734,10 @@
222 if (pos == Gtk.TreeViewDropPosition.BEFORE
223 || pos == Gtk.TreeViewDropPosition.AFTER) {
224 if (received_drag_data
225- && drag_data_info == TargetType.GTK_TREE_MODEL_ROW)
226+ && drag_data_info == TargetType.GTK_TREE_MODEL_ROW) {
227 action = Gdk.DragAction.MOVE;
228+ internal_drag_started = true;
229+ }
230 else if (drag_list != null
231 && can_accept_files_as_bookmarks (drag_list))
232 action = Gdk.DragAction.COPY;
233@@ -877,6 +904,7 @@
234 }
235
236 private void drag_leave_callback (Gdk.DragContext context, uint time) {
237+ dragged_out_of_window = true;
238 free_drag_data ();
239 tree_view.set_drag_dest_row (null, Gtk.TreeViewDropPosition.BEFORE);
240 GLib.Signal.stop_emission_by_name (tree_view, "drag-leave");

Subscribers

People subscribed via source and target branches

to all changes: