[gnome-music] playlist-dialog: add bottom entry
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music] playlist-dialog: add bottom entry
- Date: Wed, 17 Aug 2016 06:08:17 +0000 (UTC)
commit ea71c1ef28547d3eb77da741b3ccb62ee4a64aaf
Author: Billy Barrow <billyb pcthingz com>
Date: Sun Mar 27 17:34:56 2016 +1300
playlist-dialog: add bottom entry
The current implementation of the playlist editor dialog
uses an inline editor, which may be confusing due to the
lack of obviousness.
Fix that by adding a new entry + 'Add' button at the bottom
of the dialog.
https://bugzilla.gnome.org/show_bug.cgi?id=744834
data/PlaylistDialog.ui | 158 +++++++++++++++++++++++++++++-------------------
gnomemusic/widgets.py | 41 +++++++++----
2 files changed, 125 insertions(+), 74 deletions(-)
---
diff --git a/data/PlaylistDialog.ui b/data/PlaylistDialog.ui
index 41ae47a..f22b82c 100644
--- a/data/PlaylistDialog.ui
+++ b/data/PlaylistDialog.ui
@@ -1,7 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.15.2 on Thu Aug 22 16:04:08 2013 -->
+<!-- Generated with glade 3.19.0 -->
<interface>
- <!-- interface-requires gtk+ 3.10 -->
+ <requires lib="gtk+" version="3.10"/>
+ <object class="GtkHeaderBar" id="headerbar1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="title">Select Playlist</property>
+ <child>
+ <object class="GtkButton" id="cancel-button">
+ <property name="label" translatable="yes">Cancel</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="receives_default">False</property>
+ <style>
+ <class name="text-button"/>
+ </style>
+ </object>
+ </child>
+ <child>
+ <object class="GtkButton" id="select-button">
+ <property name="label" translatable="yes">Add</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="receives_default">False</property>
+ <style>
+ <class name="suggested-action"/>
+ <class name="text-button"/>
+ </style>
+ </object>
+ <packing>
+ <property name="pack_type">end</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <object class="GtkListStore" id="liststore1">
+ <columns>
+ <!-- column-name playlist-name -->
+ <column type="gchararray"/>
+ <!-- column-name editable -->
+ <column type="gboolean"/>
+ <!-- column-name item -->
+ <column type="GObject"/>
+ </columns>
+ </object>
<object class="GtkDialog" id="dialog1">
<property name="width_request">400</property>
<property name="height_request">500</property>
@@ -9,28 +51,17 @@
<property name="modal">True</property>
<property name="destroy_with_parent">True</property>
<property name="type_hint">dialog</property>
+ <property name="use_header_bar">1</property>
<child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox1">
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
- <property name="spacing">2</property>
- <child internal-child="action_area">
- <object class="GtkButtonBox" id="dialog-action_area1">
- <property name="can_focus">False</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="pack_type">end</property>
- <property name="position">0</property>
- </packing>
- </child>
+ <property name="border_width">0</property>
<child>
<object class="GtkScrolledWindow" id="scrolledwindow1">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="margin">12</property>
- <property name="shadow_type">in</property>
+ <property name="vexpand">True</property>
<child>
<object class="GtkTreeView" id="treeview1">
<property name="visible">True</property>
@@ -38,62 +69,65 @@
<property name="model">liststore1</property>
<property name="headers_visible">False</property>
<property name="activate_on_single_click">True</property>
+ <child internal-child="selection">
+ <object class="GtkTreeSelection" id="treeview-selection1"/>
+ </child>
<style>
<class name="list-row"/>
<class name="playlists-list"/>
</style>
- <child internal-child="selection">
- <object class="GtkTreeSelection" id="treeview-selection1"/>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkSeparator">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkBox" id="new-playlist-hbox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="border_width">6</property>
+ <child>
+ <object class="GtkEntry" id="new-playlist-entry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hexpand">True</property>
+ <property name="placeholder_text" translatable="yes">New Playlist</property>
+ <style>
+ <class name="linked"/>
+ </style>
+ </object>
</child>
+ <child>
+ <object class="GtkButton" id="new-playlist-button">
+ <property name="label" translatable="yes">Add</property>
+ <property name="visible">True</property>
+ <property name="sensitive">False</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <style>
+ <class name="suggested-action"/>
+ <class name="linked"/>
+ </style>
+ </object>
+ </child>
+ <style>
+ <class name="linked"/>
+ </style>
</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>
- </packing>
- </child>
- <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"/>
- </style>
- </object>
- <packing>
- <property name="pack-type">end</property>
- </packing>
- </child>
- </object>
- <object class="GtkListStore" id="liststore1">
- <columns>
- <!-- column-name playlist-name -->
- <column type="gchararray"/>
- <!-- column-name editable -->
- <column type="gboolean"/>
- <!-- column-name item -->
- <column type="GObject"/>
- </columns>
- </object>
</interface>
diff --git a/gnomemusic/widgets.py b/gnomemusic/widgets.py
index 172e25d..7b52c05 100644
--- a/gnomemusic/widgets.py
+++ b/gnomemusic/widgets.py
@@ -812,6 +812,17 @@ class PlaylistDialog():
self._cancel_button.connect('clicked', self._on_cancel_button_clicked)
self._select_button.connect('clicked', self._on_selection)
+ self._new_playlist_button = self.ui.get_object('new-playlist-button')
+ self._new_playlist_button.connect('clicked', self._on_editing_done)
+
+ self._new_playlist_entry = self.ui.get_object('new-playlist-entry')
+ self._new_playlist_entry.connect('changed',
+ self._on_new_playlist_entry_changed)
+ self._new_playlist_entry.connect('activate',
+ self._on_editing_done)
+ self._new_playlist_entry.connect('focus-in-event',
+ self._on_new_playlist_entry_focused)
+
self.playlist = Playlists.get_default()
self.playlist.connect('playlist-created', self._on_playlist_created)
@@ -833,17 +844,13 @@ class PlaylistDialog():
ellipsize=Pango.EllipsizeMode.END,
xalign=0.0
)
- 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)
cols.set_cell_data_func(type_renderer, self._on_list_text_render)
self.view.append_column(cols)
@log
def populate(self):
- self.add_playlist_iter = self.model.append()
- self.model.set(self.add_playlist_iter, [0, 1], [_("New Playlist"), True])
if grilo.tracker:
GLib.idle_add(grilo.populate_playlists, 0, self._add_item)
@@ -854,7 +861,7 @@ class PlaylistDialog():
@log
def _add_item_to_model(self, item):
- new_iter = self.model.insert_before(self.add_playlist_iter)
+ new_iter = self.model.append()
self.model.set(
new_iter,
[0, 1, 2],
@@ -880,6 +887,8 @@ class PlaylistDialog():
@log
def _on_item_activated(self, view, path, column):
+ self._new_playlist_entry.set_text("")
+ self._new_playlist_button.set_sensitive(False)
_iter = self.model.get_iter(path)
if self.model.get_value(_iter, 1):
self.view.set_cursor(path, column, True)
@@ -895,15 +904,11 @@ class PlaylistDialog():
else:
self._select_button.set_sensitive(True)
- @log
- def _on_editing_started(self, renderer, editable, path, data=None):
- editable.set_text('')
- editable.connect('editing-done', self._on_editing_done, None)
@log
- def _on_editing_done(self, editable, data=None):
- if editable.get_text() != '':
- self.playlist.create_playlist(editable.get_text())
+ def _on_editing_done(self, sender, data=None):
+ if self._new_playlist_entry.get_text() != '':
+ self.playlist.create_playlist(self._new_playlist_entry.get_text())
@log
def _on_playlist_created(self, playlists, item):
@@ -913,6 +918,18 @@ class PlaylistDialog():
self.view.get_columns()[0], False)
self.view.row_activated(self.model.get_path(new_iter),
self.view.get_columns()[0])
+ self.dialog_box.response(Gtk.ResponseType.ACCEPT)
+
+ @log
+ def _on_new_playlist_entry_changed(self, editable, data=None):
+ if editable.get_text() != '':
+ self._new_playlist_button.set_sensitive(True)
+ else:
+ self._new_playlist_button.set_sensitive(False)
+
+ @log
+ def _on_new_playlist_entry_focused(self, editable, data=None):
+ self.selection.unselect_all()
class CellRendererClickablePixbuf(Gtk.CellRendererPixbuf):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]