User Interface: Ctrl+C over a menu copies the py command
authorCampbell Barton <ideasman42@gmail.com>
Thu, 5 Dec 2013 06:26:03 +0000 (17:26 +1100)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 5 Dec 2013 06:26:03 +0000 (17:26 +1100)
also use bools rather then ints

source/blender/editors/interface/interface.c
source/blender/editors/interface/interface_handlers.c
source/blender/editors/interface/interface_panel.c
source/blender/editors/screen/screen_edit.c
source/blender/windowmanager/WM_api.h
source/blender/windowmanager/intern/wm_event_system.c
source/blender/windowmanager/intern/wm_files.c
source/blender/windowmanager/intern/wm_init_exit.c
source/blender/windowmanager/intern/wm_jobs.c
source/blender/windowmanager/intern/wm_window.c

index 46ee1700a065236106bbc851a90c410b6e79e6e6..79db94e5da8cca5b52159b0d3077bd4d2055d1df 100644 (file)
@@ -3972,7 +3972,7 @@ void uiButGetStrInfo(bContext *C, uiBut *but, ...)
                                const char *tc1, *tc2;
 
                                tc1 = strstr(but->str, "%t");
-                               tc2 = strstr(but->str, "|"); /* XXX For some reason strchr seems to not work here? */
+                               tc2 = strstr(but->str, UI_SEP_CHAR_S);
 
                                if (tc2 && (!tc1 || tc1 > tc2))
                                        tc1 = tc2;
index e51401528479c505e5053246fb7aec617431ff6e..5e17831fc426361105fdafeadd456a64e6f65004 100644 (file)
@@ -60,6 +60,7 @@
 #include "BKE_context.h"
 #include "BKE_idprop.h"
 #include "BKE_report.h"
+#include "BKE_screen.h"
 #include "BKE_texture.h"
 #include "BKE_tracking.h"
 #include "BKE_unit.h"
@@ -1556,6 +1557,15 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data,
                        MEM_freeN(str);
                }
        }
+       /* menu (any type) */
+       else if (ELEM(but->type, MENU, PULLDOWN)) {
+               MenuType *mt = uiButGetMenuType(but);
+               if (mt) {
+                       char str[32 + sizeof(mt->idname)];
+                       BLI_snprintf(str, sizeof(str), "bpy.ops.wm.call_menu(name=\"%s\")", mt->idname);
+                       WM_clipboard_text_set(str, 0);
+               }
+       }
 }
 
 /* ************************ password text ******************************
index 30ee9d294076a7c2ca6b4bb14459547dd3ee5292..3bb88d08f1fa52ee9199189e830df45ceab8bce7 100644 (file)
@@ -1128,7 +1128,7 @@ int ui_handler_panel_region(bContext *C, const wmEvent *event, ARegion *ar)
 
        retval = WM_UI_HANDLER_CONTINUE;
        for (block = ar->uiblocks.last; block; block = block->prev) {
-               int inside = 0, inside_header = 0, inside_scale = 0;
+               bool inside = false, inside_header = false, inside_scale = false;
                
                mx = event->x;
                my = event->y;
@@ -1145,24 +1145,24 @@ int ui_handler_panel_region(bContext *C, const wmEvent *event, ARegion *ar)
                /* clicked at panel header? */
                if (pa->flag & PNL_CLOSEDX) {
                        if (block->rect.xmin <= mx && block->rect.xmin + PNL_HEADER >= mx)
-                               inside_header = 1;
+                               inside_header = true;
                }
                else if (block->rect.xmin > mx || block->rect.xmax < mx) {
                        /* outside left/right side */
                }
                else if ((block->rect.ymax <= my) && (block->rect.ymax + PNL_HEADER >= my)) {
-                       inside_header = 1;
+                       inside_header = true;
                }
                else if (!(pa->flag & PNL_CLOSEDY)) {
                        /* open panel */
                        if (pa->control & UI_PNL_SCALE) {
                                if (block->rect.xmax - PNL_HEADER <= mx)
                                        if (block->rect.ymin + PNL_HEADER >= my)
-                                               inside_scale = 1;
+                                               inside_scale = true;
                        }
                        if (block->rect.xmin <= mx && block->rect.xmax >= mx)
                                if (block->rect.ymin <= my && block->rect.ymax + PNL_HEADER >= my)
-                                       inside = 1;
+                                       inside = true;
                }
                
                /* XXX hardcoded key warning */
index 474b9bc56fb6ccd7272da453acbb7d33ed091852..5c0bcabe62b589905ec5f8c4163caba5b0e28f7d 100644 (file)
@@ -1144,7 +1144,7 @@ void ED_screen_refresh(wmWindowManager *wm, wmWindow *win)
        
                /* wake up animtimer */
                if (win->screen->animtimer)
