changeset 34596:04feb00f91be

Prefer static const char arrays for string constants to #defines.
author ib
date Fri, 10 Feb 2012 15:40:53 +0000
parents 97bf974e7623
children e227a8ae4418
files gui/cfg.c gui/ui/widgets.c gui/win32/wincfg.c
diffstat 3 files changed, 19 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/gui/cfg.c	Fri Feb 10 15:24:27 2012 +0000
+++ b/gui/cfg.c	Fri Feb 10 15:40:53 2012 +0000
@@ -44,11 +44,6 @@
 #include "sub/font_load.h"
 #include "sub/sub.h"
 
-#define GUI_CONFIGURATION "gui.conf"
-#define GUI_HISTORY       "gui.history"
-#define GUI_PLAYLIST      "gui.pl"
-#define GUI_URLLIST       "gui.url"
-
 m_config_t *gui_conf;
 
 int gtkCacheOn;
@@ -103,6 +98,11 @@
 
 char *fsHistory[5];
 
+static const char gui_configuration[] = "gui.conf";
+static const char gui_history[]       = "gui.history";
+static const char gui_playlist[]      = "gui.pl";
+static const char gui_urllist[]       = "gui.url";
+
 static const m_option_t gui_opts[] = {
     { "cache",                       &gtkCacheOn,              CONF_TYPE_FLAG,        0,           0,     1,       NULL },
     { "cache_size",                  &gtkCacheSize,            CONF_TYPE_INT,         CONF_RANGE,  32,    1048576, NULL },
@@ -248,7 +248,7 @@
 
     // configuration
 
-    fname = get_path(GUI_CONFIGURATION);
+    fname = get_path(gui_configuration);
 
     mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[cfg] file: %s\n", fname);
 
@@ -270,7 +270,7 @@
 
     // playlist
 
-    fname = get_path(GUI_PLAYLIST);
+    fname = get_path(gui_playlist);
     file  = fopen(fname, "rt");
 
     if (file) {
@@ -305,7 +305,7 @@
 
     // URL list
 
-    fname = get_path(GUI_URLLIST);
+    fname = get_path(gui_urllist);
     file  = fopen(fname, "rt");
 
     if (file) {
@@ -333,7 +333,7 @@
 
     // directory history
 
-    fname = get_path(GUI_HISTORY);
+    fname = get_path(gui_history);
     file  = fopen(fname, "rt");
 
     if (file) {
@@ -357,7 +357,7 @@
 
     // configuration
 
-    fname = get_path(GUI_CONFIGURATION);
+    fname = get_path(gui_configuration);
     file  = fopen(fname, "wt+");
 
     if (file) {
@@ -387,7 +387,7 @@
 
     // playlist
 
-    fname = get_path(GUI_PLAYLIST);
+    fname = get_path(gui_playlist);
     file  = fopen(fname, "wt+");
 
     if (file) {
@@ -409,7 +409,7 @@
 
     // URL list
 
-    fname = get_path(GUI_URLLIST);
+    fname = get_path(gui_urllist);
     file  = fopen(fname, "wt+");
 
     if (file) {
@@ -429,7 +429,7 @@
 
     // directory history
 
-    fname = get_path(GUI_HISTORY);
+    fname = get_path(gui_history);
     file  = fopen(fname, "wt+");
 
     if (file) {
--- a/gui/ui/widgets.c	Fri Feb 10 15:24:27 2012 +0000
+++ b/gui/ui/widgets.c	Fri Feb 10 15:40:53 2012 +0000
@@ -64,7 +64,7 @@
 #include "gtk/url.h"
 #include "gtk/equalizer.h"
 
-#define GUI_ICON_NAME "mplayer"
+static const char gui_icon_name[] = "mplayer";
 
 #define THRESHOLD 128   // transparency values equal to or above this will become
                         // opaque, all values below this will become transparent
@@ -79,7 +79,7 @@
     guchar *data;
     int csize, i;
 
-    pixbuf = gtk_icon_theme_load_icon(theme, GUI_ICON_NAME, size, 0, NULL);
+    pixbuf = gtk_icon_theme_load_icon(theme, gui_icon_name, size, 0, NULL);
 
     if (pixbuf)
         gdk_pixbuf_render_pixmap_and_mask_for_colormap(pixbuf, gdk_colormap_get_system(), gdkIcon, gdkIconMask, THRESHOLD);
@@ -105,7 +105,7 @@
 
         g_object_unref(pixbuf);
     } else
-        mp_msg(MSGT_GPLAYER, MSGL_WARN, MSGTR_ICONERROR, GUI_ICON_NAME, size);
+        mp_msg(MSGT_GPLAYER, MSGL_WARN, MSGTR_ICONERROR, gui_icon_name, size);
 
     // start up GTK which realizes the pixmaps
     gtk_main_iteration_do(FALSE);
--- a/gui/win32/wincfg.c	Fri Feb 10 15:24:27 2012 +0000
+++ b/gui/win32/wincfg.c	Fri Feb 10 15:40:53 2012 +0000
@@ -38,7 +38,7 @@
 #include "gui/interface.h"
 #include "gui.h"
 
-#define GUI_CONFIGURATION "gui.conf"
+static const char gui_configuration[] =  "gui.conf";
 
 /* params */
 int   gtkAONorm = 0;
@@ -97,7 +97,7 @@
 
 void cfg_read(void)
 {
-    char *cfg = get_path(GUI_CONFIGURATION);
+    char *cfg = get_path(gui_configuration);
 
     player_idle_mode = 1;   // GUI is in idle mode by default
 
@@ -112,7 +112,7 @@
 
 void cfg_write(void)
 {
-    char *cfg = get_path(GUI_CONFIGURATION);
+    char *cfg = get_path(gui_configuration);
     FILE *f;
     int i;