requester with timeout, countdown visible on req window

11 posts / 0 new
Last post
jabirulo
jabirulo's picture
Offline
Last seen: 1 month 1 week ago
Joined: 2013-05-30 00:53
requester with timeout, countdown visible on req window
Hi, just trying to add a requester that timesout: .. requester = IIntuition->NewObject(NULL, "requester.class", REQ_TitleText, VERS" ("DATE")", REQ_BodyText, reqtext, REQ_GadgetText, GetString(&li, MSG_REQ_ABORT_BUTTON), REQ_TimeOutSecs, reqtout, TAG_DONE); answer = IIntuition->IDoMethod(requester, RM_OPENREQ, NULL, NULL, NULL); IIntuition->DisposeObject(requester); if(answer == 0) // user ABORTed reboot/poweroff 'LAST CHANCE', end properly .. reqtext string is: \033cSystem will %s in \033b%d\033n seconds.\nPlease wait!!! It shows the time (reqtout) the user defined in reqtext string, but is it posible that such number/countdown is visible (real time) in the requester? Ant chance that with IIntuition->DoGadgetMethod() can I achieve what I'm trying? Just newbie to programming. If soimeone can just point me (web/code/SDK autodocs..) where to look i'll be very happy. Just uploaded all c source here (poff.c). In my account/content. Is it visible for everyone? If not what must I do/change for free-viewing such piece of "great" mess-code. ;-) TIA
Ami603
Ami603's picture
Offline
Last seen: 2 years 2 months ago
Joined: 2011-10-11 23:11
@Jabirulo: According to the
@Jabirulo: According to the autodocs, REQ_BodyText accepts OM_NEW , OM_SET methods, so it should be safe to RefreshSetAttrs() with the updated string.
salass00
salass00's picture
Offline
Last seen: 1 month 1 week ago
Joined: 2011-02-03 11:27
According to the autodocs,
According to the autodocs, REQ_BodyText accepts OM_NEW , OM_SET methods, so it should be safe to RefreshSetAttrs() with the updated string.
The function you want is SetAttrs(), RefreshGadgetAttrs() is for gadgets only. Other than that I don't see how you would do this given that the RM_OPENREQ method doesn't return until after the requester has been closed either because it timed out or the user clicked it away.
jabirulo
jabirulo's picture
Offline
Last seen: 1 month 1 week ago
Joined: 2013-05-30 00:53
I tried with this piece of
I tried with this piece of code:
  1. while(sec && answer) // 'LAST CHANCE' countdown and "ugly" requester
  2. {
  3. snprintf(reqtext, sizeof(reqtext), GetString(&li, MSG_REQ_ABORT_TXT),reqoption,sec);
  4. result = IIntuition->SetAttrs(requester,
  5. REQ_GadgetText, GetString(&li, MSG_REQ_ABORT_BUTTON),
  6. REQ_BodyText, reqtext,
  7. REQ_TimeOutSecs, 1,
  8. TAG_DONE);
  9. answer = IIntuition->IDoMethod(requester, RM_OPENREQ, NULL, NULL, NULL);
  10. sec--;
  11. }
