[gnome-music/freeze-break: 83/107] window: Show Add to Playlist dialog when its button is clicked



commit 63c4bec5232bccc35378e2d00fcdfa5b0f864342
Author: Arnel A. Borja <arnelborja src gnome org>
Date:   Sat Sep 7 00:18:56 2013 +0800

    window: Show Add to Playlist dialog when its button is clicked

 gnomemusic/view.py    |    7 -------
 gnomemusic/widgets.py |    6 ------
 gnomemusic/window.py  |   15 +++++++++++++++
 3 files changed, 15 insertions(+), 13 deletions(-)
---
diff --git a/gnomemusic/view.py b/gnomemusic/view.py
index 9c79ccf..6242041 100644
--- a/gnomemusic/view.py
+++ b/gnomemusic/view.py
@@ -843,10 +843,3 @@ class Playlist(ViewContainer):
     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.playlists_sidebar.get_generic_view().add_renderer(
-            text_renderer, lambda *args: None, None)
diff --git a/gnomemusic/widgets.py b/gnomemusic/widgets.py
index 0525537..0dafb7b 100644
--- a/gnomemusic/widgets.py
+++ b/gnomemusic/widgets.py
@@ -237,8 +237,6 @@ class AlbumWidget(Gtk.EventBox):
             'clicked', self._on_header_cancel_button_clicked)
         self.view.connect('view-selection-changed',
                           self._on_view_selection_changed)
-        selection_toolbar._add_to_playlist_button.connect(
-            'clicked', self._on_add_to_playlist_button_clicked)
         self.view.set_model(self.model)
         escaped_artist = GLib.markup_escape_text(artist)
         escaped_album = GLib.markup_escape_text(album)
@@ -252,10 +250,6 @@ class AlbumWidget(Gtk.EventBox):
         self.player.connect('playlist-item-changed', self.update_model)
         #self.emit('loaded')
 
-    def _on_add_to_playlist_button_clicked(self, widget):
-        self.playlists = PlaylistDialog()
-        self.playlists.dialog_box.run()
-
     def _on_view_selection_changed(self, widget):
         items = self.view.get_selection()
         self.selection_toolbar\
diff --git a/gnomemusic/window.py b/gnomemusic/window.py
index 7fe32e3..45111b6 100644
--- a/gnomemusic/window.py
+++ b/gnomemusic/window.py
@@ -37,7 +37,10 @@ from gnomemusic.toolbar import Toolbar, ToolbarState
 from gnomemusic.player import Player, SelectionToolbar
 from gnomemusic.query import Query
 import gnomemusic.view as Views
+import gnomemusic.widgets as Widgets
+from gnomemusic.playlists import Playlists
 
+playlist = Playlists.get_default()
 tracker = Tracker.SparqlConnection.get(None)
 
 if Gtk.get_minor_version() > 8:
@@ -133,6 +136,9 @@ class Window(Gtk.ApplicationWindow):
             self.views.append(Views.Empty(self.toolbar, self.player))
             self._stack.add_titled(self.views[0], _("Empty"), _("Empty"))
 
+        self.selection_toolbar._add_to_playlist_button.connect(
+            'clicked', self._on_add_to_playlist_button_clicked)
+
         self.toolbar.set_state(ToolbarState.ALBUMS)
         self.toolbar.header_bar.show()
         self.player.eventBox.show_all()
@@ -151,3 +157,12 @@ class Window(Gtk.ApplicationWindow):
 
     def _toggle_view(self, btn, i):
         self._stack.set_visible_child(self.views[i])
+
+    def _on_add_to_playlist_button_clicked(self, widget):
+        self.playlists = Widgets.PlaylistDialog()
+        if self.playlists.dialog_box.run() == Gtk.ResponseType.ACCEPT:
+            playlist.add_to_playlist(
+                self.playlists.get_selected(),
+                self._stack.get_visible_child().get_selected_track_uris())
+        self.toolbar.set_selection_mode(False)
+        self.playlists.dialog_box.destroy()


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