[gnome-music/wip/jfelder/tag-test: 14/22] ui: align ui according to mockups
- From: Jean Felder <jfelder src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/jfelder/tag-test: 14/22] ui: align ui according to mockups
- Date: Mon, 29 Jul 2019 16:17:27 +0000 (UTC)
commit f9341f0640786b40209adea179c176b41d07bf26
Author: Sumaid Syed <sumaidsyed gmail com>
Date: Mon Jul 22 16:03:39 2019 +0530
ui: align ui according to mockups
data/org.gnome.Music.css | 5 +
data/ui/TagEditorDialog.ui | 355 +++++++++++++------------------
gnomemusic/widgets/notificationspopup.py | 51 +++++
gnomemusic/widgets/tageditordialog.py | 125 +++++++++--
4 files changed, 310 insertions(+), 226 deletions(-)
---
diff --git a/data/org.gnome.Music.css b/data/org.gnome.Music.css
index 6caaa519..a44a754f 100644
--- a/data/org.gnome.Music.css
+++ b/data/org.gnome.Music.css
@@ -18,6 +18,11 @@
font-weight: bold;
}
+/* Suggested Tags in Tag Editor Dialog*/
+.suggestion-label {
+ color: #3680DB;
+}
+
/* ArtistAlbumsWidget */
box#ArtistAlbumsWidget .artist-label {
font-weight: bold;
diff --git a/data/ui/TagEditorDialog.ui b/data/ui/TagEditorDialog.ui
index ee8789c4..1b0ee11f 100644
--- a/data/ui/TagEditorDialog.ui
+++ b/data/ui/TagEditorDialog.ui
@@ -17,31 +17,31 @@
<object class="GtkButtonBox">
<property name="can_focus">False</property>
</object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
</child>
<child>
<object class="GtkOverlay" id="overlay">
<property name="visible">True</property>
<property name="can_focus">False</property>
+ <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>
<child>
- <object class="GtkBox" id="media_details">
+ <object class="GtkGrid" id="media_details">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
- <property name="margin_left">12</property>
- <property name="margin_right">12</property>
- <property name="margin_top">12</property>
- <property name="margin_bottom">18</property>
- <property name="spacing">24</property>
+ <property name="margin">12</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
+ <property name="vexpand">True</property>
+ <property name="valign">fill</property>
<child>
<object class="GtkButton" id="_coverart_button">
<property name="visible">True</property>
@@ -49,14 +49,15 @@
<property name="focus_on_click">False</property>
<property name="receives_default">False</property>
<property name="halign">start</property>
- <property name="valign">start</property>
+ <property name="valign">fill</property>
<property name="relief">none</property>
+ <property name="margin-right">20</property>
<signal name="clicked" handler="_choose_cover" swapped="no"/>
<child>
<object class="CoverStack" id="_cover_stack">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="valign">start</property>
+ <property name="valign">fill</property>
</object>
</child>
<style>
@@ -64,16 +65,75 @@
</style>
</object>
<packing>
- <property name="expand">False</property>
+ <property name="expand">True</property>
<property name="fill">True</property>
- <property name="position">0</property>
</packing>
</child>
</object>
<packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
+ <property name="width">1</property>
+ <property name="height">4</property>
+ <property name="left-attach">0</property>
+ <property name="top-attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">6</property>
+ <property name="margin-top">12</property>
+ <property name="margin-left">10</property>
+ <property name="halign">start</property>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkLabel" id="location">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="justify">right</property>
+ <property name="margin-right">40</property>
+ <property name="label" translatable="yes">Location</property>
+ <property name="xalign">1</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
+ <style>
+ <class name="dim-label"/>
+ </style>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="_url">
+ <property name="can_focus">False</property>
+ <property name="halign">start</property>
+ <property name="max_width_chars">60</property>
+ <property name="ellipsize">end</property>
+ <style>
+ <class name="dim-label"/>
+ </style>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="pack_type">end</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="left-attach">0</property>
+ <property name="top-attach">4</property>
+ <property name="width">2</property>
</packing>
</child>
<child>
@@ -117,9 +177,10 @@
<object class="GtkLabel" id="_title_suggestion">
<property name="can_focus">False</property>
<property name="halign">start</property>
- <property name="margin_right">2</property>
+ <property name="ellipsize">end</property>
+ <property name="max-width-chars">20</property>
<style>
- <class name="dim-label"/>
+ <class name="suggestion-label"/>
</style>
</object>
<packing>
@@ -130,11 +191,6 @@
</packing>
</child>
</object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
</child>
<child>
<object class="GtkEntry" id="_title_entry">
@@ -149,9 +205,8 @@
</child>
</object>
<packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
+ <property name="left-attach">1</property>
+ <property name="top-attach">0</property>
</packing>
</child>
<child>
@@ -188,9 +243,10 @@
<object class="GtkLabel" id="_album_suggestion">
<property name="can_focus">False</property>
<property name="halign">start</property>
- <property name="margin_right">2</property>
+ <property name="ellipsize">end</property>
+ <property name="max-width-chars">20</property>
<style>
- <class name="dim-label"/>
+ <class name="suggestion-label"/>
</style>
</object>
<packing>
@@ -201,11 +257,6 @@
</packing>
</child>
</object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
</child>
<child>
<object class="GtkEntry" id="_album_entry">
@@ -220,9 +271,8 @@
</child>
</object>
<packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
+ <property name="left-attach">1</property>
+ <property name="top-attach">1</property>
</packing>
</child>
<child>
@@ -259,9 +309,10 @@
<object class="GtkLabel" id="_artist_suggestion">
<property name="can_focus">False</property>
<property name="halign">start</property>
- <property name="margin_right">2</property>
+ <property name="ellipsize">end</property>
+ <property name="max-width-chars">20</property>
<style>
- <class name="dim-label"/>
+ <class name="suggestion-label"/>
</style>
</object>
<packing>
@@ -272,11 +323,6 @@
</packing>
</child>
</object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
</child>
<child>
<object class="GtkEntry" id="_artist_entry">
@@ -291,9 +337,8 @@
</child>
</object>
<packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">2</property>
+ <property name="left-attach">1</property>
+ <property name="top-attach">2</property>
</packing>
</child>
<child>
@@ -335,9 +380,8 @@
<object class="GtkLabel" id="_track_suggestion">
<property name="can_focus">False</property>
<property name="halign">end</property>
- <property name="margin_right">2</property>
<style>
- <class name="dim-label"/>
+ <class name="suggestion-label"/>
</style>
</object>
<packing>
@@ -348,11 +392,6 @@
</packing>
</child>
</object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
</child>
<child>
<object class="GtkEntry" id="_track_entry">
@@ -369,11 +408,6 @@
</packing>
</child>
</object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
</child>
<child>
<object class="GtkBox">
@@ -411,7 +445,7 @@
<property name="halign">start</property>
<property name="margin_right">2</property>
<style>
- <class name="dim-label"/>
+ <class name="suggestion-label"/>
</style>
</object>
<packing>
@@ -421,11 +455,6 @@
</packing>
</child>
</object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
</child>
<child>
<object class="GtkEntry" id="_disc_entry">
@@ -443,11 +472,6 @@
</packing>
</child>
</object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">2</property>
- </packing>
</child>
<child>
<object class="GtkBox">
@@ -483,9 +507,8 @@
<object class="GtkLabel" id="_year_suggestion">
<property name="can_focus">False</property>
<property name="halign">start</property>
- <property name="margin_right">2</property>
<style>
- <class name="dim-label"/>
+ <class name="suggestion-label"/>
</style>
</object>
<packing>
@@ -495,11 +518,6 @@
</packing>
</child>
</object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
</child>
<child>
<object class="GtkEntry" id="_year_entry">
@@ -517,46 +535,25 @@
</packing>
</child>
</object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">4</property>
- </packing>
</child>
</object>
<packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">5</property>
+ <property name="left-attach">1</property>
+ <property name="top-attach">3</property>
</packing>
</child>
</object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
</child>
</object>
- <packing>
- <property name="index">-1</property>
- </packing>
</child>
</object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="margin_left">12</property>
- <property name="margin_right">12</property>
- <property name="margin_bottom">12</property>
- <property name="spacing">6</property>
+ <property name="margin-bottom">20</property>
+ <property name="margin-left">20</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
@@ -586,17 +583,11 @@
<class name="dim-label"/>
</style>
</object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</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>
+ <property name="left-attach">0</property>
+ <property name="top-attach">5</property>
</packing>
</child>
<child>
@@ -606,6 +597,7 @@
<property name="halign">end</property>
<property name="hexpand">True</property>
<property name="spacing">6</property>
+ <property name="margin-right">10</property>
<child>
<object class="GtkBox">
<property name="can_focus">False</property>
@@ -655,50 +647,55 @@
<class name="linked"/>
</style>
</object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
</child>
<child>
- <object class="GtkButton" id="_prev_button">
+ <object class="GtkBox" id="_prev_next_box">
<property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="valign">center</property>
- <property name="sensitive">False</property>
- <property name="tooltip_text" translatable="yes">Previous Suggestion</property>
- <signal name="clicked" handler="_on_prev_button_clicked" swapped="no"/>
+ <property name="orientation">horizontal</property>
+ <property name="homogeneous">True</property>
<style>
- <class name="image-button"/>
+ <class name="linked"/>
</style>
<child>
- <object class="GtkImage" id="_prev_button_image">
+ <object class="GtkButton" id="_prev_button">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="icon-name">go-previous</property>
- <property name="icon-size">1</property>
+ <property name="valign">center</property>
+ <property name="sensitive">False</property>
+ <property name="tooltip_text" translatable="yes">Previous Suggestion</property>
+ <signal name="clicked" handler="_on_prev_button_clicked" swapped="no"/>
+ <style>
+ <class name="image-button"/>
+ </style>
+ <child>
+ <object class="GtkImage" id="_prev_button_image">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="icon-name">go-previous-symbolic</property>
+ <property name="icon-size">1</property>
+ </object>
+ </child>
</object>
</child>
- </object>
- </child>
- <child>
- <object class="GtkButton" id="_next_button">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="valign">center</property>
- <property name="sensitive">False</property>
- <property name="tooltip_text" translatable="yes">Next Suggestion</property>
- <signal name="clicked" handler="_on_next_button_clicked" swapped="no"/>
- <style>
- <class name="image-button"/>
- </style>
<child>
- <object class="GtkImage" id="_next_button_image">
+ <object class="GtkButton" id="_next_button">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="icon-name">go-next</property>
- <property name="icon-size">1</property>
+ <property name="valign">center</property>
+ <property name="sensitive">False</property>
+ <property name="tooltip_text" translatable="yes">Next Suggestion</property>
+ <signal name="clicked" handler="_on_next_button_clicked" swapped="no"/>
+ <style>
+ <class name="image-button"/>
+ </style>
+ <child>
+ <object class="GtkImage" id="_next_button_image">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="icon-name">go-next-symbolic</property>
+ <property name="icon-size">1</property>
+ </object>
+ </child>
</object>
</child>
</object>
@@ -726,7 +723,7 @@
<object class="GtkButton" id="_submit_button">
<property name="label" translatable="yes">Submit</property>
<property name="visible">True</property>
- <property name="sensitive">True</property>
+ <property name="sensitive">False</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<signal name="clicked" handler="_on_submit_clicked" swapped="no"/>
@@ -742,81 +739,13 @@
</packing>
</child>
</object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">2</property>
- </packing>
</child>
</object>
<packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">2</property>
+ <property name="left-attach">1</property>
+ <property name="top-attach">5</property>
</packing>
</child>
- <child>
- <object class="GtkBox">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="orientation">vertical</property>
- <property name="spacing">6</property>
- <child>
- <object class="GtkBox">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <child>
- <object class="GtkLabel" id="location">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="margin_right">36</property>
- <property name="label" translatable="yes">Location</property>
- <property name="xalign">1</property>
- <attributes>
- <attribute name="weight" value="bold"/>
- </attributes>
- <style>
- <class name="dim-label"/>
- </style>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="_url">
- <property name="can_focus">False</property>
- <property name="halign">start</property>
- <property name="margin_right">2</property>
- <property name="max_width_chars">45</property>
- <property name="wrap">True</property>
- <style>
- <class name="dim-label"/>
- </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>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">2</property>
- </packing>
- </child>
</object>
</child>
</template>
diff --git a/gnomemusic/widgets/notificationspopup.py b/gnomemusic/widgets/notificationspopup.py
index a3667be2..1181a71f 100644
--- a/gnomemusic/widgets/notificationspopup.py
+++ b/gnomemusic/widgets/notificationspopup.py
@@ -249,3 +249,54 @@ class PlaylistNotification(Gtk.Grid):
self._timeout_id = 0
self._notifications_popup.remove_notification(self, 'undo-deletion')
+
+
+class UseSuggestionNotification(Gtk.Grid):
+ """Show a notification on filling with suggested tags.
+
+ It also provides an option to undo filling fields. Notification is added
+ to the NotificationsPopup.
+ """
+
+ class Type(IntEnum):
+ """Enum for Use Suggestion Notifications"""
+ ALBUM = 0
+ SONG = 1
+
+ __gsignals__ = {
+ 'undo-fill': (GObject.SignalFlags.RUN_FIRST, None, ()),
+ 'finish-fill': (GObject.SignalFlags.RUN_FIRST, None, ())
+ }
+
+ def __repr__(self):
+ return '<UseSuggestionNotification>'
+
+ @log
+ def __init__(self, notifications_popup, type_, message):
+ super().__init__(column_spacing=18)
+ self._notifications_popup = notifications_popup
+ self.type_ = type_
+
+ self._label = Gtk.Label(
+ label=message, halign=Gtk.Align.START, hexpand=True)
+ self.add(self._label)
+
+ undo_button = Gtk.Button.new_with_mnemonic(_("_Undo"))
+ undo_button.connect("clicked", self._undo_clicked)
+ self.add(undo_button)
+ self.show_all()
+
+ self._timeout_id = GLib.timeout_add_seconds(
+ 5, self._notifications_popup.remove_notification, self,
+ 'finish-fill')
+
+ self._notifications_popup.add_notification(self)
+
+ @log
+ def _undo_clicked(self, widget_):
+ """Undo fill and remove notification"""
+ if self._timeout_id > 0:
+ GLib.source_remove(self._timeout_id)
+ self._timeout_id = 0
+
+ self._notifications_popup.remove_notification(self, 'undo-fill')
diff --git a/gnomemusic/widgets/tageditordialog.py b/gnomemusic/widgets/tageditordialog.py
index 9f7c1b3d..e637128e 100644
--- a/gnomemusic/widgets/tageditordialog.py
+++ b/gnomemusic/widgets/tageditordialog.py
@@ -25,11 +25,12 @@
import logging
from gettext import gettext as _
-from gi.repository import Grl, Gtk
+from gi.repository import Grl, Gtk, Gio, GObject, GLib
from gnomemusic import log
from gnomemusic.albumartcache import Art
from gnomemusic.grilo import grilo
+from gnomemusic.widgets.notificationspopup import NotificationsPopup, UseSuggestionNotification
import gnomemusic.utils as utils
logger = logging.getLogger(__name__)
@@ -44,6 +45,8 @@ class TagEditorDialog(Gtk.Dialog):
__gtype_name__ = 'TagEditorDialog'
+ _notifications_popup = Gtk.Template.Child()
+
_cover_stack = Gtk.Template.Child()
_spinner = Gtk.Template.Child()
_spinner_label = Gtk.Template.Child()
@@ -62,13 +65,17 @@ class TagEditorDialog(Gtk.Dialog):
_track_suggestion = Gtk.Template.Child()
_year_entry = Gtk.Template.Child()
_year_suggestion = Gtk.Template.Child()
-
_prev_button = Gtk.Template.Child()
_next_button = Gtk.Template.Child()
_use_suggestion_button = Gtk.Template.Child()
+ _submit_button = Gtk.Template.Child()
_url = Gtk.Template.Child()
+ __gsignals__ = {
+ 'no-tags': (GObject.SignalFlags.RUN_FIRST, None, ()),
+ }
+
def __repr__(self):
return '<TagEditorDialog>'
@@ -83,14 +90,16 @@ class TagEditorDialog(Gtk.Dialog):
self.props.transient_for = parent
self.set_titlebar(self._title_bar)
- self._cover_stack.props.size = Art.Size.MEDIUM
+ self._cover_stack.props.size = Art.Size.LARGE
self._cover_stack.update(selected_song)
+ self._music_directory = GLib.get_user_special_dir(GLib.UserDirectory.DIRECTORY_MUSIC)
+
self._initial_song = selected_song
self._init_labels()
self._search_tags()
self._suggestions = []
- self._pointer = 0
+ self._pointer = -1
@log
def _init_labels(self):
@@ -99,8 +108,19 @@ class TagEditorDialog(Gtk.Dialog):
value = utils.fields_getter[field](self._initial_song)
if value:
entry.props.text = value
-
- self._url.props.label = self._initial_song.get_url()
+ entry.connect('notify::text', self._on_entries_changed)
+
+ file_url = self._initial_song.get_url()
+ file_ = Gio.File.new_for_uri(file_url)
+ file_path = file_.get_path()
+ if file_path.startswith(self._music_directory):
+ self._url.set_text(file_path[len(self._music_directory)+1:])
+ self._url.set_tooltip_text(file_path[len(self._music_directory)+1:])
+ self._url.set_has_tooltip(True)
+ else:
+ self._url.set_text(file_path)
+ self._url.set_tooltip_text(file_path)
+ self._url.set_has_tooltip(True)
self._url.props.visible = True
@log
@@ -121,17 +141,19 @@ class TagEditorDialog(Gtk.Dialog):
grilo.get_tags_from_musicbrainz(new_media, self._tags_found)
@log
- def _tags_found(self, media, count):
+ def _tags_found(self, media, count=0):
if media is None:
logger.warning("Unable to find tags for song {}".format(
self._initial_song.get_url()))
self._stop_spinner()
+ self._create_no_tags_notification()
return
self._use_suggestion_button.props.sensitive = True
self._suggestions.append(media)
if count == 0:
+ self._pointer = 0
self._give_suggestion()
self._stop_spinner()
@@ -144,6 +166,8 @@ class TagEditorDialog(Gtk.Dialog):
if value:
suggestion.props.label = value
suggestion.props.visible = True
+ suggestion.set_tooltip_text(value)
+ suggestion.set_has_tooltip(True)
if self._pointer < len(self._suggestions) - 1:
self._next_button.props.sensitive = True
@@ -155,28 +179,103 @@ class TagEditorDialog(Gtk.Dialog):
else:
self._prev_button.props.sensitive = False
+ @log
+ def _on_entries_changed(self, widget=None, param=None):
+ if self._pointer >= 0:
+ media = self._suggestions[self._pointer]
+ self._use_suggestion_button.props.sensitive = False
+ self._submit_button.props.sensitive = False
+ for field in utils.fields_getter:
+ entry = getattr(self, '_' + field + '_entry')
+ value = utils.fields_getter[field](self._initial_song)
+ typed_value = entry.get_text().strip()
+ if typed_value and value != typed_value:
+ self._submit_button.props.sensitive = True
+ if self._pointer >= 0:
+ suggested_value = utils.fields_getter[field](media)
+ if typed_value and suggested_value and typed_value != suggested_value:
+ self._use_suggestion_button.props.sensitive = True
+
@Gtk.Template.Callback()
@log
def _on_next_button_clicked(self, widget):
self._pointer += 1
self._give_suggestion()
+ self._on_entries_changed()
@Gtk.Template.Callback()
@log
def _on_prev_button_clicked(self, widget):
self._pointer -= 1
self._give_suggestion()
+ self._on_entries_changed()
@Gtk.Template.Callback()
@log
def _on_use_suggestion_clicked(self, widget):
- media = self._suggestions[self._pointer]
-
+ suggested_media = self._suggestions[self._pointer]
+ prev_media = Grl.Media()
for field in utils.fields_getter:
entry = getattr(self, '_' + field + '_entry')
- value = utils.fields_getter[field](media)
- if value:
- entry.props.text = value
+ suggested_value = utils.fields_getter[field](suggested_media)
+ typed_value = entry.get_text()
+ if typed_value:
+ utils.fields_setter[field](prev_media, typed_value)
+ if suggested_value:
+ entry.set_text(suggested_value)
+
+ self._prev_song = prev_media
+ self._on_entries_changed()
+ self._create_tag_fill_notification(
+ UseSuggestionNotification.Type.SONG)
+
+ @log
+ def _get_tag_fill_notification_message(self, type_):
+ """ Returns a label for the use suggestion notification popup
+
+ Handles two cases:
+ - album info updated
+ - song info updated
+ """
+ msg = ""
+
+ if type_ == UseSuggestionNotification.Type.ALBUM:
+ msg = _("Album info updated based on online suggestions.")
+
+ elif type_ == UseSuggestionNotification.Type.SONG:
+ msg = _("Song info updated based on online suggestions.")
+
+ return msg
+
+ @log
+ def _create_tag_fill_notification(self, type_):
+ msg = self._get_tag_fill_notification_message(type_)
+ self.use_suggestion_notification = UseSuggestionNotification(
+ self._notifications_popup, type_, msg)
+ self.use_suggestion_notification.connect(
+ 'undo-fill', self._undo_fill)
+
+ @log
+ def _undo_fill(self, use_suggestion_notification):
+ """Revert tags filling"""
+ notification_type = use_suggestion_notification.type_
+ if notification_type == UseSuggestionNotification.Type.SONG:
+ for field in utils.fields_getter:
+ entry = getattr(self, '_' + field + '_entry')
+ value = utils.fields_getter[field](self._prev_song)
+ if value:
+ entry.set_text(value)
+
+ @log
+ def _create_no_tags_notification(self):
+ msg = _("No Tags found online for the given media!")
+ grid = Gtk.Grid()
+ label = Gtk.Label(label=msg, halign=Gtk.Align.START, hexpand=True)
+ grid.add(label)
+ grid.show_all()
+ self._notifications_popup.add_notification(grid)
+ GLib.timeout_add_seconds(
+ 5, self._notifications_popup.remove_notification, self, 'no-tags')
@Gtk.Template.Callback()
@log
@@ -184,7 +283,7 @@ class TagEditorDialog(Gtk.Dialog):
for field in utils.fields_setter:
entry = getattr(self, '_' + field + '_entry')
- entry_text = entry.props.text
+ entry_text = entry.get_text()
if entry_text:
utils.fields_setter[field](self._initial_song, entry_text)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]