Subject: Greyed patch, round 2

From: Daniel Henninger <[email-masked]>
Date: Thu, 14 Mar 2002 09:43:37 -0500 (EST)

Here is the very same patch from yesterday, applied to todays snapshot.
It's behaving itself so far.  =)

Daniel

-- 
/\\\----------------------------------------------------------------------///\
\ \\\      Daniel Henninger           http://www.vorpalcloud.org/        /// /
 \_\\\      North Carolina State University - Systems Programmer        ///_/
    \\\                   Information Technology <IT>                  ///
     """--------------------------------------------------------------"""
diff -cr fvwm-snap-20020314.old/fvwm/fvwm2.1 fvwm-snap-20020314/fvwm/fvwm2.1
*** fvwm-snap-20020314.old/fvwm/fvwm2.1	Sun Mar 10 07:30:02 2002
--- fvwm-snap-20020314/fvwm/fvwm2.1	Thu Mar 14 09:41:01 2002
***************
*** 1792,1797 ****
--- 1792,1809 ----
  creates a menu with a picture in its bottom left corner and
  colors with blue the region of the menu containing the picture.
  
+ If a menu-label starts with '~', then it is greyed out.  This might be useful
+ if you are creating a menu on the fly and want to be able to grey out items
+ if they don't exist in a particular host.  If you want a literal '~', you
+ should insert "~~".  Example:
+ .EX
+ AddToMenu "~~Local Netscape Install"
+ .EE
+ puts Local Netscape Install in the menu, but has it greyed out.  There is no
+ restriction as to whether this greyed-out status will still do something if
+ it is clicked on.  It's up to the user to make the menu item Nop if that is
+ what is desired.
+ 
  In all the above cases, the name of the resulting menu is name
  specified, stripped of the substrings between the various
  delimiters.
***************
*** 3694,3700 ****
  .IR UseIconName ,
  .IR Alphabetic " / " NotAlphabetic ,
  .IR NoHotkeys ,
! .IR SelectOnRelease .
  
  (Note - normal means not iconic, sticky, or on top)
  
--- 3706,3713 ----
  .IR UseIconName ,
  .IR Alphabetic " / " NotAlphabetic ,
  .IR NoHotkeys ,
! .IR SelectOnRelease ,
! .IR GreyIconic
  
  (Note - normal means not iconic, sticky, or on top)
  
***************
*** 3708,3713 ****
--- 3721,3732 ----
  key.  To switch it off, use
  .I SelectOnRelease
  without a key name.
+ 
+ The
+ .I GreyIconic
+ option causes any windows that are iconified to show up using the
+ .B Greyed / GreyedColorset
+ color scheme.
  
  If you pass in a function via
  .IR "Function funcname" ,
diff -cr fvwm-snap-20020314.old/fvwm/menuitem.c fvwm-snap-20020314/fvwm/menuitem.c
*** fvwm-snap-20020314.old/fvwm/menuitem.c	Wed Mar 13 07:30:02 2002
--- fvwm-snap-20020314/fvwm/menuitem.c	Thu Mar 14 09:28:31 2002
***************
*** 550,555 ****
--- 550,557 ----
  	{
  		currentGC = (is_item_selected) ?
  			ST_MENU_ACTIVE_GC(ms) : ST_MENU_GC(ms);
+ 		if (MI_IS_GREYED(mi))
+ 			currentGC = ST_MENU_STIPPLE_GC(ms);
  		if (ST_DO_HILIGHT(ms) &&
  		    !ST_HAS_ACTIVE_FORE(ms) &&
  		    !ST_HAS_ACTIVE_CSET(ms) &&
diff -cr fvwm-snap-20020314.old/fvwm/menuitem.h fvwm-snap-20020314/fvwm/menuitem.h
*** fvwm-snap-20020314.old/fvwm/menuitem.h	Sun Mar  3 12:11:06 2002
--- fvwm-snap-20020314/fvwm/menuitem.h	Thu Mar 14 09:20:12 2002
***************
*** 50,55 ****
--- 50,56 ----
  #define MI_HAS_HOTKEY(i)        ((i)->flags.has_hotkey)
  #define MI_IS_HOTKEY_AUTOMATIC(i) ((i)->flags.is_hotkey_automatic)
  #define MI_IS_SELECTABLE(i)     ((i)->flags.is_selectable)
+ #define MI_IS_GREYED(i)		((i)->flags.is_greyed)
  /* temporary flags */
  #define MI_WAS_DESELECTED(i)    ((i)->flags.was_deselected)
  
***************
*** 100,105 ****
--- 101,107 ----
  		unsigned has_hotkey : 1;
  		unsigned is_hotkey_automatic : 1;
  		unsigned is_selectable : 1;
+ 		unsigned is_greyed : 1;
  		/* temporary flags */
  		unsigned was_deselected : 1;
  	} flags;
diff -cr fvwm-snap-20020314.old/fvwm/menus.c fvwm-snap-20020314/fvwm/menus.c
*** fvwm-snap-20020314.old/fvwm/menus.c	Wed Mar 13 07:30:02 2002
--- fvwm-snap-20020314/fvwm/menus.c	Thu Mar 14 09:24:30 2002
***************
*** 5048,5053 ****
--- 5048,5085 ----
  	return;
  }
  
