[gnome-music/freeze-break: 78/107] widgets: Create a new playlist when New Playlist is activated
- From: Arnel A. Borja <arnelborja src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/freeze-break: 78/107] widgets: Create a new playlist when New Playlist is activated
- Date: Wed, 11 Sep 2013 13:20:55 +0000 (UTC)
commit 98f596f85f47e5d9fa80eaba48ff8ec49e9f82af
Author: Arnel A. Borja <arnelborja src gnome org>
Date: Thu Sep 5 23:13:35 2013 +0800
widgets: Create a new playlist when New Playlist is activated
gnomemusic/widgets.py | 17 ++++++++++++++++-
1 files changed, 16 insertions(+), 1 deletions(-)
---
diff --git a/gnomemusic/widgets.py b/gnomemusic/widgets.py
index 0560d6e..6b34933 100644
--- a/gnomemusic/widgets.py
+++ b/gnomemusic/widgets.py
@@ -617,6 +617,7 @@ class PlaylistDialog():
self.dialog_box = self.ui.get_object('dialog1')
self.view = self.ui.get_object('treeview1')
+ self.selection = self.ui.get_object('treeview-selection1')
self._add_list_renderers()
self.view.connect('row-activated', self._on_item_activated)
@@ -640,6 +641,7 @@ class PlaylistDialog():
xalign=0.0,
width=220
)
+ type_renderer.connect('editing-started', self._on_editing_started, None)
cols.pack_start(type_renderer, True)
cols.add_attribute(type_renderer, "text", 0)
cols.add_attribute(type_renderer, "editable", 1)
@@ -658,4 +660,17 @@ class PlaylistDialog():
self.dialog_box.destroy()
def _on_item_activated(self, view, path, column):
- self.view.set_cursor(path, column, True)
+ _iter = self.model.get_iter(path)
+ if self.model.get_value(_iter, 1):
+ self.view.set_cursor(path, column, True)
+
+ def _on_editing_started(self, renderer, editable, path, data=None):
+ editable.set_text('')
+ editable.connect('editing-done', self._on_editing_done, None)
+
+ def _on_editing_done(self, editable, data=None):
+ _iter = self.selection.get_selected()[1]
+ if editable.get_text() != '':
+ playlist.create_playlist(editable.get_text())
+ new_iter = self.model.insert_before(_iter)
+ self.model.set(new_iter, [0, 1], [editable.get_text(), False])
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]