From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.5-pre1 Path: eternal-september.org!reader02.eternal-september.org!news.gegeweb.eu!gegeweb.org!usenet-fr.net!proxad.net!feeder1-2.proxad.net!cleanfeed1-a.proxad.net!nnrp1-2.free.fr!not-for-mail Newsgroups: comp.lang.ada References: <6074bf6b$0$3702$426a74cc@news.free.fr> <60757b84$0$3240$426a74cc@news.free.fr> <60760ecb$0$3674$426a74cc@news.free.fr> From: DrPi <314@drpi.fr> Subject: Re: GtkAda question Date: Wed, 14 Apr 2021 22:23:08 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Message-ID: <60774f2d$0$12700$426a74cc@news.free.fr> Organization: Guest of ProXad - France NNTP-Posting-Date: 14 Apr 2021 22:23:09 CEST NNTP-Posting-Host: 82.65.30.55 X-Trace: 1618431789 news-2.free.fr 12700 82.65.30.55:50790 X-Complaints-To: abuse@proxad.net Xref: reader02.eternal-september.org comp.lang.ada:61787 List-Id: Le 14/04/2021 à 08:11, Dmitry A. Kazakov a écrit : > On 2021-04-13 23:36, DrPi wrote: >> Le 13/04/2021 à 13:55, Dmitry A. Kazakov a écrit : >>> On 2021-04-13 13:07, DrPi wrote: >>> >>>> That's what I've written (and use). >>>> However, I think the use of Error is incorrect in all Key_File >>>> functions. >>>> I will investigate further. >>> >>> Handling GError is tricky. You must call Error_Free on it if returned >>> not null. >>> >> Yes, I've read this in the Gtk documentation. >> >> Is there a good GtkAda documentation (with examples) somewhere ? > > No that I know. BTW, that would not be documentation, rather tutorial, > book etc. GtkAda is only bindings. You would not expect it to cover Gtk > topics. > >> I've found a french tutorial. Very instructive but incomplete and a >> little bit outdated. >> I also read Test code in GtkAda repository. Again, useful but very >> incomplete. > > Use Gtk tutorials and then translate that knowledge back to GtkAda, it > is more or less straightforward. > That's what I do. But there are things specific to GtkAda that are not always easy to find. For example, GtkAda makes use of Gint data types. You have to use Glib.To_Gint() function to do the conversion. You also have to use Glib.Convert.Locale_To_UTF8() function to be able to use Strings with non ASCII characters. It is almost impossible to find this by yourself. >>> Why on Earth you even use Key_File? It is much simpler to parse >>> manually in Ada. >> When I need a functionality I start to look at what already exists. >> Key_File is what I need. Why rewrite it myself ? > > I doubt anybody needs g_key_file. For start, it loads all file into the > memory. Surely you do not want that if there are lots of parameters and > settings. Or, put it this way, if you can load/store your parameters > object, then there are better means than *.ini files. > > If you cannot then you need some cashing infrastructure to avoid massive > I/O (and potential data loss). A typical solution for the latter would > be a persistent storage, maybe, backed by a DB, like SQLite or a custom > written storage. Or things like GtkRecentManager [*] and Windows registry. > I only need to store and retrieve few data like window position and size. Key_File is made for this. >> And I currently don't have the knowledge to write it myself. > > You do not know Ada text I/O or Ada stream attributes? Not yet (except Put_Line() of course). > >> I'm learning Ada at home, on my spare time. And lazy I am. For sure ;) > > Even more reasons to write it yourself all in Ada [**]. > This could be a good exercise. > ---- > * Note that GtkRecentManager suffers the potential problems I mentioned. > You may experience corruption of *.xbel files (the equivalent to *.ini, > but in XML) because it is poorly designed. > > ** I see in another response that it is already done in Ada. Though I > never used it, I am certain it is better designed and written than > g_key_file. >