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

Port to GNOME 45 #579

Merged
merged 6 commits into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ For more details please visit the [documentation](./DOCUMENTATION.md) page.
```
git clone https://github.com/tchx84/Flatseal.git
cd Flatseal
flatpak --user install org.gnome.{Platform,Sdk}//44
flatpak --user install org.gnome.{Platform,Sdk}//45
flatpak-builder --user --force-clean --install build com.github.tchx84.Flatseal.json
flatpak --user run --branch=master com.github.tchx84.Flatseal
```
Expand Down
2 changes: 1 addition & 1 deletion com.github.tchx84.Flatseal.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"app-id": "com.github.tchx84.Flatseal",
"runtime": "org.gnome.Platform",
"runtime-version": "44",
"runtime-version": "45",
"sdk": "org.gnome.Sdk",
"separate-locales": false,
"command": "com.github.tchx84.Flatseal",
Expand Down
45 changes: 21 additions & 24 deletions src/models/applications.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

/* exported FlatpakApplicationsModel getDefault */

const {GObject, GLib, Gio, AppStreamGlib} = imports.gi;
const {GObject, GLib, Gio, AppStream} = imports.gi;

const {info} = imports.models;

Expand Down Expand Up @@ -261,21 +261,19 @@ var FlatpakApplicationsModel = GObject.registerClass({
'export', 'share', 'applications', appdata.launchable,
]);

if (GLib.access(path, 0) !== 0)
const file = Gio.File.new_for_path(path);
if (!file.query_exists(null))
return desktop;

const app = new AppStreamGlib.App();

const metadata = new AppStream.Metadata();
try {
app.parse_file(path, AppStreamGlib.AppParseFlags.NONE);
metadata.parse_file(file, AppStream.FormatKind.DESKTOP_ENTRY);
} catch (err) {
return desktop;
}

if (app === null)
return desktop;

const icon = app.get_icon_default();
const component = metadata.get_component();
const icon = component.get_icon_stock();
if (icon === null)
return desktop;

Expand All @@ -301,32 +299,31 @@ var FlatpakApplicationsModel = GObject.registerClass({
'files', 'share', 'appdata', `${appId}.appdata.xml`,
]);

if (GLib.access(path, 0) !== 0)
const file = Gio.File.new_for_path(path);
if (!file.query_exists(null))
return appdata;

const app = new AppStreamGlib.App();

const metadata = new AppStream.Metadata();
try {
app.parse_file(path, AppStreamGlib.AppParseFlags.NONE);
metadata.parse_file(file, AppStream.FormatKind.XML);
} catch (err) {
return appdata;
}

if (app === null)
return appdata;
const component = metadata.get_component();

if (app.get_name(null) !== null)
appdata.name = app.get_name(null);
if (component.get_name())
appdata.name = component.get_name();

if (app.get_developer_name(null) !== null)
appdata.author = app.get_developer_name(null);
if (component.get_developer_name())
appdata.author = component.get_developer_name();

const launchable = app.get_launchable_default();
if (launchable !== null && launchable.get_value())
appdata.launchable = launchable.get_value();
const launchable = component.get_launchable(AppStream.LaunchableKind.DESKTOP_ID);
if (launchable && launchable.get_entries())
[appdata.launchable] = launchable.get_entries();

const release = app.get_release_default();
if (release === null)
const [release] = component.get_releases();
if (!release)
return appdata;

if (release.get_version() !== null)
Expand Down
5 changes: 4 additions & 1 deletion src/style.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
.navigation-sidebar row {
padding: 3px 0px;
}
searchbar box {
background-color: transparent;
}

