lumiera_/gui/src/workspace/actions.cpp

137 lines
4.2 KiB
C++
Raw Normal View History

2008-04-11 21:28:15 +02:00
/*
Actions.cpp - Definition of the main workspace window object
Copyright (C) Lumiera.org
2008, Joel Holdsworth <joel@airwebreathe.org.uk>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
* *****************************************************/
2008-04-11 21:28:15 +02:00
#include "../gtk-lumiera.hpp"
2008-04-11 21:28:15 +02:00
#include "actions.hpp"
#include "main-window.hpp"
2008-04-11 21:28:15 +02:00
namespace lumiera {
namespace gui {
namespace workspace {
2008-04-11 21:28:15 +02:00
Actions::Actions(MainWindow &main_window) :
mainWindow(main_window)
{
actionGroup = Gtk::ActionGroup::create();
2008-04-11 21:28:15 +02:00
// File|New sub menu:
actionGroup->add(Gtk::Action::create("FileNewStandard",
2008-04-11 21:28:15 +02:00
Gtk::Stock::NEW, "_New", "Create a new file"),
sigc::mem_fun(*this, &Actions::on_menu_file_new_generic));
actionGroup->add(Gtk::Action::create("FileNewFoo",
2008-04-11 21:28:15 +02:00
Gtk::Stock::NEW, "New Foo", "Create a new foo"),
sigc::mem_fun(*this, &Actions::on_menu_file_new_generic));
actionGroup->add(Gtk::Action::create("FileNewGoo",
2008-04-11 21:28:15 +02:00
Gtk::Stock::NEW, "_New Goo", "Create a new goo"),
sigc::mem_fun(*this, &Actions::on_menu_file_new_generic));
// File menu:
actionGroup->add(Gtk::Action::create("FileMenu", "File"));
2008-04-11 21:28:15 +02:00
// Sub-menu.
actionGroup->add(Gtk::Action::create("FileNew", Gtk::Stock::NEW));
actionGroup->add(Gtk::Action::create("FileRender", _("Render...")),
Gtk::AccelKey("<shift>R"),
sigc::mem_fun(*this, &Actions::on_menu_file_render));
actionGroup->add(Gtk::Action::create("FileQuit", Gtk::Stock::QUIT),
sigc::mem_fun(*this, &Actions::on_menu_file_quit));
2008-04-11 21:28:15 +02:00
// Edit menu:
actionGroup->add(Gtk::Action::create("EditMenu", "Edit"));
actionGroup->add(Gtk::Action::create("EditCopy", Gtk::Stock::COPY),
2008-04-11 21:28:15 +02:00
sigc::mem_fun(*this, &Actions::on_menu_others));
actionGroup->add(Gtk::Action::create("EditPaste", Gtk::Stock::PASTE),
2008-04-11 21:28:15 +02:00
sigc::mem_fun(*this, &Actions::on_menu_others));
actionGroup->add(Gtk::Action::create("EditSomething", "Something"),
Gtk::AccelKey("<control><alt>S"),
sigc::mem_fun(*this, &Actions::on_menu_others));
2008-04-11 21:28:15 +02:00
// Choices menu, to demonstrate Radio items
actionGroup->add( Gtk::Action::create("ChoicesMenu", "Choices") );
2008-04-11 21:28:15 +02:00
Gtk::RadioAction::Group group_userlevel;
m_refChoiceOne = Gtk::RadioAction::create(group_userlevel, "ChoiceOne", "One");
actionGroup->add(m_refChoiceOne,
2008-04-11 21:28:15 +02:00
sigc::mem_fun(*this, &Actions::on_menu_choices_one) );
m_refChoiceTwo = Gtk::RadioAction::create(group_userlevel, "ChoiceTwo", "Two");
actionGroup->add(m_refChoiceTwo,
2008-04-11 21:28:15 +02:00
sigc::mem_fun(*this, &Actions::on_menu_choices_two) );
// Help menu:
actionGroup->add( Gtk::Action::create("HelpMenu", "Help") );
actionGroup->add( Gtk::Action::create("HelpAbout", Gtk::Stock::HELP),
2008-04-11 21:28:15 +02:00
sigc::mem_fun(*this, &Actions::on_menu_others) );
}
2008-04-11 21:28:15 +02:00
void
Actions::on_menu_file_render()
{
application().get_render_dialog()->run();
}
void
Actions::on_menu_file_quit()
{
mainWindow.hide(); // Closes the main window to stop the Gtk::Main::run().
}
2008-04-11 21:28:15 +02:00
void
Actions::on_menu_file_new_generic()
{
2008-04-11 21:28:15 +02:00
g_message("A File|New menu item was selecteda.");
}
2008-04-11 21:28:15 +02:00
void
Actions::on_menu_others()
{
2008-04-11 21:28:15 +02:00
g_message("A menu item was selected.");
}
2008-04-11 21:28:15 +02:00
void
Actions::on_menu_choices_one()
{
2008-04-11 21:28:15 +02:00
Glib::ustring message;
//if(m_refChoiceOne->get_active())
// message = "Choice 1 was selected.";
//else
message = "Choice 1 was deselected";
g_message(message.c_str());
}
2008-04-11 21:28:15 +02:00
void
Actions::on_menu_choices_two()
{
2008-04-11 21:28:15 +02:00
Glib::ustring message;
//if(_main_window.m_refChoiceTwo->get_active())
// message = "Choice 2 was selected.";
//else
message = "Choice 2 was deselected";
g_message(message.c_str());
}
2008-04-11 21:28:15 +02:00
} // namespace workspace
} // namespace gui
} // namespace lumiera
2008-04-11 21:28:15 +02:00