[MissingSubmenuFunction] - Can use only one - (Solved)

Good evening or whatever it is out there.

I have another question, this time about MissingSubmenuFunction. It is a very cool feature (and powerfull) that, unfortunatelly is not so well documented. I’m trying to convert all my configuration menus into dinamic ones, so they are regenerated automatically when the contents change. So far, I got this working:

DestroyMenu menu_fvwmConfig
AddToMenu menu_fvwmConfig MissingSubmenuFunction WallpaperBrowser
+ "Wallpapers" 					Popup WallpaperBrowser
AddToMenu   menu_fvwmConfig
+ "&Color sets%wine.png%"			Popup menu_Colorsets
+ "&Decoración%wine.png%"			Popup menu_Decorations

Of course, the WallpaperBrowser function is defined elsewhere. All is fine. The problem comes when I try to add another dinamic element (I suspect that I’m doing it terribly wrong). I try this:

DestroyMenu menu_fvwmConfig
AddToMenu menu_fvwmConfig MissingSubmenuFunction WallpaperBrowser
+ "Wallpapers" 					Popup WallpaperBrowser
AddToMenu menu_fvwmConfig MissingSubmenuFunction ColorsetBrowser
+ "Colorsets" 					Popup ColorsetBrowser
+ "&Decoración%wine.png%"			Popup menu_Decorations

The problem is that, now, the colorsets menu is displayed and correctly updated when needed, but the wallpapers one does not display anymore. If I swap the order then the wallpapers menu is shown but the colorset is not. So, I suppose that, the latest MissingSubmenuFunction, takes precedence and kill the previous one. I think that Im not doing this with a correct sintax, or is it maybe that can only be one MissingSubmenuFunction on each menu level?

I tried to dig into the man page, but there are only three references to MissingSubmenuFunctions (not too much for such a complex function…).

Thanks, people, for any help :wink:

EDIT: I tried the following, which is basically the same, so, the behaviour is also the same. :cry:

DestroyMenu menu_fvwmConfig
AddToMenu menu_fvwmConfig
+ MissingSubmenuFunction	WallpaperBrowser
+ "Wallpapers%wine.png%"	Popup WallpaperBrowser
+ MissingSubmenuFunction	ColorsetBrowser
+ "&Colorsets%wine.png%"	Popup ColorsetBrowser
+ "&Decoración%wine.png%"	Popup menu_Decorations

Have a look at using:

DestroyMenu recreate foo

– Thomas Adam

I will answer myself again. Seems that there is only possible one MissingSubmenuFunction definition per menu level, so, the solution is to define all the dinamic stull into the same function. At least that is the solution that I worked out.

DestroyMenu menu_fvwmConfig
AddToMenu menu_fvwmConfig
+ MissingSubmenuFunction	user_fvwmConfigDinamicStuff
+ "Wallpapers%wine.png%"	Popup WallpaperBrowser
+ "&Colorsets%wine.png%"	Popup ColorsetBrowser
+ "&Color sets%wine.png%"	Popup menu_Colorsets
+ "&Decoración%wine.png%"	Popup menu_Decorations

SetEnv fvwm_wallpaper_dir /home/i92guboj/.fvwm/wallpapers/
DestroyFunc user_fvwmConfigDinamicStuff
AddToFunc user_fvwmConfigDinamicStuff
+ I DestroyMenu WallpaperBrowser
+ I AddToMenu WallpaperBrowser
+ I + DynamicPopDownAction DestroyMenu WallpaperBrowser
+ I PipeRead 'test ! -d $[fvwm_wallpaper_dir]/.thumbs && mkdir $[fvwm_wallpaper_dir]/.thumbs; \
   for i in $[fvwm_wallpaper_dir]/*; do \
      test -f "$[fvwm_wallpaper_dir]/.thumbs/${i##*/}" \
         -a "${i}" -ot "$[fvwm_wallpaper_dir]/.thumbs/${i##*/}" || { \
            convert -quality 0 -scale 128 "${i}" "png:$[fvwm_wallpaper_dir]/.thumbs/${i##*/}" 2>/dev/null \
               || continue; \
         }; \
      printf "+ *%s*\\"%s\\" Exec exec fvwm-root -r %s\\n" \
         "$[fvwm_wallpaper_dir]/.thumbs/${i##*/}" "${i##*/}" "${i}"; \
   done'
+ I DestroyMenu ColorsetBrowser
+ I AddToMenu ColorsetBrowser
+ I + DynamicPopDownAction DestroyMenu ColorsetBrowser
+ I PipeRead 'for i in ${fvwm_colorsets}/*.cs; \
	do echo "+ $i user_ChangeColorset $i"; done'

DestroyFunc user_ChangeColorset
AddToFunc   user_ChangeColorset
+ I Piperead 'rm -f $[fvwm_colorsets]/.colorset'
+ I Piperead 'ln -s $0 $[fvwm_colorsets]/.colorset'
+ I Read $[fvwm_colorsets]/.colorset
+ I Restart

DestroyFunc user_ChangeDecoration
AddToFunc   user_ChangeDecoration
+ I Piperead 'rm -f $[fvwm_decorations]/.decoration'
+ I Piperead 'ln -sf $0 $[fvwm_decorations]/.decoration'
+ I Read $[fvwm_decorations]/.decoration
+ I Restart

That is the code along with all the auxiliary functions (so I hope). The thumbs function for the wallpapers menu is from Taviso, but modified to show bigger thumbnails and to ut them above the filename, rather than to the right.

I will look into that also. Thanks for the tip.