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:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2009-07-24 01:35:11 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2009-07-24 01:35:11 +0400
commit1ee8038e41f2daf3aaac40e58d7cdc416d2af35d (patch)
treedc2c0108f0b297edc3960e174457d1c57fe3dd2b /source/blender/windowmanager
parent0bb50594f9118eedaac32d716f2eaf81e3efe1dc (diff)
2.5: Top Menu
* Clean up File menu, added back recover last session op. * .blend compress now behaves a bit different, previously it would only respect the user preference. Now it saves existing files the same way they are saved, and new files following the user preference. The save operator has a Compress toggle in the file browser left panels now. * Add menu working again, some fixes to make these operators work outside the 3d view were needed. * Timeline menu removed, its contents will be moved to the timeline header menus. * Game menu can now start game, changed the start game op to choose another 3d view if none is available. * Render menu has a few items now. * Help menu contains a few links again.
Diffstat (limited to 'source/blender/windowmanager')
-rw-r--r--source/blender/windowmanager/WM_api.h2
-rw-r--r--source/blender/windowmanager/intern/wm_event_system.c2
-rw-r--r--source/blender/windowmanager/intern/wm_files.c14
-rw-r--r--source/blender/windowmanager/intern/wm_operators.c117
4 files changed, 105 insertions, 30 deletions
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h
index 542a747d454..56ae220f7f0 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -57,7 +57,7 @@ struct wmWindow *WM_window_open (struct bContext *C, struct rcti *rect);
int WM_read_homefile (struct bContext *C, struct wmOperator *op);
int WM_write_homefile (struct bContext *C, struct wmOperator *op);
void WM_read_file (struct bContext *C, char *name, struct ReportList *reports);
-void WM_write_file (struct bContext *C, char *target, struct ReportList *reports);
+void WM_write_file (struct bContext *C, char *target, int compress, struct ReportList *reports);
void WM_read_autosavefile(struct bContext *C);
void WM_write_autosave (struct bContext *C);
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index 5377e351ff0..11b8f7f8c6f 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -451,7 +451,7 @@ int WM_operator_name_call(bContext *C, const char *opstring, int context, Pointe
CTX_wm_region_set(C, NULL);
CTX_wm_area_set(C, NULL);
- retval= wm_operator_invoke(C, ot, window->eventstate, properties);
+ retval= wm_operator_invoke(C, ot, event, properties);
CTX_wm_region_set(C, ar);
CTX_wm_area_set(C, area);
diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c
index c3b317590f1..2019906bd5e 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -539,7 +539,7 @@ static void do_history(char *name, ReportList *reports)
BKE_report(reports, RPT_ERROR, "Unable to make version backup");
}
-void WM_write_file(bContext *C, char *target, ReportList *reports)
+void WM_write_file(bContext *C, char *target, int compress, ReportList *reports)
{
Library *li;
int writeflags, len;
@@ -580,10 +580,11 @@ void WM_write_file(bContext *C, char *target, ReportList *reports)
do_history(di, reports);
- /* we use the UserDef to define compression flag */
- writeflags= G.fileflags & ~G_FILE_COMPRESS;
- if(U.flag & USER_FILECOMPRESS)
- writeflags |= G_FILE_COMPRESS;
+ writeflags= G.fileflags;
+
+ /* set compression flag */
+ if(compress) writeflags |= G_FILE_COMPRESS;
+ else writeflags &= ~G_FILE_COMPRESS;
if (BLO_write_file(CTX_data_main(C), di, writeflags, reports)) {
strcpy(G.sce, di);
@@ -591,6 +592,9 @@ void WM_write_file(bContext *C, char *target, ReportList *reports)
strcpy(G.main->name, di); /* is guaranteed current file */
G.save_over = 1; /* disable untitled.blend convention */
+
+ if(compress) G.fileflags |= G_FILE_COMPRESS;
+ else G.fileflags &= ~G_FILE_COMPRESS;
writeBlog();
}
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index 5e60207f62d..5c484dfa322 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -571,7 +571,7 @@ static void WM_OT_read_homefile(wmOperatorType *ot)
static int recentfile_exec(bContext *C, wmOperator *op)
{
- int event= RNA_int_get(op->ptr, "nr");
+ int event= RNA_enum_get(op->ptr, "file");
// XXX wm in context is not set correctly after WM_read_file -> crash
// do it before for now, but is this correct with multiple windows?
@@ -594,30 +594,54 @@ static int recentfile_exec(bContext *C, wmOperator *op)
static int wm_recentfile_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
- struct RecentFile *recent;
uiPopupMenu *pup;
uiLayout *layout;
- int i, ofs= 0;
pup= uiPupMenuBegin(C, "Open Recent", 0);
layout= uiPupMenuLayout(pup);
+ uiItemsEnumO(layout, op->type->idname, "file");
+ uiPupMenuEnd(C, pup);
+
+ return OPERATOR_CANCELLED;
+}
+
+static EnumPropertyItem *open_recentfile_itemf(bContext *C, PointerRNA *ptr, int *free)
+{
+ EnumPropertyItem tmp = {0, "", 0, "", ""};
+ EnumPropertyItem *item= NULL;
+ struct RecentFile *recent;
+ int totitem= 0, i, ofs= 0;
if(G.sce[0]) {
- uiItemIntO(layout, G.sce, 0, op->type->idname, "nr", 1);
+ tmp.value= 1;
+ tmp.identifier= G.sce;
+ tmp.name= G.sce;
+ RNA_enum_item_add(&item, &totitem, &tmp);
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))
- uiItemIntO(layout, recent->filename, 0, op->type->idname, "nr", i+ofs+1);
- uiPupMenuEnd(C, pup);
-
- return OPERATOR_CANCELLED;
+ /* dynamically construct enum */
+ for(recent = G.recent_files.first, i=0; (i<U.recent_files) && (recent); recent = recent->next, i++) {
+ if(strcmp(recent->filename, G.sce)) {
+ tmp.value= i+ofs+1;
+ tmp.identifier= recent->filename;
+ tmp.name= recent->filename;
+ RNA_enum_item_add(&item, &totitem, &tmp);
+ }
+ }
+
+ RNA_enum_item_end(&item, &totitem);
+ *free= 1;
+
+ return item;
}
static void WM_OT_open_recentfile(wmOperatorType *ot)
{
+ PropertyRNA *prop;
+ static EnumPropertyItem file_items[]= {
+ {0, NULL, 0, NULL, NULL}};
+
ot->name= "Open Recent File";
ot->idname= "WM_OT_open_recentfile";
@@ -625,7 +649,8 @@ static void WM_OT_open_recentfile(wmOperatorType *ot)
ot->exec= recentfile_exec;
ot->poll= WM_operator_winactive;
- RNA_def_property(ot->srna, "nr", PROP_INT, PROP_UNSIGNED);
+ prop= RNA_def_enum(ot->srna, "file", file_items, 1, "File", "");
+ RNA_def_enum_funcs(prop, open_recentfile_itemf);
}
/* ********* main file *********** */
@@ -675,15 +700,57 @@ static void WM_OT_open_mainfile(wmOperatorType *ot)
ot->exec= wm_open_mainfile_exec;
ot->poll= WM_operator_winactive;
- ot->flag= 0;
-
RNA_def_property(ot->srna, "filename", PROP_STRING, PROP_FILEPATH);
+}
+
+static int wm_recover_last_session_exec(bContext *C, wmOperator *op)
+{
+ char scestr[FILE_MAX], filename[FILE_MAX];
+ int save_over;
+ /* back up some values */
+ BLI_strncpy(scestr, G.sce, sizeof(scestr));
+ save_over = G.save_over;
+
+ // XXX wm in context is not set correctly after WM_read_file -> crash
+ // do it before for now, but is this correct with multiple windows?
+ WM_event_add_notifier(C, NC_WINDOW, NULL);
+
+ /* load file */
+ BLI_make_file_string("/", filename, btempdir, "quit.blend");
+ WM_read_file(C, filename, op->reports);
+
+ /* restore */
+ G.save_over = save_over;
+ BLI_strncpy(G.sce, scestr, sizeof(G.sce));
+
+ return 0;
+}
+
+static void WM_OT_recover_last_session(wmOperatorType *ot)
+{
+ ot->name= "Recover Last Session";
+ ot->idname= "WM_OT_recover_last_session";
+
+ ot->exec= wm_recover_last_session_exec;
+ ot->poll= WM_operator_winactive;
+}
+
+static void save_set_compress(wmOperator *op)
+{
+ if(!RNA_property_is_set(op->ptr, "compress")) {
+ if(G.save_over) /* keep flag for existing file */
+ RNA_boolean_set(op->ptr, "compress", G.fileflags & G_FILE_COMPRESS);
+ else /* use userdef for new file */
+ RNA_boolean_set(op->ptr, "compress", U.flag & USER_FILECOMPRESS);
+ }
}
static int wm_save_as_mainfile_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
char name[FILE_MAX];
+
+ save_set_compress(op);
BLI_strncpy(name, G.sce, FILE_MAX);
untitled(name);
@@ -698,6 +765,10 @@ static int wm_save_as_mainfile_invoke(bContext *C, wmOperator *op, wmEvent *even
static int wm_save_as_mainfile_exec(bContext *C, wmOperator *op)
{
char filename[FILE_MAX];
+ int compress;
+
+ save_set_compress(op);
+ compress= RNA_boolean_get(op->ptr, "compress");
if(RNA_property_is_set(op->ptr, "filename"))
RNA_string_get(op->ptr, "filename", filename);
@@ -705,7 +776,8 @@ static int wm_save_as_mainfile_exec(bContext *C, wmOperator *op)
BLI_strncpy(filename, G.sce, FILE_MAX);
untitled(filename);
}
- WM_write_file(C, filename, op->reports);
+
+ WM_write_file(C, filename, compress, op->reports);
WM_event_add_notifier(C, NC_WM|ND_FILESAVE, NULL);
@@ -721,10 +793,8 @@ static void WM_OT_save_as_mainfile(wmOperatorType *ot)
ot->exec= wm_save_as_mainfile_exec;
ot->poll= WM_operator_winactive;
- ot->flag= 0;
-
- RNA_def_property(ot->srna, "filename", PROP_STRING, PROP_FILEPATH);
-
+ RNA_def_string_file_path(ot->srna, "filename", "", 0, "Filename", "");
+ RNA_def_boolean(ot->srna, "compress", 0, "Compress", "Write compressed .blend file.");
}
/* *************** Save file directly ******** */
@@ -732,6 +802,8 @@ static void WM_OT_save_as_mainfile(wmOperatorType *ot)
static int wm_save_mainfile_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
char name[FILE_MAX];
+
+ save_set_compress(op);
BLI_strncpy(name, G.sce, FILE_MAX);
untitled(name);
@@ -750,10 +822,8 @@ static void WM_OT_save_mainfile(wmOperatorType *ot)
ot->exec= wm_save_as_mainfile_exec;
ot->poll= WM_operator_winactive;
- ot->flag= 0;
-
- RNA_def_property(ot->srna, "filename", PROP_STRING, PROP_FILEPATH);
-
+ RNA_def_string_file_path(ot->srna, "filename", "", 0, "Filename", "");
+ RNA_def_boolean(ot->srna, "compress", 0, "Compress", "Write compressed .blend file.");
}
@@ -1590,6 +1660,7 @@ void wm_operatortype_init(void)
WM_operatortype_append(WM_OT_exit_blender);
WM_operatortype_append(WM_OT_open_recentfile);
WM_operatortype_append(WM_OT_open_mainfile);
+ WM_operatortype_append(WM_OT_recover_last_session);
WM_operatortype_append(WM_OT_jobs_timer);
WM_operatortype_append(WM_OT_save_as_mainfile);
WM_operatortype_append(WM_OT_save_mainfile);