[gnome-music/wip/jfelder/songeditor-gtk4: 8/10] songeditordialog: Display the current suggestion number




commit a22b89b9ac58f988a69b166e6d705f0b061c3cca
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            | 11 +++++++++--
 gnomemusic/widgets/songeditordialog.py | 14 +++++++++++---
 2 files changed, 20 insertions(+), 5 deletions(-)
---
diff --git a/data/ui/SongEditorDialog.ui b/data/ui/SongEditorDialog.ui
index 8fa59d14b..6caf931e8 100644
--- a/data/ui/SongEditorDialog.ui
+++ b/data/ui/SongEditorDialog.ui
@@ -392,8 +392,15 @@
                   </object>
                 </child>
                 <child>
-                  <object class="GtkLabel" id="_spinner_label">
-                    <property name="label" translatable="yes">Fetching metadata...</property>
+                  <object class="GtkLabel" id="_state_label">
+                    <style>
+                      <class name="dim-label"/>
+                    </style>
+                  </object>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="_suggestion_label">
+                    <property name="visible">False</property>
                     <style>
                       <class name="dim-label"/>
                     </style>
diff --git a/gnomemusic/widgets/songeditordialog.py b/gnomemusic/widgets/songeditordialog.py
index 29c7a787f..08125f1f5 100644
--- a/gnomemusic/widgets/songeditordialog.py
+++ b/gnomemusic/widgets/songeditordialog.py
@@ -56,8 +56,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()
 
@@ -172,7 +173,7 @@ class SongEditorDialog(Gtk.Dialog):
 
     def _start_spinner(self) -> None:
         self._spinner.start()
-        self._spinner_label.props.label = _("Fetching metadata…")
+        self._state_label.props.label = _("Fetching metadata…")
 
     def _stop_spinner(self) -> None:
         self._spinner.stop()
@@ -182,7 +183,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) -> None:
         self._start_spinner()
@@ -224,10 +225,17 @@ class SongEditorDialog(Gtk.Dialog):
                 label.props.has_tooltip = True
                 label.props.tooltip_text = value
 
+        nr_results: int = len(self._suggestions)
         self._next_button.props.sensitive = (
             self._suggestion_idx < len(self._suggestions) - 1)
         self._prev_button.props.sensitive = (self._suggestion_idx > 0)
 
+        if nr_results > 1:
+            idx: int = self._suggestion_idx + 1
+            suggestion_txt: str = "({}/{})".format(idx, nr_results)
+            self._suggestion_label.props.label = suggestion_txt
+            self._suggestion_label.props.visible = True
+
     def _on_entries_changed(
             self, widget: Optional[Gtk.Entry] = None,
             param: Optional[GObject.GParamSpec] = None) -> None:


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