+ /*
+    scans for a "grey this menu item out" indicator, which is a ~ at the
+    beginning of it.		<[email-masked]>
+ */
+ static void scanForGreyed(MenuItem *it, int column)
+ {
+   char *txt;
+ 
+   txt = MI_LABEL(it)[column]; /* Get start of string  */
+   /* Scan first character of string   */
+   if (*txt == '~')
+   {           /* A greyed indicator?          */
+     if (txt[1] == '~')
+     { /* Just an escaped ~                    */
+       char *tmp;              /* Copy the string down over it */
+       for (tmp = txt; *tmp != '\0';
+            tmp++) tmp[0] = tmp[1];
+     }
+     else
+     {
+       /* It's a greyed indicator */
+       MI_IS_GREYED(it) = 1;
+       for (; *txt != '\0'; txt++)
+       {
+         /* Copy down.. */
+         txt[0] = txt[1];
+       }
+     }
+   }
+   return;
+ }
+ 
  
  /* Side picture support: this scans for a color int the menu name
     for colorization */
***************
*** 6634,6639 ****
--- 6666,6676 ----
  					MI_HAS_HOTKEY(tmp) = 1;
  					MI_IS_HOTKEY_AUTOMATIC(tmp) = 1;
  				}
+ 			}
+ 			if (!MI_IS_GREYED(tmp))
+ 			{
+ 				/* [email-masked] */
+ 				scanForGreyed(tmp, i);
  			}
  			if (*(MI_LABEL(tmp)[i]))
  			{
diff -cr fvwm-snap-20020314.old/fvwm/windowlist.c fvwm-snap-20020314/fvwm/windowlist.c
*** fvwm-snap-20020314.old/fvwm/windowlist.c	Wed Mar 13 07:30:03 2002
--- fvwm-snap-20020314/fvwm/windowlist.c	Thu Mar 14 09:18:21 2002
***************
*** 64,69 ****
--- 64,70 ----
  #define NO_CURRENT_DESK_TITLE   (1<<11)
  #define TITLE_FOR_ALL_DESKS     (1<<12)
  #define NO_NUM_IN_DESK_TITLE    (1<<13)
+ #define GREY_ICONIC             (1<<14)
  #define SHOW_EVERYTHING (SHOW_GEOMETRY | SHOW_ALLDESKS | SHOW_NORMAL | SHOW_ICONIC | SHOW_STICKY)
  
  /* Function to compare window title names
***************
*** 123,128 ****
--- 124,130 ----
    int ii;
    char tname[80];
    char loc[40];
+   char tmpbuf[40];
    char *name=NULL;
    int dwidth;
    int dheight;
***************
*** 260,265 ****
--- 262,269 ----
  	show_listskip = 1;
        else if (StrEquals(tok,"OnlyListSkip"))
  	show_listskip = 2;
+       else if (StrEquals(tok,"GreyIconic"))
+ 	flags |= GREY_ICONIC;
        else if (StrEquals(tok,"NoDeskNum"))
  	flags |= NO_DESK_NUM;
        else if (StrEquals(tok,"NoCurrentDeskTitle"))
***************
*** 471,481 ****
          if (!name)
            name = "NULL_NAME";
  
!         t_hot = safemalloc(strlen(name) + 48);
! 	if (use_hotkey)
!           sprintf(t_hot, "&%c. ", scut);         /* Generate label */
! 	else
! 	  *t_hot = 0;
          if(!(flags & SHOW_INFONOTGEO))
            strcat(t_hot, name);
  
--- 475,492 ----
          if (!name)
            name = "NULL_NAME";
  
!         t_hot = safemalloc(strlen(name) + 49);
! 
!         if (IS_ICONIFIED(t) && (flags & GREY_ICONIC))
!           sprintf(t_hot, "~");
!         else
!           *t_hot = 0;
! 
! 	if (use_hotkey) {
!           sprintf(tmpbuf, "&%c. ", scut);         /* Generate label */
!           strcat(t_hot, tmpbuf);
! 	} 
! 
          if(!(flags & SHOW_INFONOTGEO))
            strcat(t_hot, name);

---

From: Mikhael Goikhman <[email-masked]>
Date: Thu, 14 Mar 2002 15:11:12 +0000

> It's behaving itself so far.  =)

The patch is hard to read, please use "diff -ur", not "diff -cr".
Also writting a ChangeLog entry would be nice.

I don't think that escaping a literal "~" with "~" is right. How would you
specify a grayed item starting with a literal "~" then? I suggest to
escape it with backslash (in fvwmrc file it is double backslash) - "\\~".
So a leading backslash may always be ignored in menu items. This way it is
possible to add more specifiers with a special meaning at the start.

Regards,
Mikhael.
--
Visit the official FVWM web page at <URL:http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm-workers" in the
body of a message to [email-masked].
To report problems, send mail to [email-masked]

---

From: Daniel Henninger <[email-masked]>
Date: Thu, 14 Mar 2002 11:08:50 -0500 (EST)

> Also writting a ChangeLog entry would be nice.

No problem, it's attached with ChangeLog entry included this time.

> possible to add more specifiers with a special meaning at the start.

I see your point.  I've changed the patch around to make a
"scanInitialFlag" function instead of scanForGreyed.  The function probes
the initial part of the string, up until it either hits a backslash or an
alphanumeric character (or the end of the string), looking for "whatever
flag you pass it".  Hopefully that'll be helpful in the future if there
are other flags that are added like this, and also so potentially it could
have:
*~@$Neat Menu Item With Four Different Flags

Yeah, if a menu item starts with === or something, then it'll scan over
the ='s as well, but I don't think that'll be all that big of a problem.
Was just trying to prevent it from pointlessly going over the whole
string.

Does this sound like a better option?

Daniel

diff -ur fvwm-snap-20020314.old2/ChangeLog fvwm-snap-20020314/ChangeLog
--- fvwm-snap-20020314.old2/ChangeLog	Thu Mar 14 07:30:02 2002
+++ fvwm-snap-20020314/ChangeLog	Thu Mar 14 11:07:40 2002
@@ -1,3 +1,26 @@
+2002-03-14  Daniel Henninger  <[email-masked]>
+
+	* fvwm/menus.c (scanInitialFlags):
+	added function
+
+	* fvwm/menus.c (AddToMenu):
+	added check for greyed(~) indicator using scanInitialFlags
+
+	* fvwm/menuitem.c (menuitem_paint):
+	added for greyed flag
+
+	* fvwm/menuitem.h:
+	added MI_IS_GREYED macro and is_greyed flag to MenuItem struct
+
+	* fvwm/windowlist.c (CMD_WindowList):
+	added check for GreyIconic option
+	changed ordering of label creation to account for possible ~ at front
+
+	* fvwm/fvwm2.1:
+	added instructions for use of GreyIconic WindowList flag and for
+	specifying greyed out menu options
+
+
 2002-03-13  Dominik Vogt  <[email-masked]>
 
 	* libs/gravity.c (ParseDirectionArgument):
diff -ur fvwm-snap-20020314.old2/fvwm/fvwm2.1 fvwm-snap-20020314/fvwm/fvwm2.1
--- fvwm-snap-20020314.old2/fvwm/fvwm2.1	Sun Mar 10 07:30:02 2002
+++ fvwm-snap-20020314/fvwm/fvwm2.1	Thu Mar 14 11:06:51 2002
@@ -1792,6 +1792,19 @@
 creates a menu with a picture in its bottom left corner and
 colors with blue the region of the menu containing the picture.
 
+If a menu-label starts with '~', then it is greyed out.  This might be useful
+if you are creating a menu on the fly and want to be able to grey out items
+if they don't exist in a particular host.  If you want a literal '~', you
+should escape it with a backslash.  You'll need two \\'s in your config
+file for this "\\\\~".  Example:
+.EX
+AddToMenu "~Local Netscape Install"
+.EE
+puts Local Netscape Install in the menu, but has it greyed out.  There is no
+restriction as to whether this greyed-out status will still do something if
+it is clicked on.  It's up to the user to make the menu item Nop if that is
+what is desired.
+
 In all the above cases, the name of the resulting menu is name
 specified, stripped of the substrings between the various
 delimiters.
@@ -3694,7 +3707,8 @@
 .IR UseIconName ,
 .IR Alphabetic " / " NotAlphabetic ,
 .IR NoHotkeys ,
-.IR SelectOnRelease .
+.IR SelectOnRelease ,
+.IR GreyIconic

@@ -3708,6 +3722,12 @@
 key.  To switch it off, use
 .I SelectOnRelease
 without a key name.
+
+The
+.I GreyIconic
+option causes any windows that are iconified to show up using the
+.B Greyed / GreyedColorset
+color scheme.
 
 If you pass in a function via
 .IR "Function funcname" ,
diff -ur fvwm-snap-20020314.old2/fvwm/menuitem.c fvwm-snap-20020314/fvwm/menuitem.c
--- fvwm-snap-20020314.old2/fvwm/menuitem.c	Wed Mar 13 07:30:02 2002
+++ fvwm-snap-20020314/fvwm/menuitem.c	Thu Mar 14 09:28:31 2002
@@ -550,6 +550,8 @@
 	{
 		currentGC = (is_item_selected) ?
 			ST_MENU_ACTIVE_GC(ms) : ST_MENU_GC(ms);
+		if (MI_IS_GREYED(mi))
+			currentGC = ST_MENU_STIPPLE_GC(ms);
 		if (ST_DO_HILIGHT(ms) &&
 		    !ST_HAS_ACTIVE_FORE(ms) &&
 		    !ST_HAS_ACTIVE_CSET(ms) &&
diff -ur fvwm-snap-20020314.old2/fvwm/menuitem.h fvwm-snap-20020314/fvwm/menuitem.h
--- fvwm-snap-20020314.old2/fvwm/menuitem.h	Sun Mar  3 12:11:06 2002
+++ fvwm-snap-20020314/fvwm/menuitem.h	Thu Mar 14 09:20:12 2002
@@ -50,6 +50,7 @@
 #define MI_HAS_HOTKEY(i)        ((i)->flags.has_hotkey)
 #define MI_IS_HOTKEY_AUTOMATIC(i) ((i)->flags.is_hotkey_automatic)
 #define MI_IS_SELECTABLE(i)     ((i)->flags.is_selectable)
+#define MI_IS_GREYED(i)		((i)->flags.is_greyed)
 /* temporary flags */
 #define MI_WAS_DESELECTED(i)    ((i)->flags.was_deselected)
 
@@ -100,6 +101,7 @@
 		unsigned has_hotkey : 1;
 		unsigned is_hotkey_automatic : 1;
 		unsigned is_selectable : 1;
+		unsigned is_greyed : 1;
 		/* temporary flags */
 		unsigned was_deselected : 1;
 	} flags;
diff -ur fvwm-snap-20020314.old2/fvwm/menus.c fvwm-snap-20020314/fvwm/menus.c
--- fvwm-snap-20020314.old2/fvwm/menus.c	Wed Mar 13 07:30:02 2002
+++ fvwm-snap-20020314/fvwm/menus.c	Thu Mar 14 10:57:58 2002
@@ -5048,6 +5048,36 @@
 	return;
 }
 
+/*
+   scans for a specified flag, but only at the 'beginning of the string'.
+   scanning stops once it hits an alphanumeric character, or something
+   escaped out with a \         <[email-masked]>
+*/
+static Bool scanInitialFlags(MenuItem *it, int column, char scanfor)
+{
+  char *start, *txt;
+
+  start = MI_LABEL(it)[column]; /* Get start of string */
+  /* Scan everything up until the first alphanumeric character, or something
+     escaped out */
+  for (txt = start; *txt != '\0' && !isalnum((int) *txt) && *txt != '\\'; txt++)
+  {
+    if (*txt == scanfor)
+    {
+      /* We found what we're looking for */
+      MI_IS_GREYED(it) = 1;
+      for (; *txt != '\0'; txt++)
+      {
+        /* Copy down.. */
+        txt[0] = txt[1];
+      }
+      return 1;
+    }
+  }
+  /* Didn't find it, sorry */
+  return 0;
+}
+
 
 /* Side picture support: this scans for a color int the menu name
    for colorization */
@@ -6633,6 +6663,13 @@
 					MI_HOTKEY_COLUMN(tmp) = i;
 					MI_HAS_HOTKEY(tmp) = 1;
 					MI_IS_HOTKEY_AUTOMATIC(tmp) = 1;
+				}
+			}
+			if (!MI_IS_GREYED(tmp))
+			{
+				/* [email-masked] */
+				if (scanInitialFlags(tmp, i, '~')) {
+					MI_IS_GREYED(tmp) = 1;
 				}
 			}
 			if (*(MI_LABEL(tmp)[i]))
diff -ur fvwm-snap-20020314.old2/fvwm/windowlist.c fvwm-snap-20020314/fvwm/windowlist.c
--- fvwm-snap-20020314.old2/fvwm/windowlist.c	Wed Mar 13 07:30:03 2002
+++ fvwm-snap-20020314/fvwm/windowlist.c	Thu Mar 14 09:18:21 2002
@@ -64,6 +64,7 @@
 #define NO_CURRENT_DESK_TITLE   (1<<11)
 #define TITLE_FOR_ALL_DESKS     (1<<12)
 #define NO_NUM_IN_DESK_TITLE    (1<<13)
+#define GREY_ICONIC             (1<<14)
 #define SHOW_EVERYTHING (SHOW_GEOMETRY | SHOW_ALLDESKS | SHOW_NORMAL | SHOW_ICONIC | SHOW_STICKY)
 
@@ -123,6 +124,7 @@
@@ -260,6 +262,8 @@
@@ -471,11 +475,18 @@
         if (!name)
           name = "NULL_NAME";
 
-        t_hot = safemalloc(strlen(name) + 48);
-	if (use_hotkey)
-          sprintf(t_hot, "&%c. ", scut);         /* Generate label */
-	else
-	  *t_hot = 0;
+        t_hot = safemalloc(strlen(name) + 49);
+
+        if (IS_ICONIFIED(t) && (flags & GREY_ICONIC))
+          sprintf(t_hot, "~");
+        else
+          *t_hot = 0;
+
+	if (use_hotkey) {
+          sprintf(tmpbuf, "&%c. ", scut);         /* Generate label */
+          strcat(t_hot, tmpbuf);
+	} 
+
         if(!(flags & SHOW_INFONOTGEO))
           strcat(t_hot, name);

