Permalink
Browse files

Migrated from Glade to GtkBuilder (untested)

  • Loading branch information...
1 parent 80f315b commit 5c77370606075b29e80df6e9dae090bdf0438f8d amosteo committed Oct 3, 2012
Showing with 57 additions and 44 deletions.
  1. +0 −2 3rdparty/zlib_ada/zlib.ads
  2. +1 −1 3rdparty/zlib_ada/zlib.gpr
  3. +8 −5 agpl.gpr
  4. +0 −5 agpl_gtk.gpr
  5. +3 −12 skel.gpr
  6. +30 −11 src/agpl-gdk/agpl-gdk-managed.adb
  7. +15 −8 src/agpl-gdk/agpl-gdk-managed.ads
View
2 3rdparty/zlib_ada/zlib.ads
@@ -33,8 +33,6 @@ with Interfaces;
package ZLib is
- pragma Linker_Options ("-lz");
-
ZLib_Error : exception;
Status_Error : exception;
View
2 3rdparty/zlib_ada/zlib.gpr
@@ -10,7 +10,7 @@ project Zlib is
end Compiler;
package Linker is
- for Default_Switches ("ada") use ("-lz");
+ for Linker_Options use ("-lz");
end Linker;
package Builder is
View
13 agpl.gpr
@@ -89,12 +89,8 @@ project Agpl is
package Linker is
for Default_Switches ("Ada") use Skel.Linker'Default_Switches ("Ada");
- for Default_Switches ("C") use Skel.Linker'Default_Switches ("C");
- for Default_Switches ("C++") use Skel.Linker'Default_Switches ("C++");
- for Linker_Options use ("-Wl,-Bstatic",
- "-lgsl", "-lgslcblas",
- "-Wl,-Bdynamic");
+ for Linker_Options use ("-lgsl", "-lgslcblas");
-- Linker.Linker_Options apply at the main project, not here.
-- Needed, at least, in Agpl.Drawing.Figures
@@ -104,6 +100,13 @@ project Agpl is
("-Lsrc/agpl-concorde", "-lconcorde");
when "False" => null;
end case;
+
+ case Include_Pngio is
+ when "True" =>
+ for Linker_Options use Linker'Linker_Options & ("-lz");
+ when "False" => null;
+ end case;
+
end Linker;
package Builder renames Skel.Builder;
View
5 agpl_gtk.gpr
@@ -26,11 +26,6 @@ project Agpl_Gtk is
package Linker renames Agpl.Linker;
--- package Linker is
--- for Linker_Options use Agpl.Linker'Linker_Options;
--- -- These are never inherited in extension projects
--- end Linker;
-
package Pretty_Printer renames Agpl.Pretty_Printer;
package Naming renames Agpl.Naming;
View
15 skel.gpr
@@ -16,8 +16,8 @@ project Skel is
"-gnatwa", -- optional warnings from gnat
"-Wall", -- optional warnings from gcc
"-gnatwt", -- detect dead code
- "-gnatwjl", -- extra warnings
- "-gnaty", -- standard source code style
+ "-gnatwj", -- extra warnings
+ "-gnaty-s", -- Most style checks
"");
for Required_Switches ("C") use ("-Wall");
@@ -44,21 +44,12 @@ project Skel is
for Default_Switches ("Ada") use ("-E", -- exception tracebacks
"-g", -- keep debug symbols? (Unsure)
-- "-r", -- restrictions that might be applied
- "-static", -- static runtime
+ "-static", -- static GNAT runtime
"");
end Binder;
package Linker is
for Default_Switches ("Ada") use ("-g");
- for Default_Switches ("C") use ("-g");
- for Default_Switches ("C++") use ("-g");
-
- Link_Flags := External ("LFLAGS", "");
-
- for Linker_Options use ("-Wl,-Bstatic",
- Link_Flags,
- "-Wl,-Bdynamic");
- -- Linker.Linker_Options apply at the main project, not here.
end Linker;
package Builder is
View
41 src/agpl-gdk/agpl-gdk-managed.adb
@@ -1,5 +1,5 @@
with Ada.Task_Identification;
-with Agpl.Chronos;
+with Agpl.Chronos; pragma Elaborate_All (Agpl.Chronos);
with Agpl.Trace; use Agpl.Trace;
with Gdk.Threads;
with Gtk.Main;
@@ -40,16 +40,35 @@ package body Agpl.Gdk.Managed is
-- Glade_Autoconnect --
-----------------------
- procedure Glade_Autoconnect (Xml : Glade.XML.Glade_XML) is
- procedure Glade_Connect (X : System.Address);
- pragma Import (C, Glade_Connect, "glade_xml_signal_autoconnect");
- procedure Internal is
- begin
- Glade_Connect (Xml.Get_Object);
- end Internal;
+-- procedure Glade_Autoconnect (Xml : Glade.XML.Glade_XML) is
+-- procedure Glade_Connect (X : System.Address);
+-- pragma Import (C, Glade_Connect, "glade_xml_signal_autoconnect");
+-- procedure Internal is
+-- begin
+-- Glade_Connect (Xml.Get_Object);
+-- end Internal;
+-- begin
+-- Execute (Internal'Access);
+-- end Glade_Autoconnect;
+
+ procedure GtkBuilder_Connect (Builder : Gtkada_Builder;
+ Data : access User_Data) is
+ procedure Internal (Builder : System.Address;
+ Data : access User_Data) with
+ Import,
+ Convention => C,
+ External_Name => "gtk_builder_connect_signals";
+ begin
+ Internal (Builder.all'Address, Data);
+ pragma Untested ("The above line is most likely a bomb");
+ end GtkBuilder_Connect;
+
+ procedure GtkBuilder_Connect_Void (Builder : Gtkada_Builder) is
+ type Void is null record;
+ procedure Internal is new GtkBuilder_Connect (Void);
begin
- Execute (Internal'Access);
- end Glade_Autoconnect;
+ Internal (Builder, null);
+ end GtkBuilder_Connect_Void;
--------------------
-- Execute_In_Gtk --
@@ -116,7 +135,7 @@ package body Agpl.Gdk.Managed is
procedure Init is
begin
- Standard.Gtk.Main.Set_Locale;
+ -- Standard.Gtk.Main.Set_Locale; -- Was obsolescent
Standard.Gtk.Main.Init;
Standard.Gdk.Threads.G_Init;
Standard.Gdk.Threads.Init;
View
23 src/agpl-gdk/agpl-gdk-managed.ads
@@ -1,10 +1,10 @@
-with Glade.XML;
-
-- Hierarchy starting here provides some utilities for displaying drawings
-- without having to take care of any Gdk/Gtk management. In other words,
-- a new thread for Gtk is created, and all Gtk related code is called from
-- within.
+with Gtkada.Builder; use Gtkada.Builder;
+
package Agpl.Gdk.Managed is
-- pragma Elaborate_Body;
@@ -13,26 +13,33 @@ package Agpl.Gdk.Managed is
Det_Section : constant String := "agpl.gdk.managed.detail";
-- IMPORTANT:
- -- All calls to Gdk/Gtk must be performed from a same thread, managed here.
- -- To do than, you can use the functions here. These functions will properly
- -- check that you're not already in the Gtk thread, so you *must* err in
- -- the safe side and use them, always.
+ -- All calls to Gdk/Gtk must be performed from a same thread, managed
+ -- here. To do that, you can use the functions here. These functions will
+ -- properly check that you're not already in the Gtk thread, so you *must*
+ -- err in the safe side and use them, always.
procedure Execute (Code : access procedure);
-- Execute this code within the main GTK thread
-- Will initialize first time called
- procedure Glade_Autoconnect (Xml : Glade.XML.Glade_XML);
+ -- procedure Glade_Autoconnect (Xml : Glade.XML.Glade_XML);
+ generic
+ type User_Data is limited private; -- A ptr to this is give to GtkBuilder
+ procedure GtkBuilder_Connect (Builder : Gtkada_Builder;
+ Data : access User_Data);
-- Remember to compile with -rdynamic (linker, C++) in order for this
-- to find the procedures.
+ procedure GtkBuilder_Connect_Void (Builder : Gtkada_Builder);
+ -- Use this when no user data ptr is needed
+
-- OO-mindwnking
type Gtk_Code is abstract tagged null record;
-- This type must be extended to provide code to be executed.
-- Note that the type is not limited. Any info required for drawing must
-- be accessible at all times to the instance, since now the drawing is
- -- decoupled from other code flown.
+ -- decoupled from other code flow.
procedure Execute (This : in out Gtk_Code) is abstract;
-- Override this with the code required.

0 comments on commit 5c77370

Please sign in to comment.