For the file selector filtering you could check the name of the path given and see base the filter options based on that. Kindof a hack but will work when browsing for an existing image path.
probably better to have a datatype enum (like a sub-sub-type :/ ), this way operator's which have a filepath property could set it to be any type could use existing defines for this IMAGEFILE, BLENDERFILE, TEXTFILE etc.. On Mon, Jul 26, 2010 at 3:05 PM, Nicholas Bishop <[email protected]> wrote: >> It seems that PROP_IMAGEPATH only exists so the file selector can have >> different filter settings and the icon can show different? > Yes. > >> For now Id even prefer something quick/simple, even setting the >> file-selector-filter based on the filepath given - so if a .png is >> selected it can know its an image type and setup the filter >> accordingly, same for sound, fonts etc. >> >> If you rather have this as a part of rna we could have a datatype enum. > Sure, I agree another solution might be better. I'm not sure exactly > what is meant by these suggestions though, can you elaborate further? > > -Nicholas > >> >> On Mon, Jul 26, 2010 at 11:37 AM, Nicholas Bishop >> <[email protected]> wrote: >>> Revision: 30763 >>> >>> http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=30763 >>> Author: nicholasbishop >>> Date: 2010-07-26 20:37:47 +0200 (Mon, 26 Jul 2010) >>> >>> Log Message: >>> ----------- >>> * Added a new RNA subtype, PROP_IMAGEPATH. It's the same as PROP_FILEPATH, >>> but for images only. >>> * Changed UI code to display image browser for PROP_IMAGEPATH >>> * Set the icon_filepath RNA property for brushes to use PROP_IMAGEPATH >>> * Changed preview icon drawing to ignore unset icons >>> * Fixed const warnings in brush RNA >>> >>> Modified Paths: >>> -------------- >>> trunk/blender/source/blender/editors/interface/interface_layout.c >>> trunk/blender/source/blender/editors/interface/interface_widgets.c >>> trunk/blender/source/blender/makesrna/RNA_types.h >>> trunk/blender/source/blender/makesrna/intern/makesrna.c >>> trunk/blender/source/blender/makesrna/intern/rna_brush.c >>> trunk/blender/source/blender/python/intern/bpy_props.c >>> >>> Modified: trunk/blender/source/blender/editors/interface/interface_layout.c >>> =================================================================== >>> --- trunk/blender/source/blender/editors/interface/interface_layout.c >>> 2010-07-26 18:32:22 UTC (rev 30762) >>> +++ trunk/blender/source/blender/editors/interface/interface_layout.c >>> 2010-07-26 18:37:47 UTC (rev 30763) >>> @@ -508,12 +508,16 @@ >>> type= RNA_property_type(prop); >>> subtype= RNA_property_subtype(prop); >>> >>> - if(subtype == PROP_FILEPATH || subtype == PROP_DIRPATH) { >>> + if(subtype == PROP_FILEPATH || subtype == PROP_DIRPATH || subtype >>> == PROP_IMAGEPATH) { >>> uiBlockSetCurLayout(block, uiLayoutRow(sub, 1)); >>> uiDefAutoButR(block, ptr, prop, index, "", icon, x, y, >>> w-UI_UNIT_X, h); >>> >>> /* BUTTONS_OT_file_browse calls uiFileBrowseContextProperty >>> */ >>> but= uiDefIconButO(block, BUT, "BUTTONS_OT_file_browse", >>> WM_OP_INVOKE_DEFAULT, ICON_FILESEL, x, y, UI_UNIT_X, h, NULL); >>> + if(subtype == PROP_IMAGEPATH) { >>> + RNA_boolean_set(uiButGetOperatorPtrRNA(but), >>> "filter_folder", 1); >>> + RNA_boolean_set(uiButGetOperatorPtrRNA(but), >>> "filter_image", 1); >>> + } >>> } >>> else if(subtype == PROP_DIRECTION) { >>> uiDefButR(block, BUT_NORMAL, 0, name, x, y, 100, 100, ptr, >>> RNA_property_identifier(prop), index, 0, 0, -1, -1, NULL); >>> >>> Modified: trunk/blender/source/blender/editors/interface/interface_widgets.c >>> =================================================================== >>> --- trunk/blender/source/blender/editors/interface/interface_widgets.c >>> 2010-07-26 18:32:22 UTC (rev 30762) >>> +++ trunk/blender/source/blender/editors/interface/interface_widgets.c >>> 2010-07-26 18:37:47 UTC (rev 30763) >>> @@ -748,6 +748,9 @@ >>> { >>> int w, h, x, y, size; >>> >>> + if(!icon) >>> + return; >>> + >>> w = rect->xmax - rect->xmin; >>> h = rect->ymax - rect->ymin; >>> size = MIN2(w, h); >>> >>> Modified: trunk/blender/source/blender/makesrna/RNA_types.h >>> =================================================================== >>> --- trunk/blender/source/blender/makesrna/RNA_types.h 2010-07-26 18:32:22 >>> UTC (rev 30762) >>> +++ trunk/blender/source/blender/makesrna/RNA_types.h 2010-07-26 18:37:47 >>> UTC (rev 30763) >>> @@ -98,6 +98,7 @@ >>> PROP_FILEPATH = 1, >>> PROP_DIRPATH = 2, >>> PROP_FILENAME = 3, >>> + PROP_IMAGEPATH = 4, >>> >>> /* numbers */ >>> PROP_UNSIGNED = 13, >>> >>> Modified: trunk/blender/source/blender/makesrna/intern/makesrna.c >>> =================================================================== >>> --- trunk/blender/source/blender/makesrna/intern/makesrna.c 2010-07-26 >>> 18:32:22 UTC (rev 30762) >>> +++ trunk/blender/source/blender/makesrna/intern/makesrna.c 2010-07-26 >>> 18:37:47 UTC (rev 30763) >>> @@ -1652,6 +1652,7 @@ >>> case PROP_FILEPATH: return "PROP_FILEPATH"; >>> case PROP_FILENAME: return "PROP_FILENAME"; >>> case PROP_DIRPATH: return "PROP_DIRPATH"; >>> + case PROP_IMAGEPATH: return "PROP_IMAGEPATH"; >>> case PROP_UNSIGNED: return "PROP_UNSIGNED"; >>> case PROP_PERCENTAGE: return "PROP_PERCENTAGE"; >>> case PROP_FACTOR: return "PROP_FACTOR"; >>> >>> Modified: trunk/blender/source/blender/makesrna/intern/rna_brush.c >>> =================================================================== >>> --- trunk/blender/source/blender/makesrna/intern/rna_brush.c 2010-07-26 >>> 18:32:22 UTC (rev 30762) >>> +++ trunk/blender/source/blender/makesrna/intern/rna_brush.c 2010-07-26 >>> 18:37:47 UTC (rev 30763) >>> @@ -39,7 +39,7 @@ >>> >>> #include "WM_types.h" >>> >>> -static const EnumPropertyItem prop_direction_items[]= { >>> +static EnumPropertyItem prop_direction_items[]= { >>> {0, "ADD", 0, "Add", "Add effect of brush"}, >>> {BRUSH_DIR_IN, "SUBTRACT", 0, "Subtract", "Subtract effect of >>> brush"}, >>> {0, NULL, 0, NULL, NULL}}; >>> @@ -264,30 +264,30 @@ >>> >>> static EnumPropertyItem *rna_Brush_direction_itemf(bContext *C, PointerRNA >>> *ptr, int *free) >>> { >>> - static const EnumPropertyItem prop_default_items[]= { >>> + static EnumPropertyItem prop_default_items[]= { >>> {0, NULL, 0, NULL, NULL}}; >>> >>> - static const EnumPropertyItem prop_flatten_contrast_items[]= { >>> + static EnumPropertyItem prop_flatten_contrast_items[]= { >>> {0, "FLATTEN", 0, "Flatten", "Add effect of brush"}, >>> {BRUSH_DIR_IN, "CONTRAST", 0, "Contrast", "Subtract effect >>> of brush"}, >>> {0, NULL, 0, NULL, NULL}}; >>> >>> - static const EnumPropertyItem prop_fill_deepen_items[]= { >>> + static EnumPropertyItem prop_fill_deepen_items[]= { >>> {0, "FILL", 0, "Fill", "Add effect of brush"}, >>> {BRUSH_DIR_IN, "DEEPEN", 0, "Deepen", "Subtract effect of >>> brush"}, >>> {0, NULL, 0, NULL, NULL}}; >>> >>> - static const EnumPropertyItem prop_scrape_peaks_items[]= { >>> + static EnumPropertyItem prop_scrape_peaks_items[]= { >>> {0, "SCRAPE", 0, "Scrape", "Add effect of brush"}, >>> {BRUSH_DIR_IN, "PEAKS", 0, "Peaks", "Subtract effect of >>> brush"}, >>> {0, NULL, 0, NULL, NULL}}; >>> >>> - static const EnumPropertyItem prop_pinch_magnify_items[]= { >>> + static EnumPropertyItem prop_pinch_magnify_items[]= { >>> {0, "PINCH", 0, "Pinch", "Add effect of brush"}, >>> {BRUSH_DIR_IN, "MAGNIFY", 0, "Magnify", "Subtract effect of >>> brush"}, >>> {0, NULL, 0, NULL, NULL}}; >>> >>> - static const EnumPropertyItem prop_inflate_deflate_items[]= { >>> + static EnumPropertyItem prop_inflate_deflate_items[]= { >>> {0, "INFLATE", 0, "Inflate", "Add effect of brush"}, >>> {BRUSH_DIR_IN, "DEFLATE", 0, "Deflate", "Subtract effect of >>> brush"}, >>> {0, NULL, 0, NULL, NULL}}; >>> @@ -770,7 +770,7 @@ >>> RNA_def_property_ui_text(prop, "Custom Icon", "Set the brush icon >>> from an image file"); >>> RNA_def_property_update(prop, 0, "rna_Brush_icon_update"); >>> >>> - prop= RNA_def_property(srna, "icon_filepath", PROP_STRING, >>> PROP_FILEPATH); >>> + prop= RNA_def_property(srna, "icon_filepath", PROP_STRING, >>> PROP_IMAGEPATH); >>> RNA_def_property_string_sdna(prop, NULL, "icon_filepath"); >>> RNA_def_property_ui_text(prop, "Brush Icon Filepath", "File path to >>> brush icon"); >>> RNA_def_property_update(prop, 0, "rna_Brush_icon_update"); >>> >>> Modified: trunk/blender/source/blender/python/intern/bpy_props.c >>> =================================================================== >>> --- trunk/blender/source/blender/python/intern/bpy_props.c 2010-07-26 >>> 18:32:22 UTC (rev 30762) >>> +++ trunk/blender/source/blender/python/intern/bpy_props.c 2010-07-26 >>> 18:37:47 UTC (rev 30763) >>> @@ -41,6 +41,7 @@ >>> {PROP_FILEPATH, "FILE_PATH", 0, "File Path", ""}, >>> {PROP_DIRPATH, "DIR_PATH", 0, "Directory Path", ""}, >>> {PROP_FILENAME, "FILENAME", 0, "Filename", ""}, >>> + {PROP_IMAGEPATH, "IMAGE_PATH", 0, "Image Path", ""}, >>> >>> {PROP_NONE, "NONE", 0, "None", ""}, >>> {0, NULL, 0, NULL, NULL}}; >>> >>> >>> _______________________________________________ >>> Bf-blender-cvs mailing list >>> [email protected] >>> http://lists.blender.org/mailman/listinfo/bf-blender-cvs >>> >> >> >> >> -- >> - Campbell >> _______________________________________________ >> Bf-committers mailing list >> [email protected] >> http://lists.blender.org/mailman/listinfo/bf-committers >> > _______________________________________________ > Bf-committers mailing list > [email protected] > http://lists.blender.org/mailman/listinfo/bf-committers > -- - Campbell _______________________________________________ Bf-committers mailing list [email protected] http://lists.blender.org/mailman/listinfo/bf-committers
