[gnome-music/wip/mschraal/gtk4: 117/143] songwidget: Cleanup & break



commit bd311bc9a0601e5f283b5fbcd0c14472c1a66e0f
Author: Marinus Schraal <mschraal gnome org>
Date:   Thu Oct 31 16:11:44 2019 +0100

    songwidget: Cleanup & break

 data/ui/SongWidget.ui            | 113 +++++++++++-------------------------
 gnomemusic/widgets/songwidget.py | 122 +++++++++++++++++++--------------------
 2 files changed, 94 insertions(+), 141 deletions(-)
---
diff --git a/data/ui/SongWidget.ui b/data/ui/SongWidget.ui
index b012e4aa..d69967b8 100644
--- a/data/ui/SongWidget.ui
+++ b/data/ui/SongWidget.ui
@@ -1,31 +1,18 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.20.0 -->
 <interface>
   <requires lib="gtk+" version="3.10"/>
   <template class="SongWidget" parent="GtkBox">
-    <property name="visible">True</property>
-    <property name="can_focus">False</property>
     <signal name="notify::selected" handler="_on_selection_changed"/>
-<!--<signal name="drag_data_received" handler="_on_drag_data_received"/> -->
     <child>
       <object class="GtkBox" id="box1">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
         <property name="spacing">3</property>
         <property name="margin_top">10</property>
         <property name="margin_bottom">10</property>
         <child>
           <object class="GtkBox" id="_dnd_eventbox">
-            <property name="visible">False</property>
-<!--
-            <signal name="drag-begin" handler="_on_drag_begin"/>
-            <signal name="drag-end" handler="_on_drag_end"/>
-            <signal name="drag_data_get" handler="_on_drag_data_get"/>
--->
-           <property name="no_show_all">True</property>
+            <property name="visible">0</property>
             <child>
               <object class="GtkImage">
-                <property name="visible">True</property>
                 <property name="icon-name">open-menu-symbolic</property>
               </object>
             </child>
@@ -34,17 +21,12 @@
         <child>
           <object class="GtkBox" id="box3">
             <property name="width_request">48</property>
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="homogeneous">True</property>
+            <property name="homogeneous">1</property>
             <child>
-              <!-- FIXME: Remove this box? -->
               <object class="GtkBox" id="eventbox2">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
                 <child>
                   <object class="GtkImage" id="_play_icon">
-                    <property name="can_focus">False</property>
+                    <property name="visible">0</property>
                     <property name="icon_size">1</property>
                   </object>
                 </child>
@@ -52,18 +34,11 @@
             </child>
             <child>
               <object class="GtkCheckButton" id="_select_button">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="receives_default">False</property>
-                <property name="no_show_all">True</property>
-                <property name="draw_indicator">True</property>
                 <signal name="toggled" handler="_on_select_button_toggled"/>
               </object>
             </child>
             <child>
               <object class="GtkLabel" id="_number_label">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
                 <property name="halign">end</property>
                 <property name="justify">right</property>
                 <style>
@@ -75,18 +50,14 @@
         </child>
         <child>
           <object class="GtkBox" id="title_box">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
             <property name="margin_top">1</property>
             <property name="margin_bottom">1</property>
-            <property name="hexpand">True</property>
+            <property name="hexpand">1</property>
             <child>
               <object class="GtkLabel" id="_title_label">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
                 <property name="xalign">0</property>
                 <property name="halign">start</property>
-                <property name="hexpand">True</property>
+                <property name="hexpand">1</property>
                 <property name="valign">start</property>
                 <property name="ellipsize">end</property>
                 <property name="max_width_chars">90</property>
@@ -98,18 +69,15 @@
         </child>
         <child>
           <object class="GtkBox" id="_artist_box">
-            <property name="visible">False</property>
-            <property name="can_focus">False</property>
+            <property name="visible">0</property>
             <property name="margin_top">1</property>
             <property name="margin_bottom">1</property>
-            <property name="hexpand">True</property>
+            <property name="hexpand">1</property>
             <child>
               <object class="GtkLabel" id="_artist_label">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
                 <property name="xalign">0</property>
                 <property name="halign">start</property>
-                <property name="hexpand">True</property>
+                <property name="hexpand">1</property>
                 <property name="valign">start</property>
                 <property name="ellipsize">end</property>
                 <property name="max_width_chars">90</property>
