Gtk4 Prep: Use extra_menu model for sourceview context menu#1732
Open
jeremypw wants to merge 5 commits into
Open
Gtk4 Prep: Use extra_menu model for sourceview context menu#1732jeremypw wants to merge 5 commits into
jeremypw wants to merge 5 commits into
Conversation
danirabbit
reviewed
Jun 18, 2026
|
|
||
| populate_popup.connect_after (on_context_menu); | ||
| // Actions and menumodel for additional context menu items | ||
| var sort_action = new SimpleAction ("sort-lines", null); |
Member
There was a problem hiding this comment.
It looks like we already have actions for these that we were using previously. Is there a reason to create new actions instead of reusing the existing ones?
Collaborator
Author
There was a problem hiding this comment.
I am in the process of removing those actions and associated functions from MainWindow. It makes more sense to handle them locally, especially in Gtk4.
Note that this pattern has already been used for the Terminal pane and Sidebar for example.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
As far as possible moves towards the code that will be required for sourceview-5 (Gtk4) with regards to the context menu. While in Gtk3 we still have to create Gtk.MenuItems as that is what is required for sourceview-4. However we create these items from an extra_menu MenuModel which in sourceview-5 will be automatically used.
Actions required by the extra items are moved from MainWindow into the SourceView class which makes more sense. Their associated accelerators are also moved, using a keycontroller.
Rather than setting the actions enabled/disabled only on popping up the context menu, they are constantly updated according to various property notifications as will be required for sourceview-5.
Overall this saves a few lines and porting the context menu will require little more than deleting some of these.
In passing
Stripping whitespace is inhibited if there is a selection when the context menu is invoked to avoid the selection being lost when the menu is focused.