/* vim: set noexpandtab tabstop=4 shiftwidth=4 nowrap textwidth=100
*
* Echo Media Player
* Copyright (C) 2008 Shane O'Connell
*
* [ The original file includes a copyright header in this location describing
* the file as being released under the terms of the GNU General Public
* License. It has been removed in order to display the file as part of the
* archive. ]
*/
using Echo.Core;
using Echo.Database;
using Echo.Interfaces;
using Echo.UI.Widgets;
public class Echo.UI.Tabs.PlaySourceTab : Gtk.VBox, ITab
{
public IPlaySource source { get { return _source; } }
private IPlaySource _source;
public PlaySourceView view { get { return _source_view; } }
private PlaySourceView _source_view;
private Gtk.Label _info_display;
public PlaySourceTab(IPlaySource source)
{
assert(source != null);
_source = source;
var hbox = new Gtk.HBox(false, 0);
hbox.pack_start(new Gtk.Image.from_icon_name(_source.icon, Gtk.IconSize.DIALOG), false, false, 5);
_info_display = new Gtk.Label(null);
// TODO setting ellipsize makes the window able to resize so that the label has a negative width...
//_info_display.set_ellipsize(Pango.EllipsizeMode.END);
_info_display.set_alignment(0.0f, 0.5f);
//_info_display.set_size_request(50, -1);
_source.track_removed += this.on_source_track_update;
_source.track_inserted += this.on_source_track_update;
_source.track_changed += this.on_source_track_update;
on_source_track_update(_source, -1);
var info_display_alignment = new Gtk.Alignment(0.5f, 0.5f, 1.0f, 1.0f);
info_display_alignment.add(_info_display);
info_display_alignment.set_padding(5, 5, 5, 5);
hbox.pack_start(info_display_alignment, true, true, 0);
var search_box = new Sexy.IconEntry();
search_box.set_icon(Sexy.IconEntryPosition.PRIMARY,
new Gtk.Image.from_stock("gtk-find", Gtk.IconSize.MENU));
search_box.add_clear_button();
search_box.set_size_request(250, -1);
var search_box_alignment = new Gtk.Alignment(0.5f, 0.5f, 1.0f, 1.0f);
search_box_alignment.add(search_box);
search_box_alignment.set_padding(5, 5, 2, 5);
hbox.pack_start(search_box_alignment, false, false, 0);
_source_view = new PlaySourceView(_source);
this.pack_start(hbox, false, false, 0);
this.pack_start(_source_view, true, true, 0);
}
private void on_source_track_update(IPlaySource source, int index)
{
_info_display.set_markup(
"<b>%s</b>\n%d songs - x hours, x minutes, x seconds".printf(
_source.name, _source.get_num_tracks()));
}
public weak string get_name()
{
return _source.name;
}
public weak string get_icon()
{
return _source.icon;
}
}