⬆️ ⬇️

Screwing Head Up Display to MonoDevelop or how the global menu is crookedly done in Ubuntu





The problem with the inoperability of HUD in MonoDevelop goes back to the old bug caused by the transition to the global menu and that MonoDevelop did not show any menus at all. It was " repaired " by turning off the use of the global menu as such. It's so simple, do not fix the problem in your curve, but make a black list of applications.

Pull to the economy of pixels and the desire to still screw the HUD took their own. For two whole hours of my precious time, a few crutches and still it started.



A small excursion into the global menu: it is exported by the application via D-Bus, and so that the developers do not write additional code, Canonical has snapped up clever libraries that take the normal, human menu of the window tulkit and export it to the developer, and but more about that later. At the same time, there is no possibility to manually export this menu. More precisely, there is some kind of muddy library called libdbusmenu and the complete absence of at least some documentation, not to mention binding to something. Such a proprietary concept is the opposite - the code is open, but it cannot be used properly because it is impossible to quickly figure out how to work with it in general. Thus, it is not possible to implement the SetGlobalMenu method in GnomePlatform.cs (designed specifically for systems with a global menu and implemented in MacPlatform.cs), so you have to figure out why a crutch does not work with exporting and invent your crutches to make it work. . I have not dealt with such perversions since the time when Navitel had to be made to work on various-sized Chinese pieces of iron with WinCE 4.2 mutilated beyond recognition.

')



First of all, I removed the crutch with UBUNTU_MENUPROXY vanishing, hoping that all the jambs had already been repaired and everything would work. The miracle did not happen. Okay, see if there are any debugging tools for the global menu. There was a utility called current-menu-dump that produced quite interesting results : the menu is still exported, but no one shows it. There were no explanations for this phenomenon at that time, but the environment variable APPMENU_DISPLAY_BOTH, which forced the export menu to show the normal menu, was also gobbled up. The launch results were even more marvelous:







That is, if you hover on a menu item in a 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 show the global menu items of the first level without submenus
  2. MonoDevelop uses a “lazy” loading of menu items, so there are no submenus at the start


If the medium does not send the event display menu itself, we will do it for her. We quickly add AddIn to MonoDevelop , which finds a menu bar and runs through all the menus, launch, a miracle happens: the global menu appears and works. If it were not for one "minor" trouble:







Paragraphs in points and the lack of hotkeys hints.



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



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



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

Source: https://habr.com/ru/post/143575/



All Articles