Skip to content

Commit

Permalink
Launcher: new context option to close all windows
Browse files Browse the repository at this point in the history
  • Loading branch information
moises2657 committed Jan 1, 2025
1 parent d4644ef commit 7f9ea40
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/DesktopIntegration.vala
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ public interface Dock.DesktopIntegration : GLib.Object {
public abstract async Window[] get_windows () throws GLib.DBusError, GLib.IOError;
public abstract async void show_windows_for (string app_id) throws GLib.DBusError, GLib.IOError;
public abstract async void focus_window (uint64 uid) throws GLib.DBusError, GLib.IOError;
public abstract async void close_window (uint64 uid) throws GLib.DBusError, GLib.IOError;
}
27 changes: 27 additions & 0 deletions src/Launcher.vala
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,8 @@ public class Dock.Launcher : Gtk.Box {
app.notify["running"].connect (update_running_revealer);
update_running_revealer ();

app.notify["running"].connect(close_all_instances);

var drop_target_file = new Gtk.DropTarget (typeof (File), COPY);
add_controller (drop_target_file);

Expand Down Expand Up @@ -336,6 +338,31 @@ public class Dock.Launcher : Gtk.Box {
}
}

private void close_all_instances(){
if (app.running) {
if (app.action_group.lookup_action("close-instances") != null) {
return;
}

var close_item = new GLib.MenuItem(_("Close All Windows"), "app-actions.close-instances");
app.menu_model.append_item(close_item);

var close_action = new SimpleAction("close-instances", null);
close_action.activate.connect(() => {
var desktop_integration = LauncherManager.get_default().desktop_integration;

foreach (var win in app.windows) {
desktop_integration.close_window.begin(win.uid, null);
}

app.windows.clear();
});

close_action.set_enabled(true);
app.action_group.add_action(close_action);
}
}

private void animate_launch () {
if (bounce_up.state == PLAYING || bounce_down.state == PLAYING) {
return;
Expand Down

0 comments on commit 7f9ea40

Please sign in to comment.