> > Here is the very same patch from yesterday, applied to todays snapshot.
> > 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.

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

> 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.

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:
[EMAIL PROTECTED] 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

-- 
/\\\----------------------------------------------------------------------///\
\ \\\      Daniel Henninger           http://www.vorpalcloud.org/        /// /
 \_\\\      North Carolina State University - Systems Programmer        ///_/
    \\\                   Information Technology <IT>                  ///
     """--------------------------------------------------------------"""

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 PROTECTED]>
+
+       * 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 PROTECTED]>
 
        * 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
 
 (Note - normal means not iconic, sticky, or on top)
 
@@ -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 PROTECTED]>
+*/
+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 PROTECTED] */
+                               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)
 
 /* Function to compare window title names
@@ -123,6 +124,7 @@
   int ii;
   char tname[80];
   char loc[40];
+  char tmpbuf[40];
   char *name=NULL;
   int dwidth;
   int dheight;
@@ -260,6 +262,8 @@
        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,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);

Reply via email to