Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

When speculation has done its worst, two plus two still equals four. -- S. Johnson


devel / comp.lang.ada / Re: Glade but more flexible

SubjectAuthor
* Glade but more flexibleldries46
`- Re: Glade but more flexibleDmitry A. Kazakov

1
Glade but more flexible

<nnd$2cb2ae46$32cab04c@6c46de121afb91f0>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=6584&group=comp.lang.ada#6584

  copy link   Newsgroups: comp.lang.ada
Date: Sun, 30 Jan 2022 14:20:13 +0100
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.5.1
Newsgroups: comp.lang.ada
Content-Language: en-GB
From: bertus.d...@planet.nl (ldries46)
Subject: Glade but more flexible
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Message-ID: <nnd$2cb2ae46$32cab04c@6c46de121afb91f0>
Organization: KPN B.V.
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!peer03.ams1!peer.ams1.xlned.com!news.xlned.com!peer02.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!abe006.abavia.com!abp001.abavia.com!news.kpn.nl!not-for-mail
Lines: 20
Injection-Date: Sun, 30 Jan 2022 14:20:13 +0100
Injection-Info: news.kpn.nl; mail-complaints-to="abuse@kpn.com"
X-Received-Bytes: 1688
 by: ldries46 - Sun, 30 Jan 2022 13:20 UTC

I like the way Glade can be used for designing a gtk GUI. But There is a
problem I cannot do what I like to do. The best way to illustrate that
is when I want to design a multi language program. I than need the
string variables in some kind of array. For instance Language_Open(lan)
instead of Language_Open where:
Language_Open(English) := To_Unbounded_String("Open");
Language_Open(Deutsch) := To_Unbounded_String("Offnen");
etc,
where lan := (English, Deutsch, ...);

This can be reached if Glade can also produce an Ada program output
where you can edit output simply or when a program Glade2Ada would be
created which translates the Glade Output to Ada, where you can edit the
Ada program accordingly.
The latest version can also be transfered to other language, so Glade2C,
Glade2python etc.

The question is is something like that available or is it an idea to
create such a thing for the people who created Glad

Re: Glade but more flexible

<st65jp$dgu$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=6585&group=comp.lang.ada#6585

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!aioe.org!3s634R+rSk3f11Qz2WJrTw.user.46.165.242.91.POSTED!not-for-mail
From: mail...@dmitry-kazakov.de (Dmitry A. Kazakov)
Newsgroups: comp.lang.ada
Subject: Re: Glade but more flexible
Date: Sun, 30 Jan 2022 14:59:22 +0100
Organization: Aioe.org NNTP Server
Message-ID: <st65jp$dgu$1@gioia.aioe.org>
References: <nnd$2cb2ae46$32cab04c@6c46de121afb91f0>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="13854"; posting-host="3s634R+rSk3f11Qz2WJrTw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.5.1
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: en-US
 by: Dmitry A. Kazakov - Sun, 30 Jan 2022 13:59 UTC

On 2022-01-30 14:20, ldries46 wrote:
> I like the way Glade can be used for designing a gtk GUI. But There is a
> problem I cannot do what I like to do. The best way to illustrate that
> is when I want to design a multi language program. I than need the
> string variables in some kind of array. For instance Language_Open(lan)
> instead of Language_Open where:
> Language_Open(English) := To_Unbounded_String("Open");
> Language_Open(Deutsch) := To_Unbounded_String("Offnen");
> etc,
> where lan := (English, Deutsch, ...);
>
> This can be reached if Glade can also produce an Ada program output
> where you can edit output simply or when a program Glade2Ada would be
> created which translates the Glade Output to Ada, where you can edit the
> Ada program accordingly.
> The latest version can also be transfered to other language, so Glade2C,
> Glade2python etc.
>
> The question is is something like that available or is it an idea to
> create such a thing for the people who created Glad

[ Necessary litany: never ever use Glade ]

Regarding localization I am using widget style properties for the purpose:

1. All application widgets are derived, usually from grid or dialog etc.

2. All widgets define a new class:

Initialize_Class_Record

3. All texts (and other parameters) of a widget are style properties
from the class:

Install_Style_Property
( Class_Ref (... the widget's type ...),
Gnew_String
( Name => "hello-label",
Nick => "hello",
Blurb => "The label 'hello'",
Default => "Hello"
) );

4. Provide Style_Updated to handle style-updated:

procedure Style_Updated
( Widget : access My_Custom_Widget
) is
begin
Widget.Hello_Label.Set_Text
( Style_Get (Widget, "hello-label")
);
...

From there you set all texts of the widget and all other properties.
E.g. the label text is set from the value of the "hello-label".

5. Connect to Style_Updated

Connect
( Widget,
"style-updated",
To_Marshaller (Style_Updated'Access)
);

6. Call to Style_Updated at the end of Initialize (called from Gtk_New)

7. Upon application start load a CSS file from some predefined location,
e.g. from user directory:

Load_CSS_File

This is basically all. If you want to change a text, e.g. from English
to German, you simply edit the CSS file.

MyCustomWidget {
-MyCustomWidget-hello-label: "Hallo";

You can reload CSS any time, the widgets will get the "style-updated"
event and Style_Updated will change the texts.

No texts in the application code, except for the English default
fallback, of course.

BTW, in GTK it is possible to walk down the widget tree and generate a
CSS template with all style properties of. I add this to command-line
arguments. So adding a new language you will not miss a text (a poor
man's safety you would get in Ada for free if an enumeration type were
used for the texts).

The GTK CSS overview is here:

https://docs.gtk.org/gtk3/css-overview.html

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

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor