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 
22 #include <stdlib.h>
23 #include <gtk/gtk.h>
24 #ifndef NO_GIO
25 #include <gio/gio.h>
26 #endif
27 #include <string.h>
28 
29 #include "Lists.h"
30 #include "mytrace.h"
31 #include "helpers.h"
32 #include "globalDefinitions.h"
33 #include "confighandling.h"
34 #include "userdata.h"
35 #include "myfm.h"
36 #include "fileshelf.h"
37 #include "automaticUpdate.h"
38 #include "threads.h"
39 
40 #include "allInclude.h"
41 
42 extern int g_int_AlwaysShowHidden;
43 extern GtkWidget 		*Notebooks[SIDE_BOTH];
44 
45 /////////////////////////////////////////////////////////////////////////////////////////////////
46 ///////////////// CopyReMove LISTS //////////////////////////////////////////////////////////////
47 /////////////////////////////////////////////////////////////////////////////////////////////////
48 
49 
CopyReMoveList_AddItem(struct CopyReMoveList ** FirstItem,char * string1,char * string2,struct SideObjectList * SrcObject,struct SideObjectList * DestObject,struct FileShelfObjectList * FileShelfObject)50 int CopyReMoveList_AddItem(struct CopyReMoveList **FirstItem, char *string1, char *string2, struct SideObjectList *SrcObject, struct SideObjectList *DestObject, struct FileShelfObjectList *FileShelfObject){
51 	TRACEIT(10,"CopyReMoveList_AddItem		start");
52 	struct CopyReMoveList *list;
53 	if (FirstItem == NULL || (string1==NULL && string2==NULL)){
54 		TRACEIT(10,"CopyReMoveList_AddItem		ends -2");
55 		return -2;
56 	}
57 
58 
59     struct CopyReMoveList *newItem = malloc(sizeof(struct CopyReMoveList));
60     if (newItem == NULL){
61         TRACEIT(10,"CopyReMoveList_AddItem		ends, Error allocating memory");
62         return -1;
63     }
64     if (string1==NULL){
65         newItem->string1 = NULL;
66     }
67     else{
68         newItem->string1=g_string_new(string1);
69     }
70     if (string2 ==NULL){
71         newItem->string2=NULL;
72     }
73     else{
74         newItem->string2=g_string_new(string2);
75     }
76     newItem->SrcObject=SrcObject;
77     newItem->DestObject=DestObject;
78     newItem->NextItem=NULL;
79     newItem->PrevItem=NULL;
80     newItem->CopyMoveOrRemove=0;
81     newItem->FileShelfObject=FileShelfObject;
82     newItem->UserCommand = NULL;
83     newItem->gstrCaption = NULL;
84     newItem->gstrLabel = NULL;
85     newItem->Errors = NULL;
86     newItem->ErrorMessage = NULL;
87     newItem->bOverWriteExisting=FALSE;
88     newItem->threadCalcSize=NULL;
89     newItem->listStore=NULL;
90     newItem->iBytesToCopy=0;
91     newItem->iBytesCopied=0;
92     newItem->iBytesToCopyIsValid=0;
93     newItem->ui64pTotalBytesCopied=NULL;
94     newItem->i64pStartTotalBytesCopied=NULL;
95     newItem->timepStartTimeForBytesCopied=NULL;
96     newItem->timepStartTimeForBytesCopiedSingleItem=NULL;
97     newItem->iTotalBytesValid=NULL;
98 
99     if (*FirstItem==NULL){
100         *FirstItem = newItem;
101     }
102     else{
103         for (list=*FirstItem; list->NextItem; list=list->NextItem);
104         list->NextItem = newItem;
105         newItem->PrevItem = list;
106     }
107 
108 	TRACEIT(10,"CopyReMoveList_AddItem		ends _ 2");
109 	return 0;
110 }
111 
112 
CopyReMoveList_CopyList(struct CopyReMoveList ** NewList,struct CopyReMoveList * OldList)113 int CopyReMoveList_CopyList (struct CopyReMoveList **NewList, struct CopyReMoveList *OldList){
114     TRACEIT(10,"CopyReMoveList_CopyList		start");
115     if (NewList == NULL || OldList == NULL){
116         TRACEIT(10,"CopyReMoveList_CopyList		end -1");
117         return -1;
118     }
119     while (OldList){
120         CopyReMoveList_AddItem(NewList, OldList->string1->str, OldList->string2->str, OldList->SrcObject, OldList->DestObject, OldList->FileShelfObject);
121         OldList = OldList->NextItem;
122     }
123 
124     TRACEIT(10,"CopyReMoveList_CopyList		end");
125     return 0;
126 }
127 
128 
CopyReMoveList_initializeMemberTo(struct CopyReMoveList * Item,GtkListStore * listStore,GtkTreeIter iter,guint64 * ui64pTotalBytesCopied,gint64 * i64pStartTotalBytesCopied,GTimeVal * timepStartTimeForBytesCopied,GTimeVal * timepStartTimeForBytesCopiedSingleItem,guint64 * ui64TotalBytes,int * iTotalBytesValid,GtkProgressBar * progressBar,int CopyMoveOrRemove,double * dpCopySpeed)129 int CopyReMoveList_initializeMemberTo (struct CopyReMoveList *Item, GtkListStore *listStore, GtkTreeIter iter, guint64 *ui64pTotalBytesCopied, gint64 *i64pStartTotalBytesCopied, GTimeVal *timepStartTimeForBytesCopied, GTimeVal *timepStartTimeForBytesCopiedSingleItem, guint64 *ui64TotalBytes, int *iTotalBytesValid, GtkProgressBar *progressBar, int CopyMoveOrRemove, double *dpCopySpeed){
130     TRACEIT(10,"CopyReMoveList_initializeMemberTo		end");
131 
132     Item->listStore=listStore;
133     Item->iter = iter;
134     Item->status = -1;
135     Item->ibreak=0;
136     Item->lastfinishedTotalBytes=0;
137     Item->threadCalcSize=NULL;
138     Item->ui64pTotalBytesCopied = ui64pTotalBytesCopied;
139     Item->ui64TotalBytes = ui64TotalBytes;
140     Item->iTotalBytesValid = iTotalBytesValid;
141     Item->progressBar = progressBar;
142     Item->CopyMoveOrRemove = CopyMoveOrRemove;
143     Item->i64pStartTotalBytesCopied = i64pStartTotalBytesCopied;
144     Item->timepStartTimeForBytesCopied = timepStartTimeForBytesCopied;
145     Item->timepStartTimeForBytesCopiedSingleItem = timepStartTimeForBytesCopiedSingleItem;
146     Item->dpCopySpeed = dpCopySpeed;
147 
148     TRACEIT(10,"CopyReMoveList_initializeMemberTo		end");
149     return 0;
150 }
151 
152 
CopyReMoveList_removeItemFromList(struct CopyReMoveList * theItem)153 struct CopyReMoveList *CopyReMoveList_removeItemFromList (struct CopyReMoveList *theItem){
154     //returns the new beginning of the list
155     TRACEIT(10,"CopyReMoveList_removeItemFromList		start");
156 	if (theItem == NULL){
157 		TRACEIT(2,"CopyReMoveList_removeItemFromList		PARAMETER NULL");
158 		return NULL;
159 	}
160     struct CopyReMoveList *Following;
161     struct CopyReMoveList *Before;
162 
163     Following = theItem->NextItem;
164     Before = theItem->PrevItem;
165 
166     if (Before != NULL){
167         Before->NextItem = Following;
168     }
169     if (Following != NULL){
170         Following->PrevItem = Before;
171     }
172     CopyReMoveLis_deleteItemMember (theItem);
173     free (theItem);
174     Before = (Before==NULL)?Following:Before;
175     if (Before == NULL){
176         return NULL;    //the whole list is gone
177     }
178 
179     while (Before->PrevItem != NULL){
180         Before = Before->PrevItem;
181     }
182 
183 
184     TRACEIT(10,"CopyReMoveList_removeItemFromList		end");
185     return Before;
186 }
187 
188 
CopyReMoveLis_deleteItemMember(struct CopyReMoveList * FirstItem)189 int CopyReMoveLis_deleteItemMember (struct CopyReMoveList *FirstItem){
190     //will not delete the item itself but frees all the memory resevered before
191     TRACEIT(10,"CopyReMoveLis_deleteItemMember		start");
192 	if (FirstItem == NULL){
193 		TRACEIT(2,"CopyReMoveLis_deleteItemMember		PARAMETER NULL");
194 		return -1;
195 	}
196 
197 	if (FirstItem->string1 != NULL){
198         g_string_free(FirstItem->string1,TRUE);
199         FirstItem->string1=NULL;
200     }
201     if (FirstItem->string2 != NULL){
202         g_string_free(FirstItem->string2,TRUE);
203         FirstItem->string2=NULL;
204     }
205     if (FirstItem->UserCommand != NULL){
206         g_string_free(FirstItem->UserCommand, TRUE);
207         FirstItem->UserCommand=NULL;
208     }
209     if (FirstItem->gstrCaption != NULL){
210         g_string_free(FirstItem->gstrCaption, TRUE);
211         FirstItem->gstrCaption=NULL;
212     }
213     if (FirstItem->gstrLabel != NULL){
214         g_string_free(FirstItem->gstrLabel, TRUE);
215         FirstItem->gstrLabel=NULL;
216     }
217     if (FirstItem->Errors != NULL){
218         g_string_free(FirstItem->Errors, TRUE);
219         FirstItem->Errors=NULL;
220     }
221     if (FirstItem->ErrorMessage != NULL){
222         g_string_free(FirstItem->ErrorMessage, TRUE);
223         FirstItem->ErrorMessage=NULL;
224     }
225 
226 
227 
228 	TRACEIT(10,"CopyReMoveLis_deleteItemMember		end");
229 	return 0;
230 }
231 
CopyReMoveList_DeleteList(struct CopyReMoveList * FirstItem)232 int CopyReMoveList_DeleteList(struct CopyReMoveList *FirstItem){
233 	TRACEIT(10,"CopyReMoveList_DeleteList		start");
234 	if (FirstItem == NULL){
235 		TRACEIT(2, "CopyReMoveList_DeleteList		PARAMETER NULL");
236 		return -2;
237 	}
238 	struct CopyReMoveList *bufItem;
239 	for ( bufItem=FirstItem; bufItem->PrevItem; bufItem=bufItem->PrevItem);
240 	do{
241         CopyReMoveLis_deleteItemMember (FirstItem);
242 
243 		bufItem = FirstItem;
244 		FirstItem = FirstItem->NextItem;
245 		free(bufItem);
246 	}while (FirstItem != NULL);
247 	TRACEIT(10,"CopyReMoveList_DeleteList		ends");
248 	return 0;
249 }
250 
251 
252 /////////////////////////////////////////////////////////////////////////////////////////////////
253 ///////////////// FILESHELF OBJECT LIST /////////////////////////////////////////////////////////
254 /////////////////////////////////////////////////////////////////////////////////////////////////
255 struct FileShelfObjectList *FirstFileShelfObject;
256 
FileShelftObjectList_getFirstObject()257 struct FileShelfObjectList *FileShelftObjectList_getFirstObject(){
258 	return FirstFileShelfObject;
259 }
260 
FileShelfObjectList_getNextObejct(struct FileShelfObjectList * Object)261 struct FileShelfObjectList *FileShelfObjectList_getNextObejct(struct  FileShelfObjectList *Object){
262 	return Object->NextItem;
263 }
264 
FileShelfObjectList_StartWithObjectList()265 int FileShelfObjectList_StartWithObjectList(){
266 	//called in InitFileShelf (do not call it from another function)
267 	TRACEIT(10,"FileShelfObjectList_StartWithObjectList		start");
268 	FirstFileShelfObject = malloc(sizeof(struct FileShelfObjectList));
269 	if (FirstFileShelfObject == NULL){
270 		TRACEIT(8,"FileShelfObjectList_StartWithObjectList		ends");
271 		return -1;
272 	}
273 
274 	FirstFileShelfObject->notebook=NULL;
275 	FirstFileShelfObject->listView=NULL;
276 	FirstFileShelfObject->listStore=NULL;
277 	FirstFileShelfObject->ScrollWindow=NULL;
278 	FirstFileShelfObject->actualSortCol=NULL;
279 	FirstFileShelfObject->PreviewCol=NULL;
280 	FirstFileShelfObject->label=NULL;
281 	FirstFileShelfObject->iRecursiveSizeCalculation=-1;
282 	FirstFileShelfObject->ID=getRandomIntNumber(-1, -1);	//-1: do just return the rand() output, do not apply any border calculations
283     FirstFileShelfObject->gthreadF6Updage = NULL;
284     FirstFileShelfObject->iPreview=0;
285 
286 	FirstFileShelfObject->PrevItem = NULL;
287 	FirstFileShelfObject->NextItem = NULL;
288 
289 	TRACEIT(10,"FileShelfObjectList_StartWithObjectList		ends");
290 	return 0;
291 }
292 
293 
FileShelfObjectList_NewObject(struct FileShelfObjectList ** RetObject)294 int FileShelfObjectList_NewObject(struct FileShelfObjectList **RetObject){
295 	TRACEIT(10,"FileShelfObjectList_NewObject		start");
296 	if (RetObject == NULL){
297 		TRACEIT(2,"FileShelfObjectList_NewObject		ends, PARAMETER NULL");
298 		return -1;
299 	}
300 
301 	struct  FileShelfObjectList *Object = FirstFileShelfObject;
302 
303 	while (Object->NextItem != NULL){
304 		Object = Object->NextItem;
305 	}
306 	Object->NextItem = malloc(sizeof(struct FileShelfObjectList));
307 	if (FirstFileShelfObject == NULL){
308 		TRACEIT(1,"FileShelfObjectList_NewObject		ends, error allocating memory");
309 		*RetObject = NULL;
310 		return -1;
311 	}
312 	Object->NextItem->PrevItem = Object;
313 	Object = Object->NextItem;
314 	Object->NextItem=NULL;
315 
316 	Object->notebook=NULL;
317 	Object->listView=NULL;
318 	Object->listStore=NULL;
319 	Object->ScrollWindow=NULL;
320 	Object->actualSortCol=NULL;
321 	Object->PreviewCol=NULL;
322 	Object->label=NULL;
323 	Object->iRecursiveSizeCalculation=-1;
324 	Object->ID=getRandomIntNumber(-1, -1);	//-1: do just return the rand() output, do not apply any border calculations
325     Object->gthreadF6Updage = NULL;
326     Object->iPreview=0;
327 
328 	*RetObject = Object;
329 	TRACEIT(10,"FileShelfObjectList_NewObject		ends");
330 	return 0;
331 }
332 
333 
FileShelfObjectList_GetActiveObject(struct FileShelfObjectList ** Object)334 void FileShelfObjectList_GetActiveObject(struct FileShelfObjectList **Object){
335 	TRACEIT(10,"FileShelfObjectList_GetActiveObject		start");
336 	if (Object == NULL){
337 		TRACEIT(2,"FileShelfObjectList_GetActiveObject		ends, PARAMETER NULL");
338 		return;
339 	}
340 	struct FileShelfObjectList *BufObject=FirstFileShelfObject;
341 
342 	if (BufObject == NULL){
343 		TRACEIT(10,"FileShelfObjectList_GetActiveObject		ends 2, fileshelf not initialized");
344 		*Object=NULL;
345 		return;
346 	}
347 
348 	int i_activePage = gtk_notebook_get_current_page (FirstFileShelfObject->notebook);
349 	GtkWidget *ActiveWidget = gtk_notebook_get_nth_page(FirstFileShelfObject->notebook, i_activePage);
350 	while (BufObject){
351 		if (BufObject->ScrollWindow == ActiveWidget){
352 			*Object = BufObject;
353 			TRACEIT(10,"FileShelfObjectList_GetActiveObject		ends 1");
354 			return;
355 		}
356 		BufObject = BufObject->NextItem;
357 	};
358 	*Object = NULL;
359 	TRACEIT(10,"FileShelfObjectList_GetActiveObject		ends");
360 	return;
361 }
362 
363 
FileShelfObjectList_GetPageNumberByObject(struct FileShelfObjectList * Object)364 int FileShelfObjectList_GetPageNumberByObject(struct FileShelfObjectList *Object){
365 	//return: -1=error,  pagenumber on success
366 	TRACEIT(11,"FileShelfObjectList_GetPageNumberByObject		start");
367 	if (Object == NULL){
368 		TRACEIT(2,"FileShelfObjectList_GetPageNumberByObject		end, PARAMETER NULL");
369 		return -1;
370 	}
371 	int i;
372 	struct FileShelfObjectList *BufObject=FirstFileShelfObject;
373 	int iPages = gtk_notebook_get_n_pages (BufObject->notebook);
374 	int found = 0;
375 	for (i=0; i<=iPages; i++){
376 		FileShelfObjectList_GetObjectByPageNumber(&BufObject, i);
377 		if (BufObject == Object){
378 			found = 1;
379 			break;
380 		}
381 	}
382 
383 	if (found == 1){
384 		return i;
385 	}
386 	TRACEIT(11,"FileShelfObjectList_GetPageNumberByObject		end");
387 	return -1;
388 }
389 
390 
FileShelfObjectList_GetIDByPageNumber(int iPageNumber)391 int FileShelfObjectList_GetIDByPageNumber(int iPageNumber){
392 	//return: -1=error, ID on success
393 	TRACEIT(11,"FileShelfObjectList_GetIDByPageNumber		start");
394 	int iPages = gtk_notebook_get_n_pages (FirstFileShelfObject->notebook);
395 	if (iPageNumber > iPages){
396 		TRACEIT(4,"FileShelfObjectList_GetIDByPageNumber		end, iPageNumner>iPages");
397 		return -1;
398 	}
399 	struct FileShelfObjectList *BufObject;
400 	if (-1 == FileShelfObjectList_GetObjectByPageNumber(&BufObject, iPageNumber)){
401 		TRACEIT(4,"FileShelfObjectList_GetIDByPageNumber		end, could not find object to pagenumber");
402 		return -1;
403 	}
404 	TRACEIT(11,"FileShelfObjectList_GetIDByPageNumber		end");
405 	return BufObject->ID;
406 }
407 
408 
FileShelfObjectList_GetPageNumberByID(struct FileShelfObjectList * Object,int ID)409 int FileShelfObjectList_GetPageNumberByID(struct FileShelfObjectList *Object, int ID){
410 	//return: -1=error,  pagenumber on success
411 	TRACEIT(11,"FileShelfObjectList_GetPageNumberByID		start");
412 
413 	if (Object == NULL){
414 		TRACEIT(2,"FileShelfObjectList_GetPageNumberByID		end, PARAMETER NULL");
415 		return -1;
416 	}
417 
418 	if (ID < 0){
419 		TRACEIT(2,"FileShelfObjectList_GetPageNumberByID		end, ID<0, How can this be?");
420 		return -1;
421 	}
422 
423 	struct FileShelfObjectList *BufObject=FirstFileShelfObject;
424 	int PageNumber = -1;
425 	do{
426 		if (BufObject->ID == ID){
427 			PageNumber = FileShelfObjectList_GetPageNumberByObject(BufObject);
428 			break;
429 		}
430 		BufObject = BufObject->NextItem;
431 	}while(BufObject);
432 
433 	TRACEIT(11,"FileShelfObjectList_GetPageNumberByID		end");
434 	return PageNumber;
435 }
436 
437 
FileShelfObjectList_GetObjectByID(const int ID)438 struct FileShelfObjectList  *FileShelfObjectList_GetObjectByID(const int ID){
439 	//return NULL on error
440 
441 	struct FileShelfObjectList *BufObject=FirstFileShelfObject;
442 
443 	while (BufObject){
444 		if (ID == BufObject->ID){
445 			return BufObject;
446 		}
447 		BufObject = BufObject->NextItem;
448 	}
449 
450 	return NULL;
451 }
452 
453 
FileShelfObjectList_GetObjectByPageNumber(struct FileShelfObjectList ** Object,guint Number)454 int FileShelfObjectList_GetObjectByPageNumber(struct FileShelfObjectList **Object, guint Number){
455 	//return: -1=error, 0=success
456 	TRACEIT(11,"FileShelfObjectList_GetObjectByPageNumber		start");
457 	if (Object == NULL){
458 		TRACEIT(2,"FileShelfObjectList_GetObjectByPageNumber		ends, PARAMETER NULL");
459 		return -1;
460 	}
461 
462 	int currentPage = Number;
463 
464 	*Object = NULL;
465 
466 	struct FileShelfObjectList *BufObject=FirstFileShelfObject;
467 
468 	do{
469 		if (currentPage == gtk_notebook_page_num(FirstFileShelfObject->notebook,GTK_WIDGET(BufObject->ScrollWindow))){
470 			*Object = BufObject;
471 			TRACEIT(11,"FileShelfObjectList_GetObjectByPageNumber		ends");
472 			return 0;
473 		}
474 		BufObject = BufObject->NextItem;
475 
476 	}while(BufObject);
477 	TRACEIT(8,"FileShelfObjectList_GetObjectByPageNumber		ends		NotFound ERROR");
478 	return -1;
479 }
480 
481 
FileShelfObjectList_GetObjectByChildListView(struct FileShelfObjectList ** Object,GtkTreeView * listView)482 int FileShelfObjectList_GetObjectByChildListView(struct FileShelfObjectList **Object, GtkTreeView *listView){
483     // writes NULL to *Object to determine the result to be valid (in some kind)
484     // searches all the Objects till the Listview given here is the same as in one if the Objects abnd
485     // then fills the Obect and the side where side is the notebook (left or right)
486     TRACEIT(10,"FileShelfObjectList_GetObjectByChildListView		start");
487     if (Object == NULL || listView == NULL){
488         TRACEIT(2,"FileShelfObjectList_GetObjectByChildListView		ends, parameter NULL");
489         return -1;
490     }
491     struct FileShelfObjectList *Objects = FirstFileShelfObject;
492     if (Objects == NULL){
493         TRACEIT(2,"FileShelfObjectList_GetObjectByChildListView		ends, No Objects defined");
494         return -1;
495     }
496     *Object=NULL;
497     while (Objects){
498         if (Objects->listView == (GtkWidget *)listView){
499             *Object = Objects;
500             break;
501         }
502         Objects = Objects->NextItem;
503     }
504 
505     TRACEIT(10,"FileShelfObjectList_GetObjectByChildListView		end");
506     return 0;
507 }
508 
509 
FileShelfObjectList_DeleteObject(struct FileShelfObjectList * Object)510 void FileShelfObjectList_DeleteObject(struct FileShelfObjectList *Object){
511 	TRACEIT(10,"FileShelfObjectList_DeleteObject	start");
512 	if (Object == NULL){
513 		TRACEIT(2,"FileShelfObjectList_DeleteObject		ends, PARAMETER NULL");
514 		return;
515 	}
516 
517 	if (Object->PrevItem != NULL){
518 		Object->PrevItem->NextItem = Object->NextItem;
519 	}
520 	else{
521 		FirstFileShelfObject = Object->NextItem;
522 	}
523 
524 	if (Object->NextItem != NULL){
525 		Object->NextItem->PrevItem = Object->PrevItem;
526 	}
527 
528     calcDirectorySizeInView_closeProcess (&(Object->iRecursiveSizeCalculation), &(Object->gthreadF6Updage), NULL, NULL, TRUE);
529 
530     SideObjectList_UnrefPreviewPixbufs (Object->listStore, COL_FLSHLF_PREVIEW);
531 
532 	if (Object->listStore != NULL){
533 		g_object_unref(Object->listStore);
534 	}
535 	free(Object);
536 	TRACEIT(10,"FileShelfObjectList_DeleteObject	ends");
537 	return;
538 }
539 
540 
FileShelfObjectList_ClearAllForShutdown()541 void FileShelfObjectList_ClearAllForShutdown(){
542 	TRACEIT(10,"SideObjectList_ClearAllForShutdown		start");
543 	struct FileShelfObjectList *ThisObject;
544 
545 	while (FirstFileShelfObject){
546 
547 		ThisObject = FirstFileShelfObject;
548 		FirstFileShelfObject->PrevItem=NULL;
549 
550 		calcDirectorySizeInView_closeProcess (&(ThisObject->iRecursiveSizeCalculation), &(ThisObject->gthreadF6Updage), NULL, NULL, TRUE);
551 
552         SideObjectList_UnrefPreviewPixbufs (ThisObject->listStore, COL_FLSHLF_PREVIEW);
553 
554 		if (FirstFileShelfObject->listStore != NULL){	//it can be NULL when a directory was loaded (e.g. on startup)
555 			g_object_unref(FirstFileShelfObject->listStore);	//wich does not exist then, there is no listStore defined
556 		}
557 
558 		FirstFileShelfObject = FirstFileShelfObject->NextItem;
559 		free(ThisObject);
560 	}
561 	TRACEIT(10,"SideObjectList_ClearAllForShutdown		ends");
562 	return;
563 }
564 
565 
FileShelfObjectList_ValidatObject(struct FileShelfObjectList * Object)566 int FileShelfObjectList_ValidatObject(struct FileShelfObjectList *Object){
567 	TRACEIT(10,"FileShelfObjectList_ValidateObject		start");
568 	if (Object == NULL)	//this is possible when processItemsViaList from within a SideObject (for copy Remove things)
569 		return -1;
570 	struct FileShelfObjectList *buf = FirstFileShelfObject;
571 
572 	while (buf != NULL){
573 		if (buf == Object){
574 			TRACEIT(10,"FileShelfObjectList_ValidateObject		ends 1");
575 			return 1;
576 		}
577 		buf = buf->NextItem;
578 	};
579 	TRACEIT(10,"FileShelfObjectList_ValidateObject		ends -1");
580 	return -1;
581 }
582 
583 /////////////////////////////////////////////////////////////////////////////////////////////////
584 ///////////////// SIDE OBJECT LIST //////////////////////////////////////////////////////////////
585 /////////////////////////////////////////////////////////////////////////////////////////////////
586 
587 struct  SideObjectList *FirstObject;
588 
SideObjectList_getFirstObject()589 struct SideObjectList *SideObjectList_getFirstObject(){
590 	return FirstObject;
591 }
592 
SideObjectList_getNextObejct(struct SideObjectList * Object)593 struct SideObjectList *SideObjectList_getNextObejct(struct  SideObjectList *Object){
594 	return Object->NextItem;
595 }
596 
597 
SideObjectList_StartWithObjectList(GtkNotebook * notebook,char * Path)598 int SideObjectList_StartWithObjectList(GtkNotebook *notebook, char *Path){
599 	TRACEIT(10,"SideObjectList_StartWithObjectList		start");
600 	FirstObject = malloc(sizeof(struct SideObjectList));
601 	if (FirstObject == NULL){
602 		TRACEIT(8,"SideObjectList_StartWithObjectList		ends");
603 		return -1;
604 	}
605 	FirstObject->PrevItem = NULL;
606 	FirstObject->NextItem = NULL;
607 
608 	SideObjectList_ProcessNewItem(notebook, FirstObject, Path, NULL);
609 	TRACEIT(10,"SideObjectList_StartWithObjectList		ends");
610 	return 0;
611 }
612 
613 
SideObjectList_ProcessNewItem(GtkNotebook * notebook,struct SideObjectList * Object,char * Path,struct SideObjectList * OldObject)614 void SideObjectList_ProcessNewItem(GtkNotebook *notebook, struct SideObjectList *Object, char *Path, struct SideObjectList *OldObject){
615 	TRACEIT(10,"SideObjectList_ProcessNewItem		start");
616 	Object->notebook = notebook;
617 	//predefine_NotebookTaps_Objects(Object);
618 	//connectSignalsToNotebookTapObject(Object);
619 
620 	Object->listStore=NULL;
621 	Object->gstrPath = g_string_new(Path);  //dont change this, we need this for monitoring, look in updateViewWithNewFolder
622 
623 	if (OldObject != NULL){
624 		Object->showHiddenFiles=OldObject->showHiddenFiles;
625 		Object->iPreview=OldObject->iPreview;
626 	}
627 	else{
628 		Object->showHiddenFiles=FALSE;
629 		Object->iPreview = 0;
630 	}
631 
632 	if( g_int_AlwaysShowHidden==1){
633 		Object->alwaysShowHiddenFiles=TRUE;
634 	}
635 	else{
636 		Object->alwaysShowHiddenFiles=FALSE;
637 	}
638 
639 	Object->iPreventFromUpdating = 0;
640 	Object->bUpdateFlag_UpdateOnTabSwitch = FALSE;
641 	Object->bUpdateFlag_CurrentlyUpdating = FALSE;
642 	Object->bUpdateFlag_UserWantsToUpdate = FALSE;
643 	Object->bUpdateFlag_F6 = FALSE;
644 	Object->gthreadF6Updage = NULL;
645 	Object->actualSortCol=NULL;
646 	Object->PreviewCol=NULL;
647 	Object->bPointsAddedToView=FALSE;
648 	Object->bReadOnly = FALSE;
649 
650     predefine_NotebookTaps_Objects(Object);
651 	connectSignalsToNotebookTapObject(Object);
652 
653 
654 	gtk_container_add(GTK_CONTAINER(Object->ScrollWindow),Object->listView);
655 	gtk_box_pack_start(GTK_BOX(Object->VBox),GTK_WIDGET(Object->ScrollWindow),TRUE,TRUE,1);
656 	gtk_box_pack_start(GTK_BOX(Object->VBox),GTK_WIDGET(Object->StatusBar),FALSE,FALSE,1);
657 
658 	gtk_widget_show_all (GTK_WIDGET (Object->VBox));
659 
660 #ifndef NO_GIO
661 	//add a monitor:
662 	autoUpdateList_AddMonitor(Path);
663 #endif
664 
665 	gtk_notebook_append_page(notebook,GTK_WIDGET(Object->VBox),Object->label);
666 	gtk_notebook_set_tab_reorderable(notebook,GTK_WIDGET(Object->VBox),TRUE);
667 	predefine_NotebookTabs_reorderColumns ((GtkTreeView *)Object->listView);
668     //gtk_notebook_set_tab_detachable (notebook, GTK_WIDGET(Object->VBox), TRUE);
669 
670     ////////// Test section
671     //GtkWidget *label = gtk_notebook_get_tab_label (notebook,GTK_WIDGET(Object->VBox));
672     //prepareWidgetForDrag (label);
673     /////////////
674 
675 	//updateViewWithNewFolder(Object,Object->gstrPath);	//is done in Signal "page-added"
676 	TRACEIT(10,"SideObjectList_ProcessNewItem		ends");
677 }
678 
679 
SideObjectList_CreateNewViewWithPath(GtkNotebook * notebook,char * Path,struct SideObjectList * OldObject)680 int SideObjectList_CreateNewViewWithPath(GtkNotebook *notebook, char *Path, struct SideObjectList *OldObject){	//OldObject holds object from which the new page is copied when calling movepage, copy page, dublicate page. it can be NULL
681 //this function is also called from within the fileshelf. And creates a new SideObject with the path saved in the Fileshelf.
682 //Therefor it is necessary that notebook can be NULL. In this case, the information is got from FirstObject.
683 	TRACEIT(10,"SideObjectList_CreateNewViewWithPath		start");
684 	if (FirstObject == NULL){
685 		TRACEIT(8,"SideObjectList_CreateNewViewWithPath		ends		ERROR");
686 		return -1;
687 	}
688 	struct SideObjectList *newObject = FirstObject;
689 	struct SideObjectList *bufObject;
690 
691 	while(newObject->NextItem != NULL){
692 		newObject = newObject->NextItem;
693 	}
694 
695 	newObject->NextItem = malloc(sizeof(struct SideObjectList));
696 
697 	if (newObject->NextItem == NULL){
698 		TRACEIT(8,"SideObjectList_CreateNewViewWithPath		ends		ERROR2");
699 		return -1;
700 	}
701 
702 	bufObject = newObject;
703 	newObject = bufObject->NextItem;
704 	newObject->PrevItem = bufObject;
705 	newObject->NextItem = NULL;
706 
707 	if (notebook == NULL){
708 		SideObjectList_ProcessNewItem(FirstObject->notebook, newObject, Path, OldObject);
709 	}
710 	else{
711 		SideObjectList_ProcessNewItem(notebook, newObject, Path, OldObject);
712 	}
713 	TRACEIT(10,"SideObjectList_CreateNewViewWithPath		ends");
714 	return 0;
715 }
716 
717 
SideObjectList_GetActiveObject(GtkNotebook * notebook,struct SideObjectList ** Object)718 int SideObjectList_GetActiveObject(GtkNotebook *notebook, struct SideObjectList **Object){
719 	TRACEIT(11,"SideObjectList_GetActiveObject		start");
720 	int currentPage = gtk_notebook_get_current_page(notebook);
721 
722 	if (currentPage == -1){
723 		currentPage = -4;
724 	}
725 	*Object = NULL;
726 
727 	struct SideObjectList *bufObject = FirstObject;
728 	do{
729 		if (currentPage == gtk_notebook_page_num(notebook,GTK_WIDGET(bufObject->VBox))){
730 			*Object = bufObject;
731 			//(*Object)->PageNumber=currentPage;
732 			TRACEIT(11,"SideObjectList_GetActiveObject		ends");
733 			return 0;
734 		}
735 		bufObject = bufObject->NextItem;
736 
737 
738 	}while(bufObject);
739 	TRACEIT(10,"SideObjectList_GetActiveObject		ends		NotFound ERROR");
740 	return -1;
741 }
742 
743 
SideObjectList_GetObjectByPageNumber(GtkNotebook * notebook,struct SideObjectList ** Object,guint Number)744 int SideObjectList_GetObjectByPageNumber(GtkNotebook *notebook, struct SideObjectList **Object, guint Number){
745 	TRACEIT(11,"SideObjectList_GetObjectByPageNumber		start");
746 	if (Object == NULL || notebook == NULL){
747 		TRACEIT(11,"SideObjectList_GetObjectByPageNumber		end, ERROR Object or Notebook NULL");
748 		return -2;
749 	}
750 	int currentPage = Number;
751 
752 	*Object = NULL;
753 
754 	struct SideObjectList *bufObject = FirstObject;
755 	if (FirstObject == NULL){
756 		TRACEIT(2,"SideObjectList_GetObjectByPageNumber		FirstObject==NULL");
757 	}
758 
759 	do{
760 		TRACEIT(12, "in do-while");
761 		if (currentPage == gtk_notebook_page_num(notebook,GTK_WIDGET(bufObject->VBox))){
762 			*Object = bufObject;
763 			TRACEIT(11,"SideObjectList_GetObjectByPageNumber		ends");
764 			return 0;
765 		}
766 		bufObject = bufObject->NextItem;
767 
768 	}while(bufObject);
769 	TRACEIT(10,"SideObjectList_GetObjectByPageNumber		ends		NotFound ERROR");
770 	return -1;
771 }
772 
773 
SideObjectList_GetObjectByChildListView(struct SideObjectList ** Object,GtkTreeView * listView,int * side)774 int SideObjectList_GetObjectByChildListView(struct SideObjectList **Object, GtkTreeView *listView, int *side){
775     // writes NULL to *Object to determine the result to be valid (in some kind)
776     // searches all the Objects till the Listview given here is the same as in one if the Objects abnd
777     // then fills the Obect and the side where side is the notebook (left or right)
778     TRACEIT(10,"SideObjectList_GetObjectByPageNumber		start");
779     if (Object == NULL || listView == NULL || side == NULL){
780         TRACEIT(2,"SideObjectList_GetObjectByPageNumber		ends, parameter NULL");
781         return -1;
782     }
783     struct SideObjectList *Objects = SideObjectList_getFirstObject();
784     if (Objects == NULL){
785         TRACEIT(2,"SideObjectList_GetObjectByPageNumber		ends, No Objects defined");
786         return -1;
787     }
788     *Object=NULL;
789     while (Objects){
790         if (Objects->listView == (GtkWidget *)listView){
791             *Object = Objects;
792             if (Objects->notebook == (GtkNotebook *)Notebooks[SIDE_LEFT]){
793                 *side = SIDE_LEFT;
794             }
795             else{
796                 *side = SIDE_RIGHT;
797             }
798             break;
799         }
800         Objects = Objects->NextItem;
801     }
802     TRACEIT(10,"SideObjectList_GetObjectByPageNumber		end");
803     return 0;
804 }
805 
806 
SideObjectList_GetObjectByChildVBox(struct SideObjectList ** Object,GtkWidget * vbox,int * side)807 int SideObjectList_GetObjectByChildVBox(struct SideObjectList **Object, GtkWidget *vbox, int *side){
808     // writes NULL to *Object to determine the result to be valid (in some kind)
809     // searches all the Objects till the vbox given here is the same as in one if the Objects abnd
810     // then fills the Obect and the side where side is the notebook (left or right)
811     //the vbox is the child which is stored in the notebook tabs
812     TRACEIT(10,"SideObjectList_GetObjectByChildVBox		start");
813     if (Object == NULL || vbox == NULL || side == NULL){
814         TRACEIT(2,"SideObjectList_GetObjectByChildVBox		ends, parameter NULL");
815         return -1;
816     }
817     struct SideObjectList *Objects = SideObjectList_getFirstObject();
818     if (Objects == NULL){
819         TRACEIT(2,"SideObjectList_GetObjectByChildVBox		ends, No Objects defined");
820         return -1;
821     }
822     *Object=NULL;
823     while (Objects){
824         if ((GtkWidget *)Objects->VBox == vbox){
825             *Object = Objects;
826             if (Objects->notebook == (GtkNotebook *)Notebooks[SIDE_LEFT]){
827                 *side = SIDE_LEFT;
828             }
829             else{
830                 *side = SIDE_RIGHT;
831             }
832             break;
833         }
834         Objects = Objects->NextItem;
835     }
836 
837     TRACEIT(10,"SideObjectList_GetObjectByChildVBox		end");
838     return 0;
839 }
840 
841 
SideObjectList_UpdateObject(struct SideObjectList * Object)842 void SideObjectList_UpdateObject(struct SideObjectList *Object){
843 	TRACEIT(10,"SideObjectList_UpdateObject		start");
844 	GString *labelText = g_string_new(Object->gstrPath->str);
845 	checkPathForLastCharOtherwise(labelText);
846 	getLastStringInPath(labelText);
847 
848 	cutStringToNChars(labelText,MAXCHARSINNOTEBOOKLABEL);
849 
850 	if ( Object->showHiddenFiles || Object->alwaysShowHiddenFiles){
851 		g_string_append(labelText, " (h)");
852 	}
853 	if (Object->iPreventFromUpdating!=0){
854         g_string_append(labelText, " (nu)");
855 	}
856 	if (Object->bReadOnly){
857 		g_string_append (labelText, " (ro)");
858 	}
859 
860 	gtk_label_set_text(GTK_LABEL(Object->label),labelText->str);
861 
862 	g_string_free(labelText,TRUE);
863 	TRACEIT(10,"SideObjectList_UpdateObject		ends");
864 }
865 
866 
SideObjectList_DeleteActiveObject(GtkNotebook * notebook)867 void SideObjectList_DeleteActiveObject(GtkNotebook *notebook){
868 	TRACEIT(10,"SideObjectList_DeleteActiveObject		start");
869 	struct SideObjectList *Object=NULL;
870 	SideObjectList_GetActiveObject(notebook, &Object);
871 
872 	if (Object == NULL){
873 		TRACEIT(10,"SideObjectList_DeleteActiveObject		ends");
874 		return;
875 	}
876 
877 	if (1>=gtk_notebook_get_n_pages(notebook)){
878 		TRACEIT(10,"SideObjectList_DeleteActiveObject		ends");
879 		return;
880 	}
881 	gtk_notebook_remove_page(notebook,gtk_notebook_get_current_page (notebook));
882 
883 	if (Object->NextItem!=NULL ){
884 		Object->NextItem->PrevItem=Object->PrevItem;
885 	}
886 	if (Object->PrevItem!=NULL){
887 		Object->PrevItem->NextItem=Object->NextItem;
888 	}
889 	else{
890 		FirstObject = Object->NextItem;
891 	}
892 	SideObjectList_ClearObject(Object);
893 	TRACEIT(10,"SideObjectList_DeleteActiveObject		ends");
894 }
895 
896 
SideObjectList_MoveActiveObject(GtkNotebook * srcnotebook,GtkNotebook * destnotebook)897 void SideObjectList_MoveActiveObject(GtkNotebook *srcnotebook, GtkNotebook *destnotebook){
898 	TRACEIT(10,"SideObjectList_MoveActiveObject		start");
899 
900 	struct SideObjectList *Object=NULL;
901 	SideObjectList_GetActiveObject(srcnotebook, &Object);
902 
903 	if (Object == NULL){
904 		TRACEIT(10,"SideObjectList_MoveActiveObject		ends");
905 		return;
906 	}
907 
908 	if (1>=gtk_notebook_get_n_pages(srcnotebook)){
909 		TRACEIT(10,"SideObjectList_MoveActiveObject		ends");
910 		return;
911 	}
912 
913 	SideObjectList_CreateNewViewWithPath(destnotebook, Object->gstrPath->str, Object);
914 	SideObjectList_DeleteActiveObject( srcnotebook);
915 
916 	TRACEIT(10,"SideObjectList_MoveActiveObject		ends");
917 	return;
918 }
919 
920 
SideObjectList_ValidateObject(struct SideObjectList * Object)921 int SideObjectList_ValidateObject(struct SideObjectList *Object){
922 	TRACEIT(10,"SideObjectList_ValidateObject		start");
923 	if (Object == NULL)	//this is possible when processItemsViaList is called from within the Fileshelf	(for copy Remove things)
924 		return -1;
925 	struct SideObjectList *buf = FirstObject;
926 
927 	while (buf != NULL){
928 		if (buf == Object){
929 			TRACEIT(10,"SideObjectList_ValidateObject		ends 1");
930 			return 1;
931 		}
932 		buf = buf->NextItem;
933 	};
934 	TRACEIT(10,"SideObjectList_ValidateObject		ends -1");
935 	return -1;
936 }
937 
938 
SideObjectList_ClearObject(struct SideObjectList * Object)939 void SideObjectList_ClearObject(struct SideObjectList *Object){
940 	TRACEIT(10,"SideObjectList_ClearObject		start");
941 
942 #ifndef NO_GIO
943 	//remove monitor
944     autoUpdateList_RemoveMonitor(Object->gstrPath->str);
945 #endif
946     calcDirectorySizeInView_closeProcess (&(Object->iRecursiveSizeCalculation), &(Object->gthreadF6Updage), &(Object->bUpdateFlag_F6), &(Object->iPreventFromUpdating), TRUE);
947 
948     SideObjectList_UnrefPreviewPixbufs (Object->listStore, COL_PREVIEW);
949 
950     if (Object->listStore != NULL){
951 		g_object_unref(Object->listStore);
952 	}
953 
954 	g_string_free(Object->gstrPath,TRUE);
955 	free(Object);
956 
957 	TRACEIT(10,"SideObjectList_ClearObject		ends");
958 }
959 
960 
SideObjectList_ClearAllForShutdown()961 void SideObjectList_ClearAllForShutdown(){
962 	TRACEIT(10,"SideObjectList_ClearAllForShutdown		start");
963 	struct SideObjectList *ThisObject;
964 
965 	while (FirstObject){
966 		ThisObject = FirstObject;
967 		FirstObject->PrevItem=NULL;
968 
969         FirstObject = FirstObject->NextItem;
970 
971 		SideObjectList_ClearObject (ThisObject);
972 	}
973 	TRACEIT(10,"SideObjectList_ClearAllForShutdown		ends");
974 	return;
975 }
976 
977 
SideObjectList_UnrefPreviewPixbufs_foreach(GtkTreeModel * model,GtkTreePath * path,GtkTreeIter * iter,void * data)978 gboolean SideObjectList_UnrefPreviewPixbufs_foreach ( GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, void *data ){
979     TRACEIT(10,"SideObjectList_UnrefPreviewPixbufs_foreach		start");
980 
981     GdkPixbuf *gdkpixBuf = NULL;
982     struct AllInformationAllUseStruct *stru = (struct AllInformationAllUseStruct *)data;
983     if (stru == NULL){
984         TRACEIT (3, "SideObjectList_UnrefPreviewPixbufs_foreach     error, parameter NULL");
985         return FALSE;
986     }
987     GList **glistPixBufs = NULL;
988     GtkListStore *listStore=NULL;
989     int iColumn = -1;
990 
991     listStore = (GtkListStore *)stru->Info_1;
992     glistPixBufs = (GList **)stru->Info_2;
993     iColumn = *(int *)stru->Info_3;
994     if (NULL == listStore || NULL == glistPixBufs || -1==iColumn){
995         TRACEIT (3, "SideObjectList_UnrefPreviewPixbufs_foreach     error, parameter NULL 2");
996         return FALSE;
997     }
998 
999     gtk_tree_model_get(model, iter, iColumn, &gdkpixBuf, -1);
1000     if (NULL != gdkpixBuf){
1001         *glistPixBufs = g_list_prepend (*glistPixBufs, gdkpixBuf);
1002         gtk_list_store_set (listStore, iter,iColumn, NULL, -1);
1003     }
1004 
1005     TRACEIT(10,"SideObjectList_UnrefPreviewPixbufs_foreach		end");
1006     return FALSE;   //false = continue
1007 }
1008 
1009 
1010 
SideObjectList_UnrefPreviewPixbufs(GtkListStore * listStore,int iColumn)1011 void SideObjectList_UnrefPreviewPixbufs(GtkListStore *listStore, int iColumn){
1012     //unrefers the pixbufs of the listview if they are set
1013     TRACEIT(10,"SideObjectList_ClearAllForShutdown		start");
1014     GList *glistPixBufs = NULL;
1015     GList *glistBuf = NULL;
1016 
1017     if (listStore == NULL){
1018         return;
1019     }
1020 
1021     struct AllInformationAllUseStruct stru;
1022 
1023     stru.Info_1 = (void *)listStore;
1024     stru.Info_2 = (void *)&glistPixBufs;
1025     stru.Info_3 = (void *)&iColumn;
1026 
1027     gtk_tree_model_foreach ((GtkTreeModel *)listStore, (GtkTreeModelForeachFunc)SideObjectList_UnrefPreviewPixbufs_foreach, &stru);
1028 
1029     if (NULL != glistPixBufs){
1030         glistBuf = glistPixBufs;
1031         while (glistBuf){
1032             g_object_unref (glistBuf->data);    //we need
1033             g_object_unref (glistBuf->data);    //two unrefs for the pixbufs, because it seems that the liststore increases the reference too, but does not free it
1034             glistBuf = glistBuf->next;
1035         }
1036         g_list_free (glistPixBufs);
1037     }
1038 
1039     TRACEIT(10,"SideObjectList_ClearAllForShutdown		ends");
1040 }
1041 
1042 /////////////////////////////////////////////////////////////////////////////////////////////////
1043 ///////////////// UPDATE LIST /////////////////////////////////////////////////////////////////
1044 /////////////////////////////////////////////////////////////////////////////////////////////////
1045 // Be carefull changing this, because this list is also used in other terms (e.g. when marking all items which are of the same type as the already marked one ( markItemsWithSameType )
updateList_addItem(struct updateList ** itemlist,char * Name,char * Path,GtkTreeRowReference * rowref,int found)1046 void updateList_addItem(struct updateList **itemlist, char *Name, char *Path, GtkTreeRowReference  *rowref, int found){
1047 	TRACEIT(10,"updateList_addItem		start");
1048 	if(itemlist == NULL){
1049 		TRACEIT(2,"updateList_addItem		ends, itemlist parameter NULL");
1050 		return;
1051 	}
1052     struct updateList *newItem=NULL;
1053     struct updateList *bufItem=*itemlist;
1054 
1055     newItem = malloc(sizeof(struct updateList) );
1056     if (newItem == NULL){
1057         TRACEIT(2,"updateList_addItem		unable to allocate memory");
1058 		return;
1059     }
1060 
1061     newItem->gstrName = NULL;
1062     newItem->gstrPath = NULL;
1063     newItem->rowref = NULL;
1064 
1065     if (Name)
1066         newItem->gstrName = g_string_new(Name);
1067     if (Path)
1068         newItem->gstrPath = g_string_new(Path);
1069     if (rowref)
1070         newItem->rowref = rowref;
1071     newItem->found = found;
1072     newItem->NextItem = NULL;
1073     newItem->PrevItem = NULL;
1074 
1075     if (*itemlist == NULL){
1076         *itemlist = newItem;
1077 
1078 		TRACEIT(10,"updateList_addItem		end");
1079         return;
1080     }
1081     while (bufItem->NextItem){
1082         bufItem = bufItem->NextItem;
1083     }
1084     bufItem->NextItem = newItem;
1085     newItem->PrevItem = bufItem;
1086 	TRACEIT(10,"updateList_addItem		end");
1087     return;
1088 }
1089 
1090 
updateList_getFirstItem(struct updateList ** itemlist)1091 void updateList_getFirstItem(struct updateList **itemlist){
1092 	TRACEIT(10,"updateList_getFirstItem		start");
1093     if (itemlist == NULL || *itemlist == NULL){
1094 		TRACEIT(2,"updateList_getFirstItem		end, itemlist invalid");
1095         return;
1096 	}
1097     while((*itemlist)->PrevItem){
1098         *itemlist = (*itemlist)->PrevItem;
1099     }
1100 	TRACEIT(10,"updateList_getFirstItem		end");
1101 }
1102 
1103 
updateList_deleteList(struct updateList ** itemlist)1104 void updateList_deleteList(struct updateList **itemlist){
1105 	TRACEIT(10,"updateList_deleteList		start");
1106     if (itemlist == NULL || *itemlist == NULL){
1107 		TRACEIT(2,"updateList_deleteList		end, itemlist invalid");
1108         return;
1109 	}
1110     updateList_getFirstItem(itemlist);
1111 
1112     struct updateList *bufItem=*itemlist;
1113     struct updateList *bufItem2 = NULL;
1114 
1115     while (bufItem){
1116         if (bufItem->gstrName)
1117             g_string_free(bufItem->gstrName,TRUE);
1118         if (bufItem->gstrPath)
1119             g_string_free(bufItem->gstrPath, TRUE);
1120         if (bufItem->rowref)
1121             gtk_tree_row_reference_free(bufItem->rowref);
1122 
1123         bufItem2 = bufItem;
1124         bufItem = bufItem->NextItem;
1125         free (bufItem2);
1126     }
1127     *itemlist=NULL;
1128 	TRACEIT(10,"updateList_deleteList		end");
1129 	return;
1130 }
1131 
1132 
updateList_checkForItem(struct updateList ** itemlist,char * Name)1133 GtkTreeRowReference *updateList_checkForItem(struct updateList **itemlist, char *Name){
1134 	TRACEIT(10,"updateList_checkForItem		start");
1135     if (itemlist == NULL || *itemlist == NULL){
1136 		TRACEIT(2,"updateList_checkForItem		end, itemlist invalid");
1137         return NULL;
1138 	}
1139     updateList_getFirstItem(itemlist);
1140     struct updateList *bufItem=*itemlist;
1141 
1142     while (bufItem){
1143         if (0 ==strcmp(bufItem->gstrName->str, Name)){
1144                 bufItem->found = 1;
1145                 return bufItem->rowref;
1146         }
1147         bufItem = bufItem->NextItem;
1148     }
1149 	TRACEIT(10,"updateList_checkForItem		end");
1150     return NULL;
1151 }
1152 
1153 
updateList_checkForItem_NoRef(struct updateList ** itemlist,char * Name)1154 int updateList_checkForItem_NoRef(struct updateList **itemlist, char *Name){
1155 	TRACEIT(10,"updateList_checkForItem_NoRef		start");
1156     if (itemlist == NULL || *itemlist == NULL){
1157 		TRACEIT(2,"updateList_checkForItem_NoRef		end, itemlist invalid");
1158         return -1;
1159 	}
1160     updateList_getFirstItem(itemlist);
1161     struct updateList *bufItem=*itemlist;
1162 
1163     while (bufItem){
1164         if (0 ==strcmp(bufItem->gstrName->str, Name)){
1165                 bufItem->found = 1;
1166 				TRACEIT(10,"updateList_checkForItem_NoRef		end, found");
1167                 return 1;
1168         }
1169         bufItem = bufItem->NextItem;
1170     }
1171 	TRACEIT(10,"updateList_checkForItem_NoRef		end, not found");
1172     return 0;
1173 }
1174