From 2f0e3dcf2e88620d0313d2613bab3ac4a2917ec0 Mon Sep 17 00:00:00 2001 From: Tom Beckmann Date: Thu, 27 Jun 2013 15:41:18 +0200 Subject: [PATCH] move values to constants, rename signals to closer match ClutterDragAction --- src/DragDropAction.vala | 12 ++++++------ src/Widgets/AppIcon.vala | 15 ++++++++------- src/Widgets/WorkspaceThumb.vala | 9 ++++++--- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/src/DragDropAction.vala b/src/DragDropAction.vala index 407ab2ad..3c31bd92 100644 --- a/src/DragDropAction.vala +++ b/src/DragDropAction.vala @@ -37,19 +37,19 @@ namespace Gala * A drag has been started. You have to connect to this signal * @return A ClutterActor that serves as handle **/ - public signal Clutter.Actor started (); + public signal Clutter.Actor drag_begin (); /** * A drag has been canceled. You may want to consider cleaning up * your handle. **/ - public signal void canceled (); + public signal void drag_canceled (); /** * A drag action has successfully been finished. * @param actor The actor on which the drag finished **/ - public signal void finished (Clutter.Actor actor); + public signal void drag_end (Clutter.Actor actor); /** * The destination has been crossed @@ -118,7 +118,7 @@ namespace Gala if (!clicked) return false; - handle = started (); + handle = drag_begin (); if (handle == null) { critical ("No handle has been returned by the started signal, aborting drag."); return false; @@ -205,7 +205,7 @@ namespace Gala actor.get_stage ().captured_event.disconnect (follow_move); } - canceled (); + drag_canceled (); dragging = false; } @@ -215,7 +215,7 @@ namespace Gala get_drag_drop_action (hovered).crossed (false); actor.get_stage ().captured_event.disconnect (follow_move); - finished (hovered); + drag_end (hovered); } } } diff --git a/src/Widgets/AppIcon.vala b/src/Widgets/AppIcon.vala index 6c46ac60..62aa8a10 100644 --- a/src/Widgets/AppIcon.vala +++ b/src/Widgets/AppIcon.vala @@ -22,6 +22,7 @@ namespace Gala { public class AppIcon : GtkClutter.Texture { + const string DRAG_ACTION = "drag"; Window window; Bamf.Application app; @@ -35,18 +36,18 @@ namespace Gala set_from_pixbuf (Utils.get_icon_for_window (window, WorkspaceThumb.APP_ICON_SIZE)); } catch (Error e) { warning (e.message); } - var action = new DragDropAction (DragDropActionType.SOURCE, "app-icon"); - action.started.connect (drag_started); - action.finished.connect (drag_finished); - action.canceled.connect (drag_failed); + var action = new DragDropAction (DragDropActionType.SOURCE, WorkspaceThumb.DRAG_ID); + action.drag_begin.connect (drag_started); + action.drag_end.connect (drag_finished); + action.drag_canceled.connect (drag_failed); - add_action_with_name ("drag", action); + add_action_with_name (DRAG_ACTION, action); reactive = true; } void drag_failed () { - var action = get_action ("drag") as DragDropAction; + var action = get_action (DRAG_ACTION) as DragDropAction; float ax, ay; get_transformed_position (out ax, out ay); @@ -59,7 +60,7 @@ namespace Gala void drag_finished (Actor destination) { - var action = get_action ("drag") as DragDropAction; + var action = get_action (DRAG_ACTION) as DragDropAction; action.handle.destroy (); WorkspaceThumb old = get_parent ().get_parent () as WorkspaceThumb; diff --git a/src/Widgets/WorkspaceThumb.vala b/src/Widgets/WorkspaceThumb.vala index 95c4d910..6fdc768d 100644 --- a/src/Widgets/WorkspaceThumb.vala +++ b/src/Widgets/WorkspaceThumb.vala @@ -26,11 +26,14 @@ namespace Gala internal static const int APP_ICON_SIZE = 32; static const float THUMBNAIL_HEIGHT = 80.0f; static const uint CLOSE_BUTTON_DELAY = 500; - + static const int PLUS_SIZE = 8; static const int PLUS_WIDTH = 24; static const int PLUS_OFFSET = 8; + public static const string DRAG_ID = "app-icon"; + const string DROP_ACTION = "drop"; + public signal void clicked (); public signal void closed (); public signal void window_on_last (); @@ -171,8 +174,8 @@ namespace Gala canvas.set_size ((int)plus.width, (int)plus.height); } - var drop_action = new DragDropAction (DragDropActionType.DESTINATION, "app-icon"); - add_action_with_name ("drop", drop_action); + var drop_action = new DragDropAction (DragDropActionType.DESTINATION, DRAG_ID); + add_action_with_name (DROP_ACTION, drop_action); drop_action.crossed.connect (crossed); check_last_workspace ();