[gnome-boxes/toast-revolution: 2/6] toast: Turn the PreferencesToast widget in a generic one




commit 2c409b15d6de79887433faa75f0b09feb050a46e
Author: Felipe Borges <felipeborges gnome org>
Date:   Thu Jan 20 18:35:09 2022 +0100

    toast: Turn the PreferencesToast widget in a generic one
    
    So we can migrate away from in-app notifications.

 data/gnome-boxes.gresource.xml                            |  2 +-
 data/ui/{preferences/preferences-toast.ui => toast.ui}    |  2 +-
 src/meson.build                                           |  2 +-
 src/preferences/meson.build                               |  1 -
 src/preferences/snapshot-list-row.vala                    | 10 +++++-----
 src/preferences/snapshots-page.vala                       |  8 ++++----
 src/ui/meson.build                                        |  4 ++++
 src/{preferences/preferences-toast.vala => ui/toast.vala} |  4 ++--
 8 files changed, 18 insertions(+), 15 deletions(-)
---
diff --git a/data/gnome-boxes.gresource.xml b/data/gnome-boxes.gresource.xml
index 67bc4560..f89865a9 100644
--- a/data/gnome-boxes.gresource.xml
+++ b/data/gnome-boxes.gresource.xml
@@ -22,6 +22,7 @@
     <file preprocess="xml-stripblanks">ui/searchbar.ui</file>
     <file preprocess="xml-stripblanks">ui/thumbnail.ui</file>
     <file preprocess="xml-stripblanks">ui/topbar.ui</file>
+    <file preprocess="xml-stripblanks">ui/toast.ui</file>
     <file preprocess="xml-stripblanks">ui/transfer-info-row.ui</file>
     <file preprocess="xml-stripblanks">ui/transfer-popover.ui</file>
     <file preprocess="xml-stripblanks">ui/troubleshoot-view.ui</file>
@@ -43,7 +44,6 @@
     <file preprocess="xml-stripblanks">ui/preferences/device-list-row.ui</file>
     <file preprocess="xml-stripblanks">ui/preferences/memory-row.ui</file>
     <file preprocess="xml-stripblanks">ui/preferences/preferences-window.ui</file>
-    <file preprocess="xml-stripblanks">ui/preferences/preferences-toast.ui</file>
     <file preprocess="xml-stripblanks">ui/preferences/resources-page.ui</file>
     <file preprocess="xml-stripblanks">ui/preferences/shared-folders-widget.ui</file>
     <file preprocess="xml-stripblanks">ui/preferences/shared-folder-popover.ui</file>
diff --git a/data/ui/preferences/preferences-toast.ui b/data/ui/toast.ui
similarity index 96%
rename from data/ui/preferences/preferences-toast.ui
rename to data/ui/toast.ui
index eadcf563..44a5976c 100644
--- a/data/ui/preferences/preferences-toast.ui
+++ b/data/ui/toast.ui
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
-  <template class="BoxesPreferencesToast" parent="GtkBox">
+  <template class="BoxesToast" parent="GtkBox">
     <property name="visible">True</property>
     <property name="can_focus">True</property>
     <property name="valign">end</property>
