Use MotionDirection enum instead of bool where possible

This commit is contained in:
Rico Tzschichholz 2012-07-19 13:13:28 +02:00
parent 2fb7f4e34c
commit 98323e7540
2 changed files with 13 additions and 13 deletions

View File

@ -100,8 +100,8 @@ namespace Gala
KeyBinding.set_custom_handler ("move-to-workspace-up", () => {});
KeyBinding.set_custom_handler ("move-to-workspace-down", () => {});
KeyBinding.set_custom_handler ("move-to-workspace-left", (d, s, w) => move_window (w, true) );
KeyBinding.set_custom_handler ("move-to-workspace-right", (d, s, w) => move_window (w, false) );
KeyBinding.set_custom_handler ("move-to-workspace-left", (d, s, w) => move_window (w, MotionDirection.LEFT) );
KeyBinding.set_custom_handler ("move-to-workspace-right", (d, s, w) => move_window (w, MotionDirection.RIGHT) );
KeyBinding.set_custom_handler ("switch-group", () => {});
KeyBinding.set_custom_handler ("switch-group-backward", () => {});
@ -143,20 +143,20 @@ namespace Gala
}
public void move_window (Window? window, bool reverse)
public void move_window (Window? window, MotionDirection direction)
{
if (window == null)
return;
// if there is still an unfinished window-move don't be silly and use it
if (moving != null)
window = moving
window = moving;
var screen = get_screen ();
var display = screen.get_display ();
var active = screen.get_active_workspace ();
var next = active.get_neighbor (reverse ? MotionDirection.LEFT : MotionDirection.RIGHT);
var next = active.get_neighbor (direction);
//dont allow empty workspaces to be created by moving
if (active.n_windows == 1 && next.index () == screen.n_workspaces - 1)

View File

@ -186,12 +186,12 @@ namespace Gala
}
}
void switch_to_next_workspace (bool reverse)
void switch_to_next_workspace (MotionDirection direction)
{
var screen = plugin.get_screen ();
var display = screen.get_display ();
var neighbor = screen.get_active_workspace ().get_neighbor (reverse ? MotionDirection.LEFT : MotionDirection.RIGHT);
var neighbor = screen.get_active_workspace ().get_neighbor (direction);
if (neighbor == null)
return;
@ -211,15 +211,15 @@ namespace Gala
switch (event.keyval) {
case Clutter.Key.Left:
if ((event.modifier_state & Clutter.ModifierType.SHIFT_MASK) == 1)
plugin.move_window (screen.get_display ().get_focus_window (), true);
plugin.move_window (screen.get_display ().get_focus_window (), MotionDirection.LEFT);
else
switch_to_next_workspace (true);
switch_to_next_workspace (MotionDirection.LEFT);
return false;
case Clutter.Key.Right:
if ((event.modifier_state & Clutter.ModifierType.SHIFT_MASK) == 1)
plugin.move_window (screen.get_display ().get_focus_window (), false);
plugin.move_window (screen.get_display ().get_focus_window (), MotionDirection.RIGHT);
else
switch_to_next_workspace (false);
switch_to_next_workspace (MotionDirection.RIGHT);
return false;
default:
break;
@ -358,8 +358,8 @@ namespace Gala
public void handle_switch_to_workspace (Meta.Display display, Meta.Screen screen, Meta.Window? window,
X.Event event, Meta.KeyBinding binding)
{
bool left = (binding.get_name () == "switch-to-workspace-left");
switch_to_next_workspace (left);
var direction = (binding.get_name () == "switch-to-workspace-left" ? MotionDirection.LEFT : MotionDirection.RIGHT);
switch_to_next_workspace (direction);
show (true);
}