Skip to content
This repository has been archived by the owner on Jun 8, 2021. It is now read-only.

Window function set_titlebar generate gtk-CRITICAL error messages when moving window #269

Closed
Weboholics opened this issue Jan 31, 2019 · 2 comments

Comments

@Weboholics
Copy link

Weboholics commented Jan 31, 2019

Line 41 in sourcefile mainwindow.rs enables moving window by pressing mousebutton over the headerbar in the window. When running the program in shell and moving the window I get this message:

gtk_container_propagate_draw: assertion '_gtk_widget_get_parent (child) == GTK_WIDGET (container)' failed

https://developer.gnome.org/gtk3/stable/GtkHeaderBar.html
(using headerbar with set_titlebar)
For these reasons, GtkHeaderBar is the natural choice for use as the custom titlebar widget of a GtkWindow (see gtk_window_set_titlebar()), as it gives features typical of titlebars while allowing the addition of child widgets.

https://developer.gnome.org/gtk3/stable/GtkWindow.html#gtk-window-set-titlebar
(set-titlebar api)
In gtk refrences it seems that set-titlebar should accept any type of GtkWidget

I am new to rust, gtk, open source and linux programming so excuse stupid misstakes I have made.

example code below
moving_window_error.zip

@greyltc
Copy link

greyltc commented Feb 16, 2020

I've run into the same thing today. Can anyone offer any help?

@sdroege
Copy link
Member

sdroege commented Feb 20, 2020

There are a couple of mistakes in the attached example:

  • putting the headerbar into a vbox and then afterwards setting it as titlebar, that's not allowed as each widget must only have a single parent. That gets rid of the critical warnings. If you set it as a titlebar then you can move the window on it, if you add it to the vbox then you need to implement the moving yourself
  • disabling decorations for the window, this will also disable the titlebar

I'd recommend looking at the example here https://github.com/gtk-rs/examples/blob/master/src/bin/progress_tracker.rs

@GuillaumeGomez Please close this one :)

This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants