Recent

Author Topic: I have made some progress on the LCL-GTK4 work.  (Read 1287 times)

onionmixer

  • New Member
  • *
  • Posts: 15
I have made some progress on the LCL-GTK4 work.
« on: July 12, 2026, 04:17:27 am »
https://github.com/onionmixer/LCLGtk4-prototype

I am always grateful for the efforts of the Lazarus community.

I am not a developer myself; I am just a regular person who loves Linux.

I started using AI (Claude Code) late last year, and I handle most of my major tasks using Claude.

I had been working on LCL-GTK4 using the Opus model, but I hit a wall and put the project on hold for a while. Recently, however, I was able to resolve several problematic points using the Fable model. Since today, July 12, 2026, is the closing date for Fable, I tried to get as much done as possible, and I believe I have resolved most of the issues.

Since I am Korean, I modified a few files outside of lcl/interfaces/gtk4 to handle GTK4 and IME-related issues. However, I am aware that these modifications could potentially cause issues for users in other language regions. Normally, I would want to submit this directly to the Lazarus repository, but because of these potential issues, I think it is better to create a separate repository. That way, the Lazarus developers can reference it and merge it into the official codebase as more complete code. The last thing I want is for my AI-generated work to have a negative impact or discourage the real Lazarus developers.

For now, this allowed me to easily migrate a project of mine that is over 10 years old (which couldn't be helped, as it was originally built in Lazarus 2.x).

The key features are as follows:

* Implemented TTrayIcon separately to fit GTK4.
* Operation under Wayland cannot be guaranteed (as I do not use a Wayland environment myself).

I hope my small contribution will be helpful to the Lazarus developers. Also, I must admit it's a bit bittersweet that LCL-GTK3 came out while I was working on GTK4. If I had known GTK3 would be released this quickly, I probably wouldn't have started the LCL-GTK4 work (though I don't mean that in a bad way—I am also happily using GIMP 3, which is based on GTK3 :D).

Once again, I send my deepest respect to the developers of the Lazarus community. Thanks to all of you, someone like me who loves Pascal and Smalltalk can still build things today.

ps. The following is a project where I created GTK4 bindings for GNU Smalltalk, which has had almost no maintenance. It was, of course, built using AI, and it might serve as a helpful reference for anyone interested. :D

https://github.com/onionmixer/gnu-smalltalk-gtk4

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4724
  • I like bugs.
Re: I have made some progress on the LCL-GTK4 work.
« Reply #1 on: July 12, 2026, 05:24:27 pm »
https://github.com/onionmixer/LCLGtk4-prototype
How to test it? For example your test_setup_dialog example compiles and runs but it does not use the GTK4 binding.
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

bytebites

  • Hero Member
  • *****
  • Posts: 794
Re: I have made some progress on the LCL-GTK4 work.
« Reply #2 on: July 12, 2026, 07:31:06 pm »
I added the Gtk4 folder to existing Lazarus. After some fiddling, apps compile and work some how.
I don't see any Korean letters.

onionmixer

  • New Member
  • *
  • Posts: 15
Re: I have made some progress on the LCL-GTK4 work.
« Reply #3 on: July 13, 2026, 02:55:32 am »
https://github.com/onionmixer/LCLGtk4-prototype
How to test it? For example your test_setup_dialog example compiles and runs but it does not use the GTK4 binding.

You just need to compile Lazarus itself with GTK4 as the target. That is how I did it for my project.

onionmixer

  • New Member
  • *
  • Posts: 15
Re: I have made some progress on the LCL-GTK4 work.
« Reply #4 on: July 13, 2026, 02:57:55 am »
I added the Gtk4 folder to existing Lazarus. After some fiddling, apps compile and work some how.
I don't see any Korean letters.

1. There isn't actually a full set of Korean documentation. However, a few test files or related documents might be written in Korean.

2. I applied some patches/improvements because a few things in other folders under LCL (outside of the gtk4 directory) were causing issues with the Korean IME. It isn't custom-tailored just for Koreans; my goal was absolutely to make it usable for everyone. :D

dbannon

  • Hero Member
  • *****
  • Posts: 3882
    • tomboy-ng, a rewrite of the classic Tomboy
Re: I have made some progress on the LCL-GTK4 work.
« Reply #5 on: July 14, 2026, 04:24:14 am »
You just need to compile Lazarus itself with GTK4 as the target. That is how I did it for my project.
onionmixer, maybe there is a misunderstanding here. The widget set that Lazarus is built with has absolutely no effect on the applications that Lazarus will go on and compiler for you. A gtk2 Lazarus will make gtk2, gtk3, Qt5 and Qt6 applications (given availability of appropriate libraries). I generally work with a Qt5 Lazarus and make all those different binaries from it.

Building a gtk4 Lazarus would be a pretty impressive test of your bindings, as long as it is, really, all gtk4. You would (hopefully but not realistically) not need to make any changes to the Lazarus IDE code to get it to build with gtk4, all your work would be down in lcl/interfaces/gtk4

If you are changing the Lazarus IDE code itself to directly call gtk4 functions, its not going to help at all !

Davo
Lazarus 4, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

egsuh

  • Hero Member
  • *****
  • Posts: 1826
Re: I have made some progress on the LCL-GTK4 work.
« Reply #6 on: July 14, 2026, 05:36:50 am »
@onionmixer

Nice to meet a Korean here!  Hope not to mix real onions !

onionmixer

  • New Member
  • *
  • Posts: 15
Re: I have made some progress on the LCL-GTK4 work.
« Reply #7 on: July 17, 2026, 08:08:34 pm »
@onionmixer

Nice to meet a Korean here!  Hope not to mix real onions !

not real, but little like.. maybe? :D

onionmixer

  • New Member
  • *
  • Posts: 15
Re: I have made some progress on the LCL-GTK4 work.
« Reply #8 on: July 19, 2026, 09:03:16 am »
You just need to compile Lazarus itself with GTK4 as the target. That is how I did it for my project.
onionmixer, maybe there is a misunderstanding here. The widget set that Lazarus is built with has absolutely no effect on the applications that Lazarus will go on and compiler for you. A gtk2 Lazarus will make gtk2, gtk3, Qt5 and Qt6 applications (given availability of appropriate libraries). I generally work with a Qt5 Lazarus and make all those different binaries from it.

Building a gtk4 Lazarus would be a pretty impressive test of your bindings, as long as it is, really, all gtk4. You would (hopefully but not realistically) not need to make any changes to the Lazarus IDE code to get it to build with gtk4, all your work would be down in lcl/interfaces/gtk4

If you are changing the Lazarus IDE code itself to directly call gtk4 functions, its not going to help at all !

Davo

Ah... of course I am not modifying the IDE code for LCL-gtk4. I'm definitely keeping that in mind. However, English-speaking users might not be aware of this, but IME issues on Linux are quite severe in multi-byte language cultures. For cases using native gtk4 widgets, I managed to handle it within LCL-gtk4 as much as possible... but the issue with Korean IME (XIM) syllable composition (Initial-Medial-Final consonants) in SynEdit, which is Lazarus's code editor, has been a long-standing challenge.

Personally, I think LCL-gtk4 is at a level where regular users won't face any issues. However, as a Korean user, I have been slightly tweaking Lazarus's SynEdit with every version for my own use. I am fully aware that while this part is useful "for me," it might not be necessary for other Lazarus users. On top of that, the only "multi-byte Linux IME" I have tested is fcitx5-xim-hangul, so I can't guarantee what kind of issues might pop up in other language environments.

I know myself well enough to admit I'm not a mainstream-level developer, and I am well aware that these small, convenience-focused patches shouldn't be pushed into the main branch anyway. :D

dbannon

  • Hero Member
  • *****
  • Posts: 3882
    • tomboy-ng, a rewrite of the classic Tomboy
Re: I have made some progress on the LCL-GTK4 work.
« Reply #9 on: July 19, 2026, 11:33:09 am »
Ah... of course I am not modifying the IDE code for LCL-gtk4. I'm definitely keeping that in mind. However, English-speaking users might not be aware of this, but IME issues on Linux are quite severe in multi-byte language cultures. For cases using native gtk4 widgets, I managed to handle it within LCL-gtk4 as much as possible... but the issue with Korean IME (XIM) syllable composition (Initial-Medial-Final consonants) in SynEdit, which is Lazarus's code editor, has been a long-standing challenge.

I think a solution to those 4 (?) byte utf8 character problems would be great. Its not just a Korean problem, affects Chinese and other Asian languages. Its important ! But you need to break these things up into changes that must happen to Lazarus and, separately, creation of a gtk4 interface. Even if the four byte fix only works in gtk4 it would still make sense. Its just there needs to be that clear divide between code that relates to gtk4 and code that might apply to all widget sets. Fixing it in the upper parts means that, sooner or later someone might fix it (other) widget specific code.

Quote

Personally, I think LCL-gtk4 is at a level where regular users won't face any issues. However, as a Korean user, I have been slightly tweaking Lazarus's SynEdit with every version for my own use. I am fully aware that while this part is useful "for me," it might not be necessary for other Lazarus users. On top of that, the only "multi-byte Linux IME" I have tested is fcitx5-xim-hangul, so I can't guarantee what kind of issues might pop up in other language environments.

Yep, thats why the changes you want made need to be bundled up, ideally, each fixing a specific problem. I have nothing to do with the Lazarus Devs, cannot speak for them, but lots of experience with big projects. Suggestions, fixes, patches or whatever are always welcome if they are small and its easy to see that they will not effect beyond the thing they are trying to do.

Fix the things like char issue, one at a time. Then, make a version of your gtk4 for LCL that is structurally like the existing widget sets. If you try to insert GTK4 specific code in the non-interface code, it will almost certainly be rejected.

I understand you are making a Korean specific project, why not ?  But if you make it well, and continue the i18n stuff that Lazarus does, its international.

Show we be testing your code at https://github.com/onionmixer/LCLGtk4-prototype ?   I have to say, I expect people will only test if it follows the Lazarus structure.

Davo


Lazarus 4, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

Thaddy

  • Hero Member
  • *****
  • Posts: 19625
  • Glad to be alive.
Re: I have made some progress on the LCL-GTK4 work.
« Reply #10 on: July 19, 2026, 05:01:50 pm »
Doesn't GTLx belong to FPC, not Lazarus?
Any "programmer" that knows only one programming language is not a programmer

zeljko

  • Hero Member
  • *****
  • Posts: 1998
    • http://wiki.lazarus.freepascal.org/User:Zeljan
Re: I have made some progress on the LCL-GTK4 work.
« Reply #11 on: July 19, 2026, 08:23:17 pm »
Doesn't GTLx belong to FPC, not Lazarus?

gtk3 belongs to lazarus, gtk2 to the fpc. It is better that gtk3 bindings are in lazarus tree because of fpc slow release cycle. I guess that one day gtk4 will be in lazarus tree too.

onionmixer

  • New Member
  • *
  • Posts: 15
Re: I have made some progress on the LCL-GTK4 work.
« Reply #12 on: July 20, 2026, 12:02:07 am »
https://github.com/onionmixer/LCLGtk4-prototype/tree/main/lazarus/lcl

Based on the paths and code already included, you can compile and use LCL-GTK4 as is. In fact, I have already built and used it this way on my local machine. :D

The reason I pushed other seemingly miscellaneous files to GitHub is simply that I figured the Lazarus developers might not fully trust my LCL-GTK4 implementation. So, I included some verification examples specifically for LCL-GTK4.

I am completely fine if the Lazarus developers choose not to use my code. However, if this can save them some workload whenever they decide to officially consider GTK4 down the road, sharing my code will have been worth it. :D

As I mentioned in another post... if I had known Zeljko was going to release LCL-GTK3 around the same time, I wouldn't have started working on LCL-GTK4. As a regular user who has relied on Linux desktops for 30 years, I feel deeply grateful to the Lazarus team, and I would be more than happy if my code could simply serve as a rough guideline for the future LCL-GTK4.

I completely understand that this is a time when Zeljko needs to focus on LCL-GTK3. However, I decided to make my code public now because I felt that waiting any longer would only result in redundant, duplicated work later on.

Separately from this—and while Western developers did nothing wrong—handling multi-byte characters is an "obviously" natural and critical issue for those of us in non-alphabetic cultures. My journey into LCL-GTK4 actually started because I wanted to fix an issue where the pointer would jump around while writing notes in the Linux-QT5 build of the Tomboy-ng application, which I use regularly.

In the end, that issue wasn't resolved just by implementing LCL-GTK4, so I had to modify some code in KControl as well as in Tomboy-ng itself. While I intend to submit these specific fixes to those individual projects (since the bug occurs regardless of the LCL widgetset), pushing my code directly to a massive project like Lazarus is, honestly, quite terrifying for a non-developer like me who generates code using AI. Please understand if I seem a bit hesitant. The mere thought of facing criticism from Lazarus developers and users worldwide over AI-generated code is a bit daunting.. ^.^;

onionmixer

  • New Member
  • *
  • Posts: 15
Re: I have made some progress on the LCL-GTK4 work.
« Reply #13 on: July 20, 2026, 12:32:08 am »
https://github.com/onionmixer/LCLGtk4-prototype/tree/main/lazarus/lcl

Based on the paths and code already included, you can compile and use LCL-GTK4 as is. In fact, I have already built and used it this way on my local machine. (This is also what I mentioned to dbannon above.)

As I noted in another post, I started working on LCL-GTK4 because I didn't realize you were working on LCL-GTK3 with such passion. If I had known LCL-GTK3 would be released this quickly, I would have quietly waited for it instead. :D

I fully understand how busy you must be right now with revisions for LCL-GTK3. Therefore, I don't want the code I shared to cause you any immediate, additional stress.

Having used Linux desktops for 30 years, I am well aware that GTK4 is not yet fully mature, and even the GIMP team hasn't released a GTK4 version of GIMP yet. This was actually one of my personal motivations for working on LCL-GTK4. Outside of GNOME 4, almost no one is aggressively adopting GTK4, and I agree that this is because GTK4 is still a highly active, fast-changing library.

As noted in my GitHub documentation, the LCL-GTK4 I worked on is tailored to the GTK4 version found in Ubuntu 22.04. This means extra work would be required to support the latest versions of GTK4, which is something I kept in mind while working on it. (I need to stay on Ubuntu 22.04 because I use JACK for occasional MIDI work, and some legacy MIDI applications clash with PipeWire, which was introduced in Ubuntu 24.04 and later. This is the biggest reason I stay on 22.04.) Because of this, I recognize that the current LCL-GTK4 implementation might fall short of what is needed to be merged into the Lazarus mainstream (even though it works perfectly fine for me :D).

The only reason I am sharing this incomplete LCL-GTK4 code with the Lazarus community is in the hope that it might save you some trouble whenever you decide to tackle GTK4. As a far better engineer than I am, you already know that LCL-GTK4 requires navigating the architecture across the xlib-gtk4 (and related libraries)-LCL layers. I spent a lot of time repeatedly tracking, fixing, and testing the timing of event propagation required for this setup. This process was frankly not very enjoyable, especially since GTK4 feels so foreign compared to QT5 or GTK2. (It certainly helped me understand why an old friend of mine dislikes GTK4 so much.) If my code can alleviate even a fraction of the painful process you'll face later, my work will have been well worth it.

Of course, you are under absolutely no obligation to reference this code. I am already using it successfully for my own needs (with tomboy-ng), and I entirely respect the decisions of the Lazarus developers. I won't hold the slightest bit of disappointment if it's not used.

https://github.com/onionmixer/gnu-smalltalk-gtk4
https://github.com/onionmixer/gnome-commander-gtk4

As far as AI-assisted projects go, I already have some experience porting a few projects to GTK4. Those two projects were just things I started purely for fun because the original repositories weren't very active. Lazarus, however, is a different story, which is why I simply wanted to share with the community that "there is also this approach."

To wrap up a rather long message... I repeat that I have absolutely no intention of causing confusion among the Lazarus developers. I hope there is no misunderstanding. I highly respect the Lazarus community and its developers, including you. I just hope this can be viewed as one of many reference examples rather than a source of stress. That is truly all there is to it. If this has caused you any stress, I sincerely apologize.

 

TinyPortal © 2005-2018