diff src/menubar-x.c @ 321:19dcec799385 r21-0-58

Import from CVS: tag r21-0-58
author cvs
date Mon, 13 Aug 2007 10:46:44 +0200
parents 341dac730539
children f2b5d7006b0a
line wrap: on
line diff
--- a/src/menubar-x.c	Mon Aug 13 10:46:01 2007 +0200
+++ b/src/menubar-x.c	Mon Aug 13 10:46:44 2007 +0200
@@ -146,8 +146,10 @@
 	{
 	  Lisp_Object key, val;
 	  Lisp_Object include_p = Qnil, hook_fn = Qnil, config_tag = Qnil;
+	  Lisp_Object active_p = Qt;
 	  Lisp_Object accel;
 	  int included_spec = 0;
+	  int active_spec = 0;
 	  wv->type = CASCADE_TYPE;
 	  wv->enabled = 1;
 	  wv->name = (char *) XSTRING_DATA (LISP_GETTEXT (XCAR (desc)));
@@ -172,6 +174,8 @@
 		config_tag = val;
 	      else if (EQ (key, Q_filter))
 		hook_fn = val;
+	      else if (EQ (key, Q_active))
+		active_p = val, active_spec = 1;
 	      else if (EQ (key, Q_accelerator))
 		{
 		  if ( SYMBOLP (val)
@@ -180,6 +184,10 @@
 		  else
 		    signal_simple_error ("bad keyboard accelerator", val);
 		}
+	      else if (EQ (key, Q_label))
+		{
+		  /* implement in 21.2 */
+		}
 	      else
 		signal_simple_error ("unknown menu cascade keyword", cascade);
 	    }
@@ -191,7 +199,11 @@
 	      wv = NULL;
 	      goto menu_item_done;
 	    }
-	  if (!NILP (hook_fn))
+
+	  if (active_spec)
+	    active_p = Feval (active_p);
+	  
+	  if (!NILP (hook_fn) && !NILP (active_p))
 	    {
 #if defined LWLIB_MENUBARS_LUCID || defined LWLIB_MENUBARS_MOTIF
 	      if (filter_p || depth == 0)
@@ -236,6 +248,24 @@
 	      wv->contents = title_wv;
 	      prev = sep_wv;
 	    }
+	  wv->enabled = ! NILP (active_p);
+	  if (deep_p && !wv->enabled  && !NILP (desc))
+	    {
+	      widget_value *dummy;
+	      /* Add a fake entry so the menus show up */
+	      wv->contents = dummy = xmalloc_widget_value ();
+	      dummy->name = "(inactive)";
+	      dummy->accel = NULL;
+	      dummy->enabled = 0;
+	      dummy->selected = 0;
+	      dummy->value = NULL;
+	      dummy->type = BUTTON_TYPE;
+	      dummy->call_data = NULL;
+	      dummy->next = NULL;
+	      
+	      goto menu_item_done;
+	}
+
 	}
       else if (menubar_root_p)
 	{
@@ -248,8 +278,7 @@
 	  signal_simple_error ("menu name (first element) must be a string",
                                desc);
 	}
-
-      wv->enabled = 1;
+      
       if (deep_p || menubar_root_p)
 	{
 	  widget_value *next;