Text Editor Bugfixes:

The poll() callbacks used in the Text Editor for scrolling and text-
block unlinking operators were too restrictive when the text block was
lib-data.

- Scrolling lib-linked texts is useful for just checking out parts of
the linked-in file that aren't visible on screen already. For example,
checking the specific rig that some UI panels script will work on, or
reading a "README.txt" linked in with notes on which layers various
controls are on. It should be fine that this temporarily modifies the
linked text-block (but for view-settings which will can be reset
later/on file load without any real consequences).
- Unlink operator should be able to be run, otherwise it would be very
difficult to remove linked files from a file (?)
This commit is contained in:
2011-02-08 09:57:51 +00:00
parent 37f55ec194
commit 71ec3f03fb

View File

@@ -124,7 +124,6 @@ static int text_region_edit_poll(bContext *C)
return 1;
}
/********************** updates *********************/
void text_update_line_edited(TextLine *line)
@@ -342,6 +341,12 @@ void TEXT_OT_reload(wmOperatorType *ot)
/******************* delete operator *********************/
static int text_unlink_poll(bContext *C)
{
/* it should be possible to unlink texts if they're lib-linked in... */
return CTX_data_edit_text(C) != NULL;
}
static int unlink_exec(bContext *C, wmOperator *UNUSED(op))
{
Main *bmain= CTX_data_main(C);
@@ -381,7 +386,7 @@ void TEXT_OT_unlink(wmOperatorType *ot)
/* api callbacks */
ot->exec= unlink_exec;
ot->invoke= WM_operator_confirm;
ot->poll= text_edit_poll;
ot->poll= text_unlink_poll;
/* flags */
ot->flag= OPTYPE_UNDO;
@@ -2019,6 +2024,12 @@ typedef struct TextScroll {
int zone;
} TextScroll;
static int text_scroll_poll(bContext *C)
{
/* it should be possible to still scroll linked texts to read them, even if they can't be edited... */
return CTX_data_edit_text(C) != NULL;
}
static int scroll_exec(bContext *C, wmOperator *op)
{
SpaceText *st= CTX_wm_space_text(C);
@@ -2183,7 +2194,7 @@ void TEXT_OT_scroll(wmOperatorType *ot)
ot->invoke= scroll_invoke;
ot->modal= scroll_modal;
ot->cancel= scroll_cancel;
ot->poll= text_space_edit_poll;
ot->poll= text_scroll_poll;
/* flags */
ot->flag= OPTYPE_BLOCKING|OPTYPE_GRAB_POINTER;
@@ -2194,6 +2205,22 @@ void TEXT_OT_scroll(wmOperatorType *ot)
/******************** scroll bar operator *******************/
static int text_region_scroll_poll(bContext *C)
{
/* same as text_region_edit_poll except it works on libdata too */
SpaceText *st= CTX_wm_space_text(C);
Text *text= CTX_data_edit_text(C);
ARegion *ar= CTX_wm_region(C);
if(!st || !text)
return 0;
if(!ar || ar->regiontype != RGN_TYPE_WINDOW)
return 0;
return 1;
}
static int scroll_bar_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
SpaceText *st= CTX_wm_space_text(C);
@@ -2249,7 +2276,7 @@ void TEXT_OT_scroll_bar(wmOperatorType *ot)
ot->invoke= scroll_bar_invoke;
ot->modal= scroll_modal;
ot->cancel= scroll_cancel;
ot->poll= text_region_edit_poll;
ot->poll= text_region_scroll_poll;
/* flags */
ot->flag= OPTYPE_BLOCKING;