From 6af348ea1d967c6d3f09cdffe03d804251673d35 Mon Sep 17 00:00:00 2001 From: Leonhard Date: Fri, 19 Jun 2026 18:16:31 +0200 Subject: [PATCH 1/2] BaseItem: Make index a property and notify when it changes --- src/BaseItem.vala | 18 ++++++++++++------ src/ItemGroup.vala | 3 +++ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/BaseItem.vala b/src/BaseItem.vala index 0522be34..6bf3dcd4 100644 --- a/src/BaseItem.vala +++ b/src/BaseItem.vala @@ -54,6 +54,17 @@ public class Dock.BaseItem : Gtk.Box { public State state { get; set; } + public uint index { + get { + var item_group = get_ancestor (typeof (ItemGroup)) as ItemGroup; + if (item_group == null) { + return Gtk.INVALID_LIST_POSITION; + } + + return item_group.get_index_for_item (this); + } + } + protected Gtk.Overlay overlay; protected Gtk.GestureClick gesture_click; @@ -194,11 +205,6 @@ public class Dock.BaseItem : Gtk.Box { popover_tooltip.dispose (); } - public uint get_index () { - var item_group = get_ancestor (typeof (ItemGroup)) as ItemGroup; - return item_group?.get_index_for_item (this) ?? Gtk.INVALID_LIST_POSITION; - } - public void set_revealed (bool revealed) { fade.skip (); reveal.skip (); @@ -307,7 +313,7 @@ public class Dock.BaseItem : Gtk.Box { */ public void calculate_dnd_move (BaseItem source, double x, double y) { var launcher_manager = ItemManager.get_default (); - launcher_manager.move_launcher_after (source, (int) get_index ()); + launcher_manager.move_launcher_after (source, (int) index); } private bool on_drop (Value val) { diff --git a/src/ItemGroup.vala b/src/ItemGroup.vala index cc51fe5f..1e3e5e86 100644 --- a/src/ItemGroup.vala +++ b/src/ItemGroup.vala @@ -74,6 +74,9 @@ for (uint i = 0; i < current_children.get_n_items (); i++) { var item = (BaseItem) current_children.get_item (i); item.animate_move (get_launcher_size () * i); + + /* Index might have changed so notify */ + item.notify_property ("index"); } relayout_queued = false; From 7f2d4bdbbbfe7f1859bae003e599e4bb2b8d21a5 Mon Sep 17 00:00:00 2001 From: Leonhard Date: Fri, 19 Jun 2026 18:16:48 +0200 Subject: [PATCH 2/2] Launcher: Use index for tooltip --- src/AppSystem/Launcher.vala | 5 ++--- src/ItemManager.vala | 4 ---- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/AppSystem/Launcher.vala b/src/AppSystem/Launcher.vala index 9b2d05df..24a27004 100644 --- a/src/AppSystem/Launcher.vala +++ b/src/AppSystem/Launcher.vala @@ -98,7 +98,7 @@ public class Dock.Launcher : BaseItem { popover_menu.set_parent (this); update_tooltip (); - notify["current-pos"].connect (update_tooltip); + notify["index"].connect (update_tooltip); keybinding_settings.changed.connect (update_tooltip); image = new Gtk.Image (); @@ -379,9 +379,8 @@ public class Dock.Launcher : BaseItem { private void update_tooltip () { string[] accels = {}; - var index = (int) current_pos / ItemManager.get_launcher_size (); if (index < 9) { - accels = keybinding_settings.get_strv ("launch-dock-%i".printf (index + 1)); + accels = keybinding_settings.get_strv ("launch-dock-%u".printf (index + 1)); } tooltip_text = Granite.markup_accel_tooltip ( diff --git a/src/ItemManager.vala b/src/ItemManager.vala index a3e7e964..cfae0936 100644 --- a/src/ItemManager.vala +++ b/src/ItemManager.vala @@ -173,8 +173,4 @@ var app = (App) AppSystem.get_default ().apps.get_item (index - 1); app.launch (context); } - - public static int get_launcher_size () { - return settings.get_int ("icon-size") + Launcher.PADDING * 2; - } }