1 /*
2     Copyright 2007, 2008, 2009, 2010 Geyer Klaus
3 
4     This file is part of Cat'sEyE.
5 
6     Cat'sEyE is free software: you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation, either version 3 of the License, or
9     (at your option) any later version.
10 
11     Cat'sEyE is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15 
16     You should have received a copy of the GNU General Public License
17     along with Cat'sEyE.  If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 
21 //#include <gdk/gdk.h>
22 #include <gtk/gtk.h>
23 #include <stdlib.h>
24 #include <string.h>
25 #include <gdk/gdkkeysyms.h>
26 #include <unistd.h>
27 
28 #include "confighandling.h"
29 #include "confighandlingDefinitions.h"
30 #include "mytrace.h"
31 #include "globalDefinitions.h"
32 #include "helpers.h"
33 #include "Lists.h"
34 #include "userdata.h"
35 #include "myfm.h"
36 #include "CreateUsercommandDialog.h"
37 
38 #include "allInclude.h"
39 
40 
41 #define INFOTEXT "\
42 Find all information at:\n\
43 catseye-fm-temp.sourceforge.net\n\
44 \n\
45 Options need to be saved before they take effect.\n\
46 Same counts for items moved up or down in the lists.\n\
47 \n\
48 Here are the predefined variables you can use within the\n\
49 command section (use them like this: $(TDIR)):\n\
50 \n\
51 \tThisDirectory\t\t=\tTDIR\n\
52 \tOtherDirectory\t\t=\tODIR\n\
53 \tLeftSideDirectory\t=\tLDIR\n\
54 \tRightSideDirectory\t=\tRDIR\n\
55 \tHome = HOME = home\n\
56 \tAllItemsWithoutPathUnQuoted\t\t= MIS_NP_UQ\n\
57 \tAllItemsWithoutPathQuoted\t\t= MIS_NP_Q\n\
58 \tAllItemsWithPathUnQuoted\t\t= MIS_WP_UQ\n\
59 \tAllItemsWithPathQuoted\t\t\t= MIS_WP_Q\n\
60 \tItemWithoutPathUnQuoted\t\t= MI_NP_UQ\n\
61 \tItemWithoutPathQuoted\t\t\t= MI_NP_Q\n\
62 \ttemWithPathUnQuoted\t\t\t= MI_WP_UQ\n\
63 \tItemWithPathQuoted\t\t\t= MI_WP_Q\n\
64 \n\
65 \tMIS_* means allways all marked files in one row\n\
66 \tMI_* is filled different in order which call type is active:\n\
67 \t\tCalltype = all: same as MIS_*\n\
68 \t\tCalltype = each | list: only one item at a time\n\
69 \n\
70 \tExample: If you have marked 2 files: m1.txt and m2.txt, here is what some\n\
71 \t\tvariables would look like:\n\
72 \t\t$(MIS_NP_Q) will be replaced by : 'm1.txt m2.txt'\n\
73 \t\t$(MIS_NP_UQ) will be replaced by : '\"m1.txt\" \"m2.txt\"'\n\
74 \n\
75 \n\
76 Hints:\n\
77 \tPressing the middle mouse button over a specific type of file\n\
78 \twill automaticaly mark all files of the same type in the current view.\n\
79 \n\
80 \tMiddle mouse button on notebook tab will close the current tab.\n\
81 \n\
82 \tDouble click on a notebook will add a new page or FileShelf\n\
83 \n\
84 \tDouble click an item will open the item with the default command,\n\
85 \tdefined in the usercommand section of the property page.\n\
86 \n\
87 \tChanging the position of a bookmark or a usercommand in the property page\n\
88 \tonly takes effect after saving the currently used config file.\n\
89 \n\
90 \tUse Ctrl+d to easily add all marked items to a new FileShelf.\n\
91 \n\
92 \tCat'sEyE distinguishes filetypes by their ending.\n\
93 \n\
94 \tA usercommand must be connected to some file type.\n\
95 \tIf you want a usercommand to be connected to all types of files\n\
96 \tuse the \"allfls\" keyword as a target.\n\
97 \n\
98 \tCtrl+p enables or disables the preview of pictures. You can define\n\
99 \twhich pictures to preview within the options section of the property page,\n\
100 \twhere you can define the size of the preview too\n\
101 \n\
102 \n\
103 Shortcuts:\n\
104 \tctrl + c|x|v\tcopy,cut,paste. Only works in Cat'sEyE.\n\
105 \t\tif you want to copy the file name to the clipboard use:\n\
106 \tctrl + y\t\tcopies the marked name(s) to the clipboard\n\
107 \talt + y\t\tcopyies the marked name(s) including their directories to the clipboard\n\
108 \tctrl + n\t\tnew page\n\
109 \tctrl + i\t\tsize of selected items\n\
110 \tctrl + h\t\tshow/hide hidden files\n\
111 \tctrl + a\t\tselect all items in a view\n\
112 \tctrl + s\t\tadd selected items to active fileshelf\n\
113 \tctrl + d\t\tadd selected items to new fileshelf\n\
114 \tctrl + p\t\tenable/disable picture preview\n\
115 \tctrl + r\t\t(un)mark current tab as read only (Cat'sEyE only)\n\
116 \talt + f\t\tsearch string in highlighted items\n\
117 \talt + c|x\t\tcopy,move selected items to the other side\n\
118 \n\
119 \tF2\t\t\trename items\n\
120 \tF3\t\t\tnew directory\n\
121 \tF4\t\t\topen terminal\n\
122 \tF5\t\t\tupdate view manually\n\
123 \tF6\t\t\tupdate view and get the size of each directorie in the current view.\n\
124 \t\t\tAttention: This may block Cat'sEyE for a long time in order how many\n\
125 \t\t\tsubdirectories there are!\n\
126 \n\
127 \n\
128 "
129 
130 #define PROPPAGE_CAPTION "CEE Property Page"
131 
132 extern const char *Names[];
133 
134 enum {
135     PROPPAGE_COL_USCMND_NAME,
136     PROPPAGE_COL_USCMND_TARGET,
137     PROPPAGE_COL_USCMND_COMMAND,
138     PROPPAGE_COL_USCMND_DEFAULT,
139     PROPPAGE_COL_USCMND_ITEMPOINTER,
140     PROPPAGE_COL_USCMND_VISIBLE,
141     PROPPAGE_COL_USCMND_NUM
142 };
143 
144 #define PROPPAGE_USRCMND_COLTYPES  G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_BOOLEAN
145 #define PROPPAGE_USRCMND_COLNAMES {"Name", "Target", "Command", "Default", "ItemPointer", "Visible"}
146 
147 enum {
148     PROPPAGE_COL_BKMRK_NAME,
149     PROPPAGE_COL_BKMRK_PATH,
150     PROPPAGE_COL_BKMRK_ITEMPOINTER,
151     //PROPPAGE_COL_BKMRK_VISIBLE,
152     PROPPAGE_COL_BKMRK_NUM
153 };
154 
155 #define PROPPAGE_BKMRK_COLTYPES  G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER//, G_TYPE_BOOLEAN
156 #define PROPPAGE_BKMRK_COLNAMES { "Name", "Path", "ItemPointer"/*, "Visible"*/}
157 
158 
159 enum {
160 	PROPPAGE_COL_COLORDER_NAME,
161 	PROPPAGE_COL_COLORDER_NUM
162 };
163 
164 #define PROPPAGE_COLORDER_COLTYPES G_TYPE_STRING
165 #define PROPPAGE_COLORDER_COLNAMES { "Name" }
166 
167 
168 
169 struct _propPage_BkmrkAddItem_BufStru{
170     GtkWidget *Parent;
171     GtkWidget *EditBox;
172 };
173 
174 struct _propPage_ReoderLists_Stru {
175     int iColumn;
176     GList *glistListPointer;
177 };
178 
179 struct _PropPage_SetVisibility_Stru {
180     int iColumn;
181     gboolean bValue;
182 };
183 
184 struct _PropPage_UnHideIfKeywordFound_Stru {
185     int iColumnSearch;
186     int iColumnVisibility;
187     char *cpKeyword;
188 };
189 
190 struct _propPage_MainEntities {
191     GtkWidget *Main_Widget;
192     GtkWidget *Main_MainVBox;
193     GtkWidget *Main_MainHBox;
194     GtkWidget *Main_Notebook;
195     GtkWidget *Main_Buttons_HBox;
196     GtkWidget *Main_Button_Save;
197     GtkWidget *Main_Button_Close;
198     GtkWidget *Main_Button_SaveTo;
199     GtkWidget *Main_Button_LoadFrom;
200     GtkWidget *Main_Button_Reload;
201     GtkWidget *Main_LabelOpendFile;
202 };
203 
204 struct _propPage_InfoEntities {
205     GtkWidget *Info_MainVBox;
206     GtkWidget *Info_Label;
207     GtkWidget *Info_ScrollWindow;
208 };
209 
210 struct _propPage_BookmarkEntities {
211 	GtkWidget *Bkmrk_MainHBox;
212 	GtkListStore *Bkmrk_ListStore;
213     GtkWidget *Bkmrk_ListView;
214     GtkWidget *Bkmrk_ScrollWindow;
215 	GtkWidget *Bkmrk_Buttons_VBox;
216 	GtkWidget *Bkmrk_Button_New;
217 	GtkWidget *Bkmrk_Button_Edit;
218 	GtkWidget *Bkmrk_Button_Delete;
219 };
220 
221 struct _propPage_UserCommandsEntities {
222     GtkWidget *UsrCmnd_MainVBox;
223     GtkWidget *UsrCmnd_MainHBox;
224 	GtkListStore *UsrCmnd_ListStore;
225     GtkWidget *UsrCmnd_ListView;
226     GtkWidget *UsrCmnd_ScrollWindow;
227 	GtkWidget *UsrCmnd_Buttons_VBox;
228 	GtkWidget *UsrCmnd_Button_New;
229 	GtkWidget *UsrCmnd_Button_Edit;
230 	GtkWidget *UsrCmnd_Button_Delete;
231 	GtkWidget *UsrCmnd_Filter_MainHBox;
232 	GtkWidget *UsrCmnd_Filter_1stVBox;
233 	GtkWidget *UsrCmnd_Filter_2ndVBox;
234 	GtkWidget *UsrCmnd_Filter_NameVBox;
235 	GtkWidget *UsrCmnd_Filter_NameLabel;
236 	GtkWidget *UsrCmnd_Filter_NameEntry;
237 	GtkWidget *UsrCmnd_Filter_TargetVBox;
238 	GtkWidget *UsrCmnd_Filter_TargetLabel;
239 	GtkWidget *UsrCmnd_Filter_TargetEntry;
240 	GtkWidget *UsrCmnd_Filter_CommandVBox;
241 	GtkWidget *UsrCmnd_Filter_CommandLabel;
242 	GtkWidget *UsrCmnd_Filter_CommandEntry;
243 	GtkWidget *UsrCmnd_Filter_DefaultVBox;
244 	GtkWidget *UsrCmnd_Filter_DefaultLabel;
245 	GtkWidget *UsrCmnd_Filter_DefaultEntry;
246 	GtkWidget *UsrCmnd_Filter_ResetButton;
247 	GtkWidget *UsrCmnd_Filter_ResetButtonVBox;
248 };
249 
250 struct _propPage_OptionsEntities {
251     GtkWidget *Option_MainVbox;
252     GdkColormap *Option_Colormap;
253     GtkWidget *Option_Stded_HBox_Value;
254     GtkWidget *Option_Stded_Label_Value;
255     GtkWidget *Option_Stded_Edit_Value;
256     GtkWidget *Option_Stded_HBox_Name;
257     GtkWidget *Option_Stded_Label_Name;
258     GtkWidget *Option_Stded_Edit_Name;
259     GtkWidget *Option_Trmnl_HBox_Value;
260     GtkWidget *Option_Trmnl_Label_Value;
261     GtkWidget *Option_Trmnl_Edit_Value;
262     GtkWidget *Option_Trmnl_HBox_Name;
263     GtkWidget *Option_Trmnl_Label_Name;
264     GtkWidget *Option_Trmnl_Edit_Name;
265     GtkWidget *Option_Stdd_HBox;
266     GtkWidget *Option_Stdd_Label;
267     GtkWidget *Option_Stdd_Edit;
268     GtkWidget *Option_Stdd_Button;
269     GtkWidget *Option_Svpths_HBox;
270     GtkWidget *Option_Svpths_Check;
271     GtkWidget *Option_Strtdl_HBox;
272     GtkWidget *Option_Strtdl_Label;
273     GtkWidget *Option_Strtdl_Edit;
274     GtkWidget *Option_Strtdl_Button;
275     GtkWidget *Option_Strtdr_HBox;
276     GtkWidget *Option_Strtdr_Label;
277     GtkWidget *Option_Strtdr_Edit;
278     GtkWidget *Option_Strtdr_Button;
279     GtkWidget *Option_ClrItm_HBox;
280     GtkWidget *Option_ClrItm_Label;
281     GtkWidget *Option_ClrItm_Button;
282     GdkColor  Option_ClrItm_gdkColor;
283     GtkWidget *Option_ClrDir_HBox;
284     GtkWidget *Option_ClrDir_Label;
285     GtkWidget *Option_ClrDir_Button;
286     GdkColor  Option_ClrDir_gdkColor;
287     GtkWidget *Option_ClrLnk_HBox;
288     GtkWidget *Option_ClrLnk_Label;
289     GtkWidget *Option_ClrLnk_Button;
290     GdkColor  Option_ClrLnk_gdkColor;
291     GtkWidget *Option_ClrMss_HBox;
292     GtkWidget *Option_ClrMss_Label;
293     GtkWidget *Option_ClrMss_Button;
294     GdkColor  Option_ClrMss_gdkColor;
295     GtkWidget *Option_PreviewSize_Label;
296     GtkWidget *Option_PreviewSize_Edit;
297     GtkWidget *Option_PreviewSize_HBox;
298     GtkWidget *Option_PreviewEndings_Label;
299     GtkWidget *Option_PreviewEndings_Edit;
300     GtkWidget *Option_PreviewEndings_HBox;
301     GtkWidget *Option_SaveSessionEveryMinutes_Label;
302     GtkWidget *Option_SaveSessionEveryMinutes_Edit;
303     GtkWidget *Option_SaveSessionEveryMinutes_HBox;
304 };
305 
306 
307 struct _propPage_ColumnOrder {
308 	GtkWidget *ClmOrder_MainVBox;
309     GtkListStore *ClmOrder_ListStore;
310     GtkWidget *ClmOrder_ListView;
311     GtkWidget *ClmOrder_ScrollWindow;
312 	GtkWidget *ClmOrder_Buttons_VBox;
313 	GtkWidget *ClmOrder_Button_Reset;
314 };
315 
316 //this is our main communication struct in here.
317 struct _propPage_MainStruct {
318 
319 	struct _propPage_MainEntities 			mainEntities;
320 	struct _propPage_BookmarkEntities		bkmrkEntities;
321 	struct _propPage_OptionsEntities		OptionsEntities;
322 	struct _propPage_UserCommandsEntities	UserCommandsEntities;
323 	struct _propPage_InfoEntities           InfoEntities;
324 	struct _propPage_ColumnOrder			ColumnOrder;
325 
326 
327 	int iSaved;	//our saved flag, 0=not saved after last change, 1=saved after last change
328 };
329 ////////////////////////////////////////////////////////////////////////////////
330 ////////////////////////////////////////////////////////////////////////////////
331 //////////////////////////	globals 	////////////////////////////////////////
332 
333 extern GtkWindow 		*win;
334 extern struct _UserCommandList *g_UserCommandList;
335 extern struct _OptionsList *g_OptionsList;
336 extern struct _OptionsList *g_BookMarkList;
337 
338 
339 ////////////////////////////////////////////////////////////////////////////////
340 ////////////////////////////////////////////////////////////////////////////////
341 //////////////////////////	prototypes 	////////////////////////////////////////
342 
343 int propPage_createOptionsMainWidgets (struct _propPage_MainStruct *mainStruct);
344 int propPage_arangeListViewAndCo(GtkListStore *listStore, GtkWidget *listView, GtkWidget *scrollwidget, char **cppNames, int iNumOfColums, int iInvisibleColumns, int iVisibilityColumn);
345 int propPage_createUserCommandsMainWidgets (struct _propPage_MainStruct *mainStruct);
346 int propPage_createBkmrkMainWidgets (struct _propPage_MainStruct *mainStruct);
347 int propPage_createPropPageWidgets (struct _propPage_MainStruct *mainStruct);
348 int propPage_openConfigFile (const char *ccpFileName, struct _propPage_MainStruct *mainStruct);
349 void propPage_freeMainStruct (struct _propPage_MainStruct *mainStruct);
350 void propPage_destroyEvent ( GtkObject *object , struct _propPage_MainStruct *mainStruct);
351 int propPage_fillPropPageWidgets (struct _propPage_MainStruct *mainStruct);
352 int propPage_fillOptionsMainWidgets (struct _propPage_MainStruct *mainStruct);
353 int propPage_fillBkmrkMainWidgets (struct _propPage_MainStruct *mainStruct);
354 int propPage_fillUserCommandsMainWidgets (struct _propPage_MainStruct *mainStruct);
355 int propPage_updateFileNameLabel (struct _propPage_MainStruct *mainStruct);
356 int propPage_assignOptionsFunctionality (struct _propPage_MainStruct *mainStruct);
357 int propPage_assignBkmrkFunctionality (struct _propPage_MainStruct *mainStruct);
358 int propPage_assignUserCommandsFunctionality (struct _propPage_MainStruct *mainStruct);
359 void propPage_BkmrkdeleteItem (GtkButton *button, struct _propPage_MainStruct *mainStruct);
360 int propPage_BkmrkAddItem (struct _propPage_MainStruct *mainStruct, int iEditOrAdd );
361 int propPage_assignFunctionality (struct _propPage_MainStruct *mainStruct);
362 void propPage_BkmrkButtonEdit (GtkButton *Button, struct _propPage_MainStruct *mainStruct);
363 void propPage_BkmrkButtonNew (GtkButton *Button, struct _propPage_MainStruct *mainStruct);
364 void propPage_UserCommandDeleteItem (GtkButton *button, struct _propPage_MainStruct *mainStruct);
365 int propPage_UserCommandAddItem (struct _UserCommandList *UserCommandListItem, GtkWidget *Parent);
366 void propPage_UserCommandButtonNew (GtkButton *button, struct _propPage_MainStruct *mainStructs);
367 void propPage_UserCommandButtonEdit (GtkButton *button, struct _propPage_MainStruct *mainStruct);
368 void propPage_OptionsChooseDirStrtdl (GtkButton *Button, struct _propPage_MainStruct *mainStruct);
369 void propPage_OptionsChooseDirStrtdr (GtkButton *Button, struct _propPage_MainStruct *mainStruct);
370 void propPage_OptionsChooseDirStdd (GtkButton *Button, struct _propPage_MainStruct *mainStruct);
371 int propPage_OptionsChooseDir (GtkWidget *Parent, GtkWidget *entrybox);
372 //gboolean propPage_OptionsoneKeyPressedInMainWidget(GtkWidget *widget, GdkEventKey *event, struct _propPage_MainStruct *mainStruct);
373 int propPage_assignMainFunctionality (struct _propPage_MainStruct *mainStruct);
374 void propPage_MainButtonClose (GtkButton *Button, struct _propPage_MainStruct *mainStruct);
375 void propPage_MainButtonReload (GtkButton *Button, struct _propPage_MainStruct *mainStruct);
376 void propPage_MainButtonLoadFrom (GtkButton *Button, struct _propPage_MainStruct *mainStruct);
377 void propPage_BkmrkAddItemPathButton (GtkButton *Button, struct _propPage_BkmrkAddItem_BufStru *BufStru);
378 gboolean propPage_BkmrkOneMouseButtonPressedInView(GtkWidget *treeview, GdkEventButton *event, struct _propPage_MainStruct *mainStruct);
379 gboolean propPage_BkmrkContextMenuOnListView(GtkWidget *treeview, GdkEventButton *event,  struct _propPage_MainStruct *mainStruct);
380 gboolean propPage_BkmrkOneKeyPressedInView(GtkWidget *widget, GdkEventKey *event, struct _propPage_MainStruct *mainStruct);
381 void propPage_BkmrkRowActivated (GtkTreeView *tree_view, GtkTreePath *path, GtkTreeViewColumn *column, struct _propPage_MainStruct *mainStruct);
382 gboolean propPage_UsrCmndContextMenuOnListView(GtkWidget *treeview, GdkEventButton *event,  struct _propPage_MainStruct *mainStruct);
383 gboolean propPage_UsrCmndOneMouseButtonPressedInView(GtkWidget *treeview, GdkEventButton *event, struct _propPage_MainStruct *mainStruct);
384 gboolean propPage_UsrCmndOneKeyPressedInView(GtkWidget *widget, GdkEventKey *event, struct _propPage_MainStruct *mainStruct);
385 void propPage_UsrCmndRowActivated (GtkTreeView *tree_view, GtkTreePath *path, GtkTreeViewColumn *column, struct _propPage_MainStruct *mainStruct);
386 int propPage_saveAllToXMLFile (struct _propPage_MainStruct *mainStruct, const char *FileName);
387 int propPage_writeOptionsToGlobalStruct (struct _propPage_MainStruct *mainStruct);
388 void propPage_MainButtonSave (GtkButton *Button, struct _propPage_MainStruct *mainStruct);
389 void propPage_MainButtonSaveTo (GtkButton *Button, struct _propPage_MainStruct *mainStruct);
390 int propPage_reorderUsercommandListByListView (struct _propPage_MainStruct *mainStruct);
391 int propPage_reorderBookmarkListByListView (struct _propPage_MainStruct *mainStruct);
392 gboolean getPointerFromListView (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, struct _propPage_ReoderLists_Stru *Struct );
393 void propPage_UserCommandFilterEntryBoxActivate (GtkEntry *entry, struct _propPage_UserCommandsEntities *UserCommandsEntities);
394 int propPage_UserCommandFilterApply (struct _propPage_UserCommandsEntities *UserCommandsEntities);
395 gboolean propPage_setVisibilityInListView (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, struct _PropPage_SetVisibility_Stru *Struct );
396 void propPage_UserCommandClearFilter (GtkButton *button, struct _propPage_UserCommandsEntities *UserCommandsEntities);
397 gboolean propPage_UserCommandFilterApply_foreach ( GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, struct _propPage_UserCommandsEntities *UserCommandsEntities );
398 int propPage_UserCommand_WouldThisFilterHideIt( GtkEntry *Entry, int iColumnSearch, GtkTreeModel *model, GtkTreeIter *iter );
399 int propPage_createInfoMainWidgets (struct _propPage_MainStruct *mainStruct);
400 int propPage_createColumnOrderWidgets (struct _propPage_MainStruct *mainStruct);
401 int propPage_fillColumnOrderWidgets (struct _propPage_MainStruct *mainStruct, int iUseDefault);
402 int propPage_assignColumnOrderFunctionality (struct _propPage_MainStruct *mainStruct);
403 void propPage_ClmnOrderButtonReset (GtkButton *Button, struct _propPage_MainStruct *mainStruct);
404 int propPage_writeColumnOrderToGlobalStruct (struct _propPage_MainStruct *mainStruct);
405 
406 ////////////////////////////////////////////////////////////////////////////////
407 ////////////////////////////////////////////////////////////////////////////////
408 //////////////////////////	My globals 	////////////////////////////////////////
409 
410 static struct _propPage_MainStruct *g_mainStruct=NULL;  //we need this in propPage_external_fillPropPageWidgets and in CreateUsercommand.c
411 static int g_iWidgetIsRunning=0;
412 static GList *g_glistUserCommandWidgets=NULL;   //stores pointer to widgets from CreateUserCommandDialog.c if the usercommandstructitem isnt NULL
413 
414 ////////////////////////////////////////////////////////////////////////////////
415 ////////////////////////////////////////////////////////////////////////////////
416 //////////////////////////	functions 	////////////////////////////////////////
417 
propPage_startPropPage()418 void propPage_startPropPage (){
419 	TRACEIT (10, "propPage_startPropPage			start");
420 	//printf("g_iWidgetIsRunning = %d\n",g_iWidgetIsRunning);
421 	if (g_iWidgetIsRunning != 0){
422         TRACEIT (10, "propPage_startPropPage            end, allready running");
423         return;
424 	}
425 	g_iWidgetIsRunning = 1;
426     //This is our main entry point for the property pages.
427     g_mainStruct = NULL;
428 	struct _propPage_MainStruct *mainStruct = malloc (sizeof (struct _propPage_MainStruct));
429 	if (mainStruct == NULL){
430 		TRACEIT (2, "propPage_startPropPage			unable to allocate memory");
431 		return;
432 	}
433     g_mainStruct = mainStruct;
434 	// initialize mainStruct members
435 	mainStruct->iSaved = 1;	//1=saved after last change, because we just have loaded the information
436 
437 	propPage_openConfigFile (NULL, mainStruct);	//Null loads file which is currently in use, confighandling.c knows more
438 
439     propPage_createPropPageWidgets (mainStruct);
440 
441     propPage_fillPropPageWidgets (mainStruct);
442 
443     propPage_assignFunctionality (mainStruct);
444 
445     gtk_widget_show_all(mainStruct->mainEntities.Main_Widget);
446 
447 	TRACEIT (10, "propPage_startPropPage			end");
448 }
449 
450 
propPage_destroyEvent(GtkObject * object,struct _propPage_MainStruct * mainStruct)451 void propPage_destroyEvent ( GtkObject *object , struct _propPage_MainStruct *mainStruct){
452 	//connected to the destroy event of the main widget, frees all the memory reseverd
453 	TRACEIT (10, "propPage_destroyEvent			start");
454 	if (mainStruct == NULL){
455 		TRACEIT (2, "propPage_destroyEvent			parameter NULL");
456 		return;
457 	}
458 
459     configFileHandling_setPreventReloadFlag (0);
460 	propPage_freeMainStruct (mainStruct);
461     g_iWidgetIsRunning = 0;
462 	TRACEIT (10, "propPage_destroyEvent			end");
463 }
464 
465 
propPage_freeMainStruct(struct _propPage_MainStruct * mainStruct)466 void propPage_freeMainStruct (struct _propPage_MainStruct *mainStruct){
467 	TRACEIT (10, "propPage_freeMainStruct			start");
468 
469 	gdk_colormap_free_colors (mainStruct->OptionsEntities.Option_Colormap, &(mainStruct->OptionsEntities.Option_ClrItm_gdkColor), 1);
470     gdk_colormap_free_colors (mainStruct->OptionsEntities.Option_Colormap, &(mainStruct->OptionsEntities.Option_ClrLnk_gdkColor), 1);
471     gdk_colormap_free_colors (mainStruct->OptionsEntities.Option_Colormap, &(mainStruct->OptionsEntities.Option_ClrDir_gdkColor), 1);
472     gdk_colormap_free_colors (mainStruct->OptionsEntities.Option_Colormap, &(mainStruct->OptionsEntities.Option_ClrMss_gdkColor), 1);
473 
474     g_object_ref(mainStruct->OptionsEntities.Option_Colormap);
475 
476 	free (mainStruct);
477 
478 	g_list_free (g_glistUserCommandWidgets);
479 
480 	TRACEIT (10, "propPage_freeMainStruct			end");
481 }
482 
483 
propPage_openConfigFile(const char * ccpFileName,struct _propPage_MainStruct * mainStruct)484 int propPage_openConfigFile (const char *ccpFileName, struct _propPage_MainStruct *mainStruct){
485 	TRACEIT (10, "propPage_openConfigFile			start");
486 	//opens the file in ccpFileName and reads in its properties.
487 	//this functions uses the functions from confighandling.c
488 	//this means, loading a file with this will effect whole Cat'sEyE
489 	//if ccpFileName == NULL, the currently file in use simply will be reloaded.
490     if (mainStruct == NULL){
491         TRACEIT (10, "propPage_openConfigFile			parameter NULL");
492         return -1;
493     }
494 
495     if (g_glistUserCommandWidgets != NULL){ //then the lists holds all the CreateUsercommandDialogs which hold a reverence to a
496         //userCommandListItem which most propably becomes invalid after we have loaded a file
497         GtkWidget *dialog = CreateMyDialog("Close",(GtkWindow *)mainStruct->mainEntities.Main_Widget,2,"Ok",GTK_RESPONSE_ACCEPT,"Cancel",GTK_RESPONSE_REJECT, NULL, 0,  TRUE);
498         GtkWidget *label = gtk_label_new("There is at least one UserCommandDialog open which holds\na reverence on an internal struct.\nBefore loading a new file, you have to close this dialogs.\n\nPress 'Cancel' to close the dialogs by yourself or\n'Ok' if you want me to close the dialogs for you and load the specified file.\n");
499         gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox),label);
500         gtk_widget_show_all(dialog);
501         int iDRet = gtk_dialog_run(GTK_DIALOG(dialog));
502         if (iDRet != GTK_RESPONSE_ACCEPT){
503             gtk_widget_destroy(dialog);
504             TRACEIT(10,"propPage_openConfigFile		end");
505             return 0;
506         }
507         gtk_widget_destroy(dialog);
508 
509         GtkWidget *wBuf = NULL;
510         while (g_glistUserCommandWidgets){
511             while (g_glistUserCommandWidgets != NULL && wBuf == (GtkWidget *)g_glistUserCommandWidgets->data){
512                 usleep(10);
513             }
514             wBuf = (GtkWidget *)g_glistUserCommandWidgets->data;
515             gtk_widget_destroy ((GtkWidget *)g_glistUserCommandWidgets->data);
516         }
517     }
518 
519 	if (ccpFileName != NULL){
520 		configFileHandling_defineConfigFileName (ccpFileName);
521 	}
522 	configFileHandling_setPreventReloadFlag (0);
523 	configFileHandling_loadConfigFile(TRUE, FALSE);
524     configFileHandling_setPreventReloadFlag (1);
525 
526 	TRACEIT (10, "propPage_openConfigFile			end");
527 	return 0;
528 }
529 
530 
propPage_updateFileNameLabel(struct _propPage_MainStruct * mainStruct)531 int propPage_updateFileNameLabel (struct _propPage_MainStruct *mainStruct){
532     TRACEIT (10, "propPage_updateFileNameLabel			start");
533 	if (mainStruct == NULL){
534 		TRACEIT (2, "propPage_updateFileNameLabel			parameter NULL");
535 		return -1;
536 	}
537     const char *ccpConfigFileName = configFileHandling_getConfigFileName ();
538     if (ccpConfigFileName == NULL){
539         gtk_label_set_text ((GtkLabel *)mainStruct->mainEntities.Main_LabelOpendFile , "n.a.");
540     }
541     else{
542         gtk_label_set_text ((GtkLabel *)mainStruct->mainEntities.Main_LabelOpendFile , ccpConfigFileName);
543     }
544 
545     TRACEIT (10, "propPage_updateFileNameLabel			end");
546     return 0;
547 }
548 
549 
propPage_createPropPageWidgets(struct _propPage_MainStruct * mainStruct)550 int propPage_createPropPageWidgets (struct _propPage_MainStruct *mainStruct){
551 	TRACEIT (10, "propPage_createPropPageWidgets			start");
552 	if (mainStruct == NULL){
553 		TRACEIT (2, "propPage_createPropPageWidgets			parameter NULL");
554 		return -1;
555 	}
556 
557 	struct _propPage_MainEntities *mainEntities = &(mainStruct->mainEntities);
558 
559     mainEntities->Main_Widget                   = CreateMyWindow(PROPPAGE_CAPTION, win, -1, -1, TRUE, TRUE, FALSE, NULL, FALSE, TRUE);
560 	mainEntities->Main_MainVBox                 = gtk_vbox_new (FALSE, 5);
561 	mainEntities->Main_MainHBox                 = gtk_hbox_new (FALSE, 0);
562     mainEntities->Main_Notebook                 = gtk_notebook_new ();
563     mainEntities->Main_Buttons_HBox             = gtk_hbox_new (TRUE, 0);
564     mainEntities->Main_Button_Save              = gtk_button_new_with_label ("Save");
565     mainEntities->Main_Button_Close             = gtk_button_new_with_label ("Close");
566     mainEntities->Main_Button_SaveTo            = gtk_button_new_with_label ("Save as");
567     mainEntities->Main_Button_LoadFrom          = gtk_button_new_with_label ("Load from");
568     mainEntities->Main_Button_Reload            = gtk_button_new_with_label ("Reload");
569     mainEntities->Main_LabelOpendFile           = gtk_label_new ("n.a.");
570 
571     gtk_box_pack_start ( (GtkBox *)mainEntities->Main_Buttons_HBox, mainEntities->Main_Button_Save, FALSE, FALSE, 5);
572     gtk_box_pack_start ( (GtkBox *)mainEntities->Main_Buttons_HBox, mainEntities->Main_Button_SaveTo, FALSE, FALSE, 5);
573     gtk_box_pack_start ( (GtkBox *)mainEntities->Main_Buttons_HBox, mainEntities->Main_Button_LoadFrom, FALSE, FALSE, 5);
574     gtk_box_pack_start ( (GtkBox *)mainEntities->Main_Buttons_HBox, mainEntities->Main_Button_Reload, FALSE, FALSE, 5);
575     gtk_box_pack_start ( (GtkBox *)mainEntities->Main_Buttons_HBox, mainEntities->Main_Button_Close, FALSE, FALSE, 5);
576 
577     gtk_box_pack_start ( (GtkBox *)mainEntities->Main_MainVBox, mainEntities->Main_Notebook, TRUE, TRUE, 5);
578     gtk_box_pack_start ( (GtkBox *)mainEntities->Main_MainVBox, mainEntities->Main_LabelOpendFile, FALSE, TRUE, 0);
579     gtk_box_pack_start ( (GtkBox *)mainEntities->Main_MainVBox, gtk_hseparator_new(), FALSE, FALSE, 2);
580     gtk_box_pack_start ( (GtkBox *)mainEntities->Main_MainVBox, mainEntities->Main_Buttons_HBox, FALSE, TRUE, 3);
581 
582 	propPage_createOptionsMainWidgets (mainStruct);
583 	propPage_createBkmrkMainWidgets (mainStruct);
584 	propPage_createUserCommandsMainWidgets (mainStruct);
585 	propPage_createColumnOrderWidgets (mainStruct);
586 	propPage_createInfoMainWidgets (mainStruct);
587 
588     gtk_notebook_append_page ((GtkNotebook *)mainEntities->Main_Notebook, mainStruct->OptionsEntities.Option_MainVbox, gtk_label_new("Options"));
589     gtk_notebook_append_page ((GtkNotebook *)mainEntities->Main_Notebook, mainStruct->bkmrkEntities.Bkmrk_MainHBox, gtk_label_new("Bookmarks"));
590     gtk_notebook_append_page ((GtkNotebook *)mainEntities->Main_Notebook, mainStruct->UserCommandsEntities.UsrCmnd_MainVBox, gtk_label_new("User commands"));
591     gtk_notebook_append_page ((GtkNotebook *)mainEntities->Main_Notebook, mainStruct->ColumnOrder.ClmOrder_MainVBox, gtk_label_new("Column order"));
592     gtk_notebook_append_page ((GtkNotebook *)mainEntities->Main_Notebook, mainStruct->InfoEntities.Info_MainVBox, gtk_label_new("Info"));
593 
594     gtk_box_pack_start ( (GtkBox *)mainEntities->Main_MainHBox, mainEntities->Main_MainVBox, TRUE, TRUE, 5);
595     gtk_container_add(GTK_CONTAINER(mainEntities->Main_Widget),mainEntities->Main_MainHBox);
596 
597     g_signal_connect (mainEntities->Main_Widget, "destroy", G_CALLBACK(propPage_destroyEvent),mainStruct);
598 
599 	TRACEIT (10, "propPage_createPropPageWidgets			end");
600 	return 0;
601 }
602 
603 
propPage_createInfoMainWidgets(struct _propPage_MainStruct * mainStruct)604 int propPage_createInfoMainWidgets (struct _propPage_MainStruct *mainStruct){
605     TRACEIT (10, "propPage_createInfoMainWidgets			start");
606 	if (mainStruct == NULL){
607 		TRACEIT (2, "propPage_createInfoMainWidgets			parameter NULL");
608 		return -1;
609 	}
610     mainStruct->InfoEntities.Info_MainVBox      = gtk_vbox_new(FALSE, 0);
611     mainStruct->InfoEntities.Info_Label         = gtk_label_new( INFOTEXT );
612     mainStruct->InfoEntities.Info_ScrollWindow  = gtk_scrolled_window_new (NULL,NULL);
613 
614     gtk_label_set_selectable ( (GtkLabel *)mainStruct->InfoEntities.Info_Label, TRUE);
615 
616     gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(mainStruct->InfoEntities.Info_ScrollWindow),GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC);
617     gtk_scrolled_window_add_with_viewport((GtkScrolledWindow *)(mainStruct->InfoEntities.Info_ScrollWindow),mainStruct->InfoEntities.Info_Label );
618 
619     gtk_container_add(GTK_CONTAINER(mainStruct->InfoEntities.Info_MainVBox), mainStruct->InfoEntities.Info_ScrollWindow);
620 
621     TRACEIT (10, "propPage_createInfoMainWidgets			end");
622 	return -1;
623 }
624 
625 
propPage_createBkmrkMainWidgets(struct _propPage_MainStruct * mainStruct)626 int propPage_createBkmrkMainWidgets (struct _propPage_MainStruct *mainStruct){
627     TRACEIT (10, "propPage_createBkmrkMainWidgets			start");
628 	if (mainStruct == NULL){
629 		TRACEIT (2, "propPage_createBkmrkMainWidgets			parameter NULL");
630 		return -1;
631 	}
632     struct _propPage_BookmarkEntities *bkmrkEntities = &(mainStruct->bkmrkEntities);
633 
634 
635     bkmrkEntities->Bkmrk_MainHBox     = gtk_hbox_new(FALSE, 5);
636 	bkmrkEntities->Bkmrk_ListStore    = gtk_list_store_new(PROPPAGE_COL_BKMRK_NUM, PROPPAGE_BKMRK_COLTYPES);
637     bkmrkEntities->Bkmrk_ListView     = gtk_tree_view_new ();
638     bkmrkEntities->Bkmrk_ScrollWindow = gtk_scrolled_window_new (NULL,NULL);
639 	bkmrkEntities->Bkmrk_Buttons_VBox = gtk_vbox_new(FALSE, 5);
640 	bkmrkEntities->Bkmrk_Button_New   = gtk_button_new_with_label("New");
641 	bkmrkEntities->Bkmrk_Button_Edit  = gtk_button_new_with_label("Edit");
642 	bkmrkEntities->Bkmrk_Button_Delete= gtk_button_new_with_label("Delete");
643 
644     char *ccpNames[] = PROPPAGE_BKMRK_COLNAMES;
645 
646     propPage_arangeListViewAndCo(bkmrkEntities->Bkmrk_ListStore, bkmrkEntities->Bkmrk_ListView, bkmrkEntities->Bkmrk_ScrollWindow, ccpNames, PROPPAGE_COL_BKMRK_NUM, PROPPAGE_COL_BKMRK_ITEMPOINTER, -1);
647 
648     gtk_box_pack_start ((GtkBox *)bkmrkEntities->Bkmrk_Buttons_VBox, bkmrkEntities->Bkmrk_Button_New, FALSE, FALSE, 0);
649     gtk_box_pack_start ((GtkBox *)bkmrkEntities->Bkmrk_Buttons_VBox, bkmrkEntities->Bkmrk_Button_Edit, FALSE, FALSE, 0);
650     gtk_box_pack_start ((GtkBox *)bkmrkEntities->Bkmrk_Buttons_VBox, bkmrkEntities->Bkmrk_Button_Delete, FALSE, FALSE, 0);
651 
652     gtk_box_pack_start ((GtkBox *)bkmrkEntities->Bkmrk_MainHBox, bkmrkEntities->Bkmrk_ScrollWindow, TRUE, TRUE, 0);
653     gtk_box_pack_start ((GtkBox *)bkmrkEntities->Bkmrk_MainHBox, bkmrkEntities->Bkmrk_Buttons_VBox, FALSE, FALSE, 0);
654 
655 
656     gtk_tree_view_set_reorderable ((GtkTreeView *)bkmrkEntities->Bkmrk_ListView, TRUE );
657 
658     TRACEIT (10, "propPage_createBkmrkMainWidgets			end");
659 	return 0;
660 }
661 
662 
propPage_createColumnOrderWidgets(struct _propPage_MainStruct * mainStruct)663 int propPage_createColumnOrderWidgets (struct _propPage_MainStruct *mainStruct){
664     TRACEIT (10, "propPage_createColumnOrderWidgets			start");
665 	if (mainStruct == NULL){
666 		TRACEIT (2, "propPage_createColumnOrderWidgets			parameter NULL");
667 		return -1;
668 	}
669 
670 	struct _propPage_ColumnOrder *clmOrder = &(mainStruct->ColumnOrder);
671 
672 	clmOrder->ClmOrder_MainVBox = gtk_vbox_new(FALSE, 5);
673 	clmOrder->ClmOrder_ListStore = gtk_list_store_new (PROPPAGE_COL_COLORDER_NUM, PROPPAGE_COLORDER_COLTYPES);
674 	clmOrder->ClmOrder_ListView = gtk_tree_view_new ();
675 	clmOrder->ClmOrder_ScrollWindow = gtk_scrolled_window_new (NULL, NULL);
676 	clmOrder->ClmOrder_Buttons_VBox = gtk_vbox_new (FALSE, 5);
677 	clmOrder->ClmOrder_Button_Reset = gtk_button_new_with_label ("reset to default");
678 
679 	char *cppNames[] = PROPPAGE_COLORDER_COLNAMES;
680 
681 	propPage_arangeListViewAndCo(clmOrder->ClmOrder_ListStore, clmOrder->ClmOrder_ListView, clmOrder->ClmOrder_ScrollWindow, cppNames, PROPPAGE_COL_COLORDER_NUM, -1, -1);
682 
683 	gtk_box_pack_start ((GtkBox *)clmOrder->ClmOrder_Buttons_VBox, clmOrder->ClmOrder_Button_Reset, FALSE, FALSE, 0);
684 
685     gtk_box_pack_start ((GtkBox *)clmOrder->ClmOrder_MainVBox, clmOrder->ClmOrder_ScrollWindow, TRUE, TRUE, 0);
686     gtk_box_pack_start ((GtkBox *)clmOrder->ClmOrder_MainVBox, clmOrder->ClmOrder_Buttons_VBox, FALSE, FALSE, 0);
687 
688     gtk_tree_view_set_reorderable ((GtkTreeView *)clmOrder->ClmOrder_ListView, TRUE );
689 	return 0;
690 }
691 
692 
propPage_createUserCommandsMainWidgets(struct _propPage_MainStruct * mainStruct)693 int propPage_createUserCommandsMainWidgets (struct _propPage_MainStruct *mainStruct){
694     TRACEIT (10, "propPage_createUserCommandsMainWidgets			start");
695 	if (mainStruct == NULL){
696 		TRACEIT (2, "propPage_createUserCommandsMainWidgets			parameter NULL");
697 		return -1;
698 	}
699     struct _propPage_UserCommandsEntities *UserCommandsEntities = &(mainStruct->UserCommandsEntities);
700 
701     UserCommandsEntities->UsrCmnd_MainVBox     = gtk_vbox_new(FALSE, 0);
702     UserCommandsEntities->UsrCmnd_MainHBox     = gtk_hbox_new(FALSE, 5);
703 	UserCommandsEntities->UsrCmnd_ListStore    = gtk_list_store_new(PROPPAGE_COL_USCMND_NUM, PROPPAGE_USRCMND_COLTYPES);
704     UserCommandsEntities->UsrCmnd_ListView     = gtk_tree_view_new ();
705     UserCommandsEntities->UsrCmnd_ScrollWindow = gtk_scrolled_window_new (NULL,NULL);
706 	UserCommandsEntities->UsrCmnd_Buttons_VBox = gtk_vbox_new(FALSE, 5);
707 	UserCommandsEntities->UsrCmnd_Button_New   = gtk_button_new_with_label("New");
708 	UserCommandsEntities->UsrCmnd_Button_Edit  = gtk_button_new_with_label("Edit");
709 	UserCommandsEntities->UsrCmnd_Button_Delete= gtk_button_new_with_label("Delete");
710 	UserCommandsEntities->UsrCmnd_Filter_MainHBox       = gtk_hbox_new(FALSE, 5);
711 	UserCommandsEntities->UsrCmnd_Filter_1stVBox        = gtk_vbox_new(FALSE, 0);
712 	UserCommandsEntities->UsrCmnd_Filter_2ndVBox        = gtk_vbox_new(FALSE, 0);
713 	UserCommandsEntities->UsrCmnd_Filter_NameVBox       = gtk_vbox_new(FALSE, 0);
714 	UserCommandsEntities->UsrCmnd_Filter_NameLabel      = gtk_label_new ("Name(s):");
715 	UserCommandsEntities->UsrCmnd_Filter_NameEntry      = gtk_entry_new ();
716 	UserCommandsEntities->UsrCmnd_Filter_TargetVBox     = gtk_vbox_new(FALSE, 0);
717 	UserCommandsEntities->UsrCmnd_Filter_TargetLabel    = gtk_label_new ("Target(s):");
718 	UserCommandsEntities->UsrCmnd_Filter_TargetEntry    = gtk_entry_new ();
719 	UserCommandsEntities->UsrCmnd_Filter_CommandVBox    = gtk_vbox_new(FALSE, 0);
720 	UserCommandsEntities->UsrCmnd_Filter_CommandLabel   = gtk_label_new ("Command(s):");
721 	UserCommandsEntities->UsrCmnd_Filter_CommandEntry   = gtk_entry_new ();
722 	UserCommandsEntities->UsrCmnd_Filter_DefaultVBox    = gtk_vbox_new(FALSE, 0);
723 	UserCommandsEntities->UsrCmnd_Filter_DefaultLabel   = gtk_label_new ("Default:");
724 	UserCommandsEntities->UsrCmnd_Filter_DefaultEntry   = gtk_entry_new ();
725 	UserCommandsEntities->UsrCmnd_Filter_ResetButtonVBox= gtk_vbox_new(FALSE, 0);
726 	UserCommandsEntities->UsrCmnd_Filter_ResetButton    = gtk_button_new_with_label ("reset filter");
727 
728     char *ccpNames[] = PROPPAGE_USRCMND_COLNAMES;
729 
730     propPage_arangeListViewAndCo(UserCommandsEntities->UsrCmnd_ListStore, UserCommandsEntities->UsrCmnd_ListView, UserCommandsEntities->UsrCmnd_ScrollWindow, ccpNames, PROPPAGE_COL_USCMND_NUM, PROPPAGE_COL_USCMND_ITEMPOINTER, PROPPAGE_COL_USCMND_VISIBLE);
731 
732     gtk_box_pack_start ((GtkBox *)UserCommandsEntities->UsrCmnd_Buttons_VBox, UserCommandsEntities->UsrCmnd_Button_New, FALSE, FALSE, 0);
733     gtk_box_pack_start ((GtkBox *)UserCommandsEntities->UsrCmnd_Buttons_VBox, UserCommandsEntities->UsrCmnd_Button_Edit, FALSE, FALSE, 0);
734     gtk_box_pack_start ((GtkBox *)UserCommandsEntities->UsrCmnd_Buttons_VBox, UserCommandsEntities->UsrCmnd_Button_Delete, FALSE, FALSE, 0);
735 
736     gtk_box_pack_start ((GtkBox *)UserCommandsEntities->UsrCmnd_Filter_NameVBox, UserCommandsEntities->UsrCmnd_Filter_NameLabel, FALSE, FALSE, 0);
737     gtk_box_pack_start ((GtkBox *)UserCommandsEntities->UsrCmnd_Filter_NameVBox, UserCommandsEntities->UsrCmnd_Filter_NameEntry, TRUE, TRUE, 0);
738     gtk_box_pack_start ((GtkBox *)UserCommandsEntities->UsrCmnd_Filter_TargetVBox, UserCommandsEntities->UsrCmnd_Filter_TargetLabel, FALSE, FALSE, 0);
739     gtk_box_pack_start ((GtkBox *)UserCommandsEntities->UsrCmnd_Filter_TargetVBox, UserCommandsEntities->UsrCmnd_Filter_TargetEntry, TRUE, TRUE, 0);
740     gtk_box_pack_start ((GtkBox *)UserCommandsEntities->UsrCmnd_Filter_CommandVBox, UserCommandsEntities->UsrCmnd_Filter_CommandLabel, FALSE, FALSE, 0);
741     gtk_box_pack_start ((GtkBox *)UserCommandsEntities->UsrCmnd_Filter_CommandVBox, UserCommandsEntities->UsrCmnd_Filter_CommandEntry, TRUE, TRUE, 0);
742     gtk_box_pack_start ((GtkBox *)UserCommandsEntities->UsrCmnd_Filter_DefaultVBox, UserCommandsEntities->UsrCmnd_Filter_DefaultLabel, FALSE, FALSE, 0);
743     gtk_box_pack_start ((GtkBox *)UserCommandsEntities->UsrCmnd_Filter_DefaultVBox, UserCommandsEntities->UsrCmnd_Filter_DefaultEntry, TRUE, TRUE, 0);
744     gtk_box_pack_end ((GtkBox *)UserCommandsEntities->UsrCmnd_Filter_ResetButtonVBox, UserCommandsEntities->UsrCmnd_Filter_ResetButton, FALSE, FALSE, 0);
745 
746     gtk_box_pack_start ((GtkBox *)UserCommandsEntities->UsrCmnd_Filter_1stVBox, UserCommandsEntities->UsrCmnd_Filter_NameVBox, TRUE, TRUE, 0);
747     gtk_box_pack_start ((GtkBox *)UserCommandsEntities->UsrCmnd_Filter_1stVBox, UserCommandsEntities->UsrCmnd_Filter_TargetVBox, TRUE, TRUE, 0);
748 
749     gtk_box_pack_start ((GtkBox *)UserCommandsEntities->UsrCmnd_Filter_2ndVBox, UserCommandsEntities->UsrCmnd_Filter_CommandVBox, TRUE, TRUE, 0);
750     gtk_box_pack_start ((GtkBox *)UserCommandsEntities->UsrCmnd_Filter_2ndVBox, UserCommandsEntities->UsrCmnd_Filter_DefaultVBox, TRUE, TRUE, 0);
751 
752     gtk_box_pack_start ((GtkBox *)UserCommandsEntities->UsrCmnd_Filter_MainHBox, UserCommandsEntities->UsrCmnd_Filter_1stVBox, TRUE, TRUE, 0);
753     gtk_box_pack_start ((GtkBox *)UserCommandsEntities->UsrCmnd_Filter_MainHBox, UserCommandsEntities->UsrCmnd_Filter_2ndVBox, TRUE, TRUE, 0);
754     gtk_box_pack_start ((GtkBox *)UserCommandsEntities->UsrCmnd_Filter_MainHBox, UserCommandsEntities->UsrCmnd_Filter_ResetButtonVBox, FALSE, FALSE, 0);
755 
756     gtk_box_pack_start ((GtkBox *)UserCommandsEntities->UsrCmnd_MainHBox, UserCommandsEntities->UsrCmnd_ScrollWindow, TRUE, TRUE, 0);
757     gtk_box_pack_start ((GtkBox *)UserCommandsEntities->UsrCmnd_MainHBox, UserCommandsEntities->UsrCmnd_Buttons_VBox, FALSE, FALSE, 0);
758 
759     gtk_box_pack_start ((GtkBox *)UserCommandsEntities->UsrCmnd_MainVBox, UserCommandsEntities->UsrCmnd_MainHBox, TRUE, TRUE, 0);
760     gtk_box_pack_start ((GtkBox *)UserCommandsEntities->UsrCmnd_MainVBox, gtk_hseparator_new(), FALSE, FALSE, 4);
761     gtk_box_pack_start ((GtkBox *)UserCommandsEntities->UsrCmnd_MainVBox, UserCommandsEntities->UsrCmnd_Filter_MainHBox, FALSE, FALSE, 0);
762 
763     gtk_tree_view_set_reorderable ((GtkTreeView *)UserCommandsEntities->UsrCmnd_ListView, TRUE );
764 
765     TRACEIT (10, "propPage_createUserCommandsMainWidgets			end");
766 	return 0;
767 }
768 
769 
propPage_arangeListViewAndCo(GtkListStore * listStore,GtkWidget * listView,GtkWidget * scrollwidget,char ** cppNames,int iNumOfColums,int iInvisibleColumns,int iVisibilityColumn)770 int propPage_arangeListViewAndCo(GtkListStore *listStore, GtkWidget *listView, GtkWidget *scrollwidget, char **cppNames, int iNumOfColums, int iInvisibleColumns, int iVisibilityColumn){
771     TRACEIT (10, "propPage_arangeListViewAndCo			start");
772 
773     if (listStore==NULL || listView==NULL || scrollwidget==NULL || cppNames==NULL){
774         TRACEIT (2, "propPage_arangeListViewAndCo			parameter NULL");
775         return -1;
776     }
777 
778     GtkTreeViewColumn   *col;
779 	GtkCellRenderer     *renderer;
780     int i;
781 
782 	for (i=0; i<iNumOfColums ;i++){
783 		col=gtk_tree_view_column_new();
784 
785 		gtk_tree_view_column_set_resizable(col,TRUE);
786 		gtk_tree_view_column_set_reorderable(col,TRUE);
787 		gtk_tree_view_column_set_title(col, cppNames[i]);
788 		if (iInvisibleColumns != -1 && i >= iInvisibleColumns){
789             gtk_tree_view_column_set_visible(col,FALSE);
790         }
791         else{
792             renderer = gtk_cell_renderer_text_new();
793             gtk_tree_view_column_pack_start(col, renderer, TRUE);
794             gtk_tree_view_column_add_attribute(col,renderer,"text",i);
795             gtk_tree_view_append_column(GTK_TREE_VIEW(listView),col);
796             //gtk_tree_view_column_set_sort_column_id(col,i);
797             if (iVisibilityColumn != -1){
798                 gtk_tree_view_column_add_attribute(col,renderer,"visible",iVisibilityColumn);
799             }
800         }
801 	}
802 
803     gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollwidget),GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC);
804     gtk_tree_view_set_model (GTK_TREE_VIEW(listView), GTK_TREE_MODEL(listStore));
805 	gtk_container_add(GTK_CONTAINER(scrollwidget),listView);
806 
807     g_object_unref(listStore);
808 
809     TRACEIT (10, "propPage_arangeListViewAndCo			end");
810     return 0;
811 }
812 
813 
propPage_createOptionsMainWidgets(struct _propPage_MainStruct * mainStruct)814 int propPage_createOptionsMainWidgets (struct _propPage_MainStruct *mainStruct){
815 	TRACEIT (10, "propPage_createOptionsMainWidgets			start");
816 	if (mainStruct == NULL){
817 		TRACEIT (2, "propPage_createOptionsMainWidgets			parameter NULL");
818 		return -1;
819 	}
820     struct _propPage_OptionsEntities *OptionsEntities = &(mainStruct->OptionsEntities);
821 
822     OptionsEntities->Option_MainVbox    = gtk_vbox_new (FALSE, 5);
823     OptionsEntities->Option_Stded_HBox_Name  = gtk_hbox_new (FALSE, 0);
824     OptionsEntities->Option_Stded_Label_Name = gtk_label_new ("Standard editor name:");
825     OptionsEntities->Option_Stded_Edit_Name  = gtk_entry_new ();
826     OptionsEntities->Option_Stded_HBox_Value  = gtk_hbox_new (FALSE, 0);
827     OptionsEntities->Option_Stded_Label_Value = gtk_label_new ("Standard editor:");
828     OptionsEntities->Option_Stded_Edit_Value  = gtk_entry_new ();
829     OptionsEntities->Option_Trmnl_HBox_Name  = gtk_hbox_new (FALSE, 0);
830     OptionsEntities->Option_Trmnl_Label_Name = gtk_label_new ("Terminal name:");
831     OptionsEntities->Option_Trmnl_Edit_Name  = gtk_entry_new ();
832     OptionsEntities->Option_Trmnl_HBox_Value  = gtk_hbox_new (FALSE, 0);
833     OptionsEntities->Option_Trmnl_Label_Value = gtk_label_new ("Terminal:");
834     OptionsEntities->Option_Trmnl_Edit_Value  = gtk_entry_new ();
835     OptionsEntities->Option_Stdd_HBox   = gtk_hbox_new (FALSE, 0);
836     OptionsEntities->Option_Stdd_Label  = gtk_label_new ("Standard directory:");
837     OptionsEntities->Option_Stdd_Edit   = gtk_entry_new ();
838     OptionsEntities->Option_Stdd_Button = gtk_button_new_with_label ("search dir");
839     OptionsEntities->Option_Svpths_HBox = gtk_hbox_new (FALSE, 0);
840     OptionsEntities->Option_Svpths_Check = gtk_check_button_new_with_label ("Save sideview pathes on exit.");
841     OptionsEntities->Option_Strtdl_HBox = gtk_hbox_new (FALSE, 0);
842     OptionsEntities->Option_Strtdl_Label = gtk_label_new ("Start directory left:");
843     OptionsEntities->Option_Strtdl_Edit = gtk_entry_new ();
844     OptionsEntities->Option_Strtdl_Button = gtk_button_new_with_label ("search dir");
845     OptionsEntities->Option_Strtdr_HBox = gtk_hbox_new (FALSE, 0);
846     OptionsEntities->Option_Strtdr_Label = gtk_label_new ("Start directory right:");
847     OptionsEntities->Option_Strtdr_Edit = gtk_entry_new ();
848     OptionsEntities->Option_Strtdr_Button = gtk_button_new_with_label ("search dir");
849     OptionsEntities->Option_ClrItm_HBox = gtk_hbox_new (FALSE, 0);
850     OptionsEntities->Option_ClrItm_Label = gtk_label_new ("Color for items:");
851     OptionsEntities->Option_ClrItm_Button = gtk_color_button_new();//gtk_button_new_with_label ("search dir");
852     OptionsEntities->Option_ClrDir_HBox = gtk_hbox_new (FALSE, 0);
853     OptionsEntities->Option_ClrDir_Label = gtk_label_new ("Color for directories:");
854     OptionsEntities->Option_ClrDir_Button = gtk_color_button_new();//;gtk_button_new_with_label ("search dir");
855     OptionsEntities->Option_ClrLnk_HBox = gtk_hbox_new (FALSE, 0);
856     OptionsEntities->Option_ClrLnk_Label = gtk_label_new ("Color for links:");
857     OptionsEntities->Option_ClrLnk_Button = gtk_color_button_new();//gtk_button_new_with_label ("color");
858     OptionsEntities->Option_ClrMss_HBox = gtk_hbox_new (FALSE, 0);
859     OptionsEntities->Option_ClrMss_Label = gtk_label_new ("Color for missing items:");
860     OptionsEntities->Option_ClrMss_Button = gtk_color_button_new();//gtk_button_new_with_label ("search dir");
861     OptionsEntities->Option_PreviewSize_Label = gtk_label_new ("Preview size:");
862     OptionsEntities->Option_PreviewSize_Edit = gtk_entry_new ();
863     OptionsEntities->Option_PreviewSize_HBox = gtk_hbox_new (FALSE, 0);
864     OptionsEntities->Option_PreviewEndings_Label = gtk_label_new ("Preview of files ending:");
865     OptionsEntities->Option_PreviewEndings_Edit = gtk_entry_new ();
866     OptionsEntities->Option_PreviewEndings_HBox = gtk_hbox_new (FALSE, 0);
867     OptionsEntities->Option_SaveSessionEveryMinutes_Label =  gtk_label_new ("Save Session every N Minutes (0=off):\n(needs a restart of Cat'sEyE)");
868     OptionsEntities->Option_SaveSessionEveryMinutes_Edit = gtk_entry_new();
869     OptionsEntities->Option_SaveSessionEveryMinutes_HBox = gtk_hbox_new (FALSE, 0);
870 
871     gtk_box_pack_start ((GtkBox *)OptionsEntities->Option_Stded_HBox_Name, OptionsEntities->Option_Stded_Label_Name, FALSE, FALSE, 5);
872     gtk_box_pack_end ((GtkBox *)OptionsEntities->Option_Stded_HBox_Name, OptionsEntities->Option_Stded_Edit_Name, TRUE, TRUE, 5);
873     gtk_box_pack_start ((GtkBox *)OptionsEntities->Option_Stded_HBox_Value, OptionsEntities->Option_Stded_Label_Value, FALSE, FALSE, 5);
874     gtk_box_pack_end ((GtkBox *)OptionsEntities->Option_Stded_HBox_Value, OptionsEntities->Option_Stded_Edit_Value, TRUE, TRUE, 5);
875 
876     gtk_box_pack_start ((GtkBox *)OptionsEntities->Option_Trmnl_HBox_Name, OptionsEntities->Option_Trmnl_Label_Name, FALSE, FALSE, 5);
877     gtk_box_pack_end ((GtkBox *)OptionsEntities->Option_Trmnl_HBox_Name, OptionsEntities->Option_Trmnl_Edit_Name, TRUE, TRUE, 5);
878     gtk_box_pack_start ((GtkBox *)OptionsEntities->Option_Trmnl_HBox_Value, OptionsEntities->Option_Trmnl_Label_Value, FALSE, FALSE, 5);
879     gtk_box_pack_end ((GtkBox *)OptionsEntities->Option_Trmnl_HBox_Value, OptionsEntities->Option_Trmnl_Edit_Value, TRUE, TRUE, 5);
880 
881     gtk_box_pack_start ((GtkBox *)OptionsEntities->Option_Stdd_HBox, OptionsEntities->Option_Stdd_Label, FALSE, FALSE, 5);
882     gtk_box_pack_start ((GtkBox *)OptionsEntities->Option_Stdd_HBox, OptionsEntities->Option_Stdd_Edit, TRUE, TRUE, 5);
883     gtk_box_pack_end ((GtkBox *)OptionsEntities->Option_Stdd_HBox, OptionsEntities->Option_Stdd_Button, FALSE, FALSE, 5);
884 
885     gtk_box_pack_start ((GtkBox *)OptionsEntities->Option_Svpths_HBox, OptionsEntities->Option_Svpths_Check, FALSE, FALSE, 5);
886 
887     gtk_box_pack_start ((GtkBox *)OptionsEntities->Option_Strtdl_HBox, OptionsEntities->Option_Strtdl_Label, FALSE, FALSE, 5);
888     gtk_box_pack_start ((GtkBox *)OptionsEntities->Option_Strtdl_HBox, OptionsEntities->Option_Strtdl_Edit, TRUE, TRUE, 5);
889     gtk_box_pack_end ((GtkBox *)OptionsEntities->Option_Strtdl_HBox, OptionsEntities->Option_Strtdl_Button, FALSE, FALSE, 5);
890 
891     gtk_box_pack_start ((GtkBox *)OptionsEntities->Option_Strtdr_HBox, OptionsEntities->Option_Strtdr_Label, FALSE, FALSE, 5);
892     gtk_box_pack_start ((GtkBox *)OptionsEntities->Option_Strtdr_HBox, OptionsEntities->Option_Strtdr_Edit, TRUE, TRUE, 5);
893     gtk_box_pack_end ((GtkBox *)OptionsEntities->Option_Strtdr_HBox, OptionsEntities->Option_Strtdr_Button, FALSE, FALSE, 5);
894 
895     gtk_box_pack_start ((GtkBox *)OptionsEntities->Option_ClrItm_HBox, OptionsEntities->Option_ClrItm_Label, FALSE, FALSE, 5);
896     gtk_box_pack_end ((GtkBox *)OptionsEntities->Option_ClrItm_HBox, OptionsEntities->Option_ClrItm_Button, FALSE, FALSE, 5);
897 
898     gtk_box_pack_start ((GtkBox *)OptionsEntities->Option_ClrDir_HBox, OptionsEntities->Option_ClrDir_Label, FALSE, FALSE, 5);
899     gtk_box_pack_end ((GtkBox *)OptionsEntities->Option_ClrDir_HBox, OptionsEntities->Option_ClrDir_Button, FALSE, FALSE, 5);
900 
901     gtk_box_pack_start ((GtkBox *)OptionsEntities->Option_ClrLnk_HBox, OptionsEntities->Option_ClrLnk_Label, FALSE, FALSE, 5);
902     gtk_box_pack_end ((GtkBox *)OptionsEntities->Option_ClrLnk_HBox, OptionsEntities->Option_ClrLnk_Button, FALSE, FALSE, 5);
903 
904     gtk_box_pack_start ((GtkBox *)OptionsEntities->Option_ClrMss_HBox, OptionsEntities->Option_ClrMss_Label, FALSE, FALSE, 5);
905     gtk_box_pack_end ((GtkBox *)OptionsEntities->Option_ClrMss_HBox, OptionsEntities->Option_ClrMss_Button, FALSE, FALSE, 5);
906 
907     gtk_box_pack_start ((GtkBox *)OptionsEntities->Option_PreviewSize_HBox, OptionsEntities->Option_PreviewSize_Label, FALSE, FALSE, 5);
908     gtk_box_pack_end ((GtkBox *)OptionsEntities->Option_PreviewSize_HBox, OptionsEntities->Option_PreviewSize_Edit, FALSE, FALSE, 5);
909 
910     gtk_box_pack_start ((GtkBox *)OptionsEntities->Option_PreviewEndings_HBox, OptionsEntities->Option_PreviewEndings_Label, FALSE, FALSE, 5);
911     gtk_box_pack_end ((GtkBox *)OptionsEntities->Option_PreviewEndings_HBox, OptionsEntities->Option_PreviewEndings_Edit, FALSE, FALSE, 5);
912 
913 	gtk_box_pack_start ((GtkBox *)OptionsEntities->Option_SaveSessionEveryMinutes_HBox, OptionsEntities->Option_SaveSessionEveryMinutes_Label, FALSE, FALSE, 5);
914 	gtk_box_pack_end ((GtkBox *)OptionsEntities->Option_SaveSessionEveryMinutes_HBox, OptionsEntities->Option_SaveSessionEveryMinutes_Edit, FALSE, FALSE, 5);
915 
916 
917     gtk_box_pack_start ((GtkBox *)OptionsEntities->Option_MainVbox, OptionsEntities->Option_Stded_HBox_Name, FALSE, FALSE, 0);
918     gtk_box_pack_start ((GtkBox *)OptionsEntities->Option_MainVbox, OptionsEntities->Option_Stded_HBox_Value, FALSE, FALSE, 0);
919     gtk_box_pack_start ((GtkBox *)OptionsEntities->Option_MainVbox, OptionsEntities->Option_Trmnl_HBox_Name, FALSE, FALSE, 0);
920     gtk_box_pack_start ((GtkBox *)OptionsEntities->Option_MainVbox, OptionsEntities->Option_Trmnl_HBox_Value, FALSE, FALSE, 0);
921     gtk_box_pack_start ((GtkBox *)OptionsEntities->Option_MainVbox, OptionsEntities->Option_Stdd_HBox, FALSE, FALSE, 0);
922     gtk_box_pack_start ((GtkBox *)OptionsEntities->Option_MainVbox, OptionsEntities->Option_Svpths_HBox, FALSE, FALSE, 0);
923     gtk_box_pack_start ((GtkBox *)OptionsEntities->Option_MainVbox, OptionsEntities->Option_Strtdl_HBox, FALSE, FALSE, 0);
924     gtk_box_pack_start ((GtkBox *)OptionsEntities->Option_MainVbox, OptionsEntities->Option_Strtdr_HBox, FALSE, FALSE, 0);
925     gtk_box_pack_start ((GtkBox *)OptionsEntities->Option_MainVbox, OptionsEntities->Option_ClrItm_HBox, FALSE, FALSE, 0);
926     gtk_box_pack_start ((GtkBox *)OptionsEntities->Option_MainVbox, OptionsEntities->Option_ClrDir_HBox, FALSE, FALSE, 0);
927     gtk_box_pack_start ((GtkBox *)OptionsEntities->Option_MainVbox, OptionsEntities->Option_ClrLnk_HBox, FALSE, FALSE, 0);
928     gtk_box_pack_start ((GtkBox *)OptionsEntities->Option_MainVbox, OptionsEntities->Option_ClrMss_HBox, FALSE, FALSE, 0);
929     gtk_box_pack_start ((GtkBox *)OptionsEntities->Option_MainVbox, OptionsEntities->Option_PreviewSize_HBox, FALSE, FALSE, 0);
930     gtk_box_pack_start ((GtkBox *)OptionsEntities->Option_MainVbox, OptionsEntities->Option_PreviewEndings_HBox, FALSE, FALSE, 0);
931     gtk_box_pack_start ((GtkBox *)OptionsEntities->Option_MainVbox, OptionsEntities->Option_SaveSessionEveryMinutes_HBox, FALSE, FALSE, 0);
932 
933 
934 	TRACEIT (10, "propPage_createOptionsMainWidgets			end");
935 	return 0;
936 }
937 
938 
propPage_external_fillPropPageWidgets()939 int propPage_external_fillPropPageWidgets (){
940     TRACEIT (10, "propPage_external_fillPropPageWidgets			start");
941     if (g_mainStruct != NULL){
942         propPage_fillPropPageWidgets (g_mainStruct);
943         g_mainStruct->iSaved = 0;
944     }
945     TRACEIT (10, "propPage_external_fillPropPageWidgets			end");
946     return 0;
947 }
948 
949 
propPage_external_deleteItemFromglistUserCommandWidgets(GtkWidget * widget)950 int propPage_external_deleteItemFromglistUserCommandWidgets (GtkWidget *widget){
951     TRACEIT (10, "propPage_external_deleteItemFromglistUserCommandWidgets			start");
952     if (widget == NULL){
953         TRACEIT (2, "propPage_external_deleteItemFromglistUserCommandWidgets			parameter NULL");
954         return -1;
955     }
956 
957     if (g_glistUserCommandWidgets)
958         g_glistUserCommandWidgets = g_list_remove (g_glistUserCommandWidgets, widget);
959 
960     TRACEIT (10, "propPage_external_deleteItemFromglistUserCommandWidgets			end");
961     return 0;
962 }
963 
964 
propPage_fillPropPageWidgets(struct _propPage_MainStruct * mainStruct)965 int propPage_fillPropPageWidgets (struct _propPage_MainStruct *mainStruct){
966 	TRACEIT (10, "propPage_fillPropPageWidgets			start");
967 	if (mainStruct == NULL){
968 		TRACEIT (2, "propPage_fillPropPageWidgets			parameter NULL");
969 		return -1;
970 	}
971 
972     propPage_updateFileNameLabel (mainStruct);
973     propPage_fillOptionsMainWidgets (mainStruct);
974     propPage_fillBkmrkMainWidgets (mainStruct);
975     propPage_fillColumnOrderWidgets (mainStruct, 0);
976 	propPage_fillUserCommandsMainWidgets (mainStruct);
977 
978     TRACEIT (10, "propPage_fillPropPageWidgets			end");
979     return 0;
980 }
981 
982 
propPage_fillUserCommandsMainWidgets(struct _propPage_MainStruct * mainStruct)983 int propPage_fillUserCommandsMainWidgets (struct _propPage_MainStruct *mainStruct){
984     TRACEIT (10, "propPage_fillUserCommandsMainWidgets			start");
985 	if (mainStruct == NULL){
986 		TRACEIT (2, "propPage_fillUserCommandsMainWidgets			parameter NULL");
987 		return -1;
988 	}
989     struct _propPage_UserCommandsEntities *UserCommandsEntities = &(mainStruct->UserCommandsEntities);
990 
991     GtkTreeIter iter;
992     int i;
993     GString *gstrBuf = g_string_sized_new (10);
994     GList *glistBuf = NULL;
995     struct _UserCommandList *listBuf = UserCommandList_getFirstItem (g_UserCommandList);
996 
997     gtk_list_store_clear (UserCommandsEntities->UsrCmnd_ListStore);
998 
999     i=1;
1000     while (listBuf){
1001         gtk_list_store_append (UserCommandsEntities->UsrCmnd_ListStore, &iter);
1002         //Position
1003         //gtk_list_store_set (UserCommandsEntities->UsrCmnd_ListStore, &iter, PROPPAGE_COL_USCMND_POSITION, i, -1);
1004         //DefaultCommand
1005         if (listBuf->iIsDefaultCommand == 1){
1006             g_string_assign (gstrBuf, "true");
1007         }
1008         else{
1009             g_string_assign (gstrBuf, "false");
1010         }
1011         gtk_list_store_set (UserCommandsEntities->UsrCmnd_ListStore, &iter, PROPPAGE_COL_USCMND_DEFAULT, gstrBuf->str, -1);
1012         //Command
1013         g_string_assign (gstrBuf, listBuf->gstrCommand->str);
1014         //g_string_truncate (gstrBuf, 20);
1015         gtk_list_store_set (UserCommandsEntities->UsrCmnd_ListStore, &iter, PROPPAGE_COL_USCMND_COMMAND, gstrBuf->str, -1);
1016         //Targets
1017         g_string_assign (gstrBuf, "");
1018         glistBuf = listBuf->glistTargets;
1019         while (glistBuf){
1020             g_string_append (gstrBuf, ((GString *)(glistBuf->data))->str);
1021             g_string_append (gstrBuf, " ");
1022 
1023             glistBuf = glistBuf->next;
1024         }
1025         gtk_list_store_set (UserCommandsEntities->UsrCmnd_ListStore, &iter, PROPPAGE_COL_USCMND_TARGET, gstrBuf->str, -1);
1026         //Itempointer
1027         gtk_list_store_set (UserCommandsEntities->UsrCmnd_ListStore, &iter, PROPPAGE_COL_USCMND_ITEMPOINTER, listBuf, -1);
1028         //Name
1029         gtk_list_store_set (UserCommandsEntities->UsrCmnd_ListStore, &iter, PROPPAGE_COL_USCMND_NAME, listBuf->gstrName->str, -1);
1030         //visibility
1031         gtk_list_store_set (UserCommandsEntities->UsrCmnd_ListStore, &iter, PROPPAGE_COL_USCMND_VISIBLE, TRUE, -1);
1032         i++;
1033         listBuf = listBuf->nextItem;
1034     }
1035 
1036     propPage_UserCommandFilterApply (UserCommandsEntities);
1037 
1038     g_string_free (gstrBuf, TRUE);
1039     TRACEIT (10, "propPage_fillUserCommandsMainWidgets			end");
1040     return 0;
1041 }
1042 
propPage_fillColumnOrderWidgets(struct _propPage_MainStruct * mainStruct,int iUseDefault)1043 int propPage_fillColumnOrderWidgets (struct _propPage_MainStruct *mainStruct, int iUseDefault){
1044 	//iUseDefault == 0 : Do not use default if there is some user information
1045 	//				!= 0 : Default will be used
1046 	TRACEIT (10, "propPage_fillColumnOrderWidgets			start");
1047 	if (mainStruct == NULL){
1048 		TRACEIT (2, "propPage_fillColumnOrderWidgets			parameter NULL");
1049 		return -1;
1050 	}
1051 	struct _propPage_ColumnOrder *clmnOrder = &(mainStruct->ColumnOrder);
1052 
1053 	//try to load users order, then start filling the listview
1054 	const char *ccpUsersOrder = OptionsList_getValueByID (g_OptionsList, COLUMN_ORDER);
1055 	int i;
1056 	GString *gstrColumnNames = g_string_sized_new (100);
1057 	GString *gstrToken = g_string_sized_new (15);
1058 	GtkTreeIter iter;
1059 
1060 	if (iUseDefault == 0 && NULL != ccpUsersOrder ){
1061 		g_string_assign (gstrColumnNames, ccpUsersOrder);
1062 	}
1063 	else{
1064 		g_string_append (gstrColumnNames, "\"");
1065 		for (i=0; i<COL_TIMESTAMPACCESSED; i++){
1066 			g_string_append (gstrColumnNames, Names[i]);
1067 
1068 			g_string_append (gstrColumnNames, COLUMN_ORDER_SEPARATOR);
1069 		}
1070 		g_string_append (gstrColumnNames, "\"");
1071 		g_string_erase (gstrColumnNames, gstrColumnNames->len-strlen(COLUMN_ORDER_SEPARATOR), -1);
1072 	}
1073 
1074 	gtk_list_store_clear (clmnOrder->ClmOrder_ListStore);
1075 	//fill the listview
1076 	for (i=0 ; 1 == myTokenFunction(gstrColumnNames, i, COLUMN_ORDER_SEPARATOR, gstrToken) ; i++){
1077 		cutCharFromGString(gstrToken, '\"', 0);
1078 		if ( 0 == strlen (gstrToken->str)){
1079 			break;
1080 		}
1081 
1082 		gtk_list_store_append (clmnOrder->ClmOrder_ListStore, &iter);
1083         gtk_list_store_set (clmnOrder->ClmOrder_ListStore, &iter, PROPPAGE_COL_COLORDER_NAME, gstrToken->str, -1);
1084 	}
1085 
1086 	g_string_free (gstrToken, TRUE);
1087 	g_string_free (gstrColumnNames, TRUE);
1088 
1089 	TRACEIT (10, "propPage_fillColumnOrderWidgets			end");
1090 	return 0;
1091 }
1092 
propPage_fillBkmrkMainWidgets(struct _propPage_MainStruct * mainStruct)1093 int propPage_fillBkmrkMainWidgets (struct _propPage_MainStruct *mainStruct){
1094 	TRACEIT (10, "propPage_fillBkmrkMainWidgets			start");
1095 	if (mainStruct == NULL){
1096 		TRACEIT (2, "propPage_fillBkmrkMainWidgets			parameter NULL");
1097 		return -1;
1098 	}
1099     struct _propPage_BookmarkEntities *bkmrkEntities = &(mainStruct->bkmrkEntities);
1100 
1101     GtkTreeIter iter;
1102     int i;
1103 
1104     struct _OptionsList *listBuf = OptionsList_getFirstItem (g_BookMarkList);
1105 
1106     gtk_list_store_clear (bkmrkEntities->Bkmrk_ListStore);
1107 
1108     i=1;
1109     while (listBuf){
1110         gtk_list_store_append (bkmrkEntities->Bkmrk_ListStore, &iter);
1111         //Position
1112         //gtk_list_store_set (bkmrkEntities->Bkmrk_ListStore, &iter, PROPPAGE_COL_BKMRK_POSITION, i, -1);
1113         //Name
1114         if (listBuf->gstrName)
1115             gtk_list_store_set (bkmrkEntities->Bkmrk_ListStore, &iter, PROPPAGE_COL_BKMRK_NAME, listBuf->gstrName->str, -1);
1116         //Path
1117         if (listBuf->gstrValue)
1118             gtk_list_store_set (bkmrkEntities->Bkmrk_ListStore, &iter, PROPPAGE_COL_BKMRK_PATH, listBuf->gstrValue->str, -1);
1119         //Itempointer
1120         gtk_list_store_set (bkmrkEntities->Bkmrk_ListStore, &iter, PROPPAGE_COL_BKMRK_ITEMPOINTER, listBuf, -1);
1121 
1122         i++;
1123         listBuf = listBuf->nextItem;
1124     }
1125 
1126     TRACEIT (10, "propPage_fillBkmrkMainWidgets			end");
1127     return 0;
1128 }
1129 
1130 
propPage_fillOptionsMainWidgets(struct _propPage_MainStruct * mainStruct)1131 int propPage_fillOptionsMainWidgets (struct _propPage_MainStruct *mainStruct){
1132 	TRACEIT (10, "propPage_fillOptionsMainWidgets			start");
1133 	if (mainStruct == NULL){
1134 		TRACEIT (2, "propPage_fillOptionsMainWidgets			parameter NULL");
1135 		return -1;
1136 	}
1137     struct _propPage_OptionsEntities *OptionsEntities = &(mainStruct->OptionsEntities);
1138 
1139     const char *cpColorDir=NULL;
1140 	const char *cpColorItm=NULL;
1141 	const char *cpColorLnk=NULL;
1142 	const char *cpColorMss=NULL;
1143 	const char cpColorFallBackItms[] = DEFAULT_COLOR_ITEMS_DEFAULT;
1144 	const char cpColorFallBackDirs[] = DEFAULT_COLOR_DIRECTORIES;
1145 	const char cpColorFallBackLnks[] = DEFAULT_COLOR_LINKS;
1146 	const char cpColorFallBackMss[]  = DEFAULT_COLOR_ITEMS_MISSING;
1147 
1148 	cpColorDir = OptionsList_getValueByID (g_OptionsList, COLOR_DIRECTORIES);
1149 	cpColorItm = OptionsList_getValueByID (g_OptionsList, COLOR_ITEMS_DEFAULT);
1150 	cpColorLnk = OptionsList_getValueByID (g_OptionsList, COLOR_LINKS);
1151 	cpColorMss = OptionsList_getValueByID (g_OptionsList, COLOR_ITEMS_MISSING);
1152 
1153     if (cpColorDir == NULL)
1154         cpColorDir = cpColorFallBackDirs;
1155     if (cpColorItm == NULL)
1156         cpColorItm = cpColorFallBackItms;
1157     if (cpColorLnk == NULL)
1158         cpColorLnk = cpColorFallBackLnks;
1159     if (cpColorMss == NULL)
1160         cpColorMss = cpColorFallBackMss;
1161 
1162     OptionsEntities->Option_Colormap = gdk_colormap_get_system ();
1163 
1164     gdk_colormap_alloc_color (OptionsEntities->Option_Colormap, &(OptionsEntities->Option_ClrItm_gdkColor), TRUE, TRUE);
1165     gdk_colormap_alloc_color (OptionsEntities->Option_Colormap, &(OptionsEntities->Option_ClrDir_gdkColor), TRUE, TRUE);
1166     gdk_colormap_alloc_color (OptionsEntities->Option_Colormap, &(OptionsEntities->Option_ClrLnk_gdkColor), TRUE, TRUE);
1167     gdk_colormap_alloc_color (OptionsEntities->Option_Colormap, &(OptionsEntities->Option_ClrMss_gdkColor), TRUE, TRUE);
1168 
1169     gdk_color_parse (cpColorItm, &(OptionsEntities->Option_ClrItm_gdkColor));
1170     gdk_color_parse (cpColorDir, &(OptionsEntities->Option_ClrDir_gdkColor));
1171     gdk_color_parse (cpColorLnk, &(OptionsEntities->Option_ClrLnk_gdkColor));
1172     gdk_color_parse (cpColorMss, &(OptionsEntities->Option_ClrMss_gdkColor));
1173 
1174     gtk_color_button_set_color ((GtkColorButton *)OptionsEntities->Option_ClrItm_Button, &(OptionsEntities->Option_ClrItm_gdkColor));
1175     gtk_color_button_set_color ((GtkColorButton *)OptionsEntities->Option_ClrDir_Button, &(OptionsEntities->Option_ClrDir_gdkColor));
1176     gtk_color_button_set_color ((GtkColorButton *)OptionsEntities->Option_ClrLnk_Button, &(OptionsEntities->Option_ClrLnk_gdkColor));
1177     gtk_color_button_set_color ((GtkColorButton *)OptionsEntities->Option_ClrMss_Button, &(OptionsEntities->Option_ClrMss_gdkColor));
1178 
1179     const char *ccpBuf = NULL;
1180 
1181     ccpBuf = OptionsList_getValueByID (g_OptionsList, STANDARDEDITORKEY);
1182     gtk_entry_set_text ((GtkEntry *)OptionsEntities->Option_Stded_Edit_Value, "");
1183     if (ccpBuf != NULL){
1184         gtk_entry_set_text ((GtkEntry *)OptionsEntities->Option_Stded_Edit_Value, ccpBuf);
1185     }
1186     ccpBuf = OptionsList_getNameByID (g_OptionsList, STANDARDEDITORKEY);
1187     gtk_entry_set_text ((GtkEntry *)OptionsEntities->Option_Stded_Edit_Name, "");
1188     if (ccpBuf != NULL){
1189         gtk_entry_set_text ((GtkEntry *)OptionsEntities->Option_Stded_Edit_Name, ccpBuf);
1190     }
1191     ccpBuf = OptionsList_getValueByID (g_OptionsList, TERMINALKEY);
1192     gtk_entry_set_text ((GtkEntry *)OptionsEntities->Option_Trmnl_Edit_Value, "");
1193     if (ccpBuf != NULL){
1194         gtk_entry_set_text ((GtkEntry *)OptionsEntities->Option_Trmnl_Edit_Value, ccpBuf);
1195     }
1196     ccpBuf = OptionsList_getNameByID (g_OptionsList, TERMINALKEY);
1197     gtk_entry_set_text ((GtkEntry *)OptionsEntities->Option_Trmnl_Edit_Name, "");
1198     if (ccpBuf != NULL){
1199         gtk_entry_set_text ((GtkEntry *)OptionsEntities->Option_Trmnl_Edit_Name, ccpBuf);
1200     }
1201     ccpBuf = OptionsList_getValueByID (g_OptionsList, STANDARDSTARTDIRECTORY);
1202     gtk_entry_set_text ((GtkEntry *)OptionsEntities->Option_Stdd_Edit, "");
1203     if (ccpBuf != NULL){
1204         gtk_entry_set_text ((GtkEntry *)OptionsEntities->Option_Stdd_Edit, ccpBuf);
1205     }
1206     ccpBuf = OptionsList_getValueByID (g_OptionsList, STARTDIRECTORIESLEFTKEY);
1207     gtk_entry_set_text ((GtkEntry *)OptionsEntities->Option_Strtdl_Edit, "");
1208     if (ccpBuf != NULL){
1209         gtk_entry_set_text ((GtkEntry *)OptionsEntities->Option_Strtdl_Edit, ccpBuf);
1210     }
1211     ccpBuf = OptionsList_getValueByID (g_OptionsList, STARTDIRECTORIESRIGHTKEY);
1212     gtk_entry_set_text ((GtkEntry *)OptionsEntities->Option_Strtdr_Edit, "");
1213     if (ccpBuf != NULL){
1214         gtk_entry_set_text ((GtkEntry *)OptionsEntities->Option_Strtdr_Edit, ccpBuf);
1215     }
1216     ccpBuf = OptionsList_getValueByID (g_OptionsList, SAVEPATHESONEXIT);
1217     if (ccpBuf != NULL && ( 0==strcmp(ccpBuf, "TRUE") || 0==strcmp(ccpBuf, "true") || 0==strcmp(ccpBuf, "True"))){
1218         gtk_toggle_button_set_active ( (GtkToggleButton *)OptionsEntities->Option_Svpths_Check, TRUE);
1219     }
1220     else{
1221         gtk_toggle_button_set_active ( (GtkToggleButton *)OptionsEntities->Option_Svpths_Check, FALSE);
1222     }
1223     ccpBuf = OptionsList_getValueByID (g_OptionsList, PREVIEWSIZE);
1224     gtk_entry_set_text ((GtkEntry *)OptionsEntities->Option_PreviewSize_Edit, "");
1225     if (ccpBuf != NULL){
1226         gtk_entry_set_text ((GtkEntry *)OptionsEntities->Option_PreviewSize_Edit, ccpBuf);
1227     }
1228     ccpBuf = OptionsList_getValueByID (g_OptionsList, PREVIEWTYPES);
1229     gtk_entry_set_text ((GtkEntry *)OptionsEntities->Option_PreviewEndings_Edit, "");
1230     if (ccpBuf != NULL){
1231         gtk_entry_set_text ((GtkEntry *)OptionsEntities->Option_PreviewEndings_Edit, ccpBuf);
1232     }
1233 	ccpBuf = OptionsList_getValueByID (g_OptionsList, SAVESESSIONMINUTESTYPES);
1234     gtk_entry_set_text ((GtkEntry *)OptionsEntities->Option_SaveSessionEveryMinutes_Edit, "");
1235     if (ccpBuf != NULL){
1236         gtk_entry_set_text ((GtkEntry *)OptionsEntities->Option_SaveSessionEveryMinutes_Edit, ccpBuf);
1237     }
1238     else{
1239 		gtk_entry_set_text ((GtkEntry *)OptionsEntities->Option_SaveSessionEveryMinutes_Edit, "0");
1240     }
1241 
1242     TRACEIT (10, "propPage_fillOptionsMainWidgets			end");
1243     return 0;
1244 }
1245 
1246 
propPage_assignFunctionality(struct _propPage_MainStruct * mainStruct)1247 int propPage_assignFunctionality (struct _propPage_MainStruct *mainStruct){
1248 	TRACEIT (10, "propPage_assignFunctionality			start");
1249 	if (mainStruct == NULL){
1250 		TRACEIT (2, "propPage_assignFunctionality			parameter NULL");
1251 		return -1;
1252 	}
1253 
1254     propPage_assignMainFunctionality (mainStruct);
1255 	propPage_assignOptionsFunctionality (mainStruct);
1256     propPage_assignBkmrkFunctionality (mainStruct);
1257     propPage_assignColumnOrderFunctionality (mainStruct);
1258 	propPage_assignUserCommandsFunctionality (mainStruct);
1259 	TRACEIT (10, "propPage_assignFunctionality			end");
1260     return 0;
1261 }
1262 
1263 
propPage_assignMainFunctionality(struct _propPage_MainStruct * mainStruct)1264 int propPage_assignMainFunctionality (struct _propPage_MainStruct *mainStruct){
1265     TRACEIT (10, "propPage_assignMainFunctionality			start");
1266 	if (mainStruct == NULL){
1267 		TRACEIT (2, "propPage_assignMainFunctionality			parameter NULL");
1268 		return -1;
1269 	}
1270 
1271     g_signal_connect(mainStruct->mainEntities.Main_Button_Close,"clicked",G_CALLBACK(propPage_MainButtonClose), (void *)mainStruct);
1272     g_signal_connect(mainStruct->mainEntities.Main_Button_Reload,"clicked",G_CALLBACK(propPage_MainButtonReload), (void *)mainStruct);
1273     g_signal_connect(mainStruct->mainEntities.Main_Button_LoadFrom,"clicked",G_CALLBACK(propPage_MainButtonLoadFrom), (void *)mainStruct);
1274 
1275     g_signal_connect(mainStruct->mainEntities.Main_Button_SaveTo,"clicked",G_CALLBACK(propPage_MainButtonSaveTo), (void *)mainStruct);
1276     g_signal_connect(mainStruct->mainEntities.Main_Button_Save,"clicked",G_CALLBACK(propPage_MainButtonSave), (void *)mainStruct);
1277 
1278     TRACEIT (10, "propPage_assignMainFunctionality			end");
1279     return 0;
1280 }
1281 
1282 
propPage_MainButtonSave(GtkButton * Button,struct _propPage_MainStruct * mainStruct)1283 void propPage_MainButtonSave (GtkButton *Button, struct _propPage_MainStruct *mainStruct){
1284     TRACEIT(10,"propPage_MainButtonSave		start");
1285     if (mainStruct == NULL){
1286         TRACEIT(2,"propPage_MainButtonSave		parameter NULL");
1287         return;
1288     }
1289     GtkWidget *dialog = CreateMyDialog("Overwrite",(GtkWindow *)mainStruct->mainEntities.Main_Widget,2,"Ok",GTK_RESPONSE_ACCEPT,"Cancel",GTK_RESPONSE_REJECT, NULL, 0,  TRUE);
1290     GtkWidget *label = gtk_label_new("Do you want to overwrite the\ncurrently used config file?\n");
1291 	gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox),label);
1292     gtk_widget_show_all(dialog);
1293     int iDRet = gtk_dialog_run(GTK_DIALOG(dialog));
1294     if (iDRet != GTK_RESPONSE_ACCEPT){
1295         gtk_widget_destroy(dialog);
1296         TRACEIT(10,"propPage_MainButtonSave		end");
1297         return;
1298     }
1299 
1300     gtk_widget_destroy(dialog);
1301     propPage_saveAllToXMLFile (mainStruct, NULL);
1302 
1303     TRACEIT(10,"propPage_MainButtonSave		end");
1304     return;
1305 }
1306 
1307 
propPage_MainButtonSaveTo(GtkButton * Button,struct _propPage_MainStruct * mainStruct)1308 void propPage_MainButtonSaveTo (GtkButton *Button, struct _propPage_MainStruct *mainStruct){
1309     TRACEIT(10,"propPage_MainButtonSaveTo		start");
1310     if (mainStruct == NULL){
1311         TRACEIT(2,"propPage_MainButtonSaveTo		parameter NULL");
1312         return;
1313     }
1314 
1315     GtkWidget *dialog;
1316     GString *HomeDir = g_string_sized_new (20);
1317     char *filename = NULL;
1318 
1319     dialog = gtk_file_chooser_dialog_new ("Save configuration as",
1320 				      (GtkWindow *)mainStruct->mainEntities.Main_Widget,
1321 				      GTK_FILE_CHOOSER_ACTION_SAVE,
1322 				      GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
1323 				      GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
1324 				      NULL);
1325     gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog), TRUE);
1326 
1327     getHomeDirectory(HomeDir);
1328     checkPathForLastChar(HomeDir);
1329     g_string_append(HomeDir,CATSEYEHOMEDIR);
1330     gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), HomeDir->str);
1331 
1332     getHomeDirectory(HomeDir);
1333     checkPathForLastChar(HomeDir);
1334     g_string_assign(HomeDir, CONFIG_FILE_TYPES);
1335     getLastStringInPath (HomeDir);
1336 
1337     gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog), HomeDir->str);
1338 
1339     if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT){
1340         filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
1341         gtk_widget_destroy (dialog);
1342         if (filename){
1343             propPage_saveAllToXMLFile (mainStruct, filename);
1344         }
1345     }
1346     else{
1347         gtk_widget_destroy (dialog);
1348     }
1349 
1350     if (HomeDir){
1351         g_string_free (HomeDir, TRUE);
1352     }
1353     if (filename)
1354         g_free (filename);
1355 
1356     TRACEIT(10,"propPage_MainButtonSaveTo		end");
1357     return;
1358 }
1359 
1360 
propPage_saveAllToXMLFile(struct _propPage_MainStruct * mainStruct,const char * FileName)1361 int propPage_saveAllToXMLFile (struct _propPage_MainStruct *mainStruct, const char *FileName){
1362     TRACEIT(10,"propPage_saveAllToXMLFile		start");
1363     if (mainStruct == NULL){
1364         TRACEIT(2,"propPage_saveAllToXMLFile		parameter NULL");
1365         return -1;
1366     }
1367     mainStruct->iSaved = 1;
1368     propPage_writeOptionsToGlobalStruct (mainStruct);
1369     propPage_writeColumnOrderToGlobalStruct (mainStruct);
1370     propPage_reorderBookmarkListByListView (mainStruct);
1371     propPage_reorderUsercommandListByListView (mainStruct);
1372 
1373     configFileHandling_saveGlobalStructsAsXMLConfigFile (FileName, FALSE);
1374 
1375     TRACEIT(10,"propPage_saveAllToXMLFile		end");
1376     return 0;
1377 }
1378 
1379 
getPointerFromListView(GtkTreeModel * model,GtkTreePath * path,GtkTreeIter * iter,struct _propPage_ReoderLists_Stru * Struct)1380 gboolean getPointerFromListView (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, struct _propPage_ReoderLists_Stru *Struct ){
1381     TRACEIT(10,"getPointerFromListView		start");
1382     if (Struct == NULL){
1383         TRACEIT(10,"getPointerFromListView		parameter NULL");
1384         return TRUE;
1385     }
1386 
1387     void *vP=NULL;
1388     gtk_tree_model_get(model, iter, Struct->iColumn, &vP, -1);
1389 
1390     Struct->glistListPointer = g_list_append (Struct->glistListPointer, vP);
1391 
1392     TRACEIT(10,"getPointerFromListView		end");
1393     return FALSE; //to continue, TRUE to stop iterating
1394 }
1395 
1396 
propPage_reorderBookmarkListByListView(struct _propPage_MainStruct * mainStruct)1397 int propPage_reorderBookmarkListByListView (struct _propPage_MainStruct *mainStruct){
1398     TRACEIT(10,"propPage_reorderBookmarkListByListView		start");
1399     if (mainStruct == NULL){
1400         TRACEIT(2,"propPage_reorderBookmarkListByListView		parameter NULL");
1401         return -1;
1402     }
1403     struct _propPage_ReoderLists_Stru Struct;
1404     GList *glistBuf=NULL;
1405     struct _OptionsList *BkmrkListNewFirstItem=NULL;
1406     Struct.glistListPointer = NULL;
1407     Struct.iColumn = PROPPAGE_COL_BKMRK_ITEMPOINTER;
1408 
1409     gtk_tree_model_foreach ((GtkTreeModel *)mainStruct->bkmrkEntities.Bkmrk_ListStore, (GtkTreeModelForeachFunc)getPointerFromListView, &Struct);
1410 
1411     glistBuf = Struct.glistListPointer;
1412     if (glistBuf)
1413         BkmrkListNewFirstItem = (struct _OptionsList *)glistBuf->data;
1414     while (glistBuf){
1415         ((struct _OptionsList *)glistBuf->data)->prevItem = (glistBuf->prev)?((struct _OptionsList *)glistBuf->prev->data):NULL;
1416         ((struct _OptionsList *)glistBuf->data)->nextItem = (glistBuf->next)?((struct _OptionsList *)glistBuf->next->data):NULL;
1417         glistBuf = glistBuf->next;
1418     }
1419     g_BookMarkList = BkmrkListNewFirstItem;
1420     g_list_free (Struct.glistListPointer);
1421 
1422     TRACEIT(10,"propPage_reorderBookmarkListByListView		end");
1423     return 0;
1424 }
1425 
1426 
propPage_reorderUsercommandListByListView(struct _propPage_MainStruct * mainStruct)1427 int propPage_reorderUsercommandListByListView (struct _propPage_MainStruct *mainStruct){
1428     TRACEIT(10,"propPage_reorderUsercommandListByListView		start");
1429     if (mainStruct == NULL){
1430         TRACEIT(2,"propPage_reorderBookmarkListByListView		parameter NULL");
1431         return -1;
1432     }
1433     struct _propPage_ReoderLists_Stru Struct;
1434     GList *glistBuf=NULL;
1435     struct _UserCommandList *UserCmndListNewFirstItem=NULL;
1436     Struct.glistListPointer = NULL;
1437     Struct.iColumn = PROPPAGE_COL_USCMND_ITEMPOINTER;
1438 
1439     gtk_tree_model_foreach ((GtkTreeModel *)mainStruct->UserCommandsEntities.UsrCmnd_ListStore, (GtkTreeModelForeachFunc)getPointerFromListView, &Struct);
1440 
1441     glistBuf = Struct.glistListPointer;
1442     if (glistBuf)
1443         UserCmndListNewFirstItem = (struct _UserCommandList *)glistBuf->data;
1444     while (glistBuf){
1445         ((struct _UserCommandList *)glistBuf->data)->prevItem = (glistBuf->prev)?((struct _UserCommandList *)glistBuf->prev->data):NULL;
1446         ((struct _UserCommandList *)glistBuf->data)->nextItem = (glistBuf->next)?((struct _UserCommandList *)glistBuf->next->data):NULL;
1447         glistBuf = glistBuf->next;
1448     }
1449     g_UserCommandList = UserCmndListNewFirstItem;
1450     g_list_free (Struct.glistListPointer);
1451 
1452     TRACEIT(10,"propPage_reorderBookmarkListByListView		end");
1453     return 0;
1454 }
1455 
1456 
porpPage_checkIfNewColOrderIsDefault_helper(GtkTreeModel * model,GtkTreePath * path,GtkTreeIter * iter,GList ** pglistListOrder)1457 gboolean porpPage_checkIfNewColOrderIsDefault_helper (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, GList **pglistListOrder ){
1458     TRACEIT(10,"porpPage_checkIfNewColOrderIsDefault_helper		start");
1459     if (pglistListOrder == NULL){
1460         TRACEIT(10,"porpPage_checkIfNewColOrderIsDefault_helper		parameter NULL");
1461         return TRUE;
1462     }
1463 
1464 	gchar *Name=NULL;
1465 	//do not free here!
1466     gtk_tree_model_get(model, iter, PROPPAGE_COL_COLORDER_NAME, &Name, -1);
1467 
1468 	if (NULL != Name){
1469 		*pglistListOrder = g_list_append (*pglistListOrder, Name);
1470 	}
1471 
1472     TRACEIT(10,"porpPage_checkIfNewColOrderIsDefault_helper		end");
1473     return FALSE; //to continue, TRUE to stop iterating
1474 }
1475 
1476 
porpPage_checkIfNewColOrderIsDefault(struct _propPage_MainStruct * mainStruct)1477 int porpPage_checkIfNewColOrderIsDefault (struct _propPage_MainStruct *mainStruct){
1478 	// return: 	-1 = error
1479 	//			0 = NOT default order
1480 	//			1 = default order
1481 	TRACEIT(10,"porpPage_checkIfNewColOrderIsDefault		start");
1482 
1483 	int iOrderChange = 1;
1484 	int i;
1485 	GList *glistListOrder = NULL;
1486 	GList *glistBuf = NULL;
1487 
1488     gtk_tree_model_foreach ((GtkTreeModel *)mainStruct->ColumnOrder.ClmOrder_ListStore, (GtkTreeModelForeachFunc)porpPage_checkIfNewColOrderIsDefault_helper, &glistListOrder);
1489 
1490 	if (NULL == glistListOrder){
1491 		return iOrderChange;
1492 	}
1493 
1494 	glistBuf = glistListOrder;
1495 
1496 	i=0;
1497 	while (glistBuf){
1498 		i+=1;
1499 		if (0!=strcmp (Names[i], (char *)glistBuf->data)){
1500 			iOrderChange = 0;
1501 			break;
1502 		}
1503 		glistBuf = glistBuf->next;
1504 	}
1505 
1506 	g_list_foreach(glistListOrder, (GFunc) g_free, NULL);
1507 	g_list_free(glistListOrder);
1508 
1509 
1510 	TRACEIT(10,"porpPage_checkIfNewColOrderIsDefault		end");
1511 	return iOrderChange;
1512 }
1513 
1514 
propPage_writeColumnOrderToGlobalStruct(struct _propPage_MainStruct * mainStruct)1515 int propPage_writeColumnOrderToGlobalStruct (struct _propPage_MainStruct *mainStruct){
1516 	TRACEIT(10,"propPage_writeColumnOrderToGlobalStruct		start");
1517     if (mainStruct == NULL){
1518         TRACEIT(2,"propPage_writeColumnOrderToGlobalStruct		parameter NULL");
1519         return -1;
1520     }
1521 
1522 	//we will delete the existing item before
1523 	//then, check if the new order is the same as the default order.
1524 	//default order will not be stored.
1525 
1526 	struct _OptionsList *ListItem = NULL;
1527 	GList *glistListOrder = NULL;
1528 	GList *glistBuf = NULL;
1529 	GString *gstrValue = g_string_sized_new(100);
1530 
1531 	ListItem = OptionsList_getItemByID(g_OptionsList, COLUMN_ORDER);
1532 
1533 	if (ListItem != NULL){
1534 		g_OptionsList = OptionsList_deleteItem(ListItem);
1535 	}
1536 
1537 	gtk_tree_model_foreach ((GtkTreeModel *)mainStruct->ColumnOrder.ClmOrder_ListStore, (GtkTreeModelForeachFunc)porpPage_checkIfNewColOrderIsDefault_helper, &glistListOrder);
1538 
1539 	if (NULL == glistListOrder){
1540 		TRACEIT(2,"propPage_writeColumnOrderToGlobalStruct		No entries in list?");
1541 		return 0;
1542 	}
1543 
1544 	glistBuf = glistListOrder;
1545 	if (NULL != glistBuf){
1546 		g_string_append (gstrValue, "\"");
1547 		while (glistBuf){
1548 			g_string_append (gstrValue, (char *)glistBuf->data);
1549 			g_string_append (gstrValue, COLUMN_ORDER_SEPARATOR);
1550 
1551 			glistBuf = glistBuf->next;
1552 		}
1553 		g_string_erase (gstrValue, gstrValue->len - strlen(COLUMN_ORDER_SEPARATOR), -1);
1554 		g_string_append (gstrValue, "\"");
1555 
1556 		OptionsList_addItem(&g_OptionsList, COLUMN_ORDER, NULL, gstrValue->str);
1557 
1558 		reorderAllTabsColumns ();
1559 
1560 		if (0 != porpPage_checkIfNewColOrderIsDefault(mainStruct)){
1561 			ListItem = OptionsList_getItemByID(g_OptionsList, COLUMN_ORDER);
1562 			if (NULL != ListItem){
1563 				g_OptionsList = OptionsList_deleteItem(ListItem);
1564 			}
1565 		}
1566 
1567 		g_list_foreach(glistListOrder, (GFunc) g_free, NULL);
1568 		g_list_free(glistListOrder);
1569 	}
1570 
1571 	g_string_free (gstrValue, TRUE);
1572     TRACEIT(10,"propPage_writeColumnOrderToGlobalStruct		end");
1573     return 0;
1574 }
1575 
1576 
propPage_writeOptionsToGlobalStruct(struct _propPage_MainStruct * mainStruct)1577 int propPage_writeOptionsToGlobalStruct (struct _propPage_MainStruct *mainStruct){
1578     TRACEIT(10,"propPage_writeOptionsToGlobalStruct		start");
1579     if (mainStruct == NULL){
1580         TRACEIT(2,"propPage_writeOptionsToGlobalStruct		parameter NULL");
1581         return -1;
1582     }
1583     struct _propPage_OptionsEntities *OptionsEntities = &(mainStruct->OptionsEntities);
1584     const char *ccpBuf1 = NULL;
1585     const char *ccpBuf2 = NULL;
1586     gchar *cpColorString = NULL;
1587     gboolean bState;
1588 
1589     if (g_OptionsList){
1590         OptionsList_freeList(&g_OptionsList);
1591     }
1592 
1593     ccpBuf1 = gtk_entry_get_text ((GtkEntry *)OptionsEntities->Option_Stded_Edit_Value);
1594     ccpBuf2 = gtk_entry_get_text ((GtkEntry *)OptionsEntities->Option_Stded_Edit_Name);
1595     if (ccpBuf1 && ccpBuf2 && 0<strlen(ccpBuf1) && 0<strlen(ccpBuf2) ){
1596         OptionsList_addItem(&g_OptionsList, STANDARDEDITORKEY, ccpBuf2, ccpBuf1);
1597     }
1598     ccpBuf1 = gtk_entry_get_text ((GtkEntry *)OptionsEntities->Option_Trmnl_Edit_Value);
1599     ccpBuf2 = gtk_entry_get_text ((GtkEntry *)OptionsEntities->Option_Trmnl_Edit_Name);
1600     if (ccpBuf1 && ccpBuf2 && 0<strlen(ccpBuf1) && 0<strlen(ccpBuf2) ){
1601         OptionsList_addItem(&g_OptionsList, TERMINALKEY, ccpBuf2, ccpBuf1);
1602     }
1603     ccpBuf1 = gtk_entry_get_text ((GtkEntry *)OptionsEntities->Option_Stdd_Edit);
1604     if (ccpBuf1 && 0<strlen(ccpBuf1) ){
1605         OptionsList_addItem(&g_OptionsList, STANDARDSTARTDIRECTORY, NULL, ccpBuf1);
1606     }
1607     ccpBuf1 = gtk_entry_get_text ((GtkEntry *)OptionsEntities->Option_Strtdl_Edit);
1608     if (ccpBuf1 && 0<strlen(ccpBuf1) ){
1609         OptionsList_addItem(&g_OptionsList, STARTDIRECTORIESLEFTKEY, NULL, ccpBuf1);
1610     }
1611     ccpBuf1 = gtk_entry_get_text ((GtkEntry *)OptionsEntities->Option_Strtdr_Edit);
1612     if (ccpBuf1 && 0<strlen(ccpBuf1) ){
1613         OptionsList_addItem(&g_OptionsList, STARTDIRECTORIESRIGHTKEY, NULL, ccpBuf1);
1614     }
1615     ccpBuf1 = gtk_entry_get_text ((GtkEntry *)OptionsEntities->Option_Strtdr_Edit);
1616     if (ccpBuf1 && 0<strlen(ccpBuf1) ){
1617         OptionsList_addItem(&g_OptionsList, STARTDIRECTORIESRIGHTKEY, NULL, ccpBuf1);
1618     }
1619 
1620     bState = gtk_toggle_button_get_active ((GtkToggleButton *)OptionsEntities->Option_Svpths_Check);
1621     if (bState){
1622         OptionsList_addItem(&g_OptionsList, SAVEPATHESONEXIT, NULL, "true");
1623     }
1624     else{
1625         OptionsList_addItem(&g_OptionsList, SAVEPATHESONEXIT, NULL, "false");
1626     }
1627 
1628     gtk_color_button_get_color ( (GtkColorButton *)OptionsEntities->Option_ClrItm_Button, &OptionsEntities->Option_ClrItm_gdkColor);
1629     cpColorString = gdk_color_to_string (&OptionsEntities->Option_ClrItm_gdkColor);
1630     if (cpColorString){
1631         OptionsList_addItem(&g_OptionsList, COLOR_ITEMS_DEFAULT, NULL, cpColorString);
1632         g_free(cpColorString);
1633     }
1634     gtk_color_button_get_color ( (GtkColorButton *)OptionsEntities->Option_ClrDir_Button, &OptionsEntities->Option_ClrDir_gdkColor);
1635     cpColorString = gdk_color_to_string (&OptionsEntities->Option_ClrDir_gdkColor);
1636     if (cpColorString){
1637         OptionsList_addItem(&g_OptionsList, COLOR_DIRECTORIES, NULL, cpColorString);
1638         g_free(cpColorString);
1639     }
1640     gtk_color_button_get_color ( (GtkColorButton *)OptionsEntities->Option_ClrLnk_Button, &OptionsEntities->Option_ClrLnk_gdkColor);
1641     cpColorString = gdk_color_to_string (&OptionsEntities->Option_ClrLnk_gdkColor);
1642     if (cpColorString){
1643         OptionsList_addItem(&g_OptionsList, COLOR_LINKS, NULL, cpColorString);
1644         g_free(cpColorString);
1645     }
1646     gtk_color_button_get_color ( (GtkColorButton *)OptionsEntities->Option_ClrMss_Button, &OptionsEntities->Option_ClrMss_gdkColor);
1647     cpColorString = gdk_color_to_string (&OptionsEntities->Option_ClrMss_gdkColor);
1648     if (cpColorString){
1649         OptionsList_addItem(&g_OptionsList, COLOR_ITEMS_MISSING, NULL, cpColorString);
1650         g_free(cpColorString);
1651     }
1652 
1653     ccpBuf1 = gtk_entry_get_text ((GtkEntry *)OptionsEntities->Option_PreviewSize_Edit);
1654     if (ccpBuf1 && 0<strlen(ccpBuf1) ){
1655         OptionsList_addItem(&g_OptionsList, PREVIEWSIZE, NULL, ccpBuf1);
1656     }
1657     ccpBuf1 = gtk_entry_get_text ((GtkEntry *)OptionsEntities->Option_PreviewEndings_Edit);
1658     if (ccpBuf1 && 0<strlen(ccpBuf1) ){
1659         OptionsList_addItem(&g_OptionsList, PREVIEWTYPES, NULL, ccpBuf1);
1660     }
1661 
1662     ccpBuf1 = gtk_entry_get_text ((GtkEntry *)OptionsEntities->Option_SaveSessionEveryMinutes_Edit);
1663     if (ccpBuf1 && 0<strlen(ccpBuf1) ){
1664         OptionsList_addItem(&g_OptionsList, SAVESESSIONMINUTESTYPES, NULL, ccpBuf1);
1665     }
1666 
1667 
1668     TRACEIT(10,"propPage_writeOptionsToGlobalStruct		end");
1669     return 0;
1670 }
1671 
1672 
propPage_MainButtonLoadFrom(GtkButton * Button,struct _propPage_MainStruct * mainStruct)1673 void propPage_MainButtonLoadFrom (GtkButton *Button, struct _propPage_MainStruct *mainStruct){
1674     TRACEIT(10,"propPage_MainButtonLoadFrom		start");
1675     if (mainStruct == NULL){
1676         TRACEIT(2,"propPage_MainButtonLoadFrom		parameter NULL");
1677         return;
1678     }
1679     char *cpFile=NULL;
1680     GtkWidget *dialog = NULL;
1681     GString *HomeDir = g_string_sized_new(20);;
1682 
1683     dialog = gtk_file_chooser_dialog_new ("choose Cat'sEyE XML config file to load",
1684                                             //NULL,
1685                                             (GtkWindow *)mainStruct->mainEntities.Main_Widget,
1686                                             GTK_FILE_CHOOSER_ACTION_OPEN,
1687                                             GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
1688                                             GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
1689                                             NULL);
1690 
1691     getHomeDirectory(HomeDir);
1692     checkPathForLastChar(HomeDir);
1693     g_string_append(HomeDir,CATSEYEHOMEDIR);
1694     gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), HomeDir->str);
1695 
1696 
1697     if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT){
1698         cpFile = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
1699         if (cpFile){
1700             propPage_openConfigFile (cpFile, mainStruct);
1701             propPage_fillPropPageWidgets ( mainStruct);
1702         }
1703     }
1704 
1705     gtk_widget_destroy (dialog);
1706     if (cpFile)
1707         g_free (cpFile);
1708     if (HomeDir)
1709         g_string_free (HomeDir, TRUE);
1710 
1711     TRACEIT(10,"propPage_MainButtonLoadFrom		end");
1712     return;
1713 }
1714 
1715 
propPage_MainButtonReload(GtkButton * Button,struct _propPage_MainStruct * mainStruct)1716 void propPage_MainButtonReload (GtkButton *Button, struct _propPage_MainStruct *mainStruct){
1717     TRACEIT(10,"propPage_MainButtonReload		start");
1718     if (mainStruct == NULL){
1719         TRACEIT(2,"propPage_MainButtonReload		parameter NULL");
1720         return;
1721     }
1722     propPage_openConfigFile (NULL, mainStruct);
1723     propPage_fillPropPageWidgets ( mainStruct);
1724     TRACEIT(10,"propPage_MainButtonReload		end");
1725     return;
1726 }
1727 
1728 
propPage_MainButtonClose(GtkButton * Button,struct _propPage_MainStruct * mainStruct)1729 void propPage_MainButtonClose (GtkButton *Button, struct _propPage_MainStruct *mainStruct){
1730     TRACEIT(10,"propPage_MainButtonClose		start");
1731     if (mainStruct == NULL){
1732         TRACEIT(2,"propPage_MainButtonClose		parameter NULL");
1733         return;
1734     }
1735     int iCloseIt=1;
1736     if (mainStruct->iSaved == 0){
1737         GtkWidget *dialog = CreateMyDialog("Close",(GtkWindow *)mainStruct->mainEntities.Main_Widget,2,"Back",GTK_RESPONSE_REJECT,"Close anyway",GTK_RESPONSE_ACCEPT, NULL, 0,  TRUE);
1738         GtkWidget *label = gtk_label_new("The changes you have made were not saved.\nDo you really want to close?\nYou will loose all your changes.");
1739         gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox),label);
1740         gtk_widget_show_all(dialog);
1741         if (GTK_RESPONSE_ACCEPT != gtk_dialog_run(GTK_DIALOG(dialog))){
1742             iCloseIt = 0;
1743         }
1744         gtk_widget_destroy(dialog);
1745     }
1746 
1747     if (iCloseIt == 1)
1748         gtk_widget_destroy (mainStruct->mainEntities.Main_Widget);
1749 
1750     TRACEIT(10,"propPage_MainButtonClose		end");
1751     return;
1752 }
1753 
1754 
propPage_assignOptionsFunctionality(struct _propPage_MainStruct * mainStruct)1755 int propPage_assignOptionsFunctionality (struct _propPage_MainStruct *mainStruct){
1756     TRACEIT (10, "propPage_assignOptionsMainWidgets			start");
1757 	if (mainStruct == NULL){
1758 		TRACEIT (2, "propPage_assignOptionsMainWidgets			parameter NULL");
1759 		return -1;
1760 	}
1761 
1762 	struct _propPage_OptionsEntities *OptionsEntities = &(mainStruct->OptionsEntities);
1763 
1764     g_signal_connect(OptionsEntities->Option_Stdd_Button,"clicked",G_CALLBACK(propPage_OptionsChooseDirStdd), (void *)mainStruct);
1765     g_signal_connect(OptionsEntities->Option_Strtdr_Button,"clicked",G_CALLBACK(propPage_OptionsChooseDirStrtdr), (void *)mainStruct);
1766     g_signal_connect(OptionsEntities->Option_Strtdl_Button,"clicked",G_CALLBACK(propPage_OptionsChooseDirStrtdl), (void *)mainStruct);
1767 
1768 //  mainStruct->mainEntities.Main_Widget       OptionsEntities->Option_MainVbox
1769 //    g_signal_connect (mainStruct->mainEntities.Main_Widget , "key-press-event", G_CALLBACK(propPage_OptionsoneKeyPressedInMainWidget),(void *)mainStruct);
1770 
1771     TRACEIT (10, "propPage_assignOptionsMainWidgets			end");
1772     return 0;
1773 }
1774 
1775 /*
1776 this does not work if we connect it to OptionsEntities->Option_MainVbox
1777 gboolean propPage_OptionsoneKeyPressedInMainWidget(GtkWidget *widget, GdkEventKey *event, struct _propPage_MainStruct *mainStruct){
1778 	TRACEIT(10,"createUserCommand_oneKeyPressedInMainWidget		start");
1779 	printf("Iam here\n");
1780 	if (mainStruct == NULL){
1781 		TRACEIT (2, "createUserCommand_oneKeyPressedInMainWidget			parameter NULL");
1782 		return FALSE;
1783 	}
1784 
1785     mainStruct->iSaved = 0;
1786 
1787 	TRACEIT(10,"createUserCommand_oneKeyPressedInMainWidget		end");
1788 	return FALSE;
1789 }
1790 */
1791 
1792 
propPage_OptionsChooseDirStdd(GtkButton * Button,struct _propPage_MainStruct * mainStruct)1793 void propPage_OptionsChooseDirStdd (GtkButton *Button, struct _propPage_MainStruct *mainStruct){
1794     TRACEIT(10,"propPage_OptionsChooseDirStdd		start");
1795     if ( 0 == propPage_OptionsChooseDir (mainStruct->mainEntities.Main_Widget , mainStruct->OptionsEntities.Option_Stdd_Edit)){
1796         mainStruct->iSaved = 0;
1797     }
1798     TRACEIT(10,"propPage_OptionsChooseDirStdd		end");
1799 }
1800 
propPage_OptionsChooseDirStrtdr(GtkButton * Button,struct _propPage_MainStruct * mainStruct)1801 void propPage_OptionsChooseDirStrtdr (GtkButton *Button, struct _propPage_MainStruct *mainStruct){
1802     TRACEIT(10,"propPage_OptionsChooseDirStrtdr		start");
1803     if (0 == propPage_OptionsChooseDir (mainStruct->mainEntities.Main_Widget , mainStruct->OptionsEntities.Option_Strtdr_Edit)){
1804         mainStruct->iSaved = 0;
1805     }
1806     TRACEIT(10,"propPage_OptionsChooseDirStrtdr		end");
1807 }
1808 
propPage_OptionsChooseDirStrtdl(GtkButton * Button,struct _propPage_MainStruct * mainStruct)1809 void propPage_OptionsChooseDirStrtdl (GtkButton *Button, struct _propPage_MainStruct *mainStruct){
1810     TRACEIT(10,"propPage_OptionsChooseDirStrtdl		start");
1811     if (0==propPage_OptionsChooseDir (mainStruct->mainEntities.Main_Widget , mainStruct->OptionsEntities.Option_Strtdl_Edit)){
1812         mainStruct->iSaved = 0;
1813     }
1814     TRACEIT(10,"propPage_OptionsChooseDirStrtdl		end");
1815 }
1816 
1817 
propPage_OptionsChooseDir(GtkWidget * Parent,GtkWidget * entrybox)1818 int propPage_OptionsChooseDir (GtkWidget *Parent, GtkWidget *entrybox){
1819     //return: 0= directory changed, 1=user canceled, -1=error
1820     TRACEIT(10,"propPage_OptionsChooseDir		start");
1821     if (entrybox == NULL){
1822         TRACEIT(2,"propPage_OptionsChooseDir		parameter NULL");
1823         return -1;
1824     }
1825     char *cpDirectory=NULL;
1826     GtkWidget *dialog = NULL;
1827     int iRet = 0;
1828 
1829     dialog = gtk_file_chooser_dialog_new ("choose directory",
1830                                             //NULL,
1831                                             (GtkWindow *)Parent,
1832                                             GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
1833                                             GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
1834                                             GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
1835                                             NULL);
1836 
1837     if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT){
1838         iRet = 1;
1839         cpDirectory = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
1840         gtk_entry_set_text(	(GtkEntry *)entrybox, cpDirectory);
1841     }
1842     gtk_widget_destroy (dialog);
1843     if (cpDirectory)
1844         g_free (cpDirectory);
1845 
1846     TRACEIT(10,"propPage_OptionsChooseDir		end");
1847     return iRet;
1848 }
1849 
1850 
propPage_assignColumnOrderFunctionality(struct _propPage_MainStruct * mainStruct)1851 int propPage_assignColumnOrderFunctionality (struct _propPage_MainStruct *mainStruct){
1852 	TRACEIT (10, "propPage_assignColumnOrderFunctionality			start");
1853 	if (mainStruct == NULL){
1854 		TRACEIT (2, "propPage_assignColumnOrderFunctionality			parameter NULL");
1855 		return -1;
1856 	}
1857 
1858 	struct _propPage_ColumnOrder *ColOrder = &(mainStruct->ColumnOrder);
1859 
1860 	g_signal_connect(ColOrder->ClmOrder_Button_Reset,"clicked",G_CALLBACK(propPage_ClmnOrderButtonReset), (void *)mainStruct);
1861 
1862 	TRACEIT (10, "propPage_assignColumnOrderFunctionality			end");
1863 	return 0;
1864 }
1865 
1866 
propPage_ClmnOrderButtonReset(GtkButton * Button,struct _propPage_MainStruct * mainStruct)1867 void propPage_ClmnOrderButtonReset (GtkButton *Button, struct _propPage_MainStruct *mainStruct){
1868     TRACEIT(10,"propPage_ClmnOrderButtonReset		start");
1869     propPage_fillColumnOrderWidgets (mainStruct, 1);
1870     TRACEIT(10,"propPage_ClmnOrderButtonReset		end");
1871 }
1872 
1873 
propPage_assignBkmrkFunctionality(struct _propPage_MainStruct * mainStruct)1874 int propPage_assignBkmrkFunctionality (struct _propPage_MainStruct *mainStruct){
1875     TRACEIT (10, "propPage_assignBkmrkFunctionality			start");
1876 	if (mainStruct == NULL){
1877 		TRACEIT (2, "propPage_assignBkmrkFunctionality			parameter NULL");
1878 		return -1;
1879 	}
1880 
1881     struct _propPage_BookmarkEntities *bkmrkEntities = &(mainStruct->bkmrkEntities);
1882 
1883     g_signal_connect(bkmrkEntities->Bkmrk_Button_Delete,"clicked",G_CALLBACK(propPage_BkmrkdeleteItem), (void *)bkmrkEntities);
1884     g_signal_connect(bkmrkEntities->Bkmrk_Button_New,"clicked",G_CALLBACK(propPage_BkmrkButtonNew), (void *)mainStruct);
1885     g_signal_connect(bkmrkEntities->Bkmrk_Button_Edit,"clicked",G_CALLBACK(propPage_BkmrkButtonEdit), (void *)mainStruct);
1886 
1887     g_signal_connect (bkmrkEntities->Bkmrk_ListView, "button-press-event",G_CALLBACK(propPage_BkmrkOneMouseButtonPressedInView), (void *)mainStruct);
1888     g_signal_connect (bkmrkEntities->Bkmrk_ListView, "row-activated",G_CALLBACK(propPage_BkmrkRowActivated), (void *)mainStruct);
1889     g_signal_connect (bkmrkEntities->Bkmrk_ListView, "key-press-event",G_CALLBACK(propPage_BkmrkOneKeyPressedInView),(void *)mainStruct);
1890 
1891     TRACEIT (10, "propPage_assignBkmrkFunctionality			end");
1892     return 0;
1893 }
1894 
1895 
propPage_BkmrkRowActivated(GtkTreeView * tree_view,GtkTreePath * path,GtkTreeViewColumn * column,struct _propPage_MainStruct * mainStruct)1896 void propPage_BkmrkRowActivated (GtkTreeView *tree_view, GtkTreePath *path, GtkTreeViewColumn *column, struct _propPage_MainStruct *mainStruct){
1897     TRACEIT(10,"propPage_BkmrkRowActivated		start");
1898     propPage_BkmrkAddItem (mainStruct, 1 );
1899     TRACEIT(10,"propPage_BkmrkRowActivated		end");
1900     return;
1901 }
1902 
1903 
propPage_BkmrkOneKeyPressedInView(GtkWidget * widget,GdkEventKey * event,struct _propPage_MainStruct * mainStruct)1904 gboolean propPage_BkmrkOneKeyPressedInView(GtkWidget *widget, GdkEventKey *event, struct _propPage_MainStruct *mainStruct){
1905     //Be aware of using widget, as this function is called when a key is pressed on a notebook (tab) too
1906     //data = struct SideObjectList
1907 	TRACEIT(10,"propPage_BkmrkOneKeyPressedInView		start");
1908 	if (mainStruct == NULL){
1909 		TRACEIT (2, "propPage_BkmrkOneKeyPressedInView			parameter NULL");
1910 		return FALSE;
1911 	}
1912 
1913 	guint modifiers;
1914 
1915 	modifiers = gtk_accelerator_get_default_mod_mask ();
1916 
1917     if ( (event->keyval == GDK_Delete)){
1918 	    //Delete selected files with 'del-key'
1919 		propPage_BkmrkdeleteItem (NULL, mainStruct);
1920 		TRACEIT(10,"propPage_BkmrkOneKeyPressedInView		ends");
1921 		return TRUE;
1922 	}
1923 
1924 	TRACEIT(10,"propPage_BkmrkOneKeyPressedInView		end");
1925 	return FALSE;
1926 }
1927 
1928 
propPage_BkmrkOneMouseButtonPressedInView(GtkWidget * treeview,GdkEventButton * event,struct _propPage_MainStruct * mainStruct)1929 gboolean propPage_BkmrkOneMouseButtonPressedInView(GtkWidget *treeview, GdkEventButton *event, struct _propPage_MainStruct *mainStruct){
1930     TRACEIT(10,"propPage_BkmrkOneMouseButtonPressedInView		start");
1931     if (event->type == GDK_BUTTON_PRESS  &&  event->button == 3){
1932 		propPage_BkmrkContextMenuOnListView(treeview,event, mainStruct);
1933 		TRACEIT(10,"propPage_BkmrkOneMouseButtonPressedInView		end");
1934 		return TRUE;
1935 	}
1936 	TRACEIT(10,"propPage_BkmrkOneMouseButtonPressedInView		end");
1937 	return FALSE;
1938 }
1939 
1940 
propPage_BkmrkContextMenuOnListView(GtkWidget * treeview,GdkEventButton * event,struct _propPage_MainStruct * mainStruct)1941 gboolean propPage_BkmrkContextMenuOnListView(GtkWidget *treeview, GdkEventButton *event,  struct _propPage_MainStruct *mainStruct){
1942 	TRACEIT(10,"propPage_BkmrkContextMenuOnListView		start");
1943     if (mainStruct == NULL){
1944 		TRACEIT (2, "propPage_BkmrkContextMenuOnListView			parameter NULL");
1945 		return TRUE;
1946 	}
1947 
1948 	GtkWidget *menu, *menuitem;
1949 	GtkWidget *sep2;
1950     GtkTreeSelection *selection;
1951     int iSelectedRows;
1952 
1953 	menu = gtk_menu_new();
1954 
1955     selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview));
1956     iSelectedRows = gtk_tree_selection_count_selected_rows(selection);
1957 
1958     selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview));
1959 	if (iSelectedRows <= 1){   //Event can be NULL if the key for contextmenu is presed
1960 		GtkTreePath *path;
1961         TRACEIT(11,"propPage_BkmrkContextMenuOnListView		mark the item coverd by mousepointer");
1962         if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(treeview), (gint) event->x, (gint) event->y, &path, NULL, NULL, NULL)){
1963 			gtk_tree_selection_unselect_all(selection);
1964 			gtk_tree_selection_select_path(selection, path);
1965 			gtk_tree_path_free(path);
1966 		}
1967 	}
1968 
1969 	sep2 = gtk_separator_menu_item_new ();
1970 
1971     menuitem = gtk_menu_item_new_with_label("new ...");
1972 	g_signal_connect(menuitem,"activate",G_CALLBACK(propPage_BkmrkButtonNew),mainStruct);
1973 	gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
1974 
1975     menuitem = gtk_menu_item_new_with_label("edit ...");
1976 	g_signal_connect(menuitem,"activate",G_CALLBACK(propPage_BkmrkButtonEdit),mainStruct);
1977 	gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
1978 
1979     gtk_menu_shell_append(GTK_MENU_SHELL(menu), sep2);
1980 
1981     menuitem = gtk_menu_item_new_with_label("delete");
1982 	g_signal_connect(menuitem,"activate",G_CALLBACK(propPage_BkmrkdeleteItem), mainStruct);
1983 	gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
1984 
1985 
1986     gtk_widget_show_all(menu);
1987 	// Note: event can be NULL here when called from view_onPopupMenu;
1988 	// gdk_event_get_time() accepts a NULL argument
1989 	gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, (event != NULL) ? event->button : 0, gdk_event_get_time((GdkEvent*)event));
1990 
1991 	TRACEIT(10,"propPage_BkmrkContextMenuOnListView		ends");
1992 	return TRUE;
1993 }
1994 
1995 
propPage_BkmrkButtonNew(GtkButton * Button,struct _propPage_MainStruct * mainStruct)1996 void propPage_BkmrkButtonNew (GtkButton *Button, struct _propPage_MainStruct *mainStruct){
1997     TRACEIT(10,"propPage_BkmrkButtonNew		start");
1998     propPage_BkmrkAddItem (mainStruct, 0 );
1999     TRACEIT(10,"propPage_BkmrkButtonNew		end");
2000 }
2001 
2002 
propPage_BkmrkButtonEdit(GtkButton * Button,struct _propPage_MainStruct * mainStruct)2003 void propPage_BkmrkButtonEdit (GtkButton *Button, struct _propPage_MainStruct *mainStruct){
2004     TRACEIT(10,"propPage_BkmrkButtonEdit		start");
2005     propPage_BkmrkAddItem (mainStruct, 1 );
2006     TRACEIT(10,"propPage_BkmrkButtonEdit		end");
2007 }
2008 
2009 
propPage_BkmrkdeleteItem(GtkButton * button,struct _propPage_MainStruct * mainStruct)2010 void propPage_BkmrkdeleteItem (GtkButton *button, struct _propPage_MainStruct *mainStruct){
2011     TRACEIT(10,"propPage_BkmrkdeleteItem		start");
2012     if (mainStruct == NULL){
2013         TRACEIT(2,"propPage_BkmrkdeleteItem		parameter NULL");
2014         return;
2015     }
2016     GtkTreeModel *model=NULL;
2017     GtkTreeIter iter;
2018     GtkTreeSelection	*selection;
2019     struct _propPage_BookmarkEntities *bkmrkEntities = &(mainStruct->bkmrkEntities);
2020     selection  = gtk_tree_view_get_selection((GtkTreeView *)bkmrkEntities->Bkmrk_ListView);
2021 
2022     struct _OptionsList *BkmrkListBuf = NULL;
2023     GList *glistPathList = gtk_tree_selection_get_selected_rows (selection, &model);
2024     GList *glistBuf;
2025 
2026     if (glistPathList == NULL){
2027         return;
2028     }
2029 
2030     glistBuf = glistPathList;
2031     while (glistBuf){
2032         gtk_tree_model_get_iter(GTK_TREE_MODEL(bkmrkEntities->Bkmrk_ListStore), &iter, (GtkTreePath *)glistBuf->data);
2033 
2034         gtk_tree_model_get (GTK_TREE_MODEL(bkmrkEntities->Bkmrk_ListStore), &iter, PROPPAGE_COL_BKMRK_ITEMPOINTER, &BkmrkListBuf, -1);
2035         if (BkmrkListBuf != NULL){
2036             g_BookMarkList = OptionsList_deleteItem(BkmrkListBuf);
2037             gtk_list_store_remove(GTK_LIST_STORE(model), &iter);
2038         }
2039         else{
2040             TRACEIT(4,"propPage_BkmrkdeleteItem		error searching for bookmark pointer");
2041         }
2042         glistBuf = glistBuf->next;
2043     }
2044     mainStruct->iSaved=0;
2045     g_list_foreach (glistPathList,(GFunc) gtk_tree_path_free, NULL);
2046     g_list_free (glistPathList);
2047     TRACEIT(10,"propPage_BkmrkdeleteItem		end");
2048     return;
2049 }
2050 
2051 
2052 
propPage_BkmrkAddItem(struct _propPage_MainStruct * mainStruct,int iEditOrAdd)2053 int propPage_BkmrkAddItem (struct _propPage_MainStruct *mainStruct, int iEditOrAdd ){
2054     //also used for editing.
2055     //iEditOrAdd: 0=add, 1=edit
2056     TRACEIT(10,"propPage_BkmrkAddItem		end");
2057 
2058     if ( mainStruct == NULL){
2059         TRACEIT (2, "propPage_BkmrkAddItem      Parameter NULL");
2060         return -1;
2061     }
2062 
2063     int iRet = 0;
2064     GtkTreeModel *model = NULL;
2065     GString *gstrName = g_string_sized_new(10);
2066     GString *gstrPath = g_string_sized_new(10);
2067     GtkWidget *dialog;
2068     GtkTreeIter iter;
2069     struct _propPage_BookmarkEntities *bkmrkEntities = NULL;
2070     GtkTreeSelection	*selection;
2071     GList *glistPathList = NULL;
2072     struct _OptionsList *BkmrkListBuf = NULL;
2073     struct _propPage_BkmrkAddItem_BufStru BufStru;
2074 
2075     bkmrkEntities = &(mainStruct->bkmrkEntities);
2076 
2077     dialog = CreateMyDialog("Bookmark", (GtkWindow *)mainStruct->mainEntities.Main_Widget, 2, "Ok", GTK_RESPONSE_ACCEPT, "Cancel", 1,NULL,0, TRUE);
2078 
2079     GtkWidget *vboxMain = gtk_vbox_new (FALSE, 0);
2080     GtkWidget *lblName = gtk_label_new ("Name:");
2081     GtkWidget *lblPath = gtk_label_new ("Path:");
2082     GtkWidget *entryName = gtk_entry_new ();
2083     GtkWidget *entryPath = gtk_entry_new ();
2084     GtkWidget *pathButton = gtk_button_new_with_label ("open path");
2085     GtkWidget *hbox = gtk_hbox_new (FALSE, 0);
2086     g_signal_connect (entryName, "activate",G_CALLBACK(MyEasyInputWidget_EntryBoxActivate),dialog);
2087     g_signal_connect (entryPath, "activate",G_CALLBACK(MyEasyInputWidget_EntryBoxActivate),dialog);
2088 
2089     //if we want to edit the item we have to get all the information:
2090     if (iEditOrAdd == 1){
2091         selection  = gtk_tree_view_get_selection((GtkTreeView *)bkmrkEntities->Bkmrk_ListView);
2092         glistPathList = gtk_tree_selection_get_selected_rows (selection, &model);
2093 
2094         if (glistPathList == NULL){
2095             iRet = -1;
2096         }
2097         else {
2098             gtk_tree_model_get_iter(GTK_TREE_MODEL(bkmrkEntities->Bkmrk_ListStore), &iter, (GtkTreePath *)glistPathList->data);
2099 
2100             gtk_tree_model_get (GTK_TREE_MODEL(bkmrkEntities->Bkmrk_ListStore), &iter, PROPPAGE_COL_BKMRK_ITEMPOINTER, &BkmrkListBuf, -1);
2101             if (BkmrkListBuf == NULL){
2102                 TRACEIT(4,"propPage_BkmrkdeleteItem		error searching for bookmark pointer");
2103                 iRet = -1;
2104             }
2105             else{
2106                 gtk_entry_set_text ((GtkEntry *)entryName, BkmrkListBuf->gstrName->str);
2107                 gtk_entry_set_text ((GtkEntry *)entryPath, BkmrkListBuf->gstrValue->str);
2108             }
2109         }
2110     }
2111 
2112     if (iRet == 0){
2113         BufStru.EditBox = entryPath;
2114         BufStru.Parent = mainStruct->mainEntities.Main_Widget;
2115         g_signal_connect(pathButton,"clicked",G_CALLBACK(propPage_BkmrkAddItemPathButton), (void *)&BufStru);
2116 
2117         gtk_box_pack_start ((GtkBox *)hbox, entryPath, TRUE, FALSE, 0);
2118         gtk_box_pack_start ((GtkBox *)hbox, pathButton, FALSE, FALSE, 0);
2119 
2120         gtk_box_pack_start ((GtkBox *)vboxMain, lblName, TRUE, FALSE, 0);
2121         gtk_box_pack_start ((GtkBox *)vboxMain, entryName, TRUE, FALSE, 0);
2122         gtk_box_pack_start ((GtkBox *)vboxMain, lblPath, TRUE, FALSE, 0);
2123         gtk_box_pack_start ((GtkBox *)vboxMain, hbox, TRUE, FALSE, 0);
2124 
2125         gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox),vboxMain);
2126 
2127         gtk_widget_show_all(dialog);
2128     }
2129 
2130     if (iRet == 0 && gtk_dialog_run(GTK_DIALOG(dialog))== GTK_RESPONSE_ACCEPT){
2131         mainStruct->iSaved = 0;
2132         g_string_assign (gstrName, gtk_entry_get_text ((GtkEntry *)entryName));
2133         g_string_assign (gstrPath, gtk_entry_get_text ((GtkEntry *)entryPath));
2134 
2135         if (iEditOrAdd == 0){    //0=add, 1=edit
2136             OptionsList_addItem(&g_BookMarkList, NULL, gstrName->str, gstrPath->str);
2137             gtk_list_store_append (bkmrkEntities->Bkmrk_ListStore, &iter);
2138             gtk_list_store_set (bkmrkEntities->Bkmrk_ListStore, &iter, PROPPAGE_COL_BKMRK_ITEMPOINTER, OptionsList_getLastItem(g_BookMarkList), -1);
2139         }
2140         else{
2141             OptionsList_editItem(BkmrkListBuf, NULL, gstrName->str, gstrPath->str);
2142         }
2143 
2144         gtk_list_store_set (bkmrkEntities->Bkmrk_ListStore, &iter, PROPPAGE_COL_BKMRK_NAME, gstrName->str, -1);
2145         gtk_list_store_set (bkmrkEntities->Bkmrk_ListStore, &iter, PROPPAGE_COL_BKMRK_PATH, gstrPath->str, -1);
2146     }
2147 
2148     if (iRet == 0){
2149         gtk_widget_destroy(dialog);
2150     }
2151 
2152     g_string_free(gstrName, TRUE);
2153     g_string_free(gstrPath, TRUE);
2154 
2155     if (glistPathList){
2156         g_list_foreach (glistPathList,(GFunc) gtk_tree_path_free, NULL);
2157         g_list_free (glistPathList);
2158     }
2159 
2160     TRACEIT(10,"propPage_BkmrkAddItem		end");
2161     return 0;
2162 }
2163 
2164 
propPage_BkmrkAddItemPathButton(GtkButton * Button,struct _propPage_BkmrkAddItem_BufStru * BufStru)2165 void propPage_BkmrkAddItemPathButton (GtkButton *Button, struct _propPage_BkmrkAddItem_BufStru *BufStru){
2166     TRACEIT(10,"propPage_OptionsChooseDirStdd		start");
2167     propPage_OptionsChooseDir ( BufStru->Parent, BufStru->EditBox );
2168     TRACEIT(10,"propPage_OptionsChooseDirStdd		end");
2169 }
2170 
2171 
2172 
propPage_assignUserCommandsFunctionality(struct _propPage_MainStruct * mainStruct)2173 int propPage_assignUserCommandsFunctionality (struct _propPage_MainStruct *mainStruct){
2174     TRACEIT (10, "propPage_assignUserCommandsFunctionality			start");
2175 	if (mainStruct == NULL){
2176 		TRACEIT (2, "propPage_assignUserCommandsFunctionality			parameter NULL");
2177 		return -1;
2178 	}
2179     struct _propPage_UserCommandsEntities *UserCommandsEntities = &(mainStruct->UserCommandsEntities);
2180 
2181     g_signal_connect (UserCommandsEntities->UsrCmnd_Button_Delete,"clicked",G_CALLBACK(propPage_UserCommandDeleteItem), (void *)mainStruct);
2182     g_signal_connect (UserCommandsEntities->UsrCmnd_Button_New,"clicked",G_CALLBACK(propPage_UserCommandButtonNew), (void *)mainStruct);
2183     g_signal_connect (UserCommandsEntities->UsrCmnd_Button_Edit,"clicked",G_CALLBACK(propPage_UserCommandButtonEdit), (void *)mainStruct);
2184 
2185     g_signal_connect (UserCommandsEntities->UsrCmnd_Filter_ResetButton,"clicked",G_CALLBACK(propPage_UserCommandClearFilter), (void *)UserCommandsEntities);
2186     g_signal_connect (UserCommandsEntities->UsrCmnd_Filter_NameEntry, "activate",G_CALLBACK(propPage_UserCommandFilterEntryBoxActivate),UserCommandsEntities);
2187     g_signal_connect (UserCommandsEntities->UsrCmnd_Filter_TargetEntry, "activate",G_CALLBACK(propPage_UserCommandFilterEntryBoxActivate),UserCommandsEntities);
2188     g_signal_connect (UserCommandsEntities->UsrCmnd_Filter_CommandEntry, "activate",G_CALLBACK(propPage_UserCommandFilterEntryBoxActivate),UserCommandsEntities);
2189     g_signal_connect (UserCommandsEntities->UsrCmnd_Filter_DefaultEntry, "activate",G_CALLBACK(propPage_UserCommandFilterEntryBoxActivate),UserCommandsEntities);
2190 
2191     g_signal_connect (UserCommandsEntities->UsrCmnd_ListView, "button-press-event",G_CALLBACK(propPage_UsrCmndOneMouseButtonPressedInView), (void *)mainStruct);
2192     g_signal_connect (UserCommandsEntities->UsrCmnd_ListView, "row-activated",G_CALLBACK(propPage_UsrCmndRowActivated), (void *)mainStruct);
2193     g_signal_connect (UserCommandsEntities->UsrCmnd_ListView, "key-press-event",G_CALLBACK(propPage_UsrCmndOneKeyPressedInView),(void *)mainStruct);
2194 
2195     TRACEIT (10, "propPage_assignUserCommandsFunctionality			end");
2196     return 0;
2197 }
2198 
2199 
propPage_UserCommandFilterEntryBoxActivate(GtkEntry * entry,struct _propPage_UserCommandsEntities * UserCommandsEntities)2200 void propPage_UserCommandFilterEntryBoxActivate (GtkEntry *entry, struct _propPage_UserCommandsEntities *UserCommandsEntities){
2201     TRACEIT(10,"propPage_UserCommandFilterEntryBoxActivate		start");
2202     if (UserCommandsEntities == NULL){
2203         TRACEIT(2,"propPage_UserCommandFilterEntryBoxActivate		parameter NULL");
2204         return;
2205     }
2206 
2207     propPage_UserCommandFilterApply (UserCommandsEntities);
2208 
2209     TRACEIT(10,"propPage_UserCommandFilterEntryBoxActivate		end");
2210     return;
2211 }
2212 
2213 
propPage_UserCommandFilterApply(struct _propPage_UserCommandsEntities * UserCommandsEntities)2214 int propPage_UserCommandFilterApply (struct _propPage_UserCommandsEntities *UserCommandsEntities){
2215     TRACEIT(10,"propPage_UserCommandFilterApply		start");
2216     if (UserCommandsEntities == NULL){
2217         TRACEIT(2,"propPage_UserCommandFilterApply		parameter NULL");
2218         return -1;
2219     }
2220     struct _PropPage_SetVisibility_Stru Struct;
2221     Struct.iColumn = PROPPAGE_COL_USCMND_VISIBLE;
2222     Struct.bValue = FALSE;
2223     gtk_tree_model_foreach ((GtkTreeModel *)UserCommandsEntities->UsrCmnd_ListStore, (GtkTreeModelForeachFunc)propPage_setVisibilityInListView, &Struct);
2224 
2225     gtk_tree_model_foreach ((GtkTreeModel *)UserCommandsEntities->UsrCmnd_ListStore, (GtkTreeModelForeachFunc)propPage_UserCommandFilterApply_foreach, UserCommandsEntities);
2226 
2227     TRACEIT(10,"propPage_UserCommandFilterApply		end");
2228     return 0;
2229 }
2230 
2231 
propPage_UserCommandFilterApply_foreach(GtkTreeModel * model,GtkTreePath * path,GtkTreeIter * iter,struct _propPage_UserCommandsEntities * UserCommandsEntities)2232 gboolean propPage_UserCommandFilterApply_foreach ( GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, struct _propPage_UserCommandsEntities *UserCommandsEntities ){
2233     TRACEIT(10,"propPage_setVisibilityInListView		start");
2234     if (UserCommandsEntities == NULL){
2235         TRACEIT(2,"propPage_setVisibilityInListView		parameter NULL");
2236         return TRUE;
2237     }
2238     int iHideIt = 1;
2239     int counter = 0;
2240     if (0 ==propPage_UserCommand_WouldThisFilterHideIt((GtkEntry *)UserCommandsEntities->UsrCmnd_Filter_NameEntry, PROPPAGE_COL_USCMND_NAME, model, iter )){
2241         iHideIt = 0;
2242         counter++;
2243     }
2244     if (0 == propPage_UserCommand_WouldThisFilterHideIt((GtkEntry *)UserCommandsEntities->UsrCmnd_Filter_TargetEntry, PROPPAGE_COL_USCMND_TARGET, model, iter )){
2245         iHideIt = 0;
2246         counter++;
2247     }
2248     if (0 == propPage_UserCommand_WouldThisFilterHideIt((GtkEntry *)UserCommandsEntities->UsrCmnd_Filter_CommandEntry, PROPPAGE_COL_USCMND_COMMAND, model, iter )){
2249         iHideIt = 0;
2250         counter++;
2251     }
2252     if (0 == propPage_UserCommand_WouldThisFilterHideIt((GtkEntry *)UserCommandsEntities->UsrCmnd_Filter_DefaultEntry, PROPPAGE_COL_USCMND_DEFAULT, model, iter )){
2253         iHideIt = 0;
2254         counter++;
2255     }
2256 
2257     if (counter == 4)
2258         gtk_list_store_set ((GtkListStore *)model, iter, PROPPAGE_COL_USCMND_VISIBLE, TRUE, -1);
2259 
2260     TRACEIT(10,"propPage_setVisibilityInListView		start");
2261     return FALSE;
2262 }
2263 
2264 
propPage_UserCommand_WouldThisFilterHideIt(GtkEntry * Entry,int iColumnSearch,GtkTreeModel * model,GtkTreeIter * iter)2265 int propPage_UserCommand_WouldThisFilterHideIt( GtkEntry *Entry, int iColumnSearch, GtkTreeModel *model, GtkTreeIter *iter ){
2266     TRACEIT(10,"propPage_UserCommand_WouldThisFilterHideIt		start");
2267     if (Entry==NULL || model==NULL || iter==NULL){
2268         TRACEIT(10,"propPage_UserCommand_WouldThisFilterHideIt		parameter NULL");
2269         return -1;
2270     }
2271     char *cpBuf1 = NULL;
2272     char *cpBuf2 = NULL;
2273     const char *ccpBuf = NULL;
2274     ccpBuf = gtk_entry_get_text ((GtkEntry *)Entry);
2275     GString *gstrBuf = g_string_sized_new (10);
2276     int iRet = 1;   //1=I would hide it, 0=I would not hide it
2277 
2278     gtk_tree_model_get(model, iter, iColumnSearch, &cpBuf2, -1);
2279     if (cpBuf2 != NULL && 1<=strlen (ccpBuf)){
2280         g_string_assign (gstrBuf, ccpBuf);
2281         for (cpBuf1=strtok(gstrBuf->str, " ") ; cpBuf1!=NULL ; cpBuf1=strtok(NULL, " ")){
2282             if (strstr (cpBuf2, cpBuf1) != NULL){
2283                 iRet = 0;
2284             }
2285         }
2286     }
2287     else{
2288         iRet = 0;
2289     }
2290 
2291     if (cpBuf2)
2292         free (cpBuf2);
2293     g_string_free (gstrBuf, TRUE);
2294     TRACEIT(10,"propPage_UserCommand_WouldThisFilterHideIt		end");
2295     return iRet;
2296 }
2297 
2298 
propPage_setVisibilityInListView(GtkTreeModel * model,GtkTreePath * path,GtkTreeIter * iter,struct _PropPage_SetVisibility_Stru * Struct)2299 gboolean propPage_setVisibilityInListView (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, struct _PropPage_SetVisibility_Stru *Struct ){
2300     TRACEIT(10,"propPage_setVisibilityInListView		start");
2301     if (Struct == NULL){
2302         TRACEIT(2,"propPage_setVisibilityInListView		parameter NULL");
2303         return TRUE;
2304     }
2305 
2306     gtk_list_store_set ((GtkListStore *)model, iter, Struct->iColumn, Struct->bValue, -1);
2307 
2308     TRACEIT(10,"propPage_setVisibilityInListView		end");
2309     return FALSE;
2310 }
2311 
2312 
propPage_UserCommandClearFilter(GtkButton * button,struct _propPage_UserCommandsEntities * UserCommandsEntities)2313 void propPage_UserCommandClearFilter (GtkButton *button, struct _propPage_UserCommandsEntities *UserCommandsEntities){
2314     TRACEIT(10,"propPage_UserCommandDeleteItem		start");
2315     if (UserCommandsEntities == NULL){
2316         TRACEIT(2,"propPage_UserCommandDeleteItem		parameter NULL");
2317         return;
2318     }
2319 
2320     gtk_entry_set_text ((GtkEntry *)UserCommandsEntities->UsrCmnd_Filter_NameEntry, "");
2321     gtk_entry_set_text ((GtkEntry *)UserCommandsEntities->UsrCmnd_Filter_TargetEntry, "");
2322     gtk_entry_set_text ((GtkEntry *)UserCommandsEntities->UsrCmnd_Filter_CommandEntry, "");
2323     gtk_entry_set_text ((GtkEntry *)UserCommandsEntities->UsrCmnd_Filter_DefaultEntry, "");
2324 
2325     struct _PropPage_SetVisibility_Stru Struct;
2326     Struct.iColumn = PROPPAGE_COL_USCMND_VISIBLE;
2327     Struct.bValue = TRUE;
2328     gtk_tree_model_foreach ((GtkTreeModel *)UserCommandsEntities->UsrCmnd_ListStore, (GtkTreeModelForeachFunc)propPage_setVisibilityInListView, &Struct);
2329 
2330     TRACEIT(10,"propPage_UserCommandDeleteItem		end");
2331     return;
2332 }
2333 
2334 
propPage_UsrCmndRowActivated(GtkTreeView * tree_view,GtkTreePath * path,GtkTreeViewColumn * column,struct _propPage_MainStruct * mainStruct)2335 void propPage_UsrCmndRowActivated (GtkTreeView *tree_view, GtkTreePath *path, GtkTreeViewColumn *column, struct _propPage_MainStruct *mainStruct){
2336     TRACEIT(10,"propPage_UsrCmndRowActivated		start");
2337     propPage_UserCommandButtonEdit (NULL, mainStruct);
2338     TRACEIT(10,"propPage_UsrCmndRowActivated		end");
2339     return;
2340 }
2341 
2342 
propPage_UsrCmndOneKeyPressedInView(GtkWidget * widget,GdkEventKey * event,struct _propPage_MainStruct * mainStruct)2343 gboolean propPage_UsrCmndOneKeyPressedInView(GtkWidget *widget, GdkEventKey *event, struct _propPage_MainStruct *mainStruct){
2344     //Be aware of using widget, as this function is called when a key is pressed on a notebook (tab) too
2345     //data = struct SideObjectList
2346 	TRACEIT(10,"propPage_UsrCmndOneKeyPressedInView		start");
2347 	if (mainStruct == NULL){
2348 		TRACEIT (2, "propPage_UsrCmndOneKeyPressedInView			parameter NULL");
2349 		return FALSE;
2350 	}
2351 
2352 	guint modifiers;
2353 
2354 	modifiers = gtk_accelerator_get_default_mod_mask ();
2355 
2356     if ( (event->keyval == GDK_Delete)){
2357 	    //Delete selected files with 'del-key'
2358 		propPage_UserCommandDeleteItem (NULL, mainStruct);
2359 		TRACEIT(10,"propPage_UsrCmndOneKeyPressedInView		ends");
2360 		return TRUE;
2361 	}
2362 
2363 	TRACEIT(10,"propPage_UsrCmndOneKeyPressedInView		end");
2364 	return FALSE;
2365 }
2366 
2367 
propPage_UsrCmndOneMouseButtonPressedInView(GtkWidget * treeview,GdkEventButton * event,struct _propPage_MainStruct * mainStruct)2368 gboolean propPage_UsrCmndOneMouseButtonPressedInView(GtkWidget *treeview, GdkEventButton *event, struct _propPage_MainStruct *mainStruct){
2369     TRACEIT(10,"propPage_UsrCmndOneMouseButtonPressedInView		start");
2370     if (event->type == GDK_BUTTON_PRESS  &&  event->button == 3){
2371 		propPage_UsrCmndContextMenuOnListView(treeview,event, mainStruct);
2372 		TRACEIT(10,"propPage_UsrCmndOneMouseButtonPressedInView		end");
2373 		return TRUE;
2374 	}
2375 	TRACEIT(10,"propPage_UsrCmndOneMouseButtonPressedInView		end");
2376 	return FALSE;
2377 }
2378 
2379 
propPage_UsrCmndContextMenuOnListView(GtkWidget * treeview,GdkEventButton * event,struct _propPage_MainStruct * mainStruct)2380 gboolean propPage_UsrCmndContextMenuOnListView(GtkWidget *treeview, GdkEventButton *event,  struct _propPage_MainStruct *mainStruct){
2381 	TRACEIT(10,"propPage_BkmrkContextMenuOnListView		start");
2382     if (mainStruct == NULL){
2383 		TRACEIT (2, "propPage_BkmrkContextMenuOnListView			parameter NULL");
2384 		return TRUE;
2385 	}
2386 
2387 	GtkWidget *menu, *menuitem;
2388 	GtkWidget *sep2;
2389     GtkTreeSelection *selection;
2390     int iSelectedRows;
2391 
2392 	menu = gtk_menu_new();
2393 
2394     selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview));
2395     iSelectedRows = gtk_tree_selection_count_selected_rows(selection);
2396 
2397     selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview));
2398 	if (iSelectedRows <= 1){   //Event can be NULL if the key for contextmenu is presed
2399 		GtkTreePath *path;
2400         TRACEIT(11,"propPage_BkmrkContextMenuOnListView		mark the item coverd by mousepointer");
2401         if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(treeview), (gint) event->x, (gint) event->y, &path, NULL, NULL, NULL)){
2402 			gtk_tree_selection_unselect_all(selection);
2403 			gtk_tree_selection_select_path(selection, path);
2404 			gtk_tree_path_free(path);
2405 		}
2406 	}
2407 
2408 	sep2 = gtk_separator_menu_item_new ();
2409 
2410     menuitem = gtk_menu_item_new_with_label("new ...");
2411 	g_signal_connect(menuitem,"activate",G_CALLBACK(propPage_UserCommandButtonNew),mainStruct);
2412 	gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
2413 
2414     menuitem = gtk_menu_item_new_with_label("edit ...");
2415 	g_signal_connect(menuitem,"activate",G_CALLBACK(propPage_UserCommandButtonEdit),mainStruct);
2416 	gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
2417 
2418     gtk_menu_shell_append(GTK_MENU_SHELL(menu), sep2);
2419 
2420     menuitem = gtk_menu_item_new_with_label("delete");
2421 	g_signal_connect(menuitem,"activate",G_CALLBACK(propPage_UserCommandDeleteItem), &(mainStruct->UserCommandsEntities));
2422 	gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
2423 
2424 
2425     gtk_widget_show_all(menu);
2426 	// Note: event can be NULL here when called from view_onPopupMenu;
2427 	// gdk_event_get_time() accepts a NULL argument
2428 	gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, (event != NULL) ? event->button : 0, gdk_event_get_time((GdkEvent*)event));
2429 
2430 	TRACEIT(10,"propPage_UsrCmndContextMenuOnListView		ends");
2431 	return TRUE;
2432 }
2433 
2434 
propPage_UserCommandButtonEdit(GtkButton * button,struct _propPage_MainStruct * mainStruct)2435 void propPage_UserCommandButtonEdit (GtkButton *button, struct _propPage_MainStruct *mainStruct){
2436     TRACEIT(10,"propPage_UserCommandButtonEdit		start");
2437     if (mainStruct == NULL){
2438         TRACEIT(2,"propPage_UserCommandButtonEdit		parameter NULL");
2439         return;
2440     }
2441 
2442     GtkTreeModel *model=NULL;
2443     GtkTreeIter iter;
2444     GtkTreeSelection	*selection;
2445     selection  = gtk_tree_view_get_selection((GtkTreeView *)mainStruct->UserCommandsEntities.UsrCmnd_ListView);
2446 
2447     struct _UserCommandList *UserCommandListBuf = NULL;
2448 
2449     GList *glistPathList = gtk_tree_selection_get_selected_rows (selection, &model);
2450 
2451     if (glistPathList == NULL){
2452         TRACEIT(10,"propPage_UserCommandButtonEdit		pathlist NULL, nothing marked, end");
2453         return;
2454     }
2455     gtk_tree_model_get_iter(GTK_TREE_MODEL(mainStruct->UserCommandsEntities.UsrCmnd_ListStore), &iter, (GtkTreePath *)glistPathList->data);
2456 
2457     gtk_tree_model_get (GTK_TREE_MODEL(mainStruct->UserCommandsEntities.UsrCmnd_ListStore), &iter, PROPPAGE_COL_USCMND_ITEMPOINTER, &UserCommandListBuf, -1);
2458     if (UserCommandListBuf == NULL){
2459         TRACEIT(4,"propPage_UserCommandDeleteItem		error searching for bookmark pointer");
2460     }
2461 
2462     g_list_foreach (glistPathList,(GFunc) gtk_tree_path_free, NULL);
2463     g_list_free (glistPathList);
2464 
2465     propPage_UserCommandAddItem (UserCommandListBuf, mainStruct->mainEntities.Main_Widget);
2466 
2467     TRACEIT(10,"propPage_UserCommandButtonEdit		end");
2468 }
2469 
2470 
propPage_UserCommandButtonNew(GtkButton * button,struct _propPage_MainStruct * mainStruct)2471 void propPage_UserCommandButtonNew (GtkButton *button, struct _propPage_MainStruct *mainStruct){
2472     TRACEIT(10,"propPage_UserCommandButtonNew		start");
2473     if (mainStruct == NULL){
2474         TRACEIT(2,"propPage_UserCommandButtonNew		parameter NULL");
2475         return;
2476     }
2477 
2478     propPage_UserCommandAddItem (NULL, mainStruct->mainEntities.Main_Widget);
2479 
2480     TRACEIT(10,"propPage_UserCommandButtonNew		end");
2481 }
2482 
2483 
propPage_UserCommandAddItem(struct _UserCommandList * UserCommandListItem,GtkWidget * Parent)2484 int propPage_UserCommandAddItem (struct _UserCommandList *UserCommandListItem, GtkWidget *Parent){
2485     TRACEIT(10,"propPage_UserCommandAddItem		start");
2486 
2487 
2488     GtkWidget *wBuf=NULL;
2489 
2490     wBuf = createUserCommand_start (UserCommandListItem, (GtkWindow *)Parent);
2491     if (wBuf){
2492         g_glistUserCommandWidgets = g_list_append (g_glistUserCommandWidgets, wBuf);
2493     }
2494 
2495     TRACEIT(10,"propPage_UserCommandAddItem		end");
2496     return 0;
2497 }
2498 
2499 
propPage_UserCommandDeleteItem(GtkButton * button,struct _propPage_MainStruct * mainStruct)2500 void propPage_UserCommandDeleteItem (GtkButton *button, struct _propPage_MainStruct *mainStruct){
2501     TRACEIT(10,"propPage_UserCommandDeleteItem		start");
2502     if (mainStruct == NULL){
2503         TRACEIT(2,"propPage_UserCommandDeleteItem		parameter NULL");
2504         return;
2505     }
2506     GtkTreeModel *model=NULL;
2507     GtkTreeIter iter;
2508     GtkTreeSelection	*selection;
2509     struct _propPage_UserCommandsEntities *UserCommandsEntities = &(mainStruct->UserCommandsEntities);
2510     selection = gtk_tree_view_get_selection((GtkTreeView *)UserCommandsEntities->UsrCmnd_ListView);
2511 
2512     struct _UserCommandList *UserCommandListBuf = NULL;
2513 
2514     GList *glistPathList = gtk_tree_selection_get_selected_rows (selection, &model);
2515     GList *glistBuf;
2516 
2517     if (glistPathList == NULL){
2518         TRACEIT(10,"propPage_UserCommandDeleteItem		end");
2519         return;
2520     }
2521 
2522     glistBuf = glistPathList;
2523     while (glistBuf){
2524         gtk_tree_model_get_iter(GTK_TREE_MODEL(UserCommandsEntities->UsrCmnd_ListStore), &iter, (GtkTreePath *)glistBuf->data);
2525 
2526         gtk_tree_model_get (GTK_TREE_MODEL(UserCommandsEntities->UsrCmnd_ListStore), &iter, PROPPAGE_COL_USCMND_ITEMPOINTER, &UserCommandListBuf, -1);
2527         if (UserCommandListBuf != NULL){
2528             g_UserCommandList = UserCommandList_deleteItem(UserCommandListBuf);
2529             gtk_list_store_remove(GTK_LIST_STORE(model), &iter);
2530         }
2531         else{
2532             TRACEIT(4,"propPage_UserCommandDeleteItem		error searching for bookmark pointer");
2533         }
2534         glistBuf = glistBuf->next;
2535     }
2536     mainStruct->iSaved=0;
2537     g_list_foreach (glistPathList,(GFunc) gtk_tree_path_free, NULL);
2538     g_list_free (glistPathList);
2539     TRACEIT(10,"propPage_UserCommandDeleteItem		end");
2540     return;
2541 }
2542 
2543