diff --git a/src/meson.build b/src/meson.build
index 8ca050e7..26e1b5dc 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -79,7 +79,6 @@ vala_sources = [
   'troubleshoot-view.vala',
   'topbar.vala',
   'ui.vala',
-  'ui/thumbnail.vala', # FIXME: move this into ui/meson.build
   'unattended-installer.vala',
   'unattended-file.vala',
   'unattended-setup-box.vala',
@@ -96,6 +95,7 @@ vala_sources = [
   'tracker-iso-query.vala',
 ]
 
+subdir('ui')
 subdir('assistant')
 subdir('preferences')
 
diff --git a/src/preferences/meson.build b/src/preferences/meson.build
index b95dd70f..1869490d 100644
--- a/src/preferences/meson.build
+++ b/src/preferences/meson.build
@@ -4,7 +4,6 @@ vala_sources += files(
   'device-list-row.vala',
   'memory-row.vala',
   'preferences-window.vala',
-  'preferences-toast.vala',
   'ram-row.vala',
   'resources-page.vala',
   'shared-folders-widget.vala',
diff --git a/src/preferences/snapshot-list-row.vala b/src/preferences/snapshot-list-row.vala
index 40fdb332..407e1a55 100644
--- a/src/preferences/snapshot-list-row.vala
+++ b/src/preferences/snapshot-list-row.vala
@@ -2,7 +2,7 @@
 
 [GtkTemplate (ui = "/org/gnome/Boxes/ui/preferences/snapshot-list-row.ui")]
 private class Boxes.SnapshotListRow : Hdy.ActionRow {
-    public signal void display_toast (Boxes.PreferencesToast toast);
+    public signal void display_toast (Boxes.Toast toast);
     public signal void is_current ();
 
     public GVir.DomainSnapshot snapshot;
@@ -45,7 +45,7 @@ public SnapshotListRow (GVir.DomainSnapshot snapshot,
         } catch (GLib.Error e) {
             critical (e.message);
 
-            display_toast (new Boxes.PreferencesToast () {
+            display_toast (new Boxes.Toast () {
                 message = e.message
             });
         }
@@ -75,7 +75,7 @@ private void on_save_name_button_clicked () {
         } catch (GLib.Error e) {
             warning ("Failed to rename snapshot to %s: %s", name, e.message);
 
-            display_toast (new Boxes.PreferencesToast () {
+            display_toast (new Boxes.Toast () {
                 // Translators: %s is the reason why Boxes failed to rename the snapshot.
                 message = _("Failed to rename snapshot: %s").printf (e.message)
             });
@@ -115,7 +115,7 @@ private void on_revert_button_clicked () {
             } catch (GLib.Error e) {
                 warning (e.message);
 
-                display_toast (new Boxes.PreferencesToast () {
+                display_toast (new Boxes.Toast () {
                     // Translators: %s is the reason why Boxes failed to apply the snapshot.
                     message = _("Failed to revert to snapshot: %s").printf (e.message)
                 });
@@ -158,7 +158,7 @@ private void on_delete_button_clicked () {
             row = null;
         };
 
-        display_toast (new Boxes.PreferencesToast () {
+        display_toast (new Boxes.Toast () {
             message = message,
             action = _("Undo"),
             undo_func = (owned) undo,
diff --git a/src/preferences/snapshots-page.vala b/src/preferences/snapshots-page.vala
index 0ba2c8e9..ef74481b 100644
--- a/src/preferences/snapshots-page.vala
+++ b/src/preferences/snapshots-page.vala
@@ -7,8 +7,8 @@
 
     [GtkChild]
     private unowned Gtk.Overlay toast_overlay;
-    private Boxes.PreferencesToast _toast;
-    private Boxes.PreferencesToast toast {
+    private Boxes.Toast _toast;
+    private Boxes.Toast toast {
         set {
             if (_toast != null) {
                 _toast.dismiss ();
@@ -118,7 +118,7 @@ private void select_row (SnapshotListRow selected_row) {
         listbox.select_row (selected_row);
     }
 
-    private void display_toast (Boxes.PreferencesToast new_toast) {
+    private void display_toast (Boxes.Toast new_toast) {
         toast = new_toast;
     }
 
@@ -156,7 +156,7 @@ private async void create_snapshot () {
             var msg = _("Failed to create snapshot of %s").printf (machine.name);
             warning (e.message);
 
-            toast = new Boxes.PreferencesToast () {
+            toast = new Boxes.Toast () {
                 message = msg
             };
         }
diff --git a/src/ui/meson.build b/src/ui/meson.build
new file mode 100644
index 00000000..3e1c96f6
--- /dev/null
+++ b/src/ui/meson.build
@@ -0,0 +1,4 @@
+vala_sources += files(
+  'thumbnail.vala',
+  'toast.vala',
+)
diff --git a/src/preferences/preferences-toast.vala b/src/ui/toast.vala
similarity index 88%
rename from src/preferences/preferences-toast.vala
rename to src/ui/toast.vala
index 14a6deec..5730392a 100644
--- a/src/preferences/preferences-toast.vala
+++ b/src/ui/toast.vala
@@ -1,7 +1,7 @@
 // This file is part of GNOME Boxes. License: LGPLv2+
 
-[GtkTemplate (ui = "/org/gnome/Boxes/ui/preferences/preferences-toast.ui")]
-private class Boxes.PreferencesToast : Gtk.Box {
+[GtkTemplate (ui = "/org/gnome/Boxes/ui/toast.ui")]
+private class Boxes.Toast : Gtk.Box {
     public delegate void OKFunc ();
     public delegate void DismissFunc ();
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]