Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_text/text_ops.c
| Show First 20 Lines • Show All 165 Lines • ▼ Show 20 Lines | static int text_new_exec(bContext *C, wmOperator *UNUSED(op)) | ||||
| Main *bmain = CTX_data_main(C); | Main *bmain = CTX_data_main(C); | ||||
| Text *text; | Text *text; | ||||
| PointerRNA ptr, idptr; | PointerRNA ptr, idptr; | ||||
| PropertyRNA *prop; | PropertyRNA *prop; | ||||
| text = BKE_text_add(bmain, "Text"); | text = BKE_text_add(bmain, "Text"); | ||||
| /* hook into UI */ | /* hook into UI */ | ||||
| uiIDContextProperty(C, &ptr, &prop); | UI_context_active_but_prop_get_templateID(C, &ptr, &prop); | ||||
| if (prop) { | if (prop) { | ||||
| RNA_id_pointer_create(&text->id, &idptr); | RNA_id_pointer_create(&text->id, &idptr); | ||||
| RNA_property_pointer_set(&ptr, prop, idptr); | RNA_property_pointer_set(&ptr, prop, idptr); | ||||
| RNA_property_update(C, &ptr, prop); | RNA_property_update(C, &ptr, prop); | ||||
| } | } | ||||
| else if (st) { | else if (st) { | ||||
| st->text = text; | st->text = text; | ||||
| Show All 26 Lines | |||||
| /******************* open operator *********************/ | /******************* open operator *********************/ | ||||
| static void text_open_init(bContext *C, wmOperator *op) | static void text_open_init(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| PropertyPointerRNA *pprop; | PropertyPointerRNA *pprop; | ||||
| op->customdata = pprop = MEM_callocN(sizeof(PropertyPointerRNA), "OpenPropertyPointerRNA"); | op->customdata = pprop = MEM_callocN(sizeof(PropertyPointerRNA), "OpenPropertyPointerRNA"); | ||||
| uiIDContextProperty(C, &pprop->ptr, &pprop->prop); | UI_context_active_but_prop_get_templateID(C, &pprop->ptr, &pprop->prop); | ||||
| } | } | ||||
| static void text_open_cancel(bContext *UNUSED(C), wmOperator *op) | static void text_open_cancel(bContext *UNUSED(C), wmOperator *op) | ||||
| { | { | ||||
| MEM_freeN(op->customdata); | MEM_freeN(op->customdata); | ||||
| } | } | ||||
| static int text_open_exec(bContext *C, wmOperator *op) | static int text_open_exec(bContext *C, wmOperator *op) | ||||
| ▲ Show 20 Lines • Show All 2,913 Lines • ▼ Show 20 Lines | static int text_resolve_conflict_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) | ||||
| Text *text = CTX_data_edit_text(C); | Text *text = CTX_data_edit_text(C); | ||||
| uiPopupMenu *pup; | uiPopupMenu *pup; | ||||
| uiLayout *layout; | uiLayout *layout; | ||||
| switch (BKE_text_file_modified_check(text)) { | switch (BKE_text_file_modified_check(text)) { | ||||
| case 1: | case 1: | ||||
| if (text->flags & TXT_ISDIRTY) { | if (text->flags & TXT_ISDIRTY) { | ||||
| /* modified locally and externally, ahhh. offer more possibilites. */ | /* modified locally and externally, ahhh. offer more possibilites. */ | ||||
| pup = uiPupMenuBegin(C, IFACE_("File Modified Outside and Inside Blender"), ICON_NONE); | pup = UI_popup_menu_begin(C, IFACE_("File Modified Outside and Inside Blender"), ICON_NONE); | ||||
| layout = uiPupMenuLayout(pup); | layout = UI_popup_menu_layout(pup); | ||||
| uiItemEnumO_ptr(layout, op->type, IFACE_("Reload from disk (ignore local changes)"), | uiItemEnumO_ptr(layout, op->type, IFACE_("Reload from disk (ignore local changes)"), | ||||
| 0, "resolution", RESOLVE_RELOAD); | 0, "resolution", RESOLVE_RELOAD); | ||||
| uiItemEnumO_ptr(layout, op->type, IFACE_("Save to disk (ignore outside changes)"), | uiItemEnumO_ptr(layout, op->type, IFACE_("Save to disk (ignore outside changes)"), | ||||
| 0, "resolution", RESOLVE_SAVE); | 0, "resolution", RESOLVE_SAVE); | ||||
| uiItemEnumO_ptr(layout, op->type, IFACE_("Make text internal (separate copy)"), | uiItemEnumO_ptr(layout, op->type, IFACE_("Make text internal (separate copy)"), | ||||
| 0, "resolution", RESOLVE_MAKE_INTERNAL); | 0, "resolution", RESOLVE_MAKE_INTERNAL); | ||||
| uiPupMenuEnd(C, pup); | UI_popup_menu_end(C, pup); | ||||
| } | } | ||||
| else { | else { | ||||
| pup = uiPupMenuBegin(C, IFACE_("File Modified Outside Blender"), ICON_NONE); | pup = UI_popup_menu_begin(C, IFACE_("File Modified Outside Blender"), ICON_NONE); | ||||
| layout = uiPupMenuLayout(pup); | layout = UI_popup_menu_layout(pup); | ||||
| uiItemEnumO_ptr(layout, op->type, IFACE_("Reload from disk"), 0, "resolution", RESOLVE_RELOAD); | uiItemEnumO_ptr(layout, op->type, IFACE_("Reload from disk"), 0, "resolution", RESOLVE_RELOAD); | ||||
| uiItemEnumO_ptr(layout, op->type, IFACE_("Make text internal (separate copy)"), | uiItemEnumO_ptr(layout, op->type, IFACE_("Make text internal (separate copy)"), | ||||
| 0, "resolution", RESOLVE_MAKE_INTERNAL); | 0, "resolution", RESOLVE_MAKE_INTERNAL); | ||||
| uiItemEnumO_ptr(layout, op->type, IFACE_("Ignore"), 0, "resolution", RESOLVE_IGNORE); | uiItemEnumO_ptr(layout, op->type, IFACE_("Ignore"), 0, "resolution", RESOLVE_IGNORE); | ||||
| uiPupMenuEnd(C, pup); | UI_popup_menu_end(C, pup); | ||||
| } | } | ||||
| break; | break; | ||||
| case 2: | case 2: | ||||
| pup = uiPupMenuBegin(C, IFACE_("File Deleted Outside Blender"), ICON_NONE); | pup = UI_popup_menu_begin(C, IFACE_("File Deleted Outside Blender"), ICON_NONE); | ||||
| layout = uiPupMenuLayout(pup); | layout = UI_popup_menu_layout(pup); | ||||
| uiItemEnumO_ptr(layout, op->type, IFACE_("Make text internal"), 0, "resolution", RESOLVE_MAKE_INTERNAL); | uiItemEnumO_ptr(layout, op->type, IFACE_("Make text internal"), 0, "resolution", RESOLVE_MAKE_INTERNAL); | ||||
| uiItemEnumO_ptr(layout, op->type, IFACE_("Recreate file"), 0, "resolution", RESOLVE_SAVE); | uiItemEnumO_ptr(layout, op->type, IFACE_("Recreate file"), 0, "resolution", RESOLVE_SAVE); | ||||
| uiPupMenuEnd(C, pup); | UI_popup_menu_end(C, pup); | ||||
| break; | break; | ||||
| } | } | ||||
| return OPERATOR_INTERFACE; | return OPERATOR_INTERFACE; | ||||
| } | } | ||||
| void TEXT_OT_resolve_conflict(wmOperatorType *ot) | void TEXT_OT_resolve_conflict(wmOperatorType *ot) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 66 Lines • Show Last 20 Lines | |||||