comparison Gui/interface.c @ 9291:64b8c5a07c2c

- It adds an option enqueue/noenqueue, so users can choose if they want to have playlist overwritten by files on commandline or just enqueue them at the end ... - Playtree is finally cleared, as such gui has total control! - Autoplay if files are available on commandline and -enqueue is not set! - Fallback on Playlists finally does work with Gui and even with streaming Playlists! [ Before gui was broken as mplayer.c:playtree tried to have control] patch by Fabian Franz <FabianFranz@gmx.de>
author arpi
date Wed, 05 Feb 2003 23:02:35 +0000
parents c2f31ca14a92
children b78cd2e33d2c
comparison
equal deleted inserted replaced
9290:0e043196d176 9291:64b8c5a07c2c
668 dvd_chapter=guiIntfStruct.Chapter; 668 dvd_chapter=guiIntfStruct.Chapter;
669 dvd_angle=guiIntfStruct.Angle; 669 dvd_angle=guiIntfStruct.Angle;
670 break; 670 break;
671 #endif 671 #endif
672 } 672 }
673 if ( guiIntfStruct.StreamType != STREAMTYPE_PLAYLIST ) 673 //if ( guiIntfStruct.StreamType != STREAMTYPE_PLAYLIST ) // Does not make problems anymore!
674 { 674 {
675 if ( guiIntfStruct.Filename ) filename=gstrdup( guiIntfStruct.Filename ); 675 if ( guiIntfStruct.Filename ) filename=gstrdup( guiIntfStruct.Filename );
676 else if ( filename ) guiSetFilename( guiIntfStruct.Filename,filename ); 676 else if ( filename ) guiSetFilename( guiIntfStruct.Filename,filename );
677 } 677 }
678 // --- video opts 678 // --- video opts
832 while ( next->next ) { /*printf( "%s\n",next->name );*/ next=next->next; } 832 while ( next->next ) { /*printf( "%s\n",next->name );*/ next=next->next; }
833 next->next=item; item->prev=next; 833 next->next=item; item->prev=next;
834 } else { item->prev=item->next=NULL; plCurrent=plList=item; } 834 } else { item->prev=item->next=NULL; plCurrent=plList=item; }
835 list(); 835 list();
836 return NULL; 836 return NULL;
837 case gtkInsertPlItem: // add item into playlist after current
838 if ( plCurrent )
839 {
840 plItem * curr = plCurrent;
841 item->next=curr->next;
842 if (item->next)
843 item->next->prev=item;
844 item->prev=curr;
845 curr->next=item;
846 plCurrent=plCurrent->next;
847 return plCurrent;
848 }
849 else
850 return gtkSet(gtkAddPlItem,0,(void*)item);
851 return NULL;
837 case gtkGetNextPlItem: // get current item from playlist 852 case gtkGetNextPlItem: // get current item from playlist
838 if ( plCurrent ) 853 if ( plCurrent && plCurrent->next)
839 { 854 {
840 plCurrent=plCurrent->next; 855 plCurrent=plCurrent->next;
841 if ( !plCurrent && plList ) 856 /*if ( !plCurrent && plList )
842 { 857 {
843 plItem * next = plList; 858 plItem * next = plList;
844 while ( next->next ) { if ( !next->next ) break; next=next->next; } 859 while ( next->next ) { if ( !next->next ) break; next=next->next; }
845 plCurrent=next; 860 plCurrent=next;
846 } 861 }*/
847 return plCurrent; 862 return plCurrent;
848 } 863 }
849 return NULL; 864 return NULL;
850 case gtkGetPrevPlItem: 865 case gtkGetPrevPlItem:
851 if ( plCurrent ) 866 if ( plCurrent && plCurrent->prev)
852 { 867 {
853 plCurrent=plCurrent->prev; 868 plCurrent=plCurrent->prev;
854 if ( !plCurrent && plList ) plCurrent=plList; 869 //if ( !plCurrent && plList ) plCurrent=plList;
855 return plCurrent; 870 return plCurrent;
856 } 871 }
857 return NULL; 872 return NULL;
873 case gtkSetCurrPlItem: // set current item
874 plCurrent=item;
875 return plCurrent;
858 case gtkGetCurrPlItem: // get current item 876 case gtkGetCurrPlItem: // get current item
859 return plCurrent; 877 return plCurrent;
878 case gtkDelCurrPlItem: // delete current item
879 {
880 plItem * curr = plCurrent;
881
882 if (!curr)
883 return NULL;
884 if (curr->prev)
885 curr->prev->next=curr->next;
886 if (curr->next)
887 curr->next->prev=curr->prev;
888 if (curr==plList)
889 plList=curr->next;
890 plCurrent=curr->next;
891 // Free it
892 if ( curr->path ) free( curr->path );
893 if ( curr->name ) free( curr->name );
894 free( curr );
895 }
896 mplCurr(); // Instead of using mplNext && mplPrev
897
898 return plCurrent;
860 case gtkDelPl: // delete list 899 case gtkDelPl: // delete list
861 { 900 {
862 plItem * curr = plList; 901 plItem * curr = plList;
863 plItem * next; 902 plItem * next;
864 if ( !plList ) return NULL; 903 if ( !plList ) return NULL;
1000 } 1039 }
1001 return NULL; 1040 return NULL;
1002 } 1041 }
1003 return NULL; 1042 return NULL;
1004 } 1043 }
1044
1045 #define mp_basename(s) (strrchr(s,'/')==NULL?(char*)s:(strrchr(s,'/')+1))
1046
1047 #include "../playtree.h"
1048
1049 //This function adds/inserts one file into the gui playlist
1050
1051 int import_file_into_gui(char* temp, int insert)
1052 {
1053 char *filename, *pathname;
1054 plItem * item;
1055
1056 filename = strdup(mp_basename(temp));
1057 pathname = strdup(temp);
1058 if (strlen(pathname)-strlen(filename)>0)
1059 pathname[strlen(pathname)-strlen(filename)-1]='\0'; // We have some path so remove / at end
1060 else
1061 pathname[strlen(pathname)-strlen(filename)]='\0';
1062 mp_msg(MSGT_PLAYTREE,MSGL_V, "Adding filename %s && pathname %s\n",filename,pathname); //FIXME: Change to MSGL_DBG2 ?
1063 item=calloc( 1,sizeof( plItem ) );
1064 if (!item)
1065 return 0;
1066 item->name=filename;
1067 item->path=pathname;
1068 if (insert)
1069 gtkSet( gtkInsertPlItem,0,(void*)item ); // Inserts the item after current, and makes current=item
1070 else
1071 gtkSet( gtkAddPlItem,0,(void*)item );
1072 return 1;
1073 }
1074
1075 #ifdef NEW_CONFIG
1076 #include "../m_option.h"
1077 #include "../m_config.h"
1078 #else
1079 #include "../cfgparser.h"
1080 #endif
1081
1082 // This function imports the initial playtree (based on cmd-line files) into the gui playlist
1083 // by either:
1084 // - overwriting gui pl (enqueue=0)
1085 // - appending it to gui pl (enqueue=1)
1086
1087 int import_initial_playtree_into_gui(play_tree_t* my_playtree, m_config_t* config, int enqueue)
1088 {
1089 play_tree_iter_t* my_pt_iter=NULL;
1090 int result=0;
1091
1092 if (!enqueue) // Delete playlist before "appending"
1093 gtkSet(gtkDelPl,0,0);
1094
1095 if((my_pt_iter=pt_iter_create(&my_playtree,config)))
1096 {
1097 while ((filename=pt_iter_get_next_file(my_pt_iter))!=NULL)
1098 {
1099 if (import_file_into_gui(filename, 0)) // Add it to end of list
1100 result=1;
1101 }
1102 }
1103
1104 mplCurr(); // Update filename
1105
1106 if (!enqueue)
1107 filename=guiIntfStruct.Filename; // Backward compatibility; if file is specified on commandline,
1108 // gmplayer does directly start in Play-Mode.
1109 else
1110 filename=NULL;
1111
1112 return result;
1113 }
1114
1115 // This function imports and inserts an playtree, that is created "on the fly", for example by
1116 // parsing some MOV-Reference-File; or by loading an playlist with "File Open"
1117 //
1118 // The file which contained the playlist is thereby replaced with it's contents.
1119
1120 int import_playtree_playlist_into_gui(play_tree_t* my_playtree, m_config_t* config)
1121 {
1122 play_tree_iter_t* my_pt_iter=NULL;
1123 int result=0;
1124 plItem * save=(plItem*)gtkSet( gtkGetCurrPlItem, 0, 0); // Save current item
1125
1126 if((my_pt_iter=pt_iter_create(&my_playtree,config)))
1127 {
1128 while ((filename=pt_iter_get_next_file(my_pt_iter))!=NULL)
1129 {
1130 if (import_file_into_gui(filename, 1)) // insert it into the list and set plCurrent=new item
1131 result=1;
1132 }
1133 pt_iter_destroy(&my_pt_iter);
1134 }
1135
1136 if (save)
1137 gtkSet(gtkSetCurrPlItem, 0, (void*)save);
1138 else
1139 gtkSet(gtkSetCurrPlItem, 0, (void*)plList); // go to head, if plList was empty before
1140
1141 if (save && result)
1142 gtkSet(gtkDelCurrPlItem, 0, 0);
1143
1144 mplCurr(); // Update filename
1145 filename=NULL;
1146
1147 return result;
1148 }