PtFileSelection

Hi,
I tried to use the confirm_display function.

In this function, I’m interested by the stat buf but both statbuf and
lstatbuf pointers are NULL!

But, if in this function, I stat() or lstat() the files by myself, both
stat() and lstat() succeed.

What’s wrong?

Thanks,
Alain.

Using the PtFileSelect widget in 6.3, is it possible to specify a pattern
that says what NOT to display?

I want to display everything but *.xyz files.

Bill Caroselli <qtps@earthlink.net> wrote:
BC > Using the PtFileSelect widget in 6.3, is it possible to specify a pattern
BC > that says what NOT to display?

BC > I want to display everything but *.xyz files.

I’m still interested in this answer. If it’s no, please just say so.

Also, is it possible to display file size right justified? PFM appears to
do it but I guess it’s not using the file select widget.

Bill Caroselli wrote:

Bill Caroselli <> qtps@earthlink.net> > wrote:
BC > Using the PtFileSelect widget in 6.3, is it possible to specify a pattern
BC > that says what NOT to display?

BC > I want to display everything but *.xyz files.

I’m still interested in this answer. If it’s no, please just say so.

It just uses fnmatch(). I don’t think fnmatch() allows that.

Also, is it possible to display file size right justified? PFM appears to
do it but I guess it’s not using the file select widget.

The Pt_ARG_LIST_COLUMN_ATTR resource should do the trick.

Wojtek Lerch <Wojtek_L@yahoo.ca> wrote:
WL > Bill Caroselli wrote:

Bill Caroselli <> qtps@earthlink.net> > wrote:
BC > Using the PtFileSelect widget in 6.3, is it possible to specify a pattern
BC > that says what NOT to display?

BC > I want to display everything but *.xyz files.

I’m still interested in this answer. If it’s no, please just say so.
WL > It just uses fnmatch(). I don’t think fnmatch() allows that.

OK. In reading about this function I found this:

Pattern Matching Special Characters
[bracket_expr]
Matches a single collating element as per Regular Expression Bracket
Expressions (1003.2 2.9.1.2) except that:
The exclamation point character (!) replaces the circumflex character
(^) in its role as a nonmatching list in the regular expression notation.

I’ve never been good at regular expressions. Does this mean it can or
can not be done?


Also, is it possible to display file size right justified? PFM appears to
do it but I guess it’s not using the file select widget.

WL > The Pt_ARG_LIST_COLUMN_ATTR resource should do the trick.

This looks helpful, but I’m not sure how to use it. If my file select
widget has a Pt_ARG_FS_FORMAT of “280n120d120s” and I want my columns
left aligned, left aligned and right aligned, what should my call to
PtSetResource() look like? I tried:

PtListColumnAttributes_t formats [3] = {
Pt_LIST_COLUMN_LEFT,
Pt_LIST_COLUMN_LEFT,
Pt_LIST_COLUMN_RIGHT };
PtSetResource( ABW_fileSel, Pt_ARG_LIST_COLUMN_ATTR, (long)formats, 0 );

but this did not seem to work.

Bill Caroselli wrote:

Pattern Matching Special Characters
[bracket_expr]
Matches a single collating element as per Regular Expression Bracket
Expressions (1003.2 2.9.1.2) except that:
The exclamation point character (!) replaces the circumflex character
(^) in its role as a nonmatching list in the regular expression notation.

I’ve never been good at regular expressions. Does this mean it can or
can not be done?

The ! only negates one character. For instance, “*.[!ch]” will match
all the files that have a one-character extension other than “.c” or
“.h”. I can’t think of many situations where this could be very useful…

PtListColumnAttributes_t formats [3] = {
Pt_LIST_COLUMN_LEFT,
Pt_LIST_COLUMN_LEFT,
Pt_LIST_COLUMN_RIGHT };
PtSetResource( ABW_fileSel, Pt_ARG_LIST_COLUMN_ATTR, (long)formats, 0 );

