Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Is it possible to check from the application if its menu will be displayed in the window or in the panel (AppMenu)?

I can of course check if the environment is Unity, but some people use AppMenu in KDE or in classic GNOME, so I'm looking for more universal way.

I'll prefer a way suitable for C language and working in Ubuntu 11.10.

share|improve this question

3 Answers 3

Here's a more complete answer that works from any Linux distro:

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

void *proxylib;
KVoidPtoF gtk_menu_proxy_get;

menu_proxy = 0;
proxylib = dlopen("libappmenu.so", RTLD_NOLOAD | RTLD_LAZY);
if (proxylib)
{
    gtk_menu_proxy_get = (KVoidPtoF)dlsym(proxylib, 
        "ubuntu_menu_proxy_get");
    if (gtk_menu_proxy_get && (*gtk_menu_proxy_get)() != 0)
        menu_proxy = 1;
}
share|improve this answer
up vote 0 down vote accepted

I have found a better solution here: https://wiki.ubuntu.com/MenuBar#Advertising_the_presence_of_the_menu_bar.

share|improve this answer

I'm not sure how to check for the Qt module specifically. To look for the GTK module you can look for the environment variable UBUNTU_MENUPROXY. If you want to ensure that menus appear in the applications (and are exported if possible) then you can set APPMENU_DISPLAY_BOTH to 1. If you want to see if the indicator-appmenu host is taking menus you can look for the well-known-name "com.canonical.AppMenu.Registrar" on DBus. If it exists, it is hosting menus.

share|improve this answer

Your Answer

 
discard

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.