.permissions clamp {
margin-bottom: 25px;
Expand Down Expand Up @@ -78,7 +81,7 @@ row .content .path popover treeview:selected {

.permissions .app-info .name {
font-size: xx-large;
font-weight: bold;
font-weight: ultra-bold;
margin-bottom: 5px;
}

Expand Down
29 changes: 5 additions & 24 deletions src/widgets/window.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ const _bindFlags = GObject.BindingFlags.BIDIRECTIONAL | GObject.BindingFlags.SYN
const _bindReadFlags = GObject.BindingFlags.SYNC_CREATE;

const menuResource = '/com/github/tchx84/Flatseal/widgets/menu.ui';
const ACTION_BAR_BREAKPOINT = 540;
const APP_SELECTION_DELAY = 100;


Expand All @@ -66,7 +65,6 @@ var FlatsealWindow = GObject.registerClass({
'startActionBox',
'endActionBox',
'menuButton',
'backButton',
'contentLeaflet',
'permissionsTitle',
'toastOverlay',
Expand Down Expand Up @@ -116,9 +114,6 @@ var FlatsealWindow = GObject.registerClass({
this._applicationsToast.timeout = null;
this._applications.connect('changed', this._showApplicationsToast.bind(this));

this._contentLeaflet.bind_property(
'folded', this._backButton, 'visible', _bindReadFlags);

this._applicationsListBox.set_filter_func(this._filter.bind(this));
this._applicationsListBox.set_sort_func(this._sort.bind(this));

Expand All @@ -136,8 +131,6 @@ var FlatsealWindow = GObject.registerClass({
this._setupPermissions();

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

this._applicationsSearchBar.set_key_capture_widget(this.root);
}
Expand Down Expand Up @@ -197,12 +190,12 @@ var FlatsealWindow = GObject.registerClass({
this._appInfoViewer = new FlatsealAppInfoViewer();
this._appInfoGroup.add(this._appInfoViewer);
this._contentLeaflet.bind_property(
'folded', this._appInfoViewer, 'compact', _bindReadFlags);
'collapsed', this._appInfoViewer, 'compact', _bindReadFlags);

this._globalInfoViewer = new FlatsealGlobalInfoViewer();
this._appInfoGroup.add(this._globalInfoViewer);
this._contentLeaflet.bind_property(
'folded', this._globalInfoViewer, 'compact', _bindReadFlags);
'collapsed', this._globalInfoViewer, 'compact', _bindReadFlags);

let lastGroup = '';
let lastPrefsGroup;
Expand Down Expand Up @@ -294,7 +287,7 @@ var FlatsealWindow = GObject.registerClass({
}

_activateApplication() {
if (this._contentLeaflet.folded)
if (this._contentLeaflet.collapsed)
this._showPermissions();
}

Expand Down Expand Up @@ -383,12 +376,11 @@ var FlatsealWindow = GObject.registerClass({
}

_showApplications() {
this._contentLeaflet.set_visible_child_name('applications');
this._backButton.active = false;
this._contentLeaflet.show_content = false;
}

_showPermissions() {
this._contentLeaflet.set_visible_child_name('permissions');
this._contentLeaflet.show_content = true;
}

_showToast() {
Expand Down Expand Up @@ -416,17 +408,6 @@ var FlatsealWindow = GObject.registerClass({
this._permissions.undo();
}

/* XXX switch to Breakpoints API when available */
vfunc_size_allocate(width, height, baseline) {
const visible = width <= ACTION_BAR_BREAKPOINT;

this._detailsHeaderButton.visible = !visible;
this._resetHeaderButton.visible = !visible;
this._actionBar.visible = visible;

return super.vfunc_size_allocate(width, height, baseline);
}

vfunc_close_request() {
this._settings.saveWindowState(this);
this._shutdown();
Expand Down
92 changes: 34 additions & 58 deletions src/widgets/window.ui
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,28 @@
<interface>
<template class="FlatsealWindow" parent="AdwApplicationWindow">
<property name="title">Flatseal</property>
<property name="width-request">360</property>
<property name="height-request">294</property>
<child>
<object class="AdwLeaflet" id="contentLeaflet">
<property name="width-request">360</property>
<property name="can-navigate-back">True</property>
<child>
<object class="AdwLeafletPage">
<property name="name">applications</property>
<object class="AdwBreakpoint">
<condition>max-width: 720sp</condition>
<setter object="contentLeaflet" property="collapsed">True</setter>
<setter object="startHeaderBox" property="visible">False</setter>
<setter object="endHeaderBox" property="visible">False</setter>
<setter object="actionBar" property="visible">True</setter>
</object>
</child>
<property name="content">
<object class="AdwNavigationSplitView" id="contentLeaflet">
<property name="sidebar">
<object class="AdwNavigationPage">
<property name="tag">applications</property>
<property name="title" translatable="yes">Applications</property>
<property name="child">
<object class="GtkBox">
<property name="width-request">360</property>
<style>
<class name="applications" />
</style>
<property name="orientation">vertical</property>
<child>
<object class="AdwToolbarView">
<child type="top">
<object class="AdwHeaderBar" id="applicationsHeaderBar">
<property name="width-request">360</property>
<property name="visible">True</property>
<property name="title-widget">
<object class="AdwWindowTitle">
<property name="title" translatable="yes">Applications</property>
</object>
</property>
<binding name="show-end-title-buttons">
<lookup name="folded">contentLeaflet</lookup>
</binding>
<child type="end">
<object class="GtkMenuButton" id="menuButton">
<property name="icon-name">open-menu-symbolic</property>
Expand All @@ -53,7 +49,7 @@
</child>
</object>
</child>
<child>
<property name="content">
<object class="AdwToastOverlay" id="applicationsToastOverlay">
<property name="child">
<object class="GtkBox">
Expand All @@ -63,7 +59,9 @@
<child>
<object class="GtkSearchBar" id="applicationsSearchBar">
<child>
<object class="GtkSearchEntry" id="applicationsSearchEntry" />
<object class="GtkSearchEntry" id="applicationsSearchEntry">
<property name="hexpand">True</property>
</object>
</child>
</object>
</child>
Expand Down Expand Up @@ -92,47 +90,26 @@
</object>
</property>
</object>
</child>
</property>
</object>
</property>
</object>
</child>
<child>
<object class="AdwLeafletPage">
<property name="navigatable">False</property>
</property>
<property name="content">
<object class="AdwNavigationPage">
<property name="tag">permissions</property>
<property name="title" translatable="yes">Permissions</property>
<property name="child">
<object class="GtkSeparator">
<property name="orientation">vertical</property>
</object>
</property>
</object>
</child>
<child>
<object class="AdwLeafletPage">
<property name="name">permissions</property>
<property name="child">
<object class="GtkBox">
<property name="orientation">vertical</property>
<child>
<object class="AdwToolbarView">
<child type="top">
<object class="AdwHeaderBar" id="permissionsHeaderBar">
<property name="width-request">360</property>
<property name="hexpand">True</property>
<binding name="show-start-title-buttons">
<lookup name="folded">contentLeaflet</lookup>
</binding>
<property name="title-widget">
<object class="AdwWindowTitle" id="permissionsTitle"/>
</property>
<child>
<object class="GtkBox" id="startHeaderBox">
<property name="valign">center</property>
<child>
<object class="GtkButton" id="backButton">
<property name="sensitive">False</property>
<property name="valign">center</property>
<property name="icon-name">go-previous-symbolic</property>
</object>
</child>
</object>
</child>
<child type="end">
Expand All @@ -142,12 +119,11 @@
</child>
</object>
</child>
<child>
<property name="content">
<object class="AdwToastOverlay" id="toastOverlay">
<property name="child">
<object class="GtkBox">
<property name="vexpand">True</property>
<property name="width-request">360</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkStack" id="permissionsStack">
Expand Down Expand Up @@ -200,12 +176,12 @@
</object>
</property>
</object>
</child>
</property>
</object>
</property>
</object>
</child>
</property>
</object>
</child>
</property>
</template>
</interface>