Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTon Roosendaal <ton@blender.org>2008-12-19 21:28:37 +0300
committerTon Roosendaal <ton@blender.org>2008-12-19 21:28:37 +0300
commita3d3619898f541b989bedca67ffc8592892ac4dc (patch)
tree44d35c7e95d80885bb731abf3c566e6be7cdcea7 /source/blender/windowmanager/intern
parent7729ddd4240f49c58fc397f570a4b817d64b7733 (diff)
2.5
- CTRL+O "open recent file" is back. Need it for testing :) - Added a simple WM_error() to replace old error()
Diffstat (limited to 'source/blender/windowmanager/intern')
-rw-r--r--source/blender/windowmanager/intern/wm_files.c3
-rw-r--r--source/blender/windowmanager/intern/wm_operators.c76
2 files changed, 78 insertions, 1 deletions
diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c
index baaba13a5dc..00297a56167 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -481,6 +481,7 @@ void WM_read_file(bContext *C, char *name)
/* first try to append data from exotic file formats... */
/* it throws error box when file doesnt exist and returns -1 */
+ /* note; it should set some error message somewhere... (ton) */
retval= BKE_read_exotic(name);
/* we didn't succeed, now try to read Blender file */
@@ -513,6 +514,8 @@ void WM_read_file(bContext *C, char *name)
}
// else if(retval==1)
// XXX BIF_undo_push("Import file");
+ else if(retval == -1)
+ WM_error(C, "Cannot read file");
}
static void outliner_242_patch(void)
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index 1c8f0601b68..d69b0901bc6 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -30,6 +30,7 @@
#include "DNA_ID.h"
#include "DNA_screen_types.h"
+#include "DNA_userdef_types.h"
#include "DNA_windowmanager_types.h"
#include "MEM_guardedalloc.h"
@@ -40,6 +41,7 @@
#include "BKE_context.h"
#include "BKE_idprop.h"
#include "BKE_library.h"
+#include "BKE_global.h"
#include "BKE_main.h"
#include "BKE_utildefines.h"
@@ -94,10 +96,20 @@ static void operator_callback(bContext *C, void *arg, int retval)
{
wmOperator *op= arg;
- if(retval > 0)
+ if(op && retval > 0)
op->type->exec(C, op);
}
+void WM_error(bContext *C, char *str)
+{
+ char buf[148], testbuf[128];
+
+ BLI_strncpy(testbuf, str, 128);
+ sprintf(buf, "Error %%i%d%%t|%s", ICON_ERROR, testbuf);
+ uiPupmenu(C, 0, operator_callback, NULL, buf);
+
+}
+
int WM_operator_confirm(bContext *C, wmOperator *op, wmEvent *event)
{
char buf[512];
@@ -138,6 +150,66 @@ static void WM_OT_save_homefile(wmOperatorType *ot)
ot->flag= OPTYPE_REGISTER;
}
+/* ********* recent file *********** */
+
+static void recent_filelist(char *pup)
+{
+ struct RecentFile *recent;
+ int i, ofs= 0;
+ char *p;
+
+ p= pup + sprintf(pup, "Open Recent%%t");
+
+ if (G.sce[0]) {
+ p+= sprintf(p, "|%s %%x%d", G.sce, 1);
+ ofs = 1;
+ }
+
+ for (recent = G.recent_files.first, i=0; (i<U.recent_files) && (recent); recent = recent->next, i++) {
+ if (strcmp(recent->filename, G.sce)) {
+ p+= sprintf(p, "|%s %%x%d", recent->filename, i+ofs+1);
+ }
+ }
+}
+
+static void recentfile_callback(bContext *C, void *arg, int event)
+{
+
+ if(event>0) {
+ if (G.sce[0] && (event==1))
+ WM_read_file(C, G.sce);
+ else {
+ struct RecentFile *recent = BLI_findlink(&(G.recent_files), event-2);
+ if(recent) {
+ WM_read_file(C, recent->filename);
+ }
+ }
+ }
+}
+
+static int wm_recentfile_invoke(bContext *C, wmOperator *op, wmEvent *event)
+{
+ char pup[2048];
+
+ recent_filelist(pup);
+ uiPupmenu(C, 0, recentfile_callback, op, pup);
+
+ return 1;
+}
+
+static void WM_OT_open_recentfile(wmOperatorType *ot)
+{
+ ot->name= "Open Recent File";
+ ot->idname= "WM_OT_open_recentfile";
+
+ ot->invoke= wm_recentfile_invoke;
+ ot->poll= WM_operator_winactive;
+
+ ot->flag= OPTYPE_REGISTER;
+}
+
+/* *********************** */
+
static void WM_OT_window_fullscreen_toggle(wmOperatorType *ot)
{
ot->name= "Toggle Fullscreen";
@@ -365,6 +437,7 @@ void wm_operatortype_init(void)
WM_operatortype_append(WM_OT_window_fullscreen_toggle);
WM_operatortype_append(WM_OT_exit_blender);
WM_operatortype_append(WM_OT_tweak_gesture);
+ WM_operatortype_append(WM_OT_open_recentfile);
}
/* default keymap for windows and screens, only call once per WM */
@@ -375,6 +448,7 @@ void wm_window_keymap(wmWindowManager *wm)
/* note, this doesn't replace existing keymap items */
WM_keymap_verify_item(keymap, "WM_OT_window_duplicate", AKEY, KM_PRESS, KM_CTRL|KM_ALT, 0);
WM_keymap_verify_item(keymap, "WM_OT_save_homefile", UKEY, KM_PRESS, KM_CTRL, 0);
+ WM_keymap_verify_item(keymap, "WM_OT_open_recentfile", OKEY, KM_PRESS, KM_CTRL, 0);
WM_keymap_verify_item(keymap, "WM_OT_window_fullscreen_toggle", FKEY, KM_PRESS, 0, 0);
WM_keymap_verify_item(keymap, "WM_OT_exit_blender", QKEY, KM_PRESS, KM_CTRL, 0);
}