We fasten the Head Up Display to MonoDevelop or how the global menu is crookedly made in Ubuntu



    The problem with the inoperability of the HUD in MonoDevelop is rooted in an old bug caused by the transition to the global menu, which consisted in the fact that no menus were shown at all in MonoDevelop. It was repaired by turning off the use of the global menu as such. It's so simple, not to fix the problem in your own curve, but to make a blacklist of applications.
    The desire for saving pixels and the desire to still screw the HUD took their toll. As much as two hours of my precious time, a few crutches and still wound up.

    A small digression into the work of the global menu: it is exported by the application via D-Bus, and so that the developers do not write additional code, Canonical riveted the inverted libraries that take the normal, human menu of the window toolkit and export it for the developer, and, as it turned out, it’s very crooked, but more on that later. However, there is no way to manually export this menu. More precisely, there is some kind of muddy library with the name libdbusmenu and the complete absence of at least some documentation, not to mention bindings to something. This kind of proprietorship is the opposite - the code is open, but you can’t use it properly because you cannot quickly understand how to work with it at all. Thus, implement the SetGlobalMenu method in GnomePlatform.cs (provided specifically for systems with a global menu and implemented in MacPlatform. cs) it is not possible, well, you have to figure out why the crutch does not work with the exporter and come up with your crutches to make it work. I have not dealt with such perversions since the time when it was necessary to make Navitel work on various-sized Chinese pieces of iron with WinCE 4.2 mutilated beyond recognition.


    First of all, I removed the crutch with the UBUNTU_MENUPROXY zeroing, hoping that all the jambs had already been fixed and everything worked. No miracle happened. Okay, see if there are any debugging tools for the global menu. There was a utility called current-menu-dump, which produced very interesting results : the menu is still exported, but nobody shows it. There was no explanation for this phenomenon at that time, but the environment variable APPMENU_DISPLAY_BOTH was googled, forcing the exporter to show the normal menu as well. The launch results were even more marvelous:



    That is, if you hover over a menu item in the normal menu bar, it immediately appears in the global menu.

    This strange behavior is explained by a combination of two original technical solutions:

    1. Unity does not display first level global menu items without submenus
    2. MonoDevelop uses “lazy” loading of menu items, so there are no these submenus at the start

    If the environment does not send menu display events itself, we will do it for it. In a hurry, we sculpt AddIn to MonoDevelop , which finds the menu bar and runs through all the menus, we start it, a miracle happens: a global menu has appeared and works. If it weren’t for one “minor” nuisance:



    P_ underscores in points and lack of hints for hotkeys.

    This is again caused by the crooked implementation of libappmenu: it cannot adequately handle complex menu items, and they are complex in MonoDevelop, each item inside is HBox with two Labels, one for signature, another for hotkey, left and right aligned, respectively. It was cured by catching a notification about a change in the “label” property of, in fact, one of the Labels, for the presence of which I want to say a lot of human thanks to the GLib developers, for I did not even see an adequate automatic implementation of IPropertyChanged for all classes and properties.

    To get HUD and global menu support in MonoDevelop, you need to install the monodevelop-latest and monodevelop-appmenu packages from my PPA (builds only for 12.04):

    sudo apt-add-repository ppa:keks9n/monodevelop-latest
    sudo apt-get update
    sudo apt-get install  monodevelop-latest monodevelop-appmenu
    

    Also popular now: