Skip to content

Instantly share code, notes, and snippets.

@amatiasq
Created January 19, 2016 11:03
Show Gist options
  • Save amatiasq/96f28b5a89d26b35aa4d to your computer and use it in GitHub Desktop.
Save amatiasq/96f28b5a89d26b35aa4d to your computer and use it in GitHub Desktop.
function banshee_application(checknum, pid, args) {
var app = new eyeos.application.Banshee(checknum, pid, args);
}
qx.Class.define("eyeos.application.Banshee", {
extend: eyeos.system.EyeApplication,
construct: function(checknum, pid, args) {
arguments.callee.base.call(this, 'banshee', checknum, pid);
this._drawGUI();
},
statics: {
DEFAULT_HEIGHT: 500,
DEFAULT_WIDTH: 900
},
members: {
_noBorder: new qx.ui.decoration.Single(0),
_borderDecoration: new qx.ui.decoration.Single(1, 'solid', "#9D9893"),
_backgroundColor: '#F2F1F0',
_window: null,
_menuBar: null,
_topBarContainer: null,
_btnPrev: null,
_btnPlay: null,
_btnPause: null,
_btnNext: null,
_btnMore: null,
_sliderSplitter: null,
_childSplitter: null,
_sliderContainer: null,
_slider: null,
_lblTime: null,
_songInfo: null,
_songImg: null,
_songData: null,
_lblSongTitle: null,
_authorContainer: null,
_lblBy: null,
_lblArtist: null,
_searchContainer: null,
_txtSearch: null,
_volume: null,
_treeSplitter: null,
_tree: null,
// And here all diferent grids and splitters from functionalities
_mainScreen:null,
_libraryScreen: null,
_librarySplitter: null,
_artistSplitter: null,
_artistList: null,
_albumList: null,
_libraryGrid: null,
//...
_statusBar: null,
//
// Events
//
play: function() {
this._btnPlay.exclude();
this._btnPause.show();
//alert("Play");
},
pause: function() {
this._btnPause.exclude();
this._btnPlay.show();
//alert("Pause");
},
prev: function() { alert("Previous"); },
next: function() { alert("Next"); },
_btnShuffle_click: function() { alert("Shuffle"); },
_btnVolume_click: function() { alert("Volume"); },
//
// GUI
//
_drawGUI: function() {
this._window = new eyeos.ui.Window(this, "Banshee", '').set({
layout: new qx.ui.layout.VBox(),
backgroundColor: this._backgroundColor,
height: this.self(arguments).DEFAULT_HEIGHT,
width: this.self(arguments).DEFAULT_WIDTH,
destroyOnClose: true,
textColor: "#463C49",
contentPadding: 0
});
this._window.add(this._buildTopBar());
this._window.add(this._buildMainScreen(), { flex: 1 });
//this._window.add(this._buildStatusBar());
this._window.restore();
this._window.center();
},
_buildTopBar: function() {
this._menuBar = new qx.ui.container.Composite(new qx.ui.layout.HBox()).set({
backgroundColor: this._backgroundColor,
height: 49
});
this._btnPrev = this._createTopBarButton(34, "index.php?extern=/images/banshee/media-skip-backward.png", this.prev);
this._btnPlay = this._createTopBarButton(34, "index.php?extern=/images/banshee/media-playback-start.png", this.play);
this._btnPause = this._createTopBarButton(34, "index.php?extern=/images/banshee/media-playback-pause.png", this.pause);
this._btnPause.exclude();
this._btnNext = this._createTopBarButton(34, "index.php?extern=/images/banshee/media-skip-forward.png", this.next);
this._btnMore = this._createTopBarButton(22, "index.php?extern=/images/banshee/treeDownTriangleBlack.png", this._btnShuffle_click);
this._menuBar.add(this._buildTopBarSplitters(), { flex: 1 });
this._volume = this._createTopBarButton(32, "index.php?extern=/images/banshee/audio-volume-high.png", this._btnVolume_click);
return this._menuBar;
},
_createTopBarButton: function(width, img, action) {
var button = new qx.ui.toolbar.Button(null, img);
button.set({
width: width,
height: 40,
minWidth: 10,
padding : 3,
marginTop: 5,
marginBottom: 5,
marginLeft: 2,
marginRight: 2
});
button.addListener('execute', action, this);
this._menuBar.add(button);
return button;
},
_buildTopBarSplitters: function(container) {
this._sliderSplitter = new qx.ui.splitpane.Pane("horizontal");
this._sliderSplitter.getChildControl('splitter').setBackgroundColor(this._backgroundColor);
this._sliderSplitter.setDecorator(this._noBorder);
this._childSplitter = new qx.ui.splitpane.Pane("horizontal");
this._childSplitter.getChildControl('splitter').setBackgroundColor(this._backgroundColor);
this._childSplitter.setDecorator(this._noBorder);
this._sliderSplitter.add(this._childSplitter, 1);
this._sliderContainer = new qx.ui.container.Composite(new qx.ui.layout.VBox());
this._sliderContainer.setMinWidth(125);
var sliderWidth = 165;
this._slider = new qx.ui.form.Slider().set({
marginBottom: 5,
marginTop: 5,
maximum: 1000,
width: sliderWidth
});
this._sliderContainer.add(this._slider);
this._lblTime = new qx.ui.basic.Label(tr("En reposo")).set({
textAlign: 'center',
width: sliderWidth
});
this._sliderContainer.add(this._lblTime);
this._childSplitter.add(this._sliderContainer, 0);
// TODO
this._childSplitter.add(new qx.ui.core.Widget(), 1);
//this._childSplitter.add(this._buildSongInfo());
this._searchContainer = new qx.ui.container.Composite(new qx.ui.layout.VBox());
this._txtSearch = new qx.ui.form.TextField().set({
placeholder: tr("Buscar en su música"),
marginLeft: 4,
marginTop: 11,
minWidth: 150,
height: 26,
width: 200
});
this._searchContainer.add(this._txtSearch);
this._sliderSplitter.add(this._searchContainer, 0);
return this._sliderSplitter;
},
_buildMainScreen: function() {
this._treeSplitter = new qx.ui.splitpane.Pane("horizontal");
this._treeSplitter.getChildControl('splitter').setBackgroundColor(this._backgroundColor);
this._treeSplitter.setDecorator(this._noBorder);
this._treeSplitter.add(this._buildTree(), { width: 200 });
this._mainScreen = new qx.ui.container.Stack().set({
decorator: this._borderDecoration,
minWidth: 200
});
// TODO
//this._mainScreen.add(this._buildLibraryMainScreen());
this._treeSplitter.add(this._mainScreen);
return this._treeSplitter;
},
_buildTree: function() {
var treeFont = new qx.bom.Font(14, [ 'arial' ]);
var boldFont = new qx.bom.Font(14, [ 'arial' ]);
boldFont.setBold(true);
var headerConfig = {
textColor: "#9F9E9E",
font: boldFont,
indent: 0
};
this._tree = new qx.ui.tree.Tree().set({
decorator: this._borderDecoration,
font: treeFont,
backgroundColor: 'white',
rootOpenClose: true,
scrollbarX: 'off',
hideRoot: true,
minWidth: 50,
width: 200
});
var root = new qx.ui.tree.TreeFolder("root").set({ open: true });
var items = {
'playlist': new qx.ui.tree.TreeFile(tr("En reproducción")).set({ indent: 0, icon: "index.php?extern=/images/banshee/categories/media-playback-start.png" }),
'queue': new qx.ui.tree.TreeFile(tr("Cola de reproducción")).set({ indent: 0, icon: "index.php?extern=/images/banshee/categories/source-playlist.png" }),
'filequeue': new qx.ui.tree.TreeFile(tr("Cola del sistema de archivos")).set({ indent: 0, icon: "index.php?extern=/images/banshee/categories/drive-harddisk.png" }),
'collections': new qx.ui.tree.TreeFile(tr("Colecciones")).set(headerConfig),
'music': new qx.ui.tree.TreeFolder(tr("Música")).set({ icon: "index.php?extern=/images/banshee/categories/audio-x-generic.png" }),
'music-favorites': new qx.ui.tree.TreeFile(tr("Favoritos")).set({ icon: "index.php?extern=/images/banshee/categories/source-smart-playlist.png" }),
'music-favoritesrecent': new qx.ui.tree.TreeFile(tr("Favoritos Recientes")).set({ icon: "index.php?extern=/images/banshee/categories/source-smart-playlist.png" }),
'music-noplayed': new qx.ui.tree.TreeFile(tr("No oídas")).set({ icon: "index.php?extern=/images/banshee/categories/source-smart-playlist.png" }),
'music-recent': new qx.ui.tree.TreeFile(tr("Reproducidas recientemente")).set({ icon: "index.php?extern=/images/banshee/categories/source-smart-playlist.png" }),
'audiobook': new qx.ui.tree.TreeFile(tr("Audiolibros")).set({ icon: "index.php?extern=/images/banshee/categories/audiobook.png" }),
'videos': new qx.ui.tree.TreeFolder(tr("Videos")).set({ icon: "index.php?extern=/images/banshee/categories/video-x-generic.png" }),
'videos-favorites': new qx.ui.tree.TreeFile(tr("Favoritos")).set({ icon: "index.php?extern=/images/banshee/categories/source-smart-playlist.png" }),
'videos-noplayed': new qx.ui.tree.TreeFile(tr("No vistos")).set({ icon: "index.php?extern=/images/banshee/categories/source-smart-playlist.png" }),
'podcasts': new qx.ui.tree.TreeFile(tr("Podcasts")).set({ icon: "index.php?extern=/images/banshee/categories/podcast.png" }),
'radio': new qx.ui.tree.TreeFile(tr("Radio")).set({ icon: "index.php?extern=/images/banshee/categories/radio.png" }),
'online': new qx.ui.tree.TreeFile(tr("Multimedia en línea")).set(headerConfig),
'amazon': new qx.ui.tree.TreeFile(tr("Tienda de Amazon MP3")).set({ icon: "index.php?extern=/images/banshee/categories/amazon-mp3-store-source.png" }),
'miro': new qx.ui.tree.TreeFile(tr("Miro Guide")).set({ icon: "index.php?extern=/images/banshee/categories/miro-guide-source.png" }),
'internetarchive': new qx.ui.tree.TreeFile(tr("Internet Archive")).set({ icon: "index.php?extern=/images/banshee/categories/internet-archive.png" }),
'ubuntu': new qx.ui.tree.TreeFile(tr("Tienda de música de Ubuntu One")).set({ icon: "index.php?extern=/images/banshee/categories/ubuntuone.png" }),
'lastfm': new qx.ui.tree.TreeFile(tr("Last.fm")).set({ icon: "index.php?extern=/images/banshee/categories/lastfm-audioscrobbler.png" })
};
for (var section in items) {
if (items.hasOwnProperty(section)) {
var item = items[section];
var path = section.split(/-/);
var parent = path.length > 1 ? items[path[0]] : root;
item.setMarginTop(4);
parent.add(item);
}
}
this._tree.setRoot(root);
return this._tree;
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment