Added a name dialog for track

This commit is contained in:
Joel Holdsworth 2008-12-26 19:51:41 +00:00
parent ea89f27668
commit 7a838fc4eb
8 changed files with 46 additions and 25 deletions

View file

@ -30,8 +30,8 @@ using namespace Glib;
namespace gui {
namespace dialogs {
NameChooser::NameChooser(Window &parent, Glib::ustring title,
Glib::ustring default_name) :
NameChooser::NameChooser(Window &parent, const Glib::ustring title,
const Glib::ustring default_name) :
Dialog::Dialog(title, parent, true),
caption(_("Name:"))
{

View file

@ -46,8 +46,8 @@ public:
* @param default_name The name that will be shown by default in the
* edit box of the dialog.
**/
NameChooser(Gtk::Window &parent, Glib::ustring title,
Glib::ustring default_name);
NameChooser(Gtk::Window &parent, const Glib::ustring title,
const Glib::ustring default_name);
/**
* Gets the current name of the chosen in the dialog.

View file

@ -41,17 +41,5 @@ ParentTrack::get_child_track_list()
return tracks;
}
const Glib::ustring
ParentTrack::get_name() const
{
return name;
}
void
ParentTrack::set_name(const Glib::ustring &name)
{
this->name = name;
}
} // namespace model
} // namespace gui

View file

@ -47,14 +47,6 @@ public:
lumiera::observable_list< boost::shared_ptr<Track> >&
get_child_track_list();
const Glib::ustring get_name() const;
void set_name(const Glib::ustring &name);
private:
//----- Data -----//
Glib::ustring name;
protected:
lumiera::observable_list< boost::shared_ptr<Track> > tracks;

View file

@ -38,5 +38,17 @@ Track::get_child_tracks() const
return Track::NoChildren;
}
const Glib::ustring
Track::get_name() const
{
return name;
}
void
Track::set_name(const Glib::ustring &name)
{
this->name = name;
}
} // namespace model
} // namespace gui

View file

@ -40,6 +40,14 @@ protected:
public:
virtual std::list< boost::shared_ptr<Track> >
get_child_tracks() const;
const Glib::ustring get_name() const;
void set_name(const Glib::ustring &name);
private:
//----- Data -----//
Glib::ustring name;
protected:
static const std::list< boost::shared_ptr<Track> > NoChildren;

View file

@ -26,6 +26,7 @@
#include "timeline-track.hpp"
#include "../timeline-widget.hpp"
#include "../../window-manager.hpp"
#include "../../dialogs/name-chooser.hpp"
using namespace boost;
using namespace Gtk;
@ -65,7 +66,7 @@ Track::Track(TimelineWidget &timeline_widget) :
// Setup the title menu
Menu::MenuList& title_list = titleMenuButton.get_menu().items();
title_list.push_back( Menu_Helpers::MenuElem(_("_Name..."),
mem_fun(this, &Track::on_remove_track) ) );
mem_fun(this, &Track::on_set_name) ) );
// Setup the context menu
Menu::MenuList& context_list = contextMenu.items();
@ -105,6 +106,24 @@ Track::show_header_context_menu(guint button, guint32 time)
contextMenu.popup(button, time);
}
void
Track::on_set_name()
{
shared_ptr<model::Track> model_track =
timelineWidget.lookup_model_track(this);
REQUIRE(model_track);
Gtk::Window *window = dynamic_cast<Window*>(
timelineWidget.get_toplevel());
REQUIRE(window != NULL);
dialogs::NameChooser dialog(*window,
_("Set Track Name"), model_track->get_name());
if(dialog.run() == RESPONSE_OK)
model_track->set_name(dialog.get_name());
}
void
Track::on_remove_track()
{

View file

@ -58,6 +58,8 @@ public:
private:
void on_set_name();
void on_remove_track();