[gnome-music] window: Remove PopupNotification from template



commit 50512c23a85554890901a0ddd96e3ceb80435f75
Author: Atharva Veer <adveer_b17 it vjti ac in>
Date:   Tue Mar 31 18:05:54 2020 +0000

    window: Remove PopupNotification from template
    
    Having PopupNotification called in the Window template does not allow to
    template PopupNotification itself currently, due to a bug in PyGI
    templates support.

 data/org.gnome.Music.gresource.xml       |  1 +
 data/ui/NotificationsPopup.ui            | 24 ++++++++++++++++++++++++
 data/ui/Window.ui                        |  7 -------
 gnomemusic/widgets/notificationspopup.py | 15 +++------------
 gnomemusic/window.py                     |  6 ++++--
 5 files changed, 32 insertions(+), 21 deletions(-)
---
diff --git a/data/org.gnome.Music.gresource.xml b/data/org.gnome.Music.gresource.xml
index 9d3cceb2..5633440a 100644
--- a/data/org.gnome.Music.gresource.xml
+++ b/data/org.gnome.Music.gresource.xml
@@ -18,6 +18,7 @@
     <file preprocess="xml-stripblanks">ui/FilterView.ui</file>
     <file preprocess="xml-stripblanks">ui/HeaderBar.ui</file>
     <file preprocess="xml-stripblanks">ui/LastfmDialog.ui</file>
+    <file preprocess="xml-stripblanks">ui/NotificationsPopup.ui</file>
     <file preprocess="xml-stripblanks">ui/PlayerToolbar.ui</file>
     <file preprocess="xml-stripblanks">ui/PlaylistContextMenu.ui</file>
     <file preprocess="xml-stripblanks">ui/PlaylistControls.ui</file>
diff --git a/data/ui/NotificationsPopup.ui b/data/ui/NotificationsPopup.ui
new file mode 100644
index 00000000..ae2d3007
--- /dev/null
+++ b/data/ui/NotificationsPopup.ui
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <template class="NotificationsPopup" parent="GtkRevealer">
+    <property name="visible">True</property>
+    <property name="halign">center</property>
+    <property name="valign">start</property>
+    <child>
+      <object class="GtkFrame">
+        <property name="visible">True</property>
+        <property name="shadow_type">none</property>
+        <child>
+          <object class="GtkGrid" id="_grid">
+            <property name="visible">True</property>
+            <property name="orientation">vertical</property>
+            <property name="row_spacing">6</property>
+          </object>
+        </child>
+        <style>
+          <class name="app-notification"/>
+        </style>
+      </object>
+    </child>
+  </template>
+</interface>
diff --git a/data/ui/Window.ui b/data/ui/Window.ui
index 161b3059..62059ebf 100644
--- a/data/ui/Window.ui
+++ b/data/ui/Window.ui
@@ -20,13 +20,6 @@
                 <property name="visible">True</property>
               </object>
             </child>
-            <child type="overlay">
-              <object class="NotificationsPopup" id="notifications_popup">
-                <property name="halign">center</property>
-                <property name="transition-type">slide-down</property>
-                <property name="valign">start</property>
-              </object>
-            </child>
           </object>
         </child>
         <child>
diff --git a/gnomemusic/widgets/notificationspopup.py b/gnomemusic/widgets/notificationspopup.py
index 76ee1e49..29c8be48 100644
--- a/gnomemusic/widgets/notificationspopup.py
+++ b/gnomemusic/widgets/notificationspopup.py
@@ -27,6 +27,7 @@ from gettext import gettext as _
 from gi.repository import GLib, GObject, Gtk
 
 
+@Gtk.Template(resource_path="/org/gnome/Music/ui/NotificationsPopup.ui")
 class NotificationsPopup(Gtk.Revealer):
     """Display notification messages as popups
 
@@ -38,26 +39,16 @@ class NotificationsPopup(Gtk.Revealer):
 
     __gtype_name__ = "NotificationsPopup"
 
+    _grid = Gtk.Template.Child()
+
     def __init__(self):
         super().__init__()
 
-        self._setup_view()
-
-    def _setup_view(self):
-        frame = Gtk.Frame()
-        frame.get_style_context().add_class('app-notification')
-        self.add(frame)
-
-        self._grid = Gtk.Grid(
-            row_spacing=6, orientation=Gtk.Orientation.VERTICAL)
-        frame.add(self._grid)
-
         self._loading_notification = LoadingNotification()
         self._loading_notification.connect('visible', self._set_visibility)
         self._loading_notification.connect('invisible', self._set_visibility)
         self._grid.add(self._loading_notification)
 
-        self.show_all()
         self._loading_notification.hide()
 
     def _hide_notifications(self, notification, remove):
diff --git a/gnomemusic/window.py b/gnomemusic/window.py
index a88c29ec..bcdae2f8 100644
--- a/gnomemusic/window.py
+++ b/gnomemusic/window.py
@@ -38,7 +38,7 @@ from gnomemusic.views.searchview import SearchView
 from gnomemusic.views.songsview import SongsView
 from gnomemusic.views.playlistsview import PlaylistsView
 from gnomemusic.widgets.headerbar import HeaderBar
-from gnomemusic.widgets.notificationspopup import NotificationsPopup  # noqa
+from gnomemusic.widgets.notificationspopup import NotificationsPopup
 from gnomemusic.widgets.playertoolbar import PlayerToolbar
 from gnomemusic.widgets.playlistdialog import PlaylistDialog
 from gnomemusic.widgets.searchheaderbar import SearchHeaderBar
@@ -55,7 +55,6 @@ class Window(Gtk.ApplicationWindow):
     selected_items_count = GObject.Property(type=int, default=0, minimum=0)
     selection_mode = GObject.Property(type=bool, default=False)
 
-    notifications_popup = Gtk.Template.Child()
     _box = Gtk.Template.Child()
     _overlay = Gtk.Template.Child()
     _selection_toolbar = Gtk.Template.Child()
@@ -122,6 +121,9 @@ class Window(Gtk.ApplicationWindow):
         self._search.connect(
             "notify::search-mode-active", self._on_search_mode_changed)
 
+        self.notifications_popup = NotificationsPopup()
+        self._overlay.add_overlay(self.notifications_popup)
+
         self._player_toolbar = PlayerToolbar()
         self._player_toolbar.props.player = self._player
 


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