mirror of
https://github.com/elementary/gala.git
synced 2024-09-17 10:27:37 +03:00
move values to constants, rename signals to closer match ClutterDragAction
This commit is contained in:
parent
eeccd29bbe
commit
2f0e3dcf2e
@ -37,19 +37,19 @@ namespace Gala
|
|||||||
* A drag has been started. You have to connect to this signal
|
* A drag has been started. You have to connect to this signal
|
||||||
* @return A ClutterActor that serves as handle
|
* @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
|
* A drag has been canceled. You may want to consider cleaning up
|
||||||
* your handle.
|
* your handle.
|
||||||
**/
|
**/
|
||||||
public signal void canceled ();
|
public signal void drag_canceled ();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A drag action has successfully been finished.
|
* A drag action has successfully been finished.
|
||||||
* @param actor The actor on which the drag 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
|
* The destination has been crossed
|
||||||
@ -118,7 +118,7 @@ namespace Gala
|
|||||||
if (!clicked)
|
if (!clicked)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
handle = started ();
|
handle = drag_begin ();
|
||||||
if (handle == null) {
|
if (handle == null) {
|
||||||
critical ("No handle has been returned by the started signal, aborting drag.");
|
critical ("No handle has been returned by the started signal, aborting drag.");
|
||||||
return false;
|
return false;
|
||||||
@ -205,7 +205,7 @@ namespace Gala
|
|||||||
actor.get_stage ().captured_event.disconnect (follow_move);
|
actor.get_stage ().captured_event.disconnect (follow_move);
|
||||||
}
|
}
|
||||||
|
|
||||||
canceled ();
|
drag_canceled ();
|
||||||
dragging = false;
|
dragging = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -215,7 +215,7 @@ namespace Gala
|
|||||||
get_drag_drop_action (hovered).crossed (false);
|
get_drag_drop_action (hovered).crossed (false);
|
||||||
|
|
||||||
actor.get_stage ().captured_event.disconnect (follow_move);
|
actor.get_stage ().captured_event.disconnect (follow_move);
|
||||||
finished (hovered);
|
drag_end (hovered);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@ namespace Gala
|
|||||||
{
|
{
|
||||||
public class AppIcon : GtkClutter.Texture
|
public class AppIcon : GtkClutter.Texture
|
||||||
{
|
{
|
||||||
|
const string DRAG_ACTION = "drag";
|
||||||
|
|
||||||
Window window;
|
Window window;
|
||||||
Bamf.Application app;
|
Bamf.Application app;
|
||||||
@ -35,18 +36,18 @@ namespace Gala
|
|||||||
set_from_pixbuf (Utils.get_icon_for_window (window, WorkspaceThumb.APP_ICON_SIZE));
|
set_from_pixbuf (Utils.get_icon_for_window (window, WorkspaceThumb.APP_ICON_SIZE));
|
||||||
} catch (Error e) { warning (e.message); }
|
} catch (Error e) { warning (e.message); }
|
||||||
|
|
||||||
var action = new DragDropAction (DragDropActionType.SOURCE, "app-icon");
|
var action = new DragDropAction (DragDropActionType.SOURCE, WorkspaceThumb.DRAG_ID);
|
||||||
action.started.connect (drag_started);
|
action.drag_begin.connect (drag_started);
|
||||||
action.finished.connect (drag_finished);
|
action.drag_end.connect (drag_finished);
|
||||||
action.canceled.connect (drag_failed);
|
action.drag_canceled.connect (drag_failed);
|
||||||
|
|
||||||
add_action_with_name ("drag", action);
|
add_action_with_name (DRAG_ACTION, action);
|
||||||
reactive = true;
|
reactive = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void drag_failed ()
|
void drag_failed ()
|
||||||
{
|
{
|
||||||
var action = get_action ("drag") as DragDropAction;
|
var action = get_action (DRAG_ACTION) as DragDropAction;
|
||||||
|
|
||||||
float ax, ay;
|
float ax, ay;
|
||||||
get_transformed_position (out ax, out ay);
|
get_transformed_position (out ax, out ay);
|
||||||
@ -59,7 +60,7 @@ namespace Gala
|
|||||||
|
|
||||||
void drag_finished (Actor destination)
|
void drag_finished (Actor destination)
|
||||||
{
|
{
|
||||||
var action = get_action ("drag") as DragDropAction;
|
var action = get_action (DRAG_ACTION) as DragDropAction;
|
||||||
action.handle.destroy ();
|
action.handle.destroy ();
|
||||||
|
|
||||||
WorkspaceThumb old = get_parent ().get_parent () as WorkspaceThumb;
|
WorkspaceThumb old = get_parent ().get_parent () as WorkspaceThumb;
|
||||||
|
@ -26,11 +26,14 @@ namespace Gala
|
|||||||
internal static const int APP_ICON_SIZE = 32;
|
internal static const int APP_ICON_SIZE = 32;
|
||||||
static const float THUMBNAIL_HEIGHT = 80.0f;
|
static const float THUMBNAIL_HEIGHT = 80.0f;
|
||||||
static const uint CLOSE_BUTTON_DELAY = 500;
|
static const uint CLOSE_BUTTON_DELAY = 500;
|
||||||
|
|
||||||
static const int PLUS_SIZE = 8;
|
static const int PLUS_SIZE = 8;
|
||||||
static const int PLUS_WIDTH = 24;
|
static const int PLUS_WIDTH = 24;
|
||||||
static const int PLUS_OFFSET = 8;
|
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 clicked ();
|
||||||
public signal void closed ();
|
public signal void closed ();
|
||||||
public signal void window_on_last ();
|
public signal void window_on_last ();
|
||||||
@ -171,8 +174,8 @@ namespace Gala
|
|||||||
canvas.set_size ((int)plus.width, (int)plus.height);
|
canvas.set_size ((int)plus.width, (int)plus.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
var drop_action = new DragDropAction (DragDropActionType.DESTINATION, "app-icon");
|
var drop_action = new DragDropAction (DragDropActionType.DESTINATION, DRAG_ID);
|
||||||
add_action_with_name ("drop", drop_action);
|
add_action_with_name (DROP_ACTION, drop_action);
|
||||||
drop_action.crossed.connect (crossed);
|
drop_action.crossed.connect (crossed);
|
||||||
|
|
||||||
check_last_workspace ();
|
check_last_workspace ();
|
||||||
|
Loading…
Reference in New Issue
Block a user