Tk Source Code

View Ticket
Login
Ticket UUID: 2860363
Title: Add a command to list available image handlers
Type: RFE Version: None
Submitter: hat0 Created on: 2009-09-16 23:26:51
Subsystem: 41. Photo Images Assigned To: dkf
Priority: 5 Medium Severity:
Status: Open Last Modified: 2009-12-22 02:22:02
Resolution: None Closed By:
    Closed on:
Description:
There is currently no way to request a list of available image handlers, e.g. for use by [image data -format ___].  This list may vary depending on which extensions are loaded.  A subcommand could be added to produce a list, such as { gif ppm }, listing all valid options to the -format flag.
User Comments: mickey_knox added on 2009-09-20 03:14:02:
DIFF-ed against version 1.91

diff -ru ..\tksrc_orig/generic/tkImgPhoto.c ./generic/tkImgPhoto.c
--- ..\tksrc_orig/generic/tkImgPhoto.c2009-09-19 21:48:11.765625000 +0200
+++ ./generic/tkImgPhoto.c2009-09-19 22:01:32.531250000 +0200
@@ -397,12 +397,12 @@
 {
     static const char *const photoOptions[] = {
 "blank", "cget", "configure", "copy", "data", "get", "put",
-"read", "redither", "transparency", "write", NULL
+"read", "redither", "transparency", "write", "formats", NULL
     };
     enum PhotoOptions {
 PHOTO_BLANK, PHOTO_CGET, PHOTO_CONFIGURE, PHOTO_COPY, PHOTO_DATA,
 PHOTO_GET, PHOTO_PUT, PHOTO_READ, PHOTO_REDITHER, PHOTO_TRANS,
-PHOTO_WRITE
+PHOTO_WRITE, PHOTO_FORMATS
     };
 
     PhotoMaster *masterPtr = clientData;
@@ -1359,6 +1359,20 @@
 return result;
     }
 
+case PHOTO_FORMATS: {
+Tk_PhotoImageFormat *formatPtr;
+    ThreadSpecificData *tsdPtr =
+    Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
+Tcl_Obj *formatsObj = Tcl_NewListObj(0, NULL);
+formatPtr = tsdPtr->formatList;
+while (formatPtr != NULL) {
+Tcl_ListObjAppendElement(NULL, formatsObj, Tcl_NewStringObj(
+formatPtr->name, strlen(formatPtr->name)));
+formatPtr = formatPtr->nextPtr;
+}
+Tcl_SetObjResult(interp, formatsObj);
+return TCL_OK;
+}
     }
     Tcl_Panic("unexpected fallthrough");
     return TCL_ERROR; /* NOT REACHED */

ferrieux added on 2009-09-17 13:54:02:
One alternative to a specific subcommand would be to give the list of possibilities in the error message, like for static options.

ferrieux added on 2009-09-17 13:32:48:

data_type - 362997