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:
Diffstat (limited to 'source/blender/windowmanager/intern/wm_operators.c')
-rw-r--r--source/blender/windowmanager/intern/wm_operators.c127
1 files changed, 80 insertions, 47 deletions
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index 2e813bac37d..0913d58258f 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -91,10 +91,12 @@ wmOperatorType *WM_operatortype_find(const char *idname, int quiet)
char idname_bl[OP_MAX_TYPENAME]; // XXX, needed to support python style names without the _OT_ syntax
WM_operator_bl_idname(idname_bl, idname);
-
- for(ot= global_ops.first; ot; ot= ot->next) {
- if(strncmp(ot->idname, idname_bl, OP_MAX_TYPENAME)==0)
- return ot;
+
+ if (idname_bl[0]) {
+ for(ot= global_ops.first; ot; ot= ot->next) {
+ if(strncmp(ot->idname, idname_bl, OP_MAX_TYPENAME)==0)
+ return ot;
+ }
}
if(!quiet)
@@ -109,10 +111,12 @@ wmOperatorType *WM_operatortype_exists(const char *idname)
char idname_bl[OP_MAX_TYPENAME]; // XXX, needed to support python style names without the _OT_ syntax
WM_operator_bl_idname(idname_bl, idname);
-
- for(ot= global_ops.first; ot; ot= ot->next) {
- if(strncmp(ot->idname, idname_bl, OP_MAX_TYPENAME)==0)
- return ot;
+
+ if(idname_bl[0]) {
+ for(ot= global_ops.first; ot; ot= ot->next) {
+ if(strncmp(ot->idname, idname_bl, OP_MAX_TYPENAME)==0)
+ return ot;
+ }
}
return NULL;
}
@@ -322,21 +326,25 @@ void WM_operator_py_idname(char *to, const char *from)
/* some.op -> SOME_OT_op */
void WM_operator_bl_idname(char *to, const char *from)
{
- char *sep= strchr(from, '.');
+ if (from) {
+ char *sep= strchr(from, '.');
- if(sep) {
- int i, ofs= (sep-from);
+ if(sep) {
+ int i, ofs= (sep-from);
- for(i=0; i<ofs; i++)
- to[i]= toupper(from[i]);
+ for(i=0; i<ofs; i++)
+ to[i]= toupper(from[i]);
- BLI_strncpy(to+ofs, "_OT_", OP_MAX_TYPENAME);
- BLI_strncpy(to+(ofs+4), sep+1, OP_MAX_TYPENAME);
- }
- else {
- /* should not happen but support just incase */
- BLI_strncpy(to, from, OP_MAX_TYPENAME);
+ BLI_strncpy(to+ofs, "_OT_", OP_MAX_TYPENAME);
+ BLI_strncpy(to+(ofs+4), sep+1, OP_MAX_TYPENAME);
+ }
+ else {
+ /* should not happen but support just incase */
+ BLI_strncpy(to, from, OP_MAX_TYPENAME);
+ }
}
+ else
+ to[0]= 0;
}
/* print a string representation of the operator, with the args that it runs
@@ -440,13 +448,24 @@ void WM_operator_properties_free(PointerRNA *ptr)
/* ************ default op callbacks, exported *********** */
/* invoke callback, uses enum property named "type" */
-/* only weak thing is the fixed property name... */
int WM_menu_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
- PropertyRNA *prop= RNA_struct_find_property(op->ptr, "type");
+ PropertyRNA *prop;
uiPopupMenu *pup;
uiLayout *layout;
+ prop= RNA_struct_find_property(op->ptr, "type");
+
+ if(!prop) {
+ RNA_STRUCT_BEGIN(op->ptr, findprop) {
+ if(RNA_property_type(findprop) == PROP_ENUM) {
+ prop= findprop;
+ break;
+ }
+ }
+ RNA_STRUCT_END;
+ }
+
if(prop==NULL) {
printf("WM_menu_invoke: %s has no \"type\" enum property\n", op->type->idname);
}
@@ -456,7 +475,7 @@ int WM_menu_invoke(bContext *C, wmOperator *op, wmEvent *event)
else {
pup= uiPupMenuBegin(C, op->type->name, 0);
layout= uiPupMenuLayout(pup);
- uiItemsEnumO(layout, op->type->idname, "type");
+ uiItemsEnumO(layout, op->type->idname, (char*)RNA_property_identifier(prop));
uiPupMenuEnd(C, pup);
}
@@ -720,6 +739,7 @@ int wm_search_menu_poll(bContext *C)
{
if(CTX_wm_window(C)==NULL) return 0;
if(CTX_wm_area(C) && CTX_wm_area(C)->spacetype==SPACE_CONSOLE) return 0; // XXX - so we can use the shortcut in the console
+ if(CTX_wm_area(C) && CTX_wm_area(C)->spacetype==SPACE_TEXT) return 0; // XXX - so we can use the spacebar in the text editor
return 1;
}
@@ -741,7 +761,6 @@ static void WM_OT_window_duplicate(wmOperatorType *ot)
ot->name= "Duplicate Window";
ot->idname= "WM_OT_window_duplicate";
- ot->invoke= WM_operator_confirm;
ot->exec= wm_window_duplicate_op;
ot->poll= WM_operator_winactive;
}
@@ -814,22 +833,12 @@ static EnumPropertyItem *open_recentfile_itemf(bContext *C, PointerRNA *ptr, int
struct RecentFile *recent;
int totitem= 0, i, ofs= 0;
- if(G.sce[0]) {
- tmp.value= 1;
- tmp.identifier= G.sce;
- tmp.name= G.sce;
- RNA_enum_item_add(&item, &totitem, &tmp);
- ofs = 1;
- }
-
/* dynamically construct enum */
for(recent = G.recent_files.first, i=0; (i<U.recent_files) && (recent); recent = recent->next, i++) {
- if(strcmp(recent->filename, G.sce)) {
- tmp.value= i+ofs+1;
- tmp.identifier= recent->filename;
- tmp.name= recent->filename;
- RNA_enum_item_add(&item, &totitem, &tmp);
- }
+ tmp.value= i+ofs+1;
+ tmp.identifier= recent->filename;
+ tmp.name= recent->filename;
+ RNA_enum_item_add(&item, &totitem, &tmp);
}
RNA_enum_item_end(&item, &totitem);
@@ -869,10 +878,17 @@ static void untitled(char *name)
}
}
+static void load_set_load_ui(wmOperator *op)
+{
+ if(!RNA_property_is_set(op->ptr, "load_ui"))
+ RNA_boolean_set(op->ptr, "load_ui", !(U.flag & USER_FILENOUI));
+}
static int wm_open_mainfile_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
RNA_string_set(op->ptr, "filename", G.sce);
+ load_set_load_ui(op);
+
WM_event_add_fileselect(C, op);
return OPERATOR_RUNNING_MODAL;
@@ -881,7 +897,14 @@ static int wm_open_mainfile_invoke(bContext *C, wmOperator *op, wmEvent *event)
static int wm_open_mainfile_exec(bContext *C, wmOperator *op)
{
char filename[FILE_MAX];
+
RNA_string_get(op->ptr, "filename", filename);
+ load_set_load_ui(op);
+
+ if(RNA_boolean_get(op->ptr, "load_ui"))
+ G.fileflags &= ~G_FILE_NO_UI;
+ else
+ G.fileflags |= G_FILE_NO_UI;
// XXX wm in context is not set correctly after WM_read_file -> crash
// do it before for now, but is this correct with multiple windows?
@@ -902,6 +925,8 @@ static void WM_OT_open_mainfile(wmOperatorType *ot)
ot->poll= WM_operator_winactive;
WM_operator_properties_filesel(ot, FOLDERFILE|BLENDERFILE);
+
+ RNA_def_boolean(ot->srna, "load_ui", 1, "Load UI", "Load user interface setup in the .blend file.");
}
static int wm_recover_last_session_exec(bContext *C, wmOperator *op)
@@ -1035,7 +1060,6 @@ static void WM_OT_window_fullscreen_toggle(wmOperatorType *ot)
ot->name= "Toggle Fullscreen";
ot->idname= "WM_OT_window_fullscreen_toggle";
- ot->invoke= WM_operator_confirm;
ot->exec= wm_window_fullscreen_toggle_op;
ot->poll= WM_operator_winactive;
}
@@ -1067,7 +1091,7 @@ static void WM_OT_exit_blender(wmOperatorType *ot)
*/
void *WM_paint_cursor_activate(wmWindowManager *wm, int (*poll)(bContext *C),
- void (*draw)(bContext *C, int, int, void *customdata), void *customdata)
+ wmPaintCursorDraw draw, void *customdata)
{
wmPaintCursor *pc= MEM_callocN(sizeof(wmPaintCursor), "paint cursor");
@@ -1894,19 +1918,28 @@ void wm_window_keymap(wmWindowManager *wm)
/* note, this doesn't replace existing keymap items */
WM_keymap_verify_item(keymap, "WM_OT_window_duplicate", WKEY, KM_PRESS, KM_CTRL|KM_ALT, 0);
- WM_keymap_verify_item(keymap, "WM_OT_read_homefile", XKEY, KM_PRESS, KM_CTRL, 0);
- WM_keymap_verify_item(keymap, "WM_OT_save_homefile", UKEY, KM_PRESS, KM_CTRL, 0);
- WM_keymap_verify_item(keymap, "WM_OT_open_recentfile", OKEY, KM_PRESS, KM_CTRL, 0);
- WM_keymap_verify_item(keymap, "WM_OT_open_mainfile", F1KEY, KM_PRESS, 0, 0);
- WM_keymap_verify_item(keymap, "WM_OT_save_mainfile", WKEY, KM_PRESS, KM_CTRL, 0);
- WM_keymap_verify_item(keymap, "WM_OT_save_as_mainfile", F2KEY, KM_PRESS, 0, 0);
+ #ifdef __APPLE__
+ WM_keymap_add_item(keymap, "WM_OT_read_homefile", NKEY, KM_PRESS, KM_OSKEY, 0);
+ WM_keymap_add_item(keymap, "WM_OT_open_recentfile", OKEY, KM_PRESS, KM_SHIFT|KM_OSKEY, 0);
+ WM_keymap_add_item(keymap, "WM_OT_open_mainfile", OKEY, KM_PRESS, KM_OSKEY, 0);
+ WM_keymap_add_item(keymap, "WM_OT_save_mainfile", SKEY, KM_PRESS, KM_OSKEY, 0);
+ WM_keymap_add_item(keymap, "WM_OT_save_as_mainfile", SKEY, KM_PRESS, KM_SHIFT|KM_OSKEY, 0);
+ WM_keymap_add_item(keymap, "WM_OT_exit_blender", QKEY, KM_PRESS, KM_OSKEY, 0);
+ #endif
+ WM_keymap_add_item(keymap, "WM_OT_read_homefile", NKEY, KM_PRESS, KM_CTRL, 0);
+ WM_keymap_add_item(keymap, "WM_OT_save_homefile", UKEY, KM_PRESS, KM_CTRL, 0);
+ WM_keymap_add_item(keymap, "WM_OT_open_recentfile", OKEY, KM_PRESS, KM_SHIFT|KM_CTRL, 0);
+ WM_keymap_add_item(keymap, "WM_OT_open_mainfile", OKEY, KM_PRESS, KM_CTRL, 0);
+ WM_keymap_add_item(keymap, "WM_OT_save_mainfile", SKEY, KM_PRESS, KM_CTRL, 0);
+ WM_keymap_add_item(keymap, "WM_OT_save_as_mainfile", SKEY, KM_PRESS, KM_SHIFT|KM_CTRL, 0);
+
WM_keymap_verify_item(keymap, "WM_OT_window_fullscreen_toggle", F11KEY, KM_PRESS, KM_SHIFT, 0);
- WM_keymap_verify_item(keymap, "WM_OT_exit_blender", QKEY, KM_PRESS, KM_CTRL, 0);
+ WM_keymap_add_item(keymap, "WM_OT_exit_blender", QKEY, KM_PRESS, KM_CTRL, 0);
/* debug/testing */
WM_keymap_verify_item(keymap, "WM_OT_ten_timer", TKEY, KM_PRESS, KM_ALT|KM_CTRL, 0);
WM_keymap_verify_item(keymap, "WM_OT_debug_menu", DKEY, KM_PRESS, KM_ALT|KM_CTRL, 0);
- WM_keymap_verify_item(keymap, "WM_OT_search_menu", SPACEKEY, KM_PRESS, KM_CTRL, 0);
+ WM_keymap_verify_item(keymap, "WM_OT_search_menu", SPACEKEY, KM_PRESS, 0, 0);
}