Possible fix for issue #2 in [#25664] Remove Pack does not work in Texture panel
[blender.git] / source / blender / editors / space_image / image_header.c
1 /**
2  * $Id$
3  *
4  * ***** BEGIN GPL LICENSE BLOCK *****
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version. 
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software Foundation,
18  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19  *
20  * The Original Code is Copyright (C) 2008 Blender Foundation.
21  * All rights reserved.
22  *
23  * 
24  * Contributor(s): Blender Foundation
25  *
26  * ***** END GPL LICENSE BLOCK *****
27  */
28
29 #include <string.h>
30 #include <stdio.h>
31
32 #include "DNA_object_types.h"
33 #include "DNA_space_types.h"
34 #include "DNA_windowmanager_types.h"
35
36 #include "BLI_blenlib.h"
37 #include "BLI_editVert.h"
38 #include "BLI_utildefines.h"
39
40 #include "BKE_context.h"
41
42 #include "ED_image.h"
43
44 #include "WM_types.h"
45
46 #include "UI_interface.h"
47
48 #include "image_intern.h"
49
50 /********************** toolbox operator *********************/
51
52 static int toolbox_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *UNUSED(event))
53 {
54         SpaceImage *sima= CTX_wm_space_image(C);
55         Object *obedit= CTX_data_edit_object(C);
56         uiPopupMenu *pup;
57         uiLayout *layout;
58         int show_uvedit;
59
60         show_uvedit= ED_space_image_show_uvedit(sima, obedit);
61
62         pup= uiPupMenuBegin(C, "Toolbox", ICON_NULL);
63         layout= uiPupMenuLayout(pup);
64
65         uiItemM(layout, C, "IMAGE_MT_view", NULL, ICON_NULL);
66         if(show_uvedit) uiItemM(layout, C, "IMAGE_MT_select", NULL, ICON_NULL);
67         uiItemM(layout, C, "IMAGE_MT_image", NULL, ICON_NULL);
68         if(show_uvedit) uiItemM(layout, C, "IMAGE_MT_uvs", NULL, ICON_NULL);
69
70         uiPupMenuEnd(C, pup);
71
72         return OPERATOR_CANCELLED;
73 }
74
75 void IMAGE_OT_toolbox(wmOperatorType *ot)
76 {
77         /* identifiers */
78         ot->name= "Toolbox";
79         ot->idname= "IMAGE_OT_toolbox";
80         
81         /* api callbacks */
82         ot->invoke= toolbox_invoke;
83         ot->poll= space_image_main_area_poll;
84 }
85