From 9dc21270a2d8946df38d778045f9277d9593c12a Mon Sep 17 00:00:00 2001 From: tchernobog Date: Sat, 18 Mar 2006 10:50:16 +0000 Subject: [PATCH] - Make GUI a little bit more responsive. Still doesn't scroll to the end of output - Use GraphicalTerminalIO::read_command into GraphicalTerminalIO::onSend() as per specs (fixes a program crash) git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@552 3ecf2c5c-341e-0410-92b4-d18e462d057c --- ChangeLog | 31 +++++++++++++++++++++++++++++++ src/graphical_terminal_io.cc | 16 +++++++++------- src/graphical_terminal_io.hh | 4 +++- src/parse_opts.cc | 11 ++++++----- 4 files changed, 49 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index 624b0de..1ea1e4f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,34 @@ +2006-03-10 15:21 tchernobog + + * trunk/src/backend/pyloader/ScriptAdapter.py, + trunk/src/backend/pyloader/python_policy.cc: - Finish fix for + return values in PythonPolicy - Put mutex and global _ret_val + variable into ScriptAdapter instead of the global space, space + which is anyway not accessible after decref'ing the corresponding + python module + +2006-03-10 15:08 jinx + + * trunk/doc/sgpem2uman.texi: essageMinor correcions + +2006-03-10 14:54 tchernobog + + * trunk/src/backend/pyloader/ScriptAdapter.py, + trunk/src/backend/pyloader/python_policy.cc, + trunk/src/backend/pyloader/python_policy.hh, + trunk/src/builtin-policies/fcfs.py, trunk/src/simulation.cc: - + Partial attempt at fixing PythonPolicies broken return values + +2006-03-10 14:46 jinx + + * trunk/doc/sgpem2uman.texi: essageAdded chapter Writing new + policies + +2006-03-10 11:38 tchernobog + + * trunk/ChangeLog, trunk/src/backend/pyloader/python_policy.cc: - + Fix bug with retval not treated as a bool value in wait_unlock() + 2006-03-10 03:20 jinx * trunk/doc/sgpem2uman.texi: Added chapters Overview of SGPEM and diff --git a/src/graphical_terminal_io.cc b/src/graphical_terminal_io.cc index 40ad1d9..b6bb035 100644 --- a/src/graphical_terminal_io.cc +++ b/src/graphical_terminal_io.cc @@ -37,7 +37,6 @@ using namespace sgpem; using namespace std; using Glib::ustring; -using Glib::Thread; GraphicalTerminalIO::GraphicalTerminalIO(TextSimulation* sim) : _sim(sim) @@ -84,22 +83,22 @@ GraphicalTerminalIO::~GraphicalTerminalIO() void GraphicalTerminalIO::onSend() { + using Glib::Thread; pair, const ustring> p( pair(_sim, this), - _text_input.get_text()); + read_command()); Thread::create(sigc::bind(&TextSimulation::parse_command, p), true); - - _text_input.set_text(""); - _text_input.grab_focus(); } uint GraphicalTerminalIO::write_buffer(const Glib::ustring& buffer) { - Gtk::TextBuffer::iterator i = _text_output.get_buffer()->end(); - _text_output.get_buffer()->insert(i, buffer); + Glib::Mutex::Lock lock(_mtx); + + Glib::RefPtr txbuf = _text_output.get_buffer(); + txbuf->insert_at_cursor(buffer); // Force the UI update queue to flush // while(Gtk::Main::instance()->events_pending()) @@ -127,6 +126,9 @@ GraphicalTerminalIO::read_command() uint l = command.find_last_not_of(whitespaces); if(f == ustring::npos) return ""; + + _text_input.set_text(""); + _text_input.grab_focus(); return command.substr(f,l-f+1); } diff --git a/src/graphical_terminal_io.hh b/src/graphical_terminal_io.hh index 9bf1a17..fb14ea1 100644 --- a/src/graphical_terminal_io.hh +++ b/src/graphical_terminal_io.hh @@ -28,6 +28,7 @@ #include #include #include +#include #include #include "io_manager.hh" @@ -89,9 +90,10 @@ namespace sgpem { void onSend(); private: - TextSimulation* _sim; + TextSimulation* _sim; Gtk::TextView _text_output; mutable Gtk::Entry _text_input; + Glib::Mutex _mtx; }; } diff --git a/src/parse_opts.cc b/src/parse_opts.cc index 6aefd23..a2ee50b 100644 --- a/src/parse_opts.cc +++ b/src/parse_opts.cc @@ -93,7 +93,8 @@ parse_options(int& argc, char**& argv) default : display_help(); } - } while( opt != -1 ); + } + while( opt != -1 ); // Set these two to start from additional filenames on the cmdline: argc -= optind; @@ -105,7 +106,7 @@ void display_help() { printf( _("SGPEMv2 is an educational software acting as a process scheduling simulator\n" - "\n\nUsage : sgpemv2 [options]" // filenames" + "\n\nUsage : sgpemv2 [options] filename" "\n\nOptions:\n" "\t-h, --help this help you're reading\n" "\t-N, --no-gui starts the program in command line mode\n" @@ -115,9 +116,9 @@ display_help() "\t-M dir, --modules-dir=dir\n" "\t add this directory to default plugin\n" "\t search path\n" - "\nFilenames:\n" - "\t a list of any valid SGPEMv2 XML file\n" - "\t to be opened, space-separated.\n" + "\nFilename:\n" + "\t a valid SGPEMv2 XML file\n" + "\t to be opened.\n" "\nLong options are available only on GNU systems.\n\n" ) ); exit(0); }