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



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

    songwidget: Cleanup & break

 data/ui/SongWidget.ui            | 108 +++++++++++--------------------------
 gnomemusic/widgets/songwidget.py | 114 +++++++++++++++++++--------------------
 2 files changed, 88 insertions(+), 134 deletions(-)
---
diff --git a/data/ui/SongWidget.ui b/data/ui/SongWidget.ui
index 474fe8f4..340e6e58 100644
--- a/data/ui/SongWidget.ui
+++ b/data/ui/SongWidget.ui
@@ -1,28 +1,16 @@
 <?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>
@@ -37,17 +25,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>
@@ -55,18 +38,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>
@@ -78,18 +54,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>
@@ -101,18 +73,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>
@@ -124,18 +93,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>
@@ -145,9 +111,6 @@
             </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>
@@ -161,42 +124,34 @@
         </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>
@@ -204,7 +159,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 fc5e159a..a0b2ef92 100644
--- a/gnomemusic/widgets/songwidget.py
+++ b/gnomemusic/widgets/songwidget.py
@@ -166,70 +166,70 @@ class SongWidget(Gtk.Box):
             self.drag_dest_set(
                 Gtk.DestDefaults.ALL, entries, Gdk.DragAction.MOVE)
 
-    @Gtk.Template.Callback()
-    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()
+    # 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()
-    def _on_star_toggle(self, widget, event):
-        (_, button) = event.get_button()
-        if button != Gdk.BUTTON_PRIMARY:
-            return False
+    # @Gtk.Template.Callback()
+    # 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()
-    def _on_star_hover(self, widget, event):
-        self._star_image.props.hover = True
+    # @Gtk.Template.Callback()
+    # def _on_star_hover(self, widget, event):
+    #     self._star_image.props.hover = True
 
-    @Gtk.Template.Callback()
-    def _on_star_unhover(self, widget, event):
-        self._star_image.props.hover = False
+    # @Gtk.Template.Callback()
+    # 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]