2 Copyright 2002-2014, 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"
40 #include <aros/debug.h>
42 /************************************************************************/
44 #ifndef MAXFILENAMELENGTH
45 #define MAXFILENAMELENGTH 255
48 /************************************************************************/
50 #define MCC_Query(x) AROS_LVO_CALL1(struct MUI_CustomClass *, \
51 AROS_LCA(LONG, (x), D0), \
52 struct Library *, mcclib, 5, lib)
55 #define ZUNEVERSION "$VER: Zune 0.2 (22.02.2006) AROS Dev Team"
59 struct TagItem prefstags
[] =
61 { ASLFR_DoPatterns
, (IPTR
)TRUE
},
62 { ASLFR_InitialPattern
, (IPTR
)"#?.prefs" },
66 /************************************************************************/
68 void load_prefs(CONST_STRPTR name
);
69 void save_prefs(CONST_STRPTR name
, BOOL envarc
);
70 void test_prefs(void);
71 void main_open_menu(void);
72 void main_saveas_menu(void);
73 void restore_prefs(CONST_STRPTR name
);
75 /************************************************************************/
78 static struct Hook main_cancel_pressed_hook
;
79 static struct Hook main_save_pressed_hook
;
80 static struct Hook main_use_pressed_hook
;
81 static struct Hook main_test_pressed_hook
;
82 static struct Hook main_open_menu_hook
;
83 static struct Hook main_saveas_menu_hook
;
84 static struct Hook main_page_active_hook
;
85 static struct Hook page_display_hook
;
88 static Object
*open_menuitem
;
89 static Object
*append_menuitem
;
90 static Object
*saveas_menuitem
;
91 static Object
*aboutzune_menuitem
;
92 static Object
*quit_menuitem
;
93 static Object
*LastSavedConfigdata
= NULL
;
94 static STRPTR appname
= NULL
;
96 static Object
*main_wnd
;
97 static Object
*main_page_list
;
98 static Object
*main_page_group
; /* contains the selelected group */
99 static Object
*main_page_group_displayed
; /* The current displayed group */
100 static Object
*main_page_space
; /* a space object */
102 void close_classes(void)
104 delete_listview_class();
107 int open_classes(void)
109 if ((ClassListview_CLASS
= create_listview_class()) != NULL
)
121 #define MAX_PAGE_ENTRIES 100
123 /* the name field is set in init_gui() */
124 struct page_entry main_page_entries
[MAX_PAGE_ENTRIES
+ 1] =
126 /* {"Info", NULL, NULL, NULL, NULL, NULL}, */
127 { "", NULL
, NULL
, NULL
, NULL
, &_MUIP_System_desc
},
128 { "", NULL
, NULL
, NULL
, NULL
, &_MUIP_Windows_desc
},
129 { "", NULL
, NULL
, NULL
, NULL
, &_MUIP_Groups_desc
},
130 { "", NULL
, NULL
, NULL
, NULL
, &_MUIP_Buttons_desc
},
131 { "", NULL
, NULL
, NULL
, NULL
, &_MUIP_Cycles_desc
},
132 { "", NULL
, NULL
, NULL
, NULL
, &_MUIP_Sliders_desc
},
133 { "", NULL
, NULL
, NULL
, NULL
, &_MUIP_Scrollbars_desc
},
134 { "", NULL
, NULL
, NULL
, NULL
, &_MUIP_Listviews_desc
},
135 { "", NULL
, NULL
, NULL
, NULL
, &_MUIP_Strings_desc
},
136 { "", NULL
, NULL
, NULL
, NULL
, &_MUIP_Navigation_desc
},
137 { "", NULL
, NULL
, NULL
, NULL
, &_MUIP_Special_desc
},
138 { "", NULL
, NULL
, NULL
, NULL
, &_MUIP_Frames_desc
},
139 { NULL
, NULL
, NULL
, NULL
, NULL
, NULL
},
142 struct MUI_CustomClass
*create_class(const struct __MUIBuiltinClass
*desc
)
144 return MUI_CreateCustomClass(NULL
,MUIC_Settingsgroup
,NULL
,desc
->datasize
,desc
->dispatcher
);
148 /****************************************************************
149 The display function for the page listview
150 *****************************************************************/
151 static void main_page_list_display(struct Hook
*h
, char **strings
, struct page_entry
*entry
)
155 sprintf(entry
->mcp_imagespec
, "\33O[%08lx]", (long unsigned)entry
->mcp_listimage
);
156 *strings
++ = entry
->mcp_imagespec
;
157 *strings
= entry
->name
;
162 /****************************************************************
163 A new entry has been selected
164 *****************************************************************/
165 void main_page_active(void)
167 int new_active
= XGET(main_page_list
,MUIA_List_Active
);
170 if (new_active
== -1)
171 new_group
= main_page_space
;
174 new_group
= main_page_entries
[new_active
].group
;
176 new_group
= main_page_space
;
179 if (new_group
== main_page_group_displayed
)
182 DoMethod(main_page_group
, MUIM_Group_InitChange
);
183 DoMethod(main_page_group
, OM_REMMEMBER
, (IPTR
)main_page_group_displayed
);
184 DoMethod(main_page_group
, OM_ADDMEMBER
, (IPTR
)new_group
);
185 DoMethod(main_page_group
, MUIM_Group_ExitChange
);
186 main_page_group_displayed
= new_group
;
189 /****************************************************************
191 *****************************************************************/
192 void main_save_pressed(void)
194 save_prefs(appname
, TRUE
);
195 DoMethod(app
, MUIM_Application_ReturnID
, MUIV_Application_ReturnID_Quit
);
198 /****************************************************************
200 *****************************************************************/
201 void main_use_pressed(void)
203 save_prefs(appname
, FALSE
);
204 DoMethod(app
, MUIM_Application_ReturnID
, MUIV_Application_ReturnID_Quit
);
207 /****************************************************************
209 *****************************************************************/
210 void main_test_pressed(void)
215 /****************************************************************
217 *****************************************************************/
218 void main_cancel_pressed(void)
220 restore_prefs(appname
);
221 DoMethod(app
, MUIM_Application_ReturnID
, MUIV_Application_ReturnID_Quit
);
224 /****************************************************************
226 *****************************************************************/
229 static CONST_STRPTR
const searchpaths
[] =
232 "Classes/Zune/#?.(mcp|mcc)",
236 CONST_STRPTR
const *pathptr
;
237 struct DevProc
*dp
= NULL
;
238 struct page_entry
*pe
;
239 WORD num_page_entries
= 0;
242 for(pe
= main_page_entries
; pe
->name
; pe
++)
247 olddir
= CurrentDir(BNULL
);
249 while((dp
= GetDeviceProc("LIBS:", dp
)))
251 CurrentDir(dp
->dvp_Lock
);
253 for(pathptr
= searchpaths
; *pathptr
; pathptr
++)
255 struct AnchorPath
*ap
;
258 ap
= (struct AnchorPath
*)AllocVec(sizeof(struct AnchorPath
) + 256, MEMF_CLEAR
);
263 for(match
= MatchFirst((STRPTR
)*pathptr
, ap
);
265 match
= MatchNext(ap
))
267 struct Library
*mcclib
;
269 if (num_page_entries
< MAX_PAGE_ENTRIES
)
271 if ((mcclib
= OpenLibrary(ap
->ap_Buf
, 0)))
273 struct MUI_CustomClass
*mcp
;
275 if ((mcp
= MCC_Query(1)))
280 pe
->mcp_library
= mcclib
;
281 pe
->mcp_icon
= (Object
*)MCC_Query(2); /* Get MCP image */
282 D(bug("[Zune Prefs/find_mcps] image %p\n", pe
->mcp_icon
));
286 strncpy(pe
->mcp_namebuffer
, mcp
->mcc_Class
->cl_ID
, sizeof(pe
->mcp_namebuffer
) - 1);
288 if ((sp
= strrchr(pe
->mcp_namebuffer
, '.')))
291 pe
->name
= pe
->mcp_namebuffer
;
296 } /* if ((mcp = MCC_Query(1))) */
298 if (mcclib
) CloseLibrary(mcclib
);
300 } /* if ((mcclib = OpenLibrary(ap->ap_Buf, 0))) */
302 } /* if (num_page_entries < MAX_PAGE_ENTRIES) */
304 } /* for(match = ... */
312 } /* for(pathptr = searchpaths; *pathptr; pathptr++) */
314 if (!(dp
->dvp_Flags
& DVPF_ASSIGN
)) break;
316 } /* while((dp = GetDeviceProc("LIBS:", dp))) */
323 /****************************************************************
324 Deallocates all gui resources
325 *****************************************************************/
326 void deinit_gui(void)
331 MUI_DisposeObject(app
);
333 for (i
= 0; main_page_entries
[i
].name
; i
++)
335 if ((main_page_entries
[i
].group
!= NULL
) &&
336 (main_page_entries
[i
].group
!= main_page_group_displayed
))
338 DisposeObject(main_page_entries
[i
].group
);
341 if (main_page_entries
[i
].mcp_library
)
343 main_page_entries
[i
].cl
= NULL
; /* Prevent MUI_DeleteCustomClass call below */
345 if ((main_page_entries
[i
].group
== NULL
) ||
346 (main_page_entries
[i
].group
!= main_page_group_displayed
))
348 /* Only close library if main_page_group_displayed is not this page,
349 because in that case the object got automatically killed through
350 MUI_DisposeObject(app) which also does the CloseLibrary()!! */
352 CloseLibrary(main_page_entries
[i
].mcp_library
);
353 main_page_entries
[i
].mcp_library
= NULL
;
357 main_page_entries
[i
].group
= NULL
;
359 if (main_page_entries
[i
].cl
!= NULL
)
361 MUI_DeleteCustomClass(main_page_entries
[i
].cl
);
362 main_page_entries
[i
].cl
= NULL
;
364 /* Dispose the icons which were created by MUI_Query for extenal classes
365 and xxxclass_get_icon() for internal classes */
366 DisposeObject(main_page_entries
[i
].mcp_icon
);
369 if (main_page_group_displayed
!= main_page_space
)
370 MUI_DisposeObject(main_page_space
);
373 /****************************************************************
374 Allocate resources for gui
375 *****************************************************************/
381 Object
*cancel_button
;
385 main_page_entries
[ 0].name
= (char *)_(MSG_DSC_SYSTEM
);
386 main_page_entries
[ 0].mcp_icon
= systemclass_get_icon();
387 main_page_entries
[ 1].name
= (char *)_(MSG_DSC_WINDOWS
);
388 main_page_entries
[ 1].mcp_icon
= windowsclass_get_icon();
389 main_page_entries
[ 2].name
= (char *)_(MSG_DSC_GROUPS
);
390 main_page_entries
[ 2].mcp_icon
= groupsclass_get_icon();
391 main_page_entries
[ 3].name
= (char *)_(MSG_DSC_BUTTONS
);
392 main_page_entries
[ 3].mcp_icon
= buttonsclass_get_icon();
393 main_page_entries
[ 4].name
= (char *)_(MSG_DSC_CYCLES
);
394 main_page_entries
[ 4].mcp_icon
= cyclesclass_get_icon();
395 main_page_entries
[ 5].name
= (char *)_(MSG_DSC_SLIDERS
);
396 main_page_entries
[ 5].mcp_icon
= slidersclass_get_icon();
397 main_page_entries
[ 6].name
= (char *)_(MSG_DSC_SCROLLBARS
);
398 main_page_entries
[ 6].mcp_icon
= scrollbarsclass_get_icon();
399 main_page_entries
[ 7].name
= (char *)_(MSG_DSC_LISTVIEWS
);
400 main_page_entries
[ 7].mcp_icon
= listviewsclass_get_icon();
401 main_page_entries
[ 8].name
= (char *)_(MSG_DSC_STRINGS
);
402 main_page_entries
[ 8].mcp_icon
= stringsclass_get_icon();
403 main_page_entries
[ 9].name
= (char *)_(MSG_DSC_NAVIGATION
);
404 main_page_entries
[ 9].mcp_icon
= navigationclass_get_icon();
405 main_page_entries
[10].name
= (char *)_(MSG_DSC_SPECIAL
);
406 main_page_entries
[10].mcp_icon
= specialclass_get_icon();
407 main_page_entries
[11].name
= (char *)_(MSG_DSC_FRAMES
);
408 main_page_entries
[11].mcp_icon
= framesclass_get_icon();
410 main_cancel_pressed_hook
.h_Entry
= HookEntry
;
411 main_cancel_pressed_hook
.h_SubEntry
= (HOOKFUNC
)main_cancel_pressed
;
413 main_save_pressed_hook
.h_Entry
= HookEntry
;
414 main_save_pressed_hook
.h_SubEntry
= (HOOKFUNC
)main_save_pressed
;
416 main_use_pressed_hook
.h_Entry
= HookEntry
;
417 main_use_pressed_hook
.h_SubEntry
= (HOOKFUNC
)main_use_pressed
;
419 main_test_pressed_hook
.h_Entry
= HookEntry
;
420 main_test_pressed_hook
.h_SubEntry
= (HOOKFUNC
)main_test_pressed
;
422 main_open_menu_hook
.h_Entry
= HookEntry
;
423 main_open_menu_hook
.h_SubEntry
= (HOOKFUNC
)main_open_menu
;
425 main_saveas_menu_hook
.h_Entry
= HookEntry
;
426 main_saveas_menu_hook
.h_SubEntry
= (HOOKFUNC
)main_saveas_menu
;
428 main_page_active_hook
.h_Entry
= HookEntry
;
429 main_page_active_hook
.h_SubEntry
= (HOOKFUNC
)main_page_active
;
431 page_display_hook
.h_Entry
= HookEntry
;
432 page_display_hook
.h_SubEntry
= (APTR
)main_page_list_display
;
434 if (!strcmp(appname
, "global"))
435 wintitle
= (STRPTR
) _(MSG_WINTITLE1
);
438 snprintf(titlebuf
, 255, _(MSG_WINTITLE2
), appname
);
442 app
= ApplicationObject
,
443 MUIA_Application_Title
, (IPTR
) "Zune",
444 MUIA_Application_Version
, (IPTR
) ZUNEVERSION
,
445 MUIA_Application_Copyright
, (IPTR
) " 2006, The AROS Development Team",
446 MUIA_Application_Description
, wintitle
,
447 MUIA_Application_Base
, "ZUNEPREF",
448 MUIA_Application_Menustrip
, MenustripObject
,
449 MUIA_Family_Child
, MenuObject
,
450 MUIA_Menu_Title
, _(MSG_MEN_PROJECT
),
451 MUIA_Family_Child
, open_menuitem
= MenuitemObject
,
452 MUIA_Menuitem_Title
, _(MSG_MEN_OPEN
), MUIA_Menuitem_Shortcut
, _(MSG_MEN_OPEN_SC
),
454 MUIA_Family_Child
, append_menuitem
= MenuitemObject
, MUIA_Menuitem_Title
, _(MSG_MEN_APPEND
), End
,
455 MUIA_Family_Child
, saveas_menuitem
= MenuitemObject
,
456 MUIA_Menuitem_Title
, _(MSG_MEN_SAVEAS
), MUIA_Menuitem_Shortcut
, _(MSG_MEN_SAVEAS_SC
),
458 MUIA_Family_Child
, MenuitemObject
, MUIA_Menuitem_Title
, NM_BARLABEL
, End
,
459 MUIA_Family_Child
, aboutzune_menuitem
= MenuitemObject
,
460 MUIA_Menuitem_Title
, _(MSG_MEN_ABOUT
), MUIA_Menuitem_Shortcut
, _(MSG_MEN_ABOUT_SC
),
462 MUIA_Family_Child
, MenuitemObject
, MUIA_Menuitem_Title
, NM_BARLABEL
, End
,
463 MUIA_Family_Child
, quit_menuitem
= MenuitemObject
,
464 MUIA_Menuitem_Title
, _(MSG_MEN_QUIT
), MUIA_Menuitem_Shortcut
, _(MSG_MEN_QUIT_SC
),
468 SubWindow
, main_wnd
= WindowObject
,
469 MUIA_Window_Title
, (IPTR
)wintitle
,
470 MUIA_Window_Activate
, TRUE
,
471 MUIA_Window_CloseGadget
, FALSE
,
472 MUIA_Window_ID
, MAKE_ID('Z','W','I','N'),
474 WindowContents
, VGroup
,
475 MUIA_Group_VertSpacing
, 10,
478 Child
, (NewObject(ClassListview_CLASS
->mcc_Class
, NULL
,
480 MUIA_Listview_List
, main_page_list
= ListObject
,
482 MUIA_List_AdjustWidth
, TRUE
,
483 MUIA_List_Format
, ",",
484 MUIA_List_DisplayHook
, &page_display_hook
,
488 Child
, MUI_NewObject(MUIC_Popframe
,
490 MUIA_Window_Title
, (IPTR
) _(MSG_FRAME_CLIPBOARD
),
492 Child
, MUI_NewObject(MUIC_Popimage
,
494 MUIA_Imageadjust_Type
, MUIV_Imageadjust_Type_All
,
495 MUIA_Window_Title
, (IPTR
) _(MSG_IMAGE_CLIPBOARD
),
502 MUIA_Background
, MUII_PageBack
,
503 Child
, main_page_group
= VGroup
,
504 Child
, main_page_group_displayed
= main_page_space
= HVSpace
,
509 Child
, test_button
= ImageButton(_(MSG_GAD_TEST
), "THEME:Images/Gadgets/Test"),
511 Child
, save_button
= ImageButton(_(MSG_GAD_SAVE
), "THEME:Images/Gadgets/Save"),
512 Child
, use_button
= ImageButton(_(MSG_GAD_USE
), "THEME:Images/Gadgets/Use"),
513 Child
, cancel_button
= ImageButton(_(MSG_GAD_CANCEL
), "THEME:Images/Gadgets/Cancel"),
523 DoMethod(main_wnd
, MUIM_Notify
, MUIA_Window_CloseRequest
, TRUE
,
524 (IPTR
)app
, 2, MUIM_CallHook
, (IPTR
)&main_cancel_pressed_hook
);
525 DoMethod(cancel_button
, MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)app
, 2,
526 MUIM_CallHook
, (IPTR
)&main_cancel_pressed_hook
);
527 DoMethod(save_button
, MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)app
, 2,
528 MUIM_CallHook
, (IPTR
)&main_save_pressed_hook
);
529 DoMethod(use_button
, MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)app
, 2,
530 MUIM_CallHook
, (IPTR
)&main_use_pressed_hook
);
531 DoMethod(test_button
, MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)app
, 5,
532 MUIM_Application_PushMethod
, (IPTR
)app
, 2, MUIM_CallHook
,
533 (IPTR
)&main_test_pressed_hook
);
534 DoMethod(quit_menuitem
, MUIM_Notify
, MUIA_Menuitem_Trigger
,
535 MUIV_EveryTime
, (IPTR
)app
, 2, MUIM_CallHook
,
536 (IPTR
)&main_cancel_pressed_hook
);
537 DoMethod(open_menuitem
, MUIM_Notify
, MUIA_Menuitem_Trigger
,
538 MUIV_EveryTime
, (IPTR
)app
, 2, MUIM_CallHook
,
539 (IPTR
)&main_open_menu_hook
);
540 DoMethod(saveas_menuitem
, MUIM_Notify
, MUIA_Menuitem_Trigger
,
541 MUIV_EveryTime
, (IPTR
)app
, 2, MUIM_CallHook
,
542 (IPTR
)&main_saveas_menu_hook
);
543 DoMethod(aboutzune_menuitem
, MUIM_Notify
, MUIA_Menuitem_Trigger
,
544 MUIV_EveryTime
, (IPTR
)app
, 2, MUIM_Application_AboutMUI
,
547 for (i
= 0; main_page_entries
[i
].name
!= NULL
; i
++)
549 struct page_entry
*p
= &main_page_entries
[i
];
551 if (!p
->cl
) p
->cl
= create_class(p
->desc
);
553 if (!(p
->cl
&& (p
->group
= NewObject(p
->cl
->mcc_Class
, NULL
, TAG_DONE
))))
559 DoMethod(main_page_list
, MUIM_List_InsertSingle
, (IPTR
)p
,
560 MUIV_List_Insert_Bottom
);
563 DoMethod(main_page_list
, MUIM_Notify
, MUIA_List_Active
, MUIV_EveryTime
,
564 (IPTR
)app
, 3, MUIM_CallHook
, (IPTR
)&main_page_active_hook
);
566 /* Activate first entry */
567 set(main_page_list
,MUIA_List_Active
,0);
574 /****************************************************************
576 *****************************************************************/
577 void load_prefs(CONST_STRPTR name
)
581 configdata
= MUI_NewObject(MUIC_Configdata
,
582 MUIA_Configdata_ApplicationBase
, (IPTR
)name
,
584 if (configdata
!= NULL
)
588 /* D(bug("zune::load_prefs: created configdata %p\n", configdata)); */
589 LastSavedConfigdata
= configdata
;
591 /* Call MUIM_Settingsgroup_ConfigToGadgets for every group */
592 for (i
=0;main_page_entries
[i
].name
;i
++)
594 struct page_entry
*p
= &main_page_entries
[i
];
596 DoMethod(p
->group
, MUIM_Settingsgroup_ConfigToGadgets
,
600 /* D(bug("zune::save_prefs: disposed configdata %p\n", configdata)); */
604 /* write prefs to env: */
605 void test_prefs(void)
609 save_prefs(appname
, FALSE
);
611 cfg
= MUI_NewObject(MUIC_Configdata
, MUIA_Configdata_Application
, (IPTR
)app
, TAG_DONE
);
612 set(app
, MUIA_Application_Configdata
, (IPTR
)cfg
);
615 void restore_prefs(CONST_STRPTR name
)
619 snprintf(buf
, 255, "ENV:zune/%s.prefs", name
);
620 DoMethod(LastSavedConfigdata
, MUIM_Configdata_Save
, (IPTR
)buf
);
624 /****************************************************************
625 open given prefs file from menue
626 *****************************************************************/
628 void main_open_menu(void)
630 static char dirpart
[500]="ENVARC:Zune",filepart
[500],filename
[1000];
632 if (aslfilerequest ("Load a Zune Prefs File", (char *)&dirpart
, (char *)&filepart
, (char *)&filename
, prefstags
))
636 configdata
= MUI_NewObject(MUIC_Configdata
,
637 MUIA_Configdata_ApplicationBase
,appname
,
640 if (configdata
!= NULL
)
644 /* D(bug("zune::load_prefs: created configdata %p\n", configdata)); */
645 //LastSavedConfigdata = configdata;
646 DoMethod(configdata
, MUIM_Configdata_Load
,filename
);
648 /* Call MUIM_Settingsgroup_ConfigToGadgets for every group */
649 for (i
=0;main_page_entries
[i
].name
;i
++)
651 struct page_entry
*p
= &main_page_entries
[i
];
653 if (p
->group
) DoMethod(p
->group
, MUIM_Settingsgroup_ConfigToGadgets
, (IPTR
)configdata
);
656 /* activate prefs in test mode */
659 /* D(bug("zune::save_prefs: disposed configdata %p\n", configdata)); */
665 /****************************************************************
667 *****************************************************************/
668 void save_prefs(CONST_STRPTR name
, BOOL envarc
)
672 configdata
= MUI_NewObject(MUIC_Configdata
,
673 //MUIA_Configdata_ApplicationBase, name,
674 MUIA_Configdata_Application
,appaddr
,
676 if (configdata
!= NULL
)
681 /* D(bug("zune::save_prefs: created configdata %p\n", configdata)); */
683 /* Call MUIM_Settingsgroup_GadgetsToConfig for every group */
684 for (i
=0;main_page_entries
[i
].name
;i
++)
686 struct page_entry
*p
= &main_page_entries
[i
];
688 DoMethod(p
->group
, MUIM_Settingsgroup_GadgetsToConfig
,
694 snprintf(buf
, 255, "ENVARC:zune/%s.prefs", name
);
695 DoMethod(configdata
, MUIM_Configdata_Save
, (IPTR
)buf
);
697 snprintf(buf
, 255, "ENV:zune/%s.prefs", name
);
698 DoMethod(configdata
, MUIM_Configdata_Save
, (IPTR
)buf
);
700 MUI_DisposeObject(configdata
);
701 /* D(bug("zune::save_prefs: disposed configdata %p\n", configdata)); */
706 /****************************************************************
707 SaveAS the done prefs from menu
708 *****************************************************************/
710 void main_saveas_menu(void)
712 static char dirpart
[500]="ENVARC:Zune",filepart
[500],filename
[1000];
714 if (aslfilerequest("Save a Zune Prefs File", (char *)&dirpart
, (char *)&filepart
, (char *)&filename
, prefstags
))
718 configdata
= MUI_NewObject(MUIC_Configdata
,
719 MUIA_Configdata_ApplicationBase
, "dummyfile",
722 /* check for ".prefs" suffix in filename, add if not existing */
723 if ( !strstr( filename
, ".prefs") ) strcat(filename
, ".prefs");
725 if (configdata
!= NULL
)
729 /* D(bug("zune::save_prefs: created configdata %p\n", configdata)); */
731 /* Call MUIM_Settingsgroup_GadgetsToConfig for every group */
732 for (i
=0;main_page_entries
[i
].name
;i
++)
734 struct page_entry
*p
= &main_page_entries
[i
];
736 if (p
->group
) DoMethod(p
->group
, MUIM_Settingsgroup_GadgetsToConfig
, (IPTR
)configdata
);
739 DoMethod(configdata
, MUIM_Configdata_Save
, filename
);
741 MUI_DisposeObject(configdata
);
742 /* D(bug("zune::save_prefs: disposed configdata %p\n", configdata)); */
750 /****************************************************************
752 *****************************************************************/
757 while((LONG
) DoMethod(app
, MUIM_Application_NewInput
, (IPTR
)&sigs
)
758 != MUIV_Application_ReturnID_Quit
)
762 sigs
= Wait(sigs
| SIGBREAKF_CTRL_C
| SIGBREAKF_CTRL_D
);
763 if (sigs
& SIGBREAKF_CTRL_C
) break;
764 if (sigs
& SIGBREAKF_CTRL_D
) break;
769 /****************************************************************
771 *****************************************************************/
775 BPTR OldDir
= BNULL
, NewDir
;
776 int retval
= RETURN_OK
;
777 struct RDArgs
*rda
= NULL
;
779 IPTR args
[] = { 0,0 };
780 enum { ARG_APPNAME
= 0,ARG_APPADDR
=1 };
786 rda
= ReadArgs("/A,/N", args
, NULL
);
787 appname
=(STRPTR
)args
[ARG_APPNAME
];
788 appaddr
=(APTR
)args
[ARG_APPADDR
];
789 if (appaddr
)appaddr
=*(appaddr
);
796 if (retval
== RETURN_OK
)
804 NewDir
= Lock("RAM:", SHARED_LOCK
);
806 OldDir
= CurrentDir(NewDir
);
809 load_prefs((STRPTR
)args
[ARG_APPNAME
]);
810 set(main_wnd
, MUIA_Window_Open
, TRUE
);
811 if (XGET(main_wnd
,MUIA_Window_Open
))
815 if (LastSavedConfigdata
)
816 MUI_DisposeObject(LastSavedConfigdata
);
827 if (rda
) FreeArgs(rda
);
829 Locale_Deinitialize();