update patch to work with build system changes
[AROS-Contrib.git] / Networking / Apps / OWB / browsertab.c
blob890fcaac94ae2a5def78f82124602e2977ae0303
1 /*
2 Copyright © 2009, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <exec/memory.h>
7 #include <utility/tagitem.h>
8 #include <dos/dos.h>
9 #include <libraries/mui.h>
11 #include <proto/exec.h>
12 #include <proto/muimaster.h>
13 #include <proto/intuition.h>
14 #include <proto/utility.h>
15 #include <proto/dos.h>
16 #include <proto/alib.h>
17 #include <aros/debug.h>
18 #include <zune/customclasses.h>
20 #include "browsertab.h"
21 #include "browsertab_private.h"
23 #include "locale.h"
25 struct MUI_CustomClass *BrowserTabClass;
28 /*** Methods ****************************************************************/
29 IPTR BrowserTab__OM_NEW(Class *CLASS, Object *self, struct opSet *message)
31 struct BrowserTab_DATA *data = NULL;
32 struct TagItem *tag = NULL, *tstate = message->ops_AttrList;
33 Object *titleObject;
34 STRPTR title = NULL;
36 /* Parse initial attributes --------------------------------------------*/
37 while ((tag = NextTagItem(&tstate)) != NULL)
39 switch (tag->ti_Tag)
41 case MUIA_BrowserTab_Title:
42 title = StrDup((STRPTR) tag->ti_Data);
43 if(!title)
44 return (IPTR) NULL;
45 break;
46 default:
47 continue; /* Don't supress non-processed tags */
50 tag->ti_Tag = TAG_IGNORE;
53 if(title == NULL)
55 title = StrDup(_(MSG_Untitled));
56 if(!title)
57 return (IPTR) NULL;
60 self = (Object *) DoSuperNewTags
62 CLASS, self, NULL,
63 MUIA_Frame, MUIV_Frame_None,
64 MUIA_InnerLeft, 0,
65 MUIA_InnerRight, 0,
66 MUIA_InnerTop, 0,
67 MUIA_InnerBottom, 0,
68 MUIA_Group_Horiz, TRUE,
69 MUIA_Group_HorizSpacing, 0,
70 MUIA_ShowSelState, FALSE,
71 Child, (IPTR)(titleObject = TextObject,
72 MUIA_Frame, MUIV_Frame_None,
73 MUIA_Text_SetMin, FALSE,
74 MUIA_Text_Contents, (IPTR)title,
75 End),
76 TAG_MORE, (IPTR) message->ops_AttrList
79 if (self == NULL)
80 return (IPTR) NULL;
82 data = INST_DATA(CLASS, self);
83 data->title = title;
84 data->titleObject = titleObject;
86 return (IPTR) self;
89 IPTR BrowserTab__OM_DISPOSE(Class *CLASS, Object *self, Msg message)
91 struct BrowserTab_DATA *data = INST_DATA(CLASS, self);
92 IPTR ret;
93 ret = DoSuperMethodA(CLASS, self, message);
94 FreeVec(data->title);
95 return ret;
98 IPTR BrowserTab__OM_SET(Class *cl, Object *obj, struct opSet *msg)
100 struct BrowserTab_DATA *data = INST_DATA(cl, obj);
101 struct TagItem *tags = msg->ops_AttrList;
102 struct TagItem *tag;
104 while ((tag = NextTagItem(&tags)) != NULL)
106 switch(tag->ti_Tag)
108 case MUIA_BrowserTab_Title:
110 if(tag->ti_Data == (IPTR) NULL || ((char*) tag->ti_Data)[0] == 0)
111 tag->ti_Data = (IPTR) _(MSG_Untitled);
112 STRPTR newtitle = StrDup((STRPTR) tag->ti_Data);
113 if(!newtitle)
114 return FALSE;
115 FreeVec(data->title);
116 data->title = newtitle;
117 set(data->titleObject, MUIA_Text_Contents, data->title);
118 break;
120 default:
121 continue;
125 return DoSuperMethodA(cl, obj, (Msg)msg);
128 IPTR BrowserTab__OM_GET(Class *cl, Object *obj, struct opGet *msg)
130 struct BrowserTab_DATA *data = INST_DATA(cl, obj);
131 IPTR retval = TRUE;
133 switch(msg->opg_AttrID)
135 case MUIA_BrowserTab_Title:
136 *(STRPTR*)msg->opg_Storage = data->title;
137 break;
138 default:
139 retval = DoSuperMethodA(cl, obj, (Msg)msg);
140 break;
143 return retval;
146 /*** Setup ******************************************************************/
147 ZUNE_CUSTOMCLASS_4
149 BrowserTab, NULL, MUIC_Group, NULL,
150 OM_NEW, struct opSet*,
151 OM_DISPOSE, Msg,
152 OM_SET, struct opSet*,
153 OM_GET, struct opGet*