changeset 36891:c5ee0fc2ec75

Print an information on deprecated skin config file entries. There are several skin config file entries which oughtn't be used any more, although they are still being supported. Inform the user about these without being too annoying.
author ib
date Mon, 10 Mar 2014 17:15:24 +0000
parents 8f38fea0b91b
children f50427ad9ff6
files Changelog gui/skin/skin.c gui/win32/skinload.c help/help_mp-de.h help/help_mp-en.h
diffstat 5 files changed, 106 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/Changelog	Sat Mar 08 19:17:43 2014 +0000
+++ b/Changelog	Mon Mar 10 17:15:24 2014 +0000
@@ -37,6 +37,8 @@
 
     GUI:
     * Support for TV/DVB
+    * Console message with information on deprecated (but still supported)
+      entries in the skin configuration file
 
   1.1: "We gave up on 1.0"
 
--- a/gui/skin/skin.c	Sat Mar 08 19:17:43 2014 +0000
+++ b/gui/skin/skin.c	Mon Mar 10 17:15:24 2014 +0000
@@ -57,6 +57,33 @@
 static guiItem *currWinItems;
 
 /**
+ * @brief Print a legacy information on an entry.
+ *
+ * @param old identifier (and deprecated entry)
+ * @param data pointer to additional data necessary for checking and
+ *             to print the information on @a old
+ */
+static void skin_legacy(const char *old, const char *data)
+{
+    const char *p;
+
+    if (strcmp(old, "fontid") == 0) {
+        p = strchr(data, ',');
+
+        if (p)
+            mp_msg(MSGT_GPLAYER, MSGL_INFO, MSGTR_GUI_MSG_SkinLegacy, linenumber, p, "font = fontfile");
+    } else if (strcmp(old, "$l") == 0) {
+        p = strstr(old, data);
+
+        if (p && (p == data || p[-1] != '$'))
+            mp_msg(MSGT_GPLAYER, MSGL_INFO, MSGTR_GUI_MSG_SkinLegacy, linenumber, old, "$p");
+    } else if (strcmp(old, "evSetURL") == 0 && strcmp(data, old) == 0)
+        mp_msg(MSGT_GPLAYER, MSGL_INFO, MSGTR_GUI_MSG_SkinLegacy, linenumber, old, "evLoadURL");
+    else if (strcmp(old, "sub") == 0)
+        mp_msg(MSGT_GPLAYER, MSGL_INFO, MSGTR_GUI_MSG_SkinLegacy, linenumber, old, data);
+}
+
+/**
  * @brief Display a skin error message.
  *
  * @param format format string
@@ -231,8 +258,11 @@
 
     strlower(in);
 
-    if (strcmp(in, "sub") == 0)
-        strcpy(in, "video");                           // legacy
+    // legacy
+    if (strcmp(in, "sub") == 0) {
+        strcpy(in, "video");
+        skin_legacy("sub", in);
+    }
 
     if (strcmp(in, "main") == 0) {
         currWin = &skin->main;
@@ -415,6 +445,9 @@
         skin_error(MSGTR_GUI_MSG_SkinUnknownMessage, msg);
         return 1;
     }
+    // legacy
+    else
+        skin_legacy("evSetURL", msg);
 
     mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin]    button image: %s %d,%d\n", fname, x, y);
     mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin]     message: %s (#%d)\n", msg, message);
@@ -531,6 +564,9 @@
         skin_error(MSGTR_GUI_MSG_SkinUnknownMessage, msg);
         return 1;
     }
+    // legacy
+    else
+        skin_legacy("evSetURL", msg);
 
     item = next_item();
 
@@ -595,6 +631,9 @@
         skin_error(MSGTR_GUI_MSG_SkinUnknownMessage, buf);
         return 1;
     }
+    // legacy
+    else
+        skin_legacy("evSetURL", buf);
 
     mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin]    h/v potmeter image: %s %d,%d %dx%d\n", phfname, x, y, w, h);
     mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin]     button image: %s %dx%d\n", pfname, pwidth, pheight);
@@ -708,6 +747,9 @@
         skin_error(MSGTR_GUI_MSG_SkinUnknownMessage, buf);
         return 1;
     }
+    // legacy
+    else
+        skin_legacy("evSetURL", buf);
 
     mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin]    potmeter image: %s %d,%d %dx%d\n", phfname, x, y, w, h);
     mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin]     numphases: %d, default: %d%%\n", ph, d);
@@ -765,6 +807,9 @@
 
     cutItem(in, fnt, ',', 0);   // Note: This seems needless but isn't for compatibility
                                 // reasons with a meanwhile deprecated second parameter.
+    // legacy
+    skin_legacy("fontid", in);
+
     switch (fntRead(path, fnt)) {
     case -1:
         skin_error(MSGTR_GUI_MSG_SkinMemoryError);
@@ -883,6 +928,9 @@
     cutItem(in, txt, ',', 5);
     cutItem(txt, txt, '"', 1);
 
+    // legacy
+    skin_legacy("$l", txt);
+
     mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin]    dlabel: \"%s\"\n", txt);
     mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin]     pos: %d,%d\n", x, y);
     mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin]     width: %d, align: %d\n", w, a);
--- a/gui/win32/skinload.c	Sat Mar 08 19:17:43 2014 +0000
+++ b/gui/win32/skinload.c	Mon Mar 10 17:15:24 2014 +0000
@@ -28,6 +28,7 @@
 #include <windows.h>
 
 #include "mp_msg.h"
+#include "help_mp.h"
 #include "cpudetect.h"
 #include "libswscale/swscale.h"
 #include "libavutil/imgutils.h"
@@ -95,6 +96,35 @@
 
 static int linenumber;
 
+/**
+ * @brief Print a legacy information on an entry.
+ *
+ * @param old identifier (and deprecated entry)
+ * @param data pointer to additional data necessary for checking and
+ *             to print the information on @a old
+ */
+static void skin_legacy (const char *old, const char *data)
+{
+    const char *p;
+
+    if (strcmp(old, "fontid") == 0)
+    {
+        p = strchr(data, ',');
+
+        if (p) mp_msg(MSGT_GPLAYER, MSGL_INFO, MSGTR_GUI_MSG_SkinLegacy, linenumber, p, "font = fontfile");
+    }
+    else if (strcmp(old, "$l") == 0)
+    {
+        p = strstr(old, data);
+
+        if (p && (p == data || p[-1] != '$')) mp_msg(MSGT_GPLAYER, MSGL_INFO, MSGTR_GUI_MSG_SkinLegacy, linenumber, old, "$p");
+    }
+    else if (strcmp(old, "evSetURL") == 0 && strcmp(data, old) == 0)
+        mp_msg(MSGT_GPLAYER, MSGL_INFO, MSGTR_GUI_MSG_SkinLegacy, linenumber, old, "evLoadURL");
+    else if (strcmp(old, "sub") == 0)
+        mp_msg(MSGT_GPLAYER, MSGL_INFO, MSGTR_GUI_MSG_SkinLegacy, linenumber, old, data);
+}
+
 static char *geteventname(int event)
 {
     int i;
@@ -322,6 +352,9 @@
         {
             if(!strcmp(temp, evNames[i].name))
             {
+                // legacy
+                skin_legacy("evSetURL", temp);
+
                 mywidget->msg = evNames[i].msg;
                 break;
             }
@@ -354,6 +387,9 @@
         {
             if(!strcmp(temp, evNames[i].name))
             {
+                // legacy
+                skin_legacy("evSetURL", temp);
+
                 mywidget->msg = evNames[i].msg;
                 break;
             }
@@ -386,6 +422,9 @@
         {
             if(!strcmp(temp, evNames[i].name))
             {
+                // legacy
+                skin_legacy("evSetURL", temp);
+
                 mywidget->msg=evNames[i].msg;
                 break;
             }
@@ -413,6 +452,9 @@
         {
             if(!strcmp(temp, evNames[i].name))
             {
+                // legacy
+                skin_legacy("evSetURL", temp);
+
                 mywidget->msg = evNames[i].msg;
                 break;
             }
@@ -466,6 +508,10 @@
             }
         }
         mywidget->label=strdup(findnextstring(temp, desc, &base));
+
+        // legacy
+        skin_legacy("$l", mywidget->label);
+
         mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[SKIN] [ITEM] [DLABEL] %i %i %i %i %s \"%s\"\n",
                mywidget->x, mywidget->y, mywidget->length, mywidget->align, mywidget->font->name, mywidget->label);
     }
@@ -623,6 +669,8 @@
             {
                 mywindow->type = wiVideo;
                 mywindow->decoration = TRUE;
+                // legacy
+                if (desc[7] == 's') skin_legacy("sub", "video");
             }
             else if(!strncmp(desc + 7, "menu", 4)) mywindow->type = wiMenu;
             else if(!strncmp(desc + 7, "playbar", 7)) mywindow->type = wiPlaybar;
@@ -668,6 +716,10 @@
             skin->fonts = realloc(skin->fonts, sizeof(font_t *) * skin->fontcount);
             skin->fonts[id]=calloc(1, sizeof(font_t));
             skin->fonts[id]->name = strdup(temp);
+
+            // legacy
+            skin_legacy("fontid", desc);
+
             mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[SKIN] [FONT] name \"%s\"\n", skin->fonts[id]->name);
         }
         else
--- a/help/help_mp-de.h	Sat Mar 08 19:17:43 2014 +0000
+++ b/help/help_mp-de.h	Mon Mar 10 17:15:24 2014 +0000
@@ -928,6 +928,7 @@
 #define MSGTR_GUI_MSG_SkinFontFileNotFound "Schrift-Beschreibungsdatei nicht gefunden.\n"
 #define MSGTR_GUI_MSG_SkinFontImageNotFound "Schrift-Bilddatei nicht gefunden.\n"
 #define MSGTR_GUI_MSG_SkinFontNotFound "Schrift '%s' nicht gefunden.\n"
+#define MSGTR_GUI_MSG_SkinLegacy "Skin-Konfigurationsdatei in Zeile %d: '%s' ist veraltet, stattdessen sollte '%s' verwendet werden.\n"
 #define MSGTR_GUI_MSG_SkinMemoryError "Nicht genug Speicher\n"
 #define MSGTR_GUI_MSG_SkinTooManyFonts "Zu viele Schriften definiert.\n"
 #define MSGTR_GUI_MSG_SkinTooManyItems "Zu viele Elemente definiert.\n"
--- a/help/help_mp-en.h	Sat Mar 08 19:17:43 2014 +0000
+++ b/help/help_mp-en.h	Mon Mar 10 17:15:24 2014 +0000
@@ -719,6 +719,7 @@
 #define MSGTR_GUI_MSG_SkinFontFileNotFound "Font description file not found.\n"
 #define MSGTR_GUI_MSG_SkinFontImageNotFound "Font image file not found.\n"
 #define MSGTR_GUI_MSG_SkinFontNotFound "Font '%s' not found.\n"
+#define MSGTR_GUI_MSG_SkinLegacy "Skin config file at line %d: '%s' is deprecated, use '%s' instead.\n"
 #define MSGTR_GUI_MSG_SkinMemoryError "Not enough memory\n"
 #define MSGTR_GUI_MSG_SkinTooManyFonts "Too many fonts defined.\n"
 #define MSGTR_GUI_MSG_SkinTooManyItems "Too many items defined.\n"