---

From: Mikhael Goikhman <[email-masked]>
Date: Fri, 15 Mar 2002 11:51:33 +0000

> Does this sound like a better option?

Maybe, if we would not have to keep backward compatibility.
This is a bit too much to ask from a user. It should just test against all
valid specifiers, instead of ignoring all non-alphanumeric chars. For
example I have several menu items like "->" or "<-".

Ideally it should be done differently by specifying Greyed flag, not by
some ascii character in front of the string. I would like if we stop this
hacking that breaks things that are automated. I.e. all automatic menu
generation scripts should include the same escape engine that fvwm itself
uses to parse item strings. This is not good.

I like this patch, but can we delay it until we solve the problem of
specifying more than one action for the menu item? This will make it
possible to specify "Grayed" option just like "CommandOnMouse 2" option.

Regards,
Mikhael.

---

From: Dominik Vogt <[email-masked]>
Date: Fri, 15 Mar 2002 14:14:23 +0100

> possible to specify "Grayed" option just like "CommandOnMouse 2" option.

How about dumping that whole screwed up method to specify options
for individual menu items and doing it from scratch?  E.g.

  NewAddToMenu menu_name item_name [(item_options)] ItemAction
  NewAddToMenu menu_name (menu_options)

and

  + item_name [(item_options)] ItemAction
  + (menu_options)

The item_options and menu_options are enclosed in parentheses and
can be omitted.

Menu options:
  DynamicPopupAction
  DynamicPopdownAction
  MissingSubmenuFunc
  SidePicture
  SideColor
  (did I forget anything?)

Item options:
  Greyed
  Hotkey
  Picture

The mini icons should stay parts of the labels because they are
formatted like the text.

The proposed syntax is almost completely compatible with the old.
Only items that have a name enclosed in parentheses but no action
or items that have an action beginning with a left parenthesis
are interpreted differently.  I can't hink of any reason why
someone would want that.

Bye

Dominik ^_^  ^_^

 --
Dominik Vogt, [email-masked]
Reply-To: [email-masked]
--
Visit the official FVWM web page at <URL:http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm-workers" in the
body of a message to [email-masked].
To report problems, send mail to [email-masked]

---

From: Daniel Henninger <[email-masked]>
Date: Fri, 15 Mar 2002 09:54:16 -0500 (EST)

> > possible to specify "Grayed" option just like "CommandOnMouse 2" option.

I like this option better as well.  Tell you what, I'll start looking into
this and see what I can come up with.  Well, after we have some discussion
about it.  =D

> The item_options and menu_options are enclosed in parentheses and

Couldn't we just do this in MenuStyle or something along those lines?  IE,
if it has to do with the menu as a whole, do it with MenuStyle.  If it has
to do with Items, do it on a per-item basis?