But requester opens/closes (flickers), don't know how to proceed. So I changed to use ReAction and fuelgauge_cl and shows better. TIA
AOS4.1/SAM460ex/PPC460EX-1155MHZ/2048MB/RadeonHD6570/SSD120GB/DVDRW :-P
trixie
trixie's picture
Offline
Last seen: 1 day 14 hours ago
Joined: 2011-02-03 13:58
Opening one requester on top
Opening one requester on top of another is a hopelessly brain-dead idea, you'd better implement your own solution. But Requester Class could do with an enhancement: if it can support timeout (which it does), it could also support displaying the countdown.
SAM440ep-flex @ 667MHz / 1GB RAM / Radeon 9250 / AmigaOS 4.1 Final Edition Author of WordNet for OS4
jabirulo
jabirulo's picture
Offline
Last seen: 1 month 1 week ago
Joined: 2013-05-30 00:53
Yes, its quite ugly think
Yes, its quite ugly think IMHO, will fill a BZ enhancement ASAP. Other thing I get 'warning: assignment from incompatible pointer type' pointing to FuelGaugeEnd. Any idea why? (sec is a int32 variable if it matters)
  1. ..
  2. WINDOW_ParentGroup, VGroupObject,
  3. LAYOUT_AddChild, gadgets[GID_GAUGE] = FuelGaugeObject,
  4. GA_ID, GID_GAUGE,
  5. FUELGAUGE_Justification, FGJ_CENTER,
  6. FUELGAUGE_Min, 0,
  7. FUELGAUGE_Max, sec,
  8. FUELGAUGE_Level, sec,
  9. FUELGAUGE_Percent, FALSE,
  10. FUELGAUGE_TickSize, 0,
  11. FUELGAUGE_Ticks, 0,
  12. FuelGaugeEnd,
  13.  
  14. LAYOUT_AddImage, LabelObject,
  15. LABEL_Text, reqtext,
  16. LABEL_Justification, LJ_CENTER,
  17. LabelEnd,
  18. ..
TIA
AOS4.1/SAM460ex/PPC460EX-1155MHZ/2048MB/RadeonHD6570/SSD120GB/DVDRW :-P
thomas
thomas's picture
Offline
Last seen: 1 day 7 hours ago
Joined: 2011-05-16 14:23
How is gadgets[] defined?
How is gadgets[] defined?
salass00
salass00's picture
Offline
Last seen: 1 month 1 week ago
Joined: 2011-02-03 11:27
I'm guessing you have defined
I'm guessing you have defined the gadgets array as 'struct Gadget *'. This causes the warning as the return value from NewObject() is of type 'Object *' (FuelGaugeObject is just a fancy macro that hides the call to NewObject()). Either add a cast like: LAYOUT_AddChild, gadgets[GID_GAUGE] = (struct Gadget *)FuelGaugeObject or just change the gadgets array type to 'Object *' (may require casts in other places though, like if you use SetGadgetAttrs()).
jabirulo
jabirulo's picture
Offline
Last seen: 1 month 1 week ago
Joined: 2013-05-30 00:53
@thomas & salass00 struct
@thomas & salass00 struct Gadget *gadgets[GID_LAST]; cast'ed LAYOUT_AddChild, gadgets[GID_GAUGE] = (struct Gadget *)FuelGaugeObject, and no more warning. THX. BTW is there a "big" problem/bug if not cast'ed? OR is just gcc parser/compiler issue (don't know how to explain, hope you understand what I mean) TIA
AOS4.1/SAM460ex/PPC460EX-1155MHZ/2048MB/RadeonHD6570/SSD120GB/DVDRW :-P
salass00
salass00's picture
Offline
Last seen: 1 month 1 week ago
Joined: 2011-02-03 11:27
The cast in this case is
The cast in this case is basically just a way to tell the compiler to shut up and that you know what you're doing. You could just ignore the compiler warning or disable it but I wouldn't recommend it as compiler warnings can be useful to find mistakes that really are bugs too.
trixie
trixie's picture
Offline
Last seen: 1 day 14 hours ago
Joined: 2011-02-03 13:58
@jabirulo Older ReAction
@jabirulo Older ReAction examples (even some in the SDK I think) declare BOOPSI gadgets as pointers to struct Gadget. However, since one of the recent SDKs all BOOPSI objects are meant to be declared as Object pointers so I suggest you do that in your code as well. But as salass00 says, you'll need to cast them to (struct Gadget *) for SetGadgetAttrs() or RefreshSetGadgetAttrs() because these functions take a struct Gadget pointer as parameter.
SAM440ep-flex @ 667MHz / 1GB RAM / Radeon 9250 / AmigaOS 4.1 Final Edition Author of WordNet for OS4
Log in or register to post comments