[gnome-music/freeze-break: 62/107] Cleanup class ordering



commit fe842c2fb4f677e072cf3e4498b99db824b8461f
Author: Arnel A. Borja <arnelborja src gnome org>
Date:   Wed Sep 4 11:49:26 2013 +0800

    Cleanup class ordering

 gnomemusic/view.py    |  122 ++++++++++++++++++++++++------------------------
 gnomemusic/widgets.py |  102 ++++++++++++++++++++--------------------
 2 files changed, 112 insertions(+), 112 deletions(-)
---
diff --git a/gnomemusic/view.py b/gnomemusic/view.py
index 72a248c..b81676b 100644
--- a/gnomemusic/view.py
+++ b/gnomemusic/view.py
@@ -464,67 +464,6 @@ class Songs(ViewContainer):
             GLib.idle_add(grilo.populate_songs, self._offset, self._add_item)
 
 
-class Playlist(ViewContainer):
-    playlists_list = playlists.get_playlists()
-
-    def __init__(self, header_bar, selection_toolbar, player):
-        ViewContainer.__init__(self, _("Playlists"), header_bar,
-                               selection_toolbar)
-        self._playlist_list = {}
-        self.view.set_view_type(Gd.MainViewType.LIST)
-        self.view.set_hexpand(False)
-        self.view.get_generic_view().get_selection().set_mode(
-            Gtk.SelectionMode.SINGLE)
-        self._grid.attach(Gtk.Separator(orientation=Gtk.Orientation.VERTICAL),
-                          1, 0, 1, 1)
-        self._add_list_renderers()
-        if (Gtk.Settings.get_default().get_property(
-                'gtk_application_prefer_dark_theme')):
-            self.view.get_generic_view().get_style_context().\
-                add_class("artist-panel-dark")
-        else:
-            self.view.get_generic_view().get_style_context().\
-                add_class("artist-panel-white")
-
-    def _add_list_renderers(self):
-        list_widget = self.view.get_generic_view()
-
-        cols = list_widget.get_columns()
-        cells = cols[0].get_cells()
-        cells[1].set_visible(False)
-        cells[2].set_visible(False)
-        type_renderer = Gd.StyledTextRenderer(
-            xpad=16,
-            ypad=16,
-            ellipsize=Pango.EllipsizeMode.END,
-            xalign=0.0,
-            width=220
-        )
-        list_widget.add_renderer(type_renderer, lambda *args: None, None)
-        cols[0].clear_attributes(type_renderer)
-        cols[0].add_attribute(type_renderer, "text", 2)
-
-    def _populate(self):
-        self._init = True
-        self.populate()
-
-    def _add_item(self, item):
-        _iter = self._model.append()
-        self._playlist_list[item] = {"iter": _iter, "albums": []}
-        self._model.set(_iter, [2], [item])
-
-    def populate(self):
-        for item in self.playlists_list:
-            self._add_item(item)
-
-    def _on_add_button_clicked(self, button):
-        text_renderer = Gtk.CellRendererText()
-        text_renderer.set_property('editable', True)
-        text_renderer.set_property('editable-set', True)
-        self.view.get_generic_view().add_renderer(text_renderer,
-                                                  lambda *args: None, None)
-
-
 class Artists (ViewContainer):
     def __init__(self, header_bar, selection_toolbar, player):
         ViewContainer.__init__(self, _("Artists"), header_bar,
@@ -652,3 +591,64 @@ class Artists (ViewContainer):
             if self._last_selection is not None:
                 self.view.get_generic_view().get_selection().select_iter(
                     self._last_selection)
+
+
+class Playlist(ViewContainer):
+    playlists_list = playlists.get_playlists()
+
+    def __init__(self, header_bar, selection_toolbar, player):
+        ViewContainer.__init__(self, _("Playlists"), header_bar,
+                               selection_toolbar)
+        self._playlist_list = {}
+        self.view.set_view_type(Gd.MainViewType.LIST)
+        self.view.set_hexpand(False)
+        self.view.get_generic_view().get_selection().set_mode(
+            Gtk.SelectionMode.SINGLE)
+        self._grid.attach(Gtk.Separator(orientation=Gtk.Orientation.VERTICAL),
+                          1, 0, 1, 1)
+        self._add_list_renderers()
+        if (Gtk.Settings.get_default().get_property(
+                'gtk_application_prefer_dark_theme')):
+            self.view.get_generic_view().get_style_context().\
+                add_class("artist-panel-dark")
+        else:
+            self.view.get_generic_view().get_style_context().\
+                add_class("artist-panel-white")
+
+    def _add_list_renderers(self):
+        list_widget = self.view.get_generic_view()
+
+        cols = list_widget.get_columns()
+        cells = cols[0].get_cells()
+        cells[1].set_visible(False)
+        cells[2].set_visible(False)
+        type_renderer = Gd.StyledTextRenderer(
+            xpad=16,
+            ypad=16,
+            ellipsize=Pango.EllipsizeMode.END,
+            xalign=0.0,
+            width=220
+        )
+        list_widget.add_renderer(type_renderer, lambda *args: None, None)
+        cols[0].clear_attributes(type_renderer)
+        cols[0].add_attribute(type_renderer, "text", 2)
+
+    def _populate(self):
+        self._init = True
+        self.populate()
+
+    def _add_item(self, item):
+        _iter = self._model.append()
+        self._playlist_list[item] = {"iter": _iter, "albums": []}
+        self._model.set(_iter, [2], [item])
+
+    def populate(self):
+        for item in self.playlists_list:
+            self._add_item(item)
+
+    def _on_add_button_clicked(self, button):
+        text_renderer = Gtk.CellRendererText()
+        text_renderer.set_property('editable', True)
+        text_renderer.set_property('editable-set', True)
+        self.view.get_generic_view().add_renderer(text_renderer,
+                                                  lambda *args: None, None)
diff --git a/gnomemusic/widgets.py b/gnomemusic/widgets.py
index bb63fbb..0560d6e 100644
--- a/gnomemusic/widgets.py
+++ b/gnomemusic/widgets.py
@@ -443,57 +443,6 @@ class ArtistAlbums(Gtk.VBox):
         return False
 
 
-class PlaylistDialog():
-    def __init__(self):
-        self.ui = Gtk.Builder()
-        self.ui.add_from_resource('/org/gnome/Music/PlaylistDialog.ui')
-        self.dialog_box = self.ui.get_object('dialog1')
-
-        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.title_bar = self.ui.get_object('headerbar1')
-        self.dialog_box.set_titlebar(self.title_bar)
-        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)
-
-    def _add_list_renderers(self):
-        cols = Gtk.TreeViewColumn()
-        type_renderer = Gd.StyledTextRenderer(
-            xpad=16,
-            ypad=16,
-            ellipsize=Pango.EllipsizeMode.END,
-            xalign=0.0,
-            width=220
-        )
-        cols.pack_start(type_renderer, True)
-        cols.add_attribute(type_renderer, "text", 0)
-        cols.add_attribute(type_renderer, "editable", 1)
-        self.view.append_column(cols)
-
-    def populate(self, items):
-        for playlist_name in items:
-            self.model.append([playlist_name, False])
-        add_playlist_iter = self.model.append()
-        self.model.set(add_playlist_iter, [0, 1], [_("New Playlist"), True])
-
-    def _on_selection(self, select_button):
-        pass
-
-    def _on_cancel_button_clicked(self, cancel_button):
-        self.dialog_box.destroy()
-
-    def _on_item_activated(self, view, path, column):
-        self.view.set_cursor(path, column, True)
-
-
 class AllArtistsAlbums(ArtistAlbums):
 
     def __init__(self, player):
