]> git.sur5r.net Git - glabels/commitdiff
Don't touch compression of original file -- still defaults to 9 for new files. Origi...
authorJim Evins <evins@snaught.com>
Tue, 8 Jun 2004 02:41:32 +0000 (02:41 +0000)
committerJim Evins <evins@snaught.com>
Tue, 8 Jun 2004 02:41:32 +0000 (02:41 +0000)
git-svn-id: https://glabels.svn.sourceforge.net/svnroot/glabels/trunk@425 f5e0f49d-192f-0410-a22d-a8d8700d0965

glabels2/src/label.c
glabels2/src/label.h
glabels2/src/xml-label.c

index 84a3620f9251090fa09aef7fbb3a7d8953e5e2a6..a5f6de226dea03f9b67099b217d595353e6494d4 100644 (file)
@@ -45,6 +45,7 @@ struct _glLabelPrivate {
         gboolean     rotate_flag;
 
        gchar       *filename;
+       gint         compression;
        gboolean     modified_flag;
        gint         untitled_instance;
 
@@ -230,6 +231,8 @@ gl_label_new (void)
 
        label = g_object_new (gl_label_get_type(), NULL);
 
+       label->private->compression = 9;
+
        label->private->modified_flag = FALSE;
 
        gl_debug (DEBUG_LABEL, "END");
@@ -654,4 +657,33 @@ gl_label_clear_modified (glLabel *label)
 }
 
 
+/****************************************************************************/
+/* Set compression level.                                                   */
+/****************************************************************************/
+void
+gl_label_set_compression (glLabel  *label,
+                         gint      compression)
+{
+       gl_debug (DEBUG_LABEL, "set %d", compression);
+
+       /* Older versions of libxml2 always return a -1 for documents "read in," so
+        * default to 9.  Also, default to 9 for anything else out of range. */
+       if ((compression < 0) || (compression >9)) {
+               compression = 9;
+       }
+
+       gl_debug (DEBUG_LABEL, "actual set %d", compression);
+       label->private->compression = compression;
+}
+
+
+/****************************************************************************/
+/* Get compression level.                                                   */
+/****************************************************************************/
+gint
+gl_label_get_compression (glLabel *label)
+{
+       gl_debug (DEBUG_LABEL, "return %d", label->private->compression);
+       return label->private->compression;
+}
 
index f901180b97f425c6ffec65de87abe408912d2d79..791dbd23a6202fdde7195335e9891f7817557c02 100644 (file)
@@ -126,6 +126,11 @@ void          gl_label_set_filename            (glLabel       *label,
 
 void          gl_label_clear_modified          (glLabel       *label);
 
+void          gl_label_set_compression         (glLabel       *label,
+                                               gint           compression);
+
+gint          gl_label_get_compression         (glLabel       *label);
+
 G_END_DECLS
 
 
index d90c89e909dae3cdc02c95339c3275cb4d754964..067fe41ee30caf2a0cb664283ad50754fce1ef29 100644 (file)
@@ -255,6 +255,8 @@ xml_doc_to_label (xmlDocPtr         doc,
        ns = xmlSearchNsByHref (doc, root, GL_XML_NAME_SPACE);
        if (ns != NULL) {
                label = xml_parse_label (root, status);
+               if (label)
+                       gl_label_set_compression (label, xmlGetDocCompressMode (doc));
        } else {
                /* Try compatability mode 0.1 */
                ns = xmlSearchNsByHref (doc, root, COMPAT01_NAME_SPACE);
@@ -952,7 +954,7 @@ gl_xml_label_save (glLabel          *label,
        if (!filename)
                g_warning (_("Utf8 conversion error."));
        else {
-               xmlSetDocCompressMode (doc, 9);
+               xmlSetDocCompressMode (doc, gl_label_get_compression (label));
                xml_ret = xmlSaveFormatFile (filename, doc, TRUE);
                xmlFreeDoc (doc);
                if (xml_ret == -1) {