2 Copyright © 2002-2014, The AROS Development Team. All rights reserved.
10 #include <exec/types.h>
11 #include <prefs/prefhdr.h>
12 #include <clib/alib_protos.h>
13 #include <proto/exec.h>
14 #include <proto/intuition.h>
15 #include <proto/utility.h>
16 #include <proto/iffparse.h>
17 #include <proto/dos.h>
18 #include <proto/commodities.h>
19 #include <proto/muimaster.h>
21 /* #define MYDEBUG 1 */
24 #include "muimaster_intern.h"
30 extern struct Library
*MUIMasterBase
;
32 struct MUI_ConfigdataData
36 struct ZunePrefsNew prefs
;
40 static CONST_STRPTR
GetConfigString(Object
*obj
, ULONG id
)
42 return (CONST_STRPTR
) DoMethod(obj
, MUIM_Configdata_GetString
, id
);
45 static ULONG
GetConfigULong(Object
*obj
, ULONG id
)
47 return (ULONG
) DoMethod(obj
, MUIM_Configdata_GetULong
, id
);
51 /**************************************************************************
52 Default ImageSpec values
53 **************************************************************************/
62 const static struct spec_cfg DefImspecValues
[] =
64 { MUII_WindowBack
, MUICFG_Background_Window
, "0:128" },
65 { MUII_RequesterBack
, MUICFG_Background_Requester
, "0:137" },
66 { MUII_ButtonBack
, MUICFG_Background_Button
, "0:128" },
67 { MUII_ListBack
, MUICFG_Background_List
, "0:128" },
68 { MUII_TextBack
, MUICFG_Background_Text
, "0:128" },
69 { MUII_PropBack
, MUICFG_Background_Prop
, "0:128" },
70 { MUII_PopupBack
, MUICFG_Background_PopUp
, "0:128" },
71 { MUII_SelectedBack
, MUICFG_Background_Selected
, "0:131" },
72 { MUII_ListCursor
, MUICFG_Background_ListCursor
, "0:131" },
73 { MUII_ListSelect
, MUICFG_Background_ListSelect
, "0:135" },
74 { MUII_ListSelCur
, MUICFG_Background_ListSelCur
, "0:138" },
75 { MUII_ArrowUp
, MUICFG_Image_ArrowUp
, "1:0" },
76 { MUII_ArrowDown
, MUICFG_Image_ArrowDown
, "1:1" },
77 { MUII_ArrowLeft
, MUICFG_Image_ArrowLeft
, "1:2" },
78 { MUII_ArrowRight
, MUICFG_Image_ArrowRight
, "1:3" },
79 { MUII_CheckMark
, MUICFG_Image_CheckMark
, "1:4" },
80 { MUII_RadioButton
, MUICFG_Image_RadioButton
, "1:5" },
81 { MUII_Cycle
, MUICFG_Image_Cycle
, "1:6" },
82 { MUII_PopUp
, MUICFG_Image_PopUp
, "1:7" },
83 { MUII_PopFile
, MUICFG_Image_PopFile
, "1:8" },
84 { MUII_PopDrawer
, MUICFG_Image_PopDrawer
, "1:9" },
85 { MUII_PropKnob
, MUICFG_Image_PropKnob
, "0:129" },
86 { MUII_Drawer
, MUICFG_Image_Drawer
, "1:10" },
87 { MUII_HardDisk
, MUICFG_Image_HardDisk
, "1:11" },
88 { MUII_Disk
, MUICFG_Image_Disk
, "1:12" },
89 { MUII_Chip
, MUICFG_Image_Chip
, "1:13" },
90 { MUII_Volume
, MUICFG_Image_Volume
, "1:14" },
91 { MUII_RegisterBack
, MUICFG_Background_Register
, "0:128" },
92 { MUII_Network
, MUICFG_Image_Network
, "1:15" },
93 { MUII_Assign
, MUICFG_Image_Assign
, "1:16" },
94 { MUII_TapePlay
, MUICFG_Image_TapePlay
, "1:17" },
95 { MUII_TapePlayBack
, MUICFG_Image_TapePlayBack
, "1:18" },
96 { MUII_TapePause
, MUICFG_Image_TapePause
, "1:19" },
97 { MUII_TapeStop
, MUICFG_Image_TapeStop
, "1:20" },
98 { MUII_TapeRecord
, MUICFG_Image_TapeRecord
, "1:21" },
99 { MUII_GroupBack
, MUICFG_Background_Framed
, "0:128" },
100 { MUII_SliderBack
, MUICFG_Background_Slider
, "0:128" },
101 { MUII_SliderKnob
, MUICFG_Background_SliderKnob
, "0:128" },
102 { MUII_TapeUp
, MUICFG_Image_TapeUp
, "1:22" },
103 { MUII_TapeDown
, MUICFG_Image_TapeDown
, "1:23" },
104 { MUII_PageBack
, MUICFG_Background_Page
, "0:128" },
105 { MUII_ReadListBack
, MUICFG_Background_ReadList
, "0:128" },
109 /* called by Configdata_New */
110 static void init_imspecs(Object
*obj
, struct MUI_ConfigdataData
*data
)
114 for (i
= 0; DefImspecValues
[i
].defspec
; i
++)
117 const struct spec_cfg
*img
= DefImspecValues
+ i
;
119 imspec
= GetConfigString(obj
, img
->cfgid
);
120 /* D(bug("init_imspecs: %ld %lx %s ...\n", img->muiv, img->cfgid, imspec)); */
121 data
->prefs
.imagespecs
[img
->muiv
] = imspec
;
122 if (!data
->prefs
.imagespecs
[img
->muiv
])
124 /* D(bug("*** init_imspecs: null imagespec %ld\n", img->muiv)); */
129 /**************************************************************************
130 Default FrameSpec values
131 **************************************************************************/
133 /* spec format : type, recessed, left, right, up, down spacing */
134 const static struct spec_cfg DefFramespecValues
[] =
136 { MUIV_Frame_None
, MUICFG_Invalid
, "000000" }, /* invisible frame */
137 { MUIV_Frame_Button
, MUICFG_Frame_Button
, "202211" }, /* text button */
138 { MUIV_Frame_ImageButton
, MUICFG_Frame_ImageButton
, "202211" }, /* image button */
139 { MUIV_Frame_Text
, MUICFG_Frame_Text
, "212211" }, /* textfield without input */
140 { MUIV_Frame_String
, MUICFG_Frame_String
, "302211" }, /* string gadget */
141 { MUIV_Frame_ReadList
, MUICFG_Frame_ReadList
, "212211" }, /* list without input */
142 { MUIV_Frame_InputList
, MUICFG_Frame_InputList
, "202211" }, /* list with input */
143 { MUIV_Frame_Prop
, MUICFG_Frame_Prop
, "202211" }, /* scrollbar container */
144 { MUIV_Frame_Gauge
, MUICFG_Frame_Gauge
, "210000" }, /* gauge */
145 { MUIV_Frame_Group
, MUICFG_Frame_Group
, "314444" }, /* normal group */
146 { MUIV_Frame_PopUp
, MUICFG_Frame_PopUp
, "112211" }, /* cycle menu, popup window */
147 { MUIV_Frame_Virtual
, MUICFG_Frame_Virtual
, "212211" }, /* virt group */
148 { MUIV_Frame_Slider
, MUICFG_Frame_Slider
, "400000" }, /* slider container */
149 { MUIV_Frame_Knob
, MUICFG_Frame_Knob
, "202211" }, /* slider knob */
150 { MUIV_Frame_Drag
, MUICFG_Frame_Drag
, "300000" }, /* dnd frame */
154 /* called by Configdata_New */
155 static void init_framespecs(Object
*obj
, struct MUI_ConfigdataData
*data
)
159 for (i
= 0; DefFramespecValues
[i
].defspec
; i
++)
161 CONST_STRPTR framespec
;
162 const struct spec_cfg
*fcfg
= DefFramespecValues
+ i
;
164 framespec
= GetConfigString(obj
, fcfg
->cfgid
);
165 zune_frame_spec_to_intern(framespec
,
166 &data
->prefs
.frames
[fcfg
->muiv
]);
170 /**************************************************************************
172 **************************************************************************/
180 const static struct def_ulval DefULValues
[] = {
181 {MUICFG_Window_Spacing_Left
, 4},
182 {MUICFG_Window_Spacing_Right
, 4},
183 {MUICFG_Window_Spacing_Top
, 3},
184 {MUICFG_Window_Buttons
, 0},
185 {MUICFG_Window_Spacing_Bottom
, 3},
186 {MUICFG_Window_Positions
, WINDOW_POSITION_FORGET_ON_EXIT
},
187 {MUICFG_Window_Redraw
, WINDOW_REDRAW_WITHOUT_CLEAR
},
188 {MUICFG_Window_Refresh
, WINDOW_REFRESH_SIMPLE
},
189 {MUICFG_Radio_HSpacing
, 4},
190 {MUICFG_Radio_VSpacing
, 1},
191 {MUICFG_Group_HSpacing
, 6},
192 {MUICFG_Group_VSpacing
, 3},
193 {MUICFG_Cycle_MenuCtrl_Position
, CYCLE_MENU_POSITION_BELOW
},
194 {MUICFG_Cycle_MenuCtrl_Level
, 2},
195 {MUICFG_Cycle_MenuCtrl_Speed
, 0},
196 {MUICFG_Cycle_Menu_Recessed
, FALSE
},
197 {MUICFG_Listview_Font_Leading
, 1},
198 {MUICFG_Listview_Smoothed
, FALSE
},
199 {MUICFG_Listview_SmoothVal
, 0},
200 {MUICFG_Listview_Refresh
, LISTVIEW_REFRESH_MIXED
},
201 {MUICFG_Listview_Multi
, LISTVIEW_MULTI_SHIFTED
},
202 {MUICFG_GroupTitle_Position
, GROUP_TITLE_POSITION_CENTERED
},
203 {MUICFG_GroupTitle_Color
, GROUP_TITLE_COLOR_HILITE
},
204 {MUICFG_Scrollbar_Type
, SCROLLBAR_TYPE_STANDARD
},
205 {MUICFG_Scrollbar_Arrangement
, SCROLLBAR_ARRANGEMENT_TOP
},
206 {MUICFG_Balance_Look
, BALANCING_SHOW_FRAMES
},
207 {MUICFG_Dragndrop_Look
, DND_LOOK_GHOSTED_ON_BOX
},
208 {MUICFG_Drag_Autostart
, TRUE
},
209 {MUICFG_Drag_Autostart_Length
, 3},
210 {MUICFG_Drag_LeftButton
, TRUE
},
211 {MUICFG_Drag_MiddleButton
, FALSE
},
212 {MUICFG_Register_TruncateTitles
, FALSE
},
213 {MUICFG_Screen_Mode
, 0},
214 {MUICFG_Screen_Mode_ID
, -1},
215 {MUICFG_Screen_Width
, 0},
216 {MUICFG_Screen_Height
, 0},
217 {MUICFG_PublicScreen_PopToFront
, TRUE
},
218 {MUICFG_Iconification_ShowIcon
, TRUE
},
219 {MUICFG_Iconification_ShowMenu
, FALSE
},
220 {MUICFG_Iconification_OnStartup
, FALSE
},
221 {MUICFG_Interfaces_EnableARexx
, TRUE
},
222 {MUICFG_BubbleHelp_FirstDelay
, 30},
223 {MUICFG_BubbleHelp_NextDelay
, 10},
227 /**************************************************************************
228 Default string values
229 **************************************************************************/
237 /* NULL values not allowed */
238 const static struct def_strval DefStrValues
[] = {
239 {MUICFG_Font_Normal
, ""},
240 {MUICFG_Font_List
, ""},
241 {MUICFG_Font_Tiny
, ""},
242 {MUICFG_Font_Fixed
, ""},
243 {MUICFG_Font_Title
, ""},
244 {MUICFG_Font_Big
, ""},
245 {MUICFG_Font_Button
, ""},
246 {MUICFG_Font_Knob
, ""},
247 {MUICFG_String_Background
, "2:m2"},
248 {MUICFG_String_Text
, "m5"},
249 {MUICFG_String_ActiveBackground
, "2:m1"},
250 {MUICFG_String_ActiveText
, "m5"},
251 {MUICFG_String_Cursor
, "m7"},
252 {MUICFG_String_MarkedBackground
, "m6"},
253 {MUICFG_String_MarkedText
, "m0"},
254 {MUICFG_ActiveObject_Color
, "m0"},
255 {MUICFG_Keyboard_Press
, "-upstroke return"},
256 {MUICFG_Keyboard_Toggle
, "-repeat space"},
257 {MUICFG_Keyboard_Up
, "-repeat up"},
258 {MUICFG_Keyboard_Down
, "-repeat down"},
259 {MUICFG_Keyboard_PageUp
, "-repeat shift up"},
260 {MUICFG_Keyboard_PageDown
, "-repeat shift down"},
261 {MUICFG_Keyboard_Top
, "control up"},
262 {MUICFG_Keyboard_Bottom
, "control down"},
263 {MUICFG_Keyboard_Left
, "-repeat left"},
264 {MUICFG_Keyboard_Right
, "-repeat right"},
265 {MUICFG_Keyboard_WordLeft
, "-repeat control left"},
266 {MUICFG_Keyboard_WordRight
, "-repeat control right"},
267 {MUICFG_Keyboard_LineStart
, "shift left"},
268 {MUICFG_Keyboard_LineEnd
, "shift right"},
269 {MUICFG_Keyboard_NextGadget
, "-repeat tab"},
270 {MUICFG_Keyboard_PrevGadget
, "-repeat shift tab"},
271 {MUICFG_Keyboard_GadgetOff
, "control tab"},
272 {MUICFG_Keyboard_CloseWindow
, "esc"},
273 {MUICFG_Keyboard_NextWindow
, "-repeat alt tab"},
274 {MUICFG_Keyboard_PrevWindow
, "-repeat alt shift tab"},
275 {MUICFG_Keyboard_Help
, "help"},
276 {MUICFG_Keyboard_Popup
, "control p"},
277 {MUICFG_Drag_LMBModifier
, "control"},
278 {MUICFG_Drag_MMBModifier
, ""},
279 {MUICFG_PublicScreen
, ""},
280 {MUICFG_Iconification_Hotkey
, ""},
285 /**************************************************************************
287 Load global (and maybe application-specific) prefs files into the dataspace,
288 then fill the prefs struct with dataspace or default values
289 **************************************************************************/
290 IPTR
Configdata__OM_NEW(struct IClass
*cl
, Object
*obj
, struct opSet
*msg
)
292 struct MUI_ConfigdataData
*data
;
293 struct TagItem
*tags
;
298 obj
= (Object
*) DoSuperMethodA(cl
, obj
, (Msg
) msg
);
302 /* D(bug("Configdata_New(%p)\n", obj)); */
304 data
= INST_DATA(cl
, obj
);
306 for (tags
= msg
->ops_AttrList
; (tag
= NextTagItem(&tags
));)
310 case MUIA_Configdata_Application
:
311 data
->app
= (Object
*) tag
->ti_Data
;
313 case MUIA_Configdata_ApplicationBase
:
314 data
->appbase
= (CONST_STRPTR
) tag
->ti_Data
;
319 if (data
->app
&& !data
->appbase
)
321 get(data
->app
, MUIA_Application_Base
, &data
->appbase
);
327 snprintf(filename
, 255, "ENV:zune/%s.prefs", data
->appbase
);
328 res
= DoMethod(obj
, MUIM_Configdata_Load
, (IPTR
) filename
);
331 snprintf(filename
, 255, "ENVARC:zune/%s.prefs", data
->appbase
);
332 res
= DoMethod(obj
, MUIM_Configdata_Load
, (IPTR
) filename
);
336 // load only global prefs if no local app pref is found
339 if (!DoMethod(obj
, MUIM_Configdata_Load
,
340 (IPTR
) "ENV:zune/global.prefs"))
342 DoMethod(obj
, MUIM_Configdata_Load
,
343 (IPTR
) "ENVARC:zune/global.prefs");
346 /*---------- fonts stuff ----------*/
348 data
->prefs
.fonts
[-MUIV_Font_Normal
] =
349 GetConfigString(obj
, MUICFG_Font_Normal
);
350 data
->prefs
.fonts
[-MUIV_Font_List
] =
351 GetConfigString(obj
, MUICFG_Font_List
);
352 data
->prefs
.fonts
[-MUIV_Font_Tiny
] =
353 GetConfigString(obj
, MUICFG_Font_Tiny
);
354 data
->prefs
.fonts
[-MUIV_Font_Fixed
] =
355 GetConfigString(obj
, MUICFG_Font_Fixed
);
356 data
->prefs
.fonts
[-MUIV_Font_Title
] =
357 GetConfigString(obj
, MUICFG_Font_Title
);
358 data
->prefs
.fonts
[-MUIV_Font_Big
] =
359 GetConfigString(obj
, MUICFG_Font_Big
);
360 data
->prefs
.fonts
[-MUIV_Font_Button
] =
361 GetConfigString(obj
, MUICFG_Font_Button
);
362 data
->prefs
.fonts
[-MUIV_Font_Knob
] =
363 GetConfigString(obj
, MUICFG_Font_Knob
);
365 /*---------- images stuff ----------*/
367 init_imspecs(obj
, data
);
369 /*---------- frame stuff ----------*/
371 init_framespecs(obj
, data
);
373 /*---------- system stuff ----------*/
375 data
->prefs
.publicscreen_name
=
376 GetConfigString(obj
, MUICFG_PublicScreen
);
377 data
->prefs
.publicscreen_pop_to_front
=
378 GetConfigULong(obj
, MUICFG_PublicScreen_PopToFront
);
379 data
->prefs
.iconification_hotkey
=
380 GetConfigString(obj
, MUICFG_Iconification_Hotkey
);
381 data
->prefs
.iconification_show_icon
=
382 GetConfigULong(obj
, MUICFG_Iconification_ShowIcon
);
383 data
->prefs
.iconification_show_menu
=
384 GetConfigULong(obj
, MUICFG_Iconification_ShowMenu
);
385 data
->prefs
.iconification_on_startup
=
386 GetConfigULong(obj
, MUICFG_Iconification_OnStartup
);
387 data
->prefs
.interfaces_enable_arexx
=
388 GetConfigULong(obj
, MUICFG_Interfaces_EnableARexx
);
389 data
->prefs
.bubblehelp_first_delay
=
390 GetConfigULong(obj
, MUICFG_BubbleHelp_FirstDelay
);
391 data
->prefs
.bubblehelp_next_delay
=
392 GetConfigULong(obj
, MUICFG_BubbleHelp_NextDelay
);
394 /*---------- window stuff ----------*/
396 data
->prefs
.window_inner_left
=
397 GetConfigULong(obj
, MUICFG_Window_Spacing_Left
);
398 data
->prefs
.window_inner_right
=
399 GetConfigULong(obj
, MUICFG_Window_Spacing_Right
);
400 data
->prefs
.window_inner_top
=
401 GetConfigULong(obj
, MUICFG_Window_Spacing_Top
);
402 data
->prefs
.window_inner_bottom
=
403 GetConfigULong(obj
, MUICFG_Window_Spacing_Bottom
);
404 data
->prefs
.window_position
=
405 GetConfigULong(obj
, MUICFG_Window_Positions
);
406 data
->prefs
.window_redraw
= GetConfigULong(obj
, MUICFG_Window_Redraw
);
407 data
->prefs
.window_refresh
= GetConfigULong(obj
, MUICFG_Window_Refresh
);
408 data
->prefs
.screenmode
= GetConfigULong(obj
, MUICFG_Screen_Mode
);
409 data
->prefs
.screenmodeid
= GetConfigULong(obj
, MUICFG_Screen_Mode_ID
);
410 data
->prefs
.screen_width
= GetConfigULong(obj
, MUICFG_Screen_Width
);
411 data
->prefs
.screen_height
= GetConfigULong(obj
, MUICFG_Screen_Height
);
412 data
->prefs
.window_buttons
= GetConfigULong(obj
, MUICFG_Window_Buttons
);
414 /*---------- group stuff ----------*/
416 data
->prefs
.group_title_position
=
417 GetConfigULong(obj
, MUICFG_GroupTitle_Position
);
418 data
->prefs
.group_title_color
=
419 GetConfigULong(obj
, MUICFG_GroupTitle_Color
);
420 data
->prefs
.group_hspacing
= GetConfigULong(obj
, MUICFG_Group_HSpacing
);
421 data
->prefs
.group_vspacing
= GetConfigULong(obj
, MUICFG_Group_VSpacing
);
423 /*---------- registers ----------*/
425 data
->prefs
.register_look
= REGISTER_LOOK_TRADITIONAL
;
426 data
->prefs
.register_truncate_titles
=
427 GetConfigULong(obj
, MUICFG_Register_TruncateTitles
);
429 /*---------- Buttons ----------*/
431 data
->prefs
.radiobutton_hspacing
=
432 GetConfigULong(obj
, MUICFG_Radio_HSpacing
);
433 data
->prefs
.radiobutton_vspacing
=
434 GetConfigULong(obj
, MUICFG_Radio_VSpacing
);
436 /*---------- Cycles ----------*/
438 data
->prefs
.cycle_menu_position
=
439 GetConfigULong(obj
, MUICFG_Cycle_MenuCtrl_Position
);
440 data
->prefs
.cycle_menu_min_entries
=
441 GetConfigULong(obj
, MUICFG_Cycle_MenuCtrl_Level
);
442 data
->prefs
.cycle_menu_speed
=
443 GetConfigULong(obj
, MUICFG_Cycle_MenuCtrl_Speed
);
444 data
->prefs
.cycle_menu_recessed_entries
=
445 GetConfigULong(obj
, MUICFG_Cycle_Menu_Recessed
);
447 /*---------- Sliders ----------*/
448 /* all taken care of in frames and images */
450 /*---------- Scrollbars ----------*/
452 data
->prefs
.scrollbar_type
= GetConfigULong(obj
, MUICFG_Scrollbar_Type
);
453 data
->prefs
.scrollbar_arrangement
=
454 GetConfigULong(obj
, MUICFG_Scrollbar_Arrangement
);
456 /*---------- Lists ----------*/
458 data
->prefs
.list_linespacing
=
459 GetConfigULong(obj
, MUICFG_Listview_Font_Leading
);
460 data
->prefs
.list_smoothed
=
461 GetConfigULong(obj
, MUICFG_Listview_Smoothed
);
462 data
->prefs
.list_smoothval
=
463 GetConfigULong(obj
, MUICFG_Listview_SmoothVal
);
464 data
->prefs
.list_multi
= GetConfigULong(obj
, MUICFG_Listview_Multi
);
465 data
->prefs
.list_refresh
= GetConfigULong(obj
, MUICFG_Listview_Refresh
);
467 /*---------- Strings ----------*/
468 data
->prefs
.string_bg_inactive
=
469 GetConfigString(obj
, MUICFG_String_Background
);
470 data
->prefs
.string_text_inactive
=
471 GetConfigString(obj
, MUICFG_String_Text
);
472 data
->prefs
.string_bg_active
=
473 GetConfigString(obj
, MUICFG_String_ActiveBackground
);
474 data
->prefs
.string_text_active
=
475 GetConfigString(obj
, MUICFG_String_ActiveText
);
476 data
->prefs
.string_cursor
= GetConfigString(obj
, MUICFG_String_Cursor
);
477 data
->prefs
.string_bg_marked
=
478 GetConfigString(obj
, MUICFG_String_MarkedBackground
);
479 data
->prefs
.string_text_marked
=
480 GetConfigString(obj
, MUICFG_String_MarkedText
);
482 /*---------- Navigation ----------*/
484 data
->prefs
.drag_left_button
=
485 GetConfigULong(obj
, MUICFG_Drag_LeftButton
);
486 data
->prefs
.drag_left_modifier
.readable_hotkey
=
487 GetConfigString(obj
, MUICFG_Drag_LMBModifier
);
488 data
->prefs
.drag_middle_button
=
489 GetConfigULong(obj
, MUICFG_Drag_MiddleButton
);
490 data
->prefs
.drag_middle_modifier
.readable_hotkey
=
491 GetConfigString(obj
, MUICFG_Drag_MMBModifier
);
492 data
->prefs
.drag_autostart
= GetConfigULong(obj
, MUICFG_Drag_Autostart
);
493 data
->prefs
.drag_autostart_length
=
494 GetConfigULong(obj
, MUICFG_Drag_Autostart_Length
);
495 data
->prefs
.drag_look
= GetConfigULong(obj
, MUICFG_Dragndrop_Look
);
496 data
->prefs
.balancing_look
= GetConfigULong(obj
, MUICFG_Balance_Look
);
498 if (data
->prefs
.drag_left_modifier
.readable_hotkey
!= NULL
)
499 data
->prefs
.drag_left_modifier
.ix_well
=
500 !ParseIX(data
->prefs
.drag_left_modifier
.readable_hotkey
,
501 &data
->prefs
.drag_left_modifier
.ix
);
503 data
->prefs
.drag_left_modifier
.ix_well
= 0;
505 if (data
->prefs
.drag_middle_modifier
.readable_hotkey
!= NULL
)
506 data
->prefs
.drag_middle_modifier
.ix_well
=
507 !ParseIX(data
->prefs
.drag_middle_modifier
.readable_hotkey
,
508 &data
->prefs
.drag_middle_modifier
.ix
);
510 data
->prefs
.drag_middle_modifier
.ix_well
= 0;
512 data
->prefs
.active_object_color
=
513 GetConfigString(obj
, MUICFG_ActiveObject_Color
);
514 /*---------- mui keys ----------*/
516 data
->prefs
.muikeys
[MUIKEY_PRESS
].readable_hotkey
=
517 GetConfigString(obj
, MUICFG_Keyboard_Press
);
518 data
->prefs
.muikeys
[MUIKEY_TOGGLE
].readable_hotkey
=
519 GetConfigString(obj
, MUICFG_Keyboard_Toggle
);
520 data
->prefs
.muikeys
[MUIKEY_UP
].readable_hotkey
=
521 GetConfigString(obj
, MUICFG_Keyboard_Up
);
522 data
->prefs
.muikeys
[MUIKEY_DOWN
].readable_hotkey
=
523 GetConfigString(obj
, MUICFG_Keyboard_Down
);
524 data
->prefs
.muikeys
[MUIKEY_PAGEUP
].readable_hotkey
=
525 GetConfigString(obj
, MUICFG_Keyboard_PageUp
);
526 data
->prefs
.muikeys
[MUIKEY_PAGEDOWN
].readable_hotkey
=
527 GetConfigString(obj
, MUICFG_Keyboard_PageDown
);
528 data
->prefs
.muikeys
[MUIKEY_TOP
].readable_hotkey
=
529 GetConfigString(obj
, MUICFG_Keyboard_Top
);
530 data
->prefs
.muikeys
[MUIKEY_BOTTOM
].readable_hotkey
=
531 GetConfigString(obj
, MUICFG_Keyboard_Bottom
);
532 data
->prefs
.muikeys
[MUIKEY_LEFT
].readable_hotkey
=
533 GetConfigString(obj
, MUICFG_Keyboard_Left
);
534 data
->prefs
.muikeys
[MUIKEY_RIGHT
].readable_hotkey
=
535 GetConfigString(obj
, MUICFG_Keyboard_Right
);
536 data
->prefs
.muikeys
[MUIKEY_WORDLEFT
].readable_hotkey
=
537 GetConfigString(obj
, MUICFG_Keyboard_WordLeft
);
538 data
->prefs
.muikeys
[MUIKEY_WORDRIGHT
].readable_hotkey
=
539 GetConfigString(obj
, MUICFG_Keyboard_WordRight
);
540 data
->prefs
.muikeys
[MUIKEY_LINESTART
].readable_hotkey
=
541 GetConfigString(obj
, MUICFG_Keyboard_LineStart
);
542 data
->prefs
.muikeys
[MUIKEY_LINEEND
].readable_hotkey
=
543 GetConfigString(obj
, MUICFG_Keyboard_LineEnd
);
544 data
->prefs
.muikeys
[MUIKEY_GADGET_NEXT
].readable_hotkey
=
545 GetConfigString(obj
, MUICFG_Keyboard_NextGadget
);
546 data
->prefs
.muikeys
[MUIKEY_GADGET_PREV
].readable_hotkey
=
547 GetConfigString(obj
, MUICFG_Keyboard_PrevGadget
);
548 data
->prefs
.muikeys
[MUIKEY_GADGET_OFF
].readable_hotkey
=
549 GetConfigString(obj
, MUICFG_Keyboard_GadgetOff
);
550 data
->prefs
.muikeys
[MUIKEY_WINDOW_CLOSE
].readable_hotkey
=
551 GetConfigString(obj
, MUICFG_Keyboard_CloseWindow
);
552 data
->prefs
.muikeys
[MUIKEY_WINDOW_NEXT
].readable_hotkey
=
553 GetConfigString(obj
, MUICFG_Keyboard_NextWindow
);
554 data
->prefs
.muikeys
[MUIKEY_WINDOW_PREV
].readable_hotkey
=
555 GetConfigString(obj
, MUICFG_Keyboard_PrevWindow
);
556 data
->prefs
.muikeys
[MUIKEY_HELP
].readable_hotkey
=
557 GetConfigString(obj
, MUICFG_Keyboard_Help
);
558 data
->prefs
.muikeys
[MUIKEY_POPUP
].readable_hotkey
=
559 GetConfigString(obj
, MUICFG_Keyboard_Popup
);
561 for (i
= 0; i
< MUIKEY_COUNT
; i
++)
563 if (data
->prefs
.muikeys
[i
].readable_hotkey
)
564 data
->prefs
.muikeys
[i
].ix_well
=
565 !ParseIX(data
->prefs
.muikeys
[i
].readable_hotkey
,
566 &data
->prefs
.muikeys
[i
].ix
);
568 data
->prefs
.muikeys
[i
].ix_well
= 0;
571 /*---------- CustomFrames ----------*/
572 data
->prefs
.customframe_config_1
=
573 GetConfigString(obj
, MUICFG_CustomFrame_1
);
574 data
->prefs
.customframe_config_2
=
575 GetConfigString(obj
, MUICFG_CustomFrame_2
);
576 data
->prefs
.customframe_config_3
=
577 GetConfigString(obj
, MUICFG_CustomFrame_3
);
578 data
->prefs
.customframe_config_4
=
579 GetConfigString(obj
, MUICFG_CustomFrame_4
);
580 data
->prefs
.customframe_config_5
=
581 GetConfigString(obj
, MUICFG_CustomFrame_5
);
582 data
->prefs
.customframe_config_6
=
583 GetConfigString(obj
, MUICFG_CustomFrame_6
);
584 data
->prefs
.customframe_config_7
=
585 GetConfigString(obj
, MUICFG_CustomFrame_7
);
586 data
->prefs
.customframe_config_8
=
587 GetConfigString(obj
, MUICFG_CustomFrame_8
);
588 data
->prefs
.customframe_config_9
=
589 GetConfigString(obj
, MUICFG_CustomFrame_9
);
590 data
->prefs
.customframe_config_10
=
591 GetConfigString(obj
, MUICFG_CustomFrame_10
);
592 data
->prefs
.customframe_config_11
=
593 GetConfigString(obj
, MUICFG_CustomFrame_11
);
594 data
->prefs
.customframe_config_12
=
595 GetConfigString(obj
, MUICFG_CustomFrame_12
);
596 data
->prefs
.customframe_config_13
=
597 GetConfigString(obj
, MUICFG_CustomFrame_13
);
598 data
->prefs
.customframe_config_14
=
599 GetConfigString(obj
, MUICFG_CustomFrame_14
);
600 data
->prefs
.customframe_config_15
=
601 GetConfigString(obj
, MUICFG_CustomFrame_15
);
602 data
->prefs
.customframe_config_16
=
603 GetConfigString(obj
, MUICFG_CustomFrame_16
);
605 /*---------- Special ----------*/
606 /* all taken care of in frames and images */
611 /**************************************************************************
613 **************************************************************************/
614 IPTR
Configdata__OM_DISPOSE(struct IClass
*cl
, Object
*obj
, Msg msg
)
616 /* struct MUI_ConfigdataData *data = INST_DATA(cl, obj); */
619 return DoSuperMethodA(cl
, obj
, msg
);
622 /**************************************************************************
624 **************************************************************************/
625 IPTR
Configdata__OM_GET(struct IClass
*cl
, Object
*obj
,
628 struct MUI_ConfigdataData
*data
= INST_DATA(cl
, obj
);
629 IPTR
*store
= msg
->opg_Storage
;
630 ULONG tag
= msg
->opg_AttrID
;
634 case MUIA_Configdata_ZunePrefs
:
635 *store
= (IPTR
) & data
->prefs
;
636 DoMethod(obj
, MUIM_Configdata_GetWindowPos
, 0);
640 return DoSuperMethodA(cl
, obj
, (Msg
) msg
);
643 #ifndef AROS_BIG_ENDIAN
644 #define AROS_BIG_ENDIAN 0
647 static LONG
windowpos_endian(IPTR data
, BOOL isNative
)
651 void *p
= (void *)data
;
665 size
= AROS_BE2LONG(*((LONG
*) p
));
667 *((LONG
*) p
) = AROS_SWAP_BYTES_LONG(*((LONG
*) p
));
671 items
= (size
- sizeof(LONG
)) / sizeof(struct windowpos
);
672 D(bug("size=%d items=%d\n", size
, items
));
674 for (i
= 0; i
< items
; i
++)
678 D(bug("ID=%08x\n", *((LONG
*) ((IPTR
)p
+ cnt
))));
683 D(bug("ID=%08x\n", *((LONG
*) ((IPTR
)p
+ cnt
))));
684 *((LONG
*) ((IPTR
)p
+ cnt
)) =
685 AROS_SWAP_BYTES_LONG(*((LONG
*) ((IPTR
)p
+ cnt
)));
687 D(bug("ID=%08x\n", *((LONG
*) ((IPTR
)p
+ cnt
))));
690 for (j
= 0; j
< 8; j
++)
694 D(bug("V%d: %d\n", j
, *((WORD
*) ((IPTR
)p
+ cnt
))));
699 D(bug("V%d: %d\n", j
, *((WORD
*) ((IPTR
)p
+ cnt
))));
700 *((WORD
*) ((IPTR
)p
+ cnt
)) =
701 AROS_SWAP_BYTES_WORD(*((WORD
*) ((IPTR
)p
+ cnt
)));
703 D(bug("V%d: %d\n", j
, *((WORD
*) ((IPTR
)p
+ cnt
))));
708 D(bug("size=%d\n", cnt
));
712 static IPTR
Configdata_GetWindowPos(struct IClass
*cl
, Object
*obj
,
713 struct MUIP_Configdata_GetString
*msg
)
715 struct MUI_ConfigdataData
*data
;
717 data
= INST_DATA(cl
, obj
);
718 //kprintf ("getwindowpos\n");
719 s
= (IPTR
) DoMethod(obj
, MUIM_Dataspace_Find
, MUICFG_WindowPos
);
722 windowpos_endian(s
, FALSE
);
723 set(data
->app
, MUIA_Application_CopyWinPosToApp
, s
);
724 windowpos_endian(s
, TRUE
);
729 static IPTR
Configdata_SetWindowPos(struct IClass
*cl
, Object
*obj
,
730 struct MUIP_Configdata_GetString
*msg
)
732 struct MUI_ConfigdataData
*data
;
733 //kprintf ("setwindowpos\n");
734 data
= INST_DATA(cl
, obj
);
740 get(data
->app
, MUIA_Application_GetWinPosAddr
, &addr
);
741 get(data
->app
, MUIA_Application_GetWinPosSize
, &size
);
743 /* We can ignore size-variable because
744 * MUIA_Application_GetWinPosSize updates *((LONG*)addr) */
745 size
= windowpos_endian(addr
, TRUE
);
746 DoMethod(obj
, MUIM_Dataspace_Add
, addr
, size
, MUICFG_WindowPos
);
747 windowpos_endian(addr
, FALSE
);
754 /**************************************************************************
755 MUIM_Configdata_GetString
756 Check if string is found in dataspace, then if not found, search each
758 **************************************************************************/
759 IPTR
Configdata__MUIM_GetString(struct IClass
*cl
, Object
*obj
,
760 struct MUIP_Configdata_GetString
*msg
)
764 s
= (CONST_STRPTR
) DoMethod(obj
, MUIM_Dataspace_Find
, msg
->id
);
769 for (i
= 0; DefStrValues
[i
].id
; i
++)
771 if (DefStrValues
[i
].id
== msg
->id
)
772 return (IPTR
) DefStrValues
[i
].val
;
774 for (i
= 0; DefImspecValues
[i
].defspec
; i
++)
776 if (DefImspecValues
[i
].cfgid
== msg
->id
)
777 return (IPTR
) DefImspecValues
[i
].defspec
;
779 for (i
= 0; DefFramespecValues
[i
].defspec
; i
++)
781 if (DefFramespecValues
[i
].cfgid
== msg
->id
)
782 return (IPTR
) DefFramespecValues
[i
].defspec
;
792 /**************************************************************************
793 MUIM_Configdata_SetImspec
794 search in builtin array first, to not not have in dataspace the default
795 value (would be redundant)
796 **************************************************************************/
797 IPTR
Configdata__MUIM_SetImspec(struct IClass
*cl
, Object
*obj
,
798 struct MUIP_Configdata_SetImspec
*msg
)
802 if (!msg
->imspec
|| !*msg
->imspec
|| *msg
->imspec
== '6')
804 /* D(bug("Configdata_SetImspec(%p) : id %08lx, val invalid\n", */
805 /* obj, msg->id)); */
809 for (i
= 0; DefImspecValues
[i
].defspec
; i
++)
811 if (DefImspecValues
[i
].cfgid
== msg
->id
)
812 if (!strcmp(DefImspecValues
[i
].defspec
, msg
->imspec
))
814 /* D(bug("Configdata_SetImspec(%p) : set to def, id %08lx, val %s\n", */
815 /* obj, msg->id, msg->imspec)); */
816 DoMethod(obj
, MUIM_Dataspace_Remove
, msg
->id
);
821 for (i
= 0; DefStrValues
[i
].id
; i
++)
823 if (DefStrValues
[i
].id
== msg
->id
)
824 if (!strcmp(DefStrValues
[i
].val
, msg
->imspec
))
826 DoMethod(obj
, MUIM_Dataspace_Remove
, msg
->id
);
831 DoMethod(obj
, MUIM_Dataspace_Add
, (IPTR
) msg
->imspec
,
832 strlen(msg
->imspec
) + 1, msg
->id
);
836 /**************************************************************************
837 MUIM_Configdata_SetFramespec
838 **************************************************************************/
839 IPTR
Configdata__MUIM_SetFramespec(struct IClass
*cl
, Object
*obj
,
840 struct MUIP_Configdata_SetFramespec
*msg
)
844 if (!msg
->framespec
|| !*msg
->framespec
)
846 /* D(bug("Configdata_SetFramespec(%p) : id %08lx, val invalid\n", */
847 /* obj, msg->id)); */
851 for (i
= 0; DefFramespecValues
[i
].defspec
; i
++)
853 if (DefFramespecValues
[i
].cfgid
== msg
->id
)
854 if (!strcmp(DefFramespecValues
[i
].defspec
, msg
->framespec
))
856 /* D(bug("Configdata_SetFramespec(%p): " */
857 /* "set to def, id %08lx, val %s\n", */
858 /* obj, msg->id, msg->framespec)); */
859 DoMethod(obj
, MUIM_Dataspace_Remove
, msg
->id
);
864 DoMethod(obj
, MUIM_Dataspace_Add
, (IPTR
) msg
->framespec
,
865 strlen(msg
->framespec
) + 1, msg
->id
);
869 /**************************************************************************
870 MUIM_Configdata_SetPenspec
871 **************************************************************************/
872 IPTR
Configdata__MUIM_SetPenspec(struct IClass
*cl
, Object
*obj
,
873 struct MUIP_Configdata_SetPenspec
*msg
)
877 if (!msg
->penspec
|| !*msg
->penspec
)
880 for (i
= 0; DefStrValues
[i
].id
; i
++)
882 if (DefStrValues
[i
].id
== msg
->id
)
883 if (!strcmp(DefStrValues
[i
].val
, msg
->penspec
))
885 DoMethod(obj
, MUIM_Dataspace_Remove
, msg
->id
);
890 DoMethod(obj
, MUIM_Dataspace_Add
, (IPTR
) msg
->penspec
,
891 strlen(msg
->penspec
) + 1, msg
->id
);
895 /**************************************************************************
896 MUIM_Configdata_SetFont
897 **************************************************************************/
898 IPTR
Configdata__MUIM_SetFont(struct IClass
*cl
, Object
*obj
,
899 struct MUIP_Configdata_SetFont
*msg
)
901 if (!msg
->font
|| !*msg
->font
)
903 /* D(bug("Configdata_SetFont(%p) : id %08lx, val invalid\n", */
904 /* obj, msg->id)); */
905 DoMethod(obj
, MUIM_Dataspace_Remove
, msg
->id
);
909 DoMethod(obj
, MUIM_Dataspace_Add
, (IPTR
) msg
->font
,
910 strlen(msg
->font
) + 1, msg
->id
);
914 /**************************************************************************
915 MUIM_Configdata_SetString
916 **************************************************************************/
917 IPTR
Configdata__MUIM_SetString(struct IClass
*cl
, Object
*obj
,
918 struct MUIP_Configdata_SetString
*msg
)
922 for (i
= 0; DefStrValues
[i
].id
; i
++)
924 if (DefStrValues
[i
].id
== msg
->id
)
925 if (!strcmp(DefStrValues
[i
].val
, msg
->string
))
927 DoMethod(obj
, MUIM_Dataspace_Remove
, msg
->id
);
932 DoMethod(obj
, MUIM_Dataspace_Add
, (IPTR
) msg
->string
,
933 strlen(msg
->string
) + 1, msg
->id
);
937 /**************************************************************************
938 MUIM_Configdata_GetULong
939 **************************************************************************/
940 IPTR
Configdata__MUIM_GetULong(struct IClass
*cl
, Object
*obj
,
941 struct MUIP_Configdata_GetULong
*msg
)
945 vp
= (ULONG
*) DoMethod(obj
, MUIM_Dataspace_Find
, msg
->id
);
950 for (i
= 0; DefULValues
[i
].id
!= 0; i
++)
952 if (DefULValues
[i
].id
== msg
->id
)
953 return DefULValues
[i
].val
;
959 return AROS_BE2LONG(*vp
);
963 /**************************************************************************
964 MUIM_Configdata_SetULong
965 **************************************************************************/
966 IPTR
Configdata__MUIM_SetULong(struct IClass
*cl
, Object
*obj
,
967 struct MUIP_Configdata_SetULong
*msg
)
973 for (i
= 0; DefULValues
[i
].id
!= 0; i
++)
975 if (DefULValues
[i
].id
== msg
->id
)
976 if (DefULValues
[i
].val
== v
)
978 /* D(bug("Configdata_SetULong(%p):" */
979 /* " set to def, id %08lx, val %ld\n", */
980 /* obj, msg->id, v)); */
981 DoMethod(obj
, MUIM_Dataspace_Remove
, msg
->id
);
987 /* D(bug("Configdata_SetULong(%p): adding %08lx to %08lx chunk\n", */
988 /* obj, v, msg->id)); */
989 DoMethod(obj
, MUIM_Dataspace_Add
, (IPTR
) vp
, 4, msg
->id
);
994 /**************************************************************************
995 SavePrefsHeader: Write a PRHD chunk
996 **************************************************************************/
997 static int SavePrefsHeader(struct IFFHandle
*iff
)
999 if (!PushChunk(iff
, 0, MAKE_ID('P', 'R', 'H', 'D'), IFFSIZE_UNKNOWN
))
1001 struct PrefHeader ph
;
1006 if (WriteChunkBytes(iff
, &ph
, sizeof(struct PrefHeader
)))
1014 /**************************************************************************
1015 MUIM_Configdata_Save
1016 **************************************************************************/
1017 IPTR
Configdata__MUIM_Save(struct IClass
*cl
, Object
*obj
,
1018 struct MUIP_Configdata_Save
*msg
)
1020 struct IFFHandle
*iff
;
1021 if ((iff
= AllocIFF()))
1023 if (!(iff
->iff_Stream
= (IPTR
) Open(msg
->filename
, MODE_NEWFILE
)))
1025 /* Try to Create the directory where the file is located */
1026 char *path
= StrDup(msg
->filename
);
1029 char *path_end
= PathPart(path
);
1030 if (path_end
!= path
)
1034 if ((lock
= CreateDir(path
)))
1038 (IPTR
) Open(msg
->filename
, MODE_NEWFILE
);
1045 if (iff
->iff_Stream
)
1049 if (!OpenIFF(iff
, IFFF_WRITE
))
1051 if (!PushChunk(iff
, MAKE_ID('P', 'R', 'E', 'F'), ID_FORM
,
1054 Configdata_SetWindowPos(cl
, obj
, (APTR
) msg
);
1055 if (SavePrefsHeader(iff
))
1057 DoMethod(obj
, MUIM_Dataspace_WriteIFF
, (IPTR
) iff
,
1058 0, MAKE_ID('M', 'U', 'I', 'C'));
1065 Close((BPTR
) iff
->iff_Stream
);
1073 /**************************************************************************
1074 MUIM_Configdata_Load
1075 Get the content of the file into the object.
1076 **************************************************************************/
1077 IPTR
Configdata__MUIM_Load(struct IClass
*cl
, Object
*obj
,
1078 struct MUIP_Configdata_Load
*msg
)
1080 struct IFFHandle
*iff
;
1083 if ((iff
= AllocIFF()))
1085 D(bug("loading prefs from %s\n", msg
->filename
));
1086 if ((iff
->iff_Stream
= (IPTR
) Open(msg
->filename
, MODE_OLDFILE
)))
1090 if (!OpenIFF(iff
, IFFF_READ
))
1092 StopChunk(iff
, MAKE_ID('P', 'R', 'E', 'F'), MAKE_ID('M',
1095 while (!ParseIFF(iff
, IFFPARSE_SCAN
))
1097 struct ContextNode
*cn
;
1098 if (!(cn
= CurrentChunk(iff
)))
1100 if (cn
->cn_ID
== MAKE_ID('M', 'U', 'I', 'C'))
1101 DoMethod(obj
, MUIM_Dataspace_ReadIFF
, (IPTR
) iff
);
1110 Close((BPTR
) iff
->iff_Stream
);
1127 * The class dispatcher
1129 BOOPSI_DISPATCHER(IPTR
, Configdata_Dispatcher
, cl
, obj
, msg
)
1131 switch (msg
->MethodID
)
1134 return Configdata__OM_NEW(cl
, obj
, (struct opSet
*)msg
);
1136 return Configdata__OM_DISPOSE(cl
, obj
, (APTR
) msg
);
1138 return Configdata__OM_GET(cl
, obj
, (APTR
) msg
);
1139 case MUIM_Configdata_GetString
:
1140 return Configdata__MUIM_GetString(cl
, obj
, (APTR
) msg
);
1141 case MUIM_Configdata_GetULong
:
1142 return Configdata__MUIM_GetULong(cl
, obj
, (APTR
) msg
);
1143 case MUIM_Configdata_SetULong
:
1144 return Configdata__MUIM_SetULong(cl
, obj
, (APTR
) msg
);
1145 case MUIM_Configdata_SetImspec
:
1146 return Configdata__MUIM_SetImspec(cl
, obj
, (APTR
) msg
);
1147 case MUIM_Configdata_SetFramespec
:
1148 return Configdata__MUIM_SetFramespec(cl
, obj
, (APTR
) msg
);
1149 case MUIM_Configdata_SetPenspec
:
1150 return Configdata__MUIM_SetPenspec(cl
, obj
, (APTR
) msg
);
1151 case MUIM_Configdata_SetFont
:
1152 return Configdata__MUIM_SetFont(cl
, obj
, (APTR
) msg
);
1153 case MUIM_Configdata_SetString
:
1154 return Configdata__MUIM_SetString(cl
, obj
, (APTR
) msg
);
1155 case MUIM_Configdata_Save
:
1156 return Configdata__MUIM_Save(cl
, obj
, (APTR
) msg
);
1157 case MUIM_Configdata_Load
:
1158 return Configdata__MUIM_Load(cl
, obj
, (APTR
) msg
);
1159 case MUIM_Configdata_SetWindowPos
:
1160 return Configdata_SetWindowPos(cl
, obj
, (APTR
) msg
);
1161 case MUIM_Configdata_GetWindowPos
:
1162 return Configdata_GetWindowPos(cl
, obj
, (APTR
) msg
);
1166 return DoSuperMethodA(cl
, obj
, msg
);
1168 BOOPSI_DISPATCHER_END
1173 const struct __MUIBuiltinClass _MUI_Configdata_desc
=
1175 MUIC_Configdata
, /* Class name */
1176 MUIC_Dataspace
, /* super class name */
1177 sizeof(struct MUI_ConfigdataData
), /* size of class own datas */
1178 (void *) Configdata_Dispatcher
/* class dispatcher */