diff options
author | Ton Roosendaal <ton@blender.org> | 2009-02-18 16:29:54 +0300 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2009-02-18 16:29:54 +0300 |
commit | 1090b0c598712a8375e6189447b461ddd3d781b6 (patch) | |
tree | cde5a33c17d262cdf5dd7b7a88c6f3021197686f /source/blender | |
parent | 915e989f9d60d4523563f14b71df8c7f6d5e812e (diff) |
2.5
Several things in one commit; could not split this up easily,
one job invoked another, and so on. :)
- Added pulldowns for save/load .blend file in top bar.
- To enable "Save" without further popups (save over)
I've added a signaling function in window header to
indicate a succesful save.
- On any undo push it now signals 'file changed'. This
goes by notifiers nicely, but now registers only the
undopushes, which is quite unreliable. "Changed" state
shows in header as "Blender*" and for OSX with the
standard close button black dot.
- Made screencast show a button in top bar indicating such,
and allowing quit. No hotkey for quit yet... but ESC will
keep casting now.
- Fixed new BLF_init(), which should be in WM_init() and not
on any .B.blend read.
- Fixed CTRL+F3 "Save Screenshot", which was still using old
fileselect code.
Diffstat (limited to 'source/blender')
18 files changed, 321 insertions, 37 deletions
diff --git a/source/blender/blenfont/intern/blf.c b/source/blender/blenfont/intern/blf.c index b602a7f1234..491d39aa301 100644 --- a/source/blender/blenfont/intern/blf.c +++ b/source/blender/blenfont/intern/blf.c @@ -99,7 +99,8 @@ void BLF_exit(void) for (i= 0; i < global_font_num; i++) { font= global_font[i]; - blf_font_free(font); + if(font) + blf_font_free(font); } blf_font_exit(); diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index dfbd6c031d1..68a67823c60 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -119,7 +119,7 @@ void ED_region_do_listen(ARegion *ar, wmNotifier *note) case NC_SCREEN: if(note->action==NA_EDITED) ED_region_tag_redraw(ar); - break; + /* pass on */ default: if(ar->type && ar->type->listener) ar->type->listener(ar, note); diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index 3f047add6d5..51515f18623 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -1374,7 +1374,6 @@ void ed_screen_fullarea(bContext *C, ScrArea *sa) /* is there only 1 area? */ if(oldscreen->areabase.first==oldscreen->areabase.last) return; - if(sa->spacetype==SPACE_INFO) return; oldscreen->full = SCREENFULL; diff --git a/source/blender/editors/screen/screendump.c b/source/blender/editors/screen/screendump.c index 9818e2fdd6f..75b85b9499f 100644 --- a/source/blender/editors/screen/screendump.c +++ b/source/blender/editors/screen/screendump.c @@ -142,7 +142,6 @@ static int screenshot_invoke(bContext *C, wmOperator *op, wmEvent *event) dumprect= screenshot(C, &dumpsx, &dumpsy, RNA_boolean_get(op->ptr, "full")); if(dumprect) { - SpaceFile *sfile; ScreenshotData *scd= MEM_callocN(sizeof(ScreenshotData), "screenshot"); scd->dumpsx= dumpsx; @@ -153,13 +152,9 @@ static int screenshot_invoke(bContext *C, wmOperator *op, wmEvent *event) if(RNA_property_is_set(op->ptr, "filename")) return screenshot_exec(C, op); - ED_screen_full_newspace(C, CTX_wm_area(C), SPACE_FILE); + RNA_string_set(op->ptr, "filename", G.ima); - /* settings for filebrowser */ - sfile= (SpaceFile*)CTX_wm_space_data(C); - sfile->op = op; - - ED_fileselect_set_params(sfile, FILE_BLENDER, "Save Screenshot As", G.ima, 0, 0, 0); + WM_event_add_fileselect(C, op); return OPERATOR_RUNNING_MODAL; } @@ -169,7 +164,7 @@ static int screenshot_invoke(bContext *C, wmOperator *op, wmEvent *event) void SCREEN_OT_screenshot(wmOperatorType *ot) { - ot->name= "Make Screenshot"; + ot->name= "Save Screenshot"; /* weak: opname starting with 'save' makes filewindow give save-over */ ot->idname= "SCREEN_OT_screenshot"; ot->invoke= screenshot_invoke; @@ -242,7 +237,7 @@ static void screenshot_startjob(void *sjv, short *stop, short *do_update) *do_update= 1; // wait for opengl rect - while(*stop==0 && G.afbreek==0) { + while(*stop==0) { if(sj->dumprect) { @@ -311,13 +306,13 @@ static int screencast_exec(bContext *C, wmOperator *op) /* setup job */ WM_jobs_customdata(steve, sj, screenshot_freejob); - WM_jobs_timer(steve, 0.1, 0, 0); + WM_jobs_timer(steve, 0.1, 0, NC_SCREEN|ND_SCREENCAST); WM_jobs_callbacks(steve, screenshot_startjob, NULL, screenshot_updatejob); - G.afbreek= 0; // XXX? - WM_jobs_start(steve); + WM_event_add_notifier(C, NC_SCREEN|ND_SCREENCAST, screen); + return OPERATOR_FINISHED; } diff --git a/source/blender/editors/space_info/info_header.c b/source/blender/editors/space_info/info_header.c index 4b750600583..32c01b53a9e 100644 --- a/source/blender/editors/space_info/info_header.c +++ b/source/blender/editors/space_info/info_header.c @@ -29,17 +29,23 @@ #include <string.h> #include <stdio.h> +#include "DNA_packedFile_types.h" #include "DNA_space_types.h" #include "DNA_scene_types.h" #include "DNA_screen_types.h" +#include "DNA_userdef_types.h" #include "DNA_windowmanager_types.h" #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" +#include "BLI_bpath.h" #include "BKE_context.h" #include "BKE_global.h" +#include "BKE_image.h" +#include "BKE_main.h" +#include "BKE_packedFile.h" #include "BKE_screen.h" #include "ED_screen.h" @@ -56,12 +62,18 @@ #include "UI_resources.h" #include "UI_view2d.h" +#include "IMB_imbuf_types.h" + #include "info_intern.h" +static int pupmenu() {return 0;} +static int okee() {return 0;} +static int error() {return 0;} /* ************************ header area region *********************** */ #define B_STOPRENDER 1 +#define B_STOPCAST 2 static void do_viewmenu(bContext *C, void *arg, int event) { @@ -93,6 +105,219 @@ static uiBlock *dummy_viewmenu(bContext *C, ARegion *ar, void *arg_unused) return block; } +static int buttons_do_unpack() +{ + int how; + char menu[2048]; + char *line = menu; + int ret_value = 1, count = 0; + + count = countPackedFiles(); + + if(!count) { + pupmenu("No packed files. Autopack disabled"); + return ret_value; + } + if (count == 1) + line += sprintf(line, "Unpack 1 file%%t"); + else + line += sprintf(line, "Unpack %d files%%t", count); + + line += sprintf(line, "|Use files in current directory (create when necessary)%%x%d", PF_USE_LOCAL); + line += sprintf(line, "|Write files to current directory (overwrite existing files)%%x%d", PF_WRITE_LOCAL); + line += sprintf(line, "|%%l|Use files in original location (create when necessary)%%x%d", PF_USE_ORIGINAL); + line += sprintf(line, "|Write files to original location (overwrite existing files)%%x%d", PF_WRITE_ORIGINAL); + line += sprintf(line, "|%%l|Disable AutoPack, keep all packed files %%x%d", PF_KEEP); + line += sprintf(line, "|Ask for each file %%x%d", PF_ASK); + + how = pupmenu(menu); + + if(how == -1) + ret_value = 0; + else { + if (how != PF_KEEP) unpackAll(how); + G.fileflags &= ~G_AUTOPACK; + } + + return ret_value; +} + +static void check_packAll() +{ + // first check for dirty images + Image *ima; + + for(ima = G.main->image.first; ima; ima= ima->id.next) { + if (ima->ibufs.first) { /* XXX FIX */ + ImBuf *ibuf= BKE_image_get_ibuf(ima, NULL); + + if (ibuf && (ibuf->userflags &= IB_BITMAPDIRTY)) + break; + } + } + + if (ima == NULL || okee("Some images are painted on. These changes will be lost. Continue ?")) { + packAll(); + G.fileflags |= G_AUTOPACK; + } +} + +static void do_info_externalfiles(bContext *C, void *arg, int event) +{ + switch (event) { + + case 1: /* pack data */ + check_packAll(); + break; + case 3: /* unpack data */ + if (buttons_do_unpack() != 0) { + /* Clear autopack bit only if user selected one of the unpack options */ + G.fileflags &= ~G_AUTOPACK; + } + break; + case 10: /* make all paths relative */ + if (G.relbase_valid) { + int tot,changed,failed,linked; + char str[512]; + char txtname[24]; /* text block name */ + txtname[0] = '\0'; + makeFilesRelative(txtname, &tot, &changed, &failed, &linked); + if (failed) sprintf(str, "Make Relative%%t|Total files %i|Changed %i|Failed %i, See Text \"%s\"|Linked %i", tot, changed, failed, txtname, linked); + else sprintf(str, "Make Relative%%t|Total files %i|Changed %i|Failed %i|Linked %i", tot, changed, failed, linked); + pupmenu(str); + } else { + pupmenu("Can't set relative paths with an unsaved blend file"); + } + break; + case 11: /* make all paths absolute */ + { + int tot,changed,failed,linked; + char str[512]; + char txtname[24]; /* text block name */ + txtname[0] = '\0'; + makeFilesAbsolute(txtname, &tot, &changed, &failed, &linked); + sprintf(str, "Make Absolute%%t|Total files %i|Changed %i|Failed %i|Linked %i", tot, changed, failed, linked); + if (failed) sprintf(str, "Make Absolute%%t|Total files %i|Changed %i|Failed %i, See Text \"%s\"|Linked %i", tot, changed, failed, txtname, linked); + else sprintf(str, "Make Absolute%%t|Total files %i|Changed %i|Failed %i|Linked %i", tot, changed, failed, linked); + + pupmenu(str); + } + break; + case 12: /* check images exist */ + { + char txtname[24]; /* text block name */ + txtname[0] = '\0'; + + /* run the missing file check */ + checkMissingFiles( txtname ); + + if (txtname[0] == '\0') { + okee("No external files missing"); + } else { + char str[128]; + sprintf(str, "Missing files listed in Text \"%s\"", txtname ); + error(str); + } + } + break; + case 13: /* search for referenced files that are not available */ +// XXX if(curarea->spacetype==SPACE_INFO) { +// ScrArea *sa; +// sa= closest_bigger_area(); +// areawinset(sa->win); +// } +// activate_fileselect(FILE_SPECIAL, "Find Missing Files", "", findMissingFiles); + break; + } + +} + + +uiBlock *info_externalfiles(bContext *C, ARegion *ar, void *arg_unused) +{ + uiBlock *block; + short yco = 20, menuwidth = 120; + + block= uiBeginBlock(C, ar, "info_externalfiles", UI_EMBOSSP, UI_HELV); + uiBlockSetButmFunc(block, do_info_externalfiles, NULL); + + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Pack into .blend file", 0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 1, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Unpack into Files...", 0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 3, ""); + + uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); + + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Make all Paths Relative", 0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 10, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Make all Paths Absolute", 0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 11, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Report Missing Files...", 0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 12, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Find Missing Files...", 0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 13, ""); + + uiBlockSetDirection(block, UI_RIGHT); + uiTextBoundsBlock(block, 60); + return block; +} + + + +static void info_filemenu(bContext *C, uiMenuItem *head, void *arg_unused) +{ + + uiMenuContext(head, WM_OP_EXEC_AREA); + uiMenuItemO(head, 0, "WM_OT_read_homefile"); + uiMenuContext(head, WM_OP_INVOKE_AREA); + uiMenuItemO(head, 0, "WM_OT_open_mainfile"); +// uiDefIconTextBlockBut(block, info_openrecentmenu, NULL, ICON_RIGHTARROW_THIN, "Open Recent",0, yco-=20, 120, 19, ""); +// uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Recover Last Session", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 15, ""); + + uiMenuSeparator(head); + + uiMenuContext(head, WM_OP_EXEC_AREA); + uiMenuItemO(head, 0, "WM_OT_save_mainfile"); + uiMenuContext(head, WM_OP_INVOKE_AREA); + uiMenuItemO(head, 0, "WM_OT_save_as_mainfile"); + +#if 0 + if(U.flag & USER_FILECOMPRESS) { + uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Compress File", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 35, "Enable file compression"); + } else { + uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Compress File", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 35, "Enable file compression"); + } + + uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); + + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Save Rendered Image...|F3", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 6, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Screenshot Subwindow|Ctrl F3", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 24, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Screenshot All|Ctrl Shift F3", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 25, ""); +#if GAMEBLENDER == 1 + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Save Game As Runtime...", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 22, ""); +#endif + uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); + + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Save Default Settings|Ctrl U", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 31, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Load Factory Settings", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 32, ""); + + + uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); + + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Append or Link|Shift F1", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 3, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Append or Link (Image Browser)|Ctrl F1", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 7, ""); +// uiDefIconTextBlockBut(block, info_file_importmenu, NULL, ICON_RIGHTARROW_THIN, "Import", 0, yco-=20, menuwidth, 19, ""); +// uiDefIconTextBlockBut(block, info_file_exportmenu, NULL, ICON_RIGHTARROW_THIN, "Export", 0, yco-=20, menuwidth, 19, ""); + + uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); + + uiDefIconTextBlockBut(block, info_externalfiles, NULL, ICON_RIGHTARROW_THIN, "External Data",0, yco-=20, 120, 19, ""); + + uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); + + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Quit Blender|Ctrl Q", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 13, ""); + uiBlockSetDirection(block, UI_DOWN); + uiTextBoundsBlock(block, 80); + + uiEndBlock(C, block); + return block; +#endif +} + static void do_info_buttons(bContext *C, void *arg, int event) { @@ -100,6 +325,9 @@ static void do_info_buttons(bContext *C, void *arg, int event) case B_STOPRENDER: G.afbreek= 1; break; + case B_STOPCAST: + WM_jobs_stop(CTX_wm_manager(C), CTX_wm_screen(C)); + break; } } @@ -179,7 +407,7 @@ void info_header_buttons(const bContext *C, ARegion *ar) uiBlockSetEmboss(block, UI_EMBOSSP); xmax= GetButStringLength("File"); - uiDefPulldownBut(block, dummy_viewmenu, sa, "File", xco, yco, xmax-3, 22, ""); + uiDefMenuBut(block, info_filemenu, NULL, "File", xco, yco-2, xmax-3, 24, ""); xco+= xmax; xmax= GetButStringLength("Add"); @@ -218,6 +446,11 @@ void info_header_buttons(const bContext *C, ARegion *ar) if(WM_jobs_test(CTX_wm_manager(C), CTX_data_scene(C))) { uiDefIconTextBut(block, BUT, B_STOPRENDER, ICON_REC, "Render", xco+5,yco,75,19, NULL, 0.0f, 0.0f, 0, 0, "Stop rendering"); + xco+= 80; + } + if(WM_jobs_test(CTX_wm_manager(C), CTX_wm_screen(C))) { + uiDefIconTextBut(block, BUT, B_STOPCAST, ICON_REC, "Capture", xco+5,yco,85,19, NULL, 0.0f, 0.0f, 0, 0, "Stop screencast"); + xco+= 90; } /* always as last */ diff --git a/source/blender/editors/space_info/space_info.c b/source/blender/editors/space_info/space_info.c index 141127d7eb5..6d7fb5a1cdf 100644 --- a/source/blender/editors/space_info/space_info.c +++ b/source/blender/editors/space_info/space_info.c @@ -218,9 +218,14 @@ static void info_header_listener(ARegion *ar, wmNotifier *wmn) { /* context changes */ switch(wmn->category) { + case NC_SCREEN: + if(wmn->data==ND_SCREENCAST) + ED_region_tag_redraw(ar); + break; case NC_SCENE: if(wmn->data==ND_RENDER_RESULT) ED_region_tag_redraw(ar); + break; } } diff --git a/source/blender/editors/util/undo.c b/source/blender/editors/util/undo.c index 5d7ed72127e..15dba3fc951 100644 --- a/source/blender/editors/util/undo.c +++ b/source/blender/editors/util/undo.c @@ -78,6 +78,7 @@ static void sound_initialize_sounds() {} void ED_undo_push(bContext *C, char *str) { + wmWindowManager *wm= CTX_wm_manager(C); Object *obedit= CTX_data_edit_object(C); if(obedit) { @@ -105,6 +106,11 @@ void ED_undo_push(bContext *C, char *str) if(U.uiflag & USER_GLOBALUNDO) BKE_write_undo(C, str); } + + if(wm->file_saved) { + wm->file_saved= 0; + WM_event_add_notifier(C, NC_WM|ND_DATACHANGED, NULL); + } } void ED_undo_push_op(bContext *C, wmOperator *op) diff --git a/source/blender/makesdna/DNA_windowmanager_types.h b/source/blender/makesdna/DNA_windowmanager_types.h index 468623cd2b0..ba423334cce 100644 --- a/source/blender/makesdna/DNA_windowmanager_types.h +++ b/source/blender/makesdna/DNA_windowmanager_types.h @@ -61,7 +61,8 @@ typedef struct wmWindowManager { ListBase windows; int initialized; /* set on file read */ - int pad; + short file_saved; /* indicator whether data was saved */ + short pad; ListBase operators; /* operator registry */ diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index 45dd2f3aee2..2dd1aa871c2 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -203,6 +203,7 @@ void WM_jobs_callbacks(struct wmJob *, void (*update)(void *)); void WM_jobs_start(struct wmJob *); +void WM_jobs_stop(struct wmWindowManager *wm, void *owner); void WM_jobs_stop_all(struct wmWindowManager *wm); #endif /* WM_API_H */ diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h index 2e7b31b0700..d67a31f9e42 100644 --- a/source/blender/windowmanager/WM_types.h +++ b/source/blender/windowmanager/WM_types.h @@ -160,9 +160,13 @@ typedef struct wmNotifier { /* NC_WM windowmanager */ #define ND_FILEREAD (1<<16) +#define ND_FILESAVE (2<<16) +#define ND_DATACHANGED (3<<16) /* NC_SCREEN screen */ #define ND_SCREENBROWSE (1<<16) +#define ND_SCREENCAST (2<<16) + /* NC_SCENE Scene */ #define ND_SCENEBROWSE (1<<16) diff --git a/source/blender/windowmanager/intern/wm.c b/source/blender/windowmanager/intern/wm.c index 56d8788fdcb..e209a9e658f 100644 --- a/source/blender/windowmanager/intern/wm.c +++ b/source/blender/windowmanager/intern/wm.c @@ -135,6 +135,7 @@ void wm_add_default(bContext *C) BLI_strncpy(win->screenname, screen->id.name+2, 21); wm->winactive= win; + wm->file_saved= 1; wm_window_make_drawable(C, win); } diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 804c8e6b828..9fe97f307c5 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -141,6 +141,14 @@ void wm_event_do_notifiers(bContext *C) CTX_wm_window_set(C, win); for(note= wm->queue.first; note; note= note->next) { + if(note->category==NC_WM) { + if( ELEM(note->data, ND_FILEREAD, ND_FILESAVE)) { + wm->file_saved= 1; + wm_window_title(wm, win); + } + else if(note->data==ND_DATACHANGED) + wm_window_title(wm, win); + } if(note->window==win) { if(note->category==NC_SCREEN) { if(note->data==ND_SCREENBROWSE) @@ -177,7 +185,7 @@ void wm_event_do_notifiers(bContext *C) /* XXX context in notifiers? */ CTX_wm_window_set(C, win); - /* printf("notifier win %d screen %s\n", win->winid, win->screen->id.name+2); */ + /* printf("notifier win %d screen %s cat %x\n", win->winid, win->screen->id.name+2, note->category); */ ED_screen_do_listen(win, note); for(ar=win->screen->regionbase.first; ar; ar= ar->next) { @@ -776,6 +784,7 @@ static int wm_handler_fileselect_call(bContext *C, ListBase *handlers, wmEventHa wm_handler_op_context(C, handler); /* a bit weak, might become arg for WM_event_fileselect? */ + /* XXX also extension code in image-save doesnt work for this yet */ if(strncmp(handler->op->type->name, "Save", 4)==0) { /* this gives ownership to pupmenu */ uiPupMenuSaveOver(C, handler->op, path); diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index cf93b4f0df3..7fc0efc4370 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -84,7 +84,6 @@ #include "GHOST_C-api.h" #include "UI_interface.h" -#include "BLF_api.h" #include "GPU_draw.h" @@ -588,10 +587,7 @@ int WM_read_homefile(bContext *C, wmOperator *op) wm_check(C); /* opens window(s), checks keymaps */ strcpy(G.sce, scestr); /* restore */ - - BLF_lang_init(); - BLF_init(); - + init_userdef_themes(); /* When loading factory settings, the reset solid OpenGL lights need to be applied. */ @@ -868,8 +864,7 @@ void WM_write_file(bContext *C, char *target, ReportList *reports) G.relbase_valid = 1; strcpy(G.main->name, di); /* is guaranteed current file */ - G.save_over = 1; - wm_window_titles(CTX_wm_manager(C)); + G.save_over = 1; /* disable untitled.blend convention */ writeBlog(); } @@ -890,6 +885,8 @@ int WM_write_homefile(bContext *C, wmOperator *op) BLO_write_file(CTX_data_main(C), tstr, write_flags, op->reports); + G.save_over= 0; + return OPERATOR_FINISHED; } diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index df3ad0d6d5c..9c13a321cf1 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -121,6 +121,9 @@ void WM_init(bContext *C) ED_file_init(); /* for fsmenu */ ED_init_node_butfuncs(); + BLF_init(); + BLF_lang_init(); + /* get the default database, plus a wm */ WM_read_homefile(C, NULL); diff --git a/source/blender/windowmanager/intern/wm_jobs.c b/source/blender/windowmanager/intern/wm_jobs.c index 40a72034d26..31c3a803246 100644 --- a/source/blender/windowmanager/intern/wm_jobs.c +++ b/source/blender/windowmanager/intern/wm_jobs.c @@ -249,6 +249,17 @@ void WM_jobs_stop_all(wmWindowManager *wm) BLI_freelistN(&wm->jobs); } +/* stops job(s) from this owner */ +void WM_jobs_stop(wmWindowManager *wm, void *owner) +{ + wmJob *steve; + + for(steve= wm->jobs.first; steve; steve= steve->next) + if(steve->owner==owner) + if(steve->running) + steve->stop= 1; +} + /* hardcoded to event TIMERJOBS */ static int wm_jobs_timer(bContext *C, wmOperator *op, wmEvent *evt) { diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 9626fda6ffe..3729365694f 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -412,11 +412,16 @@ 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]; - RNA_string_get(op->ptr, "filename", filename); + if(RNA_property_is_set(op->ptr, "filename")) + RNA_string_get(op->ptr, "filename", filename); + else { + BLI_strncpy(filename, G.sce, FILE_MAX); + untitled(filename); + } WM_write_file(C, filename, op->reports); - WM_event_add_notifier(C, NC_WINDOW, NULL); + WM_event_add_notifier(C, NC_WM|ND_FILESAVE, NULL); return 0; } diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index 30c5d7e3a10..43871ba5a7f 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -181,19 +181,31 @@ static void wm_window_close(bContext *C, wmWindow *win) WM_exit(C); } -void wm_window_titles(wmWindowManager *wm) +void wm_window_title(wmWindowManager *wm, wmWindow *win) { + /* this is set to 1 if you don't have .B.blend open */ if(G.save_over) { - wmWindow *win; char *str= MEM_mallocN(strlen(G.sce) + 16, "title"); - sprintf(str, "Blender [%s]", G.sce); + if(wm->file_saved) + sprintf(str, "Blender [%s]", G.sce); + else + sprintf(str, "Blender* [%s]", G.sce); + + GHOST_SetTitle(win->ghostwin, str); - for(win= wm->windows.first; win; win= win->next) - GHOST_SetTitle(win->ghostwin, str); - MEM_freeN(str); } + else + GHOST_SetTitle(win->ghostwin, "Blender"); + +#ifdef __APPLE__ + if(wm->file_saved) + GHOST_SetWindowState(win->ghostwin, GHOST_kWindowStateUnModified); + else + GHOST_SetWindowState(win->ghostwin, GHOST_kWindowStateModified); +#endif + } /* belongs to below */ @@ -236,6 +248,8 @@ static void wm_window_add_ghostwindow(wmWindowManager *wm, char *title, wmWindow glClear(GL_COLOR_BUFFER_BIT); wm_window_swap_buffers(win); + //GHOST_SetWindowState(ghostwin, GHOST_kWindowStateModified); + /* standard state vars for window */ glEnable(GL_SCISSOR_TEST); @@ -289,10 +303,9 @@ void wm_window_add_ghostwindows(wmWindowManager *wm) keymap= WM_keymap_listbase(wm, "Screen", 0, 0); WM_event_add_keymap_handler(&win->handlers, keymap); + + wm_window_title(wm, win); } - - wm_window_titles(wm); - } /* new window, no screen yet, but we open ghostwindow for it */ diff --git a/source/blender/windowmanager/wm_window.h b/source/blender/windowmanager/wm_window.h index 5db86989fd9..f386510a2eb 100644 --- a/source/blender/windowmanager/wm_window.h +++ b/source/blender/windowmanager/wm_window.h @@ -37,7 +37,7 @@ void wm_ghost_init (bContext *C); wmWindow *wm_window_new (bContext *C); void wm_window_free (bContext *C, wmWindow *win); -void wm_window_titles (wmWindowManager *wm); +void wm_window_title (wmWindowManager *wm, wmWindow *win); void wm_window_add_ghostwindows (wmWindowManager *wm); void wm_window_process_events (const bContext *C); |