[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [17927] branches/blender2.5/blender: 2.5

Andrea Weikert elubie at gmx.net
Thu Dec 18 20:21:30 CET 2008


Revision: 17927
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=17927
Author:   elubie
Date:     2008-12-18 20:21:30 +0100 (Thu, 18 Dec 2008)

Log Message:
-----------
2.5

Adding back internal files for file/imagebrowser.

Modified Paths:
--------------
    branches/blender2.5/blender/projectfiles_vc9/blender/editors/ED_editors.vcproj

Added Paths:
-----------
    branches/blender2.5/blender/source/blender/editors/space_file/filelist.c
    branches/blender2.5/blender/source/blender/editors/space_file/filelist.h
    branches/blender2.5/blender/source/blender/editors/space_file/fsmenu.c
    branches/blender2.5/blender/source/blender/editors/space_file/fsmenu.h

Modified: branches/blender2.5/blender/projectfiles_vc9/blender/editors/ED_editors.vcproj
===================================================================
--- branches/blender2.5/blender/projectfiles_vc9/blender/editors/ED_editors.vcproj	2008-12-18 18:49:38 UTC (rev 17926)
+++ branches/blender2.5/blender/projectfiles_vc9/blender/editors/ED_editors.vcproj	2008-12-18 19:21:30 UTC (rev 17927)
@@ -511,10 +511,26 @@
 				>
 			</File>
 			<File
+				RelativePath="..\..\..\source\blender\editors\space_file\filelist.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\..\source\blender\editors\space_file\filelist.h"
+				>
+			</File>
+			<File
 				RelativePath="..\..\..\source\blender\editors\space_file\filesel.c"
 				>
 			</File>
 			<File
+				RelativePath="..\..\..\source\blender\editors\space_file\fsmenu.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\..\source\blender\editors\space_file\fsmenu.h"
+				>
+			</File>
+			<File
 				RelativePath="..\..\..\source\blender\editors\space_file\space_file.c"
 				>
 			</File>

Copied: branches/blender2.5/blender/source/blender/editors/space_file/filelist.c (from rev 17926, trunk/blender/source/blender/src/filelist.c)
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_file/filelist.c	                        (rev 0)
+++ branches/blender2.5/blender/source/blender/editors/space_file/filelist.c	2008-12-18 19:21:30 UTC (rev 17927)
@@ -0,0 +1,1111 @@
+/**
+ * $Id$
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version. 
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2007 Blender Foundation.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+
+/* global includes */
+
+#include <stdlib.h>
+#include <math.h>
+#include <string.h>
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#ifndef WIN32
+#include <unistd.h>
+#else
+#include <io.h>
+#include <direct.h>
+#endif   
+#include "MEM_guardedalloc.h"
+
+#include "BLI_blenlib.h"
+#include "BLI_linklist.h"
+#include "BLI_storage_types.h"
+
+#ifdef WIN32
+#include "BLI_winstuff.h"
+#endif
+
+#include "BKE_utildefines.h"
+#include "BKE_global.h"
+#include "BKE_library.h"
+#include "BKE_global.h"
+#include "BKE_main.h"
+#include "BLO_readfile.h"
+
+#include "DNA_space_types.h"
+#include "DNA_ipo_types.h"
+#include "DNA_ID.h"
+#include "DNA_object_types.h"
+#include "DNA_lamp_types.h"
+#include "DNA_material_types.h"
+#include "DNA_texture_types.h"
+#include "DNA_world_types.h"
+#include "DNA_scene_types.h"
+#include "DNA_userdef_types.h"
+
+#include "IMB_imbuf.h"
+#include "IMB_imbuf_types.h"
+#include "IMB_thumbs.h"
+
+#include "PIL_time.h"
+
+#include "ED_datafiles.h"
+
+#include "filelist.h"
+
+/* Elubie: VERY, really very ugly and evil! Remove asap!!! */
+/* for state of file */
+#define ACTIVE				2
+
+/* max length of library group name within filesel */
+#define GROUP_MAX 32
+
+typedef struct FileList
+{
+	struct direntry *filelist;
+	int *fidx;
+
+	int numfiles;
+	int numfiltered;
+	char dir[FILE_MAX];
+	short type;
+	short ipotype;
+	struct BlendHandle *libfiledata;
+	int has_func;
+	short prv_w;
+	short prv_h;
+	short hide_dot;
+	unsigned int filter;
+} FileList;
+
+int BIF_groupname_to_code(char *group)
+{
+	char buf[32];
+	char *lslash;
+	
+	BLI_strncpy(buf, group, 31);
+	lslash= BLI_last_slash(buf);
+	if (lslash)
+		lslash[0]= '\0';
+
+	return BLO_idcode_from_name(buf);
+}
+
+
+#define SPECIAL_IMG_SIZE 48
+#define SPECIAL_IMG_ROWS 4
+#define SPECIAL_IMG_COLS 4
+
+#define SPECIAL_IMG_FOLDER 0
+#define SPECIAL_IMG_PARENT 1
+#define SPECIAL_IMG_REFRESH 2
+#define SPECIAL_IMG_BLENDFILE 3
+#define SPECIAL_IMG_SOUNDFILE 4
+#define SPECIAL_IMG_MOVIEFILE 5
+#define SPECIAL_IMG_PYTHONFILE 6
+#define SPECIAL_IMG_TEXTFILE 7
+#define SPECIAL_IMG_FONTFILE 8
+#define SPECIAL_IMG_UNKNOWNFILE 9
+#define SPECIAL_IMG_MAX SPECIAL_IMG_UNKNOWNFILE + 1
+
+static ImBuf* gSpecialFileImages[SPECIAL_IMG_MAX];
+
+
+/* ******************* SORT ******************* */
+
+static int compare_name(const void *a1, const void *a2)
+{
+	const struct direntry *entry1=a1, *entry2=a2;
+
+	/* type is is equal to stat.st_mode */
+
+	if (S_ISDIR(entry1->type)){
+		if (S_ISDIR(entry2->type)==0) return (-1);
+	} else{
+		if (S_ISDIR(entry2->type)) return (1);
+	}
+	if (S_ISREG(entry1->type)){
+		if (S_ISREG(entry2->type)==0) return (-1);
+	} else{
+		if (S_ISREG(entry2->type)) return (1);
+	}
+	if ((entry1->type & S_IFMT) < (entry2->type & S_IFMT)) return (-1);
+	if ((entry1->type & S_IFMT) > (entry2->type & S_IFMT)) return (1);
+	
+	/* make sure "." and ".." are always first */
+	if( strcmp(entry1->relname, ".")==0 ) return (-1);
+	if( strcmp(entry2->relname, ".")==0 ) return (1);
+	if( strcmp(entry1->relname, "..")==0 ) return (-1);
+	
+	return (BLI_strcasecmp(entry1->relname,entry2->relname));
+}
+
+static int compare_date(const void *a1, const void *a2)	
+{
+	const struct direntry *entry1=a1, *entry2=a2;
+	
+	/* type is equal to stat.st_mode */
+
+	if (S_ISDIR(entry1->type)){
+		if (S_ISDIR(entry2->type)==0) return (-1);
+	} else{
+		if (S_ISDIR(entry2->type)) return (1);
+	}
+	if (S_ISREG(entry1->type)){
+		if (S_ISREG(entry2->type)==0) return (-1);
+	} else{
+		if (S_ISREG(entry2->type)) return (1);
+	}
+	if ((entry1->type & S_IFMT) < (entry2->type & S_IFMT)) return (-1);
+	if ((entry1->type & S_IFMT) > (entry2->type & S_IFMT)) return (1);
+
+	/* make sure "." and ".." are always first */
+	if( strcmp(entry1->relname, ".")==0 ) return (-1);
+	if( strcmp(entry2->relname, ".")==0 ) return (1);
+	if( strcmp(entry1->relname, "..")==0 ) return (-1);
+	
+	if ( entry1->s.st_mtime < entry2->s.st_mtime) return 1;
+	if ( entry1->s.st_mtime > entry2->s.st_mtime) return -1;
+	
+	else return BLI_strcasecmp(entry1->relname,entry2->relname);
+}
+
+static int compare_size(const void *a1, const void *a2)	
+{
+	const struct direntry *entry1=a1, *entry2=a2;
+
+	/* type is equal to stat.st_mode */
+
+	if (S_ISDIR(entry1->type)){
+		if (S_ISDIR(entry2->type)==0) return (-1);
+	} else{
+		if (S_ISDIR(entry2->type)) return (1);
+	}
+	if (S_ISREG(entry1->type)){
+		if (S_ISREG(entry2->type)==0) return (-1);
+	} else{
+		if (S_ISREG(entry2->type)) return (1);
+	}
+	if ((entry1->type & S_IFMT) < (entry2->type & S_IFMT)) return (-1);
+	if ((entry1->type & S_IFMT) > (entry2->type & S_IFMT)) return (1);
+
+	/* make sure "." and ".." are always first */
+	if( strcmp(entry1->relname, ".")==0 ) return (-1);
+	if( strcmp(entry2->relname, ".")==0 ) return (1);
+	if( strcmp(entry1->relname, "..")==0 ) return (-1);
+	
+	if ( entry1->s.st_size < entry2->s.st_size) return 1;
+	if ( entry1->s.st_size > entry2->s.st_size) return -1;
+	else return BLI_strcasecmp(entry1->relname,entry2->relname);
+}
+
+static int compare_extension(const void *a1, const void *a2) {
+	const struct direntry *entry1=a1, *entry2=a2;
+	char *sufix1, *sufix2;
+	char *nil="";
+
+	if (!(sufix1= strstr (entry1->relname, ".blend.gz"))) 
+		sufix1= strrchr (entry1->relname, '.');
+	if (!(sufix2= strstr (entry2->relname, ".blend.gz")))
+		sufix2= strrchr (entry2->relname, '.');
+	if (!sufix1) sufix1= nil;
+	if (!sufix2) sufix2= nil;
+
+	/* type is is equal to stat.st_mode */
+
+	if (S_ISDIR(entry1->type)){
+		if (S_ISDIR(entry2->type)==0) return (-1);
+	} else{
+		if (S_ISDIR(entry2->type)) return (1);
+	}
+	if (S_ISREG(entry1->type)){
+		if (S_ISREG(entry2->type)==0) return (-1);
+	} else{
+		if (S_ISREG(entry2->type)) return (1);
+	}
+	if ((entry1->type & S_IFMT) < (entry2->type & S_IFMT)) return (-1);
+	if ((entry1->type & S_IFMT) > (entry2->type & S_IFMT)) return (1);
+	
+	/* make sure "." and ".." are always first */
+	if( strcmp(entry1->relname, ".")==0 ) return (-1);
+	if( strcmp(entry2->relname, ".")==0 ) return (1);
+	if( strcmp(entry1->relname, "..")==0 ) return (-1);
+	if( strcmp(entry2->relname, "..")==0 ) return (-1);
+	
+	return (BLI_strcasecmp(sufix1, sufix2));
+}
+
+void filelist_filter(FileList* filelist)
+{
+	char dir[FILE_MAX], group[GROUP_MAX];
+	int num_filtered = 0;
+	int i, j;
+	
+	if (!filelist->filelist)
+		return;
+	
+	if ( ( (filelist->type == FILE_LOADLIB) &&  filelist_islibrary(filelist, dir, group)) 
+		|| (filelist->type == FILE_MAIN) ) {
+		filelist->filter = 0;
+	}
+
+	if (!filelist->filter) {
+		if (filelist->fidx) {
+			MEM_freeN(filelist->fidx);
+			filelist->fidx = NULL;
+		}
+		filelist->fidx = (int *)MEM_callocN(filelist->numfiles*sizeof(int), "filteridx");
+		for (i = 0; i < filelist->numfiles; ++i) {
+			filelist->fidx[i] = i;
+		}
+		filelist->numfiltered = filelist->numfiles;
+		return;
+	}
+
+	// How many files are left after filter ?
+	for (i = 0; i < filelist->numfiles; ++i) {
+		if (filelist->filelist[i].flags & filelist->filter) {
+			num_filtered++;
+		} 
+		else if (filelist->filelist[i].type & S_IFDIR) {
+			if (filelist->filter & FOLDERFILE) {
+				num_filtered++;
+			}
+		}		
+	}
+	
+	if (filelist->fidx) {
+			MEM_freeN(filelist->fidx);
+			filelist->fidx = NULL;
+	}
+	filelist->fidx = (int *)MEM_callocN(num_filtered*sizeof(int), "filteridx");
+	filelist->numfiltered = num_filtered;
+
+	for (i = 0, j=0; i < filelist->numfiles; ++i) {
+		if (filelist->filelist[i].flags & filelist->filter) {
+			filelist->fidx[j++] = i;
+		}
+		else if (filelist->filelist[i].type & S_IFDIR) {
+			if (filelist->filter & FOLDERFILE) {
+				filelist->fidx[j++] = i;
+			}
+		}  
+	}
+}
+
+void filelist_init_icons()
+{
+#if 0 /* XXX add icons here */
+	short x, y, k;
+	ImBuf *bbuf;
+	ImBuf *ibuf;
+	bbuf = IMB_ibImageFromMemory((int *)datatoc_prvicons, datatoc_prvicons_size, IB_rect);
+	if (bbuf) {
+		for (y=0; y<SPECIAL_IMG_ROWS; y++) {
+			for (x=0; x<SPECIAL_IMG_COLS; x++) {
+				int tile = SPECIAL_IMG_COLS*y + x; 
+				if (tile < SPECIAL_IMG_MAX) {

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list