Commit e42d28fc authored by Jim Nelson's avatar Jim Nelson

#1155: Ctrl++ and Ctrl+- now accelerator keys for zooming. Code also checks...

#1155: Ctrl++ and Ctrl+- now accelerator keys for zooming.  Code also checks for unadorned plus and minus, or 
those keys with any modifier key, in fact.
parent 98c43147
......@@ -16,7 +16,7 @@ public class CollectionViewManager : ViewManager {
}
}
public abstract class CollectionPage : CheckerboardPage {
public abstract class CollectionPage : CheckerboardPage {
public const int SORT_ORDER_ASCENDING = 0;
public const int SORT_ORDER_DESCENDING = 1;
......@@ -235,13 +235,13 @@ public abstract class CollectionPage : CheckerboardPage {
actions += photos;
Gtk.ActionEntry increase_size = { "IncreaseSize", Gtk.STOCK_ZOOM_IN, TRANSLATABLE,
"bracketright", TRANSLATABLE, on_increase_size };
"<Ctrl>plus", TRANSLATABLE, on_increase_size };
increase_size.label = _("Zoom _In");
increase_size.tooltip = _("Increase the magnification of the thumbnails");
actions += increase_size;
Gtk.ActionEntry decrease_size = { "DecreaseSize", Gtk.STOCK_ZOOM_OUT, TRANSLATABLE,
"bracketleft", TRANSLATABLE, on_decrease_size };
"<Ctrl>minus", TRANSLATABLE, on_decrease_size };
decrease_size.label = _("Zoom _Out");
decrease_size.tooltip = _("Decrease the magnification of the thumbnails");
actions += decrease_size;
......@@ -591,6 +591,28 @@ public abstract class CollectionPage : CheckerboardPage {
return false;
}
protected override bool on_app_key_pressed(Gdk.EventKey event) {
bool handled = true;
switch (Gdk.keyval_name(event.keyval)) {
case "equal":
case "plus":
on_increase_size();
break;
case "minus":
case "underscore":
on_decrease_size();
break;
default:
handled = false;
break;
}
return handled ? true : base.on_app_key_pressed(event);
}
public void increase_thumb_size() {
set_thumb_size(scale + MANUAL_STEPPING);
}
......
......@@ -5,13 +5,6 @@
*/
public abstract class Page : Gtk.ScrolledWindow, SidebarPage {
public const uint KEY_CTRL_L = Gdk.keyval_from_name("Control_L");
public const uint KEY_CTRL_R = Gdk.keyval_from_name("Control_R");
public const uint KEY_ALT_L = Gdk.keyval_from_name("Alt_L");
public const uint KEY_ALT_R = Gdk.keyval_from_name("Alt_R");
public const uint KEY_SHIFT_L = Gdk.keyval_from_name("Shift_L");
public const uint KEY_SHIFT_R = Gdk.keyval_from_name("Shift_R");
private const int CONSIDER_CONFIGURE_HALTED_MSEC = 400;
protected enum TargetType {
......@@ -230,7 +223,7 @@ public abstract class Page : Gtk.ScrolledWindow, SidebarPage {
private virtual void update_modifiers() {
int x, y;
Gdk.ModifierType mask;
AppWindow.get_instance().window.get_pointer(out x, out y, out mask);
AppWindow.get_instance().window.get_pointer(out x, out y, out mask);
bool ctrl_currently_pressed = (mask & Gdk.ModifierType.CONTROL_MASK) != 0;
bool alt_currently_pressed = (mask & Gdk.ModifierType.MOD1_MASK) != 0;
......@@ -513,50 +506,65 @@ public abstract class Page : Gtk.ScrolledWindow, SidebarPage {
return false;
}
protected virtual bool on_app_key_pressed(Gdk.EventKey event) {
return false;
}
protected virtual bool on_app_key_released(Gdk.EventKey event) {
return false;
}
public bool notify_app_key_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) {
ctrl_pressed = true;
return on_ctrl_pressed(event);
}
if (event.keyval == KEY_ALT_L || event.keyval == KEY_ALT_R) {
alt_pressed = true;
return on_alt_pressed(event);
}
if (event.keyval == KEY_SHIFT_L || event.keyval == KEY_SHIFT_R) {
shift_pressed = true;
return on_shift_pressed(event);
switch (Gdk.keyval_name(event.keyval)) {
case "Control_L":
case "Control_R":
ctrl_pressed = true;
return on_ctrl_pressed(event);
case "Alt_L":
case "Alt_R":
alt_pressed = true;
return on_alt_pressed(event);
case "Shift_L":
case "Shift_R":
shift_pressed = true;
return on_shift_pressed(event);
}
return false;
return on_app_key_pressed(event);
}
public bool notify_app_key_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) {
ctrl_pressed = false;
return on_ctrl_released(event);
}
if (event.keyval == KEY_ALT_L || event.keyval == KEY_ALT_R) {
alt_pressed = false;
return on_alt_released(event);
}
if (event.keyval == KEY_SHIFT_L || event.keyval == KEY_SHIFT_R) {
shift_pressed = false;
return on_shift_released(event);
switch (Gdk.keyval_name(event.keyval)) {
case "Control_L":
case "Control_R":
ctrl_pressed = false;
return on_ctrl_released(event);
case "Alt_L":
case "Alt_R":
alt_pressed = false;
return on_alt_released(event);
case "Shift_L":
case "Shift_R":
shift_pressed = false;
return on_shift_released(event);
}
return false;
return on_app_key_released(event);
}
public bool notify_app_focus_in(Gdk.EventFocus event) {
update_modifiers();
return false;
}
......
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