[Xfce4-commits] r22642 - in xarchiver/branches/xarchiver-psybsd: . libxarchiver po src

Stephan Arts stephan at xfce.org
Thu Aug 3 15:05:50 UTC 2006


Author: stephan
Date: 2006-08-03 15:05:48 +0000 (Thu, 03 Aug 2006)
New Revision: 22642

Added:
   xarchiver/branches/xarchiver-psybsd/libxarchiver/archive-support-zip.c
   xarchiver/branches/xarchiver-psybsd/libxarchiver/archive-support-zip.h
   xarchiver/branches/xarchiver-psybsd/src/extract_dialog.c
   xarchiver/branches/xarchiver-psybsd/src/extract_dialog.h
Modified:
   xarchiver/branches/xarchiver-psybsd/TODO
   xarchiver/branches/xarchiver-psybsd/libxarchiver/Makefile.am
   xarchiver/branches/xarchiver-psybsd/libxarchiver/archive-support-gnu-tar.c
   xarchiver/branches/xarchiver-psybsd/libxarchiver/archive-support-gnu-tar.h
   xarchiver/branches/xarchiver-psybsd/libxarchiver/archive.h
   xarchiver/branches/xarchiver-psybsd/libxarchiver/libxarchiver.c
   xarchiver/branches/xarchiver-psybsd/po/nl.po
   xarchiver/branches/xarchiver-psybsd/src/Makefile.am
   xarchiver/branches/xarchiver-psybsd/src/main.c
   xarchiver/branches/xarchiver-psybsd/src/new_dialog.c
   xarchiver/branches/xarchiver-psybsd/src/new_dialog.h
Log:
- updated TODO
- added bzsic zip support
- added extract-options to gnu-tar support object
- added extract-dialog (is just a filechooser atm)



Modified: xarchiver/branches/xarchiver-psybsd/TODO
===================================================================
--- xarchiver/branches/xarchiver-psybsd/TODO	2006-08-03 12:40:08 UTC (rev 22641)
+++ xarchiver/branches/xarchiver-psybsd/TODO	2006-08-03 15:05:48 UTC (rev 22642)
@@ -4,26 +4,32 @@
 
 Long Version:
 
+	Make ArchiveSupport functions ArchiveSupport aware.
+
   Implement archive-type verification and 'open' support for existing archives
-    - done for tar
-               tar.gz
-               tar.bz2
+	  - .rar
+		- .arj
+		- .iso
+		- .7zip
 
-	Implement lxa_archivetype_supported() function
-	Implement lxa_compressiontype_supported() function
-
-	Implement 'NewArchiveDialog'
-
 	Implement 'ExtractArchiveDialog'
 
   Implement transaction-options for archive-support objects
+    - implement option listing
+		- implement set_property code
+
   Implement transaction-options for compression-support objects
-    (use g_object_class_properties for that?)
+    - implement option listing
+		- implement set_property code
 
   Let support objects check if the program in question exists upon object creation.
 
 	add configure-options to enable / disable support-objects.
 
+  add support for libarchive
+
+  See if we can avoid using /tmp when possible.
+  Write view support for all support objects.
   Optimize memory usage and library size (remove duplicate code)
 
   Extend testing: 
@@ -32,6 +38,19 @@
          Extract
          View
 
-  See if we can avoid using /tmp when possible.
-  Write view support for gnu-tar support object.
+  add passwd property to archive
 
+
+---------------------------------------------------------------
+| DONE                                                   DONE |
+---------------------------------------------------------------
+	Implement lxa_archivetype_supported() function           DONE
+	Implement lxa_compressiontype_supported() function       DONE
+
+	Implement 'NewArchiveDialog'                             DONE
+
+  Implement archive-type verification and 'open' support for existing archives
+    - done for .tar
+               .tar.gz
+               .tar.bz2
+							 .zip

Modified: xarchiver/branches/xarchiver-psybsd/libxarchiver/Makefile.am
===================================================================
--- xarchiver/branches/xarchiver-psybsd/libxarchiver/Makefile.am	2006-08-03 12:40:08 UTC (rev 22641)
+++ xarchiver/branches/xarchiver-psybsd/libxarchiver/Makefile.am	2006-08-03 15:05:48 UTC (rev 22642)
@@ -5,6 +5,7 @@
 	archive.c archive.h \
 	internals.c internals.h           \
 	archive-support.c archive-support.h \
+	archive-support-zip.c archive-support-zip.h \
 	archive-support-gnu-tar.c archive-support-gnu-tar.h \
 	compression-support.c compression-support.h \
 	compression-support-gzip.c compression-support-gzip.h \

Modified: xarchiver/branches/xarchiver-psybsd/libxarchiver/archive-support-gnu-tar.c
===================================================================
--- xarchiver/branches/xarchiver-psybsd/libxarchiver/archive-support-gnu-tar.c	2006-08-03 12:40:08 UTC (rev 22641)
+++ xarchiver/branches/xarchiver-psybsd/libxarchiver/archive-support-gnu-tar.c	2006-08-03 15:05:48 UTC (rev 22642)
@@ -33,6 +33,13 @@
 
 #define _(String) gettext(String)
 
+enum
+{
+	LXA_ARCHIVE_SUPPORT_GNU_TAR_EXTRACT_OVERWRITE = 1,
+	LXA_ARCHIVE_SUPPORT_GNU_TAR_EXTRACT_TOUCH,
+	LXA_ARCHIVE_SUPPORT_GNU_TAR_EXTRACT_STRIP
+};
+
 gint
 lxa_archive_support_gnu_tar_add(LXAArchive *archive);
 
@@ -48,6 +55,11 @@
 void
 lxa_archive_support_gnu_tar_child_watch_func(GPid pid, gint status, gpointer data);
 
+void
+lxa_archive_support_gnu_tar_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
+void
+lxa_archive_support_gnu_tar_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
+
 gboolean
 lxa_archive_support_gnu_tar_view_func(GIOChannel *source, GIOCondition condition, gpointer data);
 
@@ -113,19 +125,45 @@
 void
 lxa_archive_support_gnu_tar_class_init(LXAArchiveSupportGnuTarClass *supportclass)
 {
-	/*
-	GObjectClass *gobject_class = G_OBJECT_CLASS (supportclass);
+	GObjectClass *object_class = G_OBJECT_CLASS (supportclass);
+	GParamSpec *pspec = NULL;
 	LXAArchiveSupportGnuTarClass *klass = LXA_ARCHIVE_SUPPORT_GNU_TAR_CLASS (supportclass);
-	*/
+
+	object_class->set_property = lxa_archive_support_gnu_tar_set_property;
+	object_class->get_property = lxa_archive_support_gnu_tar_get_property;
+
+	pspec = g_param_spec_boolean("extract-overwrite",
+		"Overwrite exisiting files",
+		"Overwrite existing files on extraction",
+		FALSE,
+		G_PARAM_READWRITE);
+	g_object_class_install_property(object_class, LXA_ARCHIVE_SUPPORT_GNU_TAR_EXTRACT_OVERWRITE, pspec);
+
+	pspec = g_param_spec_boolean("extract-touch",
+		"Touch files",
+		"Touch files",
+		FALSE,
+		G_PARAM_READWRITE);
+	g_object_class_install_property(object_class, LXA_ARCHIVE_SUPPORT_GNU_TAR_EXTRACT_TOUCH, pspec);
+
+	pspec = g_param_spec_uint("extract-strip",
+		"Strip directories",
+		"Strip directories",
+		0,
+		128,
+		0,
+		G_PARAM_READWRITE);
+	g_object_class_install_property(object_class, LXA_ARCHIVE_SUPPORT_GNU_TAR_EXTRACT_STRIP, pspec);
 }
 
 LXAArchiveSupport*
 lxa_archive_support_gnu_tar_new()
 {
+	guint i;
 	LXAArchiveSupportGnuTar *support;
 
 	support = g_object_new(LXA_TYPE_ARCHIVE_SUPPORT_GNU_TAR, NULL);
-	
+
 	return LXA_ARCHIVE_SUPPORT(support);
 }
 
@@ -159,6 +197,9 @@
 gint
 lxa_archive_support_gnu_tar_extract(LXAArchive *archive)
 {
+	/*
+	 * TODO: use extract- options
+	 */
 	gchar *command;
 	GSList *files = archive->tmp_data;
 
@@ -255,6 +296,29 @@
 		lxa_archive_set_status(archive, LXA_ARCHIVESTATUS_IDLE);
 }
 
+void
+lxa_archive_support_gnu_tar_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+{
+	switch(prop_id)
+	{
+		case LXA_ARCHIVE_SUPPORT_GNU_TAR_EXTRACT_OVERWRITE:
+			LXA_ARCHIVE_SUPPORT_GNU_TAR(object)->_extr_overwrite = g_value_get_boolean(value);
+			break;
+		case LXA_ARCHIVE_SUPPORT_GNU_TAR_EXTRACT_TOUCH:
+			LXA_ARCHIVE_SUPPORT_GNU_TAR(object)->_extr_touch = g_value_get_boolean(value);
+			break;
+		case LXA_ARCHIVE_SUPPORT_GNU_TAR_EXTRACT_STRIP:
+			LXA_ARCHIVE_SUPPORT_GNU_TAR(object)->_extr_strip = g_value_get_uint(value);
+			break;
+	}
+}
+
+void
+lxa_archive_support_gnu_tar_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+{
+
+}
+
 gboolean
 lxa_archive_support_gnu_tar_view_func(GIOChannel *ioc, GIOCondition condition, gpointer data)
 {

Modified: xarchiver/branches/xarchiver-psybsd/libxarchiver/archive-support-gnu-tar.h
===================================================================
--- xarchiver/branches/xarchiver-psybsd/libxarchiver/archive-support-gnu-tar.h	2006-08-03 12:40:08 UTC (rev 22641)
+++ xarchiver/branches/xarchiver-psybsd/libxarchiver/archive-support-gnu-tar.h	2006-08-03 15:05:48 UTC (rev 22642)
@@ -47,6 +47,9 @@
 {
 	LXAArchiveSupport parent;
 	LXAArchiveType type;
+	gboolean _extr_overwrite;
+	gboolean _extr_touch;
+	guint    _extr_strip;
 };
 
 typedef struct _LXAArchiveSupportGnuTarClass LXAArchiveSupportGnuTarClass;

Added: xarchiver/branches/xarchiver-psybsd/libxarchiver/archive-support-zip.c
===================================================================
--- xarchiver/branches/xarchiver-psybsd/libxarchiver/archive-support-zip.c	                        (rev 0)
+++ xarchiver/branches/xarchiver-psybsd/libxarchiver/archive-support-zip.c	2006-08-03 15:05:48 UTC (rev 22642)
@@ -0,0 +1,239 @@
+/*
+ *  Copyright (c) 2006 Stephan Arts <psyBSD at gmail.com>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <signal.h>
+#include <glib.h>
+#include <glib-object.h>
+#include <libintl.h>
+#include "archive.h"
+#include "archive-support.h"
+#include "archive-support-zip.h"
+
+#include "compression-support.h"
+
+#include "internals.h"
+
+#define _(String) gettext(String)
+
+gint
+lxa_archive_support_zip_add(LXAArchive *archive);
+
+gint
+lxa_archive_support_zip_extract(LXAArchive *archive);
+
+gint
+lxa_archive_support_zip_remove(LXAArchive *archive);
+
+gint
+lxa_archive_support_zip_view(LXAArchive *archive);
+
+void
+lxa_archive_support_zip_child_watch_func(GPid pid, gint status, gpointer data);
+
+gboolean
+lxa_archive_support_zip_view_func(GIOChannel *source, GIOCondition condition, gpointer data);
+
+void
+lxa_archive_support_zip_init(LXAArchiveSupportZip *support);
+void
+lxa_archive_support_zip_class_init(LXAArchiveSupportZipClass *supportclass);
+
+GType
+lxa_archive_support_zip_get_type ()
+{
+	static GType lxa_archive_support_zip_type = 0;
+
+ 	if (!lxa_archive_support_zip_type)
+	{
+ 		static const GTypeInfo lxa_archive_support_zip_info = 
+		{
+			sizeof (LXAArchiveSupportZipClass),
+			(GBaseInitFunc) NULL,
+			(GBaseFinalizeFunc) NULL,
+			(GClassInitFunc) lxa_archive_support_zip_class_init,
+			(GClassFinalizeFunc) NULL,
+			NULL,
+			sizeof (LXAArchiveSupportZip),
+			0,
+			(GInstanceInitFunc) lxa_archive_support_zip_init,
+		};
+
+		lxa_archive_support_zip_type = g_type_register_static (LXA_TYPE_ARCHIVE_SUPPORT, "LXAArchiveSupportZip", &lxa_archive_support_zip_info, 0);
+	}
+	return lxa_archive_support_zip_type;
+}
+
+void
+lxa_archive_support_zip_init(LXAArchiveSupportZip *support)
+{
+	LXAArchiveSupport *archive_support = LXA_ARCHIVE_SUPPORT(support);
+
+	archive_support->id = "Zip";
+	archive_support->type = LXA_ARCHIVETYPE_ZIP;
+
+	archive_support->add = lxa_archive_support_zip_add;
+	archive_support->extract = lxa_archive_support_zip_extract;
+	archive_support->remove = lxa_archive_support_zip_remove;
+	archive_support->view = lxa_archive_support_zip_view;
+	archive_support->column_nr = 8;
+	archive_support->column_names = g_new0(gchar *, archive_support->column_nr);
+	archive_support->column_types = g_new0(GType , archive_support->column_nr);
+	archive_support->column_names[0] = _("Filename");
+	archive_support->column_names[1] = _("Original");
+	archive_support->column_names[2] = _("Method");
+	archive_support->column_names[3] = _("Compressed");
+	archive_support->column_names[4] = _("Ratio");
+	archive_support->column_names[5] = _("Date");
+	archive_support->column_names[6] = _("Time");
+	archive_support->column_names[7] = _("CRC-32");
+	archive_support->column_types[0] = G_TYPE_STRING;
+	archive_support->column_types[1] = G_TYPE_UINT64;
+	archive_support->column_types[2] = G_TYPE_STRING;
+	archive_support->column_types[3] = G_TYPE_UINT64;
+	archive_support->column_types[4] = G_TYPE_STRING;
+	archive_support->column_types[5] = G_TYPE_STRING;
+	archive_support->column_types[6] = G_TYPE_STRING;
+	archive_support->column_types[7] = G_TYPE_STRING;
+}
+
+void
+lxa_archive_support_zip_class_init(LXAArchiveSupportZipClass *supportclass)
+{
+	/*
+	GObjectClass *gobject_class = G_OBJECT_CLASS (supportclass);
+	LXAArchiveSupportZipClass *klass = LXA_ARCHIVE_SUPPORT_ZIP_CLASS (supportclass);
+	*/
+}
+
+LXAArchiveSupport*
+lxa_archive_support_zip_new()
+{
+	LXAArchiveSupportZip *support;
+
+	support = g_object_new(LXA_TYPE_ARCHIVE_SUPPORT_ZIP, NULL);
+	
+	return LXA_ARCHIVE_SUPPORT(support);
+}
+
+gint
+lxa_archive_support_zip_add(LXAArchive *archive)
+{
+	gchar *command;
+	GSList *files = archive->tmp_data;
+
+	command = g_strconcat("zip -r ", archive->path, " ", files->data, NULL);
+
+	if(lxa_execute(command, archive, lxa_archive_support_zip_child_watch_func, NULL, NULL, NULL))
+		return 1;
+
+	return 0;
+}
+
+gint
+lxa_archive_support_zip_extract(LXAArchive *archive)
+{
+	/*
+	 * TODO: use extract- options
+	 */
+	gchar *command;
+	GSList *files = archive->tmp_data;
+
+	if(g_file_test(archive->path, G_FILE_TEST_EXISTS))
+		command = g_strconcat("unzip -o ", archive->path, " -d ", files->data, NULL);
+	else
+		return 1;
+
+	if(lxa_execute(command, archive, lxa_archive_support_zip_child_watch_func, NULL, NULL, NULL))
+		return 1;
+	return 0;
+}
+
+gint
+lxa_archive_support_zip_remove(LXAArchive *archive)
+{
+	gchar *command;
+
+	GSList *files = archive->tmp_data;
+	if(g_file_test(archive->path, G_FILE_TEST_EXISTS))
+		command = g_strconcat("zip -d ", archive->path, " ", files->data, NULL);
+	else
+		return 2;
+
+	if(lxa_execute(command, archive, lxa_archive_support_zip_child_watch_func, NULL, NULL, NULL))
+		return 1;
+
+	return 0;
+
+}
+
+gint
+lxa_archive_support_zip_view(LXAArchive *archive)
+{
+	gchar *command;
+	if(g_file_test(archive->path, G_FILE_TEST_EXISTS))
+		command = g_strconcat("unzip -vl -qq ", archive->path, NULL);
+	else
+		return 2;
+
+	if(lxa_execute(command, archive, lxa_archive_support_zip_child_watch_func, NULL, lxa_archive_support_zip_view_func, NULL))
+		return 1;
+	return 0;
+}
+
+void
+lxa_archive_support_zip_child_watch_func(GPid pid, gint status, gpointer data)
+{
+	GSList *find_result;
+	LXACompressionSupport *compression_support;
+	LXAArchive *archive = data;
+
+	archive->child_pid = 0;
+	if((archive->compression != LXA_COMPRESSIONTYPE_NONE) && (archive->status != LXA_ARCHIVESTATUS_EXTRACT))
+	{
+		find_result = g_slist_find_custom(lxa_compression_support_list, &(archive->compression), lookup_compression_support);
+		if(find_result)
+		{
+			compression_support = find_result->data;
+			compression_support->compress(archive);
+		}
+	} else
+		lxa_archive_set_status(archive, LXA_ARCHIVESTATUS_IDLE);
+}
+
+gboolean
+lxa_archive_support_zip_view_func(GIOChannel *ioc, GIOCondition condition, gpointer data)
+{
+	gchar *line = NULL;
+	GIOStatus status = 0;
+	GError *error = NULL;
+
+	if (condition & (G_IO_IN | G_IO_PRI) )
+	{
+		status = g_io_channel_read_line(ioc, &line, NULL,NULL,&error);
+	}
+	else if (condition & (G_IO_ERR | G_IO_HUP | G_IO_NVAL) )
+	{
+		g_io_channel_shutdown ( ioc,TRUE,NULL );
+		g_io_channel_unref (ioc);
+		return FALSE;
+	}
+	return TRUE;
+}

Added: xarchiver/branches/xarchiver-psybsd/libxarchiver/archive-support-zip.h
===================================================================
--- xarchiver/branches/xarchiver-psybsd/libxarchiver/archive-support-zip.h	                        (rev 0)
+++ xarchiver/branches/xarchiver-psybsd/libxarchiver/archive-support-zip.h	2006-08-03 15:05:48 UTC (rev 22642)
@@ -0,0 +1,64 @@
+/*
+ *  Copyright (c) 2006 Stephan Arts <psyBSD at gmail.com>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+#ifndef __LIBXARCHIVER_ARCHIVE_SUPPORT_ZIP_H__
+#define __LIBXARCHIVER_ARCHIVE_SUPPORT_ZIP_H__
+
+G_BEGIN_DECLS
+
+
+#define LXA_TYPE_ARCHIVE_SUPPORT_ZIP lxa_archive_support_zip_get_type()
+
+#define LXA_ARCHIVE_SUPPORT_ZIP(obj)         ( \
+		G_TYPE_CHECK_INSTANCE_CAST ((obj),    \
+			LXA_TYPE_ARCHIVE_SUPPORT_ZIP,      \
+			LXAArchiveSupportZip))
+
+#define LXA_IS_ARCHIVE_SUPPORT_ZIP(obj)      ( \
+		G_TYPE_CHECK_INSTANCE_TYPE ((obj),    \
+			LXA_TYPE_ARCHIVE_SUPPORT_ZIP))
+
+#define LXA_ARCHIVE_SUPPORT_ZIP_CLASS(klass) ( \
+		G_TYPE_CHECK_CLASS_CAST ((klass),     \
+			LXA_TYPE_ARCHIVE_SUPPORT_ZIP,      \
+			LXAArchiveSupportZipClass))
+
+#define LXA_IS_ARCHIVE_SUPPORT_ZIP_CLASS(klass) ( \
+		G_TYPE_CHECK_CLASS_TYPE ((klass),        \
+			LXA_TYPE_ARCHIVE_SUPPORT_ZIP))
+
+typedef struct _LXAArchiveSupportZip LXAArchiveSupportZip;
+
+struct _LXAArchiveSupportZip
+{
+	LXAArchiveSupport parent;
+	LXAArchiveType type;
+};
+
+typedef struct _LXAArchiveSupportZipClass LXAArchiveSupportZipClass;
+
+struct _LXAArchiveSupportZipClass
+{
+	LXAArchiveSupportClass parent;
+}; 
+
+GType                lxa_archive_support_zip_get_type(void);
+LXAArchiveSupport *  lxa_archive_support_zip_new();
+
+G_END_DECLS
+
+#endif /* __LIBXARCHIVER_ARCHIVE_SUPPORT_ZIP_H__ */

Modified: xarchiver/branches/xarchiver-psybsd/libxarchiver/archive.h
===================================================================
--- xarchiver/branches/xarchiver-psybsd/libxarchiver/archive.h	2006-08-03 12:40:08 UTC (rev 22641)
+++ xarchiver/branches/xarchiver-psybsd/libxarchiver/archive.h	2006-08-03 15:05:48 UTC (rev 22642)
@@ -78,16 +78,14 @@
 struct _LXAArchive
 {
 	GObject parent;
-	LXAArchiveStatus   status;
-	LXAArchiveStatus   oldstatus;
-	LXAArchiveType     type;
-	LXACompressionType compression;
-	gchar             *path;
-	gchar             *tmp_file;
-	gpointer           tmp_data;
-	GPid               child_pid;
-	gchar             *passwd;
-	gboolean           has_passwd;
+	LXAArchiveStatus       status;
+	LXAArchiveStatus       oldstatus;
+	LXAArchiveType         type;
+	LXACompressionType     compression;
+	gchar                 *path;
+	gchar                 *tmp_file;
+	gpointer               tmp_data;
+	GPid                   child_pid;
 };
 
 typedef struct _LXAArchiveClass LXAArchiveClass;

Modified: xarchiver/branches/xarchiver-psybsd/libxarchiver/libxarchiver.c
===================================================================
--- xarchiver/branches/xarchiver-psybsd/libxarchiver/libxarchiver.c	2006-08-03 12:40:08 UTC (rev 22641)
+++ xarchiver/branches/xarchiver-psybsd/libxarchiver/libxarchiver.c	2006-08-03 15:05:48 UTC (rev 22642)
@@ -22,6 +22,7 @@
 #include "libxarchiver.h"
 #include "archive-support.h"
 #include "archive-support-gnu-tar.h"
+#include "archive-support-zip.h"
 
 #include "compression-support.h"
 #include "compression-support-gzip.h"
@@ -34,12 +35,14 @@
 {
 	lxa_archive_support_list = g_slist_alloc();
 	lxa_archive_support_list = g_slist_prepend(lxa_archive_support_list, lxa_archive_support_gnu_tar_new());
+	lxa_archive_support_list = g_slist_prepend(lxa_archive_support_list, lxa_archive_support_zip_new());
 
 	lxa_compression_support_list = g_slist_alloc();
 	lxa_compression_support_list = g_slist_prepend(lxa_compression_support_list, lxa_compression_support_gzip_new());
 	lxa_compression_support_list = g_slist_prepend(lxa_compression_support_list, lxa_compression_support_bzip2_new());
 
 	lxa_tmp_dir = g_get_tmp_dir();
+
 #ifdef DEBUG
 	g_debug("lxa_tmp_dir: %s\n", lxa_tmp_dir); g_debug("lxa_cmp_list_length: %d\n", g_slist_length(lxa_compression_support_list));
 #endif

Modified: xarchiver/branches/xarchiver-psybsd/po/nl.po
===================================================================
--- xarchiver/branches/xarchiver-psybsd/po/nl.po	2006-08-03 12:40:08 UTC (rev 22641)
+++ xarchiver/branches/xarchiver-psybsd/po/nl.po	2006-08-03 15:05:48 UTC (rev 22642)
@@ -3,12 +3,11 @@
 # This file is distributed under the same license as the xarchiver package.
 # Stephan Arts <psybsd at gmail.com>, 2006.
 #
-#: ../src/main.c:50 ../src/main.c:54 ../src/main.c:58 ../src/main.c:62
 msgid ""
 msgstr ""
 "Project-Id-Version: xarchiver 0.3.9psybsd\n"
 "Report-Msgid-Bugs-To: psybsd at gmail.com\n"
-"POT-Creation-Date: 2006-07-28 14:58+0200\n"
+"POT-Creation-Date: 2006-08-03 17:01+0200\n"
 "PO-Revision-Date: 2006-07-20 16:36+0200\n"
 "Last-Translator: Stephan Arts <psybsd at gmail.com>\n"
 "Language-Team: Dutch <vertaling at vrijschrift.org>\n"
@@ -17,47 +16,47 @@
 "Content-Transfer-Encoding: 8bit\n"
 "Plural-Forms: nplurals=2; plural=(n != 1);\n"
 
-#: ../src/main.c:51
+#: ../src/main.c:52
 msgid "[destination path]"
 msgstr "[bestemmings map]"
 
-#: ../src/main.c:59
+#: ../src/main.c:60
 msgid "[archive path] [file1] [file2] ... [fileN]"
 msgstr "[archief map] [bestand1] [bestand2] ... [bestandN]"
 
-#: ../src/main.c:63
+#: ../src/main.c:64
 msgid "[file1] [file2] ... [fileN]"
 msgstr "[bestand1] [bestand2] ... [bestandN]"
 
-#: ../src/main.c:105
+#: ../src/main.c:106
 #, c-format
 msgid "Could not add file(s) to archive '%s'"
 msgstr "Kan bestand(en) niet toevoegen aan archief '%s'"
 
-#: ../src/main.c:108 ../src/main.c:197
+#: ../src/main.c:109 ../src/main.c:205
 #, c-format
 msgid "Could not extract archive '%s'"
 msgstr "Kan archief '%s' niet uitpakken"
 
-#: ../src/main.c:111
+#: ../src/main.c:112
 #, c-format
 msgid "Could not remove file(s) from archive '%s'"
 msgstr "Kon bestand(en) niet verwijderen uit archief '%s'"
 
-#: ../src/main.c:134
+#: ../src/main.c:135
 #, c-format
 msgid "File '%s' does not exist: ABORTING"
 msgstr "Bestand '%s' bestaat niet"
 
-#: ../src/main.c:168
+#: ../src/main.c:169
 msgid "[archive name]"
 msgstr "[archief naam]"
 
-#: ../src/main.c:209
+#: ../src/main.c:218
 msgid "You should provide at least one file to add\n"
 msgstr "U moet ten minste een bestand toevoegen\n"
 
-#: ../src/main.c:302
+#: ../src/main.c:329
 msgid "Archive type unknown\n"
 msgstr "Onbekend archieftype\n"
 

Modified: xarchiver/branches/xarchiver-psybsd/src/Makefile.am
===================================================================
--- xarchiver/branches/xarchiver-psybsd/src/Makefile.am	2006-08-03 12:40:08 UTC (rev 22641)
+++ xarchiver/branches/xarchiver-psybsd/src/Makefile.am	2006-08-03 15:05:48 UTC (rev 22642)
@@ -2,7 +2,8 @@
 
 xarchiver_SOURCES = \
 	main.c main.h \
-	new_dialog.c new_dialog.h
+	new_dialog.c new_dialog.h \ 
+	extract_dialog.c extract_dialog.h
 
 xarchiver_CFLAGS = \
 	@GTK_CFLAGS@ \

Added: xarchiver/branches/xarchiver-psybsd/src/extract_dialog.c
===================================================================
--- xarchiver/branches/xarchiver-psybsd/src/extract_dialog.c	                        (rev 0)
+++ xarchiver/branches/xarchiver-psybsd/src/extract_dialog.c	2006-08-03 15:05:48 UTC (rev 22642)
@@ -0,0 +1,80 @@
+/*
+ *  Copyright (c) 2006 Stephan Arts <psybsd at gmail.com>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include <config.h>
+#include <gettext.h>
+#include <glib.h>
+#include <gtk/gtk.h>
+#include <libxarchiver/libxarchiver.h>
+#include "extract_dialog.h"
+
+static void
+xa_extract_archive_dialog_class_init(XAExtractArchiveDialogClass *archive_class);
+
+static void
+xa_extract_archive_dialog_init(XAExtractArchiveDialog *archive);
+
+static void
+xa_extract_archive_dialog_finalize(GObject *object);
+
+GType
+xa_extract_archive_dialog_get_type ()
+{
+	static GType xa_extract_archive_dialog_type = 0;
+
+ 	if (!xa_extract_archive_dialog_type)
+	{
+ 		static const GTypeInfo xa_extract_archive_dialog_info = 
+		{
+			sizeof (XAExtractArchiveDialogClass),
+			(GBaseInitFunc) NULL,
+			(GBaseFinalizeFunc) NULL,
+			(GClassInitFunc) xa_extract_archive_dialog_class_init,
+			(GClassFinalizeFunc) NULL,
+			NULL,
+			sizeof (XAExtractArchiveDialog),
+			0,
+			(GInstanceInitFunc) xa_extract_archive_dialog_init,
+			NULL
+		};
+
+		xa_extract_archive_dialog_type = g_type_register_static (GTK_TYPE_FILE_CHOOSER_DIALOG, "XAExtractArchiveDialog", &xa_extract_archive_dialog_info, 0);
+	}
+	return xa_extract_archive_dialog_type;
+}
+
+static void
+xa_extract_archive_dialog_class_init(XAExtractArchiveDialogClass *dialog_class)
+{
+}
+
+static void
+xa_extract_archive_dialog_init(XAExtractArchiveDialog *dialog)
+{
+}
+
+GtkWidget *
+xa_extract_archive_dialog_new()
+{
+	GtkWidget *dialog;
+	GtkFileFilter *filter = NULL;
+
+	dialog = g_object_new(xa_extract_archive_dialog_get_type(), "title", _("Extract archive"), "action", GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER, "do-overwrite-confirmation", TRUE, NULL);
+
+	return dialog;
+}

Added: xarchiver/branches/xarchiver-psybsd/src/extract_dialog.h
===================================================================
--- xarchiver/branches/xarchiver-psybsd/src/extract_dialog.h	                        (rev 0)
+++ xarchiver/branches/xarchiver-psybsd/src/extract_dialog.h	2006-08-03 15:05:48 UTC (rev 22642)
@@ -0,0 +1,58 @@
+/*
+ *  Copyright (c) 2006 Stephan Arts <psybsd at gmail.com>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __XARCHIVER_EXTRACT_ARCHIVE_DIALOG_H__
+#define __XARCHIVER_EXTRACT_ARCHIVE_DIALOG_H__
+G_BEGIN_DECLS
+
+#define XA_EXTRACT_ARCHIVE_DIALOG(obj)         ( \
+		G_TYPE_CHECK_INSTANCE_CAST ((obj),    \
+			xa_extract_archive_dialog_get_type(),      \
+			XAExtractArchiveDialog))
+
+#define XA_IS_EXTRACT_ARCHIVE_DIALOG(obj)      ( \
+		G_TYPE_CHECK_INSTANCE_TYPE ((obj),    \
+			xa_extract_archive_dialog_get_type()))
+
+#define XA_EXTRACT_ARCHIVE_DIALOG_CLASS(class) ( \
+		G_TYPE_CHECK_CLASS_CAST ((class),     \
+			xa_extract_archive_dialog_get_type(),      \
+			XAExtractArchiveDialogClass))
+
+#define XA_IS_EXTRACT_ARCHIVE_DIALOG_CLASS(class) ( \
+		G_TYPE_CHECK_CLASS_TYPE ((class),        \
+			xa_extract_archive_dialog_get_type()))
+
+typedef struct _XAExtractArchiveDialog XAExtractArchiveDialog;
+
+struct _XAExtractArchiveDialog
+{
+	GtkFileSelection parent;
+};
+
+typedef struct _XAExtractArchiveDialogClass XAExtractArchiveDialogClass;
+
+struct _XAExtractArchiveDialogClass
+{
+	GtkFileSelectionClass parent;
+};
+
+GtkWidget *xa_extract_archive_dialog_new();
+
+G_END_DECLS
+#endif /* __XARCHIVER_EXTRACT_ARCHIVE_DIALOG_H__ */

Modified: xarchiver/branches/xarchiver-psybsd/src/main.c
===================================================================
--- xarchiver/branches/xarchiver-psybsd/src/main.c	2006-08-03 12:40:08 UTC (rev 22641)
+++ xarchiver/branches/xarchiver-psybsd/src/main.c	2006-08-03 15:05:48 UTC (rev 22642)
@@ -24,6 +24,7 @@
 #include <gtk/gtk.h>
 
 #include "new_dialog.h"
+#include "extract_dialog.h"
 #include "main.h"
 
 gboolean no_gui = FALSE;
@@ -47,19 +48,19 @@
 static GOptionEntry entries[] =
 {
 	{	"extract-to", 'x', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_STRING, &extract_archive_path,
-		"",
+		NULL,
 		N_("[destination path]")
 	},
 	{	"extract", 'e', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE, &extract_archive,
-		"",
+		NULL,
 		NULL
 	},
 	{	"add-to", 'd', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_STRING, &add_archive_path,
-		"",
+		NULL,
 		N_("[archive path] [file1] [file2] ... [fileN]")
 	},
 	{	"new", 'n', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE, &new_archive,
-		"",
+		NULL,
 		N_("[file1] [file2] ... [fileN]")
 	},
 	{ NULL }
@@ -182,6 +183,13 @@
 			/* 
 			 * TODO: Show extract-dialog.
 			 */
+			dialog = xa_extract_archive_dialog_new();
+			result = gtk_dialog_run (GTK_DIALOG (dialog) );
+			if(result == GTK_RESPONSE_CANCEL || result == GTK_RESPONSE_DELETE_EVENT)
+			{
+				gtk_widget_destroy (GTK_WIDGET (dialog) );
+				return 2;
+			}
 		}
 		for(i = 1; i < argc; i++)
 		{
@@ -234,10 +242,13 @@
 				/* do crazy stuff */
 				new_archivetype = xa_new_archive_dialog_get_archive_type(XA_NEW_ARCHIVE_DIALOG(dialog));
 				new_compressiontype = xa_new_archive_dialog_get_compression_type(XA_NEW_ARCHIVE_DIALOG(dialog));
-				add_archive_path = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
+				add_archive_path = xa_new_archive_dialog_get_filename(XA_NEW_ARCHIVE_DIALOG(dialog));
 				if(new_archivetype == LXA_ARCHIVETYPE_UNKNOWN)
 				{
-					/* auto-detect*/
+					/* auto-detect
+				   * FIXME: should not work if type is unsupported
+					 * TODO: Move this code to new_dialog, if possible 
+					 */
 					if(g_str_has_suffix(add_archive_path, ".tgz") || g_str_has_suffix(add_archive_path, ".tar.gz"))
 					{
 						new_archivetype = LXA_ARCHIVETYPE_TAR;
@@ -253,6 +264,11 @@
 						new_archivetype = LXA_ARCHIVETYPE_TAR;
 						new_compressiontype = LXA_COMPRESSIONTYPE_NONE;
 					}
+					if(g_str_has_suffix(add_archive_path, ".zip"))
+					{
+						new_archivetype = LXA_ARCHIVETYPE_ZIP;
+						new_compressiontype = LXA_COMPRESSIONTYPE_NONE;
+					}
 				}
 				if(new_archivetype != LXA_ARCHIVETYPE_UNKNOWN)
 				{
@@ -289,6 +305,16 @@
 							g_debug("TAR\n");
 						}
 					}
+					if(new_archivetype == LXA_ARCHIVETYPE_ZIP)
+					{
+							if(!g_str_has_suffix(add_archive_path, ".zip"))
+							{
+								temp_path = g_strconcat(add_archive_path, ".zip",  NULL);
+								g_free(add_archive_path);
+								add_archive_path = temp_path;
+							}
+							g_debug("ZIP\n");
+					}
 					if(!lxa_new_archive(add_archive_path, new_archivetype, new_compressiontype, TRUE, &xa_archive, G_CALLBACK(archive_initialized)))
 					{
 						g_signal_connect(G_OBJECT(xa_archive), "lxa_status_changed", G_CALLBACK(archive_status_changed), NULL);

Modified: xarchiver/branches/xarchiver-psybsd/src/new_dialog.c
===================================================================
--- xarchiver/branches/xarchiver-psybsd/src/new_dialog.c	2006-08-03 12:40:08 UTC (rev 22641)
+++ xarchiver/branches/xarchiver-psybsd/src/new_dialog.c	2006-08-03 15:05:48 UTC (rev 22642)
@@ -213,3 +213,11 @@
 	g_free(ct_value);
 	return type;
 }
+
+gchar *
+xa_new_archive_dialog_get_filename (XANewArchiveDialog *dialog)
+{
+	gchar *filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
+
+	return filename;
+}

Modified: xarchiver/branches/xarchiver-psybsd/src/new_dialog.h
===================================================================
--- xarchiver/branches/xarchiver-psybsd/src/new_dialog.h	2006-08-03 12:40:08 UTC (rev 22641)
+++ xarchiver/branches/xarchiver-psybsd/src/new_dialog.h	2006-08-03 15:05:48 UTC (rev 22642)
@@ -60,6 +60,7 @@
 
 LXAArchiveType     xa_new_archive_dialog_get_archive_type (XANewArchiveDialog *);
 LXACompressionType xa_new_archive_dialog_get_compression_type (XANewArchiveDialog *);
+gchar *            xa_new_archive_dialog_get_filename (XANewArchiveDialog *dialog);
 
 G_END_DECLS
 #endif /* __XARCHIVER_NEW_ARCHIVE_DIALOG_H__ */



More information about the Xfce4-commits mailing list