gave a facelift to SimplePlaylistManagementWindow

This commit is contained in:
fgerlits 2005-05-21 19:05:25 +00:00
parent d751df9404
commit 6601609ed4
6 changed files with 117 additions and 80 deletions

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ Author : $Author: fgerlits $
Version : $Revision: 1.19 $ Version : $Revision: 1.20 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/include/LiveSupport/Widgets/WidgetFactory.h,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/include/LiveSupport/Widgets/WidgetFactory.h,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -89,7 +89,7 @@ class ZebraTreeView;
* </code></pre> * </code></pre>
* *
* @author $Author: fgerlits $ * @author $Author: fgerlits $
* @version $Revision: 1.19 $ * @version $Revision: 1.20 $
*/ */
class WidgetFactory : class WidgetFactory :
virtual public Configurable virtual public Configurable
@ -116,7 +116,8 @@ class WidgetFactory :
typedef enum { resizeImage, typedef enum { resizeImage,
scratchpadWindowTitleImage, scratchpadWindowTitleImage,
searchWindowTitleImage, searchWindowTitleImage,
liveModeWindowTitleImage } liveModeWindowTitleImage,
playlistsWindowTitleImage }
ImageType; ImageType;

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ Author : $Author: fgerlits $
Version : $Revision: 1.21 $ Version : $Revision: 1.22 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/src/WidgetFactory.cxx,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/src/WidgetFactory.cxx,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -261,6 +261,12 @@ static const std::string searchWindowTitleImageName
static const std::string liveModeWindowTitleImageName static const std::string liveModeWindowTitleImageName
= "titleImages/liveModeWindowTitle.png"; = "titleImages/liveModeWindowTitle.png";
/**
* The name of the image for the title of the playlist editor window.
*/
static const std::string playlistsWindowTitleImageName
= "titleImages/playlistsWindowTitle.png";
/* =============================================== local function prototypes */ /* =============================================== local function prototypes */
@ -500,6 +506,10 @@ WidgetFactory :: createImage(ImageType imageName) throw ()
rawImage = loadImage(liveModeWindowTitleImageName); rawImage = loadImage(liveModeWindowTitleImageName);
break; break;
case playlistsWindowTitleImage:
rawImage = loadImage(playlistsWindowTitleImageName);
break;
default: default:
return 0; return 0;
} }

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/Attic/PlaylistListWindow.cxx,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/Attic/PlaylistListWindow.cxx,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -63,10 +63,12 @@ PlaylistListWindow :: PlaylistListWindow (
Ptr<GLiveSupport>::Ref gLiveSupport, Ptr<GLiveSupport>::Ref gLiveSupport,
Ptr<ResourceBundle>::Ref bundle) Ptr<ResourceBundle>::Ref bundle)
throw () throw ()
: LocalizedObject(bundle) : WhiteWindow(WidgetFactory::liveModeWindowTitleImage,
Colors::White,
WidgetFactory::getInstance()->getWhiteWindowCorners()),
LocalizedObject(bundle),
gLiveSupport(gLiveSupport)
{ {
this->gLiveSupport = gLiveSupport;
// get localized resources // get localized resources
try { try {
set_title(*getResourceUstring("windowTitle")); set_title(*getResourceUstring("windowTitle"));

View file

@ -21,8 +21,8 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author: maroy $ Author : $Author: fgerlits $
Version : $Revision: 1.5 $ Version : $Revision: 1.6 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/Attic/PlaylistListWindow.h,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/Attic/PlaylistListWindow.h,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -48,6 +48,7 @@
#include "LiveSupport/Core/Ptr.h" #include "LiveSupport/Core/Ptr.h"
#include "LiveSupport/Core/LocalizedObject.h" #include "LiveSupport/Core/LocalizedObject.h"
#include "LiveSupport/Widgets/WhiteWindow.h"
#include "GLiveSupport.h" #include "GLiveSupport.h"
namespace LiveSupport { namespace LiveSupport {
@ -83,10 +84,10 @@ using namespace LiveSupport::Core;
* +---------------------------------------------------------------+ * +---------------------------------------------------------------+
* </pre></code> * </pre></code>
* *
* @author $Author: maroy $ * @author $Author: fgerlits $
* @version $Revision: 1.5 $ * @version $Revision: 1.6 $
*/ */
class PlaylistListWindow : public Gtk::Window, public LocalizedObject class PlaylistListWindow : public WhiteWindow, public LocalizedObject
{ {
private: private:
@ -119,8 +120,8 @@ class PlaylistListWindow : public Gtk::Window, public LocalizedObject
* The model columns, for the playlist window. * The model columns, for the playlist window.
* Lists one playlist per row. * Lists one playlist per row.
* *
* @author $Author: maroy $ * @author $Author: fgerlits $
* @version $Revision: 1.5 $ * @version $Revision: 1.6 $
*/ */
class ModelColumns : public Gtk::TreeModel::ColumnRecord class ModelColumns : public Gtk::TreeModel::ColumnRecord
{ {

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/products/gLiveSupport/src/SimplePlaylistManagementWindow.cxx,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/SimplePlaylistManagementWindow.cxx,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -42,6 +42,7 @@
using namespace Glib; using namespace Glib;
using namespace LiveSupport::Core; using namespace LiveSupport::Core;
using namespace LiveSupport::Widgets;
using namespace LiveSupport::GLiveSupport; using namespace LiveSupport::GLiveSupport;
/* =================================================== local data structures */ /* =================================================== local data structures */
@ -62,17 +63,20 @@ SimplePlaylistManagementWindow :: SimplePlaylistManagementWindow (
Ptr<GLiveSupport>::Ref gLiveSupport, Ptr<GLiveSupport>::Ref gLiveSupport,
Ptr<ResourceBundle>::Ref bundle) Ptr<ResourceBundle>::Ref bundle)
throw () throw ()
: LocalizedObject(bundle) : WhiteWindow(WidgetFactory::playlistsWindowTitleImage,
Colors::White,
WidgetFactory::getInstance()->getWhiteWindowCorners()),
LocalizedObject(bundle),
gLiveSupport(gLiveSupport)
{ {
this->gLiveSupport = gLiveSupport; Ptr<WidgetFactory>::Ref wf = WidgetFactory::getInstance();
try { try {
set_title(*getResourceUstring("windowTitle")); nameLabel = Gtk::manage(new Gtk::Label(
nameLabel = Gtk::manage(new Gtk::Label(*getResourceUstring( *getResourceUstring("nameLabel")));
"nameLabel"))); saveButton = Gtk::manage(wf->createButton(
saveButton = Gtk::manage(new Gtk::Button(
*getResourceUstring("saveButtonLabel"))); *getResourceUstring("saveButtonLabel")));
closeButton = Gtk::manage(new Gtk::Button( closeButton = Gtk::manage(wf->createButton(
*getResourceUstring("closeButtonLabel"))); *getResourceUstring("closeButtonLabel")));
} catch (std::invalid_argument &e) { } catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl; std::cerr << e.what() << std::endl;
@ -81,25 +85,22 @@ SimplePlaylistManagementWindow :: SimplePlaylistManagementWindow (
nameEntry = Gtk::manage(new Gtk::Entry()); nameEntry = Gtk::manage(new Gtk::Entry());
entriesScrolledWindow = Gtk::manage(new Gtk::ScrolledWindow()); entriesScrolledWindow = Gtk::manage(new Gtk::ScrolledWindow());
entriesView = Gtk::manage(new Gtk::TreeView()); entriesModel = Gtk::ListStore::create(modelColumns);
entriesView = Gtk::manage(wf->createTreeView(entriesModel));
// set up the entry scrolled window, with the entry treeview inside. // set up the entry scrolled window, with the entry treeview inside.
entriesScrolledWindow->add(*entriesView); entriesScrolledWindow->add(*entriesView);
entriesScrolledWindow->set_policy(Gtk::POLICY_AUTOMATIC, entriesScrolledWindow->set_policy(Gtk::POLICY_AUTOMATIC,
Gtk::POLICY_AUTOMATIC); Gtk::POLICY_AUTOMATIC);
// Create the Tree model:
entriesModel = Gtk::ListStore::create(modelColumns);
entriesView->set_model(entriesModel);
// Add the TreeView's view columns: // Add the TreeView's view columns:
try { try {
entriesView->append_column(*getResourceUstring("startColumnLabel"), entriesView->appendColumn(*getResourceUstring("startColumnLabel"),
modelColumns.startColumn); modelColumns.startColumn, 120);
entriesView->append_column(*getResourceUstring("titleColumnLabel"), entriesView->appendColumn(*getResourceUstring("titleColumnLabel"),
modelColumns.titleColumn); modelColumns.titleColumn, 200);
entriesView->append_column(*getResourceUstring("lengthColumnLabel"), entriesView->appendColumn(*getResourceUstring("lengthColumnLabel"),
modelColumns.lengthColumn); modelColumns.lengthColumn, 120);
statusBar = Gtk::manage(new Gtk::Label( statusBar = Gtk::manage(new Gtk::Label(
*getResourceUstring("statusBar"))); *getResourceUstring("statusBar")));
@ -109,17 +110,32 @@ SimplePlaylistManagementWindow :: SimplePlaylistManagementWindow (
} }
// set up the layout // set up the layout
layout = Gtk::manage(new Gtk::Table()); Gtk::VBox * mainBox = Gtk::manage(new Gtk::VBox);
Gtk::HBox * nameBox = Gtk::manage(new Gtk::HBox);
nameBox->pack_start(*nameLabel, Gtk::PACK_SHRINK, 10);
Gtk::Alignment * nameEntryAlignment = Gtk::manage(new Gtk::Alignment(
Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER,
0.7)); // take up 70% of available room
nameEntryAlignment->add(*nameEntry);
nameBox->pack_start(*nameEntryAlignment, Gtk::PACK_EXPAND_WIDGET, 5);
mainBox->pack_start(*nameBox, Gtk::PACK_SHRINK, 5);
set_border_width(10); mainBox->pack_start(*entriesScrolledWindow, Gtk::PACK_EXPAND_WIDGET, 5);
layout->attach(*nameLabel, 0, 1, 0, 1);
layout->attach(*nameEntry, 1, 2, 0, 1); Gtk::ButtonBox * buttonBox = Gtk::manage(new Gtk::HButtonBox(
layout->attach(*entriesScrolledWindow, 0, 2, 1, 2); Gtk::BUTTONBOX_END, 5));
layout->attach(*saveButton, 1, 2, 2, 3); buttonBox->pack_start(*saveButton);
layout->attach(*closeButton, 1, 2, 3, 4); buttonBox->pack_start(*closeButton);
layout->attach(*statusBar, 0, 2, 4, 5); mainBox->pack_start(*buttonBox, Gtk::PACK_SHRINK, 0);
Gtk::Alignment * statusBarAlignment = Gtk::manage(new Gtk::Alignment(
Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER,
0.0)); // do not expand the label
statusBarAlignment->add(*statusBar);
mainBox->pack_start(*statusBarAlignment, Gtk::PACK_SHRINK, 5);
add(*layout); add(*mainBox);
// Register the signal handlers // Register the signal handlers
saveButton->signal_clicked().connect(sigc::mem_fun(*this, saveButton->signal_clicked().connect(sigc::mem_fun(*this,
@ -127,7 +143,12 @@ SimplePlaylistManagementWindow :: SimplePlaylistManagementWindow (
closeButton->signal_clicked().connect(sigc::mem_fun(*this, closeButton->signal_clicked().connect(sigc::mem_fun(*this,
&SimplePlaylistManagementWindow::onCloseButtonClicked)); &SimplePlaylistManagementWindow::onCloseButtonClicked));
// show all // show
set_name("simplePlaylistManagementWindow");
set_default_size(450, 300);
set_modal(false);
property_window_position().set_value(Gtk::WIN_POS_NONE);
show_all(); show_all();
} }
@ -196,29 +217,32 @@ SimplePlaylistManagementWindow :: onCloseButtonClicked (void) throw ()
void void
SimplePlaylistManagementWindow :: showContents(void) throw () SimplePlaylistManagementWindow :: showContents(void) throw ()
{ {
Ptr<Playlist>::Ref playlist; Ptr<Playlist>::Ref playlist;
Playlist::const_iterator it; Playlist::const_iterator it;
Playlist::const_iterator end; Playlist::const_iterator end;
int rowNumber;
playlist = gLiveSupport->getEditedPlaylist(); playlist = gLiveSupport->getEditedPlaylist();
if (playlist) { if (playlist) {
it = playlist->begin();
end = playlist->end();
entriesModel->clear(); entriesModel->clear();
while (it != end) { rowNumber = 0;
Ptr<PlaylistElement>::Ref playlistElem = it->second; for (it = playlist->begin(); it != playlist->end(); ++it) {
Ptr<Playable>::Ref playable = playlistElem->getPlayable(); Ptr<PlaylistElement>::Ref
Gtk::TreeModel::Row row = *(entriesModel->append()); playlistElem = it->second;
Ptr<Playable>::Ref playable = playlistElem->getPlayable();
Gtk::TreeModel::Row row = *(entriesModel->append());
row[modelColumns.idColumn] = playable->getId(); row[modelColumns.rowNumberColumn]
row[modelColumns.startColumn] = = rowNumber++;
to_simple_string(*playlistElem->getRelativeOffset()); row[modelColumns.idColumn]
row[modelColumns.titleColumn] = *playable->getTitle(); = playable->getId();
row[modelColumns.lengthColumn] = row[modelColumns.startColumn]
to_simple_string(*playable->getPlaylength()); = to_simple_string(*playlistElem->getRelativeOffset());
row[modelColumns.titleColumn]
it++; = *playable->getTitle();
row[modelColumns.lengthColumn]
= to_simple_string(*playable->getPlaylength());
} }
} }
} }

View file

@ -21,8 +21,8 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author: maroy $ Author : $Author: fgerlits $
Version : $Revision: 1.3 $ Version : $Revision: 1.4 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/SimplePlaylistManagementWindow.h,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/SimplePlaylistManagementWindow.h,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -48,12 +48,16 @@
#include "LiveSupport/Core/Ptr.h" #include "LiveSupport/Core/Ptr.h"
#include "LiveSupport/Core/LocalizedObject.h" #include "LiveSupport/Core/LocalizedObject.h"
#include "LiveSupport/Widgets/WhiteWindow.h"
#include "LiveSupport/Widgets/ZebraTreeModelColumnRecord.h"
#include "LiveSupport/Widgets/ZebraTreeView.h"
#include "GLiveSupport.h" #include "GLiveSupport.h"
namespace LiveSupport { namespace LiveSupport {
namespace GLiveSupport { namespace GLiveSupport {
using namespace LiveSupport::Core; using namespace LiveSupport::Core;
using namespace LiveSupport::Widgets;
/* ================================================================ constants */ /* ================================================================ constants */
@ -82,10 +86,10 @@ using namespace LiveSupport::Core;
* +----------------------------------------------+ * +----------------------------------------------+
* </code></pre> * </code></pre>
* *
* @author $Author: maroy $ * @author $Author: fgerlits $
* @version $Revision: 1.3 $ * @version $Revision: 1.4 $
*/ */
class SimplePlaylistManagementWindow : public Gtk::Window, class SimplePlaylistManagementWindow : public WhiteWindow,
public LocalizedObject public LocalizedObject
{ {
@ -95,10 +99,10 @@ class SimplePlaylistManagementWindow : public Gtk::Window,
* The columns model needed by Gtk::TreeView. * The columns model needed by Gtk::TreeView.
* Lists one playlist entry per row. * Lists one playlist entry per row.
* *
* @author $Author: maroy $ * @author $Author: fgerlits $
* @version $Revision: 1.3 $ * @version $Revision: 1.4 $
*/ */
class ModelColumns : public Gtk::TreeModel::ColumnRecord class ModelColumns : public ZebraTreeModelColumnRecord
{ {
public: public:
/** /**
@ -144,11 +148,6 @@ class SimplePlaylistManagementWindow : public Gtk::Window,
*/ */
ModelColumns modelColumns; ModelColumns modelColumns;
/**
* The layout used in the window.
*/
Gtk::Table * layout;
/** /**
* The label for the name entry. * The label for the name entry.
*/ */
@ -162,27 +161,27 @@ class SimplePlaylistManagementWindow : public Gtk::Window,
/** /**
* A scrolled window, so that the entry list can be scrolled. * A scrolled window, so that the entry list can be scrolled.
*/ */
Gtk::ScrolledWindow * entriesScrolledWindow; Gtk::ScrolledWindow * entriesScrolledWindow;
/** /**
* The entry tree view, now only showing rows. * The entry tree view, now only showing rows.
*/ */
Gtk::TreeView * entriesView; ZebraTreeView * entriesView;
/** /**
* The entry tree model, as a GTK reference. * The entry tree model, as a GTK reference.
*/ */
Glib::RefPtr<Gtk::ListStore> entriesModel; Glib::RefPtr<Gtk::ListStore> entriesModel;
/** /**
* The save button. * The save button.
*/ */
Gtk::Button * saveButton; Button * saveButton;
/** /**
* The close button. * The close button.
*/ */
Gtk::Button * closeButton; Button * closeButton;
/** /**
* The status bar. * The status bar.