2.5
authorTon Roosendaal <ton@blender.org>
Wed, 18 Feb 2009 13:29:54 +0000 (13:29 +0000)
committerTon Roosendaal <ton@blender.org>
Wed, 18 Feb 2009 13:29:54 +0000 (13:29 +0000)
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.

18 files changed:
source/blender/blenfont/intern/blf.c
source/blender/editors/screen/area.c
source/blender/editors/screen/screen_edit.c
source/blender/editors/screen/screendump.c
source/blender/editors/space_info/info_header.c
source/blender/editors/space_info/space_info.c
source/blender/editors/util/undo.c
source/blender/makesdna/DNA_windowmanager_types.h
source/blender/windowmanager/WM_api.h
source/blender/windowmanager/WM_types.h
source/blender/windowmanager/intern/wm.c
source/blender/windowmanager/intern/wm_event_system.c
source/blender/windowmanager/intern/wm_files.c
source/blender/windowmanager/intern/wm_init_exit.c
source/blender/windowmanager/intern/wm_jobs.c
source/blender/windowmanager/intern/wm_operators.c
source/blender/windowmanager/intern/wm_window.c
source/blender/windowmanager/wm_window.h

index b602a7f1234277541ecdd7e6520e61229b777921..491d39aa30189cef23c013d3477c812a7340256e 100644 (file)
@@ -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();
index dfbd6c031d174b32b1e6103cf17f70a6e240b013..68a67823c606f4289d7d19e37e407269a553631f 100644 (file)
@@ -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);
index 3f047add6d550c1784cb6ecff2f240ada1655292..51515f1862343903a27821b054b82fccadc267e6 100644 (file)
@@ -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;
                
index 9818e2fdd6f188f8844c8a79d3ed444b6f297533..75b85b9499f71125c753557f34148c43aef119f0 100644 (file)
@@ -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;
 }
 
index 4b750600583c81c4f6e3032a3e19b550f04eac3e..32c01b53a9e041b9d0d4e18e6dbba4f187e8563b 100644 (file)
 #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"
 #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  */
index 141127d7eb5f72b880a55f031d1ca6f4fdc702ee..6d7fb5a1cdf52feee8dad4c95c528c9322b2a138 100644 (file)
@@ -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;
        }
        
 }
index 5d7ed72127e8b3990185fa56e3cf16ec18c9411f..15dba3fc951c6871a63afd512dc90533249179af 100644 (file)
@@ -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)
index 468623cd2b020946c43015cb91b8a8f19f3063d6..ba423334ccedc814fa5dbd1cb5a5f9715801cfc6 100644 (file)
@@ -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 */
        
index 45dd2f3aee2b340beb283359e35013670208cfd6..2dd1aa871c242b27ef77d62d1efa237a4d651e8c 100644 (file)
@@ -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 */
index 2e7b31b070060a13a64847aad4fcfc542d6d429f..d67a31f9e426db962801c12dfd908134b5b1fd17 100644 (file)
@@ -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)
index 56d8788fdcb7283362eb801dd1d3e3ba698c0d9e..e209a9e658fd8b47801d49d4b778bf38e2535d0d 100644 (file)
@@ -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); 
 }
 
index 804c8e6b828bf130d2c42fa01dad3d8dc1cc5792..9fe97f307c5636acfe564bcadedb5a15ce12da88 100644 (file)
@@ -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);
index cf93b4f0df3dfa3550b2c261eb0204fe7f2ba28e..7fc0efc4370cea9c5640b59df9f76ecf6491b326 100644 (file)
@@ -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;
 }
 
index df3ad0d6d5c1fe1637a77d739c9aa07b4d2fd1aa..9c13a321cf1f235792a3cb076a12dd31144cda4f 100644 (file)
@@ -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);
        
index 40a72034d2613fc7c7cc9a4f7724c0809c134516..31c3a8032467c5174431fb961863ed3908a7662b 100644 (file)
@@ -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)
 {
index 9626fda6ffe2381468ecb2c57e22a71bd49c7744..3729365694f0ae32c02956b408a991600973cde5 100644 (file)
@@ -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;
 }
index 30c5d7e3a1080a6fa73cfe37a753d8d8ef877fb2..43871ba5a7fdbc473c27d4662075d4d74ee41432 100644 (file)
@@ -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 */
index 5db86989fd9dda3b2b922aba40de89e2a0525baa..f386510a2eb8a0b3c6efa80764d6abae525d259e 100644 (file)
@@ -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);