2 ** OpenURL - MUI preferences for openurl.library
4 ** Written by Troels Walsted Hansen <troels@thule.no>
5 ** Placed in the public domain.
8 ** - Alfonso Ranieri <alforan@tin.it>
9 ** - Stefan Kost <ensonic@sonicpulse.de>
11 ** Ported to OS4 by Alexandre Balaban <alexandre@balaban.name>
13 ** Pop public ports object
18 #include "libraries/openurl.h"
19 #include <exec/execbase.h>
21 /**************************************************************************/
26 static struct MUI_CustomClass
*listClass
= NULL
;
28 #define listObject BOOPSIOBJMACRO_START(listClass->mcc_Class)
30 #define listObject NewObject(listClass->mcc_Class,NULL
34 mListNew(struct IClass
*cl
,Object
*obj
,struct opSet
*msg
)
36 return (ULONG
)DoSuperNew(cl
,obj
,
37 MUIA_Frame
, MUIV_Frame_InputList
,
38 MUIA_Background
, MUII_ListBack
,
39 MUIA_List_AutoVisible
, TRUE
,
40 MUIA_List_ConstructHook
, MUIV_List_ConstructHook_String
,
41 MUIA_List_DestructHook
, MUIV_List_DestructHook_String
,
42 TAG_MORE
,(ULONG
)msg
->ops_AttrList
);
45 /**************************************************************************/
48 mListSetup(struct IClass
*cl
,Object
*obj
,Msg msg
)
52 if (!DoSuperMethodA(cl
,obj
,msg
)) return FALSE
;
54 DoSuperMethod(cl
,obj
,MUIM_List_Clear
);
58 for (mstate
= SysBase
->PortList
.lh_Head
; mstate
->ln_Succ
; mstate
= mstate
->ln_Succ
)
60 // Zune Listclass doesn't support Insert_Sorted
61 DoSuperMethod(cl
,obj
,MUIM_List_InsertSingle
,(ULONG
)mstate
->ln_Name
,MUIV_List_Insert_Bottom
);
63 DoSuperMethod(cl
,obj
,MUIM_List_InsertSingle
,(ULONG
)mstate
->ln_Name
,MUIV_List_Insert_Sorted
);
71 /**************************************************************************/
73 M_DISP(listDispatcher
)
77 switch (msg
->MethodID
)
79 case OM_NEW
: return mListNew(cl
,obj
,(APTR
)msg
);
81 case MUIM_Setup
: return mListSetup(cl
,obj
,(APTR
)msg
);
83 default: return DoSuperMethodA(cl
,obj
,msg
);
87 M_DISPEND(listDispatcher
)
89 /**************************************************************************/
94 return (ULONG
)(listClass
= MUI_CreateCustomClass(NULL
,MUIC_List
,NULL
,0,DISP(listDispatcher
)));
97 /**************************************************************************/
100 disposeListClass(void)
102 if (listClass
) MUI_DeleteCustomClass(listClass
);
105 /**************************************************************************/
111 //struct Hook *hook = (struct Hook *)REG_A0;
112 Object
*pop
= (Object
*)REG_A2
;
113 Object
*win
= (Object
*)REG_A1
;
114 #elif defined(__AROS__)
115 AROS_UFH3S(void, windowFun
,
116 AROS_UFHA(struct Hook
*, hook
, A0
),
117 AROS_UFHA(Object
* , pop
, A2
),
118 AROS_UFHA(Object
* , win
, A1
))
122 static void SAVEDS ASM
123 windowFun(REG(a0
,struct Hook
*hook
),REG(a2
,Object
*pop
),REG(a1
,Object
*win
))
126 set(win
,MUIA_Window_DefaultObject
,pop
);
133 static struct EmulLibEntry windowTrap
= {TRAP_LIB
,0,(void (*)(void))windowFun
};
134 static struct Hook windowHook
= {0,0,(HOOKFUNC
)&windowTrap
};
136 static struct Hook windowHook
= {0,0,(HOOKFUNC
)&windowFun
};
139 /***********************************************************************/
145 //struct Hook *hook = (struct Hook *)REG_A0;
146 Object
*list
= (Object
*)REG_A2
;
147 Object
*str
= (Object
*)REG_A1
;
148 #elif defined(__AROS__)
149 AROS_UFH3S(ULONG
, openFun
,
150 AROS_UFHA(struct Hook
*, hook
, A0
),
151 AROS_UFHA(Object
* , list
, A2
),
152 AROS_UFHA(Object
* , str
, A1
))
156 static ULONG SAVEDS ASM
157 openFun(REG(a0
,struct Hook
*hook
),REG(a2
,Object
*list
),REG(a1
,Object
*str
))
163 s
= (STRPTR
)xget(str
,MUIA_String_Contents
);
167 DoMethod(list
,MUIM_List_GetEntry
,i
,(ULONG
)&x
);
170 set(list
,MUIA_List_Active
,MUIV_List_Active_Off
);
176 set(list
,MUIA_List_Active
,i
);
188 static struct EmulLibEntry openTrap
= {TRAP_LIB
,0,(void (*)(void))openFun
};
189 static struct Hook openHook
= {0,0,(HOOKFUNC
)&openTrap
};
191 static struct Hook openHook
= {0,0,(HOOKFUNC
)&openFun
};
194 /***********************************************************************/
197 static void closeFun(void)
199 //struct Hook *hook = (struct Hook *)REG_A0;
200 Object
*list
= (Object
*)REG_A2
;
201 Object
*str
= (Object
*)REG_A1
;
202 #elif defined(__AROS__)
203 AROS_UFH3S(void, closeFun
,
204 AROS_UFHA(struct Hook
*, hook
, A0
),
205 AROS_UFHA(Object
* , list
, A2
),
206 AROS_UFHA(Object
* , str
, A1
))
210 static void SAVEDS ASM
211 closeFun(REG(a0
,struct Hook
*hook
),REG(a2
,Object
*list
),REG(a1
,Object
*str
))
216 DoMethod(list
,MUIM_List_GetEntry
,MUIV_List_GetEntry_Active
,(ULONG
)&port
);
219 TEXT buf
[PORT_LEN
], *dot
, *digit
;
221 dot
= strrchr(port
,'.');
227 for (digit
= dot
; *digit
; digit
++)
228 if (!isdigit(*digit
))
236 stccpy(buf
,port
,dot
-port
);
242 set(str
,MUIA_String_Contents
,port
);
249 static struct EmulLibEntry closeTrap
= {TRAP_LIB
,0,(void (*)(void))closeFun
};
250 static struct Hook closeHook
= {0,0,(HOOKFUNC
)&closeTrap
};
252 static struct Hook closeHook
= {0,0,(HOOKFUNC
)&closeFun
};
255 /***********************************************************************/
258 mNew(struct IClass
*cl
,Object
*obj
,struct opSet
*msg
)
262 if (obj
= (Object
*)DoSuperNew(cl
,obj
,
264 MUIA_Popstring_String
, ostring(GetTagData(MUIA_Popport_Len
,64,msg
->ops_AttrList
),GetTagData(MUIA_Popport_Key
,0,msg
->ops_AttrList
),0),
265 MUIA_Popstring_Button
, opopbutton(MUII_PopUp
,0),
267 MUIA_Popobject_Object
, lv
= ListviewObject
,
268 MUIA_Listview_List
, listObject
, End
,
270 MUIA_Popobject_WindowHook
, &windowHook
,
271 MUIA_Popobject_StrObjHook
, &openHook
,
272 MUIA_Popobject_ObjStrHook
, &closeHook
,
274 TAG_MORE
,(ULONG
)msg
->ops_AttrList
))
276 DoMethod(lv
,MUIM_Notify
,MUIA_Listview_DoubleClick
,TRUE
,(ULONG
)obj
,2,MUIM_Popstring_Close
,TRUE
);
282 /***********************************************************************/
288 switch (msg
->MethodID
)
290 case OM_NEW
: return mNew(cl
,obj
,(APTR
)msg
);
291 default: return DoSuperMethodA(cl
,obj
,msg
);
295 M_DISPEND(dispatcher
)
297 /***********************************************************************/
300 initPopportClass(void)
304 if (g_popportClass
= MUI_CreateCustomClass(NULL
,MUIC_Popobject
,NULL
,0,DISP(dispatcher
)))
313 /**************************************************************************/
316 disposePopportClass(void)
319 if (g_popportClass
) MUI_DeleteCustomClass(g_popportClass
);
322 /**************************************************************************/