From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED.2uCIJahv+a4XEBqttj5Vkw.user.gioia.aioe.org!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: GtkAda problems Date: Tue, 16 Jun 2020 09:11:32 +0200 Organization: Aioe.org NNTP Server Message-ID: References: <4960e48d-1e72-497c-94fe-d7c1aaea192co@googlegroups.com> NNTP-Posting-Host: 2uCIJahv+a4XEBqttj5Vkw.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 Content-Language: en-US X-Notice: Filtered by postfilter v. 0.9.2 Xref: reader01.eternal-september.org comp.lang.ada:59080 List-Id: 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