Revision: 15162
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=15162
Author:   quorn
Date:     2008-06-08 21:29:19 +0200 (Sun, 08 Jun 2008)

Log Message:
-----------
Prevent editing of linked library Texts

Modified Paths:
--------------
    branches/soc-2008-quorn/source/blender/src/drawtext.c
    branches/soc-2008-quorn/source/blender/src/header_text.c

Modified: branches/soc-2008-quorn/source/blender/src/drawtext.c
===================================================================
--- branches/soc-2008-quorn/source/blender/src/drawtext.c       2008-06-08 
10:48:37 UTC (rev 15161)
+++ branches/soc-2008-quorn/source/blender/src/drawtext.c       2008-06-08 
19:29:19 UTC (rev 15162)
@@ -1605,7 +1605,10 @@
                        }
                }
        } else if (ascii) {
-               if ((st->overwrite && txt_replace_char(text, ascii)) || 
txt_add_char(text, ascii)) {
+               if (text && text->id.lib) {
+                       error_libdata();
+
+               } else if ((st->overwrite && txt_replace_char(text, ascii)) || 
txt_add_char(text, ascii)) {
                        if (st->showsyntax) get_format_string(st);
                        pop_space_text(st);
                        do_draw= 1;
@@ -1633,6 +1636,10 @@
                        }
                        break; /* BREAK C */
                case DKEY:
+                       if (text && text->id.lib) {
+                               error_libdata();
+                               break;
+                       }
                        if (G.qual == (LR_CTRLKEY|LR_SHIFTKEY)) {
                                //uncommenting
                                txt_order_cursors(text);
@@ -1651,6 +1658,10 @@
                        if (G.qual == (LR_ALTKEY|LR_SHIFTKEY)) {
                                switch(pupmenu("Edit %t|Cut %x0|Copy %x1|Paste 
%x2|Print Cut Buffer %x3")) {
                                case 0:
+                                       if (text && text->id.lib) {
+                                               error_libdata();
+                                               break;
+                                       }
                                        txt_copy_clipboard(text); //First copy 
to clipboard
                                        txt_cut_sel(text);
                                        do_draw= 1;
@@ -1661,6 +1672,10 @@
                                        do_draw= 1;
                                        break;
                                case 2:
+                                       if (text && text->id.lib) {
+                                               error_libdata();
+                                               break;
+                                       }
                                        //txt_paste(text);
                                        txt_paste_clipboard(text);
                                        if (st->showsyntax) 
get_format_string(st);
@@ -1824,6 +1839,10 @@
                        }
                        /* Support for both Alt-V and Ctrl-V for Paste, for 
backward compatibility reasons */
                        else if (G.qual & LR_ALTKEY || G.qual & LR_CTRLKEY) {
+                               if (text && text->id.lib) {
+                                       error_libdata();
+                                       break;
+                               }
                                /* Throwing in the Shift modifier Paste from 
the OS clipboard */
                                if (G.qual & LR_SHIFTKEY)
                                        txt_paste_clipboard(text);
@@ -1836,6 +1855,10 @@
                        break; /* BREAK V */
                case XKEY:
                        if (G.qual == LR_ALTKEY || G.qual == LR_CTRLKEY) {
+                               if (text && text->id.lib) {
+                                       error_libdata();
+                                       break;
+                               }
                                txt_cut_sel(text);
                                if (st->showsyntax) get_format_string(st);
                                do_draw= 1;     
@@ -1854,6 +1877,10 @@
                        }
                        break;
                case TABKEY:
+                       if (text && text->id.lib) {
+                               error_libdata();
+                               break;
+                       }
                        if (G.qual & LR_SHIFTKEY) {
                                if (txt_has_sel(text)) {
                                        txt_order_cursors(text);
@@ -1874,6 +1901,10 @@
                        st->currtab_set = setcurr_tab(text);
                        break;
                case RETKEY:
+                       if (text && text->id.lib) {
+                               error_libdata();
+                               break;
+                       }
                        //double check tabs before splitting the line
                        st->currtab_set = setcurr_tab(text);
                        txt_split_curline(text);
@@ -1892,6 +1923,10 @@
                        pop_space_text(st);
                        break;
                case BACKSPACEKEY:
+                       if (text && text->id.lib) {
+                               error_libdata();
+                               break;
+                       }
                        if (G.qual & (LR_ALTKEY | LR_CTRLKEY)) {
                                txt_backspace_word(text);
                        } else {
@@ -1903,6 +1938,10 @@
                        pop_space_text(st);
                        break;
                case DELKEY:
+                       if (text && text->id.lib) {
+                               error_libdata();
+                               break;
+                       }
                        if (G.qual & (LR_ALTKEY | LR_CTRLKEY)) {
                                txt_delete_word(text);
                        } else {

Modified: branches/soc-2008-quorn/source/blender/src/header_text.c
===================================================================
--- branches/soc-2008-quorn/source/blender/src/header_text.c    2008-06-08 
10:48:37 UTC (rev 15161)
+++ branches/soc-2008-quorn/source/blender/src/header_text.c    2008-06-08 
19:29:19 UTC (rev 15162)
@@ -346,6 +346,10 @@
                txt_do_redo(text);
                break;
        case 3:
+               if (text && text->id.lib) {
+                       error_libdata();
+                       break;
+               }
                txt_copy_clipboard(text);
                txt_cut_sel(text);
                pop_space_text(st);
@@ -355,6 +359,10 @@
                txt_copy_clipboard(text);
                break;
        case 5:
+               if (text && text->id.lib) {
+                       error_libdata();
+                       break;
+               }
                txt_paste_clipboard(text);
                if (st->showsyntax) get_format_string(st);
                break;
@@ -457,6 +465,10 @@
        
        switch(event) {
        case 3:
+               if (text && text->id.lib) {
+                       error_libdata();
+                       break;
+               }
                if (txt_has_sel(text)) {
                        txt_order_cursors(text);
                        indent(text);
@@ -467,6 +479,10 @@
                        break;
                }
        case 4:
+               if (text && text->id.lib) {
+                       error_libdata();
+                       break;
+               }
                if ( txt_has_sel(text)) {
                        txt_order_cursors(text);
                        unindent(text);
@@ -474,6 +490,10 @@
                }
                break;
        case 5:
+               if (text && text->id.lib) {
+                       error_libdata();
+                       break;
+               }
                if ( txt_has_sel(text)) {
                        txt_order_cursors(text);
                        comment(text);
@@ -482,6 +502,10 @@
                }
                break;
        case 6:
+               if (text && text->id.lib) {
+                       error_libdata();
+                       break;
+               }
                if ( txt_has_sel(text)) {
                        txt_order_cursors(text);
                        uncomment(text);
@@ -818,14 +842,14 @@
                                len = PATH_MAX-1;
                        strncpy(fname, text->name, len);
                        fname[len]='\0';
+                       if (text->flags & TXT_ISDIRTY)
+                               sprintf(headtxt, "File: *%s (unsaved)", fname);
+                       else
+                               sprintf(headtxt, "File: %s", fname);
                } else {
-                       strcpy(fname, "Internal");
+                       sprintf(headtxt, text->id.lib?"Text: External":"Text: 
Internal");
                }
                BIF_ThemeColor(TH_MENU_TEXT);
-               if (text->flags & TXT_ISDIRTY)
-                       sprintf(headtxt, "File: *%s (unsaved)", fname);
-               else
-                       sprintf(headtxt, "File: %s", fname);
                glRasterPos2i(xco+=XIC, 5);
                BMF_DrawString(G.font, headtxt);
                xco += BMF_GetStringWidth(G.font, headtxt);


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

Reply via email to