Problem with WorkbenchControl
  • Just looking around
    zzd10h
    Posts: 20 from 2012/1/10
    Bonjour,
    I'm trying to port, for fun, one of my little programs from OS4 to MOS (on a PowerBook under MOS3.2). The goal of this program is to detect selected files in Workbench and to pass them to YAM or SimpleMail as attachment.

    But I have problem with WorkbenchControl function.

    The following code works under AOS4 but I can't find why it fails under MOS.
    The call to WorkbenchControl always return FALSE (therefore "Error" in my sample)

    Certainly that I miss a little thing...

    I compile the following code with
    gcc AttachMail.c -o AttachMail -noixemul

    When I start it (even with files selected in Ambient) I obtain "Error"

    Thank for your help


    Code:

    #include <stdio.h>
    #include <proto/exec.h>
    #include <proto/wb.h>
    #include <workbench/workbench.h>
    #include <string.h>

    int main(int argc,char **argv)
    {

    struct List * selectIcons;

    if (WorkbenchControl(NULL,WBCTRLA_GetSelectedIconList,&selectIcons,TAG_DONE))
    {

    printf("OK n");
    WorkbenchControl(NULL,WBCTRLA_FreeSelectedIconList,selectIcons,TAG_DONE);
    }
    else
    {
    printf("Error n") ;
    }

    return 0;
    }


    [ Edité par zzd10h 10.07.2013 - 21:54 ]
  • »10.07.13 - 19:53
    Profile
  • MorphOS Developer
    Piru
    Posts: 587 from 2003/2/24
    From: finland, the l...
    WBCTRLA_GetSelectedIconList and WBCTRLA_FreeSelectedIconList return an error because they are not implemented.

    You can see the implemented tags here:

    http://morphosambient.cvs.sourceforge.net/viewvc/morphosambient/ambient/wblib/control.c?view=markup

    [ Edited by Piru 10.07.2013 - 23:06 ]
  • »10.07.13 - 20:05
    Profile
  • Just looking around
    zzd10h
    Posts: 20 from 2012/1/10
    Thank you Piru,
    I thought that it was implemented because it is in GG/os-include/workbench/workbench.h

    But I don't need to search more ;)

    Is a similar function on Ambient to retrieve selected files ?

    [ Edité par zzd10h 10.07.2013 - 22:17 ]
  • »10.07.13 - 20:12
    Profile
  • MorphOS Developer
    itix
    Posts: 1520 from 2003/2/24
    From: Finland
    Quote:

    zzd10h wrote:
    Thank you Piru,
    I thought that it was implemented because it is in GG/os-include/workbench/workbench.h

    But I don't need to search more ;)

    Is a similar function on Ambient to retrieve selected files ?

    [ Edité par zzd10h 10.07.2013 - 22:17 ]


    I dont see how this could be implemented in Ambient. In Ambient you can have icons selected in multiple windows (drawers). In Workbench you have only one global lasso that selects only icons which are visible (i.e. not underneath other window or otherwise hidden) or select icons only in one window.

    I dont know if this could be implemened using mime types or some arexx script. Unable to check here.
    1 + 1 = 3 with very large values of 1
  • »10.07.13 - 22:41
    Profile
  • jPV
  • Yokemate of Keyboards
    Yokemate of Keyboards
    jPV
    Posts: 2096 from 2003/2/24
    From: po-RNO
    I think using separate program for this on Ambient is overkill. I'd do this just with Ambient's mime types. Select files you want to send and have a hotkey or context menu action to send them to a little arexx script (or maybe here could be separate program too) which adds them to SimpleMail or YAM. ARexx script could detect if either of them is running, and if not, start one of them before adding files.

    [ Edited by jPV 11.07.2013 - 08:56 ]
  • »11.07.13 - 05:55
    Profile Visit Website
  • Fab
  • MorphOS Developer
    Fab
    Posts: 1331 from 2003/6/16
    I implemented the necessary internal functions to retrieve selected files in a given lister (and list all views as well). So it is actually possible to do that using a REXX script.

    For instance, create some selected.rexx file with the following contents:

    /**/

    address AMBIENT
    ViewList views

    /* say 'number of views ' views.count */

    do i = 0 to views.count - 1
    viewpath = substr(views.i, pos(':', views.i)+1)
    viewid = substr(views.i, 1, pos(':', views.i)-1)

    /*
    say 'viewpath ' viewpath
    say 'viewid ' viewid
    */

    GetSelectedNames selectedfiles viewid

    do j = 0 to selectedfiles.count - 1
    say selectedfiles.j
    end

    end

    This example will list all selected files in all opened views. In your case, you might want to get only files of the active view, so you'd need to check against active window title, i suppose.

    That said, doing that with mimetypes as jPV explained would be even better.


    [ Edited by Fab 11.07.2013 - 11:32 ]
  • »11.07.13 - 09:15
    Profile Visit Website
  • Just looking around
    zzd10h
    Posts: 20 from 2012/1/10
    Thanks you guys for your suggestions,
    and merci Fab for your sample.
  • »11.07.13 - 09:48
    Profile