@@ -121,18 +89,15 @@
         </child>
         <child>
           <object class="GtkBox" id="_album_duration_box">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
             <property name="margin_top">1</property>
             <property name="margin_bottom">1</property>
-            <property name="hexpand">True</property>
+            <property name="hexpand">1</property>
             <child>
               <object class="GtkLabel" id="_album_label">
-                <property name="visible">False</property>
-                <property name="can_focus">False</property>
+                <property name="visible">0</property>
                 <property name="xalign">0</property>
                 <property name="halign">start</property>
-                <property name="hexpand">True</property>
+                <property name="hexpand">1</property>
                 <property name="valign">start</property>
                 <property name="ellipsize">end</property>
                 <property name="max_width_chars">90</property>
@@ -142,55 +107,44 @@
             </child>
             <child>
               <object class="GtkLabel" id="_duration_label">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="no_show_all">True</property>
                 <property name="halign">end</property>
                 <property name="valign">center</property>
-                <property name="hexpand">True</property>
-                <property name="single_line_mode">True</property>
+                <property name="hexpand">1</property>
+                <property name="single_line_mode">1</property>
               </object>
             </child>
           </object>
         </child>
         <child>
           <object class="GtkStack" id="_star_stack">
-            <property name="can-focus">False</property>
-            <property name="visible">True</property>
             <child>
-              <object class="GtkBox" id="_star_eventbox">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="halign">end</property>
-                <property name="valign">center</property>
-                <property name="visible_window">True</property>
-                <property name="margin_right">12</property>
-<!--
-                <signal name="button-release-event" handler="_on_star_toggle" swapped="no"/>
-                <signal name="enter-notify-event" handler="_on_star_hover" swapped="no"/>
-                <signal name="leave-notify-event" handler="_on_star_unhover" swapped="no"/>
--->
-                <child>
-                  <object class="StarImage" id="_star_image">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
+              <object class="GtkStackPage">
+                <property name="name">star</property>
+                <property name="child">
+                  <object class="GtkBox" id="_star_eventbox">
+                    <property name="halign">end</property>
                     <property name="valign">center</property>
-                    <property name="margin_start">10</property>
+<!--                    <property name="margin_right">12</property>  -->
+                    <child>
+                      <object class="StarImage" id="_star_image">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="valign">center</property>
+                        <property name="margin_start">10</property>
+                      </object>
+                    </child>
                   </object>
-                </child>
+                </property>
               </object>
-              <packing>
-                <property name="name">star</property>
-              </packing>
             </child>
             <child>
-              <object class="GtkBox">
-                <property name="visible">True</property>
-              </object>
-              <packing>
+              <object class="GtkStackPage">
                 <property name="name">empty</property>
                 <property name="position">1</property>
-              </packing>
+                <property name="child">
+                  <object class="GtkBox"/>
+                </property>
+              </object>
             </child>
           </object>
         </child>
@@ -198,7 +152,6 @@
     </child>
   </template>
   <object class="GtkSizeGroup" id="_size_group">
-    <property name="mode">horizontal</property>
     <widgets>
       <widget name="title_box"/>
       <widget name="_artist_box"/>
diff --git a/gnomemusic/widgets/songwidget.py b/gnomemusic/widgets/songwidget.py
index cd923485..2f8f5c6e 100644
--- a/gnomemusic/widgets/songwidget.py
+++ b/gnomemusic/widgets/songwidget.py
@@ -171,74 +171,74 @@ class SongWidget(Gtk.Box):
             self.drag_dest_set(
                 Gtk.DestDefaults.ALL, entries, Gdk.DragAction.MOVE)
 
