- include operator commands in tooltips (needs sanitizing for transform operators...
authorCampbell Barton <ideasman42@gmail.com>
Wed, 29 Jul 2009 23:12:30 +0000 (23:12 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Wed, 29 Jul 2009 23:12:30 +0000 (23:12 +0000)
- WM_operator_pystring can now be used with an operator type and properties (rather then a wmOperator instance)
- removed menus from file selector

release/ui/space_filebrowser.py
source/blender/editors/interface/interface_regions.c
source/blender/editors/space_file/file_draw.c
source/blender/editors/space_file/file_ops.c
source/blender/windowmanager/WM_api.h
source/blender/windowmanager/intern/wm.c
source/blender/windowmanager/intern/wm_event_system.c
source/blender/windowmanager/intern/wm_operators.c

index 2d35616..0fecbdb 100644 (file)
@@ -11,18 +11,16 @@ class FILEBROWSER_HT_header(bpy.types.Header):
                
                params = st.params 
                layout.template_header()
-
-               if context.area.show_menus:
-                       row = layout.row()
-                       row.itemM("FILEBROWSER_MT_directory")
-                       row.itemM("FILEBROWSER_MT_bookmarks")
-
+               
                row = layout.row(align=True)
                row.itemO("file.parent", text="", icon='ICON_FILE_PARENT')
                row.itemO("file.refresh", text="", icon='ICON_FILE_REFRESH')
                row.itemO("file.previous", text="", icon='ICON_PREV_KEYFRAME')
                row.itemO("file.next", text="", icon='ICON_NEXT_KEYFRAME')
                
+               row = layout.row(align=True)
+               row.itemO("file.directory_new", text="", icon='ICON_NEWFOLDER')
+               
                layout.itemR(params, "display", expand=True, text="")
                layout.itemR(params, "sort", expand=True, text="")
                
@@ -41,27 +39,5 @@ class FILEBROWSER_HT_header(bpy.types.Header):
 
                row.active = params.do_filter
 
-class FILEBROWSER_MT_directory(bpy.types.Menu):
-       __space_type__ = "FILE_BROWSER"
-       __label__ = "Directory"
-
-       def draw(self, context):
-               layout = self.layout
-
-               layout.itemO("file.directory_new", text="New Directory", icon='ICON_NEWFOLDER')
-               layout.itemO("file.refresh", text="Refresh", icon='ICON_FILE_REFRESH')
-               layout.itemO("file.parent", text="Parent", icon='ICON_FILE_PARENT')
-               
-class FILEBROWSER_MT_bookmarks(bpy.types.Menu):
-       __space_type__ = "FILE_BROWSER"
-       __label__ = "Bookmarks"
-
-       def draw(self, context):
-               layout = self.layout
-
-               layout.itemO("file.add_bookmark", text="Add current directory", icon='ICON_BOOKMARKS')
-
                
 bpy.types.register(FILEBROWSER_HT_header)
-bpy.types.register(FILEBROWSER_MT_directory)
-bpy.types.register(FILEBROWSER_MT_bookmarks)
index 7cce7a0..94442c5 100644 (file)
@@ -391,6 +391,21 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but)
                data->linedark[data->totline]= 1;
                data->totline++;
        }
+       else if (but->optype) {
+               PointerRNA *opptr;
+               char *str;
+               opptr= uiButGetOperatorPtrRNA(but);
+
+               str= WM_operator_pystring(but->optype, opptr);
+
+               /* operator info */
+               BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), "Python: %s", str);
+               data->linedark[data->totline]= 1;
+               data->totline++;
+
+               WM_operator_properties_free(opptr);
+               MEM_freeN(str);
+       }
 
        if(data->totline == 0) {
                MEM_freeN(data);
index e807bad..933b9cc 100644 (file)
@@ -81,6 +81,7 @@
 
 /* ui geometry */
 #define IMASEL_BUTTONS_HEIGHT 40
+#define IMASEL_BUTTONS_MARGIN 6
 #define TILE_BORDER_X 8
 #define TILE_BORDER_Y 8
 
@@ -134,8 +135,8 @@ void file_draw_buttons(const bContext *C, ARegion *ar)
        /* Button layout. */
        const short min_x      = 10;
        const short max_x      = ar->winx - 10;
-       const short line2_y    = ar->winy - IMASEL_BUTTONS_HEIGHT - 12;
-       const short line1_y    = line2_y  + IMASEL_BUTTONS_HEIGHT/2 + 4;
+       const short line2_y    = IMASEL_BUTTONS_HEIGHT/2 + IMASEL_BUTTONS_MARGIN*2;
+       const short line1_y    = IMASEL_BUTTONS_MARGIN;
        const short input_minw = 20;
        const short btn_h      = UI_UNIT_Y;
        const short btn_fn_w   = UI_UNIT_X;
index a217dbe..9c73956 100644 (file)
@@ -716,6 +716,7 @@ void FILE_OT_directory_new(struct wmOperatorType *ot)
        /* identifiers */
        ot->name= "Create New Directory";
        ot->idname= "FILE_OT_directory_new";
+       ot->description= "Create a new directory";
        
        /* api callbacks */
        ot->invoke= WM_operator_confirm;
index f65e5b1..3670f1a 100644 (file)
@@ -172,7 +172,7 @@ void                WM_operator_properties_free(struct PointerRNA *ptr);
 void           WM_operator_properties_filesel(struct wmOperatorType *ot, int filter);
 
                /* operator as a python command (resultuing string must be free'd) */
-char           *WM_operator_pystring(struct wmOperator *op);
+char           *WM_operator_pystring(struct wmOperatorType *ot, struct PointerRNA *opptr);
 void           WM_operator_bl_idname(char *to, const char *from);
 void           WM_operator_py_idname(char *to, const char *from);
 
index c0ac7b0..46cf13f 100644 (file)
@@ -103,7 +103,7 @@ void wm_operator_register(bContext *C, wmOperator *op)
        
        
        /* Report the string representation of the operator */
-       buf = WM_operator_pystring(op);
+       buf = WM_operator_pystring(op->type, op->ptr);
        BKE_report(CTX_wm_reports(C), RPT_OPERATOR, buf);
        MEM_freeN(buf);
        
index 3f668b2..86de549 100644 (file)
@@ -362,7 +362,7 @@ static wmOperator *wm_operator_create(wmWindowManager *wm, wmOperatorType *ot, P
 
 static void wm_operator_print(wmOperator *op)
 {
-       char *buf = WM_operator_pystring(op);
+       char *buf = WM_operator_pystring(op->type, op->ptr);
        printf("%s\n", buf);
        MEM_freeN(buf);
 }
index 2b7a18d..d0d5081 100644 (file)
@@ -340,8 +340,12 @@ void WM_operator_bl_idname(char *to, const char *from)
 }
 
 /* print a string representation of the operator, with the args that it runs 
- * so python can run it again */
-char *WM_operator_pystring(wmOperator *op)
+ * so python can run it again,
+ *
+ * When calling from an existing wmOperator do.
+ * WM_operator_pystring(op->type, op->ptr);
+ */
+char *WM_operator_pystring(wmOperatorType *ot, PointerRNA *opptr)
 {
        const char *arg_name= NULL;
        char idname_py[OP_MAX_TYPENAME];
@@ -353,18 +357,18 @@ char *WM_operator_pystring(wmOperator *op)
        char *cstring, *buf;
        int first_iter=1;
 
-       WM_operator_py_idname(idname_py, op->idname);
+       WM_operator_py_idname(idname_py, ot->idname);
        BLI_dynstr_appendf(dynstr, "bpy.ops.%s(", idname_py);
 
-       iterprop= RNA_struct_iterator_property(op->ptr->type);
+       iterprop= RNA_struct_iterator_property(opptr->type);
 
-       RNA_PROP_BEGIN(op->ptr, propptr, iterprop) {
+       RNA_PROP_BEGIN(opptr, propptr, iterprop) {
                prop= propptr.data;
                arg_name= RNA_property_identifier(prop);
 
                if (strcmp(arg_name, "rna_type")==0) continue;
 
-               buf= RNA_property_as_string(op->ptr, prop);
+               buf= RNA_property_as_string(opptr, prop);
                
                BLI_dynstr_appendf(dynstr, first_iter?"%s=%s":", %s=%s", arg_name, buf);