reformatted the Live Mode table

This commit is contained in:
fgerlits 2005-05-06 16:23:27 +00:00
parent 125d6ceb64
commit d56c8131fd
6 changed files with 113 additions and 41 deletions

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ Author : $Author: fgerlits $
Version : $Revision: 1.10 $ Version : $Revision: 1.11 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/include/LiveSupport/Widgets/ZebraTreeView.h,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/include/LiveSupport/Widgets/ZebraTreeView.h,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -92,7 +92,7 @@ using namespace LiveSupport::Core;
* 3) connected with a TreeModelColumn using set_renderer(). * 3) connected with a TreeModelColumn using set_renderer().
* *
* @author $Author: fgerlits $ * @author $Author: fgerlits $
* @version $Revision: 1.10 $ * @version $Revision: 1.11 $
*/ */
class ZebraTreeView : public Gtk::TreeView class ZebraTreeView : public Gtk::TreeView
{ {
@ -158,6 +158,23 @@ class ZebraTreeView : public Gtk::TreeView
WidgetFactory::ImageButtonType buttonType, WidgetFactory::ImageButtonType buttonType,
int minimumWidth = 0) int minimumWidth = 0)
throw (); throw ();
/**
* Add a centered text column to the TreeView.
*
* @param title the title of the column
* @param modelColumn the model column this view will display
* @param minimumWidth the minimum width of the column, in pixels
* (optional)
* @return the number of columns after adding this one
*/
int
appendCenteredColumn(
const Glib::ustring& title,
const Gtk::TreeModelColumn<Glib::ustring>& modelColumn,
int minimumWidth = 0)
throw ();
}; };

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ Author : $Author: fgerlits $
Version : $Revision: 1.10 $ Version : $Revision: 1.11 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/src/ZebraTreeView.cxx,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/src/ZebraTreeView.cxx,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -90,7 +90,7 @@ ZebraTreeView :: appendColumn(
Gtk::TreeViewColumn(title, *renderer) ); Gtk::TreeViewColumn(title, *renderer) );
// and then we associate this renderer with the model column // and then we associate this renderer with the model column
viewColumn->set_renderer(*renderer, modelColumn); viewColumn->add_attribute(renderer->property_markup(), modelColumn);
// this cell data function will do the blue-gray zebra stripes // this cell data function will do the blue-gray zebra stripes
viewColumn->set_cell_data_func( viewColumn->set_cell_data_func(
@ -161,3 +161,40 @@ ZebraTreeView :: cellDataFunction(Gtk::CellRenderer* cell,
cell->property_cell_background_gdk() = Colors::getColor(colorName); cell->property_cell_background_gdk() = Colors::getColor(colorName);
} }
/*------------------------------------------------------------------------------
* Add a centered text column to the TreeView.
*----------------------------------------------------------------------------*/
int
ZebraTreeView :: appendCenteredColumn(
const Glib::ustring& title,
const Gtk::TreeModelColumn<Glib::ustring>& modelColumn,
int minimumWidth)
throw ()
{
// a standard cell renderer; can be replaced with a ZebraCellRenderer
Gtk::CellRendererText* renderer = Gtk::manage(new Gtk::CellRendererText);
// the constructor packs the renderer into the TreeViewColumn
Gtk::TreeViewColumn* viewColumn = Gtk::manage(new
Gtk::TreeViewColumn(title, *renderer) );
// and then we associate this renderer with the model column
viewColumn->add_attribute(renderer->property_markup(), modelColumn);
// center the text in the column
viewColumn->set_alignment(Gtk::ALIGN_CENTER);
// this cell data function will do the blue-gray zebra stripes
viewColumn->set_cell_data_func(
*renderer,
sigc::mem_fun(*this, &ZebraTreeView::cellDataFunction) );
// set the minimum width of the column
if (minimumWidth) {
viewColumn->set_min_width(minimumWidth);
}
return append_column(*viewColumn);
}

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ Author : $Author: fgerlits $
Version : $Revision: 1.8 $ Version : $Revision: 1.9 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/LiveModeWindow.cxx,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/LiveModeWindow.cxx,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -35,6 +35,7 @@
#include <iostream> #include <iostream>
#include <stdexcept> #include <stdexcept>
#include <glibmm.h>
#include "LiveSupport/Widgets/WidgetFactory.h" #include "LiveSupport/Widgets/WidgetFactory.h"
#include "SchedulePlaylistWindow.h" #include "SchedulePlaylistWindow.h"
@ -81,16 +82,13 @@ LiveModeWindow :: LiveModeWindow (Ptr<GLiveSupport>::Ref gLiveSupport,
// ... and the tree view: // ... and the tree view:
treeView = Gtk::manage(widgetFactory->createTreeView(treeModel)); treeView = Gtk::manage(widgetFactory->createTreeView(treeModel));
treeView->set_headers_visible(false);
// Add the TreeView's view columns: // Add the TreeView's view columns:
try { try {
treeView->appendCenteredColumn("", modelColumns.numberColumn, 50);
treeView->appendColumn("", WidgetFactory::hugePlayButton, 82); treeView->appendColumn("", WidgetFactory::hugePlayButton, 82);
treeView->appendColumn(*getResourceUstring("titleColumnLabel"), treeView->appendColumn("", modelColumns.infoColumn, 200);
modelColumns.titleColumn, 200);
treeView->appendColumn(*getResourceUstring("creatorColumnLabel"),
modelColumns.creatorColumn, 200);
treeView->appendColumn(*getResourceUstring("lengthColumnLabel"),
modelColumns.lengthColumn, 120);
} catch (std::invalid_argument &e) { } catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl; std::cerr << e.what() << std::endl;
std::exit(1); std::exit(1);
@ -157,12 +155,46 @@ LiveModeWindow :: addItem(Ptr<Playable>::Ref playable) throw ()
Gtk::TreeModel::Row row = *(treeModel->append()); Gtk::TreeModel::Row row = *(treeModel->append());
row[modelColumns.playableColumn] = playable; row[modelColumns.playableColumn] = playable;
row[modelColumns.titleColumn] = *playable->getTitle();
Ptr<Glib::ustring>::Ref numberString(new Glib::ustring);
numberString->append("<span size=\"larger\" weight=\"ultrabold\">");
std::stringstream numberStr;
numberStr << (rowNumber + 2);
numberString->append(numberStr.str());
numberString->append("</span>");
row[modelColumns.numberColumn] = *numberString;
Ptr<Glib::ustring>::Ref infoString(new Glib::ustring);
infoString->append("<span size=\"larger\" weight=\"bold\">");
infoString->append(Glib::Markup::escape_text(*playable->getTitle()));
infoString->append("</span>");
// TODO: rewrite this using the Core::Metadata class
Ptr<Glib::ustring>::Ref Ptr<Glib::ustring>::Ref
creator = playable->getMetadata("dc:creator"); creator = playable->getMetadata("dc:creator");
row[modelColumns.creatorColumn] = creator ? *creator : ""; if (creator) {
row[modelColumns.lengthColumn] = to_simple_string( infoString->append("\n<span weight=\"bold\">");
*playable->getPlaylength() ); infoString->append(Glib::Markup::escape_text(*creator));
infoString->append("</span>");
}
Ptr<Glib::ustring>::Ref
album = playable->getMetadata("dc:source");
if (album) {
infoString->append("\n<span weight=\"bold\">");
infoString->append(Glib::Markup::escape_text(*album));
infoString->append("</span>");
}
infoString->append("\nduration: ");
infoString->append(to_simple_string(*playable->getPlaylength()));
row[modelColumns.infoColumn] = *infoString;
row[modelColumns.rowNumberColumn] = rowNumber; row[modelColumns.rowNumberColumn] = rowNumber;
} }

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ Author : $Author: fgerlits $
Version : $Revision: 1.7 $ Version : $Revision: 1.8 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/LiveModeWindow.h,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/LiveModeWindow.h,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -73,7 +73,7 @@ using namespace LiveSupport::Widgets;
* playlists. * playlists.
* *
* @author $Author: fgerlits $ * @author $Author: fgerlits $
* @version $Revision: 1.7 $ * @version $Revision: 1.8 $
*/ */
class LiveModeWindow : public WhiteWindow, public LocalizedObject class LiveModeWindow : public WhiteWindow, public LocalizedObject
{ {
@ -86,7 +86,7 @@ class LiveModeWindow : public WhiteWindow, public LocalizedObject
* Lists one clip per row. * Lists one clip per row.
* *
* @author $Author: fgerlits $ * @author $Author: fgerlits $
* @version $Revision: 1.7 $ * @version $Revision: 1.8 $
*/ */
class ModelColumns : public ZebraTreeModelColumnRecord class ModelColumns : public ZebraTreeModelColumnRecord
{ {
@ -96,6 +96,11 @@ class LiveModeWindow : public WhiteWindow, public LocalizedObject
*/ */
Gtk::TreeModelColumn<Ptr<Playable>::Ref> playableColumn; Gtk::TreeModelColumn<Ptr<Playable>::Ref> playableColumn;
/**
* The column for the big row number display.
*/
Gtk::TreeModelColumn<Glib::ustring> numberColumn;
/** /**
* The column for the play button. * The column for the play button.
*/ */
@ -103,19 +108,9 @@ class LiveModeWindow : public WhiteWindow, public LocalizedObject
playButtonColumn; playButtonColumn;
/** /**
* The column for the title of the audio clip or playlist. * The column for the title, creator, etc.
*/ */
Gtk::TreeModelColumn<Glib::ustring> titleColumn; Gtk::TreeModelColumn<Glib::ustring> infoColumn;
/**
* The column for the creator of the audio clip or playlist.
*/
Gtk::TreeModelColumn<Glib::ustring> creatorColumn;
/**
* The column for the length of the audio clip or playlist.
*/
Gtk::TreeModelColumn<Glib::ustring> lengthColumn;
/** /**
* Constructor. * Constructor.
@ -123,10 +118,9 @@ class LiveModeWindow : public WhiteWindow, public LocalizedObject
ModelColumns(void) throw () ModelColumns(void) throw ()
{ {
add(playableColumn); add(playableColumn);
add(numberColumn);
add(playButtonColumn); add(playButtonColumn);
add(titleColumn); add(infoColumn);
add(creatorColumn);
add(lengthColumn);
} }
}; };

View file

@ -179,10 +179,6 @@ hu:table
{ {
windowTitle:string { "LiveSupport Élő adás ablak" } windowTitle:string { "LiveSupport Élő adás ablak" }
titleColumnLabel:string { "Cím" }
creatorColumnLabel:string { "Előadó" }
lengthColumnLabel:string { "Hossz" }
cueMenuItem:string { "Bele_hallgatni" } cueMenuItem:string { "Bele_hallgatni" }
upMenuItem:string { "_Fel" } upMenuItem:string { "_Fel" }
downMenuItem:string { "_Le" } downMenuItem:string { "_Le" }

View file

@ -181,10 +181,6 @@ root:table
{ {
windowTitle:string { "LiveSupport Live Mode Window" } windowTitle:string { "LiveSupport Live Mode Window" }
titleColumnLabel:string { "Title" }
creatorColumnLabel:string { "Creator" }
lengthColumnLabel:string { "Length" }
cueMenuItem:string { "_Cue" } cueMenuItem:string { "_Cue" }
upMenuItem:string { "Move _Up" } upMenuItem:string { "Move _Up" }
downMenuItem:string { "Move D_own" } downMenuItem:string { "Move D_own" }