-    @Gtk.Template.Callback()
-    @log
-    def _on_selection_changed(self, klass, value):
-        self.emit('selection-changed')
-
-    @Gtk.Template.Callback()
-    def _on_drag_begin(self, klass, context):
-        gdk_window = self.get_window()
-        _, x, y, _ = gdk_window.get_device_position(context.get_device())
-        allocation = self.get_allocation()
-
-        self._drag_widget = Gtk.ListBox()
-        self._drag_widget.set_size_request(allocation.width, allocation.height)
-
-        drag_row = SongWidget(self.props.coresong)
-        self._drag_widget.add(drag_row)
-        self._drag_widget.drag_highlight_row(drag_row.get_parent())
-        self._drag_widget.show_all()
-        Gtk.drag_set_icon_widget(context, self._drag_widget, x, y)
-
-    @Gtk.Template.Callback()
-    def _on_drag_end(self, klass, context):
-        self._drag_widget = None
-
-    @Gtk.Template.Callback()
-    def _on_drag_data_get(self, klass, context, selection_data, info, time_):
-        row_position = self.get_parent().get_index()
-        selection_data.set(
-            Gdk.Atom.intern("row_position", False), 0,
-            bytes(str(row_position), encoding="UTF8"))
-
-    @Gtk.Template.Callback()
-    def _on_drag_data_received(
-            self, klass, context, x, y, selection_data, info, time_):
-        source_position = int(str(selection_data.get_data(), "UTF-8"))
-        target_position = self.get_parent().get_index()
-        if source_position == target_position:
-            return
-
-        self.emit("widget-moved", source_position)
-
-    @Gtk.Template.Callback()
-    def _on_select_button_toggled(self, widget):
+    # @Gtk.Template.Callback()
+    # @log
+    # def _on_selection_changed(self, klass, value):
+    #     self.emit('selection-changed')
+
+    # @Gtk.Template.Callback()
+    # def _on_drag_begin(self, klass, context):
+    #     gdk_window = self.get_window()
+    #     _, x, y, _ = gdk_window.get_device_position(context.get_device())
+    #     allocation = self.get_allocation()
+
+    #     self._drag_widget = Gtk.ListBox()
+    #     self._drag_widget.set_size_request(allocation.width, allocation.height)
+
+    #     drag_row = SongWidget(self.props.coresong)
+    #     self._drag_widget.add(drag_row)
+    #     self._drag_widget.drag_highlight_row(drag_row.get_parent())
+    #     self._drag_widget.show_all()
+    #     Gtk.drag_set_icon_widget(context, self._drag_widget, x, y)
+
+    # @Gtk.Template.Callback()
+    # def _on_drag_end(self, klass, context):
+    #     self._drag_widget = None
+
+    # @Gtk.Template.Callback()
+    # def _on_drag_data_get(self, klass, context, selection_data, info, time_):
+    #     row_position = self.get_parent().get_index()
+    #     selection_data.set(
+    #         Gdk.Atom.intern("row_position", False), 0,
+    #         bytes(str(row_position), encoding="UTF8"))
+
+    # @Gtk.Template.Callback()
+    # def _on_drag_data_received(
+    #         self, klass, context, x, y, selection_data, info, time_):
+    #     source_position = int(str(selection_data.get_data(), "UTF-8"))
+    #     target_position = self.get_parent().get_index()
+    #     if source_position == target_position:
+    #         return
+
+    #     self.emit("widget-moved", source_position)
+
+    # @Gtk.Template.Callback()
+    # def _on_select_button_toggled(self, widget):
         # This property is used to ignore the second click event
         # (one event in SongWidget and the other one in select_button).
-        self.props.select_click = not self.props.select_click
+    #     self.props.select_click = not self.props.select_click
 
-    @Gtk.Template.Callback()
-    @log
-    def _on_star_toggle(self, widget, event):
-        (_, button) = event.get_button()
-        if button != Gdk.BUTTON_PRIMARY:
-            return False
+    # @Gtk.Template.Callback()
+    # @log
+    # def _on_star_toggle(self, widget, event):
+    #     (_, button) = event.get_button()
+    #     if button != Gdk.BUTTON_PRIMARY:
+    #         return False
 
-        favorite = not self._star_image.favorite
-        self._star_image.props.favorite = favorite
+    #     favorite = not self._star_image.favorite
+    #     self._star_image.props.favorite = favorite
 
-        return True
+    #     return True
 
-    @Gtk.Template.Callback()
-    @log
-    def _on_star_hover(self, widget, event):
-        self._star_image.props.hover = True
+    # @Gtk.Template.Callback()
+    # @log
+    # def _on_star_hover(self, widget, event):
+    #     self._star_image.props.hover = True
 
-    @Gtk.Template.Callback()
-    @log
-    def _on_star_unhover(self, widget, event):
-        self._star_image.props.hover = False
+    # @Gtk.Template.Callback()
+    # @log
+    # def _on_star_unhover(self, widget, event):
+    #     self._star_image.props.hover = False
 
     @GObject.Property(type=bool, default=False)
     def selection_mode(self):


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