Re: closing the window automatically



On 2/19/07, SaiKamesh Rathinasabapathy <rsaikamesh gmail com> wrote:
Sorry I forgot to attach my sample program in the first mail. here I have
attached that.
Hi Daniel,
     Thank you very much once again.Even though you don't know what my
problem is, you are trying to help me. Thank you very much. Here I have
attached a sample code which explains what I am trying to do and what the
problem I am facing. I have given comments to explain my problem. please
have a look at this program and try to help me!.



On 2/19/07, SaiKamesh Rathinasabapathy <rsaikamesh gmail com> wrote:
>
>
>
>
> On 2/18/07, Daniel Elstner < daniel kitta googlemail com> wrote:
> > Am Samstag, den 17.02.2007, 19:19 +0530 schrieb SaiKamesh
> > Rathinasabapathy:
> >
> > > I have already written a program in c++, which reads the data from the
> > > serial port.
> > > So I have no problem in reading the data from the barcode reader which
> > > is connected to the serial port.
> >
> > Okay, then I don't know what your problem is.  The thing is, the answer
> > to your question very much depends on the context.  Without any context,
> > it's nearly impossible to help you.  The answer might boil down to "hide
> > it" or "delete it", but I reckon you'd have figured that out by yourself
> > if it really was that trivial.
> >
> > So, why don't you send us a sample program that roughly shows what
> > you're actually trying to do?  And please CC to the list, too.
> >
> > > My problem is, when I run my application a window should be opened,
> > > that has a label on it "Scan the barcode using scanner". then I have
> > > to read the barcode, after reading the barcode the window should
> > > automatically be closed, then a new window should be opened.
> > > I don't know how to close the first window automatically, after
> > > reading the barcode. plz help me to so this.
> >
> > > If possible send me sample program.
> >
> > I already said that I don't have such a sample program.
> >
> > --Daniel
> >
> >
> >
>     Hi Daniel,
>      Thank you very much once again.Even though you don't know what my
problem is, you are trying to help me. Thank you very much. Here I have
attached a sample code which explains what I am trying to do and what the
problem I am facing. I have given comments to explain my problem. please
have a look at this program and try to help me!.
>


_______________________________________________
gtkmm-list mailing list
gtkmm-list gnome org
http://mail.gnome.org/mailman/listinfo/gtkmm-list




Well, the most obvious thing that jumps out is that on line 275 you're
creating a Glib main loop. This loop blocks until either a call to
Gtk::Main::quit() or the obj.wind Gtk::Window is hidden (and probably
other ways I don't know about).

This is the call thats starting things off:
	Gtk::Main::run(obj.wind);// displaying the first window

Does rs_getch() ever even get called? I'm just looking at how this is
written and my initial guess is probably not. But then again, I could
be completely wrong because this is a bit hard to parse.

You should probably rework a bit of the architecture here.

First off, I've never made more than a single call to Gtk::Main::run()
in a program. I'm not sure if anyone else has done this, but I'm
guessing most people on the list will agree that its probably not a
good idea in this case.

If  I were writing this, I would start with this basic structure:

Create a main window class. This is the first window show.

When the main window is instantiated, create a Glib::IOSource for your
serial port communication. (This gets rid of all your signaling code.)

http://www.gtkmm.org/docs/glibmm-2.4/docs/reference/html/classGlib_1_1IOSource.html

Once, you read enough from the serial port you can call a function
that performs your mysql lookup.

In this same function you can use a dialog to display the message
about being logged in.

Something like the following:

MainWindowClass:

  Constructor()
    open serial port with options (like you already have)
    create IOSource
    connect callback to IOSource ( on_data_ready() )

  on_data_ready():
     read data from serial port until a block would occur.
          (you can check by testing  errno == EAGAIN )
     store data read in buffer.

     if( all data has been read ):
         perform_mysql_look()
         if( lookup is successful ):
           notify_user( success )
         else
            notify_user( failure )


The trickiest part of all this should be in your on_data_read()
method. Specificaly the

if( all data has been read ):

check.  I usually pick ease of coding over efficiency and read all
data a byte at a time. Granted I'm not reading huge amounts of data so
this is generally ok. You only seem to be reading a max of 600 bytes
so this would probably be fine for you as well.

Anyway, that should be enough to get you going for a bit.

HTH,
Paul Davis



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]