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 <glib.h> //g_thread_init
23 #include <glib/gstdio.h> //g_rename
24 #include <gtk/gtk.h>
25 #ifndef NO_GIO
26 #include <gio/gio.h> //gfile, monitor, ...
27 #endif
28 #include <gdk/gdkkeysyms.h>
29 #include <stdlib.h>
30 #include <string.h>
31 #include <dirent.h> //Verzeichnis Zeiger und DIR - Struktur
32 #include <unistd.h> //e.g. chdir, usleep
33 #include <errno.h>
34
35 #include "globalDefinitions.h"
36 #include "listitems.h"
37 #include "helpers.h"
38 #include "confighandling.h"
39 #include "confighandlingDefinitions.h"
40 #include "Lists.h"
41 #include "threads.h"
42 #include "userdata.h"
43 #include "myfm.h"
44 #include "fileshelf.h"
45 #include "mytrace.h"
46 #include "internals.h"
47 #include "userdata.h"
48 #include "CommandParser.h"
49 #include "DragnDrop.h"
50 #include "automaticUpdate.h"
51 #include "SearchFor.h"
52
53 #include "CreateUsercommandDialog.h"
54 #include "propertyPage.h"
55
56 #include "allInclude.h"
57
58 static gint delete_Event(GtkWidget *widget, GdkEvent event, gpointer daten);
59 static void end (GtkWidget *widget, GdkEvent event, gpointer daten);
60 int predefine_Main_Objects();
61 int makeLists(struct SideObjectList *Object, struct updateList **itemlist);
62 void connectListToView(struct SideObjectList *Object);
63 void doActionsForNewView (struct SideObjectList *Object);
64 void disconnectListAndView (struct SideObjectList *Object);
65 void bringAllToTheRightOrder();
66 void onePathChanged(GtkEntry *entry, gpointer g);
67 gboolean oneKeyPressed_PathEntry(GtkWidget *widget, GdkEventKey *event, gpointer data);
68 int checkDirectory(struct SideObjectList *Object, GString *NewPath);
69 void oneColumnWasClicked(GtkTreeViewColumn *Column, gpointer data);
70 void formatPathString(GString *NewPath);
71 void oneOnePathUpButtonClicked(GtkButton *button, gpointer data);
72 void oneSelectionChanged(GtkTreeSelection *treeselection, gpointer data);
73 gboolean oneKeyPressedInView(GtkWidget *widget, GdkEventKey *event, gpointer data);
74 static void deleteSelectedRowsHelper(GtkTreeModel *model,GtkTreePath *path,GtkTreeIter *iter,gpointer data);
75 static void sizeOfSelected_Helper (GtkTreeModel *model,GtkTreePath *path,GtkTreeIter *iter,gpointer data);
76 gboolean oneContextMenuReplied(GtkWidget *treeview, gpointer data);
77 gboolean oneNoteBookContextMenuReplied(GtkWidget *treeview, gpointer data);
78 void openContextMenu(GtkWidget *treeview, GdkEventButton *event, gpointer data);
79 void mayDeleteSelectedRows(GtkWidget *menuitem, gpointer data);
80 void editItems(GtkWidget *menuitem, gpointer data);
81 gboolean onePageSwitched(GtkNotebook *notebook, GtkNotebookPage *page, guint page_num, gpointer user_data);
82 void openTabContextMenu(GtkWidget *notebook, GdkEventButton *event, gpointer data);
83 void onePageAddedToNotebook(GtkNotebook *notebook, GtkWidget *child, guint page_num, gpointer data);
84 struct SideObjectList *getOtherSideObject(struct SideObjectList *ThisSideObject);
85 void updatePathEntryBox(GtkNotebook *notebook, guint num);
86 void loadThings();
87 void loadStartPathes();
88 void savePathes();
89 void saveThings();
90 void loadSize();
91 void saveSize();
92 void getStandardStartDirectory(GString *gstrCommand);//, GString *gstrCommandName);
93 void addNewPage(GtkWidget *menuitem, gpointer data);
94 void closeActivePage(GtkWidget *menuitem, gpointer data);
95 void dublicateActivePage(GtkWidget *menuitem, gpointer data);
96 void moveActivePage(GtkWidget *menuitem, gpointer data);
97 void copyActivePage(GtkWidget *menuitem, gpointer data);
98 void AlwaysShowHiddenfilesInAllTabs();
99 void ChangePreviewState(GtkWidget *menuitem, gpointer data);
100 void ChangeReadOnlyState (GtkWidget *menuitem, gpointer data);
101 void showHiddenFilesInActivePage(GtkWidget *menuitem, gpointer data);
102 void addNewPageFromBookmarks(GtkWidget *menuitem, struct UserDataList *UserDataListItem);
103 void goToFromBookmarks(GtkWidget *menuitem, struct UserDataList *UserDataListItem);
104 int AddPathesToNotebook( GtkNotebook *Notebook, GString *gstrPathes, int AllreadyStarted);
105 static void getSizeOfSelectedItemsRecursive_getItems (GtkTreeModel *model,GtkTreePath *path,GtkTreeIter *iter,gpointer data);
106 void CopyPasteCreateList_SideObject(struct SideObjectList *Object, int CopyOrMove);
107 void CopyPasteProcessList_SideObject(struct SideObjectList *Object);
108 void defineGlobals();
109 void clearUpGobals();
110 void loadGlobals();
111 int mysortfunctionforNamesLeft(GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer userdata);
112 void ShowSplashScreen();
113 void DestroySplashScreen();
114 void MenuAddToNewFileshelf(GtkWidget *menuitem, gpointer data);
115 void searchStringInAndHighlightItems_WraperforSideObject(GtkWidget *menuitem, gpointer data);
116 void copyToOtherPannel(GtkWidget *menuitem, gpointer data);
117 void moveToOtherPannel(GtkWidget *menuitem, gpointer data);
118 void renameItems(GtkWidget *menuitem, gpointer data);
119 void startItemsWithUserCommand_WraperforSideObject(GtkWidget *menuitem, gpointer data);
120 void oneRowActivated_SideObjectWrap(GtkTreeView *treeview, GtkTreePath *TreePath, GtkTreeViewColumn *col, gpointer data);
121 void internalSavePatheAsBookmark_wrap(GtkWidget *menuitem, gpointer data);
122 void mayNewDirectory(GtkWidget *menuitem, gpointer data);
123 int addPointsToSideView(char *cpPath, GtkListStore *listStore, const char *cpColorDir);
124 void internal_startPropPage (GtkWidget *menuitem, gpointer data);
125 gboolean IntervallTimer_SaveSession (gpointer data);
126
127 gint glistComparePointer (gconstpointer a, gconstpointer b);
128
129
130 const char *Names[] = { "preview",
131 "filename",
132 "size",
133 "owner",
134 "group",
135 "perm.",
136 "accessed",
137 "changed",
138 "target",
139 "type",
140 "TimeStamp_1",
141 "TimeStamp_2",
142 "type_d",
143 "Color"
144 };
145 #define COLTYPES G_TYPE_OBJECT,\
146 G_TYPE_STRING,\
147 G_TYPE_UINT64,\
148 G_TYPE_INT,\
149 G_TYPE_INT,\
150 G_TYPE_STRING,\
151 G_TYPE_STRING,\
152 G_TYPE_STRING,\
153 G_TYPE_STRING,\
154 G_TYPE_STRING,\
155 G_TYPE_INT,\
156 G_TYPE_INT,\
157 G_TYPE_INT,\
158 G_TYPE_STRING
159
160 GtkWindow *win;
161 GtkWindow *Splashwin;
162 GtkWidget *HPanedLeftRight;
163 GtkWidget *VPanedForFileShelf;
164 GtkWidget *Notebooks[SIDE_BOTH];
165 GtkWidget *PathEntryBox[SIDE_BOTH];
166 GtkVBox *VBox[SIDE_BOTH];
167 GtkHBox *HBoxForButtonsAndPathEntry[SIDE_BOTH];
168 GtkButton *OnePathUpButton[SIDE_BOTH];
169
170
171 struct CopyReMoveList *g_CopyPasteShortcutStruct;
172
173 extern int g_iFileshelfIsInitialized;
174 extern GtkNotebook *g_FileShelfNotebook;
175 extern struct FileShelfObjectList *FirstFileShelfObject;
176
177 //extern struct _UserCommandList *g_UserCommandsForMarkedItems; //save a list of usercommands which have the target of the marked items ending
178 extern struct UserDataList *g_UserDataList; //used wthin the contextmenu
179 extern struct _OptionsList *g_OptionsList;
180 extern struct _UserCommandList *g_UserCommandList;
181
182 #ifndef NO_GIO
183 extern struct autoUpdateList *g_listAutoUpdateList;
184 #endif
185
186 int gint_Starting; //is 1 while startprocess. when program is in mainloop, its 0
187
188 int g_int_AlwaysShowHidden;
189
190 GtkTextBuffer *g_TextBuffer_CommandHistory;
191
192 struct SearchParams *gpSearchParamStru;
193
194
195
main(int argc,char * argv[])196 int main(int argc, char *argv[]){
197 TRACEIT(10,"main start");
198 gint_Starting = 1;
199
200 g_thread_init(NULL);
201 gdk_threads_init();
202
203
204 gtk_init(&argc, &argv);
205
206 //ShowSplashScreen();
207
208 win = g_object_new(GTK_TYPE_WINDOW,
209 "title",MYNAME,
210 "default-width", 800,
211 "default-height", 640,
212 "resizable",TRUE,
213 "border-width",5,
214 NULL);
215 //gtk_window_maximize(win);
216
217 // Add Icon to Window
218 AddMyIconsToWindow(win);
219
220 //Set some global variables
221 defineGlobals();
222
223 //Predefine Objects
224 predefine_Main_Objects();
225
226 //some Signals
227 g_signal_connect (win, "delete-event",G_CALLBACK(delete_Event),NULL);
228 g_signal_connect (win, "destroy", G_CALLBACK(end),NULL);
229
230 g_signal_connect (PathEntryBox[SIDE_LEFT], "activate",G_CALLBACK(onePathChanged),GINT_TO_POINTER(SIDE_LEFT));
231 g_signal_connect (PathEntryBox[SIDE_RIGHT], "activate",G_CALLBACK(onePathChanged),GINT_TO_POINTER(SIDE_RIGHT));
232 g_signal_connect (PathEntryBox[SIDE_LEFT], "key-press-event",G_CALLBACK(oneKeyPressed_PathEntry),GINT_TO_POINTER(SIDE_LEFT));
233 g_signal_connect (PathEntryBox[SIDE_RIGHT], "key-press-event",G_CALLBACK(oneKeyPressed_PathEntry),GINT_TO_POINTER(SIDE_RIGHT));
234
235 g_signal_connect (OnePathUpButton[SIDE_LEFT],"clicked",G_CALLBACK(oneOnePathUpButtonClicked),GINT_TO_POINTER(SIDE_LEFT));
236 g_signal_connect (OnePathUpButton[SIDE_RIGHT],"clicked",G_CALLBACK(oneOnePathUpButtonClicked),GINT_TO_POINTER(SIDE_RIGHT));
237
238 g_signal_connect (Notebooks[SIDE_LEFT],"page-added",G_CALLBACK(onePageAddedToNotebook),GINT_TO_POINTER(SIDE_LEFT));
239 g_signal_connect (Notebooks[SIDE_RIGHT],"page-added",G_CALLBACK(onePageAddedToNotebook),GINT_TO_POINTER(SIDE_RIGHT));
240 g_signal_connect (Notebooks[SIDE_LEFT],"button-press-event",G_CALLBACK(oneMouseButtonPressedOnNotebook),GINT_TO_POINTER(SIDE_LEFT));
241 g_signal_connect (Notebooks[SIDE_RIGHT],"button-press-event",G_CALLBACK(oneMouseButtonPressedOnNotebook),GINT_TO_POINTER(SIDE_RIGHT));
242 g_signal_connect (Notebooks[SIDE_LEFT],"popup-menu",G_CALLBACK(oneNoteBookContextMenuReplied),GINT_TO_POINTER(SIDE_LEFT));
243 g_signal_connect (Notebooks[SIDE_RIGHT],"popup-menu",G_CALLBACK(oneNoteBookContextMenuReplied),GINT_TO_POINTER(SIDE_RIGHT));
244 g_signal_connect (Notebooks[SIDE_LEFT],"key-press-event",G_CALLBACK(oneKeyPressedOnNotebook),GINT_TO_POINTER(SIDE_LEFT));
245 g_signal_connect (Notebooks[SIDE_RIGHT],"key-press-event",G_CALLBACK(oneKeyPressedOnNotebook),GINT_TO_POINTER(SIDE_RIGHT));
246 g_signal_connect (Notebooks[SIDE_LEFT],"switch-page",G_CALLBACK(onePageSwitched),GINT_TO_POINTER(SIDE_LEFT));
247 g_signal_connect (Notebooks[SIDE_RIGHT],"switch-page",G_CALLBACK(onePageSwitched),GINT_TO_POINTER(SIDE_RIGHT));
248
249 //We want to see the things we have created
250 bringAllToTheRightOrder();
251
252 loadThings();
253
254 //gtk_window_set_opacity (win, 0.8);
255 //DestroySplashScreen();
256
257
258 gtk_widget_show_all (GTK_WIDGET (win));
259
260 //set the position of the devider. This should make sure that the divider will not change its position when some view changes, e.g. if th user changes the directory
261 //its important that this is done after we have shown all widgets, otherwise they will not know their size
262 int iNewPosition;
263 g_object_get ( (gpointer) HPanedLeftRight,"max-position", &iNewPosition, NULL);
264 gtk_paned_set_position ((GtkPaned *)HPanedLeftRight, iNewPosition/2);
265
266
267 //prepare the timer for saving the session after a specific intervall
268 int iSaveSessionMinutes;
269 iSaveSessionMinutes = OptionsList_GetIntValueByID (g_OptionsList, SAVESESSIONMINUTESTYPES, DEFAULT_SAVESESSIONMINUTES);
270 if (iSaveSessionMinutes > 0){
271 g_timeout_add_seconds (iSaveSessionMinutes*60, (GSourceFunc)( IntervallTimer_SaveSession), NULL);
272 }
273
274 //MainLOOP
275 TRACEIT(10,"main-mainloop start");
276 gint_Starting=0;
277 myWrap_gdk_threads_enter("main");
278 gtk_main();
279 //printf("after big MAIN\n");
280 myWrap_gdk_threads_leave("main");
281
282 //Let us forget this things!
283 clearUpGobals();
284
285 #ifdef MYGSTRINGWATCH
286 my_g_gstring_exit();
287 #endif
288
289 TRACEIT(10,"main ends");
290 return 0;
291 }
292
293
delete_Event(GtkWidget * widget,GdkEvent event,gpointer daten)294 static gint delete_Event (GtkWidget *widget, GdkEvent event, gpointer daten){
295 TRACEIT(10,"main delete_Event (noerror) (event: delete-event)");
296 saveThings();
297 return FALSE;
298 }
299
300
end(GtkWidget * widget,GdkEvent event,gpointer daten)301 static void end (GtkWidget *widget, GdkEvent event, gpointer daten){
302 // g_printf("end\n");
303 TRACEIT(10,"main end (noerror) (event: destroy)");
304 gtk_main_quit();
305
306 }
307
308
ShowSplashScreen()309 void ShowSplashScreen(){
310 //funktioniert nicht, weiss aber nicht warum!
311 GString *home = g_string_sized_new(20);
312 struct myFiles_struct *filestru;
313
314 getHomeDirectory(home);
315 checkPathForLastChar(home);
316 g_string_append(home, SPASHIMAGENAME);
317 filestru = myFiles_openFile(home->str, "r");
318 printf("filename: %s\n",home->str);
319 if (filestru){
320 //gtk_window_set_auto_startup_notification(FALSE);
321
322 myFiles_closeFile(filestru);
323 GtkWidget *image = gtk_image_new_from_file (home->str);
324 Splashwin = g_object_new(GTK_TYPE_WINDOW,
325 /*"allow-grow",FALSE,*/
326 /*"allow-shrink",FALSE,*/
327 /*"decorated",FALSE,*/
328 /*"default-width", 800,*/
329 /*"default-height", 640,*/
330 "deletable", FALSE,
331 /*"opacity",0.4,*/
332 "resizable",FALSE,
333 /*"skip-pager-hint",TRUE,*/
334 /*"skip-taskbar-hint",TRUE,*/
335 /*"title",MYNAME,*/
336 /*"border-width",5,*/
337 "type_hint",GDK_WINDOW_TYPE_HINT_SPLASHSCREEN,
338 NULL);
339 //gtk_window_set_type_hint(Splashwin,GDK_WINDOW_TYPE_HINT_SPLASHSCREEN);
340 printf("File found\n");
341 gtk_container_add (GTK_CONTAINER(Splashwin),image);
342
343 gtk_widget_show_all (GTK_WIDGET (Splashwin));
344
345 }
346 if (home)
347 g_string_free(home, TRUE);
348 }
349
350
DestroySplashScreen()351 void DestroySplashScreen(){
352 gtk_widget_destroy(GTK_WIDGET(Splashwin));
353 //gtk_window_set_auto_startup_notification(TRUE);
354 }
355
356
defineGlobals()357 void defineGlobals(){
358 g_CopyPasteShortcutStruct = NULL;
359
360 g_int_AlwaysShowHidden=0;
361
362 g_iFileshelfIsInitialized = 0;
363 g_FileShelfNotebook = NULL;
364 FirstFileShelfObject = NULL;
365
366 //create a TextBuffer which holds the commands send to the shell by catseye
367 //and add an tag, wich will be refered to when an error occured while processing a command
368 //the text in the error string will be displayed in the color specified here ( "myWrapOf__g_spawn_command_line_sync" )
369 g_TextBuffer_CommandHistory = gtk_text_buffer_new(NULL);
370 gtk_text_buffer_create_tag (g_TextBuffer_CommandHistory, "error", "foreground", "red", NULL);
371
372
373 //used in the SearchForDialog, we want it to now the last searched text
374 gpSearchParamStru = NULL;
375
376 #ifndef NO_GIO
377 g_listAutoUpdateList=NULL;
378 #endif
379 }
380
381
clearUpGobals()382 void clearUpGobals(){
383 //please free all memory in here (global used varaibles)
384 TRACEIT(10,"clearUpGobals start");
385
386
387 //MIND!! autoUpdateList_deleteList has to be before SideObjectList_ClearAllForShutdown, because SideObjectList_ClearAllForShutdown
388 //will call a threaded function to delete the monitors but nobody waits for them to finish, leading to memory leaks
389 //while autoUpdateList_deleteList is synchrone
390 #ifndef NO_GIO
391 //free autoUpdateList
392 autoUpdateList_deleteList ();
393 #endif
394
395 SideObjectList_ClearAllForShutdown();
396
397 //freeTypesAndUserProgrammArrays();
398 //free memory used in contextmenu for usercommands
399 if (NULL != g_UserDataList){
400 UserDataList_DeleteList(&g_UserDataList);
401 //g_UserDataList = NULL; //this is allready done from deleteList function
402 }
403 //free the things the xml parser may have stored in his lists
404 configFileHandling_clearForShutdown();
405
406 if (g_CopyPasteShortcutStruct != NULL){
407 CopyReMoveList_DeleteList(g_CopyPasteShortcutStruct);
408 g_CopyPasteShortcutStruct = NULL;
409 }
410
411 //used in the SearchForDialog, we want it to now the last searched text
412 if (gpSearchParamStru)
413 searchParams_delete(gpSearchParamStru);
414
415 //Free the fileshelfthings
416 DeleteFileshelfThings();
417
418
419
420 TRACEIT(10,"clearUpGobals end");
421 }
422
423
IntervallTimer_SaveSession(gpointer data)424 gboolean IntervallTimer_SaveSession (gpointer data){
425 TRACEIT(10,"IntervallTimer_SaveSession start");
426
427 //both, this timer and the close event are signals called within the mainloop and are therefor threadsave, live's easy
428 saveThings ();
429
430 TRACEIT(10,"IntervallTimer_SaveSession end");
431 return TRUE;
432 }
433
434
saveThings()435 void saveThings(){
436 TRACEIT(10,"saveThings start");
437 GString *gstrBuf = g_string_sized_new(20);
438 if (0 == myFiles_SaveFileSimpleSave("Cat'sEyE save file, please do not touch unless you really know what to do.\n", "w+")){
439 saveSize();
440 savePathes();
441 saveFileShelfs();
442 if (1==g_int_AlwaysShowHidden){
443 g_string_printf(gstrBuf, "%s%strue\n",ALWAYS_SHOW_HIDDEN,TYPESEPARATOR);
444 myFiles_SaveFileSimpleSave(gstrBuf->str, "a+");
445 }
446 }
447 g_string_free(gstrBuf, TRUE);
448 TRACEIT(10,"saveThings ends");
449 }
450
451
saveSize()452 void saveSize(){
453 TRACEIT(10,"saveSize start");
454 GString *gstrBuf = g_string_sized_new (20);
455 gint width;
456 gint height;
457
458 gtk_window_get_size (win, &width, &height);
459
460 g_string_printf(gstrBuf, "%s%s%d\n", LASTSIZE_X, TYPESEPARATOR, width);
461 myFiles_SaveFileSimpleSave(gstrBuf->str, "a+");
462
463 g_string_printf(gstrBuf, "%s%s%d\n", LASTSIZE_Y, TYPESEPARATOR, height);
464 myFiles_SaveFileSimpleSave(gstrBuf->str, "a+");
465
466 g_string_free (gstrBuf, TRUE);
467 TRACEIT(10,"saveSize end");
468 return;
469 }
470
471
loadThings()472 void loadThings(){
473 TRACEIT(10,"loadThings start");
474
475 configFileHandling_Init();
476
477 loadGlobals();
478 loadStartPathes();
479 loadFileShelfs(NULL);
480 loadSize ();
481 TRACEIT(10,"loadThings ends");
482 }
483
loadSize()484 void loadSize(){
485 TRACEIT(10,"loadSize start");
486 GString *gstrBuf=NULL;
487
488 int iLastSize_X=0;
489 int iLastSize_Y=0;
490
491 gstrBuf = g_string_sized_new(10);
492 if (1 == myFiles_SaveFileSimpleGetValue(LASTSIZE_X, gstrBuf)){
493 sscanf (gstrBuf->str, "%d", &iLastSize_X);
494 }
495 if (1 == myFiles_SaveFileSimpleGetValue(LASTSIZE_Y, gstrBuf)){
496 sscanf (gstrBuf->str, "%d", &iLastSize_Y);
497 }
498
499 if (iLastSize_X!=0 && iLastSize_Y!=0){
500 gtk_window_resize (win, iLastSize_X, iLastSize_Y);
501 }
502
503 g_string_free(gstrBuf, TRUE);
504 TRACEIT(10,"loadSize end");
505 }
506
loadGlobals()507 void loadGlobals(){
508 TRACEIT(10,"loadGlobals start");
509 GString *gstrBuf=NULL;
510
511 //load from savefile:
512 gstrBuf = g_string_sized_new(10);
513 if (1 == myFiles_SaveFileSimpleGetValue(ALWAYS_SHOW_HIDDEN, gstrBuf)){
514 if (0==strcmp(gstrBuf->str, "true")){
515 g_int_AlwaysShowHidden=1;
516 }
517 else{
518 g_int_AlwaysShowHidden=0;
519 }
520 }
521 g_string_free(gstrBuf, TRUE);
522
523 //used in the SearchForDialog, we want it to now the last searched text
524 gpSearchParamStru = searchParams_new();
525
526 TRACEIT(10,"loadGlobals end");
527 }
528
529
savePathes()530 void savePathes(){
531 TRACEIT(10,"savePathes start");
532 GString *PathesLeft = g_string_sized_new(10);
533 GString *StartPath = g_string_sized_new(10);
534
535 configFileHandling_loadConfigFile( FALSE, FALSE );
536 const char *ccpSavePathesOnExit = OptionsList_getValueByID (g_OptionsList, SAVEPATHESONEXIT);
537
538 if (ccpSavePathesOnExit != NULL){
539 g_string_assign(StartPath, ccpSavePathesOnExit);
540 cutSpacesFromGString(StartPath);
541 if (strcmp (StartPath->str,"true") == 0 || strcmp (StartPath->str,"True") == 0 || strcmp (StartPath->str,"TRUE") == 0){
542 struct SideObjectList *Object = NULL;
543 guint i;
544 int i_NoteBookTabs;
545 guint guint_NoteBookTabs=0;
546
547
548 //save left pathes and attributes
549 i_NoteBookTabs = gtk_notebook_get_n_pages ((GtkNotebook *)Notebooks[SIDE_LEFT]);
550 if (i_NoteBookTabs > 0){
551 guint_NoteBookTabs = i_NoteBookTabs;
552 }
553 for (i=0; i<guint_NoteBookTabs; i++){
554 if ( 0== SideObjectList_GetObjectByPageNumber((GtkNotebook *)Notebooks[SIDE_LEFT], &Object, i)){
555 //PATH
556 g_string_printf(PathesLeft, LASTPATHLEFTID, i);
557 g_string_append(PathesLeft,TYPESEPARATOR);
558 g_string_append(PathesLeft,Object->gstrPath->str);
559 myFiles_SaveFileSimpleSave(PathesLeft->str, "a+");
560 //HIDDEN FLAG
561 if (Object->showHiddenFiles){
562 g_string_printf(PathesLeft, LASTPATHLEFTHIDDENID, i);
563 g_string_append(PathesLeft,TYPESEPARATOR);
564 g_string_append(PathesLeft,"true");
565 myFiles_SaveFileSimpleSave(PathesLeft->str, "a+");
566 }
567 //PREVIEW
568 if (Object->iPreview > 0){
569 g_string_printf(PathesLeft, LASTPATHLEFTPREVIEWID, i);
570 g_string_append(PathesLeft,TYPESEPARATOR);
571 g_string_append(PathesLeft,"true");
572 myFiles_SaveFileSimpleSave(PathesLeft->str, "a+");
573 }
574 //READONLY
575 if (Object->bReadOnly == TRUE){
576 g_string_printf(PathesLeft, LASTPATHLEFTREADONLYID, i);
577 g_string_append(PathesLeft, TYPESEPARATOR);
578 g_string_append(PathesLeft, "true");
579 myFiles_SaveFileSimpleSave(PathesLeft->str, "a+");
580 }
581 }
582 }
583 //save right pathes and attributes
584 guint_NoteBookTabs=0;
585 i_NoteBookTabs = gtk_notebook_get_n_pages ((GtkNotebook *)Notebooks[SIDE_RIGHT]);
586 if (i_NoteBookTabs > 0){
587 guint_NoteBookTabs = i_NoteBookTabs;
588 }
589 for (i=0; i<guint_NoteBookTabs; i++){
590 if ( 0== SideObjectList_GetObjectByPageNumber((GtkNotebook *)Notebooks[SIDE_RIGHT], &Object, i)){
591 //PATH
592 g_string_printf(PathesLeft, LASTPATHRIGHTID, i);
593 g_string_append(PathesLeft,TYPESEPARATOR);
594 g_string_append(PathesLeft,Object->gstrPath->str);
595 myFiles_SaveFileSimpleSave(PathesLeft->str, "a+");
596 //HIDDEN FLAG
597 if (Object->showHiddenFiles){
598 g_string_printf(PathesLeft, LASTPATHRIGHTHIDDENID, i);
599 g_string_append(PathesLeft,TYPESEPARATOR);
600 g_string_append(PathesLeft,"true");
601 myFiles_SaveFileSimpleSave(PathesLeft->str, "a+");
602 }
603 //PREVIEW
604 if (Object->iPreview > 0){
605 g_string_printf(PathesLeft, LASTPATHRIGHTPREVIEWID, i);
606 g_string_append(PathesLeft,TYPESEPARATOR);
607 g_string_append(PathesLeft,"true");
608 myFiles_SaveFileSimpleSave(PathesLeft->str, "a+");
609 }
610 //READONLY
611 if (Object->bReadOnly == TRUE){
612 g_string_printf(PathesLeft, LASTPATHRIGHTREADONLYID, i);
613 g_string_append(PathesLeft, TYPESEPARATOR);
614 g_string_append(PathesLeft, "true");
615 myFiles_SaveFileSimpleSave(PathesLeft->str, "a+");
616 }
617 }
618 }
619 }
620
621 }
622
623 g_string_free(PathesLeft,TRUE);
624 g_string_free(StartPath,TRUE);
625 TRACEIT(10,"savePathes ends");
626 }
627
628
loadStartPathes()629 void loadStartPathes(){
630 TRACEIT(10,"loadStartPathes start");
631 int done_pathloaded=0;
632 int LoadLastPathes = 0;
633 int i=0;
634 int firstItem=0;
635 struct SideObjectList *Object=NULL;
636 int iReUpdate=0;
637
638 GString *StartPath = g_string_sized_new(30);
639 GString *gstrIdentifier = g_string_sized_new(20);
640 GString *gstrLastPathesLeft = g_string_sized_new(50);
641 GString *gstrLastPathesRight = g_string_sized_new(50);
642 GString *gstrStandardDirCommand = g_string_sized_new(10);
643 GString *gstrStandardDirCommandName = g_string_sized_new(10);
644
645 struct myFiles_struct *Savefilestru=NULL;
646 configFileHandling_loadConfigFile( FALSE, FALSE );
647 const char *ccpSavePathesOnExit = OptionsList_getValueByID (g_OptionsList, SAVEPATHESONEXIT);
648
649 //fall back, no configfile found, load homedir and exit
650 if (g_OptionsList == NULL){
651 TRACEIT(8,"loadStartPathes configFile NOT found");
652
653 getStandardStartDirectory(gstrStandardDirCommand);//, gstrStandartDirCommandName);
654 SideObjectList_StartWithObjectList((GtkNotebook *)Notebooks[SIDE_LEFT], gstrStandardDirCommand->str);
655 SideObjectList_CreateNewViewWithPath((GtkNotebook *)Notebooks[SIDE_RIGHT], gstrStandardDirCommand->str,NULL);
656
657 g_string_free(StartPath,TRUE);
658 g_string_free(gstrLastPathesLeft,TRUE);
659 g_string_free(gstrLastPathesRight,TRUE);
660 g_string_free(gstrStandardDirCommand,TRUE);
661 g_string_free(gstrStandardDirCommandName,TRUE);
662 g_string_free(gstrIdentifier, TRUE);
663 TRACEIT(10,"loadStartPathes ends");
664 return;
665 }
666
667 //check for 'save pathes on exit' property in configfile
668 if (ccpSavePathesOnExit != NULL){
669 g_string_assign (StartPath, ccpSavePathesOnExit);
670 cutSpacesFromGString(StartPath);
671 if (strcmp (StartPath->str,"true") == 0 || strcmp (StartPath->str,"True") == 0 || strcmp (StartPath->str,"TRUE") == 0){
672 LoadLastPathes=1;
673 }
674 }
675
676 Savefilestru = myFiles_openSaveFile("r");
677
678 firstItem=0;
679 if (LoadLastPathes==1 && Savefilestru!= NULL){// && 1==myFiles_getValueFromIdentifier(Savefilestru, LASTPATHESLEFTKEY, 0)){
680 //lets get it on and load the saved pathes from savefile
681 i=0;
682 while (1){
683 //PATH
684 g_string_printf(gstrIdentifier, LASTPATHLEFTID, i);
685 if ( 1 == myFiles_getValueFromIdentifier(Savefilestru, gstrIdentifier->str, 0) ){
686 done_pathloaded = 1;
687 if (0 == firstItem){
688 SideObjectList_StartWithObjectList((GtkNotebook *)Notebooks[SIDE_LEFT], Savefilestru->gstrValue->str);
689 firstItem=1;
690 }
691 else
692 SideObjectList_CreateNewViewWithPath((GtkNotebook *)Notebooks[SIDE_LEFT], Savefilestru->gstrValue->str, NULL);
693 }
694 else{
695 break;
696 }
697 SideObjectList_GetActiveObject((GtkNotebook *)Notebooks[SIDE_LEFT], &Object);
698 //HIDDENFLAG
699 g_string_printf(gstrIdentifier, LASTPATHLEFTHIDDENID, i);
700 if ( 1 == myFiles_getValueFromIdentifier(Savefilestru, gstrIdentifier->str, 0) ){
701 if (strcmp(Savefilestru->gstrValue->str, "true")==0){
702 Object->showHiddenFiles=TRUE;
703 iReUpdate = 1;
704 }
705 }
706 //PREVIEW
707 g_string_printf(gstrIdentifier, LASTPATHLEFTPREVIEWID, i);
708 if ( 1 == myFiles_getValueFromIdentifier(Savefilestru, gstrIdentifier->str, 0) ){
709 if (strcmp(Savefilestru->gstrValue->str, "true")==0){
710 Object->iPreview=1;
711 iReUpdate=1;
712 gtk_tree_view_column_set_visible(Object->PreviewCol,TRUE);
713 }
714 }
715 //READONLY
716 g_string_printf(gstrIdentifier, LASTPATHLEFTREADONLYID, i);
717 if ( 1 == myFiles_getValueFromIdentifier(Savefilestru, gstrIdentifier->str, 0) ){
718 if (strcmp(Savefilestru->gstrValue->str, "true")==0){
719 Object->bReadOnly=TRUE;
720 iReUpdate=1;
721 }
722 }
723
724 if (iReUpdate==1){
725 SideObjectList_UpdateObject(Object);
726 updateViewWithNewFolder(Object,NULL);
727 }
728
729 i++;
730 }
731 }
732 //fallback, load standard start dirs from startdirectory property from configfile
733 struct _OptionsList *NextItem = NULL;
734 const char *ccpStandardStartDirs = NULL;
735 if (done_pathloaded==0){
736 NextItem = OptionsList_getFirstItem(g_OptionsList);
737 do{
738 ccpStandardStartDirs = OptionsList_getValueAndNextItemByID (NextItem, &NextItem, STARTDIRECTORIESLEFTKEY);
739 if (ccpStandardStartDirs){
740 g_string_assign(StartPath, ccpStandardStartDirs);
741 if (done_pathloaded == 0){
742 SideObjectList_StartWithObjectList((GtkNotebook *)Notebooks[SIDE_LEFT], StartPath->str);
743 done_pathloaded=1;
744 }
745 else{
746 SideObjectList_CreateNewViewWithPath((GtkNotebook *)Notebooks[SIDE_LEFT], StartPath->str,NULL);
747 }
748 }
749 }while (NextItem);
750 }
751 // fall back, just load standard start directory (one) or at least the homedir
752 if(done_pathloaded == 0){
753 TRACEIT(11,"loadStartPathes left side NOT Found");
754 getStandardStartDirectory(gstrStandardDirCommand);//, gstrStandartDirCommandName);
755 SideObjectList_StartWithObjectList((GtkNotebook *)Notebooks[SIDE_LEFT], gstrStandardDirCommand->str);
756 }
757
758 //RIGHT
759 iReUpdate=0;
760 done_pathloaded=0;
761 if (LoadLastPathes==1 && Savefilestru!= NULL){// && 1==myFiles_getValueFromIdentifier(Savefilestru, LASTPATHESLEFTKEY, 0)){
762 //lets get it on and load the saved pathes from savefile
763 i=0;
764 while (1){
765 //PATH
766 g_string_printf(gstrIdentifier, LASTPATHRIGHTID, i);
767 if ( 1 == myFiles_getValueFromIdentifier(Savefilestru, gstrIdentifier->str, 0) ){
768 done_pathloaded = 1;
769 SideObjectList_CreateNewViewWithPath((GtkNotebook *)Notebooks[SIDE_RIGHT], Savefilestru->gstrValue->str, NULL);
770 }
771 else{
772 break;
773 }
774 SideObjectList_GetActiveObject((GtkNotebook *)Notebooks[SIDE_RIGHT], &Object);
775 //HIDDENFLAG
776 g_string_printf(gstrIdentifier, LASTPATHRIGHTHIDDENID, i);
777 if ( 1 == myFiles_getValueFromIdentifier(Savefilestru, gstrIdentifier->str, 0) ){
778 if (strcmp(Savefilestru->gstrValue->str, "true")==0){
779 Object->showHiddenFiles=TRUE;
780 iReUpdate=1;
781 }
782 }
783 //PREVIEW
784 g_string_printf(gstrIdentifier, LASTPATHRIGHTPREVIEWID, i);
785 if ( 1 == myFiles_getValueFromIdentifier(Savefilestru, gstrIdentifier->str, 0) ){
786 if (strcmp(Savefilestru->gstrValue->str, "true")==0){
787 Object->iPreview=1;
788 iReUpdate=1;
789 gtk_tree_view_column_set_visible(Object->PreviewCol,TRUE);
790 }
791 }
792 //READONLY
793 g_string_printf(gstrIdentifier, LASTPATHRIGHTREADONLYID, i);
794 if ( 1 == myFiles_getValueFromIdentifier(Savefilestru, gstrIdentifier->str, 0) ){
795 if (strcmp(Savefilestru->gstrValue->str, "true")==0){
796 Object->bReadOnly=TRUE;
797 iReUpdate=1;
798 }
799 }
800
801 if (iReUpdate==1){
802 SideObjectList_UpdateObject(Object);
803 updateViewWithNewFolder(Object,NULL);
804 }
805
806 i++;
807 }
808 }
809 //fallback, load standard start dirs from startdirectory property from configfile
810 if (done_pathloaded==0){
811 NextItem = OptionsList_getFirstItem(g_OptionsList);
812 do{
813 ccpStandardStartDirs = OptionsList_getValueAndNextItemByID (NextItem, &NextItem, STARTDIRECTORIESRIGHTKEY);
814 if (ccpStandardStartDirs){
815 g_string_assign(StartPath, ccpStandardStartDirs);
816 //if (done_pathloaded == 0){
817 // SideObjectList_StartWithObjectList((GtkNotebook *)Notebooks[SIDE_RIGHT], StartPath->str);
818 // done_pathloaded=1;
819 //}
820 //else{
821 SideObjectList_CreateNewViewWithPath((GtkNotebook *)Notebooks[SIDE_RIGHT], StartPath->str,NULL);
822 done_pathloaded=1;
823 //}
824 }
825 }while (NextItem);
826 }
827 // fall back, just load standard start directory (one) or at least the homedir
828 if(done_pathloaded == 0){
829 getStandardStartDirectory(gstrStandardDirCommand);//, gstrStandartDirCommandName);
830 SideObjectList_CreateNewViewWithPath((GtkNotebook *)Notebooks[SIDE_RIGHT], gstrStandardDirCommand->str,NULL);
831 }
832
833 //clean up
834 myFiles_closeFile(Savefilestru);
835 g_string_free(StartPath,TRUE);
836 g_string_free(gstrLastPathesLeft,TRUE);
837 g_string_free(gstrLastPathesRight,TRUE);
838 g_string_free(gstrStandardDirCommand,TRUE);
839 g_string_free(gstrStandardDirCommandName,TRUE);
840 g_string_free(gstrIdentifier, TRUE);
841 TRACEIT(10,"loadStartPathes ends");
842 }
843
844
bringAllToTheRightOrder()845 void bringAllToTheRightOrder(){
846 TRACEIT(10,"bringAllToTheRightOrder start");
847
848 //PathEntry, 1UP Button
849 gtk_box_pack_start(GTK_BOX(HBoxForButtonsAndPathEntry[SIDE_LEFT]),GTK_WIDGET(PathEntryBox[SIDE_LEFT]),TRUE,TRUE,1);
850 gtk_box_pack_start(GTK_BOX(HBoxForButtonsAndPathEntry[SIDE_LEFT]),GTK_WIDGET(OnePathUpButton[SIDE_LEFT]),FALSE,FALSE,1);
851 gtk_box_pack_end(GTK_BOX(HBoxForButtonsAndPathEntry[SIDE_RIGHT]),GTK_WIDGET(PathEntryBox[SIDE_RIGHT]),TRUE,TRUE,1);
852 gtk_box_pack_end(GTK_BOX(HBoxForButtonsAndPathEntry[SIDE_RIGHT]),GTK_WIDGET(OnePathUpButton[SIDE_RIGHT]),FALSE,FALSE,1);
853
854 //Bring components of each side toghether
855 gtk_box_pack_start(GTK_BOX(VBox[SIDE_LEFT]),GTK_WIDGET(HBoxForButtonsAndPathEntry[SIDE_LEFT]),FALSE,FALSE,1);
856 gtk_box_pack_start(GTK_BOX(VBox[SIDE_LEFT]),GTK_WIDGET(Notebooks[SIDE_LEFT]),TRUE,TRUE,1);
857
858 gtk_box_pack_start(GTK_BOX(VBox[SIDE_RIGHT]),GTK_WIDGET(HBoxForButtonsAndPathEntry[SIDE_RIGHT]),FALSE,FALSE,1);
859 gtk_box_pack_start(GTK_BOX(VBox[SIDE_RIGHT]),GTK_WIDGET(Notebooks[SIDE_RIGHT]),TRUE,TRUE,1);
860
861 //Bring the two sides together
862 gtk_paned_pack1(GTK_PANED(HPanedLeftRight),GTK_WIDGET(VBox[SIDE_LEFT]),TRUE,TRUE);
863 gtk_paned_pack2(GTK_PANED(HPanedLeftRight),GTK_WIDGET(VBox[SIDE_RIGHT]),TRUE,TRUE);
864
865 //There is one more pane
866 gtk_paned_pack1(GTK_PANED(VPanedForFileShelf),GTK_WIDGET(HPanedLeftRight),TRUE,TRUE);
867
868 //Connect it with mainwindow
869 gtk_container_add (GTK_CONTAINER(win),VPanedForFileShelf);
870
871 TRACEIT(10,"bringAllToTheRightOrder ends");
872 }
873
874
AddPathesToNotebook(GtkNotebook * Notebook,GString * gstrPathes,int AllreadyStarted)875 int AddPathesToNotebook(GtkNotebook *Notebook, GString *gstrPathes, int AllreadyStarted){
876 // gets one path and add this path to the note
877 TRACEIT(10,"AddPathesToNotebook start");
878 int WeStarted=0;
879 const char sep[] = PROGRAMSEPERATOR;
880 char *cOnePath=NULL;
881 GString *gstrOnePath=g_string_sized_new(10);
882
883 cOnePath = strtok(gstrPathes->str,sep);
884 if (cOnePath == NULL){
885 TRACEIT(7,"AddPathesToNotebook ends, NOT A PATH");
886 return -1;
887 }
888 while(cOnePath != NULL){
889 g_string_assign(gstrOnePath, cOnePath);
890 cutLeadingSpacesFromGString(gstrOnePath);
891 if (AllreadyStarted == 0 && WeStarted == 0){
892 SideObjectList_StartWithObjectList(Notebook, gstrOnePath->str);
893 WeStarted = 1;
894 }
895 else{
896 SideObjectList_CreateNewViewWithPath(Notebook, gstrOnePath->str, NULL);
897 }
898 cOnePath = strtok(NULL,sep);
899 }
900 TRACEIT(10,"AddPathesToNotebook ends");
901 return 1;
902 }
903
904
updatePathEntryBox(GtkNotebook * notebook,guint num)905 void updatePathEntryBox(GtkNotebook *notebook, guint num){
906 TRACEIT(10,"updatePathEntryBox start");
907 struct SideObjectList *Object=NULL;
908 SideObjectList_GetObjectByPageNumber(notebook,&Object,(int)num);
909 if (Object == NULL){
910 TRACEIT(2,"updatePathEntryBox ends, No Object??");
911 return;
912 }
913
914 int leftORright = (Object->notebook == (GtkNotebook *)Notebooks[SIDE_LEFT])?SIDE_LEFT:SIDE_RIGHT;
915 g_object_set(PathEntryBox[leftORright],"text",Object->gstrPath->str,NULL);
916 TRACEIT(10,"updatePathEntryBox ends");
917 }
918
919
onePageSwitched(GtkNotebook * notebook,GtkNotebookPage * page,guint page_num,gpointer user_data)920 gboolean onePageSwitched(GtkNotebook *notebook, GtkNotebookPage *page, guint page_num, gpointer user_data){
921 TRACEIT(10,"onePageSwitched start");
922 updatePathEntryBox(notebook,page_num);
923
924 struct SideObjectList *Object=NULL;
925 if (gint_Starting == 0){
926 SideObjectList_GetObjectByPageNumber(notebook, &Object, page_num);
927 if (Object->bUpdateFlag_UpdateOnTabSwitch){
928 //Object->bUpdateFlag_F6=FALSE;
929 updateView(Object);
930 Object->bUpdateFlag_UpdateOnTabSwitch=FALSE;
931 }
932 }
933 TRACEIT(10,"onePageSwitched ends");
934 return FALSE;
935 }
936
937
oneMouseButtonPressedOnNotebook(GtkWidget * notebook,GdkEventButton * event,gpointer data)938 gboolean oneMouseButtonPressedOnNotebook(GtkWidget *notebook, GdkEventButton *event, gpointer data){
939 TRACEIT(10,"oneMouseButtonPressedOnNotebook start");
940
941 int leftORrightOrFileshelf = GPOINTER_TO_INT(data);
942
943 //event->button = 2 is the middle mousebutton, I've tried many things but the problem, that the
944 //tab, the mouse is over, will be deleted only once still was there. All further klicks on the
945 //middle mouse button delete just the tab which is currently active, without activating the one
946 //the mouse is over. So I decided to forget this feature. However, now it is possible to close a
947 //tab via double click with the left mouse button
948 //IT SEEMS THIS WAS A BUG in a earlier release in compination with FreeBSD or something like
949 //that, however, now it works just great and from now on, we close the tabs via the middle mouse button.
950 if (event->type == GDK_BUTTON_PRESS && (event->button == 3 /*|| event->button==2*/)){
951 //contextMenu
952 //If the user makes a right click on an unselected Tab we want the notbook to select the Tab the mouse is over.
953 //So we sent an left click event to the notebook and it will make the work for us
954 GdkEventButton newEvent;
955 newEvent.type = event->type;
956 newEvent.window = event->window;
957 newEvent.send_event = event->send_event;
958 newEvent.time = event->time+1;
959 newEvent.x = event->x;
960 newEvent.y = event->y;
961 newEvent.axes = event->axes;
962 newEvent.state = event->state;
963 newEvent.button = 1;
964 newEvent.device = event->device;
965 newEvent.x_root = event->x_root;
966 newEvent.y_root = event->y_root;
967
968 gboolean ret;
969
970 g_signal_emit_by_name (notebook,"button-press-event",&newEvent,&ret);
971 newEvent.type= GDK_BUTTON_RELEASE;
972 g_signal_emit_by_name (notebook,"button-press-event",&newEvent,&ret);
973
974 if (leftORrightOrFileshelf <= SIDE_BOTH){
975 openTabContextMenu(notebook,event,data); //Look near the end of the file
976 }
977 else if(leftORrightOrFileshelf == SIDE_FILESHELF){
978 openFileShelfTabContextMenu(notebook,event,data);
979 }
980
981 TRACEIT(10,"oneMouseButtonPressedOnNotebook ends");
982 return TRUE;
983 }
984 else if(event->type == GDK_2BUTTON_PRESS && event->button == 1){
985 //New Tab
986 if (leftORrightOrFileshelf <= SIDE_BOTH){
987 addNewPage(NULL, notebook);
988 }
989 else if(leftORrightOrFileshelf == SIDE_FILESHELF){
990 NewFileShelf(NULL);
991 }
992 return TRUE;
993 }
994 else if (event->type == GDK_BUTTON_PRESS && (event->button==2)){
995 //close tab
996 //If the user makes a right click on an unselected Tab we want the notbook to select the Tab the mouse is over.
997 //So we sent an left click event to the notebook and it will make the work for us
998 GdkEventButton newEvent;
999 newEvent.type = event->type;
1000 newEvent.window = event->window;
1001 newEvent.send_event = event->send_event;
1002 newEvent.time = event->time+1;
1003 newEvent.x = event->x;
1004 newEvent.y = event->y;
1005 newEvent.axes = event->axes;
1006 newEvent.state = event->state;
1007 newEvent.button = 1;
1008 newEvent.device = event->device;
1009 newEvent.x_root = event->x_root;
1010 newEvent.y_root = event->y_root;
1011
1012 gboolean ret;
1013
1014 g_signal_emit_by_name (notebook,"button-press-event",&newEvent,&ret);
1015 newEvent.type= GDK_BUTTON_RELEASE;
1016 g_signal_emit_by_name (notebook,"button-press-event",&newEvent,&ret);
1017
1018 if (leftORrightOrFileshelf <= SIDE_BOTH){
1019 SideObjectList_DeleteActiveObject((GtkNotebook *)notebook);
1020 }
1021 else if(leftORrightOrFileshelf == SIDE_FILESHELF){
1022 FileShelf_DeleteActiveTab();
1023 }
1024
1025 return TRUE;
1026 }
1027
1028 TRACEIT(10,"oneMouseButtonPressedOnNotebook ends");
1029 return FALSE;
1030 }
1031
1032
onePageAddedToNotebook(GtkNotebook * notebook,GtkWidget * child,guint page_num,gpointer data)1033 void onePageAddedToNotebook(GtkNotebook *notebook, GtkWidget *child, guint page_num, gpointer data){
1034 TRACEIT(10,"onePageAddedToNotebook start");
1035 struct SideObjectList *Object=NULL;
1036 SideObjectList_GetObjectByPageNumber(notebook,&Object,page_num);
1037 if (Object == NULL){
1038 TRACEIT(10,"onePageAddedToNotebook ends");
1039 return;
1040 }
1041
1042 gtk_notebook_set_current_page(notebook,page_num);
1043
1044 updateViewWithNewFolder(Object,Object->gstrPath); //dont change this, we need the the newPath here for moitoring, look updateViewWithNewFolder
1045 TRACEIT(10,"onePageAddedToNotebook ends");
1046 }
1047
1048
oneMouseButtonPressed(GtkWidget * treeview,GdkEventButton * event,gpointer data)1049 gboolean oneMouseButtonPressed(GtkWidget *treeview, GdkEventButton *event, gpointer data){
1050 TRACEIT(10,"oneMouseButtonPressed start");
1051 GdkEventButton newEvent;
1052 struct SideObjectList *Object=(struct SideObjectList *)data;
1053
1054 //dragndrop - related
1055 //I want to explain the following lines till //END-EXPLAINLINES:
1056 // This lines are here for the dragndrop thing. When marking more than one item and we want them to drag and drop we have to
1057 // catch this mousebutton event (this is the first if statement).
1058 // But we also have to unselect all the others when a simple mousebutten event on one item occurs. This is the second if statement.
1059 // We define an area in which we onyl select the item the mousepointer is over.
1060 GtkTreeSelection *selection=NULL;
1061 selection = gtk_tree_view_get_selection((GtkTreeView *)treeview);
1062 guint modifiers;
1063 modifiers = gtk_accelerator_get_default_mod_mask ();
1064 static double x=0;
1065 static double y=0;
1066 GtkTreePath *path=NULL;
1067 if (gtk_tree_selection_count_selected_rows(selection) > 1 ){ //onyl catch this if more than one item is selected
1068 if (event->type == GDK_BUTTON_PRESS && event->button == 1){ //and it is the 1st mouse button
1069 if ((event->state & modifiers) == 0){ //and no modifiers (such as ctrl or alt) are pressed.
1070 //when we have an event not over an selected Path we ignore the event
1071 gtk_tree_view_get_path_at_pos ( (GtkTreeView *)treeview, (gint) event->x, (gint) event->y, &path, NULL, NULL, NULL);
1072 if (path != NULL){ //may be NULL if the area which is clicked has no item
1073 if (TRUE == gtk_tree_selection_path_is_selected (selection, path)){
1074 gtk_tree_path_free (path);
1075 x=event->x;
1076 y=event->y;
1077 return TRUE;
1078 }
1079 gtk_tree_path_free (path);
1080 }
1081 else{
1082 gtk_tree_selection_unselect_all(selection); //dont waste time and unmark the items
1083 }
1084 }
1085 }
1086 }
1087 if (gtk_tree_selection_count_selected_rows(selection) > 1 ){
1088 if (event->type == GDK_BUTTON_RELEASE && event->button == 1){
1089 if ((event->state & modifiers) == 0){
1090 if (x-event->x < 6.0 && y-event->y < 6.0){
1091 gtk_tree_selection_unselect_all(selection);
1092 x=0;
1093 y=0;
1094 if (event->window == gtk_tree_view_get_bin_window ((GtkTreeView *)treeview)){
1095 gtk_tree_view_get_path_at_pos ( (GtkTreeView *)treeview, (gint) event->x, (gint) event->y, &path, NULL, NULL, NULL);
1096 if (path != NULL){ //may be NULL if the area which is clicked has no item
1097 gtk_tree_selection_select_path (selection, path);
1098 gtk_tree_path_free (path);
1099 }
1100 }
1101 return TRUE;
1102 }
1103 }
1104 }
1105 }
1106 //END-EXPLAINLINES (dragndrop - related)
1107
1108 if (event->type == GDK_BUTTON_PRESS && event->button == 3){
1109 openContextMenu(treeview,event,data); //Look near the end of the file
1110 TRACEIT(10,"oneMouseButtonPressed ends");
1111 return TRUE;
1112 }
1113 if (event->type == GDK_BUTTON_PRESS && event->button == 2){ //we mark all items of the view which have the same endings as the one allready marked
1114 //we fire an mousebutton 1 event to the same position to get the item selected the mouse is over
1115 newEvent.type = event->type;
1116 newEvent.window = event->window;
1117 newEvent.send_event = event->send_event;
1118 newEvent.time = event->time+1;
1119 newEvent.x = event->x;
1120 newEvent.y = event->y;
1121 newEvent.axes = event->axes;
1122 newEvent.state = event->state;
1123 newEvent.button = 1;
1124 newEvent.device = event->device;
1125 newEvent.x_root = event->x_root;
1126 newEvent.y_root = event->y_root;
1127
1128 gboolean ret;
1129
1130 g_signal_emit_by_name (treeview,"button-press-event",&newEvent,&ret);
1131 newEvent.type= GDK_BUTTON_RELEASE;
1132 g_signal_emit_by_name (treeview,"button-press-event",&newEvent,&ret);
1133
1134 markItemsWithSameType((GtkTreeView *)Object->listView, COL_FILETYPE);
1135 TRACEIT(10,"oneMouseButtonPressed ends");
1136 return TRUE;
1137 }
1138 TRACEIT(10,"oneMouseButtonPressed ends");
1139 return FALSE;
1140 }
1141
1142
oneContextMenuReplied(GtkWidget * treeview,gpointer data)1143 gboolean oneContextMenuReplied(GtkWidget *treeview, gpointer data){
1144 TRACEIT(10,"oneContextMenuReplied start");
1145 openContextMenu(treeview,NULL, data); //Look near the end of the file
1146 TRACEIT(10,"oneContextMenuReplied ends");
1147 return TRUE;
1148 }
1149
1150
oneNoteBookContextMenuReplied(GtkWidget * treeview,gpointer data)1151 gboolean oneNoteBookContextMenuReplied(GtkWidget *treeview, gpointer data){
1152 TRACEIT(10,"oneNoteBookContextMenuReplied start");
1153 openTabContextMenu(treeview,NULL, NULL); //Look near the end of the file
1154 TRACEIT(10,"oneNoteBookContextMenuReplied ends");
1155 return TRUE;
1156 }
1157
1158
oneKeyPressedOnNotebook(GtkWidget * widget,GdkEventKey * event,gpointer data)1159 gboolean oneKeyPressedOnNotebook(GtkWidget *widget, GdkEventKey *event, gpointer data){
1160 //data = SIDE_LEFT || SIDE_RIGHT
1161 //We pass key events to the view (SideObjects AND Fileshelf)
1162 TRACEIT(10,"oneKeyPressedOnNotebook start");
1163 struct SideObjectList *SideObject=NULL;
1164 struct FileShelfObjectList *ShelfObject=NULL;
1165 int leftORrightOrFileshelf = GPOINTER_TO_INT(data);
1166 gboolean bRet = FALSE;
1167
1168 if (leftORrightOrFileshelf <= SIDE_BOTH){
1169 SideObjectList_GetActiveObject((GtkNotebook *)Notebooks[leftORrightOrFileshelf], &SideObject);
1170 if (SideObject == NULL){
1171 TRACEIT(3,"oneKeyPressedOnNotebook end, No Object found");
1172 return FALSE;
1173 }
1174 bRet = oneKeyPressedInView(NULL, event, (void *)SideObject);
1175 }
1176 else if(leftORrightOrFileshelf == SIDE_FILESHELF){
1177 FileShelfObjectList_GetActiveObject(&ShelfObject);
1178 if (ShelfObject == NULL){
1179 TRACEIT(3,"oneKeyPressedOnNotebook end, No Object found");
1180 return FALSE;
1181 }
1182 bRet = oneFileShelfKeyPressedInView(NULL, event, (void *)ShelfObject);
1183 }
1184
1185 TRACEIT(10,"oneKeyPressedOnNotebook end");
1186 return bRet; //if we do not handle it return FALSE
1187 }
1188
1189
oneKeyPressedInView(GtkWidget * widget,GdkEventKey * event,gpointer data)1190 gboolean oneKeyPressedInView(GtkWidget *widget, GdkEventKey *event, gpointer data){
1191 //Be aware of using widget, as this function is called when a key is pressed on a notebook (tab) too
1192 //data = struct SideObjectList
1193 TRACEIT(10,"oneKeyPressedInView start");
1194 guint modifiers;
1195
1196 modifiers = gtk_accelerator_get_default_mod_mask ();
1197 struct SideObjectList *Object = (struct SideObjectList *)data;
1198 int leftORright = (Object->notebook == (GtkNotebook *)Notebooks[SIDE_LEFT])?SIDE_LEFT:SIDE_RIGHT;
1199
1200 if ( (event->keyval == GDK_Delete)){
1201 //Delete selected files with 'del-key'
1202 mayDeleteSelectedRows(NULL, data);
1203 TRACEIT(10,"oneKeyPressedInView ends");
1204 return TRUE;
1205 }
1206 else if ( (event->keyval == GDK_Return)){
1207 //go to directory or start userprogram with marked items
1208 oneRowActivated_SideObjectWrap(NULL, NULL, NULL, data);
1209 return TRUE;
1210 }
1211 else if (event->keyval == GDK_BackSpace){
1212 //One path up with backspace
1213 oneOnePathUpButtonClicked(NULL, GINT_TO_POINTER (leftORright));
1214 return TRUE;
1215 }
1216 else if (event->keyval == GDK_F2){
1217 //rename selected
1218 renameItems(NULL, data);
1219 return TRUE;
1220 }
1221 else if (event->keyval == GDK_F3){
1222 //create New Directory
1223 mayNewDirectory(NULL, data);
1224 return TRUE;
1225 }
1226 else if (event->keyval == GDK_F4){
1227 //open Terminal
1228 UserOption_callTerminal(Object, SOURCE_SIDEOBJECT);
1229 return TRUE;
1230 }
1231 else if (event->keyval == GDK_F5){
1232 //Update view with
1233 updateViewWithNewFolder_UserAdvice(Object, NULL);
1234 return TRUE;
1235 }
1236 else if (event->keyval == GDK_F6){
1237 //Update view with
1238
1239 //We do not need this here because calcDirectorySizeInView_wrap will wait for thread and abort if another thread allready is running
1240 //calcDirectorySizeInView_closeProcess (&(Object->iRecursiveSizeCalculation), &(Object->gthreadF6Updage));
1241 //#ifdef NO_GIO
1242 //updateView(Object); //we do not need this any longer, because of our automatic update
1243 //#endif
1244 //Object->bUpdateFlag_F6=TRUE;
1245 struct AllInformationAllUseStruct *stru = malloc (sizeof(struct AllInformationAllUseStruct));
1246 if (stru == NULL){
1247 TRACEIT(1,"oneKeyPressedInView error allocating memory");
1248 return TRUE;
1249 }
1250 stru->source=SOURCE_SIDEOBJECT;
1251 stru->Info_1 = data;
1252 stru->Info_2 = &(Object->gthreadF6Updage);
1253 stru->Info_3 = &(Object->iRecursiveSizeCalculation);
1254 stru->Info_4 = &(Object->bUpdateFlag_F6);
1255 stru->Info_5 = NULL;
1256
1257 calcDirectorySizeInView_wrap(stru);
1258
1259 return TRUE;
1260 }
1261
1262 else if ((event->keyval == 'c' || event->keyval == 'C') && (event->state & modifiers) == GDK_CONTROL_MASK){
1263 //Copy Paste // here is copy
1264 CopyPasteCreateList_SideObject(data, 1);
1265 return TRUE;
1266 }
1267 else if ((event->keyval == 'x' || event->keyval == 'X') && (event->state & modifiers) == GDK_CONTROL_MASK){
1268 //Copy Paste // here is cut
1269 CopyPasteCreateList_SideObject(data, 2);
1270 return TRUE;
1271 }
1272 else if ((event->keyval == 'v' || event->keyval == 'V') && (event->state & modifiers) == GDK_CONTROL_MASK){
1273 //Copy Paste // here is paste
1274 CopyPasteProcessList_SideObject(data);
1275 return TRUE;
1276 }
1277 else if ((event->keyval == 'n' || event->keyval == 'N') && (event->state & modifiers) == GDK_CONTROL_MASK){
1278 //new page
1279 addNewPage(NULL, Object->notebook);
1280 return TRUE;
1281 }
1282 else if ((event->keyval == 'i' || event->keyval == 'I') && (event->state & modifiers) == GDK_CONTROL_MASK){
1283 //size of selected
1284 sizeOfSelectedItemsRecursive (NULL, data);
1285 return TRUE;
1286 }
1287 else if ((event->keyval == 'h' || event->keyval == 'H') && (event->state & modifiers) == GDK_CONTROL_MASK){
1288 //show hidden files
1289 showHiddenFilesInActivePage(NULL, Object->notebook);
1290 return TRUE;
1291 }
1292 else if((event->keyval == 'a' || event->keyval == 'A') && (event->state & modifiers) == GDK_CONTROL_MASK){
1293 //select all
1294 mySelectAllFunction((GtkTreeView *)Object->listView, (void *)Object);
1295 return TRUE;
1296 }
1297 else if ((event->keyval == 's' || event->keyval == 'S') && (event->state & modifiers) == GDK_CONTROL_MASK){
1298 //Add selected items to active fileshelf
1299 MenuAddItemToFileshelf(NULL, data);
1300 return TRUE;
1301 }
1302 else if ((event->keyval == 'd' || event->keyval == 'D') && (event->state & modifiers) == GDK_CONTROL_MASK){
1303 //Add selected items to new fileshelf
1304 MenuAddToNewFileshelf(NULL, data);
1305 return TRUE;
1306 }
1307 else if ((event->keyval == 'f' || event->keyval == 'F') && (event->state & modifiers) == GDK_MOD1_MASK){
1308 //my search function
1309 searchStringInAndHighlightItems_WraperforSideObject(NULL, Object->listView);
1310 return TRUE;
1311 }
1312 else if ((event->keyval == 'c' || event->keyval == 'C') && (event->state & modifiers) == GDK_MOD1_MASK){
1313 //copy selected to other side
1314 copyToOtherPannel(NULL, data);
1315 return TRUE;
1316 }
1317 else if ((event->keyval == 'x' || event->keyval == 'X') && (event->state & modifiers) == GDK_MOD1_MASK){
1318 //move selected to other side
1319 moveToOtherPannel(NULL, data);
1320 return TRUE;
1321 }
1322 else if ((event->keyval == 'y' || event->keyval == 'Y') && (event->state & modifiers) == GDK_CONTROL_MASK){
1323 //copies the marked names withOUT path to the real clipboard
1324 markedNamesToClipboard((GtkTreeView *)Object->listView, FALSE, COL_NAME, -1, NULL);
1325 //markedNamesToClipboard(GtkTreeView *TreeView, gboolean bWithPath, int iColumnName, int iColumnPath, char *cpPath)
1326 return TRUE;
1327 }
1328 else if ((event->keyval == 'y' || event->keyval == 'Y') && (event->state & modifiers) == GDK_MOD1_MASK){
1329 //copies the marked names WITH path to the real clipboard
1330 markedNamesToClipboard((GtkTreeView *)Object->listView, TRUE, COL_NAME, -1, Object->gstrPath->str);
1331 return TRUE;
1332 }
1333 else if ((event->keyval == 'p' || event->keyval == 'P') && (event->state & modifiers) == GDK_CONTROL_MASK){
1334 // Enable/Disable Preview for current Tab
1335 ChangePreviewState(NULL, Object);
1336 return TRUE;
1337 }
1338 else if ((event->keyval == 'r' || event->keyval == 'R') && (event->state & modifiers) == GDK_CONTROL_MASK){
1339 //enable/disable read only
1340 ChangeReadOnlyState(NULL, Object);
1341 return TRUE;
1342 }
1343
1344
1345 TRACEIT(10,"oneKeyPressedInView ends");
1346 return FALSE;
1347 }
1348
1349
oneOnePathUpButtonClicked(GtkButton * button,gpointer data)1350 void oneOnePathUpButtonClicked(GtkButton *button, gpointer data){
1351 TRACEIT(10,"oneOnePathUpButtonClicked start");
1352 int leftORright = GPOINTER_TO_INT(data);
1353
1354 struct SideObjectList *Object=NULL;
1355
1356 SideObjectList_GetActiveObject(GTK_NOTEBOOK(Notebooks[leftORright]), &Object);
1357 if (Object == NULL){
1358 TRACEIT(10,"oneOnePathUpButtonClicked ends");
1359 return;
1360 }
1361 GString *gstrPath = g_string_new(Object->gstrPath->str);
1362
1363 checkPathForLastChar(gstrPath);
1364 g_string_append(gstrPath,"..");
1365 g_object_set(PathEntryBox[leftORright],"text",gstrPath->str,NULL);
1366 gtk_widget_activate(GTK_WIDGET(PathEntryBox[leftORright]));
1367 g_string_free(gstrPath, TRUE);
1368 TRACEIT(10,"oneOnePathUpButtonClicked ends");
1369 }
1370
1371
oneColumnWasClicked(GtkTreeViewColumn * Column,gpointer data)1372 void oneColumnWasClicked(GtkTreeViewColumn *Column, gpointer data){
1373 TRACEIT(10,"oneColumnWasClicked start");
1374 struct SideObjectList *Object=(struct SideObjectList *)data;
1375 Object->actualSortCol = Column;
1376 TRACEIT(10,"oneColumnWasClicked ends");
1377 }
1378
1379
oneRowActivated_SideObjectWrap(GtkTreeView * treeview,GtkTreePath * TreePath,GtkTreeViewColumn * col,gpointer data)1380 void oneRowActivated_SideObjectWrap(GtkTreeView *treeview, GtkTreePath *TreePath, GtkTreeViewColumn *col, gpointer data){
1381 struct AllInformationAllUseStruct stru;
1382
1383 stru.source = SOURCE_SIDEOBJECT;
1384 stru.Info_1 = data; //SideObject
1385 stru.Info_2 = NULL;
1386 stru.Info_3 = NULL;
1387 stru.Info_4 = NULL;
1388 stru.Info_5 = NULL;
1389
1390 //oneRowActivated (treeview, TreePath, col, (void *)&stru);
1391 oneRowActivated (&stru);
1392
1393 }
1394
1395
oneRowActivated(struct AllInformationAllUseStruct * stru)1396 void oneRowActivated(struct AllInformationAllUseStruct *stru){
1397 GtkTreeSelection *selection=NULL;
1398 int i_rowsSelected=0;
1399 int i_oneIsDirectory=0;
1400 int i_oneIsPoints=0;
1401 GtkWidget *ListView=NULL;
1402 struct SideObjectList *SideObject=NULL;
1403 struct FileShelfObjectList *FlShlfObject=NULL;
1404 GList *list=NULL;
1405 GtkTreeModel *model;
1406 GtkTreeIter iter;
1407 gchar *name=NULL;
1408 gchar *path=NULL;
1409 gint type_d;
1410 GString *NewPath=g_string_sized_new(20);
1411 int side=stru->source;
1412 struct AllInformationAllUseStruct info;
1413
1414 info.source = side;
1415 if (stru->source == SOURCE_SIDEOBJECT){
1416 SideObject=(struct SideObjectList *)stru->Info_1;
1417 }
1418 else{
1419 FlShlfObject = (struct FileShelfObjectList *)stru->Info_1;
1420 //FileShelfObjectList_GetActiveObject(&Object);
1421 }
1422 if ( (side==SOURCE_SIDEOBJECT && SideObject==NULL) || (side==SOURCE_FILESHELF && FlShlfObject== NULL) ){
1423 TRACEIT(2,"oneRowActivated end, found exception");
1424 return;
1425 }
1426 if (side==SOURCE_SIDEOBJECT){
1427 info.Info_1 = (void *)SideObject->listView;
1428 ListView = SideObject->listView;
1429 i_oneIsDirectory = checkIfOneSelectionIsPath(ListView, COL_TYPE_D);
1430 i_oneIsPoints = checkIfOneSelectionIsPoints(ListView, COL_NAME);
1431 }
1432 else{
1433 info.Info_1 = (void *)FlShlfObject->listView;
1434 ListView = FlShlfObject->listView;
1435 i_oneIsDirectory = checkIfOneSelectionIsPath(ListView, COL_FLSHLF_TYPE_D);
1436 i_oneIsPoints = checkIfOneSelectionIsPoints(ListView, COL_FLSHLF_NAME);
1437 }
1438
1439 selection = gtk_tree_view_get_selection((GtkTreeView *)ListView);
1440 i_rowsSelected = gtk_tree_selection_count_selected_rows(selection);
1441
1442 if (i_rowsSelected > 1 && (i_oneIsDirectory!=0 || i_oneIsPoints!=0)){ //We do not handle this!!, e.g. more than one directory selected, or normal items and directories are selected
1443 //TODO!!!!!!! error message in stutusbar
1444 if (side==SOURCE_SIDEOBJECT){
1445 gtk_statusbar_pop(SideObject->StatusBar,0);
1446 gtk_statusbar_push(SideObject->StatusBar,0,"There is more than one directory selected... can't do anything.");
1447 }
1448 return;
1449 }
1450 else if (i_rowsSelected != 0 && i_oneIsDirectory!=0){ //Its ONE directory we want to go to
1451 list = gtk_tree_selection_get_selected_rows (selection, &model);
1452 gtk_tree_model_get_iter (model, &iter, (GtkTreePath *)list->data);
1453
1454 if (side == SOURCE_SIDEOBJECT){
1455 gtk_tree_model_get(model, &iter,COL_NAME,&name,COL_TYPE_D,&type_d, -1);
1456 }
1457 else{
1458 gtk_tree_model_get(model, &iter,COL_FLSHLF_NAME,&name,COL_FLSHLF_TYPE_D,&type_d,COL_FLSHLF_PATH,&path, -1);
1459 }
1460 if ((type_d==4 || type_d==10) && strcmp(name,".")!=0){ //Folder!
1461 if (side==SOURCE_SIDEOBJECT){
1462 g_string_assign(NewPath, SideObject->gstrPath->str);
1463 checkPathForLastChar(NewPath);
1464 g_string_append(NewPath,name);
1465 formatPathString(NewPath);
1466 updateViewWithNewFolder_UserAdvice(SideObject,NewPath);
1467 }
1468 else{
1469 g_string_assign(NewPath,path);
1470 checkPathForLastChar(NewPath);
1471 g_string_append(NewPath,name);
1472 SideObjectList_CreateNewViewWithPath(NULL,NewPath->str,NULL);
1473 }
1474 }
1475 g_list_foreach (list, (GFunc)gtk_tree_path_free, NULL);
1476 g_list_free (list);
1477 }
1478 else if (i_oneIsDirectory==0 && i_oneIsPoints==0){ //one or more items to call
1479 if (NULL != g_UserDataList){
1480 UserDataList_DeleteList(&g_UserDataList);
1481 //g_UserDataList = NULL; //this is allready done by the deleteList function
1482 }
1483 GList *glistMarkedTypes=NULL;
1484
1485 glistMarkedTypes = getTypesOfSelectedItems(&info);
1486 getUserProgramsForSelectedItems(glistMarkedTypes, &g_UserDataList); //u will get the commands which 'countForAllItems' too
1487 if (NULL != glistMarkedTypes){
1488 g_string_assign (NewPath, ((GString *)(glistMarkedTypes->data))->str);
1489 g_list_foreach(glistMarkedTypes, (GFunc) GListFreeGStrings, NULL);
1490 g_list_free(glistMarkedTypes);
1491 glistMarkedTypes = NULL;
1492 }
1493 struct UserDataList *UserDataListBuf = UserDataList_getStandardItem(g_UserDataList);
1494 if (UserDataListBuf != NULL){
1495 if (stru->source == SOURCE_SIDEOBJECT){
1496 UserDataListBuf->iSourceType = SOURCE_SIDEOBJECT;
1497 UserDataListBuf->Object = (void *)SideObject;
1498 }
1499 else{
1500 UserDataListBuf->iSourceType = SOURCE_FILESHELF;
1501 UserDataListBuf->Object = (void *)FlShlfObject;
1502 }
1503
1504 startItemsWithUserCommand(NULL, (void *)UserDataListBuf);
1505 }
1506 else{
1507 g_string_prepend (NewPath, "Sorry, there is no default command\ndefined for this type of file: \"");
1508 g_string_append (NewPath, "\"\n\nPlease mind that in the case that\nthere are more items marked,\nonly the first item type is used.");
1509 MyMessageWidget (win, "Error",NewPath->str);
1510 }
1511 }
1512 if (name)
1513 g_free(name);
1514 if (path)
1515 g_free(path);
1516 g_string_free(NewPath,TRUE);
1517
1518 }
1519
1520
oneKeyPressed_PathEntry(GtkWidget * widget,GdkEventKey * event,gpointer data)1521 gboolean oneKeyPressed_PathEntry(GtkWidget *widget, GdkEventKey *event, gpointer data){
1522 TRACEIT(10,"oneKeyPressed_PathEntry start");
1523 char *completed=NULL;
1524 char *cpPath=NULL;
1525 int iCurrentPosition=0;
1526 int ret=0;
1527
1528 if ( (event->keyval == GDK_Tab)){ //PATH COMPLETION
1529 g_object_get(widget,"text",&cpPath,NULL);
1530 if (cpPath != NULL){
1531 ret = completePath(cpPath, &completed);
1532 if (completed){
1533 g_object_set(widget,"text",completed,NULL);
1534 gtk_editable_set_position ( (GtkEditable *)widget, -1); //sets the cursor to the end
1535 iCurrentPosition = gtk_editable_get_position ((GtkEditable *)widget);
1536 if (ret == 2){ //directory is valid
1537 gtk_editable_insert_text ( (GtkEditable *)widget, "/", -1, &iCurrentPosition );
1538 gtk_editable_set_position ( (GtkEditable *)widget, -1); //sets the cursor to the end
1539 }
1540 free(completed);
1541 }
1542 free(cpPath);
1543 }
1544 TRACEIT(10,"oneKeyPressed_PathEntry end");
1545 return TRUE;
1546 }
1547 TRACEIT(10,"oneKeyPressed_PathEntry end");
1548 return FALSE;
1549 }
1550
1551
onePathChanged(GtkEntry * entry,gpointer g)1552 void onePathChanged(GtkEntry *entry, gpointer g){
1553 TRACEIT(10,"onePathChanged start");
1554 gchar *NewPath=NULL;
1555
1556 int leftORright = GPOINTER_TO_INT(g);
1557 if (leftORright == SIDE_LEFT)
1558 g_object_get(PathEntryBox[SIDE_LEFT], "text", &NewPath, NULL);
1559 else
1560 g_object_get(PathEntryBox[SIDE_RIGHT], "text", &NewPath, NULL);
1561
1562 //Test if NewPath exists
1563 struct SideObjectList *Object=NULL;
1564 SideObjectList_GetActiveObject(GTK_NOTEBOOK(Notebooks[leftORright]), &Object);
1565 if (Object==NULL){
1566 if (NewPath)
1567 g_free(NewPath);
1568 return;
1569 }
1570 GString *gstrbuf = g_string_new(NewPath);
1571 formatPathString(gstrbuf);
1572 if (-1 == checkDirectory(Object,gstrbuf)){
1573 g_string_free(gstrbuf,TRUE);
1574 if (NewPath)
1575 g_free(NewPath);
1576 TRACEIT(10,"onePathChanged ends");
1577 return;
1578 }
1579 updateViewWithNewFolder_UserAdvice(Object, gstrbuf);
1580
1581 g_string_free(gstrbuf,TRUE);
1582 if (NewPath)
1583 g_free(NewPath);
1584 TRACEIT(10,"onePathChanged ends");
1585 }
1586
1587
sizeOfSelected_Helper(GtkTreeModel * model,GtkTreePath * path,GtkTreeIter * iter,gpointer data)1588 static void sizeOfSelected_Helper (GtkTreeModel *model,GtkTreePath *path,GtkTreeIter *iter,gpointer data){
1589 TRACEIT(10,"sizeOfSelected_Helper start");
1590 struct SideObjectList *Object = (struct SideObjectList *)data;
1591
1592 guint64 isize;
1593 gint type_d;
1594 gchar *name=NULL;
1595
1596 GString *Path= g_string_new(Object->gstrPath->str);
1597
1598 if (gtk_tree_model_get_iter(model, iter, path)){
1599 gtk_tree_model_get(model, iter, COL_SIZE, &isize, COL_NAME, &name, COL_TYPE_D, &type_d, -1);
1600 if ( strcmp(name,".")!=0 && strcmp(name,"..")!=0){
1601 Object->guint64sizeOfSelectedItems+=isize;
1602 }
1603 }
1604
1605 g_string_free(Path,TRUE);
1606 if (name)
1607 g_free(name);
1608
1609 TRACEIT(10,"sizeOfSelected_Helper ends");
1610 }
1611
1612
updateStatusBar(struct SideObjectList * Object)1613 void updateStatusBar(struct SideObjectList *Object){
1614 GtkTreeSelection *treeselection;
1615 char buf[266]; //266 should do the job, as it just represents a number (size in bytes)
1616 int len;
1617 GString *gstrBuf = g_string_sized_new(10);
1618 GString *gstrBuf2 = g_string_sized_new(10);
1619 void *data = (void *)Object;
1620
1621 treeselection = gtk_tree_view_get_selection((GtkTreeView *)Object->listView);
1622 Object->guint64sizeOfSelectedItems=0;
1623 gtk_tree_selection_selected_foreach(treeselection, sizeOfSelected_Helper, data);
1624
1625 snprintf(buf,265,"%lld",Object->guint64sizeOfSelectedItems);
1626 g_string_assign(gstrBuf2, buf);
1627 len = strlen(gstrBuf2->str)-3;
1628 while (len>0){
1629 g_string_insert_c(gstrBuf2,len,'.');
1630 len -=3;
1631 }
1632 strcpy(buf,gstrBuf2->str);
1633
1634 BytesToHumanityString (Object->guint64sizeOfSelectedItems, gstrBuf2, 0);
1635 g_string_printf(gstrBuf,"%d Items selected: %s ( %s bytes )", gtk_tree_selection_count_selected_rows(treeselection), gstrBuf2->str, buf);
1636
1637 gtk_statusbar_pop(Object->StatusBar,0);
1638 gtk_statusbar_push(Object->StatusBar,0,gstrBuf->str);
1639
1640 g_string_free(gstrBuf,TRUE);
1641 g_string_free(gstrBuf2,TRUE);
1642 }
1643
1644
oneSelectionChanged(GtkTreeSelection * treeselection,gpointer data)1645 void oneSelectionChanged(GtkTreeSelection *treeselection, gpointer data){
1646 TRACEIT(10,"oneSelectionChanged start");
1647 struct SideObjectList *Object = (struct SideObjectList *)data;
1648
1649 updateStatusBar(Object);
1650 TRACEIT(10,"oneSelectionChanged ends");
1651 }
1652
1653
formatPathString(GString * NewPath)1654 void formatPathString(GString *NewPath){
1655 TRACEIT(10,"formatPathString start");
1656 char *path = NewPath->str;
1657 int len = strlen(path);
1658
1659 char *EndString;
1660 char *buf;
1661 int Anzahl1=0;
1662 int Anzahl2=0;
1663 int i;
1664
1665 EndString = malloc(sizeof(char) * len + 20);
1666 if (EndString == NULL){
1667 TRACEIT(10,"formatPathString ends");
1668 return;
1669 }
1670
1671 //Wieviele "/.."
1672 buf = path;
1673 while(buf != NULL){
1674 buf = strstr(buf,"/..");
1675 if (buf != NULL){
1676 Anzahl1++;
1677 buf++;
1678 }
1679 }
1680 //Wieviele "/."
1681 buf = path;
1682 while(buf != NULL){
1683 buf = strstr(buf,"/.");
1684 if (buf != NULL){
1685 Anzahl2++;
1686 buf++;
1687 }
1688 }
1689 Anzahl2 = Anzahl2-Anzahl1;
1690 if (Anzahl2 == 0 && Anzahl1 == 0){
1691 free(EndString);
1692 TRACEIT(10,"formatPathString ends");
1693 return;
1694 }
1695 int Anzahl3=0;
1696 EndString[0] = '\0';
1697 const char sep[] = "/";
1698 for (buf = strtok(path,sep); buf; buf=strtok(NULL,sep)){
1699 if (strcmp(buf,".") != 0 && strcmp(buf,"..") != 0){
1700 strcat(EndString,"/");
1701 strcat(EndString,buf);
1702 Anzahl3++;
1703 }
1704 }
1705 if (Anzahl1 >= Anzahl3){
1706 sprintf(EndString,"/");
1707 g_string_assign(NewPath,EndString);
1708 free(EndString);
1709 TRACEIT(10,"formatPathString ends");
1710 return;
1711 }
1712 path = malloc(sizeof(char) * strlen(EndString) + 20);
1713 if (path == NULL){
1714 free(EndString);
1715 TRACEIT(10,"formatPathString ends");
1716 return;
1717 }
1718
1719 strcpy(path,EndString);
1720 EndString[0] = '\0';
1721 i=0;
1722 for (buf = strtok(path,sep); buf && (Anzahl3-Anzahl1) > i; buf=strtok(NULL,sep) ){
1723 i++;
1724 strcat(EndString,sep);
1725 strcat(EndString,buf);
1726 }
1727
1728 g_string_assign(NewPath,EndString);
1729
1730 free(path);
1731 free(EndString);
1732
1733 TRACEIT(10,"formatPathString ends");
1734 }
1735
1736
updateViewsFolder_Helper(GtkTreeModel * model,GtkTreePath * path,GtkTreeIter * iter,struct AllInformationAllUseStruct * infostru)1737 gboolean updateViewsFolder_Helper (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, struct AllInformationAllUseStruct *infostru){
1738 //WARNING, not only used from udateFolder, but also from within the fileshelf (interseption...)
1739 TRACEIT(11,"updateViewsFolder_Helper start");
1740 gchar *Name=NULL;
1741 gchar *Path=NULL;
1742 struct updateList **itemlist= (struct updateList **)infostru->Info_1;
1743
1744 int *columnToSearch=(int *)infostru->Info_2;
1745 int *columnToUseToo=(int *)infostru->Info_3;
1746
1747 if (columnToUseToo){
1748 gtk_tree_model_get(model, iter, *columnToSearch, &Name, *columnToUseToo, &Path, -1);
1749 }
1750 else{
1751 gtk_tree_model_get(model, iter, *columnToSearch, &Name, -1);
1752 }
1753 if (!(strcmp(Name, "..")==0 || strcmp(Name,".")==0)){
1754 updateList_addItem(itemlist, Name, Path, gtk_tree_row_reference_new(model, path), 0);
1755 }
1756
1757 if (Name)
1758 g_free(Name);
1759 if (Path)
1760 g_free(Path);
1761 TRACEIT(11,"updateViewsFolder_Helper ends");
1762 return FALSE;
1763 }
1764
1765
updateViewWithNewFolder(struct SideObjectList * Object,GString * NewPath)1766 void updateViewWithNewFolder(struct SideObjectList *Object, GString *NewPath){
1767 //NewPath may be NULL
1768 TRACEIT(10,"updateViewWithNewFolder start");
1769 if (Object == NULL){
1770 TRACEIT(2,"updateViewWithNewFolder ends. ERROR, Object=NULL");
1771 return;
1772 }
1773
1774 //SET UPDATEING FLAG
1775 if (Object->bUpdateFlag_CurrentlyUpdating==TRUE){
1776 TRACEIT(10,"updateViewWithNewFolder ends, No Update 2");
1777 return;
1778 }
1779 Object->bUpdateFlag_CurrentlyUpdating=TRUE;
1780
1781 if ( Object->iPreventFromUpdating != 0 && NewPath == NULL){
1782 TRACEIT(10,"updateViewWithNewFolder ends, No Update");
1783 Object->bUpdateFlag_CurrentlyUpdating=FALSE;
1784 SideObjectList_UpdateObject(Object);
1785 return;
1786 }
1787
1788 if (NewPath != NULL){
1789 calcDirectorySizeInView_closeProcess (&(Object->iRecursiveSizeCalculation), &(Object->gthreadF6Updage), &(Object->bUpdateFlag_F6), &(Object->iPreventFromUpdating), TRUE);
1790 }
1791
1792 struct updateList *updateItemlist=NULL;
1793 struct updateList *firstUpdateItemList=NULL;
1794 GtkTreeIter iter;
1795 GtkTreePath *path;
1796 int BrandNewStore=0;
1797 GString *OldName=NULL;
1798 GString *Ending=NULL;
1799 GString *Starting=NULL;
1800
1801 struct AllInformationAllUseStruct infostru;
1802 int columnToSearch=COL_NAME;
1803
1804 infostru.Info_1=(void *)&updateItemlist;
1805 infostru.Info_2=(void *)&columnToSearch;
1806 infostru.Info_3=NULL;
1807 infostru.Info_4=NULL;
1808 infostru.Info_5=NULL;
1809
1810 //CursorToWait(win);
1811 TRACEIT(10,"updateViewWithNewFolder check point 1");
1812 int leftORright = (Object->notebook == (GtkNotebook *)Notebooks[SIDE_LEFT])?SIDE_LEFT:SIDE_RIGHT;
1813 if (NewPath == NULL && Object->listStore != NULL){
1814 TRACEIT(10,"updateViewWithNewFolder just update view");
1815 gtk_tree_model_foreach(GTK_TREE_MODEL(Object->listStore),(GtkTreeModelForeachFunc) updateViewsFolder_Helper,&infostru);
1816 //When we try to update the view, while the folder was not available the function foreach did not do anything
1817 firstUpdateItemList = updateItemlist;
1818
1819 makeLists(Object, &updateItemlist);
1820
1821 updateItemlist = firstUpdateItemList;
1822 TRACEIT(10,"updateViewWithNewFolder check point 1.1");
1823 while (updateItemlist){
1824 if (updateItemlist->found == 0){
1825 path = gtk_tree_row_reference_get_path(updateItemlist->rowref);
1826 if (path){
1827 if (gtk_tree_model_get_iter(GTK_TREE_MODEL(Object->listStore), &iter, path)){
1828 //gtk_list_store_set (Object->listStore, &iter, COL_INTERNAL, 1,-1); //what the **CK!! why setting a value, when all the information for deleting this row is already there?
1829 gtk_list_store_remove(Object->listStore, &iter);
1830 }
1831 }
1832 }
1833 updateItemlist = updateItemlist->NextItem;
1834 }
1835 TRACEIT(10,"updateViewWithNewFolder check point 1.2");
1836 if (firstUpdateItemList != NULL){
1837 updateList_deleteList(&firstUpdateItemList);
1838 }
1839 //RemoveInternalMarkedItems(Object); //what the **CK!! why calling another function, when all the information for deleting this row is already there?
1840 updateStatusBar(Object);
1841 // SideObjectList_UpdateObject(Object); //TODO: check if we need thi, This has come ot here because we change the tenotebooktab text as long as we do not change the mouse curosr
1842 SideObjectList_UpdateObject(Object); //sets the tabs label
1843 checkDirectory(Object,NewPath); //sets the status bar
1844 }
1845 else{
1846 TRACEIT(10,"updateViewWithNewFolder new view");
1847 if (NewPath != NULL){ //we expect a completly new path, no update
1848 g_object_set(PathEntryBox[leftORright],"text",NewPath->str,NULL);
1849 OldName = g_string_new(Object->gstrPath->str);
1850 g_string_assign(Object->gstrPath,NewPath->str);
1851
1852 //printf("OldName=%s\nNewPath=%s\n",OldName->str,NewPath->str);
1853
1854 //stop old monitor and start new one
1855 if (strcmp (OldName->str, NewPath->str) != 0){ //on creating, both are the same and we dont do anything
1856 // #ifndef NO_GIO
1857 autoUpdateList_RemoveMonitor(OldName->str);
1858 autoUpdateList_AddMonitor(NewPath->str);
1859 // #endif
1860 }
1861 }
1862 if (NULL == Object->listStore){
1863 //firstly I thought we can use this on startup and create a new monitor, but this fails when copying, moving, dublicating a tab
1864 //in this cases NewPath is NULL but never the less we have to catch it.
1865 //such events are now catched where they should be, in the sideObjectList_* functions
1866 //autoUpdateList_AddMonitor(NewPath->str);
1867 BrandNewStore=1;
1868 }
1869 Object->guint64sizeOfSelectedItems=0;
1870
1871 //start reading the directory and fill items in list
1872
1873 makeLists(Object, NULL);
1874 //if (0==makeLists(Object, NULL) && BrandNewStore==1){
1875 //then we have to connect the new list to the obejct
1876 // NO, not anymore! the makeLists function will do this for us now
1877
1878 //connectListToView(Object);
1879 //doActionsForNewView ();
1880 //}
1881
1882 TRACEIT(10,"updateViewWithNewFolder check point 2.1");
1883 if (BrandNewStore != 1 && NewPath != NULL){ //its a new folder to load, but maybe we come from a lower one... lets look for this
1884 Ending = g_string_sized_new(10);
1885 Starting = g_string_sized_new(10);
1886
1887 //g_string_assign(Ending, OldName->str);
1888 g_string_assign(Starting, OldName->str);
1889 checkPathForLastCharOtherwise(Starting);
1890 checkPathForLastCharOtherwise(NewPath);
1891 if (NULL != strstr (Starting->str, NewPath->str)){ //then we can mark and scroll to the folder we just came from
1892 while(strlen(NewPath->str) <= strlen(Starting->str)){
1893 g_string_assign(Ending, Starting->str);
1894
1895 getLastStringInPath(Ending);
1896 GetPathFromPathWithName(Starting, 1);
1897 checkPathForLastCharOtherwise(Starting);
1898
1899 if (strcmp(NewPath->str, Starting->str)==0){
1900 scrollListStoreToName((GtkTreeView *)Object->listView, Object->listStore, Ending, COL_NAME);
1901 break;
1902 }
1903 }
1904 }
1905 else { //We do not come from a lower path, the scrollpoint is sewt to root position
1906 //we have to realkize the tree view before we can use scroll to point
1907 gtk_widget_realize(Object->listView); //Beacuse the BrandnewStore cant be 1 in here, we are sure to realize an item already shown.
1908 gtk_tree_view_scroll_to_point ((GtkTreeView *)Object->listView, -1, 0);
1909 }
1910 TRACEIT(10,"updateViewWithNewFolder check point 2.2");
1911 g_string_free(Ending, TRUE);
1912 g_string_free(Starting, TRUE);
1913 }
1914 if (OldName)
1915 g_string_free(OldName, TRUE);
1916 TRACEIT(10,"updateViewWithNewFolder check point 3.1");
1917 SideObjectList_UpdateObject(Object); //sets the tabs label
1918 checkDirectory(Object,NewPath); //sets the status bar
1919 TRACEIT(10,"updateViewWithNewFolder check point 3.2");
1920 }
1921
1922 //set Some updateflags:
1923 Object->bUpdateFlag_UpdateOnTabSwitch=FALSE;
1924 Object->bUpdateFlag_CurrentlyUpdating=FALSE;
1925 //CursorToNormal(win);
1926 TRACEIT(10,"updateViewWithNewFolder ends");
1927 }
1928
1929
updateViewWithNewFolder_UserAdvice(struct SideObjectList * Object,GString * NewPath)1930 void updateViewWithNewFolder_UserAdvice(struct SideObjectList *Object, GString *NewPath){
1931 Object->bUpdateFlag_UserWantsToUpdate=TRUE;
1932 while (Object->bUpdateFlag_CurrentlyUpdating){
1933 usleep(100000);
1934 }
1935 calcDirectorySizeInView_closeProcess (&(Object->iRecursiveSizeCalculation), &(Object->gthreadF6Updage), &(Object->bUpdateFlag_F6), &(Object->iPreventFromUpdating), TRUE);
1936
1937 updateViewWithNewFolder(Object, NewPath);
1938
1939 Object->bUpdateFlag_UserWantsToUpdate=FALSE;
1940 }
1941
1942
updateObjectsViewingFolder(char * Folder,gboolean automaticTriggered)1943 void updateObjectsViewingFolder(char *Folder, gboolean automaticTriggered){
1944 //automaticTriggered: TRUE: comming from a monitor event, FALSE: userevent
1945 TRACEIT(10,"updateObjectsViewingFolder start");
1946 GString *gstrFolder=g_string_sized_new(10);
1947 GString *gstrObjectFolder=g_string_sized_new(10);
1948
1949 if (Folder == NULL){
1950 TRACEIT(10,"updateObjectsViewingFolder ends");
1951 g_string_free(gstrFolder, TRUE);
1952 g_string_free(gstrObjectFolder, TRUE);
1953 return;
1954 }
1955
1956 struct SideObjectList *Objects = SideObjectList_getFirstObject();
1957 g_string_assign(gstrFolder, Folder);
1958 checkPathForLastCharOtherwise(gstrFolder);
1959
1960 //Set bUpdateFlag_UserWantsToUpdate
1961 while (Objects){
1962 g_string_assign(gstrObjectFolder, Objects->gstrPath->str);
1963 checkPathForLastCharOtherwise(gstrObjectFolder);
1964 if ( 0==strcmp(gstrFolder->str, gstrObjectFolder->str)){
1965 Objects->bUpdateFlag_UpdateOnTabSwitch=TRUE;
1966 }
1967 Objects = Objects->NextItem;
1968 }
1969
1970 SideObjectList_GetActiveObject((GtkNotebook *)Notebooks[SIDE_LEFT], &Objects);
1971 if (Objects != NULL){
1972 g_string_assign(gstrObjectFolder, Objects->gstrPath->str);
1973 checkPathForLastCharOtherwise(gstrObjectFolder);
1974 if ( 0==strcmp(gstrFolder->str, gstrObjectFolder->str)){
1975 //#ifdef NO_GIO
1976 //updateViewWithNewFolder(Objects, NULL);
1977 //#endif
1978 if (automaticTriggered==TRUE && Objects->bUpdateFlag_UserWantsToUpdate==FALSE){ //prefent automatic update when user want an update, think of big directories changing often
1979 updateView(Objects);
1980 }
1981 }
1982 }
1983
1984 SideObjectList_GetActiveObject((GtkNotebook *)Notebooks[SIDE_RIGHT], &Objects);
1985 if (Objects != NULL){
1986 g_string_assign(gstrObjectFolder, Objects->gstrPath->str);
1987 checkPathForLastCharOtherwise(gstrObjectFolder);
1988 if ( 0==strcmp(gstrFolder->str, gstrObjectFolder->str)){
1989 //#ifdef NO_GIO
1990 // updateViewWithNewFolder(Objects, NULL);
1991 //#endif
1992 if (automaticTriggered==TRUE && Objects->bUpdateFlag_UserWantsToUpdate==FALSE){ //prefent automatic update when user want an update, think of big directories changing often
1993 updateView(Objects);
1994 }
1995 }
1996 }
1997
1998 g_string_free(gstrFolder, TRUE);
1999 g_string_free(gstrObjectFolder, TRUE);
2000 TRACEIT(10,"updateObjectsViewingFolder ends");
2001 }
2002
2003
updateActiveViews()2004 void updateActiveViews(){
2005 struct SideObjectList *Objects = SideObjectList_getFirstObject();
2006
2007 SideObjectList_GetActiveObject((GtkNotebook *)Notebooks[SIDE_LEFT], &Objects);
2008 updateView(Objects);
2009
2010 SideObjectList_GetActiveObject((GtkNotebook *)Notebooks[SIDE_RIGHT], &Objects);
2011 updateView(Objects);
2012 }
2013
2014
updateView(struct SideObjectList * Object)2015 void updateView(struct SideObjectList *Object){
2016 //if (1==checkIfFolderNeedsUpdate(Object)){
2017 updateViewWithNewFolder(Object, NULL);
2018 //}
2019 }
2020
2021 /*
2022 The idea: I thought that the timestamp from a directory changed when a file within this directory changed. And therefore
2023 we could check this before we update the whole list. But after I wrote this, I saw that this does not work like this.
2024 This means this code is useless. F*SADIOSASASA'*'*�SP�DO
2025 int checkIfFolderNeedsUpdate(struct SideObjectList *Object){
2026 //returnvalues: 1:update needed. 0:no update needed
2027 struct FileAttributs attribs;
2028 GtkTreeIter iter;
2029 int viewsTimeStamp=-2;
2030 int filesTimeStamp=-1;
2031 gchar *name=NULL;
2032 GString *gstrNames = g_string_sized_new(20);
2033 DIR *Directory;
2034 struct dirent *dirzeiger;
2035 int DirectoryOpened=0;
2036
2037 GtkTreeModel *tree_model = gtk_tree_view_get_model ((GtkTreeView *)Object->listView);
2038
2039 if (TRUE == gtk_tree_model_get_iter_first (tree_model, &iter)){
2040 do{
2041 gtk_tree_model_get(tree_model, &iter, COL_NAME, &name, -1);
2042 if (name){
2043 if (strcmp(name,".") == 0){
2044 gtk_tree_model_get(tree_model, &iter, COL_TIMESTAMPCHANGED, &viewsTimeStamp, -1);
2045 g_free(name);
2046 break;
2047 }
2048 g_free(name);
2049 }
2050 }while(TRUE == gtk_tree_model_iter_next(tree_model, &iter) );
2051 }
2052 if (viewsTimeStamp == -2){
2053 g_string_free(gstrNames,TRUE);
2054 return 1;
2055 }
2056
2057 openDirectory(&Directory, &DirectoryOpened, Object->gstrPath);
2058 if (DirectoryOpened != 0){
2059 do{
2060 getNextListItem(Directory, &dirzeiger, DirectoryOpened, gstrNames);
2061 if ( 0 == strstr(gstrNames->str, ".") ){
2062 if (0==fileAttributesGet(dirzeiger, DirectoryOpened, &attribs, Object->gstrPath->str, gstrNames->str)){
2063 filesTimeStamp = attribs.utchanged;
2064 }
2065 break;
2066 }
2067 }while(strlen(gstrNames->str));
2068 }
2069 closeDirectory(&Directory);
2070 g_string_free(gstrNames,TRUE);
2071
2072 if (filesTimeStamp > viewsTimeStamp)
2073 return 1;
2074 else
2075 return 0;
2076
2077 }
2078 */
2079
doActionsForNewView(struct SideObjectList * Object)2080 void doActionsForNewView (struct SideObjectList *Object){
2081 TRACEIT(10,"doActionsForNewView start");
2082 gtk_tree_view_column_clicked(Object->actualSortCol);
2083 TRACEIT(10,"doActionsForNewView end");
2084 }
2085
2086
connectListToView(struct SideObjectList * Object)2087 void connectListToView(struct SideObjectList *Object){
2088 TRACEIT(10,"connectListToView start");
2089
2090 gtk_tree_view_set_model (GTK_TREE_VIEW(Object->listView), GTK_TREE_MODEL(Object->listStore));
2091
2092 TRACEIT(10,"connectListToView ends");
2093 }
2094
2095
disconnectListAndView(struct SideObjectList * Object)2096 void disconnectListAndView (struct SideObjectList *Object){
2097 TRACEIT(10,"disconnectListAndView start");
2098
2099 if (NULL != gtk_tree_view_get_model (GTK_TREE_VIEW(Object->listView)) ){
2100 gtk_tree_view_set_model (GTK_TREE_VIEW(Object->listView), NULL);
2101 }
2102
2103 TRACEIT(10,"disconnectListAndView end");
2104 }
2105
2106
addPointsToSideView(char * cpPath,GtkListStore * listStore,const char * cpColorDir)2107 int addPointsToSideView(char *cpPath, GtkListStore *listStore, const char *cpColorDir){
2108 //as we changed the getNextItemInLocation function to gtk functions we losed the '.' and '..'
2109 //this function simply adds them (inclusive their attribs)
2110 TRACEIT(10,"addPointsToSideView start");
2111 struct FileAttributs attribs;
2112 GtkTreeIter iter;
2113 GString *gstrNames = g_string_new(".");
2114
2115
2116 fileAttributesGet(&attribs, cpPath, gstrNames->str);
2117 gtk_list_store_append(listStore,&iter);
2118 gtk_list_store_set (listStore, &iter, COL_NAME, gstrNames->str, COL_FILETYPE, attribs.type,
2119 COL_SIZE, attribs.size,
2120 COL_OWNER, attribs.owner, COL_GROUP, attribs.group, COL_PERMISSION, attribs.permission,
2121 COL_ACCESSED, attribs.accessed, COL_CHANGED, attribs.changed,
2122 COL_TYPE_D, attribs.type_d, COL_TIMESTAMPACCESSED, attribs.utaccessed,
2123 COL_TIMESTAMPCHANGED, attribs.utchanged, COL_COLOR,cpColorDir,
2124 -1);
2125
2126 g_string_assign (gstrNames, "..");
2127 fileAttributesGet(&attribs, cpPath, gstrNames->str);
2128 gtk_list_store_append(listStore,&iter);
2129 gtk_list_store_set (listStore, &iter, COL_NAME, gstrNames->str, COL_FILETYPE, attribs.type,
2130 COL_SIZE, attribs.size,
2131 COL_OWNER, attribs.owner, COL_GROUP, attribs.group, COL_PERMISSION, attribs.permission,
2132 COL_ACCESSED, attribs.accessed, COL_CHANGED, attribs.changed,
2133 COL_TYPE_D, attribs.type_d, COL_TIMESTAMPACCESSED, attribs.utaccessed,
2134 COL_TIMESTAMPCHANGED, attribs.utchanged, COL_COLOR,cpColorDir,
2135 -1);
2136
2137 g_string_free(gstrNames, TRUE);
2138 TRACEIT(10,"addPointsToSideView end");
2139 return 0;
2140 }
2141
2142
makeLists(struct SideObjectList * Object,struct updateList ** itemlist)2143 int makeLists(struct SideObjectList *Object, struct updateList **itemlist){
2144 TRACEIT(10,"makeLists start");
2145 GtkTreeIter iter;
2146 GtkTreeRowReference *rowref=NULL;
2147 int done=0;
2148 GtkTreePath *path;
2149 struct FileAttributs attribs;
2150 GString *gstrNames = g_string_sized_new(20);
2151 int iLocationOpened=-1;
2152 struct myLocationStruct locationStru;
2153 int BrandNewStore=0;
2154 GdkPixbuf *gdkpixBuf=NULL;
2155
2156 const char *cpColorDir=NULL;
2157 const char *cpColorItm=NULL;
2158 const char *cpColorLnk=NULL;
2159 const char cpColorFallBackItms[] = DEFAULT_COLOR_ITEMS_DEFAULT;
2160 const char cpColorFallBackDirs[] = DEFAULT_COLOR_DIRECTORIES;
2161 const char cpColorFallBackLnks[] = DEFAULT_COLOR_LINKS;
2162 const char *cpPreviewEndings=NULL;
2163
2164 cpColorDir = OptionsList_getValueByID (g_OptionsList, COLOR_DIRECTORIES);
2165 cpColorItm = OptionsList_getValueByID (g_OptionsList, COLOR_ITEMS_DEFAULT);
2166 cpColorLnk = OptionsList_getValueByID (g_OptionsList, COLOR_LINKS);
2167 cpPreviewEndings = OptionsList_getValueByID (g_OptionsList, PREVIEWTYPES);
2168
2169 if (cpColorDir == NULL)
2170 cpColorDir = cpColorFallBackDirs;
2171 if (cpColorItm == NULL)
2172 cpColorItm = cpColorFallBackItms;
2173 if (cpColorLnk == NULL)
2174 cpColorLnk = cpColorFallBackLnks;
2175
2176 iLocationOpened = openLocation(Object->gstrPath->str, &locationStru, TRUE, FALSE);
2177
2178 //disconnectListAndView (Object); // I tried to disconnect the model and the treeview before updating the view.
2179 // but then, we lose the marking by every update
2180
2181 if (itemlist == NULL ){
2182 if (NULL == Object->listStore){
2183 Object->listStore = gtk_list_store_new(NUM_COLS,COLTYPES);
2184 BrandNewStore=1;
2185 }
2186 else{
2187 SideObjectList_UnrefPreviewPixbufs (Object->listStore, COL_PREVIEW);
2188 gtk_list_store_clear (Object->listStore);
2189 }
2190 if (0==iLocationOpened){
2191 addPointsToSideView(Object->gstrPath->str, Object->listStore, cpColorDir);
2192 Object->bPointsAddedToView = TRUE;
2193 }
2194 }else if (NULL != Object->listStore){
2195 SideObjectList_UnrefPreviewPixbufs (Object->listStore, COL_PREVIEW);
2196 }
2197
2198 if (-1==iLocationOpened){
2199 gtk_list_store_clear (Object->listStore);
2200 Object->bPointsAddedToView = FALSE;
2201 }
2202 else if (Object->bPointsAddedToView == FALSE){
2203 addPointsToSideView(Object->gstrPath->str, Object->listStore, cpColorDir);
2204 Object->bPointsAddedToView = TRUE;
2205 }
2206
2207 while (0==iLocationOpened && 1==getNextItemInLocation(&locationStru, gstrNames, TRUE, FALSE) ){
2208 fileAttributesGet(&attribs, Object->gstrPath->str, gstrNames->str);
2209 if (!(!Object->showHiddenFiles && attribs.hiddenfile) || Object->alwaysShowHiddenFiles){
2210 if (itemlist != NULL && *itemlist != NULL){
2211 rowref = updateList_checkForItem(itemlist, gstrNames->str);
2212 if (rowref){
2213 path = gtk_tree_row_reference_get_path(rowref);
2214 if (path){
2215 if (gtk_tree_model_get_iter(GTK_TREE_MODEL(Object->listStore), &iter, path)){
2216 done=1;
2217 }
2218 }
2219 }
2220 }
2221 if (done == 0){
2222 gtk_list_store_append(Object->listStore,&iter);
2223 }
2224 gtk_list_store_set (Object->listStore, &iter,
2225 COL_PREVIEW, NULL,
2226 COL_NAME, gstrNames->str,
2227 COL_FILETYPE, attribs.type,
2228 /*COL_SIZE, attribs.size,*/
2229 COL_OWNER, attribs.owner,
2230 COL_GROUP, attribs.group,
2231 COL_PERMISSION, attribs.permission,
2232 COL_ACCESSED, attribs.accessed,
2233 COL_CHANGED, attribs.changed,
2234 COL_TYPE_D, attribs.type_d,
2235 COL_TIMESTAMPACCESSED, attribs.utaccessed,
2236 COL_TIMESTAMPCHANGED, attribs.utchanged,
2237 COL_COLOR,(attribs.type_d==4)?cpColorDir:(attribs.type_d==10)?cpColorLnk:cpColorItm,
2238 -1);
2239 if (attribs.type_d!=4 || (attribs.type_d==4 && (Object->bUpdateFlag_F6==FALSE || done==0))){ //size of newly added items have to be set.
2240 gtk_list_store_set (Object->listStore, &iter,COL_SIZE, attribs.size, -1);
2241 }
2242 if (attribs.gstrLinkTarget){
2243 gtk_list_store_set (Object->listStore, &iter, COL_TARGET, attribs.gstrLinkTarget->str, COL_COLOR, cpColorLnk,-1);
2244 }
2245
2246 if (Object->iPreview > 0 && cpPreviewEndings!=NULL){
2247 if (1 == CheckForEndingInEndingList (cpPreviewEndings, attribs.type)){
2248 gdkpixBuf = getPreviewPixBufForFile (Object->gstrPath->str, gstrNames->str);
2249 if (NULL != gdkpixBuf){
2250 gtk_list_store_set (Object->listStore, &iter,COL_PREVIEW, gdkpixBuf, -1);
2251 }
2252 }
2253 }
2254 done = 0;
2255 }
2256 if (attribs.gstrLinkTarget){
2257 g_string_free(attribs.gstrLinkTarget, TRUE);
2258 }
2259 }
2260
2261
2262
2263 if (BrandNewStore==1){ //Connect SortFunctions
2264 connectListToView(Object);
2265 gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(Object->listStore),COL_NAME,mysortfunctionforNamesLeft,Object->listStore,NULL);
2266 gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(Object->listStore),COL_FILETYPE,mysortfunctionforText,GINT_TO_POINTER(COL_FILETYPE),NULL);
2267 gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(Object->listStore),COL_PERMISSION,mysortfunctionforText,GINT_TO_POINTER(COL_PERMISSION),NULL);
2268 gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(Object->listStore),COL_ACCESSED,mysortfunctionforNumbers,GINT_TO_POINTER(COL_TIMESTAMPACCESSED),NULL);
2269 gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(Object->listStore),COL_CHANGED,mysortfunctionforNumbers,GINT_TO_POINTER(COL_TIMESTAMPCHANGED),NULL);
2270 gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(Object->listStore),COL_SIZE,mysortfunctionforBigNumbers,GINT_TO_POINTER(COL_SIZE),NULL);
2271 gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(Object->listStore),COL_OWNER,mysortfunctionforNumbers,GINT_TO_POINTER(COL_OWNER),NULL);
2272 gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(Object->listStore),COL_GROUP,mysortfunctionforNumbers,GINT_TO_POINTER(COL_GROUP),NULL);
2273 doActionsForNewView (Object);
2274 }
2275
2276
2277
2278
2279 //S�ubern:
2280 closeLocation(&locationStru);
2281 g_string_free(gstrNames,TRUE);
2282
2283 TRACEIT(10,"makeLists ends");
2284 //gtk_widget_queue_draw((GtkWidget *)win);
2285 return 0;
2286 }
2287
2288
getPreviewPixBufForFile(const char * ccpPath,const char * ccpFilename)2289 GdkPixbuf *getPreviewPixBufForFile (const char *ccpPath, const char *ccpFilename){
2290 //this functions creates a GdkPixBuf for the given file. The calling function has to check if the file is a Picture and should be previewed.
2291 TRACEIT(10,"getPreviewPixBufForFile start");
2292
2293 if (NULL == ccpFilename || ccpPath == NULL){
2294 TRACEIT (2, "getPreviewPixBufForFile error: Parameter NULL");
2295 return NULL;
2296 }
2297
2298 const char *ccpPreviewSizeRaw=NULL;
2299 char *cpPreviewSizeRaw=NULL;
2300 char cpDefaultPreviewSize[] = DEFAULT_PREVIEWSIZE;
2301 int iX, iY;
2302 char *cpBuf = NULL;
2303 GError *error=NULL;
2304 GdkPixbuf *gdkpixBuf = NULL;
2305 GString *gstrBuf = g_string_new (ccpPath);
2306
2307 ccpPreviewSizeRaw = OptionsList_getValueByID (g_OptionsList, PREVIEWSIZE);
2308 if (ccpPreviewSizeRaw == NULL){
2309 cpPreviewSizeRaw=cpDefaultPreviewSize;
2310 }
2311 else{
2312 cpPreviewSizeRaw = malloc (sizeof(char) * (strlen(ccpPreviewSizeRaw) +1 ));
2313 if (cpPreviewSizeRaw == NULL){
2314 cpPreviewSizeRaw=cpDefaultPreviewSize;
2315 }
2316 else{
2317 strcpy (cpPreviewSizeRaw, ccpPreviewSizeRaw);
2318 }
2319 }
2320
2321 cpBuf = strtok (cpPreviewSizeRaw, "xX");
2322 if (NULL == cpBuf){
2323 iX = 24;
2324 }
2325 else{
2326 sscanf (cpBuf, "%d", &iX);
2327 }
2328 cpBuf = strtok (NULL, "xX");
2329 if (NULL == cpBuf){
2330 iY = 24;
2331 }
2332 else{
2333 sscanf (cpBuf, "%d", &iY);
2334 }
2335
2336
2337 checkPathForLastChar (gstrBuf);
2338 g_string_append (gstrBuf, ccpFilename);
2339
2340 gdkpixBuf = gdk_pixbuf_new_from_file_at_size (gstrBuf->str, iX, iY, &error);
2341 if (NULL != error){
2342 TRACEIT (3, "getPreviewPixBufForFile unable to create preview for:");
2343 TRACEIT (3, ccpFilename);
2344 TRACEIT (3, error->message);
2345 g_error_free (error);
2346 }
2347 if (NULL == gdkpixBuf){
2348 TRACEIT (3, "Error creating preview");
2349 }
2350
2351 free (cpPreviewSizeRaw);
2352 g_string_free (gstrBuf, TRUE);
2353
2354 TRACEIT(10,"getPreviewPixBufForFile ends");
2355 return gdkpixBuf;
2356 }
2357
2358
predefine_Main_Objects()2359 int predefine_Main_Objects(){
2360 TRACEIT(10,"predefine_Main_Objects start");
2361 //Defining EntrieyBoxes
2362 myWrap_gdk_threads_enter("predefine_Main_Objects");
2363 PathEntryBox[SIDE_LEFT] = gtk_entry_new();
2364 PathEntryBox[SIDE_RIGHT] = gtk_entry_new();
2365 gtk_entry_set_max_length(GTK_ENTRY(PathEntryBox[SIDE_LEFT]),MAXENTRYBOX);
2366 gtk_entry_set_max_length(GTK_ENTRY(PathEntryBox[SIDE_RIGHT]),MAXENTRYBOX);
2367 gtk_editable_set_editable(GTK_EDITABLE(PathEntryBox[SIDE_LEFT]),TRUE);
2368 gtk_editable_set_editable(GTK_EDITABLE(PathEntryBox[SIDE_RIGHT]),TRUE);
2369
2370 //Defining VBoxes
2371 VBox[SIDE_LEFT] = g_object_new(GTK_TYPE_VBOX, "spacing", 5, "homogeneous", FALSE, NULL);
2372 VBox[SIDE_RIGHT] = g_object_new(GTK_TYPE_VBOX, "spacing", 5, "homogeneous", FALSE, NULL);
2373
2374 //Defining SideObject Pane
2375 HPanedLeftRight = gtk_hpaned_new();
2376
2377 //Defining Pane for SideObject(Pane) and Fileshelf
2378 VPanedForFileShelf = gtk_vpaned_new();
2379
2380 //Defining HBoxes
2381 HBoxForButtonsAndPathEntry[SIDE_LEFT] = g_object_new(GTK_TYPE_HBOX, "spacing", 5, "homogeneous", FALSE, NULL);
2382 HBoxForButtonsAndPathEntry[SIDE_RIGHT] = g_object_new(GTK_TYPE_HBOX, "spacing", 5, "homogeneous", FALSE, NULL);
2383
2384 //Defining Buttons
2385 OnePathUpButton[SIDE_LEFT] = (GtkButton *)gtk_button_new_with_label("1up");
2386 OnePathUpButton[SIDE_RIGHT] = (GtkButton *)gtk_button_new_with_label("1up");
2387
2388 //Defining NoteBooks
2389 Notebooks[SIDE_LEFT]=g_object_new(GTK_TYPE_NOTEBOOK, "show-border",TRUE,"scrollable",TRUE,NULL); //Different show-border properties, but no effect seen
2390 Notebooks[SIDE_RIGHT]=g_object_new(GTK_TYPE_NOTEBOOK, "show-border",FALSE,"scrollable",TRUE,NULL);
2391
2392 //gtk_notebook_set_group ((GtkNotebook *)Notebooks[SIDE_LEFT], GROUP_VIEWNOTEBOOK); //enable dragndrop between notebooks
2393 //gtk_notebook_set_group ((GtkNotebook *)Notebooks[SIDE_RIGHT], GROUP_VIEWNOTEBOOK); //enable dragndrop between notebooks
2394 //gtk_drag_dest_unset ((GtkWidget *)Notebooks[SIDE_LEFT]);
2395 //gtk_drag_dest_unset ((GtkWidget *)Notebooks[SIDE_RIGHT]);
2396 prepareWidgetForDrop ((GtkWidget *)Notebooks[SIDE_LEFT], 1, DNDSignal_dragdatereceive_forSideObjectAndFileShelf, NULL); //mind the 1, to enable notbook tab acceptance from other notebooks
2397 prepareWidgetForDrop ((GtkWidget *)Notebooks[SIDE_RIGHT], 1, DNDSignal_dragdatereceive_forSideObjectAndFileShelf, NULL);
2398
2399 //gtk_drag_source_unset ((GtkWidget *)Notebooks[SIDE_LEFT]);
2400 //gtk_drag_source_unset ((GtkWidget *)Notebooks[SIDE_RIGHT]);
2401 //prepareWidgetForDrag ((GtkWidget *)Notebooks[SIDE_LEFT]);
2402 //prepareWidgetForDrag ((GtkWidget *)Notebooks[SIDE_RIGHT]);
2403 myWrap_gdk_threads_leave("predefine_Main_Objects");
2404 TRACEIT(10,"predefine_Main_Objects ends");
2405 return 0;
2406 }
2407
2408
reorderAllTabsColumns()2409 void reorderAllTabsColumns (){
2410 TRACEIT (10, "reorderAllTabsColumns start");
2411
2412 struct SideObjectList *Object = NULL;
2413
2414 Object = SideObjectList_getFirstObject();
2415 while (Object){
2416 predefine_NotebookTabs_reorderColumns ((GtkTreeView *) Object->listView);
2417
2418 Object = SideObjectList_getNextObejct (Object);
2419 }
2420
2421 TRACEIT (10, "reorderAllTabsColumns end");
2422 }
2423
2424
predefine_NotebookTabs_reorderColumns(GtkTreeView * treeview)2425 int predefine_NotebookTabs_reorderColumns (GtkTreeView *treeview){
2426 //tries to load the information from the options_list (loaded from configfile) and reoders the columns of the given TreeView
2427 //Ordering is done by the names of the columns
2428 //returns : 0 = ok
2429 // -1 = error
2430 TRACEIT (10, "predefine_NotebookTabs_reorderColumns start");
2431
2432 if (NULL == treeview){
2433 TRACEIT (2, "predefine_NotebookTabs_reorderColumns PARAMETER NULL");
2434 return -1;
2435 }
2436
2437 const char *ccpUsersOrder = OptionsList_getValueByID (g_OptionsList, COLUMN_ORDER);
2438
2439 if (NULL == ccpUsersOrder ){
2440 TRACEIT (10, "predefine_NotebookTabs_reorderColumns end, no reodering requested");
2441 return 0;
2442 }
2443
2444 int i,j;
2445 GString *gstrCompleteString = g_string_new (ccpUsersOrder);
2446 GString *gstrToken = g_string_sized_new (15);
2447
2448 GtkTreeViewColumn *col = NULL;
2449 GtkTreeViewColumn *lastCol = NULL;
2450
2451 for (i=0 ; 1 == myTokenFunction(gstrCompleteString, i, COLUMN_ORDER_SEPARATOR, gstrToken) ; i++){
2452 cutCharFromGString(gstrToken, '\"', 0);
2453 if ( 0 == strlen (gstrToken->str)){
2454 break;
2455 }
2456
2457 for (j=i; j<COL_TIMESTAMPACCESSED; j++){
2458 col = gtk_tree_view_get_column (treeview, j);
2459 if (0 == strcmp (gtk_tree_view_column_get_title(col), gstrToken->str)){
2460 gtk_tree_view_move_column_after (treeview, col, lastCol);
2461 lastCol = col;
2462 break;
2463 }
2464 }
2465 }
2466
2467 g_string_free (gstrCompleteString, TRUE);
2468 g_string_free (gstrToken, TRUE);
2469
2470 TRACEIT (10, "predefine_NotebookTabs_reorderColumns end");
2471 return 0;
2472 }
2473
2474
predefine_NotebookTaps_Objects(struct SideObjectList * Object)2475 int predefine_NotebookTaps_Objects(struct SideObjectList *Object){
2476 TRACEIT(10,"predefine_NotebookTaps_Objects start");
2477
2478 // Defining Lists
2479 GtkTreeViewColumn *col;
2480 GtkCellRenderer *renderer;
2481 GtkTreeSelection *selection;
2482 int i;
2483
2484 Object->listView = gtk_tree_view_new();
2485 prepareWidgetForDrop (Object->listView,1,DNDSignal_dragdatereceive_forSideObjectAndFileShelf, NULL);
2486 prepareWidgetForDrag (Object->listView);
2487 gtk_tree_view_set_rules_hint ((GtkTreeView *)Object->listView, TRUE);
2488
2489 selection = gtk_tree_view_get_selection((GtkTreeView *)Object->listView);
2490 gtk_tree_selection_set_mode(selection, GTK_SELECTION_MULTIPLE);
2491 //gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE);
2492
2493 g_signal_connect(selection, "changed", G_CALLBACK(oneSelectionChanged),Object);
2494
2495 for (i=0; i<NUM_COLS ;i++){
2496 col=gtk_tree_view_column_new();
2497
2498 //gtk_tree_view_column_set_alignment(col,1.0); //only for text in header-buttons
2499 gtk_tree_view_column_set_resizable(col,TRUE);
2500 gtk_tree_view_column_set_sort_column_id(col,i);
2501 gtk_tree_view_column_set_reorderable(col,TRUE);
2502 gtk_tree_view_column_set_title(col, Names[i]);
2503 gtk_tree_view_append_column(GTK_TREE_VIEW(Object->listView),col);
2504 if (i==COL_PREVIEW){
2505 renderer = gtk_cell_renderer_pixbuf_new ();
2506 gtk_tree_view_column_pack_start(col, renderer, TRUE);
2507 gtk_tree_view_column_add_attribute(col,renderer,"pixbuf",i);
2508 Object->PreviewCol = col;
2509 }
2510 else{
2511 renderer = gtk_cell_renderer_text_new();
2512 gtk_tree_view_column_pack_start(col, renderer, TRUE);
2513 gtk_tree_view_column_add_attribute(col,renderer,"text",i);
2514 gtk_tree_view_column_add_attribute(col,renderer,"foreground",COL_COLOR);
2515 }
2516
2517 g_signal_connect (col, "clicked",G_CALLBACK(oneColumnWasClicked),Object);
2518
2519 if (i==COL_NAME)
2520 Object->actualSortCol = col;
2521 if (i >= COL_TIMESTAMPACCESSED || (i==COL_PREVIEW && Object->iPreview==0) )
2522 gtk_tree_view_column_set_visible(col,FALSE);
2523 }
2524
2525 //Defining scrollWindows
2526 Object->ScrollWindow = gtk_scrolled_window_new(NULL,NULL);
2527 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(Object->ScrollWindow),GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC);
2528
2529 //Defining VBoxes
2530 Object->VBox = g_object_new(GTK_TYPE_VBOX, "spacing", 5, "homogeneous", FALSE, NULL);
2531
2532 //Defining Statusbars
2533 Object->StatusBar = (GtkStatusbar *)gtk_statusbar_new();
2534 gtk_statusbar_set_has_resize_grip(Object->StatusBar, FALSE);
2535
2536 //Defiging Label
2537 Object->label = gtk_label_new(NULL);
2538
2539 TRACEIT(10,"predefine_NotebookTaps_Objects ends");
2540 return 0;
2541 }
2542
2543
connectSignalsToNotebookTapObject(struct SideObjectList * Object)2544 int connectSignalsToNotebookTapObject(struct SideObjectList *Object){
2545 TRACEIT(10,"connectSignalsToNotebookTapObject start");
2546 g_signal_connect (Object->listView,"row-activated",G_CALLBACK(oneRowActivated_SideObjectWrap),Object);
2547 g_signal_connect (Object->listView,"key-press-event",G_CALLBACK(oneKeyPressedInView),Object);
2548 g_signal_connect (Object->listView,"button-press-event",G_CALLBACK(oneMouseButtonPressed),Object);
2549 g_signal_connect (Object->listView,"button-release-event",G_CALLBACK(oneMouseButtonPressed),Object);
2550 g_signal_connect (Object->listView,"popup-menu",G_CALLBACK(oneContextMenuReplied),Object);
2551 TRACEIT(10,"connectSignalsToNotebookTapObject ends");
2552 return 0;
2553 }
2554
2555
mysortfunctionshelperForCaseInsensitiveComparission(gchar * string1,gchar * string2,GtkSortType sortOrder)2556 int mysortfunctionshelperForCaseInsensitiveComparission(gchar *string1, gchar *string2, GtkSortType sortOrder){
2557 TRACEIT(12,"mysortfunctionshelperForCaseInsensitiveComparission start");
2558
2559 int ret=0;
2560 gchar *str1converted=NULL;
2561 gchar *str2converted=NULL;
2562 gchar *str1converted_=NULL;
2563 gchar *str2converted_=NULL;
2564 gsize read,write;
2565 //GString *ReportToUser=NULL;
2566 GError *err=NULL;
2567
2568 if (sortOrder == 0)
2569 sortOrder = GTK_SORT_ASCENDING;
2570
2571 if (strcmp(string1, ".") == 0){
2572 ret = (sortOrder == GTK_SORT_ASCENDING)?-1:1;
2573 }
2574 else if (strcmp(string2, ".") == 0){
2575 ret = (sortOrder == GTK_SORT_ASCENDING)?1:-1;
2576 }
2577 else if ( /*strcmp(string1, ".") != 0 && */strcmp(string2, "..") == 0){
2578 ret = (sortOrder == GTK_SORT_ASCENDING)?1:-1;
2579 }
2580 else if ( /*strcmp(string2, ".") != 0 && */strcmp(string1, "..") == 0){
2581 ret = (sortOrder == GTK_SORT_ASCENDING)?-1:1;
2582 }
2583 else{
2584 TRACEIT(12,"mysortfunctionshelperForCaseInsensitiveComparission g_utf8_collate");
2585
2586 str1converted = g_locale_to_utf8(string1,-1,&read,&write, &err);
2587 if (!str1converted && err){
2588 TRACEIT(6,"mysortfunctionshelperForCaseInsensitiveComparission: error in g_locale_to_utf8:");
2589 TRACEIT(6,err->message);
2590 TRACEIT(6,string1);
2591 g_error_free (err);
2592 err = NULL;
2593 str1converted = g_filename_to_utf8 (string1,-1,&read,&write,&err);
2594 TRACEIT(9,"g_filename_to_utf8 returns:");
2595 TRACEIT(9,str1converted);
2596 if (err){
2597 TRACEIT(6,"mysortfunctionshelperForCaseInsensitiveComparission: error in g_filename_to_utf8:");
2598 TRACEIT(6,err->message);
2599 TRACEIT(6,string1);
2600 g_error_free (err);
2601 err = NULL;
2602
2603 //Report problem to user.
2604 //I don't know this exactly but I think if this error occoures there is also a Pango-Warning
2605 //everytime you hit (no pressbutton) the line with the mouse.
2606 //ReportToUser = g_string_sized_new(20);
2607 //g_string_printf(ReportToUser, "displaying the name '%s' results into errors.",string1);
2608 //gtk_statusbar_pop(Object->StatusBar,0);
2609 //gtk_statusbar_push(Object->StatusBar,0,ReportToUser->str);
2610 //g_string_free(ReportToUser, TRUE);
2611 }
2612 }
2613 str2converted = g_locale_to_utf8(string2,-1,&read,&write, &err);
2614 if (!str2converted && err){
2615 TRACEIT(6,"mysortfunctionshelperForCaseInsensitiveComparission: error in g_locale_to_utf8:");
2616 TRACEIT(6,err->message);
2617 TRACEIT(6,string1);
2618 g_error_free (err);
2619 err = NULL;
2620 str2converted = g_filename_to_utf8 (string2,-1,&read,&write,&err);
2621 if (err){
2622 TRACEIT(6,"mysortfunctionshelperForCaseInsensitiveComparission: error in g_filename_to_utf8:");
2623 TRACEIT(6,err->message);
2624 TRACEIT(6,string2);
2625 g_error_free (err);
2626 err = NULL;
2627
2628 //Report problem to user
2629 //READ in the section above!
2630 //ReportToUser = g_string_sized_new(20);
2631 //g_string_printf(ReportToUser, "displaying the name '%s' results into errors.",string2);
2632 //gtk_statusbar_pop(Object->StatusBar,0);
2633 //gtk_statusbar_push(Object->StatusBar,0,ReportToUser->str);
2634 //g_string_free(ReportToUser, TRUE);
2635 }
2636 }
2637 if (str1converted != NULL && str2converted != NULL){
2638 str1converted_ = g_utf8_casefold (str1converted,strlen(str1converted));
2639 g_free(str1converted);
2640 str1converted = g_utf8_normalize (str1converted_,strlen(str1converted_),G_NORMALIZE_DEFAULT);
2641 g_free(str1converted_);
2642 str1converted_ = NULL;
2643
2644 str2converted_ = g_utf8_casefold (str2converted,strlen(str2converted));
2645 g_free(str2converted);
2646 str2converted = g_utf8_normalize (str2converted_,strlen(str2converted_),G_NORMALIZE_DEFAULT);
2647 g_free(str2converted_);
2648 str2converted_ = NULL;
2649
2650 ret = g_utf8_collate(str1converted, str2converted);
2651 }
2652 else{
2653 TRACEIT(6,"mysortfunctionshelperForCaseInsensitiveComparission end, there still is a problem with one string");
2654 ret = (sortOrder == GTK_SORT_ASCENDING)?-1:1;
2655 }
2656 if (str1converted)
2657 g_free (str1converted);
2658 if (str2converted)
2659 g_free (str2converted);
2660 }
2661
2662 TRACEIT(12,"mysortfunctionshelperForCaseInsensitiveComparission end");
2663 return ret;
2664 }
2665
2666
mysortfunctionforNamesLeft(GtkTreeModel * model,GtkTreeIter * a,GtkTreeIter * b,gpointer userdata)2667 int mysortfunctionforNamesLeft(GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer userdata){
2668 //usrdata is supposed to be of kind listStore
2669 TRACEIT(12,"mysortfunctionforNamesLeft start");
2670 int ret=0;
2671 gchar *string1=NULL;
2672 gchar *string2=NULL;
2673 int type_d_1, type_d_2;
2674 gint sortedColumnId;
2675 GtkSortType sortOrder;
2676
2677 gtk_tree_model_get(model, a, COL_NAME, &string1, COL_TYPE_D, &type_d_1, -1);
2678 gtk_tree_model_get(model, b, COL_NAME, &string2, COL_TYPE_D, &type_d_2, -1);
2679
2680 //struct SideObjectList *Object=(struct SideObjectList *)userdata;
2681 GtkListStore *listStore = (GtkListStore *)userdata;
2682 if (string1 == NULL || string2 == NULL){
2683 if (string1 == NULL && string2 == NULL){
2684 TRACEIT(12,"mysortfunctionforNamesLeft ends ERRORSTRING");
2685 return ret;
2686 }
2687 ret = (string1 == NULL)?-1:1;
2688 }
2689 else if (NULL != listStore){
2690 TRACEIT(12,"mysortfunctionforNamesLeft strdown");
2691 gtk_tree_sortable_get_sort_column_id(GTK_TREE_SORTABLE(listStore),&sortedColumnId,&sortOrder);
2692 if (type_d_1 == 4 && type_d_2 != 4){
2693 if (sortOrder == GTK_SORT_ASCENDING)
2694 ret = -1;
2695 else
2696 ret = 1;
2697 }
2698 else if (type_d_1 != 4 && type_d_2 == 4){
2699 if (sortOrder == GTK_SORT_ASCENDING)
2700 ret = 1;
2701 else
2702 ret = -1;
2703 }
2704 else{
2705 ret = mysortfunctionshelperForCaseInsensitiveComparission(string1, string2, sortOrder);
2706 }
2707 }
2708 if (string1)
2709 g_free (string1);
2710 if (string2)
2711 g_free (string2);
2712
2713 TRACEIT(12,"mysortfunctionforNamesLeft ends");
2714 return ret;
2715 }
2716
2717
mysortfunctionforText(GtkTreeModel * model,GtkTreeIter * a,GtkTreeIter * b,gpointer userdata)2718 int mysortfunctionforText(GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer userdata){
2719 TRACEIT(10,"mysortfunctionforText start");
2720 int ret=0;
2721 gchar *string1=NULL;
2722 gchar *string2=NULL;
2723
2724 gtk_tree_model_get(model, a, GPOINTER_TO_INT(userdata), &string1, -1);
2725 gtk_tree_model_get(model, b, GPOINTER_TO_INT(userdata), &string2, -1);
2726
2727 if (string1 == NULL || string2 == NULL){
2728 if (string1 == NULL && string2 == NULL){
2729 TRACEIT(10,"mysortfunctionforText ends");
2730 return ret;
2731 }
2732 ret = (string1 == NULL)?-1:1;
2733 }
2734 else{
2735 ret = mysortfunctionshelperForCaseInsensitiveComparission(string1, string2, 0);
2736 }
2737 g_free(string1);
2738 g_free(string2);
2739 TRACEIT(10,"mysortfunctionforText ends");
2740 return ret;
2741 }
2742
2743
mysortfunctionforNumbers(GtkTreeModel * model,GtkTreeIter * a,GtkTreeIter * b,gpointer userdata)2744 int mysortfunctionforNumbers(GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer userdata){
2745 TRACEIT(10,"mysortfunctionforNumbers start");
2746 int ret=0;
2747 int number1, number2;
2748
2749 gtk_tree_model_get(model, a, GPOINTER_TO_INT(userdata), &number1, -1);
2750 gtk_tree_model_get(model, b, GPOINTER_TO_INT(userdata), &number2, -1);
2751
2752 if(number1 > number2)
2753 ret=-1;
2754 else if(number2 > number1)
2755 ret=1;
2756 TRACEIT(10,"mysortfunctionforNumbers ends");
2757 return ret;
2758 }
2759
2760
mysortfunctionforBigNumbers(GtkTreeModel * model,GtkTreeIter * a,GtkTreeIter * b,gpointer userdata)2761 int mysortfunctionforBigNumbers(GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer userdata){
2762 TRACEIT(10,"mysortfunctionforBigNumbers start");
2763 int ret=0;
2764 guint64 number1, number2;
2765
2766 gtk_tree_model_get(model, a, GPOINTER_TO_INT(userdata), &number1, -1);
2767 gtk_tree_model_get(model, b, GPOINTER_TO_INT(userdata), &number2, -1);
2768
2769 if(number1 > number2)
2770 ret=-1;
2771 else if(number2 > number1)
2772 ret=1;
2773 TRACEIT(10,"mysortfunctionforBigNumbers ends");
2774 return ret;
2775 }
2776
2777
checkDirectory(struct SideObjectList * Object,GString * NewPath)2778 int checkDirectory(struct SideObjectList *Object, GString *NewPath){
2779 //sets the status bar if the directory could be not found
2780 TRACEIT(10,"checkDirectory start");
2781 if (Object == NULL){
2782 TRACEIT(2,"checkDirectory end, Parameter NULL");
2783 return -1;
2784 }
2785 GString *buf = g_string_sized_new(20);
2786 GString *buf2 = g_string_sized_new(10);
2787
2788 if (NewPath == NULL){
2789 g_string_assign(buf2, Object->gstrPath->str);
2790 }
2791 else{
2792 g_string_assign(buf2, NewPath->str);
2793 }
2794
2795 if (FALSE == checkStringIsPath(buf2->str)){
2796 g_string_sprintf(buf,"unable to load directory: %s",buf2->str);
2797 gtk_statusbar_pop(Object->StatusBar,0);
2798 gtk_statusbar_push(Object->StatusBar,0,buf->str);
2799 TRACEIT(9,"checkDirectory unable to load directory:");
2800 TRACEIT(9,buf2->str);
2801 g_string_free(buf,TRUE);
2802 g_string_free(buf2,TRUE);
2803 TRACEIT(10,"checkDirectory ends -1");
2804 return -1;
2805 }
2806
2807 g_string_free(buf,TRUE);
2808 g_string_free(buf2,TRUE);
2809 TRACEIT(10,"checkDirectory ends");
2810 return 1;
2811 }
2812
2813
getOtherSideObject(struct SideObjectList * ThisSideObject)2814 struct SideObjectList *getOtherSideObject(struct SideObjectList *ThisSideObject){
2815 TRACEIT(12,"getOtherSideObject start");
2816 struct SideObjectList *otherObject=NULL;
2817 int otherSide=((GtkNotebook *)Notebooks[SIDE_LEFT]==ThisSideObject->notebook)?SIDE_RIGHT:SIDE_LEFT;
2818 SideObjectList_GetActiveObject((GtkNotebook *)Notebooks[otherSide], &otherObject);
2819 TRACEIT(12,"getOtherSideObject ends");
2820 return otherObject;
2821 }
2822
2823
2824
deleteSelectedRowsHelper(GtkTreeModel * model,GtkTreePath * path,GtkTreeIter * iter,gpointer data)2825 static void deleteSelectedRowsHelper(GtkTreeModel *model,GtkTreePath *path,GtkTreeIter *iter,gpointer data){
2826 TRACEIT(10,"deleteSelectedRowsHelper start");
2827 gchar *Name=NULL;
2828 GString *WholeName=g_string_sized_new(300);
2829 struct SideObjectList *Object=(struct SideObjectList *)data;
2830
2831 if (Object->data == NULL){
2832 g_string_free(WholeName,TRUE);
2833 TRACEIT(8,"deleteSelectedRowsHelper end, data=NULL");
2834 return;
2835 }
2836 struct CopyReMoveList **FirstItem = (struct CopyReMoveList **)Object->data;
2837
2838 if (gtk_tree_model_get_iter(model, iter, path)){
2839 gtk_tree_model_get(model, iter, COL_NAME, &Name, -1);
2840 if (!(strcmp(Name, "..")==0 || strcmp(Name,".")==0)){
2841 g_string_assign(WholeName,Name);
2842 cutSpacesFromGString(WholeName);
2843 if (strlen (WholeName->str) == 0){
2844 if (Name)
2845 g_free(Name);
2846 g_string_free(WholeName,TRUE);
2847 TRACEIT(10,"deleteSelectedRowsHelper end 1");
2848 return;
2849 }
2850 g_string_assign(WholeName,Object->gstrPath->str);
2851 checkPathForLastChar(WholeName);
2852 g_string_append(WholeName,Name);
2853 CopyReMoveList_AddItem ( FirstItem, WholeName->str, NULL, Object, NULL, NULL);
2854 }
2855 }
2856 if (Name)
2857 g_free(Name);
2858 g_string_free(WholeName,TRUE);
2859 TRACEIT(10,"deleteSelectedRowsHelper ends");
2860 }
2861
2862
mayDeleteSelectedRows(GtkWidget * menuitem,gpointer data)2863 void mayDeleteSelectedRows(GtkWidget *menuitem, gpointer data){
2864 TRACEIT(10,"mayDeleteSelectedRows start");
2865 GtkWidget *dialog, *label;
2866 GtkTreeSelection *selection;
2867 struct SideObjectList *Object=(struct SideObjectList *)data;
2868 struct CopyReMoveList *FirstItem=NULL;
2869
2870 if (Object->bReadOnly){
2871 TRACEIT(10,"mayDeleteSelectedRows ends");
2872 MyMessageWidget(win, "Read only Tab", "The tab is marked as read only.\nPlease remove this flag to delete\nthe selected items.\n(tab context menu)");
2873 return;
2874 }
2875
2876 Object->data = (void *)&FirstItem;
2877 dialog = CreateMyDialog("Are you absolutly sure?", win, 2, "Cancel",GTK_RESPONSE_REJECT,"Ok",GTK_RESPONSE_ACCEPT, NULL, 0, FALSE);
2878 label = gtk_label_new("Do you realy want to delete\nthe selected Items?");
2879 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox),label);
2880 gtk_widget_show_all(dialog);
2881 if (gtk_dialog_run(GTK_DIALOG(dialog))== GTK_RESPONSE_ACCEPT){
2882 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(Object->listView));
2883 gtk_tree_selection_selected_foreach(selection, deleteSelectedRowsHelper, data);
2884 gtk_widget_destroy(dialog);
2885 if (FirstItem == NULL){
2886 TRACEIT(10,"mayDeleteSelectedRows ends, FirstItem = NULL");
2887 return;
2888 }
2889 ProcessItemsViaListWrap(FirstItem, 3);
2890 }
2891 else{
2892 gtk_widget_destroy(dialog);
2893 }
2894
2895 TRACEIT(10,"mayDeleteSelectedRows ends");
2896 }
2897
2898
copySelectedToAnOtherPannelRowsHelper(GtkTreeModel * model,GtkTreePath * path,GtkTreeIter * iter,gpointer data)2899 static void copySelectedToAnOtherPannelRowsHelper(GtkTreeModel *model,GtkTreePath *path,GtkTreeIter *iter,gpointer data){
2900 TRACEIT(10,"copySelectedToAnOtherPannelRowsHelper start");
2901 if (data == NULL){
2902 TRACEIT(2,"copySelectedToAnOtherPannelRowsHelper end, parameter NULL");
2903 return;
2904 }
2905 struct AllInformationAllUseStruct *stru = (struct AllInformationAllUseStruct *)data;
2906
2907 struct SideObjectList *Object = (struct SideObjectList *)stru->Info_1;
2908 struct SideObjectList *otherObject = (struct SideObjectList *)stru->Info_2;
2909
2910 if (Object == NULL){
2911 TRACEIT(2,"copySelectedToAnOtherPannelRowsHelper ends, NO OBJECT (NULL)");
2912 return;
2913 }
2914 if (otherObject == NULL){ //this function is used for the copy-paste thing too. And therefore the otherObject can be NLL
2915 otherObject=getOtherSideObject(Object); //but we need an otherObject.
2916 }
2917 if (otherObject == NULL){
2918 TRACEIT(2,"copySelectedToAnOtherPannelRowsHelper ends, NO OTHEROBJECT (NULL)");
2919 return;
2920 }
2921
2922 gchar *Name = NULL;
2923 GString *source = g_string_sized_new(100);
2924 GString *dest = g_string_new(otherObject->gstrPath->str);
2925
2926 if (Object->data == NULL){
2927 g_string_free(source,TRUE);
2928 g_string_free(dest,TRUE);
2929 TRACEIT(2,"copySelectedToAnOtherPannelRowsHelper ends, data NULL ItemList for copy...");
2930 return;
2931 }
2932 struct CopyReMoveList **FirstItem = (struct CopyReMoveList **)Object->data;
2933
2934 gtk_tree_model_get(model, iter, COL_NAME, &Name, -1);
2935 g_string_assign(source,Object->gstrPath->str);
2936 checkPathForLastChar(source);
2937 if (!(strcmp(Name, "..")==0 || strcmp(Name,".")==0)){
2938 g_string_append(source,Name);
2939 checkPathForLastCharOtherwise(source);
2940 checkPathForLastCharOtherwise(dest);
2941 if (!g_string_equal(source,dest)){ //this is a simple one and not a complete check, to prevent copying a underlying directory to one inherrited by that one
2942 CopyReMoveList_AddItem ( FirstItem, source->str, dest->str, Object, otherObject, NULL);
2943 }
2944 }
2945
2946 if (Name)
2947 g_free(Name);
2948 g_string_free(source,TRUE);
2949 g_string_free(dest,TRUE);
2950 TRACEIT(10,"copySelectedToAnOtherPannelRowsHelper ends");
2951 }
2952
2953
copyReMoveToAnOtherObject_ListCreate(struct SideObjectList * sourceObject,struct SideObjectList * destObject)2954 void copyReMoveToAnOtherObject_ListCreate(struct SideObjectList *sourceObject, struct SideObjectList *destObject){
2955 //creates the list CopyReMoveList at sourceObject->Data to use with ProcessItemsViaListWrap
2956 TRACEIT(10,"copyReMoveToAnOtherObject_ListCreate start");
2957 if (sourceObject == NULL || destObject == NULL){
2958 TRACEIT(2,"copyReMoveToAnOtherObject_ListCreate ends, parameter NULL");
2959 return;
2960 }
2961 GtkTreeSelection *selection;
2962 struct AllInformationAllUseStruct stru;
2963 stru.Info_1 = (void *)sourceObject;
2964 stru.Info_2 = (void *)destObject;
2965
2966 struct CopyReMoveList *FirstItem=NULL;
2967 sourceObject->data = (void *)&FirstItem;
2968
2969 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(sourceObject->listView));
2970
2971 gtk_tree_selection_selected_foreach(selection, copySelectedToAnOtherPannelRowsHelper, (void *)&stru);
2972
2973 sourceObject->data = (void *)FirstItem; //FirstItem becomes invalid after this function quits, but its value must be saved, its the list
2974 //even it is NULL, its allmost better than pointing to a varibale which does not exist
2975 if (FirstItem == NULL){
2976 TRACEIT(2,"copyReMoveToAnOtherObject_ListCreate ends, no list created");
2977 return;
2978 }
2979
2980 TRACEIT(10,"copyReMoveToAnOtherObject_ListCreate ends");
2981 }
2982
2983
copyToAnOtherPannel(struct SideObjectList * sourceObject,struct SideObjectList * destObject)2984 void copyToAnOtherPannel(struct SideObjectList *sourceObject, struct SideObjectList *destObject){
2985 if (sourceObject == NULL || destObject == NULL){
2986 TRACEIT(2,"copyToAnOtherPannel ends, parameter NULL");
2987 return;
2988 }
2989 copyReMoveToAnOtherObject_ListCreate (sourceObject, destObject);
2990
2991 if (sourceObject->data == NULL){
2992 TRACEIT(10,"copyToAnOtherPannel ends, -1");
2993 return;
2994 }
2995 ProcessItemsViaListWrap((struct CopyReMoveList *)sourceObject->data, 1);
2996 TRACEIT(10,"copyToAnOtherPannel ends");
2997 }
2998
2999
copyToOtherPannel(GtkWidget * menuitem,gpointer data)3000 void copyToOtherPannel(GtkWidget *menuitem, gpointer data){
3001 //gets an sideObject as data, searches the Object on the other side and continues with copyReMoveToAnOtherObject_ListCreate
3002 TRACEIT(10,"copyToOtherPannel start");
3003 if (data == NULL){
3004 TRACEIT(2,"copyToOtherPannel ends, parameter NULL");
3005 return;
3006 }
3007 struct SideObjectList *Object=(struct SideObjectList *)data;
3008
3009 struct SideObjectList *otherObject=getOtherSideObject(Object);
3010 if (otherObject == NULL){
3011 TRACEIT(2,"copyToOtherPannel ends, No other Objectfound");
3012 return;
3013 }
3014
3015 if (otherObject->bReadOnly){
3016 TRACEIT(10,"renameItems ends");
3017 MyMessageWidget(win, "Read only Tab", "The destination tab is marked as read only.\nPlease remove this flag to copy\nthe selected items.\n(tab context menu)");
3018 return;
3019 }
3020
3021 copyToAnOtherPannel (Object, otherObject);
3022
3023 TRACEIT(10,"copyToOtherPannel ends");
3024 }
3025
3026
moveToOtherPannel(GtkWidget * menuitem,gpointer data)3027 void moveToOtherPannel(GtkWidget *menuitem, gpointer data){
3028 TRACEIT(10,"moveToOtherPannel start");
3029 struct SideObjectList *Object=(struct SideObjectList *)data;
3030 //GtkTreeSelection *selection;
3031
3032 struct SideObjectList *otherObject=getOtherSideObject(Object);
3033 if (otherObject == NULL){
3034 TRACEIT(2,"copyToOtherPannel ends, No other Objectfound");
3035 return;
3036 }
3037
3038 if (otherObject->bReadOnly){
3039 TRACEIT(10,"renameItems ends");
3040 MyMessageWidget(win, "Read only Tab", "The destination tab is marked as read only.\nPlease remove this flag to move\nthe selected items.\n(tab context menu)");
3041 return;
3042 }
3043
3044 copyReMoveToAnOtherObject_ListCreate (Object, otherObject);
3045
3046 if (Object->data == NULL){
3047 TRACEIT(10,"moveToOtherPannel ends, -1");
3048 return;
3049 }
3050 ProcessItemsViaListWrap((struct CopyReMoveList *)Object->data, 2);
3051
3052 TRACEIT(10,"moveToOtherPannel ends");
3053 }
3054
3055
CopyPasteCreateList_SideObject(struct SideObjectList * Object,int CopyOrMove)3056 void CopyPasteCreateList_SideObject(struct SideObjectList *Object, int CopyOrMove){
3057 TRACEIT(10,"CopyPasteCreateList_SideObject start");
3058 if (Object == NULL){
3059 TRACEIT(10,"CopyPasteCreateList_SideObject ends");
3060 return;
3061 }
3062 GtkTreeSelection *selection;
3063
3064 if (g_CopyPasteShortcutStruct != NULL){
3065 CopyReMoveList_DeleteList(g_CopyPasteShortcutStruct);
3066 g_CopyPasteShortcutStruct = NULL;
3067 }
3068 Object->data = (void *)&g_CopyPasteShortcutStruct;
3069
3070 struct AllInformationAllUseStruct stru;
3071 stru.Info_1 = (void *)Object;
3072 stru.Info_2 = NULL;
3073
3074 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(Object->listView));
3075
3076 gtk_tree_selection_selected_foreach(selection, copySelectedToAnOtherPannelRowsHelper, (void *)&stru);
3077
3078 if (g_CopyPasteShortcutStruct != NULL){
3079 g_CopyPasteShortcutStruct->CopyMoveOrRemove = CopyOrMove;
3080 }
3081
3082 TRACEIT(10,"CopyPasteCreateList_SideObject ends");
3083 }
3084
3085
CopyPasteProcessList_SideObject(struct SideObjectList * Object)3086 void CopyPasteProcessList_SideObject(struct SideObjectList *Object){
3087 TRACEIT(10,"CopyPasteProcessList_SideObject start");
3088 struct CopyReMoveList *buflist=NULL;
3089
3090 if (g_CopyPasteShortcutStruct == NULL || Object == NULL){
3091 TRACEIT(10,"CopyPasteProcessList_SideObject ends");
3092 return;
3093 }
3094 buflist = g_CopyPasteShortcutStruct;
3095 while (buflist){
3096 buflist->DestObject = Object;
3097 if (buflist->string2){
3098 g_string_assign(buflist->string2, Object->gstrPath->str);
3099 }
3100 else{
3101 buflist->string2 = g_string_new(Object->gstrPath->str);
3102 }
3103 buflist = buflist->NextItem;
3104 }
3105 //The copyPasteShortcutStruct will be freed every time a new one is created and on shutdown
3106 //The list given to ProcessItemsViaListWrap is deleted after completion, therefore the copy
3107 CopyReMoveList_CopyList (&buflist, g_CopyPasteShortcutStruct);
3108 ProcessItemsViaListWrap(buflist, g_CopyPasteShortcutStruct->CopyMoveOrRemove);
3109 if (g_CopyPasteShortcutStruct->CopyMoveOrRemove == 2){ //2 = move
3110 CopyReMoveList_DeleteList(g_CopyPasteShortcutStruct);
3111 g_CopyPasteShortcutStruct = NULL;
3112 }
3113
3114 TRACEIT(10,"CopyPasteProcessList_SideObject ends");
3115 }
3116
3117
openInNewPannelHelper(GtkTreeModel * model,GtkTreePath * path,GtkTreeIter * iter,gpointer data)3118 static void openInNewPannelHelper(GtkTreeModel *model,GtkTreePath *path,GtkTreeIter *iter,gpointer data){
3119 TRACEIT(10,"openInNewPannelHelper start");
3120 struct SideObjectList *Object=(struct SideObjectList *)data;
3121
3122 struct SideObjectList *otherObject=getOtherSideObject(Object);
3123
3124 if (otherObject == NULL){
3125 TRACEIT(10,"openInNewPannelHelper ends");
3126 return;
3127 }
3128
3129 gchar *Name = NULL;
3130 int type_d=0;
3131 GString *NewPath = g_string_sized_new(100);
3132
3133 if (gtk_tree_model_get_iter(model, iter, path)){
3134 gtk_tree_model_get(model, iter, COL_NAME, &Name,COL_TYPE_D, &type_d, -1);
3135 g_string_assign(NewPath,Object->gstrPath->str);
3136 checkPathForLastChar(NewPath);
3137 if (!(strcmp(Name, "..")==0 || strcmp(Name,".")==0) && type_d == 4){
3138 g_string_append(NewPath,Name);
3139 SideObjectList_CreateNewViewWithPath(otherObject->notebook, NewPath->str,Object);
3140 }
3141 }
3142
3143 if (Name)
3144 g_free(Name);
3145 g_string_free(NewPath,TRUE);
3146 TRACEIT(10,"openInNewPannelHelper ends");
3147 }
3148
3149
openInNewPannel(GtkWidget * menuitem,gpointer data)3150 void openInNewPannel(GtkWidget *menuitem, gpointer data){
3151 TRACEIT(10,"openInNewPannel start");
3152 struct SideObjectList *Object=(struct SideObjectList *)data;
3153 GtkTreeSelection *selection;
3154
3155 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(Object->listView));
3156
3157 gtk_tree_selection_selected_foreach(selection, openInNewPannelHelper, data);
3158
3159 TRACEIT(10,"openInNewPannel ends");
3160 }
3161
3162
updatePannels(GtkWidget * menuitem,gpointer data)3163 void updatePannels(GtkWidget *menuitem, gpointer data){ //Updates just one Pannel now
3164 TRACEIT(10,"updatePannels start");
3165 //updateViewWithNewFolder((struct SideObjectList *)data,NULL);
3166 updateViewWithNewFolder_UserAdvice((struct SideObjectList *)data, NULL);
3167 TRACEIT(10,"updatePannels ends");
3168 }
3169
3170
sizeOfSelectedItemsRecursive(GtkWidget * menuitem,gpointer data)3171 void sizeOfSelectedItemsRecursive (GtkWidget *menuitem, gpointer data){ //Get size if selected Items, directories are searched recursivly
3172 TRACEIT(10,"sizeOfSelectedItemsRecursive start");
3173
3174 struct SideObjectList *Object=(struct SideObjectList *)data;
3175 GtkTreeSelection *selection;
3176
3177 if( !g_thread_supported() ){
3178 g_thread_init(NULL);
3179 //gdk_threads_init(); // Called to initialize internal mutex "gdk_threads_mutex".
3180 }
3181 struct RecursiveSizeStructure *stru=malloc(sizeof(struct RecursiveSizeStructure));
3182 stru->mainWin = win;
3183
3184 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(Object->listView));
3185
3186 //Get all selected items
3187 stru->gstrPath=g_string_new(Object->gstrPath->str);
3188 stru->gstrDPItems=NULL;
3189 stru->intPSizes = NULL;
3190 stru->intPTypes = NULL;
3191 stru->ItemStringCounter=0;
3192 stru->ItemCounter=0;
3193 stru->SideObjectOrFileshelfItem=SOURCE_SIDEOBJECT; //SideObject Identifier
3194 gtk_tree_selection_selected_foreach(selection, getSizeOfSelectedItemsRecursive_getItems,(void *) stru);
3195
3196 g_thread_create((GThreadFunc)getSizeOfSelectedItemsRecursive_dialog, (void *)stru , FALSE, NULL);
3197 TRACEIT(10,"sizeOfSelectedItemsRecursive end");
3198 }
3199
3200
getSizeOfSelectedItemsRecursive_getItems(GtkTreeModel * model,GtkTreePath * path,GtkTreeIter * iter,gpointer data)3201 static void getSizeOfSelectedItemsRecursive_getItems (GtkTreeModel *model,GtkTreePath *path,GtkTreeIter *iter,gpointer data){
3202 TRACEIT(10,"getSizeOfSelectedItemsRecursive_getItems start");
3203
3204 struct RecursiveSizeStructure *stru = (struct RecursiveSizeStructure *)data;
3205 gchar *name=NULL;
3206 gint type_d;
3207 GString *gstrBuf = g_string_sized_new(20);
3208 int ret=0;
3209 guint64 isize;
3210
3211 gtk_tree_model_get(model, iter, COL_SIZE, &isize, COL_NAME, &name, COL_TYPE_D, &type_d, -1);
3212 if (name != NULL && strcmp(name,".")!=0 && strcmp(name,"..")!=0){
3213 g_string_assign(gstrBuf,name);
3214 ret = AddNewGStringToDPointer(&(stru->gstrDPItems),stru->ItemCounter, gstrBuf);
3215 if (ret == 0){
3216 stru->ItemStringCounter++;
3217 ret += AddNewGUInt64ToPointerArray(&(stru->intPSizes), stru->ItemCounter, isize);
3218 }
3219 if (ret == 0){
3220 ret += AddNewGUInt64ToPointerArray(&(stru->intPTypes), stru->ItemCounter, (guint64)type_d);
3221 }
3222 if (ret == 0){
3223 stru->ItemCounter++;
3224 }
3225 }
3226
3227 g_string_free(gstrBuf,TRUE);
3228 if (name)
3229 g_free(name);
3230
3231 TRACEIT(10,"getSizeOfSelectedItemsRecursive_getItems end");
3232 }
3233
3234
mayNewDirectory(GtkWidget * menuitem,gpointer data)3235 void mayNewDirectory(GtkWidget *menuitem, gpointer data){
3236 TRACEIT(10,"mayNewDirectory start");
3237 GString *buf = g_string_sized_new(10);
3238 GString *NewDir = g_string_new("New Directory");
3239 struct SideObjectList *Object=(struct SideObjectList *)data;
3240
3241 while ( 0 == MyEasyInputWidget (win, "create directory", "name of the directory to create", NewDir)){
3242 cutSpacesFromGString(buf);
3243 if (strcmp(NewDir->str,".")==0 || strcmp(NewDir->str,"..")==0 || strlen(NewDir->str)==0 || strstr(NewDir->str,"/..")!=NULL ){
3244 MyMessageWidget(win, "not possible", "Iam not allowed to create this Directory.\nThis means me, the programm, not the user.");
3245 }
3246 else{
3247 g_string_assign(buf,Object->gstrPath->str);
3248 checkPathForLastChar(buf);
3249 g_string_append(buf,NewDir->str);
3250 makeDirectory(buf->str,1,NULL);
3251 break;
3252 }
3253 }
3254
3255 g_string_free(buf,TRUE);
3256 g_string_free(NewDir,TRUE);
3257 TRACEIT(10,"mayNewDirectory ends");
3258 }
3259
3260
renameItemsHelper(GtkTreeSelection * selection,struct AllInformationAllUseStruct * info)3261 void renameItemsHelper(GtkTreeSelection *selection, struct AllInformationAllUseStruct *info){
3262 TRACEIT(10,"renameItemsHelper start");
3263 if (selection==NULL || info==NULL){
3264 TRACEIT(2,"renameItemsHelper end, PARAMETER NULL");
3265 return;
3266 }
3267 GtkTreeModel *model;
3268 GList *selList = gtk_tree_selection_get_selected_rows (selection,&model);// = NULL; //
3269 if (selList == NULL){
3270 TRACEIT(4,"renameItemsHelper end, nothing selected?");
3271 return;
3272 }
3273 GList *buflist=selList;
3274 struct SideObjectList *Object=NULL;
3275 GtkTreeIter iter;
3276 int ibreakall=0;
3277 int ret=0;
3278 gchar *Name = NULL;
3279 gchar *Path = NULL;
3280 int sort_column_id;
3281 GtkSortType order;
3282 GtkListStore *listStore = NULL;
3283
3284 GString *source = g_string_sized_new(20);
3285 GString *dest = g_string_sized_new(20);
3286 GString *buf = g_string_sized_new(20);
3287 GString *NewName = g_string_sized_new(20);
3288
3289 if (info->source == SOURCE_SIDEOBJECT){
3290 Object= (struct SideObjectList *)info->Info_1;
3291 listStore=Object->listStore;
3292 //Object->iPreventFromUpdating++;
3293 manipulateCounter (&(Object->iPreventFromUpdating), TRUE, "renameItemsHelper");
3294 }
3295 else{
3296 listStore = (GtkListStore *)info->Info_1;
3297 }
3298 //Whenever working with Pathlists avoid reordering or updating the treeview.
3299 gtk_tree_sortable_get_sort_column_id (GTK_TREE_SORTABLE(listStore), &sort_column_id, &order);
3300 gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE(listStore),GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID, order);
3301
3302 while(buflist){
3303 if (ibreakall==1){
3304 break;
3305 }
3306 if (TRUE != gtk_tree_model_get_iter (model, &iter, (GtkTreePath *)buflist->data)){
3307 break;
3308 }
3309
3310 if (info->source == SOURCE_SIDEOBJECT){
3311 gtk_tree_model_get(model, &iter, COL_NAME, &Name, -1);
3312 }
3313 else{
3314 gtk_tree_model_get(model, &iter, COL_FLSHLF_PATH, &Path, COL_FLSHLF_NAME, &Name, -1);
3315 }
3316 if ((strcmp(Name, "..")==0 || strcmp(Name,".")==0)){
3317 if (Name){
3318 g_free(Name);
3319 Name = NULL;
3320 }
3321 if (Path){
3322 g_free(Path);
3323 Path=NULL;
3324 }
3325
3326 buflist=buflist->next;
3327 continue;
3328 }
3329 if (info->source == SOURCE_SIDEOBJECT){
3330 g_string_assign(source,Object->gstrPath->str);
3331 g_string_assign(dest,Object->gstrPath->str);
3332 }
3333 else{
3334 g_string_assign(source,Path);
3335 g_string_assign(dest,Path);
3336 }
3337 checkPathForLastChar(source);
3338 checkPathForLastChar(dest);
3339 g_string_append(source,Name);
3340
3341 g_string_assign(NewName,Name);
3342 while (1){ //Rename one item - loop
3343 ret = MyEasyInputWidget_Two (win, "rename", Name, NewName, NULL, NULL, "Ok", "Cancel all", "cancel", NULL);
3344 if (1 == ret){ //Cancel all
3345 ibreakall=1;
3346 break;
3347 }
3348 else if (ret != 0){
3349 //printf("break inner while, ret=%d\n",ret);
3350 break; //user pressed cancel
3351 }
3352
3353 g_string_assign(buf, NewName->str);
3354 cutSpacesFromGString(buf);
3355
3356 if (strcmp(buf->str,".")==0 || strcmp(buf->str,"..")==0 || strlen(buf->str)==0 || strstr(buf->str,"/..")!=NULL ){
3357 MyMessageWidget(win, "not possible", "Iam not allowed to rename to this!\nThis means me, the programm, not the user.");
3358 continue;
3359 }
3360
3361 g_string_assign(buf, dest->str);
3362 checkPathForLastChar(buf);
3363 g_string_append(buf,NewName->str);
3364
3365 if (strcmp(source->str,buf->str)==0){ //makes no sence to rename
3366 //printf("source and destination are equal\n");
3367 continue;
3368 }
3369
3370 if (TRUE == g_file_test(buf->str,G_FILE_TEST_EXISTS)){ //ask for permission to overwrite
3371 if (0 != MyEasyInputWidget_Two ((GtkWindow *)win, "overwrite", "There is allready an item with the\nsame name in the destination directory.\nDo you want to overwrite it?\n", NULL, NULL, NULL, "Overwrite", "Cancel", NULL, NULL)){
3372 continue;
3373 }
3374 }
3375
3376 if (0 == g_rename(source->str,buf->str)){
3377 g_string_printf(dest, "renamed: %s TO %s", source->str, buf->str);
3378 textbuffer_commandHistory_addText (dest->str, NULL);
3379 if (TRUE == g_file_test(buf->str,G_FILE_TEST_EXISTS)){
3380 if (info->source == SOURCE_FILESHELF){ //change name on the fileshelf, or the old filename will be marked as missing
3381 gtk_list_store_set (listStore, &iter, COL_FLSHLF_NAME, NewName->str, -1);
3382 }
3383 }
3384 break;
3385 }
3386 else{
3387 g_string_printf(buf, "Renaming item %s returned error:\n%s",Name, strerror(errno));
3388 MyMessageWidget(win, "Error renaming", buf->str);
3389 textbuffer_commandHistory_addText (buf->str, "error");
3390 }
3391 }//while (1)
3392 if (Name){
3393 g_free(Name);
3394 Name = NULL;
3395 }
3396 if (Path){
3397 g_free(Path);
3398 Path=NULL;
3399 }
3400 buflist=buflist->next;
3401 }//while (buflist)
3402
3403 gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE(listStore),sort_column_id, order);
3404
3405 if (info->source == SOURCE_SIDEOBJECT){
3406 //Object->iPreventFromUpdating--;
3407 manipulateCounter (&(Object->iPreventFromUpdating), FALSE, "renameItemsHelper 2");
3408 }
3409
3410 if (Name){
3411 g_free(Name);
3412 Name = NULL;
3413 }
3414 if (Path){
3415 g_free(Path);
3416 Path=NULL;
3417 }
3418 g_string_free(source,TRUE);
3419 g_string_free(dest,TRUE);
3420 g_string_free(buf,TRUE);
3421 g_string_free(NewName,TRUE);
3422
3423 if (selList){
3424 g_list_foreach (selList,(GFunc) gtk_tree_path_free, NULL);
3425 g_list_free (selList);
3426 }
3427
3428 TRACEIT(10,"renameItemsHelper ends");
3429 }
3430
3431
renameItems(GtkWidget * menuitem,gpointer data)3432 void renameItems(GtkWidget *menuitem, gpointer data){
3433 TRACEIT(10,"renameItems start");
3434 struct SideObjectList *Object=(struct SideObjectList *)data;
3435 GtkTreeSelection *selection;
3436 struct AllInformationAllUseStruct info;
3437
3438 if (Object->bReadOnly){
3439 TRACEIT(10,"renameItems ends");
3440 MyMessageWidget(win, "Read only Tab", "The tab is marked as read only.\nPlease remove this flag to rename\nthe selected items.\n(tab context menu)");
3441 return;
3442 }
3443
3444 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(Object->listView));
3445 info.source = SOURCE_SIDEOBJECT;
3446 info.Info_1 = (void *)data;
3447 info.Info_2 = NULL;
3448 info.Info_3 = NULL;
3449 renameItemsHelper(selection, &info);
3450 TRACEIT(10,"renameItems ends");
3451 }
3452
3453
MenuAddItemToFileshelfHelper(GtkTreeModel * model,GtkTreePath * path,GtkTreeIter * iter,gpointer data)3454 void MenuAddItemToFileshelfHelper(GtkTreeModel *model,GtkTreePath *path,GtkTreeIter *iter,gpointer data){
3455 TRACEIT(10,"MenuAddItemToFileshelfHelper start");
3456 struct SideObjectList *Object=(struct SideObjectList *)data;
3457 gchar *Name = NULL;
3458
3459 if (gtk_tree_model_get_iter(model, iter, path)){
3460 gtk_tree_model_get(model, iter, COL_NAME, &Name, -1);
3461 if ((strcmp(Name, "..")==0 || strcmp(Name,".")==0)){
3462 g_free(Name);
3463
3464 TRACEIT(10,"MenuAddItemToFileshelfHelper ends");
3465 return;
3466 }
3467 AddItemToFileshelf(NULL, Name, Object->gstrPath->str, FALSE, 1);
3468
3469 if (Name)
3470 g_free(Name);
3471 }
3472 TRACEIT(10,"MenuAddItemToFileshelfHelper ends");
3473 }
3474
3475
MenuAddItemToFileshelf(GtkWidget * menuitem,gpointer data)3476 void MenuAddItemToFileshelf(GtkWidget *menuitem, gpointer data){
3477 TRACEIT(10,"MenuAddItemToFileshelf start");
3478 struct SideObjectList *Object=(struct SideObjectList *)data;
3479 GtkTreeSelection *selection;
3480
3481 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(Object->listView));
3482
3483 gtk_tree_selection_selected_foreach(selection, MenuAddItemToFileshelfHelper, data);
3484
3485 TRACEIT(10,"MenuAddItemToFileshelf ends");
3486 }
3487
3488
MenuAddToNewFileshelf(GtkWidget * menuitem,gpointer data)3489 void MenuAddToNewFileshelf(GtkWidget *menuitem, gpointer data){
3490 TRACEIT(10,"MenuAddToNewFileshelf start");
3491 if (0==NewFileShelf(NULL)){
3492 MenuAddItemToFileshelf(menuitem, data);
3493 }
3494 TRACEIT(10,"MenuAddToNewFileshelf ends");
3495 }
3496
3497
MenuAddNewFileshelf(GtkWidget * menuitem,gpointer data)3498 void MenuAddNewFileshelf(GtkWidget *menuitem, gpointer data){
3499 TRACEIT(10,"MenuAddNewFileshelf start");
3500 NewFileShelf(NULL);
3501 TRACEIT(10,"MenuAddNewFileshelf ends");
3502 }
3503
3504
searchStringInAndHighlightItemsHelper(GtkTreeModel * model,GtkTreePath * path,GtkTreeIter * iter,gpointer data)3505 void searchStringInAndHighlightItemsHelper(GtkTreeModel *model,GtkTreePath *path,GtkTreeIter *iter,gpointer data){
3506 TRACEIT(10,"searchStringInAndHighlightItemsHelper starat");
3507 struct AllInformationAllUseStruct *info=(struct AllInformationAllUseStruct *)data;
3508 struct SearchItemStruct *theStruct = (struct SearchItemStruct *)info->Info_2;
3509 gchar *Name=NULL;
3510
3511 if (gtk_tree_model_get_iter(model, iter, path)){
3512 if (info->source == SOURCE_SIDEOBJECT){
3513 gtk_tree_model_get(model, iter, COL_NAME, &Name, -1);
3514 }
3515 else{
3516 gtk_tree_model_get(model, iter, COL_FLSHLF_NAME, &Name, -1);
3517 }
3518 if ((strcmp(Name, "..")==0 || strcmp(Name,".")==0)){
3519 gtk_tree_selection_unselect_iter(theStruct->selection, iter);
3520 if (Name)
3521 g_free(Name);
3522 TRACEIT(10,"searchStringInAndHighlightItemsHelper ends");
3523 return;
3524 }
3525 if (strcasestr(Name,theStruct->gstrSearchString->str) == NULL){ //strcasestr returns charpointer
3526 gtk_tree_selection_unselect_iter(theStruct->selection, iter);
3527 }
3528 }
3529 if (Name)
3530 g_free(Name);
3531 TRACEIT(10,"searchStringInAndHighlightItemsHelper ends");
3532 return;
3533 }
3534
3535
searchStringInAndHighlightItems(GtkWidget * menuitem,gpointer data)3536 void searchStringInAndHighlightItems(GtkWidget *menuitem, gpointer data){
3537 TRACEIT(10,"searchStringInAndHighlightItems start");
3538 struct AllInformationAllUseStruct *info=(struct AllInformationAllUseStruct *)data;
3539 struct SearchItemStruct theStruct;
3540 GtkTreeSelection *selection;
3541 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(info->Info_1));
3542 GString *SearchString = g_string_sized_new(10);
3543 GString *buf = g_string_sized_new(10);
3544 theStruct.gstrSearchString = g_string_sized_new(100);
3545
3546 while (0 == MyEasyInputWidget (win, "search", "\nSearches all selected Items for the string you enter.\n", SearchString)){
3547 g_string_assign(buf, SearchString->str);
3548
3549 cutSpacesFromGString(buf);
3550 if (strlen(buf->str)==0 || /*strcmp(buf->str,".")==0 || strcmp(buf->str,"..")==0 || */ strstr(buf->str,"/..")!=NULL ){
3551 MyMessageWidget(win, "not possible", "Makes not much sense to search for this! Haeah!?");
3552 }
3553 else{
3554 theStruct.selection = selection;
3555 g_string_assign(theStruct.gstrSearchString, SearchString->str);
3556 info->Info_2=(void *)&theStruct;
3557 gtk_tree_selection_selected_foreach(selection, searchStringInAndHighlightItemsHelper, (void *)info);
3558 break;
3559 }
3560 }
3561
3562 g_string_free(theStruct.gstrSearchString,TRUE);
3563 g_string_free(SearchString,TRUE);
3564 g_string_free(buf,TRUE);
3565
3566 TRACEIT(10,"searchStringInAndHighlightItems ends");
3567 }
3568
3569
searchStringInAndHighlightItems_WraperforSideObject(GtkWidget * menuitem,gpointer data)3570 void searchStringInAndHighlightItems_WraperforSideObject(GtkWidget *menuitem, gpointer data){
3571 TRACEIT(10,"searchStringInAndHighlightItems_WraperforSideObject start");
3572 struct AllInformationAllUseStruct info;
3573 info.source = SOURCE_SIDEOBJECT;
3574 info.Info_1 = (void *)data;
3575 searchStringInAndHighlightItems(menuitem, (void *)&info);
3576 TRACEIT(10,"searchStringInAndHighlightItems_WraperforSideObject start");
3577 }
3578
3579
searchStringInDirectoryRecursive_SideObject(GtkWidget * menuitem,struct SideObjectList * Object)3580 void searchStringInDirectoryRecursive_SideObject(GtkWidget *menuitem, struct SideObjectList *Object){
3581 TRACEIT(10,"searchStringInDirectoryRecursive_SideObject start");
3582
3583 GList *glistDirectories = NULL;
3584
3585 glistDirectories = g_list_append (glistDirectories, Object->gstrPath);
3586
3587 if (glistDirectories != NULL){
3588 find_simple(glistDirectories); //this call will copy the whole list, we can delete it and its data!
3589
3590 //g_list_foreach(glistDirectories, (GFunc) GListFreeGStrings, NULL); //do not delete this GString here, we do not own it
3591 g_list_free(glistDirectories);
3592 }
3593
3594 TRACEIT(10,"searchStringInDirectoryRecursive_SideObject start");
3595 }
3596
3597
callAllWith_WraperforSideObject(GtkWidget * menuitem,gpointer data)3598 void callAllWith_WraperforSideObject(GtkWidget *menuitem, gpointer data){
3599 TRACEIT(10,"callAllWith_WraperforSideObject start");
3600 CallUsersDummyCommand (data, SOURCE_SIDEOBJECT, USERCOMMAND_CALLTYPE_ALL);
3601 TRACEIT(10,"callAllWith_WraperforSideObject ends");
3602 }
3603
3604
callEachWith_WraperforSideObject(GtkWidget * menuitem,gpointer data)3605 void callEachWith_WraperforSideObject(GtkWidget *menuitem, gpointer data){
3606 TRACEIT(10,"callEachWith_WraperforSideObject start");
3607
3608 CallUsersDummyCommand (data, SOURCE_SIDEOBJECT, USERCOMMAND_CALLTYPE_EACH);
3609
3610 TRACEIT(10,"callEachWith_WraperforSideObject ends");
3611 }
3612
3613
checkIfOneSelectionIsPathHelper(GtkTreeModel * model,GtkTreePath * path,GtkTreeIter * iter,gpointer data)3614 void checkIfOneSelectionIsPathHelper(GtkTreeModel *model,GtkTreePath *path,GtkTreeIter *iter,gpointer data){
3615 TRACEIT(10,"checkIfOneSelectionIsPathHelper start");
3616 int type_d;
3617 struct AllInformationAllUseStruct *stru = (struct AllInformationAllUseStruct *)data;
3618 gint *TheInfo = (gint *)stru->Info_1;
3619 int *Coloumn = (int *)stru->Info_2;
3620
3621 gtk_tree_model_get(model, iter, *Coloumn, &type_d, -1);
3622 if (type_d==4 || type_d==10){
3623 *TheInfo = *TheInfo + 1;
3624 TRACEIT(10,"checkIfOneSelectionIsPathHelper ends");
3625 return;
3626 }
3627
3628 TRACEIT(10,"checkIfOneSelectionIsPathHelper ends");
3629 return;
3630 }
3631
3632
checkIfOneSelectionIsPath(gpointer data,int ColoumnToUse)3633 int checkIfOneSelectionIsPath(gpointer data, int ColoumnToUse){
3634 TRACEIT(10,"checkIfOneSelectionIsPath start");
3635 GtkTreeSelection *selection;
3636 gint IsPath=0;
3637 struct AllInformationAllUseStruct stru;
3638 stru.Info_1 = &IsPath;
3639 stru.Info_2 = &ColoumnToUse;
3640
3641 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(data));
3642 gtk_tree_selection_selected_foreach(selection, checkIfOneSelectionIsPathHelper, &stru);
3643
3644 TRACEIT(10,"checkIfOneSelectionIsPath ends");
3645 return IsPath;
3646 }
3647
3648
checkIfOneSelectionIsPointsHelper(GtkTreeModel * model,GtkTreePath * path,GtkTreeIter * iter,gpointer data)3649 void checkIfOneSelectionIsPointsHelper(GtkTreeModel *model,GtkTreePath *path,GtkTreeIter *iter,gpointer data){
3650 TRACEIT(10,"checkIfOneSelectionIsPointsHelper start");
3651 struct AllInformationAllUseStruct *stru = (struct AllInformationAllUseStruct *)data;
3652 gint *TheInfo = (gint *)stru->Info_1;
3653 int *Coloumn = (int *)stru->Info_2;
3654
3655 gchar *name=NULL;
3656
3657 if (gtk_tree_model_get_iter(model, iter, path)){
3658 gtk_tree_model_get(model, iter, *Coloumn, &name, -1);
3659 if (strcmp(name,".")==0 || strcmp(name,"..")==0){
3660 *TheInfo = *TheInfo + 1;
3661
3662 if (name)
3663 g_free(name);
3664 TRACEIT(10,"checkIfOneSelectionIsPointsHelper ends");
3665 return;
3666 }
3667 }
3668 if (name)
3669 g_free(name);
3670 TRACEIT(10,"checkIfOneSelectionIsPointsHelper ends");
3671 return;
3672 }
3673
3674
checkIfOneSelectionIsPoints(gpointer data,int ColoumnToUse)3675 int checkIfOneSelectionIsPoints(gpointer data, int ColoumnToUse){
3676 TRACEIT(10,"checkIfOneSelectionIsPoints start");
3677 GtkTreeSelection *selection;
3678 gint IsPath=0;
3679 struct AllInformationAllUseStruct stru;
3680 stru.Info_1 = &IsPath;
3681 stru.Info_2 = &ColoumnToUse;
3682
3683 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(data));
3684 gtk_tree_selection_selected_foreach(selection, checkIfOneSelectionIsPointsHelper, &stru);
3685
3686 TRACEIT(10,"checkIfOneSelectionIsPoints ends");
3687 return IsPath;
3688 }
3689
3690
getTypesOfSelectedItemsHelper(GtkTreeModel * model,GtkTreePath * path,GtkTreeIter * iter,gpointer data)3691 void getTypesOfSelectedItemsHelper(GtkTreeModel *model,GtkTreePath *path,GtkTreeIter *iter,gpointer data){
3692 TRACEIT(10,"getTypesOfSelectedItemsHelper start");
3693 gchar *type=NULL;
3694 struct AllInformationAllUseStruct *info = (struct AllInformationAllUseStruct *)data;
3695 //struct TypesOfSelectedItemsList *bufitem=NULL;
3696 GList **TheList = (GList **)info->Info_2;
3697 GList *bufItem = NULL;
3698 //GString *gstrBuf = g_string_sized_new(10);
3699
3700 if (info->source == SOURCE_SIDEOBJECT){
3701 gtk_tree_model_get(model, iter, COL_FILETYPE, &type, -1);
3702 }
3703 else{
3704 gtk_tree_model_get(model, iter, COL_FLSHLF_FILETYPE, &type, -1);
3705 }
3706 if (strcmp(type,"--")==0){
3707 //g_string_free(gstrBuf, TRUE);
3708 TRACEIT(10,"getTypesOfSelectedItemsHelper ends");
3709 return;
3710 }
3711
3712 bufItem = g_list_first (*TheList);
3713 while (bufItem){
3714 if (strcmp(type, ((GString *)(bufItem->data))->str)==0){
3715 if (type)
3716 g_free(type);
3717 //g_string_free(gstrBuf, TRUE);
3718 TRACEIT(10,"getTypesOfSelectedItemsHelper ends");
3719 return;
3720 }
3721 bufItem = bufItem->next;
3722 }
3723
3724 *TheList = g_list_append (*TheList,(void *)g_string_new(type));
3725
3726 if (type)
3727 g_free(type);
3728 TRACEIT(10,"getTypesOfSelectedItemsHelper ends");
3729 return;
3730 }
3731
3732
getTypesOfSelectedItems(struct AllInformationAllUseStruct * info)3733 GList *getTypesOfSelectedItems(struct AllInformationAllUseStruct *info){
3734 //do not forget to free the returned list, the data in the list are GString, which also have to be freed!
3735 //use: g_list_foreach(listDirs, (GFunc) GListFreeGStrings, NULL); g_list_free(listDirs);
3736 TRACEIT(10,"getTypesOfSelectedItems start");
3737 //struct AllInformationAllUseStruct *info = (struct AllInformationAllUseStruct *)data;
3738 if (info == NULL){
3739 TRACEIT(2,"getTypesOfSelectedItems parameter NULL");
3740 return NULL;
3741 }
3742
3743
3744 GtkTreeSelection *selection;
3745 GList *glistTypesList=NULL;
3746
3747 info->Info_2 = (void *)&glistTypesList;
3748 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(info->Info_1));
3749 gtk_tree_selection_selected_foreach(selection, getTypesOfSelectedItemsHelper, (void *)info);
3750 TRACEIT(10,"getTypesOfSelectedItems ends");
3751 return glistTypesList;
3752 }
3753
3754
getUserProgramsForSelectedItems(GList * glistMarkedTypes,struct UserDataList ** theUserDataList)3755 int getUserProgramsForSelectedItems(GList *glistMarkedTypes, struct UserDataList **theUserDataList){
3756 //DO NOT FORGET TO FREE THE RETURNED LIST!!!! in theUserDataList
3757 //writes a list which holds all the usercommands which are assigned to the marked items
3758 //
3759 //glistMarkedTypes can be NULL, in this case only the targets with countforall flag are written to theUserDataList
3760 //if glistMarkedTypes is not NULL, this items are also copied
3761 //return: -1=error, 0=ok
3762 TRACEIT(10,"getUserProgramsForSelectedItems start");
3763
3764
3765 struct _UserCommandList *AllUserCommandList = NULL;
3766 GList *glistBuf = NULL;
3767 int found = 0;
3768
3769 if ( theUserDataList==NULL){
3770 TRACEIT(2,"getUserProgramsForSelectedItems ends, Parameter NULL");
3771 return -1;
3772 }
3773
3774 if (*theUserDataList != NULL){
3775 TRACEIT(4,"getUserProgramsForSelectedItems theUserDataList output is not NULL, going to free this list");
3776 UserDataList_DeleteList (theUserDataList);
3777 }
3778
3779 configFileHandling_loadConfigFile ( FALSE, FALSE );
3780
3781 AllUserCommandList = g_UserCommandList;
3782
3783 while (AllUserCommandList){
3784 if (glistMarkedTypes)
3785 glistBuf = g_list_first ( glistMarkedTypes );
3786 else
3787 glistBuf = NULL;
3788 found = 0;
3789 while (glistBuf){
3790 if (TRUE == UserCommandList_ItemHasTarget (AllUserCommandList, ((GString *)(glistBuf->data))->str) ){
3791 found = 1;
3792 if (*theUserDataList==NULL || NULL == UserDataList_getItemByListElement (*theUserDataList, (void *)AllUserCommandList) ){
3793 UserDataList_AddItem (theUserDataList, AllUserCommandList->gstrName->str, (void *)AllUserCommandList);
3794 }
3795 }
3796 glistBuf = glistBuf->next;
3797 }
3798 if (found == 0 && TRUE == UserCommandList_ItemHasTarget (AllUserCommandList, COUNTSFORALLITEMSKEY) ){
3799 UserDataList_AddItem (theUserDataList, AllUserCommandList->gstrName->str, (void *)AllUserCommandList);
3800 }
3801 AllUserCommandList = AllUserCommandList->nextItem;
3802 }
3803 TRACEIT(10,"getUserProgramsForSelectedItems ends");
3804 return 0;
3805 }
3806
3807
glistComparePointer(gconstpointer a,gconstpointer b)3808 gint glistComparePointer (gconstpointer a, gconstpointer b){
3809 if (a>b)
3810 return 1;
3811 else if (a<b)
3812 return -1;
3813 else
3814 return 0;
3815 }
3816
3817
getStandardStartDirectory(GString * gstrCommand)3818 void getStandardStartDirectory(GString *gstrCommand){//, GString *gstrCommandName){
3819 TRACEIT(10,"getStandardStartDirectory start");
3820 if (gstrCommand==NULL /*|| gstrCommandName==NULL*/){
3821 TRACEIT(2,"getStandardStartDirectory ends -1 fatal: parameter are NULL");
3822 return;
3823 }
3824
3825 configFileHandling_loadConfigFile( FALSE, FALSE );
3826 struct _OptionsList *StdStartDirItem = OptionsList_getItemByID(g_OptionsList, STANDARDSTARTDIRECTORY);
3827 if (StdStartDirItem == NULL /*|| StdStartDirItem->gstrName==NULL */|| StdStartDirItem->gstrValue==NULL){
3828 getHomeDirectory(gstrCommand);
3829 //g_string_assign(gstrCommandName, "home");
3830 TRACEIT(10,"getStandardStartDirectory ends -1");
3831 return;
3832 }
3833 g_string_assign (gstrCommand, StdStartDirItem->gstrValue->str);
3834
3835 TRACEIT(10,"getStandardStartDirectory ends");
3836 }
3837
3838
MakeList_Helper(GtkTreeModel * model,GtkTreePath * path,GtkTreeIter * iter,gpointer data)3839 void MakeList_Helper (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data){
3840 TRACEIT(10,"MakeList_Helper start");
3841 struct AllInformationAllUseStruct *info = (struct AllInformationAllUseStruct *)data;
3842 if (info == NULL){
3843 return;
3844 }
3845 gchar *Name = NULL;
3846 gchar *Path = NULL;
3847 GString *gstrSource = g_string_new(((GString *)info->Info_2)->str);
3848 GString *gstrDest = g_string_new(((GString *)info->Info_3)->str);
3849 struct CopyReMoveList **FirstItem = (struct CopyReMoveList **)info->Info_1;
3850
3851 if (info->source == SOURCE_SIDEOBJECT){
3852 gtk_tree_model_get(model, iter, COL_NAME, &Name, -1);
3853 checkPathForLastChar(gstrSource);
3854 if (!(strcmp(Name, "..")==0 || strcmp(Name,".")==0)){
3855 g_string_append(gstrSource,Name);
3856 checkPathForLastCharOtherwise(gstrSource);
3857 g_string_prepend_c(gstrSource,'\"');
3858 g_string_append_c(gstrSource,'\"');
3859 checkPathForLastCharOtherwise(gstrDest);
3860 CopyReMoveList_AddItem ( FirstItem, gstrSource->str, gstrDest->str, NULL, NULL, NULL);
3861 }
3862 }
3863 else{
3864 gtk_tree_model_get(model, iter, COL_FLSHLF_NAME, &Name, COL_FLSHLF_PATH, &Path, -1);
3865 g_string_assign(gstrSource,Path);
3866 checkPathForLastChar(gstrSource);
3867 if (!(strcmp(Name, "..")==0 || strcmp(Name,".")==0)){
3868 g_string_append(gstrSource,Name);
3869 checkPathForLastCharOtherwise(gstrSource);
3870 g_string_prepend_c(gstrSource,'\"');
3871 g_string_append_c(gstrSource,'\"');
3872 checkPathForLastCharOtherwise(gstrDest);
3873 CopyReMoveList_AddItem ( FirstItem, gstrSource->str, gstrDest->str, NULL, NULL, NULL);
3874 }
3875 }
3876
3877 if (Name)
3878 g_free(Name);
3879 if (Path)
3880 g_free(Path);
3881 g_string_free(gstrSource,TRUE);
3882 g_string_free(gstrDest,TRUE);
3883 TRACEIT(10,"MakeList_Helper ends");
3884 }
3885
3886
MakeList(int Source,struct CopyReMoveList ** FirstItem,GtkTreeSelection * selection,GString * SourcePath,GString * gstrDestPath)3887 int MakeList (int Source, struct CopyReMoveList **FirstItem, GtkTreeSelection *selection, GString *SourcePath, GString *gstrDestPath){
3888 TRACEIT(10,"MakeList start");
3889 if (FirstItem == NULL || selection == NULL){
3890 return -1;
3891 }
3892 struct AllInformationAllUseStruct info;
3893 info.source = Source;
3894 info.Info_1 = (void *)FirstItem;
3895 info.Info_2 = (void *)SourcePath;
3896 info.Info_3 = (void *)gstrDestPath;
3897
3898 gtk_tree_selection_selected_foreach(selection, MakeList_Helper, (void *)&info);
3899
3900 if (*FirstItem == NULL){
3901 TRACEIT(3,"MakeList end -1");
3902 return -1;
3903 }
3904 TRACEIT(10,"MakeList end");
3905 return 0;
3906 }
3907
createItemList_Helper(GtkTreeModel * model,GtkTreePath * path,GtkTreeIter * iter,gpointer data)3908 void createItemList_Helper (GtkTreeModel *model,GtkTreePath *path,GtkTreeIter *iter,gpointer data){
3909 TRACEIT(10,"createItemList_Helper start");
3910 struct AllInformationAllUseStruct *info = (struct AllInformationAllUseStruct *)data;
3911 if (info == NULL){
3912 TRACEIT(2,"createItemList_Helper end, Parameter NULL");
3913 return;
3914 }
3915 //info struct has :
3916 //info.Info_1 = (void *)&WithPath;
3917 //info.Info_2 = (void *)&glistTheList; //do copy the list to here
3918 //info.Info_3 = (void *)UserDataListItem->Object;
3919
3920 if (info->Info_1 == NULL || info->Info_2 == NULL || info->Info_3 == NULL){
3921 TRACEIT(2,"createItemList_Helper end, Parameter NULL");
3922 return;
3923 }
3924
3925 gchar *Name = NULL;
3926 gchar *Path = NULL;
3927 GList **glistBufList = (GList **)info->Info_2;
3928 GString *gstrPathBuf = g_string_sized_new(20);
3929 GString *gstrSaveString = NULL;
3930 int iWithPath = *(int *)(info->Info_1);
3931
3932 if (info->source == SOURCE_SIDEOBJECT){
3933 gtk_tree_model_get(model, iter, COL_NAME, &Name, -1);
3934 g_string_assign (gstrPathBuf, ((struct SideObjectList *)info->Info_3)->gstrPath->str);
3935 }
3936 else if (info->source == SOURCE_FILESHELF){
3937 gtk_tree_model_get(model, iter, COL_FLSHLF_NAME, &Name, COL_FLSHLF_PATH, &Path, -1);
3938 g_string_assign (gstrPathBuf, Path);
3939 }
3940 if (!(strcmp(Name, "..")==0 || strcmp(Name,".")==0)){
3941 gstrSaveString = g_string_new (Name);
3942 if (iWithPath == 1){
3943 checkPathForLastChar (gstrPathBuf);
3944 g_string_prepend (gstrSaveString, gstrPathBuf->str);
3945 }
3946 *glistBufList = g_list_prepend (*glistBufList, gstrSaveString);
3947 }
3948
3949 if (Name)
3950 g_free(Name);
3951 if (Path)
3952 g_free(Path);
3953 g_string_free(gstrPathBuf, TRUE);
3954 }
3955
3956
createItemList(struct UserDataList * UserDataListItem,GtkWidget * ListView,int WithPath)3957 GList *createItemList (struct UserDataList *UserDataListItem, GtkWidget *ListView, int WithPath){
3958 //creates a GList which holds all the items marked in ListView
3959 //we need UserDataListItem to decide if we are a SideObject or a Fileshelf
3960 //WithPath = 0 -> No Path added to the names, =1 -> The Path of each item is added
3961 TRACEIT (10, "createItemList start");
3962 if (UserDataListItem == NULL || ListView == NULL){
3963 TRACEIT (2, "createItemList Parameter NULL");
3964 return NULL;
3965 }
3966 GtkTreeSelection *selection=NULL;
3967 GList *glistTheList = NULL;
3968
3969 struct AllInformationAllUseStruct info;
3970 info.source = UserDataListItem->iSourceType;
3971 info.Info_1 = (void *)&WithPath;
3972 info.Info_2 = (void *)&glistTheList;
3973 info.Info_3 = (void *)UserDataListItem->Object;
3974
3975
3976 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(ListView));
3977 gtk_tree_selection_selected_foreach(selection, createItemList_Helper, (void *)&info);
3978
3979 glistTheList = g_list_reverse(glistTheList);
3980
3981
3982 TRACEIT (10, "createItemList end");
3983 return glistTheList;
3984 }
3985
3986
startTerminal_WraperforSideObject(GtkWidget * menuitem,struct SideObjectList * Object)3987 void startTerminal_WraperforSideObject (GtkWidget *menuitem, struct SideObjectList *Object){
3988 TRACEIT(10,"startTerminal_WraperforSideObject start");
3989 UserOption_callTerminal(Object, SOURCE_SIDEOBJECT);
3990 TRACEIT(10,"startTerminal_WraperforSideObject end");
3991 }
3992
startStandardEditor_WraperforSideObject(GtkWidget * menuitem,struct SideObjectList * Object)3993 void startStandardEditor_WraperforSideObject (GtkWidget *menuitem, struct SideObjectList *Object){
3994 TRACEIT(10,"startStandardEditor_WraperforSideObject start");
3995 UserOption_callStandardEditor(Object, SOURCE_SIDEOBJECT);
3996 TRACEIT(10,"startStandardEditor_WraperforSideObject end");
3997 }
3998
3999
startItemsWithUserCommand(GtkWidget * menuitem,struct UserDataList * UserDataListItem)4000 void startItemsWithUserCommand(GtkWidget *menuitem, struct UserDataList *UserDataListItem){
4001 //this is the main entry point for calling usercommands.
4002 //every time we give a command to the shell we should use this function.
4003 //UserDataListItem will be copied in here and not used in any following function or thread
4004 TRACEIT(10,"startItemsWithUserCommand start");
4005
4006 if (UserDataListItem == NULL){
4007 TRACEIT(2,"startItemsWithUserCommand end, parameter NULL");
4008 return;
4009 }
4010 if (UserDataListItem->ListElement == NULL || UserDataListItem->Object==NULL){
4011 TRACEIT(2,"startItemsWithUserCommand end, parameter 2 NULL");
4012 return;
4013 }
4014
4015 //we first collect all information we may use. this means we create different lists which hold
4016 //the items with and without path.
4017
4018 //to do that, we first need a listview:
4019 GtkWidget * ListView = NULL;
4020 GList * glistItemsWithPath = NULL;
4021 GList * glistItemsWithoutPath = NULL;
4022 GString * gstrHomeDir = NULL;
4023 GString * gstrLeftSidePath = NULL;
4024 GString * gstrRightSidePath = NULL;
4025 GString * gstrThisSidePath = NULL; //only set if we come from an SideObject
4026 GString * gstrOtherSidePath = NULL;//only set if we come from an SideObject
4027 struct SideObjectList * BufObject = NULL;
4028 struct UserDataList * OurUserDataListItem = NULL; //this will save the UserDataListItem (realcopy) for further usage within the following thread
4029 struct _UserCommandList *UserCommandListItem = NULL;
4030 int iRet = 0;
4031
4032 if (UserDataListItem->iSourceType == SOURCE_SIDEOBJECT){
4033 ListView = ((struct SideObjectList *)UserDataListItem->Object)->listView;
4034 }
4035 else if(UserDataListItem->iSourceType == SOURCE_FILESHELF){
4036 ListView = ((struct FileShelfObjectList *)UserDataListItem->Object)->listView;
4037 }
4038
4039 if (ListView == NULL){
4040 TRACEIT (2, "startItemsWithUserCommand end, Unknown Source type!");
4041 return;
4042 }
4043
4044 UserCommandListItem = (struct _UserCommandList *)UserDataListItem->ListElement;
4045 if (UserCommandListItem == NULL){
4046 TRACEIT (2, "startItemsWithUserCommand end, UserCommandList NULL");
4047 return;
4048 }
4049 //now we want some additional information such as home directory
4050 //left side path, right side path and the item lists
4051 //get the home directory
4052 gstrHomeDir = g_string_sized_new (20);
4053 getHomeDirectory(gstrHomeDir);
4054 checkPathForLastCharOtherwise(gstrHomeDir);
4055 //get the left/right side pathes
4056 SideObjectList_GetActiveObject((GtkNotebook *)Notebooks[SIDE_LEFT], &BufObject);
4057 if (BufObject){
4058 gstrLeftSidePath = g_string_new(BufObject->gstrPath->str);
4059 }
4060 SideObjectList_GetActiveObject((GtkNotebook *)Notebooks[SIDE_RIGHT], &BufObject);
4061 if (BufObject){
4062 gstrRightSidePath = g_string_new(BufObject->gstrPath->str);
4063 }
4064 //the other side and this side gstrings only gots filled when we come from a SideObject
4065 if (UserDataListItem->iSourceType == SOURCE_SIDEOBJECT){
4066 gstrThisSidePath = g_string_new ( ((struct SideObjectList *)(UserDataListItem->Object))->gstrPath->str );
4067 gstrOtherSidePath = g_string_new ( (getOtherSideObject((struct SideObjectList *)(UserDataListItem->Object)))->gstrPath->str);
4068 }
4069
4070 //all this lists are NOT QUOTED!!!
4071 glistItemsWithoutPath = createItemList (UserDataListItem, ListView, 0); //0=without path
4072 glistItemsWithPath = createItemList (UserDataListItem, ListView, 1); //1=with path
4073 //if (glistItemsWithPath == NULL || glistItemsWithoutPath == NULL){
4074 //iRet = -1;
4075 //}
4076
4077 //we now will copy (this means realy copy) the UserDataListItem so we do not loose the information stored in there
4078 //when the list gets deleled while we are not yet finished with it.
4079 //because we will start a thread which to process the command and call it to the system.
4080 UserDataList_AddItem(&OurUserDataListItem, UserDataListItem->gstrMenuName->str, NULL);
4081 if (OurUserDataListItem == NULL){
4082 iRet = -1;
4083 TRACEIT (2, "startItemsWithUserCommand Error allocating new memory");
4084 }
4085 else{
4086 OurUserDataListItem->iSourceType = UserDataListItem->iSourceType;
4087 iRet = UserCommandList_copyItemToList ( ((struct _UserCommandList **)&(OurUserDataListItem->ListElement)), UserCommandListItem);
4088 }
4089
4090 if (iRet != -1 && UserDataListItem->iSourceType == SOURCE_SIDEOBJECT && ((struct _UserCommandList *)(OurUserDataListItem->ListElement))->gstrWorkingDir == NULL){
4091 UserCommandList_editItem( ((struct _UserCommandList *)(OurUserDataListItem->ListElement)), -1, NULL, NULL, NULL, -1, NULL, NULL, NULL, NULL, NULL, NULL, ((struct SideObjectList *)UserDataListItem->Object)->gstrPath->str);
4092 }
4093
4094 //now that we have all the information we want we can think about starting a thread to call the command to the system
4095 if (iRet != -1){
4096 //!!! the function CallUserCommand_StartThread will free all the variables given to them!
4097 iRet = CallUserCommand_StartThread (OurUserDataListItem, glistItemsWithPath, glistItemsWithoutPath, gstrThisSidePath, gstrOtherSidePath, gstrLeftSidePath, gstrRightSidePath, gstrHomeDir);
4098 }
4099
4100 //free things here
4101 if (iRet == -1){
4102 //in this case no thread was started which could free the things. so let us do this
4103 if (glistItemsWithPath){
4104 g_list_foreach(glistItemsWithPath, (GFunc) GListFreeGStrings, NULL); g_list_free(glistItemsWithPath);
4105 }
4106 if (glistItemsWithoutPath){
4107 g_list_foreach(glistItemsWithoutPath, (GFunc) GListFreeGStrings, NULL); g_list_free(glistItemsWithoutPath);
4108 }
4109 if (gstrHomeDir)
4110 g_string_free(gstrHomeDir, TRUE);
4111 if (gstrLeftSidePath)
4112 g_string_free(gstrLeftSidePath, TRUE);
4113 if (gstrRightSidePath)
4114 g_string_free(gstrRightSidePath, TRUE);
4115 if (gstrThisSidePath)
4116 g_string_free(gstrThisSidePath, TRUE);
4117 if (gstrOtherSidePath)
4118 g_string_free(gstrOtherSidePath, TRUE);
4119
4120 if (OurUserDataListItem){
4121 UserCommandList_freeList( ((struct _UserCommandList **)&OurUserDataListItem->ListElement));
4122 UserDataList_DeleteList(&OurUserDataListItem);
4123 }
4124 }
4125
4126 return;
4127 }
4128
4129
CallUsersDummyCommand(void * Object,int iSource,int iCallType)4130 void CallUsersDummyCommand (void *Object, int iSource, int iCallType){
4131 TRACEIT(10,"callAllWith start");
4132 //this function will ask the user for the command
4133 //Object is SideObject or FileShelfObject, iSource makes this clear
4134
4135 //struct AllInformationAllUseStruct *info= (struct AllInformationAllUseStruct *)data;
4136 if (Object == NULL){
4137 TRACEIT (2, "callAllWith parameter NULL");
4138 return;
4139 }
4140
4141 GString *gstrCommand = g_string_sized_new(10);
4142 GString *gstrBuf = g_string_sized_new(10);
4143 struct UserDataList *theDummyItem = malloc (sizeof (struct UserDataList));
4144 if (theDummyItem == NULL){
4145 TRACEIT (3, "CallUsersDummyCommand unable to allocate memory");
4146 return ;
4147 }
4148
4149 while (0 == MyEasyInputWidget (win, "open all with", "type in with which command you want to\nexecute the selected files.\nThey will be added to the end on one single line.", gstrCommand)){
4150 g_string_assign(gstrBuf, gstrCommand->str);
4151
4152 cutSpacesFromGString(gstrBuf);
4153 if (strcmp(gstrBuf->str,".")==0 || strcmp(gstrBuf->str,"..")==0 || strlen(gstrBuf->str)==0 || strstr(gstrBuf->str,"/..")!=NULL ){
4154 MyMessageWidget(win, "not possible", "Iam not allowed to call this!\nThis means me, the programm, not the user");
4155 }
4156 else{
4157 g_string_append (gstrCommand, " $(MI_WP_Q)");
4158 UserDataList_CreateDummyCommand (theDummyItem, gstrCommand->str, Object, iSource, iCallType );
4159 startItemsWithUserCommand(NULL, theDummyItem);
4160 UserCommandList_freeList( (struct _UserCommandList **)&((theDummyItem->ListElement)) );
4161 UserDataList_DeleteList(&theDummyItem);
4162 theDummyItem = NULL;
4163 break;
4164 }
4165 }
4166 if (theDummyItem != NULL){
4167 free (theDummyItem);
4168 }
4169
4170 g_string_free(gstrCommand, TRUE);
4171 g_string_free(gstrBuf, TRUE);
4172
4173 return;
4174 }
4175
4176
4177 #ifdef WORKING
4178
workingMenuItem(GtkWidget * menuitem,gpointer data)4179 void workingMenuItem(GtkWidget *menuitem, gpointer data){
4180 // MyMessageWidget(NULL,"etst","terste");
4181 //createUserCommand_start (NULL);
4182 GtkTreeViewColumn *col=NULL;
4183 struct SideObjectList *Object = NULL;
4184 const char *ccpBuf = NULL;
4185
4186 SideObjectList_GetActiveObject( (GtkNotebook *)Notebooks[0], &Object);
4187 if (Object == NULL){
4188 printf("OBJECT NULL\n");
4189 return;
4190 }
4191
4192 col = gtk_tree_view_get_column ( (GtkTreeView *)Object->listView, 2);
4193
4194
4195
4196
4197
4198
4199 ccpBuf = gtk_tree_view_column_get_title (col);
4200
4201 printf ("ccpBuf = %s\n",ccpBuf);
4202
4203 /*
4204 configFileHandling_Init();
4205 configFileHandling_loadConfigFile(FALSE, FALSE);
4206 debugOut_PrintLists();
4207 configFileHandling_clearForShutdown();
4208 */
4209 /*
4210 //XML PARSER START
4211 GMarkupParser Parser;
4212 Parser.start_element = foundStart;
4213 Parser.end_element = foundend;
4214 Parser.text = foundtext;
4215 Parser.passthrough = NULL;
4216 Parser.error = NULL;
4217 GError *err=NULL;
4218
4219 FILE *thefile = fopen ("/wurzel/TMP/new.xml", "r");
4220 if (thefile == NULL){
4221 MyMessageWidget(NULL,"etst","error opening xml file");
4222 }
4223
4224 GMarkupParseContext *cont = g_markup_parse_context_new (&Parser, 0, NULL, NULL); //G_MARKUP_TREAT_CDATA_AS_TEXT
4225
4226
4227 char line[401];
4228 while (NULL != fgets(line, 400, thefile)){
4229 //MyMessageWidget(NULL, "feeding line:",line);
4230 if (FALSE == g_markup_parse_context_parse (cont, line, strlen(line), &err)){
4231 MyMessageWidget(NULL, "Parser Error",err->message);
4232 }
4233 }
4234
4235 g_markup_parse_context_free (cont);
4236 //XML PARSER end
4237
4238
4239
4240 */ //GString *gstrBuf = g_string_sized_new(10);
4241 /*
4242 GVfs *gfvsMine = g_vfs_get_local ();
4243
4244 GFile *gfile= g_vfs_get_file_for_uri (gfvsMine, "ftp://ftp.freebsd.org/pub/FreeBSD/releases/i386/ISO-IMAGES/8.0/");
4245
4246 const char * const *cppList = g_vfs_get_supported_uri_schemes (gfvsMine);
4247 while (*cppList){
4248 //g_string_append(gstrBuf, *cppList);
4249 //g_string_append(gstrBuf, "\n");
4250 // cppList++;
4251 printf("string: %s\n",*cppList);
4252 cppList++;
4253 }
4254 //g_string_free(gstrBuf, TRUE);
4255
4256 //MyMessageWidget (NULL, "test", gstrBuf->str);
4257
4258 g_object_unref(gfile);
4259 */
4260 /*
4261 //GFile - Directory read START
4262 GError *err=NULL;
4263 GString *gstrNames = g_string_sized_new(10);
4264 GString *gstrBuf = g_string_sized_new(10);
4265
4266 //GFile *gfilePath = g_file_new_for_path ("ftp://anonymous@ftp.freebsd.org/pub/FreeBSD/releases/i386/ISO-IMAGES/7.2/");
4267 GFile *gfilePath = g_file_new_for_uri ("ftp://anonymous@ftp.freebsd.org/pub/FreeBSD/releases/i386/ISO-IMAGES/7.2/");
4268 //GFile *gfilePath = g_file_parse_name ("ftp://anonymous@ftp.freebsd.org/pub/FreeBSD/releases/i386/ISO-IMAGES/7.2/");
4269
4270
4271
4272 if (g_file_is_native(gfilePath) == TRUE){
4273 MyMessageWidget(NULL, "dfsdf","g_file_is_native returned TRUE");
4274 }
4275 else{
4276 MyMessageWidget(NULL, "dfsdf","g_file_is_native returned FALSE");
4277 }
4278 //"file:///wurzel/TMP"
4279 //g_file_get_uri_scheme
4280 //g_file_has_uri_scheme
4281 //"ftp://anonymous@ftp.freebsd.org/pub/FreeBSD/releases/i386/ISO-IMAGES/7.2/"
4282 //smb:///drhibbert/Lesbar/filme
4283 g_string_append(gstrNames, g_file_get_path (gfilePath));
4284 g_string_append(gstrNames, "\n");
4285 char *cpScheme = g_file_get_uri_scheme (gfilePath);
4286 g_string_append(gstrNames, cpScheme);
4287 g_string_append(gstrNames, "\n\n");
4288
4289 //MyMessageWidget(NULL,"lits", gstrNames->str);
4290
4291 GFileEnumerator *enumerator = g_file_enumerate_children (gfilePath, "standard::name", G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, NULL, &err); //G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS
4292
4293 if (err != NULL){
4294 g_string_printf(gstrBuf, "%d:%s",err->code, err->message);
4295 MyMessageWidget(NULL,"111",gstrBuf->str);
4296 g_error_free(err);
4297 err=NULL;
4298 }
4299
4300 GFileInfo *gfinfo = NULL;
4301 char *cpName=NULL;
4302 gfinfo = g_file_enumerator_next_file (enumerator, NULL, &err);
4303
4304 if (err != NULL){
4305 MyMessageWidget(NULL,"222",err->message);
4306 g_error_free(err);
4307 err=NULL;
4308 }
4309 do{
4310 cpName = g_file_info_get_attribute_as_string (gfinfo, G_FILE_ATTRIBUTE_STANDARD_NAME);
4311 g_string_append(gstrNames, cpName);
4312 g_string_append(gstrNames, "\n");
4313 gfinfo = g_file_enumerator_next_file (enumerator, NULL, &err);
4314 if (err != NULL){
4315 MyMessageWidget(NULL,"333",err->message);
4316 g_error_free(err);
4317 err=NULL;
4318 }
4319 }while(gfinfo!=NULL);
4320
4321 MyMessageWidget(NULL,"lits", gstrNames->str);
4322
4323 if (err)
4324 g_error_free(err);
4325 g_string_free(gstrNames, TRUE);
4326 g_string_free(gstrBuf, TRUE);
4327
4328 g_file_enumerator_close (enumerator,NULL,NULL);
4329 g_object_unref(enumerator);
4330 g_object_unref(gfinfo);
4331 // g_object_unref(stream);
4332
4333 */ //GFile - Directory read END
4334
4335
4336
4337
4338 //########################################################################
4339 //########################################################################
4340 //########################################################################
4341 //########################################################################
4342 //########################################################################
4343 //########################################################################
4344 //########################################################################
4345 //########################################################################
4346
4347 }
4348
4349 #endif
4350 /////////////////////////////////////////////////////////////////////////////////////
4351 ////////////////////// CONTEXTMENU /////////////////////////////////////////
4352 /////////////////////////////////////////////////////////////////////////////////////
4353
4354
openContextMenu(GtkWidget * treeview,GdkEventButton * event,gpointer data)4355 void openContextMenu(GtkWidget *treeview, GdkEventButton *event, gpointer data){
4356 TRACEIT(10,"openContextMenu start");
4357 GtkWidget *menu, *menuitem;
4358 struct SideObjectList *Object=(struct SideObjectList *)data;
4359 menu = gtk_menu_new();
4360 struct AllInformationAllUseStruct info;
4361 info.source = SOURCE_SIDEOBJECT;
4362 info.Info_1 = (void *)Object->listView;
4363 GtkTreeSelection *selection;
4364 GtkWidget *sep1, *sep2, *sep3, *sep4, *sep5;
4365 int NumOfSelectedRows=0;
4366 GList *glistMarkedTypes=NULL;
4367 struct _OptionsList *OptionsListBuf = NULL;
4368
4369 if (NULL != g_UserDataList){
4370 UserDataList_DeleteList(&g_UserDataList);
4371 //g_UserDataList = NULL; //this is allready done by the deleteList function
4372 }
4373
4374 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview));
4375 //NumOfSelectedRows = gtk_tree_selection_count_selected_rows(selection);
4376 if (gtk_tree_selection_count_selected_rows(selection) <= 1 && event != NULL){ //Event can be NULL if the key for contextmenu is presed
4377 GtkTreePath *path;
4378 TRACEIT(11,"openContextMenu mark the item coverd by mousepointer");
4379 if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(treeview), (gint) event->x, (gint) event->y, &path, NULL, NULL, NULL)){
4380 gtk_tree_selection_unselect_all(selection);
4381 gtk_tree_selection_select_path(selection, path);
4382 gtk_tree_path_free(path);
4383 }
4384 }
4385 NumOfSelectedRows = gtk_tree_selection_count_selected_rows(selection);
4386
4387 TRACEIT(11,"openContextMenu create seperator");
4388 sep1 = gtk_separator_menu_item_new ();
4389 sep2 = gtk_separator_menu_item_new ();
4390 sep3 = gtk_separator_menu_item_new ();
4391 sep4 = gtk_separator_menu_item_new ();
4392 sep5 = gtk_separator_menu_item_new ();
4393
4394 menuitem = gtk_menu_item_new_with_label("update panel");
4395 g_signal_connect(menuitem,"activate",G_CALLBACK(updatePannels),data);
4396 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
4397
4398 TRACEIT(11,"openContextMenu check for one selection is path");
4399 if (checkIfOneSelectionIsPath(Object->listView, COL_TYPE_D) != 0){
4400 menuitem = gtk_menu_item_new_with_label("open in new panel");
4401 g_signal_connect(menuitem,"activate", G_CALLBACK( openInNewPannel),data);
4402 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
4403 }
4404
4405 TRACEIT(11,"openContextMenu fill the terminal structure");
4406
4407 OptionsListBuf = OptionsList_getItemByID(g_OptionsList, TERMINALKEY);
4408 if (OptionsListBuf!=NULL && OptionsListBuf->gstrName!= NULL && OptionsListBuf->gstrValue!=NULL){
4409 menuitem = gtk_menu_item_new_with_label(OptionsListBuf->gstrName->str);
4410 g_signal_connect(menuitem,"activate",G_CALLBACK(startTerminal_WraperforSideObject),data);
4411 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
4412 }
4413
4414 menuitem = gtk_menu_item_new_with_label("search for...");
4415 g_signal_connect(menuitem, "activate", G_CALLBACK(searchStringInDirectoryRecursive_SideObject), Object);
4416 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
4417
4418
4419 if (NumOfSelectedRows >= 1){
4420 menuitem = gtk_menu_item_new_with_label("search highlighted...");
4421 g_signal_connect(menuitem,"activate",G_CALLBACK(searchStringInAndHighlightItems_WraperforSideObject),Object->listView);
4422 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
4423
4424 menuitem = gtk_menu_item_new_with_label("size...");
4425 g_signal_connect(menuitem,"activate",G_CALLBACK(sizeOfSelectedItemsRecursive),Object);
4426 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
4427 }
4428
4429 gtk_menu_shell_append(GTK_MENU_SHELL(menu), sep1);
4430
4431 //UserProgams/////////////////////////////////////////
4432 TRACEIT(11,"openContextMenu starting with user command section");
4433
4434 if (checkIfOneSelectionIsPath(Object->listView, COL_TYPE_D)==0 && NumOfSelectedRows>0){
4435 //if (NumOfSelectedRows != 0){
4436 OptionsListBuf = OptionsList_getItemByID(g_OptionsList, STANDARDEDITORKEY);
4437 if (OptionsListBuf!=NULL && OptionsListBuf->gstrName!= NULL && OptionsListBuf->gstrValue!=NULL){
4438 menuitem = gtk_menu_item_new_with_label(OptionsListBuf->gstrName->str);
4439 g_signal_connect(menuitem,"activate",G_CALLBACK(startStandardEditor_WraperforSideObject),data);
4440 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
4441 }
4442 //}
4443
4444 glistMarkedTypes = getTypesOfSelectedItems(&info);
4445 if (glistMarkedTypes != NULL)
4446 getUserProgramsForSelectedItems(glistMarkedTypes, &g_UserDataList); //u will get the commands which 'countForAllItems' too
4447 if (NULL != glistMarkedTypes){
4448 g_list_foreach(glistMarkedTypes, (GFunc) GListFreeGStrings, NULL);
4449 g_list_free(glistMarkedTypes);
4450 glistMarkedTypes = NULL;
4451 }
4452 }
4453 else if (checkIfOneSelectionIsPoints(Object->listView, COL_NAME) == 0){
4454 getUserProgramsForSelectedItems(NULL, &g_UserDataList); //this will only get the commands which 'countForAll'
4455 }
4456
4457
4458 //UserCommand_CreateUserMenu(menu);
4459 struct MenuObjectList *MenuObjectListForMenuCreation = NULL;
4460 if (g_UserDataList != NULL){
4461 UserCommand_CreateUserMenu(menu, g_UserDataList, &MenuObjectListForMenuCreation);
4462
4463 struct UserDataList *UserDataListBuf = UserDataList_getFirstItem(g_UserDataList);
4464 while (UserDataListBuf){
4465 UserDataListBuf->iSourceType = SOURCE_SIDEOBJECT;
4466 UserDataListBuf->Object = (void *)data;
4467
4468 menuitem = gtk_menu_item_new_with_label(UserDataListBuf->gstrMenuName->str);
4469 g_signal_connect(menuitem,"activate",G_CALLBACK(startItemsWithUserCommand),UserDataListBuf);
4470 gtk_menu_shell_append(GTK_MENU_SHELL(UserDataListBuf->MenuToAddTo), menuitem);
4471 UserDataListBuf = UserDataListBuf->nextItem;
4472 }
4473 }
4474 if (MenuObjectListForMenuCreation != NULL){
4475 UserCommand_AttachUserMenu(MenuObjectListForMenuCreation);
4476 MenuObjectList_DeleteList (&MenuObjectListForMenuCreation);
4477 }
4478
4479 TRACEIT(11,"openContextMenu end usercommand section");
4480 //EndUserPrograms/////////////////////////////////////
4481
4482 gtk_menu_shell_append(GTK_MENU_SHELL(menu), sep2);
4483
4484 if (NumOfSelectedRows >= 1){
4485 menuitem = gtk_menu_item_new_with_label("open all with...");
4486 g_signal_connect(menuitem,"activate",G_CALLBACK(callAllWith_WraperforSideObject),data);
4487 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
4488
4489 menuitem = gtk_menu_item_new_with_label("open each with...");
4490 g_signal_connect(menuitem,"activate",G_CALLBACK(callEachWith_WraperforSideObject),data);
4491 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
4492 }
4493 gtk_menu_shell_append(GTK_MENU_SHELL(menu), sep3);
4494
4495 if (NumOfSelectedRows >= 1){
4496 menuitem = gtk_menu_item_new_with_label("copy to other panel");
4497 g_signal_connect(menuitem,"activate", G_CALLBACK( copyToOtherPannel),data);
4498 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
4499
4500 menuitem = gtk_menu_item_new_with_label("move to other panel");
4501 g_signal_connect(menuitem,"activate",G_CALLBACK(moveToOtherPannel),data);
4502 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
4503
4504 menuitem = gtk_menu_item_new_with_label("rename...");
4505 g_signal_connect(menuitem,"activate",G_CALLBACK(renameItems),data);
4506 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
4507 }
4508
4509 menuitem = gtk_menu_item_new_with_label("new directory...");
4510 g_signal_connect(menuitem,"activate",G_CALLBACK(mayNewDirectory),data);
4511 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
4512
4513 gtk_menu_shell_append(GTK_MENU_SHELL(menu), sep4);
4514
4515 if (NumOfSelectedRows >= 1){
4516 menuitem = gtk_menu_item_new_with_label("add to fileshelf");
4517 g_signal_connect(menuitem,"activate",G_CALLBACK(MenuAddItemToFileshelf),data);
4518 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
4519
4520 menuitem = gtk_menu_item_new_with_label("add to new fileshelf");
4521 g_signal_connect(menuitem,"activate",G_CALLBACK(MenuAddToNewFileshelf),data);
4522 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
4523 }
4524
4525 gtk_menu_shell_append(GTK_MENU_SHELL(menu), sep5);
4526
4527 if (NumOfSelectedRows >= 1){
4528 menuitem = gtk_menu_item_new_with_label("remove");
4529 g_signal_connect(menuitem, "activate", G_CALLBACK( mayDeleteSelectedRows), data);
4530 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
4531 }
4532
4533 gtk_widget_show_all(menu);
4534 // Note: event can be NULL here when called from view_onPopupMenu;
4535 // gdk_event_get_time() accepts a NULL argument
4536 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, (event != NULL) ? event->button : 0, gdk_event_get_time((GdkEvent*)event));
4537
4538
4539 TRACEIT(10,"openContextMenu ends");
4540 }
4541
4542
openTabContextMenu(GtkWidget * notebook,GdkEventButton * event,gpointer data)4543 void openTabContextMenu(GtkWidget *notebook, GdkEventButton *event, gpointer data){
4544 TRACEIT(10,"openTabContextMenu start");
4545 GtkWidget *menu, *menuitem, *menuNewBookmarks, *menuGoToBookmarks, *menuInternals;
4546 menu = gtk_menu_new();
4547
4548 menuNewBookmarks = gtk_menu_new();
4549 menuGoToBookmarks = gtk_menu_new();
4550 menuInternals = gtk_menu_new();
4551 GtkWidget *sep1, *sep2, *sep3, *sep4, *sep5, *sep6;
4552
4553 sep1 = gtk_separator_menu_item_new ();
4554 sep2 = gtk_separator_menu_item_new ();
4555 sep3 = gtk_separator_menu_item_new ();
4556 sep4 = gtk_separator_menu_item_new ();
4557 sep5 = gtk_separator_menu_item_new ();
4558 sep6 = gtk_separator_menu_item_new ();
4559
4560 struct SideObjectList *Object=NULL;
4561 SideObjectList_GetActiveObject((GtkNotebook *)notebook, &Object);
4562
4563 //////////////////////////////////////////////////////////////////////
4564 //////// BookmarkMenu start //////////////////////////////////////////////
4565
4566 struct MenuObjectList *MenuObjectListForMenuCreation = NULL;
4567 struct UserDataList *UserDataListBuf = NULL;
4568
4569 if (NULL != g_UserDataList){
4570 UserDataList_DeleteList(&g_UserDataList);
4571 //g_UserDataList = NULL; //this is allready done by the deleteList function
4572 }
4573 UserDataListFromBookmarkList(&g_UserDataList); //loads list from file
4574 if (g_UserDataList != NULL){
4575 UserCommand_CreateUserMenu(menuNewBookmarks, g_UserDataList, &MenuObjectListForMenuCreation);
4576 UserDataListBuf = UserDataList_getFirstItem(g_UserDataList);
4577 while (UserDataListBuf){
4578 //UserDataListBuf->iSourceType = SOURCE_SIDEOBJECT;
4579 UserDataListBuf->Object = (void *)notebook;
4580 menuitem = gtk_menu_item_new_with_label(UserDataListBuf->gstrMenuName->str);
4581 g_signal_connect(menuitem,"activate",G_CALLBACK(addNewPageFromBookmarks),UserDataListBuf);
4582 gtk_menu_shell_append(GTK_MENU_SHELL(UserDataListBuf->MenuToAddTo), menuitem);
4583 UserDataListBuf->MenuToAddTo = NULL; //delete the reference or the following menucreation will fail
4584 UserDataListBuf = UserDataListBuf->nextItem;
4585 }
4586 if (MenuObjectListForMenuCreation != NULL){ //maybe noone of the items has a menu
4587 UserCommand_AttachUserMenu(MenuObjectListForMenuCreation);
4588 MenuObjectList_DeleteList (&MenuObjectListForMenuCreation);
4589 }
4590 }
4591 //if (NULL != g_UserDataList){
4592 // UserDataList_DeleteList(&g_UserDataList);
4593 //g_UserDataList = NULL; //this is allready done by the deleteList function
4594 //}
4595 //UserDataListFromBookmarkList(&g_UserDataList); //loads list from file
4596 if (g_UserDataList != NULL){
4597 UserCommand_CreateUserMenu(menuGoToBookmarks, g_UserDataList, &MenuObjectListForMenuCreation);
4598 UserDataListBuf = UserDataList_getFirstItem(g_UserDataList);
4599 while (UserDataListBuf){
4600 //UserDataListBuf->iSourceType = SOURCE_SIDEOBJECT;
4601 UserDataListBuf->Object = (void *)notebook;
4602 menuitem = gtk_menu_item_new_with_label(UserDataListBuf->gstrMenuName->str);
4603 g_signal_connect(menuitem,"activate",G_CALLBACK(goToFromBookmarks),UserDataListBuf);
4604 gtk_menu_shell_append(GTK_MENU_SHELL(UserDataListBuf->MenuToAddTo), menuitem);
4605 UserDataListBuf = UserDataListBuf->nextItem;
4606 }
4607 if (MenuObjectListForMenuCreation != NULL){ //maybe noone of the items has a menu
4608 UserCommand_AttachUserMenu(MenuObjectListForMenuCreation);
4609 MenuObjectList_DeleteList (&MenuObjectListForMenuCreation);
4610 }
4611
4612 menuitem = gtk_menu_item_new_with_label("new page from Bookmark");
4613 gtk_menu_item_set_submenu ((GtkMenuItem *)menuitem,menuNewBookmarks);
4614 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
4615
4616 menuitem = gtk_menu_item_new_with_label("go to Bookmark");
4617 gtk_menu_item_set_submenu ((GtkMenuItem *)menuitem,menuGoToBookmarks);
4618 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
4619 }
4620 //////// BookmarkMenu end //////////////////////////////////////////////
4621 //////////////////////////////////////////////////////////////////////
4622
4623 menuitem = gtk_menu_item_new_with_label("new page");
4624 g_signal_connect(menuitem,"activate",G_CALLBACK(addNewPage),notebook);
4625 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
4626
4627 gtk_menu_shell_append(GTK_MENU_SHELL(menu), sep1);
4628
4629 menuitem = gtk_menu_item_new_with_label("dublicate active page");
4630 g_signal_connect(menuitem,"activate",G_CALLBACK(dublicateActivePage),notebook);
4631 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
4632
4633 if (1<gtk_notebook_get_n_pages(GTK_NOTEBOOK(notebook))){
4634 menuitem = gtk_menu_item_new_with_label("move active page");
4635 g_signal_connect(menuitem,"activate",G_CALLBACK(moveActivePage),notebook);
4636 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
4637 }
4638
4639 menuitem = gtk_menu_item_new_with_label("copy active page");
4640 g_signal_connect(menuitem,"activate",G_CALLBACK(copyActivePage),notebook);
4641 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
4642
4643 gtk_menu_shell_append(GTK_MENU_SHELL(menu), sep2);
4644 //INTERNAL MENU START
4645 menuitem = gtk_menu_item_new_with_label("property page...");
4646 g_signal_connect(menuitem, "activate", G_CALLBACK(internal_startPropPage), NULL);
4647 gtk_menu_shell_append(GTK_MENU_SHELL(menuInternals), menuitem);
4648
4649 menuitem = gtk_menu_item_new_with_label("save pathes and FileShelfs");
4650 g_signal_connect(menuitem,"activate",G_CALLBACK(internalSavePathesAndShelfs),NULL);
4651 gtk_menu_shell_append(GTK_MENU_SHELL(menuInternals), menuitem);
4652
4653 gtk_menu_shell_append(GTK_MENU_SHELL(menuInternals), sep4);
4654
4655 menuitem = gtk_menu_item_new_with_label("command history");
4656 g_signal_connect(menuitem,"activate",G_CALLBACK(internalMenuCommandHistory),NULL);
4657 gtk_menu_shell_append(GTK_MENU_SHELL(menuInternals), menuitem);
4658
4659 gtk_menu_shell_append(GTK_MENU_SHELL(menuInternals), sep5);
4660
4661 menuitem = gtk_menu_item_new_with_label("about Cat'sEyE");
4662 g_signal_connect(menuitem,"activate",G_CALLBACK(internalMenuAbout),NULL);
4663 gtk_menu_shell_append(GTK_MENU_SHELL(menuInternals), menuitem);
4664
4665 menuitem = gtk_menu_item_new_with_label("internals");
4666 gtk_menu_item_set_submenu ((GtkMenuItem *)menuitem,menuInternals);
4667 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
4668
4669 //INTERNAL MENU END
4670
4671 gtk_menu_shell_append(GTK_MENU_SHELL(menu), sep3);
4672
4673 if (g_int_AlwaysShowHidden==0){
4674 menuitem = gtk_menu_item_new_with_label("always show hidden files (all tabs)");
4675 }
4676 else{
4677 menuitem = gtk_menu_item_new_with_label("do not show hidden files (all tabs)");
4678 }
4679 g_signal_connect(menuitem,"activate",G_CALLBACK(AlwaysShowHiddenfilesInAllTabs),NULL);
4680 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
4681
4682 if (Object != NULL){
4683 if (Object->showHiddenFiles){
4684 menuitem = gtk_menu_item_new_with_label("hide hidden files (this tab)");
4685 }
4686 else{
4687 menuitem = gtk_menu_item_new_with_label("show hidden files (this tab)");
4688 }
4689 }
4690 else{
4691 menuitem = gtk_menu_item_new_with_label("show hidden files");
4692 }
4693 g_signal_connect(menuitem,"activate",G_CALLBACK(showHiddenFilesInActivePage),notebook);
4694 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
4695
4696 if (Object != NULL){
4697 if (0 != Object->iPreview){
4698 menuitem = gtk_menu_item_new_with_label("disable preview");
4699 }
4700 if (0 == Object->iPreview){
4701 menuitem = gtk_menu_item_new_with_label("enable picture preview");
4702 }
4703 g_signal_connect(menuitem,"activate",G_CALLBACK(ChangePreviewState),Object);
4704 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
4705 }
4706
4707
4708 if (Object != NULL){
4709 if (FALSE == Object->bReadOnly){
4710 menuitem = gtk_menu_item_new_with_label("mark tab as read only");
4711 }
4712 else{
4713 menuitem = gtk_menu_item_new_with_label("mark tab as writable");
4714 }
4715 g_signal_connect(menuitem,"activate",G_CALLBACK(ChangeReadOnlyState),Object);
4716 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
4717 }
4718
4719
4720 gtk_menu_shell_append(GTK_MENU_SHELL(menu), sep6);
4721
4722 if (1<gtk_notebook_get_n_pages(GTK_NOTEBOOK(notebook))){
4723 menuitem = gtk_menu_item_new_with_label("close active page");
4724 g_signal_connect(menuitem,"activate",G_CALLBACK(closeActivePage),notebook);
4725 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
4726 }
4727
4728 #ifdef WORKING
4729 menuitem = gtk_menu_item_new_with_label("Working item");
4730 g_signal_connect(menuitem,"activate",G_CALLBACK(workingMenuItem),NULL);
4731 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
4732
4733 #endif
4734
4735
4736 gtk_widget_show_all(menu);
4737 // Note: event can be NULL here when called from view_onPopupMenu;
4738 // gdk_event_get_time() accepts a NULL argument
4739 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, (event != NULL) ? event->button : 0, gdk_event_get_time((GdkEvent*)event));
4740
4741 TRACEIT(10,"openTabContextMenu ends");
4742 }
4743
4744 ////////////////////// CONTEXTMENU /////////////////////////////////////////
4745 /////////////////////////////////////////////////////////////////////////////////////
4746
internal_startPropPage(GtkWidget * menuitem,gpointer data)4747 void internal_startPropPage (GtkWidget *menuitem, gpointer data){
4748 propPage_startPropPage ();
4749 }
4750
4751
internalSavePathesAndShelfs(GtkWidget * menuitem,gpointer data)4752 void internalSavePathesAndShelfs(GtkWidget *menuitem, gpointer data){
4753 GtkWidget *dialog, *label;
4754 GString *gstrBuf = g_string_sized_new(10);
4755
4756 g_string_sprintf(gstrBuf,"This will save the currently opened directories\nand FileShelfs to the standard file in your home directory:\n%s\n",SAVE_FILE);
4757
4758 dialog = CreateMyDialog("Save Session", win, 2, "Ok",GTK_RESPONSE_ACCEPT,"Cancel",GTK_RESPONSE_REJECT, NULL, 0, FALSE);
4759 label = gtk_label_new(gstrBuf->str);
4760 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox),label);
4761 gtk_widget_show_all(dialog);
4762 if (gtk_dialog_run(GTK_DIALOG(dialog))== GTK_RESPONSE_ACCEPT){
4763 saveThings();
4764 }
4765 gtk_widget_destroy(dialog);
4766 g_string_free(gstrBuf, TRUE);
4767 }
4768
4769
goToFromBookmarks(GtkWidget * menuitem,struct UserDataList * UserDataListItem)4770 void goToFromBookmarks(GtkWidget *menuitem, struct UserDataList *UserDataListItem){
4771 TRACEIT(10,"goToFromBookmarks start");
4772 //struct bookmarklist *Bookmark=(struct bookmarklist *)data;
4773
4774 struct SideObjectList *Object=NULL;
4775
4776 if (UserDataListItem == NULL){
4777 TRACEIT (4, "addNewPageFromBookmarks parameter NULL");
4778 return;
4779 }
4780 SideObjectList_GetActiveObject((GtkNotebook *)UserDataListItem->Object, &Object);
4781 if (Object == NULL){
4782 TRACEIT(4,"goToFromBookmarks no active object");
4783 return;
4784 }
4785 struct _OptionsList *optionsListItem = UserDataListItem->ListElement;
4786 if (optionsListItem == NULL){
4787 TRACEIT (4, "addNewPageFromBookmarks parameter 2 NULL");
4788 return;
4789 }
4790 if (optionsListItem->gstrValue == NULL){
4791 TRACEIT (4, "addNewPageFromBookmarks parameter 3 NULL");
4792 return;
4793 }
4794 updateViewWithNewFolder(Object, optionsListItem->gstrValue);
4795 TRACEIT(10,"goToFromBookmarks ends");
4796 }
4797
4798
addNewPageFromBookmarks(GtkWidget * menuitem,struct UserDataList * UserDataListItem)4799 void addNewPageFromBookmarks(GtkWidget *menuitem, struct UserDataList *UserDataListItem){
4800 TRACEIT(10,"addNewPageFromBookmarks start");
4801 //struct bookmarklist *Bookmark=(struct bookmarklist *)data;
4802 if (UserDataListItem == NULL){
4803 TRACEIT (4, "addNewPageFromBookmarks parameter NULL");
4804 return;
4805 }
4806 struct _OptionsList *optionsListItem = UserDataListItem->ListElement;
4807 if (optionsListItem == NULL){
4808 TRACEIT (4, "addNewPageFromBookmarks parameter 2 NULL");
4809 return;
4810 }
4811 if (optionsListItem->gstrValue == NULL){
4812 TRACEIT (4, "addNewPageFromBookmarks parameter 3 NULL");
4813 return;
4814 }
4815
4816 SideObjectList_CreateNewViewWithPath((GtkNotebook *)UserDataListItem->Object, optionsListItem->gstrValue->str,NULL);
4817 TRACEIT(10,"addNewPageFromBookmarks ends");
4818 }
4819
4820
AlwaysShowHiddenfilesInAllTabs()4821 void AlwaysShowHiddenfilesInAllTabs(){
4822 TRACEIT(10,"AlwaysShowHiddenfilesInAllTabs start");
4823 gboolean boolBuf=FALSE;
4824 if (1==g_int_AlwaysShowHidden){
4825 TRACEIT(11,"AlwaysShowHiddenfilesInAllTabs hide");
4826 g_int_AlwaysShowHidden=0;
4827 boolBuf=FALSE;
4828 }
4829 else{
4830 TRACEIT(11,"AlwaysShowHiddenfilesInAllTabs show");
4831 g_int_AlwaysShowHidden=1;
4832 boolBuf=TRUE;
4833 }
4834
4835 struct SideObjectList *ObjectBuf = SideObjectList_getFirstObject();
4836 while (ObjectBuf != NULL){
4837 calcDirectorySizeInView_closeProcess (&(ObjectBuf->iRecursiveSizeCalculation), &(ObjectBuf->gthreadF6Updage), &(ObjectBuf->bUpdateFlag_F6), &(ObjectBuf->iPreventFromUpdating), TRUE);
4838 ObjectBuf->alwaysShowHiddenFiles=boolBuf;
4839 //ObjectBuf->bUpdateFlag_F6=FALSE;
4840 //updating only the visible views is not enought, because we show a (h) in the tabs, when hidden flag is on
4841 SideObjectList_UpdateObject(ObjectBuf);
4842 ObjectBuf = SideObjectList_getNextObejct(ObjectBuf);
4843 }
4844
4845 updateActiveViews(); //the tabs are updated within the while loop
4846
4847 TRACEIT(10,"AlwaysShowHiddenfilesInAllTabs end");
4848 }
4849
4850
ChangeReadOnlyState(GtkWidget * menuitem,gpointer data)4851 void ChangeReadOnlyState (GtkWidget *menuitem, gpointer data){
4852 TRACEIT(10,"ChangeReadOnlyState start");
4853
4854 struct SideObjectList *Object = (struct SideObjectList *)data;
4855
4856 if (Object->PreviewCol == NULL){
4857 TRACEIT(10,"ChangeReadOnlyState ends");
4858 return;
4859 }
4860
4861 Object->bReadOnly = !(Object->bReadOnly);
4862
4863 SideObjectList_UpdateObject(Object);
4864
4865 TRACEIT(10,"ChangeReadOnlyState end");
4866 }
4867
4868
ChangePreviewState(GtkWidget * menuitem,gpointer data)4869 void ChangePreviewState(GtkWidget *menuitem, gpointer data){
4870 // data is a SideObject
4871 TRACEIT(10,"ChangePreviewState start");
4872 struct SideObjectList *Object = (struct SideObjectList *)data;
4873
4874 if (Object->PreviewCol == NULL){
4875 TRACEIT(10,"ChangePreviewState ends");
4876 return;
4877 }
4878
4879 if (0 == Object->iPreview){
4880 Object->iPreview = 1;
4881 gtk_tree_view_column_set_visible(Object->PreviewCol,TRUE);
4882 }
4883 else{
4884 Object->iPreview = 0;
4885 gtk_tree_view_column_set_visible(Object->PreviewCol,FALSE);
4886 }
4887
4888 updateViewWithNewFolder(Object, NULL);
4889
4890 TRACEIT(10,"ChangePreviewState ends");
4891 }
4892
4893
showHiddenFilesInActivePage(GtkWidget * menuitem,gpointer data)4894 void showHiddenFilesInActivePage(GtkWidget *menuitem, gpointer data){
4895 TRACEIT(10,"showHiddenFilesInActivePage start");
4896 struct SideObjectList *Object=NULL;
4897 SideObjectList_GetActiveObject((GtkNotebook *)data, &Object);
4898 if (Object == NULL){
4899 TRACEIT(10,"copyActivePage ends");
4900 return;
4901 }
4902 calcDirectorySizeInView_closeProcess (&(Object->iRecursiveSizeCalculation), &(Object->gthreadF6Updage), &(Object->bUpdateFlag_F6), &(Object->iPreventFromUpdating), TRUE);
4903
4904 Object->showHiddenFiles=!Object->showHiddenFiles;
4905
4906 updateView(Object);
4907 TRACEIT(10,"showHiddenFilesInActivePage ends");
4908 }
4909
4910
moveActivePage(GtkWidget * menuitem,gpointer data)4911 void moveActivePage(GtkWidget *menuitem, gpointer data){
4912 TRACEIT(10,"moveActivePage start");
4913 GtkNotebook *destNotebook = ( (GtkNotebook *)data == (GtkNotebook *)Notebooks[SIDE_LEFT])?(GtkNotebook *)Notebooks[SIDE_RIGHT]:(GtkNotebook *)Notebooks[SIDE_LEFT];
4914 SideObjectList_MoveActiveObject((GtkNotebook *)data, destNotebook);
4915 TRACEIT(10,"moveActivePage ends");
4916 }
4917
4918
copyActivePage(GtkWidget * menuitem,gpointer data)4919 void copyActivePage(GtkWidget *menuitem, gpointer data){
4920 TRACEIT(10,"copyActivePage start");
4921 GtkNotebook *destNotebook = ( (GtkNotebook *)data == (GtkNotebook *)Notebooks[SIDE_LEFT])?(GtkNotebook *)Notebooks[SIDE_RIGHT]:(GtkNotebook *)Notebooks[SIDE_LEFT];
4922 struct SideObjectList *Object=NULL;
4923 SideObjectList_GetActiveObject((GtkNotebook *)data, &Object);
4924 if (Object == NULL){
4925 TRACEIT(10,"copyActivePage ends");
4926 return;
4927 }
4928 SideObjectList_CreateNewViewWithPath(destNotebook, Object->gstrPath->str,Object);
4929 TRACEIT(10,"copyActivePage ends");
4930 }
4931
4932
dublicateActivePage(GtkWidget * menuitem,gpointer data)4933 void dublicateActivePage(GtkWidget *menuitem, gpointer data){
4934 TRACEIT(10,"dublicateActivePage start");
4935 struct SideObjectList *Object=NULL;
4936 SideObjectList_GetActiveObject((GtkNotebook *)data, &Object);
4937 if (Object == NULL){
4938 TRACEIT(10,"dublicateActivePage ends");
4939 return;
4940 }
4941 SideObjectList_CreateNewViewWithPath((GtkNotebook *)data, Object->gstrPath->str,Object);
4942 TRACEIT(10,"dublicateActivePage ends");
4943 }
4944
4945
addNewPage(GtkWidget * menuitem,gpointer data)4946 void addNewPage(GtkWidget *menuitem, gpointer data){
4947 TRACEIT(10,"addNewPage start");
4948 GString *gstrDirectory = g_string_sized_new(10);
4949 GString *gstrDirectoryName = g_string_sized_new(10);
4950 getStandardStartDirectory(gstrDirectory);//, gstrDirectoryName);
4951 SideObjectList_CreateNewViewWithPath((GtkNotebook *)data, gstrDirectory->str, NULL);
4952 g_string_free(gstrDirectory, TRUE);
4953 g_string_free(gstrDirectoryName, TRUE);
4954 TRACEIT(10,"addNewPage ends");
4955 }
4956
4957
closeActivePage(GtkWidget * menuitem,gpointer data)4958 void closeActivePage(GtkWidget *menuitem, gpointer data){
4959 TRACEIT(10,"closeActivePage start");
4960 SideObjectList_DeleteActiveObject((GtkNotebook *)data);
4961 TRACEIT(10,"closeActivePage ends");
4962 }
4963
4964