@@ -659,3 +608,54 @@ class ArtistAlbumWidget(Gtk.HBox):
         self.player.set_playlist('Artist', self.album,
                                  widget.model, widget._iter, 5)
         self.player.set_playing(True)
+
+
+class PlaylistDialog():
+    def __init__(self):
+        self.ui = Gtk.Builder()
+        self.ui.add_from_resource('/org/gnome/Music/PlaylistDialog.ui')
+        self.dialog_box = self.ui.get_object('dialog1')
+
+        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.title_bar = self.ui.get_object('headerbar1')
+        self.dialog_box.set_titlebar(self.title_bar)
+        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)
+
+    def _add_list_renderers(self):
+        cols = Gtk.TreeViewColumn()
+        type_renderer = Gd.StyledTextRenderer(
+            xpad=16,
+            ypad=16,
+            ellipsize=Pango.EllipsizeMode.END,
+            xalign=0.0,
+            width=220
+        )
+        cols.pack_start(type_renderer, True)
+        cols.add_attribute(type_renderer, "text", 0)
+        cols.add_attribute(type_renderer, "editable", 1)
+        self.view.append_column(cols)
+
+    def populate(self, items):
+        for playlist_name in items:
+            self.model.append([playlist_name, False])
+        add_playlist_iter = self.model.append()
+        self.model.set(add_playlist_iter, [0, 1], [_("New Playlist"), True])
+
+    def _on_selection(self, select_button):
+        pass
+
+    def _on_cancel_button_clicked(self, cancel_button):
+        self.dialog_box.destroy()
+
+    def _on_item_activated(self, view, path, column):
+        self.view.set_cursor(path, column, True)


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