Skip to content

Commit

Permalink
gtk4: Reimplement Find keybinding
Browse files Browse the repository at this point in the history
Closes tchx84#517

Signed-off-by: Nefo Fortressia <nefothingy@hotmail.com>
  • Loading branch information
togetherwithasteria authored and tchx84 committed Apr 5, 2023
1 parent 7fff553 commit bef5eed
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 30 deletions.
22 changes: 5 additions & 17 deletions src/widgets/window.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ var FlatsealWindow = GObject.registerClass({
'actionBar',
'appInfoGroup',
'applicationsSearchButton',
'applicationsSearchRevealer',
'applicationsSearchBar',
'applicationsSearchEntry',
'applicationsStack',
'applicationsListBox',
Expand All @@ -72,11 +72,6 @@ var FlatsealWindow = GObject.registerClass({
'undoPopupBox',
'permissionsTitle',
],
Signals: {
find: {
flags: GObject.SignalFlags.RUN_LAST | GObject.SignalFlags.ACTION,
},
},
}, class FlatsealWindow extends Adw.ApplicationWindow {
_init(application) {
super._init({application});
Expand Down Expand Up @@ -241,15 +236,15 @@ var FlatsealWindow = GObject.registerClass({
this._applicationsSearchEntry.connect('search-changed', this._resetSearch.bind(this));

this._applicationsSearchButton.bind_property(
'active', this._applicationsSearchRevealer, 'reveal-child', _bindFlags);
'active', this._applicationsSearchBar, 'search-mode-enabled', _bindFlags);
this._applicationsSearchButton.connect(
'toggled', this._toggleSearchWithButton.bind(this));

this.connect('find', this._enableSearchWithShortcut.bind(this));

this._showApplications();
this._backButton.set_sensitive(true);
this._backButton.connect('clicked', this._showApplications.bind(this));

this._applicationsSearchBar.set_key_capture_widget(this.root);
}

_shutdown() {
Expand Down Expand Up @@ -342,14 +337,7 @@ var FlatsealWindow = GObject.registerClass({
return 1;
}

_enableSearchWithShortcut() {
this._applicationsSearchRevealer.reveal_child = true;
this._applicationsSearchEntry.grab_focus();
}

_toggleSearchWithButton() {
this._applicationsSearchEntry.set_text('');

if (this._applicationsSearchButton.active)
this._applicationsSearchEntry.grab_focus();
else
Expand All @@ -358,7 +346,7 @@ var FlatsealWindow = GObject.registerClass({

_cancelSearch() {
if (this._applicationsSearchEntry.get_text() === '')
this._applicationsSearchRevealer.reveal_child = false;
this._applicationsSearchBar.search_mode_enabled = false;

this._applicationsSearchEntry.set_text('');
}
Expand Down
28 changes: 15 additions & 13 deletions src/widgets/window.ui
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,17 @@
<property name="icon-name">system-search-symbolic</property>
</object>
</child>
<child>
<object class="GtkShortcutController">
<property name="scope">global</property>
<child>
<object class="GtkShortcut">
<property name="trigger">&lt;Control&gt;F</property>
<property name="action">activate</property>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
Expand Down Expand Up @@ -107,19 +118,10 @@
<object class="GtkBox" id="applicationsBox">
<property name="orientation">vertical</property>
<child>
<object class="GtkRevealer" id="applicationsSearchRevealer">
<property name="reveal-child">1</property>
<property name="child">
<object class="GtkSearchEntry" id="applicationsSearchEntry">
<property name="focusable">1</property>
<!--property name="primary-icon-name">edit-find-symbolic</property> -->
<!--<property name="primary-icon-activatable">False</property>-->
<!--<property name="primary-icon-sensitive">False</property>-->
<style>
<class name="search-entry" />
</style>
</object>
</property>
<object class="GtkSearchBar" id="applicationsSearchBar">
<child>
<object class="GtkSearchEntry" id="applicationsSearchEntry" />
</child>
</object>
</child>
<child>
Expand Down

0 comments on commit bef5eed

Please sign in to comment.