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:
parent
e34b70004a
commit
bae91ba90b
|
@ -347,6 +347,7 @@ bin_PROGRAMS += sgpemv2
|
|||
sgpemv2_CPPFLAGS = \
|
||||
-I@top_srcdir@ \
|
||||
-I@top_srcdir@/src/backend \
|
||||
-DEXAMPLESDIR="\"$(examplesdir)\"" \
|
||||
-DLOCALEDIR="\"$(localedir)\"" \
|
||||
-DSHAREDIR="\"$(sharedir)\"" \
|
||||
-DUIDIR="\"$(uidir)\"" \
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -34,6 +34,12 @@
|
|||
<property name="name">Action.File.Open</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkAction" id="Action.File.OpenExample">
|
||||
<property name="name">Action.File.OpenExample</property>
|
||||
<property name="label">Open E_xample</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkAction" id="Action.File.Save">
|
||||
<property name="stock_id">gtk-save</property>
|
||||
|
@ -142,6 +148,7 @@
|
|||
<menu action="Action.File">
|
||||
<menuitem action="Action.File.New"/>
|
||||
<menuitem action="Action.File.Open"/>
|
||||
<menuitem action="Action.File.OpenExample" />
|
||||
<menuitem action="Action.File.Save"/>
|
||||
<menuitem action="Action.File.SaveAs"/>
|
||||
<separator/>
|
||||
|
|
Loading…
Reference in New Issue