Re: closing the window automatically
- From: Chris Vine <chris cvine freeserve co uk>
- To: gtkmm-list gnome org
- Cc: Daniel Elstner <daniel kitta googlemail com>
- Subject: Re: closing the window automatically
- Date: Mon, 19 Feb 2007 22:51:22 +0000
On Monday 19 February 2007 12:42, SaiKamesh Rathinasabapathy wrote:
[snip]
This is your problem:
Gtk::Main::run(obj.wind);// displaying the first window
^^^^^^^^^^^^^^
char letter;
while(!STOP)
{
if((letter=obj.rs_getch(port))>0) // getting the data from the serial port
charecter by charecter and storing those values in a charecter array.
{
buffer[i] = letter;
i++;
}
if(strlen(buffer) >= 119)
{
temp = 1;
break;
}
}
if(temp == 1)
{
obj.wind.hide();//here i want to close the first window, but it is not
^^^^^^^^^^^^^
Like practically all other GUI toolkits, GTK+ is event based.
Gtk::Main::run() will start the event loop and block until something else
causes it to unblock, such as the main window having Gtk::Widget::hide()
called on it (or if you have called Gtk::Main::run(void) rather than
Gtk::Main::run(Gtk::Window&), by calling Gtk::Main::quit()).
One quick hack is to move the code after your call to Gtk::Main::run up to an
including Gtk:Widget::hide() into your main window's constructor (that will
do if it does not take a long time to execute). Otherwise the normal
approach would be to read the serial port with a non-blocking read and plumb
it into the main program loop with Gtk::signal_io() (see
http://www.gtkmm.org/docs/glibmm-2.4/docs/reference/html/classGlib_1_1SignalIO.html ).
You will need a file descriptor to do that. If you do not have a file
descriptor, one less optimal choice is to set up a timeout and poll the
serial port (with a non-blocking read) at regular intervals, appropriate to
the likely data rate.
Chris
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]