On Wed, 2005-10-26 at 10:42 +0200, Georg Baum wrote:

...

> > We have to somehow handle the situation where a branch inset is in a
> > document for which the branch is not defined. In CharStyle you created a
> > method setUndefined, which prefixed the button text with "Undef:"
> 
> Did I? I don't remember :-) (I thought the undefined stuff was already
> there)
> 
> > Actually I think it is OK to have branch insets in a document belonging
> > to undefined branches, as long as the user is aware of it. The inset
> > should have a reasonable colour (red for warning?) and perhaps also an
> > "Undef:" prefix in the button.
> > 
> > Does this sound like a plan?
> 
> Yes. And the inset should be set to the undefined state immediately after a
> branch is deleted and after a copy from a different document. Is that
> difficult to implement?

Doesn't appear to be straightforward.

However, the attached displays the inset as undefined upon reloading the
document, which is the most important situation where a warning is
called for.

- Martin
Index: insetbranch.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetbranch.C,v
retrieving revision 1.58
diff -u -p -r1.58 insetbranch.C
--- insetbranch.C	25 Oct 2005 15:21:49 -0000	1.58
+++ insetbranch.C	26 Oct 2005 09:15:19 -0000
@@ -95,12 +95,17 @@ void InsetBranch::setButtonLabel()
 	font.decSize();
 
 	string s = _("Branch: ") + params_.branch;
-	setLabel(isOpen() ? s : getNewLabel(s) );
 	font.setColor(LColor::foreground);
-	if (!params_.branch.empty())
-		setBackgroundColor(lcolor.getFromLyXName(params_.branch));
-	else
+	if (!params_.branch.empty()) {
+		LColor_color c = lcolor.getFromLyXName(params_.branch);
+		if (c == LColor::none) {
+			c = LColor::red;
+			s = _("Undef: ") + s;
+		}
+		setBackgroundColor(c);
+	} else
 		setBackgroundColor(LColor::background);
+	setLabel(isOpen() ? s : getNewLabel(s) );
 	setLabelFont(font);
 }
 

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to