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

@@ -6,101 +6,48 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">True</property> <property name="can-focus">True</property>
<child> <child>
<object class="GtkBox"> <object class="GtkEventBox" id="event_box">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="orientation">vertical</property>
<child> <child>
<object class="GtkOverlay" id="overlay"> <object class="GtkBox">
<property name="width-request">400</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="orientation">vertical</property>
<child> <child>
<object class="GtkBox" id="base_box"> <object class="GtkOverlay" id="overlay">
<property name="width-request">400</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="orientation">vertical</property>
<child> <child>
<object class="GtkButton" id="default_button"> <object class="GtkBox" id="base_box">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="receives-default">False</property> <property name="orientation">vertical</property>
<child> <child>
<object class="GtkBox"> <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="orientation">vertical</property> <property name="receives-default">False</property>
<child> <child>
<object class="GtkBox"> <object class="GtkBox">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
<child> <property name="orientation">vertical</property>
<object class="GtkImage" id="img">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="valign">start</property>
<property name="margin-end">12</property>
<property name="icon_size">6</property>
<style>
<class name="image"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child> <child>
<object class="GtkBox"> <object class="GtkBox">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="margin-end">14</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="orientation">vertical</property>
<child> <child>
<object class="GtkBox"> <object class="GtkImage" id="img">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
<child> <property name="valign">start</property>
<object class="GtkLabel" id="summary"> <property name="margin-end">12</property>
<property name="visible">True</property> <property name="icon_size">6</property>
<property name="can-focus">False</property> <style>
<property name="ellipsize">end</property> <class name="image"/>
<property name="max-width-chars">0</property> </style>
<property name="xalign">0</property>
<attributes>
<attribute name="weight" value="bold"/>
<attribute name="size" value="12288"/>
</attributes>
<style>
<class name="summary"/>
</style>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="time">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-start">6</property>
<property name="track-visited-links">False</property>
<style>
<class name="time"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack-type">end</property>
<property name="position">1</property>
</packing>
</child>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
@@ -109,19 +56,83 @@
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkLabel" id="body"> <object class="GtkBox">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="margin-end">14</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
<property name="vexpand">True</property> <property name="vexpand">True</property>
<property name="wrap">True</property> <property name="orientation">vertical</property>
<property name="ellipsize">end</property> <child>
<property name="lines">1</property> <object class="GtkBox">
<property name="xalign">0</property> <property name="visible">True</property>
<property name="yalign">0</property> <property name="can-focus">False</property>
<style> <child>
<class name="body"/> <object class="GtkLabel" id="summary">
</style> <property name="visible">True</property>
<property name="can-focus">False</property>
<property name="ellipsize">end</property>
<property name="max-width-chars">0</property>
<property name="xalign">0</property>
<attributes>
<attribute name="weight" value="bold"/>
<attribute name="size" value="12288"/>
</attributes>
<style>
<class name="summary"/>
</style>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="time">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-start">6</property>
<property name="track-visited-links">False</property>
<style>
<class name="time"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack-type">end</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="body">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="wrap">True</property>
<property name="ellipsize">end</property>
<property name="lines">1</property>
<property name="xalign">0</property>
<property name="yalign">0</property>
<style>
<class name="body"/>
</style>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object> </object>
<packing> <packing>
<property name="expand">True</property> <property name="expand">True</property>
@@ -131,80 +142,82 @@
</child> </child>
</object> </object>
<packing> <packing>
<property name="expand">True</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkImage" id="body_image">
<property name="can-focus">False</property>
<property name="halign">center</property>
<style>
<class name="body-image"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property> <property name="position">1</property>
</packing> </packing>
</child> </child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkImage" id="body_image">
<property name="can-focus">False</property>
<property name="halign">center</property>
<style> <style>
<class name="body-image"/> <class name="notification-content"/>
</style> </style>
</object> </object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child> </child>
<style> <style>
<class name="notification-content"/> <class name="notification-default-action"/>
</style> </style>
</object> </object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child> </child>
<style> <style>
<class name="notification-default-action"/> <class name="notification"/>
</style> </style>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="index">-1</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing> </packing>
</child> </child>
<style> <child type="overlay">
<class name="notification"/> <object class="GtkRevealer" id="close_revealer">
</style> <property name="visible">True</property>
<property name="can-focus">False</property>
<property name="transition-type">crossfade</property>
<child>
<object class="GtkButton" id="close_button">
<property name="label">×</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="halign">end</property>
<property name="valign">start</property>
<property name="relief">none</property>
<property name="always-show-image">True</property>
<style>
<class name="close-button"/>
</style>
</object>
</child>
</object>
</child>
</object> </object>
<packing> <packing>
<property name="index">-1</property> <property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing> </packing>
</child> </child>
<child type="overlay"> <style>
<object class="GtkButton" id="close_button"> <class name="notification-background"/>
<property name="label">×</property> </style>
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="receives-default">True</property>
<property name="halign">end</property>
<property name="valign">start</property>
<property name="relief">none</property>
<property name="always-show-image">True</property>
<style>
<class name="close-button"/>
</style>
</object>
</child>
</object> </object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child> </child>
<style>
<class name="notification-background"/>
</style>
</object> </object>
</child> </child>
<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 ();
} }