comp.lang.ada
 help / color / mirror / Atom feed
* Tasking with GtkAda
@ 2001-04-23  8:10 Tomas Hlavaty
  2001-04-27 16:52 ` Frank
  0 siblings, 1 reply; 3+ messages in thread
From: Tomas Hlavaty @ 2001-04-23  8:10 UTC (permalink / raw)


Hi all,

I'm looking for more complicated examples of tasking with GtkAda than
the one in the GtkAda UG. Could you help me?

I need to design a distributed application with Glade. Clients should
have GtkAda GUI, but I don't know, how to pass data from server to a
GtkAda widget.

I created very simple distributed application with Glade. Server counts
queries of clients and both, server and client display the number of
current query to stdout. I would like to make the client, which displays
the query number in GtkAda widget (e.g. Gtk.Label).

-------------- example ---------------------

-- types.ads

package Types is
   pragma Pure;

   type Customer_T is new String;

end Types;

-- server.ads

with Types; use Types;

package Server is
   pragma Remote_Call_Interface;

   function Get_Counter (Customer: in Customer_T) return Positive;

end Server;

-- server.adb

with Text_Io; use Text_Io;

package body Server is

   Counter: Positive := Positive'First;

   function Get_Counter (Customer: in Customer_T) return Positive is
   begin
      Put_Line (Counter'Img);
      Counter := Counter + 1;
      return Counter;
   end Get_Counter;

end Server;

-- manager.adb

with Text_Io; use Text_Io;
with Server; use Server;

procedure Manager is
begin
   loop
      Put_Line (".");
      delay 1.0;
   end loop;
end Manager;

-- client.adb

with Text_Io; use Text_Io;
with Types; use Types;
with Server; use Server;

procedure Client is
   Customer: Customer_T := "client";
begin
   loop
      Put_Line (Get_Counter (Customer)'Img);
      delay 1.0;
   end loop;
end Client;

-- simcity.cfg

configuration Simcity is

    pragma Version (False);

    pragma Starter (None);

    pragma Boot_Location ("tcp", "localhost:5558");

    Server_Partition: Partition := (Server);

    procedure Manager is in Server_Partition;

    procedure Client;

    Client_Partition: Partition;
    for Client_Partition'Termination use Local_Termination;
    for Client_Partition'Main use Client;

end Simcity;

------------- end of example -----------------

Thanks,

Tomas



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

* Re: Tasking with GtkAda
  2001-04-23  8:10 Tasking with GtkAda Tomas Hlavaty
@ 2001-04-27 16:52 ` Frank
  2001-04-28 11:19   ` Preben Randhol
  0 siblings, 1 reply; 3+ messages in thread
From: Frank @ 2001-04-27 16:52 UTC (permalink / raw)


Hi!

Perhaps you can use a idle function in the Gtk client to poll for your data.
I don't know if it is a optimal solution, but I have managed that work on a
client task to server task (non-distributed)
situation

Frank





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

* Re: Tasking with GtkAda
  2001-04-27 16:52 ` Frank
@ 2001-04-28 11:19   ` Preben Randhol
  0 siblings, 0 replies; 3+ messages in thread
From: Preben Randhol @ 2001-04-28 11:19 UTC (permalink / raw)


On Fri, 27 Apr 2001 18:52:04 +0200, Frank wrote:
> Hi!
> 
> Perhaps you can use a idle function in the Gtk client to poll for your data.
> I don't know if it is a optimal solution, but I have managed that work on a
> client task to server task (non-distributed)
> situation


I don't know if this is what you are looking for, but I have a small app
that displays GtkAda Dialogs using Ada Tasks. The program is not
finished so I have only included some of the code below to illustrate
how you can do it. Also look under doublebuffer in the examples that
follow GtkAda.

------------------
-- avtale.adb
------------------

with Notify_Task_Pkg; use Notify_Task_Pkg;

procedure avtale is

begin
    delay 5.0;
    loop          -- main loop do clever stuff here ;-)
      New_Dialog; -- call a Dialog to be shown using GtkAda
      delay 10.0; -- waits 10 second and then show a new dialog. Program
                  -- is not finished ! :-)
    end loop;

end avtale;

----------------------
-- notify_task_pkg.adb
----------------------

with Ada.Text_IO; use Ada.Text_IO;
with Ada.Exceptions; use Ada.Exceptions;

package body Notify_Task_Pkg is

  task Notify_task is
    entry New_Dialog;
  end Notify_task;

  task body Notify_task is
  task body Notify_task is

  Notify_Dialog : Notify_Dialog_Access;
  begin
    Gtk.Main.Set_Locale;
    Gdk.Threads.Init;
    Gtk.Main.Init;

    loop
      select
         accept New_Dialog do
            Gtk_New (Notify_Dialog,
                  "This is a Notify widget that can be used with" & ASCII.LF &
                  "Ada 95 programs. It is completely written in " & ASCII.LF &
                  "Ada 95 using the GtkAda library.");
            Show_All (Notify_Dialog );
         end New_Dialog;
      else
         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 Notify_task;

  procedure New_Dialog is

  begin
    Notify_Task.New_Dialog;
  end New_Dialog;

end Notify_Task_Pkg;


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



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

end of thread, other threads:[~2001-04-28 11:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-04-23  8:10 Tasking with GtkAda Tomas Hlavaty
2001-04-27 16:52 ` Frank
2001-04-28 11:19   ` Preben Randhol

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