Mercurial > mplayer.hg
changeset 33023:ba432e34dc7e
Add message showing function.
In some cases it is necessary to show messages to the GUI users as well
or they will wonder why the GUI didn't show up.
author | ib |
---|---|
date | Fri, 25 Mar 2011 10:33:48 +0000 |
parents | 9abc0dbd6314 |
children | 21e0de9c355f |
files | gui/interface.c gui/interface.h gui/skin/skin.c |
diffstat | 3 files changed, 25 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/gui/interface.c Fri Mar 25 09:26:00 2011 +0000 +++ b/gui/interface.c Fri Mar 25 10:33:48 2011 +0000 @@ -1491,3 +1491,25 @@ return result; } + +// NOTE TO MYSELF: This function is nonsense. +// MPlayer should pass messages to the GUI +// which must decide then which message has +// to be shown (MSGL_FATAL, for example). +// But with this function it is at least +// possible to show GUI's very critical or +// abort messages. +void gmp_msg(int mod, int lev, const char *format, ...) +{ + char msg[512]; + va_list va; + + va_start(va, format); + vsnprintf(msg, sizeof(msg), format, va); + va_end(va); + + mp_msg(mod, lev, msg); + + if (mp_msg_test(mod, lev)) + gtkMessageBox(GTK_MB_FATAL, msg); +}
--- a/gui/interface.h Fri Mar 25 09:26:00 2011 +0000 +++ b/gui/interface.h Fri Mar 25 10:33:48 2011 +0000 @@ -232,6 +232,7 @@ void gaddlist(char ***list, const char *entry); void gfree(void **p); +void gmp_msg(int mod, int lev, const char *format, ...); char *gstrchr(char *str, int c); int gstrcmp(const char *a, const char *b); char *gstrdup(const char *str);
--- a/gui/skin/skin.c Fri Mar 25 09:26:00 2011 +0000 +++ b/gui/skin/skin.c Fri Mar 25 10:33:48 2011 +0000 @@ -23,6 +23,7 @@ #include "cut.h" #include "font.h" #include "gui/app.h" +#include "gui/interface.h" #include "gui/mplayer/widgets.h" #include "config.h" @@ -49,19 +50,13 @@ static void skin_error(const char *format, ...) { char p[512]; - char tmp[512]; va_list ap; va_start(ap, format); vsnprintf(p, sizeof(p), format, ap); va_end(ap); - mp_msg(MSGT_GPLAYER, MSGL_ERR, MSGTR_SKIN_ERRORMESSAGE, linenumber, p); - - if (mp_msg_test(MSGT_GPLAYER, MSGL_ERR)) { - snprintf(tmp, sizeof(tmp), MSGTR_SKIN_ERRORMESSAGE, linenumber, p); - gtkMessageBox(GTK_MB_FATAL, tmp); - } + gmp_msg(MSGT_GPLAYER, MSGL_ERR, MSGTR_SKIN_ERRORMESSAGE, linenumber, p); } #define CHECKDEFLIST(str) \