From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: GtkAda problems
Date: Tue, 16 Jun 2020 09:11:32 +0200 [thread overview]
Message-ID: <rc9rb3$tsa$1@gioia.aioe.org> (raw)
In-Reply-To: 4960e48d-1e72-497c-94fe-d7c1aaea192co@googlegroups.com
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
next parent reply other threads:[~2020-06-16 7:11 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <4960e48d-1e72-497c-94fe-d7c1aaea192co@googlegroups.com>
2020-06-16 7:11 ` Dmitry A. Kazakov [this message]
2020-06-17 1:00 ` GtkAda problems b.mcguinness747
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox