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

Launcher: Add running on current workspace indicator #255

Merged
merged 4 commits into from
Jul 13, 2024
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
10 changes: 9 additions & 1 deletion data/Application.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ dock {
0 0 0 1px alpha(@borders, 0.4),
0 1px 3px alpha(black, 0.10),
0 3px 9px alpha(black, 0.15);
margin: 0 12px 12px 12px;
margin: 9px;
margin-top: 0;
}

launcher {
padding: 6px;
padding-bottom: 0px;
}

launcher progressbar {
Expand All @@ -45,3 +47,9 @@ launcher progressbar progress {
min-height: 3px;
min-width: 0;
}

.running-indicator {
color: @selected_fg_color;
-gtk-icon-size: 9px;
margin-top: -3px;
}
13 changes: 13 additions & 0 deletions src/App.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down Expand Up @@ -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) {
Expand Down
5 changes: 5 additions & 0 deletions src/AppWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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"];
}
}
}
15 changes: 15 additions & 0 deletions src/Launcher.vala
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class Dock.Launcher : Gtk.Box {
private static Settings settings;

private Gtk.Image image;
private Gtk.Image running_indicator;
private Adw.TimedAnimation bounce_up;
private Adw.TimedAnimation bounce_down;
private Adw.TimedAnimation timed_animation;
Expand Down Expand Up @@ -98,6 +99,17 @@ public class Dock.Launcher : Gtk.Box {
transition_type = CROSSFADE
};

running_indicator = new Gtk.Image.from_icon_name ("pager-checked-symbolic");
running_indicator.add_css_class ("running-indicator");

var running_revealer = new Gtk.Revealer () {
can_target = false,
child = running_indicator,
overflow = VISIBLE,
transition_type = CROSSFADE,
valign = END
};

overlay = new Gtk.Overlay () {
child = image
};
Expand All @@ -107,6 +119,8 @@ public class Dock.Launcher : Gtk.Box {
// Needed to work around DnD bug where it
// would stop working once the button got clicked
append (overlay);
append (running_revealer);
orientation = VERTICAL;
tooltip_text = app.app_info.get_display_name ();

var launcher_manager = LauncherManager.get_default ();
Expand Down Expand Up @@ -209,6 +223,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);
Expand Down
5 changes: 3 additions & 2 deletions src/LauncherManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,12 @@
}

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);
Expand Down