another polish locale.
[AROS.git] / workbench / prefs / Zune / systemp.c
blob0519f0fa1c2608960a73811d280967eb33970f55
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 <mui/Rawimage_mcc.h>
14 #include <proto/exec.h>
15 #include <proto/graphics.h>
16 #include <proto/utility.h>
17 #include <proto/intuition.h>
18 #include <proto/muimaster.h>
19 #include <proto/muiscreen.h>
20 #include <proto/dos.h>
21 #include <zune/customclasses.h>
23 #ifdef __AROS__
24 #include <proto/alib.h>
25 //#define DEBUG 1
26 //#include <aros/debug.h>
27 #endif
29 #include "zunestuff.h"
30 #include <string.h>
31 #include <stdio.h>
33 extern struct Library *MUIMasterBase;
35 /* Utility class for the bubble help time slider */
37 struct BubbleSlider_DATA
39 char buf[20];
42 IPTR BubbleSlider__MUIM_Numeric_Stringify(struct IClass *cl, Object * obj, struct MUIP_Numeric_Stringify *msg)
44 struct BubbleSlider_DATA *data = INST_DATA(cl, obj);
46 if(msg->value != 0)
47 snprintf(data->buf, sizeof(data->buf) - 1, "%.1f s", 0.1 * msg->value);
48 else
49 snprintf(data->buf, sizeof(data->buf) - 1, "off");
51 data->buf[sizeof(data->buf) - 1] = 0;
53 return (IPTR)data->buf;
56 ZUNE_CUSTOMCLASS_1(
57 BubbleSlider, NULL, MUIC_Slider, NULL,
58 MUIM_Numeric_Stringify, struct MUIP_Numeric_Stringify*
61 /* Utility class for choosing public screen */
63 #define PSD_NAME_DEFAULT "«Default»"
65 struct PopPublicScreen_DATA
67 struct Hook strobj_hook;
68 struct Hook objstr_hook;
69 Object *list;
72 LONG PopPublicScreenStrObjFunc(struct Hook *hook, Object *popup, Object *str)
74 struct PopPublicScreen_DATA *data = (struct PopPublicScreen_DATA *)hook->h_Data;
75 struct List *pubscrlist;
76 struct PubScreenNode *pubscrnode;
77 STRPTR strtext = NULL, listentry;
78 LONG index;
79 struct MUI_PubScreenDesc *desc;
80 APTR pfh;
82 set(data->list,MUIA_List_Quiet,TRUE);
84 DoMethod(data->list, MUIM_List_Clear);
85 DoMethod(data->list, MUIM_List_InsertSingle, PSD_NAME_DEFAULT, MUIV_List_Insert_Bottom);
86 DoMethod(data->list, MUIM_List_InsertSingle, PSD_NAME_FRONTMOST, MUIV_List_Insert_Bottom);
88 if ( (pfh = MUIS_OpenPubFile(PSD_FILENAME_USE, MODE_OLDFILE)) )
90 while ( (desc = MUIS_ReadPubFile(pfh)) )
92 DoMethod(data->list, MUIM_List_InsertSingle, desc->Name, MUIV_List_Insert_Bottom);
94 MUIS_ClosePubFile(pfh);
97 pubscrlist = LockPubScreenList();
98 ForeachNode(pubscrlist, pubscrnode)
100 DoMethod(data->list, MUIM_List_InsertSingle, (IPTR)pubscrnode->psn_Node.ln_Name, MUIV_List_Insert_Bottom);
102 UnlockPubScreenList();
104 set(data->list,MUIA_List_Quiet,FALSE);
106 get(str, MUIA_String_Contents, &strtext);
108 for(index = 0; ; index++)
110 DoMethod(data->list, MUIM_List_GetEntry, index, (IPTR)&listentry);
112 if (!listentry)
114 set(data->list, MUIA_List_Active, strtext[0] ? MUIV_List_Active_Off : 0);
115 break;
118 if (stricmp(strtext, listentry) == 0)
120 set(data->list, MUIA_List_Active, index);
121 break;
125 return TRUE;
128 void PopPublicScreenObjStrFunc(struct Hook *hook, Object *popup, Object *str)
130 STRPTR listentry;
132 DoMethod(popup, MUIM_List_GetEntry, MUIV_List_GetEntry_Active, (IPTR)&listentry);
134 if (listentry)
136 if (strcmp(listentry, PSD_NAME_DEFAULT) == 0)
137 set(str, MUIA_String_Contents, "");
138 else
139 set(str, MUIA_String_Contents, listentry);
143 IPTR PopPublicScreen__OM_NEW(struct IClass *cl, Object *obj, struct opSet *msg)
145 Object *lv, *list;
147 obj = (Object *)DoSuperNewTags
149 cl, obj, NULL,
150 MUIA_Popobject_Object, (IPTR)(lv = (Object *)ListviewObject,
151 MUIA_Listview_List, (IPTR)(list = (Object *)ListObject,
152 InputListFrame,
153 End),
154 End),
155 TAG_MORE, (IPTR) msg->ops_AttrList
158 if (obj)
160 struct PopPublicScreen_DATA *data = INST_DATA(cl, obj);
162 data->list = list;
164 data->strobj_hook.h_Entry = HookEntry;
165 data->strobj_hook.h_SubEntry = (HOOKFUNC)PopPublicScreenStrObjFunc;
166 data->strobj_hook.h_Data = data;
168 data->objstr_hook.h_Entry = HookEntry;
169 data->objstr_hook.h_SubEntry = (HOOKFUNC)PopPublicScreenObjStrFunc;
170 data->objstr_hook.h_Data = data;
172 SetAttrs(obj, MUIA_Popobject_StrObjHook, (IPTR)&data->strobj_hook,
173 MUIA_Popobject_ObjStrHook, (IPTR)&data->objstr_hook,
174 TAG_DONE);
177 DoMethod(lv, MUIM_Notify, MUIA_Listview_DoubleClick, TRUE,
178 (IPTR)obj, 2, MUIM_Popstring_Close, TRUE);
181 return (IPTR)obj;
184 ZUNE_CUSTOMCLASS_1(
185 PopPublicScreen, NULL, MUIC_Popobject, NULL,
186 OM_NEW, struct opSet*
189 /* Preferences System tab class */
191 struct MUI_SystemPData
193 Object *screen_name_string;
194 Object *call_psi_button;
195 Object *pop_to_front_checkmark;
196 Object *hotkey_string;
197 Object *show_icon_checkmark;
198 Object *show_menu_checkmark;
199 Object *on_startup_checkmark;
200 Object *arexx_checkmark;
201 Object *first_bubble_slider;
202 Object *next_bubble_slider;
203 struct Hook psiHook;
206 static IPTR ExecuteScreenInspectorFunc(struct Hook *hook, Object *caller, void *data)
208 struct TagItem tags[] =
210 { SYS_Asynch, TRUE },
211 { SYS_Input, 0 },
212 { SYS_Output, 0 },
213 { NP_StackSize, AROS_STACKSIZE },
214 { TAG_DONE }
217 if (SystemTagList("sys:prefs/psi", tags) == -1)
219 return (IPTR) FALSE;
222 return (IPTR) TRUE;
225 static IPTR SystemP_New(struct IClass *cl, Object *obj, struct opSet *msg)
227 struct MUI_SystemPData *data;
228 struct MUI_SystemPData d;
230 obj = (Object *) DoSuperNewTags
232 cl, obj, NULL,
234 MUIA_Group_Columns, 2,
235 MUIA_Group_SameSize, TRUE,
237 Child, (IPTR) VGroup,
238 GroupFrameT(_(MSG_PUBLIC_SCREEN)),
239 MUIA_Group_VertSpacing, 0,
240 Child, (IPTR) VSpace(0),
241 Child, (IPTR) ColGroup(2),
242 Child, (IPTR) Label1(_(MSG_NAME)),
243 Child, NewObject(PopPublicScreen_CLASS->mcc_Class, NULL,
244 MUIA_Popstring_String, (IPTR) (d.screen_name_string = StringObject, MUIA_Frame, MUIV_Frame_String, End),
245 MUIA_Popstring_Button, PopButton(MUII_PopUp),
246 TAG_END),
247 Child, HSpace(0),
248 Child, (IPTR) (d.call_psi_button = SimpleButton(_(MSG_CALL_INSPECTOR))),
249 Child, (IPTR) Label1(_(MSG_POP_TO_FRONT)),
250 Child, HGroup,
251 Child, (IPTR) (d.pop_to_front_checkmark = MakeCheck(NULL)),
252 Child, RectangleObject, End,
253 End,
254 End,
255 Child, (IPTR) VSpace(0),
256 End,
258 Child, (IPTR) VGroup,
259 GroupFrameT(_(MSG_ICONIFICATION)),
260 MUIA_Group_VertSpacing, 0,
261 Child, (IPTR) VSpace(0),
262 Child, (IPTR) ColGroup(2),
263 Child, (IPTR) Label1(_(MSG_HOTKEY)),
264 Child, (IPTR) (d.hotkey_string = MakeString()),
265 Child, (IPTR) Label1(_(MSG_SHOW)),
266 Child, HGroup,
267 Child, (IPTR) (d.show_icon_checkmark = MakeCheck(NULL)),
268 Child, (IPTR) Label1(_(MSG_ICON)),
269 Child, (IPTR) (d.show_menu_checkmark = MakeCheck(NULL)),
270 Child, (IPTR) Label1(_(MSG_MENU)),
271 End,
272 Child, (IPTR) Label1(_(MSG_ON_STARTUP)),
273 Child, HGroup,
274 Child, (IPTR) (d.on_startup_checkmark = MakeCheck(NULL)),
275 Child, RectangleObject, End,
276 End,
277 End,
278 Child, (IPTR) VSpace(0),
279 End,
281 Child, (IPTR) VGroup,
282 GroupFrameT(_(MSG_INTERFACES)),
283 MUIA_Group_VertSpacing, 0,
284 Child, (IPTR) VSpace(0),
285 Child, (IPTR) HGroup,
286 Child, HSpace(0),
287 Child, (IPTR) Label1(_(MSG_AREXX)),
288 Child, (IPTR) (d.arexx_checkmark = MakeCheck(NULL)),
289 Child, HSpace(0),
290 End,
291 Child, (IPTR) VSpace(0),
292 End,
294 Child, (IPTR) VGroup,
295 GroupFrameT(_(MSG_BUBBLE_HELP)),
296 MUIA_Group_VertSpacing, 0,
297 Child, (IPTR) VSpace(0),
298 Child, (IPTR) ColGroup(2),
299 Child, (IPTR) Label1(_(MSG_FIRST_BUBBLE)),
300 Child, (IPTR) (d.first_bubble_slider = NewObject(BubbleSlider_CLASS->mcc_Class, NULL, MUIA_Numeric_Min, 0, MUIA_Numeric_Max, 50, TAG_END)),
301 Child, (IPTR) Label1(_(MSG_NEXT_BUBBLE)),
302 Child, (IPTR) (d.next_bubble_slider = NewObject(BubbleSlider_CLASS->mcc_Class, NULL, MUIA_Numeric_Min, 0, MUIA_Numeric_Max, 50, TAG_END)),
303 End,
304 Child, (IPTR) VSpace(0),
305 End,
307 TAG_MORE, (IPTR) msg->ops_AttrList);
309 if (!obj) return FALSE;
311 d.psiHook.h_Entry = HookEntry;
312 d.psiHook.h_SubEntry = (HOOKFUNC) ExecuteScreenInspectorFunc;
314 data = INST_DATA(cl, obj);
315 *data = d;
317 DoMethod(
318 d.first_bubble_slider, MUIM_Notify, MUIA_Numeric_Value, MUIV_EveryTime,
319 d.next_bubble_slider, (IPTR) 3, MUIM_Set, MUIA_Disabled, MUIV_NotTriggerValue
322 DoMethod(
323 d.call_psi_button, MUIM_Notify, MUIA_Pressed, FALSE,
324 obj, (IPTR) 2, MUIM_CallHook, &data->psiHook
327 return (IPTR)obj;
331 static IPTR SystemP_ConfigToGadgets(struct IClass *cl, Object *obj,
332 struct MUIP_Settingsgroup_ConfigToGadgets *msg)
334 struct MUI_SystemPData *data = INST_DATA(cl, obj);
336 ConfigToString(msg->configdata, MUICFG_PublicScreen, data->screen_name_string);
337 ConfigToCheckmark(msg->configdata, MUICFG_PublicScreen_PopToFront, data->pop_to_front_checkmark);
338 ConfigToString(msg->configdata, MUICFG_Iconification_Hotkey, data->hotkey_string);
339 ConfigToCheckmark(msg->configdata, MUICFG_Iconification_ShowIcon, data->show_icon_checkmark);
340 ConfigToCheckmark(msg->configdata, MUICFG_Iconification_ShowMenu, data->show_menu_checkmark);
341 ConfigToCheckmark(msg->configdata, MUICFG_Iconification_OnStartup, data->on_startup_checkmark);
342 ConfigToCheckmark(msg->configdata, MUICFG_Interfaces_EnableARexx, data->arexx_checkmark);
343 ConfigToSlider(msg->configdata, MUICFG_BubbleHelp_FirstDelay, data->first_bubble_slider);
344 ConfigToSlider(msg->configdata, MUICFG_BubbleHelp_NextDelay, data->next_bubble_slider);
346 return 1;
350 static IPTR SystemP_GadgetsToConfig(struct IClass *cl, Object *obj,
351 struct MUIP_Settingsgroup_GadgetsToConfig *msg)
353 struct MUI_SystemPData *data = INST_DATA(cl, obj);
355 StringToConfig(data->screen_name_string, msg->configdata, MUICFG_PublicScreen);
356 CheckmarkToConfig(data->pop_to_front_checkmark, msg->configdata, MUICFG_PublicScreen_PopToFront);
357 StringToConfig(data->hotkey_string, msg->configdata, MUICFG_Iconification_Hotkey);
358 CheckmarkToConfig(data->show_icon_checkmark, msg->configdata, MUICFG_Iconification_ShowIcon);
359 CheckmarkToConfig(data->show_menu_checkmark, msg->configdata, MUICFG_Iconification_ShowMenu);
360 CheckmarkToConfig(data->on_startup_checkmark, msg->configdata, MUICFG_Iconification_OnStartup);
361 CheckmarkToConfig(data->arexx_checkmark, msg->configdata, MUICFG_Interfaces_EnableARexx);
362 SliderToConfig(data->first_bubble_slider, msg->configdata, MUICFG_BubbleHelp_FirstDelay);
363 SliderToConfig(data->next_bubble_slider, msg->configdata, MUICFG_BubbleHelp_NextDelay);
365 return TRUE;
368 BOOPSI_DISPATCHER(IPTR, SystemP_Dispatcher, cl, obj, msg)
370 switch (msg->MethodID)
372 case OM_NEW: return SystemP_New(cl, obj, (struct opSet *)msg);
373 case MUIM_Settingsgroup_ConfigToGadgets: return SystemP_ConfigToGadgets(cl,obj,(APTR)msg);break;
374 case MUIM_Settingsgroup_GadgetsToConfig: return SystemP_GadgetsToConfig(cl,obj,(APTR)msg);break;
377 return DoSuperMethodA(cl, obj, msg);
379 BOOPSI_DISPATCHER_END
382 * Class descriptor.
384 const struct __MUIBuiltinClass _MUIP_System_desc = {
385 "System",
386 MUIC_Group,
387 sizeof(struct MUI_SystemPData),
388 (void*)SystemP_Dispatcher
392 static const UBYTE icon32[] =
394 0x00, 0x00, 0x00, 0x18, // width
395 0x00, 0x00, 0x00, 0x13, // height
396 'B', 'Z', '2', '\0',
397 0x00, 0x00, 0x00, 0x6e, // number of bytes
399 0x42, 0x5a, 0x68, 0x39, 0x31, 0x41, 0x59, 0x26, 0x53, 0x59, 0x26, 0xc3,
400 0xe9, 0x90, 0x00, 0x03, 0x0e, 0x06, 0x42, 0x80, 0x02, 0x00, 0x01, 0x08,
401 0x00, 0x42, 0x40, 0x00, 0x00, 0xb0, 0x00, 0xb6, 0xc8, 0x42, 0x54, 0xc9,
402 0x82, 0x92, 0xa1, 0x90, 0x42, 0xa6, 0x9a, 0x3a, 0x2a, 0xdb, 0x65, 0x78,
403 0xa8, 0x34, 0xa5, 0xea, 0x52, 0xe1, 0x49, 0xd2, 0x44, 0xc1, 0x51, 0x3d,
404 0xa9, 0x33, 0x43, 0x43, 0x4a, 0xad, 0x15, 0x30, 0x41, 0x40, 0xf7, 0x23,
405 0x22, 0x44, 0x50, 0x81, 0x2b, 0x08, 0x18, 0x58, 0x95, 0xa7, 0x41, 0x8b,
406 0x24, 0x50, 0x60, 0x97, 0x13, 0xa0, 0xd1, 0x42, 0x0d, 0x52, 0x86, 0x20,
407 0x62, 0x6c, 0x08, 0xf8, 0xbb, 0x92, 0x29, 0xc2, 0x84, 0x81, 0x36, 0x1f,
408 0x4c, 0x80,
412 Object *systemclass_get_icon(void)
414 return RawimageObject,
415 MUIA_Rawimage_Data, icon32,
416 End;