Beispiel #1
0
static int unpack_all_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
	Main *bmain = CTX_data_main(C);
	uiPopupMenu *pup;
	uiLayout *layout;
	char title[64];
	int count = 0;
	
	count = countPackedFiles(bmain);
	
	if (!count) {
		BKE_report(op->reports, RPT_WARNING, "No packed files to unpack");
		G.fileflags &= ~G_AUTOPACK;
		return OPERATOR_CANCELLED;
	}

	if (count == 1)
		strcpy(title, IFACE_("Unpack 1 File"));
	else
		BLI_snprintf(title, sizeof(title), IFACE_("Unpack %d Files"), count);
	
	pup = uiPupMenuBegin(C, title, ICON_NONE);
	layout = uiPupMenuLayout(pup);

	uiLayoutSetOperatorContext(layout, WM_OP_EXEC_DEFAULT);
	uiItemsEnumO(layout, "FILE_OT_unpack_all", "method");

	uiPupMenuEnd(C, pup);

	return OPERATOR_CANCELLED;
}
Beispiel #2
0
static int unpack_all_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
{
	Main *bmain= CTX_data_main(C);
	uiPopupMenu *pup;
	uiLayout *layout;
	char title[128];
	int count = 0;
	
	count = countPackedFiles(bmain);
	
	if(!count) {
		BKE_report(op->reports, RPT_WARNING, "No packed files. Autopack disabled.");
		G.fileflags &= ~G_AUTOPACK;
		return OPERATOR_CANCELLED;
	}

	if(count == 1)
		sprintf(title, "Unpack 1 file");
	else
		sprintf(title, "Unpack %d files", count);
	
	pup= uiPupMenuBegin(C, title, ICON_NULL);
	layout= uiPupMenuLayout(pup);

	uiLayoutSetOperatorContext(layout, WM_OP_EXEC_DEFAULT);
	uiItemsEnumO(layout, "FILE_OT_unpack_all", "method");

	uiPupMenuEnd(C, pup);

	return OPERATOR_CANCELLED;
}
Beispiel #3
0
static int poselib_add_menu_invoke (bContext *C, wmOperator *op, wmEvent *UNUSED(evt))
{
	Scene *scene= CTX_data_scene(C);
	Object *ob= get_poselib_object(C);
	bPose *pose= (ob) ? ob->pose : NULL;
	uiPopupMenu *pup;
	uiLayout *layout;
	
	/* sanity check */
	if (ELEM(NULL, ob, pose)) 
		return OPERATOR_CANCELLED;
	
	/* start building */
	pup= uiPupMenuBegin(C, op->type->name, ICON_NONE);
	layout= uiPupMenuLayout(pup);
	uiLayoutSetOperatorContext(layout, WM_OP_EXEC_DEFAULT);
	
	/* add new (adds to the first unoccupied frame) */
	uiItemIntO(layout, IFACE_("Add New"), ICON_NONE, "POSELIB_OT_pose_add", "frame", poselib_get_free_index(ob->poselib));
	
	/* check if we have any choices to add a new pose in any other way */
	if ((ob->poselib) && (ob->poselib->markers.first)) {
		/* add new (on current frame) */
		uiItemIntO(layout, IFACE_("Add New (Current Frame)"), ICON_NONE, "POSELIB_OT_pose_add", "frame", CFRA);
		
		/* replace existing - submenu */
		uiItemMenuF(layout, IFACE_("Replace Existing..."), 0, poselib_add_menu_invoke__replacemenu, NULL);
	}
	
	uiPupMenuEnd(C, pup);
	
	/* this operator is only for a menu, not used further */
	return OPERATOR_CANCELLED;
}
Beispiel #4
0
static int armature_parent_set_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *UNUSED(event))
{
	EditBone *actbone = CTX_data_active_bone(C);
	uiPopupMenu *pup = uiPupMenuBegin(C, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Make Parent"), ICON_NONE);
	uiLayout *layout = uiPupMenuLayout(pup);
	int allchildbones = 0;
	
	CTX_DATA_BEGIN(C, EditBone *, ebone, selected_editable_bones)
	{
		if (ebone != actbone) {
			if (ebone->parent != actbone) allchildbones = 1;
		}
	}
	CTX_DATA_END;

	uiItemEnumO(layout, "ARMATURE_OT_parent_set", NULL, 0, "type", ARM_PAR_CONNECT);
	
	/* ob becomes parent, make the associated menus */
	if (allchildbones)
		uiItemEnumO(layout, "ARMATURE_OT_parent_set", NULL, 0, "type", ARM_PAR_OFFSET);
		
	uiPupMenuEnd(C, pup);
	
	return OPERATOR_CANCELLED;
}
Beispiel #5
0
static int vertex_group_menu_exec(bContext *C, wmOperator *op)
{
	Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
	uiPopupMenu *pup;
	uiLayout *layout;

	pup= uiPupMenuBegin(C, "Vertex Groups", 0);
	layout= uiPupMenuLayout(pup);
	uiLayoutSetOperatorContext(layout, WM_OP_INVOKE_REGION_WIN);

	if(vgroup_object_in_edit_mode(ob)) {
		uiItemBooleanO(layout, "Assign to New Group", 0, "OBJECT_OT_vertex_group_assign", "new", 1);

		if(BLI_countlist(&ob->defbase) && ob->actdef) {
			uiItemO(layout, "Assign to Group", 0, "OBJECT_OT_vertex_group_assign");
			uiItemO(layout, "Remove from Group", 0, "OBJECT_OT_vertex_group_remove_from");
			uiItemBooleanO(layout, "Remove from All", 0, "OBJECT_OT_vertex_group_remove_from", "all", 1);
		}
	}

	if(BLI_countlist(&ob->defbase) && ob->actdef) {
		if(vgroup_object_in_edit_mode(ob))
			uiItemS(layout);

		uiItemO(layout, "Set Active Group", 0, "OBJECT_OT_vertex_group_set_active");
		uiItemO(layout, "Remove Group", 0, "OBJECT_OT_vertex_group_remove");
		uiItemBooleanO(layout, "Remove All Groups", 0, "OBJECT_OT_vertex_group_remove", "all", 1);
	}

	uiPupMenuEnd(C, pup);

	return OPERATOR_FINISHED;
}
Beispiel #6
0
/* popup menu wrapper */
static PointerRNA rna_PupMenuBegin(bContext *C, const char *title, int icon)
{
	PointerRNA r_ptr;
	void *data;

	data = (void *)uiPupMenuBegin(C, title, icon);

	RNA_pointer_create(NULL, &RNA_UIPopupMenu, data, &r_ptr);

	return r_ptr;
}
Beispiel #7
0
static int select_orientation_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *UNUSED(event))
{
	uiPopupMenu *pup;
	uiLayout *layout;

	pup= uiPupMenuBegin(C, "Orientation", ICON_NULL);
	layout= uiPupMenuLayout(pup);
	uiItemsEnumO(layout, "TRANSFORM_OT_select_orientation", "orientation");
	uiPupMenuEnd(C, pup);

	return OPERATOR_CANCELLED;
}
Beispiel #8
0
static int keyingset_active_menu_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
	uiPopupMenu *pup;
	uiLayout *layout;
	
	/* call the menu, which will call this operator again, hence the canceled */
	pup = uiPupMenuBegin(C, op->type->name, ICON_NONE);
	layout = uiPupMenuLayout(pup);
	uiItemsEnumO(layout, "ANIM_OT_keying_set_active_set", "type");
	uiPupMenuEnd(C, pup);
	
	return OPERATOR_CANCELLED;
}
Beispiel #9
0
static int node_group_separate_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *UNUSED(event))
{
	uiPopupMenu *pup = uiPupMenuBegin(C, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Separate"), ICON_NONE);
	uiLayout *layout = uiPupMenuLayout(pup);
	
	uiLayoutSetOperatorContext(layout, WM_OP_EXEC_DEFAULT);
	uiItemEnumO(layout, "NODE_OT_group_separate", NULL, 0, "type", NODE_GS_COPY);
	uiItemEnumO(layout, "NODE_OT_group_separate", NULL, 0, "type", NODE_GS_MOVE);
	
	uiPupMenuEnd(C, pup);
	
	return OPERATOR_CANCELLED;
}
Beispiel #10
0
static int unpack_item_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
	uiPopupMenu *pup;
	uiLayout *layout;
	
	pup = uiPupMenuBegin(C, IFACE_("Unpack"), ICON_NONE);
	layout = uiPupMenuLayout(pup);
	
	uiLayoutSetOperatorContext(layout, WM_OP_EXEC_DEFAULT);
	uiItemsFullEnumO(layout, op->type->idname, "method", op->ptr->data, WM_OP_EXEC_REGION_WIN, 0);
	
	uiPupMenuEnd(C, pup);
	
	return OPERATOR_CANCELLED;
}
Beispiel #11
0
static int object_metaball_add_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
	Object *obedit= CTX_data_edit_object(C);
	uiPopupMenu *pup;
	uiLayout *layout;

	pup= uiPupMenuBegin(C, op->type->name, 0);
	layout= uiPupMenuLayout(pup);
	if(!obedit || obedit->type == OB_MBALL)
		uiItemsEnumO(layout, op->type->idname, "type");
	else
		uiItemsEnumO(layout, "OBJECT_OT_metaball_add", "type");
	uiPupMenuEnd(C, pup);

	return OPERATOR_CANCELLED;
}
Beispiel #12
0
static int toolbox_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *UNUSED(event))
{
	bScreen *sc = CTX_wm_screen(C);
	SpaceButs *sbuts = CTX_wm_space_buts(C);
	PointerRNA ptr;
	uiPopupMenu *pup;
	uiLayout *layout;

	RNA_pointer_create(&sc->id, &RNA_SpaceProperties, sbuts, &ptr);

	pup = uiPupMenuBegin(C, "Align", ICON_NONE);
	layout = uiPupMenuLayout(pup);
	uiItemsEnumR(layout, &ptr, "align");
	uiPupMenuEnd(C, pup);

	return OPERATOR_CANCELLED;
}
Beispiel #13
0
/* invoke callback which presents a list of bone-groups for the user to choose from */
static int pose_groups_menu_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
	Object *ob = ED_pose_object_from_context(C);
	bPose *pose;
	
	uiPopupMenu *pup;
	uiLayout *layout;
	bActionGroup *grp;
	int i;
	
	/* only continue if there's an object, and a pose there too */
	if (ELEM(NULL, ob, ob->pose)) 
		return OPERATOR_CANCELLED;
	pose = ob->pose;
	
	/* if there's no active group (or active is invalid), create a new menu to find it */
	if (pose->active_group <= 0) {
		/* create a new menu, and start populating it with group names */
		pup = uiPupMenuBegin(C, op->type->name, ICON_NONE);
		layout = uiPupMenuLayout(pup);
		
		/* special entry - allow to create new group, then use that 
		 *	(not to be used for removing though)
		 */
		if (strstr(op->idname, "assign")) {
			uiItemIntO(layout, "New Group", ICON_NONE, op->idname, "type", 0);
			uiItemS(layout);
		}
		
		/* add entries for each group */
		for (grp = pose->agroups.first, i = 1; grp; grp = grp->next, i++)
			uiItemIntO(layout, grp->name, ICON_NONE, op->idname, "type", i);
			
		/* finish building the menu, and process it (should result in calling self again) */
		uiPupMenuEnd(C, pup);
		
		return OPERATOR_CANCELLED;
	}
	else {
		/* just use the active group index, and call the exec callback for the calling operator */
		RNA_int_set(op->ptr, "type", pose->active_group);
		return op->type->exec(C, op);
	}
}
Beispiel #14
0
/* Create (and show) a menu containing all the Keying Sets which can be used in the current context */
void ANIM_keying_sets_menu_setup (bContext *C, const char title[], const char op_name[])
{
	Scene *scene= CTX_data_scene(C);
	KeyingSet *ks;
	uiPopupMenu *pup;
	uiLayout *layout;
	int i = 0;
	
	pup= uiPupMenuBegin(C, title, ICON_NONE);
	layout= uiPupMenuLayout(pup);
	
	/* active Keying Set 
	 *	- only include entry if it exists
	 */
	if (scene->active_keyingset) {
		uiItemIntO(layout, "Active Keying Set", ICON_NONE, op_name, "type", i++);
		uiItemS(layout);
	}
	else
		i++;
	
	/* user-defined Keying Sets 
	 *	- these are listed in the order in which they were defined for the active scene
	 */
	if (scene->keyingsets.first) {
		for (ks= scene->keyingsets.first; ks; ks=ks->next, i++) {
			if (ANIM_keyingset_context_ok_poll(C, ks))
				uiItemIntO(layout, ks->name, ICON_NONE, op_name, "type", i);
		}
		uiItemS(layout);
	}
	
	/* builtin Keying Sets */
	i= -1;
	for (ks= builtin_keyingsets.first; ks; ks=ks->next, i--) {
		/* only show KeyingSet if context is suitable */
		if (ANIM_keyingset_context_ok_poll(C, ks))
			uiItemEnumO_value(layout, ks->name, ICON_NONE, op_name, "type", i);
	}
	
	uiPupMenuEnd(C, pup);
} 
Beispiel #15
0
static int undo_history_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
	int undosys, totitem = 0;
	
	undosys = get_undo_system(C);
	
	if (undosys) {
		EnumPropertyItem *item = rna_undo_itemf(C, undosys, &totitem);
		
		if (totitem > 0) {
			uiPopupMenu *pup = uiPupMenuBegin(C, RNA_struct_ui_name(op->type->srna), ICON_NONE);
			uiLayout *layout = uiPupMenuLayout(pup);
			uiLayout *split = uiLayoutSplit(layout, 0.0f, false);
			uiLayout *column = NULL;
			const int col_size = 20 + totitem / 12;
			int i, c;
			bool add_col = true;
			
			for (c = 0, i = totitem; i--;) {
				if (add_col && !(c % col_size)) {
					column = uiLayoutColumn(split, false);
					add_col = false;
				}
				if (item[i].identifier) {
					uiItemIntO(column, item[i].name, item[i].icon, op->type->idname, "item", item[i].value);
					++c;
					add_col = true;
				}
			}
			
			MEM_freeN(item);
			
			uiPupMenuEnd(C, pup);
		}
		
	}
	return OPERATOR_CANCELLED;
}
Beispiel #16
0
static int parent_drop_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
	Object *par = NULL;
	Object *ob = NULL;
	SpaceOops *soops = CTX_wm_space_outliner(C);
	ARegion *ar = CTX_wm_region(C);
	Main *bmain = CTX_data_main(C);
	Scene *scene = CTX_data_scene(C);
	TreeElement *te = NULL;
	TreeElement *te_found = NULL;
	char childname[MAX_ID_NAME];
	char parname[MAX_ID_NAME];
	int partype = 0;
	float fmval[2];

	UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &fmval[0], &fmval[1]);

	/* Find object hovered over */
	for (te = soops->tree.first; te; te = te->next) {
		te_found = outliner_dropzone_parent(C, event, te, fmval);
		if (te_found) break;
	}

	if (te_found) {
		RNA_string_set(op->ptr, "parent", te_found->name);
		/* Identify parent and child */
		RNA_string_get(op->ptr, "child", childname);
		ob = (Object *)BKE_libblock_find_name(ID_OB, childname);
		RNA_string_get(op->ptr, "parent", parname);
		par = (Object *)BKE_libblock_find_name(ID_OB, parname);
		
		if (ELEM(NULL, ob, par)) {
			if (par == NULL) printf("par==NULL\n");
			return OPERATOR_CANCELLED;
		}
		if (ob == par) {
			return OPERATOR_CANCELLED;
		}
		
		/* check dragged object (child) is active */
		if (ob != CTX_data_active_object(C))
			ED_base_object_select(BKE_scene_base_find(scene, ob), BA_SELECT);
		
		if ((par->type != OB_ARMATURE) && (par->type != OB_CURVE) && (par->type != OB_LATTICE)) {
			if (ED_object_parent_set(op->reports, bmain, scene, ob, par, partype)) {
				DAG_scene_sort(bmain, scene);
				DAG_ids_flush_update(bmain, 0);
				WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
				WM_event_add_notifier(C, NC_OBJECT | ND_PARENT, NULL);
			}
		}
		else {
			/* Menu creation */
			uiPopupMenu *pup = uiPupMenuBegin(C, IFACE_("Set Parent To"), ICON_NONE);
			uiLayout *layout = uiPupMenuLayout(pup);
			
			PointerRNA ptr;
			
			WM_operator_properties_create(&ptr, "OUTLINER_OT_parent_drop");
			RNA_string_set(&ptr, "parent", parname);
			RNA_string_set(&ptr, "child", childname);
			RNA_enum_set(&ptr, "type", PAR_OBJECT);
			/* Cannot use uiItemEnumO()... have multiple properties to set. */
			uiItemFullO(layout, "OUTLINER_OT_parent_drop", IFACE_("Object"),
			            0, ptr.data, WM_OP_EXEC_DEFAULT, 0);
			
			/* par becomes parent, make the associated menus */
			if (par->type == OB_ARMATURE) {
				WM_operator_properties_create(&ptr, "OUTLINER_OT_parent_drop");
				RNA_string_set(&ptr, "parent", parname);
				RNA_string_set(&ptr, "child", childname);
				RNA_enum_set(&ptr, "type", PAR_ARMATURE);
				uiItemFullO(layout, "OUTLINER_OT_parent_drop", IFACE_("Armature Deform"),
				            0, ptr.data, WM_OP_EXEC_DEFAULT, 0);
				
				WM_operator_properties_create(&ptr, "OUTLINER_OT_parent_drop");
				RNA_string_set(&ptr, "parent", parname);
				RNA_string_set(&ptr, "child", childname);
				RNA_enum_set(&ptr, "type", PAR_ARMATURE_NAME);
				uiItemFullO(layout, "OUTLINER_OT_parent_drop", IFACE_("   With Empty Groups"),
				            0, ptr.data, WM_OP_EXEC_DEFAULT, 0);
				
				WM_operator_properties_create(&ptr, "OUTLINER_OT_parent_drop");
				RNA_string_set(&ptr, "parent", parname);
				RNA_string_set(&ptr, "child", childname);
				RNA_enum_set(&ptr, "type", PAR_ARMATURE_ENVELOPE);
				uiItemFullO(layout, "OUTLINER_OT_parent_drop", IFACE_("   With Envelope Weights"),
				            0, ptr.data, WM_OP_EXEC_DEFAULT, 0);
				
				WM_operator_properties_create(&ptr, "OUTLINER_OT_parent_drop");
				RNA_string_set(&ptr, "parent", parname);
				RNA_string_set(&ptr, "child", childname);
				RNA_enum_set(&ptr, "type", PAR_ARMATURE_AUTO);
				uiItemFullO(layout, "OUTLINER_OT_parent_drop", IFACE_("   With Automatic Weights"),
				            0, ptr.data, WM_OP_EXEC_DEFAULT, 0);
				
				WM_operator_properties_create(&ptr, "OUTLINER_OT_parent_drop");
				RNA_string_set(&ptr, "parent", parname);
				RNA_string_set(&ptr, "child", childname);
				RNA_enum_set(&ptr, "type", PAR_BONE);
				uiItemFullO(layout, "OUTLINER_OT_parent_drop", IFACE_("Bone"),
				            0, ptr.data, WM_OP_EXEC_DEFAULT, 0);
			}
			else if (par->type == OB_CURVE) {
				WM_operator_properties_create(&ptr, "OUTLINER_OT_parent_drop");
				RNA_string_set(&ptr, "parent", parname);
				RNA_string_set(&ptr, "child", childname);
				RNA_enum_set(&ptr, "type", PAR_CURVE);
				uiItemFullO(layout, "OUTLINER_OT_parent_drop", IFACE_("Curve Deform"),
				            0, ptr.data, WM_OP_EXEC_DEFAULT, 0);
				
				WM_operator_properties_create(&ptr, "OUTLINER_OT_parent_drop");
				RNA_string_set(&ptr, "parent", parname);
				RNA_string_set(&ptr, "child", childname);
				RNA_enum_set(&ptr, "type", PAR_FOLLOW);
				uiItemFullO(layout, "OUTLINER_OT_parent_drop", IFACE_("Follow Path"),
				            0, ptr.data, WM_OP_EXEC_DEFAULT, 0);
				
				WM_operator_properties_create(&ptr, "OUTLINER_OT_parent_drop");
				RNA_string_set(&ptr, "parent", parname);
				RNA_string_set(&ptr, "child", childname);
				RNA_enum_set(&ptr, "type", PAR_PATH_CONST);
				uiItemFullO(layout, "OUTLINER_OT_parent_drop", IFACE_("Path Constraint"),
				            0, ptr.data, WM_OP_EXEC_DEFAULT, 0);
			}
			else if (par->type == OB_LATTICE) {
				WM_operator_properties_create(&ptr, "OUTLINER_OT_parent_drop");
				RNA_string_set(&ptr, "parent", parname);
				RNA_string_set(&ptr, "child", childname);
				RNA_enum_set(&ptr, "type", PAR_LATTICE);
				uiItemFullO(layout, "OUTLINER_OT_parent_drop", IFACE_("Lattice Deform"),
				            0, ptr.data, WM_OP_EXEC_DEFAULT, 0);
			}
			
			uiPupMenuEnd(C, pup);
			
			return OPERATOR_CANCELLED;
		}
	}
	else {
		return OPERATOR_CANCELLED;
	}

	return OPERATOR_FINISHED;
}
Beispiel #17
0
void unpack_menu(bContext *C, const char *opname, const char *id_name, const char *abs_name, const char *folder, struct PackedFile *pf)
{
	PointerRNA props_ptr;
	uiPopupMenu *pup;
	uiLayout *layout;
	char line[FILE_MAXDIR + FILE_MAXFILE + 100];

	pup= uiPupMenuBegin(C, "Unpack file", ICON_NULL);
	layout= uiPupMenuLayout(pup);

	sprintf(line, "Remove Pack");
	props_ptr= uiItemFullO(layout, opname, line, ICON_NULL, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS);
	RNA_enum_set(&props_ptr, "method", PF_REMOVE);
	RNA_string_set(&props_ptr, "id", id_name);

	if(G.relbase_valid) {
		char local_name[FILE_MAXDIR + FILE_MAX], fi[FILE_MAX];

		BLI_strncpy(local_name, abs_name, sizeof(local_name));
		BLI_splitdirstring(local_name, fi);
		sprintf(local_name, "//%s/%s", folder, fi);
		if(strcmp(abs_name, local_name)!=0) {
			switch(checkPackedFile(local_name, pf)) {
				case PF_NOFILE:
					sprintf(line, "Create %s", local_name);
					props_ptr= uiItemFullO(layout, opname, line, ICON_NULL, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS);
					RNA_enum_set(&props_ptr, "method", PF_WRITE_LOCAL);
					RNA_string_set(&props_ptr, "id", id_name);

					break;
				case PF_EQUAL:
					sprintf(line, "Use %s (identical)", local_name);
					//uiItemEnumO(layout, opname, line, 0, "method", PF_USE_LOCAL);
					props_ptr= uiItemFullO(layout, opname, line, ICON_NULL, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS);
					RNA_enum_set(&props_ptr, "method", PF_USE_LOCAL);
					RNA_string_set(&props_ptr, "id", id_name);

					break;
				case PF_DIFFERS:
					sprintf(line, "Use %s (differs)", local_name);
					//uiItemEnumO(layout, opname, line, 0, "method", PF_USE_LOCAL);
					props_ptr= uiItemFullO(layout, opname, line, ICON_NULL, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS);
					RNA_enum_set(&props_ptr, "method", PF_USE_LOCAL);
					RNA_string_set(&props_ptr, "id", id_name);

					sprintf(line, "Overwrite %s", local_name);
					//uiItemEnumO(layout, opname, line, 0, "method", PF_WRITE_LOCAL);
					props_ptr= uiItemFullO(layout, opname, line, ICON_NULL, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS);
					RNA_enum_set(&props_ptr, "method", PF_WRITE_LOCAL);
					RNA_string_set(&props_ptr, "id", id_name);
					break;
			}
		}
	}

	switch(checkPackedFile(abs_name, pf)) {
		case PF_NOFILE:
			sprintf(line, "Create %s", abs_name);
			//uiItemEnumO(layout, opname, line, 0, "method", PF_WRITE_ORIGINAL);
			props_ptr= uiItemFullO(layout, opname, line, ICON_NULL, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS);
			RNA_enum_set(&props_ptr, "method", PF_WRITE_ORIGINAL);
			RNA_string_set(&props_ptr, "id", id_name);
			break;
		case PF_EQUAL:
			sprintf(line, "Use %s (identical)", abs_name);
			//uiItemEnumO(layout, opname, line, 0, "method", PF_USE_ORIGINAL);
			props_ptr= uiItemFullO(layout, opname, line, ICON_NULL, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS);
			RNA_enum_set(&props_ptr, "method", PF_USE_ORIGINAL);
			RNA_string_set(&props_ptr, "id", id_name);
			break;
		case PF_DIFFERS:
			sprintf(line, "Use %s (differs)", abs_name);
			//uiItemEnumO(layout, opname, line, 0, "method", PF_USE_ORIGINAL);
			props_ptr= uiItemFullO(layout, opname, line, ICON_NULL, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS);
			RNA_enum_set(&props_ptr, "method", PF_USE_ORIGINAL);
			RNA_string_set(&props_ptr, "id", id_name);

			sprintf(line, "Overwrite %s", abs_name);
			//uiItemEnumO(layout, opname, line, 0, "method", PF_WRITE_ORIGINAL);
			props_ptr= uiItemFullO(layout, opname, line, ICON_NULL, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS);
			RNA_enum_set(&props_ptr, "method", PF_WRITE_ORIGINAL);
			RNA_string_set(&props_ptr, "id", id_name);
			break;
	}

	uiPupMenuEnd(C, pup);
}
Beispiel #18
0
void unpack_menu(bContext *C, const char *opname, const char *id_name, const char *abs_name, const char *folder, struct PackedFile *pf)
{
	PointerRNA props_ptr;
	uiPopupMenu *pup;
	uiLayout *layout;
	char line[FILE_MAX + 100];
	wmOperatorType *ot = WM_operatortype_find(opname, 1);

	pup = uiPupMenuBegin(C, IFACE_("Unpack File"), ICON_NONE);
	layout = uiPupMenuLayout(pup);

	props_ptr = uiItemFullO_ptr(layout, ot, IFACE_("Remove Pack"), ICON_NONE,
	                            NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS);
	RNA_enum_set(&props_ptr, "method", PF_REMOVE);
	RNA_string_set(&props_ptr, "id", id_name);

	if (G.relbase_valid) {
		char local_name[FILE_MAXDIR + FILE_MAX], fi[FILE_MAX];

		BLI_split_file_part(abs_name, fi, sizeof(fi));
		BLI_snprintf(local_name, sizeof(local_name), "//%s/%s", folder, fi);
		if (strcmp(abs_name, local_name) != 0) {
			switch (checkPackedFile(local_name, pf)) {
				case PF_NOFILE:
					BLI_snprintf(line, sizeof(line), IFACE_("Create %s"), local_name);
					props_ptr = uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS);
					RNA_enum_set(&props_ptr, "method", PF_WRITE_LOCAL);
					RNA_string_set(&props_ptr, "id", id_name);

					break;
				case PF_EQUAL:
					BLI_snprintf(line, sizeof(line), IFACE_("Use %s (identical)"), local_name);
					//uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_USE_LOCAL);
					props_ptr = uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS);
					RNA_enum_set(&props_ptr, "method", PF_USE_LOCAL);
					RNA_string_set(&props_ptr, "id", id_name);

					break;
				case PF_DIFFERS:
					BLI_snprintf(line, sizeof(line), IFACE_("Use %s (differs)"), local_name);
					//uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_USE_LOCAL);
					props_ptr = uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS);
					RNA_enum_set(&props_ptr, "method", PF_USE_LOCAL);
					RNA_string_set(&props_ptr, "id", id_name);

					BLI_snprintf(line, sizeof(line), IFACE_("Overwrite %s"), local_name);
					//uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_WRITE_LOCAL);
					props_ptr = uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS);
					RNA_enum_set(&props_ptr, "method", PF_WRITE_LOCAL);
					RNA_string_set(&props_ptr, "id", id_name);
					break;
			}
		}
	}

	switch (checkPackedFile(abs_name, pf)) {
		case PF_NOFILE:
			BLI_snprintf(line, sizeof(line), IFACE_("Create %s"), abs_name);
			//uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_WRITE_ORIGINAL);
			props_ptr = uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS);
			RNA_enum_set(&props_ptr, "method", PF_WRITE_ORIGINAL);
			RNA_string_set(&props_ptr, "id", id_name);
			break;
		case PF_EQUAL:
			BLI_snprintf(line, sizeof(line), IFACE_("Use %s (identical)"), abs_name);
			//uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_USE_ORIGINAL);
			props_ptr = uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS);
			RNA_enum_set(&props_ptr, "method", PF_USE_ORIGINAL);
			RNA_string_set(&props_ptr, "id", id_name);
			break;
		case PF_DIFFERS:
			BLI_snprintf(line, sizeof(line), IFACE_("Use %s (differs)"), abs_name);
			//uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_USE_ORIGINAL);
			props_ptr = uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS);
			RNA_enum_set(&props_ptr, "method", PF_USE_ORIGINAL);
			RNA_string_set(&props_ptr, "id", id_name);

			BLI_snprintf(line, sizeof(line), IFACE_("Overwrite %s"), abs_name);
			//uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_WRITE_ORIGINAL);
			props_ptr = uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS);
			RNA_enum_set(&props_ptr, "method", PF_WRITE_ORIGINAL);
			RNA_string_set(&props_ptr, "id", id_name);
			break;
	}

	uiPupMenuEnd(C, pup);
}