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:
authorCampbell Barton <ideasman42@gmail.com>2014-02-09 05:28:14 +0400
committerCampbell Barton <ideasman42@gmail.com>2014-02-09 05:32:20 +0400
commitb105d2ac7fbccd3998c9a01c297edc8ef9fce4cb (patch)
tree6f3127ea83327bfe7ad9550a60309191b9d610b3
parent873f901e5a3d0d10c4cca579ce1f2aaed852b1e8 (diff)
UI: replace uiPupMenuOkee & uiPupMenuSaveOver with WM_operator_confirm
-rw-r--r--source/blender/editors/include/UI_interface.h4
-rw-r--r--source/blender/editors/interface/interface_regions.c80
-rw-r--r--source/blender/editors/space_info/info_ops.c3
-rw-r--r--source/blender/windowmanager/WM_api.h6
-rw-r--r--source/blender/windowmanager/intern/wm_operators.c13
5 files changed, 16 insertions, 90 deletions
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index a0a2fde7f92..55c15ab60ad 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -348,10 +348,8 @@ struct uiPopupMenu *uiPupMenuBegin(struct bContext *C, const char *title, int ic
void uiPupMenuEnd(struct bContext *C, struct uiPopupMenu *head);
struct uiLayout *uiPupMenuLayout(uiPopupMenu *head);
-void uiPupMenuOkee(struct bContext *C, const char *opname, const char *str, ...) ATTR_PRINTF_FORMAT(3, 4);
-void uiPupMenuSaveOver(struct bContext *C, struct wmOperator *op, const char *filename);
void uiPupMenuReports(struct bContext *C, struct ReportList *reports) ATTR_NONNULL();
-void uiPupMenuInvoke(struct bContext *C, const char *idname); /* popup registered menu */
+void uiPupMenuInvoke(struct bContext *C, const char *idname) ATTR_NONNULL();
/* Popup Blocks
*
diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c
index f1a03bc6b94..2770e657ea0 100644
--- a/source/blender/editors/interface/interface_regions.c
+++ b/source/blender/editors/interface/interface_regions.c
@@ -2607,86 +2607,6 @@ uiLayout *uiPupMenuLayout(uiPopupMenu *pup)
/*************************** Standard Popup Menus ****************************/
-static void operator_name_cb(bContext *C, void *arg, int retval)
-{
- const char *opname = arg;
-
- if (opname && retval > 0)
- WM_operator_name_call(C, opname, WM_OP_EXEC_DEFAULT, NULL);
-}
-
-static void operator_cb(bContext *C, void *arg, int retval)
-{
- wmOperator *op = arg;
-
- if (op && retval > 0)
- WM_operator_call(C, op);
- else
- WM_operator_free(op);
-}
-
-static void confirm_cancel_operator(bContext *UNUSED(C), void *opv)
-{
- WM_operator_free(opv);
-}
-
-static void vconfirm_opname(bContext *C, const char *opname, const char *title,
- const char *itemfmt, va_list ap) ATTR_PRINTF_FORMAT(4, 0);
-static void vconfirm_opname(bContext *C, const char *opname, const char *title,
- const char *itemfmt, va_list ap)
-{
- uiPopupBlockHandle *handle;
- char *s, buf[512];
-
- s = buf;
- if (title) s += sprintf(s, "%s%%t|", title);
- vsnprintf(s, sizeof(buf) - (s - buf), itemfmt, ap);
- buf[sizeof(buf) - 1] = '\0';
-
- handle = ui_popup_menu_create(C, NULL, NULL, NULL, NULL, buf);
-
- handle->popup_func = operator_name_cb;
- handle->popup_arg = (void *)opname;
-}
-
-static void confirm_operator(bContext *C, wmOperator *op, const char *title, const char *item)
-{
- uiPopupBlockHandle *handle;
- char *s, buf[512];
-
- s = buf;
- if (title) s += BLI_snprintf(s, sizeof(buf), "%s%%t|%s", title, item);
- (void)s;
-
- handle = ui_popup_menu_create(C, NULL, NULL, NULL, NULL, buf);
-
- handle->popup_func = operator_cb;
- handle->popup_arg = op;
- handle->cancel_func = confirm_cancel_operator;
-}
-
-void uiPupMenuOkee(bContext *C, const char *opname, const char *str, ...)
-{
- va_list ap;
- char titlestr[256];
-
- BLI_snprintf(titlestr, sizeof(titlestr), IFACE_("OK? %%i%d"), ICON_QUESTION);
-
- va_start(ap, str);
- vconfirm_opname(C, opname, titlestr, str, ap);
- va_end(ap);
-}
-
-/* note, only call this is the file exists,
- * the case where the file does not exist so can be saved without a
- * popup must be checked for already, since saving from here
- * will free the operator which will break invoke().
- * The operator state for this is implicitly OPERATOR_RUNNING_MODAL */
-void uiPupMenuSaveOver(bContext *C, wmOperator *op, const char *filename)
-{
- confirm_operator(C, op, IFACE_("Save Over?"), filename);
-}
-
void uiPupMenuReports(bContext *C, ReportList *reports)
{
Report *report;
diff --git a/source/blender/editors/space_info/info_ops.c b/source/blender/editors/space_info/info_ops.c
index ac0023e8cc2..25fa31407ff 100644
--- a/source/blender/editors/space_info/info_ops.c
+++ b/source/blender/editors/space_info/info_ops.c
@@ -188,8 +188,7 @@ static int pack_all_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(ev
}
if (ima) {
- uiPupMenuOkee(C, "FILE_OT_pack_all", "Some images are painted on. These changes will be lost. Continue?");
- return OPERATOR_CANCELLED;
+ return WM_operator_confirm_message(C, op, "Some images are painted on. These changes will be lost. Continue?");
}
return pack_all_exec(C, op);
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h
index c9ed198d0cf..8a13decea42 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -205,7 +205,11 @@ int WM_operator_props_dialog_popup(struct bContext *C, struct wmOperator *op,
int WM_operator_redo_popup (struct bContext *C, struct wmOperator *op);
int WM_operator_ui_popup (struct bContext *C, struct wmOperator *op, int width, int height);
-int WM_operator_confirm_message(struct bContext *C, struct wmOperator *op, const char *message);
+int WM_operator_confirm_message_ex(struct bContext *C, struct wmOperator *op,
+ const char *title, const int icon,
+ const char *message);
+int WM_operator_confirm_message(struct bContext *C, struct wmOperator *op,
+ const char *message);
/* operator api */
void WM_operator_free (struct wmOperator *op);
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index 4e39394b1bc..45cfd2ca61c 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -1107,7 +1107,9 @@ int WM_enum_search_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(eve
}
/* Can't be used as an invoke directly, needs message arg (can be NULL) */
-int WM_operator_confirm_message(bContext *C, wmOperator *op, const char *message)
+int WM_operator_confirm_message_ex(bContext *C, wmOperator *op,
+ const char *title, const int icon,
+ const char *message)
{
uiPopupMenu *pup;
uiLayout *layout;
@@ -1118,7 +1120,7 @@ int WM_operator_confirm_message(bContext *C, wmOperator *op, const char *message
else
properties = NULL;
- pup = uiPupMenuBegin(C, IFACE_("OK?"), ICON_QUESTION);
+ pup = uiPupMenuBegin(C, title, icon);
layout = uiPupMenuLayout(pup);
uiItemFullO_ptr(layout, op->type, message, ICON_NONE, properties, WM_OP_EXEC_REGION_WIN, 0);
uiPupMenuEnd(C, pup);
@@ -1126,6 +1128,10 @@ int WM_operator_confirm_message(bContext *C, wmOperator *op, const char *message
return OPERATOR_CANCELLED;
}
+int WM_operator_confirm_message(bContext *C, wmOperator *op, const char *message)
+{
+ return WM_operator_confirm_message_ex(C, op, IFACE_("OK?"), ICON_QUESTION, message);
+}
int WM_operator_confirm(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
@@ -2796,8 +2802,7 @@ static int wm_save_mainfile_invoke(bContext *C, wmOperator *op, const wmEvent *U
if (G.save_over) {
if (BLI_exists(name)) {
- uiPupMenuSaveOver(C, op, name);
- ret = OPERATOR_RUNNING_MODAL;
+ ret = WM_operator_confirm_message_ex(C, op, IFACE_("Save Over?"), ICON_QUESTION, name);
}
else {
ret = wm_save_as_mainfile_exec(C, op);