+// make_sure_frame_is_within_limits
+void
+make_sure_frame_is_within_limits( BRect& frame, float minWidth, float minHeight,
+ float maxWidth, float maxHeight )
+{
+ if ( frame.Width() < minWidth )
+ frame.right = frame.left + minWidth;
+ if ( frame.Height() < minHeight )
+ frame.bottom = frame.top + minHeight;
+ if ( frame.Width() > maxWidth )
+ frame.right = frame.left + maxWidth;
+ if ( frame.Height() > maxHeight )
+ frame.bottom = frame.top + maxHeight;
+}
+
+// get_volume_info
+bool
+get_volume_info( BVolume& volume, BString& volumeName, bool& isCDROM, BString& deviceName )
+{
+ bool success = false;
+ isCDROM = false;
+ deviceName = "";
+ volumeName = "";
+ char name[B_FILE_NAME_LENGTH];
+ if ( volume.GetName( name ) >= B_OK ) // disk is currently mounted
+ {
+ volumeName = name;
+ dev_t dev = volume.Device();
+ fs_info info;
+ if ( fs_stat_dev( dev, &info ) == B_OK )
+ {
+ success = true;
+ deviceName = info.device_name;
+ if ( volume.IsReadOnly() )
+ {
+ int i_dev = open( info.device_name, O_RDONLY );
+ if ( i_dev >= 0 )
+ {
+ device_geometry g;
+ if ( ioctl( i_dev, B_GET_GEOMETRY, &g, sizeof( g ) ) >= 0 )
+ isCDROM = ( g.device_type == B_CD );
+ close( i_dev );
+ }
+ }
+ }
+ }
+ return success;
+}
+
+// collect_folder_contents
+void
+collect_folder_contents( BDirectory& dir, BList& list, bool& deep, bool& asked, BEntry& entry )
+{
+ while ( dir.GetNextEntry( &entry, true ) == B_OK )
+ {
+ if ( !entry.IsDirectory() )
+ {
+ BPath path;
+ // since the directory will give us the entries in reverse order,
+ // we put them each at the same index, effectively reversing the
+ // items while adding them
+ if ( entry.GetPath( &path ) == B_OK )
+ {
+ BString* string = new BString( path.Path() );
+ if ( !list.AddItem( string, 0 ) )
+ delete string; // at least don't leak
+ }
+ }
+ else
+ {
+ if ( !asked )
+ {
+ // ask user if we should parse sub-folders as well
+ BAlert* alert = new BAlert( "sub-folders?",
+ _("Open files from all sub-folders as well?"),
+ _("Cancel"), _("Open"), NULL, B_WIDTH_AS_USUAL,
+ B_IDEA_ALERT );
+ int32 buttonIndex = alert->Go();
+ deep = buttonIndex == 1;
+ asked = true;
+ // never delete BAlerts!!
+ }
+ if ( deep )
+ {
+ BDirectory subDir( &entry );
+ if ( subDir.InitCheck() == B_OK )
+ collect_folder_contents( subDir, list,
+ deep, asked, entry );
+ }
+ }
+ }
+}
+
+static int PlaylistChanged( vlc_object_t *p_this, const char * psz_variable,
+ vlc_value_t old_val, vlc_value_t new_val,
+ void * param )
+{
+ InterfaceWindow * w = (InterfaceWindow *) param;
+ w->UpdatePlaylist();
+ return VLC_SUCCESS;
+}