2 Copyright 2002-2012, The AROS Development Team.
11 #include <exec/memory.h>
13 #include <libraries/asl.h>
14 #include <libraries/mui.h>
15 #include <prefs/prefhdr.h>
17 #include <clib/alib_protos.h>
18 #include <proto/exec.h>
19 #include <proto/dos.h>
20 #include <proto/intuition.h>
21 #include <proto/utility.h>
22 #include <proto/iffparse.h>
23 #include <proto/muimaster.h>
31 #include "scrollbarsp.h"
32 #include "listviewsp.h"
35 #include "navigationp.h"
37 #include "zunestuff.h"
39 /************************************************************************/
41 #ifndef MAXFILENAMELENGTH
42 #define MAXFILENAMELENGTH 255
45 /************************************************************************/
48 #define MCC_Query(x) AROS_LVO_CALL1(struct MUI_CustomClass *, \
49 AROS_LCA(LONG, (x), D0), \
50 struct Library *, mcclib, 5, lib)
55 struct MUI_CustomClass
*MCC_Query(ULONG d0
);
56 #pragma libcall mcclib MCC_Query 01e 001
60 extern IPTR
ClassListview_Dispatcher();
61 struct MUI_CustomClass
*ClassListview_CLASS
;
63 #define ZUNEVERSION "$VER: Zune 0.2 (22.02.2006) AROS Dev Team"
67 struct TagItem prefstags
[] =
69 { ASLFR_DoPatterns
, (IPTR
)TRUE
},
70 { ASLFR_InitialPattern
, (IPTR
)"#?.prefs" },
74 /************************************************************************/
76 void load_prefs(CONST_STRPTR name
);
77 void save_prefs(CONST_STRPTR name
, BOOL envarc
);
78 void test_prefs(void);
79 void main_open_menu(void);
80 void main_saveas_menu(void);
81 void restore_prefs(CONST_STRPTR name
);
83 /************************************************************************/
86 struct Library
*ZuneMasterBase
;
87 struct ZuneMasterIFace
*IZuneMaster
;
91 /************************************************************************/
93 /****************************************************************
95 *****************************************************************/
99 if (!(ZuneMasterBase
= OpenLibrary("zunemaster.library",0)))
101 printf("Unable to open zunemaster.library\n");
105 if (!(IZuneMaster
= (struct ZuneMasterIFace
*)GetInterface(ZuneMasterBase
,"main",1,NULL
)))
107 printf("Unable to get main interface of zunemaster.library\n");
108 CloseLibrary(ZuneMasterBase
); ZuneMasterBase
= NULL
;
115 /****************************************************************
116 Close opened libraries
117 *****************************************************************/
118 void close_libs(void)
121 DropInterface((struct Interface
*)IZuneMaster
);
122 CloseLibrary(ZuneMasterBase
);
126 struct Hook hook_standard
;
129 static Object
*open_menuitem
;
130 static Object
*append_menuitem
;
131 static Object
*saveas_menuitem
;
132 static Object
*aboutzune_menuitem
;
133 static Object
*quit_menuitem
;
134 static Object
*LastSavedConfigdata
= NULL
;
135 static STRPTR appname
= NULL
;
137 static Object
*main_wnd
;
138 static Object
*main_page_list
;
139 static Object
*main_page_group
; /* contains the selelected group */
140 static Object
*main_page_group_displayed
; /* The current displayed group */
141 static Object
*main_page_space
; /* a space object */
143 void close_classes(void)
145 MUI_DeleteCustomClass(ClassListview_CLASS
);
148 int open_classes(void)
152 ClassListview_CLASS
= MUI_CreateCustomClass(NULL
, MUIC_Listview
, NULL
, sizeof(struct ClassListview_DATA
), ClassListview_Dispatcher
);
166 struct MUI_CustomClass
*cl
; /* The class pointer, maybe NULL */
167 Object
*group
; /* The group which should be is displayed, maybe NULL */
168 const struct __MUIBuiltinClass
*desc
;
169 struct Library
*mcp_library
;
170 UBYTE mcp_namebuffer
[MAXFILENAMELENGTH
+ 1];
173 #define MAX_PAGE_ENTRIES 100
175 /* the name field is set in init_gui() */
176 struct page_entry main_page_entries
[MAX_PAGE_ENTRIES
+ 1] =
178 /* {"Info",NULL,NULL,NULL}, */
179 { "", NULL
, NULL
, &_MUIP_System_desc
},
180 { "", NULL
, NULL
, &_MUIP_Windows_desc
},
181 { "", NULL
, NULL
, &_MUIP_Groups_desc
},
182 { "", NULL
, NULL
, &_MUIP_Buttons_desc
},
183 { "", NULL
, NULL
, &_MUIP_Cycles_desc
},
184 { "", NULL
, NULL
, &_MUIP_Sliders_desc
},
185 { "", NULL
, NULL
, &_MUIP_Scrollbars_desc
},
186 { "", NULL
, NULL
, &_MUIP_Listviews_desc
},
187 { "", NULL
, NULL
, &_MUIP_Strings_desc
},
188 { "", NULL
, NULL
, &_MUIP_Navigation_desc
},
189 { "", NULL
, NULL
, &_MUIP_Special_desc
},
190 { "", NULL
, NULL
, &_MUIP_Frames_desc
},
191 { NULL
, NULL
, NULL
, NULL
},
194 struct MUI_CustomClass
*create_class(const struct __MUIBuiltinClass
*desc
)
196 return MUI_CreateCustomClass(NULL
,MUIC_Settingsgroup
,NULL
,desc
->datasize
,desc
->dispatcher
);
199 /****************************************************************
200 Our standard hook function, for easy call backs
201 *****************************************************************/
202 static void hook_func_standard(struct Hook
*h
, void *dummy
, IPTR
*funcptr
)
204 void (*func
) (IPTR
*) = (void (*)(IPTR
*)) (*funcptr
);
205 if (func
) func(funcptr
+ 1);
208 /****************************************************************
209 The display function for the page listview
210 *****************************************************************/
211 static void main_page_list_display(struct Hook
*h
, char **strings
, struct page_entry
*entry
)
215 strings
[0] = entry
->name
;
220 /****************************************************************
221 A new entry has been selected
222 *****************************************************************/
223 void main_page_active(void)
225 int new_active
= XGET(main_page_list
,MUIA_List_Active
);
228 if (new_active
== -1)
229 new_group
= main_page_space
;
232 new_group
= main_page_entries
[new_active
].group
;
234 new_group
= main_page_space
;
237 if (new_group
== main_page_group_displayed
)
240 DoMethod(main_page_group
, MUIM_Group_InitChange
);
241 DoMethod(main_page_group
, OM_REMMEMBER
, (IPTR
)main_page_group_displayed
);
242 DoMethod(main_page_group
, OM_ADDMEMBER
, (IPTR
)new_group
);
243 DoMethod(main_page_group
, MUIM_Group_ExitChange
);
244 main_page_group_displayed
= new_group
;
247 /****************************************************************
249 *****************************************************************/
250 void main_save_pressed(void)
252 save_prefs(appname
, TRUE
);
253 DoMethod(app
, MUIM_Application_ReturnID
, MUIV_Application_ReturnID_Quit
);
256 /****************************************************************
258 *****************************************************************/
259 void main_use_pressed(void)
261 save_prefs(appname
, FALSE
);
262 DoMethod(app
, MUIM_Application_ReturnID
, MUIV_Application_ReturnID_Quit
);
265 /****************************************************************
267 *****************************************************************/
268 void main_test_pressed(void)
273 /****************************************************************
275 *****************************************************************/
276 void main_cancel_pressed(void)
278 restore_prefs(appname
);
279 DoMethod(app
, MUIM_Application_ReturnID
, MUIV_Application_ReturnID_Quit
);
282 /****************************************************************
285 TODO: Write for AmigaOS4
286 *****************************************************************/
290 static CONST_STRPTR
const searchpaths
[] =
293 "Classes/Zune/#?.(mcp|mcc)",
297 CONST_STRPTR
const *pathptr
;
298 struct DevProc
*dp
= NULL
;
299 struct page_entry
*pe
;
300 WORD num_page_entries
= 0;
303 for(pe
= main_page_entries
; pe
->name
; pe
++)
308 olddir
= CurrentDir(BNULL
);
310 while((dp
= GetDeviceProc("LIBS:", dp
)))
312 CurrentDir(dp
->dvp_Lock
);
314 for(pathptr
= searchpaths
; *pathptr
; pathptr
++)
316 struct AnchorPath
*ap
;
319 ap
= (struct AnchorPath
*)AllocVec(sizeof(struct AnchorPath
) + 256, MEMF_CLEAR
);
324 for(match
= MatchFirst((STRPTR
)*pathptr
, ap
);
326 match
= MatchNext(ap
))
328 struct Library
*mcclib
;
330 if (num_page_entries
< MAX_PAGE_ENTRIES
)
332 if ((mcclib
= OpenLibrary(ap
->ap_Buf
, 0)))
334 struct MUI_CustomClass
*mcp
;
336 if ((mcp
= MCC_Query(1)))
341 pe
->mcp_library
= mcclib
;
344 pe
->mcp_namebuffer
[0] = 27;
345 pe
->mcp_namebuffer
[1] = '3';
346 strncpy(pe
->mcp_namebuffer
+ 2, mcp
->mcc_Class
->cl_ID
, sizeof(pe
->mcp_namebuffer
) - 3);
348 if ((sp
= strrchr(pe
->mcp_namebuffer
, '.')))
351 pe
->name
= pe
->mcp_namebuffer
;
356 } /* if ((mcp = MCC_Query(1))) */
358 if (mcclib
) CloseLibrary(mcclib
);
360 } /* if ((mcclib = OpenLibrary(ap->ap_Buf, 0))) */
362 } /* if (num_page_entries < MAX_PAGE_ENTRIES) */
364 } /* for(match = ... */
372 } /* for(pathptr = searchpaths; *pathptr; pathptr++) */
374 if (!(dp
->dvp_Flags
& DVPF_ASSIGN
)) break;
376 } /* while((dp = GetDeviceProc("LIBS:", dp))) */
384 /****************************************************************
385 Deallocates all gui resources
386 *****************************************************************/
387 void deinit_gui(void)
392 MUI_DisposeObject(app
);
394 for (i
= 0; main_page_entries
[i
].name
; i
++)
396 if ((main_page_entries
[i
].group
!= NULL
) &&
397 (main_page_entries
[i
].group
!= main_page_group_displayed
))
399 DisposeObject(main_page_entries
[i
].group
);
402 if (main_page_entries
[i
].mcp_library
)
404 main_page_entries
[i
].cl
= NULL
; /* Prevent MUI_DeleteCustomClass call below */
406 if ((main_page_entries
[i
].group
== NULL
) ||
407 (main_page_entries
[i
].group
!= main_page_group_displayed
))
409 /* Only close library if main_page_group_displayed is not this page,
410 because in that case the object got automatically killed through
411 MUI_DisposeObject(app) which also does the CloseLibrary()!! */
413 CloseLibrary(main_page_entries
[i
].mcp_library
);
414 main_page_entries
[i
].mcp_library
= NULL
;
418 main_page_entries
[i
].group
= NULL
;
420 if (main_page_entries
[i
].cl
!= NULL
)
422 MUI_DeleteCustomClass(main_page_entries
[i
].cl
);
423 main_page_entries
[i
].cl
= NULL
;
427 if (main_page_group_displayed
!= main_page_space
)
428 MUI_DisposeObject(main_page_space
);
431 /****************************************************************
432 Allocate resources for gui
433 *****************************************************************/
439 Object
*cancel_button
;
443 main_page_entries
[ 0].name
= (char *)_(MSG_DSC_SYSTEM
);
444 main_page_entries
[ 1].name
= (char *)_(MSG_DSC_WINDOWS
);
445 main_page_entries
[ 2].name
= (char *)_(MSG_DSC_GROUPS
);
446 main_page_entries
[ 3].name
= (char *)_(MSG_DSC_BUTTONS
);
447 main_page_entries
[ 4].name
= (char *)_(MSG_DSC_CYCLES
);
448 main_page_entries
[ 5].name
= (char *)_(MSG_DSC_SLIDERS
);
449 main_page_entries
[ 6].name
= (char *)_(MSG_DSC_SCROLLBARS
);
450 main_page_entries
[ 7].name
= (char *)_(MSG_DSC_LISTVIEWS
);
451 main_page_entries
[ 8].name
= (char *)_(MSG_DSC_STRINGS
);
452 main_page_entries
[ 9].name
= (char *)_(MSG_DSC_NAVIGATION
);
453 main_page_entries
[10].name
= (char *)_(MSG_DSC_SPECIAL
);
454 main_page_entries
[11].name
= (char *)_(MSG_DSC_FRAMES
);
456 static struct Hook page_display_hook
;
459 hook_standard
.h_Entry
= (HOOKFUNC
)hook_func_standard
;
460 page_display_hook
.h_Entry
= (HOOKFUNC
)main_page_list_display
;
462 hook_standard
.h_Entry
= HookEntry
;
463 hook_standard
.h_SubEntry
= (APTR
)hook_func_standard
;
464 page_display_hook
.h_Entry
= HookEntry
;
465 page_display_hook
.h_SubEntry
= (APTR
)main_page_list_display
;
468 if (!strcmp(appname
, "global"))
469 wintitle
= (STRPTR
) _(MSG_WINTITLE1
);
472 snprintf(titlebuf
, 255, _(MSG_WINTITLE2
), appname
);
476 app
= ApplicationObject
,
477 MUIA_Application_Title
, (IPTR
) "Zune",
478 MUIA_Application_Version
, (IPTR
) ZUNEVERSION
,
479 MUIA_Application_Copyright
, (IPTR
) " 2006, The AROS Development Team",
480 MUIA_Application_Description
, wintitle
,
481 MUIA_Application_Base
, "ZUNEPREF",
482 MUIA_Application_Menustrip
, MenuitemObject
,
483 MUIA_Family_Child
, MenuitemObject
,
484 MUIA_Menuitem_Title
, _(MSG_MEN_PROJECT
),
485 MUIA_Family_Child
, open_menuitem
= MenuitemObject
,
486 MUIA_Menuitem_Title
, _(MSG_MEN_OPEN
), MUIA_Menuitem_Shortcut
, _(MSG_MEN_OPEN_SC
),
488 MUIA_Family_Child
, append_menuitem
= MenuitemObject
, MUIA_Menuitem_Title
, _(MSG_MEN_APPEND
), End
,
489 MUIA_Family_Child
, saveas_menuitem
= MenuitemObject
,
490 MUIA_Menuitem_Title
, _(MSG_MEN_SAVEAS
), MUIA_Menuitem_Shortcut
, _(MSG_MEN_SAVEAS_SC
),
492 MUIA_Family_Child
, MenuitemObject
, MUIA_Menuitem_Title
, NM_BARLABEL
, End
,
493 MUIA_Family_Child
, aboutzune_menuitem
= MenuitemObject
,
494 MUIA_Menuitem_Title
, _(MSG_MEN_ABOUT
), MUIA_Menuitem_Shortcut
, _(MSG_MEN_ABOUT_SC
),
496 MUIA_Family_Child
, MenuitemObject
, MUIA_Menuitem_Title
, NM_BARLABEL
, End
,
497 MUIA_Family_Child
, quit_menuitem
= MenuitemObject
,
498 MUIA_Menuitem_Title
, _(MSG_MEN_QUIT
), MUIA_Menuitem_Shortcut
, _(MSG_MEN_QUIT_SC
),
502 SubWindow
, main_wnd
= WindowObject
,
503 MUIA_Window_Title
, (IPTR
)wintitle
,
504 MUIA_Window_Activate
, TRUE
,
505 MUIA_Window_CloseGadget
, FALSE
,
506 MUIA_Window_ID
, MAKE_ID('Z','W','I','N'),
508 WindowContents
, VGroup
,
509 MUIA_Group_VertSpacing
, 10,
512 Child
, (NewObject(ClassListview_CLASS
->mcc_Class
, NULL
,
514 MUIA_Listview_List
, main_page_list
= ListObject
,
516 MUIA_List_AdjustWidth
, TRUE
,
517 MUIA_List_DisplayHook
, &page_display_hook
,
521 Child
, MUI_NewObject(MUIC_Popframe
,
523 MUIA_Window_Title
, (IPTR
) _(MSG_FRAME_CLIPBOARD
),
525 Child
, MUI_NewObject(MUIC_Popimage
,
527 MUIA_Imageadjust_Type
, MUIV_Imageadjust_Type_All
,
528 MUIA_Window_Title
, (IPTR
) _(MSG_IMAGE_CLIPBOARD
),
535 MUIA_Background
, MUII_PageBack
,
536 Child
, main_page_group
= VGroup
,
537 Child
, main_page_group_displayed
= main_page_space
= HVSpace
,
542 Child
, test_button
= ImageButton(_(MSG_GAD_TEST
), "THEME:Images/Gadgets/Prefs/Test"),
544 Child
, save_button
= ImageButton(_(MSG_GAD_SAVE
), "THEME:Images/Gadgets/Prefs/Save"),
545 Child
, use_button
= ImageButton(_(MSG_GAD_USE
), "THEME:Images/Gadgets/Prefs/Use"),
546 Child
, cancel_button
= ImageButton(_(MSG_GAD_CANCEL
), "THEME:Images/Gadgets/Prefs/Cancel"),
556 DoMethod(main_wnd
, MUIM_Notify
, MUIA_Window_CloseRequest
, TRUE
,
557 (IPTR
)app
, 3, MUIM_CallHook
, (IPTR
)&hook_standard
,
558 (IPTR
)main_cancel_pressed
);
559 DoMethod(cancel_button
, MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)app
, 3,
560 MUIM_CallHook
, (IPTR
)&hook_standard
, (IPTR
)main_cancel_pressed
);
561 DoMethod(save_button
, MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)app
, 3,
562 MUIM_CallHook
, (IPTR
)&hook_standard
, (IPTR
)main_save_pressed
);
563 DoMethod(use_button
, MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)app
, 3,
564 MUIM_CallHook
, (IPTR
)&hook_standard
, (IPTR
)main_use_pressed
);
565 DoMethod(test_button
, MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)app
, 6,
566 MUIM_Application_PushMethod
, (IPTR
)app
, 3, MUIM_CallHook
,
567 (IPTR
)&hook_standard
, (IPTR
)main_test_pressed
);
568 DoMethod(quit_menuitem
, MUIM_Notify
, MUIA_Menuitem_Trigger
,
569 MUIV_EveryTime
, (IPTR
)app
, 3, MUIM_CallHook
,
570 (IPTR
)&hook_standard
, (IPTR
)main_cancel_pressed
);
571 DoMethod(open_menuitem
, MUIM_Notify
, MUIA_Menuitem_Trigger
,
572 MUIV_EveryTime
, (IPTR
)app
, 3, MUIM_CallHook
,
573 (IPTR
)&hook_standard
, (IPTR
)main_open_menu
);
574 DoMethod(saveas_menuitem
, MUIM_Notify
, MUIA_Menuitem_Trigger
,
575 MUIV_EveryTime
, (IPTR
)app
, 3, MUIM_CallHook
,
576 (IPTR
)&hook_standard
, (IPTR
)main_saveas_menu
);
577 DoMethod(aboutzune_menuitem
, MUIM_Notify
, MUIA_Menuitem_Trigger
,
578 MUIV_EveryTime
, (IPTR
)app
, 2, MUIM_Application_AboutMUI
,
581 for (i
= 0; main_page_entries
[i
].name
!= NULL
; i
++)
583 struct page_entry
*p
= &main_page_entries
[i
];
585 if (!p
->cl
) p
->cl
= create_class(p
->desc
);
587 if (!(p
->cl
&& (p
->group
= NewObject(p
->cl
->mcc_Class
, NULL
, TAG_DONE
))))
593 DoMethod(main_page_list
, MUIM_List_InsertSingle
, (IPTR
)p
,
594 MUIV_List_Insert_Bottom
);
597 DoMethod(main_page_list
, MUIM_Notify
, MUIA_List_Active
, MUIV_EveryTime
,
598 (IPTR
)app
, 3, MUIM_CallHook
, (IPTR
)&hook_standard
,
599 (IPTR
)main_page_active
);
601 /* Activate first entry */
602 set(main_page_list
,MUIA_List_Active
,0);
609 /****************************************************************
611 *****************************************************************/
612 void load_prefs(CONST_STRPTR name
)
616 configdata
= MUI_NewObject(MUIC_Configdata
,
617 MUIA_Configdata_ApplicationBase
, (IPTR
)name
,
619 if (configdata
!= NULL
)
623 /* D(bug("zune::load_prefs: created configdata %p\n", configdata)); */
624 LastSavedConfigdata
= configdata
;
626 /* Call MUIM_Settingsgroup_ConfigToGadgets for every group */
627 for (i
=0;main_page_entries
[i
].name
;i
++)
629 struct page_entry
*p
= &main_page_entries
[i
];
631 DoMethod(p
->group
, MUIM_Settingsgroup_ConfigToGadgets
,
635 /* D(bug("zune::save_prefs: disposed configdata %p\n", configdata)); */
639 /* write prefs to env: */
640 void test_prefs(void)
644 save_prefs(appname
, FALSE
);
646 cfg
= MUI_NewObject(MUIC_Configdata
, MUIA_Configdata_Application
, (IPTR
)app
, TAG_DONE
);
647 set(app
, MUIA_Application_Configdata
, (IPTR
)cfg
);
650 void restore_prefs(CONST_STRPTR name
)
654 snprintf(buf
, 255, "ENV:zune/%s.prefs", name
);
655 DoMethod(LastSavedConfigdata
, MUIM_Configdata_Save
, (IPTR
)buf
);
659 /****************************************************************
660 open given prefs file from menue
661 *****************************************************************/
663 void main_open_menu(void)
665 static char dirpart
[500]="ENVARC:Zune",filepart
[500],filename
[1000];
667 if (aslfilerequest ("Load a Zune Prefs File", (char *)&dirpart
, (char *)&filepart
, (char *)&filename
, prefstags
));
671 configdata
= MUI_NewObject(MUIC_Configdata
,
672 MUIA_Configdata_ApplicationBase
,appname
,
675 if (configdata
!= NULL
)
679 /* D(bug("zune::load_prefs: created configdata %p\n", configdata)); */
680 //LastSavedConfigdata = configdata;
681 DoMethod(configdata
, MUIM_Configdata_Load
,filename
);
683 /* Call MUIM_Settingsgroup_ConfigToGadgets for every group */
684 for (i
=0;main_page_entries
[i
].name
;i
++)
686 struct page_entry
*p
= &main_page_entries
[i
];
688 if (p
->group
) DoMethod(p
->group
, MUIM_Settingsgroup_ConfigToGadgets
, (IPTR
)configdata
);
691 /* activate prefs in test mode */
694 /* D(bug("zune::save_prefs: disposed configdata %p\n", configdata)); */
700 /****************************************************************
702 *****************************************************************/
703 void save_prefs(CONST_STRPTR name
, BOOL envarc
)
707 configdata
= MUI_NewObject(MUIC_Configdata
,
708 //MUIA_Configdata_ApplicationBase, name,
709 MUIA_Configdata_Application
,appaddr
,
711 if (configdata
!= NULL
)
716 /* D(bug("zune::save_prefs: created configdata %p\n", configdata)); */
718 /* Call MUIM_Settingsgroup_GadgetsToConfig for every group */
719 for (i
=0;main_page_entries
[i
].name
;i
++)
721 struct page_entry
*p
= &main_page_entries
[i
];
723 DoMethod(p
->group
, MUIM_Settingsgroup_GadgetsToConfig
,
729 snprintf(buf
, 255, "ENVARC:zune/%s.prefs", name
);
730 DoMethod(configdata
, MUIM_Configdata_Save
, (IPTR
)buf
);
732 snprintf(buf
, 255, "ENV:zune/%s.prefs", name
);
733 DoMethod(configdata
, MUIM_Configdata_Save
, (IPTR
)buf
);
735 MUI_DisposeObject(configdata
);
736 /* D(bug("zune::save_prefs: disposed configdata %p\n", configdata)); */
741 /****************************************************************
742 SaveAS the done prefs from menue
743 *****************************************************************/
745 void main_saveas_menu(void)
747 static char dirpart
[500]="ENVARC:Zune",filepart
[500],filename
[1000];
749 if (aslfilerequest("Save a Zune Prefs File", (char *)&dirpart
, (char *)&filepart
, (char *)&filename
, prefstags
));
753 configdata
= MUI_NewObject(MUIC_Configdata
,
754 MUIA_Configdata_ApplicationBase
, "dummyfile",
757 /* check for ".prefs" suffix in filename, add if not existing */
758 if ( !strstr( filename
, ".prefs") ) strcat(filename
, ".prefs");
760 if (configdata
!= NULL
)
764 /* D(bug("zune::save_prefs: created configdata %p\n", configdata)); */
766 /* Call MUIM_Settingsgroup_GadgetsToConfig for every group */
767 for (i
=0;main_page_entries
[i
].name
;i
++)
769 struct page_entry
*p
= &main_page_entries
[i
];
771 if (p
->group
) DoMethod(p
->group
, MUIM_Settingsgroup_GadgetsToConfig
, (IPTR
)configdata
);
774 DoMethod(configdata
, MUIM_Configdata_Save
, filename
);
776 MUI_DisposeObject(configdata
);
777 /* D(bug("zune::save_prefs: disposed configdata %p\n", configdata)); */
785 /****************************************************************
787 *****************************************************************/
792 while((LONG
) DoMethod(app
, MUIM_Application_NewInput
, (IPTR
)&sigs
)
793 != MUIV_Application_ReturnID_Quit
)
797 sigs
= Wait(sigs
| SIGBREAKF_CTRL_C
| SIGBREAKF_CTRL_D
);
798 if (sigs
& SIGBREAKF_CTRL_C
) break;
799 if (sigs
& SIGBREAKF_CTRL_D
) break;
804 /****************************************************************
806 *****************************************************************/
810 BPTR OldDir
= BNULL
, NewDir
;
811 int retval
= RETURN_OK
;
812 struct RDArgs
*rda
= NULL
;
814 IPTR args
[] = { 0,0 };
815 enum { ARG_APPNAME
= 0,ARG_APPADDR
=1 };
821 rda
= ReadArgs("/A,/N", args
, NULL
);
822 appname
=(STRPTR
)args
[ARG_APPNAME
];
823 appaddr
=(APTR
)args
[ARG_APPADDR
];
824 if (appaddr
)appaddr
=*(appaddr
);
832 if (retval
== RETURN_OK
)
842 NewDir
= Lock("RAM:", SHARED_LOCK
);
844 OldDir
= CurrentDir(NewDir
);
847 load_prefs((STRPTR
)args
[ARG_APPNAME
]);
848 set(main_wnd
, MUIA_Window_Open
, TRUE
);
849 if (XGET(main_wnd
,MUIA_Window_Open
))
853 if (LastSavedConfigdata
)
854 MUI_DisposeObject(LastSavedConfigdata
);
867 if (rda
) FreeArgs(rda
);
869 Locale_Deinitialize();