[MPlayer-cvslog] r34751 - in trunk/gui: cfg.c interface.c ui/actions.c ui/gtk/playlist.c ui/gtk/url.c ui/main.c util/list.c util/list.h

ib subversion at mplayerhq.hu
Tue Feb 21 19:55:14 CET 2012


Author: ib
Date: Tue Feb 21 19:55:14 2012
New Revision: 34751

Log:
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.

Modified:
   trunk/gui/cfg.c
   trunk/gui/interface.c
   trunk/gui/ui/actions.c
   trunk/gui/ui/gtk/playlist.c
   trunk/gui/ui/gtk/url.c
   trunk/gui/ui/main.c
   trunk/gui/util/list.c
   trunk/gui/util/list.h

Modified: trunk/gui/cfg.c
==============================================================================
--- trunk/gui/cfg.c	Mon Feb 20 18:41:47 2012	(r34750)
+++ trunk/gui/cfg.c	Tue Feb 21 19:55:14 2012	(r34751)
@@ -291,7 +291,7 @@ void cfg_read(void)
 
             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 @@ void cfg_read(void)
             }
 
             item->url = strdup(line);
-            listMgr(gtkAddURLItem, item);
+            listMgr(URLLIST_ITEM_ADD, item);
         }
 
         fclose(file);

Modified: trunk/gui/interface.c
==============================================================================
--- trunk/gui/interface.c	Mon Feb 20 18:41:47 2012	(r34750)
+++ trunk/gui/interface.c	Tue Feb 21 19:55:14 2012	(r34751)
@@ -268,8 +268,8 @@ void guiDone(void)
     }
 
     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 @@ int gui(int what, void *data)
                 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 @@ static int import_file_into_gui(char *te
     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 guiPlaylistInitialize(play_tree_t *m
     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 guiPlaylistAdd(play_tree_t *my_playt
     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 @@ int guiPlaylistAdd(play_tree_t *my_playt
     }
 
     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
 

Modified: trunk/gui/ui/actions.c
==============================================================================
--- trunk/gui/ui/actions.c	Mon Feb 20 18:41:47 2012	(r34750)
+++ trunk/gui/ui/actions.c	Tue Feb 21 19:55:14 2012	(r34751)
@@ -254,7 +254,7 @@ void uiCurr(void)
 
     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 @@ void uiPrev(void)
 
     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 @@ void uiNext(void)
 
     default:
 
-        next = listMgr(gtkGetNextPlItem, NULL);
+        next = listMgr(PLAYLIST_ITEM_GET_NEXT, 0);
 
         if (next) {
             uiSetFileName(next->path, next->name, STREAMTYPE_FILE);

Modified: trunk/gui/ui/gtk/playlist.c
==============================================================================
--- trunk/gui/ui/gtk/playlist.c	Mon Feb 20 18:41:47 2012	(r34750)
+++ trunk/gui/ui/gtk/playlist.c	Tue Feb 21 19:55:14 2012	(r34751)
@@ -191,7 +191,7 @@ static void plButtonReleased( GtkButton 
   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 @@ static void plButtonReleased( GtkButton 
 	  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 )
 	 {

Modified: trunk/gui/ui/gtk/url.c
==============================================================================
--- trunk/gui/ui/gtk/url.c	Mon Feb 20 18:41:47 2012	(r34750)
+++ trunk/gui/ui/gtk/url.c	Tue Feb 21 19:55:14 2012	(r34751)
@@ -101,7 +101,7 @@ static void on_Button_pressed( GtkButton
 
      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 );

Modified: trunk/gui/ui/main.c
==============================================================================
--- trunk/gui/ui/main.c	Mon Feb 20 18:41:47 2012	(r34750)
+++ trunk/gui/ui/main.c	Tue Feb 21 19:55:14 2012	(r34751)
@@ -111,7 +111,7 @@ static void guiInfoMediumClear (int what
     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 @@ play:
 
         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 @@ NoPause:
         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 @@ void uiDandDHandler(int num,char** files
       /* clear playlist */
       if (filename == NULL) {
 	filename = files[f];
-	listMgr(gtkDelPl,NULL);
+	listMgr(PLAYLIST_DELETE,0);
       }
 
       item = calloc(1,sizeof(plItem));
@@ -658,7 +658,7 @@ void uiDandDHandler(int num,char** files
 	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 );
     }

Modified: trunk/gui/util/list.c
==============================================================================
--- trunk/gui/util/list.c	Mon Feb 20 18:41:47 2012	(r34750)
+++ trunk/gui/util/list.c	Tue Feb 21 19:55:14 2012	(r34751)
@@ -38,7 +38,7 @@ void *listMgr(int cmd, void *data)
     // handle playlist
 
     // add item to playlist
-    case gtkAddPlItem:
+    case PLAYLIST_ITEM_ADD:
         if (plList) {
             plItem *next = plList;
 
@@ -58,7 +58,7 @@ void *listMgr(int cmd, void *data)
         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 @@ void *listMgr(int cmd, void *data)
 
             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 @@ void *listMgr(int cmd, void *data)
         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 @@ void *listMgr(int cmd, void *data)
         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 @@ void *listMgr(int cmd, void *data)
         return plCurrent;
 
     // delete list
-    case gtkDelPl:
+    case PLAYLIST_DELETE:
         while (plList) {
             plItem *next = plList->next;
 
@@ -152,7 +152,7 @@ void *listMgr(int cmd, void *data)
         return NULL;
 
     // handle url
-    case gtkAddURLItem:
+    case URLLIST_ITEM_ADD:
         if (urlList) {
             urlItem *next_url = urlList;
             is_added = 0;
@@ -174,7 +174,7 @@ void *listMgr(int cmd, void *data)
         }
         return NULL;
 
-    case gtkDelURL:
+    case URLLIST_DELETE:
         while (urlList) {
             urlItem *next = urlList->next;
 

Modified: trunk/gui/util/list.h
==============================================================================
--- trunk/gui/util/list.h	Mon Feb 20 18:41:47 2012	(r34750)
+++ trunk/gui/util/list.h	Tue Feb 21 19:55:14 2012	(r34751)
@@ -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;


More information about the MPlayer-cvslog mailing list