-                       WM_event_timer_sleep(wm, win, win->screen->animtimer, 0);
+                       WM_event_timer_sleep(wm, win, win->screen->animtimer, false);
        }
 
        if (G.debug & G_DEBUG_EVENTS) {
@@ -1423,7 +1423,7 @@ void ED_screen_set(bContext *C, bScreen *sc)
                /* we put timer to sleep, so screen_exit has to think there's no timer */
                oldscreen->animtimer = NULL;
                if (wt)
-                       WM_event_timer_sleep(wm, win, wt, 1);
+                       WM_event_timer_sleep(wm, win, wt, true);
                
                ED_screen_exit(C, win, oldscreen);
                oldscreen->animtimer = wt;
index 2402b8d61b908bf3f8a0007bd18d542c7e03862c..26294dd58765b058a1c3eec9184ef85413a1a254 100644 (file)
@@ -75,7 +75,7 @@ void          WM_init_state_normal_set(void);
 void           WM_init_native_pixels(bool do_it);
 
 void           WM_init                         (struct bContext *C, int argc, const char **argv);
-void           WM_exit_ext                     (struct bContext *C, const short do_python);
+void           WM_exit_ext                     (struct bContext *C, const bool do_python);
 
 void           WM_exit                         (struct bContext *C) ATTR_NORETURN;
 
@@ -164,7 +164,7 @@ struct wmEventHandler *WM_event_add_dropbox_handler(ListBase *handlers, ListBase
 
                        /* mouse */
 void           WM_event_add_mousemove(struct bContext *C);
-int                    WM_modal_tweak_exit(const struct wmEvent *event, int tweak_event);
+bool        WM_modal_tweak_exit(const struct wmEvent *event, int tweak_event);
 
                        /* notifiers */
 void           WM_event_add_notifier(const struct bContext *C, unsigned int type, void *reference);
@@ -182,7 +182,7 @@ void                wm_event_init_from_window(struct wmWindow *win, struct wmEvent *event);
                        /* at maximum, every timestep seconds it triggers event_type events */
 struct wmTimer *WM_event_add_timer(struct wmWindowManager *wm, struct wmWindow *win, int event_type, double timestep);
 void           WM_event_remove_timer(struct wmWindowManager *wm, struct wmWindow *win, struct wmTimer *timer);
-void           WM_event_timer_sleep(struct wmWindowManager *wm, struct wmWindow *win, struct wmTimer *timer, int dosleep);
+void        WM_event_timer_sleep(struct wmWindowManager *wm, struct wmWindow *win, struct wmTimer *timer, bool do_sleep);
 
                /* operator api, default callbacks */
                        /* invoke callback, uses enum property named "type" */
@@ -379,13 +379,13 @@ enum {
 
 struct wmJob *WM_jobs_get(struct wmWindowManager *wm, struct wmWindow *win, void *owner, const char *name, int flag, int job_type);
 
-int                    WM_jobs_test(struct wmWindowManager *wm, void *owner, int job_type);
+bool        WM_jobs_test(struct wmWindowManager *wm, void *owner, int job_type);
 float          WM_jobs_progress(struct wmWindowManager *wm, void *owner);
 char       *WM_jobs_name(struct wmWindowManager *wm, void *owner);
 void       *WM_jobs_customdata(struct wmWindowManager *wm, void *owner);
 void       *WM_jobs_customdata_from_type(struct wmWindowManager *wm, int job_type);
 
-int         WM_jobs_is_running(struct wmJob *);
+bool        WM_jobs_is_running(struct wmJob *);
 void       *WM_jobs_customdata_get(struct wmJob *);
 void        WM_jobs_customdata_set(struct wmJob *, void *customdata, void (*free)(void *));
 void        WM_jobs_timer(struct wmJob *, double timestep, unsigned int note, unsigned int endnote);
@@ -402,14 +402,14 @@ void              WM_jobs_kill_all(struct wmWindowManager *wm);
 void           WM_jobs_kill_all_except(struct wmWindowManager *wm, void *owner);
 void           WM_jobs_kill_type(struct wmWindowManager *wm, void *owner, int job_type);
 
-int                    WM_jobs_has_running(struct wmWindowManager *wm);
+bool        WM_jobs_has_running(struct wmWindowManager *wm);
 
 void           WM_job_main_thread_lock_acquire(struct wmJob *job);
 void           WM_job_main_thread_lock_release(struct wmJob *job);
 
                        /* clipboard */
-char       *WM_clipboard_text_get(int selection);
-void        WM_clipboard_text_set(char *buf, int selection);
+char       *WM_clipboard_text_get(bool selection);
+void        WM_clipboard_text_set(const char *buf, bool selection);
 
                        /* progress */
 void           WM_progress_set(struct wmWindow *win, float progress);
@@ -421,7 +421,7 @@ void                WM_redraw_windows(struct bContext *C);
 void        WM_main_playanim(int argc, const char **argv);
 
 /* debugging only, convenience function to write on crash */
-int write_crash_blend(void);
+bool write_crash_blend(void);
 
 #ifdef __cplusplus
 }
index ef1f6c7a34a686afe2ed1611c305c1e6bcb8a994..8ac8da935844c66c9e8b9b33a38efb6c7a08c6d2 100644 (file)
@@ -2584,7 +2584,7 @@ void WM_event_add_mousemove(bContext *C)
 
 
 /* for modal callbacks, check configuration for how to interpret exit with tweaks  */
-int WM_modal_tweak_exit(const wmEvent *event, int tweak_event)
+bool WM_modal_tweak_exit(const wmEvent *event, int tweak_event)
 {
        /* if the release-confirm userpref setting is enabled, 
         * tweak events can be canceled when mouse is released
index dfdbe3089650e8b77e94e086de2feb96bd3a57ed..31af780405847e4543f17059cde2d2a0ddcbd17a 100644 (file)
@@ -832,7 +832,7 @@ static ImBuf *blend_file_thumb(Scene *scene, bScreen *screen, int **thumb_pt)
 }
 
 /* easy access from gdb */
-int write_crash_blend(void)
+bool write_crash_blend(void)
 {
        char path[FILE_MAX];
        int fileflags = G.fileflags & ~(G_FILE_HISTORY); /* don't do file history on crash file */
index 63aa3ce681152a6fcc3e7c190aa45022b76105db..8b43a6af606ef9c80c0199d63a2f01da47d3efc1 100644 (file)
@@ -382,7 +382,7 @@ static void wait_for_console_key(void)
 
 /* called in creator.c even... tsk, split this! */
 /* note, doesnt run exit() call WM_exit() for that */
-void WM_exit_ext(bContext *C, const short do_python)
+void WM_exit_ext(bContext *C, const bool do_python)
 {
        wmWindowManager *wm = C ? CTX_wm_manager(C) : NULL;
 
index b3856a2aa9c0a1d1114d2ab2ce1b6df9278b290d..7da9a1c09d3aea36609158976813750e66786d37 100644 (file)
@@ -222,7 +222,7 @@ wmJob *WM_jobs_get(wmWindowManager *wm, wmWindow *win, void *owner, const char *
 }
 
 /* returns true if job runs, for UI (progress) indicators */
-int WM_jobs_test(wmWindowManager *wm, void *owner, int job_type)
+bool WM_jobs_test(wmWindowManager *wm, void *owner, int job_type)
 {
        wmJob *wm_job;
        
@@ -280,7 +280,7 @@ void *WM_jobs_customdata_from_type(wmWindowManager *wm, int job_type)
        return NULL;
 }
 
-int WM_jobs_is_running(wmJob *wm_job)
+bool WM_jobs_is_running(wmJob *wm_job)
 {
        return wm_job->running;
 }
@@ -649,7 +649,7 @@ void wm_jobs_timer(const bContext *C, wmWindowManager *wm, wmTimer *wt)
        }
 }
 
-int WM_jobs_has_running(wmWindowManager *wm)
+bool WM_jobs_has_running(wmWindowManager *wm)
 {
        wmJob *wm_job;
 
index 5f3443406439dfe4c5f40e530313e70c7d8649c4..d3936ff32e299b9abc2657e3f450b4f7b73aa28a 100644 (file)
@@ -1137,7 +1137,7 @@ void wm_ghost_exit(void)
 /* **************** timer ********************** */
 
 /* to (de)activate running timers temporary */
-void WM_event_timer_sleep(wmWindowManager *wm, wmWindow *UNUSED(win), wmTimer *timer, int dosleep)
+void WM_event_timer_sleep(wmWindowManager *wm, wmWindow *UNUSED(win), wmTimer *timer, bool do_sleep)
 {
        wmTimer *wt;
        
@@ -1146,7 +1146,7 @@ void WM_event_timer_sleep(wmWindowManager *wm, wmWindow *UNUSED(win), wmTimer *t
                        break;
 
        if (wt)
-               wt->sleep = dosleep;
+               wt->sleep = do_sleep;
 }
 
 wmTimer *WM_event_add_timer(wmWindowManager *wm, wmWindow *win, int event_type, double timestep)
@@ -1199,7 +1199,7 @@ void WM_event_remove_timer(wmWindowManager *wm, wmWindow *UNUSED(win), wmTimer *
 
 /* ******************* clipboard **************** */
 
-char *WM_clipboard_text_get(int selection)
+char *WM_clipboard_text_get(bool selection)
 {
        char *p, *p2, *buf, *newbuf;
 
@@ -1224,7 +1224,7 @@ char *WM_clipboard_text_get(int selection)
        return newbuf;
 }
 
-void WM_clipboard_text_set(char *buf, int selection)
+void WM_clipboard_text_set(const char *buf, bool selection)
 {
        if (!G.background) {
 #ifdef _WIN32