[gnome-boxes] notification: Port Boxes.Notification to GtkRevealer
- From: Felipe Borges <felipeborges src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] notification: Port Boxes.Notification to GtkRevealer
- Date: Mon, 30 Jan 2017 11:49:39 +0000 (UTC)
commit 2c85bc0c6a4eeac7d0622f52a2b4294515cfaccf
Author: Felipe Borges <felipeborges gnome org>
Date: Thu Jan 19 16:01:48 2017 +0100
notification: Port Boxes.Notification to GtkRevealer
GtkRevealer combined with the "app-notification" class is enough
to represent the notification concept nowadays. This is part of
the effort to drop the dependency on libgd.
https://bugzilla.gnome.org/show_bug.cgi?id=777497
data/ui/notification.ui | 22 +++++++++++++++++++++-
src/notification.vala | 25 ++++++++++++++++++++++++-
2 files changed, 45 insertions(+), 2 deletions(-)
---
diff --git a/data/ui/notification.ui b/data/ui/notification.ui
index d4fe50a..f7ce0da 100644
--- a/data/ui/notification.ui
+++ b/data/ui/notification.ui
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<!-- interface-requires gtk+ 3.9 -->
- <template class="BoxesNotification" parent="GdNotification">
+ <template class="BoxesNotification" parent="GtkRevealer">
<property name="visible">True</property>
<property name="valign">start</property>
@@ -13,6 +13,10 @@
<property name="margin-end">12</property>
<property name="column-spacing">12</property>
<property name="valign">center</property>
+ <property name="halign">center</property>
+ <style>
+ <class name="app-notification"/>
+ </style>
<child>
<object class="GtkLabel" id="message_label">
@@ -32,6 +36,22 @@
</object>
</child>
+ <child>
+ <object class="GtkButton" id="close_button">
+ <property name="visible">True</property>
+ <style>
+ <class name="flat"/>
+ </style>
+
+ <child>
+ <object class="GtkImage">
+ <property name="visible">True</property>
+ <property name="icon-name">window-close</property>
+ </object>
+ </child>
+ </object>
+ </child>
+
</object>
</child>
</template>
diff --git a/src/notification.vala b/src/notification.vala
index 015b34b..f02bf24 100644
--- a/src/notification.vala
+++ b/src/notification.vala
@@ -2,8 +2,11 @@
using Gtk;
[GtkTemplate (ui = "/org/gnome/Boxes/ui/notification.ui")]
-private class Boxes.Notification: Gd.Notification {
+private class Boxes.Notification: Gtk.Revealer {
+ public signal void dismissed ();
+
public const int DEFAULT_TIMEOUT = 6;
+ private int timeout = DEFAULT_TIMEOUT;
public delegate void OKFunc ();
public delegate void DismissFunc ();
@@ -14,6 +17,8 @@ private class Boxes.Notification: Gd.Notification {
private Gtk.Label ok_button_label;
[GtkChild]
private Gtk.Button ok_button;
+ [GtkChild]
+ private Gtk.Button close_button;
public Notification (string message,
MessageType message_type,
@@ -21,7 +26,18 @@ private class Boxes.Notification: Gd.Notification {
owned OKFunc? ok_func,
owned DismissFunc? dismiss_func,
int timeout) {
+ /*
+ * Templates cannot set construct properties, so
+ * lets use the respective property setter method.
+ */
+ set_reveal_child (true);
+
this.timeout = timeout;
+ Timeout.add_seconds (this.timeout, () => {
+ dismiss ();
+
+ return true;
+ });
bool ok_pressed = false;
dismissed.connect ( () => {
@@ -43,5 +59,12 @@ private class Boxes.Notification: Gd.Notification {
ok_button.show_all ();
}
+
+ close_button.clicked.connect (dismiss);
+ }
+
+ public void dismiss () {
+ set_reveal_child (false);
+ dismissed ();
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]