Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Close tabs when middle-clicked #2030

Open
wants to merge 1 commit into
base: stable
Choose a base branch
from

Conversation

rkok
Copy link

@rkok rkok commented Oct 3, 2024

A feature I've been wanting for a while, that I'm used to having with browser tabs. ;-)

I've had to split up tab_hbox somewhat, to make it possible to catch middle clicks. Despite some attempts to make it work, I could not find a way to handle middle clicks on GtkNotebook tabs natively. Documentation on the matter seems non-existent.

@jralls
Copy link
Member

jralls commented Oct 3, 2024

I'm inclined to reject this as not being cross-platform: Neither macOS nor Windows support a middle button. @gjanssens what do you think?

@rkok
Copy link
Author

rkok commented Oct 4, 2024

I'm inclined to reject this as not being cross-platform: Neither macOS nor Windows support a middle button.

Hi @jralls, could you elaborate a bit on what additional work would need to be done to support those platforms? I'm happy to give it a try - I want to contribute.

In case I wasn't clear enough, this PR is to catch middle mouse button clicks; when pressing the middle mouse button (usually the scroll wheel) on a tab heading, the window closes, just like with Firefox/Chrome/etc. browser tabs.

It uses native features of Gdk to identify which mouse button was pressed, which as far as I could see requires no OS-specific tweaking. Whatever compatibility layer is used to run this on Windows/macOS should let it gracefully degrade by simply not catching the click, I would think. (Though I did not test it on platforms other than Linux)

middleclick

@Bob-IT
Copy link
Contributor

Bob-IT commented Oct 4, 2024

I was not sure about this so fired up chrome on my MS Windows 10 box, opened up a couple of tabs and used the middle wheel button to close one, also using that button on the Gnucash toolbar pops the menu.

Regarding the code, there is no need for changes to the .h file, just make your call back function static and add a similar entry to the start of the gnc-main-window.cpp file.

Also I am not sure about using an event box, I wonder if it would be better to have...

tab_container (GtkBox)

tab_content (GtkButton)

button_container (GtkBox)

image (GtkImage, optional)
label (GtkLabel)
entry (GtkEntry, hidden)

close_button (GtkButton, if not immutable)

I would have to try it and see if it would work and whether the tabs would be coloured correctly. Another reason for going this way is that Gtk4 has dropped GtkEventBox should we stick with Gtk.

Either way, if changing the layout you may need to change the functions that gain access to these widgets, some may be ...
gnc_main_window_update_tab_*
main_window_find_tab_items
main_window_find_tab_widget

Also I think there may be an enhancement bug for this, will need to find it, found it 493595.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants