Commit 368548db authored by Atharva Veer's avatar Atharva Veer

notificationspopup: Port PlaylistNotification to GtkTemplate

parent a0ba3379
Pipeline #167313 passed with stages
in 15 minutes and 12 seconds
......@@ -25,6 +25,7 @@
<file preprocess="xml-stripblanks">ui/PlaylistControls.ui</file>
<file preprocess="xml-stripblanks">ui/PlaylistDialog.ui</file>
<file preprocess="xml-stripblanks">ui/PlaylistDialogRow.ui</file>
<file preprocess="xml-stripblanks">ui/PlaylistNotification.ui</file>
<file preprocess="xml-stripblanks">ui/PlaylistsView.ui</file>
<file preprocess="xml-stripblanks">ui/PlaylistsWidget.ui</file>
<file preprocess="xml-stripblanks">ui/PlaylistTile.ui</file>
......
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<object class="GtkImage" id="close_notification_window">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">window-close-symbolic</property>
<property name="icon_size">1</property>
</object>
<template class="PlaylistNotification" parent="GtkGrid">
<property name="visible">True</property>
<property name="column_spacing">18</property>
<child>
<object class="GtkLabel" id="_label">
<property name="visible">True</property>
<property name="halign">start</property>
<property name="hexpand">True</property>
<property name="label" translatable="yes"></property>
</object>
</child>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">_Undo</property>
<property name="use_underline">True</property>
<property name="visible">True</property>
<signal name="clicked" handler="_undo_deletion" swapped="no"/>
</object>
</child>
<child>
<object class="GtkButton">
<property name="always_show_image">True</property>
<property name="image">close_notification_window</property>
<property name="image_position">right</property>
<property name="relief">none</property>
<property name="visible">True</property>
<signal name="clicked" handler="_close_notification" swapped="no"/>
</object>
</child>
</template>
</interface>
......@@ -165,6 +165,7 @@ class LoadingNotification(Gtk.Grid):
self._counter = self._counter + 1
@Gtk.Template(resource_path="/org/gnome/Music/ui/PlaylistNotification.ui")
class PlaylistNotification(Gtk.Grid):
"""Show a notification on playlist or song deletion.
......@@ -172,6 +173,10 @@ class PlaylistNotification(Gtk.Grid):
to the NotificationsPopup.
"""
__gtype_name__ = "PlaylistNotification"
_label = Gtk.Template.Child()
class Type(IntEnum):
"""Enum for Playlists Notifications"""
PLAYLIST = 0
......@@ -189,7 +194,7 @@ class PlaylistNotification(Gtk.Grid):
:param int position: position of the object to delete
:param object coresong: CoreSong for song deletion
"""
super().__init__(column_spacing=18)
super().__init__()
self._notifications_popup = notifications_popup
self._coregrilo = application.props.coregrilo
self.type_ = type_
......@@ -198,20 +203,7 @@ class PlaylistNotification(Gtk.Grid):
self._coresong = coresong
message = self._create_notification_message()
self._label = Gtk.Label(
label=message, halign=Gtk.Align.START, hexpand=True)
self.add(self._label)
close_button = Gtk.Button.new_from_icon_name(
"window-close-symbolic", Gtk.IconSize.BUTTON)
close_button.connect("clicked", self._close_notification)
close_button.props.relief = Gtk.ReliefStyle.NONE
undo_button = Gtk.Button.new_with_mnemonic(_("_Undo"))
undo_button.connect("clicked", self._undo_deletion)
self.add(undo_button)
self.add(close_button)
self.show_all()
self._label.props.label = message
if self.type_ == PlaylistNotification.Type.PLAYLIST:
self._coregrilo.stage_playlist_deletion(self._playlist)
......@@ -232,6 +224,7 @@ class PlaylistNotification(Gtk.Grid):
return msg
@Gtk.Template.Callback()
def _undo_deletion(self, widget_):
"""Undo deletion and remove notification"""
if self._timeout_id > 0:
......@@ -245,6 +238,7 @@ class PlaylistNotification(Gtk.Grid):
self._playlist.undo_pending_song_deletion(
self._coresong, self._position)
@Gtk.Template.Callback()
def _close_notification(self, widget_):
if self._timeout_id > 0:
GLib.source_remove(self._timeout_id)
......
......@@ -14,6 +14,7 @@ data/ui/PlayerToolbar.ui
data/ui/PlaylistContextMenu.ui
data/ui/PlaylistControls.ui
data/ui/PlaylistDialog.ui
data/ui/PlaylistNotification.ui
data/ui/SearchHeaderBar.ui
data/ui/SearchView.ui
data/ui/SelectionBarMenuButton.ui
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment