[gnome-music/freeze-break: 60/107] Some Add to Playlist Dialog cleanup



commit 6bfd9580745924c1a3aec919a537ae0db1fe8d3c
Author: Arnel A. Borja <arnelborja src gnome org>
Date:   Thu Aug 22 00:06:30 2013 +0800

    Some Add to Playlist Dialog cleanup
    
    - Move some of the code into the ui file
    - Fixed the renderer that doesn't show up
    - Add missing window decorations
    - Some code refactoring

 data/PlaylistDialog.ui |   40 +++++++++++++++++++++++++++++++++++++++-
 gnomemusic/widgets.py  |   23 ++++++++++-------------
 2 files changed, 49 insertions(+), 14 deletions(-)
---
diff --git a/data/PlaylistDialog.ui b/data/PlaylistDialog.ui
index eed6dde..269e7db 100644
--- a/data/PlaylistDialog.ui
+++ b/data/PlaylistDialog.ui
@@ -2,8 +2,11 @@
 <interface>
   <!-- interface-requires gtk+ 3.10 -->
   <object class="GtkDialog" id="dialog1">
+    <property name="width_request">400</property>
+    <property name="height_request">500</property>
     <property name="can_focus">False</property>
-    <property name="type">popup</property>
+    <property name="modal">True</property>
+    <property name="destroy_with_parent">True</property>
     <property name="type_hint">dialog</property>
     <child internal-child="vbox">
       <object class="GtkBox" id="dialog-vbox1">
@@ -21,14 +24,42 @@
             <property name="position">0</property>
           </packing>
         </child>
+        <child>
+          <object class="GtkScrolledWindow" id="scrolledwindow1">
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="shadow_type">in</property>
+            <child>
+              <object class="GtkTreeView" id="treeview1">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="model">liststore1</property>
+                <property name="headers_visible">False</property>
+                <child internal-child="selection">
+                  <object class="GtkTreeSelection" id="treeview-selection1"/>
+                </child>
+              </object>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">True</property>
+            <property name="fill">True</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
       </object>
     </child>
   </object>
   <object class="GtkHeaderBar" id="headerbar1">
     <property name="title" translatable="yes">Select Playlist</property>
+    <property name="visible">True</property>
     <child>
       <object class="GtkButton" id="cancel-button">
         <property name="label" translatable="yes">Cancel</property>
+        <property name="visible">True</property>
+        <style>
+          <class name="text-button"/>
+        </style>
       </object>
       <packing>
           <property name="pack-type">start</property>
@@ -37,6 +68,7 @@
     <child>
       <object class="GtkButton" id="select-button">
         <property name="label" translatable="yes">Select</property>
+        <property name="visible">True</property>
         <style>
           <class name="suggested-action"/>
           <class name="text-button"/>
@@ -47,4 +79,10 @@
       </packing>
     </child>
   </object>
+  <object class="GtkListStore" id="liststore1">
+    <columns>
+      <!-- column-name playlist-name -->
+      <column type="gchararray"/>
+    </columns>
+  </object>
 </interface>
diff --git a/gnomemusic/widgets.py b/gnomemusic/widgets.py
index 5705398..c042603 100644
--- a/gnomemusic/widgets.py
+++ b/gnomemusic/widgets.py
@@ -448,23 +448,21 @@ class PlaylistDialog():
         self.ui = Gtk.Builder()
         self.ui.add_from_resource('/org/gnome/Music/PlaylistDialog.ui')
         self.dialog_box = self.ui.get_object('dialog1')
-        self.dialog_box.set_default_size(300, 500)
-        self._cancel_button = self.ui.get_object('cancel-button')
-        self._select_button = self.ui.get_object('select-button')
-        self.view = Gtk.TreeView()
-        self.model = Gtk.ListStore(str)
+
+        self.view = self.ui.get_object('treeview1')
+        self._add_list_renderers()
+        self.view.connect('row-activated', self._on_item_activated)
+
+        self.model = self.ui.get_object('liststore1')
         playlist_names = playlist.get_playlists()
         self.populate(playlist_names)
-        self.view.set_model(self.model)
+
         self.title_bar = self.ui.get_object('headerbar1')
         self.dialog_box.set_titlebar(self.title_bar)
-        box = self.dialog_box.get_content_area()
-        self._add_list_renderers()
-        box.add(self.view)
-        self.view.connect('row-activated', self._on_item_activated)
+        self._cancel_button = self.ui.get_object('cancel-button')
+        self._select_button = self.ui.get_object('select-button')
         self._cancel_button.connect('clicked', self._on_cancel_button_clicked)
         self._select_button.connect('clicked', self._on_selection)
-        self.dialog_box.show_all()
 
     def _add_list_renderers(self):
         cols = Gtk.TreeViewColumn()
@@ -475,8 +473,7 @@ class PlaylistDialog():
             xalign=0.0,
             width=220
         )
-        # self.view.add_renderer(type_renderer, lambda *args: None, None)
-        cols.clear_attributes(type_renderer)
+        cols.pack_start(type_renderer, True)
         cols.add_attribute(type_renderer, "text", 0)
         self.view.append_column(cols)
 


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