[shotwell/wip/gtk4: 137/154] Fix more keybindings
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [shotwell/wip/gtk4: 137/154] Fix more keybindings
- Date: Sat, 1 Oct 2022 17:53:20 +0000 (UTC)
commit 0b2b95c058440d79f5962991e6cc585a627ad07a
Author: Jens Georg <mail jensge org>
Date: Thu Apr 21 10:24:24 2022 +0200
Fix more keybindings
src/CollectionPage.vala | 4 +-
src/MediaPage.vala | 57 +++++++--------
src/Page.vala | 4 +-
src/PhotoPage.vala | 150 ++++++++++++----------------------------
src/direct/DirectPhotoPage.vala | 4 +-
src/editing_tools/CropTool.vala | 37 +++++-----
src/sidebar/Tree.vala | 11 ---
7 files changed, 93 insertions(+), 174 deletions(-)
---
diff --git a/src/CollectionPage.vala b/src/CollectionPage.vala
index 7d200a59..11d9e7b2 100644
--- a/src/CollectionPage.vala
+++ b/src/CollectionPage.vala
@@ -360,11 +360,11 @@ public abstract class CollectionPage : MediaPage {
event.forward(this);
break;
case "bracketright":
- activate_action("RotateClockwise", format);
+ activate_action("win.RotateClockwise", format);
break;
case "bracketleft":
- activate_action("RotateCounterclockwise", format);
+ activate_action("win.RotateCounterclockwise", format);
break;
default:
diff --git a/src/MediaPage.vala b/src/MediaPage.vala
index ca6ebc96..9f272e15 100644
--- a/src/MediaPage.vala
+++ b/src/MediaPage.vala
@@ -55,11 +55,12 @@ public abstract class MediaPage : CheckerboardPage {
Object (orientation : Gtk.Orientation.HORIZONTAL, spacing : 9);
Gtk.Image zoom_out = new Gtk.Image.from_icon_name("image-zoom-out-symbolic");
- #if 0
- zoom_out_box.button_press_event.connect(on_zoom_out_pressed);
- #endif
+ var click = new Gtk.GestureClick();
+ click.set_exclusive(true);
+ zoom_out.add_controller(click);
+ click.pressed.connect(() => { snap_to_min();});
- prepend(zoom_out);
+ append(zoom_out);
// virgin ZoomSliderAssemblies are created such that they have whatever value is
// persisted in the configuration system for the photo thumbnail scale
@@ -73,14 +74,15 @@ public abstract class MediaPage : CheckerboardPage {
slider.set_size_request(200, -1);
slider.set_tooltip_text(_("Adjust the size of the thumbnails"));
- prepend(slider);
+ append(slider);
Gtk.Image zoom_in = new Gtk.Image.from_icon_name("image-zoom-in-symbolic");
- #if 0
- zoom_in_box.button_press_event.connect(on_zoom_in_pressed);
- #endif
+ click = new Gtk.GestureClick();
+ click.set_exclusive(true);
+ zoom_in.add_controller(click);
+ click.pressed.connect(() => {snap_to_max();});
- prepend(zoom_in);
+ append(zoom_in);
}
public static double scale_to_slider(int value) {
@@ -95,18 +97,6 @@ public abstract class MediaPage : CheckerboardPage {
return res;
}
-
-#if 0
- private bool on_zoom_out_pressed(Gdk.EventButton event) {
- snap_to_min();
- return true;
- }
-
- private bool on_zoom_in_pressed(Gdk.EventButton event) {
- snap_to_max();
- return true;
- }
- #endif
private void on_slider_changed() {
zoom_changed();
@@ -415,59 +405,60 @@ public abstract class MediaPage : CheckerboardPage {
}
protected override bool on_app_key_pressed(Gtk.EventControllerKey event, uint keyval, uint keycode,
Gdk.ModifierType modifiers) {
+ print("On_App_key_pressed: %s\n", Gdk.keyval_name(keyval));
bool handled = true;
string? format = null; // Workaround for missing annotation
switch (Gdk.keyval_name(keyval)) {
case "equal":
case "plus":
case "KP_Add":
- activate_action("IncreaseSize", format);
+ activate_action("win.IncreaseSize", format);
break;
case "minus":
case "underscore":
case "KP_Subtract":
- activate_action("DecreaseSize", format);
+ activate_action("win.DecreaseSize", format);
break;
case "period":
- activate_action("IncreaseRating", format);
+ activate_action("win.IncreaseRating", format);
break;
case "comma":
- activate_action("DecreaseRating", format);
+ activate_action("win.DecreaseRating", format);
break;
case "KP_1":
- activate_action("RateOne", format);
+ activate_action("win.RateOne", format);
break;
case "KP_2":
- activate_action("RateTwo", format);
+ activate_action("win.RateTwo", format);
break;
case "KP_3":
- activate_action("RateThree", format);
+ activate_action("win.RateThree", format);
break;
case "KP_4":
- activate_action("RateFour", format);
+ activate_action("win.RateFour", format);
break;
case "KP_5":
- activate_action("RateFive", format);
+ activate_action("win.RateFive", format);
break;
case "KP_0":
- activate_action("RateUnrated", format);
+ activate_action("win.RateUnrated", format);
break;
case "KP_9":
- activate_action("RateRejected", format);
+ activate_action("win.RateRejected", format);
break;
case "slash":
- activate_action("Flag", format);
+ activate_action("win.Flag", format);
break;
default:
diff --git a/src/Page.vala b/src/Page.vala
index e33c1bd1..3c87974a 100644
--- a/src/Page.vala
+++ b/src/Page.vala
@@ -849,7 +849,7 @@ public abstract class Page : Gtk.Box {
return on_super_pressed();
}
- return on_app_key_pressed(event, keycode, keyval, modifiers);
+ return on_app_key_pressed(event, keyval, keycode, modifiers);
}
public bool notify_app_key_released(Gtk.EventControllerKey event, uint keyval, uint keycode,
Gdk.ModifierType modifiers) {
@@ -898,7 +898,7 @@ public abstract class Page : Gtk.Box {
return on_super_released();
}
- return on_app_key_released(event, keycode, keyval, modifiers);
+ return on_app_key_released(event, keyval, keycode, modifiers);
}
public void notify_app_focus_in() {
diff --git a/src/PhotoPage.vala b/src/PhotoPage.vala
index 145d5984..9f63f8e0 100644
--- a/src/PhotoPage.vala
+++ b/src/PhotoPage.vala
@@ -507,6 +507,11 @@ public abstract class EditingHostPage : SinglePhotoPage {
Gtk.Box zoom_group = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 0);
Gtk.Image zoom_out = new Gtk.Image.from_icon_name("image-zoom-out-symbolic");
+ var click = new Gtk.GestureClick();
+ click.set_exclusive(true);
+ click.pressed.connect(() => {snap_zoom_to_min();});
+ zoom_out.add_controller(click);
+
//zoom_out.button_press_event.connect(on_zoom_out_pressed);
zoom_group.append(zoom_out);
@@ -522,12 +527,15 @@ public abstract class EditingHostPage : SinglePhotoPage {
zoom_slider.key_press_event.connect(on_zoom_slider_key_press);
#endif
- zoom_group.prepend(zoom_slider);
+ zoom_group.append(zoom_slider);
Gtk.Image zoom_in = new Gtk.Image.from_icon_name("image-zoom-in-symbolic");
- //zoom_in.button_press_event.connect(on_zoom_in_pressed);
+ click = new Gtk.GestureClick();
+ click.set_exclusive(true);
+ click.pressed.connect(() => {snap_zoom_to_max();});
+ zoom_in.add_controller(click);
- zoom_group.prepend(zoom_in);
+ zoom_group.append(zoom_in);
toolbar.append(zoom_group);
@@ -575,41 +583,6 @@ public abstract class EditingHostPage : SinglePhotoPage {
update_cursor_for_zoom_context();
}
-# if 0
- private bool on_zoom_slider_drag_begin(Gdk.EventButton event) {
- enable_interactive_zoom_refresh = true;
-
- if (get_container() is FullscreenWindow)
- ((FullscreenWindow) get_container()).disable_toolbar_dismissal();
-
- return false;
- }
-
- private bool on_zoom_slider_drag_end(Gdk.EventButton event) {
- enable_interactive_zoom_refresh = false;
-
- if (get_container() is FullscreenWindow)
- ((FullscreenWindow) get_container()).update_toolbar_dismissal();
-
- ZoomState zoom_state = ZoomState.rescale(get_zoom_state(), zoom_slider.get_value());
- set_zoom_state(zoom_state);
-
- repaint();
-
- return false;
- }
-
- private bool on_zoom_out_pressed(Gdk.EventButton event) {
- snap_zoom_to_min();
- return true;
- }
-
- private bool on_zoom_in_pressed(Gdk.EventButton event) {
- snap_zoom_to_max();
- return true;
- }
- #endif
-
private Gdk.Point get_cursor_wrt_viewport(Gtk.EventControllerScroll event) {
Gdk.Point cursor_wrt_canvas = {0};
double x;
@@ -709,34 +682,6 @@ public abstract class EditingHostPage : SinglePhotoPage {
zoom_slider.set_value(iso_state.get_interpolation_factor());
}
-#if 0
- protected virtual bool on_zoom_slider_key_press(Gdk.EventKey event) {
- switch (Gdk.keyval_name(event.keyval)) {
- case "equal":
- case "plus":
- case "KP_Add":
- activate_action("IncreaseSize");
- return true;
-
- case "minus":
- case "underscore":
- case "KP_Subtract":
- activate_action("DecreaseSize");
- return true;
-
- case "KP_Divide":
- activate_action("Zoom100");
- return true;
-
- case "KP_Multiply":
- activate_action("ZoomFit");
- return true;
- }
-
- return false;
- }
- #endif
-
protected virtual void on_increase_size() {
zoom_slider.set_value(adjust_interpolation_factor(ZOOM_INCREMENT_SIZE));
}
@@ -1742,11 +1687,14 @@ public abstract class EditingHostPage : SinglePhotoPage {
}
public override bool key_press_event(Gtk.EventControllerKey event, uint keyval, uint keycode,
Gdk.ModifierType modifiers) {
+ print("key_press_event! %s\n", Gdk.keyval_name(keyval));
// editing tool gets first crack at the keypress
if (current_tool != null) {
if (current_tool.on_keypress(event, keyval, keycode, modifiers))
return true;
}
+
+ print("key_press_event! 2\n");
// if panning is possible, the pan handler (on MUNI?) gets second crack at the keypress
if (is_panning_possible()) {
@@ -1754,6 +1702,7 @@ public abstract class EditingHostPage : SinglePhotoPage {
return true;
}
+
#if 0
// if the user pressed the "0", "1" or "2" keys then handle the event as if were
// directed at the zoom slider ("0", "1" and "2" are hotkeys that jump to preset
@@ -1776,20 +1725,27 @@ public abstract class EditingHostPage : SinglePhotoPage {
case "equal":
case "plus":
case "KP_Add":
- activate_action("IncreaseSize", format);
+ activate_action("win.IncreaseSize", format);
break;
// underscore is the keysym generated by SHIFT-[minus sign] -- this means zoom out
case "minus":
case "underscore":
case "KP_Subtract":
- activate_action("DecreaseSize", format);
+ activate_action("win.DecreaseSize", format);
+ break;
+ case "KP_Divide":
+ activate_action("win.Zoom100", format);
+ break;
+
+ case "KP_Multiply":
+ activate_action("win.ZoomFit", format);
break;
-
default:
handled = false;
break;
}
+ print("key_press_event! 3\n");
return base.key_press_event(event, keyval, keycode, modifiers);
}
@@ -2375,16 +2331,16 @@ public class LibraryPhotoPage : EditingHostPage {
get_view().install_view_filter(filter);
LibraryPhoto.global.items_unlinking.connect(on_photo_unlinking);
LibraryPhoto.global.items_relinked.connect(on_photo_relinked);
+
+ var key = new Gtk.EventControllerKey();
+ key.key_pressed.connect(key_press_event);
+ add_controller(key);
}
~LibraryPhotoPage() {
LibraryPhoto.global.item_destroyed.disconnect(on_photo_destroyed);
LibraryPhoto.global.items_altered.disconnect(on_metadata_altered);
Config.Facade.get_instance().external_app_changed.disconnect(on_external_app_changed);
-
- var key = new Gtk.EventControllerKey();
- key.key_pressed.connect(key_press_event);
- add_controller(key);
}
public bool not_trashed_view_filter(DataView view) {
@@ -2701,20 +2657,6 @@ public class LibraryPhotoPage : EditingHostPage {
update_zoom_menu_item_sensitivity();
}
-#if 0
- protected override bool on_zoom_slider_key_press(Gdk.EventKey event) {
- if (base.on_zoom_slider_key_press(event))
- return true;
-
- if (Gdk.keyval_name(event.keyval) == "Escape") {
- return_to_collection();
- return true;
- } else {
- return false;
- }
- }
- #endif
-
protected override void update_ui(bool missing) {
bool sensitivity = !missing;
@@ -2786,57 +2728,57 @@ public class LibraryPhotoPage : EditingHostPage {
// although bound as an accelerator in the menu, accelerators are currently
// unavailable in fullscreen mode (a variant of #324), so we do this manually
// here
- activate_action("MoveToTrash", format);
+ activate_action("win.MoveToTrash", format);
break;
case "period":
case "greater":
- activate_action("IncreaseRating", format);
+ activate_action("win.IncreaseRating", format);
break;
case "comma":
case "less":
- activate_action("DecreaseRating", format);
+ activate_action("win.DecreaseRating", format);
break;
case "KP_1":
- activate_action("RateOne", format);
+ activate_action("win.RateOne", format);
break;
case "KP_2":
- activate_action("RateTwo", format);
+ activate_action("win.RateTwo", format);
break;
case "KP_3":
- activate_action("RateThree", format);
+ activate_action("win.RateThree", format);
break;
case "KP_4":
- activate_action("RateFour", format);
+ activate_action("win.RateFour", format);
break;
case "KP_5":
- activate_action("RateFive", format);
+ activate_action("win.RateFive", format);
break;
case "KP_0":
- activate_action("RateUnrated", format);
+ activate_action("win.RateUnrated", format);
break;
case "KP_9":
- activate_action("RateRejected", format);
+ activate_action("win.RateRejected", format);
break;
case "bracketright":
- activate_action("RotateClockwise", format);
+ activate_action("win.RotateClockwise", format);
break;
case "bracketleft":
- activate_action("RotateCounterclockwise", format);
+ activate_action("win.RotateCounterclockwise", format);
break;
case "slash":
- activate_action("Flag", format);
+ activate_action("win.Flag", format);
break;
default:
@@ -2847,8 +2789,7 @@ public class LibraryPhotoPage : EditingHostPage {
return handled;
}
- #if 0
- protected override bool on_double_click(Gdk.EventButton event) {
+ protected override bool on_double_click(Gtk.EventController event, double x, double y) {
FullscreenWindow? fs = get_container() as FullscreenWindow;
if (fs == null)
return_to_collection_on_release = true;
@@ -2858,7 +2799,7 @@ public class LibraryPhotoPage : EditingHostPage {
return true;
}
- protected override bool on_left_released(Gdk.EventButton event) {
+ protected override bool on_left_released(Gtk.EventController event, int press, double x, double y) {
if (return_to_collection_on_release) {
return_to_collection_on_release = false;
return_to_collection();
@@ -2866,9 +2807,8 @@ public class LibraryPhotoPage : EditingHostPage {
return true;
}
- return base.on_left_released(event);
+ return base.on_left_released(event, press, x, y);
}
- #endif
private Gtk.PopoverMenu context_menu;
diff --git a/src/direct/DirectPhotoPage.vala b/src/direct/DirectPhotoPage.vala
index 9bb3ccbb..c54bb0a2 100644
--- a/src/direct/DirectPhotoPage.vala
+++ b/src/direct/DirectPhotoPage.vala
@@ -442,11 +442,11 @@ public class DirectPhotoPage : EditingHostPage {
switch (Gdk.keyval_name(keyval)) {
case "bracketright":
- activate_action("RotateClockwise", format);
+ activate_action("win.RotateClockwise", format);
break;
case "bracketleft":
- activate_action("RotateCounterclockwise", format);
+ activate_action("win.RotateCounterclockwise", format);
break;
default:
diff --git a/src/editing_tools/CropTool.vala b/src/editing_tools/CropTool.vala
index bf2c7900..bf6dc2d1 100644
--- a/src/editing_tools/CropTool.vala
+++ b/src/editing_tools/CropTool.vala
@@ -74,7 +74,9 @@ public class EditingTools.CropTool : EditingTool {
public Gtk.Box layout = null;
public int normal_width = -1;
public int normal_height = -1;
-
+ public Gtk.EventControllerFocus custom_width_focus;
+ public Gtk.EventControllerFocus custom_height_focus;
+
public CropToolWindow(Gtk.Window container) {
base(container);
@@ -110,6 +112,11 @@ public class EditingTools.CropTool : EditingTool {
layout.append(response_layout);
add(layout);
+
+ custom_width_focus = new Gtk.EventControllerFocus();
+ custom_width_entry.add_controller(custom_width_focus);
+ custom_height_focus = new Gtk.EventControllerFocus();
+ custom_height_entry.add_controller(custom_height_focus);
}
private static bool constraint_combo_separator_func(Gtk.TreeModel model, Gtk.TreeIter iter) {
@@ -230,18 +237,17 @@ public class EditingTools.CropTool : EditingTool {
return result;
}
- #if 0
- private bool on_width_entry_focus_out(Gdk.EventFocus event) {
+ private void on_width_entry_focus_out(Gtk.EventControllerFocus event) {
crop_tool_window.most_recently_edited = crop_tool_window.custom_width_entry;
- return on_custom_entry_focus_out(event);
+ on_custom_entry_focus_out(event);
}
- private bool on_height_entry_focus_out(Gdk.EventFocus event) {
+ private void on_height_entry_focus_out(Gtk.EventControllerFocus event) {
crop_tool_window.most_recently_edited = crop_tool_window.custom_height_entry;
- return on_custom_entry_focus_out(event);
+ on_custom_entry_focus_out(event);
}
- private bool on_custom_entry_focus_out(Gdk.EventFocus event) {
+ private void on_custom_entry_focus_out(Gtk.EventControllerFocus event) {
int width = int.parse(crop_tool_window.custom_width_entry.text);
int height = int.parse(crop_tool_window.custom_height_entry.text);
@@ -256,7 +262,7 @@ public class EditingTools.CropTool : EditingTool {
}
if ((width == custom_width) && (height == custom_height))
- return false;
+ return;
custom_aspect_ratio = ((float) width) / ((float) height);
@@ -289,10 +295,7 @@ public class EditingTools.CropTool : EditingTool {
custom_width = width;
custom_height = height;
-
- return false;
}
- #endif
private void on_width_insert_text(string text, int length, ref int position) {
on_entry_insert_text(crop_tool_window.custom_width_entry, text, length, ref position);
@@ -600,10 +603,8 @@ public class EditingTools.CropTool : EditingTool {
crop_tool_window.pivot_reticle_button.clicked.connect(on_pivot_button_clicked);
// set up the custom width and height entry boxes
- #if 0
- crop_tool_window.custom_width_entry.focus_out_event.connect(on_width_entry_focus_out);
- crop_tool_window.custom_height_entry.focus_out_event.connect(on_height_entry_focus_out);
- #endif
+ crop_tool_window.custom_width_focus.leave.connect(on_width_entry_focus_out);
+ crop_tool_window.custom_height_focus.leave.connect(on_height_entry_focus_out);
crop_tool_window.custom_width_entry.insert_text.connect(on_width_insert_text);
crop_tool_window.custom_height_entry.insert_text.connect(on_height_insert_text);
}
@@ -615,10 +616,8 @@ public class EditingTools.CropTool : EditingTool {
crop_tool_window.pivot_reticle_button.clicked.disconnect(on_pivot_button_clicked);
// set up the custom width and height entry boxes
- #if 0
- crop_tool_window.custom_width_entry.focus_out_event.disconnect(on_width_entry_focus_out);
- crop_tool_window.custom_height_entry.focus_out_event.disconnect(on_height_entry_focus_out);
- #endif
+ crop_tool_window.custom_width_focus.leave.disconnect(on_width_entry_focus_out);
+ crop_tool_window.custom_height_focus.leave.disconnect(on_height_entry_focus_out);
crop_tool_window.custom_width_entry.insert_text.disconnect(on_width_insert_text);
}
diff --git a/src/sidebar/Tree.vala b/src/sidebar/Tree.vala
index d9550cb4..e16edcc7 100644
--- a/src/sidebar/Tree.vala
+++ b/src/sidebar/Tree.vala
@@ -1193,7 +1193,6 @@ public class Sidebar.Tree : Gtk.TreeView {
text_entry.editable = false;
text_entry.editing_done.disconnect(on_editing_done);
- //text_entry.focus_out_event.disconnect(on_editing_focus_out);
}
private void on_editing_done() {
@@ -1207,17 +1206,7 @@ public class Sidebar.Tree : Gtk.TreeView {
}
text_entry.editing_done.disconnect(on_editing_done);
- //text_entry.focus_out_event.disconnect(on_editing_focus_out);
}
-
-#if 0
- private bool on_editing_focus_out(Gdk.EventFocus event) {
- // We'll return false here, in case other parts of the app
- // want to know if the button press event that caused
- // us to lose focus have been fully handled.
- return false;
- }
- #endif
private void on_new_search() {
(new SavedSearchDialog()).show();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]