From 2eb55fc486b5296229268dd92a2eb91c7942e332 Mon Sep 17 00:00:00 2001 From: Danielle Fore Date: Thu, 4 Jan 2024 16:20:19 -0800 Subject: [PATCH 1/2] Launcher: add custom tooltip --- src/Launcher.vala | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/Launcher.vala b/src/Launcher.vala index 4d0edd24..a1eb5f0f 100644 --- a/src/Launcher.vala +++ b/src/Launcher.vala @@ -43,6 +43,7 @@ public class Dock.Launcher : Gtk.Button { private Adw.TimedAnimation timed_animation; private Gtk.PopoverMenu popover; + private PopoverTooltip tooltip; public Launcher (GLib.DesktopAppInfo app_info, bool pinned) { Object (app_info: app_info, pinned: pinned); @@ -83,6 +84,16 @@ public class Dock.Launcher : Gtk.Button { }; popover.set_parent (this); + var tooltip_text = new Gtk.Label (app_info.get_display_name ()); + + tooltip = new PopoverTooltip () { + can_target = false, + child = tooltip_text, + has_arrow = false, + position = TOP + }; + tooltip.set_parent (this); + image = new Gtk.Image () { gicon = app_info.get_icon () }; @@ -122,7 +133,6 @@ public class Dock.Launcher : Gtk.Button { box.append (overlay); child = box; - tooltip_text = app_info.get_display_name (); var launcher_manager = LauncherManager.get_default (); @@ -180,6 +190,14 @@ public class Dock.Launcher : Gtk.Button { add_controller (gesture_click); gesture_click.released.connect (popover.popup); + var motion_controller = new Gtk.EventControllerMotion (); + motion_controller.enter.connect (tooltip.popup); + motion_controller.leave.connect (() => { + tooltip.popdown (); + }); + + add_controller (motion_controller); + clicked.connect (() => launch ()); settings.bind ("icon-size", image, "pixel-size", DEFAULT); @@ -223,6 +241,8 @@ public class Dock.Launcher : Gtk.Button { ~Launcher () { popover.unparent (); popover.dispose (); + tooltip.unparent (); + tooltip.dispose (); } public void launch (string? action = null) { @@ -388,4 +408,10 @@ public class Dock.Launcher : Gtk.Button { progress_visible = false; progress = 0; } + + private class PopoverTooltip : Gtk.Popover { + class construct { + set_css_name ("tooltip"); + } + } } From e9f5528982c5e7cc181c5d020e6f23565ae1c37c Mon Sep 17 00:00:00 2001 From: Danielle Fore Date: Thu, 4 Jan 2024 16:28:10 -0800 Subject: [PATCH 2/2] other things --- src/Launcher.vala | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Launcher.vala b/src/Launcher.vala index a1eb5f0f..4de5f8c2 100644 --- a/src/Launcher.vala +++ b/src/Launcher.vala @@ -84,11 +84,11 @@ public class Dock.Launcher : Gtk.Button { }; popover.set_parent (this); - var tooltip_text = new Gtk.Label (app_info.get_display_name ()); - tooltip = new PopoverTooltip () { + can_focus = false, can_target = false, - child = tooltip_text, + focusable = false, + child = new Gtk.Label (app_info.get_display_name ()), has_arrow = false, position = TOP };