Skip to content

Commit

Permalink
Launcher: Add running on current workspace indicator
Browse files Browse the repository at this point in the history
Add a small dot under the app if there is a window in the current workspace.
  • Loading branch information
tintou committed Jul 11, 2024
1 parent 7c44d65 commit 028b90a
Showing 5 changed files with 47 additions and 3 deletions.
4 changes: 4 additions & 0 deletions data/Application.css
Original file line number Diff line number Diff line change
@@ -45,3 +45,7 @@ launcher progressbar progress {
min-height: 3px;
min-width: 0;
}

.running-indicator {
opacity: 0.6;
}
13 changes: 13 additions & 0 deletions src/App.vala
Original file line number Diff line number Diff line change
@@ -20,6 +20,17 @@ public class Dock.App : Object {
public bool progress_visible { get; set; default = false; }
public double progress { get; set; default = 0; }
public bool prefers_nondefault_gpu { get; private set; default = false; }
public bool running_on_active_workspace {
get {
foreach (var win in windows) {
if (win.on_active_workspace) {
return true;
}
}

return false;
}
}

public SimpleActionGroup action_group { get; construct; }
public Menu menu_model { get; construct; }
@@ -161,6 +172,8 @@ public class Dock.App : Object {
} else {
windows = new_windows;
}

notify_property ("running-on-active-workspace");
}

public AppWindow? find_window (uint64 window_uid) {
5 changes: 5 additions & 0 deletions src/AppWindow.vala
Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@ public class Dock.AppWindow : GLib.Object {
public uint64 uid { get; construct set; }

public bool has_focus { get; private set; default = false; }
public bool on_active_workspace { get; private set; default = false; }

public AppWindow (uint64 uid) {
Object (uid: uid);
@@ -17,5 +18,9 @@ public class Dock.AppWindow : GLib.Object {
if ("has-focus" in properties) {
has_focus = (bool) properties["has-focus"];
}

if ("on-active-workspace" in properties) {
on_active_workspace = (bool) properties["on-active-workspace"];
}
}
}
20 changes: 19 additions & 1 deletion src/Launcher.vala
Original file line number Diff line number Diff line change
@@ -29,13 +29,17 @@ public class Dock.Launcher : Gtk.Box {
}
}

public Gtk.Revealer running_revealer;

private static Settings settings;

private Gtk.Image image;
private Adw.TimedAnimation bounce_up;
private Adw.TimedAnimation bounce_down;
private Adw.TimedAnimation timed_animation;

private Gtk.Image running_indicator;

private Gtk.GestureClick gesture_click;
private Gtk.Overlay overlay;
private Gtk.PopoverMenu popover;
@@ -49,7 +53,7 @@ public class Dock.Launcher : Gtk.Box {
private int drag_offset_y = 0;

public Launcher (App app) {
Object (app: app);
Object (app: app, orientation: Gtk.Orientation.VERTICAL);
}

class construct {
@@ -98,6 +102,19 @@ public class Dock.Launcher : Gtk.Box {
transition_type = CROSSFADE
};

running_indicator = new Gtk.Image.from_icon_name ("pager-checked-symbolic") {
pixel_size = 12
};
running_indicator.add_css_class ("accent");
running_indicator.add_css_class ("running-indicator");
running_revealer = new Gtk.Revealer () {
can_target = false,
child = running_indicator,
transition_type = CROSSFADE,
halign = CENTER,
valign = END
};

overlay = new Gtk.Overlay () {
child = image
};
@@ -209,6 +226,7 @@ public class Dock.Launcher : Gtk.Box {

app.bind_property ("progress-visible", progress_revealer, "reveal-child", SYNC_CREATE);
app.bind_property ("progress", progressbar, "fraction", SYNC_CREATE);
app.bind_property ("running-on-active-workspace", running_revealer, "reveal-child", SYNC_CREATE);

var drop_target_file = new Gtk.DropTarget (typeof (File), COPY);
add_controller (drop_target_file);
8 changes: 6 additions & 2 deletions src/LauncherManager.vala
Original file line number Diff line number Diff line change
@@ -119,17 +119,20 @@
}

private void reposition_launchers () {
height_request = get_launcher_size ();
var launcher_size = get_launcher_size ();
height_request = launcher_size;

int index = 0;
foreach (var launcher in launchers) {
var position = index * get_launcher_size ();
var position = index * launcher_size;

if (launcher.parent != this) {
put (launcher, position, 0);
put (launcher.running_revealer, position + (launcher_size - launcher.running_revealer.get_width ()) / 2, launcher_size - Launcher.PADDING * 2 + Launcher.PADDING / 2);
launcher.current_pos = position;
} else {
launcher.animate_move (position);
move (launcher.running_revealer, position + (launcher_size - launcher.running_revealer.get_width ()) / 2, launcher_size - Launcher.PADDING * 2 + Launcher.PADDING / 2);
}

index++;
@@ -183,6 +186,7 @@
}

private void remove_finish (Launcher launcher) {
remove (launcher.running_revealer);
remove (launcher);
reposition_launchers ();

0 comments on commit 028b90a

Please sign in to comment.