- Update ac_python_devel macro to integrate advice from Horst
- Improve a little GraphicalTerminalIo git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@461 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
parent
d5565b319f
commit
8c39173c2f
|
@ -30,6 +30,7 @@ dnl @author Alan W. Irwin <irwin@beluga.phys.uvic.ca>
|
||||||
dnl @author Rafael Laboissiere <laboissiere@psy.mpg.de>
|
dnl @author Rafael Laboissiere <laboissiere@psy.mpg.de>
|
||||||
dnl @author Andrew Collier <colliera@nu.ac.za>
|
dnl @author Andrew Collier <colliera@nu.ac.za>
|
||||||
dnl @author Matteo Settenvini <matteo@member.fsf.org>
|
dnl @author Matteo Settenvini <matteo@member.fsf.org>
|
||||||
|
dnl @author Horst Knorr <hk_classes@knoda.org>
|
||||||
dnl @version 2006-02-05
|
dnl @version 2006-02-05
|
||||||
dnl @license GPLWithACException
|
dnl @license GPLWithACException
|
||||||
|
|
||||||
|
@ -183,4 +184,41 @@ $ac_distutils_result])
|
||||||
fi
|
fi
|
||||||
AC_MSG_RESULT([$PYTHON_EXTRA_LDFLAGS])
|
AC_MSG_RESULT([$PYTHON_EXTRA_LDFLAGS])
|
||||||
AC_SUBST(PYTHON_EXTRA_LDFLAGS)
|
AC_SUBST(PYTHON_EXTRA_LDFLAGS)
|
||||||
|
|
||||||
|
#
|
||||||
|
# final check to see if everything compiles alright
|
||||||
|
#
|
||||||
|
AC_MSG_CHECKING([whether collected informations are consistent])
|
||||||
|
AC_LANG_PUSH([C])
|
||||||
|
# save current global flags
|
||||||
|
LIBS="$ac_save_LIBS $PYTHON_LDFLAGS"
|
||||||
|
CPPFLAGS="$ac_save_CPPFLAGS $PYTHON_CPPFLAGS"
|
||||||
|
AC_TRY_LINK([
|
||||||
|
#include <Python.h>
|
||||||
|
],[
|
||||||
|
Py_Initialize();
|
||||||
|
],[pythonexists=yes],[pythonexists=no])
|
||||||
|
|
||||||
|
AC_MSG_RESULT([$pythonexists])
|
||||||
|
|
||||||
|
if test ! "$pythonexists" = "yes"; then
|
||||||
|
AC_MSG_ERROR([
|
||||||
|
Could not link test program to Python. Maybe the main Python library has been
|
||||||
|
installed in some non-standard library path. If so, pass it to configure,
|
||||||
|
via the LDFLAGS environment variable.
|
||||||
|
============================================================================
|
||||||
|
ERROR!
|
||||||
|
You probably have to install the development version of the Python package
|
||||||
|
for your distribution. The exact name of this package varies among them.
|
||||||
|
============================================================================
|
||||||
|
])
|
||||||
|
fi
|
||||||
|
AC_LANG_POP
|
||||||
|
# turn back to default flags
|
||||||
|
CPPFLAGS="$ac_save_CPPFLAGS"
|
||||||
|
LIBS="$ac_save_LIBS"
|
||||||
|
|
||||||
|
#
|
||||||
|
# all done!
|
||||||
|
#
|
||||||
])
|
])
|
||||||
|
|
|
@ -25,10 +25,13 @@
|
||||||
|
|
||||||
#include <glibmm/thread.h>
|
#include <glibmm/thread.h>
|
||||||
#include <gtkmm/button.h>
|
#include <gtkmm/button.h>
|
||||||
|
#include <gtkmm/main.h>
|
||||||
|
#include <gtkmm/scrolledwindow.h>
|
||||||
#include <gtkmm/textview.h>
|
#include <gtkmm/textview.h>
|
||||||
#include <glibmm/ustring.h>
|
#include <glibmm/ustring.h>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <iostream>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
using namespace sgpem;
|
using namespace sgpem;
|
||||||
|
@ -37,36 +40,41 @@ using Glib::ustring;
|
||||||
using Glib::Thread;
|
using Glib::Thread;
|
||||||
|
|
||||||
GraphicalTerminalIO::GraphicalTerminalIO(TextSimulation* sim)
|
GraphicalTerminalIO::GraphicalTerminalIO(TextSimulation* sim)
|
||||||
:_sim(sim)
|
: _sim(sim)
|
||||||
{
|
{
|
||||||
using namespace Gtk;
|
using namespace Gtk;
|
||||||
|
|
||||||
set_title(_("Textual Simulation Log"));
|
set_title(_("Textual Simulation Log"));
|
||||||
set_default_size(500,300);
|
set_default_size(500,300);
|
||||||
|
|
||||||
Gtk::Box* mainbox = manage(new VBox());
|
Box& mainbox = *manage(new VBox());
|
||||||
add(*mainbox);
|
add(mainbox);
|
||||||
|
|
||||||
|
ScrolledWindow& txout_scroll = *manage(new ScrolledWindow());
|
||||||
_text_output.set_editable(false);
|
_text_output.set_editable(false);
|
||||||
_text_output.modify_font(Pango::FontDescription("monospace"));
|
_text_output.modify_font(Pango::FontDescription("monospace"));
|
||||||
mainbox->pack_start(_text_output);
|
txout_scroll.set_policy(POLICY_AUTOMATIC, POLICY_AUTOMATIC);
|
||||||
|
txout_scroll.add(_text_output);
|
||||||
|
mainbox.pack_start(txout_scroll);
|
||||||
|
|
||||||
Gtk::Box* cmdbox = manage(new HBox());
|
Box& cmdbox = *manage(new HBox());
|
||||||
mainbox->pack_end(*cmdbox, false, false);
|
mainbox.pack_end(cmdbox, false, false);
|
||||||
|
|
||||||
_text_input.signal_key_press_event().connect(sigc::mem_fun(*this, &GraphicalTerminalIO::_on_input_commit));
|
// Maybe we should connect explicitly TextBuffer.signal_changed
|
||||||
cmdbox->pack_start(_text_input);
|
// to the TextView redraw function (see Gtk::Widget for that)??
|
||||||
|
|
||||||
_send = manage(new Button(_("Send Command")));
|
_text_input.activate();
|
||||||
_send->signal_clicked().connect(sigc::mem_fun(*this, &GraphicalTerminalIO::onSend));
|
_text_input.set_activates_default();
|
||||||
cmdbox->pack_start(*_send, false, true);
|
cmdbox.pack_start(_text_input);
|
||||||
|
|
||||||
|
Button& btsend = *manage(new Gtk::Button(_("Send Command")));
|
||||||
|
btsend.signal_clicked().connect(sigc::mem_fun(*this, &GraphicalTerminalIO::onSend));
|
||||||
|
GTK_WIDGET_SET_FLAGS(btsend.gobj(), CAN_DEFAULT);
|
||||||
|
set_default(btsend);
|
||||||
|
cmdbox.pack_start(btsend, false, true);
|
||||||
|
|
||||||
_text_input.grab_focus();
|
_text_input.grab_focus();
|
||||||
|
|
||||||
//this button is the default widget
|
|
||||||
//GTK_WIDGET_SET_FLAGS ( _send , GTK_CAN_DEFAULT);
|
|
||||||
//_send->grab_default();
|
|
||||||
|
|
||||||
show_all_children();
|
show_all_children();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,28 +85,37 @@ void
|
||||||
GraphicalTerminalIO::onSend()
|
GraphicalTerminalIO::onSend()
|
||||||
{
|
{
|
||||||
|
|
||||||
pair< pair<TextSimulation*, IOManager*>, const ustring > p(
|
pair<pair<TextSimulation*, IOManager*>, const ustring> p(
|
||||||
pair<TextSimulation*, IOManager*>(_sim, this), _text_input.get_text());
|
pair<TextSimulation*, IOManager*>(_sim, this),
|
||||||
|
_text_input.get_text());
|
||||||
|
|
||||||
Thread::create( sigc::bind(&TextSimulation::parse_command, p), true);
|
Thread::create(sigc::bind(&TextSimulation::parse_command, p), true);
|
||||||
|
|
||||||
_text_input.set_text("");
|
_text_input.set_text("");
|
||||||
_text_input.grab_focus();
|
_text_input.grab_focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint
|
uint
|
||||||
GraphicalTerminalIO::write_buffer(const Glib::ustring& buffer)
|
GraphicalTerminalIO::write_buffer(const Glib::ustring& buffer)
|
||||||
{
|
{
|
||||||
Gtk::TextBuffer::iterator i = _text_output.get_buffer()->end();
|
Gtk::TextBuffer::iterator i = _text_output.get_buffer()->end();
|
||||||
_text_output.get_buffer()->insert(i, buffer);
|
_text_output.get_buffer()->insert(i, buffer);
|
||||||
i = _text_output.get_buffer()->end();
|
|
||||||
//_text_output.scroll_to(i); // would need a mutex!
|
// Force the UI update queue to flush
|
||||||
return buffer.size();
|
// while(Gtk::Main::instance()->events_pending())
|
||||||
|
// Gtk::Main::instance()->iteration();
|
||||||
|
|
||||||
|
// i = _text_output.get_buffer()->end();
|
||||||
|
return buffer.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
Glib::ustring
|
Glib::ustring
|
||||||
GraphicalTerminalIO::read_command()
|
GraphicalTerminalIO::read_command()
|
||||||
{
|
{
|
||||||
|
// For next implementers: take a look to Gtk::EntryCompletion...
|
||||||
|
// ... maybe it's worth using (when and if we'll have a separate
|
||||||
|
// Interpreter class)
|
||||||
|
|
||||||
using Glib::ustring;
|
using Glib::ustring;
|
||||||
static const ustring whitespaces = " \r\b\n\t\a";
|
static const ustring whitespaces = " \r\b\n\t\a";
|
||||||
// are there any other wspaces?
|
// are there any other wspaces?
|
||||||
|
@ -119,16 +136,3 @@ GraphicalTerminalIO::is_full_duplex()
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
|
||||||
GraphicalTerminalIO::_on_input_commit(GdkEventKey* event)
|
|
||||||
{
|
|
||||||
// We should use Gdk::GDK_Return here, but it doesn't work for
|
|
||||||
// some reason!!
|
|
||||||
if((event->keyval & 0xFF0D) == 0xFF0D )
|
|
||||||
{
|
|
||||||
onSend();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
|
@ -30,9 +30,10 @@
|
||||||
#include <gtkmm/window.h>
|
#include <gtkmm/window.h>
|
||||||
#include <glibmm/ustring.h>
|
#include <glibmm/ustring.h>
|
||||||
|
|
||||||
|
#include "io_manager.hh"
|
||||||
#include "text_simulation.hh"
|
#include "text_simulation.hh"
|
||||||
|
|
||||||
#include "io_manager.hh"
|
#include <memory>
|
||||||
|
|
||||||
namespace sgpem {
|
namespace sgpem {
|
||||||
|
|
||||||
|
@ -88,12 +89,9 @@ namespace sgpem {
|
||||||
void onSend();
|
void onSend();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool _on_input_commit(GdkEventKey* event);
|
TextSimulation* _sim;
|
||||||
|
Gtk::TextView _text_output;
|
||||||
TextSimulation* _sim;
|
mutable Gtk::Entry _text_input;
|
||||||
Gtk::TextView _text_output;
|
|
||||||
mutable Gtk::Entry _text_input;
|
|
||||||
Gtk::Button* _send;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue