diff --git a/livesupport/modules/widgets/include/LiveSupport/Widgets/ZebraTreeView.h b/livesupport/modules/widgets/include/LiveSupport/Widgets/ZebraTreeView.h index 29f3b1c1f..0f5560925 100644 --- a/livesupport/modules/widgets/include/LiveSupport/Widgets/ZebraTreeView.h +++ b/livesupport/modules/widgets/include/LiveSupport/Widgets/ZebraTreeView.h @@ -22,7 +22,7 @@ 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 $ ------------------------------------------------------------------------------*/ @@ -92,7 +92,7 @@ using namespace LiveSupport::Core; * 3) connected with a TreeModelColumn using set_renderer(). * * @author $Author: fgerlits $ - * @version $Revision: 1.10 $ + * @version $Revision: 1.11 $ */ class ZebraTreeView : public Gtk::TreeView { @@ -158,6 +158,23 @@ class ZebraTreeView : public Gtk::TreeView WidgetFactory::ImageButtonType buttonType, int minimumWidth = 0) 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& modelColumn, + int minimumWidth = 0) + throw (); + }; diff --git a/livesupport/modules/widgets/src/ZebraTreeView.cxx b/livesupport/modules/widgets/src/ZebraTreeView.cxx index 9a9f4be20..29f694bf6 100644 --- a/livesupport/modules/widgets/src/ZebraTreeView.cxx +++ b/livesupport/modules/widgets/src/ZebraTreeView.cxx @@ -22,7 +22,7 @@ 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 $ ------------------------------------------------------------------------------*/ @@ -90,7 +90,7 @@ ZebraTreeView :: appendColumn( Gtk::TreeViewColumn(title, *renderer) ); // 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 viewColumn->set_cell_data_func( @@ -161,3 +161,40 @@ ZebraTreeView :: cellDataFunction(Gtk::CellRenderer* cell, 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& 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); +} + diff --git a/livesupport/products/gLiveSupport/src/LiveModeWindow.cxx b/livesupport/products/gLiveSupport/src/LiveModeWindow.cxx index 796fb2738..836da8ac4 100644 --- a/livesupport/products/gLiveSupport/src/LiveModeWindow.cxx +++ b/livesupport/products/gLiveSupport/src/LiveModeWindow.cxx @@ -22,7 +22,7 @@ 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 $ ------------------------------------------------------------------------------*/ @@ -35,6 +35,7 @@ #include #include +#include #include "LiveSupport/Widgets/WidgetFactory.h" #include "SchedulePlaylistWindow.h" @@ -81,16 +82,13 @@ LiveModeWindow :: LiveModeWindow (Ptr::Ref gLiveSupport, // ... and the tree view: treeView = Gtk::manage(widgetFactory->createTreeView(treeModel)); + treeView->set_headers_visible(false); // Add the TreeView's view columns: try { + treeView->appendCenteredColumn("", modelColumns.numberColumn, 50); treeView->appendColumn("", WidgetFactory::hugePlayButton, 82); - treeView->appendColumn(*getResourceUstring("titleColumnLabel"), - modelColumns.titleColumn, 200); - treeView->appendColumn(*getResourceUstring("creatorColumnLabel"), - modelColumns.creatorColumn, 200); - treeView->appendColumn(*getResourceUstring("lengthColumnLabel"), - modelColumns.lengthColumn, 120); + treeView->appendColumn("", modelColumns.infoColumn, 200); } catch (std::invalid_argument &e) { std::cerr << e.what() << std::endl; std::exit(1); @@ -157,12 +155,46 @@ LiveModeWindow :: addItem(Ptr::Ref playable) throw () Gtk::TreeModel::Row row = *(treeModel->append()); row[modelColumns.playableColumn] = playable; - row[modelColumns.titleColumn] = *playable->getTitle(); + + Ptr::Ref numberString(new Glib::ustring); + + numberString->append(""); + std::stringstream numberStr; + numberStr << (rowNumber + 2); + numberString->append(numberStr.str()); + numberString->append(""); + + row[modelColumns.numberColumn] = *numberString; + + Ptr::Ref infoString(new Glib::ustring); + + infoString->append(""); + infoString->append(Glib::Markup::escape_text(*playable->getTitle())); + infoString->append(""); + + // TODO: rewrite this using the Core::Metadata class + Ptr::Ref creator = playable->getMetadata("dc:creator"); - row[modelColumns.creatorColumn] = creator ? *creator : ""; - row[modelColumns.lengthColumn] = to_simple_string( - *playable->getPlaylength() ); + if (creator) { + infoString->append("\n"); + infoString->append(Glib::Markup::escape_text(*creator)); + infoString->append(""); + } + + Ptr::Ref + album = playable->getMetadata("dc:source"); + if (album) { + infoString->append("\n"); + infoString->append(Glib::Markup::escape_text(*album)); + infoString->append(""); + } + + infoString->append("\nduration: "); + infoString->append(to_simple_string(*playable->getPlaylength())); + + row[modelColumns.infoColumn] = *infoString; + row[modelColumns.rowNumberColumn] = rowNumber; } diff --git a/livesupport/products/gLiveSupport/src/LiveModeWindow.h b/livesupport/products/gLiveSupport/src/LiveModeWindow.h index b8f4d3d9a..7d27d1cca 100644 --- a/livesupport/products/gLiveSupport/src/LiveModeWindow.h +++ b/livesupport/products/gLiveSupport/src/LiveModeWindow.h @@ -22,7 +22,7 @@ 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 $ ------------------------------------------------------------------------------*/ @@ -73,7 +73,7 @@ using namespace LiveSupport::Widgets; * playlists. * * @author $Author: fgerlits $ - * @version $Revision: 1.7 $ + * @version $Revision: 1.8 $ */ class LiveModeWindow : public WhiteWindow, public LocalizedObject { @@ -86,7 +86,7 @@ class LiveModeWindow : public WhiteWindow, public LocalizedObject * Lists one clip per row. * * @author $Author: fgerlits $ - * @version $Revision: 1.7 $ + * @version $Revision: 1.8 $ */ class ModelColumns : public ZebraTreeModelColumnRecord { @@ -96,6 +96,11 @@ class LiveModeWindow : public WhiteWindow, public LocalizedObject */ Gtk::TreeModelColumn::Ref> playableColumn; + /** + * The column for the big row number display. + */ + Gtk::TreeModelColumn numberColumn; + /** * The column for the play button. */ @@ -103,19 +108,9 @@ class LiveModeWindow : public WhiteWindow, public LocalizedObject playButtonColumn; /** - * The column for the title of the audio clip or playlist. + * The column for the title, creator, etc. */ - Gtk::TreeModelColumn titleColumn; - - /** - * The column for the creator of the audio clip or playlist. - */ - Gtk::TreeModelColumn creatorColumn; - - /** - * The column for the length of the audio clip or playlist. - */ - Gtk::TreeModelColumn lengthColumn; + Gtk::TreeModelColumn infoColumn; /** * Constructor. @@ -123,10 +118,9 @@ class LiveModeWindow : public WhiteWindow, public LocalizedObject ModelColumns(void) throw () { add(playableColumn); + add(numberColumn); add(playButtonColumn); - add(titleColumn); - add(creatorColumn); - add(lengthColumn); + add(infoColumn); } }; diff --git a/livesupport/products/gLiveSupport/var/hu.txt b/livesupport/products/gLiveSupport/var/hu.txt index e876d9116..bc996a411 100644 --- a/livesupport/products/gLiveSupport/var/hu.txt +++ b/livesupport/products/gLiveSupport/var/hu.txt @@ -179,10 +179,6 @@ hu:table { windowTitle:string { "LiveSupport Élő adás ablak" } - titleColumnLabel:string { "Cím" } - creatorColumnLabel:string { "Előadó" } - lengthColumnLabel:string { "Hossz" } - cueMenuItem:string { "Bele_hallgatni" } upMenuItem:string { "_Fel" } downMenuItem:string { "_Le" } diff --git a/livesupport/products/gLiveSupport/var/root.txt b/livesupport/products/gLiveSupport/var/root.txt index a965c8a8b..da7381a30 100644 --- a/livesupport/products/gLiveSupport/var/root.txt +++ b/livesupport/products/gLiveSupport/var/root.txt @@ -181,10 +181,6 @@ root:table { windowTitle:string { "LiveSupport Live Mode Window" } - titleColumnLabel:string { "Title" } - creatorColumnLabel:string { "Creator" } - lengthColumnLabel:string { "Length" } - cueMenuItem:string { "_Cue" } upMenuItem:string { "Move _Up" } downMenuItem:string { "Move D_own" }