-
-
Notifications
You must be signed in to change notification settings - Fork 36
Implement background app monitoring #394
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
Merged
Merged
Changes from 7 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
97aad50
Implement background app monitoring
leolost2605 af131bd
Use built-in styles, improve screenreader (#434)
danirabbit 683ce71
Use IconGroup for background apps
leolost2605 efd52a9
Make sep highlight less intense, fix off-by-one pos
danirabbit cc1eb98
Fix dnd
leolost2605 879b056
Merge branch 'main' into leolost/background-apps
leolost2605 bf1f8d8
Merge branch 'main' into leolost/background-apps
danirabbit acd541d
Use quit, throw error, and show notification
leolost2605 0d96373
Make item disappear and reappear
leolost2605 08050fd
Merge branch 'main' into leolost/background-apps
leolost2605 d1d9da3
Fix not interactable, popover
leolost2605 03553b7
Readd size animation
leolost2605 93c541a
Fix offset
leolost2605 aa00501
remove placeholder
leolost2605 d298025
add comment
leolost2605 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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 hidden or 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,31 @@ | ||
| /* | ||
| * SPDX-License-Identifier: GPL-3.0 | ||
| * SPDX-FileCopyrightText: 2025 elementary, Inc. (https://elementary.io) | ||
| * | ||
| * Authored by: Leonhard Kargl <leo.kargl@proton.me> | ||
| */ | ||
|
|
||
| public class Dock.BackgroundApp : Object { | ||
| public DesktopAppInfo app_info { get; construct; } | ||
| public Icon icon { get { return app_info.get_icon (); } } | ||
| public string? instance { get; construct; } | ||
| public string? message { get; construct; } | ||
|
|
||
| public BackgroundApp (DesktopAppInfo app_info, string? instance, string? message) { | ||
| Object (app_info: app_info, instance: instance, message: message); | ||
| } | ||
|
|
||
| public void kill () { | ||
| if (instance == null) { | ||
| warning ("No instance to kill"); | ||
| return; | ||
| } | ||
|
|
||
| try { | ||
| var app_id = app_info.get_id ().replace (".desktop", ""); | ||
| Process.spawn_command_line_async ("flatpak kill %s".printf (app_id)); | ||
leolost2605 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } catch (Error e) { | ||
| warning ("Failed to kill instance: %s", e.message); | ||
leolost2605 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
| } | ||
This file contains hidden or 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,78 @@ | ||
| /* | ||
| * SPDX-License-Identifier: GPL-3.0 | ||
| * SPDX-FileCopyrightText: 2025 elementary, Inc. (https://elementary.io) | ||
| * | ||
| * Authored by: Leonhard Kargl <leo.kargl@proton.me> | ||
| */ | ||
|
|
||
| public class Dock.BackgroundAppRow : Gtk.ListBoxRow { | ||
| public BackgroundApp app { get; construct; } | ||
|
|
||
| public BackgroundAppRow (BackgroundApp app) { | ||
| Object (app: app); | ||
| } | ||
|
|
||
| construct { | ||
| var icon = new Gtk.Image.from_gicon (app.app_info.get_icon ()) { | ||
| icon_size = LARGE | ||
| }; | ||
|
|
||
| var name = new Gtk.Label (app.app_info.get_display_name ()) { | ||
| xalign = 0, | ||
| hexpand = true | ||
| }; | ||
|
|
||
| var message = new Gtk.Label (app.message) { | ||
| xalign = 0, | ||
| hexpand = true | ||
| }; | ||
| message.add_css_class (Granite.STYLE_CLASS_DIM_LABEL); | ||
| message.add_css_class (Granite.STYLE_CLASS_SMALL_LABEL); | ||
|
|
||
| var button = new Gtk.Button.from_icon_name ("window-close-symbolic") { | ||
| valign = CENTER, | ||
| tooltip_text = _("Quit"), | ||
| }; | ||
| button.add_css_class ("close-button"); | ||
| button.add_css_class (Granite.STYLE_CLASS_CIRCULAR); | ||
| button.add_css_class (Granite.STYLE_CLASS_DESTRUCTIVE_ACTION); | ||
|
|
||
| var spinner = new Gtk.Spinner () { | ||
| spinning = true | ||
| }; | ||
|
|
||
| var button_stack = new Gtk.Stack () { | ||
| transition_type = CROSSFADE | ||
| }; | ||
| button_stack.add_named (button, "button"); | ||
| button_stack.add_named (spinner, "spinner"); | ||
|
|
||
| var grid = new Gtk.Grid () { | ||
| column_spacing = 9, | ||
| row_spacing = 3 | ||
| }; | ||
| grid.attach (icon, 0, 0, 1, 2); | ||
|
|
||
| if (app.message != null) { | ||
| grid.attach (name, 1, 0); | ||
| grid.attach (message, 1, 1); | ||
| } else { | ||
| grid.attach (name, 1, 0, 1, 2); | ||
| } | ||
|
|
||
| grid.attach (button_stack, 2, 0, 1, 2); | ||
|
|
||
| child = grid; | ||
|
|
||
| button.clicked.connect (() => { | ||
| button_stack.set_visible_child_name ("spinner"); | ||
| app.kill (); | ||
|
|
||
| Timeout.add_seconds (5, () => { | ||
| // Assume killing failed | ||
| button_stack.set_visible_child_name ("button"); | ||
| return Source.REMOVE; | ||
| }); | ||
leolost2605 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| }); | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.