Subject: FVWM: Dynamic Menus

From: Nils Lohner <[email-masked]>
Date: Tue, 21 Oct 1997 14:48:49 -0400

I caught this line in an .fvwm2rc.m4 and was wondering if anyone had a
sample script that showed off how to create the dynamic menus.  I was
specifically wondering how to get xterms popping up and cd'ing to different
directories automatically.

AddToFunc Dynamic-Menu-Func     "I" DestroyMenu "Dynamic-Menu"
+                               "I" FvwmM4 lib/fvwm/dynamic-menu
+                               "I" Menu Dynamic-Menu
 
Thanks, Nils.
--
Visit the official FVWM web page at <URL:http://www.hpc.uh.edu/fvwm/>.
To unsubscribe from the list, send "unsubscribe fvwm" in the body of a
message to [email-masked].
To report problems, send mail to [email-masked].

---

From: Nils Lohner <[email-masked]>
Date: Thu, 23 Oct 1997 12:30:17 -0400

OK, I've been playing with dynamic directory menus, and here's wha tI
currently have:

AddToMenu RootMenu "Root Menu"  Title
+       "Xterm 80x24"   Exec exec xterm -si -sk -geom 80x24&
+       "Xterm 80x40"   Exec exec xterm -si -sk -geom 80x40&
+       "Xterm 80x60"   Exec exec xterm -si -sk -geom 80x60&
+                       ""              Nop
+       "Xterm 80x24 Dir" DynamicDir24
+       "Xterm 80x40 Dir" DynamicDir40
+       "Xterm 80x60 Dir" DynamicDir60

AddToFunc DynamicDir24
+       "I" DestroyMenu "_root_u_lohner"
+       "I" PipeRead "/u/lohner/projects/treemenu/dynamic.pl /u/lohner 80x24"
+       "I" Popup _root_u_lohner

 and dynamic.pl is a perl5 script that takes the directory to scan, scans
it, and returns a menu for FVWM to parse, like this:

DestroyMenu     "_root_u"
AddToMenu       _root_u "/u"    Title
+       "XTerm ./"      Exec /bin/sh -c 'cd /u;exec xterm -si -sk -geom 80x24&'
+       "../"   _root_Func
+       "lohner/"       _root_u_lohnerFunc
 
AddToFunc _root_Func"
+ "I" PipeRead "/u/lohner/projects/treemenu/dynamic.pl / 80x24"
+ "I" Popup _root_
+ "C" DestroyMenu "_root_"
+ "I" DestroyFunc "_root_Func"
 
AddToFunc _root_u_lohnerFunc
+ "I" PipeRead "/u/lohner/projects/treemenu/dynamic.pl /u/lohner 80x24"
+ "I" Popup _root_u_lohner
+ "C" DestroyMenu "_root_u_lohner"
+ "I" DestroyFunc "_root_u_lohnerFunc"

The problem is this:  sometimes it works fine, sometimes it doesn't,
sometimes it refuses to remove the popups, sometimes it kills my window
system and returns to my login prompt with a core dump.  Can anyone suggest
how the AddToFuncs should look to work best?  Is it legal to have a Func
destroy itself?  Should all items be "I"?  The last two "C"?  Menu instead
of Popup?  I've tried a number of these with varying results, but so far
nothing has worked consistently so I'm wondering what the 'correct' way of
doing this is.
  Or, if anyone has a dynamic directory menu working, I wouldn't mind a
copy of that.  If anyone wants my perl code, I can post it once its
working.
  Thanks for the help in advance.

Nils.

---

From: Andrew Veliath <[email-masked]>
Date: Thu, 23 Oct 1997 18:31:16 -0400

Self-destroying functions are buggy in fvwm2, since ComplexFunction in
complex.h reuses the pointer after it has been destroyed with
DeleteFunction (!).  This is a bug, and I agree, it would be nice if
they worked.  I'm only guessing that's the problem your having, but
since I saw that your function did that, I thought I'd bring it up
again.

This was discussed a while back (one of the examples included uses
technique), but no one had time to look into it further.  A hack to
get around it should probably get into 2.0.47 and shouldn't be too
hard.  If I get some time I'll look into it, but at the moment my
hands are tied.

--
Regards,
Andrew Veliath
[email-masked], [email-masked]

>>>>> Nils Lohner writes:

    Nils> The problem is this: sometimes it works fine, sometimes it
    Nils> doesn't, sometimes it refuses to remove the popups,
    Nils> sometimes it kills my window system and returns to my login
    Nils> prompt with a core dump.  Can anyone suggest how the
    Nils> AddToFuncs should look to work best?  Is it legal to have a
    Nils> Func destroy itself?  Should all items be "I"?  The last two
    Nils> "C"?  Menu instead of Popup?  I've tried a number of these
    Nils> with varying results, but so far nothing has worked
    Nils> consistently so I'm wondering what the 'correct' way of
    Nils> doing this is.  Or, if anyone has a dynamic directory menu
    Nils> working, I wouldn't mind a copy of that.  If anyone wants my
    Nils> perl code, I can post it once its working.  Thanks for the
    Nils> help in advance.
--
Visit the official FVWM web page at <URL:http://www.hpc.uh.edu/fvwm/>.
To unsubscribe from the list, send "unsubscribe fvwm" in the body of a
message to [email-masked].
To report problems, send mail to [email-masked].