1 /*
2     Copyright 2007, 2008, 2009, 2010 Geyer Klaus
3 
4     This file is part of Cat'sEyE.
5 
6     Cat'sEyE is free software: you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation, either version 3 of the License, or
9     (at your option) any later version.
10 
11     Cat'sEyE is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15 
16     You should have received a copy of the GNU General Public License
17     along with Cat'sEyE.  If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 
21 #include <gtk/gtk.h>
22 #ifndef NO_GIO
23 #include <gio/gio.h>
24 #endif
25 #include <string.h>
26 #include <stdlib.h>
27 #include <dirent.h>	//Verzeichnis Zeiger und DIR - Struktur
28 #include <unistd.h> //usleep
29 #include <gdk/gdkkeysyms.h>
30 
31 #include "listitems.h"
32 #include "mytrace.h"
33 #include "Lists.h"
34 #include "helpers.h"
35 #include "DragnDrop.h"
36 #include "globalDefinitions.h"
37 #include "userdata.h"
38 #include "CommandParser.h"
39 #include "myfm.h"
40 #include "fileshelf.h"
41 #include "threads.h"
42 
43 #include "allInclude.h"
44 
45 void ProcessItemsViaList(void *data);
46 void calcDirectorySizeInView_thread(struct AllInformationAllUseStruct *stru);
47 void CopyReSizeWidget_deleteSelectedItems (struct ListWidgetCommunicationStruct *CommStru);
48 
49 
50 extern GtkWindow 	*win;
51 
ProcessItemsViaListWrap(struct CopyReMoveList * FirstItem,int process)52 int ProcessItemsViaListWrap(struct CopyReMoveList *FirstItem, int process){
53 	TRACEIT(10,"ProcessItemsViaListWrap		start");
54 	GError *Error=NULL;
55 	if (FirstItem == NULL){
56 		TRACEIT(10,"ProcessItemsViaListWrap		ends -1");
57 		return -1;
58 	}
59 	if( !g_thread_supported() ){
60 		g_thread_init(NULL);
61     }
62 
63 	struct CopyReMoveList *bufitem = FirstItem;
64 	while (bufitem){
65         bufitem->CopyMoveOrRemove=process;
66         bufitem = bufitem->NextItem;
67 	}
68 
69 	g_thread_create((GThreadFunc)ProcessItemsViaList, (void *)FirstItem , FALSE, &Error);
70 	if (Error){
71 		TRACEIT(2,"ProcessItemsViaListWrap: error in g_thread_create:");
72 		TRACEIT(2,Error->message);
73 		g_error_free(Error);
74 		Error=NULL;
75 	}
76 	TRACEIT(10,"ProcessItemsViaListWrap		ends");
77 	return 0;
78 }
79 
80 
FreeMemoryAndDeleteWidgetFunction(struct ListWidgetCommunicationStruct * commStru)81 gboolean FreeMemoryAndDeleteWidgetFunction (struct ListWidgetCommunicationStruct *commStru){
82     //ATTENTION!!
83     //do not access commStru after this call, it is free after this.
84     //printf("FREE MEMORY\n");
85     //free all memory in the list
86     TRACEIT(10,"FreeMemoryAndDeleteWidgetFunction		start");
87     if (commStru->cancellable)
88         g_object_unref(commStru->cancellable);
89     if (commStru->gerror)
90         g_error_free (commStru->gerror);
91     g_object_unref(commStru->listStore);
92 
93     CopyReMoveList_DeleteList (commStru->firstItem);
94 
95     g_string_free(commStru->WindowName, TRUE);
96 
97     //detroy the widget
98     gtk_widget_destroy(commStru->mainListWidget);
99 
100     g_mutex_lock (commStru->mtxContinue);
101     g_mutex_unlock (commStru->mtxContinue);
102     g_mutex_free (commStru->mtxContinue);
103 
104     free(commStru);
105     TRACEIT(10,"FreeMemoryAndDeleteWidgetFunction		ends");
106     return TRUE;
107 }
108 
109 
ListWidget_CancelList(struct ListWidgetCommunicationStruct * commStru)110 void ListWidget_CancelList(struct ListWidgetCommunicationStruct *commStru){
111     TRACEIT(10,"ListWidget_CancelList		start");
112     //struct CopyReMoveList *list = (struct CopyReMoveList *)commStru->firstItem;
113     struct CopyReMoveList *buflist = (struct CopyReMoveList *)commStru->firstItem;
114     while (buflist != NULL){
115         if (buflist->status == -1){
116             buflist->status = -10;
117         }
118         buflist->ibreak=1;
119         buflist = buflist->NextItem;
120     };
121     #ifndef NO_GIO
122     if (commStru->cancellable)
123         g_cancellable_cancel (commStru->cancellable);
124     #endif
125     commStru->iCancelled=1;
126 
127     gtk_widget_show(GTK_WIDGET(commStru->closeButton));
128     gtk_widget_hide(GTK_WIDGET(commStru->cancelButton));
129     gtk_widget_hide(GTK_WIDGET(commStru->continueButton));
130     gtk_widget_hide(GTK_WIDGET(commStru->pauseButton));
131     TRACEIT(10,"ListWidget_CancelList		end");
132 }
133 
134 
ListWidget_CancelButton(GtkButton * button,gpointer data)135 void ListWidget_CancelButton(GtkButton *button, gpointer data){
136     //simply asks the user for canceling
137     //and if the answer is ok, sets status of buflist to -10 (cancelled)
138     //and cancels  the commstru->cancellable object
139 	TRACEIT(10,"ListWidget_CancelButton		start");
140 	GtkWidget *dialog, *label;
141 	struct ListWidgetCommunicationStruct *commStru = (struct ListWidgetCommunicationStruct *)data;
142 
143 	if (commStru->iCancelled == 1){
144 	    TRACEIT(4,"ListWidget_CancelButton		ends, allready cancelled");
145         return;
146 	}
147     commStru->iCancelDialogRuns=1;
148     dialog = CreateMyDialog("Do you want to cancel Process?", (GtkWindow *)commStru->mainListWidget, 2, "Ok",GTK_RESPONSE_ACCEPT,"Cancel",GTK_RESPONSE_REJECT, NULL, 0, TRUE);
149     label = gtk_label_new("This cancels the processes in this list\nDo you want to continue?\n");
150     gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox),label);
151     gtk_widget_show_all(dialog);
152     if (gtk_dialog_run(GTK_DIALOG(dialog))== GTK_RESPONSE_ACCEPT){
153         ListWidget_CancelList(commStru);
154     }
155     gtk_widget_destroy(dialog);
156     commStru->iCancelDialogRuns=0;
157 
158     //check if the thread 2 allready exists and we can close all
159     if (commStru->iDestroyFlag == 1 && commStru->SecondThreadRunning == 0){
160         FreeMemoryAndDeleteWidgetFunction(commStru);
161     }
162 
163 	TRACEIT(10,"ListWidget_CancelButton		ends");
164 }
165 
166 
ListWidget_DeleteEvent(GtkWidget * widget,GdkEvent * event,struct ListWidgetCommunicationStruct * commStru)167 gboolean ListWidget_DeleteEvent (GtkWidget *widget, GdkEvent  *event, struct ListWidgetCommunicationStruct *commStru){
168     TRACEIT(10,"ListWidget_DeleteEvent		start");
169     //this is used to catch the signal emited when the user presses the X in the upper right corner
170     //printf("ListWidget_DeleteEvent DELETE EVENT\n");
171     if (commStru == NULL){
172         TRACEIT(2,"ListWidget_DeleteEvent		end, Parameter NULL");
173         return FALSE;
174     }
175     //thread 2 may still run -> we have to ask for canceling
176    //we may have allready cancelled -> we have to close
177 
178     if (commStru->iCancelled == 1){
179         if (commStru->SecondThreadRunning == 1){
180             //myWrap_gdk_threads_enter("ListWidget_DeleteEvent 1");
181             MyMessageWidget((GtkWindow *)commStru->mainListWidget, "Error", "List item is still active, please close the aplication\nwhich is connect to the item first.");
182             //myWrap_gdk_threads_leave("ListWidget_DeleteEvent 1");
183         }
184         else
185             FreeMemoryAndDeleteWidgetFunction(commStru);
186         return TRUE;
187     }
188     if (commStru->SecondThreadRunning == 1 && commStru->iCancelled == 0){
189         ListWidget_CancelButton(NULL, (void *)commStru);
190         if (commStru->iCancelled == 1){
191             commStru->iDestroyFlag = 1;
192         }
193         return TRUE;
194     }
195     if (commStru->iDestroyFlag == 1){
196         FreeMemoryAndDeleteWidgetFunction(commStru);
197         return TRUE;
198     }
199 
200     TRACEIT(10,"ListWidget_DeleteEvent		end");
201     return TRUE;
202 //    return gRet;   //when this is TRUE, the widget will stay even when the user tries to close it. And because of our notification we d not close it either
203                     //FALSE will destroy the widget
204 }
205 
206 
ListWidget_CloseButton(GtkButton * button,struct ListWidgetCommunicationStruct * commStru)207 void ListWidget_CloseButton(GtkButton *button, struct ListWidgetCommunicationStruct *commStru){
208     TRACEIT(10,"ListWidget_CloseButton		start");
209     if (commStru == NULL){
210         TRACEIT(2,"ListWidget_CloseButton		ends, Parameter NULL");
211         return;
212     }
213     //if the close_button is visible, the thread 2 has allready finished there cant be even an cancel dialog when pressing this
214     if (commStru->SecondThreadRunning == 1){
215         //myWrap_gdk_threads_enter("ListWidget_CloseButton");
216         MyMessageWidget((GtkWindow *)commStru->mainListWidget, "Error", "List item is still active, please close the aplication\nwhich is connect to the item first.");
217         //myWrap_gdk_threads_leave("ListWidget_CloseButton");
218     }
219     else
220         FreeMemoryAndDeleteWidgetFunction(commStru);
221 
222     TRACEIT(10,"ListWidget_CloseButton		ends");
223     return;
224 }
225 
226 
ListWidget_pauseButton(GtkButton * button,struct ListWidgetCommunicationStruct * commStru)227 void ListWidget_pauseButton(GtkButton *button, struct ListWidgetCommunicationStruct *commStru){
228     TRACEIT(10,"ListWidget_pauseButton		start");
229     if (commStru == NULL){
230         TRACEIT(2,"ListWidget_pauseButton		ends, Parameter NULL");
231         return;
232     }
233 
234     commStru->iListPaused += 1;
235     commStru->iterLastProcessedItem = &(commStru->currentItem->iter);
236 
237     gtk_widget_hide(GTK_WIDGET(commStru->pauseButton));
238     gtk_widget_show(GTK_WIDGET(commStru->continueButton));
239 
240 
241 //printf("pauseButton change selection\n");
242 
243     GtkTreeSelection	*selection;
244   	selection  = gtk_tree_view_get_selection((GtkTreeView *)commStru->listView);
245 	gtk_tree_selection_set_mode(selection, GTK_SELECTION_MULTIPLE);
246 
247 
248 
249     TRACEIT(10,"ListWidget_pauseButton		ends");
250     return;
251 }
252 
253 
ListWidget_continueButton(GtkButton * button,struct ListWidgetCommunicationStruct * commStru)254 void ListWidget_continueButton(GtkButton *button, struct ListWidgetCommunicationStruct *commStru){
255     TRACEIT(10,"ListWidget_continueButton		start");
256     if (commStru == NULL){
257         TRACEIT(2,"ListWidget_continueButton		ends, Parameter NULL");
258         return;
259     }
260 
261     commStru->iListPaused -= 1;
262     if (commStru->iListPaused <= 0){
263         commStru->iListPaused = 0;
264     }
265     else{
266         TRACEIT(10,"ListWidget_continueButton		end");
267         return;
268     }
269 
270     GtkTreeSelection	*selection;
271   	selection  = gtk_tree_view_get_selection((GtkTreeView *)commStru->listView);
272 	gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE);
273 
274 	gtk_tree_selection_select_iter(selection, commStru->iterLastProcessedItem);
275 
276     gtk_widget_hide(GTK_WIDGET(commStru->continueButton));
277     gtk_widget_show(GTK_WIDGET(commStru->pauseButton));
278 
279     g_mutex_lock (commStru->mtxContinue);
280     //if we had to wait for the mutex, we know, that the next thread has not been started
281 
282     commStru->iListPaused = 0;
283 
284     if (0 == commStru->iNextThreadStarted){
285         //Start next thread
286         commStru->iNextThreadStarted = 1;
287 
288         commStru->currentItem = commStru->currentItem->NextItem;
289 
290         if (commStru->ThreadStartStruct == NULL){
291             //if this is NULL, we assume that we are in CopyReMoveMode
292             if (NULL != commStru->currentItem){
293                 commStru->gthrdCopyReMoveThread_2 = g_thread_create((GThreadFunc)CopyReMoveItemsViaList, (void *)commStru , TRUE, NULL);
294             }
295             else {
296                 g_thread_create((GThreadFunc)CopyReMoveItemsViaList, (void *)commStru , FALSE, NULL);
297             }
298         }
299         else{
300             //if it is not NULL, we are in UserCommandListMode
301             if (NULL != commStru->currentItem){
302                 commStru->gthrdCopyReMoveThread_2 = g_thread_create((GThreadFunc)CallUserCommand_ProcessItemThread, (void *)commStru , TRUE, NULL);
303             }
304             else {
305                 g_thread_create((GThreadFunc)CallUserCommand_ProcessItemThread, (void *)commStru , FALSE, NULL);
306             }
307         }
308 
309     }
310 
311 
312     g_mutex_unlock (commStru->mtxContinue);
313 
314     TRACEIT(10,"ListWidget_continueButton		ends");
315     return;
316 }
317 
318 
copyReMoveWidget_updateItemCounterColumn(struct CopyReMoveList * theList)319 void copyReMoveWidget_updateItemCounterColumn(struct CopyReMoveList *theList){
320     TRACEIT(10,"copyReMoveWidget_updateItemCounterColumn		start");
321     if (NULL == theList){
322         TRACEIT(2,"copyReMoveWidget_updateItemCounterColumn		PARAMETER NULL");
323         return;
324     }
325 
326     struct CopyReMoveList *listbuf = NULL;
327     int intItemsCount = 0;
328     int i;
329     GString *gstrBuf = g_string_sized_new (10);
330 
331     for (; theList->PrevItem; theList=theList->PrevItem);
332 
333     listbuf = theList;
334     while(listbuf!= NULL){
335 		intItemsCount++;
336 		listbuf = listbuf->NextItem;
337 	}
338 	listbuf = theList;
339 	i=1;
340 	while(listbuf!= NULL){
341         g_string_printf (gstrBuf, "%d/%d", i++, intItemsCount);
342 		gtk_list_store_set (listbuf->listStore, &(listbuf->iter), 0, gstrBuf->str,-1);
343 		listbuf = listbuf->NextItem;
344 	}
345 
346 
347     g_string_free (gstrBuf, TRUE);
348     TRACEIT(10,"copyReMoveWidget_updateItemCounterColumn		ends");
349     return;
350 }
351 
352 
ProcessItemsViaList(void * data)353 void ProcessItemsViaList(void *data){
354 	TRACEIT(10,"ProcessItemsViaList		start");
355 	if (data == NULL){
356 		TRACEIT(2,"ProcessItemsViaList		ends, parameter NULL");
357 		g_thread_exit(0);
358 	}
359 	GtkWidget *Window, *scrollWindow, *listView;
360 	GtkListStore *listStore;
361 	GtkTreeIter iter;
362 	GtkTreeViewColumn   	*col_Items, *col_ItemNumbers, *col_Errors, *col_percentage;
363 	GtkCellRenderer     	*renderer, *renderer2;
364 	GtkButton *CancelButton;
365 	GtkButton *CloseButton;
366 	GtkButton *continueButton;
367 	GtkButton *pauseButton;
368 	GtkWidget *TheLabel;
369 	GtkWidget *progressBar;
370 	GtkVBox *VBox;
371 	GtkWidget *ButtonBox;
372 	char charLabelText[301];
373 	GError *Error=NULL;
374 	GString *WindowName = g_string_new(MYNAMESHORT); //freed when the commStru is freed
375 	struct CopyReMoveList *list = (struct CopyReMoveList *)data;
376 	struct CopyReMoveList *listbuf = list;
377 	int i=0;
378 	int intItemsCount=0;
379     struct ListWidgetCommunicationStruct *commStru = malloc(sizeof(struct ListWidgetCommunicationStruct));
380 	myWrap_gdk_threads_enter("ProcessItemsViaList");
381 
382 	Window = CreateMyWindow(WindowName->str, NULL, 400,350,TRUE, FALSE, TRUE, NULL, FALSE, FALSE);
383 	if (Window == NULL){
384         g_string_free(WindowName, TRUE);
385         free(commStru);
386         TRACEIT(1,"ProcessItemsViaList		end, window could not be created");
387         return;
388 	}
389     g_signal_connect (Window,"delete-event",G_CALLBACK(ListWidget_DeleteEvent),commStru);
390     //g_signal_connect (Window, "destroy", G_CALLBACK(ListWidget_End_FreeMemory),commStru);
391 
392 	AddMyIconsToWindow((GtkWindow *)Window);
393 
394   	char buf[320];
395 
396 	scrollWindow = gtk_scrolled_window_new (NULL,NULL);
397 	listView = gtk_tree_view_new ();
398 	listStore = gtk_list_store_new( 4 , G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING  );
399     progressBar = gtk_progress_bar_new();
400 
401     col_Items=gtk_tree_view_column_new();
402 	col_ItemNumbers=gtk_tree_view_column_new();
403 	col_Errors=gtk_tree_view_column_new();
404 	col_percentage=gtk_tree_view_column_new();
405 	gtk_tree_view_column_set_resizable(col_Items,TRUE);
406 	gtk_tree_view_column_set_resizable(col_ItemNumbers,TRUE);
407 	gtk_tree_view_column_set_resizable(col_Errors,TRUE);
408 	gtk_tree_view_column_set_resizable(col_percentage,TRUE);
409 
410 	gtk_tree_view_column_set_title(col_ItemNumbers, "#");
411 	gtk_tree_view_append_column(GTK_TREE_VIEW(listView),col_ItemNumbers);
412 	renderer2 = gtk_cell_renderer_text_new();
413 	gtk_tree_view_column_pack_start(col_ItemNumbers, renderer2, TRUE);
414 	gtk_tree_view_column_add_attribute(col_ItemNumbers,renderer2,"text",0);
415 
416     gtk_tree_view_column_set_title(col_percentage, "%");
417 	gtk_tree_view_append_column(GTK_TREE_VIEW(listView),col_percentage);
418 	renderer = gtk_cell_renderer_text_new();
419 	gtk_tree_view_column_pack_start(col_percentage, renderer, TRUE);
420 	gtk_tree_view_column_add_attribute(col_percentage,renderer,"text",1);
421 
422 	gtk_tree_view_column_set_title(col_Items, "items to process");
423 	gtk_tree_view_append_column(GTK_TREE_VIEW(listView),col_Items);
424 	renderer = gtk_cell_renderer_text_new();
425 	gtk_tree_view_column_pack_start(col_Items, renderer, TRUE);
426 	gtk_tree_view_column_add_attribute(col_Items,renderer,"text",2);
427 
428 	gtk_tree_view_column_set_title(col_Errors, "errors");
429 	gtk_tree_view_append_column(GTK_TREE_VIEW(listView),col_Errors);
430 	renderer = gtk_cell_renderer_text_new();
431 	gtk_tree_view_column_pack_start(col_Errors, renderer, TRUE);
432 	gtk_tree_view_column_add_attribute(col_Errors,renderer,"text",3);
433 
434 	//g_signal_connect (listView,"button-press-event",G_CALLBACK(oneMouseButtonPressedInLittleWindow),NULL);
435 	//g_signal_connect (listView,"button-press-event",G_CALLBACK(oneMouseButtonPressed),NULL);
436 	//g_signal_connect (listView,"button-release-event",G_CALLBACK(oneMouseButtonPressed),NULL);
437 
438 	do{
439 		intItemsCount++;
440 		listbuf = listbuf->NextItem;
441 	}while(listbuf!= NULL);
442 	listbuf = list;
443 	i=1;
444 	do{
445 		snprintf(buf,319,"%d/%d",i,intItemsCount);
446 		gtk_list_store_append(listStore,&iter);
447 		gtk_list_store_set (listStore, &iter, 0, buf, 2, listbuf->string1->str,-1);
448 
449 
450         CopyReMoveList_initializeMemberTo (listbuf, listStore, iter, &(commStru->ui64TotalBytesProcessed), &(commStru->i64StartTotalBytesCopied), &(commStru->timeStartTimeForBytesCopied), &(commStru->timeStartTimeForBytesCopiedSingleItem), &(commStru->ui64TotalBytes), &(commStru->iTotalBytesValid), (GtkProgressBar *)progressBar, list->CopyMoveOrRemove, &(commStru->dCopySpeed) );
451         /*
452         listbuf->listStore=listStore;
453 		listbuf->iter = iter;
454 		listbuf->status = -1;
455 		listbuf->ibreak=0;
456 		listbuf->lastfinishedTotalBytes=0;
457 		listbuf->threadCalcSize=NULL;
458 		listbuf->ui64pTotalBytesCopied = &(commStru->ui64TotalBytesProcessed);
459 		listbuf->ui64TotalBytes = &(commStru->ui64TotalBytes);
460 		listbuf->iTotalBytesValid = &(commStru->iTotalBytesValid);
461 		listbuf->progressBar = (GtkProgressBar *)progressBar;
462 		listbuf->CopyMoveOrRemove = list->CopyMoveOrRemove;
463         */
464 		listbuf = listbuf->NextItem;
465 		i++;
466 	}while(listbuf!= NULL);
467 
468     CancelButton = (GtkButton *)gtk_button_new_with_label("cancel all");
469 	g_signal_connect (CancelButton,"clicked",G_CALLBACK(ListWidget_CancelButton),(void *)commStru);
470 
471 	CloseButton = (GtkButton *)gtk_button_new_with_label("close");
472 	g_signal_connect (CloseButton,"clicked",G_CALLBACK(ListWidget_CloseButton),commStru);
473 
474     continueButton = (GtkButton *)gtk_button_new_with_label("continue");
475     g_signal_connect (continueButton, "clicked", G_CALLBACK(ListWidget_continueButton), commStru);
476 
477     pauseButton = (GtkButton *)gtk_button_new_with_label("pause");
478     g_signal_connect (pauseButton, "clicked", G_CALLBACK(ListWidget_pauseButton), commStru);
479 
480 	gtk_tree_view_set_model (GTK_TREE_VIEW(listView), GTK_TREE_MODEL(listStore));
481 
482     //TheLabel = gtk_label_new(charLabelText);
483 	if (list->CopyMoveOrRemove == 1){ //COPY
484 		g_string_append(WindowName," copy");
485 		snprintf(charLabelText, 300, "Copying listed items to\n%s",list->DestObject->gstrPath->str );
486 	}
487 	else if(list->CopyMoveOrRemove == 2){ //MOVE
488 		g_string_append(WindowName," move");
489 		snprintf(charLabelText, 300, "Moving listed items to\n%s",list->DestObject->gstrPath->str );
490 	}
491 	else{	//REMOVE
492 		g_string_append(WindowName," remove");
493 		snprintf(charLabelText, 300, "Deleting listed items");
494 	}
495 
496 	TheLabel = gtk_label_new(charLabelText);
497 
498 	gtk_container_add((GtkContainer *)scrollWindow, listView);
499 	VBox = g_object_new(GTK_TYPE_VBOX, "spacing", 5, "homogeneous", FALSE, NULL);
500 	gtk_box_pack_start(GTK_BOX(VBox),TheLabel,FALSE,FALSE,1);
501 	gtk_box_pack_start(GTK_BOX(VBox),GTK_WIDGET(scrollWindow),TRUE,TRUE,1);
502 	#ifndef NO_GIO
503 	if (list->CopyMoveOrRemove != 3){   //do not show progressbar when deleting
504         gtk_box_pack_start(GTK_BOX(VBox),GTK_WIDGET(progressBar),FALSE,FALSE,1);
505 	}
506     #endif
507 
508     ButtonBox = gtk_hbox_new ( TRUE, 3);
509 
510     gtk_box_pack_start(GTK_BOX(ButtonBox),GTK_WIDGET(pauseButton),TRUE,TRUE,1);
511     gtk_box_pack_start(GTK_BOX(ButtonBox),GTK_WIDGET(continueButton),TRUE,TRUE,1);
512 	gtk_box_pack_start(GTK_BOX(ButtonBox),GTK_WIDGET(CancelButton),TRUE,TRUE,1);
513     gtk_box_pack_start(GTK_BOX(ButtonBox),GTK_WIDGET(CloseButton),TRUE,TRUE,1);
514 
515     gtk_box_pack_start(GTK_BOX(VBox),GTK_WIDGET(ButtonBox),FALSE,FALSE,1);
516 
517 
518 
519     gtk_container_add((GtkContainer *)Window,(GtkWidget *)VBox);
520 
521     commStru->mainListWidget=Window;
522     commStru->listView=listView;
523     commStru->cancelButton=CancelButton;
524     commStru->closeButton=CloseButton;
525     commStru->continueButton=continueButton;
526     commStru->pauseButton=pauseButton;
527     commStru->firstItem=list;
528     commStru->currentItem=list;
529     commStru->listStore=listStore;
530     #ifndef NO_GIO
531     commStru->cancellable=g_cancellable_new();
532     #else
533     commStru->cancellable=NULL;
534     #endif
535     commStru->gerror=NULL;
536     commStru->SecondThreadRunning=0;
537     commStru->TheLabel=TheLabel;
538     commStru->WindowName=WindowName;
539     commStru->iSomeError=0;
540     commStru->iCancelled=0;  //becomes 1 if the process is cancelled
541     commStru->iListPaused=0;
542     commStru->iListPausedAutomatic=0;
543     commStru->FreeMemoryAndDeleteWidgetFunction = FreeMemoryAndDeleteWidgetFunction;
544     commStru->CancelListFunction = ListWidget_CancelList;
545     commStru->iCancelDialogRuns=0;
546     commStru->iDestroyFlag =0;
547     commStru->bOverWriteAllExisting=-1;
548     commStru->ui64TotalBytes=0;
549     commStru->ui64TotalBytesProcessed=0;
550     commStru->i64StartTotalBytesCopied=-1.0;
551     commStru->dCopySpeed=0.0;
552     //commStru->timeStartTimeForBytesCopied=0;
553     commStru->iTotalBytesValid=0;
554     commStru->progressBar=(GtkProgressBar *)progressBar;
555     commStru->gthrdCopyReMoveThread_1 = NULL;
556     commStru->gthrdCopyReMoveThread_2 = NULL;
557     commStru->mtxContinue = g_mutex_new ();
558     commStru->iNextThreadStarted = 1;
559     commStru->ThreadStartStruct = NULL;
560 
561 	gtk_widget_show_all(Window);
562 	gtk_widget_hide(GTK_WIDGET(CloseButton));
563 	gtk_widget_hide(GTK_WIDGET(continueButton));
564 
565 	prepareWidgetForDrop ((GtkWidget *)commStru->listView, 1, DNDSignal_dragdatereceive_forCopyReMoveWidget, commStru);
566 	g_signal_connect ((GtkWidget *)commStru->listView,"drag-motion",G_CALLBACK(CopyReSizeWidget_dragmotion_signal),commStru);
567 	g_signal_connect ((GtkWidget *)commStru->listView,"drag-leave",G_CALLBACK(CopyReSizeWidget_dragleave_signal),commStru);
568     g_signal_connect ((GtkWidget *)commStru->listView,"key-press-event",G_CALLBACK(CopyReSizeWidget_oneKeyPressedInView),commStru);
569     g_signal_connect ((GtkWidget *)commStru->listView,"button-press-event",G_CALLBACK(ListWidget_MousePressEventCatcher),commStru);
570 
571 	myWrap_gdk_threads_leave("ProcessItemsViaList");
572 
573     if (list->CopyMoveOrRemove != 3){    //do not calculate this when deleting
574         g_thread_create((GThreadFunc)CopyReMoveItemsViaList_SizeCalc, (void *)commStru , FALSE, NULL);
575     }
576 	//g_thread_create((GThreadFunc)CopyReMoveItemsViaList, (void *)commStru , FALSE, &Error); //why using here error at all when we do not check it
577 	commStru->gthrdCopyReMoveThread_1 = g_thread_create((GThreadFunc)CopyReMoveItemsViaList, (void *)commStru , TRUE, &Error); //why using here error at all when we do not check it
578 
579     if (Error){
580         g_error_free(Error);
581     }
582 
583 	TRACEIT(10,"ProcessItemsViaList		ends");
584 	g_thread_exit(0);
585 }
586 
587 
588 
CopyReSizeWidget_oneKeyPressedInView(GtkWidget * widget,GdkEventKey * event,struct ListWidgetCommunicationStruct * CommStru)589 gboolean CopyReSizeWidget_oneKeyPressedInView(GtkWidget *widget, GdkEventKey *event, struct ListWidgetCommunicationStruct *CommStru){
590     //Be aware of using widget, as this function is called when a key is pressed on a notebook (tab) too
591     //data = struct SideObjectList
592 	TRACEIT(10,"CopyReSizeWidget_oneKeyPressedInView		start");
593 	guint modifiers;
594 
595 	modifiers = gtk_accelerator_get_default_mod_mask ();
596 
597 	if ( (event->keyval == GDK_Delete || event->keyval == GDK_BackSpace)){
598         //delete selected items
599         if (CommStru->iListPaused != 0){
600             CopyReSizeWidget_deleteSelectedItems (CommStru);
601             copyReMoveWidget_updateItemCounterColumn(CommStru->firstItem);
602 
603             if (CommStru->ThreadStartStruct == NULL){
604                 if (CommStru->iTotalBytesValid==1){
605                     if (CommStru->firstItem->CopyMoveOrRemove != 3){    //do not calculate this when deleting
606                         g_thread_create((GThreadFunc)CopyReMoveItemsViaList_SizeCalc, (void *)CommStru , FALSE, NULL);
607                     }
608                 }
609             }
610             return TRUE;
611         }
612 	}
613 
614 
615 
616     TRACEIT(10,"CopyReSizeWidget_oneKeyPressedInView		end");
617     return FALSE;
618 }
619 
620 
CopyReSizeWidget_deleteSelectedItems(struct ListWidgetCommunicationStruct * CommStru)621 void CopyReSizeWidget_deleteSelectedItems (struct ListWidgetCommunicationStruct *CommStru){
622     TRACEIT(10,"CopyReSizeWidget_deleteSelectedItems		start");
623     //we will delete the marked items, which are not processed yet
624     GtkTreeSelection *selection;
625     struct CopyReMoveList *buflist = NULL;
626     struct CopyReMoveList *buflist2 = NULL;
627 
628     selection  = gtk_tree_view_get_selection((GtkTreeView *)CommStru->listView);
629     GList *glistBuf1 = NULL;
630     GList *glistBuf2 = NULL;
631     GList *glistBuf = NULL;
632     int i;
633     int a,b;
634 
635     buflist = CommStru->firstItem;
636 
637     i=0;
638     while (buflist){
639         if (TRUE == gtk_tree_selection_iter_is_selected (selection, &(buflist->iter))){
640             if (buflist->status != -1){ //-1=Not processed yet
641                 //gtk_tree_selection_unselect_iter (selection, &(buflist->iter));
642             }
643             else{
644                 gtk_list_store_remove(CommStru->listStore, &(buflist->iter));
645 
646                 if (CommStru->ThreadStartStruct != NULL){
647                     glistBuf1 = g_list_prepend ( glistBuf1, g_list_nth (CommStru->ThreadStartStruct->glistItemsWithPath, i));
648                     glistBuf2 = g_list_prepend ( glistBuf2, g_list_nth (CommStru->ThreadStartStruct->glistItemsWithoutPath, i));
649                     //then we are in UserCommandViaList mode
650                     //and we have to delete the selected items in the glists of ThreadStartStruct and the sizeOfTheList member variables
651                    //CommStru->ThreadStartStruct->uiSizeOfLists = g_list_length (CommStru->ThreadStartStruct->glistItemsWithP
652 
653                 }
654                 buflist2 = buflist;
655                 buflist = buflist->NextItem;
656                 CommStru->firstItem = CopyReMoveList_removeItemFromList (buflist2);
657                 continue;
658             }
659         }
660         i++;
661         buflist = buflist->NextItem;
662     }
663 
664     if (CommStru->ThreadStartStruct != NULL){
665         glistBuf = glistBuf1;
666         while (glistBuf){
667             if ( ((GList *)glistBuf->data)->data != NULL){
668                 g_string_free ( (GString *)(((GList *)glistBuf->data)->data), TRUE);
669                 ((GList *)glistBuf->data)->data = NULL;
670             }
671             glistBuf = glistBuf->next;
672         }
673         glistBuf = glistBuf2;
674         while (glistBuf){
675             if ( ((GList *)glistBuf->data)->data != NULL){
676                 g_string_free ( (GString *)(((GList *)glistBuf->data)->data), TRUE);
677                 ((GList *)glistBuf->data)->data = NULL;
678             }
679             glistBuf = glistBuf->next;
680         }
681 
682 
683         glistBuf = CommStru->ThreadStartStruct->glistItemsWithPath;
684         while (glistBuf){
685             if (glistBuf->data == NULL){
686                 CommStru->ThreadStartStruct->glistItemsWithPath =  g_list_delete_link ( CommStru->ThreadStartStruct->glistItemsWithPath, glistBuf);
687                 glistBuf = CommStru->ThreadStartStruct->glistItemsWithPath;
688                 continue;
689             }
690             glistBuf = glistBuf->next;
691         }
692         glistBuf = CommStru->ThreadStartStruct->glistItemsWithoutPath;
693         while (glistBuf){
694             if (glistBuf->data == NULL){
695                 CommStru->ThreadStartStruct->glistItemsWithoutPath =  g_list_delete_link ( CommStru->ThreadStartStruct->glistItemsWithoutPath, glistBuf);
696                 glistBuf = CommStru->ThreadStartStruct->glistItemsWithoutPath;
697                 continue;
698             }
699             glistBuf = glistBuf->next;
700         }
701 
702         a = g_list_length (CommStru->ThreadStartStruct->glistItemsWithoutPath);
703         b = g_list_length (CommStru->ThreadStartStruct->glistItemsWithPath);
704         if (a != b ){
705             TRACEIT(10,"CopyReSizeWidget_deleteSelectedItems		Internal Error, list sizes unequal");
706         }
707         a = (a<=b)?a:b;
708         CommStru->ThreadStartStruct->uiSizeOfLists = a;
709     }
710 
711 
712 
713     g_list_free (glistBuf1);
714     g_list_free (glistBuf2);
715     TRACEIT(10,"CopyReSizeWidget_deleteSelectedItems		end");
716     return;
717 }
718 
719 
720 //The "drag-motion" signal
CopyReSizeWidget_dragmotion_signal(GtkWidget * widget,GdkDragContext * drag_context,gint x,gint y,guint time,struct ListWidgetCommunicationStruct * CommStru)721 gboolean CopyReSizeWidget_dragmotion_signal (GtkWidget *widget, GdkDragContext *drag_context, gint x, gint y, guint time, struct ListWidgetCommunicationStruct *CommStru){
722     TRACEIT(10,"CopyReSizeWidget_dragmotion_signal		start");
723 
724     if (CommStru->iListPausedAutomatic == 0){
725         CommStru->iListPausedAutomatic=1;
726         gtk_button_clicked (CommStru->pauseButton );
727     }
728 
729 
730 
731     TRACEIT(10,"CopyReSizeWidget_dragmotion_signal		ends");
732     return TRUE;
733 }
734 
735 
736 //The "drag-leave" signal
CopyReSizeWidget_dragleave_signal(GtkWidget * widget,GdkDragContext * drag_context,guint time,struct ListWidgetCommunicationStruct * CommStru)737 void CopyReSizeWidget_dragleave_signal (GtkWidget *widget, GdkDragContext *drag_context, guint time, struct ListWidgetCommunicationStruct *CommStru){
738     TRACEIT(10,"CopyReSizeWidget_dragleave_signal		start");
739 
740     CommStru->iListPausedAutomatic=0;
741     gtk_button_clicked (CommStru->continueButton );
742 
743     TRACEIT(10,"CopyReSizeWidget_dragleave_signal		ends");
744 }
745 
746 
747 /*
748 gboolean oneMouseButtonPressedInLittleWindow(GtkWidget *treeview, GdkEventButton *event, gpointer data){
749 	TRACEIT(10,"oneMouseButtonPressedInLittleWindow		start - ends");
750 	return TRUE;
751 	//return FALSE;
752 }
753 */
754 
calcDirectorySizeInView_closeProcess(int * iRecursiveSizeCalculation,GThread ** threadToJoin,gboolean * bpUpdateFlag_F6,int * ipPreventFromUpdating,gboolean bAbortThread)755 void calcDirectorySizeInView_closeProcess (int *iRecursiveSizeCalculation, GThread **threadToJoin, gboolean *bpUpdateFlag_F6, int *ipPreventFromUpdating, gboolean bAbortThread){
756     //be sure to call this function every time the user could have started the F6-update
757     //in case of bAbortthread is FALSE, we will wait for the threat to finish, if it is TRUE, we will
758     //set iRecursiveSizeCalculation to -1 and will wait for the thread.
759     TRACEIT(10,"calcDirectorySizeInView_closeProcess		start");
760 
761     int iThreadIsRunnnig=0;
762 
763     if (iRecursiveSizeCalculation != NULL){
764         if (*iRecursiveSizeCalculation == 0)
765             iThreadIsRunnnig = 1;
766         if (bAbortThread==TRUE){
767             *iRecursiveSizeCalculation = -1;    //set abort flag
768         }
769     }
770 
771     if (threadToJoin != NULL && *threadToJoin != NULL){
772         //printf("Trying to join thread: %p\n", *threadToJoin);
773         //if (iThreadIsRunnnig == 1)  //we are signal driven, arent we, all signals are threadsave, but the F6 Thread needs to enter and leave this too, so we will have to leave the signal thread mutex here before joining the F6 thread
774         //    myWrap_gdk_threads_leave ("calcDirectorySizeInView_closeProcess");
775         //while (iRecursiveSizeCalculation == 0){
776         //    usleep (100000);
777         //}
778         //printf("Thread joined : %p\n",*threadToJoin );
779         g_thread_join ( *threadToJoin );  //wait for thread
780         //if (iThreadIsRunnnig == 1)
781         //    myWrap_gdk_threads_enter ("calcDirectorySizeInView_closeProcess");
782         //printf ("Joining ended\n");
783         *threadToJoin = NULL;
784     }
785 
786     if (bpUpdateFlag_F6 != NULL){
787         *bpUpdateFlag_F6 = FALSE;
788     }
789 
790     if (ipPreventFromUpdating != NULL && ipPreventFromUpdating > 0){
791         manipulateCounter (ipPreventFromUpdating, FALSE, "calcDirectorySizeInView_closeProcess");
792     }
793 
794     TRACEIT(10,"calcDirectorySizeInView_closeProcess		end");
795 }
796 
797 
calcDirectorySizeInView_wrap(struct AllInformationAllUseStruct * stru)798 void calcDirectorySizeInView_wrap(struct AllInformationAllUseStruct *stru){
799     TRACEIT(10,"calcDirectorySizeInView_wrap		start");
800     GError *Error=NULL;
801     if(!g_thread_supported() ){
802 		g_thread_init(NULL);
803      		//gdk_threads_init();                   // Called to initialize internal mutex "gdk_threads_mutex".
804    	}
805    	//stru->source=SOURCE_FILESHELF;
806     //stru->Info_1 = data;
807     //stru->Info_2 = &(Object->gthreadF6Updage);
808     //stru->Info_3 = &(Object->iRecursiveSizeCalculation);
809     //stru->Info_4 = &(Object->bUpdateFlag_F6);
810 
811     if (stru == NULL ){
812         TRACEIT(2,"calcDirectorySizeInView_wrap:       parameter NULL");
813         return;
814     }
815 
816     if (stru->Info_2==NULL){
817         free(stru);
818         TRACEIT(2,"calcDirectorySizeInView_wrap:       parameter 2 NULL");
819         return;
820     }
821     int *iRecursiveSizeCalculation = (int *)(stru->Info_3);
822     GThread *gthreadF6 = *(GThread **)(stru->Info_2);
823 
824     if (*iRecursiveSizeCalculation == 0) {   //-1 = canceled, finished, 0=running
825         TRACEIT(10,"calcDirectorySizeInView_wrap		end");
826         free(stru);
827         return;
828     }
829 
830     if (gthreadF6 != NULL){
831         //printf("Thread joined : %p\n",gthreadF6 );
832         g_thread_join (gthreadF6);
833         *((GThread **)(stru->Info_2)) = NULL;
834     }
835     *iRecursiveSizeCalculation = 0;
836 
837     if (stru->Info_4 != NULL){
838         *((gboolean *)stru->Info_4) = TRUE;
839     }
840 
841     *((GThread **)(stru->Info_2)) = g_thread_create((GThreadFunc)calcDirectorySizeInView_thread, (void *)stru , TRUE, &Error);
842     //printf("Thread created: %p\n", *((GThread **)(stru->Info_2)) );
843     //g_thread_create((GThreadFunc)calcDirectorySizeInView_thread, (void *)stru , FALSE, &Error);
844     if (Error){
845 		TRACEIT(2,"calcDirectorySizeInView_wrap: error in g_thread_create:");
846 		TRACEIT(2,Error->message);
847 		g_error_free(Error);
848 		Error=NULL;
849 		free(stru);
850 		*iRecursiveSizeCalculation = -1;
851 		if (stru->Info_4 != NULL){
852             *((gboolean *)stru->Info_4) = FALSE;
853         }
854 	}
855     TRACEIT(10,"calcDirectorySizeInView_wrap		end");
856 }
857 
858 
calcDirectorySizeInView_thread_helper(GtkTreeModel * model,GtkTreePath * path,GtkTreeIter * iter,void * data)859 static void calcDirectorySizeInView_thread_helper (GtkTreeModel *model,GtkTreePath *path,GtkTreeIter *iter, void *data){
860     TRACEIT(10,"calcDirectorySizeInView_thread_helper		start");
861     struct AllInformationAllUseStruct *stru = (struct AllInformationAllUseStruct *)data;
862     int type_d;
863     gchar *gcharname=NULL;
864     gchar *gcharpath=NULL;
865     GString *gstrPath=NULL;
866     guint64 size=0;
867     int ColumnSize;
868     int *iRecursiveSizeCalculation = (int *)stru->Info_3;
869     GtkListStore *listStore=NULL;
870 
871     if (iRecursiveSizeCalculation == NULL){
872         TRACEIT(2,"calcDirectorySizeInView_thread_helper		parameter NULL");
873         return;
874     }
875 
876     if (*iRecursiveSizeCalculation != 0){
877         return;
878     }
879 
880     gstrPath = g_string_sized_new(10);
881 
882     if (stru->source==SOURCE_SIDEOBJECT){
883         struct SideObjectList* Object = stru->Info_1;
884         //iRecursiveSizeCalculation = &(Object->iRecursiveSizeCalculation);
885 
886         ColumnSize = COL_SIZE;
887         listStore = Object->listStore;
888         //myWrap_gdk_threads_enter("calcDirectorySizeInView_thread_helper 1");
889         gtk_tree_model_get(model, iter,COL_NAME,&gcharname,COL_TYPE_D,&type_d, -1);
890         //myWrap_gdk_threads_leave("calcDirectorySizeInView_thread_helper 1");
891         g_string_assign(gstrPath, Object->gstrPath->str);
892     }
893     else{
894         struct FileShelfObjectList* Object = stru->Info_1;
895         //iRecursiveSizeCalculation = &(Object->iRecursiveSizeCalculation);
896         ColumnSize = COL_FLSHLF_SIZE;
897         listStore = Object->listStore;
898         //myWrap_gdk_threads_enter("calcDirectorySizeInView_thread_helper 2");
899         gtk_tree_model_get(model, iter, COL_FLSHLF_PATH, &gcharpath, COL_FLSHLF_NAME, &gcharname, COL_FLSHLF_TYPE_D, &type_d, -1);
900         //myWrap_gdk_threads_leave("calcDirectorySizeInView_thread_helper 2");
901         g_string_assign(gstrPath, gcharpath);
902     }
903 
904     if (strcmp(gcharname, ".")!=0 && strcmp(gcharname, "..")!=0 && *iRecursiveSizeCalculation == 0 && type_d == 4){
905         checkPathForLastChar(gstrPath);
906         g_string_append(gstrPath, gcharname);
907         if (0 != getDirectorySize(&size, gstrPath, iRecursiveSizeCalculation, FALSE)){ //error opening the directory
908             size=0;
909         }
910         //myWrap_gdk_threads_enter("calcDirectorySizeInView_thread_helper 3");
911         if (*iRecursiveSizeCalculation == 0){
912             gtk_list_store_set (listStore, iter, ColumnSize, size, -1);
913         }
914         if (stru->source==SOURCE_SIDEOBJECT)
915             updateStatusBar((struct SideObjectList *)stru->Info_1);
916         //myWrap_gdk_threads_leave("calcDirectorySizeInView_thread_helper 3");
917 
918     }
919 
920     if (gcharname)
921         g_free(gcharname);
922     if (gcharpath)
923         g_free(gcharpath);
924     g_string_free(gstrPath, TRUE);
925     TRACEIT(10,"calcDirectorySizeInView_thread_helper		end");
926 }
927 
928 
calcDirectorySizeInView_thread(struct AllInformationAllUseStruct * stru)929 void calcDirectorySizeInView_thread(struct AllInformationAllUseStruct *stru){
930     TRACEIT(10,"calcDirectorySizeInView_thread		start");
931     GtkListStore		*listStore=NULL;
932     int sort_column_id;
933     GtkSortType order;
934     //stru->source=SOURCE_FILESHELF;
935     //stru->Info_1 = data;
936     //stru->Info_2 = &(Object->gthreadF6Updage);
937     //stru->Info_3 = &(Object->iRecursiveSizeCalculation);
938     int *iRecursiveSizeCalculation = (int *)stru->Info_3;
939 
940     if (stru->source==SOURCE_SIDEOBJECT){
941         struct SideObjectList* Object = stru->Info_1;
942         listStore = Object->listStore;
943 
944         manipulateCounter (&(Object->iPreventFromUpdating), TRUE, "calcDirectorySizeInView_thread");
945         SideObjectList_UpdateObject(Object);
946         g_thread_yield ();  //give some cpu time to other threads, other wise its very unlikely that SideObjectList_UpdateObject changes take place in the views tab
947                             //however, this isnt a garantie that the changes take place before this thread quits
948 
949 
950         //When the actual sort column is the size column there is a problem.
951         //Every time we update an item with its size, the list will be reordered.
952         //This means, when we come to an directory ehich is very little and therefore is placed to the end
953         //of the list, the next item in the function for_each... is simply nothing because the list ends
954         //with the current item and we break the function and may leave many directories unchecked.
955         //To avoid this we set the current sort column to the definition GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID
956         //and the list is not going to reorder its items. But we have to set the right column when we are finished.
957         myWrap_gdk_threads_enter("calcDirectorySizeInView_thread 1");
958         gtk_tree_sortable_get_sort_column_id (GTK_TREE_SORTABLE(Object->listStore), &sort_column_id, &order);
959         if (COL_SIZE == sort_column_id){
960             gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE(Object->listStore),GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID, order);
961         }
962         //myWrap_gdk_threads_leave("calcDirectorySizeInView_thread 1");
963 
964         gtk_tree_model_foreach(GTK_TREE_MODEL(listStore),(GtkTreeModelForeachFunc) calcDirectorySizeInView_thread_helper,(void *)stru);
965 
966         //myWrap_gdk_threads_enter("calcDirectorySizeInView_thread 2");
967         if (COL_SIZE == sort_column_id){
968             gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE(Object->listStore),COL_SIZE, order);
969         }
970         myWrap_gdk_threads_leave("calcDirectorySizeInView_thread 2");
971     }
972     else{
973         struct FileShelfObjectList* Object = stru->Info_1;
974         listStore = Object->listStore;
975 
976         //When the actual sort column is the size column there is a problem.
977         //Every time we update an item with its size, the list will be reordered.
978         //This means, when we come to an directory ehich is very little and therefore is placed to the end
979         //of the list, the next item in the function for_each... is simply nothing because the list ends
980         //with the current item and we break the function and may leave many directories unchecked.
981         //To avoid this we set the current sort column to the definition GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID
982         //and the list is not going to reorder its items. But we have to set the right column when we are finished.
983         myWrap_gdk_threads_enter("calcDirectorySizeInView_thread 3");
984         gtk_tree_sortable_get_sort_column_id (GTK_TREE_SORTABLE(Object->listStore), &sort_column_id, &order);
985         if (COL_FLSHLF_SIZE == sort_column_id){
986             gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE(Object->listStore),GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID, order);
987         }
988         //myWrap_gdk_threads_leave("calcDirectorySizeInView_thread 3");
989         gtk_tree_model_foreach(GTK_TREE_MODEL(listStore),(GtkTreeModelForeachFunc) calcDirectorySizeInView_thread_helper,(void *)stru);
990         //myWrap_gdk_threads_enter("calcDirectorySizeInView_thread 4");
991         if (COL_FLSHLF_SIZE == sort_column_id){
992             gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE(Object->listStore),COL_FLSHLF_SIZE, order);
993         }
994         myWrap_gdk_threads_leave("calcDirectorySizeInView_thread 4");
995     }
996     *iRecursiveSizeCalculation = -1;
997 
998     free(stru);
999 
1000     TRACEIT(10,"calcDirectorySizeInView_thread		end");
1001     g_thread_exit(0);
1002 }
1003 
1004