- 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 Andrew Collier <colliera@nu.ac.za>
|
||||
dnl @author Matteo Settenvini <matteo@member.fsf.org>
|
||||
dnl @author Horst Knorr <hk_classes@knoda.org>
|
||||
dnl @version 2006-02-05
|
||||
dnl @license GPLWithACException
|
||||
|
||||
|
@ -183,4 +184,41 @@ $ac_distutils_result])
|
|||
fi
|
||||
AC_MSG_RESULT([$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 <gtkmm/button.h>
|
||||
#include <gtkmm/main.h>
|
||||
#include <gtkmm/scrolledwindow.h>
|
||||
#include <gtkmm/textview.h>
|
||||
#include <glibmm/ustring.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <utility>
|
||||
|
||||
using namespace sgpem;
|
||||
|
@ -44,29 +47,34 @@ GraphicalTerminalIO::GraphicalTerminalIO(TextSimulation* sim)
|
|||
set_title(_("Textual Simulation Log"));
|
||||
set_default_size(500,300);
|
||||
|
||||
Gtk::Box* mainbox = manage(new VBox());
|
||||
add(*mainbox);
|
||||
Box& mainbox = *manage(new VBox());
|
||||
add(mainbox);
|
||||
|
||||
ScrolledWindow& txout_scroll = *manage(new ScrolledWindow());
|
||||
_text_output.set_editable(false);
|
||||
_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());
|
||||
mainbox->pack_end(*cmdbox, false, false);
|
||||
Box& cmdbox = *manage(new HBox());
|
||||
mainbox.pack_end(cmdbox, false, false);
|
||||
|
||||
_text_input.signal_key_press_event().connect(sigc::mem_fun(*this, &GraphicalTerminalIO::_on_input_commit));
|
||||
cmdbox->pack_start(_text_input);
|
||||
// Maybe we should connect explicitly TextBuffer.signal_changed
|
||||
// to the TextView redraw function (see Gtk::Widget for that)??
|
||||
|
||||
_send = manage(new Button(_("Send Command")));
|
||||
_send->signal_clicked().connect(sigc::mem_fun(*this, &GraphicalTerminalIO::onSend));
|
||||
cmdbox->pack_start(*_send, false, true);
|
||||
_text_input.activate();
|
||||
_text_input.set_activates_default();
|
||||
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();
|
||||
|
||||
//this button is the default widget
|
||||
//GTK_WIDGET_SET_FLAGS ( _send , GTK_CAN_DEFAULT);
|
||||
//_send->grab_default();
|
||||
|
||||
show_all_children();
|
||||
}
|
||||
|
||||
|
@ -78,7 +86,8 @@ GraphicalTerminalIO::onSend()
|
|||
{
|
||||
|
||||
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);
|
||||
|
||||
|
@ -91,14 +100,22 @@ GraphicalTerminalIO::write_buffer(const Glib::ustring& buffer)
|
|||
{
|
||||
Gtk::TextBuffer::iterator i = _text_output.get_buffer()->end();
|
||||
_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
|
||||
// while(Gtk::Main::instance()->events_pending())
|
||||
// Gtk::Main::instance()->iteration();
|
||||
|
||||
// i = _text_output.get_buffer()->end();
|
||||
return buffer.size();
|
||||
}
|
||||
|
||||
Glib::ustring
|
||||
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;
|
||||
static const ustring whitespaces = " \r\b\n\t\a";
|
||||
// are there any other wspaces?
|
||||
|
@ -119,16 +136,3 @@ GraphicalTerminalIO::is_full_duplex()
|
|||
{
|
||||
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 <glibmm/ustring.h>
|
||||
|
||||
#include "io_manager.hh"
|
||||
#include "text_simulation.hh"
|
||||
|
||||
#include "io_manager.hh"
|
||||
#include <memory>
|
||||
|
||||
namespace sgpem {
|
||||
|
||||
|
@ -88,12 +89,9 @@ namespace sgpem {
|
|||
void onSend();
|
||||
|
||||
private:
|
||||
bool _on_input_commit(GdkEventKey* event);
|
||||
|
||||
TextSimulation* _sim;
|
||||
Gtk::TextView _text_output;
|
||||
mutable Gtk::Entry _text_input;
|
||||
Gtk::Button* _send;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue