简体   繁体   English

如何在GTK#中使用Ubuntu Unity全局菜单?

[英]How to use Ubuntu Unity global menu in GTK#?

I'm developing a simple GTK# application(nothing serious, just a little project), and I've noticed my application menu bar is showing in my application window instead of Ubuntu's Unity global menu bar. 我正在开发一个简单的GTK#应用程序(没什么大不了的,只是一个小项目),我注意到我的应用程序菜单栏显示在应用程序窗口中,而不是Ubuntu的Unity全局菜单栏。

Is there any way to make the menu bar show up in the unity menu bar? 有什么方法可以使菜单栏显示在统一菜单栏中? I've tried to google a bit but most results seem to be about disabling this behavior - I want to enable it. 我尝试了一下google,但大多数结果似乎都与禁用此行为有关-我想启用它。

Currently, I'm adding the menu bar to a VBox, via MonoDevelop's visual editor. 目前,我正在通过MonoDevelop的可视编辑器将菜单栏添加到VBox。

Somehow, the application works fine without any changes. 不知何故,应用程序可以正常运行,而无需进行任何更改。

My menubar is in a vbox which is the only child of the main window I created. 我的菜单栏位于vbox中,这是我创建的主窗口的唯一子级。 It is the first element of the vbox, not sure if that affects anything. 它是vbox的第一个元素,不确定是否会影响任何内容。

And here's what I noticed: 这是我注意到的:

I asked this question because when I clicked "Run" on MonoDevelop, the menu bar showed up in the window instead of being global. 我问这个问题是因为当我单击MonoDevelop上的“运行”时,菜单栏显示在窗口中,而不是全局的。

However, when I run it directly from the command-line mono [myappname].exe , it works just fine. 但是,当我直接从命令行mono [myappname].exe运行它时,它就可以正常工作。 Not sure what's going on here. 不知道这是怎么回事。

So apparently the Unity devs made it easy to use the global menu bar automatically, but somehow MonoDevelop does something that disables this behavior when the app is run from MD. 因此,显然,Unity开发人员可以轻松地自动使用全局菜单栏,但是从MD运行应用程序时,MonoDevelop会以某种方式禁用此行为。 Not sure if it is a bug of MD, expected behavior or if there's some gotcha going on here. 不知道这是MD的错误,预期的行为还是此处发生了一些问题。

Since the application is only run from MD for testing purposes, I'm accepting it the way it is now. 由于该应用程序仅出于测试目的而从MD运行,因此我现在接受它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM