comp.lang.ada
 help / color / mirror / Atom feed
* GtkAda and tasking how to?.
@ 2001-05-06  7:48 Per Sandbergs
  2001-05-06 10:40 ` Preben Randhol
  0 siblings, 1 reply; 4+ messages in thread
From: Per Sandbergs @ 2001-05-06  7:48 UTC (permalink / raw)


Colud somone phelp me with the folowing issue concering GTKAda and tasking.
What i want to to is basiclty the folowing:

Create a GUI in GtkAda containig a Text box.and som other widgets running as
the one Ada-task.
I am running
    Win NT4/2K
    GNAT 3.14a
    GTKAda 1.3.11
-------------------------------------------------------------------
with all nececarry units;
procedure main is
  task type Start_Task_type is
  end tart_Task_type;
   type Start_Task_Type_ref is access Start_Task_Type;

task body Start_Task_type is
begin
    while more_work_to_be_done loop
        do_some_work;
        "Update the GUI with text and status":
    end loop;
end;

begin
   declare
      Server : Start_Task_Type_Ref;
   begin
      Gtk.Main.Set_Locale;
      Gtk.Main.Init;
      Gtk_New (Server_Main);
      Show_All (Server_Main);
      Gdk.Threads.Enter;
      Server := new Start_Task_Type;
      Gtk.Main.Main;
      Gdk.Threads.Leave;
   end;
end Main;
----------------------------------------------------------------






^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: GtkAda and tasking how to?.
  2001-05-06  7:48 GtkAda and tasking how to? Per Sandbergs
@ 2001-05-06 10:40 ` Preben Randhol
  2001-05-07  5:34   ` Per Sandbergs
  0 siblings, 1 reply; 4+ messages in thread
From: Preben Randhol @ 2001-05-06 10:40 UTC (permalink / raw)


On Sun, 6 May 2001 09:48:43 +0200, Per Sandbergs wrote:
> Colud somone phelp me with the folowing issue concering GTKAda and tasking.
> What i want to to is basiclty the folowing:
> 
> Create a GUI in GtkAda containig a Text box.and som other widgets running as
> the one Ada-task.
> I am running
>     Win NT4/2K
>     GNAT 3.14a
>     GTKAda 1.3.11

I let my main program run a loop where all the checking it wants to do
are done and then I run the GUI in a spereate task, so that when I need
to update the GUI I call the Update_GUI below:


  task body GUI_task is

  begin

    Gtk.Main.Set_Locale;
    Gdk.Threads.Init;
    Gtk.Main.Init;

    loop
      select
        accept Update_GUI do
         -- Do the stuff here.......
      else
         -- If not do all the other things the GUI wants to do...
         while Gtk.Main.Events_Pending loop
            Dead := Gtk.Main.Main_Iteration;
         end loop;
      end select;
      delay 0.01;
    end loop;

   exception
      when E : others =>
         Put_Line ("Exception raised in GUI task:" &
                   Exception_Information (E));

  end GUI_task;

Hope it helps.
-- 
Preben Randhol ------------------- http://www.pvv.org/~randhol/ --
                 �For me, Ada95 puts back the joy in programming.�



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: GtkAda and tasking how to?.
  2001-05-06 10:40 ` Preben Randhol
@ 2001-05-07  5:34   ` Per Sandbergs
  2001-05-07 10:07     ` Preben Randhol
  0 siblings, 1 reply; 4+ messages in thread
From: Per Sandbergs @ 2001-05-07  5:34 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2331 bytes --]


Thanks for the example i may end up in going this way but what i realy want
is to make the
GUI thread safe since i am deling with a server program that previos took
all commands form a socket connection aand just printet to standard output
And what i want to do is to redirect Output to the GUI and still be able to
control the GUI.

My intention was basicly to encapsulate all GUI operations called from the
program with

 |Gdk.Threads.Enter;
 |   "Do the drawing operations"
 |Gdk.Threads.Leave;
as in the example with double buffering.
But what i am getting after a while is
    Gdk-ERROR **: file gdkgc-win32.c: line 875 (gdk_gc_predraw): assertion
failed: (data->xgc == NULL)
It think it os a timing/race problem since the time the program runs seem to
be random.

(May be thei shall go the the GTK-ada list as well)
/Per Sandberg



"Preben Randhol" <randhol+abuse@pvv.org> wrote in message
news:slrn9faam8.261.randhol+abuse@kiuk0156.chembio.ntnu.no...
> On Sun, 6 May 2001 09:48:43 +0200, Per Sandbergs wrote:
> > Colud somone phelp me with the folowing issue concering GTKAda and
tasking.
> > What i want to to is basiclty the folowing:
> >
> > Create a GUI in GtkAda containig a Text box.and som other widgets
running as
> > the one Ada-task.
> > I am running
> >     Win NT4/2K
> >     GNAT 3.14a
> >     GTKAda 1.3.11
>
> I let my main program run a loop where all the checking it wants to do
> are done and then I run the GUI in a spereate task, so that when I need
> to update the GUI I call the Update_GUI below:
>
>
>   task body GUI_task is
>
>   begin
>
>     Gtk.Main.Set_Locale;
>     Gdk.Threads.Init;
>     Gtk.Main.Init;
>
>     loop
>       select
>         accept Update_GUI do
>          -- Do the stuff here.......
>       else
>          -- If not do all the other things the GUI wants to do...
>          while Gtk.Main.Events_Pending loop
>             Dead := Gtk.Main.Main_Iteration;
>          end loop;
>       end select;
>       delay 0.01;
>     end loop;
>
>    exception
>       when E : others =>
>          Put_Line ("Exception raised in GUI task:" &
>                    Exception_Information (E));
>
>   end GUI_task;
>
> Hope it helps.
> --
> Preben Randhol ------------------- http://www.pvv.org/~randhol/ --
>                  �For me, Ada95 puts back the joy in programming.�





^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: GtkAda and tasking how to?.
  2001-05-07  5:34   ` Per Sandbergs
@ 2001-05-07 10:07     ` Preben Randhol
  0 siblings, 0 replies; 4+ messages in thread
From: Preben Randhol @ 2001-05-07 10:07 UTC (permalink / raw)


On Mon, 7 May 2001 07:34:38 +0200, Per Sandbergs wrote:
> 
> Thanks for the example i may end up in going this way but what i realy want
> is to make the
> GUI thread safe since i am deling with a server program that previos took
> all commands form a socket connection aand just printet to standard output
> And what i want to do is to redirect Output to the GUI and still be able to
> control the GUI.

Perhaps I misunderstand you, but isn't it better then to put the GUI in
a separate thread so that if something goes wrong you can start up a new
GUI thread when you detect that the old one has died?

> But what i am getting after a while is
>     Gdk-ERROR **: file gdkgc-win32.c: line 875 (gdk_gc_predraw): assertion
> failed: (data->xgc == NULL)
> It think it os a timing/race problem since the time the program runs seem to
> be random.

Have you tried it on Linux?

-- 
Preben Randhol ------------------- http://www.pvv.org/~randhol/ --
                 �For me, Ada95 puts back the joy in programming.�



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2001-05-07 10:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-05-06  7:48 GtkAda and tasking how to? Per Sandbergs
2001-05-06 10:40 ` Preben Randhol
2001-05-07  5:34   ` Per Sandbergs
2001-05-07 10:07     ` Preben Randhol

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox