Dear all,

Attached patch adds File->compressed menu item that

1. shows the compression status of an opened file
2. can be turned on/off
3. file will be saved compressed/decompressed accordingly.

What is missing:
A ".lyx (compressed)" format in the Save As dialog? Does not sound necessary.

Question:
Should we always save compressed to file.lyx.gz, regardless of this flag?

Please tell me whether or not you like it, or have some better idea.

Bo
Index: src/LyXAction.C
===================================================================
--- src/LyXAction.C	(revision 13708)
+++ src/LyXAction.C	(working copy)
@@ -110,6 +110,7 @@
 		{ LFUN_BEGINNINGBUFSEL, "buffer-begin-select", ReadOnly },
 		{ LFUN_CHILDOPEN, "buffer-child-open", ReadOnly },
 		{ LFUN_RUNCHKTEX, "buffer-chktex", ReadOnly },
+		{ LFUN_COMPRESSION_STATUS, "compression-status", ReadOnly},
 		{ LFUN_CLOSEBUFFER, "buffer-close", ReadOnly },
 		{ LFUN_ENDBUF, "buffer-end", ReadOnly },
 		{ LFUN_ENDBUFSEL, "buffer-end-select", ReadOnly },
Index: src/lyxfunc.C
===================================================================
--- src/lyxfunc.C	(revision 13708)
+++ src/lyxfunc.C	(working copy)
@@ -551,6 +551,16 @@
 		break;
 	}
 
+	case LFUN_COMPRESSION_STATUS: {
+#ifdef	USE_COMPRESSION
+		enable = true;
+		flag.setOnOff(view()->buffer()->params().compressed);
+#else
+		enable = false;	
+#endif
+		break;
+	}
+
 	// this one is difficult to get right. As a half-baked
 	// solution, we consider only the first action of the sequence
 	case LFUN_SEQUENCE: {
@@ -806,6 +816,16 @@
 			menuNew(argument, true);
 			break;
 
+		case LFUN_COMPRESSION_STATUS:
+			// turn compression on/off
+			BOOST_ASSERT(owner->buffer()->params().compressed == flag.onoff(true));
+			if (flag.onoff(true))
+				owner->buffer()->params().compressed = false;
+			else 
+				owner->buffer()->params().compressed = true;
+			owner->buffer()->markDirty();
+			break;
+			
 		case LFUN_CLOSEBUFFER:
 			closeBuffer();
 			break;
Index: src/lfuns.h
===================================================================
--- src/lfuns.h	(revision 13708)
+++ src/lfuns.h	(working copy)
@@ -358,6 +358,8 @@
 	LFUN_BIBDB_DEL,
 	LFUN_INSERT_CITATION,
 	LFUN_OUTLINE,			// Vermeer 20060323
+	// 275
+	LFUN_COMPRESSION_STATUS,         // bpeng 20060421
 
 	LFUN_LASTACTION                  // end of the table
 };
Index: lib/ui/stdmenus.ui
===================================================================
--- lib/ui/stdmenus.ui	(revision 13708)
+++ lib/ui/stdmenus.ui	(working copy)
@@ -37,6 +37,7 @@
 # This seems a much more sensible place to me
 		Submenu "Open recent|t" "lastfiles"
 		Separator
+		Item "Compressed|d" "compression-status"
 		Item "Close|C" "buffer-close"
 		Item "Save|S" "buffer-write"
 		Item "Save As...|A" "buffer-write-as"

Reply via email to