Fix T77000: Preferences window can not be opened from script operator
The operators to open the Preferences, Driver Editor, or Info Log window did not work when executed from another operator or the Python console. Should work for all of these now. I considered using operator properties instead, so the position could be set by a script, with some fallback (e.g. current window center). But decided that's not really worth the boilerplate and decreased code readability. Can still be done if there's a need for it.
This commit is contained in:
parent
f43bb98646
commit
8e4c74292a
Notes:
blender-bot
2023-02-14 08:28:46 +01:00
Referenced by issue #77000, bpy.ops.screen.userpref_show() not Working
|
@ -4866,8 +4866,11 @@ static void SCREEN_OT_back_to_previous(struct wmOperatorType *ot)
|
|||
/** \name Show User Preferences Operator
|
||||
* \{ */
|
||||
|
||||
static int userpref_show_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
static int userpref_show_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
wmWindow *win_cur = CTX_wm_window(C);
|
||||
/* Use eventstate, not event from _invoke, so this can be called through exec(). */
|
||||
const wmEvent *event = win_cur->eventstate;
|
||||
int sizex = (500 + UI_NAVIGATION_REGION_WIDTH) * UI_DPI_FAC;
|
||||
int sizey = 520 * UI_DPI_FAC;
|
||||
|
||||
|
@ -4904,7 +4907,7 @@ static void SCREEN_OT_userpref_show(struct wmOperatorType *ot)
|
|||
ot->idname = "SCREEN_OT_userpref_show";
|
||||
|
||||
/* api callbacks */
|
||||
ot->invoke = userpref_show_invoke;
|
||||
ot->exec = userpref_show_exec;
|
||||
ot->poll = ED_operator_screenactive;
|
||||
}
|
||||
|
||||
|
@ -4914,8 +4917,11 @@ static void SCREEN_OT_userpref_show(struct wmOperatorType *ot)
|
|||
/** \name Show Drivers Editor Operator
|
||||
* \{ */
|
||||
|
||||
static int drivers_editor_show_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
static int drivers_editor_show_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
wmWindow *win_cur = CTX_wm_window(C);
|
||||
/* Use eventstate, not event from _invoke, so this can be called through exec(). */
|
||||
const wmEvent *event = win_cur->eventstate;
|
||||
PointerRNA ptr = {NULL};
|
||||
PropertyRNA *prop = NULL;
|
||||
int index = -1;
|
||||
|
@ -4979,7 +4985,7 @@ static void SCREEN_OT_drivers_editor_show(struct wmOperatorType *ot)
|
|||
ot->idname = "SCREEN_OT_drivers_editor_show";
|
||||
|
||||
/* api callbacks */
|
||||
ot->invoke = drivers_editor_show_invoke;
|
||||
ot->exec = drivers_editor_show_exec;
|
||||
ot->poll = ED_operator_screenactive;
|
||||
}
|
||||
|
||||
|
@ -4989,8 +4995,11 @@ static void SCREEN_OT_drivers_editor_show(struct wmOperatorType *ot)
|
|||
/** \name Show Info Log Operator
|
||||
* \{ */
|
||||
|
||||
static int info_log_show_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
static int info_log_show_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
wmWindow *win_cur = CTX_wm_window(C);
|
||||
/* Use eventstate, not event from _invoke, so this can be called through exec(). */
|
||||
const wmEvent *event = win_cur->eventstate;
|
||||
int sizex = 900 * UI_DPI_FAC;
|
||||
int sizey = 580 * UI_DPI_FAC;
|
||||
int shift_y = 480;
|
||||
|
@ -5020,7 +5029,7 @@ static void SCREEN_OT_info_log_show(struct wmOperatorType *ot)
|
|||
ot->idname = "SCREEN_OT_info_log_show";
|
||||
|
||||
/* api callbacks */
|
||||
ot->invoke = info_log_show_invoke;
|
||||
ot->exec = info_log_show_exec;
|
||||
ot->poll = ED_operator_screenactive;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue