[Xfce4-commits] r27253 - in squeeze/trunk: libsqueeze src

Peter de Ridder peter at xfce.org
Thu Jul 10 23:52:53 CEST 2008


Author: peter
Date: 2008-07-10 21:52:53 +0000 (Thu, 10 Jul 2008)
New Revision: 27253

Modified:
   squeeze/trunk/libsqueeze/archive.c
   squeeze/trunk/libsqueeze/archive.h
   squeeze/trunk/libsqueeze/command-queue.c
   squeeze/trunk/libsqueeze/command-queue.h
   squeeze/trunk/src/application.c
   squeeze/trunk/src/main_window.c
   squeeze/trunk/src/notebook.c
Log:
made extract working

Modified: squeeze/trunk/libsqueeze/archive.c
===================================================================
--- squeeze/trunk/libsqueeze/archive.c	2008-07-10 15:55:22 UTC (rev 27252)
+++ squeeze/trunk/libsqueeze/archive.c	2008-07-10 21:52:53 UTC (rev 27253)
@@ -410,7 +410,7 @@
  * Return value: TRUE on success
  */
 gboolean
-lsq_archive_operate(LSQArchive *archive, LSQCommandType type, const gchar **files)
+lsq_archive_operate(LSQArchive *archive, LSQCommandType type, const gchar **files, const gchar *directory)
 {
     g_return_val_if_fail(archive, FALSE);
 
@@ -419,16 +419,16 @@
     switch (type)
     {
         case LSQ_COMMAND_TYPE_ADD:
-            lsq_command_queue_execute(s_template->add_cmd_queue, archive, files, s_template->parser);
+            lsq_command_queue_execute(s_template->add_cmd_queue, archive, files, NULL, NULL);
             break;
         case LSQ_COMMAND_TYPE_REMOVE:
-            lsq_command_queue_execute(s_template->remove_cmd_queue, archive, files, s_template->parser);
+            lsq_command_queue_execute(s_template->remove_cmd_queue, archive, files, NULL, NULL);
             break;
         case LSQ_COMMAND_TYPE_EXTRACT:
-            lsq_command_queue_execute(s_template->extract_cmd_queue, archive, files, s_template->parser);
+            lsq_command_queue_execute(s_template->extract_cmd_queue, archive, files, directory, NULL);
             break;
         case LSQ_COMMAND_TYPE_REFRESH:
-            lsq_command_queue_execute(s_template->refresh_cmd_queue, archive, files, s_template->parser);
+            lsq_command_queue_execute(s_template->refresh_cmd_queue, archive, files, NULL, s_template->parser);
             break;
         default:
             return FALSE;

Modified: squeeze/trunk/libsqueeze/archive.h
===================================================================
--- squeeze/trunk/libsqueeze/archive.h	2008-07-10 15:55:22 UTC (rev 27252)
+++ squeeze/trunk/libsqueeze/archive.h	2008-07-10 21:52:53 UTC (rev 27253)
@@ -108,7 +108,7 @@
 
 ThunarVfsPath	  *lsq_archive_get_path_info(LSQArchive *);
 
-gboolean		lsq_archive_operate(LSQArchive *archive, LSQCommandType type, const gchar **);
+gboolean		lsq_archive_operate(LSQArchive *archive, LSQCommandType type, const gchar **, const gchar *);
 
 const gchar	*
 lsq_archive_get_state_msg(const LSQArchive *archive);

Modified: squeeze/trunk/libsqueeze/command-queue.c
===================================================================
--- squeeze/trunk/libsqueeze/command-queue.c	2008-07-10 15:55:22 UTC (rev 27252)
+++ squeeze/trunk/libsqueeze/command-queue.c	2008-07-10 21:52:53 UTC (rev 27253)
@@ -57,8 +57,10 @@
   LSQParser *parser;
   LSQArchive *archive;
   gchar **files;
+  gchar *directory;
   gchar *tempfile;
   LSQParserContext *ctx;
+  GIOChannel *redir_out;
   enum {
     LSQ_EXEC_CTX_STATE_RUNNING = 1<<0,
     LSQ_EXEC_CTX_STATE_PARSING = 1<<1
@@ -132,7 +134,8 @@
   {
     if(0==strcmp((const gchar*)iter->data, "%F"))
     {
-      size += g_strv_length(ctx->files);
+      if(ctx->files)
+        size += g_strv_length(ctx->files);
     }
     else
       size++;
@@ -152,9 +155,12 @@
       switch(arg[1])
       {
         case 'F':
-          for(filei = ctx->files; *filei; filei++)
+          if(ctx->files)
           {
-            *argi++ = g_strdup(*filei);
+            for(filei = ctx->files; *filei; filei++)
+            {
+              *argi++ = g_strdup(*filei);
+            }
           }
           break;
         case 'a':
@@ -163,6 +169,9 @@
         case 't':
           *argi++ = g_strdup(lsq_execute_context_get_temp_file(ctx));
           break;
+        case 'd':
+          *argi++ = g_strdup(ctx->directory);
+          break;
         default:
           //...
           break;
@@ -220,21 +229,23 @@
 static void out_channel(GIOChannel *source, GIOCondition condition, LSQExecuteContext *ctx)
 {
 	GIOStatus stat = G_IO_STATUS_NORMAL;
+  GIOChannel *dest = ctx->redir_out;
   static gchar buffer[1024];
 
   if(condition & G_IO_IN)
   {
     gsize n;
     stat = g_io_channel_read_chars(source, buffer, 1024, &n, NULL);
-    //if(stat == G_IO_STATUS_NORMAL)
-      //g_io_channel_write_chars(dest, buffer, n, NULL, NULL);
+    if(stat == G_IO_STATUS_NORMAL)
+      g_io_channel_write_chars(dest, buffer, n, NULL, NULL);
   }
 
   if(condition & G_IO_HUP || (stat != G_IO_STATUS_NORMAL && stat != G_IO_STATUS_AGAIN))
   {
     g_io_channel_unref(source);
-    //g_io_channel_flush(dest);
-    //g_io_channel_unref(dest);
+    g_io_channel_flush(dest, NULL);
+    g_io_channel_unref(dest);
+    ctx->redir_out = NULL;
     ctx->state &= ~LSQ_EXEC_CTX_STATE_PARSING;
     if(!ctx->state)
     {
@@ -243,7 +254,6 @@
       //else
         //...//done
     }
-    lsq_archive_refreshed(ctx->archive);
   }
 }
 
@@ -251,9 +261,12 @@
 parse_channel(GIOChannel *source, GIOCondition condition, LSQExecuteContext *ctx)
 {
   if(condition & G_IO_IN)
+  {
     do {
       lsq_parser_parse(ctx->parser, ctx->ctx);
     } while(lsq_parser_context_read_again(ctx->ctx));
+  }
+
   if(condition & G_IO_HUP || !lsq_parser_context_is_good(ctx->ctx))
   {
     lsq_parser_context_set_channel(ctx->ctx, NULL);
@@ -266,6 +279,7 @@
       //else
         //...//done
     }
+    //FIXME: this is not entirely the correct place, or is it?
     lsq_archive_refreshed(ctx->archive);
     return FALSE;
   }
@@ -279,7 +293,6 @@
   gint fd_out = TRUE;
   GIOChannel *redir_in = NULL;
   GIOChannel *chan_in;
-  //GIOChannel *redir_out;
   GIOChannel *chan_out;
   gchar **argv;
   GPid pid;
@@ -287,7 +300,7 @@
   if(entry->redirect_out)
   {
     gchar *file = format_get_filename(entry->redirect_out, ctx);
-    redir_in = g_io_channel_new_file(file, "w", NULL);
+    ctx->redir_out = g_io_channel_new_file(file, "w", NULL);
     g_free(file);
   }
   else if(!ctx->ctx)
@@ -298,7 +311,7 @@
   if(entry->redirect_in)
   {
     gchar *file = format_get_filename(entry->redirect_in, ctx);
-    //redir_in = g_io_channel_new_file(file, "r", NULL);
+    redir_in = g_io_channel_new_file(file, "r", NULL);
     g_free(file);
     fd_in = TRUE;
   }
@@ -346,7 +359,7 @@
   }
 }
 
-LSQExecuteContext *lsq_command_queue_execute(LSQCommandQueue *queue, LSQArchive *archive, const gchar **files, LSQParser *parser)
+LSQExecuteContext *lsq_command_queue_execute(LSQCommandQueue *queue, LSQArchive *archive, const gchar **files, const gchar *directory, LSQParser *parser)
 {
   LSQExecuteContext *ctx;
 
@@ -355,6 +368,7 @@
   ctx->queue = queue->queue;
   ctx->archive = archive;
   ctx->files = g_strdupv((gchar**)files);
+  ctx->directory = g_strdup(directory);
   ctx->parser = parser;
   ctx->ctx = parser?lsq_parser_get_context(parser, archive):NULL;
 

Modified: squeeze/trunk/libsqueeze/command-queue.h
===================================================================
--- squeeze/trunk/libsqueeze/command-queue.h	2008-07-10 15:55:22 UTC (rev 27252)
+++ squeeze/trunk/libsqueeze/command-queue.h	2008-07-10 21:52:53 UTC (rev 27253)
@@ -56,7 +56,7 @@
 
 LSQCommandQueue *lsq_command_queue_new(const gchar *command_string);
 
-LSQExecuteContext *lsq_command_queue_execute(LSQCommandQueue *queue, LSQArchive *archive, const gchar **files, LSQParser *parser);
+LSQExecuteContext *lsq_command_queue_execute(LSQCommandQueue *queue, LSQArchive *archive, const gchar **files, const gchar *direcotry, LSQParser *parser);
 
 
 G_END_DECLS

Modified: squeeze/trunk/src/application.c
===================================================================
--- squeeze/trunk/src/application.c	2008-07-10 15:55:22 UTC (rev 27252)
+++ squeeze/trunk/src/application.c	2008-07-10 21:52:53 UTC (rev 27253)
@@ -178,7 +178,7 @@
 	}
 	GtkWidget *message_dialog = sq_message_dialog_new(GTK_WINDOW_TOPLEVEL, lp_archive);
 	gtk_widget_show(message_dialog);
-	if(!lsq_archive_operate(lp_archive, LSQ_COMMAND_TYPE_EXTRACT, NULL))
+	if(!lsq_archive_operate(lp_archive, LSQ_COMMAND_TYPE_EXTRACT, NULL, dest_path))
 	{
 		GtkWidget *warning_dialog = gtk_message_dialog_new(NULL, 
 														   GTK_DIALOG_DESTROY_WITH_PARENT, 
@@ -253,7 +253,7 @@
 	GtkWidget *message_dialog = sq_message_dialog_new(GTK_WINDOW_TOPLEVEL, lp_archive);
 	gtk_widget_show(message_dialog);
 
-	if(!lsq_archive_operate(lp_archive, LSQ_COMMAND_TYPE_ADD, NULL))
+	if(!lsq_archive_operate(lp_archive, LSQ_COMMAND_TYPE_ADD, NULL, NULL))
 	{
 		/* FIXME: show warning dialog */
 		GtkWidget *warning_dialog = gtk_message_dialog_new(NULL, 

Modified: squeeze/trunk/src/main_window.c
===================================================================
--- squeeze/trunk/src/main_window.c	2008-07-10 15:55:22 UTC (rev 27252)
+++ squeeze/trunk/src/main_window.c	2008-07-10 21:52:53 UTC (rev 27253)
@@ -821,7 +821,7 @@
 			lsq_iter_slist_free(filenames);
 			filenames = NULL;
 		}
-		if(!lsq_archive_operate(lp_archive, LSQ_COMMAND_TYPE_EXTRACT, NULL))
+		if(!lsq_archive_operate(lp_archive, LSQ_COMMAND_TYPE_EXTRACT, NULL, extract_archive_path))
 		{
 			GtkWidget *warning_dialog = gtk_message_dialog_new(GTK_WINDOW(window), 
 															   GTK_DIALOG_DESTROY_WITH_PARENT, 
@@ -869,7 +869,7 @@
 		filenames = gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(dialog));
 		if(filenames)
 		{
-			if(!lsq_archive_operate(lp_archive, LSQ_COMMAND_TYPE_ADD, NULL))
+			if(!lsq_archive_operate(lp_archive, LSQ_COMMAND_TYPE_ADD, NULL, NULL))
 			{
 				GtkWidget *warning_dialog = gtk_message_dialog_new(GTK_WINDOW(window), 
 																													 GTK_DIALOG_DESTROY_WITH_PARENT, 
@@ -911,7 +911,7 @@
 		filenames = gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(dialog));
 		if(filenames)
 		{
-			if(!lsq_archive_operate(lp_archive, LSQ_COMMAND_TYPE_ADD, NULL))
+			if(!lsq_archive_operate(lp_archive, LSQ_COMMAND_TYPE_ADD, NULL, NULL))
 			{
 				GtkWidget *warning_dialog = gtk_message_dialog_new(GTK_WINDOW(window),
 									  GTK_DIALOG_DESTROY_WITH_PARENT, 
@@ -945,7 +945,7 @@
 			gtk_widget_hide(dialog);
 			sq_notebook_get_active_archive(SQ_NOTEBOOK(window->notebook), &lp_archive);
 			/* gtk_tree_view_set_model(sq_notebook_get_active_tree_view(SQ_NOTEBOOK(window->notebook)), NULL); */
-			if(!lsq_archive_operate(lp_archive, LSQ_COMMAND_TYPE_REMOVE, NULL))
+			if(!lsq_archive_operate(lp_archive, LSQ_COMMAND_TYPE_REMOVE, NULL, NULL))
 			{
 				GtkWidget *warning_dialog = gtk_message_dialog_new(GTK_WINDOW(window), 
 																													 GTK_DIALOG_DESTROY_WITH_PARENT, 
@@ -982,7 +982,7 @@
 	SQMainWindow *window = SQ_MAIN_WINDOW(userdata);
 	SQArchiveStore *store = sq_notebook_get_active_store(SQ_NOTEBOOK(window->notebook));
 	LSQArchive *archive = sq_archive_store_get_archive(store);
-	lsq_archive_operate(archive, LSQ_COMMAND_TYPE_REFRESH, NULL);
+	lsq_archive_operate(archive, LSQ_COMMAND_TYPE_REFRESH, NULL, NULL);
 }
 
 static void
@@ -1232,7 +1232,7 @@
 	{
 		case GTK_RESPONSE_OK: /* VIEW */
 			sq_notebook_get_active_archive(SQ_NOTEBOOK(notebook), &lp_archive);
-			if(lsq_archive_operate(lp_archive, LSQ_COMMAND_TYPE_OPEN, NULL))
+			if(lsq_archive_operate(lp_archive, LSQ_COMMAND_TYPE_OPEN, NULL, NULL))
 			{
 				GtkWidget *warning_dialog = gtk_message_dialog_new(window, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_WARNING, GTK_BUTTONS_CLOSE, _("Squeeze cannot view this file.\nthe application to support this is missing."));
 				if(warning_dialog)
@@ -1255,7 +1255,7 @@
 					g_slist_free(files);
 					files = NULL;
 				}
-				if(lsq_archive_operate(lp_archive, LSQ_COMMAND_TYPE_EXTRACT, NULL))
+				if(lsq_archive_operate(lp_archive, LSQ_COMMAND_TYPE_EXTRACT, NULL, extract_archive_path))
 				{
 					GtkWidget *warning_dialog = gtk_message_dialog_new(GTK_WINDOW(window), 
 																	 GTK_DIALOG_DESTROY_WITH_PARENT, 

Modified: squeeze/trunk/src/notebook.c
===================================================================
--- squeeze/trunk/src/notebook.c	2008-07-10 15:55:22 UTC (rev 27252)
+++ squeeze/trunk/src/notebook.c	2008-07-10 21:52:53 UTC (rev 27253)
@@ -574,7 +574,7 @@
 
 	if(new_archive == FALSE)
 	{
-		lsq_archive_operate(archive, LSQ_COMMAND_TYPE_REFRESH, NULL);
+		lsq_archive_operate(archive, LSQ_COMMAND_TYPE_REFRESH, NULL, NULL);
 	}
 
 }
@@ -819,7 +819,7 @@
 
 		g_signal_connect(G_OBJECT(archive), "refreshed", G_CALLBACK(cb_notebook_archive_refreshed), treeview);
 
-		lsq_archive_operate(archive, LSQ_COMMAND_TYPE_REFRESH, NULL);
+		lsq_archive_operate(archive, LSQ_COMMAND_TYPE_REFRESH, NULL, NULL);
 
 
 		gtk_tree_view_set_model(GTK_TREE_VIEW(treeview), store);



More information about the Xfce4-commits mailing list