hugolabe / Wike

Wikipedia Reader for the GNOME Desktop
https://hugolabe.github.io/Wike/
GNU General Public License v3.0
249 stars 33 forks source link

Open links and bookmarks, lang, history links in background when pressing `ctrl` #158

Closed aunetx closed 10 months ago

aunetx commented 11 months ago

Fixes #157, and depends on #155 (although this dependence can be dropped as it is only used when loading bookmarks and history rows in background).

hugolabe commented 10 months ago

Doesn't seem to work well for me. Once you press Ctrl, all the links in the side panel open in a new tab, even when you have already released it.

This could be solved. However, I'm not convinced about the method used of capturing the key press and then saving it to a variable in the window module. This can be prone to problems and makes the code more difficult to maintain.

I think the check should be done in the module in which a link has been clicked, checking the state of the modifier keys. I'll try to look at it with more time.

jhenriquelc commented 3 weeks ago

Hi, I've been looking into implementing this as a first contribution to the project but I've run into a few obstacles

GtkListBox seems to abstract away the event used to emit the row-activated signal, making it impossible to implement this in most places without either changing what widget is used for the list and its rows (losing all of the niceties that those provide) or handling the modifier key state externally.

However, adding support for this inside the WebKit view seems pretty trivial, maybe we could add that while we figure out the rest?

Is using an Adwaita ActionRow with a button suffix for opening the link in a new window a good compromise (maybe too cluttered)? Or maybe a preference to open links in new tabs by default (kinda inflexible but at least customizable)?

camelCaseNick commented 3 weeks ago

GtkListBox seems to abstract away the event used to emit the row-activated signal

You could just not use that signal, but add your own Gtk.GestureClick and do the same handling currently done in the activation handler with an additional check for the GDK_CONTROL_MASK in Gtk.EventController.get_current_event_state() (a gesture is an event controller).

hugolabe commented 3 weeks ago

Hi @jhenriquelc

It should probably be done with Gtk.Gesture as @camelCaseNick says, but it doesn't seem like an easy task.

However, adding support for this inside the WebKit view seems pretty trivial, maybe we could add that while we figure out the rest?

I think it's more coherent to add support within Webkit if it's added to the rest of the widgets. Currently you can already open a link in another tab with the middle mouse button or with the context menu.

Is using an Adwaita ActionRow with a button suffix for opening the link in a new window a good compromise (maybe too cluttered)? Or maybe a preference to open links in new tabs by default (kinda inflexible but at least customizable)?

I don't think it's a good idea to make changes to the application's UI because of this. I think it could be an improvement to add support for the Ctrl key but it's not essential either.