Commit 0451a8bb authored by Jim Nelson's avatar Jim Nelson

#345: Home/End/PgUp/PgDn now available to move the viewport around. Sidebar...

#345: Home/End/PgUp/PgDn now available to move the viewport around.  Sidebar does not maintain focus to make this happen.  This may be revisited later, esp. for accessibility review.
parent 3c5c1704
......@@ -343,6 +343,10 @@ public class AppWindow : Gtk.Window {
destroy += Gtk.main_quit;
// the pages want to know when modifier keys are pressed
key_press_event += on_key_pressed;
key_release_event += on_key_released;
// prepare the default parent and orphan pages
collection_page = new CollectionPage();
events_directory_page = new EventsDirectoryPage();
......@@ -506,7 +510,7 @@ public class AppWindow : Gtk.Window {
public void set_normal_cursor() {
window.set_cursor(new Gdk.Cursor(Gdk.CursorType.ARROW));
}
public void batch_import_complete(SortedList<int64?> imported_photos) {
debug("Processing imported photos to create events ...");
......@@ -582,7 +586,15 @@ public class AppWindow : Gtk.Window {
last_exposure = exposure_time;
}
}
private bool on_key_pressed(Gdk.EventKey event) {
return (event.is_modifier != 0) ? current_page.notify_modifier_pressed(event) : false;
}
private bool on_key_released(Gdk.EventKey event) {
return (event.is_modifier != 0) ? current_page.notify_modifier_released(event) : false;
}
private void on_photo_removed(Photo photo) {
PhotoID photo_id = photo.get_photo_id();
......@@ -873,7 +885,7 @@ public class AppWindow : Gtk.Window {
page.switched_to();
}
private bool is_page_selected(Page page, Gtk.TreePath path) {
PageMarker marker = page.get_marker();
if (marker.get_row() == null)
......@@ -974,6 +986,12 @@ public class AppWindow : Gtk.Window {
return false;
}
private bool focus_on_current_page() {
current_page.grab_focus();
return false;
}
private void on_sidebar_cursor_changed() {
Gtk.TreePath path;
......@@ -987,7 +1005,13 @@ public class AppWindow : Gtk.Window {
// camera path selected and updated
} else if (is_event_selected(path)) {
// event page selected and updated
} else {
// nothing recognized selected
}
// this has to be done in Idle handler because the focus/ won't change properly inside
// this signal
Idle.add(focus_on_current_page);
}
private bool on_sidebar_selection(Gtk.TreeSelection selection, Gtk.TreeModel model, Gtk.TreePath path,
......
all:
cd .. && $(MAKE)
......@@ -19,7 +19,9 @@ public abstract class Page : Gtk.ScrolledWindow {
public static const uint KEY_CTRL_R = Gdk.keyval_from_name("Control_R");
public static const uint KEY_ALT_L = Gdk.keyval_from_name("Alt_L");
public static const uint KEY_ALT_R = Gdk.keyval_from_name("Alt_R");
public static const uint KEY_SHIFT_L = Gdk.keyval_from_name("Shift_L");
public static const uint KEY_SHIFT_R = Gdk.keyval_from_name("Shift_R");
protected enum TargetType {
URI_LIST
}
......@@ -38,6 +40,10 @@ public abstract class Page : Gtk.ScrolledWindow {
private Gtk.Widget event_source = null;
private bool dnd_enabled = false;
public Page() {
set_flags(Gtk.WidgetFlags.CAN_FOCUS);
}
public void set_event_source(Gtk.Widget event_source) {
assert(this.event_source == null);
......@@ -48,14 +54,9 @@ public abstract class Page : Gtk.ScrolledWindow {
event_source.button_press_event += on_button_pressed_internal;
event_source.button_release_event += on_button_released_internal;
// interested in keypresses to the application itself
AppWindow.get_instance().add_events(Gdk.EventMask.KEY_PRESS_MASK | Gdk.EventMask.KEY_RELEASE_MASK
| Gdk.EventMask.STRUCTURE_MASK);
AppWindow.get_instance().key_press_event += on_key_pressed_internal;
AppWindow.get_instance().key_release_event += on_key_released_internal;
// Use the app window's signals for window move/resize, esp. for resize, as this signal
// is used to determine inner window resizes
AppWindow.get_instance().add_events(Gdk.EventMask.STRUCTURE_MASK);
AppWindow.get_instance().configure_event += on_configure_internal;
}
......@@ -252,14 +253,6 @@ public abstract class Page : Gtk.ScrolledWindow {
}
}
protected virtual bool on_key_pressed(Gdk.EventKey event) {
return false;
}
protected virtual bool on_key_released(Gdk.EventKey event) {
return false;
}
protected virtual bool on_ctrl_pressed(Gdk.EventKey event) {
return false;
}
......@@ -276,30 +269,48 @@ public abstract class Page : Gtk.ScrolledWindow {
return false;
}
protected virtual void on_move(Gdk.Rectangle rect) {
protected virtual bool on_shift_pressed(Gdk.EventKey event) {
return false;
}
protected virtual void on_resize(Gdk.Rectangle rect) {
protected virtual bool on_shift_released(Gdk.EventKey event) {
return false;
}
private bool on_key_pressed_internal(Gdk.EventKey event) {
if ((event.keyval == KEY_CTRL_L) || (event.keyval == KEY_CTRL_R))
public bool notify_modifier_pressed(Gdk.EventKey event) {
// can't use a switch statement here due to this bug:
// http://bugzilla.gnome.org/show_bug.cgi?id=585292
if (event.keyval == KEY_CTRL_L || event.keyval == KEY_CTRL_R)
return on_ctrl_pressed(event);
if ((event.keyval == KEY_ALT_L) || (event.keyval == KEY_ALT_R))
if (event.keyval == KEY_ALT_L || event.keyval == KEY_ALT_R)
return on_alt_pressed(event);
return on_key_pressed(event);
if (event.keyval == KEY_SHIFT_L || event.keyval == KEY_SHIFT_R)
return on_shift_pressed(event);
return false;
}
private bool on_key_released_internal(Gdk.EventKey event) {
if ((event.keyval == KEY_CTRL_L) || (event.keyval == KEY_CTRL_R))
public bool notify_modifier_released(Gdk.EventKey event) {
// can't use a switch statement here due to this bug:
// http://bugzilla.gnome.org/show_bug.cgi?id=585292
if (event.keyval == KEY_CTRL_L || event.keyval == KEY_CTRL_R)
return on_ctrl_released(event);
if ((event.keyval == KEY_ALT_L) || (event.keyval == KEY_ALT_R))
if (event.keyval == KEY_ALT_L || event.keyval == KEY_ALT_R)
return on_alt_released(event);
return on_key_released(event);
if (event.keyval == KEY_SHIFT_L || event.keyval == KEY_SHIFT_R)
return on_shift_released(event);
return false;
}
protected virtual void on_move(Gdk.Rectangle rect) {
}
protected virtual void on_resize(Gdk.Rectangle rect) {
}
private bool on_configure_internal(Gdk.EventConfigure 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