[gnome-music] Implementation of selction mode in views and albumwidget.
- From: Seif Lotfy <seiflotfy src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music] Implementation of selction mode in views and albumwidget.
- Date: Sun, 9 Jun 2013 07:19:31 +0000 (UTC)
commit b5899af15acf1b45206ea16c8374d2cfd8573c66
Author: Sai <suman sai14 gmail com>
Date: Sun Jun 9 12:35:16 2013 +0530
Implementation of selction mode in views and albumwidget.
Signed-off-by: Seif Lotfy <seif lotfy com>
src/toolbar.js | 16 ++++++++++++++++
src/view.js | 31 +++++++++++++++++++------------
src/widgets.js | 29 +++++++++++++++++++++--------
3 files changed, 56 insertions(+), 20 deletions(-)
---
diff --git a/src/toolbar.js b/src/toolbar.js
index 388130c..40a14bb 100644
--- a/src/toolbar.js
+++ b/src/toolbar.js
@@ -48,6 +48,8 @@ const Toolbar = new Lang.Class({
this._stack_switcher = new Gtk.StackSwitcher ();
this.set_custom_title (null);
this._addBackButton();
+ this._addSearchButton();
+ this._addSelectButton();
},
set_stack: function(stack) {
@@ -79,6 +81,20 @@ const Toolbar = new Lang.Class({
label: _("Back") });
this._backButton.connect('clicked', Lang.bind(this, this.setState))
this.pack_start(this._backButton);
+ },
+
+ _addSearchButton: function() {
+ this._searchButton = new Gd.HeaderSimpleButton({ symbolic_icon_name: 'folder-saved-search-symbolic',
+ label: _("Search") });
+ this.pack_end(this._searchButton);
+ this._searchButton.show();
+ },
+
+ _addSelectButton: function() {
+ this._selectButton = new Gd.HeaderToggleButton({ symbolic_icon_name: 'object-select-symbolic',
+ label: _("Select") });
+ this.pack_end(this._selectButton);
+ this._selectButton.show();
}
});
Signals.addSignalMethods(Toolbar.prototype);
diff --git a/src/view.js b/src/view.js
index ee4e715..aac99f5 100644
--- a/src/view.js
+++ b/src/view.js
@@ -75,6 +75,7 @@ const ViewContainer = new Lang.Class({
GObject.TYPE_OBJECT,
GObject.TYPE_BOOLEAN,
GObject.TYPE_STRING,
+ GObject.TYPE_BOOLEAN,
GObject.TYPE_BOOLEAN
]);
this.view = new Gd.MainView({
@@ -105,6 +106,12 @@ const ViewContainer = new Lang.Class({
Lang.bind(this, this._onItemActivated));
this._cursor = null;
this.header_bar = header_bar;
+ this.header_bar._selectButton.connect('toggled',Lang.bind(this,function (button) {
+ if(button.get_active())
+ this.view.set_selection_mode(true);
+ else
+ this.view.set_selection_mode(false);
+ }));
this.title = title;
this.add(this._grid)
@@ -198,16 +205,16 @@ const ViewContainer = new Lang.Class({
this.player.discoverer.discover_uri(item.get_url());
this._model.set(
iter,
- [0, 1, 2, 3, 4, 5, 6, 7],
- [toString(item.get_id()), "", item.get_title(), artist, this._symbolicIcon, item,
false, nowPlayingIconName]
+ [0, 1, 2, 3, 4, 5, 7, 9],
+ [toString(item.get_id()), "", item.get_title(), artist, this._symbolicIcon, item,
nowPlayingIconName, false]
);
} catch(err) {
log(err.message);
log("failed to discover url " + item.get_url());
this._model.set(
iter,
- [0, 1, 2, 3, 4, 5, 6, 7],
- [toString(item.get_id()), "", item.get_title(), artist, this._symbolicIcon, item,
true, errorIconName]
+ [0, 1, 2, 3, 4, 5, 7, 9],
+ [toString(item.get_id()), "", item.get_title(), artist, this._symbolicIcon, item,
errorIconName, true]
);
}
GLib.idle_add(300, Lang.bind(this, this._updateAlbumArt, item, iter));
@@ -313,7 +320,7 @@ const Albums = new Lang.Class({
let title = this._model.get_value (iter, 2);
let artist = this._model.get_value (iter, 3);
let item = this._model.get_value (iter, 5);
- this._albumWidget.update (artist, title, item);
+ this._albumWidget.update (artist, title, item, this.header_bar);
this.header_bar.setState (0);
this.header_bar.title = title;
this.header_bar.sub_title = artist;
@@ -358,9 +365,9 @@ const Songs = new Lang.Class({
if (playlist != this._model){
return false;}
if (this.iterToClean){
- this._model.set_value(this.iterToClean, 6, false);
+ this._model.set_value(this.iterToClean, 9, false);
}
- this._model.set_value(currentIter, 6, true);
+ this._model.set_value(currentIter, 9, true);
this.iterToClean = currentIter.copy();
return false;
},
@@ -377,16 +384,16 @@ const Songs = new Lang.Class({
this.player.discoverer.discover_uri(item.get_url());
this._model.set(
iter,
- [5, 6, 7,8],
- [item, false, nowPlayingIconName,false]
+ [5, 7, 8, 9],
+ [item, nowPlayingIconName, false, false]
);
} catch(err) {
log(err.message);
log("failed to discover url " + item.get_url());
this._model.set(
iter,
- [5, 6, 7,8],
- [item, true, errorIconName,false]
+ [5, 7, 8, 9],
+ [item, errorIconName, false, true]
);
}
}
@@ -402,7 +409,7 @@ const Songs = new Lang.Class({
nowPlayingSymbolRenderer.xalign = 1.0;
columnNowPlaying.pack_start(nowPlayingSymbolRenderer, false);
columnNowPlaying.fixed_width = 24;
- columnNowPlaying.add_attribute(nowPlayingSymbolRenderer, "visible", 6);
+ columnNowPlaying.add_attribute(nowPlayingSymbolRenderer, "visible", 9);
columnNowPlaying.add_attribute(nowPlayingSymbolRenderer, "icon_name", 7);
listWidget.insert_column(columnNowPlaying, 0);
diff --git a/src/widgets.js b/src/widgets.js
index 431a5fb..df59ec7 100644
--- a/src/widgets.js
+++ b/src/widgets.js
@@ -111,8 +111,10 @@ const AlbumWidget = new Lang.Class({
GObject.TYPE_STRING,
GdkPixbuf.Pixbuf, /*icon*/
GObject.TYPE_OBJECT, /*song object*/
- GObject.TYPE_BOOLEAN,/*icon shown*/
+ GObject.TYPE_BOOLEAN,/* item selected */
GObject.TYPE_STRING,
+ GObject.TYPE_BOOLEAN,
+ GObject.TYPE_BOOLEAN,/*icon shown*/
]);
this.view = new Gd.MainView({
@@ -171,7 +173,7 @@ const AlbumWidget = new Lang.Class({
nowPlayingSymbolRenderer.yalign = 0.6;
columnNowPlaying.pack_start(nowPlayingSymbolRenderer, false);
columnNowPlaying.fixed_width = 24;
- columnNowPlaying.add_attribute(nowPlayingSymbolRenderer, "visible", 6);
+ columnNowPlaying.add_attribute(nowPlayingSymbolRenderer, "visible", 9);
columnNowPlaying.add_attribute(nowPlayingSymbolRenderer, "icon_name", 7);
listWidget.insert_column(columnNowPlaying, 0);
@@ -200,7 +202,7 @@ const AlbumWidget = new Lang.Class({
}));
},
- update: function (artist, album, item) {
+ update: function (artist, album, item, header_bar) {
let released_date = item.get_publication_date();
if (released_date != null) {
this.ui.get_object("released_label_info").set_text(
@@ -235,6 +237,8 @@ const AlbumWidget = new Lang.Class({
GObject.TYPE_OBJECT, /*song object*/
GObject.TYPE_BOOLEAN,/*icon shown*/
GObject.TYPE_STRING,
+ GObject.TYPE_BOOLEAN,
+ GObject.TYPE_BOOLEAN,
]);
var tracks = [];
grilo.getAlbumSongs(item.get_id(), Lang.bind(this, function (source, prefs, track) {
@@ -246,14 +250,14 @@ const AlbumWidget = new Lang.Class({
try{
this.player.discoverer.discover_uri(track.get_url());
this.model.set(iter,
- [0, 1, 2, 3, 4, 5, 6, 7],
- [ escapedTitle, "", "", "", this._symbolicIcon, track, false, nowPlayingIconName
]);
+ [0, 1, 2, 3, 4, 5, 7, 9],
+ [ escapedTitle, "", "", "", this._symbolicIcon, track, nowPlayingIconName,
false]);
} catch(err) {
log(err.message);
log("failed to discover url " + track.get_url());
this.model.set(iter,
- [0, 1, 2, 3, 4, 5, 6, 7],
- [ escapedTitle, "", "", "", this._symbolicIcon, track, true, errorIconName ]);
+ [0, 1, 2, 3, 4, 5, 7, 9],
+ [ escapedTitle, "", "", "", this._symbolicIcon, track, true, errorIconName,
false]);
}
this.ui.get_object("running_length_label_info").set_text(
@@ -263,6 +267,15 @@ const AlbumWidget = new Lang.Class({
}
}));
}
+ header_bar._selectButton.connect('toggled',Lang.bind(this,function (button) {
+ if(button.get_active()){
+ this.view.set_selection_mode(true);
+ header_bar._backButton.hide()
+ }else{
+ this.view.set_selection_mode(false);
+ header_bar._backButton.show();
+ }
+ }));
this.view.set_model(this.model);
let escapedArtist = GLib.markup_escape_text(artist, -1);
let escapedAlbum = GLib.markup_escape_text(album, -1);
@@ -303,7 +316,7 @@ const AlbumWidget = new Lang.Class({
iconVisible = false;
}
playlist.set_value(iter, 0, title);
- playlist.set_value(iter, 6, iconVisible);
+ playlist.set_value(iter, 9, iconVisible);
} while(playlist.iter_next(iter));
return false;
},
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]