[gnome-music/wip/mschraal/gtk4-v3: 83/192] playlistdialog: Use a controller to handle focus events




commit 03109cc7cc3d9fd0cdcda8d5549f0f7f0a142181
Author: Jean Felder <jfelder src gnome org>
Date:   Mon Jan 10 15:11:46 2022 +0100

    playlistdialog: Use a controller to handle focus events
    
    In Gtk4, the focus-in-event does not exist anymore. It has been
    replaced by GtkEventControllerFocus.

 data/ui/PlaylistDialog.ui            | 12 ++++++++++--
 gnomemusic/widgets/playlistdialog.py |  3 ++-
 2 files changed, 12 insertions(+), 3 deletions(-)
---
diff --git a/data/ui/PlaylistDialog.ui b/data/ui/PlaylistDialog.ui
index e2a9c8528..34a4451d7 100644
--- a/data/ui/PlaylistDialog.ui
+++ b/data/ui/PlaylistDialog.ui
@@ -70,7 +70,11 @@
                         <property name="margin-top">18</property>
                         <signal name="activate" handler="_on_editing_done" swapped="no"/>
                         <signal name="changed" handler="_on_add_playlist_entry_changed" swapped="no"/>
-                        <signal name="focus-in-event" handler="_on_add_playlist_entry_focused" swapped="no"/>
+                        <child>
+                          <object class="GtkEventControllerFocus">
+                            <signal name="enter" handler="_on_add_playlist_entry_focused" swapped="no"/>
+                          </object>
+                        </child>
                       </object>
                     </child>
                     <child>
@@ -149,10 +153,14 @@
                             <property name="placeholder_text" translatable="yes">New Playlist…</property>
                             <signal name="activate" handler="_on_editing_done" swapped="no"/>
                             <signal name="changed" handler="_on_add_playlist_entry_changed" swapped="no"/>
-                            <signal name="focus-in-event" handler="_on_add_playlist_entry_focused" 
swapped="no"/>
                             <style>
                               <class name="linked"/>
                             </style>
+                            <child>
+                              <object class="GtkEventControllerFocus">
+                                <signal name="enter" handler="_on_add_playlist_entry_focused" swapped="no"/>
+                              </object>
+                            </child>
                           </object>
                         </child>
                         <child>
diff --git a/gnomemusic/widgets/playlistdialog.py b/gnomemusic/widgets/playlistdialog.py
index 2c67defb9..fa402f767 100644
--- a/gnomemusic/widgets/playlistdialog.py
+++ b/gnomemusic/widgets/playlistdialog.py
@@ -132,5 +132,6 @@ class PlaylistDialog(Gtk.Dialog):
             self._add_playlist_button.props.sensitive = False
 
     @Gtk.Template.Callback()
-    def _on_add_playlist_entry_focused(self, editable, data=None):
+    def _on_add_playlist_entry_focused(
+            self, controller: Gtk.EventControllerFocus) -> None:
         self._listbox.unselect_all()


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