changeset 34663:73a5ecb53ee2

Replace symbolic constants by enums. There is no relation to gtk whatsoever, use self-explanatory names instead and add a doxygen comment. For optical reasons, change parameter data from NULL to 0 where it isn't used to pass anything.
author ib
date Tue, 21 Feb 2012 18:55:14 +0000
parents 06c84dbac243
children 4df4d842d5fb
files gui/cfg.c gui/interface.c gui/ui/actions.c gui/ui/gtk/playlist.c gui/ui/gtk/url.c gui/ui/main.c gui/util/list.c gui/util/list.h
diffstat 8 files changed, 48 insertions(+), 45 deletions(-) [+]
line wrap: on
line diff
--- a/gui/cfg.c	Mon Feb 20 17:41:47 2012 +0000
+++ b/gui/cfg.c	Tue Feb 21 18:55:14 2012 +0000
@@ -291,7 +291,7 @@
 
             if (fgetstr(line, sizeof(line), file) && *line) {
                 item->name = strdup(line);
-                listMgr(gtkAddPlItem, item);
+                listMgr(PLAYLIST_ITEM_ADD, item);
             } else {
                 free(item->path);
                 free(item);
@@ -323,7 +323,7 @@
             }
 
             item->url = strdup(line);
-            listMgr(gtkAddURLItem, item);
+            listMgr(URLLIST_ITEM_ADD, item);
         }
 
         fclose(file);
--- a/gui/interface.c	Mon Feb 20 17:41:47 2012 +0000
+++ b/gui/interface.c	Tue Feb 21 18:55:14 2012 +0000
@@ -268,8 +268,8 @@
     }
 
     appFreeStruct();
-    listMgr(gtkDelPl, NULL);
-    listMgr(gtkDelURL, NULL);
+    listMgr(PLAYLIST_DELETE, 0);
+    listMgr(URLLIST_DELETE, 0);
     free(guiIcon.collection);
 
     if (gui_conf) {
@@ -769,7 +769,7 @@
                 break;
         }
 
-        if (guiInfo.Playing && (next = listMgr(gtkGetNextPlItem, NULL)) && (plLastPlayed != next)) {
+        if (guiInfo.Playing && (next = listMgr(PLAYLIST_ITEM_GET_NEXT, 0)) && (plLastPlayed != next)) {
             plLastPlayed = next;
             uiSetFileName(next->path, next->name, STREAMTYPE_FILE);
             guiInfo.NewPlay = GUI_FILE_NEW;
@@ -850,9 +850,9 @@
     item->path = pathname;
 
     if (insert)
-        listMgr(gtkInsertPlItem, item);           // inserts the item after current, and makes current=item
+        listMgr(PLAYLIST_ITEM_INSERT, item);           // inserts the item after current, and makes current=item
     else
-        listMgr(gtkAddPlItem, item);
+        listMgr(PLAYLIST_ITEM_ADD, item);
 
     return 1;
 }
@@ -867,7 +867,7 @@
     int result = 0;
 
     if (!enqueue)
-        listMgr(gtkDelPl, NULL);             // delete playlist before "appending"
+        listMgr(PLAYLIST_DELETE, 0);             // delete playlist before "appending"
 
     if ((my_pt_iter = pt_iter_create(&my_playtree, config))) {
         while ((filename = pt_iter_get_next_file(my_pt_iter)) != NULL)
@@ -896,7 +896,7 @@
     int result = 0;
     plItem *save;
 
-    save = (plItem *)listMgr(gtkGetCurrPlItem, NULL);    // save current item
+    save = (plItem *)listMgr(PLAYLIST_ITEM_GET_CURR, 0);    // save current item
 
     if ((my_pt_iter = pt_iter_create(&my_playtree, config))) {
         while ((filename = pt_iter_get_next_file(my_pt_iter)) != NULL)
@@ -908,12 +908,12 @@
     }
 
     if (save)
-        listMgr(gtkSetCurrPlItem, save);
+        listMgr(PLAYLIST_ITEM_SET_CURR, save);
     else
-        listMgr(gtkSetCurrPlItem, plList);    // go to head, if plList was empty before
+        listMgr(PLAYLIST_ITEM_SET_CURR, plList);    // go to head, if plList was empty before
 
     if (save && result)
-        listMgr(gtkDelCurrPlItem, NULL);
+        listMgr(PLAYLIST_ITEM_DEL_CURR, 0);
 
     uiCurr();   // update filename
 
--- a/gui/ui/actions.c	Mon Feb 20 17:41:47 2012 +0000
+++ b/gui/ui/actions.c	Tue Feb 21 18:55:14 2012 +0000
@@ -254,7 +254,7 @@
 
     default:
 
-        curr = listMgr(gtkGetCurrPlItem, NULL);
+        curr = listMgr(PLAYLIST_ITEM_GET_CURR, 0);
 
         if (curr) {
             uiSetFileName(curr->path, curr->name, STREAMTYPE_FILE);
@@ -310,7 +310,7 @@
 
     default:
 
-        prev = listMgr(gtkGetPrevPlItem, NULL);
+        prev = listMgr(PLAYLIST_ITEM_GET_PREV, 0);
 
         if (prev) {
             uiSetFileName(prev->path, prev->name, STREAMTYPE_FILE);
@@ -371,7 +371,7 @@
 
     default:
 
-        next = listMgr(gtkGetNextPlItem, NULL);
+        next = listMgr(PLAYLIST_ITEM_GET_NEXT, 0);
 
         if (next) {
             uiSetFileName(next->path, next->name, STREAMTYPE_FILE);
--- a/gui/ui/gtk/playlist.c	Mon Feb 20 17:41:47 2012 +0000
+++ b/gui/ui/gtk/playlist.c	Tue Feb 21 18:55:14 2012 +0000
@@ -191,7 +191,7 @@
   case 1: // ok
        {
         int i;
-	if ( plList ) listMgr( gtkDelPl,NULL );
+	if ( plList ) listMgr( PLAYLIST_DELETE,0 );
 	for ( i=0;i<NrOfSelected;i++ )
 	 {
 	  plItem * item;
@@ -203,7 +203,7 @@
 	  if ( !item->name ) item->name = strdup( text[0] );
 	  item->path=g_filename_from_utf8( text[1], -1, NULL, NULL, NULL );
 	  if ( !item->path ) item->path = strdup( text[1] );
-	  listMgr( gtkAddPlItem,item );
+	  listMgr( PLAYLIST_ITEM_ADD,item );
 	 }
 	if ( plCurrent )
 	 {
--- a/gui/ui/gtk/url.c	Mon Feb 20 17:41:47 2012 +0000
+++ b/gui/ui/gtk/url.c	Tue Feb 21 18:55:14 2012 +0000
@@ -101,7 +101,7 @@
 
      item=calloc( 1,sizeof( urlItem ) );
      item->url=gstrdup( str );
-     listMgr( gtkAddURLItem,item );
+     listMgr( URLLIST_ITEM_ADD,item );
 
      uiSetFileName( NULL,str,STREAMTYPE_STREAM ); guiInfo.NewPlay=GUI_FILE_NEW;
      uiEventHandling( evPlay,0 );
--- a/gui/ui/main.c	Mon Feb 20 17:41:47 2012 +0000
+++ b/gui/ui/main.c	Tue Feb 21 18:55:14 2012 +0000
@@ -111,7 +111,7 @@
     nfree(guiInfo.Filename);
     nfree(guiInfo.SubtitleFilename);
     nfree(guiInfo.AudioFilename);
-    listMgr(gtkDelPl, NULL);
+    listMgr(PLAYLIST_DELETE, 0);
   }
 
   if (what & CLEAR_VCD) guiInfo.Tracks = 0;
@@ -208,9 +208,9 @@
 
         if ( ( msg == evPlaySwitchToPause )&&( guiInfo.Playing == GUI_PAUSE ) ) goto NoPause;
 
-	if ( listMgr( gtkGetCurrPlItem,NULL ) &&( guiInfo.StreamType == STREAMTYPE_FILE ) )
+	if ( listMgr( PLAYLIST_ITEM_GET_CURR,0 ) &&( guiInfo.StreamType == STREAMTYPE_FILE ) )
 	 {
-	  plItem * next = listMgr( gtkGetCurrPlItem,NULL );
+	  plItem * next = listMgr( PLAYLIST_ITEM_GET_CURR,0 );
 	  plLastPlayed=next;
 	  uiSetFileName( next->path,next->name,SAME_STREAMTYPE );
 	 }
@@ -271,7 +271,7 @@
         uiMainAutoPlay=1;
 //	guiInfo.StreamType=STREAMTYPE_FILE;
    case evLoad:
-	listMgr( gtkDelPl,NULL );
+	listMgr( PLAYLIST_DELETE,0 );
         gtkShow( evLoad,NULL );
         break;
    case evLoadSubtitle:  gtkShow( evLoadSubtitle,NULL );  break;
@@ -643,7 +643,7 @@
       /* clear playlist */
       if (filename == NULL) {
 	filename = files[f];
-	listMgr(gtkDelPl,NULL);
+	listMgr(PLAYLIST_DELETE,0);
       }
 
       item = calloc(1,sizeof(plItem));
@@ -658,7 +658,7 @@
 	item->name = strdup(str);
 	item->path = strdup("");
       }
-      listMgr(gtkAddPlItem,item);
+      listMgr(PLAYLIST_ITEM_ADD,item);
     } else {
       mp_msg( MSGT_GPLAYER,MSGL_WARN,MSGTR_NotAFile,str );
     }
--- a/gui/util/list.c	Mon Feb 20 17:41:47 2012 +0000
+++ b/gui/util/list.c	Tue Feb 21 18:55:14 2012 +0000
@@ -38,7 +38,7 @@
     // handle playlist
 
     // add item to playlist
-    case gtkAddPlItem:
+    case PLAYLIST_ITEM_ADD:
         if (plList) {
             plItem *next = plList;
 
@@ -58,7 +58,7 @@
         return NULL;
 
     // add item into playlist after current
-    case gtkInsertPlItem:
+    case PLAYLIST_ITEM_INSERT:
         if (plCurrent) {
             plItem *curr = plCurrent;
             item->next = curr->next;
@@ -72,10 +72,10 @@
 
             return plCurrent;
         } else
-            return listMgr(gtkAddPlItem, item);
+            return listMgr(PLAYLIST_ITEM_ADD, item);
 
     // get next item from playlist
-    case gtkGetNextPlItem:
+    case PLAYLIST_ITEM_GET_NEXT:
         if (plCurrent && plCurrent->next) {
             plCurrent = plCurrent->next;
 // if (!plCurrent && plList)
@@ -95,7 +95,7 @@
         return NULL;
 
     // get previous item from playlist
-    case gtkGetPrevPlItem:
+    case PLAYLIST_ITEM_GET_PREV:
         if (plCurrent && plCurrent->prev) {
             plCurrent = plCurrent->prev;
 // if ( !plCurrent && plList ) plCurrent=plList;
@@ -104,16 +104,16 @@
         return NULL;
 
     // set current item
-    case gtkSetCurrPlItem:
+    case PLAYLIST_ITEM_SET_CURR:
         plCurrent = item;
         return plCurrent;
 
     // get current item
-    case gtkGetCurrPlItem:
+    case PLAYLIST_ITEM_GET_CURR:
         return plCurrent;
 
     // delete current item
-    case gtkDelCurrPlItem:
+    case PLAYLIST_ITEM_DEL_CURR:
     {
         plItem *curr = plCurrent;
 
@@ -138,7 +138,7 @@
         return plCurrent;
 
     // delete list
-    case gtkDelPl:
+    case PLAYLIST_DELETE:
         while (plList) {
             plItem *next = plList->next;
 
@@ -152,7 +152,7 @@
         return NULL;
 
     // handle url
-    case gtkAddURLItem:
+    case URLLIST_ITEM_ADD:
         if (urlList) {
             urlItem *next_url = urlList;
             is_added = 0;
@@ -174,7 +174,7 @@
         }
         return NULL;
 
-    case gtkDelURL:
+    case URLLIST_DELETE:
         while (urlList) {
             urlItem *next = urlList->next;
 
--- a/gui/util/list.h	Mon Feb 20 17:41:47 2012 +0000
+++ b/gui/util/list.h	Tue Feb 21 18:55:14 2012 +0000
@@ -19,16 +19,19 @@
 #ifndef MPLAYER_GUI_LIST_H
 #define MPLAYER_GUI_LIST_H
 
-#define gtkAddPlItem     5
-#define gtkGetNextPlItem 6
-#define gtkGetPrevPlItem 7
-#define gtkGetCurrPlItem 8
-#define gtkDelPl         9
-#define gtkDelURL        10
-#define gtkDelCurrPlItem 23
-#define gtkInsertPlItem  24
-#define gtkSetCurrPlItem 25
-#define gtkAddURLItem    15
+/// listMgr() commands
+enum {
+    PLAYLIST_ITEM_ADD,
+    PLAYLIST_ITEM_INSERT,
+    PLAYLIST_ITEM_SET_CURR,
+    PLAYLIST_ITEM_GET_CURR,
+    PLAYLIST_ITEM_GET_PREV,
+    PLAYLIST_ITEM_GET_NEXT,
+    PLAYLIST_ITEM_DEL_CURR,
+    PLAYLIST_DELETE,
+    URLLIST_ITEM_ADD,
+    URLLIST_DELETE
+};
 
 typedef struct plItem {
     char *path;