MCPcopy Index your code
hub / github.com/material-shell/material-shell / add

Method add

src/manager/tooltipManager.ts:15–58  ·  view source on GitHub ↗
(actor: Clutter.Actor, params: Partial<MatTooltipParams> = {})

Source from the content-addressed store, hash-verified

13 super();
14 }
15 add(actor: Clutter.Actor, params: Partial<MatTooltipParams> = {}) {
16 let actorDestroyed = false;
17 actor.set_reactive(true);
18 const tooltipCallback = () => {
19 let tooltip: MatTooltip | null | undefined;
20 let left = false;
21 let timeoutId: number;
22 const leaveCallback = () => {
23 left = true;
24 if (tooltip) {
25 tooltip.remove();
26 tooltip = null;
27 }
28 // Cancel countdown, if any
29 if (timeoutId) {
30 Async.clearTimeoutId(timeoutId);
31 timeoutId = 0;
32 }
33 if (!actorDestroyed) {
34 actor.disconnect(leaveId);
35 actor.disconnect(destroyId);
36 }
37 global.stage.disconnect(deactivateId);
38 };
39 const leaveId = actor.connect('leave-event', leaveCallback);
40 const destroyId = actor.connect('destroy', () => {
41 actorDestroyed = true;
42 leaveCallback();
43 });
44 const deactivateId = global.stage.connect(
45 'deactivate',
46 leaveCallback
47 );
48
49 timeoutId = Async.addTimeout(GLib.PRIORITY_DEFAULT, 200, () => {
50 timeoutId = 0;
51 if (!left) {
52 tooltip = this.createTooltip(actor, params);
53 }
54 return GLib.SOURCE_REMOVE;
55 });
56 };
57 this.observe(actor, 'enter-event', tooltipCallback);
58 }
59
60 createTooltip(
61 actor: Clutter.Actor,

Callers

nothing calls this directly

Calls 2

set_reactiveMethod · 0.80
observeMethod · 0.45

Tested by

no test coverage detected