Is there a way to make changes to the titlebar with GTK2?

本秂侑毒 提交于 2019-12-14 03:55:07

问题


I have a desktop application written in Ruby that is using GTK2. It's just a small test application to play with GTK2, but I'm having problems achieving what I want to do. Is there any way using GTK2 to get at the titlebar (apart from setting the title), specifically to either add a button to it (beside the min/max/etc, B in the below diagram) or to add an option to the menu that pops up when you click the icon on the titlebar (A in the below diagram)?

I'm thinking there might not be because GTK is meant to work with many many different window managers, but I just wondered if there was. As a side question, what event does clicking the 'cross' button fire? At the moment if the user clicks that the window disappears but the program doesn't end - I need to capture that event and quit the program.

Thanks for any help, including hitting me over the head and telling me how silly I am.


回答1:


No, the title bar is owned by the window manager and you will typically not have direct access to it.

When the user tries to close the window by clicking the window manager's button, the window will receive the delete event.




回答2:


Note that this is possible in GTK 3.10 and up, by using gtk_window_set_titlebar(). It replaces the window manager's title bar with a custom one. GtkHeaderBar is a good custom title bar class to use.

You can't, however, make it look just like the window manager would, because you won't know which window manager the user is running.



来源:https://stackoverflow.com/questions/3753098/is-there-a-way-to-make-changes-to-the-titlebar-with-gtk2

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!