Noti close button won't show until mouse hover

This commit is contained in:
Erik Reider
2021-09-16 13:09:18 +02:00
parent a81efc0094
commit e9231ab83d
2 changed files with 160 additions and 132 deletions

View File

@@ -5,6 +5,10 @@
<template class="SwayNotificatonCenterNotification" parent="GtkListBoxRow"> <template class="SwayNotificatonCenterNotification" parent="GtkListBoxRow">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">True</property> <property name="can-focus">True</property>
<child>
<object class="GtkEventBox" id="event_box">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child> <child>
<object class="GtkBox"> <object class="GtkBox">
<property name="visible">True</property> <property name="visible">True</property>
@@ -23,7 +27,7 @@
<child> <child>
<object class="GtkButton" id="default_button"> <object class="GtkButton" id="default_button">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">True</property>
<property name="receives-default">False</property> <property name="receives-default">False</property>
<child> <child>
<object class="GtkBox"> <object class="GtkBox">
@@ -181,10 +185,15 @@
</packing> </packing>
</child> </child>
<child type="overlay"> <child type="overlay">
<object class="GtkRevealer" id="close_revealer">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="transition-type">crossfade</property>
<child>
<object class="GtkButton" id="close_button"> <object class="GtkButton" id="close_button">
<property name="label">×</property> <property name="label">×</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">True</property>
<property name="receives-default">True</property> <property name="receives-default">True</property>
<property name="halign">end</property> <property name="halign">end</property>
<property name="valign">start</property> <property name="valign">start</property>
@@ -196,6 +205,8 @@
</object> </object>
</child> </child>
</object> </object>
</child>
</object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
@@ -207,6 +218,8 @@
</style> </style>
</object> </object>
</child> </child>
</object>
</child>
<style> <style>
<class name="notification-row"/> <class name="notification-row"/>
</style> </style>

View File

@@ -1,9 +1,14 @@
namespace SwayNotificatonCenter { namespace SwayNotificatonCenter {
[GtkTemplate (ui = "/org/erikreider/sway-notification-center/notification/notification.ui")] [GtkTemplate (ui = "/org/erikreider/sway-notification-center/notification/notification.ui")]
private class Notification : Gtk.ListBoxRow { private class Notification : Gtk.ListBoxRow {
[GtkChild]
unowned Gtk.EventBox event_box;
[GtkChild] [GtkChild]
unowned Gtk.Button default_button; unowned Gtk.Button default_button;
[GtkChild]
unowned Gtk.Revealer close_revealer;
[GtkChild] [GtkChild]
unowned Gtk.Button close_button; unowned Gtk.Button close_button;
@@ -31,7 +36,7 @@ namespace SwayNotificatonCenter {
public Notification (NotifyParams param, public Notification (NotifyParams param,
NotiDaemon notiDaemon, NotiDaemon notiDaemon,
bool show = false) { bool is_cc_noti = false) {
this.notiDaemon = notiDaemon; this.notiDaemon = notiDaemon;
this.param = param; this.param = param;
@@ -41,11 +46,21 @@ namespace SwayNotificatonCenter {
close_button.clicked.connect (close_notification); close_button.clicked.connect (close_notification);
this.event_box.enter_notify_event.connect (()=> {
close_revealer.set_reveal_child (true);
return false;
});
this.event_box.leave_notify_event.connect (()=> {
close_revealer.set_reveal_child (false);
return false;
});
set_body (); set_body ();
set_icon (); set_icon ();
set_actions (); set_actions ();
if (show) { if (is_cc_noti) {
this.body.set_lines (10); this.body.set_lines (10);
this.show (); this.show ();
} }