>   Picture

What is the "Picture" one?  Not that menu code really causes a lot of
slowdown, but if nothing else, having the Hotkey specified here will stop
every line from having to be parsed every time...  which I like.  I might
have some other ideas of things to stick here as well.

> The mini icons should stay parts of the labels because they are

I'd definitely agree with this, simply because no one can be sure exactly
where the user would want the pixmap to appear.  Except.. that kinda kills
my "don't parse every line" thing.  lol  I'm not sure there's really
another option for pixmaps other than limiting options and having a:
Pixmap <filename>
PixmapAlignment left | right
item style set.  =/

> are interpreted differently.  I can't hink of any reason why

This is true, but at least they would get a complaint about the line and
go edit it (at least I assume).  The only option I can think of to insure
backwards compatibility would be:
   AddToMenu menu_name item_name ItemAction
   AddToItem item_options
   + item_name ItemAction
   * item_options
   (or ++ or : or whatever)

Except for the fact that old menu item options wouldn't be parsed anymore
and would just show up in the menu item label, this would be 100%
backwards compatible I think.  I kinda like this route better so as not to
ultra-clutter the AddToMenu lines.

Daniel

---

From: Daniel Henninger <[email-masked]>
Date: Fri, 15 Mar 2002 10:54:35 -0500 (EST)

>    AddToMenu menu_name item_name ItemAction

It occured to me that this would make it impossible to update Item actions
on the fly, so maybe this one would be:
AddToItem menu_name item_name item_options
or something like that.

>    (or ++ or : or whatever)

Whereas this one would stay the same for cleanness sake.

Daniel

---

From: Dominik Vogt <[email-masked]>
Date: Fri, 15 Mar 2002 18:20:20 +0100

> to do with Items, do it on a per-item basis?

The you might need a separate menu style for each menu.  The
SidePicture and SideColor options are already part of the menu
style, but for each dynamically generated menu you'd need a
different style.

> > Item options:
> >   Greyed
> >   Hotkey
> >   Picture
> 
> What is the "Picture" one?

The picture is displayed above the item's label.  It's a relic of
the past that I never found a use for.

>  Not that menu code really causes a lot of
> my "don't parse every line" thing.  lol

You have to parse each label for tabs anyway.

>  I'm not sure there's really

The alignment can be defined with the MenuStyle.

>    AddToMenu menu_name item_name ItemAction

Or "NewAddToMenu".  '+' remembers which command it refers to.

Bye

Dominik ^_^  ^_^

---

From: Daniel Henninger <[email-masked]>
Date: Fri, 15 Mar 2002 13:15:56 -0500 (EST)

> style, but for each dynamically generated menu you'd need a

Hrm.  Yeah, that would get ugly real quick.  Would doing something like
what follows be interesting?

NewAddToMenu "AppMenu"
+	Style		SidePixmap "ninja.xpm"
+	Style		SideColor gray
+	Item		"Application Menu" Title
+	Item		"" Nop
+	Item		"Corporate Time" Exec /usr/local/bin/ctime
+	Property	Greyed
+	Property	Hotkey T

And maybe allow for S for style, I for item, P for property, etc?

> the past that I never found a use for.

Ohhhh  ok, I remember seeing that now.

> You have to parse each label for tabs anyway.

Good point, didn't occur to me. =/

> The alignment can be defined with the MenuStyle.

Ah, via the ItemFormat option?

Now that I've read over the pixmap inclusion thing, I think I'd prefer to
take that out of the actual menu entry as well and put it up as a:
+	Property	Pixmap <filename>

> Or "NewAddToMenu".  '+' remembers which command it refers to.

Are you wanting to actually call ot NewAddToMenu or replace the current
AddToMenu?  I kinda figured since it's a "major version change" of sorts
that changing the way the menu's are specified somewhat wouldn't be all
that bad a thing.

Daniel

---

From: Mikhael Goikhman <[email-masked]>
Date: Fri, 15 Mar 2002 18:38:26 +0000

>   NewAddToMenu menu_name (menu_options)

