Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm porting a commercial app to Linux, it is to run on several distros. When run on Ubuntu, the GtkMenuBar is removed from the app's window and placed on the main global menu bar. That's fine ... but there is a corresponding empty space in the app window where the menu was removed (it is placed with GtkFixed). I need to be able to detect when this has happened (and ONLY) when it has happened from any distro, so that I can reliably remove the empty space.

What's the best way to detect this? (ie via gtk_widget_... calls) What has been done to the GtkMenuBar to achieve this? Thanks.

share|improve this question

The problem isn't that anything in particular has been done to the GtkMenuBar (it's just been hidden). The problem is because you're using GtkFixed to position it, and so things do not automatically resize when the MenuBar goes away.

Is there any particular reason you're using a GtkFixed to position things, rather than using the normal box layout structure of GTK+? You may want to look into using GtkApplication and/or GtkBuilder to create and present your user interface, instead, rather than using absolute positioning with GtkFixed.

If you wish to continue using GtkFixed, you'll need to watch a property (or signal) on the GtkMenuBar, and reposition and/or resize the other widgets in your window manually, when the GtkMenuBar is hidden.

share|improve this answer
When does it go away? Is the GtkMenuBar itself patched so I can detect this early, or does something come along later and hide it? Is there a way to ask the GtkMenuBar if it is going to stay hidden? GtkFixed is used because #1) this is a ported app that runs on Win and Mac as well, so autosizing is a considerable hindrance, #2) there is sophisticated XML-based layout language present instead. – dajoke Feb 27 '13 at 17:14
I am not 100% certain, but I think it's a GTK+ module that's doing the work. When the feature is enabled, and when the user is running under Unity, the menu structure will get parsed, and the in-window bar gets hidden. I think the hide signal is emitted when this happens. The GTK+ documentation lists all the signals for widgets. Should be simple enough to test with a simple Python script as well if necessary to discover the exact method to use. – dobey Feb 27 '13 at 19:21
I don't see any hide signal, or configure or size-allocate. The menubar is still listed as visible, realized, and mapped, though it is allocated at 0,0 with size of 0,0. I'm not sure how this is being achieved. – dajoke Mar 9 '13 at 17:41
PS - if anyone can direct me to the code that causes this, that would be a great help. – dajoke Mar 9 '13 at 18:13
up vote 1 down vote accepted

Here's what I finally had to resort to for multiple distros and the possibility the user has set an exception:

static int menu_proxy = -1;
typedef void *(*KVoidPtoF)();

void *proxylib;
KVoidPtoF gtk_menu_proxy_get;

menu_proxy = 0;
proxylib = dlopen("", RTLD_NOLOAD | RTLD_LAZY);
if (proxylib)
    gtk_menu_proxy_get = (KVoidPtoF)dlsym(proxylib, 
    if (gtk_menu_proxy_get && (*gtk_menu_proxy_get)() != 0)
        menu_proxy = 1;
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.