Skip to content

Commit

Permalink
window: Add confirmation step before reloading applications
Browse files Browse the repository at this point in the history
Closes #187
  • Loading branch information
tchx84 committed Sep 1, 2023
1 parent d812873 commit fece7ee
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 23 deletions.
14 changes: 13 additions & 1 deletion src/widgets/window.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ var FlatsealWindow = GObject.registerClass({
InternalChildren: [
'actionBar',
'appInfoGroup',
'applicationsToastOverlay',
'applicationsSearchButton',
'applicationsSearchBar',
'applicationsSearchEntry',
Expand Down Expand Up @@ -137,10 +138,21 @@ var FlatsealWindow = GObject.registerClass({

this._applicationsSearchBar.set_key_capture_widget(this.root);

this._applicationsToast = new Adw.Toast();
this._applicationsToast.title = _('Installation changed');
this._applicationsToast.button_label = _('Reload');
this._applicationsToast.timeout = null;
this._applicationsToast.connect('button-clicked', this._setupApplications.bind(this));

this._monitor = new FlatpakMonitorModel();
this._monitor.connect('changed', this._setupApplications.bind(this));
this._monitor.connect('changed', this._showApplicationsToast.bind(this));
}

_showApplicationsToast() {
this._applicationsToastOverlay.add_toast(this._applicationsToast);
}


_setupApplications() {
for (const row of Array.from(this._applicationsListBox)) {
if (row instanceof Adw.ActionRow)
Expand Down
55 changes: 33 additions & 22 deletions src/widgets/window.ui
Original file line number Diff line number Diff line change
Expand Up @@ -54,30 +54,41 @@
</object>
</child>
<child>
<object class="GtkSearchBar" id="applicationsSearchBar">
<child>
<object class="GtkSearchEntry" id="applicationsSearchEntry" />
</child>
</object>
</child>
<child>
<object class="GtkScrolledWindow">
<object class="AdwToastOverlay" id="applicationsToastOverlay">
<property name="child">
<object class="GtkListBox" id="applicationsListBox">
<style>
<class name="navigation-sidebar" />
</style>
<object class="GtkBox">
<property name="vexpand">True</property>
<property name="selection-mode">browse</property>
<child type="placeholder">
<object class="AdwStatusPage">
<property name="icon-name">system-search-symbolic</property>
<property name="title" translatable="yes">No applications found.</property>
<style>
<class name="compact"/>
</style>
</object>
</child>
<property name="width-request">360</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkSearchBar" id="applicationsSearchBar">
<child>
<object class="GtkSearchEntry" id="applicationsSearchEntry" />
</child>
</object>
</child>
<child>
<object class="GtkScrolledWindow">
<property name="child">
<object class="GtkListBox" id="applicationsListBox">
<style>
<class name="navigation-sidebar" />
</style>
<property name="vexpand">True</property>
<property name="selection-mode">browse</property>
<child type="placeholder">
<object class="AdwStatusPage">
<property name="icon-name">system-search-symbolic</property>
<property name="title" translatable="yes">No applications found.</property>
<style>
<class name="compact"/>
</style>
</object>
</child>
</object>
</property>
</object>
</child>
</object>
</property>
</object>
Expand Down

0 comments on commit fece7ee

Please sign in to comment.