This is almost exactly what I had in my mind. I though about:

  + item_name [item_default_action] [(item_options)]

The default action may probably be included in option, it is for backward
compatibility. For example, separators don't have default action.

> The mini icons should stay parts of the labels because they are

They may, but should not really stay parts of the labels. They cause
excaping problems with '&' and several other symbols. There are currently
problems/inconsistencies with how fvwm escapes '&', if there is underline
in the item, '&' should be escaped as "\&", otherwise as "&&"! This is a
real problem for menu autogenerating scripts.

I think we should only support this in the old compatibility syntax when
the default action is specified as-is and not as an option.

But I don't want to make syntax less usable, so more thoughts are needed.

Regards,
Mikhael.

---

From: Daniel Henninger <[email-masked]>
Date: Fri, 15 Mar 2002 13:55:39 -0500 (EST)

>   + item_name [item_default_action] [(item_options)]

That's the original thing I had in mind except that might cause some
parsing weirdness.  Take this menu entry for example:
+      "Wisqlite" Exec echo '(add tcl83; add sybase11; wisqlite)' | /bin/csh -s &

It might be difficult to have it decide whether the ( )'s here are in
reference to options or to a piece of a command string.

> the default action is specified as-is and not as an option.

I guess it really wouldn't be that difficult to keep some form of
backwards compatibility in there no matter what we go with...  I agree
that these options really shouldn't stay part of the labels though.  I
still dislike how hard-to-read having the options in the labels tends to
make the config files.

Daniel

---

From: Daniel Henninger <[email-masked]>
Date: Fri, 15 Mar 2002 15:36:42 -0500 (EST)

> And maybe allow for S for style, I for item, P for property, etc?

Alternatively, swap Style for MenuStyle, Property for ItemStyle:
NewAddToMenu "AppMenu"
+	MenuStyle	SidePixmap "ninja.xpm"
+	MenuStyle	SideColor gray
+	Item		"Application Menu" Title
+	Item		"" Nop
+	Item		"Corporate Time" Exec /usr/local/bin/ctime
+	ItemStyle	Greyed
+	ItemStyle	Hotkey T

Effectively making them "short aliases" for a full blown MenuStyle and
ItemStyle command.  Who knows, some folk might actually -want- to specify
an ItemStyle in the format of:
ItemStyle	<menu>	<item>	<options>
ItemStyle	"AppMenu"	"Corporate Time"	Greyed, Hotkey T

That way it could remain "easier"...

Or....  Or, completely rethinking it:
NewAddToMenu "AppMenu"
+	""			MenuStyle SidePixmap
+	""			MenuStyle SideColor gray
+	"Application Menu"	Title
+	""			Nop
+	"Corporate Time"	Exec /usr/local/bin/ctime
+	""			ItemStyle Greyed
+	""			ItemStyle Hotkey T

That could get ugly at some level, but would keep it backwards compatible.
Obviously for the "MenuStyle" and "ItemStyle" commands it would "assume"
the current menu or the 'last menu item in this menu'.  It would also
refrain from showing the ""'s for MenuStyle and ItemStyle lines.  Granted,
that would prevent users from being able to set a menu item that would
adjust MenuStyle or ItemStyle... so.......  Lessee.
NewAddToMenu "AppMenu"
+	""			PassMenuStyle SidePixmap
+	""			PassMenuStyle SideColor gray
+	"Application Menu"	Title
+	""			Nop
+	"Corporate Time"	Exec /usr/local/bin/ctime
+	""			PassItemStyle Greyed
+	""			PassItemStyle Hotkey T

maybe some sort of command that "doesn't exist anywhere else"?  Obviously
just end up being a modified version of the 'full' command that would call
the full command with the proper arguments?  I'm not sure I like the
naming scheme of "PassItemStyle", but something like that...

Alternatively:
NewAddToMenu "AppMenu"
*	MenuStyle		SidePixmap
*	MenuStyle		SideColor gray
+	"Application Menu"	Title
+	""			Nop
+	"Corporate Time"	Exec /usr/local/bin/ctime
*	ItemStyle		Greyed
*	ItemStyle		Hotkey T

Simply add a new initial marker of sorts for the special "these are config
lines, not menu items".  This would make the old menus as backwards
compatible as we can make them.  For the time being have the menu routines
go ahead and continue to parse the Label for options as well, maybe making
'comments' saying "please switch to the new style of styling your
menu/items" or something.  As Dominik pointed out, we'd have to parse the
labels anyway for tabs, so "sure why not".

