最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

gtk - Size GtkPopover to the composite widget - Stack Overflow

programmeradmin2浏览0评论

I want to set a GtkPopover widget to fit the size of the composite widget.

I have been reading around and know that in gtk3 you could listen to the size-allocate signal, but that no longer exists in gtk4. I read in a Q&A thread that it's best to use properties, but GtkWidget and GtkPopover only have width-request. I tried binding the property and nothing changes.

What would be the right way to size the GtkPopover?

Widget structure

GtkWidget (BoxLayout)
|-GtkEntry
|-GtkButton
|-GtkPopover

Update: Thanks to WhiteOwl comment, size-allocate has been removed and told to use resize signal on GtkDrawingArea and GtkGLArea. But since it's a pure composite widget this change is more of a hindrance.

.html#adapt-to-gtkwidgets-size-allocation-changes

Have tried getting the size in realize and map on GtkWidget but width returns 0 for get_size with Horizontal.

I want to set a GtkPopover widget to fit the size of the composite widget.

I have been reading around and know that in gtk3 you could listen to the size-allocate signal, but that no longer exists in gtk4. I read in a Q&A thread that it's best to use properties, but GtkWidget and GtkPopover only have width-request. I tried binding the property and nothing changes.

What would be the right way to size the GtkPopover?

Widget structure

GtkWidget (BoxLayout)
|-GtkEntry
|-GtkButton
|-GtkPopover

Update: Thanks to WhiteOwl comment, size-allocate has been removed and told to use resize signal on GtkDrawingArea and GtkGLArea. But since it's a pure composite widget this change is more of a hindrance.

https://docs.gtk.org/gtk4/migrating-3to4.html#adapt-to-gtkwidgets-size-allocation-changes

Have tried getting the size in realize and map on GtkWidget but width returns 0 for get_size with Horizontal.

Share Improve this question edited Jan 20 at 13:18 NebulaFox asked Jan 19 at 13:29 NebulaFoxNebulaFox 8,3139 gold badges51 silver badges67 bronze badges 2
  • docs.gtk.org/gtk4/… – White Owl Commented Jan 19 at 19:52
  • @WhiteOwl sadly it doesn't help, as the widget isn't a GtkDrawingArea. – NebulaFox Commented Jan 20 at 13:15
Add a comment  | 

1 Answer 1

Reset to default 0

I ended up reporting an issue on GTK's gitlab. Turns out I was looking in all the wrong places.

A maintainer replied with

If you are talking about a generic widget and its snapshot() vfunc, the size of the widget (in application units) is available at snapshot time via gtk_widget_get_width() and gtk_widget_get_height(). To go from application units to device pixels requires to factor in transforms and scale. See https://docs.gtk.org/gtk4/coordinates.html#scaling

发布评论

评论列表(0)

  1. 暂无评论