Add URL matcher functionality for domain-based application selection#184
Add URL matcher functionality for domain-based application selection#184lwille wants to merge 6 commits intosonnyp:mainfrom
Conversation
1e1d384 to
e7ccb13
Compare
41c5de2 to
494de34
Compare
- Implement regex-based URL pattern matching for automatic application selection - Add Preferences dialog with URL matcher management interface - Store URL matchers in GSettings with JSON serialization - Add automatic URL routing for HTTP/HTTPS schemes in window.js - Replace deprecated GtkShortcutsWindow with modern Adw.Dialog components - Refactor preferences action to application-level Gio.SimpleAction - Add comprehensive URL matcher test coverage Fixes sonnyp#75
494de34 to
641d7c8
Compare
|
Thanks, I will review this for Junction 2.0 |
sonnyp
left a comment
There was a problem hiding this comment.
Merged main and fixed a couple of issues.
The matcher logic needs to be fixed, we don't use Gio.AppInfo anymore
src/preferences.blp
Outdated
|
|
||
| Label { | ||
| label: _("URL Pattern (Regular Expression):"); | ||
| xalign: 0; |
There was a problem hiding this comment.
please remove all xalign
replace with halign
src/preferences.js
Outdated
| // Add dialog responses | ||
| add_matcher_dialog.add_response("cancel", "Cancel"); | ||
| add_matcher_dialog.add_response("add", "Add"); | ||
| add_matcher_dialog.set_response_appearance("add", Adw.ResponseAppearance.SUGGESTED); |
There was a problem hiding this comment.
| // Add dialog responses | |
| add_matcher_dialog.add_response("cancel", "Cancel"); | |
| add_matcher_dialog.add_response("add", "Add"); | |
| add_matcher_dialog.set_response_appearance("add", Adw.ResponseAppearance.SUGGESTED); | |
| add_matcher_dialog.add_response("cancel", "Cancel"); | |
| add_matcher_dialog.add_response("add", "Add"); | |
| add_matcher_dialog.set_response_appearance("add", Adw.ResponseAppearance.SUGGESTED); |
comments shouldn't repeat what the code says
src/preferences.js
Outdated
| add_matcher_dialog.add_response("cancel", "Cancel"); | ||
| add_matcher_dialog.add_response("add", "Add"); |
There was a problem hiding this comment.
| add_matcher_dialog.add_response("cancel", "Cancel"); | |
| add_matcher_dialog.add_response("add", "Add"); | |
| add_matcher_dialog.add_response("cancel", _("Cancel")); | |
| add_matcher_dialog.add_response("add", _("Add")); |
src/preferences.js
Outdated
| // Populate browser applications | ||
| populateAppDropdown(); | ||
|
|
||
| // Load existing matchers | ||
| loadMatchers(); |
There was a problem hiding this comment.
| // Populate browser applications | |
| populateAppDropdown(); | |
| // Load existing matchers | |
| loadMatchers(); | |
| populateAppDropdown(); | |
| loadMatchers(); |
src/preferences.js
Outdated
| // Load existing matchers | ||
| loadMatchers(); | ||
|
|
||
| // Add button handler |
There was a problem hiding this comment.
| // Add button handler |
|
|
||
| if (pattern && selectedIndex !== Gtk.INVALID_LIST_POSITION) { | ||
| const appString = app_list_model.get_string(selectedIndex); | ||
| const [appId] = appString.split(" - "); |
| section { | ||
| item { | ||
| label: _("Preferences"); | ||
| action: "app.preferences"; | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
preferences should have the ctrl+, shortcut
| Button { | ||
| label: _("Preferences"); | ||
| valign: center; | ||
| halign: center; | ||
| clicked => $onPreferences(); | ||
| } | ||
|
|
There was a problem hiding this comment.
This doesn't need to be so prominent in the welcome window
Please replace the top right about button with a menu that has Preferences + About
| using Gtk 4.0; | ||
| using Adw 1; | ||
|
|
||
| Adw.PreferencesDialog preferences_window { |
There was a problem hiding this comment.
please move the "Show App Names" menu entry to this Preferences dialog
|
|
||
| const deleteButton = new Gtk.Button({ | ||
| icon_name: "user-trash-symbolic", | ||
| tooltip_text: "Remove URL matcher", |
There was a problem hiding this comment.
all user visible strings should be marked as translatable
| tooltip_text: "Remove URL matcher", | |
| tooltip_text: _("Remove URL matcher"), |
|
|
||
| Adw.AlertDialog add_matcher_dialog { | ||
| heading: _("Add URL Matcher"); | ||
| body: _("Enter a regular expression pattern to match URLs and select the application to open them with."); |
There was a problem hiding this comment.
UI should be self explanatory
| body: _("Enter a regular expression pattern to match URLs and select the application to open them with."); |
Summary
This PR implements URL matcher functionality to automatically route URLs to specific applications based on user-defined regex patterns, addressing #75.
Also related to #5.
Key Features
Implementation Details
url-matchersGSettings key for storing JSON-serialized patternsgetUrlMatchers(),addUrlMatcher(),removeUrlMatcher()functions inutil.jsfindMatchingApp()for automatic URL-to-application matchingwindow.jsto check for URL matches before displaying application chooserGio.SimpleActionUse Cases
https://github\.com/.*https://youtube\.com/.*https://docs\..*.*\.company\.com/.*Test Coverage
Test Plan
Fixes #75
🤖 Generated with Claude Code