2 Copyright 2009, The AROS Development Team. All rights reserved.
6 #include <graphics/gfx.h>
7 #include <graphics/view.h>
9 #include <clib/alib_protos.h>
10 #include <libraries/asl.h>
11 #include <libraries/mui.h>
12 #include <libraries/muiscreen.h>
13 #include <proto/exec.h>
14 #include <proto/graphics.h>
15 #include <proto/utility.h>
16 #include <proto/intuition.h>
17 #include <proto/muimaster.h>
18 #include <proto/muiscreen.h>
19 #include <proto/dos.h>
20 #include <zune/customclasses.h>
23 #include <proto/alib.h>
25 //#include <aros/debug.h>
28 #include "zunestuff.h"
32 extern struct Library
*MUIMasterBase
;
34 /* Utility class for the bubble help time slider */
36 struct BubbleSlider_DATA
41 IPTR
BubbleSlider__MUIM_Numeric_Stringify(struct IClass
*cl
, Object
* obj
, struct MUIP_Numeric_Stringify
*msg
)
43 struct BubbleSlider_DATA
*data
= INST_DATA(cl
, obj
);
46 snprintf(data
->buf
, sizeof(data
->buf
) - 1, "%.1f s", 0.1 * msg
->value
);
48 snprintf(data
->buf
, sizeof(data
->buf
) - 1, "off");
50 data
->buf
[sizeof(data
->buf
) - 1] = 0;
52 return (IPTR
)data
->buf
;
56 BubbleSlider
, NULL
, MUIC_Slider
, NULL
,
57 MUIM_Numeric_Stringify
, struct MUIP_Numeric_Stringify
*
60 /* Utility class for choosing public screen */
62 #define PSD_NAME_DEFAULT "«Default»"
64 struct PopPublicScreen_DATA
66 struct Hook strobj_hook
;
67 struct Hook objstr_hook
;
71 LONG
PopPublicScreenStrObjFunc(struct Hook
*hook
, Object
*popup
, Object
*str
)
73 struct PopPublicScreen_DATA
*data
= (struct PopPublicScreen_DATA
*)hook
->h_Data
;
74 struct List
*pubscrlist
;
75 struct PubScreenNode
*pubscrnode
;
76 STRPTR strtext
, listentry
;
78 struct MUI_PubScreenDesc
*desc
;
81 set(data
->list
,MUIA_List_Quiet
,TRUE
);
83 DoMethod(data
->list
, MUIM_List_Clear
);
84 DoMethod(data
->list
, MUIM_List_InsertSingle
, PSD_NAME_DEFAULT
, MUIV_List_Insert_Bottom
);
85 DoMethod(data
->list
, MUIM_List_InsertSingle
, PSD_NAME_FRONTMOST
, MUIV_List_Insert_Bottom
);
87 if (pfh
= MUIS_OpenPubFile(PSD_FILENAME_USE
, MODE_OLDFILE
))
89 while (desc
= MUIS_ReadPubFile(pfh
))
91 DoMethod(data
->list
, MUIM_List_InsertSingle
, desc
->Name
, MUIV_List_Insert_Bottom
);
93 MUIS_ClosePubFile(pfh
);
96 pubscrlist
= LockPubScreenList();
97 ForeachNode(pubscrlist
, pubscrnode
)
99 DoMethod(data
->list
, MUIM_List_InsertSingle
, (IPTR
)pubscrnode
->psn_Node
.ln_Name
, MUIV_List_Insert_Bottom
);
101 UnlockPubScreenList();
103 set(data
->list
,MUIA_List_Quiet
,FALSE
);
105 get(str
, MUIA_String_Contents
, &strtext
);
107 for(index
= 0; ; index
++)
109 DoMethod(data
->list
, MUIM_List_GetEntry
, index
, (IPTR
)&listentry
);
113 set(data
->list
, MUIA_List_Active
, strtext
[0] ? MUIV_List_Active_Off
: 0);
117 if (stricmp(strtext
, listentry
) == 0)
119 set(data
->list
, MUIA_List_Active
, index
);
127 void PopPublicScreenObjStrFunc(struct Hook
*hook
, Object
*popup
, Object
*str
)
131 DoMethod(popup
, MUIM_List_GetEntry
, MUIV_List_GetEntry_Active
, (IPTR
)&listentry
);
135 if (strcmp(listentry
, PSD_NAME_DEFAULT
) == 0)
136 set(str
, MUIA_String_Contents
, "");
138 set(str
, MUIA_String_Contents
, listentry
);
142 IPTR
PopPublicScreen__OM_NEW(struct IClass
*cl
, Object
*obj
, struct opSet
*msg
)
146 obj
= (Object
*)DoSuperNewTags
149 MUIA_Popobject_Object
, (IPTR
)(lv
= (Object
*)ListviewObject
,
150 MUIA_Listview_List
, (IPTR
)(list
= (Object
*)ListObject
,
154 TAG_MORE
, (IPTR
) msg
->ops_AttrList
159 struct PopPublicScreen_DATA
*data
= INST_DATA(cl
, obj
);
163 data
->strobj_hook
.h_Entry
= HookEntry
;
164 data
->strobj_hook
.h_SubEntry
= (HOOKFUNC
)PopPublicScreenStrObjFunc
;
165 data
->strobj_hook
.h_Data
= data
;
167 data
->objstr_hook
.h_Entry
= HookEntry
;
168 data
->objstr_hook
.h_SubEntry
= (HOOKFUNC
)PopPublicScreenObjStrFunc
;
169 data
->objstr_hook
.h_Data
= data
;
171 SetAttrs(obj
, MUIA_Popobject_StrObjHook
, (IPTR
)&data
->strobj_hook
,
172 MUIA_Popobject_ObjStrHook
, (IPTR
)&data
->objstr_hook
,
176 DoMethod(lv
, MUIM_Notify
, MUIA_Listview_DoubleClick
, TRUE
,
177 (IPTR
)obj
, 2, MUIM_Popstring_Close
, TRUE
);
184 PopPublicScreen
, NULL
, MUIC_Popobject
, NULL
,
185 OM_NEW
, struct opSet
*
188 /* Preferences System tab class */
190 struct MUI_SystemPData
192 Object
*screen_name_string
;
193 Object
*call_psi_button
;
194 Object
*pop_to_front_checkmark
;
195 Object
*hotkey_string
;
196 Object
*show_icon_checkmark
;
197 Object
*show_menu_checkmark
;
198 Object
*on_startup_checkmark
;
199 Object
*arexx_checkmark
;
200 Object
*first_bubble_slider
;
201 Object
*next_bubble_slider
;
205 static IPTR
ExecuteScreenInspectorFunc(struct Hook
*hook
, Object
*caller
, void *data
)
207 struct TagItem tags
[] =
209 { SYS_Asynch
, TRUE
},
212 { NP_StackSize
, AROS_STACKSIZE
},
216 if (SystemTagList("sys:prefs/psi", tags
) == -1)
224 static IPTR
SystemP_New(struct IClass
*cl
, Object
*obj
, struct opSet
*msg
)
226 struct MUI_SystemPData
*data
;
227 struct MUI_SystemPData d
;
229 obj
= (Object
*) DoSuperNewTags
233 MUIA_Group_Columns
, 2,
234 MUIA_Group_SameSize
, TRUE
,
236 Child
, (IPTR
) VGroup
,
237 GroupFrameT(_(MSG_PUBLIC_SCREEN
)),
238 MUIA_Group_VertSpacing
, 0,
239 Child
, (IPTR
) VSpace(0),
240 Child
, (IPTR
) ColGroup(2),
241 Child
, (IPTR
) Label1(_(MSG_NAME
)),
242 Child
, NewObject(PopPublicScreen_CLASS
->mcc_Class
, NULL
,
243 MUIA_Popstring_String
, (IPTR
) (d
.screen_name_string
= StringObject
, MUIA_Frame
, MUIV_Frame_String
, End
),
244 MUIA_Popstring_Button
, PopButton(MUII_PopUp
),
247 Child
, (IPTR
) (d
.call_psi_button
= SimpleButton(_(MSG_CALL_INSPECTOR
))),
248 Child
, (IPTR
) Label1(_(MSG_POP_TO_FRONT
)),
250 Child
, (IPTR
) (d
.pop_to_front_checkmark
= MakeCheck(NULL
)),
251 Child
, RectangleObject
, End
,
254 Child
, (IPTR
) VSpace(0),
257 Child
, (IPTR
) VGroup
,
258 GroupFrameT(_(MSG_ICONIFICATION
)),
259 MUIA_Group_VertSpacing
, 0,
260 Child
, (IPTR
) VSpace(0),
261 Child
, (IPTR
) ColGroup(2),
262 Child
, (IPTR
) Label1(_(MSG_HOTKEY
)),
263 Child
, (IPTR
) (d
.hotkey_string
= MakeString()),
264 Child
, (IPTR
) Label1(_(MSG_SHOW
)),
266 Child
, (IPTR
) (d
.show_icon_checkmark
= MakeCheck(NULL
)),
267 Child
, (IPTR
) Label1(_(MSG_ICON
)),
268 Child
, (IPTR
) (d
.show_menu_checkmark
= MakeCheck(NULL
)),
269 Child
, (IPTR
) Label1(_(MSG_MENU
)),
271 Child
, (IPTR
) Label1(_(MSG_ON_STARTUP
)),
273 Child
, (IPTR
) (d
.on_startup_checkmark
= MakeCheck(NULL
)),
274 Child
, RectangleObject
, End
,
277 Child
, (IPTR
) VSpace(0),
280 Child
, (IPTR
) VGroup
,
281 GroupFrameT(_(MSG_INTERFACES
)),
282 MUIA_Group_VertSpacing
, 0,
283 Child
, (IPTR
) VSpace(0),
284 Child
, (IPTR
) HGroup
,
286 Child
, (IPTR
) Label1(_(MSG_AREXX
)),
287 Child
, (IPTR
) (d
.arexx_checkmark
= MakeCheck(NULL
)),
290 Child
, (IPTR
) VSpace(0),
293 Child
, (IPTR
) VGroup
,
294 GroupFrameT(_(MSG_BUBBLE_HELP
)),
295 MUIA_Group_VertSpacing
, 0,
296 Child
, (IPTR
) VSpace(0),
297 Child
, (IPTR
) ColGroup(2),
298 Child
, (IPTR
) Label1(_(MSG_FIRST_BUBBLE
)),
299 Child
, (IPTR
) (d
.first_bubble_slider
= NewObject(BubbleSlider_CLASS
->mcc_Class
, NULL
, MUIA_Numeric_Min
, 0, MUIA_Numeric_Max
, 50, TAG_END
)),
300 Child
, (IPTR
) Label1(_(MSG_NEXT_BUBBLE
)),
301 Child
, (IPTR
) (d
.next_bubble_slider
= NewObject(BubbleSlider_CLASS
->mcc_Class
, NULL
, MUIA_Numeric_Min
, 0, MUIA_Numeric_Max
, 50, TAG_END
)),
303 Child
, (IPTR
) VSpace(0),
306 TAG_MORE
, (IPTR
) msg
->ops_AttrList
);
308 if (!obj
) return FALSE
;
310 d
.psiHook
.h_Entry
= HookEntry
;
311 d
.psiHook
.h_SubEntry
= (HOOKFUNC
) ExecuteScreenInspectorFunc
;
313 data
= INST_DATA(cl
, obj
);
317 d
.first_bubble_slider
, MUIM_Notify
, MUIA_Numeric_Value
, MUIV_EveryTime
,
318 d
.next_bubble_slider
, (IPTR
) 3, MUIM_Set
, MUIA_Disabled
, MUIV_NotTriggerValue
322 d
.call_psi_button
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
323 obj
, (IPTR
) 2, MUIM_CallHook
, &data
->psiHook
330 static IPTR
SystemP_ConfigToGadgets(struct IClass
*cl
, Object
*obj
,
331 struct MUIP_Settingsgroup_ConfigToGadgets
*msg
)
333 struct MUI_SystemPData
*data
= INST_DATA(cl
, obj
);
335 ConfigToString(msg
->configdata
, MUICFG_PublicScreen
, data
->screen_name_string
);
336 ConfigToCheckmark(msg
->configdata
, MUICFG_PublicScreen_PopToFront
, data
->pop_to_front_checkmark
);
337 ConfigToString(msg
->configdata
, MUICFG_Iconification_Hotkey
, data
->hotkey_string
);
338 ConfigToCheckmark(msg
->configdata
, MUICFG_Iconification_ShowIcon
, data
->show_icon_checkmark
);
339 ConfigToCheckmark(msg
->configdata
, MUICFG_Iconification_ShowMenu
, data
->show_menu_checkmark
);
340 ConfigToCheckmark(msg
->configdata
, MUICFG_Iconification_OnStartup
, data
->on_startup_checkmark
);
341 ConfigToCheckmark(msg
->configdata
, MUICFG_Interfaces_EnableARexx
, data
->arexx_checkmark
);
342 ConfigToSlider(msg
->configdata
, MUICFG_BubbleHelp_FirstDelay
, data
->first_bubble_slider
);
343 ConfigToSlider(msg
->configdata
, MUICFG_BubbleHelp_NextDelay
, data
->next_bubble_slider
);
349 static IPTR
SystemP_GadgetsToConfig(struct IClass
*cl
, Object
*obj
,
350 struct MUIP_Settingsgroup_GadgetsToConfig
*msg
)
352 struct MUI_SystemPData
*data
= INST_DATA(cl
, obj
);
354 StringToConfig(data
->screen_name_string
, msg
->configdata
, MUICFG_PublicScreen
);
355 CheckmarkToConfig(data
->pop_to_front_checkmark
, msg
->configdata
, MUICFG_PublicScreen_PopToFront
);
356 StringToConfig(data
->hotkey_string
, msg
->configdata
, MUICFG_Iconification_Hotkey
);
357 CheckmarkToConfig(data
->show_icon_checkmark
, msg
->configdata
, MUICFG_Iconification_ShowIcon
);
358 CheckmarkToConfig(data
->show_menu_checkmark
, msg
->configdata
, MUICFG_Iconification_ShowMenu
);
359 CheckmarkToConfig(data
->on_startup_checkmark
, msg
->configdata
, MUICFG_Iconification_OnStartup
);
360 CheckmarkToConfig(data
->arexx_checkmark
, msg
->configdata
, MUICFG_Interfaces_EnableARexx
);
361 SliderToConfig(data
->first_bubble_slider
, msg
->configdata
, MUICFG_BubbleHelp_FirstDelay
);
362 SliderToConfig(data
->next_bubble_slider
, msg
->configdata
, MUICFG_BubbleHelp_NextDelay
);
367 BOOPSI_DISPATCHER(IPTR
, SystemP_Dispatcher
, cl
, obj
, msg
)
369 switch (msg
->MethodID
)
371 case OM_NEW
: return SystemP_New(cl
, obj
, (struct opSet
*)msg
);
372 case MUIM_Settingsgroup_ConfigToGadgets
: return SystemP_ConfigToGadgets(cl
,obj
,(APTR
)msg
);break;
373 case MUIM_Settingsgroup_GadgetsToConfig
: return SystemP_GadgetsToConfig(cl
,obj
,(APTR
)msg
);break;
376 return DoSuperMethodA(cl
, obj
, msg
);
378 BOOPSI_DISPATCHER_END
383 const struct __MUIBuiltinClass _MUIP_System_desc
= {
386 sizeof(struct MUI_SystemPData
),
387 (void*)SystemP_Dispatcher