[gtkada] testgtk/create_builder.adb patch proposal.

Pascal p.p14 at orange.fr
Wed Jul 11 21:16:37 CEST 2012


Hello, in testgtk-create_builder from GtkAda GPL 2012, On_Print_To_Console call back is missing.
Here is a patch proposal:

--- ./testgtk/create_builder.adb.0	2012-05-18 10:03:39.000000000 +0200
+++ ./testgtk/create_builder.adb	2012-07-11 09:47:47.000000000 +0200
@@ -45,6 +45,7 @@
 with Gtk.Text_Buffer;      use Gtk.Text_Buffer;
 with Gtk.Text_View;        use Gtk.Text_View;
 with Gtk.Widget;
+with Gtk.Text_Iter;    use Gtk.Text_Iter;
 
 with Common;               use Common;
 
@@ -77,7 +78,8 @@
      (On_Window1_Delete_Event,
       On_Btn_Concatenate_Clicked,
       On_Window1_Destroy,
-      On_Btn_Console_Greeting_Clicked);
+      On_Btn_Console_Greeting_Clicked,
+      On_Print_To_Console);
    --  An easy way to make sure that all callback functions are referenced
    --  from within the Connect_Signals procedure and that no one has been
    --  overlooked. The names of the callback functions must match the
@@ -87,6 +89,8 @@
      (Object : access Widget_Collection_Record'Class);
    procedure On_Btn_Console_Greeting_Clicked
      (Object : access Widget_Collection_Record'Class);
+   procedure On_Print_To_Console
+     (Object : access Widget_Collection_Record'Class);
    function On_Window1_Delete_Event
      (Object : access Widget_Collection_Record'Class) return Boolean;
    procedure On_Window1_Destroy
@@ -182,6 +186,15 @@
                Slot_Object => Widgets,
                After       => After);
 
+         when On_Print_To_Console =>
+            Widget_Collection_Cb.Object_Connect
+              (Widget      => Widget,
+               Name        => "clicked",
+               Marsh       => Widget_Collection_Cb.To_Marshaller
+                                (On_Print_To_Console'Access),
+               Slot_Object => Widgets,
+               After       => After);
+
       end case;
    end Connect_Signals;
 
@@ -263,6 +276,27 @@
       Put_Line ("On_Btn_Console_Greeting_Clicked says: HELLO!!!");
    end On_Btn_Console_Greeting_Clicked;
 
+   --------------------------------
+   -- On_Print_To_Console --
+   --------------------------------
+
+   procedure On_Print_To_Console
+     (Object : access Widget_Collection_Record'Class)
+   is
+      Buffer : Gtk_Text_Buffer;
+      Start, The_End : Gtk_Text_Iter;
+   begin
+      Put_Line ("On_Print_To_Console");
+
+      Buffer := Get_Buffer (Object.Text_Field);
+      Get_Start_Iter (Buffer, Start);
+      Get_End_Iter (Buffer, The_End);
+      Put_Line (Get_Text (Buffer, Start, The_End));
+   exception
+      when Event : others =>
+         Put_Line ("Error: " & Ada.Exceptions.Exception_Information (Event));
+   end On_Print_To_Console;
+
    -----------------------------
    -- On_Window1_Delete_Event --
    -----------------------------

HTH, Pascal.
http://blady.pagesperso-orange.fr




More information about the gtkada mailing list