[gnome-music/wip/jfelder/tracker3-rebased: 46/49] songeditordialog: Display the current suggestion number




commit 3e2153cd34ab8592f006c29403a8baa08c0272ca
Author: Jean Felder <jfelder src gnome org>
Date:   Mon May 18 19:32:25 2020 +0200

    songeditordialog: Display the current suggestion number

 data/ui/SongEditorDialog.ui            | 12 ++++++++++--
 gnomemusic/widgets/songeditordialog.py | 15 +++++++++++----
 2 files changed, 21 insertions(+), 6 deletions(-)
---
diff --git a/data/ui/SongEditorDialog.ui b/data/ui/SongEditorDialog.ui
index 9dc26095..0205e32e 100644
--- a/data/ui/SongEditorDialog.ui
+++ b/data/ui/SongEditorDialog.ui
@@ -603,10 +603,18 @@
                   </packing>
                 </child>
                 <child>
-                  <object class="GtkLabel" id="_spinner_label">
+                  <object class="GtkLabel" id="_state_label">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="label" translatable="yes">Fetching metadata...</property>
+                    <style>
+                      <class name="dim-label"/>
+                    </style>
+                  </object>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="_suggestion_label">
+                    <property name="visible">False</property>
+                    <property name="can_focus">False</property>
                     <style>
                       <class name="dim-label"/>
                     </style>
diff --git a/gnomemusic/widgets/songeditordialog.py b/gnomemusic/widgets/songeditordialog.py
index 6c81679a..29bc024d 100644
--- a/gnomemusic/widgets/songeditordialog.py
+++ b/gnomemusic/widgets/songeditordialog.py
@@ -47,8 +47,9 @@ class SongEditorDialog(Gtk.Dialog):
     _notifications_popup = Gtk.Template.Child()
     _prev_button = Gtk.Template.Child()
     _spinner = Gtk.Template.Child()
-    _spinner_label = Gtk.Template.Child()
+    _state_label = Gtk.Template.Child()
     _submit_button = Gtk.Template.Child()
+    _suggestion_label = Gtk.Template.Child()
     _url_label = Gtk.Template.Child()
     _use_suggestion_button = Gtk.Template.Child()
 
@@ -133,7 +134,7 @@ class SongEditorDialog(Gtk.Dialog):
 
     def _start_spinner(self):
         self._spinner.start()
-        self._spinner_label.props.label = _("Fetching metadata…")
+        self._state_label.props.label = _("Fetching metadata…")
 
     def _stop_spinner(self):
         self._spinner.stop()
@@ -143,7 +144,7 @@ class SongEditorDialog(Gtk.Dialog):
                 "{} suggestion found", "{} suggestions found",
                 len(self._suggestions)).format(len(self._suggestions))
 
-        self._spinner_label.props.label = label
+        self._state_label.props.label = label
 
     def _search_tags(self):
         self._start_spinner()
@@ -183,10 +184,16 @@ class SongEditorDialog(Gtk.Dialog):
                 suggestion.props.has_tooltip = True
                 suggestion.props.tooltip_text = value
 
+        nr_results = len(self._suggestions)
         self._next_button.props.sensitive = (
-            self._suggestion_index < len(self._suggestions) - 1)
+            self._suggestion_index < nr_results - 1)
         self._prev_button.props.sensitive = (self._suggestion_index > 0)
 
+        if nr_results > 1:
+            label = "({}/{})".format(self._suggestion_index + 1, nr_results)
+            self._suggestion_label.props.label = label
+            self._suggestion_label.props.visible = True
+
     def _on_entries_changed(self, widget=None, param=None):
         if self._suggestion_index >= 0:
             media = self._suggestions[self._suggestion_index]


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