Commit 6abf46ad authored by Patrick Tierney's avatar Patrick Tierney

#2020: opens on external editor on super double click and ctrl-enter, opens...

#2020: opens on external editor on super double click and ctrl-enter, opens raw editor on ctrl-shift-enter
parent 7dec20a1
......@@ -604,13 +604,33 @@ public abstract class CollectionPage : CheckerboardPage {
#endif
}
protected override void on_item_activated(CheckerboardItem item) {
// doubel clcik = switch to photo page
// Super + double click = open in external editor
// Enter = switch to PhotoPage
// Ctrl + Enter = open in external editor
// Shift + Ctrl + Enter = open in external RAW editor
protected override void on_item_activated(CheckerboardItem item, CheckerboardPage.Activator
activator, CheckerboardPage.KeyboardModifiers modifiers) {
Thumbnail thumbnail = (Thumbnail) item;
// switch to full-page view
debug("switching to %s", thumbnail.get_photo().to_string());
LibraryWindow.get_app().switch_to_photo_page(this, thumbnail.get_photo());
// switch to full-page view or open in external editor
debug("activating %s", thumbnail.get_photo().to_string());
if (activator == CheckerboardPage.Activator.MOUSE) {
if (modifiers.super_pressed)
on_external_edit();
else
LibraryWindow.get_app().switch_to_photo_page(this, thumbnail.get_photo());
} else if (activator == CheckerboardPage.Activator.KEYBOARD) {
if (modifiers.shift_pressed && modifiers.ctrl_pressed) {
if (thumbnail.get_photo().get_master_file_format() == PhotoFileFormat.RAW)
on_external_edit_raw();
} else if (modifiers.ctrl_pressed) {
on_external_edit();
} else {
LibraryWindow.get_app().switch_to_photo_page(this, thumbnail.get_photo());
}
}
}
private void set_favorite_item_sensitive(string path, bool selected) {
......
......@@ -241,7 +241,8 @@ public class EventsDirectoryPage : CheckerboardPage {
return actions;
}
public override void on_item_activated(CheckerboardItem item) {
public override void on_item_activated(CheckerboardItem item, CheckerboardPage.Activator
activator, CheckerboardPage.KeyboardModifiers modifiers) {
EventDirectoryItem event = (EventDirectoryItem) item;
LibraryWindow.get_app().switch_to_event(event.event);
}
......
......@@ -26,9 +26,10 @@ public abstract class Page : Gtk.ScrolledWindow, SidebarPage {
private bool report_resize_finished = false;
private Gdk.Point last_down = Gdk.Point();
private bool is_destroyed = false;
protected bool ctrl_pressed = false;
protected bool alt_pressed = false;
protected bool shift_pressed = false;
private bool ctrl_pressed = false;
private bool alt_pressed = false;
private bool shift_pressed = false;
private bool super_pressed = false;
public Page(string page_name) {
this.page_name = page_name;
......@@ -265,21 +266,39 @@ public abstract class Page : Gtk.ScrolledWindow, SidebarPage {
action.visible = false;
action.sensitive = false;
}
public bool get_ctrl_pressed() {
return ctrl_pressed;
}
public bool get_alt_pressed() {
return alt_pressed;
}
public bool get_shift_pressed() {
return shift_pressed;
}
public bool get_super_pressed() {
return super_pressed;
}
private void get_modifiers(out bool ctrl, out bool alt, out bool shift) {
int x, y;
private void get_modifiers(out bool ctrl, out bool alt, out bool shift, out bool super) {
int x, y;
Gdk.ModifierType mask;
AppWindow.get_instance().window.get_pointer(out x, out y, out mask);
ctrl = (mask & Gdk.ModifierType.CONTROL_MASK) != 0;
alt = (mask & Gdk.ModifierType.MOD1_MASK) != 0;
shift = (mask & Gdk.ModifierType.SHIFT_MASK) != 0;
super = (mask & Gdk.ModifierType.MOD4_MASK) != 0; // not SUPER_MASK
}
private virtual void update_modifiers() {
bool ctrl_currently_pressed, alt_currently_pressed, shift_currently_pressed;
bool ctrl_currently_pressed, alt_currently_pressed, shift_currently_pressed,
super_currently_pressed;
get_modifiers(out ctrl_currently_pressed, out alt_currently_pressed,
out shift_currently_pressed);
out shift_currently_pressed, out super_currently_pressed);
if (ctrl_pressed && !ctrl_currently_pressed)
on_ctrl_released(null);
......@@ -295,10 +314,16 @@ public abstract class Page : Gtk.ScrolledWindow, SidebarPage {
on_shift_released(null);
else if (!shift_pressed && shift_currently_pressed)
on_shift_pressed(null);
if(super_pressed && !super_currently_pressed)
on_super_released(null);
else if (!super_pressed && super_currently_pressed)
on_super_pressed(null);
ctrl_pressed = ctrl_currently_pressed;
alt_pressed = alt_currently_pressed;
shift_pressed = shift_currently_pressed;
super_pressed = super_currently_pressed;
}
public PageWindow? get_page_window() {
......@@ -570,6 +595,14 @@ public abstract class Page : Gtk.ScrolledWindow, SidebarPage {
protected virtual bool on_shift_released(Gdk.EventKey? event) {
return false;
}
protected virtual bool on_super_pressed(Gdk.EventKey? event) {
return false;
}
protected virtual bool on_super_released(Gdk.EventKey? event) {
return false;
}
protected virtual bool on_app_key_pressed(Gdk.EventKey event) {
return false;
......@@ -580,9 +613,10 @@ public abstract class Page : Gtk.ScrolledWindow, SidebarPage {
}
public bool notify_app_key_pressed(Gdk.EventKey event) {
bool ctrl_currently_pressed, alt_currently_pressed, shift_currently_pressed;
bool ctrl_currently_pressed, alt_currently_pressed, shift_currently_pressed,
super_currently_pressed;
get_modifiers(out ctrl_currently_pressed, out alt_currently_pressed,
out shift_currently_pressed);
out shift_currently_pressed, out super_currently_pressed);
switch (Gdk.keyval_name(event.keyval)) {
case "Control_L":
......@@ -613,15 +647,25 @@ public abstract class Page : Gtk.ScrolledWindow, SidebarPage {
shift_pressed = true;
return on_shift_pressed(event);
case "Super_L":
case "Super_R":
if (!super_currently_pressed || super_pressed)
return false;
super_pressed = true;
return on_super_pressed(event);
}
return on_app_key_pressed(event);
}
public bool notify_app_key_released(Gdk.EventKey event) {
bool ctrl_currently_pressed, alt_currently_pressed, shift_currently_pressed;
bool ctrl_currently_pressed, alt_currently_pressed, shift_currently_pressed,
super_currently_pressed;
get_modifiers(out ctrl_currently_pressed, out alt_currently_pressed,
out shift_currently_pressed);
out shift_currently_pressed, out super_currently_pressed);
switch (Gdk.keyval_name(event.keyval)) {
case "Control_L":
......@@ -652,6 +696,15 @@ public abstract class Page : Gtk.ScrolledWindow, SidebarPage {
shift_pressed = false;
return on_shift_released(event);
case "Super_L":
case "Super_R":
if (super_currently_pressed || !super_pressed)
return false;
super_pressed = false;
return on_super_released(event);
}
return on_app_key_released(event);
......@@ -840,6 +893,25 @@ public abstract class CheckerboardPage : Page {
private CheckerboardItem activated_item = null;
private Gee.ArrayList<CheckerboardItem> previously_selected = null;
public enum Activator {
KEYBOARD,
MOUSE
}
public struct KeyboardModifiers {
public KeyboardModifiers(Page page) {
ctrl_pressed = page.get_ctrl_pressed();
alt_pressed = page.get_alt_pressed();
shift_pressed = page.get_shift_pressed();
super_pressed = page.get_super_pressed();
}
public bool ctrl_pressed;
public bool alt_pressed;
public bool shift_pressed;
public bool super_pressed;
}
public CheckerboardPage(string page_name) {
base(page_name);
......@@ -895,7 +967,8 @@ public abstract class CheckerboardPage : Page {
return popup_context_menu(get_context_menu());
}
protected virtual void on_item_activated(CheckerboardItem item) {
protected virtual void on_item_activated(CheckerboardItem item, Activator activator,
KeyboardModifiers modifiers) {
}
public CheckerboardLayout get_checkerboard_layout() {
......@@ -1000,7 +1073,8 @@ public abstract class CheckerboardPage : Page {
case "Return":
case "KP_Enter":
if (get_view().get_selected_count() == 1)
on_item_activated((CheckerboardItem) get_view().get_selected_at(0));
on_item_activated((CheckerboardItem) get_view().get_selected_at(0),
Activator.KEYBOARD, KeyboardModifiers(this));
else
handled = false;
break;
......@@ -1113,7 +1187,7 @@ public abstract class CheckerboardPage : Page {
// if the item was activated in the double-click, report it now
if (activated_item != null) {
on_item_activated(activated_item);
on_item_activated(activated_item, Activator.MOUSE, KeyboardModifiers(this));
activated_item = null;
return true;
......
......@@ -1132,7 +1132,7 @@ public abstract class EditingHostPage : SinglePhotoPage {
private override bool on_shift_pressed(Gdk.EventKey? event) {
// show quick compare of original only if no tool is in use, the original pixbuf is handy
if (current_tool == null && !ctrl_pressed && !alt_pressed) {
if (current_tool == null && !get_ctrl_pressed() && !get_alt_pressed()) {
swap_in_original();
}
......@@ -1154,7 +1154,7 @@ public abstract class EditingHostPage : SinglePhotoPage {
}
private override bool on_alt_released(Gdk.EventKey? event) {
if (current_tool == null && shift_pressed && !ctrl_pressed)
if (current_tool == null && get_shift_pressed() && !get_ctrl_pressed())
swap_in_original();
return base.on_alt_released(event);
......@@ -1688,7 +1688,7 @@ public abstract class EditingHostPage : SinglePhotoPage {
rotate_button.clicked.disconnect(on_rotate_counterclockwise);
rotate_button.clicked.connect(on_rotate_clockwise);
if (current_tool == null && shift_pressed && !alt_pressed)
if (current_tool == null && get_shift_pressed() && !get_alt_pressed())
swap_in_original();
return base.on_ctrl_released(event);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment