[Xfce4-commits] r22736 - in xarchiver/branches/xarchiver-psybsd: libxarchiver src

Stephan Arts stephan at xfce.org
Sun Aug 13 07:50:45 UTC 2006


Author: stephan
Date: 2006-08-13 07:50:44 +0000 (Sun, 13 Aug 2006)
New Revision: 22736

Modified:
   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-support-zip.c
   xarchiver/branches/xarchiver-psybsd/libxarchiver/archive-support-zip.h
   xarchiver/branches/xarchiver-psybsd/libxarchiver/archive-support.c
   xarchiver/branches/xarchiver-psybsd/libxarchiver/archive-support.h
   xarchiver/branches/xarchiver-psybsd/libxarchiver/archive.c
   xarchiver/branches/xarchiver-psybsd/src/main.c
   xarchiver/branches/xarchiver-psybsd/src/new_dialog.c
Log:
- Implemented 'remove'
- Implemented 'add-to' commandline switch



Modified: xarchiver/branches/xarchiver-psybsd/libxarchiver/archive-support-gnu-tar.c
===================================================================
--- xarchiver/branches/xarchiver-psybsd/libxarchiver/archive-support-gnu-tar.c	2006-08-13 06:48:09 UTC (rev 22735)
+++ xarchiver/branches/xarchiver-psybsd/libxarchiver/archive-support-gnu-tar.c	2006-08-13 07:50:44 UTC (rev 22736)
@@ -84,6 +84,7 @@
 
 	archive_support->add = lxa_archive_support_gnu_tar_add;
 	archive_support->extract = lxa_archive_support_gnu_tar_extract;
+	archive_support->remove = lxa_archive_support_gnu_tar_remove;
 }
 
 void
@@ -172,13 +173,45 @@
 				command = g_strconcat(LXA_ARCHIVE_SUPPORT_GNU_TAR(support)->app_name, " -zxf ", archive->path, " -C ", dest_path, " ", files, NULL);
 			if(!g_strcasecmp((gchar *)archive->mime, "application/x-bzip-compressed-tar"))
 				command = g_strconcat(LXA_ARCHIVE_SUPPORT_GNU_TAR(support)->app_name, " -jxf ", archive->path, " -C ", dest_path, " ", files, NULL);
-			if(command)
-			{
-				g_debug("Extracting archive '%s' to '%s'", archive->path, dest_path);
-				lxa_execute(command, archive, NULL, NULL, NULL, NULL);
-			}	
 		} else
 			return 1;
+		if(command)
+			lxa_execute(command, archive, NULL, NULL, NULL, NULL);
 	}
 	return 0;
 }
+
+gint
+lxa_archive_support_gnu_tar_remove(LXAArchiveSupport *support, LXAArchive *archive, GSList *filenames)
+{
+	if(!LXA_IS_ARCHIVE_SUPPORT_GNU_TAR(support))
+	{
+		g_critical("Support is not GNU TAR");
+		return -1;
+	}
+
+	if(!lxa_archive_support_mime_supported(support, archive->mime))
+	{
+		return 1;
+	}
+	else
+	{
+		gchar *command = NULL;
+		gchar *files = lxa_concat_filenames(filenames);
+		if(g_file_test(archive->path, G_FILE_TEST_EXISTS))
+		{
+			if(!g_strcasecmp((gchar *)archive->mime, "application/x-tar"))
+				command = g_strconcat(LXA_ARCHIVE_SUPPORT_GNU_TAR(support)->app_name, " -f ", archive->path, " --delete ", files, NULL);
+			if(!g_strcasecmp((gchar *)archive->mime, "application/x-tarz"))
+				command = g_strconcat(LXA_ARCHIVE_SUPPORT_GNU_TAR(support)->app_name, " -Zf ", archive->path, " --delete ", files, NULL);
+			if(!g_strcasecmp((gchar *)archive->mime, "application/x-compressed-tar"))
+				command = g_strconcat(LXA_ARCHIVE_SUPPORT_GNU_TAR(support)->app_name, " -zf ", archive->path, " --delete ", files, NULL);
+			if(!g_strcasecmp((gchar *)archive->mime, "application/x-bzip-compressed-tar"))
+				command = g_strconcat(LXA_ARCHIVE_SUPPORT_GNU_TAR(support)->app_name, " -jf ", archive->path, " --delete ", files, NULL);
+		} else
+			return 1;
+		if(command)
+			lxa_execute(command, archive, NULL, NULL, NULL, NULL);
+	}
+	return 0;
+}

Modified: xarchiver/branches/xarchiver-psybsd/libxarchiver/archive-support-gnu-tar.h
===================================================================
--- xarchiver/branches/xarchiver-psybsd/libxarchiver/archive-support-gnu-tar.h	2006-08-13 06:48:09 UTC (rev 22735)
+++ xarchiver/branches/xarchiver-psybsd/libxarchiver/archive-support-gnu-tar.h	2006-08-13 07:50:44 UTC (rev 22736)
@@ -61,6 +61,7 @@
 
 gint                 lxa_archive_support_gnu_tar_add(LXAArchiveSupport *, LXAArchive *, GSList *);
 gint                 lxa_archive_support_gnu_tar_extract(LXAArchiveSupport *, LXAArchive *, gchar *, GSList *);
+gint                 lxa_archive_support_gnu_tar_remove(LXAArchiveSupport *, LXAArchive *, GSList *);
 
 G_END_DECLS
 

Modified: xarchiver/branches/xarchiver-psybsd/libxarchiver/archive-support-zip.c
===================================================================
--- xarchiver/branches/xarchiver-psybsd/libxarchiver/archive-support-zip.c	2006-08-13 06:48:09 UTC (rev 22735)
+++ xarchiver/branches/xarchiver-psybsd/libxarchiver/archive-support-zip.c	2006-08-13 07:50:44 UTC (rev 22736)
@@ -149,3 +149,30 @@
 	}
 	return 0;
 }
+
+gint
+lxa_archive_support_zip_remove(LXAArchiveSupport *support, LXAArchive *archive, GSList *filenames)
+{
+	if(!LXA_IS_ARCHIVE_SUPPORT_ZIP(support))
+	{
+		g_critical("Support is not zip");
+		return -1;
+	}
+
+	if(!lxa_archive_support_mime_supported(support, archive->mime))
+	{
+		return 1;
+	}
+	else
+	{
+		gchar *command = NULL;
+		gchar *files = lxa_concat_filenames(filenames);
+		if(!g_strcasecmp((gchar *)archive->mime, "application/x-zip") || 
+		   !g_strcasecmp((gchar *)archive->mime, "application/zip"))
+		{
+			command = g_strconcat("zip -d ", archive->path, " ", files, NULL);
+			lxa_execute(command, archive, NULL, NULL, NULL, NULL);
+		}
+	}
+	return 0;
+}

Modified: xarchiver/branches/xarchiver-psybsd/libxarchiver/archive-support-zip.h
===================================================================
--- xarchiver/branches/xarchiver-psybsd/libxarchiver/archive-support-zip.h	2006-08-13 06:48:09 UTC (rev 22735)
+++ xarchiver/branches/xarchiver-psybsd/libxarchiver/archive-support-zip.h	2006-08-13 07:50:44 UTC (rev 22736)
@@ -60,6 +60,7 @@
 
 gint                 lxa_archive_support_zip_add(LXAArchiveSupport *, LXAArchive *, GSList *);
 gint                 lxa_archive_support_zip_extract(LXAArchiveSupport *, LXAArchive *, gchar *, GSList *);
+gint                 lxa_archive_support_zip_remove(LXAArchiveSupport *, LXAArchive *, GSList *);
 
 G_END_DECLS
 

Modified: xarchiver/branches/xarchiver-psybsd/libxarchiver/archive-support.c
===================================================================
--- xarchiver/branches/xarchiver-psybsd/libxarchiver/archive-support.c	2006-08-13 06:48:09 UTC (rev 22735)
+++ xarchiver/branches/xarchiver-psybsd/libxarchiver/archive-support.c	2006-08-13 07:50:44 UTC (rev 22736)
@@ -69,6 +69,7 @@
 {
 	support->add = NULL;
 	support->extract = NULL;
+	support->remove = NULL;
 }
 
 /*
@@ -173,3 +174,33 @@
 	else
 		return 1;
 }		
+
+gint
+lxa_archive_support_add(LXAArchiveSupport *support, LXAArchive *archive, GSList *files)
+{
+	if(support->add)
+		return support->add(support, archive, files);
+	else
+		g_critical("ADD NOT IMPLEMENTED BY SUPPORT OBJECT '%s'", support->id);
+	return -1;
+}
+
+gint
+lxa_archive_support_extract(LXAArchiveSupport *support, LXAArchive *archive, gchar *dest_path, GSList *files)
+{
+	if(support->extract)
+		return support->extract(support, archive, dest_path, files);
+	else
+		g_critical("EXTRACT NOT IMPLEMENTED BY SUPPORT OBJECT '%s'", support->id);
+	return -1;
+}
+
+gint
+lxa_archive_support_remove(LXAArchiveSupport *support, LXAArchive *archive, GSList *files)
+{
+	if(support->remove)
+		return support->remove(support, archive, files);
+	else
+		g_critical("REMOVE NOT IMPLEMENTED BY SUPPORT OBJECT '%s'", support->id);
+	return -1;
+}

Modified: xarchiver/branches/xarchiver-psybsd/libxarchiver/archive-support.h
===================================================================
--- xarchiver/branches/xarchiver-psybsd/libxarchiver/archive-support.h	2006-08-13 06:48:09 UTC (rev 22735)
+++ xarchiver/branches/xarchiver-psybsd/libxarchiver/archive-support.h	2006-08-13 07:50:44 UTC (rev 22736)
@@ -59,6 +59,7 @@
  */
 	gint        (*add)(LXAArchiveSupport *support, LXAArchive *archive, GSList *files);
 	gint        (*extract)(LXAArchiveSupport *support, LXAArchive *archive, gchar *dest_path, GSList *files);
+	gint        (*remove)(LXAArchiveSupport *support, LXAArchive *archive, GSList *files);
 };
 
 typedef struct _LXAArchiveSupportClass LXAArchiveSupportClass;
@@ -82,6 +83,7 @@
 
 gint                 lxa_archive_support_add(LXAArchiveSupport *, LXAArchive *, GSList *);
 gint                 lxa_archive_support_extract(LXAArchiveSupport *, LXAArchive *, gchar *, GSList *);
+gint                 lxa_archive_support_remove(LXAArchiveSupport *, LXAArchive *, GSList *);
 
 G_END_DECLS
 

Modified: xarchiver/branches/xarchiver-psybsd/libxarchiver/archive.c
===================================================================
--- xarchiver/branches/xarchiver-psybsd/libxarchiver/archive.c	2006-08-13 06:48:09 UTC (rev 22735)
+++ xarchiver/branches/xarchiver-psybsd/libxarchiver/archive.c	2006-08-13 07:50:44 UTC (rev 22736)
@@ -107,23 +107,3 @@
 
 	return archive;
 }
-
-gint
-lxa_archive_support_add(LXAArchiveSupport *support, LXAArchive *archive, GSList *files)
-{
-	if(support->add)
-		return support->add(support, archive, files);
-	else
-		g_critical("ADD NOT IMPLEMENTED BY SUPPORT OBJECT '%s'", support->id);
-	return -1;
-}
-
-gint
-lxa_archive_support_extract(LXAArchiveSupport *support, LXAArchive *archive, gchar *dest_path, GSList *files)
-{
-	if(support->extract)
-		return support->extract(support, archive, dest_path, files);
-	else
-		g_critical("EXTRACT NOT IMPLEMENTED BY SUPPORT OBJECT '%s'", support->id);
-	return -1;
-}

Modified: xarchiver/branches/xarchiver-psybsd/src/main.c
===================================================================
--- xarchiver/branches/xarchiver-psybsd/src/main.c	2006-08-13 06:48:09 UTC (rev 22735)
+++ xarchiver/branches/xarchiver-psybsd/src/main.c	2006-08-13 07:50:44 UTC (rev 22736)
@@ -129,31 +129,37 @@
 			}
 		}
 	}
-	if(new_archive)
+	if(new_archive || add_archive_path)
 	{
-		dialog = xa_new_archive_dialog_new();
-		result = gtk_dialog_run (GTK_DIALOG (dialog) );
-		if(result == GTK_RESPONSE_CANCEL || result == GTK_RESPONSE_DELETE_EVENT)
+		if(!add_archive_path)
 		{
-			gtk_widget_destroy (GTK_WIDGET (dialog) );
-			return 2;
-		}
-		if(result == GTK_RESPONSE_OK)
-		{
-			add_archive_path = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
-			gtk_widget_destroy (GTK_WIDGET (dialog) );
-			if(!lxa_new_archive(add_archive_path, TRUE, NULL, &lpArchive))
+			dialog = xa_new_archive_dialog_new();
+			result = gtk_dialog_run (GTK_DIALOG (dialog) );
+			if(result == GTK_RESPONSE_CANCEL || result == GTK_RESPONSE_DELETE_EVENT)
 			{
-				GSList *files = NULL;
-				for(i = 1; i < argc; i++)
-				{
-					files = g_slist_prepend(files, argv[i]);
-				}
-				lpSupport = lxa_get_support_for_mime(lpArchive->mime);
-				lxa_archive_support_add(lpSupport, lpArchive, files);
+				gtk_widget_destroy (GTK_WIDGET (dialog) );
+				return 2;
 			}
+			if(result == GTK_RESPONSE_OK)
+			{
+				add_archive_path = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
+				gtk_widget_destroy (GTK_WIDGET (dialog) );
+			}
+			if(lxa_new_archive(add_archive_path, TRUE, NULL, &lpArchive))
+				return 1;
 		}
-
+		else
+		{
+			if(lxa_open_archive(add_archive_path, &lpArchive))
+				return 1;
+		}
+		GSList *files = NULL;
+		for(i = 1; i < argc; i++)
+		{
+			files = g_slist_prepend(files, argv[i]);
+		}
+		lpSupport = lxa_get_support_for_mime(lpArchive->mime);
+		lxa_archive_support_add(lpSupport, lpArchive, files);
 	}
 
 	gtk_main();

Modified: xarchiver/branches/xarchiver-psybsd/src/new_dialog.c
===================================================================
--- xarchiver/branches/xarchiver-psybsd/src/new_dialog.c	2006-08-13 06:48:09 UTC (rev 22735)
+++ xarchiver/branches/xarchiver-psybsd/src/new_dialog.c	2006-08-13 07:50:44 UTC (rev 22736)
@@ -79,40 +79,9 @@
 xa_new_archive_dialog_new()
 {
 	GtkWidget *dialog;
-	GtkFileFilter *filter = NULL;
 
 	dialog = g_object_new(xa_new_archive_dialog_get_type(), "title", _("Create new archive"), "action", GTK_FILE_CHOOSER_ACTION_SAVE, "do-overwrite-confirmation", TRUE, NULL);
 
-	filter = gtk_file_filter_new();
-	gtk_file_filter_add_mime_type(filter, "application/x-tar");
-	gtk_file_filter_add_mime_type(filter, "application/x-compressed-tar");
-	gtk_file_filter_add_mime_type(filter, "application/x-bzip-compressed-tar");
-	gtk_file_filter_add_mime_type(filter, "application/x-zip");
-	gtk_file_filter_add_mime_type(filter, "application/zip");
-	gtk_file_filter_set_name(filter, _("All Archives"));
-	gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog), filter);
-
-	filter = gtk_file_filter_new();
-	gtk_file_filter_add_mime_type(filter, "application/x-tar");
-	gtk_file_filter_set_name(filter, _("Tar (uncompressed) '.tar'"));
-	gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog), filter);
-
-	filter = gtk_file_filter_new();
-	gtk_file_filter_add_mime_type(filter, "application/x-compressed-tar");
-	gtk_file_filter_set_name(filter, _("Gzip compressed Tar '.tar.gz'"));
-	gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog), filter);
-
-	filter = gtk_file_filter_new();
-	gtk_file_filter_add_mime_type(filter, "application/x-bzip-compressed-tar");
-	gtk_file_filter_set_name(filter, _("Bzip2 compressed Tar '.tar.bz2'"));
-	gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog), filter);
-
-	filter = gtk_file_filter_new();
-	gtk_file_filter_add_mime_type(filter, "application/x-zip");
-	gtk_file_filter_add_mime_type(filter, "application/zip");
-	gtk_file_filter_set_name(filter, _("Zip '.zip'"));
-	gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog), filter);
-
 	return dialog;
 }
 



More information about the Xfce4-commits mailing list