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

Fix initial tray icon scaling #468

Merged
merged 3 commits into from
Oct 8, 2023
Merged
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
22 changes: 14 additions & 8 deletions src/panel/applets/tray/TrayApplet.vala
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public class TrayApplet : Budgie.Applet {
private uint dbus_identifier;
private SnWatcherInterface? watcher = null;
private int panel_size;
private const int DEFAULT_PANEL_SIZE = 36;

public TrayApplet(string uuid) {
Object(uuid: uuid);
Expand All @@ -79,8 +80,7 @@ public class TrayApplet : Budgie.Applet {
layout.set_spacing(settings.get_int("spacing"));
});
settings.changed["scaling"].connect((key) => {
var size = settings.get_boolean("scaling") ? panel_size : 36;
items.get_values().foreach((item) => item.resize(size));
items.get_values().foreach((item) => item.resize(get_target_panel_size()));
});

items = new HashTable<string, TrayItem>(str_hash, str_equal);
Expand Down Expand Up @@ -172,7 +172,7 @@ public class TrayApplet : Budgie.Applet {
if (key in items) return;

try {
var new_item = new TrayItem(name, object_path, panel_size);
var new_item = new TrayItem(name, object_path, get_target_panel_size());
items.set(key, new_item);
if (object_path == "/org/ayatana/NotificationItem/nm_applet") {
layout.pack_end(new_item);
Expand All @@ -185,6 +185,14 @@ public class TrayApplet : Budgie.Applet {
}
}

private int get_target_panel_size() {
if (settings.get_boolean("scaling")) {
return panel_size;
} else {
return (int) Math.fmin(panel_size, DEFAULT_PANEL_SIZE);
}
}

public override void panel_position_changed(Budgie.PanelPosition position) {
if (position == Budgie.PanelPosition.LEFT || position == Budgie.PanelPosition.RIGHT) {
layout.orientation = Gtk.Orientation.VERTICAL;
Expand All @@ -199,11 +207,9 @@ public class TrayApplet : Budgie.Applet {

public override void panel_size_changed(int panel, int icon, int small_icon) {
panel_size = panel;
if (settings.get_boolean("scaling")) {
items.get_values().foreach((item)=>{
item.resize(panel);
});
}
items.get_values().foreach((item) => {
item.resize(get_target_panel_size());
});
}

public override bool supports_settings() {
Expand Down