but this did not seem to work.

It’s an array resource. The last argument to PtSetResource() must be 3,
not 0.

Wojtek Lerch <Wojtek_L@yahoo.ca> wrote:
WL > Bill Caroselli wrote:
WL > …

PtListColumnAttributes_t formats [3] = {
Pt_LIST_COLUMN_LEFT,
Pt_LIST_COLUMN_LEFT,
Pt_LIST_COLUMN_RIGHT };
PtSetResource( ABW_fileSel, Pt_ARG_LIST_COLUMN_ATTR, (long)formats, 0 );

but this did not seem to work.

WL > It’s an array resource. The last argument to PtSetResource() must be 3,
WL > not 0.

Blush!

Thank you Wojtek

Bill Caroselli <qtps@earthlink.net> wrote:
BC > Wojtek Lerch <Wojtek_L@yahoo.ca> wrote:
BC > WL > Bill Caroselli wrote:
BC > WL > …

PtListColumnAttributes_t formats [3] = {
Pt_LIST_COLUMN_LEFT,
Pt_LIST_COLUMN_LEFT,
Pt_LIST_COLUMN_RIGHT };
PtSetResource( ABW_fileSel, Pt_ARG_LIST_COLUMN_ATTR, (long)formats, 0 );

but this did not seem to work.

BC > WL > It’s an array resource. The last argument to PtSetResource() must be 3,
BC > WL > not 0.

BC > Blush!

BC > Thank you Wojtek

This still has not right justified the size column.

Bill Caroselli wrote:

Bill Caroselli <> qtps@earthlink.net> > wrote:
BC > Wojtek Lerch <> Wojtek_L@yahoo.ca> > wrote:
BC > WL > Bill Caroselli wrote:
BC > WL > …

PtListColumnAttributes_t formats [3] = {
Pt_LIST_COLUMN_LEFT,
Pt_LIST_COLUMN_LEFT,
Pt_LIST_COLUMN_RIGHT };
PtSetResource( ABW_fileSel, Pt_ARG_LIST_COLUMN_ATTR, (long)formats, 0 );

but this did not seem to work.


BC > WL > It’s an array resource. The last argument to PtSetResource() must be 3,
BC > WL > not 0.

This still has not right justified the size column.

Um… That’s because a PtListColumnAttributes_t has a “reserved” array
at the end that consumes your flags… The docs do say “at least the
following members”, don’t they?

You just need to add braces around each array item. I have asked the
docs person to make this clearer.

Wojtek Lerch <Wojtek_L@yahoo.ca> wrote:
WL > Bill Caroselli wrote:

Bill Caroselli <> qtps@earthlink.net> > wrote:
BC > Wojtek Lerch <> Wojtek_L@yahoo.ca> > wrote:
BC > WL > Bill Caroselli wrote:
BC > WL > …

PtListColumnAttributes_t formats [3] = {
Pt_LIST_COLUMN_LEFT,
Pt_LIST_COLUMN_LEFT,
Pt_LIST_COLUMN_RIGHT };
PtSetResource( ABW_fileSel, Pt_ARG_LIST_COLUMN_ATTR, (long)formats, 0 );

but this did not seem to work.


BC > WL > It’s an array resource. The last argument to PtSetResource() must be 3,
BC > WL > not 0.

This still has not right justified the size column.

WL > Um… That’s because a PtListColumnAttributes_t has a “reserved” array
WL > at the end that consumes your flags… The docs do say “at least the
WL > following members”, don’t they?

WL > You just need to add braces around each array item. I have asked the
WL > docs person to make this clearer.

Now that DID work. I don’t feel quite so stupid about that one.

I am surprised that the compiler didn’t barf all over me when I tried to
compile it. I do have my warning set quite high.

I have noticed that the PtFileSel widget has a Pt_CB_FS_BKGD_HANDLER
callback. Would it be possible for me to get a callback for every
directory entry that is read, querry that entry, and either delete it if I
want to filter it out, or modify it’s appearance?

My goal is this:

  1. I want to filter out certain files that I can’t just by using a pattern
    filter.
  2. I want to modify the names of certain files, usually by just
    eliminating the filename extension.

My concern is would modifying the internal list of file names while the
widget is still trying to build that list interfere with it’s ability to
maintain state?

Bill Caroselli wrote:

I have noticed that the PtFileSel widget has a Pt_CB_FS_BKGD_HANDLER
callback. Would it be possible for me to get a callback for every
directory entry that is read, querry that entry, and either delete it if I
want to filter it out, or modify it’s appearance?

My goal is this:

  1. I want to filter out certain files that I can’t just by using a pattern
    filter.
  2. I want to modify the names of certain files, usually by just
    eliminating the filename extension.

My copy of the docs says:

“If this callback returns Pt_END, the item isn’t added. If you wish to
translate an item to another encoding, you should use PxTranslate…
functions to do so, copy the new string into name, and return
Pt_CONTINUE. You may also wish to process events.”

In other words, the purpose of the Pt_CB_FS_BKGD_HANDLER callback is
to allow you to filter out files you don’t want and to modify filenames.

(BTW I presume it really meant to say FROM a different encoding rather
than TO… I’m pretty sure that after the callback returns, the widget
will expect the string to be UTF-8.)

Thank you. This is great. I did not notice that part of the description.

I still don’t quite get the use of PxTranslate functions. If an actual
filename is “1999_01_sales.ptxi” and I want the file select widget to
display it as “1999_01_sales” or better yet as “January 1999 Sales” can I
do this kind of translation?

I assume that I just copy the new name into cbinfo->cbdata->name and
return Pt_CONTINUE?

This is very helpful. I’ve been trying to do the impossible with filename
filters and they just aren’t powerful enough for my needs. This gives me
everything.

Thanks again.


Wojtek Lerch <Wojtek_L@yahoo.ca> wrote:
WL > Bill Caroselli wrote:

I have noticed that the PtFileSel widget has a Pt_CB_FS_BKGD_HANDLER
callback. Would it be possible for me to get a callback for every
directory entry that is read, querry that entry, and either delete it if I
want to filter it out, or modify it’s appearance?

My goal is this:

  1. I want to filter out certain files that I can’t just by using a pattern
    filter.
  2. I want to modify the names of certain files, usually by just
    eliminating the filename extension.

WL > My copy of the docs says:

WL > “If this callback returns Pt_END, the item isn’t added. If you wish to
WL > translate an item to another encoding, you should use PxTranslate…
WL > functions to do so, copy the new string into name, and return
WL > Pt_CONTINUE. You may also wish to process events.”

WL > In other words, the purpose of the Pt_CB_FS_BKGD_HANDLER callback is
WL > to allow you to filter out files you don’t want and to modify filenames.

WL > (BTW I presume it really meant to say FROM a different encoding rather
WL > than TO… I’m pretty sure that after the callback returns, the widget
WL > will expect the string to be UTF-8.)

Bill Caroselli wrote:

Thank you. This is great. I did not notice that part of the description.

I still don’t quite get the use of PxTranslate functions. If an actual
filename is “1999_01_sales.ptxi” and I want the file select widget to
display it as “1999_01_sales” or better yet as “January 1999 Sales” can I
do this kind of translation?

I don’t see why not. Even if the intended purpose of the callback was
to allow you to translate the characters of the filename to UTF-8 from
some other encoding, either way you’re taking a sequence of bytes that
was read from the disk and replacing it with a UTF string you want to
represent that sequence of bytes on the screen.

I assume that I just copy the new name into cbinfo->cbdata->name and
return Pt_CONTINUE?

Yes.

This is very helpful. I’ve been trying to do the impossible with filename
filters and they just aren’t powerful enough for my needs. This gives me
everything.

Thanks again.

You’re welcome.

This one was easy. :slight_smile: