mirror of
https://github.com/danbulant/dots-hyprland
synced 2026-05-24 12:22:09 +00:00
hold notif to copy (#224)
This commit is contained in:
parent
fdea1dd8fb
commit
b6b061b172
2 changed files with 74 additions and 32 deletions
|
|
@ -105,15 +105,32 @@ export default ({
|
|||
},
|
||||
onMiddleClick: (self) => {
|
||||
destroyWithAnims();
|
||||
},
|
||||
setup: (self) => {
|
||||
self.on("button-press-event", () => {
|
||||
wholeThing.attribute.held = true;
|
||||
notificationContent.toggleClassName(`${isPopup ? 'popup-' : ''}notif-clicked-${notifObject.urgency}`, true);
|
||||
Utils.timeout(800, () => {
|
||||
if (wholeThing.attribute.held) {
|
||||
Utils.execAsync(['wl-copy', `${notifObject.body}`])
|
||||
notifTextSummary.label = notifObject.summary + " (copied)";
|
||||
Utils.timeout(3000, () => notifTextSummary.label = notifObject.summary)
|
||||
}
|
||||
})
|
||||
}).on("button-release-event", () => {
|
||||
wholeThing.attribute.held = false;
|
||||
notificationContent.toggleClassName(`${isPopup ? 'popup-' : ''}notif-clicked-${notifObject.urgency}`, false);
|
||||
})
|
||||
}
|
||||
});
|
||||
const wholeThing = Revealer({
|
||||
attribute: {
|
||||
'id': notifObject.id,
|
||||
'close': undefined,
|
||||
'hovered': false,
|
||||
'dragging': false,
|
||||
'destroyWithAnims': () => destroyWithAnims,
|
||||
'dragging': false,
|
||||
'held': false,
|
||||
'hovered': false,
|
||||
'id': notifObject.id,
|
||||
},
|
||||
revealChild: false,
|
||||
transition: 'slide_down',
|
||||
|
|
@ -205,6 +222,23 @@ export default ({
|
|||
notifTime = 'Yesterday';
|
||||
else
|
||||
notifTime = messageTime.format('%d/%m');
|
||||
const notifTextSummary = Label({
|
||||
xalign: 0,
|
||||
className: 'txt-small txt-semibold titlefont',
|
||||
justify: Gtk.Justification.LEFT,
|
||||
hexpand: true,
|
||||
maxWidthChars: 24,
|
||||
truncate: 'end',
|
||||
ellipsize: 3,
|
||||
useMarkup: notifObject.summary.startsWith('<'),
|
||||
label: notifObject.summary,
|
||||
});
|
||||
const notifTextBody = Label({
|
||||
vpack: 'center',
|
||||
justification: 'right',
|
||||
className: 'txt-smaller txt-semibold',
|
||||
label: notifTime,
|
||||
});
|
||||
const notifText = Box({
|
||||
valign: Gtk.Align.CENTER,
|
||||
vertical: true,
|
||||
|
|
@ -212,23 +246,8 @@ export default ({
|
|||
children: [
|
||||
Box({
|
||||
children: [
|
||||
Label({
|
||||
xalign: 0,
|
||||
className: 'txt-small txt-semibold titlefont',
|
||||
justify: Gtk.Justification.LEFT,
|
||||
hexpand: true,
|
||||
maxWidthChars: 24,
|
||||
truncate: 'end',
|
||||
ellipsize: 3,
|
||||
useMarkup: notifObject.summary.startsWith('<'),
|
||||
label: notifObject.summary,
|
||||
}),
|
||||
Label({
|
||||
vpack: 'center',
|
||||
justification: 'right',
|
||||
className: 'txt-smaller txt-semibold',
|
||||
label: notifTime,
|
||||
}),
|
||||
notifTextSummary,
|
||||
notifTextBody,
|
||||
]
|
||||
}),
|
||||
notifTextPreview,
|
||||
|
|
@ -313,6 +332,7 @@ export default ({
|
|||
.hook(gesture, self => {
|
||||
var offset_x = gesture.get_offset()[1];
|
||||
var offset_y = gesture.get_offset()[2];
|
||||
// Which dir?
|
||||
if (initDirVertical == -1) {
|
||||
if (Math.abs(offset_y) > MOVE_THRESHOLD)
|
||||
initDirVertical = 1;
|
||||
|
|
@ -321,7 +341,7 @@ export default ({
|
|||
initDirX = (offset_x > 0 ? 1 : -1);
|
||||
}
|
||||
}
|
||||
|
||||
// Horizontal drag
|
||||
if (initDirVertical == 0 && offset_x > MOVE_THRESHOLD) {
|
||||
if (initDirX < 0)
|
||||
self.setCss(`margin-left: 0px; margin-right: 0px;`);
|
||||
|
|
@ -342,12 +362,12 @@ export default ({
|
|||
`);
|
||||
}
|
||||
}
|
||||
|
||||
wholeThing.attribute.dragging = Math.abs(offset_x) > 10;
|
||||
|
||||
if (widget.window)
|
||||
widget.window.set_cursor(Gdk.Cursor.new_from_name(display, 'grabbing'));
|
||||
|
||||
// Update dragging
|
||||
wholeThing.attribute.dragging = Math.abs(offset_x) > MOVE_THRESHOLD;
|
||||
if (Math.abs(offset_x) > MOVE_THRESHOLD ||
|
||||
Math.abs(offset_y) > MOVE_THRESHOLD) wholeThing.attribute.held = false;
|
||||
widget.window?.set_cursor(Gdk.Cursor.new_from_name(display, 'grabbing'));
|
||||
// Vertical drag
|
||||
if (initDirVertical == 1 && offset_y > MOVE_THRESHOLD && !expanded) {
|
||||
notifTextPreview.revealChild = false;
|
||||
notifTextExpanded.revealChild = true;
|
||||
|
|
|
|||
|
|
@ -28,6 +28,18 @@ $notif_surface: $t_background;
|
|||
padding-right: $rounding_small + 0.545rem;
|
||||
}
|
||||
|
||||
.notif-clicked-low {
|
||||
background-color: mix($l_l_t_surfaceVariant, $t_onSurfaceVariant, 85%);
|
||||
}
|
||||
|
||||
.notif-clicked-normal {
|
||||
background-color: mix($l_l_t_surfaceVariant, $t_onSurfaceVariant, 85%);
|
||||
}
|
||||
|
||||
.notif-clicked-critical {
|
||||
background-color: mix($secondaryContainer, $onSecondaryContainer, 95%);
|
||||
}
|
||||
|
||||
.popup-notif-low {
|
||||
@include notif-rounding;
|
||||
min-width: 30.682rem;
|
||||
|
|
@ -55,6 +67,18 @@ $notif_surface: $t_background;
|
|||
padding-right: $rounding_small + 0.545rem;
|
||||
}
|
||||
|
||||
.popup-notif-clicked-low {
|
||||
background-color: mix($notif_surface, $onBackground, 94%);
|
||||
}
|
||||
|
||||
.popup-notif-clicked-normal {
|
||||
background-color: mix($notif_surface, $onBackground, 94%);
|
||||
}
|
||||
|
||||
.popup-notif-clicked-critical {
|
||||
background-color: mix($secondaryContainer, $onSecondaryContainer, 96%);
|
||||
}
|
||||
|
||||
.notif-body-low {
|
||||
color: mix($onSurfaceVariant, $surfaceVariant, 67%);
|
||||
}
|
||||
|
|
@ -138,10 +162,8 @@ $notif_surface: $t_background;
|
|||
|
||||
.osd-notif {
|
||||
@include notif-rounding;
|
||||
background-color: transparentize(
|
||||
$background,
|
||||
$transparentize_surface_amount_subtract_surface
|
||||
);
|
||||
background-color: transparentize($background,
|
||||
$transparentize_surface_amount_subtract_surface );
|
||||
min-width: 30.682rem;
|
||||
}
|
||||
|
||||
|
|
@ -217,4 +239,4 @@ $notif_surface: $t_background;
|
|||
|
||||
.notif-action-critical:active {
|
||||
background-color: mix($t_onSecondaryContainer, $t_secondaryContainer, 23%);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue