Updated PCI IDs to latest snapshot.
[tangerine.git] / workbench / prefs / Zune / systemp.c
bloba7b6dd2056c1aca31975779e61599ebf1045af49
1 /*
2 Copyright 2009, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <graphics/gfx.h>
7 #include <graphics/view.h>
8 #include <dos/dos.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>
22 #ifdef __AROS__
23 #include <proto/alib.h>
24 //#define DEBUG 1
25 //#include <aros/debug.h>
26 #endif
28 #include "zunestuff.h"
29 #include <string.h>
30 #include <stdio.h>
32 extern struct Library *MUIMasterBase;
34 /* Utility class for the bubble help time slider */
36 struct BubbleSlider_DATA
38 char buf[20];
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);
45 if(msg->value != 0)
46 snprintf(data->buf, sizeof(data->buf) - 1, "%.1f s", 0.1 * msg->value);
47 else
48 snprintf(data->buf, sizeof(data->buf) - 1, "off");
50 data->buf[sizeof(data->buf) - 1] = 0;
52 return (IPTR)data->buf;
55 ZUNE_CUSTOMCLASS_1(
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;
68 Object *list;
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;
77 LONG index;
78 struct MUI_PubScreenDesc *desc;
79 APTR pfh;
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);
111 if (!listentry)
113 set(data->list, MUIA_List_Active, strtext[0] ? MUIV_List_Active_Off : 0);
114 break;
117 if (stricmp(strtext, listentry) == 0)
119 set(data->list, MUIA_List_Active, index);
120 break;
124 return TRUE;
127 void PopPublicScreenObjStrFunc(struct Hook *hook, Object *popup, Object *str)
129 STRPTR listentry;
131 DoMethod(popup, MUIM_List_GetEntry, MUIV_List_GetEntry_Active, (IPTR)&listentry);
133 if (listentry)
135 if (strcmp(listentry, PSD_NAME_DEFAULT) == 0)
136 set(str, MUIA_String_Contents, "");
137 else
138 set(str, MUIA_String_Contents, listentry);
142 IPTR PopPublicScreen__OM_NEW(struct IClass *cl, Object *obj, struct opSet *msg)
144 Object *lv, *list;
146 obj = (Object *)DoSuperNewTags
148 cl, obj, NULL,
149 MUIA_Popobject_Object, (IPTR)(lv = (Object *)ListviewObject,
150 MUIA_Listview_List, (IPTR)(list = (Object *)ListObject,
151 InputListFrame,
152 End),
153 End),
154 TAG_MORE, (IPTR) msg->ops_AttrList
157 if (obj)
159 struct PopPublicScreen_DATA *data = INST_DATA(cl, obj);
161 data->list = list;
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,
173 TAG_DONE);
176 DoMethod(lv, MUIM_Notify, MUIA_Listview_DoubleClick, TRUE,
177 (IPTR)obj, 2, MUIM_Popstring_Close, TRUE);
180 return (IPTR)obj;
183 ZUNE_CUSTOMCLASS_1(
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;
202 struct Hook psiHook;
205 static IPTR ExecuteScreenInspectorFunc(struct Hook *hook, Object *caller, void *data)
207 struct TagItem tags[] =
209 { SYS_Asynch, TRUE },
210 { SYS_Input, 0 },
211 { SYS_Output, 0 },
212 { NP_StackSize, AROS_STACKSIZE },
213 { TAG_DONE }
216 if (SystemTagList("sys:prefs/psi", tags) == -1)
218 return (IPTR) FALSE;
221 return (IPTR) TRUE;
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
231 cl, obj, NULL,
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),
245 TAG_END),
246 Child, HSpace(0),
247 Child, (IPTR) (d.call_psi_button = SimpleButton(_(MSG_CALL_INSPECTOR))),
248 Child, (IPTR) Label1(_(MSG_POP_TO_FRONT)),
249 Child, HGroup,
250 Child, (IPTR) (d.pop_to_front_checkmark = MakeCheck(NULL)),
251 Child, RectangleObject, End,
252 End,
253 End,
254 Child, (IPTR) VSpace(0),
255 End,
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)),
265 Child, HGroup,
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)),
270 End,
271 Child, (IPTR) Label1(_(MSG_ON_STARTUP)),
272 Child, HGroup,
273 Child, (IPTR) (d.on_startup_checkmark = MakeCheck(NULL)),
274 Child, RectangleObject, End,
275 End,
276 End,
277 Child, (IPTR) VSpace(0),
278 End,
280 Child, (IPTR) VGroup,
281 GroupFrameT(_(MSG_INTERFACES)),
282 MUIA_Group_VertSpacing, 0,
283 Child, (IPTR) VSpace(0),
284 Child, (IPTR) HGroup,
285 Child, HSpace(0),
286 Child, (IPTR) Label1(_(MSG_AREXX)),
287 Child, (IPTR) (d.arexx_checkmark = MakeCheck(NULL)),
288 Child, HSpace(0),
289 End,
290 Child, (IPTR) VSpace(0),
291 End,
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)),
302 End,
303 Child, (IPTR) VSpace(0),
304 End,
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);
314 *data = d;
316 DoMethod(
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
321 DoMethod(
322 d.call_psi_button, MUIM_Notify, MUIA_Pressed, FALSE,
323 obj, (IPTR) 2, MUIM_CallHook, &data->psiHook
326 return (IPTR)obj;
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);
345 return 1;
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);
364 return TRUE;
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
381 * Class descriptor.
383 const struct __MUIBuiltinClass _MUIP_System_desc = {
384 "System",
385 MUIC_Group,
386 sizeof(struct MUI_SystemPData),
387 (void*)SystemP_Dispatcher