U++ framework
Do not panic. Ask here before giving up.

Home » Extra libraries, Code snippets, applications etc. » OS Problems etc., Win32, POSIX, MacOS, FreeBSD, X11 etc » Embedding a third-party GtkWidget into a U++ Ctrl on Linux
Embedding a third-party GtkWidget into a U++ Ctrl on Linux [message #62007] Sat, 23 May 2026 15:25
forlano is currently offline  forlano
Messages: 1239
Registered: March 2006
Location: Italy
Senior Contributor
Hello,

I am building a cross-platform `WebViewCtrl` that embeds a native browser engine: WebView2 on Windows, WKWebView on macOS, and WebKitGTK on Linux.

On Windows and macOS the approach works well: I obtain the native window handle (`HWND` via `GetHWND()` on Windows, `NSView*` via `GetNSView()` on macOS) from the `TopWindow`, then I embed the browser engine as a child of that handle.

On Linux I am struggling to find the correct way to embed a `GtkWidget*` (specifically a `WebKitWebView`) as a child of the U++ window.

**What I have found so far:**

Looking at the U++ source I found this in `GtkCtrl.h`:


struct Win : Moveable<Win> {
   GtkWidget   *gtk;
   GtkWidget   *drawing_area;   // ← this looks like what I need
   ...
};


And `TopWindow` has a public method:
```cpp
GtkWindow* gtk() const;
```

Using `top->gtk()` I can get the `GtkWindow*` of the `TopWindow`. However, `gtk_container_get_children()` on it always returns an empty list — the `GtkFixed` (drawing_area) that U++ uses internally to position child `Ctrl`s appears to not be a direct GTK child of the `GtkWindow`, or is added after the point where my `Init()` is called.

**What I need:**

A way to obtain the `GtkWidget*` of the `drawing_area` (the `GtkFixed` where U++ places its child controls), so I can call:

gtk_fixed_put(GTK_FIXED(drawing_area), GTK_WIDGET(webKitWebView), x, y);
gtk_fixed_move(GTK_FIXED(drawing_area), GTK_WIDGET(webKitWebView), x, y);
gtk_widget_set_size_request(GTK_WIDGET(webKitWebView), w, h);


**Questions:**

1. Is there a public API in U++ to retrieve the `drawing_area` `GtkWidget*` from a `Ctrl` or `TopWindow`?
2. Is there a recommended way to embed a third-party `GtkWidget` as a child of a U++ `Ctrl` on Linux?
3. Would `DHCtrl` be the right approach here? If so, is there an example of using it with an external `GtkWidget`?

Thank you very much.
Luigi
Previous Topic: Use TheIDE on Windows Subsystem for Linux v2
Goto Forum:
  


Current Time: Sat Jun 06 13:42:13 GMT+2 2026

Total time taken to generate the page: 0.00415 seconds