[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [59384] branches/asset-browser/source/ blender: == filebrowser ==

Andrea Weikert elubie at gmx.net
Thu Aug 22 19:27:10 CEST 2013


Revision: 59384
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=59384
Author:   elubie
Date:     2013-08-22 17:27:10 +0000 (Thu, 22 Aug 2013)
Log Message:
-----------
== filebrowser ==

* Fix wrong index in filelist when loading from the current .blend file
* Add operator to open the file browser in 'internal' view, showing the data of the current .blend file 

This is (start of) an experiment to see how easy it is to bring back the functionality of opening the current 'Main' in the filebrowser

Modified Paths:
--------------
    branches/asset-browser/source/blender/editors/space_file/filelist.c
    branches/asset-browser/source/blender/windowmanager/intern/wm_operators.c

Modified: branches/asset-browser/source/blender/editors/space_file/filelist.c
===================================================================
--- branches/asset-browser/source/blender/editors/space_file/filelist.c	2013-08-22 15:30:24 UTC (rev 59383)
+++ branches/asset-browser/source/blender/editors/space_file/filelist.c	2013-08-22 17:27:10 UTC (rev 59384)
@@ -1153,9 +1153,9 @@
 		
 		/* make directories */
 #ifdef WITH_FREESTYLE
-		filelist->numfiles = 25;
+		filelist->numfiles = 24;
 #else
-		filelist->numfiles = 24;
+		filelist->numfiles = 23;
 #endif
 		filelist->filelist = (struct direntry *)malloc(filelist->numfiles * sizeof(struct direntry));
 		
@@ -1165,30 +1165,30 @@
 		}
 		
 		filelist->filelist[0].relname = BLI_strdup("..");
-		filelist->filelist[2].relname = BLI_strdup("Scene");
-		filelist->filelist[3].relname = BLI_strdup("Object");
-		filelist->filelist[4].relname = BLI_strdup("Mesh");
-		filelist->filelist[5].relname = BLI_strdup("Curve");
-		filelist->filelist[6].relname = BLI_strdup("Metaball");
-		filelist->filelist[7].relname = BLI_strdup("Material");
-		filelist->filelist[8].relname = BLI_strdup("Texture");
-		filelist->filelist[9].relname = BLI_strdup("Image");
-		filelist->filelist[10].relname = BLI_strdup("Ika");
-		filelist->filelist[11].relname = BLI_strdup("Wave");
-		filelist->filelist[12].relname = BLI_strdup("Lattice");
-		filelist->filelist[13].relname = BLI_strdup("Lamp");
-		filelist->filelist[14].relname = BLI_strdup("Camera");
-		filelist->filelist[15].relname = BLI_strdup("Ipo");
-		filelist->filelist[16].relname = BLI_strdup("World");
-		filelist->filelist[17].relname = BLI_strdup("Screen");
-		filelist->filelist[18].relname = BLI_strdup("VFont");
-		filelist->filelist[19].relname = BLI_strdup("Text");
-		filelist->filelist[20].relname = BLI_strdup("Armature");
-		filelist->filelist[21].relname = BLI_strdup("Action");
-		filelist->filelist[22].relname = BLI_strdup("NodeTree");
-		filelist->filelist[23].relname = BLI_strdup("Speaker");
+		filelist->filelist[1].relname = BLI_strdup("Scene");
+		filelist->filelist[2].relname = BLI_strdup("Object");
+		filelist->filelist[3].relname = BLI_strdup("Mesh");
+		filelist->filelist[4].relname = BLI_strdup("Curve");
+		filelist->filelist[5].relname = BLI_strdup("Metaball");
+		filelist->filelist[6].relname = BLI_strdup("Material");
+		filelist->filelist[7].relname = BLI_strdup("Texture");
+		filelist->filelist[8].relname = BLI_strdup("Image");
+		filelist->filelist[9].relname = BLI_strdup("Ika");
+		filelist->filelist[10].relname = BLI_strdup("Wave");
+		filelist->filelist[11].relname = BLI_strdup("Lattice");
+		filelist->filelist[12].relname = BLI_strdup("Lamp");
+		filelist->filelist[13].relname = BLI_strdup("Camera");
+		filelist->filelist[14].relname = BLI_strdup("Ipo");
+		filelist->filelist[15].relname = BLI_strdup("World");
+		filelist->filelist[16].relname = BLI_strdup("Screen");
+		filelist->filelist[17].relname = BLI_strdup("VFont");
+		filelist->filelist[18].relname = BLI_strdup("Text");
+		filelist->filelist[19].relname = BLI_strdup("Armature");
+		filelist->filelist[20].relname = BLI_strdup("Action");
+		filelist->filelist[21].relname = BLI_strdup("NodeTree");
+		filelist->filelist[22].relname = BLI_strdup("Speaker");
 #ifdef WITH_FREESTYLE
-		filelist->filelist[24].relname = BLI_strdup("FreestyleLineStyle");
+		filelist->filelist[23].relname = BLI_strdup("FreestyleLineStyle");
 #endif
 		filelist_sort(filelist, FILE_SORT_ALPHA);
 	}

Modified: branches/asset-browser/source/blender/windowmanager/intern/wm_operators.c
===================================================================
--- branches/asset-browser/source/blender/windowmanager/intern/wm_operators.c	2013-08-22 15:30:24 UTC (rev 59383)
+++ branches/asset-browser/source/blender/windowmanager/intern/wm_operators.c	2013-08-22 17:27:10 UTC (rev 59384)
@@ -2125,6 +2125,67 @@
 	                "Allow .blend file to execute scripts automatically, default available from system preferences");
 }
 
+/* **************** open internal ************* */
+static int wm_open_internal_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
+{
+	const char *openname = G.main->name;
+
+	if (CTX_wm_window(C) == NULL) {
+		/* in rare cases this could happen, when trying to invoke in background
+		 * mode on load for example. Don't use poll for this because exec()
+		 * can still run without a window */
+		BKE_report(op->reports, RPT_ERROR, "Context window not set");
+		return OPERATOR_CANCELLED;
+	}
+
+	/* if possible, get the name of the most recently used .blend file */
+	if (G.recent_files.first) {
+		struct RecentFile *recent = G.recent_files.first;
+		openname = recent->filepath;
+	}
+
+	RNA_string_set(op->ptr, "filepath", openname);
+	op->customdata = NULL;
+
+	WM_event_add_fileselect(C, op);
+
+	return OPERATOR_RUNNING_MODAL;
+}
+
+static int wm_open_internal_exec(bContext *C, wmOperator *op)
+{
+	char path[FILE_MAX];
+
+	RNA_string_get(op->ptr, "filepath", path);
+
+	/* I think it used to select */
+
+	/* for file open also popup for warnings, not only errors */
+	BKE_report_print_level_set(op->reports, RPT_WARNING);
+
+	return OPERATOR_FINISHED;
+}
+
+static bool wm_open_internal_check(bContext *UNUSED(C), wmOperator *op)
+{
+	return true;
+}
+
+static void WM_OT_open_internal(wmOperatorType *ot)
+{
+	ot->name = "Show Internal";
+	ot->idname = "WM_OT_open_internal";
+	ot->description = "Show internal .blend file data";
+
+	ot->invoke = wm_open_internal_invoke;
+	ot->exec = wm_open_internal_exec;
+	ot->check = wm_open_internal_check;
+	/* ommit window poll so this can work in background mode */
+
+	WM_operator_properties_filesel(ot, FOLDERFILE | BLENDERFILE, FILE_MAIN, FILE_OPENFILE,
+	                               WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY);
+}
+
 /* **************** link/append *************** */
 
 static int wm_link_append_poll(bContext *C)
@@ -4163,6 +4224,7 @@
 	WM_operatortype_append(WM_OT_window_fullscreen_toggle);
 	WM_operatortype_append(WM_OT_quit_blender);
 	WM_operatortype_append(WM_OT_open_mainfile);
+	WM_operatortype_append(WM_OT_open_internal);
 	WM_operatortype_append(WM_OT_link_append);
 	WM_operatortype_append(WM_OT_recover_last_session);
 	WM_operatortype_append(WM_OT_recover_auto_save);
@@ -4388,6 +4450,7 @@
 	WM_keymap_add_menu(keymap, "INFO_MT_file_open_recent", OKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0);
 	WM_keymap_add_item(keymap, "WM_OT_open_mainfile", OKEY, KM_PRESS, KM_CTRL, 0);
 	WM_keymap_add_item(keymap, "WM_OT_open_mainfile", F1KEY, KM_PRESS, 0, 0);
+	WM_keymap_add_item(keymap, "WM_OT_open_internal", F9KEY, KM_PRESS, 0, 0);
 	WM_keymap_add_item(keymap, "WM_OT_link_append", OKEY, KM_PRESS, KM_CTRL | KM_ALT, 0);
 	kmi = WM_keymap_add_item(keymap, "WM_OT_link_append", F1KEY, KM_PRESS, KM_SHIFT, 0);
 	RNA_boolean_set(kmi->ptr, "link", FALSE);




More information about the Bf-blender-cvs mailing list