Add menu option to open directly an example (so it's clearer it exists!)

git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@1333 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
tchernobog 2008-12-26 15:28:06 +00:00
parent e34b70004a
commit bae91ba90b
4 changed files with 35 additions and 15 deletions

View file

@ -150,9 +150,25 @@ GuiBuilder::on_file_new_activate()
}
void
GuiBuilder::on_file_open_activate()
{
if (!_filename.empty()) // Please test the following line extensively:
open_file (Glib::path_get_dirname(_filename));
else
open_file ();
}
void
GuiBuilder::on_file_open_example_activate()
{
open_file (EXAMPLESDIR);
}
void
GuiBuilder::open_file(const std::string& basedir)
{
ask_save();
@ -172,9 +188,8 @@ GuiBuilder::on_file_open_activate()
// open file dialog...
Gtk::FileChooserDialog dialog(_("Please choose a file"), Gtk::FILE_CHOOSER_ACTION_OPEN);
dialog.set_transient_for(get_initial_window());
if(!_filename.empty()) // Please test the following line extensively:
dialog.set_current_folder(Glib::path_get_dirname(_filename));
dialog.set_current_folder (basedir);
//Add response buttons the the dialog:
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
dialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK);
@ -227,7 +242,8 @@ GuiBuilder::on_file_open_activate()
_refXml->get_widget("MainStatusBar", sbar);
sbar->push(msg);
}
}
}
void
GuiBuilder::on_file_save_activate()
@ -604,6 +620,10 @@ GuiBuilder::GuiBuilder(const std::string& uifile)
RefPtr<Action>::cast_dynamic (_refXml->get_object("Action.File.Open"))
->signal_activate().connect(sigc::mem_fun(*this, &GuiBuilder::on_file_open_activate));
// file open dialog for examples
RefPtr<Action>::cast_dynamic (_refXml->get_object("Action.File.OpenExample"))
->signal_activate().connect(sigc::mem_fun(*this, &GuiBuilder::on_file_open_example_activate));
// file save dialog
RefPtr<Action>::cast_dynamic (_refXml->get_object("Action.File.Save"))
->signal_activate().connect(sigc::mem_fun(*this, &GuiBuilder::on_file_save_activate));
@ -734,12 +754,3 @@ GuiBuilder::get_initial_window() const
return *main_window;
}
void
GuiBuilder::open_file(const std::string& filename)
{
// FIXME: to be written.
// Debug line (erase me when done):
std::cout << _("Filename to open: ") << filename << std::endl;
}

View file

@ -53,6 +53,7 @@ namespace sgpem
void on_file_new_activate();
void on_file_open_activate();
void on_file_open_example_activate();
void on_file_save_activate();
void on_file_saveas_activate();
@ -70,7 +71,7 @@ namespace sgpem
void on_selected_resource_policy(ResourcePolicy* pol);
void on_toggle_simulation_mode();
void open_file(const std::string& filename);
void open_file(const std::string& basedir = "");
void populate_with_cpu_policies(Gtk::Menu& menu);
void populate_with_resource_policies(Gtk::Menu& menu);