comp.lang.ada
 help / color / mirror / Atom feed
* Re: GtkAda problems
       [not found] <4960e48d-1e72-497c-94fe-d7c1aaea192co@googlegroups.com>
@ 2020-06-16  7:11 ` Dmitry A. Kazakov
  2020-06-17  1:00   ` b.mcguinness747
  0 siblings, 1 reply; 2+ messages in thread
From: Dmitry A. Kazakov @ 2020-06-16  7:11 UTC (permalink / raw)


On 16/06/2020 04:34, b.mcguinness747@gmail.com wrote:
 > I am trying to translate some GTK C code to Ada and am having 
problems, as I can't find decent documentation for GtkAda.
    http://docs.adacore.com/gtkada-docs/gtkada_ug/_build/html/

 > 1. I am trying to set the font for textviews using CSS.  For now I 
just want to use a character string rather than having to hunt for an 
external data file. I have:
 >
 >    START_FONT : constant String := "textview { font-family: ""SImPL 
medium""; font-size: 12pt; }";
 >
 > ...
 >
 >    css_provider    : Gtk_Css_Provider;
 >    errcode         : aliased Glib.Error.GError;
 >
 > ...
 >
 >    -- Set the initial font
 >    Gtk_New (css_provider);
 >    is_error := Load_From_Data (css_provider, START_FONT, errcode'Access);
 >
 >
 > I don't get any error messages from this when compiling and executing 
the program, but the font doesn't seem to be getting set in the textview.

    declare
       Font : Pango_Font_Description := From_String ("whatever font");
    begin
       Text_View.Modify_Font (Font);
       Free (Font);
    end;

 > 2. I don't see how to connect a menu to the menu bar in GtkAda. I have:
 >
 >    menu            : Gtk_Menu;
 >    menu_bar        : Gtk_Menu_Bar;
 >    menu_bar_item   : Gtk_Menu_Item;
 >    menu_item       : Gtk_Menu_Item;
 >
 > ...
 >
 >    -- Set up the menu bar
 >    Gtk_New (menu_bar);
 >
 >    Gtk_New (menu);
 >    --  Set_Title (menu, "File");
 >
 >    menu.Add (Gtk_Separator_Menu_Item_New);
 >    menu_item := Gtk_Menu_Item_New_With_Mnemonic ("E_xit");
 >    -- ... connect menu_item to signal ...
 >    menu.Add (menu_item);
 >
 >    menu_bar_item := Gtk_Menu_Item_New_With_Label ("File");
 >    Gtk.Menu_Shell.Append (menu_bar, menu_bar_item); -- doesn't compile --
 >
 >    In C the last statement is:
 >
 >    gtk_menu_shell_append (GTK_MENU_SHELL (menu_bar), menu_bar_item);
 >
 >    but I can't find the equivalent in GtkAda.

    Menu_Bar.Append (Menu_Bar_Item);  -- ?

 > 3. I don't know how to trap key press events for a textview in 
GtkAda.  In C I can use:
 >
 >    g_signal_connect (G_OBJECT (text_view), "key-press-event", 
G_CALLBACK (handle_key), NULL);
 >
 > but I can't find an equivalent in GtkAda.

Given:

    package My_Handlers is
       new Gtk.Handlers.Return_Callback (Gtk_Tree_View_Record, Boolean);

and

    function Handle_Key
             (  Object : access Gtk_Tree_View_Record'Class;
                Event  : Gdk_Event
             )  return Boolean;

then

    My_Handlers.Connect
    (  Text_View,
       "key-press-event",
       My_Handlers.To_Marshaller (Handle_Key'Access)
    );

 > I also want to avoid using GLADE as I have found it a pain to work with.
Good idea.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

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

* Re: GtkAda problems
  2020-06-16  7:11 ` GtkAda problems Dmitry A. Kazakov
@ 2020-06-17  1:00   ` b.mcguinness747
  0 siblings, 0 replies; 2+ messages in thread
From: b.mcguinness747 @ 2020-06-17  1:00 UTC (permalink / raw)


Thank you.  That helps quite a bit.

--- Brian McGuinness

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

end of thread, other threads:[~2020-06-17  1:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <4960e48d-1e72-497c-94fe-d7c1aaea192co@googlegroups.com>
2020-06-16  7:11 ` GtkAda problems Dmitry A. Kazakov
2020-06-17  1:00   ` b.mcguinness747

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