Last but not least, there's a "mod to what I said before" of:
NewAddToMenu "AppMenu"
+	MenuStyle	SidePixmap "ninja.xpm"
+	MenuStyle	SideColor gray
+	"Application Menu" Title
+	"" Nop
+	"Corporate Time" Exec /usr/local/bin/ctime
+	ItemStyle	Greyed
+	ItemStyle	Hotkey T

Where the "after the +" arg there is parsed for whether it's MenuStyle or
ItemStyle... if so, treat it as a style option, if not, it's a menu item.
If a user wanted to have ItemStyle or MenuStyle as a menu label for some
reason they could simply put it in quotes?

Daniel

---

From: Dominik Vogt <[email-masked]>
Date: Sat, 16 Mar 2002 15:49:20 +0100

On Fri, Mar 15, 2002 at 01:15:56PM -0500, Daniel Henninger wrote:
[snip]

> +	Item		"" Nop

Better:

  +     Item            Separator

> And maybe allow for S for style, I for item, P for property, etc?

That matches the method for defining functions nicely.  I like the
idea, but see my comments below.

[snip]

> Ah, via the ItemFormat option?

Yup.

> +	Property	Pixmap <filename>

Hm.  Shouldn't there be a way to define items is a single line (?)
On the other hand, if we ever add separate actions to the mouse
buttons for each menu item, it's going to be very ugly to have all
commands on a single line.  How about this (the indentation is
chosen for readability only):

  + Style            SidePixmap  "ninja.xpm"
  + Style            SideColor   gray
  + Item             "Application Menu" Title
  + Separator
  + Item             "Corporate Time"
  +   Action         (mouse 1) Exec /usr/local/bin/ctime
  +   Action         (mouse 2) Exec foobar
  +   Property       Greyed
  +   Property       Hotkey T
 
> AddToMenu?  I kinda figured since it's a "major version change" of sorts

No, it isn't.  There will be a 2.6 release before we move to 3.0.

> that changing the way the menu's are specified somewhat wouldn't be all

The idea is this:  support the old syntax as long as possible to
give users the time to move gently to the new syntax.  Provide a
way (usually a script) to upgrade the oold configuration file
without the need to touch everything.  Discontinue development
and possibly maintenance of the old code.  If somebody says: "I
need feature xyz" and xyz is already supported with the new
syntax, we'll ask to upgrade the configuration.

Bye

Dominik ^_^  ^_^

---

From: Dominik Vogt <[email-masked]>
Date: Sat, 16 Mar 2002 16:06:08 +0100

> +	Item		"Corporate Time" Exec /usr/local/bin/ctime

I wouldn't call it "MenuStyle" unless it can provide the same
functionality as the usual MenuStyle command.  I'd start with less
complicated matters first.

> ItemStyle	"AppMenu"	"Corporate Time"	Greyed, Hotkey T

We don't need that.  It's bad enough that the '+' command adds to
different kinds of lists.

> refrain from showing the ""'s for MenuStyle and ItemStyle lines.

That would work fine.  It's completely compatible (if the action
names are chosen well).  It might be a bit confusing, though.

> Granted,

Forget it.  Self modifying menu items are not such a good idea
anyway.  It's hard to guarantee stable code.

> naming scheme of "PassItemStyle", but something like that...

Perhaps

  NewAddToMenu "AppMenu"
  + ""     ModifyMenu Style SidePixmap foobar.xpm, ...
  + "foo"  exec bar
  + ""     ModifyItem Style Greyed, Hotkey f

?  No, I don't like that.  Although it reduces the number of new
"commands" that have to be defined, it's too complicated.

> labels anyway for tabs, so "sure why not".

Not necessarily:

  + "foo"     exec bar
  + "bar"     ModifyItem AddLabel 3

instead of

  + "foo\t\tbar" ...

> reason they could simply put it in quotes?

Thats' exactly the kind of screwed up parsing I'd like to replace
:-)  

Bye

Dominik ^_^  ^_^

---

From: Mikhael Goikhman <[email-masked]>
Date: Sat, 16 Mar 2002 21:16:16 +0000

>   +   Action         (mouse 2) Exec foobar

Do we really need to mix everything into one command?

I think we need:

  AddToMenu - don't touch it, for backward compatibility only
  AddMenuStyle menu_name - a new command, allows "+"
  AddMenuItems menu_name - a new command, allows "+"

But I prefer to think about a new design in depth before saying anything
more. There are so many small issues to solve.

Regards,
Mikhael.