move values to constants, rename signals to closer match ClutterDragAction

This commit is contained in:
Tom Beckmann 2013-06-27 15:41:18 +02:00
parent eeccd29bbe
commit 2f0e3dcf2e
3 changed files with 20 additions and 16 deletions

View File

@ -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);
}
}
}

View File

@ -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;

View File

@ -31,6 +31,9 @@ namespace Gala
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 ();