Revision: 44925
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=44925
Author:   alexk
Date:     2012-03-16 17:37:45 +0000 (Fri, 16 Mar 2012)
Log Message:
-----------
Patch by Psy-Fi + my minor changes

Adds conformation on exit for windows. Needs to be enabled in user perf.

Tried to edit blender.exe.manifest for more modern dialog look, but didn't work 
out.

Modified Paths:
--------------
    trunk/blender/intern/ghost/GHOST_C-api.h
    trunk/blender/intern/ghost/GHOST_ISystem.h
    trunk/blender/intern/ghost/intern/GHOST_C-api.cpp
    trunk/blender/intern/ghost/intern/GHOST_System.cpp
    trunk/blender/intern/ghost/intern/GHOST_System.h
    trunk/blender/intern/ghost/intern/GHOST_SystemWin32.cpp
    trunk/blender/intern/ghost/intern/GHOST_SystemWin32.h
    trunk/blender/release/scripts/startup/bl_ui/space_userpref.py
    trunk/blender/source/blender/makesdna/DNA_userdef_types.h
    trunk/blender/source/blender/makesrna/intern/rna_userdef.c
    trunk/blender/source/blender/windowmanager/intern/wm_window.c

Modified: trunk/blender/intern/ghost/GHOST_C-api.h
===================================================================
--- trunk/blender/intern/ghost/GHOST_C-api.h    2012-03-16 15:39:25 UTC (rev 
44924)
+++ trunk/blender/intern/ghost/GHOST_C-api.h    2012-03-16 17:37:45 UTC (rev 
44925)
@@ -842,6 +842,14 @@
  */
 extern int GHOST_toggleConsole(int action);
 
+
+/**
+ * Confirms quitting he program when there is just one window left open
+ * in the application
+ */
+extern int GHOST_confirmQuit(GHOST_WindowHandle windowhandle);
+
+
 #ifdef __cplusplus
 }
 #endif

Modified: trunk/blender/intern/ghost/GHOST_ISystem.h
===================================================================
--- trunk/blender/intern/ghost/GHOST_ISystem.h  2012-03-16 15:39:25 UTC (rev 
44924)
+++ trunk/blender/intern/ghost/GHOST_ISystem.h  2012-03-16 17:37:45 UTC (rev 
44925)
@@ -392,7 +392,11 @@
         */
        virtual void putClipboard(GHOST_TInt8 *buffer, bool selection) const = 
0;
 
-       
+       /**
+        * Confirms quitting he program when there is just one window left open
+        * in the application
+        */
+       virtual int confirmQuit(GHOST_IWindow * window) const = 0;
 protected:
        /**
         * Initialize the system.

Modified: trunk/blender/intern/ghost/intern/GHOST_C-api.cpp
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_C-api.cpp   2012-03-16 15:39:25 UTC 
(rev 44924)
+++ trunk/blender/intern/ghost/intern/GHOST_C-api.cpp   2012-03-16 17:37:45 UTC 
(rev 44925)
@@ -865,3 +865,9 @@
        GHOST_ISystem* system = GHOST_ISystem::getSystem();
        return system->toggleConsole(action);
 }
+
+
+int GHOST_confirmQuit(GHOST_WindowHandle windowhandle){
+       GHOST_ISystem* system = GHOST_ISystem::getSystem();
+       return system->confirmQuit((GHOST_IWindow*) windowhandle);
+}

Modified: trunk/blender/intern/ghost/intern/GHOST_System.cpp
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_System.cpp  2012-03-16 15:39:25 UTC 
(rev 44924)
+++ trunk/blender/intern/ghost/intern/GHOST_System.cpp  2012-03-16 17:37:45 UTC 
(rev 44925)
@@ -366,3 +366,9 @@
        }
        return success;
 }
+
+
+int GHOST_System::confirmQuit(GHOST_IWindow * window) const
+{
+       return 1;
+}

Modified: trunk/blender/intern/ghost/intern/GHOST_System.h
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_System.h    2012-03-16 15:39:25 UTC 
(rev 44924)
+++ trunk/blender/intern/ghost/intern/GHOST_System.h    2012-03-16 17:37:45 UTC 
(rev 44925)
@@ -297,6 +297,13 @@
           */
          virtual void putClipboard(GHOST_TInt8 *buffer, bool selection) const 
= 0;
 
+        /**
+        * Confirms quitting he program when there is just one window left open
+        * in the application
+        */
+       virtual int confirmQuit(GHOST_IWindow * window) const;
+
+
        
 protected:
        /**

Modified: trunk/blender/intern/ghost/intern/GHOST_SystemWin32.cpp
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_SystemWin32.cpp     2012-03-16 
15:39:25 UTC (rev 44924)
+++ trunk/blender/intern/ghost/intern/GHOST_SystemWin32.cpp     2012-03-16 
17:37:45 UTC (rev 44925)
@@ -1356,3 +1356,9 @@
 
        return m_consoleStatus;
 }
+
+int GHOST_SystemWin32::confirmQuit(GHOST_IWindow * window) const
+{
+       return (MessageBox(window ? ((GHOST_WindowWin32*)window)->getHWND() : 
0, "Some changes have not been saved.\nDo you really want to quit ?",
+                       "Exit Blender", MB_OKCANCEL | MB_ICONWARNING | 
MB_TOPMOST) == IDOK);
+}
\ No newline at end of file

Modified: trunk/blender/intern/ghost/intern/GHOST_SystemWin32.h
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_SystemWin32.h       2012-03-16 
15:39:25 UTC (rev 44924)
+++ trunk/blender/intern/ghost/intern/GHOST_SystemWin32.h       2012-03-16 
17:37:45 UTC (rev 44925)
@@ -200,7 +200,13 @@
         * @return Indication whether the event was handled. 
         */
        static GHOST_TSuccess pushDragDropEvent(GHOST_TEventType eventType, 
GHOST_TDragnDropTypes draggedObjectType,GHOST_IWindow* window, int mouseX, int 
mouseY, void* data);
-        
+       
+/**
+ * Confirms quitting he program when there is just one window left open
+ * in the application
+ */
+       virtual int confirmQuit(GHOST_IWindow * window) const;
+
 protected:
        /**
         * Initializes the system.

Modified: trunk/blender/release/scripts/startup/bl_ui/space_userpref.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/space_userpref.py       
2012-03-16 15:39:25 UTC (rev 44924)
+++ trunk/blender/release/scripts/startup/bl_ui/space_userpref.py       
2012-03-16 17:37:45 UTC (rev 44925)
@@ -244,7 +244,10 @@
 
         col.prop(view, "show_splash")
 
+        if os.name == 'nt':
+            col.prop(view, "quit_dialog")
 
+
 class USERPREF_PT_edit(Panel):
     bl_space_type = 'USER_PREFERENCES'
     bl_label = "Edit"

Modified: trunk/blender/source/blender/makesdna/DNA_userdef_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_userdef_types.h   2012-03-16 
15:39:25 UTC (rev 44924)
+++ trunk/blender/source/blender/makesdna/DNA_userdef_types.h   2012-03-16 
17:37:45 UTC (rev 44925)
@@ -510,6 +510,7 @@
 #define USER_SPLASH_DISABLE            (1 << 27)
 #define USER_HIDE_RECENT               (1 << 28)
 #define USER_SHOW_THUMBNAILS   (1 << 29)
+#define USER_QUIT_PROMPT               (1 << 30)
 
 /* Auto-Keying mode */
        /* AUTOKEY_ON is a bitflag */

Modified: trunk/blender/source/blender/makesrna/intern/rna_userdef.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_userdef.c  2012-03-16 
15:39:25 UTC (rev 44924)
+++ trunk/blender/source/blender/makesrna/intern/rna_userdef.c  2012-03-16 
17:37:45 UTC (rev 44925)
@@ -2369,6 +2369,11 @@
        RNA_def_property_ui_text(prop, "Sub Level Menu Open Delay",
                                 "Time delay in 1/10 seconds before 
automatically opening sub level menus");
 
+       prop = RNA_def_property(srna, "quit_dialog", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "uiflag", USER_QUIT_PROMPT);
+       RNA_def_property_ui_text(prop, "Prompt Quit",
+                                "Asks for confirmation when quitting through 
the window close button");
+
        /* Toolbox click-hold delay */
        prop = RNA_def_property(srna, "open_left_mouse_delay", PROP_INT, 
PROP_NONE);
        RNA_def_property_int_sdna(prop, NULL, "tb_leftmouse");

Modified: trunk/blender/source/blender/windowmanager/intern/wm_window.c
===================================================================
--- trunk/blender/source/blender/windowmanager/intern/wm_window.c       
2012-03-16 15:39:25 UTC (rev 44924)
+++ trunk/blender/source/blender/windowmanager/intern/wm_window.c       
2012-03-16 17:37:45 UTC (rev 44925)
@@ -250,8 +250,25 @@
 /* this is event from ghost, or exit-blender op */
 void wm_window_close(bContext *C, wmWindowManager *wm, wmWindow *win)
 {
+       wmWindow *tmpwin;
        bScreen *screen= win->screen;
        
+       /* first check if we have any non-temp remaining windows */
+       if((U.uiflag & USER_QUIT_PROMPT) && !wm->file_saved){
+               if(wm->windows.first) {
+                       for(tmpwin = wm->windows.first; tmpwin; tmpwin = 
tmpwin->next){
+                               if(tmpwin == win)
+                                       continue;
+                               if(tmpwin->screen->temp == 0)
+                                       break;
+                       }
+                       if(tmpwin == NULL){
+                               if(!GHOST_confirmQuit(win->ghostwin))
+                                       return;
+                       }
+               }
+       }
+
        BLI_remlink(&wm->windows, win);
        
        wm_draw_window_clear(win);

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to