2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2009-07-19 00:49:44 +00:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2009-07-19 00:49:44 +00:00
|
|
|
*
|
|
|
|
|
* Contributor(s): Campbell Barton
|
|
|
|
|
*
|
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
|
*/
|
|
|
|
|
|
2011-02-27 20:29:51 +00:00
|
|
|
/** \file blender/editors/space_info/info_report.c
|
|
|
|
|
* \ingroup spinfo
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
2009-07-19 00:49:44 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
2010-11-11 13:36:57 +00:00
|
|
|
#include <limits.h>
|
2009-07-19 00:49:44 +00:00
|
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
|
|
|
|
#include "BLI_blenlib.h"
|
|
|
|
|
#include "BLI_dynstr.h"
|
2011-01-07 18:36:47 +00:00
|
|
|
#include "BLI_utildefines.h"
|
2009-07-19 00:49:44 +00:00
|
|
|
|
|
|
|
|
#include "BKE_context.h"
|
|
|
|
|
|
|
|
|
|
#include "WM_api.h"
|
|
|
|
|
#include "WM_types.h"
|
|
|
|
|
|
|
|
|
|
#include "ED_screen.h"
|
|
|
|
|
#include "ED_types.h"
|
|
|
|
|
|
|
|
|
|
#include "RNA_access.h"
|
|
|
|
|
#include "RNA_define.h"
|
|
|
|
|
|
2010-11-11 13:36:57 +00:00
|
|
|
#include "info_intern.h"
|
2009-07-19 00:49:44 +00:00
|
|
|
|
2010-12-02 21:48:46 +00:00
|
|
|
int info_report_mask(SpaceInfo *UNUSED(sinfo))
|
2009-07-19 00:49:44 +00:00
|
|
|
{
|
2010-12-02 21:48:46 +00:00
|
|
|
#if 0
|
2009-07-19 00:49:44 +00:00
|
|
|
int report_mask = 0;
|
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (sinfo->rpt_mask & INFO_RPT_DEBUG) report_mask |= RPT_DEBUG_ALL;
|
|
|
|
|
if (sinfo->rpt_mask & INFO_RPT_INFO) report_mask |= RPT_INFO_ALL;
|
|
|
|
|
if (sinfo->rpt_mask & INFO_RPT_OP) report_mask |= RPT_OPERATOR_ALL;
|
|
|
|
|
if (sinfo->rpt_mask & INFO_RPT_WARN) report_mask |= RPT_WARNING_ALL;
|
|
|
|
|
if (sinfo->rpt_mask & INFO_RPT_ERR) report_mask |= RPT_ERROR_ALL;
|
2009-07-19 00:49:44 +00:00
|
|
|
|
|
|
|
|
return report_mask;
|
2010-12-02 21:48:46 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
return RPT_DEBUG_ALL|RPT_INFO_ALL|RPT_OPERATOR_ALL|RPT_WARNING_ALL|RPT_ERROR_ALL;
|
2009-07-19 00:49:44 +00:00
|
|
|
}
|
|
|
|
|
|
2010-11-11 13:36:57 +00:00
|
|
|
// TODO, get this working again!
|
2010-10-13 23:46:42 +00:00
|
|
|
static int report_replay_exec(bContext *C, wmOperator *UNUSED(op))
|
2009-07-19 00:49:44 +00:00
|
|
|
{
|
2010-11-11 13:36:57 +00:00
|
|
|
// SpaceInfo *sc= CTX_wm_space_info(C);
|
|
|
|
|
// ReportList *reports= CTX_wm_reports(C);
|
|
|
|
|
// int report_mask= info_report_mask(sc);
|
|
|
|
|
// Report *report;
|
2009-07-19 00:49:44 +00:00
|
|
|
|
2010-11-11 13:36:57 +00:00
|
|
|
#if 0
|
2009-07-19 00:49:44 +00:00
|
|
|
sc->type= CONSOLE_TYPE_PYTHON;
|
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
for (report=reports->list.last; report; report=report->prev) {
|
|
|
|
|
if ((report->type & report_mask) && (report->type & RPT_OPERATOR_ALL) && (report->flag & SELECT)) {
|
2010-10-13 23:46:42 +00:00
|
|
|
console_history_add_str(sc, report->message, 0);
|
2009-09-04 04:29:54 +00:00
|
|
|
WM_operator_name_call(C, "CONSOLE_OT_execute", WM_OP_EXEC_DEFAULT, NULL);
|
2009-07-19 00:49:44 +00:00
|
|
|
|
|
|
|
|
ED_area_tag_redraw(CTX_wm_area(C));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sc->type= CONSOLE_TYPE_REPORT;
|
2010-11-11 13:36:57 +00:00
|
|
|
#endif
|
2009-07-19 00:49:44 +00:00
|
|
|
ED_area_tag_redraw(CTX_wm_area(C));
|
|
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
2010-11-11 13:36:57 +00:00
|
|
|
void INFO_OT_report_replay(wmOperatorType *ot)
|
2009-07-19 00:49:44 +00:00
|
|
|
{
|
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Replay Operators";
|
|
|
|
|
ot->description = "Replay selected reports";
|
|
|
|
|
ot->idname = "INFO_OT_report_replay";
|
2009-07-19 00:49:44 +00:00
|
|
|
|
|
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->poll = ED_operator_info_active;
|
|
|
|
|
ot->exec = report_replay_exec;
|
2009-07-19 00:49:44 +00:00
|
|
|
|
|
|
|
|
/* flags */
|
2012-03-22 07:26:09 +00:00
|
|
|
/* ot->flag = OPTYPE_REGISTER; */
|
2009-07-19 00:49:44 +00:00
|
|
|
|
|
|
|
|
/* properties */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int select_report_pick_exec(bContext *C, wmOperator *op)
|
|
|
|
|
{
|
|
|
|
|
int report_index= RNA_int_get(op->ptr, "report_index");
|
|
|
|
|
Report *report= BLI_findlink(&CTX_wm_reports(C)->list, report_index);
|
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!report)
|
2009-07-19 00:49:44 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
|
|
|
|
|
report->flag ^= SELECT; /* toggle */
|
|
|
|
|
|
|
|
|
|
ED_area_tag_redraw(CTX_wm_area(C));
|
|
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int select_report_pick_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
|
|
|
|
{
|
2010-11-11 13:36:57 +00:00
|
|
|
SpaceInfo *sinfo= CTX_wm_space_info(C);
|
2009-07-19 00:49:44 +00:00
|
|
|
ARegion *ar= CTX_wm_region(C);
|
|
|
|
|
ReportList *reports= CTX_wm_reports(C);
|
|
|
|
|
Report *report;
|
|
|
|
|
|
2011-02-08 13:48:06 +00:00
|
|
|
/* uses opengl */
|
|
|
|
|
wmSubWindowSet(CTX_wm_window(C), ar->swinid);
|
|
|
|
|
|
2010-11-11 13:36:57 +00:00
|
|
|
report= info_text_pick(sinfo, ar, reports, event->mval[1]);
|
2009-07-19 00:49:44 +00:00
|
|
|
|
|
|
|
|
RNA_int_set(op->ptr, "report_index", BLI_findindex(&reports->list, report));
|
|
|
|
|
|
|
|
|
|
return select_report_pick_exec(C, op);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2010-11-11 13:36:57 +00:00
|
|
|
void INFO_OT_select_pick(wmOperatorType *ot)
|
2009-07-19 00:49:44 +00:00
|
|
|
{
|
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Select report";
|
|
|
|
|
ot->description = "Select reports by index";
|
|
|
|
|
ot->idname = "INFO_OT_select_pick";
|
2009-07-19 00:49:44 +00:00
|
|
|
|
|
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->poll = ED_operator_info_active;
|
|
|
|
|
ot->invoke = select_report_pick_invoke;
|
|
|
|
|
ot->exec = select_report_pick_exec;
|
2009-07-19 00:49:44 +00:00
|
|
|
|
|
|
|
|
/* flags */
|
2012-03-22 07:26:09 +00:00
|
|
|
/* ot->flag = OPTYPE_REGISTER; */
|
2009-07-19 00:49:44 +00:00
|
|
|
|
|
|
|
|
/* properties */
|
2011-10-20 07:56:04 +00:00
|
|
|
RNA_def_int(ot->srna, "report_index", 0, 0, INT_MAX, "Report", "Index of the report", 0, INT_MAX);
|
2009-07-19 00:49:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-10-13 23:46:42 +00:00
|
|
|
static int report_select_all_toggle_exec(bContext *C, wmOperator *UNUSED(op))
|
2009-07-19 00:49:44 +00:00
|
|
|
{
|
2010-11-11 13:36:57 +00:00
|
|
|
SpaceInfo *sinfo= CTX_wm_space_info(C);
|
2009-07-19 00:49:44 +00:00
|
|
|
ReportList *reports= CTX_wm_reports(C);
|
2010-11-11 13:36:57 +00:00
|
|
|
int report_mask= info_report_mask(sinfo);
|
2009-07-19 00:49:44 +00:00
|
|
|
int deselect= 0;
|
|
|
|
|
|
|
|
|
|
Report *report;
|
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
for (report=reports->list.last; report; report=report->prev) {
|
|
|
|
|
if ((report->type & report_mask) && (report->flag & SELECT)) {
|
2009-07-19 00:49:44 +00:00
|
|
|
deselect= 1;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (deselect) {
|
|
|
|
|
for (report=reports->list.last; report; report=report->prev)
|
|
|
|
|
if (report->type & report_mask)
|
2009-07-19 00:49:44 +00:00
|
|
|
report->flag &= ~SELECT;
|
|
|
|
|
}
|
|
|
|
|
else {
|
2012-03-24 06:38:07 +00:00
|
|
|
for (report=reports->list.last; report; report=report->prev)
|
|
|
|
|
if (report->type & report_mask)
|
2009-07-19 00:49:44 +00:00
|
|
|
report->flag |= SELECT;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ED_area_tag_redraw(CTX_wm_area(C));
|
|
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
2010-11-11 13:36:57 +00:00
|
|
|
void INFO_OT_select_all_toggle(wmOperatorType *ot)
|
2009-07-19 00:49:44 +00:00
|
|
|
{
|
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "(De)select All";
|
|
|
|
|
ot->description = "Select or deselect all reports";
|
|
|
|
|
ot->idname = "INFO_OT_select_all_toggle";
|
2009-07-19 00:49:44 +00:00
|
|
|
|
|
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->poll = ED_operator_info_active;
|
|
|
|
|
ot->exec = report_select_all_toggle_exec;
|
2009-07-19 00:49:44 +00:00
|
|
|
|
|
|
|
|
/* flags */
|
2012-03-22 07:26:09 +00:00
|
|
|
/*ot->flag = OPTYPE_REGISTER;*/
|
2009-07-19 00:49:44 +00:00
|
|
|
|
|
|
|
|
/* properties */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* borderselect operator */
|
|
|
|
|
static int borderselect_exec(bContext *C, wmOperator *op)
|
|
|
|
|
{
|
2010-11-11 13:36:57 +00:00
|
|
|
SpaceInfo *sinfo= CTX_wm_space_info(C);
|
2009-07-19 00:49:44 +00:00
|
|
|
ARegion *ar= CTX_wm_region(C);
|
|
|
|
|
ReportList *reports= CTX_wm_reports(C);
|
2010-11-11 13:36:57 +00:00
|
|
|
int report_mask= info_report_mask(sinfo);
|
2011-11-16 19:22:14 +00:00
|
|
|
int extend= RNA_boolean_get(op->ptr, "extend");
|
2009-07-19 00:49:44 +00:00
|
|
|
Report *report_min, *report_max, *report;
|
|
|
|
|
|
|
|
|
|
//View2D *v2d= UI_view2d_fromcontext(C);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rcti rect;
|
|
|
|
|
//rctf rectf, rq;
|
2009-11-06 22:51:08 +00:00
|
|
|
short selecting= (RNA_int_get(op->ptr, "gesture_mode")==GESTURE_MODAL_SELECT);
|
2011-05-12 16:47:36 +00:00
|
|
|
//int mval[2];
|
2009-07-19 00:49:44 +00:00
|
|
|
|
2012-03-24 02:51:46 +00:00
|
|
|
rect.xmin = RNA_int_get(op->ptr, "xmin");
|
|
|
|
|
rect.ymin = RNA_int_get(op->ptr, "ymin");
|
|
|
|
|
rect.xmax = RNA_int_get(op->ptr, "xmax");
|
|
|
|
|
rect.ymax = RNA_int_get(op->ptr, "ymax");
|
2009-07-19 00:49:44 +00:00
|
|
|
|
2012-03-03 16:31:46 +00:00
|
|
|
#if 0
|
2009-07-19 00:49:44 +00:00
|
|
|
mval[0]= rect.xmin;
|
|
|
|
|
mval[1]= rect.ymin;
|
|
|
|
|
UI_view2d_region_to_view(v2d, mval[0], mval[1], &rectf.xmin, &rectf.ymin);
|
|
|
|
|
mval[0]= rect.xmax;
|
|
|
|
|
mval[1]= rect.ymax;
|
|
|
|
|
UI_view2d_region_to_view(v2d, mval[0], mval[1], &rectf.xmax, &rectf.ymax);
|
2012-03-03 16:31:46 +00:00
|
|
|
#endif
|
2009-07-19 00:49:44 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!extend) {
|
|
|
|
|
for (report= reports->list.first; report; report= report->next) {
|
2011-11-16 19:22:14 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if ((report->type & report_mask)==0)
|
2011-11-16 19:22:14 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
report->flag &= ~SELECT;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-11-11 13:36:57 +00:00
|
|
|
report_min= info_text_pick(sinfo, ar, reports, rect.ymax);
|
|
|
|
|
report_max= info_text_pick(sinfo, ar, reports, rect.ymin);
|
2009-07-19 00:49:44 +00:00
|
|
|
|
|
|
|
|
/* get the first report if none found */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (report_min==NULL) {
|
2009-11-06 22:51:08 +00:00
|
|
|
// printf("find_min\n");
|
2012-03-24 06:38:07 +00:00
|
|
|
for (report=reports->list.first; report; report=report->next) {
|
|
|
|
|
if (report->type & report_mask) {
|
2009-07-19 00:49:44 +00:00
|
|
|
report_min= report;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (report_max==NULL) {
|
2009-11-06 22:51:08 +00:00
|
|
|
// printf("find_max\n");
|
2012-03-24 06:38:07 +00:00
|
|
|
for (report=reports->list.last; report; report=report->prev) {
|
|
|
|
|
if (report->type & report_mask) {
|
2009-07-19 00:49:44 +00:00
|
|
|
report_max= report;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (report_min==NULL || report_max==NULL)
|
2009-07-19 00:49:44 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
for (report= report_min; (report != report_max->next); report= report->next) {
|
2009-07-19 00:49:44 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if ((report->type & report_mask)==0)
|
2009-07-19 00:49:44 +00:00
|
|
|
continue;
|
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (selecting)
|
2009-11-06 22:51:08 +00:00
|
|
|
report->flag |= SELECT;
|
|
|
|
|
else
|
|
|
|
|
report->flag &= ~SELECT;
|
2009-07-19 00:49:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ED_area_tag_redraw(CTX_wm_area(C));
|
|
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* ****** Border Select ****** */
|
2010-11-11 13:36:57 +00:00
|
|
|
void INFO_OT_select_border(wmOperatorType *ot)
|
2009-07-19 00:49:44 +00:00
|
|
|
{
|
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Border Select";
|
|
|
|
|
ot->description = "Toggle border selection";
|
|
|
|
|
ot->idname = "INFO_OT_select_border";
|
2009-07-19 00:49:44 +00:00
|
|
|
|
|
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->invoke = WM_border_select_invoke;
|
|
|
|
|
ot->exec = borderselect_exec;
|
|
|
|
|
ot->modal = WM_border_select_modal;
|
|
|
|
|
ot->cancel = WM_border_select_cancel;
|
2009-07-19 00:49:44 +00:00
|
|
|
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->poll = ED_operator_info_active;
|
2009-07-19 00:49:44 +00:00
|
|
|
|
|
|
|
|
/* flags */
|
2012-03-22 07:26:09 +00:00
|
|
|
/* ot->flag = OPTYPE_REGISTER; */
|
2009-07-19 00:49:44 +00:00
|
|
|
|
|
|
|
|
/* rna */
|
2011-11-16 19:22:14 +00:00
|
|
|
WM_operator_properties_gesture_border(ot, TRUE);
|
2009-07-19 00:49:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-10-13 23:46:42 +00:00
|
|
|
static int report_delete_exec(bContext *C, wmOperator *UNUSED(op))
|
2009-07-19 00:49:44 +00:00
|
|
|
{
|
2010-11-11 13:36:57 +00:00
|
|
|
SpaceInfo *sinfo= CTX_wm_space_info(C);
|
2009-07-19 00:49:44 +00:00
|
|
|
ReportList *reports= CTX_wm_reports(C);
|
2010-11-11 13:36:57 +00:00
|
|
|
int report_mask= info_report_mask(sinfo);
|
2009-07-19 00:49:44 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
Report *report, *report_next;
|
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
for (report=reports->list.first; report; ) {
|
2009-07-19 00:49:44 +00:00
|
|
|
|
|
|
|
|
report_next=report->next;
|
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if ((report->type & report_mask) && (report->flag & SELECT)) {
|
2009-07-19 00:49:44 +00:00
|
|
|
BLI_remlink(&reports->list, report);
|
2010-12-03 17:05:21 +00:00
|
|
|
MEM_freeN((void *)report->message);
|
2009-07-19 00:49:44 +00:00
|
|
|
MEM_freeN(report);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
report= report_next;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ED_area_tag_redraw(CTX_wm_area(C));
|
|
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
2010-11-11 13:36:57 +00:00
|
|
|
void INFO_OT_report_delete(wmOperatorType *ot)
|
2009-07-19 00:49:44 +00:00
|
|
|
{
|
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Delete Reports";
|
|
|
|
|
ot->description = "Delete selected reports";
|
|
|
|
|
ot->idname = "INFO_OT_report_delete";
|
2009-07-19 00:49:44 +00:00
|
|
|
|
|
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->poll = ED_operator_info_active;
|
|
|
|
|
ot->exec = report_delete_exec;
|
2009-07-19 00:49:44 +00:00
|
|
|
|
|
|
|
|
/* flags */
|
2012-03-22 07:26:09 +00:00
|
|
|
/*ot->flag = OPTYPE_REGISTER;*/
|
2009-07-19 00:49:44 +00:00
|
|
|
|
|
|
|
|
/* properties */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2010-10-13 23:46:42 +00:00
|
|
|
static int report_copy_exec(bContext *C, wmOperator *UNUSED(op))
|
2009-07-19 00:49:44 +00:00
|
|
|
{
|
2010-11-11 13:36:57 +00:00
|
|
|
SpaceInfo *sinfo= CTX_wm_space_info(C);
|
2009-07-19 00:49:44 +00:00
|
|
|
ReportList *reports= CTX_wm_reports(C);
|
2010-11-11 13:36:57 +00:00
|
|
|
int report_mask= info_report_mask(sinfo);
|
2009-07-19 00:49:44 +00:00
|
|
|
|
|
|
|
|
Report *report;
|
|
|
|
|
|
|
|
|
|
DynStr *buf_dyn= BLI_dynstr_new();
|
|
|
|
|
char *buf_str;
|
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
for (report=reports->list.first; report; report= report->next) {
|
|
|
|
|
if ((report->type & report_mask) && (report->flag & SELECT)) {
|
2009-07-19 00:49:44 +00:00
|
|
|
BLI_dynstr_append(buf_dyn, report->message);
|
|
|
|
|
BLI_dynstr_append(buf_dyn, "\n");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
buf_str= BLI_dynstr_get_cstring(buf_dyn);
|
|
|
|
|
BLI_dynstr_free(buf_dyn);
|
|
|
|
|
|
|
|
|
|
WM_clipboard_text_set(buf_str, 0);
|
|
|
|
|
|
|
|
|
|
MEM_freeN(buf_str);
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
2010-11-11 13:36:57 +00:00
|
|
|
void INFO_OT_report_copy(wmOperatorType *ot)
|
2009-07-19 00:49:44 +00:00
|
|
|
{
|
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Copy Reports to Clipboard";
|
|
|
|
|
ot->description = "Copy selected reports to Clipboard";
|
|
|
|
|
ot->idname = "INFO_OT_report_copy";
|
2009-07-19 00:49:44 +00:00
|
|
|
|
|
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->poll = ED_operator_info_active;
|
|
|
|
|
ot->exec = report_copy_exec;
|
2009-07-19 00:49:44 +00:00
|
|
|
|
|
|
|
|
/* flags */
|
2012-03-22 07:26:09 +00:00
|
|
|
/*ot->flag = OPTYPE_REGISTER;*/
|
2009-07-19 00:49:44 +00:00
|
|
|
|
|
|
|
|
/* properties */
|
|
|
|
|
}
|