Created
January 19, 2012 10:20
-
-
Save pdobrowolski/1639279 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with Client_Pkg; use Client_Pkg; | |
with Gtk.Main; | |
with Gtk.Widget; | |
with Gtk.Window; use Gtk.Window; | |
with Gtk.Box; use Gtk.Box; | |
-- with Gtk.Scrolled_Window; use Gtk.Scrolled_Window; | |
with Gtk.Text_View; use Gtk.Text_View; | |
with Gtk.GEntry; use Gtk.GEntry; | |
with Gtk.Button; use Gtk.Button; | |
procedure Client is | |
Widgets : Widget_Collection; | |
Window : Gtk_Window; | |
Box1, Box2 : Gtk_Box; | |
Button : Gtk_Button; | |
Term : Gtk_Entry; | |
Screen : Gtk_Text_View; | |
begin | |
Gtk.Main.Init; | |
Gtk_New (Window); | |
Set_Title (Window, "Client"); | |
Widget_Collection_Retrun_Cb.Connect( | |
Window, | |
"delete_event", | |
Widget_Collection_Retrun_Cb.To_Marshaller (Delete_Event'access)); | |
Gtk_New_Vbox (Box1); | |
Add (Window, Box1); | |
Gtk_New (Screen); | |
Screen.Set_Editable(False); | |
Add (Box1, Screen); | |
Gtk_New_Hbox (Box2); | |
Add (Window, Box2); | |
Gtk_New (Term); | |
Add (Box2, Term); | |
Widgets := new Widget_Collection_Record; | |
Widgets.Input := Term; | |
Widgets.Output := Screen; | |
Gtk_New (Button, "Send"); | |
Widget_Collection_Cb.Connect( | |
Button, | |
"clicked", | |
Widget_Collection_Cb.To_Marshaller (On_Btn_Send_Clicked'access), | |
Widgets); | |
Add (Box2, Button); | |
Window.Show_All; | |
Gtk.Main.Main; | |
end Client; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with Ada.Text_IO; use Ada.Text_IO; | |
with Gtk.Main; | |
with Gtk.Text_Buffer; use Gtk.Text_Buffer; | |
package body Client_Pkg is | |
procedure On_Btn_Send_Clicked | |
(Button : access Gtk_Widget_Record'Class; | |
Object : Widget_Collection) | |
is | |
Buffer : Gtk_Text_Buffer; | |
begin | |
Put_Line ("On_Btn_Send_Clicked"); | |
Buffer := Get_Buffer (Object.Output); | |
Insert_At_Cursor(Buffer, Get_Text(Object.Input) & ASCII.LF); | |
end On_Btn_Send_Clicked; | |
function Delete_Event (Object : access Gtk_Widget_Record'Class) | |
return Boolean is | |
pragma Unreferenced(Object); | |
begin | |
Put_Line ("Delete_Event"); | |
Gtk.Main.Main_Quit; | |
return FALSE; | |
end Delete_Event; | |
end Client_Pkg; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with Gtk.Widget, Gtk.Text_View, Gtk.GEntry, Gtk.Handlers; | |
use Gtk.Widget, Gtk.Handlers; | |
package Client_Pkg is | |
-- type Widget_Collection_Record is new Glib.Object.GObject_Record with record | |
-- Terminal : Gtk.GEntry.Gtk_Entry; | |
-- Text_Field : Gtk.Text_View.Gtk_Text_View; | |
-- end record; | |
-- type Widget_Collection is access all Widget_Collection_Record'Class; | |
type Widget_Collection_Record is record | |
Input : Gtk.GEntry.Gtk_Entry; | |
Output : Gtk.Text_View.Gtk_Text_View; | |
end record; | |
type Widget_Collection is access Widget_Collection_Record; | |
package Widget_Collection_Cb is new Gtk.Handlers.User_Callback | |
(Widget_Type => Gtk_Widget_Record, | |
User_Type => Widget_Collection); | |
package Widget_Collection_Retrun_Cb is new Gtk.Handlers.Return_Callback | |
(Widget_Type => Gtk_Widget_Record, | |
Return_Type => Boolean); | |
procedure On_Btn_Send_Clicked | |
(Button : access Gtk_Widget_Record'Class; | |
Object : Widget_Collection); | |
function Delete_Event | |
(Object : access Gtk_Widget_Record'Class) return Boolean; | |
end Client_Pkg; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment