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:
authorIan Thompson <quornian@googlemail.com>2008-08-18 21:08:25 +0400
committerIan Thompson <quornian@googlemail.com>2008-08-18 21:08:25 +0400
commitd6a9f7f4850defeb13c994caecc6776adb782f08 (patch)
tree0dd51de90b7cd4e5e6c077c7914e0f46fa1a34af /source/blender/src/drawtext.c
parente1ceab6ed68b6efef839f5f1b7adbd84c48279cd (diff)
Made modification alert slightly less intrusive and added Ignore option.
Diffstat (limited to 'source/blender/src/drawtext.c')
-rw-r--r--source/blender/src/drawtext.c136
1 files changed, 80 insertions, 56 deletions
diff --git a/source/blender/src/drawtext.c b/source/blender/src/drawtext.c
index 0c8e96f89fc..91af3ecb6c6 100644
--- a/source/blender/src/drawtext.c
+++ b/source/blender/src/drawtext.c
@@ -1792,6 +1792,26 @@ int txt_file_modified(Text *text)
return 0;
}
+void txt_ignore_modified(Text *text) {
+ struct stat st;
+ int result;
+ char file[FILE_MAXDIR+FILE_MAXFILE];
+
+ if (!text || !text->name) return;
+
+ BLI_strncpy(file, text->name, FILE_MAXDIR+FILE_MAXFILE);
+ BLI_convertstringcode(file, G.sce);
+
+ if (!BLI_exists(file)) return;
+
+ result = stat(file, &st);
+
+ if(result == -1 || (st.st_mode & S_IFMT) != S_IFREG)
+ return;
+
+ text->mtime= st.st_mtime;
+}
+
static void save_mem_text(char *str)
{
SpaceText *st= curarea->spacedata.first;
@@ -2621,6 +2641,65 @@ static short do_markers(SpaceText *st, char ascii, unsigned short evnt, short va
return swallow;
}
+static short do_modification_check(SpaceText *st) {
+ Text *text= st->text;
+
+ if (last_check_time < PIL_check_seconds_timer() - 2.0) {
+ switch (txt_file_modified(text)) {
+ case 1:
+ /* Modified locally and externally, ahhh. Offer more possibilites. */
+ if (text->flags & TXT_ISDIRTY) {
+ switch (pupmenu("File Modified Outside and Inside Blender %t|Load outside changes (ignore local changes) %x0|Save local changes (ignore outside changes) %x1|Make text internal (separate copy) %x2")) {
+ case 0:
+ reopen_text(text);
+ if (st->showsyntax) txt_format_text(st);
+ return 1;
+ case 1:
+ txt_write_file(text);
+ return 1;
+ case 2:
+ text->flags |= TXT_ISMEM | TXT_ISDIRTY | TXT_ISTMP;
+ MEM_freeN(text->name);
+ text->name= NULL;
+ return 1;
+ }
+ } else {
+ switch (pupmenu("File Modified Outside Blender %t|Reload from disk %x0|Make text internal (separate copy) %x1|Ignore %x2")) {
+ case 0:
+ reopen_text(text);
+ if (st->showsyntax) txt_format_text(st);
+ return 1;
+ case 1:
+ text->flags |= TXT_ISMEM | TXT_ISDIRTY | TXT_ISTMP;
+ MEM_freeN(text->name);
+ text->name= NULL;
+ return 1;
+ case 2:
+ txt_ignore_modified(text);
+ return 1;
+ }
+ }
+ break;
+ case 2:
+ switch (pupmenu("File Deleted Outside Blender %t|Make text internal %x0|Recreate file %x1")) {
+ case 0:
+ text->flags |= TXT_ISMEM | TXT_ISDIRTY | TXT_ISTMP;
+ MEM_freeN(text->name);
+ text->name= NULL;
+ return 1;
+ case 1:
+ txt_write_file(text);
+ return 1;
+ }
+ break;
+ default:
+ break;
+ }
+ last_check_time = PIL_check_seconds_timer();
+ }
+ return 0;
+}
+
void winqreadtextspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
{
unsigned short event= evt->event;
@@ -3229,62 +3308,7 @@ void winqreadtextspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
}
}
- if (last_check_time < PIL_check_seconds_timer() - 10.0) {
- switch (txt_file_modified(text)) {
- case 1:
- /* Modified locally and externally, ahhh. Offer more possibilites. */
- if (text->flags & TXT_ISDIRTY) {
- switch (pupmenu("File Modified Outside and Inside Blender %t|Load outside changes (ignore local changes) %x0|Save local changes (ignore outside changes) %x1|Make text internal (separate copy) %x2")) {
- case 0:
- reopen_text(text);
- if (st->showsyntax) txt_format_text(st);
- do_draw= 1;
- break;
- case 1:
- txt_write_file(text);
- do_draw= 1;
- break;
- case 2:
- text->flags |= TXT_ISMEM | TXT_ISDIRTY | TXT_ISTMP;
- MEM_freeN(text->name);
- text->name= NULL;
- do_draw= 1;
- break;
- }
- } else {
- switch (pupmenu("File Modified Outside Blender %t|Reload from disk %x0|Make text internal (separate copy) %x1")) {
- case 0:
- reopen_text(text);
- if (st->showsyntax) txt_format_text(st);
- do_draw= 1;
- break;
- case 1:
- text->flags |= TXT_ISMEM | TXT_ISDIRTY | TXT_ISTMP;
- MEM_freeN(text->name);
- text->name= NULL;
- do_draw= 1;
- break;
- }
- }
- break;
- case 2:
- switch (pupmenu("File Deleted Outside Blender %t|Make text internal %x0|Recreate file %x1")) {
- case 0:
- text->flags |= TXT_ISMEM | TXT_ISDIRTY | TXT_ISTMP;
- MEM_freeN(text->name);
- text->name= NULL;
- do_draw= 1;
- break;
- case 1:
- txt_write_file(text);
- do_draw= 1;
- break;
- }
- break;
- default:
- last_check_time = PIL_check_seconds_timer();
- }
- }
+ if (do_modification_check(st)) do_draw= 1;
if (do_draw) {
ScrArea *sa;