-
-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove unsafe permissions and add dialog (#985)
Fixes #915
- Loading branch information
Showing
16 changed files
with
838 additions
and
8 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
using Gtk 4.0; | ||
using Adw 1; | ||
|
||
Adw.Dialog dialog { | ||
content-height: 750; | ||
content-width: 600; | ||
|
||
Adw.ToolbarView { | ||
[top] | ||
Adw.HeaderBar {} | ||
|
||
content: ScrolledWindow { | ||
hscrollbar-policy: never; | ||
|
||
Adw.Clamp { | ||
maximum-size: 520; | ||
tightening-threshold: 400; | ||
margin-start: 12; | ||
margin-end: 12; | ||
margin-bottom: 24; | ||
|
||
Box { | ||
orientation: vertical; | ||
halign: fill; | ||
spacing: 24; | ||
// Gtk.Picture needs to be wrapped in a box to behave properly | ||
Box { | ||
halign: center; | ||
|
||
Picture picture_illustration { | ||
can-shrink: false; | ||
margin-bottom: 24; | ||
} | ||
} | ||
|
||
Label { | ||
label: _("Permissions Needed"); | ||
|
||
styles [ | ||
"title-1" | ||
] | ||
} | ||
|
||
Label { | ||
label: _("Workbench needs additional permissions. Please run the following command in a terminal and restart the app."); | ||
wrap: true; | ||
justify: center; | ||
} | ||
|
||
Label label_command { | ||
use-markup: true; | ||
wrap: true; | ||
wrap-mode: word_char; | ||
selectable: true; | ||
xalign: 0; | ||
|
||
styles [ | ||
"command_snippet" | ||
] | ||
} | ||
|
||
Box { | ||
orientation: vertical; | ||
|
||
Box { | ||
margin-bottom: 6; | ||
|
||
Label { | ||
label: _("What it does"); | ||
halign: start; | ||
hexpand: true; | ||
|
||
styles [ | ||
"heading" | ||
] | ||
} | ||
|
||
Button button_info { | ||
icon-name: "re.sonny.Workbench-external-link-symbolic"; | ||
|
||
styles [ | ||
"flat" | ||
] | ||
} | ||
} | ||
|
||
ListBox { | ||
selection-mode: none; | ||
|
||
styles [ | ||
"boxed-list" | ||
] | ||
|
||
Adw.ActionRow { | ||
[prefix] | ||
Image { | ||
icon-name: "re.sonny.Workbench-person-symbolic"; | ||
} | ||
|
||
title: _("--user"); | ||
subtitle: _("Grant for your account only"); | ||
|
||
styles [ | ||
"property" | ||
] | ||
} | ||
|
||
Adw.ActionRow { | ||
[prefix] | ||
Image { | ||
icon-name: "re.sonny.Workbench-network-wireless-symbolic"; | ||
} | ||
|
||
title: _("--share-network"); | ||
subtitle: _("Network access"); | ||
|
||
styles [ | ||
"property" | ||
] | ||
} | ||
|
||
Adw.ActionRow { | ||
[prefix] | ||
Image { | ||
icon-name: "re.sonny.Workbench-speakers-symbolic"; | ||
} | ||
|
||
title: _("--socket=pulseaudio"); | ||
subtitle: _("Record and play audio"); | ||
|
||
styles [ | ||
"property" | ||
] | ||
} | ||
|
||
Adw.ActionRow { | ||
[prefix] | ||
Image { | ||
icon-name: "re.sonny.Workbench-gamepad-symbolic"; | ||
} | ||
|
||
title: _("--device=input"); | ||
subtitle: _("Access to input device such as gamepads"); | ||
|
||
styles [ | ||
"property" | ||
] | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}; | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import Gio from "gi://Gio"; | ||
import GLib from "gi://GLib"; | ||
import Gtk from "gi://Gtk"; | ||
|
||
import { build } from "../../troll/src/main.js"; | ||
|
||
import Interface from "./Permissions.blp" with { type: "uri" }; | ||
|
||
import illustration from "./permissions.svg"; | ||
|
||
import { getFlatpakInfo } from "../util.js"; | ||
|
||
const action_permissions = new Gio.SimpleAction({ | ||
name: "permissions", | ||
parameter_type: null, | ||
}); | ||
|
||
export function Permissions({ window }) { | ||
const { dialog, picture_illustration, label_command, button_info } = | ||
build(Interface); | ||
|
||
picture_illustration.set_resource(illustration); | ||
label_command.label = `flatpak override --user --share=network --socket=pulseaudio --device=input ${GLib.getenv( | ||
"FLATPAK_ID", | ||
)}`; | ||
|
||
button_info.connect("clicked", () => { | ||
new Gtk.UriLauncher({ | ||
uri: "https://docs.flatpak.org/en/latest/sandbox-permissions.html", | ||
}) | ||
.launch(window, null) | ||
.catch(console.error); | ||
}); | ||
|
||
action_permissions.connect("activate", () => { | ||
dialog.present(window); | ||
}); | ||
|
||
window.add_action(action_permissions); | ||
} | ||
|
||
const missing_permissions = (() => { | ||
const flatpak_info = getFlatpakInfo(); | ||
const shared = flatpak_info.get_string_list("Context", "shared"); | ||
const sockets = flatpak_info.get_string_list("Context", "sockets"); | ||
const devices = flatpak_info.get_string_list("Context", "devices"); | ||
|
||
return ( | ||
!shared.includes("network") || | ||
!sockets.includes("pulseaudio") || | ||
!devices.includes("all") | ||
); | ||
})(); | ||
|
||
export function needsAdditionalPermissions({ demo }) { | ||
if (!demo["flatpak-finish-args"]) return false; | ||
return missing_permissions; | ||
} | ||
|
||
export function showPermissionsDialog({ window }) { | ||
window.activate_action("permissions", null); | ||
} |
Oops, something went wrong.